blob: 78721cde654a5b1e41450710c9ac79211e180db1 [file] [log] [blame]
Benjamin Hahn2b143e22024-07-16 22:11:26 -07001/* 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 Hahn32fb45b2024-07-16 22:11:30 -07009 * The variables bootenv_addr_r and fdtoverlay_addr_r are board specific.
10 * get_cmd can be either tftp or dhcp. */
Benjamin Hahn2b143e22024-07-16 22:11:26 -070011
12bootenv=bootenv.txt
Benjamin Hahn32fb45b2024-07-16 22:11:30 -070013mmc_load_bootenv=load mmc ${mmcdev}:${mmcpart} ${bootenv_addr_r} ${bootenv}
14mmc_load_overlay=load mmc ${mmcdev}:${mmcpart} ${fdtoverlay_addr_r} ${overlay}
Benjamin Hahn2b143e22024-07-16 22:11:26 -070015mmc_apply_overlays=
Benjamin Hahn32fb45b2024-07-16 22:11:30 -070016 fdt address ${fdt_addr_r};
Benjamin Hahn2b143e22024-07-16 22:11:26 -070017 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 Hahn32fb45b2024-07-16 22:11:30 -070022 fdt apply ${fdtoverlay_addr_r};
Benjamin Hahn2b143e22024-07-16 22:11:26 -070023 fi;
24 done;
25 fi;
Benjamin Hahn32fb45b2024-07-16 22:11:30 -070026net_load_bootenv=${get_cmd} ${bootenv_addr_r} ${bootenv}
27net_load_overlay=${get_cmd} ${fdtoverlay_addr_r} ${overlay}
Benjamin Hahn2b143e22024-07-16 22:11:26 -070028net_apply_overlays=
Benjamin Hahn32fb45b2024-07-16 22:11:30 -070029 fdt address ${fdt_addr_r};
Benjamin Hahn2b143e22024-07-16 22:11:26 -070030 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 Hahn32fb45b2024-07-16 22:11:30 -070035 fdt apply ${fdtoverlay_addr_r};
Benjamin Hahn2b143e22024-07-16 22:11:26 -070036 fi;
37 done;
38 fi;