Benjamin Hahn | 2b143e2 | 2024-07-16 22:11:26 -0700 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
| 2 | /* |
| 3 | * Copyright (C) 2024 PHYTEC Messtechnik GmbH |
| 4 | * Author: Benjamin Hahn <b.hahn@phytec.de> |
| 5 | */ |
| 6 | |
| 7 | /* Logic to load and apply overlays. Load overlays from bootenv.txt into |
| 8 | * environment and apply those overlays. |
Benjamin Hahn | 32fb45b | 2024-07-16 22:11:30 -0700 | [diff] [blame] | 9 | * The variables bootenv_addr_r and fdtoverlay_addr_r are board specific. |
| 10 | * get_cmd can be either tftp or dhcp. */ |
Benjamin Hahn | 2b143e2 | 2024-07-16 22:11:26 -0700 | [diff] [blame] | 11 | |
| 12 | bootenv=bootenv.txt |
Benjamin Hahn | 32fb45b | 2024-07-16 22:11:30 -0700 | [diff] [blame] | 13 | mmc_load_bootenv=load mmc ${mmcdev}:${mmcpart} ${bootenv_addr_r} ${bootenv} |
| 14 | mmc_load_overlay=load mmc ${mmcdev}:${mmcpart} ${fdtoverlay_addr_r} ${overlay} |
Benjamin Hahn | 2b143e2 | 2024-07-16 22:11:26 -0700 | [diff] [blame] | 15 | mmc_apply_overlays= |
Benjamin Hahn | 32fb45b | 2024-07-16 22:11:30 -0700 | [diff] [blame] | 16 | fdt address ${fdt_addr_r}; |
Benjamin Hahn | 2b143e2 | 2024-07-16 22:11:26 -0700 | [diff] [blame] | 17 | if test ${no_overlays} = 0; then |
| 18 | for overlay in ${overlays}; |
| 19 | do; |
| 20 | if run mmc_load_overlay; then |
| 21 | fdt resize ${filesize}; |
Benjamin Hahn | 32fb45b | 2024-07-16 22:11:30 -0700 | [diff] [blame] | 22 | fdt apply ${fdtoverlay_addr_r}; |
Benjamin Hahn | 2b143e2 | 2024-07-16 22:11:26 -0700 | [diff] [blame] | 23 | fi; |
| 24 | done; |
| 25 | fi; |
Benjamin Hahn | 32fb45b | 2024-07-16 22:11:30 -0700 | [diff] [blame] | 26 | net_load_bootenv=${get_cmd} ${bootenv_addr_r} ${bootenv} |
| 27 | net_load_overlay=${get_cmd} ${fdtoverlay_addr_r} ${overlay} |
Benjamin Hahn | 2b143e2 | 2024-07-16 22:11:26 -0700 | [diff] [blame] | 28 | net_apply_overlays= |
Benjamin Hahn | 32fb45b | 2024-07-16 22:11:30 -0700 | [diff] [blame] | 29 | fdt address ${fdt_addr_r}; |
Benjamin Hahn | 2b143e2 | 2024-07-16 22:11:26 -0700 | [diff] [blame] | 30 | if test ${no_overlays} = 0; then |
| 31 | for overlay in ${overlays}; |
| 32 | do; |
| 33 | if run net_load_overlay; then |
| 34 | fdt resize ${filesize}; |
Benjamin Hahn | 32fb45b | 2024-07-16 22:11:30 -0700 | [diff] [blame] | 35 | fdt apply ${fdtoverlay_addr_r}; |
Benjamin Hahn | 2b143e2 | 2024-07-16 22:11:26 -0700 | [diff] [blame] | 36 | fi; |
| 37 | done; |
| 38 | fi; |