Merge tag 'rpi-2023.10' of https://source.denx.de/u-boot/custodians/u-boot-raspberrypi

Updates for RPi for 2023.10:

- rpi: Disable DISTRO_DEFAULTS
- arm: rpi: Switch to standard boot
- arm: rpi: Switch to a text environment
diff --git a/board/raspberrypi/rpi/rpi.env b/board/raspberrypi/rpi/rpi.env
new file mode 100644
index 0000000..3022828
--- /dev/null
+++ b/board/raspberrypi/rpi/rpi.env
@@ -0,0 +1,77 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+
+/* environment for Raspberry Pi boards */
+
+dhcpuboot=usb start; dhcp u-boot.uimg; bootm
+
+/* Environment */
+stdin=serial,usbkbd
+stdout=serial,vidconsole
+stderr=serial,vidconsole
+
+/* DFU over USB/UDC */
+#ifdef CONFIG_CMD_DFU
+dfu_alt_info=u-boot.bin fat 0 1;uboot.env fat 0 1;
+  config.txt fat 0 1;
+#ifdef CONFIG_ARM64
+dfu_alt_info+=Image fat 0 1
+#else
+dfu_alt_info+=zImage fat 0 1
+#endif
+#endif  /* CONFIG_CMD_DFU */
+
+/*
+ * Memory layout for where various images get loaded by boot scripts:
+ *
+ * I suspect address 0 is used as the SMP pen on the RPi2, so avoid this.
+ *
+ * Older versions of the boot firmware place the firmware-loaded DTB at 0x100,
+ * newer versions place it in high memory. So prevent U-Boot from doing its own
+ * DTB + initrd relocation so that we won't accidentally relocate the initrd
+ * over the firmware-loaded DTB and generally try to lay out things starting
+ * from the bottom of RAM.
+ *
+ * kernel_addr_r has different constraints on ARM and Aarch64.  For 32-bit ARM,
+ * it must be within the first 128M of RAM in order for the kernel's
+ * CONFIG_AUTO_ZRELADDR option to work. The kernel itself will be decompressed
+ * to 0x8000 but the decompressor clobbers 0x4000-0x8000 as well. The
+ * decompressor also likes to relocate itself to right past the end of the
+ * decompressed kernel, so in total the sum of the compressed and
+ * decompressed kernel needs to be reserved.
+ *
+ *   For Aarch64, the kernel image is uncompressed and must be loaded at
+ *   text_offset bytes (specified in the header of the Image) into a 2MB
+ *   boundary. The 'booti' command relocates the image if necessary. Linux uses
+ *   a default text_offset of 0x80000.  In summary, loading at 0x80000
+ *   satisfies all these constraints and reserving memory up to 0x02400000
+ *   permits fairly large (roughly 36M) kernels.
+ *
+ * scriptaddr and pxefile_addr_r can be pretty much anywhere that doesn't
+ * conflict with something else. Reserving 1M for each of them at
+ * 0x02400000-0x02500000 and 0x02500000-0x02600000 should be plenty.
+ *
+ * On ARM, both the DTB and any possible initrd must be loaded such that they
+ * fit inside the lowmem mapping in Linux. In practice, this usually means not
+ * more than ~700M away from the start of the kernel image but this number can
+ * be larger OR smaller depending on e.g. the 'vmalloc=xxxM' command line
+ * parameter given to the kernel. So reserving memory from low to high
+ * satisfies this constraint again. Reserving 1M at 0x02600000-0x02700000 for
+ * the DTB leaves rest of the free RAM to the initrd starting at 0x02700000.
+ * Even with the smallest possible CPU-GPU memory split of the CPU getting
+ * only 64M, the remaining 25M starting at 0x02700000 should allow quite
+ * large initrds before they start colliding with U-Boot.
+ */
+#ifdef CONFIG_ARM64
+fdt_high=ffffffffffffffff
+initrd_high=ffffffffffffffff
+#else
+fdt_high=ffffffff
+initrd_high=ffffffff
+#endif
+kernel_addr_r=0x00080000
+scriptaddr=0x02400000
+pxefile_addr_r=0x02500000
+fdt_addr_r=0x02600000
+ramdisk_addr_r=0x02700000
+
+boot_targets=mmc usb pxe dhcp
diff --git a/configs/rpi_0_w_defconfig b/configs/rpi_0_w_defconfig
index 5da334a..3167bfb 100644
--- a/configs/rpi_0_w_defconfig
+++ b/configs/rpi_0_w_defconfig
@@ -12,8 +12,8 @@
 CONFIG_SYS_PROMPT="U-Boot> "
 CONFIG_OF_LIBFDT_OVERLAY=y
 CONFIG_SYS_LOAD_ADDR=0x1000000
+CONFIG_BOOTSTD_DEFAULTS=y
 CONFIG_OF_BOARD_SETUP=y
-CONFIG_DISTRO_DEFAULTS=y
 CONFIG_USE_PREBOOT=y
 # CONFIG_DISPLAY_CPUINFO is not set
 # CONFIG_DISPLAY_BOARDINFO is not set
diff --git a/configs/rpi_2_defconfig b/configs/rpi_2_defconfig
index 9908621..883dab1 100644
--- a/configs/rpi_2_defconfig
+++ b/configs/rpi_2_defconfig
@@ -13,8 +13,8 @@
 CONFIG_SYS_PROMPT="U-Boot> "
 CONFIG_OF_LIBFDT_OVERLAY=y
 CONFIG_SYS_LOAD_ADDR=0x1000000
+CONFIG_BOOTSTD_DEFAULTS=y
 CONFIG_OF_BOARD_SETUP=y
-CONFIG_DISTRO_DEFAULTS=y
 CONFIG_USE_PREBOOT=y
 # CONFIG_DISPLAY_CPUINFO is not set
 # CONFIG_DISPLAY_BOARDINFO is not set
diff --git a/configs/rpi_3_32b_defconfig b/configs/rpi_3_32b_defconfig
index 80885aa..5ff7d98 100644
--- a/configs/rpi_3_32b_defconfig
+++ b/configs/rpi_3_32b_defconfig
@@ -12,8 +12,8 @@
 CONFIG_SYS_PROMPT="U-Boot> "
 CONFIG_OF_LIBFDT_OVERLAY=y
 CONFIG_SYS_LOAD_ADDR=0x1000000
+CONFIG_BOOTSTD_DEFAULTS=y
 CONFIG_OF_BOARD_SETUP=y
-CONFIG_DISTRO_DEFAULTS=y
 CONFIG_USE_PREBOOT=y
 # CONFIG_DISPLAY_CPUINFO is not set
 # CONFIG_DISPLAY_BOARDINFO is not set
diff --git a/configs/rpi_3_b_plus_defconfig b/configs/rpi_3_b_plus_defconfig
index 0acce8b..31f2a6e 100644
--- a/configs/rpi_3_b_plus_defconfig
+++ b/configs/rpi_3_b_plus_defconfig
@@ -11,8 +11,8 @@
 CONFIG_SYS_PROMPT="U-Boot> "
 CONFIG_OF_LIBFDT_OVERLAY=y
 CONFIG_SYS_LOAD_ADDR=0x1000000
+CONFIG_BOOTSTD_DEFAULTS=y
 CONFIG_OF_BOARD_SETUP=y
-CONFIG_DISTRO_DEFAULTS=y
 CONFIG_USE_PREBOOT=y
 # CONFIG_DISPLAY_CPUINFO is not set
 # CONFIG_DISPLAY_BOARDINFO is not set
diff --git a/configs/rpi_3_defconfig b/configs/rpi_3_defconfig
index bb6fe12..fa6e150 100644
--- a/configs/rpi_3_defconfig
+++ b/configs/rpi_3_defconfig
@@ -11,8 +11,8 @@
 CONFIG_SYS_PROMPT="U-Boot> "
 CONFIG_OF_LIBFDT_OVERLAY=y
 CONFIG_SYS_LOAD_ADDR=0x1000000
+CONFIG_BOOTSTD_DEFAULTS=y
 CONFIG_OF_BOARD_SETUP=y
-CONFIG_DISTRO_DEFAULTS=y
 CONFIG_USE_PREBOOT=y
 # CONFIG_DISPLAY_CPUINFO is not set
 # CONFIG_DISPLAY_BOARDINFO is not set
diff --git a/configs/rpi_4_32b_defconfig b/configs/rpi_4_32b_defconfig
index f621334..55bf6c0 100644
--- a/configs/rpi_4_32b_defconfig
+++ b/configs/rpi_4_32b_defconfig
@@ -10,9 +10,9 @@
 CONFIG_OF_LIBFDT_OVERLAY=y
 CONFIG_DM_RESET=y
 CONFIG_SYS_LOAD_ADDR=0x1000000
+CONFIG_BOOTSTD_DEFAULTS=y
 CONFIG_PCI=y
 CONFIG_OF_BOARD_SETUP=y
-CONFIG_DISTRO_DEFAULTS=y
 CONFIG_USE_PREBOOT=y
 CONFIG_PREBOOT="pci enum; usb start;"
 # CONFIG_DISPLAY_CPUINFO is not set
diff --git a/configs/rpi_4_defconfig b/configs/rpi_4_defconfig
index bbc0fd6..6679cce 100644
--- a/configs/rpi_4_defconfig
+++ b/configs/rpi_4_defconfig
@@ -10,9 +10,9 @@
 CONFIG_OF_LIBFDT_OVERLAY=y
 CONFIG_DM_RESET=y
 CONFIG_SYS_LOAD_ADDR=0x1000000
+CONFIG_BOOTSTD_DEFAULTS=y
 CONFIG_PCI=y
 CONFIG_OF_BOARD_SETUP=y
-CONFIG_DISTRO_DEFAULTS=y
 CONFIG_USE_PREBOOT=y
 CONFIG_PREBOOT="pci enum; usb start;"
 # CONFIG_DISPLAY_CPUINFO is not set
diff --git a/configs/rpi_arm64_defconfig b/configs/rpi_arm64_defconfig
index 5d9a273..26e29ff 100644
--- a/configs/rpi_arm64_defconfig
+++ b/configs/rpi_arm64_defconfig
@@ -10,9 +10,9 @@
 CONFIG_OF_LIBFDT_OVERLAY=y
 CONFIG_DM_RESET=y
 CONFIG_SYS_LOAD_ADDR=0x1000000
+CONFIG_BOOTSTD_DEFAULTS=y
 CONFIG_PCI=y
 CONFIG_OF_BOARD_SETUP=y
-CONFIG_DISTRO_DEFAULTS=y
 CONFIG_USE_PREBOOT=y
 CONFIG_PREBOOT="pci enum; usb start;"
 # CONFIG_DISPLAY_CPUINFO is not set
diff --git a/configs/rpi_defconfig b/configs/rpi_defconfig
index 550b8dc..0ac5efe 100644
--- a/configs/rpi_defconfig
+++ b/configs/rpi_defconfig
@@ -12,8 +12,8 @@
 CONFIG_SYS_PROMPT="U-Boot> "
 CONFIG_OF_LIBFDT_OVERLAY=y
 CONFIG_SYS_LOAD_ADDR=0x1000000
+CONFIG_BOOTSTD_DEFAULTS=y
 CONFIG_OF_BOARD_SETUP=y
-CONFIG_DISTRO_DEFAULTS=y
 CONFIG_USE_PREBOOT=y
 # CONFIG_DISPLAY_CPUINFO is not set
 # CONFIG_DISPLAY_BOARDINFO is not set
diff --git a/include/configs/rpi.h b/include/configs/rpi.h
index 4da982f..8e56bdc 100644
--- a/include/configs/rpi.h
+++ b/include/configs/rpi.h
@@ -13,8 +13,6 @@
 #include <asm/arch/base.h>
 #endif
 
-/* Architecture, CPU, etc.*/
-
 /* Use SoC timer for AArch32, but architected timer for AArch64 */
 #ifndef CONFIG_ARM64
 #define CFG_SYS_TIMER_RATE		1000000
@@ -33,136 +31,4 @@
  */
 #define CFG_SYS_SDRAM_SIZE		SZ_128M
 
-/* Devices */
-/* LCD */
-
-/* DFU over USB/UDC */
-#ifdef CONFIG_CMD_DFU
-#ifdef CONFIG_ARM64
-#define KERNEL_FILENAME		"Image"
-#else
-#define KERNEL_FILENAME		"zImage"
-#endif
-
-#define ENV_DFU_SETTINGS \
-	"dfu_alt_info=u-boot.bin fat 0 1;uboot.env fat 0 1;" \
-		      "config.txt fat 0 1;" \
-		      KERNEL_FILENAME " fat 0 1\0"
-#else
-#define ENV_DFU_SETTINGS ""
-#endif
-
-/* Console configuration */
-
-/* Environment */
-
-/* Shell */
-
-/* Environment */
-#define ENV_DEVICE_SETTINGS \
-	"stdin=serial,usbkbd\0" \
-	"stdout=serial,vidconsole\0" \
-	"stderr=serial,vidconsole\0"
-
-#ifdef CONFIG_ARM64
-#define FDT_HIGH "ffffffffffffffff"
-#define INITRD_HIGH "ffffffffffffffff"
-#else
-#define FDT_HIGH "ffffffff"
-#define INITRD_HIGH "ffffffff"
-#endif
-
-/*
- * Memory layout for where various images get loaded by boot scripts:
- *
- * I suspect address 0 is used as the SMP pen on the RPi2, so avoid this.
- *
- * Older versions of the boot firmware place the firmware-loaded DTB at 0x100,
- * newer versions place it in high memory. So prevent U-Boot from doing its own
- * DTB + initrd relocation so that we won't accidentally relocate the initrd
- * over the firmware-loaded DTB and generally try to lay out things starting
- * from the bottom of RAM.
- *
- * kernel_addr_r has different constraints on ARM and Aarch64.  For 32-bit ARM,
- * it must be within the first 128M of RAM in order for the kernel's
- * CONFIG_AUTO_ZRELADDR option to work. The kernel itself will be decompressed
- * to 0x8000 but the decompressor clobbers 0x4000-0x8000 as well. The
- * decompressor also likes to relocate itself to right past the end of the
- * decompressed kernel, so in total the sum of the compressed and and
- * decompressed kernel needs to be reserved.
- *
- *   For Aarch64, the kernel image is uncompressed and must be loaded at
- *   text_offset bytes (specified in the header of the Image) into a 2MB
- *   boundary. The 'booti' command relocates the image if necessary. Linux uses
- *   a default text_offset of 0x80000.  In summary, loading at 0x80000
- *   satisfies all these constraints and reserving memory up to 0x02400000
- *   permits fairly large (roughly 36M) kernels.
- *
- * scriptaddr and pxefile_addr_r can be pretty much anywhere that doesn't
- * conflict with something else. Reserving 1M for each of them at
- * 0x02400000-0x02500000 and 0x02500000-0x02600000 should be plenty.
- *
- * On ARM, both the DTB and any possible initrd must be loaded such that they
- * fit inside the lowmem mapping in Linux. In practice, this usually means not
- * more than ~700M away from the start of the kernel image but this number can
- * be larger OR smaller depending on e.g. the 'vmalloc=xxxM' command line
- * parameter given to the kernel. So reserving memory from low to high
- * satisfies this constraint again. Reserving 1M at 0x02600000-0x02700000 for
- * the DTB leaves rest of the free RAM to the initrd starting at 0x02700000.
- * Even with the smallest possible CPU-GPU memory split of the CPU getting
- * only 64M, the remaining 25M starting at 0x02700000 should allow quite
- * large initrds before they start colliding with U-Boot.
- */
-#define ENV_MEM_LAYOUT_SETTINGS \
-	"fdt_high=" FDT_HIGH "\0" \
-	"initrd_high=" INITRD_HIGH "\0" \
-	"kernel_addr_r=0x00080000\0" \
-	"scriptaddr=0x02400000\0" \
-	"pxefile_addr_r=0x02500000\0" \
-	"fdt_addr_r=0x02600000\0" \
-	"ramdisk_addr_r=0x02700000\0"
-
-#if IS_ENABLED(CONFIG_CMD_MMC)
-	#define BOOT_TARGET_MMC(func) \
-		func(MMC, mmc, 0) \
-		func(MMC, mmc, 1) \
-		func(MMC, mmc, 2)
-#else
-	#define BOOT_TARGET_MMC(func)
-#endif
-
-#if IS_ENABLED(CONFIG_CMD_USB)
-	#define BOOT_TARGET_USB(func) func(USB, usb, 0)
-#else
-	#define BOOT_TARGET_USB(func)
-#endif
-
-#if CONFIG_IS_ENABLED(CMD_PXE)
-	#define BOOT_TARGET_PXE(func) func(PXE, pxe, na)
-#else
-	#define BOOT_TARGET_PXE(func)
-#endif
-
-#if CONFIG_IS_ENABLED(CMD_DHCP)
-	#define BOOT_TARGET_DHCP(func) func(DHCP, dhcp, na)
-#else
-	#define BOOT_TARGET_DHCP(func)
-#endif
-
-#define BOOT_TARGET_DEVICES(func) \
-	BOOT_TARGET_MMC(func) \
-	BOOT_TARGET_USB(func) \
-	BOOT_TARGET_PXE(func) \
-	BOOT_TARGET_DHCP(func)
-
-#include <config_distro_bootcmd.h>
-
-#define CFG_EXTRA_ENV_SETTINGS \
-	"dhcpuboot=usb start; dhcp u-boot.uimg; bootm\0" \
-	ENV_DEVICE_SETTINGS \
-	ENV_DFU_SETTINGS \
-	ENV_MEM_LAYOUT_SETTINGS \
-	BOOTENV
-
-
 #endif