--- /dev/null
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (C) 2024 PHYTEC Messtechnik GmbH
+ * Author: Benjamin Hahn <b.hahn@phytec.de>
+ */
+
+/* Logic to load and apply overlays. Load overlays from bootenv.txt into
+ * environment and apply those overlays.
+ * The variables bootenv_addr and fdto_addr are board specific. */
+
+bootenv=bootenv.txt
+mmc_load_bootenv=load mmc ${mmcdev}:${mmcpart} ${bootenv_addr} ${bootenv}
+mmc_load_overlay=load mmc ${mmcdev}:${mmcpart} ${fdto_addr} ${overlay}
+mmc_apply_overlays=
+ fdt address ${fdt_addr};
+ if test ${no_overlays} = 0; then
+ for overlay in ${overlays};
+ do;
+ if run mmc_load_overlay; then
+ fdt resize ${filesize};
+ fdt apply ${fdto_addr};
+ fi;
+ done;
+ fi;
+net_load_bootenv=${get_cmd} ${bootenv_addr} ${bootenv}
+net_load_overlay=${get_cmd} ${fdto_addr} ${overlay}
+net_apply_overlays=
+ fdt address ${fdt_addr};
+ if test ${no_overlays} = 0; then
+ for overlay in ${overlays};
+ do;
+ if run net_load_overlay; then
+ fdt resize ${filesize};
+ fdt apply ${fdto_addr};
+ fi;
+ done;
+ fi;