summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.azure-pipelines.yml6
-rw-r--r--MAINTAINERS28
-rw-r--r--Makefile4
-rw-r--r--README22
-rw-r--r--arch/Kconfig11
-rw-r--r--arch/arm/dts/Makefile2
-rw-r--r--arch/arm/dts/at91-sam9x60_curiosity-u-boot.dtsi79
-rw-r--r--arch/arm/dts/at91-sam9x60_curiosity.dts74
-rw-r--r--arch/arm/dts/at91-sama7g5ek.dts2
-rw-r--r--arch/arm/dts/meson-axg-jethome-jethub-j100-u-boot.dtsi10
-rw-r--r--arch/arm/dts/sam9x60.dtsi13
-rw-r--r--arch/arm/dts/sama7g5.dtsi9
-rw-r--r--arch/arm/mach-at91/Kconfig7
-rw-r--r--arch/arm/mach-at91/arm926ejs/Makefile2
-rw-r--r--arch/arm/mach-at91/armv7/Makefile3
-rw-r--r--arch/arm/mach-at91/armv7/reset.c31
-rw-r--r--arch/nds32/Kconfig46
-rw-r--r--arch/nds32/Makefile6
-rw-r--r--arch/nds32/config.mk18
-rw-r--r--arch/nds32/cpu/n1213/Makefile13
-rw-r--r--arch/nds32/cpu/n1213/ae3xx/Makefile16
-rw-r--r--arch/nds32/cpu/n1213/ae3xx/cpu.c46
-rw-r--r--arch/nds32/cpu/n1213/ae3xx/lowlevel_init.S147
-rw-r--r--arch/nds32/cpu/n1213/ae3xx/timer.c15
-rw-r--r--arch/nds32/cpu/n1213/ae3xx/watchdog.S16
-rw-r--r--arch/nds32/cpu/n1213/ag101/Makefile16
-rw-r--r--arch/nds32/cpu/n1213/ag101/cpu.c63
-rw-r--r--arch/nds32/cpu/n1213/ag101/lowlevel_init.S317
-rw-r--r--arch/nds32/cpu/n1213/ag101/timer.c197
-rw-r--r--arch/nds32/cpu/n1213/ag101/watchdog.S32
-rw-r--r--arch/nds32/cpu/n1213/start.S502
-rw-r--r--arch/nds32/cpu/n1213/u-boot.lds58
-rw-r--r--arch/nds32/dts/Makefile15
-rw-r--r--arch/nds32/dts/ae3xx.dts103
-rw-r--r--arch/nds32/dts/ag101p.dts72
-rw-r--r--arch/nds32/include/asm/arch-ae3xx/ae3xx.h51
-rw-r--r--arch/nds32/include/asm/arch-ag101/ag101.h85
-rw-r--r--arch/nds32/include/asm/arch-ag102/ag102.h78
-rw-r--r--arch/nds32/include/asm/bitops.h194
-rw-r--r--arch/nds32/include/asm/bootm.h60
-rw-r--r--arch/nds32/include/asm/byteorder.h36
-rw-r--r--arch/nds32/include/asm/cache.h63
-rw-r--r--arch/nds32/include/asm/config.h11
-rw-r--r--arch/nds32/include/asm/dma-mapping.h22
-rw-r--r--arch/nds32/include/asm/global_data.h35
-rw-r--r--arch/nds32/include/asm/io.h457
-rw-r--r--arch/nds32/include/asm/linkage.h11
-rw-r--r--arch/nds32/include/asm/mach-types.h30
-rw-r--r--arch/nds32/include/asm/macro.h79
-rw-r--r--arch/nds32/include/asm/posix_types.h88
-rw-r--r--arch/nds32/include/asm/processor.h25
-rw-r--r--arch/nds32/include/asm/ptrace.h90
-rw-r--r--arch/nds32/include/asm/sections.h11
-rw-r--r--arch/nds32/include/asm/setup.h189
-rw-r--r--arch/nds32/include/asm/spl.h0
-rw-r--r--arch/nds32/include/asm/string.h57
-rw-r--r--arch/nds32/include/asm/system.h71
-rw-r--r--arch/nds32/include/asm/types.h34
-rw-r--r--arch/nds32/include/asm/u-boot-nds32.h30
-rw-r--r--arch/nds32/include/asm/u-boot.h29
-rw-r--r--arch/nds32/include/asm/unaligned.h1
-rw-r--r--arch/nds32/lib/Makefile13
-rw-r--r--arch/nds32/lib/asm-offsets.c82
-rw-r--r--arch/nds32/lib/boot.c17
-rw-r--r--arch/nds32/lib/bootm.c248
-rw-r--r--arch/nds32/lib/cache.c268
-rw-r--r--arch/nds32/lib/interrupts.c118
-rw-r--r--arch/sandbox/dts/sandbox.dts4
-rw-r--r--arch/sandbox/dts/sandbox.dtsi5
-rw-r--r--arch/sandbox/dts/test.dts18
-rw-r--r--board/AndesTech/adp-ae3xx/Kconfig18
-rw-r--r--board/AndesTech/adp-ae3xx/MAINTAINERS6
-rw-r--r--board/AndesTech/adp-ae3xx/Makefile6
-rw-r--r--board/AndesTech/adp-ae3xx/adp-ae3xx.c79
-rw-r--r--board/AndesTech/adp-ag101p/Kconfig22
-rw-r--r--board/AndesTech/adp-ag101p/MAINTAINERS6
-rw-r--r--board/AndesTech/adp-ag101p/Makefile7
-rw-r--r--board/AndesTech/adp-ag101p/adp-ag101p.c86
-rw-r--r--board/atmel/sam9x60_curiosity/Kconfig15
-rw-r--r--board/atmel/sam9x60_curiosity/MAINTAINERS7
-rw-r--r--board/atmel/sam9x60_curiosity/Makefile7
-rw-r--r--board/atmel/sam9x60_curiosity/sam9x60_curiosity.c75
-rw-r--r--boot/Kconfig115
-rw-r--r--boot/Makefile15
-rw-r--r--boot/bootdev-uclass.c649
-rw-r--r--boot/bootflow.c411
-rw-r--r--boot/bootmeth-uclass.c333
-rw-r--r--boot/bootmeth_distro.c143
-rw-r--r--boot/bootmeth_efi.c188
-rw-r--r--boot/bootmeth_efi_mgr.c86
-rw-r--r--boot/bootmeth_pxe.c186
-rw-r--r--boot/bootmeth_sandbox.c69
-rw-r--r--boot/bootmeth_script.c139
-rw-r--r--boot/bootstd-uclass.c183
-rw-r--r--boot/system_bootdev.c66
-rw-r--r--cmd/Kconfig40
-rw-r--r--cmd/Makefile3
-rw-r--r--cmd/bootdev.c120
-rw-r--r--cmd/bootefi.c36
-rw-r--r--cmd/bootflow.c404
-rw-r--r--cmd/bootmenu.c4
-rw-r--r--cmd/bootmeth.c113
-rw-r--r--common/board_f.c2
-rw-r--r--common/board_r.c7
-rw-r--r--common/main.c7
-rw-r--r--common/usb_storage.c11
-rw-r--r--configs/adp-ae3xx_defconfig60
-rw-r--r--configs/adp-ag101p_defconfig49
-rw-r--r--configs/chromebit_mickey_defconfig1
-rw-r--r--configs/chromebook_jerry_defconfig1
-rw-r--r--configs/chromebook_minnie_defconfig1
-rw-r--r--configs/chromebook_speedy_defconfig1
-rw-r--r--configs/cortina_presidio-asic-emmc_defconfig1
-rw-r--r--configs/efi-x86_app32_defconfig1
-rw-r--r--configs/efi-x86_app64_defconfig1
-rw-r--r--configs/evb-rk3036_defconfig1
-rw-r--r--configs/evb-rk3288_defconfig1
-rw-r--r--configs/firefly-rk3288_defconfig1
-rw-r--r--configs/gardena-smart-gateway-at91sam_defconfig1
-rw-r--r--configs/jethub_j100_defconfig5
-rw-r--r--configs/miqi-rk3288_defconfig1
-rw-r--r--configs/mt7620_mt7530_rfb_defconfig1
-rw-r--r--configs/mt7628_rfb_defconfig1
-rw-r--r--configs/phycore-rk3288_defconfig1
-rw-r--r--configs/popmetal-rk3288_defconfig1
-rw-r--r--configs/rcar3_salvator-x_defconfig1
-rw-r--r--configs/rock-pi-n8-rk3288_defconfig1
-rw-r--r--configs/rock2_defconfig1
-rw-r--r--configs/sam9x60_curiosity_mmc_defconfig74
-rw-r--r--configs/sam9x60ek_mmc_defconfig3
-rw-r--r--configs/sam9x60ek_nandflash_defconfig3
-rw-r--r--configs/sam9x60ek_qspiflash_defconfig3
-rw-r--r--configs/sama5d27_giantboard_defconfig5
-rw-r--r--configs/sama5d27_som1_ek_mmc1_defconfig5
-rw-r--r--configs/sama5d27_som1_ek_mmc_defconfig5
-rw-r--r--configs/sama5d27_som1_ek_qspiflash_defconfig5
-rw-r--r--configs/sama5d27_wlsom1_ek_mmc_defconfig5
-rw-r--r--configs/sama5d27_wlsom1_ek_qspiflash_defconfig5
-rw-r--r--configs/sama5d2_icp_mmc_defconfig5
-rw-r--r--configs/sama5d2_icp_qspiflash_defconfig3
-rw-r--r--configs/sama5d2_ptc_ek_mmc_defconfig3
-rw-r--r--configs/sama5d2_ptc_ek_nandflash_defconfig3
-rw-r--r--configs/sama5d2_xplained_emmc_defconfig5
-rw-r--r--configs/sama5d2_xplained_mmc_defconfig5
-rw-r--r--configs/sama5d2_xplained_qspiflash_defconfig5
-rw-r--r--configs/sama5d2_xplained_spiflash_defconfig5
-rw-r--r--configs/sama5d36ek_cmp_mmc_defconfig3
-rw-r--r--configs/sama5d36ek_cmp_nandflash_defconfig3
-rw-r--r--configs/sama5d36ek_cmp_spiflash_defconfig3
-rw-r--r--configs/sama5d3_xplained_mmc_defconfig5
-rw-r--r--configs/sama5d3_xplained_nandflash_defconfig5
-rw-r--r--configs/sama5d3xek_mmc_defconfig5
-rw-r--r--configs/sama5d3xek_nandflash_defconfig5
-rw-r--r--configs/sama5d3xek_spiflash_defconfig5
-rw-r--r--configs/sama5d4_xplained_mmc_defconfig5
-rw-r--r--configs/sama5d4_xplained_nandflash_defconfig5
-rw-r--r--configs/sama5d4_xplained_spiflash_defconfig5
-rw-r--r--configs/sama5d4ek_mmc_defconfig5
-rw-r--r--configs/sama5d4ek_nandflash_defconfig5
-rw-r--r--configs/sama5d4ek_spiflash_defconfig5
-rw-r--r--configs/sama7g5ek_mmc1_defconfig3
-rw-r--r--configs/sama7g5ek_mmc_defconfig3
-rw-r--r--configs/sandbox_defconfig3
-rw-r--r--configs/sandbox_flattree_defconfig3
-rw-r--r--configs/tbs2910_defconfig1
-rw-r--r--configs/tinker-rk3288_defconfig1
-rw-r--r--configs/tinker-s-rk3288_defconfig1
-rw-r--r--configs/vinco_defconfig3
-rw-r--r--configs/vyasa-rk3288_defconfig1
-rw-r--r--configs/xilinx_versal_mini_defconfig1
-rw-r--r--configs/xilinx_zynqmp_mini_defconfig1
-rw-r--r--configs/xilinx_zynqmp_mini_nand_defconfig1
-rw-r--r--configs/xilinx_zynqmp_mini_nand_single_defconfig1
-rw-r--r--disk/Kconfig37
-rw-r--r--disk/Makefile3
-rw-r--r--disk/disk-uclass.c247
-rw-r--r--doc/README.standalone1
-rw-r--r--doc/README.watchdog6
-rw-r--r--doc/arch/index.rst1
-rw-r--r--doc/arch/nds32.rst101
-rw-r--r--doc/board/amlogic/index.rst2
-rw-r--r--doc/board/amlogic/jethub-j100.rst26
-rw-r--r--doc/board/apple/m1.rst3
-rw-r--r--doc/develop/bootstd.rst638
-rw-r--r--doc/develop/distro.rst3
-rw-r--r--doc/develop/driver-model/design.rst21
-rw-r--r--doc/develop/global_data.rst2
-rw-r--r--doc/develop/index.rst1
-rw-r--r--doc/device-tree-bindings/bootdev.txt26
-rw-r--r--doc/device-tree-bindings/bootmeth.txt31
-rw-r--r--doc/device-tree-bindings/bootstd.txt36
-rw-r--r--doc/git-mailrc4
-rw-r--r--doc/kwboot.12
-rw-r--r--doc/usage/cmd/bootdev.rst135
-rw-r--r--doc/usage/cmd/bootefi.rst21
-rw-r--r--doc/usage/cmd/bootflow.rst427
-rw-r--r--doc/usage/cmd/bootmeth.rst108
-rw-r--r--doc/usage/index.rst3
-rw-r--r--drivers/adc/meson-saradc.c2
-rw-r--r--drivers/block/blk-uclass.c11
-rw-r--r--drivers/clk/meson/Makefile1
-rw-r--r--drivers/clk/meson/axg-ao.c86
-rw-r--r--drivers/clk/meson/g12a-ao.c17
-rw-r--r--drivers/core/tag.c4
-rw-r--r--drivers/core/uclass.c20
-rw-r--r--drivers/mmc/Makefile5
-rw-r--r--drivers/mmc/mmc-uclass.c23
-rw-r--r--drivers/mmc/mmc_bootdev.c62
-rw-r--r--drivers/spi/atmel-quadspi.c3
-rw-r--r--drivers/sysreset/Kconfig15
-rw-r--r--drivers/sysreset/Makefile1
-rw-r--r--drivers/sysreset/sysreset_at91.c71
-rw-r--r--drivers/timer/Kconfig23
-rw-r--r--drivers/timer/Makefile5
-rw-r--r--drivers/timer/ag101p_timer.c117
-rw-r--r--drivers/timer/atcpit100_timer.c112
-rw-r--r--drivers/usb/host/Makefile4
-rw-r--r--drivers/usb/host/usb_bootdev.c61
-rw-r--r--drivers/watchdog/Makefile1
-rw-r--r--drivers/watchdog/ftwdt010_wdt.c92
-rw-r--r--examples/standalone/nds32.lds39
-rw-r--r--examples/standalone/stubs.c13
-rw-r--r--fs/Kconfig2
-rw-r--r--fs/fs.c5
-rw-r--r--fs/sandbox/Kconfig2
-rw-r--r--fs/sandbox/Makefile1
-rw-r--r--fs/sandbox/host_bootdev.c56
-rw-r--r--include/blk.h8
-rw-r--r--include/bootdev.h275
-rw-r--r--include/bootflow.h310
-rw-r--r--include/bootmeth.h234
-rw-r--r--include/bootstd.h80
-rw-r--r--include/configs/adp-ae3xx.h186
-rw-r--r--include/configs/adp-ag101p.h299
-rw-r--r--include/configs/at91-sama5_common.h11
-rw-r--r--include/configs/at91sam9m10g45ek.h6
-rw-r--r--include/configs/at91sam9n12ek.h9
-rw-r--r--include/configs/sam9x60_curiosity.h31
-rw-r--r--include/configs/sam9x60ek.h10
-rw-r--r--include/configs/sama5d27_som1_ek.h4
-rw-r--r--include/configs/sama5d2_xplained.h12
-rw-r--r--include/distro.h24
-rw-r--r--include/dm/device.h2
-rw-r--r--include/dm/uclass-id.h4
-rw-r--r--include/dm/uclass-internal.h16
-rw-r--r--include/dm/uclass.h6
-rw-r--r--include/efi_loader.h6
-rw-r--r--include/env_callback.h7
-rw-r--r--include/fs.h11
-rw-r--r--include/mmc.h12
-rw-r--r--include/part.h39
-rw-r--r--include/sandboxblockdev.h2
-rw-r--r--include/test/suites.h2
-rw-r--r--include/vsprintf.h117
-rw-r--r--lib/Kconfig2
-rw-r--r--lib/efi_driver/efi_block_device.c34
-rw-r--r--lib/efi_loader/Kconfig5
-rw-r--r--lib/efi_loader/Makefile2
-rw-r--r--lib/efi_loader/efi_device_path.c9
-rw-r--r--lib/efi_loader/efi_disk.c321
-rw-r--r--lib/efi_loader/efi_setup.c62
-rw-r--r--lib/fdtdec.c7
-rw-r--r--lib/strto.c23
-rw-r--r--net/Kconfig9
-rw-r--r--net/Makefile1
-rw-r--r--net/eth-uclass.c8
-rw-r--r--net/eth_bootdev.c101
-rw-r--r--scripts/config_whitelist.txt55
-rw-r--r--test/Makefile1
-rw-r--r--test/boot/Makefile5
-rw-r--r--test/boot/bootdev.c223
-rw-r--r--test/boot/bootflow.c400
-rw-r--r--test/boot/bootmeth.c122
-rw-r--r--test/boot/bootstd_common.c35
-rw-r--r--test/boot/bootstd_common.h27
-rw-r--r--test/cmd_ut.c7
-rw-r--r--test/dm/Makefile1
-rw-r--r--test/dm/blk.c6
-rw-r--r--test/dm/core.c17
-rw-r--r--test/dm/fastboot.c4
-rw-r--r--test/dm/tag.c84
-rw-r--r--test/print_ut.c40
-rw-r--r--test/py/tests/bootstd/mmc1.img.xzbin0 -> 4448 bytes
-rw-r--r--test/py/tests/test_ut.py103
-rw-r--r--test/str_ut.c72
-rw-r--r--tools/binman/control.py3
-rw-r--r--tools/binman/entry.py2
-rw-r--r--tools/binman/etype/_testing.py36
-rw-r--r--tools/binman/etype/fit.py15
-rw-r--r--tools/binman/etype/section.py3
-rw-r--r--tools/binman/ftest.py180
-rwxr-xr-xtools/binman/main.py7
-rw-r--r--tools/binman/test/230_unique_names.dts34
-rw-r--r--tools/binman/test/231_unique_names_multi.dts38
-rw-r--r--tools/binman/test/232_replace_with_bintool.dts39
-rw-r--r--tools/binman/test/233_fit_extract_replace.dts74
-rw-r--r--tools/binman/test/234_replace_section_simple.dts23
-rw-r--r--tools/buildman/README7
-rw-r--r--tools/buildman/bsettings.py1
-rw-r--r--tools/buildman/builder.py1
-rw-r--r--tools/docker/Dockerfile2
301 files changed, 9217 insertions, 6138 deletions
diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml
index ec77c7ab5fc..48a587a59ea 100644
--- a/.azure-pipelines.yml
+++ b/.azure-pipelines.yml
@@ -431,10 +431,10 @@ stages:
vmImage: $(ubuntu_vm)
strategy:
# Use almost the same target division in .travis.yml, only merged
- # 4 small build jobs (arc/microblaze/nds32/xtensa) into one.
+ # 3 small build jobs (arc/microblaze/xtensa) into one.
matrix:
- arc_microblaze_nds32_xtensa:
- BUILDMAN: "arc microblaze nds32 xtensa"
+ arc_microblaze_xtensa:
+ BUILDMAN: "arc microblaze xtensa"
arm11_arm7_arm920t_arm946es:
BUILDMAN: "arm11 arm7 arm920t arm946es"
arm926ejs:
diff --git a/MAINTAINERS b/MAINTAINERS
index f7665fccf7a..56be0bfad00 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -690,9 +690,31 @@ F: arch/arm/dts/phytium-durian.dts
BINMAN
M: Simon Glass <sjg@chromium.org>
+M: Alper Nebi Yasak <alpernebiyasak@gmail.com>
S: Maintained
F: tools/binman/
+BOOTDEVICE
+M: Simon Glass <sjg@chromium.org>
+S: Maintained
+F: boot/bootdev*.c
+F: boot/bootflow.c
+F: boot/bootmeth*.c
+F: boot/bootstd.c
+F: cmd/bootdev.c
+F: cmd/bootflow.c
+F: doc/develop/bootstd.rst
+F: doc/usage/bootdev.rst
+F: doc/usage/bootflow.rst
+F: doc/usage/bootmeth.rst
+F: drivers/mmc/mmc_bootdev.c
+F: include/bootdev.h
+F: include/bootflow.h
+F: include/bootmeth.h
+F: include/bootstd.h
+F: net/eth_bootdevice.c
+F: test/boot/
+
BTRFS
M: Marek Behun <marek.behun@nic.cz>
R: Qu Wenruo <wqu@suse.com>
@@ -1035,12 +1057,6 @@ S: Orphaned (Since 2018-07)
T: git https://source.denx.de/u-boot/custodians/u-boot-nand-flash.git
F: drivers/mtd/nand/raw/
-NDS32
-M: Rick Chen <rick@andestech.com>
-S: Maintained
-T: git https://source.denx.de/u-boot/custodians/u-boot-nds32.git
-F: arch/nds32/
-
NETWORK
M: Joe Hershberger <joe.hershberger@ni.com>
M: Ramon Fried <rfried.dev@gmail.com>
diff --git a/Makefile b/Makefile
index 7937a4cfd32..ccc87c3a5cd 100644
--- a/Makefile
+++ b/Makefile
@@ -1,9 +1,9 @@
# SPDX-License-Identifier: GPL-2.0+
VERSION = 2022
-PATCHLEVEL = 04
+PATCHLEVEL = 07
SUBLEVEL =
-EXTRAVERSION =
+EXTRAVERSION = -rc1
NAME =
# *DOCUMENTATION*
diff --git a/README b/README
index 1967961eea0..b7ab6e50708 100644
--- a/README
+++ b/README
@@ -134,7 +134,6 @@ Directory Hierarchy:
/m68k Files generic to m68k architecture
/microblaze Files generic to microblaze architecture
/mips Files generic to MIPS architecture
- /nds32 Files generic to NDS32 architecture
/nios2 Files generic to Altera NIOS2 architecture
/powerpc Files generic to PowerPC architecture
/riscv Files generic to RISC-V architecture
@@ -2689,8 +2688,8 @@ details; basically, the header defines the following image properties:
LynxOS, pSOS, QNX, RTEMS, INTEGRITY;
Currently supported: Linux, NetBSD, VxWorks, QNX, RTEMS, INTEGRITY).
* Target CPU Architecture (Provisions for Alpha, ARM, Intel x86,
- IA64, MIPS, NDS32, Nios II, PowerPC, IBM S390, SuperH, Sparc, Sparc 64 Bit;
- Currently supported: ARM, Intel x86, MIPS, NDS32, Nios II, PowerPC).
+ IA64, MIPS, Nios II, PowerPC, IBM S390, SuperH, Sparc, Sparc 64 Bit;
+ Currently supported: ARM, Intel x86, MIPS, Nios II, PowerPC).
* Compression Type (uncompressed, gzip, bzip2)
* Load Address
* Entry Point
@@ -3402,23 +3401,6 @@ On Nios II, the ABI is documented here:
Note: on Nios II, we give "-G0" option to gcc and don't use gp
to access small data sections, so gp is free.
-On NDS32, the following registers are used:
-
- R0-R1: argument/return
- R2-R5: argument
- R15: temporary register for assembler
- R16: trampoline register
- R28: frame pointer (FP)
- R29: global pointer (GP)
- R30: link register (LP)
- R31: stack pointer (SP)
- PC: program counter (PC)
-
- ==> U-Boot will use R10 to hold a pointer to the global data
-
-NOTE: DECLARE_GLOBAL_DATA_PTR must be used with file-global scope,
-or current versions of GCC may "optimize" the code too much.
-
On RISC-V, the following registers are used:
x0: hard-wired zero (zero)
diff --git a/arch/Kconfig b/arch/Kconfig
index c3e9f9aef6a..12de8a11650 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -1,5 +1,5 @@
config ARCH_MAP_SYSMEM
- depends on SANDBOX || NDS32
+ depends on SANDBOX
def_bool y
config CREATE_ARCH_SYMLINK
@@ -87,10 +87,6 @@ config MIPS
select SUPPORT_OF_CONTROL
select SPL_SEPARATE_BSS if SPL
-config NDS32
- bool "NDS32 architecture"
- select SUPPORT_OF_CONTROL
-
config NIOS2
bool "Nios II architecture"
select CPU
@@ -382,7 +378,7 @@ config SYS_IMMR
config SKIP_LOWLEVEL_INIT
bool "Skip the calls to certain low level initialization functions"
- depends on ARM || NDS32 || MIPS || RISCV
+ depends on ARM || MIPS || RISCV
help
If enabled, then certain low level initializations (like setting up
the memory controller) are omitted and/or U-Boot does not relocate
@@ -393,7 +389,7 @@ config SKIP_LOWLEVEL_INIT
config SPL_SKIP_LOWLEVEL_INIT
bool "Skip the calls to certain low level initialization functions"
- depends on SPL && (ARM || NDS32 || MIPS || RISCV)
+ depends on SPL && (ARM || MIPS || RISCV)
help
If enabled, then certain low level initializations (like setting up
the memory controller) are omitted and/or U-Boot does not relocate
@@ -442,7 +438,6 @@ source "arch/arm/Kconfig"
source "arch/m68k/Kconfig"
source "arch/microblaze/Kconfig"
source "arch/mips/Kconfig"
-source "arch/nds32/Kconfig"
source "arch/nios2/Kconfig"
source "arch/powerpc/Kconfig"
source "arch/sandbox/Kconfig"
diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 1032ce4c856..ab2d0da192c 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -1021,6 +1021,8 @@ dtb-$(CONFIG_TARGET_AT91SAM9X5EK) += \
dtb-$(CONFIG_TARGET_SAM9X60EK) += sam9x60ek.dtb
+dtb-$(CONFIG_TARGET_SAM9X60_CURIOSITY) += at91-sam9x60_curiosity.dtb
+
dtb-$(CONFIG_TARGET_AT91SAM9N12EK) += at91sam9n12ek.dtb
dtb-$(CONFIG_TARGET_GARDENA_SMART_GATEWAY_AT91SAM) += \
diff --git a/arch/arm/dts/at91-sam9x60_curiosity-u-boot.dtsi b/arch/arm/dts/at91-sam9x60_curiosity-u-boot.dtsi
new file mode 100644
index 00000000000..d176e20f28f
--- /dev/null
+++ b/arch/arm/dts/at91-sam9x60_curiosity-u-boot.dtsi
@@ -0,0 +1,79 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * at91-sam9x60_curiosity-u-boot.dtsi - Device Tree Include file for SAM9X60
+ * CURIOSITY.
+ *
+ * Copyright (C) 2022 Microchip Technology Inc. and its subsidiaries
+ *
+ * Author: Durai Manickam KR <durai.manickamkr@microchip.com>
+ */
+
+/ {
+ ahb {
+ u-boot,dm-pre-reloc;
+
+ apb {
+ u-boot,dm-pre-reloc;
+
+ pinctrl {
+ u-boot,dm-pre-reloc;
+ };
+ };
+ };
+
+ chosen {
+ u-boot,dm-pre-reloc;
+ };
+};
+
+&clk32 {
+ u-boot,dm-pre-reloc;
+};
+
+&dbgu {
+ u-boot,dm-pre-reloc;
+};
+
+&main_rc {
+ u-boot,dm-pre-reloc;
+};
+
+&main_xtal {
+ u-boot,dm-pre-reloc;
+};
+
+&pinctrl_dbgu {
+ u-boot,dm-pre-reloc;
+};
+
+&pinctrl_sdhci0 {
+ u-boot,dm-pre-reloc;
+};
+
+&pioA {
+ u-boot,dm-pre-reloc;
+};
+
+&pioB {
+ u-boot,dm-pre-reloc;
+};
+
+&pit64b0 {
+ u-boot,dm-pre-reloc;
+};
+
+&pmc {
+ u-boot,dm-pre-reloc;
+};
+
+&sdhci0 {
+ u-boot,dm-pre-reloc;
+};
+
+&slow_rc_osc {
+ u-boot,dm-pre-reloc;
+};
+
+&slow_xtal {
+ u-boot,dm-pre-reloc;
+};
diff --git a/arch/arm/dts/at91-sam9x60_curiosity.dts b/arch/arm/dts/at91-sam9x60_curiosity.dts
new file mode 100644
index 00000000000..2e7ccb0ffb8
--- /dev/null
+++ b/arch/arm/dts/at91-sam9x60_curiosity.dts
@@ -0,0 +1,74 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * at91-sam9x60_curiosity.dts - Device Tree file for SAM9X60 CURIOSITY board
+ *
+ * Copyright (C) 2022 Microchip Technology Inc. and its subsidiaries
+ *
+ * Author: Durai Manickam KR <durai.manickamkr@microchip.com>
+ */
+/dts-v1/;
+#include <dt-bindings/mfd/atmel-flexcom.h>
+#include "sam9x60.dtsi"
+
+/ {
+ model = "Microchip SAM9X60 CURIOSITY";
+ compatible = "microchip,sam9x60-curiosity", "microchip,sam9x60", "atmel,at91sam9";
+
+ ahb {
+ apb {
+ flx0: flexcom@f801c600 {
+ atmel,flexcom-mode = <ATMEL_FLEXCOM_MODE_TWI>;
+ status = "okay";
+
+ i2c@600 {
+ compatible = "atmel,sama5d2-i2c";
+ reg = <0x600 0x200>;
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_flx0>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+ clocks = <&pmc PMC_TYPE_PERIPHERAL 5>;
+ status = "okay";
+
+ eeprom@53 {
+ compatible = "atmel,24c32";
+ reg = <0x53>;
+ pagesize = <16>;
+ };
+ };
+ };
+
+ pinctrl {
+ pinctrl_flx0: flx0_default {
+ atmel,pins =
+ <AT91_PIOA 0 AT91_PERIPH_A AT91_PINCTRL_NONE
+ AT91_PIOA 1 AT91_PERIPH_A AT91_PINCTRL_NONE>;
+ };
+ };
+ };
+ };
+
+ chosen {
+ stdout-path = &dbgu;
+ i2c0 = &flx0;
+ };
+
+ clocks {
+ slow_xtal: slow_xtal {
+ clock-frequency = <32768>;
+ };
+
+ main_xtal: main_xtal {
+ clock-frequency = <24000000>;
+ };
+ };
+
+ memory {
+ reg = <0x20000000 0x8000000>;
+ };
+};
+
+&macb0 {
+ phy-mode = "rmii";
+ status = "okay";
+};
diff --git a/arch/arm/dts/at91-sama7g5ek.dts b/arch/arm/dts/at91-sama7g5ek.dts
index 5313c6d160e..ee46112b08b 100644
--- a/arch/arm/dts/at91-sama7g5ek.dts
+++ b/arch/arm/dts/at91-sama7g5ek.dts
@@ -667,7 +667,7 @@
<PIN_PB21__QSPI0_INT>;
bias-disable;
slew-rate = <0>;
- atmel,drive-strength = <ATMEL_PIO_DRVSTR_HI>;
+ atmel,drive-strength = <ATMEL_PIO_DRVSTR_ME>;
};
pinctrl_sdmmc0_default: sdmmc0_default {
diff --git a/arch/arm/dts/meson-axg-jethome-jethub-j100-u-boot.dtsi b/arch/arm/dts/meson-axg-jethome-jethub-j100-u-boot.dtsi
new file mode 100644
index 00000000000..3ecb233f8e2
--- /dev/null
+++ b/arch/arm/dts/meson-axg-jethome-jethub-j100-u-boot.dtsi
@@ -0,0 +1,10 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2022 Vyacheslav Bocharov <adeep@lexina.in>
+ * Author: Vyacheslav Bocharov <adeep@lexina.in>
+ */
+
+&saradc {
+ status = "okay";
+ vref-supply = <&vddio_ao18>;
+};
diff --git a/arch/arm/dts/sam9x60.dtsi b/arch/arm/dts/sam9x60.dtsi
index be44519934b..a5c429eb3a7 100644
--- a/arch/arm/dts/sam9x60.dtsi
+++ b/arch/arm/dts/sam9x60.dtsi
@@ -223,12 +223,25 @@
status = "okay";
};
+ reset_controller: rstc@fffffe00 {
+ compatible = "microchip,sam9x60-rstc";
+ reg = <0xfffffe00 0x10>;
+ clocks = <&clk32 0>;
+ };
+
pit: timer@fffffe40 {
compatible = "atmel,at91sam9260-pit";
reg = <0xfffffe40 0x10>;
clocks = <&pmc PMC_TYPE_CORE 11>; /* ID_MCK. */
};
+ pit64b0: timer@f0028000 {
+ compatible = "microchip,sam9x60-pit64b";
+ reg = <0xf0028000 0xec>;
+ clocks = <&pmc PMC_TYPE_PERIPHERAL 37>, <&pmc PMC_TYPE_GCK 37>;
+ clock-names = "pclk", "gclk";
+ };
+
clk32: sckc@fffffe50 {
compatible = "microchip,sam9x60-sckc";
reg = <0xfffffe50 0x4>;
diff --git a/arch/arm/dts/sama7g5.dtsi b/arch/arm/dts/sama7g5.dtsi
index b7c261ebe9e..4efecdb92c7 100644
--- a/arch/arm/dts/sama7g5.dtsi
+++ b/arch/arm/dts/sama7g5.dtsi
@@ -232,6 +232,13 @@
clocks = <&clk32k 0>;
};
+ reset_controller: rstc@e001d000 {
+ compatible = "microchip,sama7g5-rstc", "microchip,sam9x60-rstc";
+ reg = <0xe001d000 0xc>, <0xe001d0e4 0x4>;
+ #reset-cells = <1>;
+ clocks = <&clk32k 0>;
+ };
+
clk32k: clock-controller@e001d050 {
compatible = "microchip,sama7g5-sckc", "microchip,sam9x60-sckc";
reg = <0xe001d050 0x4>;
@@ -316,7 +323,7 @@
dma-names = "tx", "rx";
clocks = <&pmc PMC_TYPE_PERIPHERAL 79>, <&pmc PMC_TYPE_GCK 79>;
clock-names = "pclk", "gclk";
- assigned-clocks = <&pmc PMC_TYPE_GCK 78>;
+ assigned-clocks = <&pmc PMC_TYPE_GCK 79>;
assigned-clock-parents = <&pmc PMC_TYPE_CORE 10>; /* sys pll div. */
#address-cells = <1>;
#size-cells = <0>;
diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
index 488a43ad4fb..b87639f8c07 100644
--- a/arch/arm/mach-at91/Kconfig
+++ b/arch/arm/mach-at91/Kconfig
@@ -165,6 +165,12 @@ config TARGET_SAM9X60EK
select BOARD_EARLY_INIT_F
select BOARD_LATE_INIT
+config TARGET_SAM9X60_CURIOSITY
+ bool "SAM9X60 CURIOSITY board"
+ select SAM9X60
+ select BOARD_EARLY_INIT_F
+ select BOARD_LATE_INIT
+
config TARGET_SAMA5D2_PTC_EK
bool "SAMA5D2 PTC EK board"
select BOARD_EARLY_INIT_F
@@ -339,6 +345,7 @@ source "board/atmel/at91sam9n12ek/Kconfig"
source "board/atmel/at91sam9rlek/Kconfig"
source "board/atmel/at91sam9x5ek/Kconfig"
source "board/atmel/sam9x60ek/Kconfig"
+source "board/atmel/sam9x60_curiosity/Kconfig"
source "board/atmel/sama7g5ek/Kconfig"
source "board/atmel/sama5d2_ptc_ek/Kconfig"
source "board/atmel/sama5d2_xplained/Kconfig"
diff --git a/arch/arm/mach-at91/arm926ejs/Makefile b/arch/arm/mach-at91/arm926ejs/Makefile
index f306b172f09..902dd3a60e3 100644
--- a/arch/arm/mach-at91/arm926ejs/Makefile
+++ b/arch/arm/mach-at91/arm926ejs/Makefile
@@ -18,7 +18,9 @@ obj-$(CONFIG_SAM9X60) += sam9x60_devices.o
obj-$(CONFIG_AT91_EFLASH) += eflash.o
obj-y += clock.o
obj-y += cpu.o
+ifndef CONFIG_$(SPL_TPL_)SYSRESET
obj-y += reset.o
+endif
ifneq ($(CONFIG_ATMEL_PIT_TIMER),y)
ifneq ($(CONFIG_MCHP_PIT64B_TIMER),y)
# old non-DM timer driver
diff --git a/arch/arm/mach-at91/armv7/Makefile b/arch/arm/mach-at91/armv7/Makefile
index f395b55c3de..6da1cdffef6 100644
--- a/arch/arm/mach-at91/armv7/Makefile
+++ b/arch/arm/mach-at91/armv7/Makefile
@@ -11,9 +11,6 @@ obj-$(CONFIG_SAMA5D3) += sama5d3_devices.o clock.o
obj-$(CONFIG_SAMA5D4) += sama5d4_devices.o clock.o
obj-$(CONFIG_SAMA7G5) += sama7g5_devices.o
obj-y += cpu.o
-ifndef CONFIG_$(SPL_TPL_)SYSRESET
-obj-y += reset.o
-endif
ifneq ($(CONFIG_ATMEL_TCB_TIMER),y)
ifneq ($(CONFIG_ATMEL_PIT_TIMER),y)
ifneq ($(CONFIG_MCHP_PIT64B_TIMER),y)
diff --git a/arch/arm/mach-at91/armv7/reset.c b/arch/arm/mach-at91/armv7/reset.c
deleted file mode 100644
index 1ea415ea9ef..00000000000
--- a/arch/arm/mach-at91/armv7/reset.c
+++ /dev/null
@@ -1,31 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * (C) Copyright 2007-2008
- * Stelian Pop <stelian@popies.net>
- * Lead Tech Design <www.leadtechdesign.com>
- *
- * (C) Copyright 2013
- * Bo Shen <voice.shen@atmel.com>
- */
-
-#include <common.h>
-#include <cpu_func.h>
-#include <asm/io.h>
-#include <asm/arch/hardware.h>
-#include <asm/arch/at91_rstc.h>
-
-/* Reset the cpu by telling the reset controller to do so */
-void reset_cpu(void)
-{
- at91_rstc_t *rstc = (at91_rstc_t *)ATMEL_BASE_RSTC;
-
- writel(AT91_RSTC_KEY
- | AT91_RSTC_CR_PROCRST /* Processor Reset */
- | AT91_RSTC_CR_PERRST /* Peripheral Reset */
-#ifdef CONFIG_AT91RESET_EXTRST
- | AT91_RSTC_CR_EXTRST /* External Reset (assert nRST pin) */
-#endif
- , &rstc->cr);
- /* never reached */
- do { } while (1);
-}
diff --git a/arch/nds32/Kconfig b/arch/nds32/Kconfig
deleted file mode 100644
index 435333720c7..00000000000
--- a/arch/nds32/Kconfig
+++ /dev/null
@@ -1,46 +0,0 @@
-menu "NDS32 architecture"
- depends on NDS32
-
-config SYS_ARCH
- default "nds32"
-
-choice
- prompt "Target select"
- optional
-
-config TARGET_ADP_AG101P
- bool "Support adp-ag101p"
-
-config TARGET_ADP_AE3XX
- bool "Support adp-ae3xx"
-
-endchoice
-
-config SYS_ICACHE_OFF
- bool "Do not enable icache"
- help
- Do not enable instruction cache in U-Boot.
-
-config SPL_SYS_ICACHE_OFF
- bool "Do not enable icache in SPL"
- depends on SPL
- default SYS_ICACHE_OFF
- help
- Do not enable instruction cache in SPL.
-
-config SYS_DCACHE_OFF
- bool "Do not enable dcache"
- help
- Do not enable data cache in U-Boot.
-
-config SPL_SYS_DCACHE_OFF
- bool "Do not enable dcache in SPL"
- depends on SPL
- default SYS_DCACHE_OFF
- help
- Do not enable data cache in SPL.
-
-source "board/AndesTech/adp-ag101p/Kconfig"
-source "board/AndesTech/adp-ae3xx/Kconfig"
-
-endmenu
diff --git a/arch/nds32/Makefile b/arch/nds32/Makefile
deleted file mode 100644
index e9980e85fd1..00000000000
--- a/arch/nds32/Makefile
+++ /dev/null
@@ -1,6 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0+
-
-head-y := arch/nds32/cpu/$(CPU)/start.o
-
-libs-y += arch/nds32/cpu/$(CPU)/
-libs-y += arch/nds32/lib/
diff --git a/arch/nds32/config.mk b/arch/nds32/config.mk
deleted file mode 100644
index c82dd69c6c3..00000000000
--- a/arch/nds32/config.mk
+++ /dev/null
@@ -1,18 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0+
-#
-# (C) Copyright 2000-2002
-# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
-#
-# (C) Copyright 2011
-# Shawn Lin, Andes Technology Corporation <nobuhiro@andestech.com>
-# Macpaul Lin, Andes Technology Corporation <macpaul@andestech.com>
-#
-
-CONFIG_STANDALONE_LOAD_ADDR = 0x300000
-LDFLAGS_STANDALONE += -T $(srctree)/examples/standalone/nds32.lds
-
-PLATFORM_RELFLAGS += -fno-common -mrelax -mno-ext-fpu-dp -mfloat-abi=soft
-PLATFORM_RELFLAGS += -gdwarf-2
-PLATFORM_CPPFLAGS += -D__nds32__ -ffixed-10 -fpie -mcmodel=large
-
-LDFLAGS_u-boot = --gc-sections --relax -pie --mabi=AABI
diff --git a/arch/nds32/cpu/n1213/Makefile b/arch/nds32/cpu/n1213/Makefile
deleted file mode 100644
index 0b8ce7b1804..00000000000
--- a/arch/nds32/cpu/n1213/Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0+
-#
-# (C) Copyright 2000-2006
-# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
-#
-# Copyright (C) 2011 Andes Technology Corporation
-# Shawn Lin, Andes Technology Corporation <nobuhiro@andestech.com>
-# Macpaul Lin, Andes Technology Corporation <macpaul@andestech.com>
-
-extra-y = start.o
-
-obj-$(if $(filter ag101,$(SOC)),y) += ag101/
-obj-$(if $(filter ae3xx,$(SOC)),y) += ae3xx/
diff --git a/arch/nds32/cpu/n1213/ae3xx/Makefile b/arch/nds32/cpu/n1213/ae3xx/Makefile
deleted file mode 100644
index 721a9ffafa3..00000000000
--- a/arch/nds32/cpu/n1213/ae3xx/Makefile
+++ /dev/null
@@ -1,16 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0+
-#
-# (C) Copyright 2009
-# Marvell Semiconductor <www.marvell.com>
-# Written-by: Prafulla Wadaskar <prafulla@marvell.com>
-#
-# Copyright (C) 2011 Andes Technology Corporation
-# Shawn Lin, Andes Technology Corporation <nobuhiro@andestech.com>
-# Macpaul Lin, Andes Technology Corporation <macpaul@andestech.com>
-
-obj-y := cpu.o timer.o
-obj-y += lowlevel_init.o
-
-ifndef CONFIG_SKIP_TRUNOFF_WATCHDOG
-obj-y += watchdog.o
-endif
diff --git a/arch/nds32/cpu/n1213/ae3xx/cpu.c b/arch/nds32/cpu/n1213/ae3xx/cpu.c
deleted file mode 100644
index c3efa31f594..00000000000
--- a/arch/nds32/cpu/n1213/ae3xx/cpu.c
+++ /dev/null
@@ -1,46 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * (C) Copyright 2002
- * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
- * Marius Groeger <mgroeger@sysgo.de>
- *
- * (C) Copyright 2002
- * Gary Jennejohn, DENX Software Engineering, <gj@denx.de>
- *
- * Copyright (C) 2011 Andes Technology Corporation
- * Shawn Lin, Andes Technology Corporation <nobuhiro@andestech.com>
- * Macpaul Lin, Andes Technology Corporation <macpaul@andestech.com>
- */
-
-/* CPU specific code */
-#include <common.h>
-#include <command.h>
-#include <cpu_func.h>
-#include <irq_func.h>
-#include <watchdog.h>
-#include <asm/cache.h>
-
-#include <faraday/ftwdt010_wdt.h>
-
-/*
- * cleanup_before_linux() is called just before we call linux
- * it prepares the processor for linux
- *
- * we disable interrupt and caches.
- */
-int cleanup_before_linux(void)
-{
- disable_interrupts();
-
- /* turn off I/D-cache */
- cache_flush();
- icache_disable();
- dcache_disable();
- return 0;
-}
-
-int do_reset(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
-{
- disable_interrupts();
- panic("AE3XX wdt not support yet.\n");
-}
diff --git a/arch/nds32/cpu/n1213/ae3xx/lowlevel_init.S b/arch/nds32/cpu/n1213/ae3xx/lowlevel_init.S
deleted file mode 100644
index d1c5b87f7e9..00000000000
--- a/arch/nds32/cpu/n1213/ae3xx/lowlevel_init.S
+++ /dev/null
@@ -1,147 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * Copyright (C) 2011 Andes Technology Corporation
- * Shawn Lin, Andes Technology Corporation <nobuhiro@andestech.com>
- * Macpaul Lin, Andes Technology Corporation <macpaul@andestech.com>
- */
-
-.pic
-
-.text
-
-#include <common.h>
-#include <config.h>
-
-#include <asm/macro.h>
-#include <generated/asm-offsets.h>
-
-/*
- * parameters for the SDRAM controller
- */
-#define SDMC_TP1_A (CONFIG_FTSDMC021_BASE + FTSDMC021_TP1)
-#define SDMC_TP2_A (CONFIG_FTSDMC021_BASE + FTSDMC021_TP2)
-#define SDMC_CR1_A (CONFIG_FTSDMC021_BASE + FTSDMC021_CR1)
-#define SDMC_CR2_A (CONFIG_FTSDMC021_BASE + FTSDMC021_CR2)
-#define SDMC_B0_BSR_A (CONFIG_FTSDMC021_BASE + FTSDMC021_BANK0_BSR)
-#define SDMC_B1_BSR_A (CONFIG_FTSDMC021_BASE + FTSDMC021_BANK1_BSR)
-
-#define SDMC_TP1_D CONFIG_SYS_FTSDMC021_TP1
-#define SDMC_TP2_D CONFIG_SYS_FTSDMC021_TP2
-#define SDMC_CR1_D CONFIG_SYS_FTSDMC021_CR1
-#define SDMC_CR2_D CONFIG_SYS_FTSDMC021_CR2
-
-#define SDMC_B0_BSR_D CONFIG_SYS_FTSDMC021_BANK0_BSR
-#define SDMC_B1_BSR_D CONFIG_SYS_FTSDMC021_BANK1_BSR
-
-
-/*
- * for Orca and Emerald
- */
-#define BOARD_ID_REG 0x104
-#define BOARD_ID_FAMILY_MASK 0xfff000
-#define BOARD_ID_FAMILY_V5 0x556000
-#define BOARD_ID_FAMILY_K7 0x74b000
-
-/*
- * parameters for the static memory controller
- */
-#define SMC_BANK0_CR_A (CONFIG_FTSMC020_BASE + FTSMC020_BANK0_CR)
-#define SMC_BANK0_TPR_A (CONFIG_FTSMC020_BASE + FTSMC020_BANK0_TPR)
-
-#define SMC_BANK0_CR_D FTSMC020_BANK0_LOWLV_CONFIG
-#define SMC_BANK0_TPR_D FTSMC020_BANK0_LOWLV_TIMING
-
-/*
- * for Orca and Emerald
- */
-#define AHBC_BSR4_A (CONFIG_FTAHBC020S_BASE + FTAHBC020S_SLAVE_BSR_4)
-#define AHBC_BSR6_D CONFIG_SYS_FTAHBC020S_SLAVE_BSR_6
-
-/*
- * parameters for the pmu controoler
- */
-#define PMU_PDLLCR0_A (CONFIG_FTPMU010_BASE + FTPMU010_PDLLCR0)
-
-/*
- * numeric 7 segment display
- */
-.macro led, num
- write32 CONFIG_DEBUG_LED, \num
-.endm
-
-/*
- * Waiting for SDRAM to set up
- */
-.macro wait_sdram
- li $r0, CONFIG_FTSDMC021_BASE
-1:
- lwi $r1, [$r0+FTSDMC021_CR2]
- bnez $r1, 1b
-.endm
-
-.globl mem_init
-mem_init:
- move $r11, $lp
- li $r0, SMC_BANK0_CR_A
- lwi $r1, [$r0+#0x00]
- ori $r1, $r1, 0x8f0
- xori $r1, $r1, 0x8f0
- /* 16-bit mode */
- ori $r1, $r1, 0x60
- li $r2, 0x00153153
- swi $r1, [$r0+#0x00]
- swi $r2, [$r0+#0x04]
- move $lp, $r11
- ret
-
-#if !CONFIG_IS_ENABLED(SKIP_LOWLEVEL_INIT)
-.globl lowlevel_init
-lowlevel_init:
- move $r10, $lp
- jal remap
-
-#if (defined(NDS32_EXT_FPU_DP) || defined(NDS32_EXT_FPU_SP))
- jal enable_fpu
-#endif
- ret $r10
-
-remap:
- move $r11, $lp
-relo_base:
- mfusr $r0, $pc
-
-#ifdef CONFIG_MEM_REMAP
- li $r4, 0x00000000
- li $r5, 0x80000000
- la $r6, _end@GOTOFF
-1:
- lmw.bim $r12, [$r5], $r19
- smw.bim $r12, [$r4], $r19
- blt $r5, $r6, 1b
-#endif /* #ifdef CONFIG_MEM_REMAP */
- move $lp, $r11
-2:
- ret
-
- /*
- * enable_fpu:
- * Some of Andes CPU version support FPU coprocessor, if so,
- * and toolchain support FPU instruction set, we should enable it.
- */
-#if (defined(NDS32_EXT_FPU_DP) || defined(NDS32_EXT_FPU_SP))
-enable_fpu:
- mfsr $r0, $CPU_VER /* enable FPU if it exists */
- srli $r0, $r0, 3
- andi $r0, $r0, 1
- beqz $r0, 1f /* skip if no COP */
- mfsr $r0, $FUCOP_EXIST
- srli $r0, $r0, 31
- beqz $r0, 1f /* skip if no FPU */
- mfsr $r0, $FUCOP_CTL
- ori $r0, $r0, 1
- mtsr $r0, $FUCOP_CTL
-1:
- ret
-#endif
-
-#endif /* #if !CONFIG_IS_ENABLED(SKIP_LOWLEVEL_INIT) */
diff --git a/arch/nds32/cpu/n1213/ae3xx/timer.c b/arch/nds32/cpu/n1213/ae3xx/timer.c
deleted file mode 100644
index 23cc7675fdc..00000000000
--- a/arch/nds32/cpu/n1213/ae3xx/timer.c
+++ /dev/null
@@ -1,15 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * (C) Copyright 2009 Faraday Technology
- * Po-Yu Chuang <ratbert@faraday-tech.com>
- *
- * Copyright (C) 2011 Andes Technology Corporation
- * Shawn Lin, Andes Technology Corporation <nobuhiro@andestech.com>
- * Macpaul Lin, Andes Technology Corporation <macpaul@andestech.com>
- */
-#ifndef CONFIG_TIMER
-#include <common.h>
-#include <asm/io.h>
-#include <faraday/fttmr010.h>
-#error "AE3XX timer only support DM flow"
-#endif /* CONFIG_TIMER */
diff --git a/arch/nds32/cpu/n1213/ae3xx/watchdog.S b/arch/nds32/cpu/n1213/ae3xx/watchdog.S
deleted file mode 100644
index e46bcfbbebe..00000000000
--- a/arch/nds32/cpu/n1213/ae3xx/watchdog.S
+++ /dev/null
@@ -1,16 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * Copyright (C) 2011 Andes Technology Corporation
- * Macpaul Lin, Andes Technology Corporation <macpaul@andestech.com>
- */
-
-#include <asm/arch-ag101/ag101.h>
-#include <linux/linkage.h>
-
-.text
-
-#ifndef CONFIG_SKIP_TRUNOFF_WATCHDOG
-ENTRY(turnoff_watchdog)
-#error "AE3XX not support wdt yet"
-ENDPROC(turnoff_watchdog)
-#endif
diff --git a/arch/nds32/cpu/n1213/ag101/Makefile b/arch/nds32/cpu/n1213/ag101/Makefile
deleted file mode 100644
index 721a9ffafa3..00000000000
--- a/arch/nds32/cpu/n1213/ag101/Makefile
+++ /dev/null
@@ -1,16 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0+
-#
-# (C) Copyright 2009
-# Marvell Semiconductor <www.marvell.com>
-# Written-by: Prafulla Wadaskar <prafulla@marvell.com>
-#
-# Copyright (C) 2011 Andes Technology Corporation
-# Shawn Lin, Andes Technology Corporation <nobuhiro@andestech.com>
-# Macpaul Lin, Andes Technology Corporation <macpaul@andestech.com>
-
-obj-y := cpu.o timer.o
-obj-y += lowlevel_init.o
-
-ifndef CONFIG_SKIP_TRUNOFF_WATCHDOG
-obj-y += watchdog.o
-endif
diff --git a/arch/nds32/cpu/n1213/ag101/cpu.c b/arch/nds32/cpu/n1213/ag101/cpu.c
deleted file mode 100644
index 91c3574bce6..00000000000
--- a/arch/nds32/cpu/n1213/ag101/cpu.c
+++ /dev/null
@@ -1,63 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * (C) Copyright 2002
- * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
- * Marius Groeger <mgroeger@sysgo.de>
- *
- * (C) Copyright 2002
- * Gary Jennejohn, DENX Software Engineering, <gj@denx.de>
- *
- * Copyright (C) 2011 Andes Technology Corporation
- * Shawn Lin, Andes Technology Corporation <nobuhiro@andestech.com>
- * Macpaul Lin, Andes Technology Corporation <macpaul@andestech.com>
- */
-
-/* CPU specific code */
-#include <common.h>
-#include <command.h>
-#include <cpu_func.h>
-#include <irq_func.h>
-#include <watchdog.h>
-#include <asm/cache.h>
-
-#include <faraday/ftwdt010_wdt.h>
-
-/*
- * cleanup_before_linux() is called just before we call linux
- * it prepares the processor for linux
- *
- * we disable interrupt and caches.
- */
-int cleanup_before_linux(void)
-{
- disable_interrupts();
-
- /* turn off I/D-cache */
- cache_flush();
- icache_disable();
- dcache_disable();
- return 0;
-}
-
-int do_reset(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
-{
- disable_interrupts();
-
- /*
- * reset to the base addr of andesboot.
- * currently no ROM loader at addr 0.
- * do not use reset_cpu();
- */
-#ifdef CONFIG_FTWDT010_WATCHDOG
- /*
- * workaround: if we use CONFIG_HW_WATCHDOG with ftwdt010, will lead
- * automatic hardware reset when booting Linux.
- * Please do not use CONFIG_HW_WATCHDOG and WATCHDOG_RESET() here.
- */
- ftwdt010_wdt_reset();
- while (1)
- ;
-#endif /* CONFIG_FTWDT010_WATCHDOG */
-
- /*NOTREACHED*/
-}
diff --git a/arch/nds32/cpu/n1213/ag101/lowlevel_init.S b/arch/nds32/cpu/n1213/ag101/lowlevel_init.S
deleted file mode 100644
index c423b38f896..00000000000
--- a/arch/nds32/cpu/n1213/ag101/lowlevel_init.S
+++ /dev/null
@@ -1,317 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * Copyright (C) 2011 Andes Technology Corporation
- * Shawn Lin, Andes Technology Corporation <nobuhiro@andestech.com>
- * Macpaul Lin, Andes Technology Corporation <macpaul@andestech.com>
- */
-
-.pic
-
-.text
-
-#include <common.h>
-#include <config.h>
-
-#include <asm/macro.h>
-#include <generated/asm-offsets.h>
-
-/*
- * parameters for the SDRAM controller
- */
-#define SDMC_TP1_A (CONFIG_FTSDMC021_BASE + FTSDMC021_TP1)
-#define SDMC_TP2_A (CONFIG_FTSDMC021_BASE + FTSDMC021_TP2)
-#define SDMC_CR1_A (CONFIG_FTSDMC021_BASE + FTSDMC021_CR1)
-#define SDMC_CR2_A (CONFIG_FTSDMC021_BASE + FTSDMC021_CR2)
-#define SDMC_B0_BSR_A (CONFIG_FTSDMC021_BASE + FTSDMC021_BANK0_BSR)
-#define SDMC_B1_BSR_A (CONFIG_FTSDMC021_BASE + FTSDMC021_BANK1_BSR)
-
-#define SDMC_TP1_D CONFIG_SYS_FTSDMC021_TP1
-#define SDMC_TP2_D CONFIG_SYS_FTSDMC021_TP2
-#define SDMC_CR1_D CONFIG_SYS_FTSDMC021_CR1
-#define SDMC_CR2_D CONFIG_SYS_FTSDMC021_CR2
-
-#define SDMC_B0_BSR_D CONFIG_SYS_FTSDMC021_BANK0_BSR
-#define SDMC_B1_BSR_D CONFIG_SYS_FTSDMC021_BANK1_BSR
-
-
-/*
- * for Orca and Emerald
- */
-#define BOARD_ID_REG 0x104
-#define BOARD_ID_FAMILY_MASK 0xfff000
-#define BOARD_ID_FAMILY_V5 0x556000
-#define BOARD_ID_FAMILY_K7 0x74b000
-
-/*
- * parameters for the static memory controller
- */
-#define SMC_BANK0_CR_A (CONFIG_FTSMC020_BASE + FTSMC020_BANK0_CR)
-#define SMC_BANK0_TPR_A (CONFIG_FTSMC020_BASE + FTSMC020_BANK0_TPR)
-
-#define SMC_BANK0_CR_D FTSMC020_BANK0_LOWLV_CONFIG
-#define SMC_BANK0_TPR_D FTSMC020_BANK0_LOWLV_TIMING
-
-/*
- * parameters for the ahbc controller
- */
-#define AHBC_CR_A (CONFIG_FTAHBC020S_BASE + FTAHBC020S_CR)
-#define AHBC_BSR6_A (CONFIG_FTAHBC020S_BASE + FTAHBC020S_SLAVE_BSR_6)
-
-/*
- * for Orca and Emerald
- */
-#define AHBC_BSR4_A (CONFIG_FTAHBC020S_BASE + FTAHBC020S_SLAVE_BSR_4)
-#define AHBC_BSR6_D CONFIG_SYS_FTAHBC020S_SLAVE_BSR_6
-
-/*
- * parameters for the pmu controoler
- */
-#define PMU_PDLLCR0_A (CONFIG_FTPMU010_BASE + FTPMU010_PDLLCR0)
-
-/*
- * numeric 7 segment display
- */
-.macro led, num
- write32 CONFIG_DEBUG_LED, \num
-.endm
-
-/*
- * Waiting for SDRAM to set up
- */
-.macro wait_sdram
- li $r0, CONFIG_FTSDMC021_BASE
-1:
- lwi $r1, [$r0+FTSDMC021_CR2]
- bnez $r1, 1b
-.endm
-
-.globl mem_init
-mem_init:
- move $r11, $lp
-
- /*
- * mem_init:
- * There are 2 bank connected to FTSMC020 on AG101
- * BANK0: FLASH/ROM (SW5, J16), BANK1: OnBoard SDRAM.
- * we need to set onboard SDRAM before remap and relocation.
- */
- led 0x01
-
- /*
- * for Orca and Emerald
- * disable write protection and reset bank size
- */
- li $r0, SMC_BANK0_CR_A
- lwi $r1, [$r0+#0x00]
- ori $r1, $r1, 0x8f0
- xori $r1, $r1, 0x8f0
- /* check board */
- li $r3, CONFIG_FTPMU010_BASE + BOARD_ID_REG
- lwi $r3, [$r3]
- li $r4, BOARD_ID_FAMILY_MASK
- and $r3, $r3, $r4
- li $r4, BOARD_ID_FAMILY_K7
- xor $r4, $r3, $r4
- beqz $r4, use_flash_16bit_boot
- /* 32-bit mode */
-use_flash_32bit_boot:
- ori $r1, $r1, 0x50
- li $r2, 0x00151151
- j sdram_b0_cr
- /* 16-bit mode */
-use_flash_16bit_boot:
- ori $r1, $r1, 0x60
- li $r2, 0x00153153
- /* SRAM bank0 config */
-sdram_b0_cr:
- swi $r1, [$r0+#0x00]
- swi $r2, [$r0+#0x04]
-
- /* config AHB Controller */
- led 0x02
-
- /*
- * config PMU controller
- */
- /* ftpmu010_dlldis_disable, must do it in lowleve_init */
- led 0x03
- setbf32 PMU_PDLLCR0_A, FTPMU010_PDLLCR0_DLLDIS ! 0x00010000
-
- /*
- * config SDRAM controller
- */
- led 0x04
- write32 SDMC_TP1_A, SDMC_TP1_D ! 0x00011312
- led 0x05
- write32 SDMC_TP2_A, SDMC_TP2_D ! 0x00480180
- led 0x06
- write32 SDMC_CR1_A, SDMC_CR1_D ! 0x00002326
-
- led 0x07
- write32 SDMC_CR2_A, FTSDMC021_CR2_IPREC ! 0x00000010
- wait_sdram
-
- led 0x08
- write32 SDMC_CR2_A, FTSDMC021_CR2_ISMR ! 0x00000004
- wait_sdram
-
- led 0x09
- write32 SDMC_CR2_A, FTSDMC021_CR2_IREF ! 0x00000008
- wait_sdram
-
- led 0x0a
- move $lp, $r11
- ret
-
-
-#if !CONFIG_IS_ENABLED(SKIP_LOWLEVEL_INIT)
-
-.globl lowlevel_init
-lowlevel_init:
- move $r10, $lp
- led 0x10
- jal remap
-#if (defined(NDS32_EXT_FPU_DP) || defined(NDS32_EXT_FPU_SP))
- led 0x1f
- jal enable_fpu
-#endif
- led 0x20
- ret $r10
-
-remap:
- move $r11, $lp
-#ifdef __NDS32_N1213_43U1H__ /* NDS32 V0 ISA - AG101 Only */
- bal 2f
-relo_base:
- move $r0, $lp
-#else
-relo_base:
- mfusr $r0, $pc
-#endif /* __NDS32_N1213_43U1H__ */
-
- /* Remapping */
- led 0x1a
- write32 SDMC_B0_BSR_A, SDMC_B0_BSR_D ! 0x00001800
- write32 SDMC_B1_BSR_A, SDMC_B1_BSR_D ! 0x00001880
-
- /* clear empty BSR registers */
- led 0x1b
- li $r4, CONFIG_FTSDMC021_BASE
- li $r5, 0x0
- swi $r5, [$r4 + FTSDMC021_BANK2_BSR]
- swi $r5, [$r4 + FTSDMC021_BANK3_BSR]
-
-#ifdef CONFIG_MEM_REMAP
- /*
- * Copy ROM code to SDRAM base for memory remap layout.
- * This is not the real relocation, the real relocation is the function
- * relocate_code() is start.S which supports the systems is memory
- * remapped or not.
- */
- /*
- * Doing memory remap is essential for preparing some non-OS or RTOS
- * applications.
- *
- * This is also a must on ADP-AG101 board.
- * The reason is because the ROM/FLASH circuit on PCB board.
- * AG101-A0 board has 2 jumpers MA17 and SW5 to configure which
- * ROM/FLASH is used to boot.
- *
- * When SW5 = "0101", MA17 = LO, the ROM is connected to BANK0,
- * and the FLASH is connected to BANK1.
- * When SW5 = "1010", MA17 = HI, the ROM is disabled (still at BANK0),
- * and the FLASH is connected to BANK0.
- * It will occur problem when doing flash probing if the flash is at
- * BANK0 (0x00000000) while memory remapping was skipped.
- *
- * Other board like ADP-AG101P may not enable this since there is only
- * a FLASH connected to bank0.
- */
- led 0x11
- /*
- * for Orca and Emerald
- * read sdram base address automatically
- */
- li $r5, AHBC_BSR6_A
- lwi $r8, [$r5]
- li $r4, 0xfff00000 /* r4 = bank6 base */
- and $r4, $r4, $r8
-
- la $r5, _start@GOTOFF
- la $r6, _end@GOTOFF
-1:
- lwi.p $r7, [$r5], #4
- swi.p $r7, [$r4], #4
- blt $r5, $r6, 1b
-
- /* set remap bit */
- /*
- * MEM remap bit is operational
- * - use it to map writeable memory at 0x00000000, in place of flash
- * - before remap: flash/rom 0x00000000, sdram: 0x10000000-0x4fffffff
- * - after remap: flash/rom 0x80000000, sdram: 0x00000000
- */
- led 0x1c
- write32 SDMC_B0_BSR_A, 0x00001000
- write32 SDMC_B1_BSR_A, 0x00001200
- li $r5, CONFIG_SYS_TEXT_BASE /* flash base address */
- add $r11, $r11, $r5 /* add flash address offset for ret */
- add $r10, $r10, $r5
- move $lp, $r11
- setbf15 AHBC_CR_A, FTAHBC020S_CR_REMAP ! 0x1
-
- /*
- * for Orca and Emerald
- * extend sdram size from 256MB to 2GB
- */
- li $r5, AHBC_BSR6_A
- lwi $r6, [$r5]
- li $r4, 0xfff0ffff
- and $r6 ,$r4, $r6
- li $r4, 0x000b0000
- or $r6, $r4, $r6
- swi $r6, [$r5]
-
- /*
- * for Orca and Emerald
- * extend rom base from 256MB to 2GB
- */
- li $r4, AHBC_BSR4_A
- lwi $r5, [$r4]
- li $r6, 0xffffff
- and $r5, $r5, $r6
- li $r6, 0x80000000
- or $r5, $r5, $r6
- swi $r5, [$r4]
-#endif /* #ifdef CONFIG_MEM_REMAP */
- move $lp, $r11
-2:
- ret
-
- /*
- * enable_fpu:
- * Some of Andes CPU version support FPU coprocessor, if so,
- * and toolchain support FPU instruction set, we should enable it.
- */
-#if (defined(NDS32_EXT_FPU_DP) || defined(NDS32_EXT_FPU_SP))
-enable_fpu:
- mfsr $r0, $CPU_VER /* enable FPU if it exists */
- srli $r0, $r0, 3
- andi $r0, $r0, 1
- beqz $r0, 1f /* skip if no COP */
- mfsr $r0, $FUCOP_EXIST
- srli $r0, $r0, 31
- beqz $r0, 1f /* skip if no FPU */
- mfsr $r0, $FUCOP_CTL
- ori $r0, $r0, 1
- mtsr $r0, $FUCOP_CTL
-1:
- ret
-#endif
-
-.globl show_led
-show_led:
- li $r8, (CONFIG_DEBUG_LED)
- swi $r7, [$r8]
- ret
-#endif /* #if !CONFIG_IS_ENABLED(SKIP_LOWLEVEL_INIT) */
diff --git a/arch/nds32/cpu/n1213/ag101/timer.c b/arch/nds32/cpu/n1213/ag101/timer.c
deleted file mode 100644
index f6dcbf199c7..00000000000
--- a/arch/nds32/cpu/n1213/ag101/timer.c
+++ /dev/null
@@ -1,197 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * (C) Copyright 2009 Faraday Technology
- * Po-Yu Chuang <ratbert@faraday-tech.com>
- *
- * Copyright (C) 2011 Andes Technology Corporation
- * Shawn Lin, Andes Technology Corporation <nobuhiro@andestech.com>
- * Macpaul Lin, Andes Technology Corporation <macpaul@andestech.com>
- */
-#ifndef CONFIG_TIMER
-#include <common.h>
-#include <clock_legacy.h>
-#include <init.h>
-#include <irq_func.h>
-#include <log.h>
-#include <time.h>
-#include <asm/io.h>
-#include <faraday/fttmr010.h>
-#include <linux/delay.h>
-
-static ulong timestamp;
-static ulong lastdec;
-
-int timer_init(void)
-{
- struct fttmr010 *tmr = (struct fttmr010 *)CONFIG_FTTMR010_BASE;
- unsigned int cr;
-
- debug("%s()\n", __func__);
-
- /* disable timers */
- writel(0, &tmr->cr);
-
-#ifdef CONFIG_FTTMR010_EXT_CLK
- /* use 32768Hz oscillator for RTC, WDT, TIMER */
- ftpmu010_32768osc_enable();
-#endif
-
- /* setup timer */
- writel(TIMER_LOAD_VAL, &tmr->timer3_load);
- writel(TIMER_LOAD_VAL, &tmr->timer3_counter);
- writel(0, &tmr->timer3_match1);
- writel(0, &tmr->timer3_match2);
-
- /* we don't want timer to issue interrupts */
- writel(FTTMR010_TM3_MATCH1 |
- FTTMR010_TM3_MATCH2 |
- FTTMR010_TM3_OVERFLOW,
- &tmr->interrupt_mask);
-
- cr = readl(&tmr->cr);
-#ifdef CONFIG_FTTMR010_EXT_CLK
- cr |= FTTMR010_TM3_CLOCK; /* use external clock */
-#endif
- cr |= FTTMR010_TM3_ENABLE;
- writel(cr, &tmr->cr);
-
- /* init the timestamp and lastdec value */
- reset_timer_masked();
-
- return 0;
-}
-
-/*
- * timer without interrupts
- */
-
-/*
- * reset time
- */
-void reset_timer_masked(void)
-{
- struct fttmr010 *tmr = (struct fttmr010 *)CONFIG_FTTMR010_BASE;
-
- /* capure current decrementer value time */
-#ifdef CONFIG_FTTMR010_EXT_CLK
- lastdec = readl(&tmr->timer3_counter) / (TIMER_CLOCK / CONFIG_SYS_HZ);
-#else
- lastdec = readl(&tmr->timer3_counter) /
- (get_board_sys_clk() / 2 / CONFIG_SYS_HZ);
-#endif
- timestamp = 0; /* start "advancing" time stamp from 0 */
-
- debug("%s(): lastdec = %lx\n", __func__, lastdec);
-}
-
-void reset_timer(void)
-{
- debug("%s()\n", __func__);
- reset_timer_masked();
-}
-
-/*
- * return timer ticks
- */
-ulong get_timer_masked(void)
-{
- struct fttmr010 *tmr = (struct fttmr010 *)CONFIG_FTTMR010_BASE;
-
- /* current tick value */
-#ifdef CONFIG_FTTMR010_EXT_CLK
- ulong now = readl(&tmr->timer3_counter) / (TIMER_CLOCK / CONFIG_SYS_HZ);
-#else
- ulong now = readl(&tmr->timer3_counter) /
- (get_board_sys_clk() / 2 / CONFIG_SYS_HZ);
-#endif
-
- debug("%s(): now = %lx, lastdec = %lx\n", __func__, now, lastdec);
-
- if (lastdec >= now) {
- /*
- * normal mode (non roll)
- * move stamp fordward with absoulte diff ticks
- */
- timestamp += lastdec - now;
- } else {
- /*
- * we have overflow of the count down timer
- *
- * nts = ts + ld + (TLV - now)
- * ts=old stamp, ld=time that passed before passing through -1
- * (TLV-now) amount of time after passing though -1
- * nts = new "advancing time stamp"...it could also roll and
- * cause problems.
- */
- timestamp += lastdec + TIMER_LOAD_VAL - now;
- }
-
- lastdec = now;
-
- debug("%s() returns %lx\n", __func__, timestamp);
-
- return timestamp;
-}
-
-/*
- * return difference between timer ticks and base
- */
-ulong get_timer(ulong base)
-{
- debug("%s(%lx)\n", __func__, base);
- return get_timer_masked() - base;
-}
-
-void set_timer(ulong t)
-{
- debug("%s(%lx)\n", __func__, t);
- timestamp = t;
-}
-
-/* delay x useconds AND preserve advance timestamp value */
-void __udelay(unsigned long usec)
-{
- struct fttmr010 *tmr = (struct fttmr010 *)CONFIG_FTTMR010_BASE;
-
-#ifdef CONFIG_FTTMR010_EXT_CLK
- long tmo = usec * (TIMER_CLOCK / 1000) / 1000;
-#else
- long tmo = usec * ((get_board_sys_clk() / 2) / 1000) / 1000;
-#endif
- unsigned long now, last = readl(&tmr->timer3_counter);
-
- debug("%s(%lu)\n", __func__, usec);
- while (tmo > 0) {
- now = readl(&tmr->timer3_counter);
- if (now > last) /* count down timer overflow */
- tmo -= TIMER_LOAD_VAL + last - now;
- else
- tmo -= last - now;
- last = now;
- }
-}
-
-/*
- * This function is derived from PowerPC code (read timebase as long long).
- * On ARM it just returns the timer value.
- */
-unsigned long long get_ticks(void)
-{
- debug("%s()\n", __func__);
- return get_timer(0);
-}
-
-/*
- * This function is derived from PowerPC code (timebase clock frequency).
- * On ARM it returns the number of timer ticks per second.
- */
-ulong get_tbclk(void)
-{
- debug("%s()\n", __func__);
-#ifdef CONFIG_FTTMR010_EXT_CLK
- return CONFIG_SYS_HZ;
-#else
- return get_board_sys_clk();
-#endif
-}
-#endif /* CONFIG_TIMER */
diff --git a/arch/nds32/cpu/n1213/ag101/watchdog.S b/arch/nds32/cpu/n1213/ag101/watchdog.S
deleted file mode 100644
index 8e7399d0df7..00000000000
--- a/arch/nds32/cpu/n1213/ag101/watchdog.S
+++ /dev/null
@@ -1,32 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * Copyright (C) 2011 Andes Technology Corporation
- * Macpaul Lin, Andes Technology Corporation <macpaul@andestech.com>
- */
-
-#include <asm/arch-ag101/ag101.h>
-#include <linux/linkage.h>
-
-.text
-
-#ifndef CONFIG_SKIP_TRUNOFF_WATCHDOG
-ENTRY(turnoff_watchdog)
-
-#define WD_CR 0xC
-#define WD_ENABLE 0x1
-
- ! Turn off the watchdog, according to Faraday FTWDT010 spec
- li $p0, (CONFIG_FTWDT010_BASE+WD_CR) ! Get the addr of WD CR
- lwi $p1, [$p0] ! Get the config of WD
- andi $p1, $p1, 0x1f ! Wipe out useless bits
- li $r0, ~WD_ENABLE
- and $p1, $p1, $r0 ! Set WD disable
- sw $p1, [$p0] ! Write back to WD CR
-
- ! Disable Interrupts by clear GIE in $PSW reg
- setgie.d
-
- ret
-
-ENDPROC(turnoff_watchdog)
-#endif
diff --git a/arch/nds32/cpu/n1213/start.S b/arch/nds32/cpu/n1213/start.S
deleted file mode 100644
index 93ea5e4ad48..00000000000
--- a/arch/nds32/cpu/n1213/start.S
+++ /dev/null
@@ -1,502 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * Andesboot - Startup Code for Whitiger core
- *
- * Copyright (C) 2006 Andes Technology Corporation
- * Copyright (C) 2006 Shawn Lin <nobuhiro@andestech.com>
- * Copyright (C) 2011 Macpaul Lin <macpaul@andestech.com>
- * Greentime Hu <greentime@andestech.com>
- */
-
-.pic
-
-#include <asm-offsets.h>
-#include <config.h>
-#include <common.h>
-#include <asm/macro.h>
-
-/*
- * Jump vector table for EVIC mode
- */
-#define ENA_DCAC 2UL
-#define DIS_DCAC ~ENA_DCAC
-#define ICAC_MEM_KBF_ISET (0x07) ! I Cache sets per way
-#define ICAC_MEM_KBF_IWAY (0x07<<3) ! I cache ways
-#define ICAC_MEM_KBF_ISZ (0x07<<6) ! I cache line size
-#define DCAC_MEM_KBF_DSET (0x07) ! D Cache sets per way
-#define DCAC_MEM_KBF_DWAY (0x07<<3) ! D cache ways
-#define DCAC_MEM_KBF_DSZ (0x07<<6) ! D cache line size
-
-#define PSW $ir0
-#define EIT_INTR_PSW $ir1 ! interruption $PSW
-#define EIT_PREV_IPSW $ir2 ! previous $IPSW
-#define EIT_IVB $ir3 ! intr vector base address
-#define EIT_EVA $ir4 ! MMU related Exception VA reg
-#define EIT_PREV_EVA $ir5 ! previous $eva
-#define EIT_ITYPE $ir6 ! interruption type
-#define EIT_PREV_ITYPE $ir7 ! prev intr type
-#define EIT_MACH_ERR $ir8 ! machine error log
-#define EIT_INTR_PC $ir9 ! Interruption PC
-#define EIT_PREV_IPC $ir10 ! previous $IPC
-#define EIT_OVL_INTR_PC $ir11 ! overflow interruption PC
-#define EIT_PREV_P0 $ir12 ! prev $P0
-#define EIT_PREV_P1 $ir13 ! prev $p1
-#define CR_ICAC_MEM $cr1 ! I-cache/memory config reg
-#define CR_DCAC_MEM $cr2 ! D-cache/memory config reg
-#define MR_CAC_CTL $mr8
-
-.globl _start
-
-_start: j reset
- j tlb_fill
- j tlb_not_present
- j tlb_misc
- j tlb_vlpt_miss
- j machine_error
- j debug
- j general_exception
- j syscall
- j internal_interrupt ! H0I
- j internal_interrupt ! H1I
- j internal_interrupt ! H2I
- j internal_interrupt ! H3I
- j internal_interrupt ! H4I
- j internal_interrupt ! H5I
- j software_interrupt ! S0I
-
- .balign 16
-
-/*
- * Andesboot Startup Code (reset vector)
- *
- * 1. bootstrap
- * 1.1 reset - start of u-boot
- * 1.2 to superuser mode - as is when reset
- * 1.4 Do lowlevel_init
- * - (this will jump out to lowlevel_init.S in SoC)
- * - (lowlevel_init)
- * 1.3 Turn off watchdog timer
- * - (this will jump out to watchdog.S in SoC)
- * - (turnoff_watchdog)
- * 2. Do critical init when reboot (not from mem)
- * 3. Relocate andesboot to ram
- * 4. Setup stack
- * 5. Jump to second stage (board_init_r)
- */
-
-/* Note: TEXT_BASE is defined by the (board-dependent) linker script */
-.globl _TEXT_BASE
-_TEXT_BASE:
- .word CONFIG_SYS_TEXT_BASE
-
-/* IRQ stack memory (calculated at run-time) + 8 bytes */
-.globl IRQ_STACK_START_IN
-IRQ_STACK_START_IN:
- .word 0x0badc0de
-
-/*
- * The bootstrap code of nds32 core
- */
-
-reset:
-
-/*
- * gp = ~0 for burn mode
- * = ~load_address for load mode
- */
-reset_gp:
- .relax_hint 0
- sethi $gp, hi20(_GLOBAL_OFFSET_TABLE_-8)
- .relax_hint 0
- ori $gp, $gp, lo12(_GLOBAL_OFFSET_TABLE_-4)
- add5.pc $gp
-
-set_ivb:
- li $r0, 0x0
- /* turn on BTB */
- mtsr $r0, $misc_ctl
- /* set IVIC, vector size: 4 bytes, base: 0x0 */
- mtsr $r0, $ivb
-/*
- * MMU_CTL NTC0 Non-cacheable
- */
- li $r0, ~0x6
- mfsr $r1, $mr0
- and $r1, $r1, $r0
- mtsr $r1, $mr0
-
- li $r0, ~0x3
- mfsr $r1, $mr8
- and $r1, $r1, $r0
- mtsr $r1, $mr8
-#if !(CONFIG_IS_ENABLED(SYS_ICACHE_OFF) && CONFIG_IS_ENABLED(SYS_DCACHE_OFF))
-/*
- * MMU_CTL NTC0 Cacheable/Write-Back
- */
- li $r0, 0x4
- mfsr $r1, $mr0
- or $r1, $r1, $r0
- mtsr $r1, $mr0
-#endif
-
-#if !CONFIG_IS_ENABLED(SYS_DCACHE_OFF)
-#ifdef CONFIG_ARCH_MAP_SYSMEM
-/*
- * MMU_CTL NTC1 Non-cacheable
- */
- li $r0, ~0x18
- mfsr $r1, $mr0
- and $r1, $r1, $r0
- mtsr $r1, $mr0
-/*
- * MMU_CTL NTM1 mapping for partition 0
- */
- li $r0, ~0x6000
- mfsr $r1, $mr0
- and $r1, $r1, $r0
- mtsr $r1, $mr0
-#endif
-#endif
-
-#if !CONFIG_IS_ENABLED(SYS_ICACHE_OFF)
- li $r0, 0x1
- mfsr $r1, $mr8
- or $r1, $r1, $r0
- mtsr $r1, $mr8
-#endif
-
-#if !CONFIG_IS_ENABLED(SYS_DCACHE_OFF)
- li $r0, 0x2
- mfsr $r1, $mr8
- or $r1, $r1, $r0
- mtsr $r1, $mr8
-#endif
-
- jal mem_init
-
-#if !CONFIG_IS_ENABLED(SKIP_LOWLEVEL_INIT)
- jal lowlevel_init
-/*
- * gp = ~VMA for burn mode
- * = ~load_address for load mode
- */
-update_gp:
- .relax_hint 0
- sethi $gp, hi20(_GLOBAL_OFFSET_TABLE_-8)
- .relax_hint 0
- ori $gp, $gp, lo12(_GLOBAL_OFFSET_TABLE_-4)
- add5.pc $gp
-#endif
-/*
- * do critical initializations first (shall be in short time)
- * do self_relocation ASAP.
- */
-
-/*
- * Set the N1213 (Whitiger) core to superuser mode
- * According to spec, it is already when reset
- */
-#ifndef CONFIG_SKIP_TRUNOFF_WATCHDOG
- jal turnoff_watchdog
-#endif
-
-/*
- * Set stackpointer in internal RAM to call board_init_f
- * $sp must be 8-byte alignment for ABI compliance.
- */
-call_board_init_f:
- li $sp, CONFIG_SYS_INIT_SP_ADDR
- move $r0, $sp
- bal board_init_f_alloc_reserve
- move $sp, $r0
- bal board_init_f_init_reserve
-#ifdef CONFIG_DEBUG_UART
- bal debug_uart_init
-#endif
- li $r0, 0x00000000
-#ifdef __PIC__
-#ifdef __NDS32_N1213_43U1H__
-/* __NDS32_N1213_43U1H__ implies NDS32 V0 ISA */
- la $r15, board_init_f ! store function address into $r15
-#endif
-#endif
- j board_init_f ! jump to board_init_f() in lib/board.c
-
-/*
- * void relocate_code(addr_sp, gd, addr_moni)
- *
- * This "function" does not return, instead it continues in RAM
- * after relocating the monitor code.
- *
- */
-
-/*
- * gp = ~RAM_SIZE - TEXT_SIZE for burn/load mode
- */
-
-.globl relocate_code
-relocate_code:
- move $r4, $r0 /* save addr_sp */
- move $r5, $r1 /* save addr of gd */
- move $r6, $r2 /* save addr of destination */
-
-/* Set up the stack */
-stack_setup:
- move $sp, $r4
-
- la $r0, _start@GOTOFF
- beq $r0, $r6, clear_bss /* skip relocation */
-
- la $r1, _end@GOTOFF
- move $r2, $r6 /* r2 <- scratch for copy_loop */
-copy_loop:
- lmw.bim $r11, [$r0], $r18
- smw.bim $r11, [$r2], $r18
- blt $r0, $r1, copy_loop
-/*
- * fix relocations related issues
- */
-fix_relocations:
- l.w $r0, _TEXT_BASE@GOTOFF /* r0 <- Text base */
- sub $r9, $r6, $r0 /* r9 <- relocation offset */
-
- la $r7, __rel_dyn_start@GOTOFF
- add $r7, $r7, $r9 /* r2 <- rel __got_start in RAM */
- la $r8, __rel_dyn_end@GOTOFF
- add $r8, $r8, $r9 /* r2 <- rel __got_start in RAM */
- li $r3, #0x2a /* R_NDS32_RELATIVE */
-1:
- lmw.bim $r0, [$r7], $r2 /* r0,r1,r2 <- adr,type,addend */
- bne $r1, $r3, 2f
-
- add $r0, $r0, $r9
- add $r2, $r2, $r9
- sw $r2, [$r0]
-2:
- blt $r7, $r8, 1b
-
-clear_bss:
- la $r0, __bss_start@GOTOFF /* r0 <- rel __bss_start in FLASH */
- add $r0, $r0, $r9 /* r0 <- rel __bss_start in FLASH */
- la $r1, __bss_end@GOTOFF /* r1 <- rel __bss_end in RAM */
- add $r1, $r1, $r9 /* r0 <- rel __bss_end in RAM */
- li $r2, 0x00000000 /* clear */
-
-clbss_l:
- sw $r2, [$r0] /* clear loop... */
- addi $r0, $r0, #4
- bne $r0, $r1, clbss_l
-
-/*
- * We are done. Do not return, instead branch to second part of board
- * initialization, now running from RAM.
- */
-call_board_init_r:
- bal invalidate_icache_all
- bal flush_dcache_all
- la $r0, board_init_r@GOTOFF
- move $lp, $r0 /* offset of board_init_r() */
- add $lp, $lp, $r9 /* real address of board_init_r() */
- /* setup parameters for board_init_r */
- move $r0, $r5 /* gd_t */
- move $r1, $r6 /* dest_addr */
-
-#ifdef __PIC__
-#ifdef __NDS32_N1213_43U1H__ /* NDS32 V0 ISA */
- move $r15, $lp /* store function address into $r15 */
-#endif
-#endif
-
- /* jump to it ... */
- jr $lp /* jump to board_init_r() */
-
-/*
- * Invalidate I$
- */
-invalidate_icac:
- ! read $cr1(I CAC/MEM cfg. reg.) configuration
- mfsr $t0, CR_ICAC_MEM
-
- ! Get the ISZ field
- andi $p0, $t0, ICAC_MEM_KBF_ISZ
-
- ! if $p0=0, then no I CAC existed
- beqz $p0, end_flush_icache
-
- ! get $p0 the index of I$ block
- srli $p0, $p0, 6
-
- ! $t1= bit width of I cache line size(ISZ)
- addi $t1, $p0, 2
-
- li $t4, 1
- sll $t5, $t4, $t1 ! get $t5 cache line size
- andi $p1, $t0, ICAC_MEM_KBF_ISET ! get the ISET field
- addi $t2, $p1, 6 ! $t2= bit width of ISET
- andi $p1, $t0, ICAC_MEM_KBF_IWAY ! get bitfield of Iway
- srli $p1, $p1, 3
- addi $p1, $p1, 1 ! then $p1 is I way number
- add $t3, $t2, $t1 ! SHIFT
- sll $p1, $p1, $t3 ! GET the total cache size
-ICAC_LOOP:
- sub $p1, $p1, $t5
- cctl $p1, L1I_IX_INVAL
- bnez $p1, ICAC_LOOP
-end_flush_icache:
- ret
-
-/*
- * Invalidate D$
- */
-invalidate_dcac:
- ! read $cr2(D CAC/MEM cfg. reg.) configuration
- mfsr $t0, CR_DCAC_MEM
-
- ! Get the DSZ field
- andi $p0, $t0, DCAC_MEM_KBF_DSZ
-
- ! if $p0=0, then no D CAC existed
- beqz $p0, end_flush_dcache
-
- ! get $p0 the index of D$ block
- srli $p0, $p0, 6
-
- ! $t1= bit width of D cache line size(DSZ)
- addi $t1, $p0, 2
-
- li $t4, 1
- sll $t5, $t4, $t1 ! get $t5 cache line size
- andi $p1, $t0, DCAC_MEM_KBF_DSET ! get the DSET field
- addi $t2, $p1, 6 ! $t2= bit width of DSET
- andi $p1, $t0, DCAC_MEM_KBF_DWAY ! get bitfield of D way
- srli $p1, $p1, 3
- addi $p1, $p1, 1 ! then $p1 is D way number
- add $t3, $t2, $t1 ! SHIFT
- sll $p1, $p1, $t3 ! GET the total cache size
-DCAC_LOOP:
- sub $p1, $p1, $t5
- cctl $p1, L1D_IX_INVAL
- bnez $p1, DCAC_LOOP
-end_flush_dcache:
- ret
-
-/*
- * Interrupt handling
- */
-
-/*
- * exception handlers
- */
- .align 5
-
-.macro SAVE_ALL
- ! FIXME: Other way to get PC?
- ! FIXME: Update according to the newest spec!!
-1:
- li $r28, 1
- push $r28
- mfsr $r28, PSW ! $PSW
- push $r28
- mfsr $r28, EIT_EVA ! $ir1 $EVA
- push $r28
- mfsr $r28, EIT_ITYPE ! $ir2 $ITYPE
- push $r28
- mfsr $r28, EIT_MACH_ERR ! $ir3 Mach Error
- push $r28
- mfsr $r28, EIT_INTR_PSW ! $ir5 $IPSW
- push $r28
- mfsr $r28, EIT_PREV_IPSW ! $ir6 prev $IPSW
- push $r28
- mfsr $r28, EIT_PREV_EVA ! $ir7 prev $EVA
- push $r28
- mfsr $r28, EIT_PREV_ITYPE ! $ir8 prev $ITYPE
- push $r28
- mfsr $r28, EIT_INTR_PC ! $ir9 Interruption PC
- push $r28
- mfsr $r28, EIT_PREV_IPC ! $ir10 prev INTR_PC
- push $r28
- mfsr $r28, EIT_OVL_INTR_PC ! $ir11 Overflowed INTR_PC
- push $r28
- mfusr $r28, $d1.lo
- push $r28
- mfusr $r28, $d1.hi
- push $r28
- mfusr $r28, $d0.lo
- push $r28
- mfusr $r28, $d0.hi
- push $r28
- pushm $r0, $r30 ! store $sp-$r31, ra-$r30, $gp-$r29, $r28-$fp
- addi $sp, $sp, -4 ! make room for implicit pt_regs parameters
-.endm
-
- .align 5
-tlb_fill:
- SAVE_ALL
- move $r0, $sp ! To get the kernel stack
- li $r1, 1 ! Determine interruption type
- bal do_interruption
-
- .align 5
-tlb_not_present:
- SAVE_ALL
- move $r0, $sp ! To get the kernel stack
- li $r1, 2 ! Determine interruption type
- bal do_interruption
-
- .align 5
-tlb_misc:
- SAVE_ALL
- move $r0, $sp ! To get the kernel stack
- li $r1, 3 ! Determine interruption type
- bal do_interruption
-
- .align 5
-tlb_vlpt_miss:
- SAVE_ALL
- move $r0, $sp ! To get the kernel stack
- li $r1, 4 ! Determine interruption type
- bal do_interruption
-
- .align 5
-machine_error:
- SAVE_ALL
- move $r0, $sp ! To get the kernel stack
- li $r1, 5 ! Determine interruption type
- bal do_interruption
-
- .align 5
-debug:
- SAVE_ALL
- move $r0, $sp ! To get the kernel stack
- li $r1, 6 ! Determine interruption type
- bal do_interruption
-
- .align 5
-general_exception:
- SAVE_ALL
- move $r0, $sp ! To get the kernel stack
- li $r1, 7 ! Determine interruption type
- bal do_interruption
-
- .align 5
-syscall:
- SAVE_ALL
- move $r0, $sp ! To get the kernel stack
- li $r1, 8 ! Determine interruption type
- bal do_interruption
-
- .align 5
-internal_interrupt:
- SAVE_ALL
- move $r0, $sp ! To get the kernel stack
- li $r1, 9 ! Determine interruption type
- bal do_interruption
-
- .align 5
-software_interrupt:
- SAVE_ALL
- move $r0, $sp ! To get the kernel stack
- li $r1, 10 ! Determine interruption type
- bal do_interruption
-
- .align 5
diff --git a/arch/nds32/cpu/n1213/u-boot.lds b/arch/nds32/cpu/n1213/u-boot.lds
deleted file mode 100644
index 4abaf0af1a8..00000000000
--- a/arch/nds32/cpu/n1213/u-boot.lds
+++ /dev/null
@@ -1,58 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * (C) Copyright 2000
- * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
- *
- * Copyright (C) 2011 Andes Technology Corporation
- * Shawn Lin, Andes Technology Corporation <nobuhiro@andestech.com>
- * Macpaul Lin, Andes Technology Corporation <macpaul@andestech.com>
- */
-
-OUTPUT_FORMAT("elf32-nds32", "elf32-nds32", "elf32-nds32")
-OUTPUT_ARCH(nds32)
-ENTRY(_start)
-SECTIONS
-{
- . = ALIGN(4);
- .text :
- {
- arch/nds32/cpu/n1213/start.o (.text)
- *(.text)
- }
-
- . = ALIGN(4);
- .rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
-
- . = ALIGN(4);
- .data : { *(.data*) }
-
- . = ALIGN(4);
-
- .got : {
- __got_start = .;
- *(.got.plt) *(.got)
- __got_end = .;
- }
-
- . = ALIGN(4);
- .u_boot_list : {
- KEEP(*(SORT(.u_boot_list*)));
- }
-
- . = ALIGN(4);
- /DISCARD/ : { *(.rela.plt*) }
- .rela.dyn : {
- __rel_dyn_start = .;
- *(.rela*)
- __rel_dyn_end = .;
- }
- _end = .;
-
- .bss : {
- __bss_start = .;
- *(.bss)
- . = ALIGN(4);
- __bss_end = .;
- }
-
-}
diff --git a/arch/nds32/dts/Makefile b/arch/nds32/dts/Makefile
deleted file mode 100644
index 5a09e3b45b3..00000000000
--- a/arch/nds32/dts/Makefile
+++ /dev/null
@@ -1,15 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0+
-
-dtb-$(CONFIG_TARGET_ADP_AG101P) += ag101p.dtb
-dtb-$(CONFIG_TARGET_ADP_AE3XX) += ae3xx.dtb
-include $(srctree)/scripts/Makefile.dts
-
-targets += $(dtb-y)
-
-DTC_FLAGS += -R 4 -p 0x1000
-
-PHONY += dtbs
-dtbs: $(addprefix $(obj)/, $(dtb-y))
- @:
-
-clean-files := *.dtb
diff --git a/arch/nds32/dts/ae3xx.dts b/arch/nds32/dts/ae3xx.dts
deleted file mode 100644
index 7bba2a2bf09..00000000000
--- a/arch/nds32/dts/ae3xx.dts
+++ /dev/null
@@ -1,103 +0,0 @@
-/dts-v1/;
-/ {
- compatible = "nds32 ae3xx";
- #address-cells = <1>;
- #size-cells = <1>;
- interrupt-parent = <&intc>;
-
- aliases {
- uart0 = &serial0;
- ethernet0 = &mac0;
- spi0 = &spi;
- } ;
-
- chosen {
- /* bootargs = "console=ttyS0,38400n8 earlyprintk=uart8250-32bit,0xf0300000 debug bootmem_debug memblock=debug loglevel=7"; */
- bootargs = "console=ttyS0,38400n8 earlyprintk=uart8250-32bit,0xf0300000 debug loglevel=7";
- stdout-path = "uart0:38400n8";
- tick-timer = &timer0;
- };
-
- memory@0 {
- device_type = "memory";
- reg = <0x00000000 0x40000000>;
- };
-
- spiclk: virt_100mhz {
- #clock-cells = <0>;
- compatible = "fixed-clock";
- clock-frequency = <100000000>;
- };
-
- cpus {
- #address-cells = <1>;
- #size-cells = <0>;
- cpu@0 {
- compatible = "andestech,n13";
- reg = <0>;
- /* FIXME: to fill correct frqeuency */
- clock-frequency = <60000000>;
- };
- };
-
- intc: interrupt-controller {
- compatible = "andestech,atnointc010";
- #interrupt-cells = <1>;
- interrupt-controller;
- };
-
- serial0: serial@f0300000 {
- compatible = "andestech,uart16550", "ns16550a";
- reg = <0xf0300000 0x1000>;
- interrupts = <7 4>;
- clock-frequency = <14745600>;
- reg-shift = <2>;
- reg-offset = <32>;
- no-loopback-test = <1>;
- };
-
- timer0: timer@f0400000 {
- compatible = "andestech,atcpit100";
- reg = <0xf0400000 0x1000>;
- interrupts = <2 4>;
- clock-frequency = <30000000>;
- };
-
- mac0: mac@e0100000 {
- compatible = "andestech,atmac100";
- reg = <0xe0100000 0x1000>;
- interrupts = <25 4>;
- };
-
- mmc0: mmc@f0e00000 {
- compatible = "andestech,atfsdc010";
- max-frequency = <100000000>;
- fifo-depth = <0x10>;
- reg = <0xf0e00000 0x1000>;
- interrupts = <17 4>;
- };
-
- nor@0,0 {
- compatible = "cfi-flash";
- reg = <0x88000000 0x1000>;
- bank-width = <2>;
- device-width = <1>;
- };
-
- spi: spi@f0b00000 {
- compatible = "andestech,atcspi200";
- reg = <0xf0b00000 0x1000>;
- #address-cells = <1>;
- #size-cells = <0>;
- num-cs = <1>;
- clocks = <&spiclk>;
- interrupts = <3 4>;
- flash@0 {
- compatible = "jedec,spi-nor";
- spi-max-frequency = <50000000>;
- reg = <0>;
- spi-cpol;
- spi-cpha;
- };
- };
-};
diff --git a/arch/nds32/dts/ag101p.dts b/arch/nds32/dts/ag101p.dts
deleted file mode 100644
index d2ed9efe93d..00000000000
--- a/arch/nds32/dts/ag101p.dts
+++ /dev/null
@@ -1,72 +0,0 @@
-/dts-v1/;
-/ {
- compatible = "nds32 ag101p";
- #address-cells = <1>;
- #size-cells = <1>;
- interrupt-parent = <&intc>;
-
- aliases {
- uart0 = &serial0;
- ethernet0 = &mac0;
- } ;
-
- chosen {
- /* bootargs = "console=ttyS0,38400n8 earlyprintk=uart8250-32bit,0x99600000 debug bootmem_debug memblock=debug loglevel=7"; */
- bootargs = "console=ttyS0,38400n8 earlyprintk=uart8250-32bit,0x99600000 debug loglevel=7";
- stdout-path = "uart0:38400n8";
- tick-timer = &timer0;
- };
-
- memory@0 {
- device_type = "memory";
- reg = <0x00000000 0x40000000>;
- };
-
- cpus {
- #address-cells = <1>;
- #size-cells = <0>;
- cpu@0 {
- compatible = "andestech,n13";
- reg = <0>;
- /* FIXME: to fill correct frqeuency */
- clock-frequency = <60000000>;
- };
- };
-
- intc: interrupt-controller {
- compatible = "andestech,atnointc010";
- #interrupt-cells = <1>;
- interrupt-controller;
- };
-
- serial0: serial@99600000 {
- compatible = "andestech,uart16550", "ns16550a";
- reg = <0x99600000 0x1000>;
- interrupts = <7 4>;
- clock-frequency = <14745600>;
- reg-shift = <2>;
- no-loopback-test = <1>;
- };
-
- timer0: timer@98400000 {
- compatible = "andestech,attmr010";
- reg = <0x98400000 0x1000>;
- interrupts = <19 4>;
- clock-frequency = <15000000>;
- };
-
- mac0: mac@90900000 {
- compatible = "andestech,atmac100";
- reg = <0x90900000 0x1000>;
- interrupts = <25 4>;
- };
-
- mmc0: mmc@98e00000 {
- compatible = "andestech,atfsdc010";
- max-frequency = <30000000>;
- fifo-depth = <0x10>;
- reg = <0x98e00000 0x1000>;
- interrupts = <5 4>;
- cap-sd-highspeed;
- };
-};
diff --git a/arch/nds32/include/asm/arch-ae3xx/ae3xx.h b/arch/nds32/include/asm/arch-ae3xx/ae3xx.h
deleted file mode 100644
index c283cfae9b5..00000000000
--- a/arch/nds32/include/asm/arch-ae3xx/ae3xx.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * Copyright (C) 2016 Andes Technology Corporation
- * Nobuhiro Lin, Andes Technology Corporation <nobuhiro@andestech.com>
- * Macpaul Lin, Andes Technology Corporation <macpaul@andestech.com>
- */
-
-#ifndef __AE3XX_H
-#define __AE3XX_H
-
-/* Hardware register bases */
-
-/* Static Memory Controller (SRAM) */
-#define CONFIG_FTSMC020_BASE 0xe0400000
-/* DMA Controller */
-#define CONFIG_FTDMAC020_BASE 0xf0c00000
-/* AHB-to-APB Bridge */
-#define CONFIG_FTAPBBRG020S_01_BASE 0xf0000000
-/* Reserved */
-#define CONFIG_RESERVED_01_BASE 0xe0500000
-/* Reserved */
-#define CONFIG_RESERVED_02_BASE 0xf0800000
-/* Reserved */
-#define CONFIG_RESERVED_03_BASE 0xf0900000
-/* Ethernet */
-#define CONFIG_FTMAC100_BASE 0xe0100000
-/* Reserved */
-#define CONFIG_RESERVED_04_BASE 0xf1000000
-
-/* APB Device definitions */
-
-/* UART1 */
-#define CONFIG_FTUART010_01_BASE 0xf0200000
-/* UART2 */
-#define CONFIG_FTUART010_02_BASE 0xf0300000
-/* Counter/Timers */
-#define CONFIG_FTTMR010_BASE 0xf0400000
-/* Watchdog Timer */
-#define CONFIG_FTWDT010_BASE 0xf0500000
-/* Real Time Clock */
-#define CONFIG_FTRTC010_BASE 0xf0600000
-/* GPIO */
-#define CONFIG_FTGPIO010_BASE 0xf0700000
-/* I2C */
-#define CONFIG_FTIIC010_BASE 0xf0a00000
-
-/* The following address was not defined in Linux */
-
-/* Synchronous Serial Port Controller (SSP) 01 */
-#define CONFIG_FTSSP010_01_BASE 0xf0d00000
-#endif /* __AE3XX_H */
diff --git a/arch/nds32/include/asm/arch-ag101/ag101.h b/arch/nds32/include/asm/arch-ag101/ag101.h
deleted file mode 100644
index 6900868a66c..00000000000
--- a/arch/nds32/include/asm/arch-ag101/ag101.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * Copyright (C) 2011 Andes Technology Corporation
- * Nobuhiro Lin, Andes Technology Corporation <nobuhiro@andestech.com>
- * Macpaul Lin, Andes Technology Corporation <macpaul@andestech.com>
- */
-
-#ifndef __AG101_H
-#define __AG101_H
-
-/* Hardware register bases */
-
-/* AHB Controller */
-#define CONFIG_FTAHBC020S_BASE 0x90100000
-/* Static Memory Controller (SRAM) */
-#define CONFIG_FTSMC020_BASE 0x90200000
-/* FTSDMC021 SDRAM Controller */
-#define CONFIG_FTSDMC021_BASE 0x90300000
-/* DMA Controller */
-#define CONFIG_FTDMAC020_BASE 0x90400000
-/* AHB-to-APB Bridge */
-#define CONFIG_FTAPBBRG020S_01_BASE 0x90500000
-/* LCD Controller */
-#define CONFIG_FTLCDC100_BASE 0x90600000
-/* Reserved */
-#define CONFIG_RESERVED_01_BASE 0x90700000
-/* Reserved */
-#define CONFIG_RESERVED_02_BASE 0x90800000
-/* Ethernet */
-#define CONFIG_FTMAC100_BASE 0x90900000
-/* External USB host */
-#define CONFIG_EXT_USB_HOST_BASE 0x90A00000
-/* USB Device */
-#define CONFIG_USB_DEV_BASE 0x90B00000
-/* External AHB-to-PCI Bridge (FTPCI100 not exist in ag101) */
-#define CONFIG_EXT_AHBPCIBRG_BASE 0x90C00000
-/* Reserved */
-#define CONFIG_RESERVED_03_BASE 0x90D00000
-/* External AHB-to-APB Bridger (FTAPBBRG020S_02) */
-#define CONFIG_EXT_AHBAPBBRG_BASE 0x90E00000
-/* External AHB slave1 (LCD) */
-#define CONFIG_EXT_AHBSLAVE01_BASE 0x90F00000
-/* External AHB slave2 (FUSBH200) */
-#define CONFIG_EXT_AHBSLAVE02_BASE 0x92000000
-
-/* APB Device definitions */
-
-/* Power Management Unit */
-#define CONFIG_FTPMU010_BASE 0x98100000
-/* BT UART 2/IrDA (UART 01 in Linux) */
-#define CONFIG_FTUART010_01_BASE 0x98300000
-/* Counter/Timers */
-#define CONFIG_FTTMR010_BASE 0x98400000
-/* Watchdog Timer */
-#define CONFIG_FTWDT010_BASE 0x98500000
-/* Real Time Clock */
-#define CONFIG_FTRTC010_BASE 0x98600000
-/* GPIO */
-#define CONFIG_FTGPIO010_BASE 0x98700000
-/* Interrupt Controller */
-#define CONFIG_FTINTC010_BASE 0x98800000
-/* I2C */
-#define CONFIG_FTIIC010_BASE 0x98A00000
-/* Reserved */
-#define CONFIG_RESERVED_04_BASE 0x98C00000
-/* Compat Flash Controller */
-#define CONFIG_FTCFC010_BASE 0x98D00000
-
-/* Synchronous Serial Port Controller (SSP) I2S/AC97 */
-#define CONFIG_FTSSP010_02_BASE 0x99400000
-/* ST UART ? SSP 02 (UART 02 in Linux) */
-#define CONFIG_FTUART010_02_BASE 0x99600000
-
-/* The following address was not defined in Linux */
-
-/* FF UART 3 */
-#define CONFIG_FTUART010_03_BASE 0x98200000
-/* Synchronous Serial Port Controller (SSP) 01 */
-#define CONFIG_FTSSP010_01_BASE 0x98B00000
-/* IrDA */
-#define CONFIG_IRDA_BASE 0x98900000
-/* PWM - Pulse Width Modulator Controller */
-#define CONFIG_PMW_BASE 0x99100000
-
-#endif /* __AG101_H */
diff --git a/arch/nds32/include/asm/arch-ag102/ag102.h b/arch/nds32/include/asm/arch-ag102/ag102.h
deleted file mode 100644
index 53d38b35734..00000000000
--- a/arch/nds32/include/asm/arch-ag102/ag102.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * Copyright (C) 2011 Andes Technology Corporation
- * Macpaul Lin, Andes Technology Corporation <macpaul@andestech.com>
- */
-
-#ifndef __AG102_H
-#define __AG102_H
-
-/*
- * Hardware register bases
- */
-
-/* LPC Controller */
-#define CONFIG_LPC_IO_BASE 0x90100000
-/* LPC Controller */
-#define CONFIG_LPC_BASE 0x90200000
-
-/* NDS32 Data Local Memory 01 */
-#define CONFIG_NDS_DLM1_BASE 0x90300000
-/* NDS32 Data Local Memory 02 */
-#define CONFIG_NDS_DLM2_BASE 0x90400000
-
-/* Synopsys DWC DDR2/1 Controller */
-#define CONFIG_DWCDDR21MCTL_BASE 0x90500000
-/* DMA Controller */
-#define CONFIG_FTDMAC020_BASE 0x90600000
-/* FTIDE020_S IDE (ATA) Controller */
-#define CONFIG_FTIDE020S_BASE 0x90700000
-/* USB OTG Controller */
-#define CONFIG_FZOTG266HD0A_BASE 0x90800000
-/* Andes L2 Cache Controller */
-#define CONFIG_NCEL2C100_BASE 0x90900000
-/* XGI XG22 GPU */
-#define CONFIG_XGI_XG22_BASE 0x90A00000
-/* GMAC Ethernet Controller */
-#define CONFIG_FTGMAC100_BASE 0x90B00000
-/* AHB Controller */
-#define CONFIG_FTAHBC020S_BASE 0x90C00000
-/* AHB-to-APB Bridge Controller */
-#define CONFIG_FTAPBBRG020S_01_BASE 0x90D00000
-/* External AHB2AHB Controller */
-#define CONFIG_EXT_AHB2AHB_BASE 0x90E00000
-/* Andes Multi-core Interrupt Controller */
-#define CONFIG_NCEMIC100_BASE 0x90F00000
-
-/*
- * APB Device definitions
- */
-/* Compat Flash Controller */
-#define CONFIG_FTCFC010_BASE 0x94000000
-/* APB - SSP (SPI) (without AC97) Controller */
-#define CONFIG_FTSSP010_01_BASE 0x94100000
-/* UART1 - APB STUART Controller (UART0 in Linux) */
-#define CONFIG_FTUART010_01_BASE 0x94200000
-/* APB - SSP with HDA/AC97 Controller */
-#define CONFIG_FTSSP010_02_BASE 0x94500000
-/* UART2 - APB STUART Controller (UART1 in Linux) */
-#define CONFIG_FTUART010_02_BASE 0x94600000
-/* PCU Controller */
-#define CONFIG_ANDES_PCU_BASE 0x94800000
-/* FTTMR010 Timer */
-#define CONFIG_FTTMR010_BASE 0x94900000
-/* Watch Dog Controller */
-#define CONFIG_FTWDT010_BASE 0x94A00000
-/* FTRTC010 Real Time Clock */
-#define CONFIG_FTRTC010_BASE 0x98B00000
-/* GPIO Controller */
-#define CONFIG_FTGPIO010_BASE 0x94C00000
-/* I2C Controller */
-#define CONFIG_FTIIC010_BASE 0x94E00000
-/* PWM - Pulse Width Modulator Controller */
-#define CONFIG_FTPWM010_BASE 0x94F00000
-
-/* Power Management Unit */
-#define CONFIG_FTPMU010_BASE 0x98100000
-
-#endif /* __AG102_H */
diff --git a/arch/nds32/include/asm/bitops.h b/arch/nds32/include/asm/bitops.h
deleted file mode 100644
index f1cdcf3e65d..00000000000
--- a/arch/nds32/include/asm/bitops.h
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- * Copyright 1995, Russell King.
- * Various bits and pieces copyrights include:
- * Linus Torvalds (test_bit).
- *
- * Copyright (C) 2011 Andes Technology Corporation
- * Shawn Lin, Andes Technology Corporation <nobuhiro@andestech.com>
- *
- * bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1).
- *
- * Please note that the code in this file should never be included
- * from user space. Many of these are not implemented in assembler
- * since they would be too costly. Also, they require priviledged
- * instructions (which are not available from user mode) to ensure
- * that they are atomic.
- */
-
-#ifndef __ASM_NDS_BITOPS_H
-#define __ASM_NDS_BITOPS_H
-
-#ifdef __KERNEL__
-
-#include <asm/system.h>
-#include <asm-generic/bitops/fls.h>
-#include <asm-generic/bitops/__fls.h>
-#include <asm-generic/bitops/fls64.h>
-#include <asm-generic/bitops/__ffs.h>
-
-#define smp_mb__before_clear_bit() do { } while (0)
-#define smp_mb__after_clear_bit() do { } while (0)
-
-/*
- * Function prototypes to keep gcc -Wall happy.
- */
-extern void set_bit(int nr, void *addr);
-
-static inline void __set_bit(int nr, void *addr)
-{
- int *a = (int *)addr;
- int mask;
-
- a += nr >> 5;
- mask = 1 << (nr & 0x1f);
- *a |= mask;
-}
-
-#define PLATFORM__SET_BIT
-
-extern void clear_bit(int nr, void *addr);
-
-static inline void __clear_bit(int nr, void *addr)
-{
- int *a = (int *)addr;
- int mask;
- unsigned long flags;
-
- a += nr >> 5;
- mask = 1 << (nr & 0x1f);
- local_irq_save(flags);
- *a &= ~mask;
- local_irq_restore(flags);
-}
-
-#define PLATFORM__CLEAR_BIT
-
-extern void change_bit(int nr, void *addr);
-
-static inline void __change_bit(int nr, void *addr)
-{
- int mask;
- unsigned long *ADDR = (unsigned long *)addr;
-
- ADDR += nr >> 5;
- mask = 1 << (nr & 31);
- *ADDR ^= mask;
-}
-
-extern int test_and_set_bit(int nr, void *addr);
-
-static inline int __test_and_set_bit(int nr, void *addr)
-{
- int mask, retval;
- unsigned int *a = (unsigned int *)addr;
-
- a += nr >> 5;
- mask = 1 << (nr & 0x1f);
- retval = (mask & *a) != 0;
- *a |= mask;
- return retval;
-}
-
-extern int test_and_clear_bit(int nr, void *addr);
-
-static inline int __test_and_clear_bit(int nr, void *addr)
-{
- int mask, retval;
- unsigned int *a = (unsigned int *)addr;
-
- a += nr >> 5;
- mask = 1 << (nr & 0x1f);
- retval = (mask & *a) != 0;
- *a &= ~mask;
- return retval;
-}
-
-extern int test_and_change_bit(int nr, void *addr);
-
-static inline int __test_and_change_bit(int nr, void *addr)
-{
- int mask, retval;
- unsigned int *a = (unsigned int *)addr;
-
- a += nr >> 5;
- mask = 1 << (nr & 0x1f);
- retval = (mask & *a) != 0;
- *a ^= mask;
- return retval;
-}
-
-extern int find_first_zero_bit(void *addr, unsigned size);
-extern int find_next_zero_bit(void *addr, int size, int offset);
-
-/*
- * This routine doesn't need to be atomic.
- */
-static inline int test_bit(int nr, const void *addr)
-{
- return ((unsigned char *) addr)[nr >> 3] & (1U << (nr & 7));
-}
-
-/*
- * ffz = Find First Zero in word. Undefined if no zero exists,
- * so code should check against ~0UL first..
- */
-static inline unsigned long ffz(unsigned long word)
-{
- int k;
-
- word = ~word;
- k = 31;
- if (word & 0x0000ffff) {
- k -= 16; word <<= 16;
- }
- if (word & 0x00ff0000) {
- k -= 8; word <<= 8;
- }
- if (word & 0x0f000000) {
- k -= 4; word <<= 4;
- }
- if (word & 0x30000000) {
- k -= 2; word <<= 2;
- }
- if (word & 0x40000000)
- k -= 1;
-
- return k;
-}
-
-/*
- * ffs: find first bit set. This is defined the same way as
- * the libc and compiler builtin ffs routines, therefore
- * differs in spirit from the above ffz (man ffs).
- */
-
-/*
- * redefined in include/linux/bitops.h
- * #define ffs(x) generic_ffs(x)
- */
-
-/*
- * hweightN: returns the hamming weight (i.e. the number
- * of bits set) of a N-bit word
- */
-
-#define hweight32(x) generic_hweight32(x)
-#define hweight16(x) generic_hweight16(x)
-#define hweight8(x) generic_hweight8(x)
-
-#define ext2_set_bit test_and_set_bit
-#define ext2_clear_bit test_and_clear_bit
-#define ext2_test_bit test_bit
-#define ext2_find_first_zero_bit find_first_zero_bit
-#define ext2_find_next_zero_bit find_next_zero_bit
-
-/* Bitmap functions for the minix filesystem. */
-#define minix_test_and_set_bit(nr, addr) test_and_set_bit(nr, addr)
-#define minix_set_bit(nr, addr) set_bit(nr, addr)
-#define minix_test_and_clear_bit(nr, addr) test_and_clear_bit(nr, addr)
-#define minix_test_bit(nr, addr) test_bit(nr, addr)
-#define minix_find_first_zero_bit(addr, size) find_first_zero_bit(addr, size)
-
-#endif /* __KERNEL__ */
-
-#endif /* __ASM_NDS_BITOPS_H */
diff --git a/arch/nds32/include/asm/bootm.h b/arch/nds32/include/asm/bootm.h
deleted file mode 100644
index c956fdd49c9..00000000000
--- a/arch/nds32/include/asm/bootm.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * Copyright (c) 2013, Google Inc.
- *
- * Copyright (C) 2011
- * Corscience GmbH & Co. KG - Simon Schwarz <schwarz@corscience.de>
- */
-#ifndef NDS32_BOOTM_H
-#define NDS32_BOOTM_H
-
-#include <asm/setup.h>
-
-extern void udc_disconnect(void);
-
-#ifdef CONFIG_SUPPORT_PASSING_ATAGS
-# define BOOTM_ENABLE_TAGS 1
-#else
-# define BOOTM_ENABLE_TAGS 0
-#endif
-
-#ifdef CONFIG_SETUP_MEMORY_TAGS
-# define BOOTM_ENABLE_MEMORY_TAGS 1
-#else
-# define BOOTM_ENABLE_MEMORY_TAGS 0
-#endif
-
-#ifdef CONFIG_CMDLINE_TAG
- #define BOOTM_ENABLE_CMDLINE_TAG 1
-#else
- #define BOOTM_ENABLE_CMDLINE_TAG 0
-#endif
-
-#ifdef CONFIG_INITRD_TAG
- #define BOOTM_ENABLE_INITRD_TAG 1
-#else
- #define BOOTM_ENABLE_INITRD_TAG 0
-#endif
-
-#ifdef CONFIG_SERIAL_TAG
- #define BOOTM_ENABLE_SERIAL_TAG 1
-void get_board_serial(struct tag_serialnr *serialnr);
-#else
- #define BOOTM_ENABLE_SERIAL_TAG 0
-static inline void get_board_serial(struct tag_serialnr *serialnr)
-{
-}
-#endif
-
-#ifdef CONFIG_REVISION_TAG
- #define BOOTM_ENABLE_REVISION_TAG 1
-u32 get_board_rev(void);
-#else
- #define BOOTM_ENABLE_REVISION_TAG 0
-static inline u32 get_board_rev(void)
-{
- return 0;
-}
-#endif
-
-#endif
diff --git a/arch/nds32/include/asm/byteorder.h b/arch/nds32/include/asm/byteorder.h
deleted file mode 100644
index 39fd9eddf07..00000000000
--- a/arch/nds32/include/asm/byteorder.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * linux/include/asm-arm/byteorder.h
- *
- * Copyright (C) 2011 Andes Technology Corporation
- * Shawn Lin, Andes Technology Corporation <nobuhiro@andestech.com>
- * Macpaul Lin, Andes Technology Corporation <macpaul@andestech.com>
- *
- * ARM Endian-ness. In little endian mode, the data bus is connected such
- * that byte accesses appear as:
- * 0 = d0...d7, 1 = d8...d15, 2 = d16...d23, 3 = d24...d31
- * and word accesses (data or instruction) appear as:
- * d0...d31
- *
- * When in big endian mode, byte accesses appear as:
- * 0 = d24...d31, 1 = d16...d23, 2 = d8...d15, 3 = d0...d7
- * and word accesses (data or instruction) appear as:
- * d0...d31
- */
-
-#ifndef __ASM_NDS_BYTEORDER_H
-#define __ASM_NDS_BYTEORDER_H
-
-#include <asm/types.h>
-
-#if !defined(__STRICT_ANSI__) || defined(__KERNEL__)
-# define __BYTEORDER_HAS_U64__
-# define __SWAB_64_THRU_32__
-#endif
-
-#ifdef __NDSEB__
-#include <linux/byteorder/big_endian.h>
-#else
-#include <linux/byteorder/little_endian.h>
-#endif
-
-#endif
diff --git a/arch/nds32/include/asm/cache.h b/arch/nds32/include/asm/cache.h
deleted file mode 100644
index 6c72b2baf53..00000000000
--- a/arch/nds32/include/asm/cache.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * Copyright (C) 2011 Andes Technology Corporation
- * Shawn Lin, Andes Technology Corporation <nobuhiro@andestech.com>
- * Macpaul Lin, Andes Technology Corporation <macpaul@andestech.com>
- */
-
-#ifndef _ASM_CACHE_H
-#define _ASM_CACHE_H
-
-/* cache */
-int icache_status(void);
-void icache_enable(void);
-void icache_disable(void);
-int dcache_status(void);
-void dcache_enable(void);
-void dcache_disable(void);
-void cache_flush(void);
-
-#define DEFINE_GET_SYS_REG(reg) \
- static inline unsigned long GET_##reg(void) \
- { \
- unsigned long val; \
- __asm__ volatile ( \
- "mfsr %0, $"#reg : "=&r" (val) : : "memory" \
- ); \
- return val; \
- }
-
-enum cache_t {ICACHE, DCACHE};
-DEFINE_GET_SYS_REG(ICM_CFG);
-DEFINE_GET_SYS_REG(DCM_CFG);
-/* I-cache sets (# of cache lines) per way */
-#define ICM_CFG_OFF_ISET 0
-/* I-cache ways */
-#define ICM_CFG_OFF_IWAY 3
-#define ICM_CFG_MSK_ISET (0x7 << ICM_CFG_OFF_ISET)
-#define ICM_CFG_MSK_IWAY (0x7 << ICM_CFG_OFF_IWAY)
-/* D-cache sets (# of cache lines) per way */
-#define DCM_CFG_OFF_DSET 0
-/* D-cache ways */
-#define DCM_CFG_OFF_DWAY 3
-#define DCM_CFG_MSK_DSET (0x7 << DCM_CFG_OFF_DSET)
-#define DCM_CFG_MSK_DWAY (0x7 << DCM_CFG_OFF_DWAY)
-/* I-cache line size */
-#define ICM_CFG_OFF_ISZ 6
-#define ICM_CFG_MSK_ISZ (0x7UL << ICM_CFG_OFF_ISZ)
-/* D-cache line size */
-#define DCM_CFG_OFF_DSZ 6
-#define DCM_CFG_MSK_DSZ (0x7UL << DCM_CFG_OFF_DSZ)
-
-/*
- * The current upper bound for NDS32 L1 data cache line sizes is 32 bytes.
- * We use that value for aligning DMA buffers unless the board config has
- * specified an alternate cache line size.
- */
-#ifdef CONFIG_SYS_CACHELINE_SIZE
-#define ARCH_DMA_MINALIGN CONFIG_SYS_CACHELINE_SIZE
-#else
-#define ARCH_DMA_MINALIGN 32
-#endif
-
-#endif /* _ASM_CACHE_H */
diff --git a/arch/nds32/include/asm/config.h b/arch/nds32/include/asm/config.h
deleted file mode 100644
index 6c1cbce7ef5..00000000000
--- a/arch/nds32/include/asm/config.h
+++ /dev/null
@@ -1,11 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * Copyright (C) 2011 Andes Technology Corporation
- * Copyright (C) 2010 Shawn Lin (nobuhiro@andestech.com)
- * Copyright (C) 2011 Macpaul Lin (macpaul@andestech.com)
- */
-
-#ifndef _ASM_CONFIG_H_
-#define _ASM_CONFIG_H_
-
-#endif
diff --git a/arch/nds32/include/asm/dma-mapping.h b/arch/nds32/include/asm/dma-mapping.h
deleted file mode 100644
index f8668f1fe5d..00000000000
--- a/arch/nds32/include/asm/dma-mapping.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * Copyright (C) 2013 Andes Technology Corporation
- * Ken Kuo, Andes Technology Corporation <ken_kuo@andestech.com>
- */
-#ifndef __ASM_NDS_DMA_MAPPING_H
-#define __ASM_NDS_DMA_MAPPING_H
-
-#include <common.h>
-#include <asm/cache.h>
-#include <cpu_func.h>
-#include <linux/dma-direction.h>
-#include <linux/types.h>
-#include <malloc.h>
-
-static void *dma_alloc_coherent(size_t len, unsigned long *handle)
-{
- *handle = (unsigned long)memalign(ARCH_DMA_MINALIGN, len);
- return (void *)*handle;
-}
-
-#endif /* __ASM_NDS_DMA_MAPPING_H */
diff --git a/arch/nds32/include/asm/global_data.h b/arch/nds32/include/asm/global_data.h
deleted file mode 100644
index 297481beaae..00000000000
--- a/arch/nds32/include/asm/global_data.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * (C) Copyright 2002
- * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
- *
- * Copyright (C) 2011 Andes Technology Corporation
- * Shawn Lin, Andes Technology Corporation <nobuhiro@andestech.com>
- * Macpaul Lin, Andes Technology Corporation <macpaul@andestech.com>
- */
-
-/**************************************************************
- * CAUTION:
- * - do not implement for NDS32 Arch yet.
- * - so far no one uses the macros defined in this head file.
- **************************************************************/
-
-#ifndef __ASM_GBL_DATA_H
-#define __ASM_GBL_DATA_H
-
-#include <config.h>
-
-/* Architecture-specific global data */
-struct arch_global_data {
-};
-
-#include <asm-generic/global_data.h>
-
-#ifdef CONFIG_GLOBAL_DATA_NOT_REG10
-extern volatile gd_t g_gd;
-#define DECLARE_GLOBAL_DATA_PTR static volatile gd_t *gd = &g_gd
-#else
-#define DECLARE_GLOBAL_DATA_PTR register volatile gd_t *gd asm ("$r10")
-#endif
-
-#endif /* __ASM_GBL_DATA_H */
diff --git a/arch/nds32/include/asm/io.h b/arch/nds32/include/asm/io.h
deleted file mode 100644
index fdfc574afc0..00000000000
--- a/arch/nds32/include/asm/io.h
+++ /dev/null
@@ -1,457 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * linux/include/asm-nds/io.h
- *
- * Copyright (C) 1996-2000 Russell King
- *
- * Copyright (C) 2011 Andes Technology Corporation
- * Shawn Lin, Andes Technology Corporation <nobuhiro@andestech.com>
- * Macpaul Lin, Andes Technology Corporation <macpaul@andestech.com>
- *
- * Modifications:
- * 16-Sep-1996 RMK Inlined the inx/outx functions & optimised for both
- * constant addresses and variable addresses.
- * 04-Dec-1997 RMK Moved a lot of this stuff to the new architecture
- * specific IO header files.
- * 27-Mar-1999 PJB Second parameter of memcpy_toio is const..
- * 04-Apr-1999 PJB Added check_signature.
- * 12-Dec-1999 RMK More cleanups
- * 18-Jun-2000 RMK Removed virt_to_* and friends definitions
- */
-#ifndef __ASM_NDS_IO_H
-#define __ASM_NDS_IO_H
-
-/*
- * CAUTION:
- * - do not implement for NDS32 Arch yet.
- * - cmd_pci.c, cmd_scsi.c, Lynxkdi.c, usb.c, usb_storage.c, etc...
- * iinclude asm/io.h
- */
-
-#ifdef __KERNEL__
-
-#include <linux/types.h>
-#include <asm/byteorder.h>
-
-static inline void sync(void)
-{
-}
-
-#ifdef CONFIG_ARCH_MAP_SYSMEM
-static inline void *map_sysmem(phys_addr_t paddr, unsigned long len)
-{
- if(paddr <PHYS_SDRAM_0_SIZE + PHYS_SDRAM_1_SIZE)
- paddr = paddr | 0x40000000;
- return (void *)(uintptr_t)paddr;
-}
-
-static inline void *unmap_sysmem(const void *vaddr)
-{
- phys_addr_t paddr = (phys_addr_t)vaddr;
- paddr = paddr & ~0x40000000;
- return (void *)(uintptr_t)paddr;
-}
-
-static inline phys_addr_t map_to_sysmem(const void *ptr)
-{
- return (phys_addr_t)(uintptr_t)ptr;
-}
-#endif
-
-/*
- * Generic virtual read/write. Note that we don't support half-word
- * read/writes. We define __arch_*[bl] here, and leave __arch_*w
- * to the architecture specific code.
- */
-#define __arch_getb(a) (*(unsigned char *)(a))
-#define __arch_getw(a) (*(unsigned short *)(a))
-#define __arch_getl(a) (*(unsigned int *)(a))
-
-#define __arch_putb(v, a) (*(unsigned char *)(a) = (v))
-#define __arch_putw(v, a) (*(unsigned short *)(a) = (v))
-#define __arch_putl(v, a) (*(unsigned int *)(a) = (v))
-
-extern void __raw_writesb(unsigned int addr, const void *data, int bytelen);
-extern void __raw_writesw(unsigned int addr, const void *data, int wordlen);
-extern void __raw_writesl(unsigned int addr, const void *data, int longlen);
-
-extern void __raw_readsb(unsigned int addr, void *data, int bytelen);
-extern void __raw_readsw(unsigned int addr, void *data, int wordlen);
-extern void __raw_readsl(unsigned int addr, void *data, int longlen);
-
-#define __raw_writeb(v, a) __arch_putb(v, a)
-#define __raw_writew(v, a) __arch_putw(v, a)
-#define __raw_writel(v, a) __arch_putl(v, a)
-
-#define __raw_readb(a) __arch_getb(a)
-#define __raw_readw(a) __arch_getw(a)
-#define __raw_readl(a) __arch_getl(a)
-
-/*
- * TODO: The kernel offers some more advanced versions of barriers, it might
- * have some advantages to use them instead of the simple one here.
- */
-#define dmb() __asm__ __volatile__ ("" : : : "memory")
-#define __iormb() dmb()
-#define __iowmb() dmb()
-
-static inline void writeb(u8 val, volatile void __iomem *addr)
-{
- __iowmb();
- __arch_putb(val, addr);
-}
-
-static inline void writew(u16 val, volatile void __iomem *addr)
-{
- __iowmb();
- __arch_putw(val, addr);
-
-}
-
-static inline void writel(u32 val, volatile void __iomem *addr)
-{
- __iowmb();
- __arch_putl(val, addr);
-}
-
-static inline u8 readb(const volatile void __iomem *addr)
-{
- u8 val;
-
- val = __arch_getb(addr);
- __iormb();
- return val;
-}
-
-static inline u16 readw(const volatile void __iomem *addr)
-{
- u16 val;
-
- val = __arch_getw(addr);
- __iormb();
- return val;
-}
-
-static inline u32 readl(const volatile void __iomem *addr)
-{
- u32 val;
-
- val = __arch_getl(addr);
- __iormb();
- return val;
-}
-
-/*
- * The compiler seems to be incapable of optimising constants
- * properly. Spell it out to the compiler in some cases.
- * These are only valid for small values of "off" (< 1<<12)
- */
-#define __raw_base_writeb(val, base, off) __arch_base_putb(val, base, off)
-#define __raw_base_writew(val, base, off) __arch_base_putw(val, base, off)
-#define __raw_base_writel(val, base, off) __arch_base_putl(val, base, off)
-
-#define __raw_base_readb(base, off) __arch_base_getb(base, off)
-#define __raw_base_readw(base, off) __arch_base_getw(base, off)
-#define __raw_base_readl(base, off) __arch_base_getl(base, off)
-
-#define out_arch(type, endian, a, v) __raw_write##type(cpu_to_##endian(v), a)
-#define in_arch(type, endian, a) endian##_to_cpu(__raw_read##type(a))
-
-#define out_le32(a, v) out_arch(l, le32, a, v)
-#define out_le16(a, v) out_arch(w, le16, a, v)
-
-#define in_le32(a) in_arch(l, le32, a)
-#define in_le16(a) in_arch(w, le16, a)
-
-#define out_be32(a, v) out_arch(l, be32, a, v)
-#define out_be16(a, v) out_arch(w, be16, a, v)
-
-#define in_be32(a) in_arch(l, be32, a)
-#define in_be16(a) in_arch(w, be16, a)
-
-#define out_8(a, v) __raw_writeb(v, a)
-#define in_8(a) __raw_readb(a)
-
-/*
- * Clear and set bits in one shot. These macros can be used to clear and
- * set multiple bits in a register using a single call. These macros can
- * also be used to set a multiple-bit bit pattern using a mask, by
- * specifying the mask in the 'clear' parameter and the new bit pattern
- * in the 'set' parameter.
- */
-
-#define clrbits(type, addr, clear) \
- out_##type((addr), in_##type(addr) & ~(clear))
-
-#define setbits(type, addr, set) \
- out_##type((addr), in_##type(addr) | (set))
-
-#define clrsetbits(type, addr, clear, set) \
- out_##type((addr), (in_##type(addr) & ~(clear)) | (set))
-
-#define clrbits_be32(addr, clear) clrbits(be32, addr, clear)
-#define setbits_be32(addr, set) setbits(be32, addr, set)
-#define clrsetbits_be32(addr, clear, set) clrsetbits(be32, addr, clear, set)
-
-#define clrbits_le32(addr, clear) clrbits(le32, addr, clear)
-#define setbits_le32(addr, set) setbits(le32, addr, set)
-#define clrsetbits_le32(addr, clear, set) clrsetbits(le32, addr, clear, set)
-
-#define clrbits_be16(addr, clear) clrbits(be16, addr, clear)
-#define setbits_be16(addr, set) setbits(be16, addr, set)
-#define clrsetbits_be16(addr, clear, set) clrsetbits(be16, addr, clear, set)
-
-#define clrbits_le16(addr, clear) clrbits(le16, addr, clear)
-#define setbits_le16(addr, set) setbits(le16, addr, set)
-#define clrsetbits_le16(addr, clear, set) clrsetbits(le16, addr, clear, set)
-
-#define clrbits_8(addr, clear) clrbits(8, addr, clear)
-#define setbits_8(addr, set) setbits(8, addr, set)
-#define clrsetbits_8(addr, clear, set) clrsetbits(8, addr, clear, set)
-
-/*
- * Now, pick up the machine-defined IO definitions
- * #include <asm/arch/io.h>
- */
-
-/*
- * IO port access primitives
- * -------------------------
- *
- * The NDS32 doesn't have special IO access instructions just like ARM;
- * all IO is memory mapped.
- * Note that these are defined to perform little endian accesses
- * only. Their primary purpose is to access PCI and ISA peripherals.
- *
- * Note that for a big endian machine, this implies that the following
- * big endian mode connectivity is in place, as described by numerious
- * ARM documents:
- *
- * PCI: D0-D7 D8-D15 D16-D23 D24-D31
- * ARM: D24-D31 D16-D23 D8-D15 D0-D7
- *
- * The machine specific io.h include defines __io to translate an "IO"
- * address to a memory address.
- *
- * Note that we prevent GCC re-ordering or caching values in expressions
- * by introducing sequence points into the in*() definitions. Note that
- * __raw_* do not guarantee this behaviour.
- *
- * The {in,out}[bwl] macros are for emulating x86-style PCI/ISA IO space.
- */
-#ifdef __io
-#define outb(v, p) __raw_writeb(v, __io(p))
-#define outw(v, p) __raw_writew(cpu_to_le16(v), __io(p))
-#define outl(v, p) __raw_writel(cpu_to_le32(v), __io(p))
-
-#define inb(p) ({ unsigned int __v = __raw_readb(__io(p)); __v; })
-#define inw(p) ({ unsigned int __v = le16_to_cpu(__raw_readw(__io(p))); __v; })
-#define inl(p) ({ unsigned int __v = le32_to_cpu(__raw_readl(__io(p))); __v; })
-
-#define outsb(p, d, l) writesb(__io(p), d, l)
-#define outsw(p, d, l) writesw(__io(p), d, l)
-#define outsl(p, d, l) writesl(__io(p), d, l)
-
-#define insb(p, d, l) readsb(__io(p), d, l)
-#define insw(p, d, l) readsw(__io(p), d, l)
-#define insl(p, d, l) readsl(__io(p), d, l)
-
-static inline void readsb(unsigned int *addr, void * data, int bytelen)
-{
- unsigned char *ptr = (unsigned char *)addr;
- unsigned char *ptr2 = (unsigned char *)data;
- while (bytelen) {
- *ptr2 = *ptr;
- ptr2++;
- bytelen--;
- }
-}
-
-static inline void readsw(unsigned int *addr, void * data, int wordlen)
-{
- unsigned short *ptr = (unsigned short *)addr;
- unsigned short *ptr2 = (unsigned short *)data;
- while (wordlen) {
- *ptr2 = *ptr;
- ptr2++;
- wordlen--;
- }
-}
-
-static inline void readsl(unsigned int *addr, void * data, int longlen)
-{
- unsigned int *ptr = (unsigned int *)addr;
- unsigned int *ptr2 = (unsigned int *)data;
- while (longlen) {
- *ptr2 = *ptr;
- ptr2++;
- longlen--;
- }
-}
-static inline void writesb(unsigned int *addr, const void * data, int bytelen)
-{
- unsigned char *ptr = (unsigned char *)addr;
- unsigned char *ptr2 = (unsigned char *)data;
- while (bytelen) {
- *ptr = *ptr2;
- ptr2++;
- bytelen--;
- }
-}
-static inline void writesw(unsigned int *addr, const void * data, int wordlen)
-{
- unsigned short *ptr = (unsigned short *)addr;
- unsigned short *ptr2 = (unsigned short *)data;
- while (wordlen) {
- *ptr = *ptr2;
- ptr2++;
- wordlen--;
- }
-}
-static inline void writesl(unsigned int *addr, const void * data, int longlen)
-{
- unsigned int *ptr = (unsigned int *)addr;
- unsigned int *ptr2 = (unsigned int *)data;
- while (longlen) {
- *ptr = *ptr2;
- ptr2++;
- longlen--;
- }
-}
-#endif
-
-#define outb_p(val, port) outb((val), (port))
-#define outw_p(val, port) outw((val), (port))
-#define outl_p(val, port) outl((val), (port))
-#define inb_p(port) inb((port))
-#define inw_p(port) inw((port))
-#define inl_p(port) inl((port))
-
-#define outsb_p(port, from, len) outsb(port, from, len)
-#define outsw_p(port, from, len) outsw(port, from, len)
-#define outsl_p(port, from, len) outsl(port, from, len)
-#define insb_p(port, to, len) insb(port, to, len)
-#define insw_p(port, to, len) insw(port, to, len)
-#define insl_p(port, to, len) insl(port, to, len)
-
-/*
- * DMA-consistent mapping functions. These allocate/free a region of
- * uncached, unwrite-buffered mapped memory space for use with DMA
- * devices. This is the "generic" version. The PCI specific version
- * is in pci.h
- */
-extern void *consistent_alloc(int gfp, size_t size, dma_addr_t *handle);
-extern void consistent_free(void *vaddr, size_t size, dma_addr_t handle);
-extern void consistent_sync(void *vaddr, size_t size, int rw);
-
-/*
- * String version of IO memory access ops:
- */
-extern void _memcpy_fromio(void *, unsigned long, size_t);
-extern void _memcpy_toio(unsigned long, const void *, size_t);
-extern void _memset_io(unsigned long, int, size_t);
-
-extern void __readwrite_bug(const char *fn);
-
-/*
- * If this architecture has PCI memory IO, then define the read/write
- * macros. These should only be used with the cookie passed from
- * ioremap.
- */
-#ifdef __mem_pci
-
-#define readb(c) ({ unsigned int __v = \
- __raw_readb(__mem_pci(c)); __v; })
-#define readw(c) ({ unsigned int __v = \
- le16_to_cpu(__raw_readw(__mem_pci(c))); __v; })
-#define readl(c) ({ unsigned int __v = \
- le32_to_cpu(__raw_readl(__mem_pci(c))); __v; })
-
-#define writeb(v, c) __raw_writeb(v, __mem_pci(c))
-#define writew(v, c) __raw_writew(cpu_to_le16(v), __mem_pci(c))
-#define writel(v, c) __raw_writel(cpu_to_le32(v), __mem_pci(c))
-
-#define memset_io(c, v, l) _memset_io(__mem_pci(c), (v), (l))
-#define memcpy_fromio(a, c, l) _memcpy_fromio((a), __mem_pci(c), (l))
-#define memcpy_toio(c, a, l) _memcpy_toio(__mem_pci(c), (a), (l))
-
-#define eth_io_copy_and_sum(s, c, l, b) \
- eth_copy_and_sum((s), __mem_pci(c), (l), (b))
-
-static inline int
-check_signature(unsigned long io_addr, const unsigned char *signature,
- int length)
-{
- int retval = 0;
- do {
- if (readb(io_addr) != *signature)
- goto out;
- io_addr++;
- signature++;
- length--;
- } while (length);
- retval = 1;
-out:
- return retval;
-}
-#endif /* __mem_pci */
-
-/*
- * If this architecture has ISA IO, then define the isa_read/isa_write
- * macros.
- */
-#ifdef __mem_isa
-
-#define isa_readb(addr) __raw_readb(__mem_isa(addr))
-#define isa_readw(addr) __raw_readw(__mem_isa(addr))
-#define isa_readl(addr) __raw_readl(__mem_isa(addr))
-#define isa_writeb(val, addr) __raw_writeb(val, __mem_isa(addr))
-#define isa_writew(val, addr) __raw_writew(val, __mem_isa(addr))
-#define isa_writel(val, addr) __raw_writel(val, __mem_isa(addr))
-#define isa_memset_io(a, b, c) _memset_io(__mem_isa(a), (b), (c))
-#define isa_memcpy_fromio(a, b, c) _memcpy_fromio((a), __mem_isa(b), (c))
-#define isa_memcpy_toio(a, b, c) _memcpy_toio(__mem_isa((a)), (b), (c))
-
-#define isa_eth_io_copy_and_sum(a, b, c, d) \
- eth_copy_and_sum((a), __mem_isa(b), (c), (d))
-
-static inline int
-isa_check_signature(unsigned long io_addr, const unsigned char *signature,
- int length)
-{
- int retval = 0;
- do {
- if (isa_readb(io_addr) != *signature)
- goto out;
- io_addr++;
- signature++;
- length--;
- } while (length);
- retval = 1;
-out:
- return retval;
-}
-
-#else /* __mem_isa */
-
-#define isa_readb(addr) (__readwrite_bug("isa_readb"), 0)
-#define isa_readw(addr) (__readwrite_bug("isa_readw"), 0)
-#define isa_readl(addr) (__readwrite_bug("isa_readl"), 0)
-#define isa_writeb(val, addr) __readwrite_bug("isa_writeb")
-#define isa_writew(val, addr) __readwrite_bug("isa_writew")
-#define isa_writel(val, addr) __readwrite_bug("isa_writel")
-#define isa_memset_io(a, b, c) __readwrite_bug("isa_memset_io")
-#define isa_memcpy_fromio(a, b, c) __readwrite_bug("isa_memcpy_fromio")
-#define isa_memcpy_toio(a, b, c) __readwrite_bug("isa_memcpy_toio")
-
-#define isa_eth_io_copy_and_sum(a, b, c, d) \
- __readwrite_bug("isa_eth_io_copy_and_sum")
-
-#define isa_check_signature(io, sig, len) (0)
-
-#endif /* __mem_isa */
-
-#include <asm-generic/io.h>
-
-#endif /* __KERNEL__ */
-#endif /* __ASM_NDS_IO_H */
diff --git a/arch/nds32/include/asm/linkage.h b/arch/nds32/include/asm/linkage.h
deleted file mode 100644
index 0c8822b7d4d..00000000000
--- a/arch/nds32/include/asm/linkage.h
+++ /dev/null
@@ -1,11 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * U-Boot - linkage.h
- *
- * Copyright (c) 2005-2007 Analog Devices Inc.
- */
-
-#ifndef __ASM_LINKAGE_H
-#define __ASM_LINKAGE_H
-
-#endif
diff --git a/arch/nds32/include/asm/mach-types.h b/arch/nds32/include/asm/mach-types.h
deleted file mode 100644
index 99904f9ed55..00000000000
--- a/arch/nds32/include/asm/mach-types.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * This was automagically generated from arch/nds/tools/mach-types!
- * Do NOT edit
- */
-
-#ifndef __ASM_NDS32_MACH_TYPE_H
-#define __ASM_NDS32_MACH_TYPE_H
-
-#ifndef __ASSEMBLY__
-/* The type of machine we're running on */
-extern unsigned int __machine_arch_type;
-#endif
-
-/* see arch/arm/kernel/arch.c for a description of these */
-#define MACH_TYPE_ADPAG101P 1
-#define MACH_TYPE_ADPAE3XX 2
-
-#ifdef CONFIG_ARCH_ADPAG101P
-# ifdef machine_arch_type
-# undef machine_arch_type
-# define machine_arch_type __machine_arch_type
-# else
-# define machine_arch_type MACH_TYPE_ADPAG101P
-# endif
-# define machine_is_adpag101p() (machine_arch_type == MACH_TYPE_ADPAG101P)
-#else
-# define machine_is_adpag101p() (1)
-#endif
-
-#endif /* __ASM_NDS32_MACH_TYPE_H */
diff --git a/arch/nds32/include/asm/macro.h b/arch/nds32/include/asm/macro.h
deleted file mode 100644
index 4e119470ee2..00000000000
--- a/arch/nds32/include/asm/macro.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * include/asm-nds32/macro.h
- *
- * Copyright (C) 2009 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
- * Copyright (C) 2011 Andes Technology Corporation
- * Macpaul Lin, Andes Technology Corporation <macpaul@andestech.com>
- */
-
-#ifndef __ASM_NDS_MACRO_H
-#define __ASM_NDS_MACRO_H
-#ifdef __ASSEMBLY__
-
-/*
- * These macros provide a convenient way to write 8, 16 and 32 bit data
- * to an "immediate address (address used by periphal)" only.
- * Registers r4 and r5 are used, any data in these registers are
- * overwritten by the macros.
- * The macros are valid for any NDS32 architecture, they do not implement
- * any memory barriers so caution is recommended when using these when the
- * caches are enabled or on a multi-core system.
- */
-
-.macro write32, addr, data
- li $r4, \addr
- li $r5, \data
- swi $r5, [$r4]
-.endm
-
-.macro write16, addr, data
- li $r4, \addr
- li $r5, \data
- shi $r5, [$r4]
-.endm
-
-.macro write8, addr, data
- li $r4, \addr
- li $r5, \data
- sbi $r5, [$r4]
-.endm
-
-/*
- * This macro read a value from a register, then do OR operation
- * (set bit fields) to the value, and then store it back to the register.
- * Note: Instruction 'ori' supports immediate value up to 15 bits.
- */
-.macro setbf32, addr, data
- li $r4, \addr
- lwi $r5, [$r4]
- li $r6, \data
- or $r5, $r5, $r6
- swi $r5, [$r4]
-.endm
-
-.macro setbf15, addr, data
- li $r4, \addr
- lwi $r5, [$r4]
- ori $r5, $r5, \data
- swi $r5, [$r4]
-.endm
-
-/*
- * This macro generates a loop that can be used for delays in the code.
- * Register r4 is used, any data in this register is overwritten by the
- * macro.
- * The macro is valid for any NDS32 architeture. The actual time spent in the
- * loop will vary from CPU to CPU though.
- */
-
-.macro wait_timer, time
- li $r4, \time
-1:
- nop
- addi $r4, $r4, -1
- bnez $r4, 1b
-.endm
-
-#endif /* __ASSEMBLY__ */
-#endif /* __ASM_ARM_MACRO_H */
diff --git a/arch/nds32/include/asm/posix_types.h b/arch/nds32/include/asm/posix_types.h
deleted file mode 100644
index e6c591dfe4f..00000000000
--- a/arch/nds32/include/asm/posix_types.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * linux/include/asm-arm/posix_types.h
- *
- * Copyright (C) 1996-1998 Russell King.
- *
- * Copyright (C) 2011 Andes Technology Corporation
- * Copyright (C) 2010 Shawn Lin (nobuhiro@andestech.com)
- * Copyright (C) 2011 Macpaul Lin (macpaul@andestech.com)
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * Changelog:
- * 27-06-1996 RMK Created
- * 05-03-2010 Modified for arch NDS32
- */
-#ifndef __ARCH_NDS_POSIX_TYPES_H
-#define __ARCH_NDS_POSIX_TYPES_H
-
-/*
- * This file is generally used by user-level software, so you need to
- * be a little careful about namespace pollution etc. Also, we cannot
- * assume GCC is being used.
- */
-
-typedef unsigned short __kernel_dev_t;
-typedef unsigned long __kernel_ino_t;
-typedef unsigned short __kernel_mode_t;
-typedef unsigned short __kernel_nlink_t;
-typedef long __kernel_off_t;
-typedef int __kernel_pid_t;
-typedef unsigned short __kernel_ipc_pid_t;
-typedef unsigned short __kernel_uid_t;
-typedef unsigned short __kernel_gid_t;
-#ifdef __GNUC__
-typedef __SIZE_TYPE__ __kernel_size_t;
-#else
-typedef unsigned int __kernel_size_t;
-#endif
-typedef int __kernel_ssize_t;
-typedef int __kernel_ptrdiff_t;
-typedef long __kernel_time_t;
-typedef long __kernel_suseconds_t;
-typedef long __kernel_clock_t;
-typedef int __kernel_daddr_t;
-typedef char *__kernel_caddr_t;
-typedef unsigned short __kernel_uid16_t;
-typedef unsigned short __kernel_gid16_t;
-typedef unsigned int __kernel_uid32_t;
-typedef unsigned int __kernel_gid32_t;
-
-typedef unsigned short __kernel_old_uid_t;
-typedef unsigned short __kernel_old_gid_t;
-
-#ifdef __GNUC__
-typedef long long __kernel_loff_t;
-#endif
-
-typedef struct {
-#if defined(__KERNEL__) || defined(__USE_ALL)
- int val[2];
-#else /* !defined(__KERNEL__) && !defined(__USE_ALL) */
- int __val[2];
-#endif /* !defined(__KERNEL__) && !defined(__USE_ALL) */
-} __kernel_fsid_t;
-
-#if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2)
-
-#undef __FD_SET
-#define __FD_SET(fd, fdsetp) \
- (((fd_set *)fdsetp)->fds_bits[fd >> 5] |= (1<<(fd & 31)))
-
-#undef __FD_CLR
-#define __FD_CLR(fd, fdsetp) \
- (((fd_set *)fdsetp)->fds_bits[fd >> 5] &= ~(1<<(fd & 31)))
-
-#undef __FD_ISSET
-#define __FD_ISSET(fd, fdsetp) \
- ((((fd_set *)fdsetp)->fds_bits[fd >> 5] & (1<<(fd & 31))) != 0)
-
-#undef __FD_ZERO
-#define __FD_ZERO(fdsetp) \
- (memset(fdsetp, 0, sizeof(*(fd_set *) fdsetp)))
-
-#endif
-
-#endif /* __ARCH_NDS_POSIX_TYPES_H */
diff --git a/arch/nds32/include/asm/processor.h b/arch/nds32/include/asm/processor.h
deleted file mode 100644
index e5d186cc55e..00000000000
--- a/arch/nds32/include/asm/processor.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * linux/include/asm-arm/processor.h
- *
- * Copyright (C) 1995-2002 Russell King
- *
- * Copyright (C) 2011 Andes Technology Corporation
- * Copyright (C) 2010 Shawn Lin (nobuhiro@andestech.com)
- * Copyright (C) 2011 Macpaul Lin (macpaul@andestech.com)
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#ifndef __ASM_NDS_PROCESSOR_H
-#define __ASM_NDS_PROCESSOR_H
-
-/**************************************************************
- * CAUTION:
- * - do not implement for NDS32 Arch yet.
- * - so far some files include /asm/processor.h, but
- * no one uses the macros defined in this head file.
- **************************************************************/
-
-#endif /* __ASM_ARM_PROCESSOR_H */
diff --git a/arch/nds32/include/asm/ptrace.h b/arch/nds32/include/asm/ptrace.h
deleted file mode 100644
index ee181b26712..00000000000
--- a/arch/nds32/include/asm/ptrace.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (C) 2011 Andes Technology Corporation
- * Copyright (C) 2010 Shawn Lin (nobuhiro@andestech.com)
- * Copyright (C) 2011 Macpaul Lin (macpaul@andestech.com)
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-#ifndef __ASM_NDS_PTRACE_H
-#define __ASM_NDS_PTRACE_H
-
-#define USR_MODE 0x00
-#define SU_MODE 0x01
-#define HV_MODE 0x10
-#define MODE_MASK (0x03<<3)
-#define GIE_BIT 0x01
-
-#ifndef __ASSEMBLY__
-
-/* this struct defines the way the registers are stored on the
- stack during a system call. */
-
-#define NDS32_REG long
-
-struct pt_regs {
- NDS32_REG ir0;
- NDS32_REG ipsw;
- NDS32_REG ipc;
- NDS32_REG sp;
- NDS32_REG orig_r0;
- NDS32_REG pipsw;
- NDS32_REG pipc;
- NDS32_REG pp0;
- NDS32_REG pp1;
- NDS32_REG d0hi;
- NDS32_REG d0lo;
- NDS32_REG d1hi;
- NDS32_REG d1lo;
- NDS32_REG r[26]; /* r0 - r25 */
- NDS32_REG p0; /* r26 - used by OS */
- NDS32_REG p1; /* r27 - used by OS */
- NDS32_REG fp; /* r28 */
- NDS32_REG gp; /* r29 */
- NDS32_REG lp; /* r30 */
- NDS32_REG fucop_ctl;
- NDS32_REG osp;
-};
-
-#define processor_mode(regs) \
- (((regs)->ipsw & MODE_MASK) >> 3)
-
-#define interrupts_enabled(regs) \
- ((regs)->ipsw & GIE_BIT)
-
-/*
- * Offsets used by 'ptrace' system call interface.
- * These can't be changed without breaking binary compatibility
- * with MkLinux, etc.
- */
-#define PT_R0 0
-#define PT_R1 1
-#define PT_R2 2
-#define PT_R3 3
-#define PT_R4 4
-#define PT_R5 5
-#define PT_R6 6
-#define PT_R7 7
-#define PT_R8 8
-#define PT_R9 9
-#define PT_R10 10
-#define PT_R11 11
-#define PT_R12 12
-#define PT_R13 13
-#define PT_R14 14
-#define PT_R15 15
-#define PT_R16 16
-#define PT_R17 17
-#define PT_R18 18
-#define PT_R19 19
-#define PT_R20 20
-#define PT_R21 21
-#define PT_R22 22
-#define PT_R23 23
-#define PT_R24 24
-#define PT_R25 25
-
-#endif /* __ASSEMBLY__ */
-
-#endif /* __ASM_NDS_PTRACE_H */
diff --git a/arch/nds32/include/asm/sections.h b/arch/nds32/include/asm/sections.h
deleted file mode 100644
index aba9d974192..00000000000
--- a/arch/nds32/include/asm/sections.h
+++ /dev/null
@@ -1,11 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * Copyright (c) 2012 The Chromium OS Authors.
- */
-
-#ifndef __ASM_NDS32_SECTIONS_H
-#define __ASM_NDS32_SECTIONS_H
-
-#include <asm-generic/sections.h>
-
-#endif
diff --git a/arch/nds32/include/asm/setup.h b/arch/nds32/include/asm/setup.h
deleted file mode 100644
index a7d52373c66..00000000000
--- a/arch/nds32/include/asm/setup.h
+++ /dev/null
@@ -1,189 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * linux/arch/nds32/include/asm/setup.h
- *
- * Copyright (C) 1997-1999 Russell King
- * Copyright (C) 2008 Andes Technology Corporation
- * Copyright (C) 2013 Ken Kuo (ken_kuo@andestech.com)
- *
- * Structure passed to kernel to tell it about the
- * hardware it's running on. See Documentation/arm/Setup
- * for more info.
- */
-#ifndef __ASMNDS32_SETUP_H
-#define __ASMNDS32_SETUP_H
-
-#define COMMAND_LINE_SIZE 256
-
-/* The list ends with an ATAG_NONE node. */
-#define ATAG_NONE 0x00000000
-
-struct tag_header {
- u32 size;
- u32 tag;
-};
-
-/* The list must start with an ATAG_CORE node */
-#define ATAG_CORE 0x54410001
-
-struct tag_core {
- u32 flags; /* bit 0 = read-only */
- u32 pagesize;
- u32 rootdev;
-};
-
-/* it is allowed to have multiple ATAG_MEM nodes */
-#define ATAG_MEM 0x54410002
-
-struct tag_mem32 {
- u32 size;
- u32 start; /* physical start address */
-};
-
-/* VGA text type displays */
-#define ATAG_VIDEOTEXT 0x54410003
-
-struct tag_videotext {
- u8 x;
- u8 y;
- u16 video_page;
- u8 video_mode;
- u8 video_cols;
- u16 video_ega_bx;
- u8 video_lines;
- u8 video_isvga;
- u16 video_points;
-};
-
-/* describes how the ramdisk will be used in kernel */
-#define ATAG_RAMDISK 0x54410004
-
-struct tag_ramdisk {
- u32 flags; /* bit 0 = load, bit 1 = prompt */
- u32 size; /* decompressed ramdisk size in _kilo_ bytes */
- u32 start; /* starting block of floppy-based RAM disk image */
-};
-
-/*
- * this one accidentally used virtual addresses - as such,
- * it's deprecated.
- * describes where the compressed ramdisk image lives (virtual address)
- */
-#define ATAG_INITRD 0x54410005
-
-/* describes where the compressed ramdisk image lives (physical address) */
-#define ATAG_INITRD2 0x54420005
-
-struct tag_initrd {
- u32 start; /* physical start address */
- u32 size; /* size of compressed ramdisk image in bytes */
-};
-
-/* board serial number. "64 bits should be enough for everybody" */
-#define ATAG_SERIAL 0x54410006
-
-struct tag_serialnr {
- u32 low;
- u32 high;
-};
-
-/* board revision */
-#define ATAG_REVISION 0x54410007
-
-struct tag_revision {
- u32 rev;
-};
-
-/* initial values for vesafb-type framebuffers. see struct screen_info
- * in include/linux/tty.h
- */
-#define ATAG_VIDEOLFB 0x54410008
-
-struct tag_videolfb {
- u16 lfb_width;
- u16 lfb_height;
- u16 lfb_depth;
- u16 lfb_linelength;
- u32 lfb_base;
- u32 lfb_size;
- u8 red_size;
- u8 red_pos;
- u8 green_size;
- u8 green_pos;
- u8 blue_size;
- u8 blue_pos;
- u8 rsvd_size;
- u8 rsvd_pos;
-};
-
-/* command line: \0 terminated string */
-#define ATAG_CMDLINE 0x54410009
-
-struct tag_cmdline {
- char cmdline[COMMAND_LINE_SIZE];
-};
-
-struct tag {
- struct tag_header hdr;
- union {
- struct tag_core core;
- struct tag_mem32 mem;
- struct tag_videotext videotext;
- struct tag_ramdisk ramdisk;
- struct tag_initrd initrd;
- struct tag_serialnr serialnr;
- struct tag_revision revision;
- struct tag_videolfb videolfb;
- struct tag_cmdline cmdline;
- } u;
-};
-
-struct tagtable {
- u32 tag;
- int (*parse)(const struct tag *);
-};
-
-#define tag_member_present(tag, member) \
- ((unsigned long)(&((struct tag *)0L)->member + 1) \
- <= (tag)->hdr.size * 4)
-
-#define tag_next(t) ((struct tag *)((u32 *)(t) + (t)->hdr.size))
-#define tag_size(type) ((sizeof(struct tag_header) + sizeof(struct type)) >> 2)
-
-#define for_each_tag(t, base) \
- for (t = base; t->hdr.size; t = tag_next(t))
-
-#ifdef __KERNEL__
-
-#define __tag __used __section(".taglist")
-#define __tagtable(tag, fn) \
-static struct tagtable __tagtable_##fn __tag = { tag, fn }
-
-/*
- * Memory map description
- */
-#define NR_BANKS 8
-
-struct meminfo {
- int nr_banks;
- struct {
- unsigned long start;
- unsigned long size;
- int node;
- } bank[NR_BANKS];
-};
-
-/*
- * Early command line parameters.
- */
-struct early_params {
- const char *arg;
- void (*fn)(char **p);
-};
-
-#define __early_param(name, fn) \
-static struct early_params __early_##fn __used \
-__section("__early_param") = { name, fn }
-
-#endif
-#endif
diff --git a/arch/nds32/include/asm/spl.h b/arch/nds32/include/asm/spl.h
deleted file mode 100644
index e69de29bb2d..00000000000
--- a/arch/nds32/include/asm/spl.h
+++ /dev/null
diff --git a/arch/nds32/include/asm/string.h b/arch/nds32/include/asm/string.h
deleted file mode 100644
index 610aa9e4e6e..00000000000
--- a/arch/nds32/include/asm/string.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2011 Andes Technology Corporation
- * Copyright (C) 2010 Shawn Lin (nobuhiro@andestech.com)
- * Copyright (C) 2011 Macpaul Lin (macpaul@andestech.com)
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License. See the file "COPYING" in the main directory of this archive
- * for more details.
- */
-
-#ifndef __ASM_NDS_STRING_H
-#define __ASM_NDS_STRING_H
-
-/*
- * We don't do inline string functions, since the
- * optimised inline asm versions are not small.
- */
-
-#undef __HAVE_ARCH_STRRCHR
-extern char *strrchr(const char *s, int c);
-
-#undef __HAVE_ARCH_STRCHR
-extern char *strchr(const char *s, int c);
-
-#undef __HAVE_ARCH_MEMCPY
-extern void *memcpy(void *, const void *, __kernel_size_t);
-
-#undef __HAVE_ARCH_MEMMOVE
-extern void *memmove(void *, const void *, __kernel_size_t);
-
-#undef __HAVE_ARCH_MEMCHR
-extern void *memchr(const void *, int, __kernel_size_t);
-
-#undef __HAVE_ARCH_MEMZERO
-#undef __HAVE_ARCH_MEMSET
-extern void *memset(void *, int, __kernel_size_t);
-
-#ifdef CONFIG_MARCO_MEMSET
-extern void __memzero(void *ptr, __kernel_size_t n);
-
-#define memset(p, v, n) \
- ({ \
- if ((n) != 0) { \
- if (__builtin_constant_p((v)) && (v) == 0) \
- __memzero((p), (n)); \
- else \
- memset((p), (v), (n)); \
- } \
- (p); \
- })
-
-#define memzero(p, n) ({ if ((n) != 0) __memzero((p), (n)); (p); })
-#else
-extern void memzero(void *ptr, __kernel_size_t n);
-#endif
-
-#endif /* __ASM_NDS_STRING_H */
diff --git a/arch/nds32/include/asm/system.h b/arch/nds32/include/asm/system.h
deleted file mode 100644
index 5453a9b902a..00000000000
--- a/arch/nds32/include/asm/system.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * Copyright (C) 2011 Andes Technology Corporation
- * Macpaul Lin, Andes Technology Corporation <macpaul@andestech.com>
- */
-
-#ifndef __ASM_NDS_SYSTEM_H
-#define __ASM_NDS_SYSTEM_H
-
-/*
- * Interrupt configuring macros.
- */
-
-extern int irq_flags;
-
-#define local_irq_enable() \
- __asm__ __volatile__ ( \
- "mfsr %0, $psw\n\t" \
- "andi %0, %0, 0x1\n\t" \
- "setgie.e\n\t" \
- : \
- : "r" (irq_flags) \
- )
-
-#define local_irq_disable() \
- do { \
- int __tmp_dummy; \
- __asm__ __volatile__ ( \
- "mfsr %0, $psw\n\t" \
- "andi %0, %0, 0x1\n\t" \
- "setgie.d\n\t" \
- "dsb\n\t" \
- : "=r" (__tmp_dummy) \
- ); \
- } while (0)
-
-#define local_irq_save(x) \
- __asm__ __volatile__ ( \
- "mfsr %0, $psw\n\t" \
- "andi %0, %0, 0x1\n\t" \
- "setgie.d\n\t" \
- "dsb\n\t" \
- : "=&r" (x) \
- )
-
-#define local_save_flags(x) \
- __asm__ __volatile__ ( \
- "mfsr %0, $psw\n\t" \
- "andi %0, %0, 0x1\n\t" \
- "setgie.e\n\t" \
- "setgie.d\n\t" \
- : "=r" (x) \
- )
-
-#define irqs_enabled_from_flags(x) ((x) != 0x1f)
-
-#define local_irq_restore(x) \
- do { \
- if (irqs_enabled_from_flags(x)) \
- local_irq_enable(); \
- } while (0)
-
-/*
- * Force strict CPU ordering.
- */
-#define nop() asm volatile ("nop;\n\t" : : )
-#define mb() asm volatile ("" : : : "memory")
-#define rmb() asm volatile ("" : : : "memory")
-#define wmb() asm volatile ("" : : : "memory")
-
-#endif /* __ASM_NDS_SYSTEM_H */
diff --git a/arch/nds32/include/asm/types.h b/arch/nds32/include/asm/types.h
deleted file mode 100644
index d2444da9b60..00000000000
--- a/arch/nds32/include/asm/types.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2011 Andes Technology Corporation
- * Copyright (C) 2010 Shawn Lin (nobuhiro@andestech.com)
- * Copyright (C) 2011 Macpaul Lin (macpaul@andestech.com)
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License. See the file "COPYING" in the main directory of this archive
- * for more details.
- */
-
-#ifndef __ASM_NDS_TYPES_H
-#define __ASM_NDS_TYPES_H
-
-#include <asm-generic/int-ll64.h>
-
-typedef unsigned short umode_t;
-
-/*
- * These aren't exported outside the kernel to avoid name space clashes
- */
-#ifdef __KERNEL__
-
-#define BITS_PER_LONG 32
-
-#include <stddef.h>
-
-typedef u32 dma_addr_t;
-
-typedef unsigned long phys_addr_t;
-typedef unsigned long phys_size_t;
-
-#endif /* __KERNEL__ */
-
-#endif
diff --git a/arch/nds32/include/asm/u-boot-nds32.h b/arch/nds32/include/asm/u-boot-nds32.h
deleted file mode 100644
index f086f34729f..00000000000
--- a/arch/nds32/include/asm/u-boot-nds32.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * (C) Copyright 2002
- * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
- * Marius Groeger <mgroeger@sysgo.de>
- *
- * Copyright (C) 2011 Andes Technology Corporation
- * Shawn Lin, Andes Technology Corporation <nobuhiro@andestech.com>
- * Macpaul Lin, Andes Technology Corporation <macpaul@andestech.com>
- */
-
-#ifndef _U_BOOT_NDS32_H_
-#define _U_BOOT_NDS32_H_ 1
-
-#include <linux/types.h>
-
-/* for the following variables, see start.S */
-extern ulong IRQ_STACK_START; /* top of IRQ stack */
-extern ulong FIQ_STACK_START; /* top of FIQ stack */
-
-/* cpu/.../cpu.c */
-int cleanup_before_linux(void);
-
-/* board/.../... */
-int board_init(void);
-
-/* cpu/.../interrupt.c */
-void reset_timer_masked(void);
-
-#endif /* _U_BOOT_NDS32_H_ */
diff --git a/arch/nds32/include/asm/u-boot.h b/arch/nds32/include/asm/u-boot.h
deleted file mode 100644
index 7b6e905f2ac..00000000000
--- a/arch/nds32/include/asm/u-boot.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * (C) Copyright 2002
- * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
- * Marius Groeger <mgroeger@sysgo.de>
- *
- * Copyright (C) 2011 Andes Technology Corporation
- * Copyright (C) 2010 Shawn Lin (nobuhiro@andestech.com)
- * Copyright (C) 2011 Macpaul Lin (macpaul@andestech.com)
- *
- ********************************************************************
- * NOTE: This header file defines an interface to U-Boot. Including
- * this (unmodified) header file in another file is considered normal
- * use of U-Boot, and does *not* fall under the heading of "derived
- * work".
- ********************************************************************
- */
-
-#ifndef _U_BOOT_H_
-#define _U_BOOT_H_ 1
-
-/* Use the generic board which requires a unified bd_info */
-#include <asm-generic/u-boot.h>
-#include <asm/u-boot-nds32.h>
-
-/* For image.h:image_check_target_arch() */
-#define IH_ARCH_DEFAULT IH_ARCH_NDS32
-
-#endif /* _U_BOOT_H_ */
diff --git a/arch/nds32/include/asm/unaligned.h b/arch/nds32/include/asm/unaligned.h
deleted file mode 100644
index 6cecbbb2111..00000000000
--- a/arch/nds32/include/asm/unaligned.h
+++ /dev/null
@@ -1 +0,0 @@
-#include <asm-generic/unaligned.h>
diff --git a/arch/nds32/lib/Makefile b/arch/nds32/lib/Makefile
deleted file mode 100644
index 501f26f1c37..00000000000
--- a/arch/nds32/lib/Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0+
-#
-# (C) Copyright 2000-2006
-# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
-#
-# Copyright (C) 2011 Andes Technology Corporation
-# Shawn Lin, Andes Technology Corporation <nobuhiro@andestech.com>
-# Macpaul Lin, Andes Technology Corporation <macpaul@andestech.com>
-
-obj-y += cache.o
-obj-$(CONFIG_CMD_BOOTM) += bootm.o
-obj-$(CONFIG_CMD_GO) += boot.o
-obj-y += interrupts.o
diff --git a/arch/nds32/lib/asm-offsets.c b/arch/nds32/lib/asm-offsets.c
deleted file mode 100644
index 39e3480bd52..00000000000
--- a/arch/nds32/lib/asm-offsets.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Adapted from Linux v2.6.36 kernel: arch/powerpc/kernel/asm-offsets.c
- *
- * Generate definitions needed by assembly language modules.
- * This code generates raw asm output which is post-processed to extract
- * and format the required data.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-#include <common.h>
-
-#include <linux/kbuild.h>
-
-int main(void)
-{
- /*
- * TODO : Check if each entry in this file is really necessary.
- * - struct ftahbc02s
- * - struct ftsdmc021
- * - struct andes_pcu
- * - struct dwcddr21mctl
- * are used only for generating asm-offsets.h.
- * It means their offset addresses are referenced only from assembly
- * code. Is it better to define the macros directly in headers?
- */
-
-#ifdef CONFIG_FTSMC020
- OFFSET(FTSMC020_BANK0_CR, ftsmc020, bank[0].cr);
- OFFSET(FTSMC020_BANK0_TPR, ftsmc020, bank[0].tpr);
-#endif
- BLANK();
-#ifdef CONFIG_FTAHBC020S
- OFFSET(FTAHBC020S_SLAVE_BSR_4, ftahbc02s, s_bsr[4]);
- OFFSET(FTAHBC020S_SLAVE_BSR_6, ftahbc02s, s_bsr[6]);
- OFFSET(FTAHBC020S_CR, ftahbc02s, cr);
-#endif
- BLANK();
-#ifdef CONFIG_FTPMU010
- OFFSET(FTPMU010_PDLLCR0, ftpmu010, PDLLCR0);
-#endif
- BLANK();
-#ifdef CONFIG_FTSDMC021
- OFFSET(FTSDMC021_TP1, ftsdmc021, tp1);
- OFFSET(FTSDMC021_TP2, ftsdmc021, tp2);
- OFFSET(FTSDMC021_CR1, ftsdmc021, cr1);
- OFFSET(FTSDMC021_CR2, ftsdmc021, cr2);
- OFFSET(FTSDMC021_BANK0_BSR, ftsdmc021, bank0_bsr);
- OFFSET(FTSDMC021_BANK1_BSR, ftsdmc021, bank1_bsr);
- OFFSET(FTSDMC021_BANK2_BSR, ftsdmc021, bank2_bsr);
- OFFSET(FTSDMC021_BANK3_BSR, ftsdmc021, bank3_bsr);
-#endif
- BLANK();
-#ifdef CONFIG_ANDES_PCU
- OFFSET(ANDES_PCU_PCS4, andes_pcu, pcs4.parm); /* 0x104 */
-#endif
- BLANK();
-#ifdef CONFIG_DWCDDR21MCTL
- OFFSET(DWCDDR21MCTL_CCR, dwcddr21mctl, ccr); /* 0x04 */
- OFFSET(DWCDDR21MCTL_DCR, dwcddr21mctl, dcr); /* 0x04 */
- OFFSET(DWCDDR21MCTL_IOCR, dwcddr21mctl, iocr); /* 0x08 */
- OFFSET(DWCDDR21MCTL_CSR, dwcddr21mctl, csr); /* 0x0c */
- OFFSET(DWCDDR21MCTL_DRR, dwcddr21mctl, drr); /* 0x10 */
- OFFSET(DWCDDR21MCTL_DLLCR0, dwcddr21mctl, dllcr[0]); /* 0x24 */
- OFFSET(DWCDDR21MCTL_DLLCR1, dwcddr21mctl, dllcr[1]); /* 0x28 */
- OFFSET(DWCDDR21MCTL_DLLCR2, dwcddr21mctl, dllcr[2]); /* 0x2c */
- OFFSET(DWCDDR21MCTL_DLLCR3, dwcddr21mctl, dllcr[3]); /* 0x30 */
- OFFSET(DWCDDR21MCTL_DLLCR4, dwcddr21mctl, dllcr[4]); /* 0x34 */
- OFFSET(DWCDDR21MCTL_DLLCR5, dwcddr21mctl, dllcr[5]); /* 0x38 */
- OFFSET(DWCDDR21MCTL_DLLCR6, dwcddr21mctl, dllcr[6]); /* 0x3c */
- OFFSET(DWCDDR21MCTL_DLLCR7, dwcddr21mctl, dllcr[7]); /* 0x40 */
- OFFSET(DWCDDR21MCTL_DLLCR8, dwcddr21mctl, dllcr[8]); /* 0x44 */
- OFFSET(DWCDDR21MCTL_DLLCR9, dwcddr21mctl, dllcr[9]); /* 0x48 */
- OFFSET(DWCDDR21MCTL_RSLR0, dwcddr21mctl, rslr[0]); /* 0x4c */
- OFFSET(DWCDDR21MCTL_RDGR0, dwcddr21mctl, rdgr[0]); /* 0x5c */
- OFFSET(DWCDDR21MCTL_DTAR, dwcddr21mctl, dtar); /* 0xa4 */
- OFFSET(DWCDDR21MCTL_MR, dwcddr21mctl, mr); /* 0x1f0 */
-#endif
-
- return 0;
-}
diff --git a/arch/nds32/lib/boot.c b/arch/nds32/lib/boot.c
deleted file mode 100644
index da2fd36a16c..00000000000
--- a/arch/nds32/lib/boot.c
+++ /dev/null
@@ -1,17 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Copyright (C) 2011 Andes Technology Corporation
- * Rick Chen, Andes Technology Corporation <rick@andestech.com>
- */
-
-
-#include <common.h>
-#include <command.h>
-
-unsigned long do_go_exec(ulong (*entry)(int, char * const []),
- int argc, char *const argv[])
-{
- cleanup_before_linux();
-
- return entry(argc, argv);
-}
diff --git a/arch/nds32/lib/bootm.c b/arch/nds32/lib/bootm.c
deleted file mode 100644
index 71ebfb4225b..00000000000
--- a/arch/nds32/lib/bootm.c
+++ /dev/null
@@ -1,248 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Copyright (C) 2011 Andes Technology Corporation
- * Shawn Lin, Andes Technology Corporation <nobuhiro@andestech.com>
- * Macpaul Lin, Andes Technology Corporation <macpaul@andestech.com>
- */
-
-#include <common.h>
-#include <bootstage.h>
-#include <command.h>
-#include <env.h>
-#include <hang.h>
-#include <image.h>
-#include <log.h>
-#include <asm/global_data.h>
-#include <u-boot/zlib.h>
-#include <asm/byteorder.h>
-#include <asm/bootm.h>
-
-DECLARE_GLOBAL_DATA_PTR;
-
-#ifdef CONFIG_SUPPORT_PASSING_ATAGS
-static void setup_start_tag(struct bd_info *bd);
-
-# ifdef CONFIG_SETUP_MEMORY_TAGS
-static void setup_memory_tags(struct bd_info *bd);
-# endif
-static void setup_commandline_tag(struct bd_info *bd, char *commandline);
-
-# ifdef CONFIG_INITRD_TAG
-static void setup_initrd_tag(struct bd_info *bd, ulong initrd_start,
- ulong initrd_end);
-# endif
-static void setup_end_tag(struct bd_info *bd);
-
-static struct tag *params;
-#endif /* CONFIG_SUPPORT_PASSING_ATAGS */
-
-int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
-{
- struct bd_info *bd = gd->bd;
- char *s;
- int machid = bd->bi_arch_number;
- void (*theKernel)(int zero, int arch, uint params);
-
-#ifdef CONFIG_CMDLINE_TAG
- char *commandline = env_get("bootargs");
-#endif
-
- /*
- * allow the PREP bootm subcommand, it is required for bootm to work
- */
- if (flag & BOOTM_STATE_OS_PREP)
- return 0;
-
- if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
- return 1;
-
- theKernel = (void (*)(int, int, uint))images->ep;
-
- s = env_get("machid");
- if (s) {
- machid = hextoul(s, NULL);
- printf("Using machid 0x%x from environment\n", machid);
- }
-
- bootstage_mark(BOOTSTAGE_ID_RUN_OS);
-
- debug("## Transferring control to Linux (at address %08lx) ...\n",
- (ulong)theKernel);
-
- if (CONFIG_IS_ENABLED(OF_LIBFDT) && images->ft_len) {
-#ifdef CONFIG_OF_LIBFDT
- debug("using: FDT\n");
- if (image_setup_linux(images)) {
- printf("FDT creation failed! hanging...");
- hang();
- }
-#endif
- } else if (BOOTM_ENABLE_TAGS) {
-#ifdef CONFIG_SUPPORT_PASSING_ATAGS
- setup_start_tag(bd);
-#ifdef CONFIG_SERIAL_TAG
- setup_serial_tag(&params);
-#endif
-#ifdef CONFIG_REVISION_TAG
- setup_revision_tag(&params);
-#endif
-#ifdef CONFIG_SETUP_MEMORY_TAGS
- setup_memory_tags(bd);
-#endif
-#ifdef CONFIG_CMDLINE_TAG
- setup_commandline_tag(bd, commandline);
-#endif
-#ifdef CONFIG_INITRD_TAG
- if (images->rd_start && images->rd_end)
- setup_initrd_tag(bd, images->rd_start, images->rd_end);
-#endif
- setup_end_tag(bd);
-#endif
-
- /* we assume that the kernel is in place */
- printf("\nStarting kernel ...\n\n");
-
-#ifdef CONFIG_USB_DEVICE
- {
- extern void udc_disconnect(void);
- udc_disconnect();
- }
-#endif
- }
- cleanup_before_linux();
- if (CONFIG_IS_ENABLED(OF_LIBFDT) && images->ft_len)
- theKernel(0, machid, (unsigned long)images->ft_addr);
- else
- theKernel(0, machid, bd->bi_boot_params);
- /* does not return */
-
- return 1;
-}
-
-#ifdef CONFIG_SUPPORT_PASSING_ATAGS
-static void setup_start_tag(struct bd_info *bd)
-{
- params = (struct tag *)bd->bi_boot_params;
-
- params->hdr.tag = ATAG_CORE;
- params->hdr.size = tag_size(tag_core);
-
- params->u.core.flags = 0;
- params->u.core.pagesize = 0;
- params->u.core.rootdev = 0;
-
- params = tag_next(params);
-}
-
-#ifdef CONFIG_SETUP_MEMORY_TAGS
-static void setup_memory_tags(struct bd_info *bd)
-{
- int i;
-
- for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
- params->hdr.tag = ATAG_MEM;
- params->hdr.size = tag_size(tag_mem32);
-
- params->u.mem.start = bd->bi_dram[i].start;
- params->u.mem.size = bd->bi_dram[i].size;
-
- params = tag_next(params);
- }
-}
-#endif /* CONFIG_SETUP_MEMORY_TAGS */
-
-static void setup_commandline_tag(struct bd_info *bd, char *commandline)
-{
- char *p;
-
- if (!commandline)
- return;
-
- /* eat leading white space */
- for (p = commandline; *p == ' '; p++)
- ;
-
- /* skip non-existent command lines so the kernel will still
- * use its default command line.
- */
- if (*p == '\0')
- return;
-
- params->hdr.tag = ATAG_CMDLINE;
- params->hdr.size =
- (sizeof(struct tag_header) + strlen(p) + 1 + 4) >> 2;
-
- strcpy(params->u.cmdline.cmdline, p)
- ;
-
- params = tag_next(params);
-}
-
-#ifdef CONFIG_INITRD_TAG
-static void setup_initrd_tag(struct bd_info *bd, ulong initrd_start,
- ulong initrd_end)
-{
- /* an ATAG_INITRD node tells the kernel where the compressed
- * ramdisk can be found. ATAG_RDIMG is a better name, actually.
- */
- params->hdr.tag = ATAG_INITRD2;
- params->hdr.size = tag_size(tag_initrd);
-
- params->u.initrd.start = initrd_start;
- params->u.initrd.size = initrd_end - initrd_start;
-
- params = tag_next(params);
-}
-#endif /* CONFIG_INITRD_TAG */
-
-#ifdef CONFIG_SERIAL_TAG
-void setup_serial_tag(struct tag **tmp)
-{
- struct tag *params = *tmp;
- struct tag_serialnr serialnr;
- void get_board_serial(struct tag_serialnr *serialnr);
-
- get_board_serial(&serialnr);
- params->hdr.tag = ATAG_SERIAL;
- params->hdr.size = tag_size(tag_serialnr);
- params->u.serialnr.low = serialnr.low;
- params->u.serialnr.high = serialnr.high;
- params = tag_next(params);
- *tmp = params;
-}
-#endif
-
-#ifdef CONFIG_REVISION_TAG
-void setup_revision_tag(struct tag **in_params)
-{
- u32 rev = 0;
- u32 get_board_rev(void);
-
- rev = get_board_rev();
- params->hdr.tag = ATAG_REVISION;
- params->hdr.size = tag_size(tag_revision);
- params->u.revision.rev = rev;
- params = tag_next(params);
-}
-#endif /* CONFIG_REVISION_TAG */
-
-static void setup_end_tag(struct bd_info *bd)
-{
- params->hdr.tag = ATAG_NONE;
- params->hdr.size = 0;
-}
-
-#endif /* CONFIG_SUPPORT_PASSING_ATAGS */
-
-static ulong get_sp(void)
-{
- ulong ret;
-
- asm("move %0, $sp" : "=r"(ret) : );
- return ret;
-}
-
-void arch_lmb_reserve(struct lmb *lmb)
-{
- arch_lmb_reserve_generic(lmb, get_sp(), gd->ram_top, 4096);
-}
diff --git a/arch/nds32/lib/cache.c b/arch/nds32/lib/cache.c
deleted file mode 100644
index 21917e5da5e..00000000000
--- a/arch/nds32/lib/cache.c
+++ /dev/null
@@ -1,268 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Copyright (C) 2012 Andes Technology Corporation
- * Shawn Lin, Andes Technology Corporation <nobuhiro@andestech.com>
- * Macpaul Lin, Andes Technology Corporation <macpaul@andestech.com>
- */
-
-#include <common.h>
-#include <cpu_func.h>
-#if !(CONFIG_IS_ENABLED(SYS_ICACHE_OFF) && CONFIG_IS_ENABLED(SYS_DCACHE_OFF))
-#include <asm/cache.h>
-static inline unsigned long CACHE_SET(unsigned char cache)
-{
- if (cache == ICACHE)
- return 64 << ((GET_ICM_CFG() & ICM_CFG_MSK_ISET) \
- >> ICM_CFG_OFF_ISET);
- else
- return 64 << ((GET_DCM_CFG() & DCM_CFG_MSK_DSET) \
- >> DCM_CFG_OFF_DSET);
-}
-
-static inline unsigned long CACHE_WAY(unsigned char cache)
-{
- if (cache == ICACHE)
- return 1 + ((GET_ICM_CFG() & ICM_CFG_MSK_IWAY) \
- >> ICM_CFG_OFF_IWAY);
- else
- return 1 + ((GET_DCM_CFG() & DCM_CFG_MSK_DWAY) \
- >> DCM_CFG_OFF_DWAY);
-}
-
-static inline unsigned long CACHE_LINE_SIZE(enum cache_t cache)
-{
- if (cache == ICACHE)
- return 8 << (((GET_ICM_CFG() & ICM_CFG_MSK_ISZ) \
- >> ICM_CFG_OFF_ISZ) - 1);
- else
- return 8 << (((GET_DCM_CFG() & DCM_CFG_MSK_DSZ) \
- >> DCM_CFG_OFF_DSZ) - 1);
-}
-#endif
-
-#if !CONFIG_IS_ENABLED(SYS_ICACHE_OFF)
-void invalidate_icache_all(void)
-{
- unsigned long end, line_size;
- line_size = CACHE_LINE_SIZE(ICACHE);
- end = line_size * CACHE_WAY(ICACHE) * CACHE_SET(ICACHE);
- do {
- end -= line_size;
- __asm__ volatile ("\n\tcctl %0, L1I_IX_INVAL" : : "r" (end));
-
- end -= line_size;
- __asm__ volatile ("\n\tcctl %0, L1I_IX_INVAL" : : "r" (end));
-
- end -= line_size;
- __asm__ volatile ("\n\tcctl %0, L1I_IX_INVAL" : : "r" (end));
- end -= line_size;
- __asm__ volatile ("\n\tcctl %0, L1I_IX_INVAL" : : "r" (end));
- } while (end > 0);
-}
-
-void invalidate_icache_range(unsigned long start, unsigned long end)
-{
- unsigned long line_size;
-
- line_size = CACHE_LINE_SIZE(ICACHE);
- while (end > start) {
- asm volatile (
- "\n\tcctl %0, L1I_VA_INVAL"
- :
- : "r"(start)
- );
- start += line_size;
- }
-}
-
-void icache_enable(void)
-{
- asm volatile (
- "mfsr $p0, $mr8\n\t"
- "ori $p0, $p0, 0x01\n\t"
- "mtsr $p0, $mr8\n\t"
- "isb\n\t"
- );
-}
-
-void icache_disable(void)
-{
- asm volatile (
- "mfsr $p0, $mr8\n\t"
- "li $p1, ~0x01\n\t"
- "and $p0, $p0, $p1\n\t"
- "mtsr $p0, $mr8\n\t"
- "isb\n\t"
- );
-}
-
-int icache_status(void)
-{
- int ret;
-
- asm volatile (
- "mfsr $p0, $mr8\n\t"
- "andi %0, $p0, 0x01\n\t"
- : "=r" (ret)
- :
- : "memory"
- );
-
- return ret;
-}
-
-#else
-void invalidate_icache_all(void)
-{
-}
-
-void invalidate_icache_range(unsigned long start, unsigned long end)
-{
-}
-
-void icache_enable(void)
-{
-}
-
-void icache_disable(void)
-{
-}
-
-int icache_status(void)
-{
- return 0;
-}
-
-#endif
-
-#if !CONFIG_IS_ENABLED(SYS_DCACHE_OFF)
-void dcache_wbinval_all(void)
-{
- unsigned long end, line_size;
- line_size = CACHE_LINE_SIZE(DCACHE);
- end = line_size * CACHE_WAY(DCACHE) * CACHE_SET(DCACHE);
- do {
- end -= line_size;
- __asm__ volatile ("\n\tcctl %0, L1D_IX_WB" : : "r" (end));
- __asm__ volatile ("\n\tcctl %0, L1D_IX_INVAL" : : "r" (end));
- end -= line_size;
- __asm__ volatile ("\n\tcctl %0, L1D_IX_WB" : : "r" (end));
- __asm__ volatile ("\n\tcctl %0, L1D_IX_INVAL" : : "r" (end));
- end -= line_size;
- __asm__ volatile ("\n\tcctl %0, L1D_IX_WB" : : "r" (end));
- __asm__ volatile ("\n\tcctl %0, L1D_IX_INVAL" : : "r" (end));
- end -= line_size;
- __asm__ volatile ("\n\tcctl %0, L1D_IX_WB" : : "r" (end));
- __asm__ volatile ("\n\tcctl %0, L1D_IX_INVAL" : : "r" (end));
-
- } while (end > 0);
-}
-
-void flush_dcache_range(unsigned long start, unsigned long end)
-{
- unsigned long line_size;
-
- line_size = CACHE_LINE_SIZE(DCACHE);
-
- while (end > start) {
- asm volatile (
- "\n\tcctl %0, L1D_VA_WB"
- "\n\tcctl %0, L1D_VA_INVAL" : : "r" (start)
- );
- start += line_size;
- }
-}
-
-void invalidate_dcache_range(unsigned long start, unsigned long end)
-{
- unsigned long line_size;
-
- line_size = CACHE_LINE_SIZE(DCACHE);
- while (end > start) {
- asm volatile (
- "\n\tcctl %0, L1D_VA_INVAL" : : "r"(start)
- );
- start += line_size;
- }
-}
-
-void dcache_enable(void)
-{
- asm volatile (
- "mfsr $p0, $mr8\n\t"
- "ori $p0, $p0, 0x02\n\t"
- "mtsr $p0, $mr8\n\t"
- "isb\n\t"
- );
-}
-
-void dcache_disable(void)
-{
- asm volatile (
- "mfsr $p0, $mr8\n\t"
- "li $p1, ~0x02\n\t"
- "and $p0, $p0, $p1\n\t"
- "mtsr $p0, $mr8\n\t"
- "isb\n\t"
- );
-}
-
-int dcache_status(void)
-{
- int ret;
- asm volatile (
- "mfsr $p0, $mr8\n\t"
- "andi %0, $p0, 0x02\n\t"
- : "=r" (ret)
- :
- : "memory"
- );
- return ret;
-}
-
-#else
-void dcache_wbinval_all(void)
-{
-}
-
-void flush_dcache_range(unsigned long start, unsigned long end)
-{
-}
-
-void invalidate_dcache_range(unsigned long start, unsigned long end)
-{
-}
-
-void dcache_enable(void)
-{
-}
-
-void dcache_disable(void)
-{
-}
-
-int dcache_status(void)
-{
- return 0;
-}
-
-#endif
-
-
-void flush_dcache_all(void)
-{
- dcache_wbinval_all();
-}
-
-void cache_flush(void)
-{
- flush_dcache_all();
- invalidate_icache_all();
-}
-
-
-void flush_cache(unsigned long addr, unsigned long size)
-{
- flush_dcache_range(addr, addr + size);
- invalidate_icache_range(addr, addr + size);
-}
diff --git a/arch/nds32/lib/interrupts.c b/arch/nds32/lib/interrupts.c
deleted file mode 100644
index 0ec72d157fb..00000000000
--- a/arch/nds32/lib/interrupts.c
+++ /dev/null
@@ -1,118 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * (C) Copyright 2002
- * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
- * Alex Zuepke <azu@sysgo.de>
- *
- * Copyright (C) 2011 Andes Technology Corporation
- * Shawn Lin, Andes Technology Corporation <nobuhiro@andestech.com>
- * Macpaul Lin, Andes Technology Corporation <macpaul@andestech.com>
- */
-
-#include <common.h>
-#include <cpu_func.h>
-#include <irq_func.h>
-#include <asm/ptrace.h>
-#include <asm/system.h>
-#undef INTERRUPT_MODE
-
-static int int_flag;
-
-int irq_flags; /* needed by asm-nds32/system.h */
-
-int GIE_STATUS(void)
-{
- int ret;
-
- __asm__ __volatile__ (
- "mfsr $p0, $psw\n\t"
- "andi %0, %0, 0x1\n\t"
- : "=r" (ret)
- :
- : "memory"
- );
- return ret;
-}
-
-#ifdef CONFIG_USE_INTERRUPT
-
-int interrupt_init(void)
-{
- return 0;
-}
-/* enable interrupts */
-void enable_interrupts(void)
-{
- local_irq_restore(int_flag);
-}
-
-/*
- * disable interrupts
- * Return true if GIE is enabled before we disable it.
- */
-int disable_interrupts(void)
-{
-
- int gie_ori_status;
-
- gie_ori_status = GIE_STATUS();
-
- local_irq_save(int_flag);
-
- return gie_ori_status;
-}
-#endif
-
-void bad_mode(void)
-{
- panic("Resetting CPU ...\n");
- reset_cpu();
-}
-
-void show_regs(struct pt_regs *regs)
-{
- const char *processor_modes[] = {"USER", "SuperUser" , "HyperVisor"};
-
- printf("\n");
- printf("pc : [<%08lx>] sp: [<%08lx>]\n"
- "lp : %08lx gp : %08lx fp : %08lx\n",
- regs->ipc, regs->sp, regs->lp, regs->gp, regs->fp);
- printf("D1H: %08lx D1L: %08lx D0H: %08lx D0L: %08lx\n",
- regs->d1hi, regs->d1lo, regs->d0hi, regs->d0lo);
- printf("r27: %08lx r26: %08lx r25: %08lx r24: %08lx\n",
- regs->p1, regs->p0, regs->r[25], regs->r[24]);
- printf("r23: %08lx r22: %08lx r21: %08lx r20: %08lx\n",
- regs->r[23], regs->r[22], regs->r[21], regs->r[20]);
- printf("r19: %08lx r18: %08lx r17: %08lx r16: %08lx\n",
- regs->r[19], regs->r[18], regs->r[17], regs->r[16]);
- printf("r15: %08lx r14: %08lx r13: %08lx r12: %08lx\n",
- regs->r[15], regs->r[14], regs->r[13], regs->r[12]);
- printf("r11: %08lx r10: %08lx r9 : %08lx r8 : %08lx\n",
- regs->r[11], regs->r[10], regs->r[9], regs->r[8]);
- printf("r7 : %08lx r6 : %08lx r5 : %08lx r4 : %08lx\n",
- regs->r[7], regs->r[6], regs->r[5], regs->r[4]);
- printf("r3 : %08lx r2 : %08lx r1 : %08lx r0 : %08lx\n",
- regs->r[3], regs->r[2], regs->r[1], regs->r[0]);
- printf(" Interrupts %s Mode %s\n",
- interrupts_enabled(regs) ? "on" : "off",
- processor_modes[processor_mode(regs)]);
-}
-
-void do_interruption(struct pt_regs *pt_regs, int EVIC_num)
-{
- const char *interruption_type[] = {
- "Reset",
- "TLB Fill",
- "TLB Not Present",
- "TLB Misc",
- "VLPT Miss",
- "Cache Parity Error",
- "Debug",
- "General Exception",
- "External Interrupt"
- };
-
- printf("%s\n", interruption_type[EVIC_num]);
- show_regs(pt_regs);
- bad_mode();
-}
diff --git a/arch/sandbox/dts/sandbox.dts b/arch/sandbox/dts/sandbox.dts
index 127f168f022..18fde1c8c6f 100644
--- a/arch/sandbox/dts/sandbox.dts
+++ b/arch/sandbox/dts/sandbox.dts
@@ -66,6 +66,10 @@
fake-host-hwaddr = [00 00 66 44 22 00];
};
+ host-fs {
+ compatible = "sandbox,bootdev-host";
+ };
+
i2c_0: i2c@0 {
#address-cells = <1>;
#size-cells = <0>;
diff --git a/arch/sandbox/dts/sandbox.dtsi b/arch/sandbox/dts/sandbox.dtsi
index 826db26fc2b..29306ac04da 100644
--- a/arch/sandbox/dts/sandbox.dtsi
+++ b/arch/sandbox/dts/sandbox.dtsi
@@ -19,6 +19,11 @@
#sound-dai-cells = <1>;
};
+ bootstd {
+ compatible = "u-boot,boot-std";
+ filename-prefixes = "./";
+ };
+
buttons {
compatible = "gpio-keys";
diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index 5b38ee4a5f9..a8a86bc7155 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -74,6 +74,21 @@
};
};
+ bootstd {
+ compatible = "u-boot,boot-std";
+
+ filename-prefixes = "/", "/boot/";
+ bootdev-order = "mmc2", "mmc1";
+
+ syslinux {
+ compatible = "u-boot,distro-syslinux";
+ };
+
+ efi {
+ compatible = "u-boot,distro-efi";
+ };
+ };
+
reboot-mode0 {
compatible = "reboot-mode-gpio";
gpios = <&gpio_c 0 GPIO_ACTIVE_HIGH>, <&gpio_c 1 GPIO_ACTIVE_HIGH>;
@@ -891,10 +906,13 @@
non-removable;
};
+ /* This is used for the bootdev tests */
mmc1 {
compatible = "sandbox,mmc";
+ filename = "mmc1.img";
};
+ /* This is used for the fastboot tests */
mmc0 {
compatible = "sandbox,mmc";
};
diff --git a/board/AndesTech/adp-ae3xx/Kconfig b/board/AndesTech/adp-ae3xx/Kconfig
deleted file mode 100644
index 8ec69d611a3..00000000000
--- a/board/AndesTech/adp-ae3xx/Kconfig
+++ /dev/null
@@ -1,18 +0,0 @@
-if TARGET_ADP_AE3XX
-
-config SYS_CPU
- default "n1213"
-
-config SYS_BOARD
- default "adp-ae3xx"
-
-config SYS_VENDOR
- default "AndesTech"
-
-config SYS_SOC
- default "ae3xx"
-
-config SYS_CONFIG_NAME
- default "adp-ae3xx"
-
-endif
diff --git a/board/AndesTech/adp-ae3xx/MAINTAINERS b/board/AndesTech/adp-ae3xx/MAINTAINERS
deleted file mode 100644
index 02e5a19c9d8..00000000000
--- a/board/AndesTech/adp-ae3xx/MAINTAINERS
+++ /dev/null
@@ -1,6 +0,0 @@
-ADP-AG101P BOARD
-M: Andes <uboot@andestech.com>
-S: Maintained
-F: board/AndesTech/adp-ae3xx/
-F: include/configs/adp-ae3xx.h
-F: configs/adp-ae3xx_defconfig
diff --git a/board/AndesTech/adp-ae3xx/Makefile b/board/AndesTech/adp-ae3xx/Makefile
deleted file mode 100644
index 8c889d1003d..00000000000
--- a/board/AndesTech/adp-ae3xx/Makefile
+++ /dev/null
@@ -1,6 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0+
-#
-# Copyright (C) 2016 Andes Technology Corporation
-# Rick Chen, Andes Technology Corporation <rick@andestech.com>
-
-obj-y := adp-ae3xx.o
diff --git a/board/AndesTech/adp-ae3xx/adp-ae3xx.c b/board/AndesTech/adp-ae3xx/adp-ae3xx.c
deleted file mode 100644
index 3c4a27d63f6..00000000000
--- a/board/AndesTech/adp-ae3xx/adp-ae3xx.c
+++ /dev/null
@@ -1,79 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Copyright (C) 2011 Andes Technology Corporation
- * Shawn Lin, Andes Technology Corporation <nobuhiro@andestech.com>
- * Macpaul Lin, Andes Technology Corporation <macpaul@andestech.com>
- */
-
-#include <init.h>
-#include <net.h>
-#include <asm/global_data.h>
-#include <asm/mach-types.h>
-#include <common.h>
-#include <flash.h>
-#if defined(CONFIG_FTMAC100) && !defined(CONFIG_DM_ETH)
-#include <netdev.h>
-#endif
-#include <linux/io.h>
-#include <faraday/ftsmc020.h>
-
-DECLARE_GLOBAL_DATA_PTR;
-
-/*
- * Miscellaneous platform dependent initializations
- */
-int board_init(void)
-{
- /*
- * refer to BOOT_PARAMETER_PA_BASE within
- * "linux/arch/nds32/include/asm/misc_spec.h"
- */
- printf("Board: %s\n" , CONFIG_SYS_BOARD);
- gd->bd->bi_arch_number = MACH_TYPE_ADPAE3XX;
- gd->bd->bi_boot_params = PHYS_SDRAM_0 + 0x400;
- return 0;
-}
-
-int dram_init(void)
-{
- unsigned long sdram_base = PHYS_SDRAM_0;
- unsigned long expected_size = PHYS_SDRAM_0_SIZE + PHYS_SDRAM_1_SIZE;
- unsigned long actual_size;
- actual_size = get_ram_size((void *)sdram_base, expected_size);
- gd->ram_size = actual_size;
- if (expected_size != actual_size) {
- printf("Warning: Only %lu of %lu MiB SDRAM is working\n",
- actual_size >> 20, expected_size >> 20);
- }
-
- return 0;
-}
-
-int dram_init_banksize(void)
-{
- gd->bd->bi_dram[0].start = PHYS_SDRAM_0;
- gd->bd->bi_dram[0].size = PHYS_SDRAM_0_SIZE;
- gd->bd->bi_dram[1].start = PHYS_SDRAM_1;
- gd->bd->bi_dram[1].size = PHYS_SDRAM_1_SIZE;
-
- return 0;
-}
-
-#if defined(CONFIG_FTMAC100) && !defined(CONFIG_DM_ETH)
-int board_eth_init(struct bd_info *bd)
-{
- return ftmac100_initialize(bd);
-}
-#endif
-
-ulong board_flash_get_legacy(ulong base, int banknum, flash_info_t *info)
-{
- if (banknum == 0) { /* non-CFI boot flash */
- info->portwidth = FLASH_CFI_8BIT;
- info->chipwidth = FLASH_CFI_BY8;
- info->interface = FLASH_CFI_X8;
- return 1;
- } else {
- return 0;
- }
-}
diff --git a/board/AndesTech/adp-ag101p/Kconfig b/board/AndesTech/adp-ag101p/Kconfig
deleted file mode 100644
index 0fb7a10409b..00000000000
--- a/board/AndesTech/adp-ag101p/Kconfig
+++ /dev/null
@@ -1,22 +0,0 @@
-if TARGET_ADP_AG101P
-
-config DEBUG_LED
- hex
- default 0x902FFFFC
-
-config SYS_CPU
- default "n1213"
-
-config SYS_BOARD
- default "adp-ag101p"
-
-config SYS_VENDOR
- default "AndesTech"
-
-config SYS_SOC
- default "ag101"
-
-config SYS_CONFIG_NAME
- default "adp-ag101p"
-
-endif
diff --git a/board/AndesTech/adp-ag101p/MAINTAINERS b/board/AndesTech/adp-ag101p/MAINTAINERS
deleted file mode 100644
index 9a2c7a3c161..00000000000
--- a/board/AndesTech/adp-ag101p/MAINTAINERS
+++ /dev/null
@@ -1,6 +0,0 @@
-ADP-AG101P BOARD
-M: Andes <uboot@andestech.com>
-S: Maintained
-F: board/AndesTech/adp-ag101p/
-F: include/configs/adp-ag101p.h
-F: configs/adp-ag101p_defconfig
diff --git a/board/AndesTech/adp-ag101p/Makefile b/board/AndesTech/adp-ag101p/Makefile
deleted file mode 100644
index 5398f7ed097..00000000000
--- a/board/AndesTech/adp-ag101p/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0+
-#
-# Copyright (C) 2011 Andes Technology Corporation
-# Shawn Lin, Andes Technology Corporation <nobuhiro@andestech.com>
-# Macpaul Lin, Andes Technology Corporation <macpaul@andestech.com>
-
-obj-y := adp-ag101p.o
diff --git a/board/AndesTech/adp-ag101p/adp-ag101p.c b/board/AndesTech/adp-ag101p/adp-ag101p.c
deleted file mode 100644
index 8848b7f9738..00000000000
--- a/board/AndesTech/adp-ag101p/adp-ag101p.c
+++ /dev/null
@@ -1,86 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Copyright (C) 2011 Andes Technology Corporation
- * Shawn Lin, Andes Technology Corporation <nobuhiro@andestech.com>
- * Macpaul Lin, Andes Technology Corporation <macpaul@andestech.com>
- */
-
-#include <common.h>
-#include <flash.h>
-#include <init.h>
-#include <net.h>
-#if defined(CONFIG_FTMAC100) && !defined(CONFIG_DM_ETH)
-#include <netdev.h>
-#endif
-#include <asm/global_data.h>
-#include <linux/io.h>
-#include <asm/io.h>
-#include <asm/mach-types.h>
-
-#include <faraday/ftsmc020.h>
-
-DECLARE_GLOBAL_DATA_PTR;
-
-/*
- * Miscellaneous platform dependent initializations
- */
-
-int board_init(void)
-{
- /*
- * refer to BOOT_PARAMETER_PA_BASE within
- * "linux/arch/nds32/include/asm/misc_spec.h"
- */
- printf("Board: %s\n" , CONFIG_SYS_BOARD);
- gd->bd->bi_arch_number = MACH_TYPE_ADPAG101P;
- gd->bd->bi_boot_params = PHYS_SDRAM_0 + 0x400;
-
- return 0;
-}
-
-int dram_init(void)
-{
- unsigned long sdram_base = PHYS_SDRAM_0;
- unsigned long expected_size = PHYS_SDRAM_0_SIZE + PHYS_SDRAM_1_SIZE;
- unsigned long actual_size;
-
- actual_size = get_ram_size((void *)sdram_base, expected_size);
-
- gd->ram_size = actual_size;
-
- if (expected_size != actual_size) {
- printf("Warning: Only %lu of %lu MiB SDRAM is working\n",
- actual_size >> 20, expected_size >> 20);
- }
-
- return 0;
-}
-
-int dram_init_banksize(void)
-{
- gd->bd->bi_dram[0].start = PHYS_SDRAM_0;
- gd->bd->bi_dram[0].size = PHYS_SDRAM_0_SIZE;
- gd->bd->bi_dram[1].start = PHYS_SDRAM_1;
- gd->bd->bi_dram[1].size = PHYS_SDRAM_1_SIZE;
-
- return 0;
-}
-
-#if defined(CONFIG_FTMAC100) && !defined(CONFIG_DM_ETH)
-int board_eth_init(struct bd_info *bd)
-{
- return ftmac100_initialize(bd);
-}
-#endif
-
-ulong board_flash_get_legacy(ulong base, int banknum, flash_info_t *info)
-{
- if (banknum == 0) { /* non-CFI boot flash */
- info->portwidth = FLASH_CFI_8BIT;
- info->chipwidth = FLASH_CFI_BY8;
- info->interface = FLASH_CFI_X8;
- return 1;
- } else {
- return 0;
- }
-}
diff --git a/board/atmel/sam9x60_curiosity/Kconfig b/board/atmel/sam9x60_curiosity/Kconfig
new file mode 100644
index 00000000000..ae84e0f32c9
--- /dev/null
+++ b/board/atmel/sam9x60_curiosity/Kconfig
@@ -0,0 +1,15 @@
+if TARGET_SAM9X60_CURIOSITY
+
+config SYS_BOARD
+ default "sam9x60_curiosity"
+
+config SYS_VENDOR
+ default "atmel"
+
+config SYS_SOC
+ default "at91"
+
+config SYS_CONFIG_NAME
+ default "sam9x60_curiosity"
+
+endif
diff --git a/board/atmel/sam9x60_curiosity/MAINTAINERS b/board/atmel/sam9x60_curiosity/MAINTAINERS
new file mode 100644
index 00000000000..3e1dce29803
--- /dev/null
+++ b/board/atmel/sam9x60_curiosity/MAINTAINERS
@@ -0,0 +1,7 @@
+SAM9X60 CURIOSITY BOARD
+M: Durai Manickam KR <durai.manickamkr@microchip.com>
+M: Eugen Hristev <eugen.hristev@microchip.com>
+S: Maintained
+F: board/atmel/sam9x60_curiosity/
+F: include/configs/sam9x60_curiosity.h
+F: configs/sam9x60_curiosity_mmc_defconfig
diff --git a/board/atmel/sam9x60_curiosity/Makefile b/board/atmel/sam9x60_curiosity/Makefile
new file mode 100644
index 00000000000..c4d17e66d42
--- /dev/null
+++ b/board/atmel/sam9x60_curiosity/Makefile
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Copyright (C) 2022 Microchip Technology Inc. and its subsidiaries
+#
+# Author: Durai Manickam KR <durai.manickamkr@microchip.com>
+
+obj-y += sam9x60_curiosity.o
diff --git a/board/atmel/sam9x60_curiosity/sam9x60_curiosity.c b/board/atmel/sam9x60_curiosity/sam9x60_curiosity.c
new file mode 100644
index 00000000000..00de2778125
--- /dev/null
+++ b/board/atmel/sam9x60_curiosity/sam9x60_curiosity.c
@@ -0,0 +1,75 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2022 Microchip Technology Inc. and its subsidiaries
+ *
+ * Author: Durai Manickam KR <durai.manickamkr@microchip.com>
+ */
+
+#include <common.h>
+#include <debug_uart.h>
+#include <fdtdec.h>
+#include <init.h>
+#include <asm/arch/at91_common.h>
+#include <asm/arch/at91_rstc.h>
+#include <asm/arch/at91_sfr.h>
+#include <asm/arch/at91sam9_smc.h>
+#include <asm/arch/clk.h>
+#include <asm/arch/gpio.h>
+#include <asm/global_data.h>
+#include <asm/io.h>
+#include <asm/mach-types.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+void at91_prepare_cpu_var(void);
+
+int board_late_init(void)
+{
+ at91_prepare_cpu_var();
+
+ return 0;
+}
+
+#ifdef CONFIG_DEBUG_UART_BOARD_INIT
+void board_debug_uart_init(void)
+{
+ at91_seriald_hw_init();
+}
+#endif
+
+int board_early_init_f(void)
+{
+#ifdef CONFIG_DEBUG_UART
+ debug_uart_init();
+#endif
+ return 0;
+}
+
+#define MAC24AA_MAC_OFFSET 0xfa
+
+#ifdef CONFIG_MISC_INIT_R
+int misc_init_r(void)
+{
+#ifdef CONFIG_I2C_EEPROM
+ at91_set_ethaddr(MAC24AA_MAC_OFFSET);
+#endif
+ return 0;
+}
+#endif
+
+int board_init(void)
+{
+ /* address of boot parameters */
+ gd->bd->bi_boot_params = gd->bd->bi_dram[0].start + 0x100;
+ return 0;
+}
+
+int dram_init_banksize(void)
+{
+ return fdtdec_setup_memory_banksize();
+}
+
+int dram_init(void)
+{
+ return fdtdec_setup_mem_size_base();
+}
diff --git a/boot/Kconfig b/boot/Kconfig
index ec5b956490d..4b0802b8c6e 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -292,6 +292,117 @@ endif # SPL
endif # FIT
+config BOOTSTD
+ bool "Standard boot support"
+ default y
+ depends on DM && OF_CONTROL && BLK
+ help
+ U-Boot supports a standard way of locating something to boot,
+ typically an Operating System such as Linux, provided by a distro such
+ as Arch Linux or Debian. Enable this to support iterating through
+ available bootdevs and using bootmeths to find bootflows suitable for
+ booting.
+
+ Standard boot is not a standard way of booting, just a framework
+ within U-Boot for supporting all the different ways that exist.
+
+ Terminology:
+
+ - bootdev - a device which can hold a distro (e.g. MMC)
+ - bootmeth - a method to scan a bootdev to find bootflows (owned by
+ U-Boot)
+ - bootflow - a description of how to boot (owned by the distro)
+
+config BOOTSTD_FULL
+ bool "Enhanced features for standard boot"
+ default y if SANDBOX
+ help
+ This enables various useful features for standard boot, which are not
+ essential for operation:
+
+ - bootdev, bootmeth commands
+ - extra features in the bootflow command
+ - support for selecting the ordering of bootmeths ("bootmeth order")
+ - support for selecting the ordering of bootdevs using the devicetree
+ as well as the "boot_targets" environment variable
+
+if BOOTSTD
+
+config BOOTSTD_BOOTCOMMAND
+ bool "Use bootstd to boot"
+ default y if !DISTRO_DEFAULTS
+ help
+ Enable this to select a default boot-command suitable for booting
+ with standard boot. This can be overridden by the board if needed,
+ but the default command should be enough for most boards which use
+ standard boot.
+
+ For now this is only selected if distro boot is NOT used, since
+ standard boot does not support all of the features of distro boot
+ yet.
+
+config BOOTMETH_DISTRO
+ bool "Bootdev support for distro boot"
+ depends on CMD_PXE
+ default y
+ help
+ Enables support for distro boot using bootdevs. This makes the
+ bootdevs look for a 'extlinux/extlinux.conf' on each filesystem
+ they scan.
+
+ This provides a way to try out standard boot on an existing boot flow.
+
+config BOOTMETH_DISTRO_PXE
+ bool "Bootdev support for distro boot over network"
+ depends on CMD_PXE && CMD_NET && DM_ETH
+ default y
+ help
+ Enables support for distro boot using bootdevs. This makes the
+ bootdevs look for a 'extlinux/extlinux.conf' on the tftp server.
+
+ This provides a way to try out standard boot on an existing boot flow.
+
+config BOOTMETH_EFILOADER
+ bool "Bootdev support for EFI boot"
+ depends on CMD_BOOTEFI
+ default y
+ help
+ Enables support for EFI boot using bootdevs. This makes the
+ bootdevs look for a 'boot<arch>.efi' on each filesystem
+ they scan. The resulting file is booted after enabling U-Boot's
+ EFI loader support.
+
+ The <arch> depends on the architecture of the board:
+
+ aa64 - aarch64 (ARM 64-bit)
+ arm - ARM 32-bit
+ ia32 - x86 32-bit
+ x64 - x86 64-bit
+ riscv32 - RISC-V 32-bit
+ riscv64 - RISC-V 64-bit
+
+ This provides a way to try out standard boot on an existing boot flow.
+
+config BOOTMETH_SANDBOX
+ def_bool y
+ depends on SANDBOX
+ help
+ This is a sandbox bootmeth driver used for testing. It always returns
+ -ENOTSUPP when attempting to boot.
+
+config BOOTMETH_SCRIPT
+ bool "Bootdev support for U-Boot scripts"
+ default y if BOOTSTD_FULL
+ help
+ Enables support for booting a distro via a U-Boot script. This makes
+ the bootdevs look for a 'boot/boot.scr' file which can be used to
+ boot the distro.
+
+ This provides a way to try out standard boot on an existing boot flow.
+ It is not enabled by default to save space.
+
+endif
+
config LEGACY_IMAGE_FORMAT
bool "Enable support for the legacy image format"
default y if !FIT_SIGNATURE
@@ -1162,7 +1273,9 @@ config USE_BOOTCOMMAND
config BOOTCOMMAND
string "bootcmd value"
depends on USE_BOOTCOMMAND && !USE_DEFAULT_ENV_FILE
- default "run distro_bootcmd" if DISTRO_DEFAULTS
+ default "bootflow scan -lb" if BOOTSTD_BOOTCOMMAND && CMD_BOOTFLOW_FULL
+ default "bootflow scan" if BOOTSTD_BOOTCOMMAND && !CMD_BOOTFLOW_FULL
+ default "run distro_bootcmd" if !BOOTSTD_BOOTCOMMAND && DISTRO_DEFAULTS
help
This is the string of commands that will be used as bootcmd and if
AUTOBOOT is set, automatically run.
diff --git a/boot/Makefile b/boot/Makefile
index 1b99e6ee33f..a70674259c1 100644
--- a/boot/Makefile
+++ b/boot/Makefile
@@ -18,6 +18,21 @@ endif
obj-y += image.o image-board.o
obj-$(CONFIG_ANDROID_AB) += android_ab.o
obj-$(CONFIG_ANDROID_BOOT_IMAGE) += image-android.o image-android-dt.o
+
+obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += bootdev-uclass.o system_bootdev.o
+obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += bootflow.o
+obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += bootmeth-uclass.o
+obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += bootstd-uclass.o
+
+obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_DISTRO) += bootmeth_distro.o
+obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_DISTRO_PXE) += bootmeth_pxe.o
+obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_EFILOADER) += bootmeth_efi.o
+obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_SANDBOX) += bootmeth_sandbox.o
+obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_SCRIPT) += bootmeth_script.o
+ifdef CONFIG_$(SPL_TPL_)BOOTSTD_FULL
+obj-$(CONFIG_$(SPL_TPL_)CMD_BOOTEFI_BOOTMGR) += bootmeth_efi_mgr.o
+endif
+
obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += image-fdt.o
obj-$(CONFIG_$(SPL_TPL_)FIT_SIGNATURE) += fdt_region.o
obj-$(CONFIG_$(SPL_TPL_)FIT) += image-fit.o
diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c
new file mode 100644
index 00000000000..1ede933c2f2
--- /dev/null
+++ b/boot/bootdev-uclass.c
@@ -0,0 +1,649 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2021 Google LLC
+ * Written by Simon Glass <sjg@chromium.org>
+ */
+
+#define LOG_CATEGORY UCLASS_BOOTSTD
+
+#include <common.h>
+#include <dm.h>
+#include <bootdev.h>
+#include <bootflow.h>
+#include <bootmeth.h>
+#include <bootstd.h>
+#include <env.h>
+#include <fs.h>
+#include <log.h>
+#include <malloc.h>
+#include <part.h>
+#include <sort.h>
+#include <dm/device-internal.h>
+#include <dm/lists.h>
+#include <dm/uclass-internal.h>
+
+enum {
+ /*
+ * Set some sort of limit on the number of partitions a bootdev can
+ * have. Note that for disks this limits the partitions numbers that
+ * are scanned to 1..MAX_BOOTFLOWS_PER_BOOTDEV
+ */
+ MAX_PART_PER_BOOTDEV = 30,
+
+ /* Maximum supported length of the "boot_targets" env string */
+ BOOT_TARGETS_MAX_LEN = 100,
+};
+
+int bootdev_add_bootflow(struct bootflow *bflow)
+{
+ struct bootdev_uc_plat *ucp = dev_get_uclass_plat(bflow->dev);
+ struct bootstd_priv *std;
+ struct bootflow *new;
+ int ret;
+
+ assert(bflow->dev);
+ ret = bootstd_get_priv(&std);
+ if (ret)
+ return ret;
+
+ new = malloc(sizeof(*bflow));
+ if (!new)
+ return log_msg_ret("bflow", -ENOMEM);
+ memcpy(new, bflow, sizeof(*bflow));
+
+ list_add_tail(&new->glob_node, &std->glob_head);
+ list_add_tail(&new->bm_node, &ucp->bootflow_head);
+
+ return 0;
+}
+
+int bootdev_first_bootflow(struct udevice *dev, struct bootflow **bflowp)
+{
+ struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev);
+
+ if (list_empty(&ucp->bootflow_head))
+ return -ENOENT;
+
+ *bflowp = list_first_entry(&ucp->bootflow_head, struct bootflow,
+ bm_node);
+
+ return 0;
+}
+
+int bootdev_next_bootflow(struct bootflow **bflowp)
+{
+ struct bootflow *bflow = *bflowp;
+ struct bootdev_uc_plat *ucp = dev_get_uclass_plat(bflow->dev);
+
+ *bflowp = NULL;
+
+ if (list_is_last(&bflow->bm_node, &ucp->bootflow_head))
+ return -ENOENT;
+
+ *bflowp = list_entry(bflow->bm_node.next, struct bootflow, bm_node);
+
+ return 0;
+}
+
+int bootdev_bind(struct udevice *parent, const char *drv_name, const char *name,
+ struct udevice **devp)
+{
+ struct udevice *dev;
+ char dev_name[30];
+ char *str;
+ int ret;
+
+ snprintf(dev_name, sizeof(dev_name), "%s.%s", parent->name, name);
+ str = strdup(dev_name);
+ if (!str)
+ return -ENOMEM;
+ ret = device_bind_driver(parent, drv_name, str, &dev);
+ if (ret)
+ return ret;
+ device_set_name_alloced(dev);
+ *devp = dev;
+
+ return 0;
+}
+
+int bootdev_find_in_blk(struct udevice *dev, struct udevice *blk,
+ struct bootflow_iter *iter, struct bootflow *bflow)
+{
+ struct blk_desc *desc = dev_get_uclass_plat(blk);
+ struct disk_partition info;
+ char partstr[20];
+ char name[60];
+ int ret;
+
+ /* Sanity check */
+ if (iter->part >= MAX_PART_PER_BOOTDEV)
+ return log_msg_ret("max", -ESHUTDOWN);
+
+ bflow->blk = blk;
+ if (iter->part)
+ snprintf(partstr, sizeof(partstr), "part_%x", iter->part);
+ else
+ strcpy(partstr, "whole");
+ snprintf(name, sizeof(name), "%s.%s", dev->name, partstr);
+ bflow->name = strdup(name);
+ if (!bflow->name)
+ return log_msg_ret("name", -ENOMEM);
+
+ bflow->part = iter->part;
+
+ ret = bootmeth_check(bflow->method, iter);
+ if (ret)
+ return log_msg_ret("check", ret);
+
+ /*
+ * partition numbers start at 0 so this cannot succeed, but it can tell
+ * us whether there is valid media there
+ */
+ ret = part_get_info(desc, iter->part, &info);
+ if (!iter->part && ret == -ENOENT)
+ ret = 0;
+
+ /*
+ * This error indicates the media is not present. Otherwise we just
+ * blindly scan the next partition. We could be more intelligent here
+ * and check which partition numbers actually exist.
+ */
+ if (ret == -EOPNOTSUPP)
+ ret = -ESHUTDOWN;
+ else
+ bflow->state = BOOTFLOWST_MEDIA;
+ if (ret)
+ return log_msg_ret("part", ret);
+
+ /*
+ * Currently we don't get the number of partitions, so just
+ * assume a large number
+ */
+ iter->max_part = MAX_PART_PER_BOOTDEV;
+
+ if (iter->part) {
+ ret = fs_set_blk_dev_with_part(desc, bflow->part);
+ bflow->state = BOOTFLOWST_PART;
+
+ /* Use an #ifdef due to info.sys_ind */
+#ifdef CONFIG_DOS_PARTITION
+ log_debug("%s: Found partition %x type %x fstype %d\n",
+ blk->name, bflow->part, info.sys_ind,
+ ret ? -1 : fs_get_type());
+#endif
+ if (ret)
+ return log_msg_ret("fs", ret);
+ bflow->state = BOOTFLOWST_FS;
+ }
+
+ ret = bootmeth_read_bootflow(bflow->method, bflow);
+ if (ret)
+ return log_msg_ret("method", ret);
+
+ return 0;
+}
+
+void bootdev_list(bool probe)
+{
+ struct udevice *dev;
+ int ret;
+ int i;
+
+ printf("Seq Probed Status Uclass Name\n");
+ printf("--- ------ ------ -------- ------------------\n");
+ if (probe)
+ ret = uclass_first_device_err(UCLASS_BOOTDEV, &dev);
+ else
+ ret = uclass_find_first_device(UCLASS_BOOTDEV, &dev);
+ for (i = 0; dev; i++) {
+ printf("%3x [ %c ] %6s %-9.9s %s\n", dev_seq(dev),
+ device_active(dev) ? '+' : ' ',
+ ret ? simple_itoa(ret) : "OK",
+ dev_get_uclass_name(dev_get_parent(dev)), dev->name);
+ if (probe)
+ ret = uclass_next_device_err(&dev);
+ else
+ ret = uclass_find_next_device(&dev);
+ }
+ printf("--- ------ ------ -------- ------------------\n");
+ printf("(%d bootdev%s)\n", i, i != 1 ? "s" : "");
+}
+
+int bootdev_setup_for_dev(struct udevice *parent, const char *drv_name)
+{
+ struct udevice *bdev;
+ int ret;
+
+ ret = device_find_first_child_by_uclass(parent, UCLASS_BOOTDEV,
+ &bdev);
+ if (ret) {
+ if (ret != -ENODEV) {
+ log_debug("Cannot access bootdev device\n");
+ return ret;
+ }
+
+ ret = bootdev_bind(parent, drv_name, "bootdev", &bdev);
+ if (ret) {
+ log_debug("Cannot create bootdev device\n");
+ return ret;
+ }
+ }
+
+ return 0;
+}
+
+int bootdev_setup_sibling_blk(struct udevice *blk, const char *drv_name)
+{
+ struct udevice *parent, *dev;
+ char dev_name[50];
+ int ret;
+
+ snprintf(dev_name, sizeof(dev_name), "%s.%s", blk->name, "bootdev");
+
+ parent = dev_get_parent(blk);
+ ret = device_find_child_by_name(parent, dev_name, &dev);
+ if (ret) {
+ char *str;
+
+ if (ret != -ENODEV) {
+ log_debug("Cannot access bootdev device\n");
+ return ret;
+ }
+ str = strdup(dev_name);
+ if (!str)
+ return -ENOMEM;
+
+ ret = device_bind_driver(parent, drv_name, str, &dev);
+ if (ret) {
+ log_debug("Cannot create bootdev device\n");
+ return ret;
+ }
+ device_set_name_alloced(dev);
+ }
+
+ return 0;
+}
+
+int bootdev_get_sibling_blk(struct udevice *dev, struct udevice **blkp)
+{
+ struct udevice *parent = dev_get_parent(dev);
+ struct udevice *blk;
+ int ret, len;
+ char *p;
+
+ if (device_get_uclass_id(dev) != UCLASS_BOOTDEV)
+ return -EINVAL;
+
+ /* This should always work if bootdev_setup_sibling_blk() was used */
+ p = strstr(dev->name, ".bootdev");
+ if (!p)
+ return log_msg_ret("str", -EINVAL);
+
+ len = p - dev->name;
+ ret = device_find_child_by_namelen(parent, dev->name, len, &blk);
+ if (ret)
+ return log_msg_ret("find", ret);
+ *blkp = blk;
+
+ return 0;
+}
+
+static int bootdev_get_from_blk(struct udevice *blk, struct udevice **bootdevp)
+{
+ struct udevice *parent = dev_get_parent(blk);
+ struct udevice *bootdev;
+ char dev_name[50];
+ int ret;
+
+ if (device_get_uclass_id(blk) != UCLASS_BLK)
+ return -EINVAL;
+
+ /* This should always work if bootdev_setup_sibling_blk() was used */
+ snprintf(dev_name, sizeof(dev_name), "%s.%s", blk->name, "bootdev");
+ ret = device_find_child_by_name(parent, dev_name, &bootdev);
+ if (ret)
+ return log_msg_ret("find", ret);
+ *bootdevp = bootdev;
+
+ return 0;
+}
+
+int bootdev_unbind_dev(struct udevice *parent)
+{
+ struct udevice *dev;
+ int ret;
+
+ ret = device_find_first_child_by_uclass(parent, UCLASS_BOOTDEV, &dev);
+ if (!ret) {
+ ret = device_remove(dev, DM_REMOVE_NORMAL);
+ if (ret)
+ return log_msg_ret("rem", ret);
+ ret = device_unbind(dev);
+ if (ret)
+ return log_msg_ret("unb", ret);
+ }
+
+ return 0;
+}
+
+/**
+ * bootdev_find_by_label() - Convert a label string to a bootdev device
+ *
+ * Looks up a label name to find the associated bootdev. For example, if the
+ * label name is "mmc2", this will find a bootdev for an mmc device whose
+ * sequence number is 2.
+ *
+ * @label: Label string to convert, e.g. "mmc2"
+ * @devp: Returns bootdev device corresponding to that boot label
+ * Return: 0 if OK, -EINVAL if the label name (e.g. "mmc") does not refer to a
+ * uclass, -ENOENT if no bootdev for that media has the sequence number
+ * (e.g. 2)
+ */
+int bootdev_find_by_label(const char *label, struct udevice **devp)
+{
+ struct udevice *media;
+ struct uclass *uc;
+ enum uclass_id id;
+ const char *end;
+ int seq;
+
+ seq = trailing_strtoln_end(label, NULL, &end);
+ id = uclass_get_by_namelen(label, end - label);
+ log_debug("find %s: seq=%d, id=%d/%s\n", label, seq, id,
+ uclass_get_name(id));
+ if (id == UCLASS_INVALID) {
+ log_warning("Unknown uclass '%s' in label\n", label);
+ return -EINVAL;
+ }
+ if (id == UCLASS_USB)
+ id = UCLASS_MASS_STORAGE;
+
+ /* Iterate through devices in the media uclass (e.g. UCLASS_MMC) */
+ uclass_id_foreach_dev(id, media, uc) {
+ struct udevice *bdev, *blk;
+ int ret;
+
+ /* if there is no seq, match anything */
+ if (seq != -1 && dev_seq(media) != seq) {
+ log_debug("- skip, media seq=%d\n", dev_seq(media));
+ continue;
+ }
+
+ ret = device_find_first_child_by_uclass(media, UCLASS_BOOTDEV,
+ &bdev);
+ if (ret) {
+ log_debug("- looking via blk, seq=%d, id=%d\n", seq,
+ id);
+ ret = blk_find_device(id, seq, &blk);
+ if (!ret) {
+ log_debug("- get from blk %s\n", blk->name);
+ ret = bootdev_get_from_blk(blk, &bdev);
+ }
+ }
+ if (!ret) {
+ log_debug("- found %s\n", bdev->name);
+ *devp = bdev;
+ return 0;
+ }
+ log_debug("- no device in %s\n", media->name);
+ }
+ log_warning("Unknown seq %d for label '%s'\n", seq, label);
+
+ return -ENOENT;
+}
+
+int bootdev_find_by_any(const char *name, struct udevice **devp)
+{
+ struct udevice *dev;
+ int ret, seq;
+ char *endp;
+
+ seq = simple_strtol(name, &endp, 16);
+
+ /* Select by name, label or number */
+ if (*endp) {
+ ret = uclass_get_device_by_name(UCLASS_BOOTDEV, name, &dev);
+ if (ret == -ENODEV) {
+ ret = bootdev_find_by_label(name, &dev);
+ if (ret) {
+ printf("Cannot find bootdev '%s' (err=%d)\n",
+ name, ret);
+ return ret;
+ }
+ ret = device_probe(dev);
+ }
+ if (ret) {
+ printf("Cannot probe bootdev '%s' (err=%d)\n", name,
+ ret);
+ return ret;
+ }
+ } else {
+ ret = uclass_get_device_by_seq(UCLASS_BOOTDEV, seq, &dev);
+ }
+ if (ret) {
+ printf("Cannot find '%s' (err=%d)\n", name, ret);
+ return ret;
+ }
+
+ *devp = dev;
+
+ return 0;
+}
+
+int bootdev_get_bootflow(struct udevice *dev, struct bootflow_iter *iter,
+ struct bootflow *bflow)
+{
+ const struct bootdev_ops *ops = bootdev_get_ops(dev);
+
+ if (!ops->get_bootflow)
+ return -ENOSYS;
+ memset(bflow, '\0', sizeof(*bflow));
+ bflow->dev = dev;
+ bflow->method = iter->method;
+ bflow->state = BOOTFLOWST_BASE;
+
+ return ops->get_bootflow(dev, iter, bflow);
+}
+
+void bootdev_clear_bootflows(struct udevice *dev)
+{
+ struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev);
+
+ while (!list_empty(&ucp->bootflow_head)) {
+ struct bootflow *bflow;
+
+ bflow = list_first_entry(&ucp->bootflow_head, struct bootflow,
+ bm_node);
+ bootflow_remove(bflow);
+ }
+}
+
+/**
+ * h_cmp_bootdev() - Compare two bootdevs to find out which should go first
+ *
+ * @v1: struct udevice * of first bootdev device
+ * @v2: struct udevice * of second bootdev device
+ * Return: sort order (<0 if dev1 < dev2, ==0 if equal, >0 if dev1 > dev2)
+ */
+static int h_cmp_bootdev(const void *v1, const void *v2)
+{
+ const struct udevice *dev1 = *(struct udevice **)v1;
+ const struct udevice *dev2 = *(struct udevice **)v2;
+ const struct bootdev_uc_plat *ucp1 = dev_get_uclass_plat(dev1);
+ const struct bootdev_uc_plat *ucp2 = dev_get_uclass_plat(dev2);
+ int diff;
+
+ /* Use priority first */
+ diff = ucp1->prio - ucp2->prio;
+ if (diff)
+ return diff;
+
+ /* Fall back to seq for devices of the same priority */
+ diff = dev_seq(dev1) - dev_seq(dev2);
+
+ return diff;
+}
+
+/**
+ * build_order() - Build the ordered list of bootdevs to use
+ *
+ * This builds an ordered list of devices by one of three methods:
+ * - using the boot_targets environment variable, if non-empty
+ * - using the bootdev-order devicetree property, if present
+ * - sorted by priority and sequence number
+ *
+ * @bootstd: BOOTSTD device to use
+ * @order: Bootdevs listed in default order
+ * @max_count: Number of entries in @order
+ * Return: number of bootdevs found in the ordering, or -E2BIG if the
+ * boot_targets string is too long, or -EXDEV if the ordering produced 0 results
+ */
+static int build_order(struct udevice *bootstd, struct udevice **order,
+ int max_count)
+{
+ const char *overflow_target = NULL;
+ const char *const *labels;
+ struct udevice *dev;
+ const char *targets;
+ int i, ret, count;
+
+ targets = env_get("boot_targets");
+ labels = IS_ENABLED(CONFIG_BOOTSTD_FULL) ?
+ bootstd_get_bootdev_order(bootstd) : NULL;
+ if (targets) {
+ char str[BOOT_TARGETS_MAX_LEN];
+ char *target;
+
+ if (strlen(targets) >= BOOT_TARGETS_MAX_LEN)
+ return log_msg_ret("len", -E2BIG);
+
+ /* make a copy of the string, since strok() will change it */
+ strcpy(str, targets);
+ for (i = 0, target = strtok(str, " "); target;
+ target = strtok(NULL, " ")) {
+ ret = bootdev_find_by_label(target, &dev);
+ if (!ret) {
+ if (i == max_count) {
+ overflow_target = target;
+ break;
+ }
+ order[i++] = dev;
+ }
+ }
+ count = i;
+ } else if (labels) {
+ int upto;
+
+ upto = 0;
+ for (i = 0; labels[i]; i++) {
+ ret = bootdev_find_by_label(labels[i], &dev);
+ if (!ret) {
+ if (upto == max_count) {
+ overflow_target = labels[i];
+ break;
+ }
+ order[upto++] = dev;
+ }
+ }
+ count = upto;
+ } else {
+ /* sort them into priority order */
+ count = max_count;
+ qsort(order, count, sizeof(struct udevice *), h_cmp_bootdev);
+ }
+
+ if (overflow_target) {
+ log_warning("Expected at most %d bootdevs, but overflowed with boot_target '%s'\n",
+ max_count, overflow_target);
+ }
+
+ if (!count)
+ return log_msg_ret("targ", -EXDEV);
+
+ return count;
+}
+
+int bootdev_setup_iter_order(struct bootflow_iter *iter, struct udevice **devp)
+{
+ struct udevice *bootstd, *dev = *devp, **order;
+ int upto, i;
+ int count;
+ int ret;
+
+ ret = uclass_first_device_err(UCLASS_BOOTSTD, &bootstd);
+ if (ret) {
+ log_err("Missing bootstd device\n");
+ return log_msg_ret("std", ret);
+ }
+
+ /* Handle scanning a single device */
+ if (dev) {
+ iter->flags |= BOOTFLOWF_SINGLE_DEV;
+ return 0;
+ }
+
+ count = uclass_id_count(UCLASS_BOOTDEV);
+ if (!count)
+ return log_msg_ret("count", -ENOENT);
+
+ order = calloc(count, sizeof(struct udevice *));
+ if (!order)
+ return log_msg_ret("order", -ENOMEM);
+
+ /*
+ * Get a list of bootdevs, in seq order (i.e. using aliases). There may
+ * be gaps so try to count up high enough to find them all.
+ */
+ for (i = 0, upto = 0; upto < count && i < 20 + count * 2; i++) {
+ ret = uclass_find_device_by_seq(UCLASS_BOOTDEV, i, &dev);
+ if (!ret)
+ order[upto++] = dev;
+ }
+ log_debug("Found %d bootdevs\n", count);
+ if (upto != count)
+ log_debug("Expected %d bootdevs, found %d using aliases\n",
+ count, upto);
+
+ count = build_order(bootstd, order, upto);
+ if (count < 0) {
+ free(order);
+ return log_msg_ret("build", count);
+ }
+
+ iter->dev_order = order;
+ iter->num_devs = count;
+ iter->cur_dev = 0;
+
+ dev = *order;
+ ret = device_probe(dev);
+ if (ret)
+ return log_msg_ret("probe", ret);
+ *devp = dev;
+
+ return 0;
+}
+
+static int bootdev_post_bind(struct udevice *dev)
+{
+ struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev);
+
+ INIT_LIST_HEAD(&ucp->bootflow_head);
+
+ return 0;
+}
+
+static int bootdev_pre_unbind(struct udevice *dev)
+{
+ bootdev_clear_bootflows(dev);
+
+ return 0;
+}
+
+UCLASS_DRIVER(bootdev) = {
+ .id = UCLASS_BOOTDEV,
+ .name = "bootdev",
+ .flags = DM_UC_FLAG_SEQ_ALIAS,
+ .per_device_plat_auto = sizeof(struct bootdev_uc_plat),
+ .post_bind = bootdev_post_bind,
+ .pre_unbind = bootdev_pre_unbind,
+};
diff --git a/boot/bootflow.c b/boot/bootflow.c
new file mode 100644
index 00000000000..24ba3c34660
--- /dev/null
+++ b/boot/bootflow.c
@@ -0,0 +1,411 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2021 Google LLC
+ * Written by Simon Glass <sjg@chromium.org>
+ */
+
+#define LOG_CATEGORY UCLASS_BOOTSTD
+
+#include <common.h>
+#include <bootdev.h>
+#include <bootflow.h>
+#include <bootmeth.h>
+#include <bootstd.h>
+#include <dm.h>
+#include <malloc.h>
+#include <dm/device-internal.h>
+#include <dm/uclass-internal.h>
+
+/* error codes used to signal running out of things */
+enum {
+ BF_NO_MORE_PARTS = -ESHUTDOWN,
+ BF_NO_MORE_DEVICES = -ENODEV,
+};
+
+/**
+ * bootflow_state - name for each state
+ *
+ * See enum bootflow_state_t for what each of these means
+ */
+static const char *const bootflow_state[BOOTFLOWST_COUNT] = {
+ "base",
+ "media",
+ "part",
+ "fs",
+ "file",
+ "ready",
+};
+
+const char *bootflow_state_get_name(enum bootflow_state_t state)
+{
+ /* This doesn't need to be a useful name, since it will never occur */
+ if (state < 0 || state >= BOOTFLOWST_COUNT)
+ return "?";
+
+ return bootflow_state[state];
+}
+
+int bootflow_first_glob(struct bootflow **bflowp)
+{
+ struct bootstd_priv *std;
+ int ret;
+
+ ret = bootstd_get_priv(&std);
+ if (ret)
+ return ret;
+
+ if (list_empty(&std->glob_head))
+ return -ENOENT;
+
+ *bflowp = list_first_entry(&std->glob_head, struct bootflow,
+ glob_node);
+
+ return 0;
+}
+
+int bootflow_next_glob(struct bootflow **bflowp)
+{
+ struct bootstd_priv *std;
+ struct bootflow *bflow = *bflowp;
+ int ret;
+
+ ret = bootstd_get_priv(&std);
+ if (ret)
+ return ret;
+
+ *bflowp = NULL;
+
+ if (list_is_last(&bflow->glob_node, &std->glob_head))
+ return -ENOENT;
+
+ *bflowp = list_entry(bflow->glob_node.next, struct bootflow, glob_node);
+
+ return 0;
+}
+
+void bootflow_iter_init(struct bootflow_iter *iter, int flags)
+{
+ memset(iter, '\0', sizeof(*iter));
+ iter->flags = flags;
+}
+
+void bootflow_iter_uninit(struct bootflow_iter *iter)
+{
+ free(iter->dev_order);
+ free(iter->method_order);
+}
+
+int bootflow_iter_drop_bootmeth(struct bootflow_iter *iter,
+ const struct udevice *bmeth)
+{
+ /* We only support disabling the current bootmeth */
+ if (bmeth != iter->method || iter->cur_method >= iter->num_methods ||
+ iter->method_order[iter->cur_method] != bmeth)
+ return -EINVAL;
+
+ memmove(&iter->method_order[iter->cur_method],
+ &iter->method_order[iter->cur_method + 1],
+ (iter->num_methods - iter->cur_method - 1) * sizeof(void *));
+
+ iter->num_methods--;
+
+ return 0;
+}
+
+static void bootflow_iter_set_dev(struct bootflow_iter *iter,
+ struct udevice *dev)
+{
+ iter->dev = dev;
+ if ((iter->flags & (BOOTFLOWF_SHOW | BOOTFLOWF_SINGLE_DEV)) ==
+ BOOTFLOWF_SHOW) {
+ if (dev)
+ printf("Scanning bootdev '%s':\n", dev->name);
+ else
+ printf("No more bootdevs\n");
+ }
+}
+
+/**
+ * iter_incr() - Move to the next item (method, part, bootdev)
+ *
+ * Return: 0 if OK, BF_NO_MORE_DEVICES if there are no more bootdevs
+ */
+static int iter_incr(struct bootflow_iter *iter)
+{
+ struct udevice *dev;
+ int ret;
+
+ if (iter->err == BF_NO_MORE_DEVICES)
+ return BF_NO_MORE_DEVICES;
+
+ if (iter->err != BF_NO_MORE_PARTS) {
+ /* Get the next boothmethod */
+ if (++iter->cur_method < iter->num_methods) {
+ iter->method = iter->method_order[iter->cur_method];
+ return 0;
+ }
+ }
+
+ /* No more bootmeths; start at the first one, and... */
+ iter->cur_method = 0;
+ iter->method = iter->method_order[iter->cur_method];
+
+ if (iter->err != BF_NO_MORE_PARTS) {
+ /* ...select next partition */
+ if (++iter->part <= iter->max_part)
+ return 0;
+ }
+
+ /* No more partitions; start at the first one and...*/
+ iter->part = 0;
+
+ /*
+ * Note: as far as we know, there is no partition table on the next
+ * bootdev, so set max_part to 0 until we discover otherwise. See
+ * bootdev_find_in_blk() for where this is set.
+ */
+ iter->max_part = 0;
+
+ /* ...select next bootdev */
+ if (iter->flags & BOOTFLOWF_SINGLE_DEV) {
+ ret = -ENOENT;
+ } else if (++iter->cur_dev == iter->num_devs) {
+ ret = -ENOENT;
+ bootflow_iter_set_dev(iter, NULL);
+ } else {
+ dev = iter->dev_order[iter->cur_dev];
+ ret = device_probe(dev);
+ if (!log_msg_ret("probe", ret))
+ bootflow_iter_set_dev(iter, dev);
+ }
+
+ /* if there are no more bootdevs, give up */
+ if (ret)
+ return log_msg_ret("incr", BF_NO_MORE_DEVICES);
+
+ return 0;
+}
+
+/**
+ * bootflow_check() - Check if a bootflow can be obtained
+ *
+ * @iter: Provides part, bootmeth to use
+ * @bflow: Bootflow to update on success
+ * Return: 0 if OK, -ENOSYS if there is no bootflow support on this device,
+ * BF_NO_MORE_PARTS if there are no more partitions on bootdev
+ */
+static int bootflow_check(struct bootflow_iter *iter, struct bootflow *bflow)
+{
+ struct udevice *dev;
+ int ret;
+
+ dev = iter->dev;
+ ret = bootdev_get_bootflow(dev, iter, bflow);
+
+ /* If we got a valid bootflow, return it */
+ if (!ret) {
+ log_debug("Bootdevice '%s' part %d method '%s': Found bootflow\n",
+ dev->name, iter->part, iter->method->name);
+ return 0;
+ }
+
+ /* Unless there is nothing more to try, move to the next device */
+ else if (ret != BF_NO_MORE_PARTS && ret != -ENOSYS) {
+ log_debug("Bootdevice '%s' part %d method '%s': Error %d\n",
+ dev->name, iter->part, iter->method->name, ret);
+ /*
+ * For 'all' we return all bootflows, even
+ * those with errors
+ */
+ if (iter->flags & BOOTFLOWF_ALL)
+ return log_msg_ret("all", ret);
+ }
+ if (ret)
+ return log_msg_ret("check", ret);
+
+ return 0;
+}
+
+int bootflow_scan_bootdev(struct udevice *dev, struct bootflow_iter *iter,
+ int flags, struct bootflow *bflow)
+{
+ int ret;
+
+ bootflow_iter_init(iter, flags);
+
+ ret = bootdev_setup_iter_order(iter, &dev);
+ if (ret)
+ return log_msg_ret("obdev", -ENODEV);
+ bootflow_iter_set_dev(iter, dev);
+
+ ret = bootmeth_setup_iter_order(iter);
+ if (ret)
+ return log_msg_ret("obmeth", -ENODEV);
+
+ /* Find the first bootmeth (there must be at least one!) */
+ iter->method = iter->method_order[iter->cur_method];
+
+ ret = bootflow_check(iter, bflow);
+ if (ret) {
+ if (ret != BF_NO_MORE_PARTS && ret != -ENOSYS) {
+ if (iter->flags & BOOTFLOWF_ALL)
+ return log_msg_ret("all", ret);
+ }
+ iter->err = ret;
+ ret = bootflow_scan_next(iter, bflow);
+ if (ret)
+ return log_msg_ret("get", ret);
+ }
+
+ return 0;
+}
+
+int bootflow_scan_first(struct bootflow_iter *iter, int flags,
+ struct bootflow *bflow)
+{
+ int ret;
+
+ ret = bootflow_scan_bootdev(NULL, iter, flags, bflow);
+ if (ret)
+ return log_msg_ret("start", ret);
+
+ return 0;
+}
+
+int bootflow_scan_next(struct bootflow_iter *iter, struct bootflow *bflow)
+{
+ int ret;
+
+ do {
+ ret = iter_incr(iter);
+ if (ret == BF_NO_MORE_DEVICES)
+ return log_msg_ret("done", ret);
+
+ if (!ret) {
+ ret = bootflow_check(iter, bflow);
+ if (!ret)
+ return 0;
+ iter->err = ret;
+ if (ret != BF_NO_MORE_PARTS && ret != -ENOSYS) {
+ if (iter->flags & BOOTFLOWF_ALL)
+ return log_msg_ret("all", ret);
+ }
+ } else {
+ iter->err = ret;
+ }
+
+ } while (1);
+}
+
+void bootflow_free(struct bootflow *bflow)
+{
+ free(bflow->name);
+ free(bflow->subdir);
+ free(bflow->fname);
+ free(bflow->buf);
+}
+
+void bootflow_remove(struct bootflow *bflow)
+{
+ list_del(&bflow->bm_node);
+ list_del(&bflow->glob_node);
+
+ bootflow_free(bflow);
+ free(bflow);
+}
+
+int bootflow_boot(struct bootflow *bflow)
+{
+ int ret;
+
+ if (bflow->state != BOOTFLOWST_READY)
+ return log_msg_ret("load", -EPROTO);
+
+ ret = bootmeth_boot(bflow->method, bflow);
+ if (ret)
+ return log_msg_ret("boot", ret);
+
+ /*
+ * internal error, should not get here since we should have booted
+ * something or returned an error
+ */
+
+ return log_msg_ret("end", -EFAULT);
+}
+
+int bootflow_run_boot(struct bootflow_iter *iter, struct bootflow *bflow)
+{
+ int ret;
+
+ printf("** Booting bootflow '%s' with %s\n", bflow->name,
+ bflow->method->name);
+ ret = bootflow_boot(bflow);
+ if (!IS_ENABLED(CONFIG_BOOTSTD_FULL)) {
+ printf("Boot failed (err=%d)\n", ret);
+ return ret;
+ }
+
+ switch (ret) {
+ case -EPROTO:
+ printf("Bootflow not loaded (state '%s')\n",
+ bootflow_state_get_name(bflow->state));
+ break;
+ case -ENOSYS:
+ printf("Boot method '%s' not supported\n", bflow->method->name);
+ break;
+ case -ENOTSUPP:
+ /* Disable this bootflow for this iteration */
+ if (iter) {
+ int ret2;
+
+ ret2 = bootflow_iter_drop_bootmeth(iter, bflow->method);
+ if (!ret2) {
+ printf("Boot method '%s' failed and will not be retried\n",
+ bflow->method->name);
+ }
+ }
+
+ break;
+ default:
+ printf("Boot failed (err=%d)\n", ret);
+ break;
+ }
+
+ return ret;
+}
+
+int bootflow_iter_uses_blk_dev(const struct bootflow_iter *iter)
+{
+ const struct udevice *media = dev_get_parent(iter->dev);
+ enum uclass_id id = device_get_uclass_id(media);
+
+ log_debug("uclass %d: %s\n", id, uclass_get_name(id));
+ if (id != UCLASS_ETH && id != UCLASS_BOOTSTD)
+ return 0;
+
+ return -ENOTSUPP;
+}
+
+int bootflow_iter_uses_network(const struct bootflow_iter *iter)
+{
+ const struct udevice *media = dev_get_parent(iter->dev);
+ enum uclass_id id = device_get_uclass_id(media);
+
+ log_debug("uclass %d: %s\n", id, uclass_get_name(id));
+ if (id == UCLASS_ETH)
+ return 0;
+
+ return -ENOTSUPP;
+}
+
+int bootflow_iter_uses_system(const struct bootflow_iter *iter)
+{
+ const struct udevice *media = dev_get_parent(iter->dev);
+ enum uclass_id id = device_get_uclass_id(media);
+
+ log_debug("uclass %d: %s\n", id, uclass_get_name(id));
+ if (id == UCLASS_BOOTSTD)
+ return 0;
+
+ return -ENOTSUPP;
+}
diff --git a/boot/bootmeth-uclass.c b/boot/bootmeth-uclass.c
new file mode 100644
index 00000000000..c040d5f92b2
--- /dev/null
+++ b/boot/bootmeth-uclass.c
@@ -0,0 +1,333 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2021 Google LLC
+ * Written by Simon Glass <sjg@chromium.org>
+ */
+
+#define LOG_CATEGORY UCLASS_BOOTSTD
+
+#include <common.h>
+#include <blk.h>
+#include <bootflow.h>
+#include <bootmeth.h>
+#include <bootstd.h>
+#include <dm.h>
+#include <env_internal.h>
+#include <fs.h>
+#include <malloc.h>
+#include <mapmem.h>
+#include <dm/uclass-internal.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+int bootmeth_check(struct udevice *dev, struct bootflow_iter *iter)
+{
+ const struct bootmeth_ops *ops = bootmeth_get_ops(dev);
+
+ if (!ops->check)
+ return 0;
+
+ return ops->check(dev, iter);
+}
+
+int bootmeth_read_bootflow(struct udevice *dev, struct bootflow *bflow)
+{
+ const struct bootmeth_ops *ops = bootmeth_get_ops(dev);
+
+ if (!ops->read_bootflow)
+ return -ENOSYS;
+
+ return ops->read_bootflow(dev, bflow);
+}
+
+int bootmeth_boot(struct udevice *dev, struct bootflow *bflow)
+{
+ const struct bootmeth_ops *ops = bootmeth_get_ops(dev);
+
+ if (!ops->boot)
+ return -ENOSYS;
+
+ return ops->boot(dev, bflow);
+}
+
+int bootmeth_read_file(struct udevice *dev, struct bootflow *bflow,
+ const char *file_path, ulong addr, ulong *sizep)
+{
+ const struct bootmeth_ops *ops = bootmeth_get_ops(dev);
+
+ if (!ops->read_file)
+ return -ENOSYS;
+
+ return ops->read_file(dev, bflow, file_path, addr, sizep);
+}
+
+/**
+ * bootmeth_setup_iter_order() - Set up the ordering of bootmeths to scan
+ *
+ * This sets up the ordering information in @iter, based on the selected
+ * ordering of the bootmethds in bootstd_priv->bootmeth_order. If there is no
+ * ordering there, then all bootmethods are added
+ *
+ * @iter: Iterator to update with the order
+ * Return: 0 if OK, -ENOENT if no bootdevs, -ENOMEM if out of memory, other -ve
+ * on other error
+ */
+int bootmeth_setup_iter_order(struct bootflow_iter *iter)
+{
+ struct bootstd_priv *std;
+ struct udevice **order;
+ int count;
+ int ret;
+
+ ret = bootstd_get_priv(&std);
+ if (ret)
+ return ret;
+
+ /* Create an array large enough */
+ count = std->bootmeth_count ? std->bootmeth_count :
+ uclass_id_count(UCLASS_BOOTMETH);
+ if (!count)
+ return log_msg_ret("count", -ENOENT);
+
+ order = calloc(count, sizeof(struct udevice *));
+ if (!order)
+ return log_msg_ret("order", -ENOMEM);
+
+ /* If we have an ordering, copy it */
+ if (IS_ENABLED(CONFIG_BOOTSTD_FULL) && std->bootmeth_count) {
+ memcpy(order, std->bootmeth_order,
+ count * sizeof(struct bootmeth *));
+ } else {
+ struct udevice *dev;
+ int i, upto;
+
+ /*
+ * Get a list of bootmethods, in seq order (i.e. using aliases).
+ * There may be gaps so try to count up high enough to find them
+ * all.
+ */
+ for (i = 0, upto = 0; upto < count && i < 20 + count * 2; i++) {
+ ret = uclass_get_device_by_seq(UCLASS_BOOTMETH, i,
+ &dev);
+ if (!ret)
+ order[upto++] = dev;
+ }
+ count = upto;
+ }
+
+ iter->method_order = order;
+ iter->num_methods = count;
+ iter->cur_method = 0;
+
+ return 0;
+}
+
+int bootmeth_set_order(const char *order_str)
+{
+ struct bootstd_priv *std;
+ struct udevice **order;
+ int count, ret, i, len;
+ const char *s, *p;
+
+ ret = bootstd_get_priv(&std);
+ if (ret)
+ return ret;
+
+ if (!order_str) {
+ free(std->bootmeth_order);
+ std->bootmeth_order = NULL;
+ std->bootmeth_count = 0;
+ return 0;
+ }
+
+ /* Create an array large enough */
+ count = uclass_id_count(UCLASS_BOOTMETH);
+ if (!count)
+ return log_msg_ret("count", -ENOENT);
+
+ order = calloc(count + 1, sizeof(struct udevice *));
+ if (!order)
+ return log_msg_ret("order", -ENOMEM);
+
+ for (i = 0, s = order_str; *s && i < count; s = p + (*p == ' '), i++) {
+ struct udevice *dev;
+
+ p = strchrnul(s, ' ');
+ len = p - s;
+ ret = uclass_find_device_by_namelen(UCLASS_BOOTMETH, s, len,
+ &dev);
+ if (ret) {
+ printf("Unknown bootmeth '%.*s'\n", len, s);
+ free(order);
+ return ret;
+ }
+ order[i] = dev;
+ }
+ order[i] = NULL;
+ free(std->bootmeth_order);
+ std->bootmeth_order = order;
+ std->bootmeth_count = i;
+
+ return 0;
+}
+
+/**
+ * setup_fs() - Set up read to read a file
+ *
+ * We must redo the setup before each filesystem operation. This function
+ * handles that, including setting the filesystem type if a block device is not
+ * being used
+ *
+ * @bflow: Information about file to try
+ * @desc: Block descriptor to read from (NULL if not a block device)
+ * Return: 0 if OK, -ve on error
+ */
+static int setup_fs(struct bootflow *bflow, struct blk_desc *desc)
+{
+ int ret;
+
+ if (desc) {
+ ret = fs_set_blk_dev_with_part(desc, bflow->part);
+ if (ret)
+ return log_msg_ret("set", ret);
+ } else if (IS_ENABLED(CONFIG_BOOTSTD_FULL) && bflow->fs_type) {
+ fs_set_type(bflow->fs_type);
+ }
+
+ return 0;
+}
+
+int bootmeth_try_file(struct bootflow *bflow, struct blk_desc *desc,
+ const char *prefix, const char *fname)
+{
+ char path[200];
+ loff_t size;
+ int ret, ret2;
+
+ snprintf(path, sizeof(path), "%s%s", prefix ? prefix : "", fname);
+ log_debug("trying: %s\n", path);
+
+ free(bflow->fname);
+ bflow->fname = strdup(path);
+ if (!bflow->fname)
+ return log_msg_ret("name", -ENOMEM);
+
+ if (IS_ENABLED(CONFIG_BOOTSTD_FULL) && bflow->fs_type)
+ fs_set_type(bflow->fs_type);
+
+ ret = fs_size(path, &size);
+ log_debug(" %s - err=%d\n", path, ret);
+
+ /* Sadly FS closes the file after fs_size() so we must redo this */
+ ret2 = setup_fs(bflow, desc);
+ if (ret2)
+ return log_msg_ret("fs", ret2);
+
+ if (ret)
+ return log_msg_ret("size", ret);
+
+ bflow->size = size;
+ bflow->state = BOOTFLOWST_FILE;
+
+ return 0;
+}
+
+int bootmeth_alloc_file(struct bootflow *bflow, uint size_limit, uint align)
+{
+ loff_t bytes_read;
+ ulong addr;
+ char *buf;
+ uint size;
+ int ret;
+
+ size = bflow->size;
+ log_debug(" - script file size %x\n", size);
+ if (size > size_limit)
+ return log_msg_ret("chk", -E2BIG);
+
+ buf = memalign(align, size + 1);
+ if (!buf)
+ return log_msg_ret("buf", -ENOMEM);
+ addr = map_to_sysmem(buf);
+
+ ret = fs_read(bflow->fname, addr, 0, 0, &bytes_read);
+ if (ret) {
+ free(buf);
+ return log_msg_ret("read", ret);
+ }
+ if (size != bytes_read)
+ return log_msg_ret("bread", -EINVAL);
+ buf[size] = '\0';
+ bflow->state = BOOTFLOWST_READY;
+ bflow->buf = buf;
+
+ return 0;
+}
+
+int bootmeth_common_read_file(struct udevice *dev, struct bootflow *bflow,
+ const char *file_path, ulong addr, ulong *sizep)
+{
+ struct blk_desc *desc = NULL;
+ loff_t len_read;
+ loff_t size;
+ int ret;
+
+ if (bflow->blk)
+ desc = dev_get_uclass_plat(bflow->blk);
+
+ ret = setup_fs(bflow, desc);
+ if (ret)
+ return log_msg_ret("fs", ret);
+
+ ret = fs_size(file_path, &size);
+ if (ret)
+ return log_msg_ret("size", ret);
+ if (size > *sizep)
+ return log_msg_ret("spc", -ENOSPC);
+
+ ret = setup_fs(bflow, desc);
+ if (ret)
+ return log_msg_ret("fs", ret);
+
+ ret = fs_read(file_path, addr, 0, 0, &len_read);
+ if (ret)
+ return ret;
+ *sizep = len_read;
+
+ return 0;
+}
+
+#ifdef CONFIG_BOOTSTD_FULL
+/**
+ * on_bootmeths() - Update the bootmeth order
+ *
+ * This will check for a valid baudrate and only apply it if valid.
+ */
+static int on_bootmeths(const char *name, const char *value, enum env_op op,
+ int flags)
+{
+ int ret;
+
+ switch (op) {
+ case env_op_create:
+ case env_op_overwrite:
+ ret = bootmeth_set_order(value);
+ if (ret)
+ return 1;
+ return 0;
+ case env_op_delete:
+ bootmeth_set_order(NULL);
+ fallthrough;
+ default:
+ return 0;
+ }
+}
+U_BOOT_ENV_CALLBACK(bootmeths, on_bootmeths);
+#endif /* CONFIG_BOOTSTD_FULL */
+
+UCLASS_DRIVER(bootmeth) = {
+ .id = UCLASS_BOOTMETH,
+ .name = "bootmeth",
+ .flags = DM_UC_FLAG_SEQ_ALIAS,
+ .per_device_plat_auto = sizeof(struct bootmeth_uc_plat),
+};
diff --git a/boot/bootmeth_distro.c b/boot/bootmeth_distro.c
new file mode 100644
index 00000000000..2b41e654ade
--- /dev/null
+++ b/boot/bootmeth_distro.c
@@ -0,0 +1,143 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Bootmethod for distro boot (syslinux boot from a block device)
+ *
+ * Copyright 2021 Google LLC
+ * Written by Simon Glass <sjg@chromium.org>
+ */
+
+#define LOG_CATEGORY UCLASS_BOOTSTD
+
+#include <common.h>
+#include <bootdev.h>
+#include <bootflow.h>
+#include <bootmeth.h>
+#include <bootstd.h>
+#include <command.h>
+#include <distro.h>
+#include <dm.h>
+#include <fs.h>
+#include <malloc.h>
+#include <mapmem.h>
+#include <mmc.h>
+#include <pxe_utils.h>
+
+static int disto_getfile(struct pxe_context *ctx, const char *file_path,
+ char *file_addr, ulong *sizep)
+{
+ struct distro_info *info = ctx->userdata;
+ ulong addr;
+ int ret;
+
+ addr = simple_strtoul(file_addr, NULL, 16);
+
+ /* Allow up to 1GB */
+ *sizep = 1 << 30;
+ ret = bootmeth_read_file(info->dev, info->bflow, file_path, addr,
+ sizep);
+ if (ret)
+ return log_msg_ret("read", ret);
+
+ return 0;
+}
+
+static int distro_check(struct udevice *dev, struct bootflow_iter *iter)
+{
+ int ret;
+
+ /* This only works on block devices */
+ ret = bootflow_iter_uses_blk_dev(iter);
+ if (ret)
+ return log_msg_ret("blk", ret);
+
+ return 0;
+}
+
+static int distro_read_bootflow(struct udevice *dev, struct bootflow *bflow)
+{
+ struct blk_desc *desc;
+ const char *const *prefixes;
+ struct udevice *bootstd;
+ const char *prefix;
+ loff_t size;
+ int ret, i;
+
+ ret = uclass_first_device_err(UCLASS_BOOTSTD, &bootstd);
+ if (ret)
+ return log_msg_ret("std", ret);
+
+ /* If a block device, we require a partition table */
+ if (bflow->blk && !bflow->part)
+ return -ENOENT;
+
+ prefixes = bootstd_get_prefixes(bootstd);
+ i = 0;
+ desc = bflow->blk ? dev_get_uclass_plat(bflow->blk) : NULL;
+ do {
+ prefix = prefixes ? prefixes[i] : NULL;
+
+ ret = bootmeth_try_file(bflow, desc, prefix, DISTRO_FNAME);
+ } while (ret && prefixes && prefixes[++i]);
+ if (ret)
+ return log_msg_ret("try", ret);
+ size = bflow->size;
+
+ ret = bootmeth_alloc_file(bflow, 0x10000, 1);
+ if (ret)
+ return log_msg_ret("read", ret);
+
+ return 0;
+}
+
+static int distro_boot(struct udevice *dev, struct bootflow *bflow)
+{
+ struct cmd_tbl cmdtp = {}; /* dummy */
+ struct pxe_context ctx;
+ struct distro_info info;
+ ulong addr;
+ int ret;
+
+ addr = map_to_sysmem(bflow->buf);
+ info.dev = dev;
+ info.bflow = bflow;
+ ret = pxe_setup_ctx(&ctx, &cmdtp, disto_getfile, &info, true,
+ bflow->subdir);
+ if (ret)
+ return log_msg_ret("ctx", -EINVAL);
+
+ ret = pxe_process(&ctx, addr, false);
+ if (ret)
+ return log_msg_ret("bread", -EINVAL);
+
+ return 0;
+}
+
+static int distro_bootmeth_bind(struct udevice *dev)
+{
+ struct bootmeth_uc_plat *plat = dev_get_uclass_plat(dev);
+
+ plat->desc = IS_ENABLED(CONFIG_BOOTSTD_FULL) ?
+ "Syslinux boot from a block device" : "syslinux";
+
+ return 0;
+}
+
+static struct bootmeth_ops distro_bootmeth_ops = {
+ .check = distro_check,
+ .read_bootflow = distro_read_bootflow,
+ .read_file = bootmeth_common_read_file,
+ .boot = distro_boot,
+};
+
+static const struct udevice_id distro_bootmeth_ids[] = {
+ { .compatible = "u-boot,distro-syslinux" },
+ { }
+};
+
+U_BOOT_DRIVER(bootmeth_distro) = {
+ .name = "bootmeth_distro",
+ .id = UCLASS_BOOTMETH,
+ .of_match = distro_bootmeth_ids,
+ .ops = &distro_bootmeth_ops,
+ .bind = distro_bootmeth_bind,
+};
diff --git a/boot/bootmeth_efi.c b/boot/bootmeth_efi.c
new file mode 100644
index 00000000000..d5438eb67b9
--- /dev/null
+++ b/boot/bootmeth_efi.c
@@ -0,0 +1,188 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Bootmethod for distro boot via EFI
+ *
+ * Copyright 2021 Google LLC
+ * Written by Simon Glass <sjg@chromium.org>
+ */
+
+#define LOG_CATEGORY UCLASS_BOOTSTD
+
+#include <common.h>
+#include <bootdev.h>
+#include <bootflow.h>
+#include <bootmeth.h>
+#include <command.h>
+#include <dm.h>
+#include <efi_loader.h>
+#include <fs.h>
+#include <malloc.h>
+#include <mapmem.h>
+#include <mmc.h>
+#include <pxe_utils.h>
+
+#define EFI_DIRNAME "efi/boot/"
+
+/**
+ * get_efi_leafname() - Get the leaf name for the EFI file we expect
+ *
+ * @str: Place to put leaf name for this architecture, e.g. "bootaa64.efi".
+ * Must have at least 16 bytes of space
+ * @max_len: Length of @str, must be >=16
+ */
+static int get_efi_leafname(char *str, int max_len)
+{
+ const char *base;
+
+ if (max_len < 16)
+ return log_msg_ret("spc", -ENOSPC);
+ if (IS_ENABLED(CONFIG_ARM64))
+ base = "bootaa64";
+ else if (IS_ENABLED(CONFIG_ARM))
+ base = "bootarm";
+ else if (IS_ENABLED(CONFIG_X86_RUN_32BIT))
+ base = "bootia32";
+ else if (IS_ENABLED(CONFIG_X86_RUN_64BIT))
+ base = "bootx64";
+ else if (IS_ENABLED(CONFIG_ARCH_RV32I))
+ base = "bootriscv32";
+ else if (IS_ENABLED(CONFIG_ARCH_RV64I))
+ base = "bootriscv64";
+ else if (IS_ENABLED(CONFIG_SANDBOX))
+ base = "bootsbox";
+ else
+ return -EINVAL;
+
+ strcpy(str, base);
+ strcat(str, ".efi");
+
+ return 0;
+}
+
+static int efiload_read_file(struct blk_desc *desc, struct bootflow *bflow)
+{
+ const struct udevice *media_dev;
+ int size = bflow->size;
+ const char *dev_name;
+ char devnum_str[9];
+ char dirname[200];
+ char *last_slash;
+ int ret;
+
+ ret = bootmeth_alloc_file(bflow, 0x2000000, 0x10000);
+ if (ret)
+ return log_msg_ret("read", ret);
+
+ /*
+ * This is a horrible hack to tell EFI about this boot device. Once we
+ * unify EFI with the rest of U-Boot we can clean this up. The same hack
+ * exists in multiple places, e.g. in the fs, tftp and load commands.
+ *
+ * Once we can clean up the EFI code to make proper use of driver model,
+ * this can go away.
+ */
+ media_dev = dev_get_parent(bflow->dev);
+ snprintf(devnum_str, sizeof(devnum_str), "%x", dev_seq(media_dev));
+
+ strlcpy(dirname, bflow->fname, sizeof(dirname));
+ last_slash = strrchr(dirname, '/');
+ if (last_slash)
+ *last_slash = '\0';
+
+ log_debug("setting bootdev %s, %s, %s, %p, %x\n",
+ dev_get_uclass_name(media_dev), devnum_str, bflow->fname,
+ bflow->buf, size);
+ dev_name = device_get_uclass_id(media_dev) == UCLASS_MASS_STORAGE ?
+ "usb" : dev_get_uclass_name(media_dev);
+ efi_set_bootdev(dev_name, devnum_str, bflow->fname, bflow->buf, size);
+
+ return 0;
+}
+
+static int distro_efi_check(struct udevice *dev, struct bootflow_iter *iter)
+{
+ int ret;
+
+ /* This only works on block devices */
+ ret = bootflow_iter_uses_blk_dev(iter);
+ if (ret)
+ return log_msg_ret("blk", ret);
+
+ return 0;
+}
+
+static int distro_efi_read_bootflow(struct udevice *dev, struct bootflow *bflow)
+{
+ struct blk_desc *desc = NULL;
+ char fname[sizeof(EFI_DIRNAME) + 16];
+ int ret;
+
+ /* We require a partition table */
+ if (!bflow->part)
+ return -ENOENT;
+
+ strcpy(fname, EFI_DIRNAME);
+ ret = get_efi_leafname(fname + strlen(fname),
+ sizeof(fname) - strlen(fname));
+ if (ret)
+ return log_msg_ret("leaf", ret);
+
+ if (bflow->blk)
+ desc = dev_get_uclass_plat(bflow->blk);
+ ret = bootmeth_try_file(bflow, desc, NULL, fname);
+ if (ret)
+ return log_msg_ret("try", ret);
+
+ ret = efiload_read_file(desc, bflow);
+ if (ret)
+ return log_msg_ret("read", -EINVAL);
+
+ return 0;
+}
+
+int distro_efi_boot(struct udevice *dev, struct bootflow *bflow)
+{
+ char cmd[50];
+
+ /*
+ * At some point we can add a real interface to bootefi so we can call
+ * this directly. For now, go through the CLI like distro boot.
+ */
+ snprintf(cmd, sizeof(cmd), "bootefi %lx %lx",
+ (ulong)map_to_sysmem(bflow->buf),
+ (ulong)map_to_sysmem(gd->fdt_blob));
+ if (run_command(cmd, 0))
+ return log_msg_ret("run", -EINVAL);
+
+ return 0;
+}
+
+static int distro_bootmeth_efi_bind(struct udevice *dev)
+{
+ struct bootmeth_uc_plat *plat = dev_get_uclass_plat(dev);
+
+ plat->desc = IS_ENABLED(CONFIG_BOOTSTD_FULL) ?
+ "EFI boot from an .efi file" : "EFI";
+
+ return 0;
+}
+
+static struct bootmeth_ops distro_efi_bootmeth_ops = {
+ .check = distro_efi_check,
+ .read_bootflow = distro_efi_read_bootflow,
+ .read_file = bootmeth_common_read_file,
+ .boot = distro_efi_boot,
+};
+
+static const struct udevice_id distro_efi_bootmeth_ids[] = {
+ { .compatible = "u-boot,distro-efi" },
+ { }
+};
+
+U_BOOT_DRIVER(bootmeth_efi) = {
+ .name = "bootmeth_efi",
+ .id = UCLASS_BOOTMETH,
+ .of_match = distro_efi_bootmeth_ids,
+ .ops = &distro_efi_bootmeth_ops,
+ .bind = distro_bootmeth_efi_bind,
+};
diff --git a/boot/bootmeth_efi_mgr.c b/boot/bootmeth_efi_mgr.c
new file mode 100644
index 00000000000..a6914466db7
--- /dev/null
+++ b/boot/bootmeth_efi_mgr.c
@@ -0,0 +1,86 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Bootmethod for EFI boot manager
+ *
+ * Copyright 2021 Google LLC
+ * Written by Simon Glass <sjg@chromium.org>
+ */
+
+#define LOG_CATEGORY UCLASS_BOOTSTD
+
+#include <common.h>
+#include <bootdev.h>
+#include <bootflow.h>
+#include <bootmeth.h>
+#include <command.h>
+#include <dm.h>
+
+static int efi_mgr_check(struct udevice *dev, struct bootflow_iter *iter)
+{
+ int ret;
+
+ /* Must be an bootstd device */
+ ret = bootflow_iter_uses_system(iter);
+ if (ret)
+ return log_msg_ret("net", ret);
+
+ return 0;
+}
+
+static int efi_mgr_read_bootflow(struct udevice *dev, struct bootflow *bflow)
+{
+ /*
+ * Just assume there is something to boot since we don't have any way
+ * of knowing in advance
+ */
+ bflow->state = BOOTFLOWST_READY;
+
+ return 0;
+}
+
+static int efi_mgr_read_file(struct udevice *dev, struct bootflow *bflow,
+ const char *file_path, ulong addr, ulong *sizep)
+{
+ /* Files are loaded by the 'bootefi bootmgr' command */
+
+ return -ENOSYS;
+}
+
+static int efi_mgr_boot(struct udevice *dev, struct bootflow *bflow)
+{
+ int ret;
+
+ /* Booting is handled by the 'bootefi bootmgr' command */
+ ret = run_command("bootefi bootmgr", 0);
+
+ return 0;
+}
+
+static int bootmeth_efi_mgr_bind(struct udevice *dev)
+{
+ struct bootmeth_uc_plat *plat = dev_get_uclass_plat(dev);
+
+ plat->desc = "EFI bootmgr flow";
+
+ return 0;
+}
+
+static struct bootmeth_ops efi_mgr_bootmeth_ops = {
+ .check = efi_mgr_check,
+ .read_bootflow = efi_mgr_read_bootflow,
+ .read_file = efi_mgr_read_file,
+ .boot = efi_mgr_boot,
+};
+
+static const struct udevice_id efi_mgr_bootmeth_ids[] = {
+ { .compatible = "u-boot,efi-bootmgr" },
+ { }
+};
+
+U_BOOT_DRIVER(bootmeth_zefi_mgr) = {
+ .name = "bootmeth_efi_mgr",
+ .id = UCLASS_BOOTMETH,
+ .of_match = efi_mgr_bootmeth_ids,
+ .ops = &efi_mgr_bootmeth_ops,
+ .bind = bootmeth_efi_mgr_bind,
+};
diff --git a/boot/bootmeth_pxe.c b/boot/bootmeth_pxe.c
new file mode 100644
index 00000000000..f1e2b4c7762
--- /dev/null
+++ b/boot/bootmeth_pxe.c
@@ -0,0 +1,186 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Bootmethod for distro boot using PXE (network boot)
+ *
+ * Copyright 2021 Google LLC
+ * Written by Simon Glass <sjg@chromium.org>
+ */
+
+#define LOG_CATEGORY UCLASS_BOOTSTD
+
+#include <common.h>
+#include <bootdev.h>
+#include <bootflow.h>
+#include <bootmeth.h>
+#include <command.h>
+#include <distro.h>
+#include <dm.h>
+#include <fs.h>
+#include <log.h>
+#include <malloc.h>
+#include <mapmem.h>
+#include <mmc.h>
+#include <net.h>
+#include <pxe_utils.h>
+
+static int disto_pxe_getfile(struct pxe_context *ctx, const char *file_path,
+ char *file_addr, ulong *sizep)
+{
+ struct distro_info *info = ctx->userdata;
+ ulong addr;
+ int ret;
+
+ addr = simple_strtoul(file_addr, NULL, 16);
+ ret = bootmeth_read_file(info->dev, info->bflow, file_path, addr,
+ sizep);
+ if (ret)
+ return log_msg_ret("read", ret);
+
+ return 0;
+}
+
+static int distro_pxe_check(struct udevice *dev, struct bootflow_iter *iter)
+{
+ int ret;
+
+ /* This only works on network devices */
+ ret = bootflow_iter_uses_network(iter);
+ if (ret)
+ return log_msg_ret("net", ret);
+
+ return 0;
+}
+
+static int distro_pxe_read_bootflow(struct udevice *dev, struct bootflow *bflow)
+{
+ const char *addr_str;
+ char fname[200];
+ char *bootdir;
+ ulong addr;
+ ulong size;
+ char *buf;
+ int ret;
+
+ addr_str = env_get("pxefile_addr_r");
+ if (!addr_str)
+ return log_msg_ret("pxeb", -EPERM);
+ addr = simple_strtoul(addr_str, NULL, 16);
+
+ log_debug("calling pxe_get()\n");
+ ret = pxe_get(addr, &bootdir, &size);
+ log_debug("pxe_get() returned %d\n", ret);
+ if (ret)
+ return log_msg_ret("pxeb", ret);
+ bflow->size = size;
+
+ /* Use the directory of the dhcp bootdir as our subdir, if provided */
+ if (bootdir) {
+ const char *last_slash;
+ int path_len;
+
+ last_slash = strrchr(bootdir, '/');
+ if (last_slash) {
+ path_len = (last_slash - bootdir) + 1;
+ bflow->subdir = malloc(path_len + 1);
+ memcpy(bflow->subdir, bootdir, path_len);
+ bflow->subdir[path_len] = '\0';
+ }
+ }
+ snprintf(fname, sizeof(fname), "%s%s",
+ bflow->subdir ? bflow->subdir : "", DISTRO_FNAME);
+
+ bflow->fname = strdup(fname);
+ if (!bflow->fname)
+ return log_msg_ret("name", -ENOMEM);
+
+ bflow->state = BOOTFLOWST_READY;
+
+ /* Allocate the buffer, including the \0 byte added by get_pxe_file() */
+ buf = malloc(size + 1);
+ if (!buf)
+ return log_msg_ret("buf", -ENOMEM);
+ memcpy(buf, map_sysmem(addr, 0), size + 1);
+ bflow->buf = buf;
+
+ return 0;
+}
+
+static int distro_pxe_read_file(struct udevice *dev, struct bootflow *bflow,
+ const char *file_path, ulong addr, ulong *sizep)
+{
+ char *tftp_argv[] = {"tftp", NULL, NULL, NULL};
+ struct pxe_context *ctx = dev_get_priv(dev);
+ char file_addr[17];
+ ulong size;
+ int ret;
+
+ sprintf(file_addr, "%lx", addr);
+ tftp_argv[1] = file_addr;
+ tftp_argv[2] = (void *)file_path;
+
+ if (do_tftpb(ctx->cmdtp, 0, 3, tftp_argv))
+ return -ENOENT;
+ ret = pxe_get_file_size(&size);
+ if (ret)
+ return log_msg_ret("tftp", ret);
+ if (size > *sizep)
+ return log_msg_ret("spc", -ENOSPC);
+ *sizep = size;
+
+ return 0;
+}
+
+static int distro_pxe_boot(struct udevice *dev, struct bootflow *bflow)
+{
+ struct pxe_context *ctx = dev_get_priv(dev);
+ struct cmd_tbl cmdtp = {}; /* dummy */
+ struct distro_info info;
+ ulong addr;
+ int ret;
+
+ addr = map_to_sysmem(bflow->buf);
+ info.dev = dev;
+ info.bflow = bflow;
+ info.cmdtp = &cmdtp;
+ ret = pxe_setup_ctx(ctx, &cmdtp, disto_pxe_getfile, &info, false,
+ bflow->subdir);
+ if (ret)
+ return log_msg_ret("ctx", -EINVAL);
+
+ ret = pxe_process(ctx, addr, false);
+ if (ret)
+ return log_msg_ret("bread", -EINVAL);
+
+ return 0;
+}
+
+static int distro_bootmeth_pxe_bind(struct udevice *dev)
+{
+ struct bootmeth_uc_plat *plat = dev_get_uclass_plat(dev);
+
+ plat->desc = IS_ENABLED(CONFIG_BOOTSTD_FULL) ?
+ "PXE boot from a network device" : "PXE";
+
+ return 0;
+}
+
+static struct bootmeth_ops distro_bootmeth_pxe_ops = {
+ .check = distro_pxe_check,
+ .read_bootflow = distro_pxe_read_bootflow,
+ .read_file = distro_pxe_read_file,
+ .boot = distro_pxe_boot,
+};
+
+static const struct udevice_id distro_bootmeth_pxe_ids[] = {
+ { .compatible = "u-boot,distro-pxe" },
+ { }
+};
+
+U_BOOT_DRIVER(bootmeth_pxe) = {
+ .name = "bootmeth_pxe",
+ .id = UCLASS_BOOTMETH,
+ .of_match = distro_bootmeth_pxe_ids,
+ .ops = &distro_bootmeth_pxe_ops,
+ .bind = distro_bootmeth_pxe_bind,
+ .priv_auto = sizeof(struct pxe_context),
+};
diff --git a/boot/bootmeth_sandbox.c b/boot/bootmeth_sandbox.c
new file mode 100644
index 00000000000..13ec5e95e64
--- /dev/null
+++ b/boot/bootmeth_sandbox.c
@@ -0,0 +1,69 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Bootmethod for sandbox testing
+ *
+ * Copyright 2021 Google LLC
+ * Written by Simon Glass <sjg@chromium.org>
+ */
+
+#define LOG_CATEGORY UCLASS_BOOTSTD
+
+#include <common.h>
+#include <bootdev.h>
+#include <bootflow.h>
+#include <bootmeth.h>
+#include <dm.h>
+
+static int sandbox_check(struct udevice *dev, struct bootflow_iter *iter)
+{
+ return 0;
+}
+
+static int sandbox_read_bootflow(struct udevice *dev, struct bootflow *bflow)
+{
+ /* pretend we are ready */
+ bflow->state = BOOTFLOWST_READY;
+
+ return 0;
+}
+
+static int sandbox_read_file(struct udevice *dev, struct bootflow *bflow,
+ const char *file_path, ulong addr, ulong *sizep)
+{
+ return -ENOSYS;
+}
+
+static int sandbox_boot(struct udevice *dev, struct bootflow *bflow)
+{
+ /* always fail: see bootflow_iter_disable() */
+ return -ENOTSUPP;
+}
+
+static int sandbox_bootmeth_bind(struct udevice *dev)
+{
+ struct bootmeth_uc_plat *plat = dev_get_uclass_plat(dev);
+
+ plat->desc = "Sandbox boot for testing";
+
+ return 0;
+}
+
+static struct bootmeth_ops sandbox_bootmeth_ops = {
+ .check = sandbox_check,
+ .read_bootflow = sandbox_read_bootflow,
+ .read_file = sandbox_read_file,
+ .boot = sandbox_boot,
+};
+
+static const struct udevice_id sandbox_bootmeth_ids[] = {
+ { .compatible = "u-boot,sandbox-syslinux" },
+ { }
+};
+
+U_BOOT_DRIVER(bootmeth_sandbox) = {
+ .name = "bootmeth_sandbox",
+ .id = UCLASS_BOOTMETH,
+ .of_match = sandbox_bootmeth_ids,
+ .ops = &sandbox_bootmeth_ops,
+ .bind = sandbox_bootmeth_bind,
+};
diff --git a/boot/bootmeth_script.c b/boot/bootmeth_script.c
new file mode 100644
index 00000000000..d1c3f940037
--- /dev/null
+++ b/boot/bootmeth_script.c
@@ -0,0 +1,139 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Bootmethod for booting via a U-Boot script
+ *
+ * Copyright 2021 Google LLC
+ * Written by Simon Glass <sjg@chromium.org>
+ */
+
+#define LOG_CATEGORY UCLASS_BOOTSTD
+
+#include <common.h>
+#include <blk.h>
+#include <bootflow.h>
+#include <bootmeth.h>
+#include <bootstd.h>
+#include <dm.h>
+#include <env.h>
+#include <fs.h>
+#include <image.h>
+#include <malloc.h>
+#include <mapmem.h>
+
+#define SCRIPT_FNAME1 "boot.scr.uimg"
+#define SCRIPT_FNAME2 "boot.scr"
+
+static int script_check(struct udevice *dev, struct bootflow_iter *iter)
+{
+ int ret;
+
+ /* This only works on block devices */
+ ret = bootflow_iter_uses_blk_dev(iter);
+ if (ret)
+ return log_msg_ret("blk", ret);
+
+ return 0;
+}
+
+static int script_read_bootflow(struct udevice *dev, struct bootflow *bflow)
+{
+ struct blk_desc *desc = NULL;
+ const char *const *prefixes;
+ struct udevice *bootstd;
+ const char *prefix;
+ int ret, i;
+
+ ret = uclass_first_device_err(UCLASS_BOOTSTD, &bootstd);
+ if (ret)
+ return log_msg_ret("std", ret);
+
+ /* We require a partition table */
+ if (!bflow->part)
+ return -ENOENT;
+
+ if (bflow->blk)
+ desc = dev_get_uclass_plat(bflow->blk);
+
+ prefixes = bootstd_get_prefixes(bootstd);
+ i = 0;
+ do {
+ prefix = prefixes ? prefixes[i] : NULL;
+
+ ret = bootmeth_try_file(bflow, desc, prefix, SCRIPT_FNAME1);
+ if (ret)
+ ret = bootmeth_try_file(bflow, desc, prefix,
+ SCRIPT_FNAME2);
+ } while (ret && prefixes && prefixes[++i]);
+ if (ret)
+ return log_msg_ret("try", ret);
+
+ bflow->subdir = strdup(prefix ? prefix : "");
+ if (!bflow->subdir)
+ return log_msg_ret("prefix", -ENOMEM);
+
+ ret = bootmeth_alloc_file(bflow, 0x10000, 1);
+ if (ret)
+ return log_msg_ret("read", ret);
+
+ return 0;
+}
+
+static int script_boot(struct udevice *dev, struct bootflow *bflow)
+{
+ struct blk_desc *desc = dev_get_uclass_plat(bflow->blk);
+ ulong addr;
+ int ret;
+
+ ret = env_set("devtype", blk_get_devtype(bflow->blk));
+ if (!ret)
+ ret = env_set_hex("devnum", desc->devnum);
+ if (!ret)
+ ret = env_set("prefix", bflow->subdir);
+ if (!ret && IS_ENABLED(CONFIG_ARCH_SUNXI) &&
+ !strcmp("mmc", blk_get_devtype(bflow->blk)))
+ ret = env_set_hex("mmc_bootdev", desc->devnum);
+ if (ret)
+ return log_msg_ret("env", ret);
+
+ log_debug("devtype: %s\n", env_get("devtype"));
+ log_debug("devnum: %s\n", env_get("devnum"));
+ log_debug("prefix: %s\n", env_get("prefix"));
+ log_debug("mmc_bootdev: %s\n", env_get("mmc_bootdev"));
+
+ addr = map_to_sysmem(bflow->buf);
+ ret = image_source_script(addr, NULL);
+ if (ret)
+ return log_msg_ret("boot", ret);
+
+ return 0;
+}
+
+static int script_bootmeth_bind(struct udevice *dev)
+{
+ struct bootmeth_uc_plat *plat = dev_get_uclass_plat(dev);
+
+ plat->desc = IS_ENABLED(CONFIG_BOOTSTD_FULL) ?
+ "Script boot from a block device" : "script";
+
+ return 0;
+}
+
+static struct bootmeth_ops script_bootmeth_ops = {
+ .check = script_check,
+ .read_bootflow = script_read_bootflow,
+ .read_file = bootmeth_common_read_file,
+ .boot = script_boot,
+};
+
+static const struct udevice_id script_bootmeth_ids[] = {
+ { .compatible = "u-boot,script" },
+ { }
+};
+
+U_BOOT_DRIVER(bootmeth_script) = {
+ .name = "bootmeth_script",
+ .id = UCLASS_BOOTMETH,
+ .of_match = script_bootmeth_ids,
+ .ops = &script_bootmeth_ops,
+ .bind = script_bootmeth_bind,
+};
diff --git a/boot/bootstd-uclass.c b/boot/bootstd-uclass.c
new file mode 100644
index 00000000000..3c6c32ae604
--- /dev/null
+++ b/boot/bootstd-uclass.c
@@ -0,0 +1,183 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Uclass implementation for standard boot
+ *
+ * Copyright 2021 Google LLC
+ * Written by Simon Glass <sjg@chromium.org>
+ */
+
+#include <common.h>
+#include <bootflow.h>
+#include <bootstd.h>
+#include <dm.h>
+#include <log.h>
+#include <malloc.h>
+#include <dm/device-internal.h>
+#include <dm/lists.h>
+#include <dm/read.h>
+#include <dm/uclass-internal.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/* These are used if filename-prefixes is not present */
+const char *const default_prefixes[] = {"/", "/boot/", NULL};
+
+static int bootstd_of_to_plat(struct udevice *dev)
+{
+ struct bootstd_priv *priv = dev_get_priv(dev);
+ int ret;
+
+ if (IS_ENABLED(CONFIG_BOOTSTD_FULL)) {
+ /* Don't check errors since livetree and flattree are different */
+ ret = dev_read_string_list(dev, "filename-prefixes",
+ &priv->prefixes);
+ dev_read_string_list(dev, "bootdev-order",
+ &priv->bootdev_order);
+ }
+
+ return 0;
+}
+
+static void bootstd_clear_glob_(struct bootstd_priv *priv)
+{
+ while (!list_empty(&priv->glob_head)) {
+ struct bootflow *bflow;
+
+ bflow = list_first_entry(&priv->glob_head, struct bootflow,
+ glob_node);
+ bootflow_remove(bflow);
+ }
+}
+
+void bootstd_clear_glob(void)
+{
+ struct bootstd_priv *std;
+
+ if (bootstd_get_priv(&std))
+ return;
+
+ bootstd_clear_glob_(std);
+}
+
+static int bootstd_remove(struct udevice *dev)
+{
+ struct bootstd_priv *priv = dev_get_priv(dev);
+
+ free(priv->prefixes);
+ free(priv->bootdev_order);
+ bootstd_clear_glob_(priv);
+
+ return 0;
+}
+
+const char *const *const bootstd_get_bootdev_order(struct udevice *dev)
+{
+ struct bootstd_priv *std = dev_get_priv(dev);
+
+ return std->bootdev_order;
+}
+
+const char *const *const bootstd_get_prefixes(struct udevice *dev)
+{
+ struct bootstd_priv *std = dev_get_priv(dev);
+
+ return std->prefixes ? std->prefixes : default_prefixes;
+}
+
+int bootstd_get_priv(struct bootstd_priv **stdp)
+{
+ struct udevice *dev;
+ int ret;
+
+ ret = uclass_first_device_err(UCLASS_BOOTSTD, &dev);
+ if (ret)
+ return ret;
+ *stdp = dev_get_priv(dev);
+
+ return 0;
+}
+
+static int bootstd_probe(struct udevice *dev)
+{
+ struct bootstd_priv *std = dev_get_priv(dev);
+
+ INIT_LIST_HEAD(&std->glob_head);
+
+ return 0;
+}
+
+/* For now, bind the boormethod device if none are found in the devicetree */
+int dm_scan_other(bool pre_reloc_only)
+{
+ struct driver *drv = ll_entry_start(struct driver, driver);
+ const int n_ents = ll_entry_count(struct driver, driver);
+ struct udevice *dev, *bootstd;
+ int i, ret;
+
+ /* These are not needed before relocation */
+ if (!(gd->flags & GD_FLG_RELOC))
+ return 0;
+
+ /* Create a bootstd device if needed */
+ uclass_find_first_device(UCLASS_BOOTSTD, &bootstd);
+ if (!bootstd) {
+ ret = device_bind_driver(gd->dm_root, "bootstd_drv", "bootstd",
+ &bootstd);
+ if (ret)
+ return log_msg_ret("bootstd", ret);
+ }
+
+ /* If there are no bootmeth devices, create them */
+ uclass_find_first_device(UCLASS_BOOTMETH, &dev);
+ if (dev)
+ return 0;
+
+ for (i = 0; i < n_ents; i++, drv++) {
+ /*
+ * Disable EFI Manager for now as no one uses it so it is
+ * confusing
+ */
+ if (drv->id == UCLASS_BOOTMETH &&
+ strcmp("efi_mgr_bootmeth", drv->name)) {
+ const char *name = drv->name;
+
+ if (!strncmp("bootmeth_", name, 9))
+ name += 9;
+ ret = device_bind(bootstd, drv, name, 0, ofnode_null(),
+ &dev);
+ if (ret)
+ return log_msg_ret("meth", ret);
+ }
+ }
+
+ /* Create the system bootdev too */
+ ret = device_bind_driver(bootstd, "system_bootdev", "system-bootdev",
+ &dev);
+ if (ret)
+ return log_msg_ret("sys", ret);
+
+ return 0;
+}
+
+static const struct udevice_id bootstd_ids[] = {
+ { .compatible = "u-boot,boot-std" },
+ { }
+};
+
+U_BOOT_DRIVER(bootstd_drv) = {
+ .id = UCLASS_BOOTSTD,
+ .name = "bootstd_drv",
+ .of_to_plat = bootstd_of_to_plat,
+ .probe = bootstd_probe,
+ .remove = bootstd_remove,
+ .of_match = bootstd_ids,
+ .priv_auto = sizeof(struct bootstd_priv),
+};
+
+UCLASS_DRIVER(bootstd) = {
+ .id = UCLASS_BOOTSTD,
+ .name = "bootstd",
+#if CONFIG_IS_ENABLED(OF_REAL)
+ .post_bind = dm_scan_fdt_dev,
+#endif
+};
diff --git a/boot/system_bootdev.c b/boot/system_bootdev.c
new file mode 100644
index 00000000000..432d2034780
--- /dev/null
+++ b/boot/system_bootdev.c
@@ -0,0 +1,66 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Bootdevice for system, used for bootmeths not tied to any partition device
+ *
+ * Copyright 2021 Google LLC
+ * Written by Simon Glass <sjg@chromium.org>
+ */
+
+#define LOG_CATEGORY UCLASS_BOOTSTD
+
+#include <common.h>
+#include <bootdev.h>
+#include <bootflow.h>
+#include <bootmeth.h>
+#include <command.h>
+#include <distro.h>
+#include <dm.h>
+#include <log.h>
+#include <net.h>
+
+static int system_get_bootflow(struct udevice *dev, struct bootflow_iter *iter,
+ struct bootflow *bflow)
+{
+ int ret;
+
+ /* Must be an bootstd device */
+ ret = bootflow_iter_uses_system(iter);
+ if (ret)
+ return log_msg_ret("net", ret);
+
+ ret = bootmeth_check(bflow->method, iter);
+ if (ret)
+ return log_msg_ret("check", ret);
+
+ ret = bootmeth_read_bootflow(bflow->method, bflow);
+ if (ret)
+ return log_msg_ret("method", ret);
+
+ return 0;
+}
+
+static int system_bootdev_bind(struct udevice *dev)
+{
+ struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev);
+
+ ucp->prio = BOOTDEVP_6_SYSTEM;
+
+ return 0;
+}
+
+struct bootdev_ops system_bootdev_ops = {
+ .get_bootflow = system_get_bootflow,
+};
+
+static const struct udevice_id system_bootdev_ids[] = {
+ { .compatible = "u-boot,bootdev-system" },
+ { }
+};
+
+U_BOOT_DRIVER(system_bootdev) = {
+ .name = "system_bootdev",
+ .id = UCLASS_BOOTDEV,
+ .ops = &system_bootdev_ops,
+ .bind = system_bootdev_bind,
+ .of_match = system_bootdev_ids,
+};
diff --git a/cmd/Kconfig b/cmd/Kconfig
index f580797d2d3..2b575a2b42d 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -211,6 +211,45 @@ config CMD_BOOTM_PRE_LOAD
This stage allow to check or modify the image provided
to the bootm command.
+config CMD_BOOTDEV
+ bool "bootdev"
+ depends on BOOTSTD
+ default y if BOOTSTD_FULL
+ help
+ Support listing available bootdevs (boot devices) which can provide an
+ OS to boot, as well as showing information about a particular one.
+
+ This command is not necessary for bootstd to work.
+
+config CMD_BOOTFLOW
+ bool "bootflow"
+ depends on BOOTSTD
+ default y
+ help
+ Support scanning for bootflows available with the bootdevs. The
+ bootflows can optionally be booted.
+
+config CMD_BOOTFLOW_FULL
+ bool "bootflow - extract subcommands"
+ depends on BOOTSTD_FULL
+ default y if BOOTSTD_FULL
+ help
+ Add the ability to list the available bootflows, select one and obtain
+ information about it.
+
+ This command is not necessary for bootstd to work.
+
+config CMD_BOOTMETH
+ bool "bootmeth"
+ depends on BOOTSTD
+ default y if BOOTSTD_FULL
+ help
+ Support listing available bootmethds (methods used to boot an
+ Operating System), as well as selecting the order that the bootmeths
+ are used.
+
+ This command is not necessary for bootstd to work.
+
config BOOTM_EFI
bool "Support booting UEFI FIT images"
depends on CMD_BOOTEFI && CMD_BOOTM && FIT
@@ -1246,6 +1285,7 @@ config CMD_OSD
config CMD_PART
bool "part"
+ depends on PARTITIONS
select HAVE_BLOCK_DEVICE
select PARTITION_UUIDS
help
diff --git a/cmd/Makefile b/cmd/Makefile
index ede634d731c..5e43a1e022e 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -19,6 +19,9 @@ obj-$(CONFIG_CMD_AB_SELECT) += ab_select.o
obj-$(CONFIG_CMD_ADC) += adc.o
obj-$(CONFIG_CMD_ARMFLASH) += armflash.o
obj-$(CONFIG_HAVE_BLOCK_DEVICE) += blk_common.o
+obj-$(CONFIG_CMD_BOOTDEV) += bootdev.o
+obj-$(CONFIG_CMD_BOOTFLOW) += bootflow.o
+obj-$(CONFIG_CMD_BOOTMETH) += bootmeth.o
obj-$(CONFIG_CMD_SOURCE) += source.o
obj-$(CONFIG_CMD_BCB) += bcb.o
obj-$(CONFIG_CMD_BDI) += bdinfo.o
diff --git a/cmd/bootdev.c b/cmd/bootdev.c
new file mode 100644
index 00000000000..ecd797c0503
--- /dev/null
+++ b/cmd/bootdev.c
@@ -0,0 +1,120 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * 'bootdev' command
+ *
+ * Copyright 2021 Google LLC
+ * Written by Simon Glass <sjg@chromium.org>
+ */
+
+#include <common.h>
+#include <bootdev.h>
+#include <bootflow.h>
+#include <bootstd.h>
+#include <command.h>
+#include <dm.h>
+#include <dm/device-internal.h>
+#include <dm/uclass-internal.h>
+
+static int bootdev_check_state(struct bootstd_priv **stdp)
+{
+ struct bootstd_priv *std;
+ int ret;
+
+ ret = bootstd_get_priv(&std);
+ if (ret)
+ return ret;
+ if (!std->cur_bootdev) {
+ printf("Please use 'bootdev select' first\n");
+ return -ENOENT;
+ }
+ *stdp = std;
+
+ return 0;
+}
+
+static int do_bootdev_list(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+ bool probe;
+
+ probe = argc >= 2 && !strcmp(argv[1], "-p");
+ bootdev_list(probe);
+
+ return 0;
+}
+
+static int do_bootdev_select(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+ struct bootstd_priv *std;
+ struct udevice *dev;
+ int ret;
+
+ ret = bootstd_get_priv(&std);
+ if (ret)
+ return CMD_RET_FAILURE;
+ if (argc < 2) {
+ std->cur_bootdev = NULL;
+ return 0;
+ }
+ if (bootdev_find_by_any(argv[1], &dev))
+ return CMD_RET_FAILURE;
+
+ std->cur_bootdev = dev;
+
+ return 0;
+}
+
+static int do_bootdev_info(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+ struct bootstd_priv *priv;
+ struct bootflow *bflow;
+ int ret, i, num_valid;
+ struct udevice *dev;
+ bool probe;
+
+ probe = argc >= 2 && !strcmp(argv[1], "-p");
+
+ ret = bootdev_check_state(&priv);
+ if (ret)
+ return CMD_RET_FAILURE;
+
+ dev = priv->cur_bootdev;
+
+ /* Count the number of bootflows, including how many are valid*/
+ num_valid = 0;
+ for (ret = bootdev_first_bootflow(dev, &bflow), i = 0;
+ !ret;
+ ret = bootdev_next_bootflow(&bflow), i++)
+ num_valid += bflow->state == BOOTFLOWST_READY;
+
+ /*
+ * Prove the device, if requested, otherwise assume that there is no
+ * error
+ */
+ ret = 0;
+ if (probe)
+ ret = device_probe(dev);
+
+ printf("Name: %s\n", dev->name);
+ printf("Sequence: %d\n", dev_seq(dev));
+ printf("Status: %s\n", ret ? simple_itoa(ret) : device_active(dev) ?
+ "Probed" : "OK");
+ printf("Uclass: %s\n", dev_get_uclass_name(dev_get_parent(dev)));
+ printf("Bootflows: %d (%d valid)\n", i, num_valid);
+
+ return 0;
+}
+
+#ifdef CONFIG_SYS_LONGHELP
+static char bootdev_help_text[] =
+ "list [-p] - list all available bootdevs (-p to probe)\n"
+ "bootdev select <bd> - select a bootdev by name | label | seq\n"
+ "bootdev info [-p] - show information about a bootdev (-p to probe)";
+#endif
+
+U_BOOT_CMD_WITH_SUBCMDS(bootdev, "Boot devices", bootdev_help_text,
+ U_BOOT_SUBCMD_MKENT(list, 2, 1, do_bootdev_list),
+ U_BOOT_SUBCMD_MKENT(select, 2, 1, do_bootdev_select),
+ U_BOOT_SUBCMD_MKENT(info, 2, 1, do_bootdev_info));
diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index 53d9f0e0dcc..d80353fa718 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -422,10 +422,11 @@ static int do_efibootmgr(void)
* Set up memory image for the binary to be loaded, prepare device path, and
* then call do_bootefi_exec() to execute it.
*
- * @image_opt: string of image start address
+ * @image_opt: string with image start address
+ * @size_opt: string with image size or NULL
* Return: status code
*/
-static int do_bootefi_image(const char *image_opt)
+static int do_bootefi_image(const char *image_opt, const char *size_opt)
{
void *image_buf;
unsigned long addr, size;
@@ -443,14 +444,21 @@ static int do_bootefi_image(const char *image_opt)
/* Check that a numeric value was passed */
if (!addr)
return CMD_RET_USAGE;
-
image_buf = map_sysmem(addr, 0);
- if (image_buf != image_addr) {
- log_err("No UEFI binary known at %s\n", image_opt);
- return CMD_RET_FAILURE;
+ if (size_opt) {
+ size = strtoul(size_opt, NULL, 16);
+ if (!size)
+ return CMD_RET_USAGE;
+ efi_clear_bootdev();
+ } else {
+ if (image_buf != image_addr) {
+ log_err("No UEFI binary known at %s\n",
+ image_opt);
+ return CMD_RET_FAILURE;
+ }
+ size = image_size;
}
- size = image_size;
}
ret = efi_run_image(image_buf, size);
@@ -654,7 +662,7 @@ static int do_bootefi(struct cmd_tbl *cmdtp, int flag, int argc,
return CMD_RET_FAILURE;
}
- if (argc > 2) {
+ if (argc > 2 && strcmp(argv[2], "-")) {
uintptr_t fdt_addr;
fdt_addr = hextoul(argv[2], NULL);
@@ -677,15 +685,15 @@ static int do_bootefi(struct cmd_tbl *cmdtp, int flag, int argc,
return do_efi_selftest();
#endif
- return do_bootefi_image(argv[1]);
+ return do_bootefi_image(argv[1], argc > 3 ? argv[3] : NULL);
}
#ifdef CONFIG_SYS_LONGHELP
static char bootefi_help_text[] =
- "<image address> [fdt address]\n"
- " - boot EFI payload stored at address <image address>.\n"
- " If specified, the device tree located at <fdt address> gets\n"
- " exposed as EFI configuration table.\n"
+ "<image address> [fdt address [image size]]\n"
+ " - boot EFI payload stored at <image address>\n"
+ " fdt address, address of device-tree or '-'\n"
+ " image size, required if image not preloaded\n"
#ifdef CONFIG_CMD_BOOTEFI_HELLO
"bootefi hello\n"
" - boot a sample Hello World application stored within U-Boot\n"
@@ -707,7 +715,7 @@ static char bootefi_help_text[] =
#endif
U_BOOT_CMD(
- bootefi, 3, 0, do_bootefi,
+ bootefi, 4, 0, do_bootefi,
"Boots an EFI payload from memory",
bootefi_help_text
);
diff --git a/cmd/bootflow.c b/cmd/bootflow.c
new file mode 100644
index 00000000000..af4b9c37323
--- /dev/null
+++ b/cmd/bootflow.c
@@ -0,0 +1,404 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * 'bootflow' command
+ *
+ * Copyright 2021 Google LLC
+ * Written by Simon Glass <sjg@chromium.org>
+ */
+
+#include <common.h>
+#include <bootdev.h>
+#include <bootflow.h>
+#include <bootstd.h>
+#include <command.h>
+#include <console.h>
+#include <dm.h>
+#include <mapmem.h>
+
+/**
+ * report_bootflow_err() - Report where a bootflow failed
+ *
+ * When a bootflow does not make it to the 'loaded' state, something went wrong.
+ * Print a helpful message if there is an error
+ *
+ * @bflow: Bootflow to process
+ * @err: Error code (0 if none)
+ */
+static void report_bootflow_err(struct bootflow *bflow, int err)
+{
+ if (!err)
+ return;
+
+ /* Indent out to 'Method' */
+ printf(" ** ");
+
+ switch (bflow->state) {
+ case BOOTFLOWST_BASE:
+ printf("No media/partition found");
+ break;
+ case BOOTFLOWST_MEDIA:
+ printf("No partition found");
+ break;
+ case BOOTFLOWST_PART:
+ printf("No filesystem found");
+ break;
+ case BOOTFLOWST_FS:
+ printf("File not found");
+ break;
+ case BOOTFLOWST_FILE:
+ printf("File cannot be loaded");
+ break;
+ case BOOTFLOWST_READY:
+ printf("Ready");
+ break;
+ case BOOTFLOWST_COUNT:
+ break;
+ }
+
+ printf(", err=%d\n", err);
+}
+
+/**
+ * show_bootflow() - Show the status of a bootflow
+ *
+ * @seq: Bootflow index
+ * @bflow: Bootflow to show
+ * @errors: True to show the error received, if any
+ */
+static void show_bootflow(int index, struct bootflow *bflow, bool errors)
+{
+ printf("%3x %-11s %-6s %-9.9s %4x %-25.25s %s\n", index,
+ bflow->method->name, bootflow_state_get_name(bflow->state),
+ dev_get_uclass_name(dev_get_parent(bflow->dev)), bflow->part,
+ bflow->name, bflow->fname);
+ if (errors)
+ report_bootflow_err(bflow, bflow->err);
+}
+
+static void show_header(void)
+{
+ printf("Seq Method State Uclass Part Name Filename\n");
+ printf("--- ----------- ------ -------- ---- ------------------------ ----------------\n");
+}
+
+static void show_footer(int count, int num_valid)
+{
+ printf("--- ----------- ------ -------- ---- ------------------------ ----------------\n");
+ printf("(%d bootflow%s, %d valid)\n", count, count != 1 ? "s" : "",
+ num_valid);
+}
+
+static int do_bootflow_scan(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+ struct bootstd_priv *std;
+ struct bootflow_iter iter;
+ struct udevice *dev;
+ struct bootflow bflow;
+ bool all = false, boot = false, errors = false, list = false;
+ int num_valid = 0;
+ bool has_args;
+ int ret, i;
+ int flags;
+
+ ret = bootstd_get_priv(&std);
+ if (ret)
+ return CMD_RET_FAILURE;
+ dev = std->cur_bootdev;
+
+ has_args = argc > 1 && *argv[1] == '-';
+ if (IS_ENABLED(CONFIG_CMD_BOOTFLOW_FULL)) {
+ if (has_args) {
+ all = strchr(argv[1], 'a');
+ boot = strchr(argv[1], 'b');
+ errors = strchr(argv[1], 'e');
+ list = strchr(argv[1], 'l');
+ argc--;
+ argv++;
+ }
+ if (argc > 1) {
+ const char *label = argv[1];
+
+ if (bootdev_find_by_any(label, &dev))
+ return CMD_RET_FAILURE;
+ }
+ } else {
+ if (has_args) {
+ printf("Flags not supported: enable CONFIG_BOOTFLOW_FULL\n");
+ return CMD_RET_USAGE;
+ }
+ boot = true;
+ }
+
+ std->cur_bootflow = NULL;
+
+ flags = 0;
+ if (list)
+ flags |= BOOTFLOWF_SHOW;
+ if (all)
+ flags |= BOOTFLOWF_ALL;
+
+ /*
+ * If we have a device, just scan for bootflows attached to that device
+ */
+ if (IS_ENABLED(CONFIG_CMD_BOOTFLOW_FULL) && dev) {
+ if (list) {
+ printf("Scanning for bootflows in bootdev '%s'\n",
+ dev->name);
+ show_header();
+ }
+ bootdev_clear_bootflows(dev);
+ for (i = 0,
+ ret = bootflow_scan_bootdev(dev, &iter, flags, &bflow);
+ i < 1000 && ret != -ENODEV;
+ i++, ret = bootflow_scan_next(&iter, &bflow)) {
+ bflow.err = ret;
+ if (!ret)
+ num_valid++;
+ ret = bootdev_add_bootflow(&bflow);
+ if (ret) {
+ printf("Out of memory\n");
+ return CMD_RET_FAILURE;
+ }
+ if (list)
+ show_bootflow(i, &bflow, errors);
+ if (boot && !bflow.err)
+ bootflow_run_boot(&iter, &bflow);
+ }
+ } else {
+ if (list) {
+ printf("Scanning for bootflows in all bootdevs\n");
+ show_header();
+ }
+ bootstd_clear_glob();
+
+ for (i = 0,
+ ret = bootflow_scan_first(&iter, flags, &bflow);
+ i < 1000 && ret != -ENODEV;
+ i++, ret = bootflow_scan_next(&iter, &bflow)) {
+ bflow.err = ret;
+ if (!ret)
+ num_valid++;
+ ret = bootdev_add_bootflow(&bflow);
+ if (ret) {
+ printf("Out of memory\n");
+ return CMD_RET_FAILURE;
+ }
+ if (list)
+ show_bootflow(i, &bflow, errors);
+ if (boot && !bflow.err)
+ bootflow_run_boot(&iter, &bflow);
+ }
+ }
+ bootflow_iter_uninit(&iter);
+ if (list)
+ show_footer(i, num_valid);
+
+ return 0;
+}
+
+#ifdef CONFIG_CMD_BOOTFLOW_FULL
+static int do_bootflow_list(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+ struct bootstd_priv *std;
+ struct udevice *dev;
+ struct bootflow *bflow;
+ int num_valid = 0;
+ bool errors = false;
+ int ret, i;
+
+ if (argc > 1 && *argv[1] == '-')
+ errors = strchr(argv[1], 'e');
+
+ ret = bootstd_get_priv(&std);
+ if (ret)
+ return CMD_RET_FAILURE;
+ dev = std->cur_bootdev;
+
+ /* If we have a device, just list bootflows attached to that device */
+ if (dev) {
+ printf("Showing bootflows for bootdev '%s'\n", dev->name);
+ show_header();
+ for (ret = bootdev_first_bootflow(dev, &bflow), i = 0;
+ !ret;
+ ret = bootdev_next_bootflow(&bflow), i++) {
+ num_valid += bflow->state == BOOTFLOWST_READY;
+ show_bootflow(i, bflow, errors);
+ }
+ } else {
+ printf("Showing all bootflows\n");
+ show_header();
+ for (ret = bootflow_first_glob(&bflow), i = 0;
+ !ret;
+ ret = bootflow_next_glob(&bflow), i++) {
+ num_valid += bflow->state == BOOTFLOWST_READY;
+ show_bootflow(i, bflow, errors);
+ }
+ }
+ show_footer(i, num_valid);
+
+ return 0;
+}
+
+static int do_bootflow_select(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+ struct bootstd_priv *std;
+ struct bootflow *bflow, *found;
+ struct udevice *dev;
+ const char *name;
+ char *endp;
+ int seq, i;
+ int ret;
+
+ ret = bootstd_get_priv(&std);
+ if (ret)
+ return CMD_RET_FAILURE;
+;
+ if (argc < 2) {
+ std->cur_bootflow = NULL;
+ return 0;
+ }
+ dev = std->cur_bootdev;
+
+ name = argv[1];
+ seq = simple_strtol(name, &endp, 16);
+ found = NULL;
+
+ /*
+ * If we have a bootdev device, only allow selection of bootflows
+ * attached to that device
+ */
+ if (dev) {
+ for (ret = bootdev_first_bootflow(dev, &bflow), i = 0;
+ !ret;
+ ret = bootdev_next_bootflow(&bflow), i++) {
+ if (*endp ? !strcmp(bflow->name, name) : i == seq) {
+ found = bflow;
+ break;
+ }
+ }
+ } else {
+ for (ret = bootflow_first_glob(&bflow), i = 0;
+ !ret;
+ ret = bootflow_next_glob(&bflow), i++) {
+ if (*endp ? !strcmp(bflow->name, name) : i == seq) {
+ found = bflow;
+ break;
+ }
+ }
+ }
+
+ if (!found) {
+ printf("Cannot find bootflow '%s' ", name);
+ if (dev)
+ printf("in bootdev '%s' ", dev->name);
+ printf("(err=%d)\n", ret);
+ return CMD_RET_FAILURE;
+ }
+ std->cur_bootflow = found;
+
+ return 0;
+}
+
+static int do_bootflow_info(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+ struct bootstd_priv *std;
+ struct bootflow *bflow;
+ bool dump = false;
+ int ret;
+
+ if (argc > 1 && *argv[1] == '-')
+ dump = strchr(argv[1], 'd');
+
+ ret = bootstd_get_priv(&std);
+ if (ret)
+ return CMD_RET_FAILURE;
+
+ if (!std->cur_bootflow) {
+ printf("No bootflow selected\n");
+ return CMD_RET_FAILURE;
+ }
+ bflow = std->cur_bootflow;
+
+ printf("Name: %s\n", bflow->name);
+ printf("Device: %s\n", bflow->dev->name);
+ printf("Block dev: %s\n", bflow->blk ? bflow->blk->name : "(none)");
+ printf("Method: %s\n", bflow->method->name);
+ printf("State: %s\n", bootflow_state_get_name(bflow->state));
+ printf("Partition: %d\n", bflow->part);
+ printf("Subdir: %s\n", bflow->subdir ? bflow->subdir : "(none)");
+ printf("Filename: %s\n", bflow->fname);
+ printf("Buffer: %lx\n", (ulong)map_to_sysmem(bflow->buf));
+ printf("Size: %x (%d bytes)\n", bflow->size, bflow->size);
+ printf("Error: %d\n", bflow->err);
+ if (dump && bflow->buf) {
+ /* Set some sort of maximum on the size */
+ int size = min(bflow->size, 10 << 10);
+ int i;
+
+ printf("Contents:\n\n");
+ for (i = 0; i < size; i++) {
+ putc(bflow->buf[i]);
+ if (!(i % 128) && ctrlc()) {
+ printf("...interrupted\n");
+ break;
+ }
+ }
+ }
+
+ return 0;
+}
+
+static int do_bootflow_boot(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+ struct bootstd_priv *std;
+ struct bootflow *bflow;
+ int ret;
+
+ ret = bootstd_get_priv(&std);
+ if (ret)
+ return CMD_RET_FAILURE;
+
+ /*
+ * Require a current bootflow. Users can use 'bootflow scan -b' to
+ * automatically scan and boot, if needed.
+ */
+ if (!std->cur_bootflow) {
+ printf("No bootflow selected\n");
+ return CMD_RET_FAILURE;
+ }
+ bflow = std->cur_bootflow;
+ ret = bootflow_run_boot(NULL, bflow);
+ if (ret)
+ return CMD_RET_FAILURE;
+
+ return 0;
+}
+#endif /* CONFIG_CMD_BOOTFLOW_FULL */
+
+#ifdef CONFIG_SYS_LONGHELP
+static char bootflow_help_text[] =
+#ifdef CONFIG_CMD_BOOTFLOW_FULL
+ "scan [-abel] [bdev] - scan for valid bootflows (-l list, -a all, -e errors, -b boot)\n"
+ "bootflow list [-e] - list scanned bootflows (-e errors)\n"
+ "bootflow select [<num>|<name>] - select a bootflow\n"
+ "bootflow info [-d] - show info on current bootflow (-d dump bootflow)\n"
+ "bootflow boot - boot current bootflow (or first available if none selected)";
+#else
+ "scan - boot first available bootflow\n";
+#endif
+#endif /* CONFIG_SYS_LONGHELP */
+
+U_BOOT_CMD_WITH_SUBCMDS(bootflow, "Boot flows", bootflow_help_text,
+ U_BOOT_SUBCMD_MKENT(scan, 3, 1, do_bootflow_scan),
+#ifdef CONFIG_CMD_BOOTFLOW_FULL
+ U_BOOT_SUBCMD_MKENT(list, 2, 1, do_bootflow_list),
+ U_BOOT_SUBCMD_MKENT(select, 2, 1, do_bootflow_select),
+ U_BOOT_SUBCMD_MKENT(info, 2, 1, do_bootflow_info),
+ U_BOOT_SUBCMD_MKENT(boot, 1, 1, do_bootflow_boot)
+#endif
+);
diff --git a/cmd/bootmenu.c b/cmd/bootmenu.c
index 409ef9a8480..d5734872720 100644
--- a/cmd/bootmenu.c
+++ b/cmd/bootmenu.c
@@ -463,7 +463,7 @@ static void bootmenu_show(int delay)
}
for (iter = bootmenu->first; iter; iter = iter->next) {
- if (!menu_item_add(menu, iter->key, iter))
+ if (menu_item_add(menu, iter->key, iter) != 1)
goto cleanup;
}
@@ -476,7 +476,7 @@ static void bootmenu_show(int delay)
init = 1;
- if (menu_get_choice(menu, &choice)) {
+ if (menu_get_choice(menu, &choice) == 1) {
iter = choice;
title = strdup(iter->title);
command = strdup(iter->command);
diff --git a/cmd/bootmeth.c b/cmd/bootmeth.c
new file mode 100644
index 00000000000..c9a27fe8ac6
--- /dev/null
+++ b/cmd/bootmeth.c
@@ -0,0 +1,113 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * 'bootmeth' command
+ *
+ * Copyright 2021 Google LLC
+ * Written by Simon Glass <sjg@chromium.org>
+ */
+
+#include <common.h>
+#include <bootdev.h>
+#include <bootmeth.h>
+#include <bootstd.h>
+#include <command.h>
+#include <dm.h>
+#include <malloc.h>
+#include <dm/uclass-internal.h>
+
+static int do_bootmeth_list(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+ struct bootstd_priv *std;
+ struct udevice *dev;
+ bool use_order;
+ bool all = false;
+ int ret;
+ int i;
+
+ if (argc > 1 && *argv[1] == '-') {
+ all = strchr(argv[1], 'a');
+ argc--;
+ argv++;
+ }
+
+ ret = bootstd_get_priv(&std);
+ if (ret) {
+ printf("Cannot get bootstd (err=%d)\n", ret);
+ return CMD_RET_FAILURE;
+ }
+
+ printf("Order Seq Name Description\n");
+ printf("----- --- ------------------ ------------------\n");
+
+ /*
+ * Use the ordering if we have one, so long as we are not trying to list
+ * all bootmethds
+ */
+ use_order = std->bootmeth_count && !all;
+ if (use_order)
+ dev = std->bootmeth_order[0];
+ else
+ ret = uclass_find_first_device(UCLASS_BOOTMETH, &dev);
+
+ for (i = 0; dev;) {
+ struct bootmeth_uc_plat *ucp = dev_get_uclass_plat(dev);
+ int order = i;
+
+ /*
+ * With the -a flag we may list bootdevs that are not in the
+ * ordering. Find their place in the order
+ */
+ if (all && std->bootmeth_count) {
+ int j;
+
+ /* Find the position of this bootmeth in the order */
+ order = -1;
+ for (j = 0; j < std->bootmeth_count; j++) {
+ if (std->bootmeth_order[j] == dev)
+ order = j;
+ }
+ }
+
+ if (order == -1)
+ printf("%5s", "-");
+ else
+ printf("%5x", order);
+ printf(" %3x %-19.19s %s\n", dev_seq(dev), dev->name,
+ ucp->desc);
+ i++;
+ if (use_order)
+ dev = std->bootmeth_order[i];
+ else
+ uclass_find_next_device(&dev);
+ }
+ printf("----- --- ------------------ ------------------\n");
+ printf("(%d bootmeth%s)\n", i, i != 1 ? "s" : "");
+
+ return 0;
+}
+
+static int do_bootmeth_order(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+ int ret;
+
+ ret = bootmeth_set_order(argv[1]);
+ if (ret) {
+ printf("Failed (err=%d)\n", ret);
+ return CMD_RET_FAILURE;
+ }
+ env_set("bootmeths", argv[1]);
+
+ return 0;
+}
+
+#ifdef CONFIG_SYS_LONGHELP
+static char bootmeth_help_text[] =
+ "list [-a] - list available bootmeths (-a all)\n"
+ "bootmeth order [<bd> ...] - select bootmeth order / subset to use";
+#endif
+
+U_BOOT_CMD_WITH_SUBCMDS(bootmeth, "Boot methods", bootmeth_help_text,
+ U_BOOT_SUBCMD_MKENT(list, 2, 1, do_bootmeth_list),
+ U_BOOT_SUBCMD_MKENT(order, CONFIG_SYS_MAXARGS, 1, do_bootmeth_order));
diff --git a/common/board_f.c b/common/board_f.c
index 4d7e40013e1..51d2f3c365e 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -272,7 +272,7 @@ static int setup_mon_len(void)
gd->mon_len = (ulong)&_end - (ulong)_init;
#elif defined(CONFIG_NIOS2) || defined(CONFIG_XTENSA)
gd->mon_len = CONFIG_SYS_MONITOR_LEN;
-#elif defined(CONFIG_NDS32) || defined(CONFIG_SH) || defined(CONFIG_RISCV)
+#elif defined(CONFIG_SH) || defined(CONFIG_RISCV)
gd->mon_len = (ulong)(&__bss_end) - (ulong)(&_start);
#elif defined(CONFIG_SYS_MONITOR_BASE)
/* TODO: use (ulong)&__bss_end - (ulong)&__text_start; ? */
diff --git a/common/board_r.c b/common/board_r.c
index 8dc87ed2be4..ff17720cf3f 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -120,7 +120,7 @@ static int initr_reloc_global_data(void)
{
#ifdef __ARM__
monitor_flash_len = _end - __image_copy_start;
-#elif defined(CONFIG_NDS32) || defined(CONFIG_RISCV)
+#elif defined(CONFIG_RISCV)
monitor_flash_len = (ulong)&_end - (ulong)&_start;
#elif !defined(CONFIG_SANDBOX) && !defined(CONFIG_NIOS2)
monitor_flash_len = (ulong)&__init_end - gd->relocaddr;
@@ -631,8 +631,7 @@ static init_fnc_t init_sequence_r[] = {
#ifdef CONFIG_ADDR_MAP
init_addr_map,
#endif
-#if defined(CONFIG_ARM) || defined(CONFIG_NDS32) || defined(CONFIG_RISCV) || \
- defined(CONFIG_SANDBOX)
+#if defined(CONFIG_ARM) || defined(CONFIG_RISCV) || defined(CONFIG_SANDBOX)
board_init, /* Setup chipselects */
#endif
/*
@@ -795,7 +794,7 @@ static init_fnc_t init_sequence_r[] = {
initr_mem,
#endif
#ifdef CONFIG_EFI_SETUP_EARLY
- (init_fnc_t)efi_init_obj_list,
+ efi_init_early,
#endif
run_main_loop,
};
diff --git a/common/main.c b/common/main.c
index 3f5214fd44b..682f3359ea3 100644
--- a/common/main.c
+++ b/common/main.c
@@ -54,8 +54,11 @@ void main_loop(void)
if (IS_ENABLED(CONFIG_UPDATE_TFTP))
update_tftp(0UL, NULL, NULL);
- if (IS_ENABLED(CONFIG_EFI_CAPSULE_ON_DISK_EARLY))
- efi_launch_capsules();
+ if (IS_ENABLED(CONFIG_EFI_CAPSULE_ON_DISK_EARLY)) {
+ /* efi_init_early() already called */
+ if (efi_init_obj_list() == EFI_SUCCESS)
+ efi_launch_capsules();
+ }
s = bootdelay_process();
if (cli_process_fdt(&s))
diff --git a/common/usb_storage.c b/common/usb_storage.c
index 291728f37e0..eaa31374ef7 100644
--- a/common/usb_storage.c
+++ b/common/usb_storage.c
@@ -34,6 +34,7 @@
#include <common.h>
#include <blk.h>
+#include <bootdev.h>
#include <command.h>
#include <dm.h>
#include <errno.h>
@@ -243,6 +244,16 @@ static int usb_stor_probe_device(struct usb_device *udev)
ret = blk_probe_or_unbind(dev);
if (ret)
return ret;
+
+ ret = bootdev_setup_sibling_blk(dev, "usb_bootdev");
+ if (ret) {
+ int ret2;
+
+ ret2 = device_unbind(dev);
+ if (ret2)
+ return log_msg_ret("bootdev", ret2);
+ return log_msg_ret("bootdev", ret);
+ }
}
#else
/* We don't have space to even probe if we hit the maximum */
diff --git a/configs/adp-ae3xx_defconfig b/configs/adp-ae3xx_defconfig
deleted file mode 100644
index a4990ce7594..00000000000
--- a/configs/adp-ae3xx_defconfig
+++ /dev/null
@@ -1,60 +0,0 @@
-CONFIG_NDS32=y
-CONFIG_SKIP_LOWLEVEL_INIT=y
-CONFIG_SYS_TEXT_BASE=0x4A000000
-CONFIG_SYS_MALLOC_LEN=0x80000
-CONFIG_SYS_MALLOC_F_LEN=0x400
-CONFIG_NR_DRAM_BANKS=2
-CONFIG_ENV_SIZE=0x2000
-CONFIG_ENV_OFFSET=0x140000
-CONFIG_ENV_SECT_SIZE=0x1000
-CONFIG_DEFAULT_DEVICE_TREE="ae3xx"
-CONFIG_SYS_CLK_FREQ=39062500
-CONFIG_SYS_LOAD_ADDR=0x300000
-CONFIG_TARGET_ADP_AE3XX=y
-CONFIG_FIT=y
-CONFIG_SYS_MONITOR_BASE=0x88000000
-CONFIG_BOOTDELAY=3
-# CONFIG_AUTO_COMPLETE is not set
-CONFIG_SYS_PROMPT="NDS32 # "
-CONFIG_CMD_IMLS=y
-CONFIG_CMD_MMC=y
-CONFIG_CMD_SF_TEST=y
-# CONFIG_CMD_SETEXPR is not set
-CONFIG_CMD_DHCP=y
-CONFIG_CMD_PING=y
-CONFIG_CMD_CACHE=y
-CONFIG_CMD_DATE=y
-CONFIG_CMD_EXT2=y
-CONFIG_CMD_FAT=y
-CONFIG_OF_CONTROL=y
-CONFIG_OF_EMBED=y
-CONFIG_ENV_OVERWRITE=y
-CONFIG_ENV_IS_IN_SPI_FLASH=y
-CONFIG_SYS_RELOC_GD_ENV_ADDR=y
-CONFIG_BOOTP_SEND_HOSTNAME=y
-CONFIG_NET_RANDOM_ETHADDR=y
-CONFIG_BOOTP_SERVERIP=y
-CONFIG_DM=y
-CONFIG_CLK=y
-CONFIG_MMC=y
-CONFIG_FTSDC010=y
-CONFIG_FTSDC010_SDIO=y
-CONFIG_MTD=y
-CONFIG_DM_MTD=y
-CONFIG_MTD_NOR_FLASH=y
-CONFIG_CFI_FLASH=y
-CONFIG_SYS_FLASH_USE_BUFFER_WRITE=y
-CONFIG_SYS_FLASH_CFI=y
-CONFIG_DM_SPI_FLASH=y
-CONFIG_SPI_FLASH_MACRONIX=y
-CONFIG_DM_ETH=y
-CONFIG_FTMAC100=y
-CONFIG_BAUDRATE=38400
-CONFIG_DM_SERIAL=y
-CONFIG_SYS_NS16550=y
-CONFIG_SPI=y
-CONFIG_DM_SPI=y
-CONFIG_ATCSPI200_SPI=y
-CONFIG_TIMER=y
-CONFIG_ATCPIT100_TIMER=y
-CONFIG_PANIC_HANG=y
diff --git a/configs/adp-ag101p_defconfig b/configs/adp-ag101p_defconfig
deleted file mode 100644
index a9649e4b218..00000000000
--- a/configs/adp-ag101p_defconfig
+++ /dev/null
@@ -1,49 +0,0 @@
-CONFIG_NDS32=y
-CONFIG_SKIP_LOWLEVEL_INIT=y
-CONFIG_SYS_TEXT_BASE=0x11000000
-CONFIG_SYS_MALLOC_LEN=0x80000
-CONFIG_SYS_MALLOC_F_LEN=0x400
-CONFIG_NR_DRAM_BANKS=2
-CONFIG_ENV_SIZE=0x2000
-CONFIG_ENV_SECT_SIZE=0x20000
-CONFIG_DEFAULT_DEVICE_TREE="ag101p"
-CONFIG_SYS_CLK_FREQ=39062500
-CONFIG_SYS_LOAD_ADDR=0x300000
-CONFIG_ENV_ADDR=0x80140000
-CONFIG_TARGET_ADP_AG101P=y
-CONFIG_FIT=y
-CONFIG_SYS_MONITOR_BASE=0x80000000
-CONFIG_BOOTDELAY=3
-# CONFIG_AUTO_COMPLETE is not set
-CONFIG_SYS_PROMPT="NDS32 # "
-CONFIG_CMD_IMLS=y
-CONFIG_CMD_MMC=y
-# CONFIG_CMD_SETEXPR is not set
-CONFIG_CMD_DHCP=y
-CONFIG_CMD_PING=y
-CONFIG_CMD_CACHE=y
-CONFIG_CMD_DATE=y
-CONFIG_CMD_EXT2=y
-CONFIG_CMD_FAT=y
-CONFIG_OF_CONTROL=y
-CONFIG_OF_EMBED=y
-CONFIG_ENV_OVERWRITE=y
-CONFIG_ENV_IS_IN_FLASH=y
-CONFIG_BOOTP_SEND_HOSTNAME=y
-CONFIG_NET_RANDOM_ETHADDR=y
-CONFIG_BOOTP_SERVERIP=y
-CONFIG_DM=y
-CONFIG_MMC=y
-CONFIG_FTSDC010=y
-CONFIG_FTSDC010_SDIO=y
-CONFIG_MTD_NOR_FLASH=y
-CONFIG_FLASH_CFI_DRIVER=y
-CONFIG_SYS_FLASH_USE_BUFFER_WRITE=y
-CONFIG_SYS_FLASH_CFI=y
-CONFIG_DM_ETH=y
-CONFIG_FTMAC100=y
-CONFIG_BAUDRATE=38400
-CONFIG_DM_SERIAL=y
-CONFIG_SYS_NS16550=y
-CONFIG_TIMER=y
-CONFIG_AG101P_TIMER=y
diff --git a/configs/chromebit_mickey_defconfig b/configs/chromebit_mickey_defconfig
index b6456b431ef..81662915d24 100644
--- a/configs/chromebit_mickey_defconfig
+++ b/configs/chromebit_mickey_defconfig
@@ -44,7 +44,6 @@ CONFIG_CMD_PMIC=y
CONFIG_CMD_REGULATOR=y
# CONFIG_SPL_DOS_PARTITION is not set
# CONFIG_SPL_EFI_PARTITION is not set
-CONFIG_SPL_PARTITION_UUIDS=y
CONFIG_SPL_OF_CONTROL=y
CONFIG_OF_SPL_REMOVE_PROPS="pinctrl-0 pinctrl-names clock-names interrupt-parent assigned-clocks assigned-clock-rates assigned-clock-parents"
CONFIG_SPL_OF_PLATDATA=y
diff --git a/configs/chromebook_jerry_defconfig b/configs/chromebook_jerry_defconfig
index 5e23e96ecae..d3d9f8fc0ba 100644
--- a/configs/chromebook_jerry_defconfig
+++ b/configs/chromebook_jerry_defconfig
@@ -46,7 +46,6 @@ CONFIG_CMD_PMIC=y
CONFIG_CMD_REGULATOR=y
# CONFIG_SPL_DOS_PARTITION is not set
# CONFIG_SPL_EFI_PARTITION is not set
-CONFIG_SPL_PARTITION_UUIDS=y
CONFIG_SPL_OF_CONTROL=y
CONFIG_OF_SPL_REMOVE_PROPS="pinctrl-0 pinctrl-names clock-names interrupt-parent assigned-clocks assigned-clock-rates assigned-clock-parents"
CONFIG_SPL_OF_PLATDATA=y
diff --git a/configs/chromebook_minnie_defconfig b/configs/chromebook_minnie_defconfig
index a347ae96bfc..63899f37aaa 100644
--- a/configs/chromebook_minnie_defconfig
+++ b/configs/chromebook_minnie_defconfig
@@ -46,7 +46,6 @@ CONFIG_CMD_PMIC=y
CONFIG_CMD_REGULATOR=y
# CONFIG_SPL_DOS_PARTITION is not set
# CONFIG_SPL_EFI_PARTITION is not set
-CONFIG_SPL_PARTITION_UUIDS=y
CONFIG_SPL_OF_CONTROL=y
CONFIG_OF_SPL_REMOVE_PROPS="pinctrl-0 pinctrl-names clock-names interrupt-parent assigned-clocks assigned-clock-rates assigned-clock-parents"
CONFIG_SPL_OF_PLATDATA=y
diff --git a/configs/chromebook_speedy_defconfig b/configs/chromebook_speedy_defconfig
index 9ff423fe991..9343263be5e 100644
--- a/configs/chromebook_speedy_defconfig
+++ b/configs/chromebook_speedy_defconfig
@@ -45,7 +45,6 @@ CONFIG_CMD_PMIC=y
CONFIG_CMD_REGULATOR=y
# CONFIG_SPL_DOS_PARTITION is not set
# CONFIG_SPL_EFI_PARTITION is not set
-CONFIG_SPL_PARTITION_UUIDS=y
CONFIG_SPL_OF_CONTROL=y
CONFIG_OF_SPL_REMOVE_PROPS="pinctrl-0 pinctrl-names clock-names interrupt-parent assigned-clocks assigned-clock-rates assigned-clock-parents"
CONFIG_SPL_OF_PLATDATA=y
diff --git a/configs/cortina_presidio-asic-emmc_defconfig b/configs/cortina_presidio-asic-emmc_defconfig
index b0bd54f7cb1..b8a1c96c834 100644
--- a/configs/cortina_presidio-asic-emmc_defconfig
+++ b/configs/cortina_presidio-asic-emmc_defconfig
@@ -20,7 +20,6 @@ CONFIG_LAST_STAGE_INIT=y
CONFIG_SYS_PROMPT="G3#"
CONFIG_CMD_I2C=y
CONFIG_CMD_MMC=y
-CONFIG_CMD_PART=y
CONFIG_CMD_WDT=y
CONFIG_BOOTP_BOOTFILESIZE=y
CONFIG_CMD_CACHE=y
diff --git a/configs/efi-x86_app32_defconfig b/configs/efi-x86_app32_defconfig
index 228643a1bd6..7a723c136c2 100644
--- a/configs/efi-x86_app32_defconfig
+++ b/configs/efi-x86_app32_defconfig
@@ -8,6 +8,7 @@ CONFIG_VENDOR_EFI=y
CONFIG_TARGET_EFI_APP32=y
CONFIG_DEBUG_UART=y
CONFIG_FIT=y
+# CONFIG_BOOTSTD is not set
CONFIG_SHOW_BOOT_PROGRESS=y
CONFIG_USE_BOOTARGS=y
CONFIG_BOOTARGS="root=/dev/sdb3 init=/sbin/init rootwait ro"
diff --git a/configs/efi-x86_app64_defconfig b/configs/efi-x86_app64_defconfig
index 1ed2f130509..98f91d81164 100644
--- a/configs/efi-x86_app64_defconfig
+++ b/configs/efi-x86_app64_defconfig
@@ -8,6 +8,7 @@ CONFIG_VENDOR_EFI=y
CONFIG_TARGET_EFI_APP64=y
CONFIG_DEBUG_UART=y
CONFIG_FIT=y
+# CONFIG_BOOTSTD is not set
CONFIG_SHOW_BOOT_PROGRESS=y
CONFIG_USE_BOOTARGS=y
CONFIG_BOOTARGS="root=/dev/sdb3 init=/sbin/init rootwait ro"
diff --git a/configs/evb-rk3036_defconfig b/configs/evb-rk3036_defconfig
index 848d0a5cb25..dcc70cb0bc7 100644
--- a/configs/evb-rk3036_defconfig
+++ b/configs/evb-rk3036_defconfig
@@ -34,7 +34,6 @@ CONFIG_CMD_CACHE=y
CONFIG_CMD_TIME=y
# CONFIG_SPL_DOS_PARTITION is not set
# CONFIG_SPL_EFI_PARTITION is not set
-CONFIG_SPL_PARTITION_UUIDS=y
CONFIG_SYS_RELOC_GD_ENV_ADDR=y
CONFIG_REGMAP=y
CONFIG_SYSCON=y
diff --git a/configs/evb-rk3288_defconfig b/configs/evb-rk3288_defconfig
index be1ca146dde..14a1d4cf332 100644
--- a/configs/evb-rk3288_defconfig
+++ b/configs/evb-rk3288_defconfig
@@ -41,7 +41,6 @@ CONFIG_CMD_PMIC=y
CONFIG_CMD_REGULATOR=y
# CONFIG_SPL_DOS_PARTITION is not set
# CONFIG_SPL_EFI_PARTITION is not set
-CONFIG_SPL_PARTITION_UUIDS=y
CONFIG_SPL_OF_CONTROL=y
CONFIG_OF_SPL_REMOVE_PROPS="pinctrl-0 pinctrl-names clock-names interrupt-parent assigned-clocks assigned-clock-rates assigned-clock-parents"
CONFIG_ENV_IS_IN_MMC=y
diff --git a/configs/firefly-rk3288_defconfig b/configs/firefly-rk3288_defconfig
index c66d3a410f5..c0dbd8470a7 100644
--- a/configs/firefly-rk3288_defconfig
+++ b/configs/firefly-rk3288_defconfig
@@ -36,7 +36,6 @@ CONFIG_CMD_PMIC=y
CONFIG_CMD_REGULATOR=y
# CONFIG_SPL_DOS_PARTITION is not set
# CONFIG_SPL_EFI_PARTITION is not set
-CONFIG_SPL_PARTITION_UUIDS=y
CONFIG_SPL_OF_CONTROL=y
CONFIG_OF_SPL_REMOVE_PROPS="pinctrl-0 pinctrl-names clock-names interrupt-parent assigned-clocks assigned-clock-rates assigned-clock-parents"
CONFIG_ENV_IS_IN_MMC=y
diff --git a/configs/gardena-smart-gateway-at91sam_defconfig b/configs/gardena-smart-gateway-at91sam_defconfig
index 9c000d10b2f..dd61b834a92 100644
--- a/configs/gardena-smart-gateway-at91sam_defconfig
+++ b/configs/gardena-smart-gateway-at91sam_defconfig
@@ -101,6 +101,7 @@ CONFIG_ATMEL_USART=y
CONFIG_TIMER=y
CONFIG_SPL_TIMER=y
CONFIG_ATMEL_PIT_TIMER=y
+CONFIG_SPL_ATMEL_PIT_TIMER=y
# CONFIG_SYS_WHITE_ON_BLACK is not set
CONFIG_WDT=y
CONFIG_WDT_AT91=y
diff --git a/configs/jethub_j100_defconfig b/configs/jethub_j100_defconfig
index 1c6db9f6a0d..a30940bf1ce 100644
--- a/configs/jethub_j100_defconfig
+++ b/configs/jethub_j100_defconfig
@@ -17,6 +17,7 @@ CONFIG_REMAKE_ELF=y
CONFIG_OF_BOARD_SETUP=y
# CONFIG_DISPLAY_CPUINFO is not set
CONFIG_MISC_INIT_R=y
+CONFIG_CMD_ADC=y
# CONFIG_CMD_BDI is not set
# CONFIG_CMD_IMI is not set
CONFIG_CMD_EEPROM=y
@@ -34,6 +35,10 @@ CONFIG_OF_CONTROL=y
CONFIG_SYS_RELOC_GD_ENV_ADDR=y
CONFIG_DM_I2C=y
CONFIG_SYS_I2C_MESON=y
+CONFIG_ADC=y
+CONFIG_SARADC_MESON=y
+CONFIG_CLK=y
+CONFIG_CLK_MESON_AXG=y
CONFIG_MMC_MESON_GX=y
CONFIG_MTD_UBI=y
CONFIG_PHY_REALTEK=y
diff --git a/configs/miqi-rk3288_defconfig b/configs/miqi-rk3288_defconfig
index 0bb194d5243..c5af739fa48 100644
--- a/configs/miqi-rk3288_defconfig
+++ b/configs/miqi-rk3288_defconfig
@@ -36,7 +36,6 @@ CONFIG_CMD_PMIC=y
CONFIG_CMD_REGULATOR=y
# CONFIG_SPL_DOS_PARTITION is not set
# CONFIG_SPL_EFI_PARTITION is not set
-CONFIG_SPL_PARTITION_UUIDS=y
CONFIG_SPL_OF_CONTROL=y
CONFIG_OF_SPL_REMOVE_PROPS="pinctrl-0 pinctrl-names clock-names interrupt-parent assigned-clocks assigned-clock-rates assigned-clock-parents"
CONFIG_ENV_IS_IN_MMC=y
diff --git a/configs/mt7620_mt7530_rfb_defconfig b/configs/mt7620_mt7530_rfb_defconfig
index 7a0f72e3242..af1282c9904 100644
--- a/configs/mt7620_mt7530_rfb_defconfig
+++ b/configs/mt7620_mt7530_rfb_defconfig
@@ -35,7 +35,6 @@ CONFIG_CMD_SPI=y
# CONFIG_CMD_NFS is not set
CONFIG_CMD_MII=y
# CONFIG_CMD_MDIO is not set
-# CONFIG_PARTITIONS is not set
CONFIG_OF_SPL_REMOVE_PROPS="pinctrl-0 pinctrl-names clocks clock-names interrupt-parent interrupts resets reset-names"
CONFIG_ENV_IS_IN_SPI_FLASH=y
CONFIG_SYS_RELOC_GD_ENV_ADDR=y
diff --git a/configs/mt7628_rfb_defconfig b/configs/mt7628_rfb_defconfig
index 6c74efb1379..5862295871b 100644
--- a/configs/mt7628_rfb_defconfig
+++ b/configs/mt7628_rfb_defconfig
@@ -32,7 +32,6 @@ CONFIG_CMD_GPIO=y
# CONFIG_CMD_LOADS is not set
CONFIG_CMD_SPI=y
# CONFIG_CMD_NFS is not set
-# CONFIG_PARTITIONS is not set
CONFIG_ENV_IS_IN_SPI_FLASH=y
CONFIG_SYS_RELOC_GD_ENV_ADDR=y
CONFIG_NET_RANDOM_ETHADDR=y
diff --git a/configs/phycore-rk3288_defconfig b/configs/phycore-rk3288_defconfig
index d582a0d9a9d..64446492221 100644
--- a/configs/phycore-rk3288_defconfig
+++ b/configs/phycore-rk3288_defconfig
@@ -37,7 +37,6 @@ CONFIG_CMD_PMIC=y
CONFIG_CMD_REGULATOR=y
# CONFIG_SPL_DOS_PARTITION is not set
# CONFIG_SPL_EFI_PARTITION is not set
-CONFIG_SPL_PARTITION_UUIDS=y
CONFIG_SPL_OF_CONTROL=y
CONFIG_OF_SPL_REMOVE_PROPS="pinctrl-0 pinctrl-names clock-names interrupt-parent assigned-clocks assigned-clock-rates assigned-clock-parents"
CONFIG_ENV_IS_IN_MMC=y
diff --git a/configs/popmetal-rk3288_defconfig b/configs/popmetal-rk3288_defconfig
index 4e5db07f217..cb463a9b69a 100644
--- a/configs/popmetal-rk3288_defconfig
+++ b/configs/popmetal-rk3288_defconfig
@@ -37,7 +37,6 @@ CONFIG_CMD_PMIC=y
CONFIG_CMD_REGULATOR=y
# CONFIG_SPL_DOS_PARTITION is not set
# CONFIG_SPL_EFI_PARTITION is not set
-CONFIG_SPL_PARTITION_UUIDS=y
CONFIG_SPL_OF_CONTROL=y
CONFIG_OF_SPL_REMOVE_PROPS="pinctrl-0 pinctrl-names clock-names interrupt-parent assigned-clocks assigned-clock-rates assigned-clock-parents"
CONFIG_ENV_IS_IN_MMC=y
diff --git a/configs/rcar3_salvator-x_defconfig b/configs/rcar3_salvator-x_defconfig
index f333291aa4b..6ef62ab4cbb 100644
--- a/configs/rcar3_salvator-x_defconfig
+++ b/configs/rcar3_salvator-x_defconfig
@@ -14,6 +14,7 @@ CONFIG_SYS_LOAD_ADDR=0x58000000
CONFIG_LTO=y
CONFIG_REMAKE_ELF=y
CONFIG_FIT=y
+# CONFIG_BOOTSTD is not set
CONFIG_SUPPORT_RAW_INITRD=y
CONFIG_SYS_MONITOR_BASE=0x00000000
CONFIG_USE_BOOTARGS=y
diff --git a/configs/rock-pi-n8-rk3288_defconfig b/configs/rock-pi-n8-rk3288_defconfig
index 6c8300bd0eb..6d13e351ee6 100644
--- a/configs/rock-pi-n8-rk3288_defconfig
+++ b/configs/rock-pi-n8-rk3288_defconfig
@@ -35,7 +35,6 @@ CONFIG_CMD_PMIC=y
CONFIG_CMD_REGULATOR=y
# CONFIG_SPL_DOS_PARTITION is not set
# CONFIG_SPL_EFI_PARTITION is not set
-CONFIG_SPL_PARTITION_UUIDS=y
CONFIG_SPL_OF_CONTROL=y
CONFIG_OF_SPL_REMOVE_PROPS="pinctrl-0 pinctrl-names clock-names interrupt-parent assigned-clocks assigned-clock-rates assigned-clock-parents"
CONFIG_ENV_IS_IN_MMC=y
diff --git a/configs/rock2_defconfig b/configs/rock2_defconfig
index 03d9c87ff38..e8d183cd9b6 100644
--- a/configs/rock2_defconfig
+++ b/configs/rock2_defconfig
@@ -37,7 +37,6 @@ CONFIG_CMD_PMIC=y
CONFIG_CMD_REGULATOR=y
# CONFIG_SPL_DOS_PARTITION is not set
# CONFIG_SPL_EFI_PARTITION is not set
-CONFIG_SPL_PARTITION_UUIDS=y
CONFIG_SPL_OF_CONTROL=y
CONFIG_OF_SPL_REMOVE_PROPS="pinctrl-0 pinctrl-names clock-names interrupt-parent"
CONFIG_ENV_IS_IN_MMC=y
diff --git a/configs/sam9x60_curiosity_mmc_defconfig b/configs/sam9x60_curiosity_mmc_defconfig
new file mode 100644
index 00000000000..06db6192703
--- /dev/null
+++ b/configs/sam9x60_curiosity_mmc_defconfig
@@ -0,0 +1,74 @@
+CONFIG_ARM=y
+CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_ARCH_AT91=y
+CONFIG_SYS_TEXT_BASE=0x23f00000
+CONFIG_SYS_MALLOC_LEN=0x81000
+CONFIG_SYS_MALLOC_F_LEN=0x8000
+CONFIG_TARGET_SAM9X60_CURIOSITY=y
+CONFIG_ATMEL_LEGACY=y
+CONFIG_NR_DRAM_BANKS=8
+CONFIG_ENV_SIZE=0x4000
+CONFIG_DM_GPIO=y
+CONFIG_DEFAULT_DEVICE_TREE="at91-sam9x60_curiosity"
+CONFIG_DEBUG_UART_BOARD_INIT=y
+CONFIG_DEBUG_UART_BASE=0xfffff200
+CONFIG_DEBUG_UART_CLOCK=200000000
+CONFIG_DEBUG_UART=y
+CONFIG_SYS_LOAD_ADDR=0x22000000
+CONFIG_FIT=y
+CONFIG_SD_BOOT=y
+CONFIG_BOOTDELAY=3
+CONFIG_USE_BOOTARGS=y
+CONFIG_BOOTARGS="mem=128M console=ttyS0,115200 root=/dev/mmcblk0p2 rw rootfstype=ext4 rootwait"
+CONFIG_USE_BOOTCOMMAND=y
+CONFIG_BOOTCOMMAND="fatload mmc 0:1 0x21000000 at91-sam9x60_curiosity.dtb; fatload mmc 0:1 0x22000000 zImage; bootz 0x22000000 - 0x21000000"
+CONFIG_SYS_CONSOLE_IS_IN_ENV=y
+# CONFIG_DISPLAY_BOARDINFO is not set
+CONFIG_MISC_INIT_R=y
+CONFIG_HUSH_PARSER=y
+CONFIG_SYS_PROMPT="U-Boot> "
+CONFIG_CMD_BOOTZ=y
+CONFIG_CMD_CLK=y
+CONFIG_CMD_DM=y
+# CONFIG_CMD_FLASH is not set
+CONFIG_CMD_GPIO=y
+CONFIG_CMD_I2C=y
+CONFIG_CMD_MMC=y
+# CONFIG_CMD_SETEXPR is not set
+CONFIG_CMD_DHCP=y
+CONFIG_BOOTP_BOOTFILESIZE=y
+CONFIG_CMD_MII=y
+CONFIG_CMD_PING=y
+CONFIG_CMD_HASH=y
+CONFIG_HASH_VERIFY=y
+CONFIG_CMD_FAT=y
+CONFIG_OF_CONTROL=y
+CONFIG_ENV_IS_IN_FAT=y
+CONFIG_ENV_FAT_DEVICE_AND_PART="0:1"
+CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_DM=y
+CONFIG_CLK=y
+CONFIG_CLK_CCF=y
+CONFIG_CLK_AT91=y
+CONFIG_AT91_GENERIC_CLK=y
+CONFIG_AT91_SAM9X60_PLL=y
+CONFIG_CPU=y
+CONFIG_AT91_GPIO=y
+CONFIG_DM_I2C=y
+CONFIG_SYS_I2C_AT91=y
+CONFIG_I2C_EEPROM=y
+CONFIG_MICROCHIP_FLEXCOM=y
+CONFIG_DM_MMC=y
+CONFIG_MMC_SDHCI=y
+CONFIG_MMC_SDHCI_ATMEL=y
+CONFIG_PHY_MICREL=y
+CONFIG_DM_ETH=y
+CONFIG_MACB=y
+CONFIG_PINCTRL=y
+CONFIG_PINCTRL_AT91=y
+CONFIG_DM_SERIAL=y
+CONFIG_DEBUG_UART_ANNOUNCE=y
+CONFIG_ATMEL_USART=y
+CONFIG_TIMER=y
+CONFIG_MCHP_PIT64B_TIMER=y
+CONFIG_OF_LIBFDT_OVERLAY=y
diff --git a/configs/sam9x60ek_mmc_defconfig b/configs/sam9x60ek_mmc_defconfig
index 17ba0905f87..dee112ab675 100644
--- a/configs/sam9x60ek_mmc_defconfig
+++ b/configs/sam9x60ek_mmc_defconfig
@@ -76,6 +76,9 @@ CONFIG_DM_SERIAL=y
CONFIG_DEBUG_UART_ANNOUNCE=y
CONFIG_ATMEL_USART=y
CONFIG_TIMER=y
+CONFIG_SYSRESET=y
+CONFIG_SYSRESET_CMD_RESET=y
+CONFIG_SYSRESET_AT91=y
CONFIG_ATMEL_PIT_TIMER=y
CONFIG_W1=y
CONFIG_W1_GPIO=y
diff --git a/configs/sam9x60ek_nandflash_defconfig b/configs/sam9x60ek_nandflash_defconfig
index 225ae654363..ca848e1aa89 100644
--- a/configs/sam9x60ek_nandflash_defconfig
+++ b/configs/sam9x60ek_nandflash_defconfig
@@ -78,6 +78,9 @@ CONFIG_DEBUG_UART_ANNOUNCE=y
CONFIG_ATMEL_USART=y
CONFIG_TIMER=y
CONFIG_ATMEL_PIT_TIMER=y
+CONFIG_SYSRESET=y
+CONFIG_SYSRESET_CMD_RESET=y
+CONFIG_SYSRESET_AT91=y
CONFIG_W1=y
CONFIG_W1_GPIO=y
CONFIG_W1_EEPROM=y
diff --git a/configs/sam9x60ek_qspiflash_defconfig b/configs/sam9x60ek_qspiflash_defconfig
index fb20216e150..b8cacaff75b 100644
--- a/configs/sam9x60ek_qspiflash_defconfig
+++ b/configs/sam9x60ek_qspiflash_defconfig
@@ -90,6 +90,9 @@ CONFIG_DM_SPI=y
CONFIG_ATMEL_QSPI=y
CONFIG_TIMER=y
CONFIG_ATMEL_PIT_TIMER=y
+CONFIG_SYSRESET=y
+CONFIG_SYSRESET_CMD_RESET=y
+CONFIG_SYSRESET_AT91=y
CONFIG_W1=y
CONFIG_W1_GPIO=y
CONFIG_W1_EEPROM=y
diff --git a/configs/sama5d27_giantboard_defconfig b/configs/sama5d27_giantboard_defconfig
index 34358c53287..4855e0f072d 100644
--- a/configs/sama5d27_giantboard_defconfig
+++ b/configs/sama5d27_giantboard_defconfig
@@ -77,9 +77,14 @@ CONFIG_DM_SPI=y
CONFIG_TIMER=y
CONFIG_SPL_TIMER=y
CONFIG_ATMEL_PIT_TIMER=y
+CONFIG_SPL_ATMEL_PIT_TIMER=y
CONFIG_USB=y
CONFIG_USB_EHCI_HCD=y
CONFIG_USB_STORAGE=y
CONFIG_USB_GADGET=y
CONFIG_USB_GADGET_ATMEL_USBA=y
CONFIG_OF_LIBFDT_OVERLAY=y
+CONFIG_SYSRESET=y
+CONFIG_SPL_SYSRESET=y
+CONFIG_SYSRESET_CMD_RESET=y
+CONFIG_SYSRESET_AT91=y
diff --git a/configs/sama5d27_som1_ek_mmc1_defconfig b/configs/sama5d27_som1_ek_mmc1_defconfig
index 2914e0636d1..d0ff6a90126 100644
--- a/configs/sama5d27_som1_ek_mmc1_defconfig
+++ b/configs/sama5d27_som1_ek_mmc1_defconfig
@@ -89,8 +89,13 @@ CONFIG_SPI=y
CONFIG_DM_SPI=y
CONFIG_ATMEL_QSPI=y
CONFIG_TIMER=y
+CONFIG_SYSRESET=y
+CONFIG_SPL_SYSRESET=y
+CONFIG_SYSRESET_CMD_RESET=y
+CONFIG_SYSRESET_AT91=y
CONFIG_SPL_TIMER=y
CONFIG_ATMEL_PIT_TIMER=y
+CONFIG_SPL_ATMEL_PIT_TIMER=y
CONFIG_USB=y
CONFIG_USB_EHCI_HCD=y
CONFIG_USB_STORAGE=y
diff --git a/configs/sama5d27_som1_ek_mmc_defconfig b/configs/sama5d27_som1_ek_mmc_defconfig
index e9c4c3f966a..8096ec7b61d 100644
--- a/configs/sama5d27_som1_ek_mmc_defconfig
+++ b/configs/sama5d27_som1_ek_mmc_defconfig
@@ -89,8 +89,13 @@ CONFIG_SPI=y
CONFIG_DM_SPI=y
CONFIG_ATMEL_QSPI=y
CONFIG_TIMER=y
+CONFIG_SYSRESET=y
+CONFIG_SPL_SYSRESET=y
+CONFIG_SYSRESET_CMD_RESET=y
+CONFIG_SYSRESET_AT91=y
CONFIG_SPL_TIMER=y
CONFIG_ATMEL_PIT_TIMER=y
+CONFIG_SPL_ATMEL_PIT_TIMER=y
CONFIG_USB=y
CONFIG_USB_EHCI_HCD=y
CONFIG_USB_STORAGE=y
diff --git a/configs/sama5d27_som1_ek_qspiflash_defconfig b/configs/sama5d27_som1_ek_qspiflash_defconfig
index e6105b1e585..e0b11e91981 100644
--- a/configs/sama5d27_som1_ek_qspiflash_defconfig
+++ b/configs/sama5d27_som1_ek_qspiflash_defconfig
@@ -88,8 +88,13 @@ CONFIG_SPI=y
CONFIG_DM_SPI=y
CONFIG_ATMEL_QSPI=y
CONFIG_TIMER=y
+CONFIG_SYSRESET=y
+CONFIG_SPL_SYSRESET=y
+CONFIG_SYSRESET_CMD_RESET=y
+CONFIG_SYSRESET_AT91=y
CONFIG_SPL_TIMER=y
CONFIG_ATMEL_PIT_TIMER=y
+CONFIG_SPL_ATMEL_PIT_TIMER=y
CONFIG_USB=y
CONFIG_USB_EHCI_HCD=y
CONFIG_USB_STORAGE=y
diff --git a/configs/sama5d27_wlsom1_ek_mmc_defconfig b/configs/sama5d27_wlsom1_ek_mmc_defconfig
index f61e2c33b74..a0e37fa74d8 100644
--- a/configs/sama5d27_wlsom1_ek_mmc_defconfig
+++ b/configs/sama5d27_wlsom1_ek_mmc_defconfig
@@ -94,8 +94,13 @@ CONFIG_SPI=y
CONFIG_DM_SPI=y
CONFIG_ATMEL_QSPI=y
CONFIG_TIMER=y
+CONFIG_SYSRESET=y
+CONFIG_SPL_SYSRESET=y
+CONFIG_SYSRESET_CMD_RESET=y
+CONFIG_SYSRESET_AT91=y
CONFIG_SPL_TIMER=y
CONFIG_ATMEL_PIT_TIMER=y
+CONFIG_SPL_ATMEL_PIT_TIMER=y
CONFIG_USB=y
CONFIG_USB_EHCI_HCD=y
CONFIG_USB_STORAGE=y
diff --git a/configs/sama5d27_wlsom1_ek_qspiflash_defconfig b/configs/sama5d27_wlsom1_ek_qspiflash_defconfig
index 9ffe162f814..8acb8f22421 100644
--- a/configs/sama5d27_wlsom1_ek_qspiflash_defconfig
+++ b/configs/sama5d27_wlsom1_ek_qspiflash_defconfig
@@ -98,8 +98,13 @@ CONFIG_SPI=y
CONFIG_DM_SPI=y
CONFIG_ATMEL_QSPI=y
CONFIG_TIMER=y
+CONFIG_SYSRESET=y
+CONFIG_SPL_SYSRESET=y
+CONFIG_SYSRESET_CMD_RESET=y
+CONFIG_SYSRESET_AT91=y
CONFIG_SPL_TIMER=y
CONFIG_ATMEL_PIT_TIMER=y
+CONFIG_SPL_ATMEL_PIT_TIMER=y
CONFIG_USB=y
CONFIG_USB_EHCI_HCD=y
CONFIG_USB_STORAGE=y
diff --git a/configs/sama5d2_icp_mmc_defconfig b/configs/sama5d2_icp_mmc_defconfig
index 1a95946d6db..37f2798608b 100644
--- a/configs/sama5d2_icp_mmc_defconfig
+++ b/configs/sama5d2_icp_mmc_defconfig
@@ -80,7 +80,12 @@ CONFIG_DM_SERIAL=y
CONFIG_DEBUG_UART_ANNOUNCE=y
CONFIG_ATMEL_USART=y
CONFIG_TIMER=y
+CONFIG_SYSRESET=y
+CONFIG_SPL_SYSRESET=y
+CONFIG_SYSRESET_CMD_RESET=y
+CONFIG_SYSRESET_AT91=y
CONFIG_SPL_TIMER=y
CONFIG_ATMEL_TCB_TIMER=y
+CONFIG_SPL_ATMEL_TCB_TIMER=y
CONFIG_OF_LIBFDT_OVERLAY=y
# CONFIG_EFI_LOADER_HII is not set
diff --git a/configs/sama5d2_icp_qspiflash_defconfig b/configs/sama5d2_icp_qspiflash_defconfig
index a70532cf144..cac96e638c3 100644
--- a/configs/sama5d2_icp_qspiflash_defconfig
+++ b/configs/sama5d2_icp_qspiflash_defconfig
@@ -87,6 +87,9 @@ CONFIG_SPI=y
CONFIG_DM_SPI=y
CONFIG_ATMEL_QSPI=y
CONFIG_TIMER=y
+CONFIG_SYSRESET=y
+CONFIG_SYSRESET_CMD_RESET=y
+CONFIG_SYSRESET_AT91=y
CONFIG_ATMEL_PIT_TIMER=y
CONFIG_USB=y
CONFIG_USB_EHCI_HCD=y
diff --git a/configs/sama5d2_ptc_ek_mmc_defconfig b/configs/sama5d2_ptc_ek_mmc_defconfig
index 7d1578be0bd..27618bbefe7 100644
--- a/configs/sama5d2_ptc_ek_mmc_defconfig
+++ b/configs/sama5d2_ptc_ek_mmc_defconfig
@@ -70,6 +70,9 @@ CONFIG_DM_SERIAL=y
CONFIG_DEBUG_UART_ANNOUNCE=y
CONFIG_ATMEL_USART=y
CONFIG_TIMER=y
+CONFIG_SYSRESET=y
+CONFIG_SYSRESET_CMD_RESET=y
+CONFIG_SYSRESET_AT91=y
CONFIG_ATMEL_TCB_TIMER=y
CONFIG_USB=y
CONFIG_USB_EHCI_HCD=y
diff --git a/configs/sama5d2_ptc_ek_nandflash_defconfig b/configs/sama5d2_ptc_ek_nandflash_defconfig
index 941683b3cd7..cd66b60586d 100644
--- a/configs/sama5d2_ptc_ek_nandflash_defconfig
+++ b/configs/sama5d2_ptc_ek_nandflash_defconfig
@@ -70,6 +70,9 @@ CONFIG_DM_SERIAL=y
CONFIG_DEBUG_UART_ANNOUNCE=y
CONFIG_ATMEL_USART=y
CONFIG_TIMER=y
+CONFIG_SYSRESET=y
+CONFIG_SYSRESET_CMD_RESET=y
+CONFIG_SYSRESET_AT91=y
CONFIG_ATMEL_TCB_TIMER=y
CONFIG_USB=y
CONFIG_USB_EHCI_HCD=y
diff --git a/configs/sama5d2_xplained_emmc_defconfig b/configs/sama5d2_xplained_emmc_defconfig
index 53aece8569d..06b337ef8bd 100644
--- a/configs/sama5d2_xplained_emmc_defconfig
+++ b/configs/sama5d2_xplained_emmc_defconfig
@@ -88,8 +88,13 @@ CONFIG_SPI=y
CONFIG_DM_SPI=y
CONFIG_ATMEL_QSPI=y
CONFIG_TIMER=y
+CONFIG_SYSRESET=y
+CONFIG_SPL_SYSRESET=y
+CONFIG_SYSRESET_CMD_RESET=y
+CONFIG_SYSRESET_AT91=y
CONFIG_SPL_TIMER=y
CONFIG_ATMEL_TCB_TIMER=y
+CONFIG_SPL_ATMEL_TCB_TIMER=y
CONFIG_USB=y
CONFIG_USB_EHCI_HCD=y
CONFIG_USB_STORAGE=y
diff --git a/configs/sama5d2_xplained_mmc_defconfig b/configs/sama5d2_xplained_mmc_defconfig
index 74491d6331c..871ade2135a 100644
--- a/configs/sama5d2_xplained_mmc_defconfig
+++ b/configs/sama5d2_xplained_mmc_defconfig
@@ -90,8 +90,13 @@ CONFIG_SPI=y
CONFIG_DM_SPI=y
CONFIG_ATMEL_QSPI=y
CONFIG_TIMER=y
+CONFIG_SYSRESET=y
+CONFIG_SPL_SYSRESET=y
+CONFIG_SYSRESET_CMD_RESET=y
+CONFIG_SYSRESET_AT91=y
CONFIG_SPL_TIMER=y
CONFIG_ATMEL_TCB_TIMER=y
+CONFIG_SPL_ATMEL_TCB_TIMER=y
CONFIG_USB=y
CONFIG_USB_EHCI_HCD=y
CONFIG_USB_STORAGE=y
diff --git a/configs/sama5d2_xplained_qspiflash_defconfig b/configs/sama5d2_xplained_qspiflash_defconfig
index b2e78c63f60..59f62c51d77 100644
--- a/configs/sama5d2_xplained_qspiflash_defconfig
+++ b/configs/sama5d2_xplained_qspiflash_defconfig
@@ -90,8 +90,13 @@ CONFIG_SPI=y
CONFIG_DM_SPI=y
CONFIG_ATMEL_QSPI=y
CONFIG_TIMER=y
+CONFIG_SYSRESET=y
+CONFIG_SPL_SYSRESET=y
+CONFIG_SYSRESET_CMD_RESET=y
+CONFIG_SYSRESET_AT91=y
CONFIG_SPL_TIMER=y
CONFIG_ATMEL_TCB_TIMER=y
+CONFIG_SPL_ATMEL_TCB_TIMER=y
CONFIG_USB=y
CONFIG_USB_EHCI_HCD=y
CONFIG_USB_STORAGE=y
diff --git a/configs/sama5d2_xplained_spiflash_defconfig b/configs/sama5d2_xplained_spiflash_defconfig
index 83092e91aec..ec2091d1b0c 100644
--- a/configs/sama5d2_xplained_spiflash_defconfig
+++ b/configs/sama5d2_xplained_spiflash_defconfig
@@ -94,8 +94,13 @@ CONFIG_SPI=y
CONFIG_DM_SPI=y
CONFIG_ATMEL_QSPI=y
CONFIG_TIMER=y
+CONFIG_SYSRESET=y
+CONFIG_SPL_SYSRESET=y
+CONFIG_SYSRESET_CMD_RESET=y
+CONFIG_SYSRESET_AT91=y
CONFIG_SPL_TIMER=y
CONFIG_ATMEL_TCB_TIMER=y
+CONFIG_SPL_ATMEL_TCB_TIMER=y
CONFIG_USB=y
CONFIG_USB_EHCI_HCD=y
CONFIG_USB_STORAGE=y
diff --git a/configs/sama5d36ek_cmp_mmc_defconfig b/configs/sama5d36ek_cmp_mmc_defconfig
index 911916199a6..7c31b75acef 100644
--- a/configs/sama5d36ek_cmp_mmc_defconfig
+++ b/configs/sama5d36ek_cmp_mmc_defconfig
@@ -65,6 +65,9 @@ CONFIG_ATMEL_USART=y
CONFIG_SPI=y
CONFIG_DM_SPI=y
CONFIG_TIMER=y
+CONFIG_SYSRESET=y
+CONFIG_SYSRESET_CMD_RESET=y
+CONFIG_SYSRESET_AT91=y
CONFIG_ATMEL_PIT_TIMER=y
CONFIG_DM_VIDEO=y
# CONFIG_VIDEO_BPP8 is not set
diff --git a/configs/sama5d36ek_cmp_nandflash_defconfig b/configs/sama5d36ek_cmp_nandflash_defconfig
index 1c1d20cbf57..00f5b2bd806 100644
--- a/configs/sama5d36ek_cmp_nandflash_defconfig
+++ b/configs/sama5d36ek_cmp_nandflash_defconfig
@@ -67,6 +67,9 @@ CONFIG_ATMEL_USART=y
CONFIG_SPI=y
CONFIG_DM_SPI=y
CONFIG_TIMER=y
+CONFIG_SYSRESET=y
+CONFIG_SYSRESET_CMD_RESET=y
+CONFIG_SYSRESET_AT91=y
CONFIG_ATMEL_PIT_TIMER=y
CONFIG_DM_VIDEO=y
# CONFIG_VIDEO_BPP8 is not set
diff --git a/configs/sama5d36ek_cmp_spiflash_defconfig b/configs/sama5d36ek_cmp_spiflash_defconfig
index 2e39207c4f3..1a6e47b3f95 100644
--- a/configs/sama5d36ek_cmp_spiflash_defconfig
+++ b/configs/sama5d36ek_cmp_spiflash_defconfig
@@ -67,6 +67,9 @@ CONFIG_ATMEL_USART=y
CONFIG_SPI=y
CONFIG_DM_SPI=y
CONFIG_TIMER=y
+CONFIG_SYSRESET=y
+CONFIG_SYSRESET_CMD_RESET=y
+CONFIG_SYSRESET_AT91=y
CONFIG_ATMEL_PIT_TIMER=y
CONFIG_DM_VIDEO=y
# CONFIG_VIDEO_BPP8 is not set
diff --git a/configs/sama5d3_xplained_mmc_defconfig b/configs/sama5d3_xplained_mmc_defconfig
index 668f61321e8..ff74988f46f 100644
--- a/configs/sama5d3_xplained_mmc_defconfig
+++ b/configs/sama5d3_xplained_mmc_defconfig
@@ -84,8 +84,13 @@ CONFIG_DM_SERIAL=y
CONFIG_DEBUG_UART_ANNOUNCE=y
CONFIG_ATMEL_USART=y
CONFIG_TIMER=y
+CONFIG_SYSRESET=y
+CONFIG_SPL_SYSRESET=y
+CONFIG_SYSRESET_CMD_RESET=y
+CONFIG_SYSRESET_AT91=y
CONFIG_SPL_TIMER=y
CONFIG_ATMEL_PIT_TIMER=y
+CONFIG_SPL_ATMEL_PIT_TIMER=y
CONFIG_USB=y
CONFIG_USB_EHCI_HCD=y
CONFIG_USB_STORAGE=y
diff --git a/configs/sama5d3_xplained_nandflash_defconfig b/configs/sama5d3_xplained_nandflash_defconfig
index 8364d7e7047..ba7ffd47d7b 100644
--- a/configs/sama5d3_xplained_nandflash_defconfig
+++ b/configs/sama5d3_xplained_nandflash_defconfig
@@ -87,8 +87,13 @@ CONFIG_DM_SERIAL=y
CONFIG_DEBUG_UART_ANNOUNCE=y
CONFIG_ATMEL_USART=y
CONFIG_TIMER=y
+CONFIG_SYSRESET=y
+CONFIG_SPL_SYSRESET=y
+CONFIG_SYSRESET_CMD_RESET=y
+CONFIG_SYSRESET_AT91=y
CONFIG_SPL_TIMER=y
CONFIG_ATMEL_PIT_TIMER=y
+CONFIG_SPL_ATMEL_PIT_TIMER=y
CONFIG_USB=y
CONFIG_USB_EHCI_HCD=y
CONFIG_USB_STORAGE=y
diff --git a/configs/sama5d3xek_mmc_defconfig b/configs/sama5d3xek_mmc_defconfig
index 2345aa4843b..4c8294252cd 100644
--- a/configs/sama5d3xek_mmc_defconfig
+++ b/configs/sama5d3xek_mmc_defconfig
@@ -92,8 +92,13 @@ CONFIG_ATMEL_USART=y
CONFIG_SPI=y
CONFIG_DM_SPI=y
CONFIG_TIMER=y
+CONFIG_SYSRESET=y
+CONFIG_SPL_SYSRESET=y
+CONFIG_SYSRESET_CMD_RESET=y
+CONFIG_SYSRESET_AT91=y
CONFIG_SPL_TIMER=y
CONFIG_ATMEL_PIT_TIMER=y
+CONFIG_SPL_ATMEL_PIT_TIMER=y
CONFIG_USB=y
CONFIG_USB_EHCI_HCD=y
CONFIG_USB_STORAGE=y
diff --git a/configs/sama5d3xek_nandflash_defconfig b/configs/sama5d3xek_nandflash_defconfig
index 7aecb1a3fb7..977eafd5c37 100644
--- a/configs/sama5d3xek_nandflash_defconfig
+++ b/configs/sama5d3xek_nandflash_defconfig
@@ -94,8 +94,13 @@ CONFIG_ATMEL_USART=y
CONFIG_SPI=y
CONFIG_DM_SPI=y
CONFIG_TIMER=y
+CONFIG_SYSRESET=y
+CONFIG_SPL_SYSRESET=y
+CONFIG_SYSRESET_CMD_RESET=y
+CONFIG_SYSRESET_AT91=y
CONFIG_SPL_TIMER=y
CONFIG_ATMEL_PIT_TIMER=y
+CONFIG_SPL_ATMEL_PIT_TIMER=y
CONFIG_USB=y
CONFIG_USB_EHCI_HCD=y
CONFIG_USB_STORAGE=y
diff --git a/configs/sama5d3xek_spiflash_defconfig b/configs/sama5d3xek_spiflash_defconfig
index ef579203bdd..f2c5576c225 100644
--- a/configs/sama5d3xek_spiflash_defconfig
+++ b/configs/sama5d3xek_spiflash_defconfig
@@ -93,8 +93,13 @@ CONFIG_ATMEL_USART=y
CONFIG_SPI=y
CONFIG_DM_SPI=y
CONFIG_TIMER=y
+CONFIG_SYSRESET=y
+CONFIG_SPL_SYSRESET=y
+CONFIG_SYSRESET_CMD_RESET=y
+CONFIG_SYSRESET_AT91=y
CONFIG_SPL_TIMER=y
CONFIG_ATMEL_PIT_TIMER=y
+CONFIG_SPL_ATMEL_PIT_TIMER=y
CONFIG_USB=y
CONFIG_USB_EHCI_HCD=y
CONFIG_USB_STORAGE=y
diff --git a/configs/sama5d4_xplained_mmc_defconfig b/configs/sama5d4_xplained_mmc_defconfig
index a77fb89d370..d147c3e0c35 100644
--- a/configs/sama5d4_xplained_mmc_defconfig
+++ b/configs/sama5d4_xplained_mmc_defconfig
@@ -85,8 +85,13 @@ CONFIG_ATMEL_USART=y
CONFIG_SPI=y
CONFIG_DM_SPI=y
CONFIG_TIMER=y
+CONFIG_SYSRESET=y
+CONFIG_SPL_SYSRESET=y
+CONFIG_SYSRESET_CMD_RESET=y
+CONFIG_SYSRESET_AT91=y
CONFIG_SPL_TIMER=y
CONFIG_ATMEL_PIT_TIMER=y
+CONFIG_SPL_ATMEL_PIT_TIMER=y
CONFIG_USB=y
CONFIG_USB_EHCI_HCD=y
CONFIG_USB_STORAGE=y
diff --git a/configs/sama5d4_xplained_nandflash_defconfig b/configs/sama5d4_xplained_nandflash_defconfig
index 74e56d7b3d8..8db8ee36d5b 100644
--- a/configs/sama5d4_xplained_nandflash_defconfig
+++ b/configs/sama5d4_xplained_nandflash_defconfig
@@ -89,8 +89,13 @@ CONFIG_ATMEL_USART=y
CONFIG_SPI=y
CONFIG_DM_SPI=y
CONFIG_TIMER=y
+CONFIG_SYSRESET=y
+CONFIG_SPL_SYSRESET=y
+CONFIG_SYSRESET_CMD_RESET=y
+CONFIG_SYSRESET_AT91=y
CONFIG_SPL_TIMER=y
CONFIG_ATMEL_PIT_TIMER=y
+CONFIG_SPL_ATMEL_PIT_TIMER=y
CONFIG_USB=y
CONFIG_USB_EHCI_HCD=y
CONFIG_USB_STORAGE=y
diff --git a/configs/sama5d4_xplained_spiflash_defconfig b/configs/sama5d4_xplained_spiflash_defconfig
index ff46f43dd81..0407f7d576a 100644
--- a/configs/sama5d4_xplained_spiflash_defconfig
+++ b/configs/sama5d4_xplained_spiflash_defconfig
@@ -91,8 +91,13 @@ CONFIG_ATMEL_USART=y
CONFIG_SPI=y
CONFIG_DM_SPI=y
CONFIG_TIMER=y
+CONFIG_SYSRESET=y
+CONFIG_SPL_SYSRESET=y
+CONFIG_SYSRESET_CMD_RESET=y
+CONFIG_SYSRESET_AT91=y
CONFIG_SPL_TIMER=y
CONFIG_ATMEL_PIT_TIMER=y
+CONFIG_SPL_ATMEL_PIT_TIMER=y
CONFIG_USB=y
CONFIG_USB_EHCI_HCD=y
CONFIG_USB_STORAGE=y
diff --git a/configs/sama5d4ek_mmc_defconfig b/configs/sama5d4ek_mmc_defconfig
index 81b96d04fbe..d143569c96f 100644
--- a/configs/sama5d4ek_mmc_defconfig
+++ b/configs/sama5d4ek_mmc_defconfig
@@ -83,8 +83,13 @@ CONFIG_ATMEL_USART=y
CONFIG_SPI=y
CONFIG_DM_SPI=y
CONFIG_TIMER=y
+CONFIG_SYSRESET=y
+CONFIG_SPL_SYSRESET=y
+CONFIG_SYSRESET_CMD_RESET=y
+CONFIG_SYSRESET_AT91=y
CONFIG_SPL_TIMER=y
CONFIG_ATMEL_PIT_TIMER=y
+CONFIG_SPL_ATMEL_PIT_TIMER=y
CONFIG_USB=y
CONFIG_USB_EHCI_HCD=y
CONFIG_USB_STORAGE=y
diff --git a/configs/sama5d4ek_nandflash_defconfig b/configs/sama5d4ek_nandflash_defconfig
index 1edfc256448..3a037b93b90 100644
--- a/configs/sama5d4ek_nandflash_defconfig
+++ b/configs/sama5d4ek_nandflash_defconfig
@@ -87,8 +87,13 @@ CONFIG_ATMEL_USART=y
CONFIG_SPI=y
CONFIG_DM_SPI=y
CONFIG_TIMER=y
+CONFIG_SYSRESET=y
+CONFIG_SPL_SYSRESET=y
+CONFIG_SYSRESET_CMD_RESET=y
+CONFIG_SYSRESET_AT91=y
CONFIG_SPL_TIMER=y
CONFIG_ATMEL_PIT_TIMER=y
+CONFIG_SPL_ATMEL_PIT_TIMER=y
CONFIG_USB=y
CONFIG_USB_EHCI_HCD=y
CONFIG_USB_STORAGE=y
diff --git a/configs/sama5d4ek_spiflash_defconfig b/configs/sama5d4ek_spiflash_defconfig
index 2045a655c9d..fb4c58c4341 100644
--- a/configs/sama5d4ek_spiflash_defconfig
+++ b/configs/sama5d4ek_spiflash_defconfig
@@ -86,8 +86,13 @@ CONFIG_ATMEL_USART=y
CONFIG_SPI=y
CONFIG_DM_SPI=y
CONFIG_TIMER=y
+CONFIG_SYSRESET=y
+CONFIG_SPL_SYSRESET=y
+CONFIG_SYSRESET_CMD_RESET=y
+CONFIG_SYSRESET_AT91=y
CONFIG_SPL_TIMER=y
CONFIG_ATMEL_PIT_TIMER=y
+CONFIG_SPL_ATMEL_PIT_TIMER=y
CONFIG_USB=y
CONFIG_USB_EHCI_HCD=y
CONFIG_USB_STORAGE=y
diff --git a/configs/sama7g5ek_mmc1_defconfig b/configs/sama7g5ek_mmc1_defconfig
index 75b24b380d9..31db8c1d5e0 100644
--- a/configs/sama7g5ek_mmc1_defconfig
+++ b/configs/sama7g5ek_mmc1_defconfig
@@ -71,6 +71,9 @@ CONFIG_DM_SERIAL=y
CONFIG_DEBUG_UART_ANNOUNCE=y
CONFIG_ATMEL_USART=y
CONFIG_TIMER=y
+CONFIG_SYSRESET=y
+CONFIG_SYSRESET_CMD_RESET=y
+CONFIG_SYSRESET_AT91=y
CONFIG_MCHP_PIT64B_TIMER=y
CONFIG_OF_LIBFDT_OVERLAY=y
# CONFIG_EFI_LOADER_HII is not set
diff --git a/configs/sama7g5ek_mmc_defconfig b/configs/sama7g5ek_mmc_defconfig
index 9d4da95677f..2e5e78e7b6a 100644
--- a/configs/sama7g5ek_mmc_defconfig
+++ b/configs/sama7g5ek_mmc_defconfig
@@ -71,6 +71,9 @@ CONFIG_DM_SERIAL=y
CONFIG_DEBUG_UART_ANNOUNCE=y
CONFIG_ATMEL_USART=y
CONFIG_TIMER=y
+CONFIG_SYSRESET=y
+CONFIG_SYSRESET_CMD_RESET=y
+CONFIG_SYSRESET_AT91=y
CONFIG_MCHP_PIT64B_TIMER=y
CONFIG_OF_LIBFDT_OVERLAY=y
# CONFIG_EFI_LOADER_HII is not set
diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index 14d7af4db28..fe8ea4626d9 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -28,7 +28,7 @@ CONFIG_AUTOBOOT_STOP_STR_CRYPT="$5$rounds=640000$HrpE65IkB8CM5nCL$BKT3QdF98Bo8fJ
CONFIG_IMAGE_PRE_LOAD=y
CONFIG_IMAGE_PRE_LOAD_SIG=y
CONFIG_CONSOLE_RECORD=y
-CONFIG_CONSOLE_RECORD_OUT_SIZE=0x1000
+CONFIG_CONSOLE_RECORD_OUT_SIZE=0x6000
CONFIG_PRE_CONSOLE_BUFFER=y
CONFIG_LOG=y
CONFIG_DISPLAY_BOARDINFO_LATE=y
@@ -120,6 +120,7 @@ CONFIG_ENV_IS_IN_EXT4=y
CONFIG_ENV_EXT4_INTERFACE="host"
CONFIG_ENV_EXT4_DEVICE_AND_PART="0:0"
CONFIG_ENV_IMPORT_FDT=y
+# CONFIG_BOOTDEV_ETH is not set
CONFIG_BOOTP_SEND_HOSTNAME=y
CONFIG_NETCONSOLE=y
CONFIG_IP_DEFRAG=y
diff --git a/configs/sandbox_flattree_defconfig b/configs/sandbox_flattree_defconfig
index ded16af9f51..80a4be47eba 100644
--- a/configs/sandbox_flattree_defconfig
+++ b/configs/sandbox_flattree_defconfig
@@ -17,7 +17,7 @@ CONFIG_BOOTSTAGE_FDT=y
CONFIG_BOOTSTAGE_STASH=y
CONFIG_BOOTSTAGE_STASH_SIZE=0x4096
CONFIG_CONSOLE_RECORD=y
-CONFIG_CONSOLE_RECORD_OUT_SIZE=0x1000
+CONFIG_CONSOLE_RECORD_OUT_SIZE=0x6000
CONFIG_DISPLAY_BOARDINFO_LATE=y
CONFIG_CMD_CPU=y
CONFIG_CMD_LICENSE=y
@@ -72,6 +72,7 @@ CONFIG_ENV_IS_NOWHERE=y
CONFIG_ENV_IS_IN_EXT4=y
CONFIG_ENV_EXT4_INTERFACE="host"
CONFIG_ENV_EXT4_DEVICE_AND_PART="0:0"
+# CONFIG_BOOTDEV_ETH is not set
CONFIG_BOOTP_SEND_HOSTNAME=y
CONFIG_NETCONSOLE=y
CONFIG_IP_DEFRAG=y
diff --git a/configs/tbs2910_defconfig b/configs/tbs2910_defconfig
index 60a816059a6..9f7642f25ca 100644
--- a/configs/tbs2910_defconfig
+++ b/configs/tbs2910_defconfig
@@ -17,6 +17,7 @@ CONFIG_SYS_MEMTEST_END=0x2f400000
CONFIG_LTO=y
CONFIG_HAS_BOARD_SIZE_LIMIT=y
CONFIG_BOARD_SIZE_LIMIT=392192
+# CONFIG_BOOTSTD is not set
CONFIG_SUPPORT_RAW_INITRD=y
CONFIG_BOOTDELAY=3
CONFIG_USE_BOOTCOMMAND=y
diff --git a/configs/tinker-rk3288_defconfig b/configs/tinker-rk3288_defconfig
index 9b94a40ea2e..5c2366098b7 100644
--- a/configs/tinker-rk3288_defconfig
+++ b/configs/tinker-rk3288_defconfig
@@ -39,7 +39,6 @@ CONFIG_CMD_PMIC=y
CONFIG_CMD_REGULATOR=y
# CONFIG_SPL_DOS_PARTITION is not set
# CONFIG_SPL_EFI_PARTITION is not set
-CONFIG_SPL_PARTITION_UUIDS=y
CONFIG_SPL_OF_CONTROL=y
CONFIG_OF_SPL_REMOVE_PROPS="clock-names interrupt-parent assigned-clocks assigned-clock-rates assigned-clock-parents"
CONFIG_ENV_IS_IN_MMC=y
diff --git a/configs/tinker-s-rk3288_defconfig b/configs/tinker-s-rk3288_defconfig
index 4cec319460a..4b6ae64988a 100644
--- a/configs/tinker-s-rk3288_defconfig
+++ b/configs/tinker-s-rk3288_defconfig
@@ -40,7 +40,6 @@ CONFIG_CMD_PMIC=y
CONFIG_CMD_REGULATOR=y
# CONFIG_SPL_DOS_PARTITION is not set
# CONFIG_SPL_EFI_PARTITION is not set
-CONFIG_SPL_PARTITION_UUIDS=y
CONFIG_SPL_OF_CONTROL=y
CONFIG_OF_SPL_REMOVE_PROPS="clock-names interrupt-parent assigned-clocks assigned-clock-rates assigned-clock-parents"
CONFIG_ENV_IS_IN_MMC=y
diff --git a/configs/vinco_defconfig b/configs/vinco_defconfig
index 23883d5de88..1394a1925e4 100644
--- a/configs/vinco_defconfig
+++ b/configs/vinco_defconfig
@@ -56,3 +56,6 @@ CONFIG_USB_GADGET=y
CONFIG_USB_GADGET_MANUFACTURER="L+G VInCo"
CONFIG_USB_GADGET_ATMEL_USBA=y
CONFIG_USB_ETHER=y
+CONFIG_SYSRESET=y
+CONFIG_SYSRESET_CMD_RESET=y
+CONFIG_SYSRESET_AT91=y
diff --git a/configs/vyasa-rk3288_defconfig b/configs/vyasa-rk3288_defconfig
index 9c0e3d441e7..ecba1a76c38 100644
--- a/configs/vyasa-rk3288_defconfig
+++ b/configs/vyasa-rk3288_defconfig
@@ -39,7 +39,6 @@ CONFIG_CMD_PMIC=y
CONFIG_CMD_REGULATOR=y
# CONFIG_SPL_DOS_PARTITION is not set
# CONFIG_SPL_EFI_PARTITION is not set
-CONFIG_SPL_PARTITION_UUIDS=y
CONFIG_SPL_OF_CONTROL=y
CONFIG_OF_SPL_REMOVE_PROPS="pinctrl-0 pinctrl-names clock-names interrupt-parent assigned-clocks assigned-clock-rates assigned-clock-parents"
CONFIG_ENV_IS_IN_MMC=y
diff --git a/configs/xilinx_versal_mini_defconfig b/configs/xilinx_versal_mini_defconfig
index 16d26352ec2..00d08f49f61 100644
--- a/configs/xilinx_versal_mini_defconfig
+++ b/configs/xilinx_versal_mini_defconfig
@@ -54,7 +54,6 @@ CONFIG_SYS_ALT_MEMTEST=y
# CONFIG_CMD_SOURCE is not set
# CONFIG_CMD_SETEXPR is not set
# CONFIG_CMD_SLEEP is not set
-# CONFIG_PARTITIONS is not set
CONFIG_SYS_RELOC_GD_ENV_ADDR=y
# CONFIG_NET is not set
# CONFIG_DM_WARN is not set
diff --git a/configs/xilinx_zynqmp_mini_defconfig b/configs/xilinx_zynqmp_mini_defconfig
index 1eab616f2f3..f2eaec2f91b 100644
--- a/configs/xilinx_zynqmp_mini_defconfig
+++ b/configs/xilinx_zynqmp_mini_defconfig
@@ -49,7 +49,6 @@ CONFIG_SYS_ALT_MEMTEST=y
# CONFIG_CMD_SETEXPR is not set
CONFIG_CMD_CACHE=y
# CONFIG_CMD_SLEEP is not set
-# CONFIG_PARTITIONS is not set
CONFIG_OF_EMBED=y
CONFIG_SYS_RELOC_GD_ENV_ADDR=y
# CONFIG_NET is not set
diff --git a/configs/xilinx_zynqmp_mini_nand_defconfig b/configs/xilinx_zynqmp_mini_nand_defconfig
index d57bafcf893..90e28203b3f 100644
--- a/configs/xilinx_zynqmp_mini_nand_defconfig
+++ b/configs/xilinx_zynqmp_mini_nand_defconfig
@@ -45,7 +45,6 @@ CONFIG_CLOCKS=y
# CONFIG_CMD_ITEST is not set
# CONFIG_CMD_SOURCE is not set
# CONFIG_CMD_SETEXPR is not set
-# CONFIG_PARTITIONS is not set
CONFIG_OF_EMBED=y
CONFIG_SYS_RELOC_GD_ENV_ADDR=y
# CONFIG_NET is not set
diff --git a/configs/xilinx_zynqmp_mini_nand_single_defconfig b/configs/xilinx_zynqmp_mini_nand_single_defconfig
index f9bc9afbbad..1a63ec9195f 100644
--- a/configs/xilinx_zynqmp_mini_nand_single_defconfig
+++ b/configs/xilinx_zynqmp_mini_nand_single_defconfig
@@ -45,7 +45,6 @@ CONFIG_CLOCKS=y
# CONFIG_CMD_ITEST is not set
# CONFIG_CMD_SOURCE is not set
# CONFIG_CMD_SETEXPR is not set
-# CONFIG_PARTITIONS is not set
CONFIG_OF_EMBED=y
CONFIG_SYS_RELOC_GD_ENV_ADDR=y
# CONFIG_NET is not set
diff --git a/disk/Kconfig b/disk/Kconfig
index 13700322e97..359af3b27e6 100644
--- a/disk/Kconfig
+++ b/disk/Kconfig
@@ -2,8 +2,7 @@
menu "Partition Types"
config PARTITIONS
- bool "Enable Partition Labels (disklabels) support"
- default y
+ bool
help
Partition Labels (disklabels) Supported:
Zero or more of the following:
@@ -20,8 +19,7 @@ config PARTITIONS
as well.
config SPL_PARTITIONS
- bool "Enable Partition Labels (disklabels) support in SPL"
- default y if PARTITIONS
+ bool
select SPL_SPRINTF
select SPL_STRTO
help
@@ -30,8 +28,7 @@ config SPL_PARTITIONS
small amount of size to SPL, typically 500 bytes.
config TPL_PARTITIONS
- bool "Enable Partition Labels (disklabels) support in TPL"
- default y if PARTITIONS
+ bool
select TPL_SPRINTF
select TPL_STRTO
help
@@ -41,57 +38,61 @@ config TPL_PARTITIONS
config MAC_PARTITION
bool "Enable Apple's MacOS partition table"
- depends on PARTITIONS
+ select PARTITIONS
help
Say Y here if you would like to use device under U-Boot which
were partitioned on a Macintosh.
config SPL_MAC_PARTITION
bool "Enable Apple's MacOS partition table for SPL"
- depends on SPL && PARTITIONS
+ depends on SPL
default y if MAC_PARTITION
+ select SPL_PARTITIONS
config DOS_PARTITION
bool "Enable MS Dos partition table"
- depends on PARTITIONS
default y if DISTRO_DEFAULTS
default y if x86 || CMD_FAT || USB_STORAGE
+ select PARTITIONS
help
traditional on the Intel architecture, USB sticks, etc.
config SPL_DOS_PARTITION
bool "Enable MS Dos partition table for SPL"
- depends on SPL && PARTITIONS
+ depends on SPL
default n if ARCH_SUNXI
default y if DOS_PARTITION
+ select SPL_PARTITIONS
config ISO_PARTITION
bool "Enable ISO partition table"
- depends on PARTITIONS
default y if DISTRO_DEFAULTS
default y if MIPS || ARCH_TEGRA
+ select PARTITIONS
config SPL_ISO_PARTITION
bool "Enable ISO partition table for SPL"
- depends on SPL && PARTITIONS
+ depends on SPL
+ select SPL_PARTITIONS
config AMIGA_PARTITION
bool "Enable AMIGA partition table"
- depends on PARTITIONS
+ select PARTITIONS
help
Say Y here if you would like to use device under U-Boot which
were partitioned under AmigaOS.
config SPL_AMIGA_PARTITION
bool "Enable AMIGA partition table for SPL"
- depends on SPL && PARTITIONS
+ depends on SPL
default y if AMIGA_PARTITION
+ select SPL_PARTITIONS
config EFI_PARTITION
bool "Enable EFI GPT partition table"
- depends on PARTITIONS
default y if DISTRO_DEFAULTS
default y if ARCH_TEGRA
+ select PARTITIONS
select LIB_UUID
help
Say Y here if you would like to use device under U-Boot which
@@ -128,9 +129,10 @@ config EFI_PARTITION_ENTRIES_OFF
config SPL_EFI_PARTITION
bool "Enable EFI GPT partition table for SPL"
- depends on SPL && PARTITIONS
+ depends on SPL
default n if ARCH_SUNXI
default y if EFI_PARTITION
+ select SPL_PARTITIONS
config PARTITION_UUIDS
bool "Enable support of UUID for partition"
@@ -143,12 +145,11 @@ config PARTITION_UUIDS
config SPL_PARTITION_UUIDS
bool "Enable support of UUID for partition in SPL"
- depends on SPL && PARTITIONS
+ depends on SPL_PARTITIONS
default y if SPL_EFI_PARTITION
config PARTITION_TYPE_GUID
bool "Enable support of GUID for partition type"
- depends on PARTITIONS
depends on EFI_PARTITION
help
Activate the configuration of GUID type
diff --git a/disk/Makefile b/disk/Makefile
index 5ca10c55762..ec148832b33 100644
--- a/disk/Makefile
+++ b/disk/Makefile
@@ -6,6 +6,9 @@
#ccflags-y += -DET_DEBUG -DDEBUG
obj-$(CONFIG_$(SPL_TPL_)PARTITIONS) += part.o
+ifdef CONFIG_$(SPL_TPL_)BLK
+obj-$(CONFIG_$(SPL_TPL_)PARTITIONS) += disk-uclass.o
+endif
obj-$(CONFIG_$(SPL_TPL_)MAC_PARTITION) += part_mac.o
obj-$(CONFIG_$(SPL_TPL_)DOS_PARTITION) += part_dos.o
obj-$(CONFIG_$(SPL_TPL_)ISO_PARTITION) += part_iso.o
diff --git a/disk/disk-uclass.c b/disk/disk-uclass.c
new file mode 100644
index 00000000000..72ff62ebf58
--- /dev/null
+++ b/disk/disk-uclass.c
@@ -0,0 +1,247 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Software partition device (UCLASS_PARTITION)
+ *
+ * Copyright (c) 2021 Linaro Limited
+ * Author: AKASHI Takahiro
+ */
+
+#define LOG_CATEGORY UCLASS_PARTITION
+
+#include <blk.h>
+#include <dm.h>
+#include <log.h>
+#include <part.h>
+#include <vsprintf.h>
+#include <dm/device-internal.h>
+#include <dm/lists.h>
+
+int part_create_block_devices(struct udevice *blk_dev)
+{
+ int part, count;
+ struct blk_desc *desc = dev_get_uclass_plat(blk_dev);
+ struct disk_partition info;
+ struct disk_part *part_data;
+ char devname[32];
+ struct udevice *dev;
+ int ret;
+
+ if (!CONFIG_IS_ENABLED(PARTITIONS) ||
+ !CONFIG_IS_ENABLED(HAVE_BLOCK_DEVICE))
+ return 0;
+
+ if (device_get_uclass_id(blk_dev) != UCLASS_BLK)
+ return 0;
+
+ /* Add devices for each partition */
+ for (count = 0, part = 1; part <= MAX_SEARCH_PARTITIONS; part++) {
+ if (part_get_info(desc, part, &info))
+ continue;
+ snprintf(devname, sizeof(devname), "%s:%d", blk_dev->name,
+ part);
+
+ ret = device_bind_driver(blk_dev, "blk_partition",
+ strdup(devname), &dev);
+ if (ret)
+ return ret;
+
+ part_data = dev_get_uclass_plat(dev);
+ part_data->partnum = part;
+ part_data->gpt_part_info = info;
+ count++;
+
+ ret = device_probe(dev);
+ if (ret) {
+ debug("Can't probe\n");
+ count--;
+ device_unbind(dev);
+
+ continue;
+ }
+ }
+ debug("%s: %d partitions found in %s\n", __func__, count,
+ blk_dev->name);
+
+ return 0;
+}
+
+static ulong blk_part_read(struct udevice *dev, lbaint_t start,
+ lbaint_t blkcnt, void *buffer)
+{
+ struct udevice *parent;
+ struct disk_part *part;
+ const struct blk_ops *ops;
+
+ parent = dev_get_parent(dev);
+ ops = blk_get_ops(parent);
+ if (!ops->read)
+ return -ENOSYS;
+
+ part = dev_get_uclass_plat(dev);
+ if (start >= part->gpt_part_info.size)
+ return 0;
+
+ if ((start + blkcnt) > part->gpt_part_info.size)
+ blkcnt = part->gpt_part_info.size - start;
+ start += part->gpt_part_info.start;
+
+ return ops->read(parent, start, blkcnt, buffer);
+}
+
+static ulong blk_part_write(struct udevice *dev, lbaint_t start,
+ lbaint_t blkcnt, const void *buffer)
+{
+ struct udevice *parent;
+ struct disk_part *part;
+ const struct blk_ops *ops;
+
+ parent = dev_get_parent(dev);
+ ops = blk_get_ops(parent);
+ if (!ops->write)
+ return -ENOSYS;
+
+ part = dev_get_uclass_plat(dev);
+ if (start >= part->gpt_part_info.size)
+ return 0;
+
+ if ((start + blkcnt) > part->gpt_part_info.size)
+ blkcnt = part->gpt_part_info.size - start;
+ start += part->gpt_part_info.start;
+
+ return ops->write(parent, start, blkcnt, buffer);
+}
+
+static ulong blk_part_erase(struct udevice *dev, lbaint_t start,
+ lbaint_t blkcnt)
+{
+ struct udevice *parent;
+ struct disk_part *part;
+ const struct blk_ops *ops;
+
+ parent = dev_get_parent(dev);
+ ops = blk_get_ops(parent);
+ if (!ops->erase)
+ return -ENOSYS;
+
+ part = dev_get_uclass_plat(dev);
+ if (start >= part->gpt_part_info.size)
+ return 0;
+
+ if ((start + blkcnt) > part->gpt_part_info.size)
+ blkcnt = part->gpt_part_info.size - start;
+ start += part->gpt_part_info.start;
+
+ return ops->erase(parent, start, blkcnt);
+}
+
+static const struct blk_ops blk_part_ops = {
+ .read = blk_part_read,
+ .write = blk_part_write,
+ .erase = blk_part_erase,
+};
+
+U_BOOT_DRIVER(blk_partition) = {
+ .name = "blk_partition",
+ .id = UCLASS_PARTITION,
+ .ops = &blk_part_ops,
+};
+
+/*
+ * BLOCK IO APIs
+ */
+static struct blk_desc *dev_get_blk(struct udevice *dev)
+{
+ struct blk_desc *block_dev;
+
+ switch (device_get_uclass_id(dev)) {
+ /*
+ * We won't support UCLASS_BLK with dev_* interfaces.
+ */
+ case UCLASS_PARTITION:
+ block_dev = dev_get_uclass_plat(dev_get_parent(dev));
+ break;
+ default:
+ block_dev = NULL;
+ break;
+ }
+
+ return block_dev;
+}
+
+unsigned long dev_read(struct udevice *dev, lbaint_t start,
+ lbaint_t blkcnt, void *buffer)
+{
+ struct blk_desc *block_dev;
+ const struct blk_ops *ops;
+ struct disk_part *part;
+ lbaint_t start_in_disk;
+ ulong blks_read;
+
+ block_dev = dev_get_blk(dev);
+ if (!block_dev)
+ return -ENOSYS;
+
+ ops = blk_get_ops(dev);
+ if (!ops->read)
+ return -ENOSYS;
+
+ start_in_disk = start;
+ if (device_get_uclass_id(dev) == UCLASS_PARTITION) {
+ part = dev_get_uclass_plat(dev);
+ start_in_disk += part->gpt_part_info.start;
+ }
+
+ if (blkcache_read(block_dev->if_type, block_dev->devnum,
+ start_in_disk, blkcnt, block_dev->blksz, buffer))
+ return blkcnt;
+ blks_read = ops->read(dev, start, blkcnt, buffer);
+ if (blks_read == blkcnt)
+ blkcache_fill(block_dev->if_type, block_dev->devnum,
+ start_in_disk, blkcnt, block_dev->blksz, buffer);
+
+ return blks_read;
+}
+
+unsigned long dev_write(struct udevice *dev, lbaint_t start,
+ lbaint_t blkcnt, const void *buffer)
+{
+ struct blk_desc *block_dev;
+ const struct blk_ops *ops;
+
+ block_dev = dev_get_blk(dev);
+ if (!block_dev)
+ return -ENOSYS;
+
+ ops = blk_get_ops(dev);
+ if (!ops->write)
+ return -ENOSYS;
+
+ blkcache_invalidate(block_dev->if_type, block_dev->devnum);
+
+ return ops->write(dev, start, blkcnt, buffer);
+}
+
+unsigned long dev_erase(struct udevice *dev, lbaint_t start,
+ lbaint_t blkcnt)
+{
+ struct blk_desc *block_dev;
+ const struct blk_ops *ops;
+
+ block_dev = dev_get_blk(dev);
+ if (!block_dev)
+ return -ENOSYS;
+
+ ops = blk_get_ops(dev);
+ if (!ops->erase)
+ return -ENOSYS;
+
+ blkcache_invalidate(block_dev->if_type, block_dev->devnum);
+
+ return ops->erase(dev, start, blkcnt);
+}
+
+UCLASS_DRIVER(partition) = {
+ .id = UCLASS_PARTITION,
+ .per_device_plat_auto = sizeof(struct disk_part),
+ .name = "partition",
+};
diff --git a/doc/README.standalone b/doc/README.standalone
index 874ca2f7c66..3306c300cf9 100644
--- a/doc/README.standalone
+++ b/doc/README.standalone
@@ -56,7 +56,6 @@ Design Notes on Exporting U-Boot Functions to Standalone Applications:
ARM 0x0c100000 0x0c100000
MIPS 0x80200000 0x80200000
Blackfin 0x00001000 0x00001000
- NDS32 0x00300000 0x00300000
Nios II 0x02000000 0x02000000
RISC-V 0x00600000 0x00600000
diff --git a/doc/README.watchdog b/doc/README.watchdog
index f23c923910a..c50dc79e15e 100644
--- a/doc/README.watchdog
+++ b/doc/README.watchdog
@@ -17,12 +17,6 @@ CONFIG_WATCHDOG_TIMEOUT_MSECS
CONFIG_WDT_AT91
Available for AT91SAM9 to service the watchdog.
-CONFIG_FTWDT010_WATCHDOG
- Available for FTWDT010 to service the watchdog.
-
-CONFIG_FTWDT010_HW_TIMEOUT
- Can be used to change the timeout for FTWDT010.
-
CONFIG_IMX_WATCHDOG
Available for i.mx31/35/5x/6x to service the watchdog. This is not
automatically set because some boards (vision2) still need to define
diff --git a/doc/arch/index.rst b/doc/arch/index.rst
index 369d8eeb6d1..792d9182c31 100644
--- a/doc/arch/index.rst
+++ b/doc/arch/index.rst
@@ -10,7 +10,6 @@ Architecture-specific doc
arm64
m68k
mips
- nds32
nios2
sandbox
sh
diff --git a/doc/arch/nds32.rst b/doc/arch/nds32.rst
deleted file mode 100644
index 502397cf7f6..00000000000
--- a/doc/arch/nds32.rst
+++ /dev/null
@@ -1,101 +0,0 @@
-.. SPDX-License-Identifier: GPL-2.0+
-
-NDS32
-=====
-
-NDS32 is a new high-performance 32-bit RISC microprocessor core.
-
-http://www.andestech.com/
-
-AndeStar ISA
-------------
-AndeStar is a patent-pending 16-bit/32-bit mixed-length instruction set to
-achieve optimal system performance, code density, and power efficiency.
-
-It contains the following features:
- - Intermixable 32-bit and 16-bit instruction sets without the need for
- mode switch.
- - 16-bit instructions as a frequently used subset of 32-bit instructions.
- - RISC-style register-based instruction set.
- - 32 32-bit General Purpose Registers (GPR).
- - Upto 1024 User Special Registers (USR) for existing and extension
- instructions.
- - Rich load/store instructions for...
- - Single memory access with base address update.
- - Multiple aligned and unaligned memory accesses for memory copy and stack
- operations.
- - Data prefetch to improve data cache performance.
- - Non-bus locking synchronization instructions.
- - PC relative jump and PC read instructions for efficient position independent
- code.
- - Multiply-add and multiple-sub with 64-bit accumulator.
- - Instruction for efficient power management.
- - Bi-endian support.
- - Three instruction extension space for application acceleration:
- - Performance extension.
- - Andes future extensions (for floating-point, multimedia, etc.)
- - Customer extensions.
-
-AndesCore CPU
--------------
-Andes Technology has 4 families of CPU cores: N12, N10, N9, N8.
-
-For details about N12 CPU family, please check below N1213 features.
-N1213 is a configurable hard/soft core of NDS32's N12 CPU family.
-
-N1213 Features
-^^^^^^^^^^^^^^
-
-CPU Core
- - 16-/32-bit mixable instruction format.
- - 32 general-purpose 32-bit registers.
- - 8-stage pipeline.
- - Dynamic branch prediction.
- - 32/64/128/256 BTB.
- - Return address stack (RAS).
- - Vector interrupts for internal/external.
- interrupt controller with 6 hardware interrupt signals.
- - 3 HW-level nested interruptions.
- - User and super-user mode support.
- - Memory-mapped I/O.
- - Address space up to 4GB.
-
-Memory Management Unit
- - TLB
- - 4/8-entry fully associative iTLB/dTLB.
- - 32/64/128-entry 4-way set-associati.ve main TLB.
- - TLB locking support
- - Optional hardware page table walker.
- - Two groups of page size support.
- - 4KB & 1MB.
- - 8KB & 1MB.
-
-Memory Subsystem
- - I & D cache.
- - Virtually indexed and physically tagged.
- - Cache size: 8KB/16KB/32KB/64KB.
- - Cache line size: 16B/32B.
- - Set associativity: 2-way, 4-way or direct-mapped.
- - Cache locking support.
- - I & D local memory (LM).
- - Size: 4KB to 1MB.
- - Bank numbers: 1 or 2.
- - Optional 1D/2D DMA engine.
- - Internal or external to CPU core.
-
-Bus Interface
- - Synchronous/Asynchronous AHB bus: 0, 1 or 2 ports.
- - Synchronous High speed memory port.
- (HSMP): 0, 1 or 2 ports.
-
-Debug
- - JTAG debug interface.
- - Embedded debug module (EDM).
- - Optional embedded program tracer interface.
-
-Miscellaneous
- - Programmable data endian control.
- - Performance monitoring mechanism.
-
-The NDS32 ports of u-boot, the Linux kernel, the GNU toolchain and other
-associated software are actively supported by Andes Technology Corporation.
diff --git a/doc/board/amlogic/index.rst b/doc/board/amlogic/index.rst
index 9ef14404331..9c7fadf2c02 100644
--- a/doc/board/amlogic/index.rst
+++ b/doc/board/amlogic/index.rst
@@ -55,7 +55,7 @@ This matrix concerns the actual source code version.
+-------------------------------+-----------+-----------------+--------------+-------------+------------+-------------+--------------+
| NAND | No | No | No | No | No | No | No |
+-------------------------------+-----------+-----------------+--------------+-------------+------------+-------------+--------------+
-| ADC | **Yes** | **Yes** | **Yes** | No | No | No | No |
+| ADC | **Yes** | **Yes** | **Yes** | **Yes** | No | No | No |
+-------------------------------+-----------+-----------------+--------------+-------------+------------+-------------+--------------+
| CVBS Output | **Yes** | **Yes** | **Yes** | *N/A* | **Yes** | **Yes** | **Yes** |
+-------------------------------+-----------+-----------------+--------------+-------------+------------+-------------+--------------+
diff --git a/doc/board/amlogic/jethub-j100.rst b/doc/board/amlogic/jethub-j100.rst
index d54519aaefb..dd1ed68b9ce 100644
--- a/doc/board/amlogic/jethub-j100.rst
+++ b/doc/board/amlogic/jethub-j100.rst
@@ -3,27 +3,33 @@
U-Boot for JetHub J100
=======================
-JetHome Jethub D1 (http://jethome.ru/jethub-d1) is a home automation
-controller manufactured by JetHome with the following specifications:
+JetHome Jethub D1 (http://jethome.ru/jethub-d1) is a series of home
+automation controller manufactured by JetHome with the following
+specifications:
- Amlogic A113X (ARM Cortex-A53) quad-core up to 1.5GHz
- no video out
- - 512Mb/1GB DDR3
- - 8/16GB eMMC flash
+ - 512MB/1GB DDR3 or 2GB DDR4 SDRAM
+ - 8/16/32GB eMMC flash
- 1 x USB 2.0
- 1 x 10/100Mbps ethernet
- - WiFi / Bluetooth AMPAK AP6255 (Broadcom BCM43455) IEEE
- 802.11a/b/g/n/ac, Bluetooth 4.2.
- - TI CC2538 + CC2592 Zigbee Wireless Module with up to 20dBm output
- power and Zigbee 3.0 support.
+ - WiFi / Bluetooth one from:
+ - AMPAK AP6255 (Broadcom BCM43455) IEEE 802.11a/b/g/n/ac, Bluetooth 4.2
+ - RTL8822CS IEEE 802.11a/b/g/n/ac, Bluetooth 5.0
+ - Amlogic W155S1 WiFi5 IEEE 802.11a/b/g/n/ac, Bluetooth 5.2
- 2 x gpio LEDS
- GPIO user Button
+ - DC source with a voltage of 9 to 56 V / Passive POE
+ - DIN Rail Mounting case
+
+Basic version also has:
+
+ - TI CC2538 + CC2592 Zigbee Wireless Module with up to 20dBm output
+ power and Zigbee 3.0 support.
- 1 x 1-Wire
- 2 x RS-485
- 4 x dry contact digital GPIO inputs
- 3 x relay GPIO outputs
- - DC source with a voltage of 9 to 56 V / Passive POE
- - DIN Rail Mounting case
U-Boot compilation
------------------
diff --git a/doc/board/apple/m1.rst b/doc/board/apple/m1.rst
index 083bfb0a1a6..8fa7637629e 100644
--- a/doc/board/apple/m1.rst
+++ b/doc/board/apple/m1.rst
@@ -10,6 +10,7 @@ the following SoCs work:
- Apple M1 SoC (t8103)
- Apple M1 Pro SoC (t6000)
- Apple M1 Max SoC (t6001)
+ - Apple M1 Ultra SoC (t6002)
On these SoCs the following hardware is supported:
@@ -78,5 +79,5 @@ supported SoCs.
- Base Address
* - M1 (t8103)
- 0x235200000
- * - M1 Pro/Max (t6000/t6001)
+ * - M1 Pro/Max/Ultra (t6000/t6001/t6002)
- 0x39b200000
diff --git a/doc/develop/bootstd.rst b/doc/develop/bootstd.rst
new file mode 100644
index 00000000000..5e9c0d282bb
--- /dev/null
+++ b/doc/develop/bootstd.rst
@@ -0,0 +1,638 @@
+.. SPDX-License-Identifier: GPL-2.0+:
+
+U-Boot Standard Boot
+====================
+
+Introduction
+------------
+
+Standard boot provides a built-in way for U-Boot to automatically boot
+an Operating System without custom scripting and other customisation. It
+introduces the following concepts:
+
+ - bootdev - a device which can hold or access a distro (e.g. MMC, Ethernet)
+ - bootmeth - a method to scan a bootdev to find bootflows (e.g. distro boot)
+ - bootflow - a description of how to boot (provided by the distro)
+
+For Linux, the distro (Linux distribution, e.g. Debian, Fedora) is responsible
+for creating a bootflow for each kernel combination that it wants to offer.
+These bootflows are stored on media so they can be discovered by U-Boot. This
+feature is typically called `distro boot` (see :doc:`distro`) because it is
+a way for distributions to boot on any hardware.
+
+Traditionally U-Boot has relied on scripts to implement this feature. See
+disto_boodcmd_ for details. This is done because U-Boot has no native support
+for scanning devices. While the scripts work remarkably well, they can be hard
+to understand and extend, and the feature does not include tests. They are also
+making it difficult to move away from ad-hoc CONFIGs, since they are implemented
+using the environment and a lot of #defines.
+
+Standard boot is a generalisation of distro boot. It provides a more built-in
+way to boot with U-Boot. The feature is extensible to different Operating
+Systems (such as Chromium OS) and devices (beyond just block and network
+devices). It supports EFI boot and EFI bootmgr too.
+
+
+Bootflow
+--------
+
+A bootflow is a file that describes how to boot a distro. Conceptually there can
+be different formats for that file but at present U-Boot only supports the
+BootLoaderSpec_ format. which looks something like this::
+
+ menu autoboot Welcome to Fedora-Workstation-armhfp-31-1.9. Automatic boot in # second{,s}. Press a key for options.
+ menu title Fedora-Workstation-armhfp-31-1.9 Boot Options.
+ menu hidden
+
+ label Fedora-Workstation-armhfp-31-1.9 (5.3.7-301.fc31.armv7hl)
+ kernel /vmlinuz-5.3.7-301.fc31.armv7hl
+ append ro root=UUID=9732b35b-4cd5-458b-9b91-80f7047e0b8a rhgb quiet LANG=en_US.UTF-8 cma=192MB cma=256MB
+ fdtdir /dtb-5.3.7-301.fc31.armv7hl/
+ initrd /initramfs-5.3.7-301.fc31.armv7hl.img
+
+As you can see it specifies a kernel, a ramdisk (initrd) and a directory from
+which to load devicetree files. The details are described in disto_boodcmd_.
+
+The bootflow is provided by the distro. It is not part of U-Boot. U-Boot's job
+is simply to interpret the file and carry out the instructions. This allows
+distros to boot on essentially any device supported by U-Boot.
+
+Typically the first available bootflow is selected and booted. If that fails,
+then the next one is tried.
+
+
+Bootdev
+-------
+
+Where does U-Boot find the media that holds the operating systems? That is the
+job of bootdev. A bootdev is simply a layer on top of a media device (such as
+MMC, NVMe). The bootdev accesses the device, including partitions and
+filesystems that might contain things related to an operating system.
+
+For example, an MMC bootdev provides access to the individual partitions on the
+MMC device. It scans through these to find filesystems, then provides a list of
+these for consideration.
+
+
+Bootmeth
+--------
+
+Once the list of filesystems is provided, how does U-Boot find the bootflow
+files in these filesystems. That is the job of bootmeth. Each boot method has
+its own way of doing this.
+
+For example, the distro bootmeth simply looks through the provided filesystem
+for a file called `extlinux/extlinux.conf`. This files constitutes a bootflow.
+If the distro bootmeth is used on multiple partitions it may produce multiple
+bootflows.
+
+Note: it is possible to have a bootmeth that uses a partition or a whole device
+directly, but it is more common to use a filesystem.
+
+
+Boot process
+------------
+
+U-Boot tries to use the 'lazy init' approach whereever possible and distro boot
+is no exception. The algorithm is::
+
+ while (get next bootdev)
+ while (get next bootmeth)
+ while (get next bootflow)
+ try to boot it
+
+So U-Boot works its way through the bootdevs, trying each bootmeth in turn to
+obtain bootflows, until it either boots or exhausts the available options.
+
+Instead of 500 lines of #defines and a 4KB boot script, all that is needed is
+the following command::
+
+ bootflow scan -lb
+
+which scans for available bootflows, optionally listing each find it finds (-l)
+and trying to boot it (-b).
+
+
+Controlling ordering
+--------------------
+
+Several options are available to control the ordering of boot scanning:
+
+
+boot_targets
+~~~~~~~~~~~~
+
+This environment variable can be used to control the list of bootdevs searched
+and their ordering, for example::
+
+ setenv boot_targets "mmc0 mmc1 usb pxe"
+
+Entries may be removed or re-ordered in this list to affect the boot order. If
+the variable is empty, the default ordering is used, based on the priority of
+bootdevs and their sequence numbers.
+
+
+bootmeths
+~~~~~~~~~
+
+This environment variable can be used to control the list of bootmeths used and
+their ordering for example::
+
+ setenv bootmeths "syslinux efi"
+
+Entries may be removed or re-ordered in this list to affect the order the
+bootmeths are tried on each bootdev. If the variable is empty, the default
+ordering is used, based on the bootmeth sequence numbers, which can be
+controlled by aliases.
+
+The :ref:`usage/cmd/bootmeth:bootmeth command` (`bootmeth order`) operates in
+the same way as setting this variable.
+
+
+Bootdev uclass
+--------------
+
+The bootdev uclass provides an simple API call to obtain a bootflows from a
+device::
+
+ int bootdev_get_bootflow(struct udevice *dev, struct bootflow_iter *iter,
+ struct bootflow *bflow);
+
+This takes a iterator which indicates the bootdev, partition and bootmeth to
+use. It returns a bootflow. This is the core of the bootdev implementation. The
+bootdev drivers that implement this differ depending on the media they are
+reading from, but each is responsible for returning a valid bootflow if
+available.
+
+A helper called `bootdev_find_in_blk()` makes it fairly easy to implement this
+function for each media device uclass, in a few lines of code.
+
+
+Bootdev drivers
+---------------
+
+A bootdev driver is typically fairly simple. Here is one for mmc::
+
+ static int mmc_get_bootflow(struct udevice *dev, struct bootflow_iter *iter,
+ struct bootflow *bflow)
+ {
+ struct udevice *mmc_dev = dev_get_parent(dev);
+ struct udevice *blk;
+ int ret;
+
+ ret = mmc_get_blk(mmc_dev, &blk);
+ /*
+ * If there is no media, indicate that no more partitions should be
+ * checked
+ */
+ if (ret == -EOPNOTSUPP)
+ ret = -ESHUTDOWN;
+ if (ret)
+ return log_msg_ret("blk", ret);
+ assert(blk);
+ ret = bootdev_find_in_blk(dev, blk, iter, bflow);
+ if (ret)
+ return log_msg_ret("find", ret);
+
+ return 0;
+ }
+
+ static int mmc_bootdev_bind(struct udevice *dev)
+ {
+ struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev);
+
+ ucp->prio = BOOTDEVP_0_INTERNAL_FAST;
+
+ return 0;
+ }
+
+ struct bootdev_ops mmc_bootdev_ops = {
+ .get_bootflow = mmc_get_bootflow,
+ };
+
+ static const struct udevice_id mmc_bootdev_ids[] = {
+ { .compatible = "u-boot,bootdev-mmc" },
+ { }
+ };
+
+ U_BOOT_DRIVER(mmc_bootdev) = {
+ .name = "mmc_bootdev",
+ .id = UCLASS_BOOTDEV,
+ .ops = &mmc_bootdev_ops,
+ .bind = mmc_bootdev_bind,
+ .of_match = mmc_bootdev_ids,
+ };
+
+The implementation of the `get_bootflow()` method is simply to obtain the
+block device and call a bootdev helper function to do the rest. The
+implementation of `bootdev_find_in_blk()` checks the partition table, and
+attempts to read a file from a filesystem on the partition number given by the
+`@iter->part` parameter.
+
+Each bootdev has a priority, which indicates the order in which it is used.
+Faster bootdevs are used first, since they are more likely to be able to boot
+the device quickly.
+
+
+Device hierarchy
+----------------
+
+A bootdev device is a child of the media device. In this example, you can see
+that the bootdev is a sibling of the block device and both are children of
+media device::
+
+ mmc 0 [ + ] bcm2835-sdhost | |-- mmc@7e202000
+ blk 0 [ + ] mmc_blk | | |-- mmc@7e202000.blk
+ bootdev 0 [ ] mmc_bootdev | | `-- mmc@7e202000.bootdev
+ mmc 1 [ + ] sdhci-bcm2835 | |-- sdhci@7e300000
+ blk 1 [ ] mmc_blk | | |-- sdhci@7e300000.blk
+ bootdev 1 [ ] mmc_bootdev | | `-- sdhci@7e300000.bootdev
+
+The bootdev device is typically created automatically in the media uclass'
+`post_bind()` method by calling `bootdev_setup_for_dev()`. The code typically
+something like this::
+
+ ret = bootdev_setup_for_dev(dev, "eth_bootdev");
+ if (ret)
+ return log_msg_ret("bootdev", ret);
+
+Here, `eth_bootdev` is the name of the Ethernet bootdev driver and `dev`
+is the ethernet device. This function is safe to call even if standard boot is
+not enabled, since it does nothing in that case. It can be added to all uclasses
+which implement suitable media.
+
+
+The bootstd device
+------------------
+
+Standard boot requires a single instance of the bootstd device to make things
+work. This includes global information about the state of standard boot. See
+`struct bootstd_priv` for this structure, accessed with `bootstd_get_priv()`.
+
+Within the devicetree, if you add bootmeth devices or a system bootdev, they
+should be children of the bootstd device. See `arch/sandbox/dts/test.dts` for
+an example of this.
+
+
+The system bootdev
+------------------
+
+Some bootmeths don't operate on individual bootdevs, but on the whole system.
+For example, the EFI boot manager does its own device scanning and does not
+make use of the bootdev devices. Such bootmeths can make use of the system
+bootdev, typically considered last, after everything else has been tried.
+
+
+.. _`Automatic Devices`:
+
+Automatic devices
+-----------------
+
+It is possible to define all the required devices in the devicetree manually,
+but it is not necessary. The bootstd uclass includes a `dm_scan_other()`
+function which creates the bootstd device if not found. If no bootmeth devices
+are found at all, it creates one for each available bootmeth driver as well as a
+system bootdev.
+
+If your devicetree has any bootmeth device it must have all of them that you
+want to use, as well as the system bootdev if needed, since no bootmeth devices
+will be created automatically in that case.
+
+
+Using devicetree
+----------------
+
+If a bootdev is complicated or needs configuration information, it can be
+added to the devicetree as a child of the media device. For example, imagine a
+bootdev which reads a bootflow from SPI flash. The devicetree fragment might
+look like this::
+
+ spi@0 {
+ flash@0 {
+ reg = <0>;
+ compatible = "spansion,m25p16", "jedec,spi-nor";
+ spi-max-frequency = <40000000>;
+
+ bootdev {
+ compatible = "u-boot,sf-bootdev";
+ offset = <0x2000>;
+ size = <0x1000>;
+ };
+ };
+ };
+
+The `sf-bootdev` driver can implement a way to read from the SPI flash, using
+the offset and size provided, and return that bootflow file back to the caller.
+When distro boot wants to read the kernel it calls disto_getfile() which must
+provide a way to read from the SPI flash. See `distro_boot()` at distro_boot_
+for more details.
+
+Of course this is all internal to U-Boot. All the distro sees is another way
+to boot.
+
+
+Configuration
+-------------
+
+Standard boot is enabled with `CONFIG_BOOTSTD`. Each bootmeth has its own CONFIG
+option also. For example, `CONFIG_BOOTMETH_DISTRO` enables support for distro
+boot from a disk.
+
+
+Available bootmeth drivers
+--------------------------
+
+Bootmeth drivers are provided for:
+
+ - distro boot from a disk (syslinux)
+ - distro boot from a network (PXE)
+ - EFI boot using bootefi
+ - EFI boot using boot manager
+
+
+Command interface
+-----------------
+
+Three commands are available:
+
+`bootdev`
+ Allows listing of available bootdevs, selecting a particular one and
+ getting information about it. See :doc:`../usage/cmd/bootdev`
+
+`bootflow`
+ Allows scanning one or more bootdevs for bootflows, listing available
+ bootflows, selecting one, obtaining information about it and booting it.
+ See :doc:`../usage/cmd/bootflow`
+
+`bootmeth`
+ Allow listing of available bootmethds and setting the order in which they
+ are tried. See :doc:`../usage/cmd/bootmeth`
+
+.. _BootflowStates:
+
+Bootflow states
+---------------
+
+Here is a list of states that a bootflow can be in:
+
+======= =======================================================================
+State Meaning
+======= =======================================================================
+base Starting-out state, indicates that no media/partition was found. For an
+ SD card socket it may indicate that the card is not inserted.
+media Media was found (e.g. SD card is inserted) but no partition information
+ was found. It might lack a partition table or have a read error.
+part Partition was found but a filesystem could not be read. This could be
+ because the partition does not hold a filesystem or the filesystem is
+ very corrupted.
+fs Filesystem was found but the file could not be read. It could be
+ missing or in the wrong subdirectory.
+file File was found and its size detected, but it could not be read. This
+ could indicate filesystem corruption.
+ready File was loaded and is ready for use. In this state the bootflow is
+ ready to be booted.
+======= =======================================================================
+
+
+Theory of operation
+-------------------
+
+This describes how standard boot progresses through to booting an operating
+system.
+
+To start. all the necessary devices must be bound, including bootstd, which
+provides the top-level `struct bootstd_priv` containing optional configuration
+information. The bootstd device is also holds the various lists used while
+scanning. This step is normally handled automatically by driver model, as
+described in `Automatic Devices`_.
+
+Bootdevs are also required, to provide access to the media to use. These are not
+useful by themselves: bootmeths are needed to provide the means of scanning
+those bootdevs. So, all up, we need a single bootstd device, one or more bootdev
+devices and one or more bootmeth devices.
+
+Once these are ready, typically a `bootflow scan` command is issued. This kicks
+of the iteration process, which involves looking through the bootdevs and their
+partitions one by one to find bootflows.
+
+Iteration is kicked off using `bootflow_scan_first()`, which calls
+`bootflow_scan_bootdev()`.
+
+The iterator is set up with `bootflow_iter_init()`. This simply creates an
+empty one with the given flags. Flags are used to control whether each
+iteration is displayed, whether to return iterations even if they did not result
+in a valid bootflow, whether to iterate through just a single bootdev, etc.
+
+Then the ordering of bootdevs is determined, by `bootdev_setup_iter_order()`. By
+default, the bootdevs are used in the order specified by the `boot_targets`
+environment variable (e.g. "mmc2 mmc0 usb"). If that is missing then their
+sequence order is used, as determined by the `/aliases` node, or failing that
+their order in the devicetree. For BOOTSTD_FULL, if there is a `bootdev-order`
+property in the bootstd node, then this is used as a final fallback. In any
+case, the iterator ends up with a `dev_order` array containing the bootdevs that
+are going to be used, with `num_devs` set to the number of bootdevs and
+`cur_dev` starting at 0.
+
+Next, the ordering of bootdevs is determined, by `bootmeth_setup_iter_order()`.
+By default the ordering is again by sequence number, i.e. the `/aliases` node,
+or failing that the order in the devicetree. But the `bootmeth order` command
+or `bootmeths` environment variable can be used to set up an ordering. If that
+has been done, the ordering is in `struct bootstd_priv`, so that ordering is
+simply copied into the iterator. Either way, the `method_order` array it set up,
+along with `num_methods`. Then `cur_method` is set to 0.
+
+At this point the iterator is ready to use, with the first bootdev and bootmeth
+selected. All the other fields are 0. This means that the current partition is
+0, which is taken to mean the whole device, since partition numbers start at 1.
+It also means that `max_part` is 0, i.e. the maximum partition number we know
+about is 0, meaning that, as far as we know, there is no partition table on this
+bootdev.
+
+With the iterator ready, `bootflow_scan_bootdev()` checks whether the current
+settings produce a valid bootflow. This is handled by `bootflow_check()`, which
+either returns 0 (if it got something) or an error if not (more on that later).
+If the `BOOTFLOWF_ALL` iterator flag is set, even errors are returned as
+incomplete bootflows, but normally an error results in moving onto the next
+iteration.
+
+The `bootflow_scan_next()` function handles moving onto the next iteration and
+checking it. In fact it sits in a loop doing that repeatedly until it finds
+something it wants to return.
+
+The actual 'moving on' part is implemented in `iter_incr()`. This is a very
+simple function. It increments the first counter. If that hits its maximum, it
+sets it to zero and increments the second counter. You can think of all the
+counters together as a number with three digits which increment in order, with
+the least-sigificant digit on the right, counting like this:
+
+ ======== ======= =======
+ bootdev part method
+ ======== ======= =======
+ 0 0 0
+ 0 0 1
+ 0 0 2
+ 0 1 0
+ 0 1 1
+ 0 1 1
+ 1 0 0
+ 1 0 1
+ ======== ======= =======
+
+The maximum value for `method` is `num_methods - 1` so when it exceeds that, it
+goes back to 0 and the next `part` is considered. The maximum value for that is
+`max_part`, which is initially zero for all bootdevs. If we find a partition
+table on that bootdev, `max_part` can be updated during the iteration to a
+higher value - see `bootdev_find_in_blk()` for that, described later. If that
+exceeds its maximum, then the next bootdev is used. In this way, iter_incr()
+works its way through all possibilities, moving forward one each time it is
+called.
+
+There is no expectation that iteration will actually finish. Quite often a
+valid bootflow is found early on. With `bootflow scan -b`, that causes the
+bootflow to be immediately booted. Assuming it is successful, the iteration never
+completes.
+
+Also note that the iterator hold the **current** combination being considered.
+So when `iter_incr()` is called, it increments to the next one and returns it,
+the new **current** combination.
+
+Note also the `err` field in `struct bootflow_iter`. This is normally 0 and has
+thus has no effect on `iter_inc()`. But if it is non-zero, signalling an error,
+it indicates to the iterator what it should do when called. It can force moving
+to the next partition, or bootdev, for example. The special values
+`BF_NO_MORE_PARTS` and `BF_NO_MORE_DEVICES` handle this. When `iter_incr` sees
+`BF_NO_MORE_PARTS` it knows that it should immediately move to the next bootdev.
+When it sees `BF_NO_MORE_DEVICES` it knows that there is nothing more it can do
+so it should immediately return. The caller of `iter_incr()` is responsible for
+updating the `err` field, based on the return value it sees.
+
+The above describes the iteration process at a high level. It is basically a
+very simple increment function with a checker called `bootflow_check()` that
+checks the result of each iteration generated, to determine whether it can
+produce a bootflow.
+
+So what happens inside of `bootflow_check()`? It simply calls the uclass
+method `bootdev_get_bootflow()` to ask the bootdev to return a bootflow. It
+passes the iterator to the bootdev method, so that function knows what we are
+talking about. At first, the bootflow is set up in the state `BOOTFLOWST_BASE`,
+with just the `method` and `dev` intiialised. But the bootdev may fill in more,
+e.g. updating the state, depending on what it finds.
+
+Based on what the bootdev responds with, `bootflow_check()` either
+returns a valid bootflow, or a partial one with an error. A partial bootflow
+is one that has some fields set up, but did not reach the `BOOTFLOWST_READY`
+state. As noted before, if the `BOOTFLOWF_ALL` iterator flag is set, then all
+bootflows are returned, even partial ones. This can help with debugging.
+
+So at this point you can see that total control over whether a bootflow can
+be generated from a particular iteration, or not, rests with the bootdev.
+Each one can adopt its own approach.
+
+Going down a level, what does the bootdev do in its `get_bootflow()` method?
+Let us consider the MMC bootdev. In that case the call to
+`bootdev_get_bootflow()` ends up in `mmc_get_bootflow()`. It locates the parent
+device of the bootdev, i.e. the `UCLASS_MMC` device itself, then finds the block
+device associated with it. It then calls the helper function
+`bootdev_find_in_blk()` to do all the work. This is common with just about any
+bootdev that is based on a media device.
+
+The `bootdev_find_in_blk()` helper is implemented in the bootdev uclass. It
+names the bootflow and copies the partition number in from the iterator. Then it
+calls the bootmeth device to check if it can support this device. This is
+important since some bootmeths only work with network devices, for example. If
+that check fails, it stops.
+
+Assuming the bootmeth is happy, or at least indicates that it is willing to try
+(by returning 0 from its `check()` method), the next step is to try the
+partition. If that works it tries to detect a file system. If that works then it
+calls the bootmeth device once more, this time to read the bootflow.
+
+Note: At present a filesystem is needed for the bootmeth to be called on block
+devices, simply because we don't have any examples where this is not the case.
+This feature can be added as needed.
+
+If we take the example of the `bootmeth_distro` driver, this call ends up at
+`distro_read_bootflow()`. It has the filesystem ready, so tries various
+filenames to try to find the `extlinux.conf` file, reading it if possible. If
+all goes well the bootflow ends up in the `BOOTFLOWST_READY` state.
+
+At this point, we fall back from the bootmeth driver, to
+`bootdev_find_in_blk()`, then back to `mmc_get_bootflow()`, then to
+`bootdev_get_bootflow()`, then to `bootflow_check()` and finally to its caller,
+either `bootflow_scan_bootdev()` or `bootflow_scan_next()`. In either case,
+the bootflow is returned as the result of this iteration, assuming it made it to
+the `BOOTFLOWST_READY` state.
+
+That is the basic operation of scanning for bootflows. The process of booting a
+bootflow is handled by the bootmeth driver for that bootflow. In the case of
+distro boot, this parses and processes the `extlinux.conf` file that was read.
+See `distro_boot()` for how that works. The processing may involve reading
+additional files, which is handled by the `read_file()` method, which is
+`distro_read_file()` in this case. All bootmethds should support reading files,
+since the bootflow is typically only the basic instructions and does not include
+the operating system itself, ramdisk, device tree, etc.
+
+The vast majority of the bootstd code is concerned with iterating through
+partitions on bootdevs and using bootmethds to find bootflows.
+
+How about bootdevs which are not block devices? They are handled by the same
+methods as above, but with a different implementation. For example, the bootmeth
+for PXE boot (over a network) uses `tftp` to read files rather than `fs_read()`.
+But other than that it is very similar.
+
+
+Tests
+-----
+
+Tests are located in `test/boot` and cover the core functionality as well as
+the commands. All tests use sandbox so can be run on a standard Linux computer
+and in U-Boot's CI.
+
+For testing, a DOS-formatted disk image is used with a single FAT partition on
+it. This is created in `setup_bootflow_image()`, with a canned one from the
+source tree used if it cannot be created (e.g. in CI).
+
+
+Bootflow internals
+------------------
+
+The bootstd device holds a linked list of scanned bootflows as well as the
+currently selected bootdev and bootflow (for use by commands). This is in
+`struct bootstd_priv`.
+
+Each bootdev device has its own `struct bootdev_uc_plat` which holds a
+list of scanned bootflows just for that device.
+
+The bootflow itself is documented in bootflow_h_. It includes various bits of
+information about the bootflow and a buffer to hold the file.
+
+
+Future
+------
+
+Apart from the to-do items below, different types of bootflow files may be
+implemented in future, e.g. Chromium OS support which is currently only
+available as a script in chromebook_coral.
+
+
+To do
+-----
+
+Some things that need to be done to completely replace the distro-boot scripts:
+
+- add bootdev drivers for dhcp, sata, scsi, ide, virtio
+- PXE boot for EFI
+- support for loading U-Boot scripts
+
+Other ideas:
+
+- `bootflow prep` to load everything preparing for boot, so that `bootflow boot`
+ can just do the boot.
+- automatically load kernel, FDT, etc. to suitable addresses so the board does
+ not need to specify things like `pxefile_addr_r`
+
+
+.. _disto_boodcmd: https://github.com/u-boot/u-boot/blob/master/include/config_distro_bootcmd.h
+.. _BootLoaderSpec: http://www.freedesktop.org/wiki/Specifications/BootLoaderSpec/
+.. _distro_boot: https://github.com/u-boot/u-boot/blob/master/boot/distro.c
+.. _bootflow_h: https://github.com/u-boot/u-boot/blob/master/include/bootflow.h
diff --git a/doc/develop/distro.rst b/doc/develop/distro.rst
index 0113a3d4ec4..3ee3dac6a27 100644
--- a/doc/develop/distro.rst
+++ b/doc/develop/distro.rst
@@ -157,6 +157,9 @@ a line with "CONFIG_DISTRO_DEFAULTS=y". If you want to enable this
from Kconfig itself, for e.g. all boards using a specific SoC then
add a "imply DISTRO_DEFAULTS" to your SoC CONFIG option.
+
+TO BE UPDATED:
+
In your board configuration file, include the following::
#ifndef CONFIG_SPL_BUILD
diff --git a/doc/develop/driver-model/design.rst b/doc/develop/driver-model/design.rst
index b0e6337030a..5f33f9fbb32 100644
--- a/doc/develop/driver-model/design.rst
+++ b/doc/develop/driver-model/design.rst
@@ -1042,6 +1042,27 @@ data structure might be worthwhile in some rare cases, once we understand
what the bottlenecks are.
+Tag Support
+-----------
+
+It is sometimes useful for a subsystem to associate its own private
+data (or object) to a DM device, i.e. struct udevice, to support
+additional features.
+
+Tag support in driver model will give us the ability to do so dynamically
+instead of modifying "udevice" data structure. In the initial release, we
+will support two type of attributes:
+
+- a pointer with dm_tag_set_ptr(), and
+- an unsigned long with dm_tag_set_val()
+
+For example, UEFI subsystem utilizes the feature to maintain efi_disk
+objects depending on linked udevice's lifecycle.
+
+While the current implementation is quite simple, it will get evolved
+as the feature is more extensively used in U-Boot subsystems.
+
+
Changes since v1
----------------
diff --git a/doc/develop/global_data.rst b/doc/develop/global_data.rst
index 230ebcd8604..2ac893de491 100644
--- a/doc/develop/global_data.rst
+++ b/doc/develop/global_data.rst
@@ -23,8 +23,6 @@ On most architectures the global data pointer is stored in a register.
+------------+----------+
| MicroBlaze | r31 |
+------------+----------+
-| NDS32 | r10 |
-+------------+----------+
| Nios II | gp |
+------------+----------+
| PowerPC | r2 |
diff --git a/doc/develop/index.rst b/doc/develop/index.rst
index 2e6d6c302a5..d32ec490221 100644
--- a/doc/develop/index.rst
+++ b/doc/develop/index.rst
@@ -10,6 +10,7 @@ Implementation
:maxdepth: 1
bloblist
+ bootstd
ci_testing
commands
config_binding
diff --git a/doc/device-tree-bindings/bootdev.txt b/doc/device-tree-bindings/bootdev.txt
new file mode 100644
index 00000000000..4bb2345a0b9
--- /dev/null
+++ b/doc/device-tree-bindings/bootdev.txt
@@ -0,0 +1,26 @@
+U-Boot boot device (bootdev)
+============================
+
+A bootdev provides a way to obtain a bootflow file from a device. It is a
+child of the media device (UCLASS_MMC, UCLASS_SPI_FLASH, etc.)
+
+The bootdev driver is provided by the media devices. The bindings for each
+are described in this file (to come).
+
+Required properties:
+
+compatible:
+ "u-boot,bootdev-eth" - Ethernet bootdev
+ "u-boot,bootdev-mmc" - MMC bootdev
+ "u-boot,bootdev-usb" - USB bootdev
+
+
+Example:
+
+ mmc1 {
+ compatible = "sandbox,mmc";
+
+ mmc-bootdev {
+ compatible = "u-boot,bootdev-eth";
+ };
+ };
diff --git a/doc/device-tree-bindings/bootmeth.txt b/doc/device-tree-bindings/bootmeth.txt
new file mode 100644
index 00000000000..de6396a7b35
--- /dev/null
+++ b/doc/device-tree-bindings/bootmeth.txt
@@ -0,0 +1,31 @@
+U-Boot standard boot methods (bootmeth)
+======================================
+
+This provides methods (called bootmeths) for locating bootflows on a boot
+device (bootdev). These are normally created as children of the bootstd device.
+
+Required properties:
+
+compatible:
+ "u-boot,distro-syslinux" - distro boot from a block device
+ "u-boot,distro-pxe" - distro boot from a network device
+ "u-boot,distro-efi" - EFI boot from an .efi file
+ "u-boot,efi-bootmgr" - EFI boot using boot manager (bootmgr)
+
+
+Example:
+
+ bootstd {
+ compatible = "u-boot,boot-std";
+
+ filename-prefixes = "/", "/boot/";
+ bootdev-order = "mmc2", "mmc1";
+
+ syslinux {
+ compatible = "u-boot,distro-syslinux";
+ };
+
+ efi {
+ compatible = "u-boot,distro-efi";
+ };
+ };
diff --git a/doc/device-tree-bindings/bootstd.txt b/doc/device-tree-bindings/bootstd.txt
new file mode 100644
index 00000000000..8706c5f4993
--- /dev/null
+++ b/doc/device-tree-bindings/bootstd.txt
@@ -0,0 +1,36 @@
+U-Boot standard boot device (bootstd)
+=====================================
+
+This is the controlling device for U-Boot standard boot, providing a way to
+boot operating systems in a way that can be controlled by distros.
+
+Required properties:
+
+compatible: "u-boot,boot-std"
+
+Optional properties:
+
+filename-prefixes:
+ List of strings, each a directory to search for bootflow files
+
+bootdev-order:
+ List of bootdevs to check for bootflows, each a bootdev label (the media
+ uclass followed by the numeric sequence number of the media device)
+
+
+Example:
+
+ bootstd {
+ compatible = "u-boot,boot-std";
+
+ filename-prefixes = "/", "/boot/";
+ bootdev-order = "mmc2", "mmc1";
+
+ syslinux {
+ compatible = "u-boot,distro-syslinux";
+ };
+
+ efi {
+ compatible = "u-boot,distro-efi";
+ };
+ };
diff --git a/doc/git-mailrc b/doc/git-mailrc
index 410be387bed..63c2f6e7daa 100644
--- a/doc/git-mailrc
+++ b/doc/git-mailrc
@@ -52,7 +52,7 @@ alias wd Wolfgang Denk <wd@denx.de>
alias priyankajain Priyanka Jain <priyanka.jain@nxp.com>
# Architecture aliases
-alias arch arc, arm, m68k, microblaze, mips, nds32, nios2, powerpc, sandbox, superh, x86
+alias arch arc, arm, m68k, microblaze, mips, nios2, powerpc, sandbox, superh, x86
alias arches arch
alias arc uboot, abrodkin
@@ -90,8 +90,6 @@ alias mb microblaze
alias mips uboot, danielschwierzeck
-alias nds32 uboot, macpaul
-
alias nios uboot, Thomas Chou <thomas@wytron.com.tw>, smcnutt
alias nios2 nios
diff --git a/doc/kwboot.1 b/doc/kwboot.1
index f555ff26a25..d663bf1f775 100644
--- a/doc/kwboot.1
+++ b/doc/kwboot.1
@@ -74,7 +74,7 @@ BootROM's standard input and BootROM's terminal echo are active and working
fine. To workaround this BootROM bug with standard output, it is possible
to manually overwrite BootROM variables stored in SRAM which BootROM use
for checking if standard output is enabled or not. To enable BootROM
-standard output on UART, type this command folled by ENTER key:
+standard output on UART, type this command followed by ENTER key:
.RS 1.2i
.TP
diff --git a/doc/usage/cmd/bootdev.rst b/doc/usage/cmd/bootdev.rst
new file mode 100644
index 00000000000..5e02e32c514
--- /dev/null
+++ b/doc/usage/cmd/bootdev.rst
@@ -0,0 +1,135 @@
+.. SPDX-License-Identifier: GPL-2.0+:
+
+bootdev command
+===============
+
+Synopis
+-------
+
+::
+
+ bootdev list [-p] - list all available bootdevs (-p to probe)\n"
+ bootdev select <bm> - select a bootdev by name\n"
+ bootdev info [-p] - show information about a bootdev";
+
+Description
+-----------
+
+The `bootdev` command is used to manage bootdevs. It can list available
+bootdevs, select one and obtain information about it.
+
+See :doc:`../../develop/bootstd` for more information about bootdevs in general.
+
+
+bootdev list
+~~~~~~~~~~~~
+
+This lists available bootdevs
+
+Scanning with `-p` causes the bootdevs to be probed. This happens automatically
+when they are used.
+
+The list looks something like this:
+
+=== ====== ====== ======== =========================
+Seq Probed Status Uclass Name
+=== ====== ====== ======== =========================
+ 0 [ + ] OK mmc mmc@7e202000.bootdev
+ 1 [ ] OK mmc sdhci@7e300000.bootdev
+ 2 [ ] OK ethernet smsc95xx_eth.bootdev
+=== ====== ====== ======== =========================
+
+
+The fields are as follows:
+
+Seq:
+ Sequence number in the scan, used to reference the bootflow later
+
+Probed:
+ Shows a plus (+) if the device is probed, empty if not.
+
+Status:
+ Shows the status of the device. Typically this is `OK` meaning that there is
+ no error. If you use -p and an error occurs when probing, then this shows
+ the error number. You can look up Linux error codes to find the meaning of
+ the number.
+
+Uclass:
+ Name of the media device's Uclass. This indicates the type of the parent
+ device (e.g. MMC, Ethernet).
+
+Name:
+ Name of the bootdev. This is generated from the media device appended
+ with `.bootdev`
+
+
+bootdev select
+~~~~~~~~~~~~~~~~~
+
+Use this to select a particular bootdev. You can select it by the sequence
+number or name, as shown in `bootdev list`.
+
+Once a bootdev is selected, you can use `bootdev info` to look at it or
+`bootflow scan` to scan it.
+
+If no bootdev name or number is provided, then any existing bootdev is
+unselected.
+
+
+bootdev info
+~~~~~~~~~~~~~~~
+
+This shows information on the current bootdev, with the format looking like
+this:
+
+========= =======================
+Name mmc@7e202000.bootdev
+Sequence 0
+Status Probed
+Uclass mmc
+Bootflows 1 (1 valid)
+========= =======================
+
+Most of the information is the same as `bootdev list` above. The new fields
+are:
+
+Device
+ Name of the bootdev
+
+Status
+ Shows `Probed` if the device is probed, `OK` if not. If `-p` is used and the
+ device fails to probe, an error code is shown.
+
+Bootflows
+ Indicates the number of bootflows attached to the bootdev. This is 0
+ unless you have used 'bootflow scan' on the bootflow, or on all bootflows.
+
+
+Example
+-------
+
+This example shows listing available bootdev and getting information about
+one of them::
+
+ U-Boot> bootdev list
+ Seq Probed Status Uclass Name
+ --- ------ ------ -------- ------------------
+ 0 [ + ] OK mmc mmc@7e202000.bootdev
+ 1 [ ] OK mmc sdhci@7e300000.bootdev
+ 2 [ ] OK ethernet smsc95xx_eth.bootdev
+ --- ------ ------ -------- ------------------
+ (3 devices)
+ U-Boot> bootdev sel 0
+ U-Boot> bootflow scan
+ U-Boot> bootdev info
+ Name: mmc@7e202000.bootdev
+ Sequence: 0
+ Status: Probed
+ Uclass: mmc
+ Bootflows: 1 (1 valid)
+
+
+Return value
+------------
+
+The return value $? is always 0 (true).
diff --git a/doc/usage/cmd/bootefi.rst b/doc/usage/cmd/bootefi.rst
index 31279fc0cbf..4cc8c0718c5 100644
--- a/doc/usage/cmd/bootefi.rst
+++ b/doc/usage/cmd/bootefi.rst
@@ -9,7 +9,7 @@ Synopsis
::
- bootefi [image_addr] [fdt_addr]
+ bootefi [image_addr] [fdt_addr [image_size]]
bootefi bootmgr [fdt_addr]
bootefi hello [fdt_addr]
bootefi selftest [fdt_addr]
@@ -41,13 +41,28 @@ command sequence to run a UEFI application might look like
load mmc 0:1 $kernel_addr_r /EFI/grub/grubaa64.efi
bootefi $kernel_addr_r $fdt_addr_r
-The last file loaded defines the image file path in the loaded image protocol.
-Hence the executable should always be loaded last.
+The last UEFI binary loaded defines the image file path in the loaded image
+protocol.
The value of the environment variable *bootargs* is converted from UTF-8 to
UTF-16 and passed as load options in the loaded image protocol to the UEFI
binary.
+image_addr
+ Address of the UEFI binary.
+
+fdt_addr
+ Address of the device-tree or '-'. If no address is specifiy, the
+ environment variable $fdt_addr is used as first fallback, the address of
+ U-Boot's internal device-tree $fdtcontroladdr as second fallback.
+ When using ACPI no device-tree shall be specified.
+
+image_size
+ Size of the UEFI binary file. This argument is only needed if *image_addr*
+ does not match the address of the last loaded UEFI binary. In this case
+ a memory device path will be used as image file path in the loaded image
+ protocol.
+
Note
UEFI binaries that are contained in FIT images are launched via the
*bootm* command.
diff --git a/doc/usage/cmd/bootflow.rst b/doc/usage/cmd/bootflow.rst
new file mode 100644
index 00000000000..aa12dc2e3ab
--- /dev/null
+++ b/doc/usage/cmd/bootflow.rst
@@ -0,0 +1,427 @@
+.. SPDX-License-Identifier: GPL-2.0+:
+
+bootflow command
+================
+
+Synopis
+-------
+
+::
+
+ bootflow scan [-abel] [bootdev]
+ bootflow list [-e]
+ bootflow select [<num|name>]
+ bootflow info [-d]
+ bootflow boot
+
+
+Description
+-----------
+
+The `bootflow` command is used to manage bootflows. It can scan bootdevs to
+locate bootflows, list them and boot them.
+
+See :doc:`../../develop/bootstd` for more information.
+
+
+bootflow scan
+~~~~~~~~~~~~~
+
+Scans for available bootflows, optionally booting the first valid one it finds.
+This operates in two modes:
+
+- If no bootdev is selected (see `bootdev select`) it scans bootflows one
+ by one, extracting all the bootdevs from each
+- If a bootdev is selected, it just scans that one bootflow
+
+Flags are:
+
+-a
+ Collect all bootflows, even those that cannot be loaded. Normally if a file
+ is not where it is expected, then the bootflow fails and so is dropped
+ during the scan. With this option you can see why each bootflow would be
+ dropped.
+
+-b
+ Boot each valid bootflow as it is scanned. Typically only the first bootflow
+ matters, since by then the system boots in the OS and U-Boot is no-longer
+ running. `bootflow scan -b` is a quick way to boot the first available OS.
+ A valid bootflow is one that made it all the way to the `loaded` state.
+
+-e
+ Used with -l to also show errors for each bootflow. The shows detailed error
+ information for each bootflow that failed to make it to the `loaded` state.
+
+-l
+ List bootflows while scanning. This is helpful when you want to see what
+ is happening during scanning. Use it with the `-b` flag to see which
+ bootdev and bootflows are being tried.
+
+The optional argument specifies a particular bootdev to scan. This can either be
+the name of a bootdev or its sequence number (both shown with `bootdev list`).
+Alternatively a convenience label can be used, like `mmc0`, which is the type of
+device and an optional sequence number. Specifically, the label is the uclass of
+the bootdev's parent followed by the sequence number of that parent. Sequence
+numbers are typically set by aliases, so if you have 'mmc0' in your devicetree
+alias section, then `mmc0` refers to the bootdev attached to that device.
+
+
+bootflow list
+~~~~~~~~~~~~~
+
+Lists the previously scanned bootflows. You must use `bootflow scan` before this
+to see anything.
+
+If you scanned with -a and have bootflows with errors, -e can be used to show
+those errors.
+
+The list looks something like this:
+
+=== ====== ====== ======== ==== =============================== ================
+Seq Method State Uclass Part Name Filename
+=== ====== ====== ======== ==== =============================== ================
+ 0 distro ready mmc 2 mmc\@7e202000.bootdev.part_2 /boot/extlinux/extlinux.conf
+ 1 pxe ready ethernet 0 smsc95xx_eth.bootdev.0 rpi.pxe/extlinux/extlinux.conf
+=== ====== ====== ======== ==== =============================== ================
+
+The fields are as follows:
+
+Seq:
+ Sequence number in the scan, used to reference the bootflow later
+
+Method:
+ The boot method (bootmeth) used to find the bootflow. Several methods are
+ included in U-Boot.
+
+State:
+ Current state of the bootflow, indicating how far the bootdev got in
+ obtaining a valid one. See :ref:`BootflowStates` for a list of states.
+
+Uclass:
+ Name of the media device's Uclass. This indicates the type of the parent
+ device (e.g. MMC, Ethernet).
+
+Part:
+ Partition number being accesseed, numbered from 1. Normally a device will
+ have a partition table with a small number of partitions. For devices
+ without partition tables (e.g. network) this field is 0.
+
+Name:
+ Name of the bootflow. This is generated from the bootdev appended with
+ the partition information
+
+Filename:
+ Name of the bootflow file. This indicates where the file is on the
+ filesystem or network device.
+
+
+bootflow select
+~~~~~~~~~~~~~~~
+
+Use this to select a particular bootflow. You can select it by the sequence
+number or name, as shown in `bootflow list`.
+
+Once a bootflow is selected, you can use `bootflow info` and `bootflow boot`.
+
+If no bootflow name or number is provided, then any existing bootflow is
+unselected.
+
+
+bootflow info
+~~~~~~~~~~~~~
+
+This shows information on the current bootflow, with the format looking like
+this:
+
+========= ===============================
+Name mmc\@7e202000.bootdev.part_2
+Device mmc\@7e202000.bootdev
+Block dev mmc\@7e202000.blk
+Type distro
+Method: syslinux
+State ready
+Partition 2
+Subdir (none)
+Filename /extlinux/extlinux.conf
+Buffer 3db7ad48
+Size 232 (562 bytes)
+Error 0
+========= ===============================
+
+Most of the information is the same as `bootflow list` above. The new fields
+are:
+
+Device
+ Name of the bootdev
+
+Block dev
+ Name of the block device, if any. Network devices don't have a block device.
+
+Subdir
+ Subdirectory used for retrieving files. For network bootdevs this is the
+ directory of the 'bootfile' parameter passed from DHCP. All file retrievals
+ when booting are relative to this.
+
+Buffer
+ Buffer containing the bootflow file. You can use the :doc:`md` to look at
+ it, or dump it with `bootflow info -d`.
+
+Size
+ Size of the bootflow file
+
+Error
+ Error number returned from scanning for the bootflow. This is 0 if the
+ bootflow is in the 'loaded' state, or a negative error value on error. You
+ can look up Linux error codes to find the meaning of the number.
+
+Use the `-d` flag to dump out the contents of the bootfile file.
+
+
+bootflow boot
+~~~~~~~~~~~~~
+
+This boots the current bootflow.
+
+
+Example
+-------
+
+Here is an example of scanning for bootflows, then listing them::
+
+ U-Boot> bootflow scan -l
+ Scanning for bootflows in all bootdevs
+ Seq Type State Uclass Part Name Filename
+ --- ----------- ------ -------- ---- ------------------------ ----------------
+ Scanning bootdev 'mmc@7e202000.bootdev':
+ 0 distro ready mmc 2 mmc@7e202000.bootdev.p /extlinux/extlinux.conf
+ Scanning bootdev 'sdhci@7e300000.bootdev':
+ Card did not respond to voltage select! : -110
+ Scanning bootdev 'smsc95xx_eth.bootdev':
+ Waiting for Ethernet connection... done.
+ BOOTP broadcast 1
+ DHCP client bound to address 192.168.4.30 (4 ms)
+ Using smsc95xx_eth device
+ TFTP from server 192.168.4.1; our IP address is 192.168.4.30
+ Filename 'rpi.pxe/'.
+ Load address: 0x200000
+ Loading: *
+ TFTP error: 'Is a directory' (0)
+ Starting again
+
+ missing environment variable: pxeuuid
+ Retrieving file: rpi.pxe/pxelinux.cfg/01-b8-27-eb-a6-61-e1
+ Waiting for Ethernet connection... done.
+ Using smsc95xx_eth device
+ TFTP from server 192.168.4.1; our IP address is 192.168.4.30
+ Filename 'rpi.pxe/pxelinux.cfg/01-b8-27-eb-a6-61-e1'.
+ Load address: 0x2500000
+ Loading: ################################################## 566 Bytes
+ 45.9 KiB/s
+ done
+ Bytes transferred = 566 (236 hex)
+ 1 distro ready ethernet 0 smsc95xx_eth.bootdev.0 rpi.pxe/extlinux/extlinux.conf
+ No more bootdevs
+ --- ----------- ------ -------- ---- ------------------------ ----------------
+ (2 bootflows, 2 valid)
+ U-Boot> bootflow l
+ Showing all bootflows
+ Seq Type State Uclass Part Name Filename
+ --- ----------- ------ -------- ---- ------------------------ ----------------
+ 0 distro ready mmc 2 mmc@7e202000.bootdev.p /extlinux/extlinux.conf
+ 1 pxe ready ethernet 0 smsc95xx_eth.bootdev.0 rpi.pxe/extlinux/extlinux.conf
+ --- ----------- ------ -------- ---- ------------------------ ----------------
+ (2 bootflows, 2 valid)
+
+
+The second one is then selected by name (we could instead use `bootflow sel 0`),
+displayed and booted::
+
+ U-Boot> bootflow info
+ No bootflow selected
+ U-Boot> bootflow sel mmc@7e202000.bootdev.part_2
+ U-Boot> bootflow info
+ Name: mmc@7e202000.bootdev.part_2
+ Device: mmc@7e202000.bootdev
+ Block dev: mmc@7e202000.blk
+ Sequence: 1
+ Method: distro
+ State: ready
+ Partition: 2
+ Subdir: (none)
+ Filename: extlinux/extlinux.conf
+ Buffer: 3db7ae88
+ Size: 232 (562 bytes)
+ Error: 0
+ U-Boot> bootflow boot
+ ** Booting bootflow 'smsc95xx_eth.bootdev.0'
+ Ignoring unknown command: ui
+ Ignoring malformed menu command: autoboot
+ Ignoring malformed menu command: hidden
+ Ignoring unknown command: totaltimeout
+ 1: Fedora-Workstation-armhfp-31-1.9 (5.3.7-301.fc31.armv7hl)
+ Retrieving file: rpi.pxe/initramfs-5.3.7-301.fc31.armv7hl.img
+ get 2700000 rpi.pxe/initramfs-5.3.7-301.fc31.armv7hl.img
+ Waiting for Ethernet connection... done.
+ Using smsc95xx_eth device
+ TFTP from server 192.168.4.1; our IP address is 192.168.4.30
+ Filename 'rpi.pxe/initramfs-5.3.7-301.fc31.armv7hl.img'.
+ Load address: 0x2700000
+ Loading: ###################################T ############### 57.7 MiB
+ 1.9 MiB/s
+ done
+ Bytes transferred = 60498594 (39b22a2 hex)
+ Retrieving file: rpi.pxe//vmlinuz-5.3.7-301.fc31.armv7hl
+ get 80000 rpi.pxe//vmlinuz-5.3.7-301.fc31.armv7hl
+ Waiting for Ethernet connection... done.
+ Using smsc95xx_eth device
+ TFTP from server 192.168.4.1; our IP address is 192.168.4.30
+ Filename 'rpi.pxe//vmlinuz-5.3.7-301.fc31.armv7hl'.
+ Load address: 0x80000
+ Loading: ################################################## 7.2 MiB
+ 2.3 MiB/s
+ done
+ Bytes transferred = 7508480 (729200 hex)
+ append: ro root=UUID=9732b35b-4cd5-458b-9b91-80f7047e0b8a rhgb quiet LANG=en_US.UTF-8 cma=192MB cma=256MB
+ Retrieving file: rpi.pxe//dtb-5.3.7-301.fc31.armv7hl/bcm2837-rpi-3-b.dtb
+ get 2600000 rpi.pxe//dtb-5.3.7-301.fc31.armv7hl/bcm2837-rpi-3-b.dtb
+ Waiting for Ethernet connection... done.
+ Using smsc95xx_eth device
+ TFTP from server 192.168.4.1; our IP address is 192.168.4.30
+ Filename 'rpi.pxe//dtb-5.3.7-301.fc31.armv7hl/bcm2837-rpi-3-b.dtb'.
+ Load address: 0x2600000
+ Loading: ################################################## 13.8 KiB
+ 764.6 KiB/s
+ done
+ Bytes transferred = 14102 (3716 hex)
+ Kernel image @ 0x080000 [ 0x000000 - 0x729200 ]
+ ## Flattened Device Tree blob at 02600000
+ Booting using the fdt blob at 0x2600000
+ Using Device Tree in place at 02600000, end 02606715
+
+ Starting kernel ...
+
+ [ OK ] Started Show Plymouth Boot Screen.
+ [ OK ] Started Forward Password R…s to Plymouth Directory Watch.
+ [ OK ] Reached target Local Encrypted Volumes.
+ [ OK ] Reached target Paths.
+ ....
+
+
+Here we scan for bootflows and boot the first one found::
+
+ U-Boot> bootflow scan -bl
+ Scanning for bootflows in all bootdevs
+ Seq Method State Uclass Part Name Filename
+ --- ----------- ------ -------- ---- ---------------------- ----------------
+ Scanning bootdev 'mmc@7e202000.bootdev':
+ 0 distro ready mmc 2 mmc@7e202000.bootdev.p /extlinux/extlinux.conf
+ ** Booting bootflow 'mmc@7e202000.bootdev.part_2'
+ Ignoring unknown command: ui
+ Ignoring malformed menu command: autoboot
+ Ignoring malformed menu command: hidden
+ Ignoring unknown command: totaltimeout
+ 1: Fedora-KDE-armhfp-31-1.9 (5.3.7-301.fc31.armv7hl)
+ Retrieving file: /initramfs-5.3.7-301.fc31.armv7hl.img
+ getfile 2700000 /initramfs-5.3.7-301.fc31.armv7hl.img
+ Retrieving file: /vmlinuz-5.3.7-301.fc31.armv7hl
+ getfile 80000 /vmlinuz-5.3.7-301.fc31.armv7hl
+ append: ro root=UUID=b8781f09-e2dd-4cb8-979b-7df5eeaaabea rhgb LANG=en_US.UTF-8 cma=192MB console=tty0 console=ttyS1,115200
+ Retrieving file: /dtb-5.3.7-301.fc31.armv7hl/bcm2837-rpi-3-b.dtb
+ getfile 2600000 /dtb-5.3.7-301.fc31.armv7hl/bcm2837-rpi-3-b.dtb
+ Kernel image @ 0x080000 [ 0x000000 - 0x729200 ]
+ ## Flattened Device Tree blob at 02600000
+ Booting using the fdt blob at 0x2600000
+ Using Device Tree in place at 02600000, end 02606715
+
+ Starting kernel ...
+
+ [ 0.000000] Booting Linux on physical CPU 0x0
+
+
+Here is am example using the -e flag to see all errors::
+
+ U-Boot> bootflow scan -a
+ Card did not respond to voltage select! : -110
+ Waiting for Ethernet connection... done.
+ BOOTP broadcast 1
+ DHCP client bound to address 192.168.4.30 (4 ms)
+ Using smsc95xx_eth device
+ TFTP from server 192.168.4.1; our IP address is 192.168.4.30
+ Filename 'rpi.pxe/'.
+ Load address: 0x200000
+ Loading: *
+ TFTP error: 'Is a directory' (0)
+ Starting again
+
+ missing environment variable: pxeuuid
+ Retrieving file: rpi.pxe/pxelinux.cfg/01-b8-27-eb-a6-61-e1
+ Waiting for Ethernet connection... done.
+ Using smsc95xx_eth device
+ TFTP from server 192.168.4.1; our IP address is 192.168.4.30
+ Filename 'rpi.pxe/pxelinux.cfg/01-b8-27-eb-a6-61-e1'.
+ Load address: 0x2500000
+ Loading: ################################################## 566 Bytes
+ 49.8 KiB/s
+ done
+ Bytes transferred = 566 (236 hex)
+ U-Boot> bootflow l -e
+ Showing all bootflows
+ Seq Type State Uclass Part Name Filename
+ --- ----------- ------ -------- ---- --------------------- ----------------
+ 0 distro fs mmc 1 mmc@7e202000.bootdev.p /extlinux/extlinux.conf
+ ** File not found, err=-2
+ 1 distro ready mmc 2 mmc@7e202000.bootdev.p /extlinux/extlinux.conf
+ 2 distro fs mmc 3 mmc@7e202000.bootdev.p /extlinux/extlinux.conf
+ ** File not found, err=-1
+ 3 distro media mmc 0 mmc@7e202000.bootdev.p <NULL>
+ ** No partition found, err=-2
+ 4 distro media mmc 0 mmc@7e202000.bootdev.p <NULL>
+ ** No partition found, err=-2
+ 5 distro media mmc 0 mmc@7e202000.bootdev.p <NULL>
+ ** No partition found, err=-2
+ 6 distro media mmc 0 mmc@7e202000.bootdev.p <NULL>
+ ** No partition found, err=-2
+ 7 distro media mmc 0 mmc@7e202000.bootdev.p <NULL>
+ ** No partition found, err=-2
+ 8 distro media mmc 0 mmc@7e202000.bootdev.p <NULL>
+ ** No partition found, err=-2
+ 9 distro media mmc 0 mmc@7e202000.bootdev.p <NULL>
+ ** No partition found, err=-2
+ a distro media mmc 0 mmc@7e202000.bootdev.p <NULL>
+ ** No partition found, err=-2
+ b distro media mmc 0 mmc@7e202000.bootdev.p <NULL>
+ ** No partition found, err=-2
+ c distro media mmc 0 mmc@7e202000.bootdev.p <NULL>
+ ** No partition found, err=-2
+ d distro media mmc 0 mmc@7e202000.bootdev.p <NULL>
+ ** No partition found, err=-2
+ e distro media mmc 0 mmc@7e202000.bootdev.p <NULL>
+ ** No partition found, err=-2
+ f distro media mmc 0 mmc@7e202000.bootdev.p <NULL>
+ ** No partition found, err=-2
+ 10 distro media mmc 0 mmc@7e202000.bootdev.p <NULL>
+ ** No partition found, err=-2
+ 11 distro media mmc 0 mmc@7e202000.bootdev.p <NULL>
+ ** No partition found, err=-2
+ 12 distro media mmc 0 mmc@7e202000.bootdev.p <NULL>
+ ** No partition found, err=-2
+ 13 distro media mmc 0 mmc@7e202000.bootdev.p <NULL>
+ ** No partition found, err=-2
+ 14 distro ready ethernet 0 smsc95xx_eth.bootdev.0 rpi.pxe/extlinux/extlinux.conf
+ --- ----------- ------ -------- ---- --------------------- ----------------
+ (21 bootflows, 2 valid)
+ U-Boot>
+
+
+Return value
+------------
+
+On success `bootflow boot` normally boots into the Operating System and does not
+return to U-Boot. If something about the U-Boot processing fails, then the
+return value $? is 1. If the boot succeeds but for some reason the Operating
+System returns, then $? is 0, indicating success.
+
+For other subcommands, the return value $? is always 0 (true).
+
+
+.. BootflowStates_:
diff --git a/doc/usage/cmd/bootmeth.rst b/doc/usage/cmd/bootmeth.rst
new file mode 100644
index 00000000000..9fc7ebf0abf
--- /dev/null
+++ b/doc/usage/cmd/bootmeth.rst
@@ -0,0 +1,108 @@
+.. SPDX-License-Identifier: GPL-2.0+:
+
+bootmeth command
+================
+
+Synopis
+-------
+
+::
+
+ bootmeth list [-a] - list selected bootmeths (-a for all)
+ bootmeth order "[<bm> ...]" - select the order of bootmeths\n"
+
+
+Description
+-----------
+
+The `bootmeth` command is used to manage bootmeths. It can list them and change
+the order in which they are used.
+
+See :doc:`../../develop/bootstd` for more information.
+
+
+.. _bootmeth_order:
+
+bootmeth order
+~~~~~~~~~~~~~~
+
+Selects which bootmeths to use and the order in which they are invoked. When
+scanning bootdevs, each bootmeth is tried in turn to see if it can find a valid
+bootflow. You can use this command to adjust the order or even to omit some
+boomeths.
+
+The argument is a quoted list of bootmeths to use, by name.
+
+
+bootmeth list
+~~~~~~~~~~~~~
+
+This lists the selected bootmeths, or all of them, if the `-a` flag is used.
+The format looks like this:
+
+===== === ================== =================================
+Order Seq Name Description
+===== === ================== =================================
+ 0 0 distro Syslinux boot from a block device
+ 1 1 efi EFI boot from an .efi file
+ 2 2 pxe PXE boot from a network device
+ 3 3 sandbox Sandbox boot for testing
+ 4 4 efi_mgr EFI bootmgr flow
+===== === ================== =================================
+
+The fields are as follows:
+
+Order:
+ The order in which these bootmeths are invoked for each bootdev. If this
+ shows as a hyphen, then the bootmeth is not in the current ordering.
+
+Seq:
+ The sequence number of the bootmeth, i.e. the normal ordering if none is set
+
+Name:
+ Name of the bootmeth
+
+Description:
+ A friendly description for the bootmeth
+
+
+Example
+-------
+
+This shows listing bootmeths. All are present and in the normal order::
+
+ => bootmeth list
+ Order Seq Name Description
+ ----- --- ------------------ ------------------
+ 0 0 distro Syslinux boot from a block device
+ 1 1 efi EFI boot from an .efi file
+ 2 2 pxe PXE boot from a network device
+ 3 3 sandbox Sandbox boot for testing
+ 4 4 efi_mgr EFI bootmgr flow
+ ----- --- ------------------ ------------------
+ (5 bootmeths)
+
+Now the order is changed, to include only two of them::
+
+ => bootmeth order "sandbox distro"
+ => bootmeth list
+ Order Seq Name Description
+ ----- --- ------------------ ------------------
+ 0 3 sandbox Sandbox boot for testing
+ 1 0 distro Syslinux boot from a block device
+ ----- --- ------------------ ------------------
+ (2 bootmeths)
+
+The -a flag shows all bootmeths so you can clearly see which ones are used and
+which are not::
+
+ => bootmeth list -a
+ Order Seq Name Description
+ ----- --- ------------------ ------------------
+ 1 0 distro Syslinux boot from a block device
+ - 1 efi EFI boot from an .efi file
+ - 2 pxe PXE boot from a network device
+ 0 3 sandbox Sandbox boot for testing
+ - 4 efi_mgr EFI bootmgr flow
+ ----- --- ------------------ ------------------
+ (5 bootmeths)
diff --git a/doc/usage/index.rst b/doc/usage/index.rst
index f343e4e05f7..c03f4aef9eb 100644
--- a/doc/usage/index.rst
+++ b/doc/usage/index.rst
@@ -23,9 +23,12 @@ Shell commands
cmd/addrmap
cmd/askenv
cmd/base
+ cmd/bootdev
cmd/bootefi
+ cmd/bootflow
cmd/booti
cmd/bootmenu
+ cmd/bootmeth
cmd/button
cmd/cbsysinfo
cmd/conitrace
diff --git a/drivers/adc/meson-saradc.c b/drivers/adc/meson-saradc.c
index 1a45a3a2655..37023512f0d 100644
--- a/drivers/adc/meson-saradc.c
+++ b/drivers/adc/meson-saradc.c
@@ -737,6 +737,8 @@ static const struct udevice_id meson_saradc_ids[] = {
.data = (ulong)&gxl_saradc_data },
{ .compatible = "amlogic,meson-g12a-saradc",
.data = (ulong)&gxl_saradc_data },
+ { .compatible = "amlogic,meson-axg-saradc",
+ .data = (ulong)&gxl_saradc_data },
{ }
};
diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
index f1e4a856467..21c5209bb63 100644
--- a/drivers/block/blk-uclass.c
+++ b/drivers/block/blk-uclass.c
@@ -509,6 +509,13 @@ int blk_get_from_parent(struct udevice *parent, struct udevice **devp)
return 0;
}
+const char *blk_get_devtype(struct udevice *dev)
+{
+ struct udevice *parent = dev_get_parent(dev);
+
+ return uclass_get_name(device_get_uclass_id(parent));
+};
+
int blk_find_max_devnum(enum if_type if_type)
{
struct udevice *dev;
@@ -741,6 +748,10 @@ static int blk_post_probe(struct udevice *dev)
struct blk_desc *desc = dev_get_uclass_plat(dev);
part_init(desc);
+
+ if (desc->part_type != PART_TYPE_UNKNOWN &&
+ part_create_block_devices(dev))
+ debug("*** creating partitions failed\n");
}
return 0;
diff --git a/drivers/clk/meson/Makefile b/drivers/clk/meson/Makefile
index b9c6bd66cfa..a486b13e9ce 100644
--- a/drivers/clk/meson/Makefile
+++ b/drivers/clk/meson/Makefile
@@ -5,5 +5,6 @@
obj-$(CONFIG_CLK_MESON_GX) += gxbb.o
obj-$(CONFIG_CLK_MESON_AXG) += axg.o
+obj-$(CONFIG_CLK_MESON_AXG) += axg-ao.o
obj-$(CONFIG_CLK_MESON_G12A) += g12a.o
obj-$(CONFIG_CLK_MESON_G12A) += g12a-ao.o
diff --git a/drivers/clk/meson/axg-ao.c b/drivers/clk/meson/axg-ao.c
new file mode 100644
index 00000000000..311ffc1cca9
--- /dev/null
+++ b/drivers/clk/meson/axg-ao.c
@@ -0,0 +1,86 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+#include <common.h>
+#include <log.h>
+#include <asm/io.h>
+#include <clk-uclass.h>
+#include <dm.h>
+#include <regmap.h>
+#include <syscon.h>
+#include <dt-bindings/clock/axg-aoclkc.h>
+
+#include "clk_meson.h"
+
+struct meson_clk {
+ struct regmap *map;
+};
+
+#define AO_CLK_GATE0 0x40
+#define AO_SAR_CLK 0x90
+
+static struct meson_gate gates[] = {
+ MESON_GATE(CLKID_AO_SAR_ADC, AO_CLK_GATE0, 7),
+ MESON_GATE(CLKID_AO_SAR_ADC_CLK, AO_SAR_CLK, 7),
+};
+
+static int meson_set_gate(struct clk *clk, bool on)
+{
+ struct meson_clk *priv = dev_get_priv(clk->dev);
+ struct meson_gate *gate;
+
+ gate = &gates[clk->id];
+
+ regmap_update_bits(priv->map, gate->reg,
+ BIT(gate->bit), on ? BIT(gate->bit) : 0);
+
+ return 0;
+}
+
+static int meson_clk_enable(struct clk *clk)
+{
+ return meson_set_gate(clk, true);
+}
+
+static int meson_clk_disable(struct clk *clk)
+{
+ return meson_set_gate(clk, false);
+}
+
+static int meson_clk_probe(struct udevice *dev)
+{
+ struct meson_clk *priv = dev_get_priv(dev);
+
+ priv->map = syscon_node_to_regmap(dev_ofnode(dev_get_parent(dev)));
+ if (IS_ERR(priv->map))
+ return PTR_ERR(priv->map);
+
+ return 0;
+}
+
+static int meson_clk_request(struct clk *clk)
+{
+ if (clk->id >= ARRAY_SIZE(gates))
+ return -ENOENT;
+
+ return 0;
+}
+
+static struct clk_ops meson_clk_ops = {
+ .disable = meson_clk_disable,
+ .enable = meson_clk_enable,
+ .request = meson_clk_request,
+};
+
+static const struct udevice_id meson_clk_ids[] = {
+ { .compatible = "amlogic,meson-axg-aoclkc" },
+ { }
+};
+
+U_BOOT_DRIVER(meson_clk_axg_ao) = {
+ .name = "meson_clk_axg_ao",
+ .id = UCLASS_CLK,
+ .of_match = meson_clk_ids,
+ .priv_auto = sizeof(struct meson_clk),
+ .ops = &meson_clk_ops,
+ .probe = meson_clk_probe,
+};
diff --git a/drivers/clk/meson/g12a-ao.c b/drivers/clk/meson/g12a-ao.c
index 0148529e04f..1a855a68966 100644
--- a/drivers/clk/meson/g12a-ao.c
+++ b/drivers/clk/meson/g12a-ao.c
@@ -28,14 +28,8 @@ static int meson_set_gate(struct clk *clk, bool on)
struct meson_clk *priv = dev_get_priv(clk->dev);
struct meson_gate *gate;
- if (clk->id >= ARRAY_SIZE(gates))
- return -ENOENT;
-
gate = &gates[clk->id];
- if (gate->reg == 0)
- return 0;
-
regmap_update_bits(priv->map, gate->reg,
BIT(gate->bit), on ? BIT(gate->bit) : 0);
@@ -63,9 +57,18 @@ static int meson_clk_probe(struct udevice *dev)
return 0;
}
+static int meson_clk_request(struct clk *clk)
+{
+ if (clk->id >= ARRAY_SIZE(gates))
+ return -ENOENT;
+
+ return 0;
+}
+
static struct clk_ops meson_clk_ops = {
.disable = meson_clk_disable,
.enable = meson_clk_enable,
+ .request = meson_clk_request,
};
static const struct udevice_id meson_clk_ids[] = {
@@ -73,7 +76,7 @@ static const struct udevice_id meson_clk_ids[] = {
{ }
};
-U_BOOT_DRIVER(meson_clk_axg) = {
+U_BOOT_DRIVER(meson_clk_g12a_ao) = {
.name = "meson_clk_g12a_ao",
.id = UCLASS_CLK,
.of_match = meson_clk_ids,
diff --git a/drivers/core/tag.c b/drivers/core/tag.c
index 6829bcd8806..22999193a5a 100644
--- a/drivers/core/tag.c
+++ b/drivers/core/tag.c
@@ -29,7 +29,7 @@ int dev_tag_set_ptr(struct udevice *dev, enum dm_tag_t tag, void *ptr)
node = calloc(sizeof(*node), 1);
if (!node)
- return -ENOSPC;
+ return -ENOMEM;
node->dev = dev;
node->tag = tag;
@@ -53,7 +53,7 @@ int dev_tag_set_val(struct udevice *dev, enum dm_tag_t tag, ulong val)
node = calloc(sizeof(*node), 1);
if (!node)
- return -ENOSPC;
+ return -ENOMEM;
node->dev = dev;
node->tag = tag;
diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c
index 2578803b7a4..08d9ed82de2 100644
--- a/drivers/core/uclass.c
+++ b/drivers/core/uclass.c
@@ -180,14 +180,15 @@ void uclass_set_priv(struct uclass *uc, void *priv)
uc->priv_ = priv;
}
-enum uclass_id uclass_get_by_name_len(const char *name, int len)
+enum uclass_id uclass_get_by_namelen(const char *name, int len)
{
int i;
for (i = 0; i < UCLASS_COUNT; i++) {
struct uclass_driver *uc_drv = lists_uclass_lookup(i);
- if (uc_drv && !strncmp(uc_drv->name, name, len))
+ if (uc_drv && !strncmp(uc_drv->name, name, len) &&
+ strlen(uc_drv->name) == len)
return i;
}
@@ -196,7 +197,7 @@ enum uclass_id uclass_get_by_name_len(const char *name, int len)
enum uclass_id uclass_get_by_name(const char *name)
{
- return uclass_get_by_name_len(name, strlen(name));
+ return uclass_get_by_namelen(name, strlen(name));
}
int dev_get_uclass_index(struct udevice *dev, struct uclass **ucp)
@@ -273,8 +274,8 @@ int uclass_find_next_device(struct udevice **devp)
return 0;
}
-int uclass_find_device_by_name(enum uclass_id id, const char *name,
- struct udevice **devp)
+int uclass_find_device_by_namelen(enum uclass_id id, const char *name, int len,
+ struct udevice **devp)
{
struct uclass *uc;
struct udevice *dev;
@@ -288,7 +289,8 @@ int uclass_find_device_by_name(enum uclass_id id, const char *name,
return ret;
uclass_foreach_dev(dev, uc) {
- if (!strcmp(dev->name, name)) {
+ if (!strncmp(dev->name, name, len) &&
+ strlen(dev->name) == len) {
*devp = dev;
return 0;
}
@@ -297,6 +299,12 @@ int uclass_find_device_by_name(enum uclass_id id, const char *name,
return -ENODEV;
}
+int uclass_find_device_by_name(enum uclass_id id, const char *name,
+ struct udevice **devp)
+{
+ return uclass_find_device_by_namelen(id, name, strlen(name), devp);
+}
+
int uclass_find_next_free_seq(struct uclass *uc)
{
struct udevice *dev;
diff --git a/drivers/mmc/Makefile b/drivers/mmc/Makefile
index 17ebc04203e..96275093022 100644
--- a/drivers/mmc/Makefile
+++ b/drivers/mmc/Makefile
@@ -5,6 +5,11 @@
obj-y += mmc.o
obj-$(CONFIG_$(SPL_)DM_MMC) += mmc-uclass.o
+
+ifdef CONFIG_$(SPL_TPL_)DM_MMC
+obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += mmc_bootdev.o
+endif
+
obj-$(CONFIG_$(SPL_)MMC_WRITE) += mmc_write.o
obj-$(CONFIG_MMC_PWRSEQ) += mmc-pwrseq.o
obj-$(CONFIG_MMC_SDHCI_ADMA_HELPERS) += sdhci-adma.o
diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c
index 57da788ad80..688bdc06d42 100644
--- a/drivers/mmc/mmc-uclass.c
+++ b/drivers/mmc/mmc-uclass.c
@@ -8,6 +8,7 @@
#define LOG_CATEGORY UCLASS_MMC
#include <common.h>
+#include <bootdev.h>
#include <log.h>
#include <mmc.h>
#include <dm.h>
@@ -315,6 +316,20 @@ int mmc_get_next_devnum(void)
return blk_find_max_devnum(IF_TYPE_MMC);
}
+int mmc_get_blk(struct udevice *dev, struct udevice **blkp)
+{
+ struct udevice *blk;
+ int ret;
+
+ device_find_first_child_by_uclass(dev, UCLASS_BLK, &blk);
+ ret = device_probe(blk);
+ if (ret)
+ return ret;
+ *blkp = blk;
+
+ return 0;
+}
+
struct blk_desc *mmc_get_blk_desc(struct mmc *mmc)
{
struct blk_desc *desc;
@@ -406,6 +421,10 @@ int mmc_bind(struct udevice *dev, struct mmc *mmc, const struct mmc_config *cfg)
mmc->cfg = cfg;
mmc->priv = dev;
+ ret = bootdev_setup_for_dev(dev, "mmc_bootdev");
+ if (ret)
+ return log_msg_ret("bootdev", ret);
+
/* the following chunk was from mmc_register() */
/* Setup dsr related values */
@@ -424,12 +443,16 @@ int mmc_bind(struct udevice *dev, struct mmc *mmc, const struct mmc_config *cfg)
int mmc_unbind(struct udevice *dev)
{
struct udevice *bdev;
+ int ret;
device_find_first_child_by_uclass(dev, UCLASS_BLK, &bdev);
if (bdev) {
device_remove(bdev, DM_REMOVE_NORMAL);
device_unbind(bdev);
}
+ ret = bootdev_unbind_dev(dev);
+ if (ret)
+ return log_msg_ret("bootdev", ret);
return 0;
}
diff --git a/drivers/mmc/mmc_bootdev.c b/drivers/mmc/mmc_bootdev.c
new file mode 100644
index 00000000000..b4f41fb3a67
--- /dev/null
+++ b/drivers/mmc/mmc_bootdev.c
@@ -0,0 +1,62 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Bootdevice for MMC
+ *
+ * Copyright 2021 Google LLC
+ * Written by Simon Glass <sjg@chromium.org>
+ */
+
+#include <common.h>
+#include <bootdev.h>
+#include <dm.h>
+#include <mmc.h>
+
+static int mmc_get_bootflow(struct udevice *dev, struct bootflow_iter *iter,
+ struct bootflow *bflow)
+{
+ struct udevice *mmc_dev = dev_get_parent(dev);
+ struct udevice *blk;
+ int ret;
+
+ ret = mmc_get_blk(mmc_dev, &blk);
+ /*
+ * If there is no media, indicate that no more partitions should be
+ * checked
+ */
+ if (ret == -EOPNOTSUPP)
+ ret = -ESHUTDOWN;
+ if (ret)
+ return log_msg_ret("blk", ret);
+ assert(blk);
+ ret = bootdev_find_in_blk(dev, blk, iter, bflow);
+ if (ret)
+ return log_msg_ret("find", ret);
+
+ return 0;
+}
+
+static int mmc_bootdev_bind(struct udevice *dev)
+{
+ struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev);
+
+ ucp->prio = BOOTDEVP_0_INTERNAL_FAST;
+
+ return 0;
+}
+
+struct bootdev_ops mmc_bootdev_ops = {
+ .get_bootflow = mmc_get_bootflow,
+};
+
+static const struct udevice_id mmc_bootdev_ids[] = {
+ { .compatible = "u-boot,bootdev-mmc" },
+ { }
+};
+
+U_BOOT_DRIVER(mmc_bootdev) = {
+ .name = "mmc_bootdev",
+ .id = UCLASS_BOOTDEV,
+ .ops = &mmc_bootdev_ops,
+ .bind = mmc_bootdev_bind,
+ .of_match = mmc_bootdev_ids,
+};
diff --git a/drivers/spi/atmel-quadspi.c b/drivers/spi/atmel-quadspi.c
index 098298336da..cb64119f972 100644
--- a/drivers/spi/atmel-quadspi.c
+++ b/drivers/spi/atmel-quadspi.c
@@ -438,6 +438,9 @@ static bool atmel_qspi_supports_op(struct spi_slave *slave,
{
struct atmel_qspi *aq = dev_get_priv(slave->dev->parent);
+ if (!spi_mem_default_supports_op(slave, op))
+ return false;
+
if (aq->caps->octal) {
if (atmel_qspi_sama7g5_find_mode(op) < 0)
return false;
diff --git a/drivers/sysreset/Kconfig b/drivers/sysreset/Kconfig
index f6d60038b89..25dd02c7049 100644
--- a/drivers/sysreset/Kconfig
+++ b/drivers/sysreset/Kconfig
@@ -77,6 +77,21 @@ config SYSRESET_OCTEON
This enables the system reset driver support for Marvell Octeon
SoCs.
+config SYSRESET_AT91
+ bool "Enable support for Microchip/Atmel reset driver"
+ depends on ARCH_AT91
+ select SYSRESET_SPL_AT91 if SPL && SPL_SYSRESET
+ help
+ This enables the system reset driver support for Microchip/Atmel
+ SoCs.
+
+config SYSRESET_SPL_AT91
+ bool "Enable support for Microchip/Atmel reset driver in SPL"
+ depends on ARCH_AT91
+ help
+ This enables the system reset driver support for Microchip/Atmel
+ SoCs in SPL.
+
config SYSRESET_PSCI
bool "Enable support for PSCI System Reset"
depends on ARM_PSCI_FW
diff --git a/drivers/sysreset/Makefile b/drivers/sysreset/Makefile
index 8e00be07794..0ed3bbf356a 100644
--- a/drivers/sysreset/Makefile
+++ b/drivers/sysreset/Makefile
@@ -20,5 +20,6 @@ obj-$(CONFIG_SYSRESET_TI_SCI) += sysreset-ti-sci.o
obj-$(CONFIG_SYSRESET_SYSCON) += sysreset_syscon.o
obj-$(CONFIG_SYSRESET_WATCHDOG) += sysreset_watchdog.o
obj-$(CONFIG_SYSRESET_RESETCTL) += sysreset_resetctl.o
+obj-$(CONFIG_SYSRESET_$(SPL_TPL_)AT91) += sysreset_at91.o
obj-$(CONFIG_$(SPL_TPL_)SYSRESET_X86) += sysreset_x86.o
obj-$(CONFIG_TARGET_XTFPGA) += sysreset_xtfpga.o
diff --git a/drivers/sysreset/sysreset_at91.c b/drivers/sysreset/sysreset_at91.c
new file mode 100644
index 00000000000..24b87ee987d
--- /dev/null
+++ b/drivers/sysreset/sysreset_at91.c
@@ -0,0 +1,71 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2022 Microchip Technology, Inc. and its subsidiaries
+ */
+
+#include <asm/arch/hardware.h>
+#include <asm/io.h>
+#include <asm/arch/at91_rstc.h>
+#include <clk.h>
+#include <common.h>
+#include <cpu_func.h>
+#include <dm.h>
+#include <dm/device_compat.h>
+#include <dm/device-internal.h>
+#include <sysreset.h>
+
+static int at91_sysreset_request(struct udevice *dev, enum sysreset_t type)
+{
+ at91_rstc_t *rstc = (at91_rstc_t *)dev_get_priv(dev);
+
+ writel(AT91_RSTC_KEY
+ | AT91_RSTC_CR_PROCRST /* Processor Reset */
+ | AT91_RSTC_CR_PERRST /* Peripheral Reset */
+#ifdef CONFIG_AT91RESET_EXTRST
+ | AT91_RSTC_CR_EXTRST /* External Reset (assert nRST pin) */
+#endif
+ , &rstc->cr);
+
+ return -EINPROGRESS;
+}
+
+static int at91_sysreset_probe(struct udevice *dev)
+{
+ struct clk slck;
+ void *priv;
+ int ret;
+
+ priv = dev_remap_addr(dev);
+ if (!priv)
+ return -EINVAL;
+
+ dev_set_priv(dev, priv);
+
+ ret = clk_get_by_index(dev, 0, &slck);
+ if (ret)
+ return ret;
+
+ ret = clk_prepare_enable(&slck);
+ if (ret)
+ return ret;
+
+ return 0;
+}
+
+static struct sysreset_ops at91_sysreset = {
+ .request = at91_sysreset_request,
+};
+
+static const struct udevice_id a91_sysreset_ids[] = {
+ { .compatible = "atmel,sama5d3-rstc" },
+ { .compatible = "microchip,sam9x60-rstc" },
+ { }
+};
+
+U_BOOT_DRIVER(sysreset_at91) = {
+ .id = UCLASS_SYSRESET,
+ .name = "at91_reset",
+ .ops = &at91_sysreset,
+ .probe = at91_sysreset_probe,
+ .of_match = a91_sysreset_ids,
+};
diff --git a/drivers/timer/Kconfig b/drivers/timer/Kconfig
index 8fad59b81aa..92050179c28 100644
--- a/drivers/timer/Kconfig
+++ b/drivers/timer/Kconfig
@@ -40,12 +40,6 @@ config TIMER_EARLY
use an early timer. These functions must be supported by your timer
driver: timer_early_get_count() and timer_early_get_rate().
-config AG101P_TIMER
- bool "AG101P timer support"
- depends on TIMER && NDS32
- help
- Select this to enable a timer for AG01P devices.
-
config ALTERA_TIMER
bool "Altera timer support"
depends on TIMER
@@ -96,6 +90,15 @@ config ATMEL_PIT_TIMER
it is designed to offer maximum accuracy and efficient management,
even for systems with long response time.
+config SPL_ATMEL_PIT_TIMER
+ bool "Atmel periodic interval timer support in SPL"
+ depends on SPL_TIMER
+ help
+ Select this to enable a periodic interval timer for Atmel devices,
+ it is designed to offer maximum accuracy and efficient management,
+ even for systems with long response time.
+ Select this to be available in SPL.
+
config ATMEL_TCB_TIMER
bool "Atmel timer counter support"
depends on TIMER
@@ -104,6 +107,14 @@ config ATMEL_TCB_TIMER
Select this to enable the use of the timer counter as a monotonic
counter.
+config SPL_ATMEL_TCB_TIMER
+ bool "Atmel timer counter support in SPL"
+ depends on SPL_TIMER
+ depends on ARCH_AT91
+ help
+ Select this to enable the use of the timer counter as a monotonic
+ counter in SPL.
+
config CADENCE_TTC_TIMER
bool "Cadence TTC (Triple Timer Counter)"
depends on TIMER
diff --git a/drivers/timer/Makefile b/drivers/timer/Makefile
index 58da6c1e846..35cc490db1e 100644
--- a/drivers/timer/Makefile
+++ b/drivers/timer/Makefile
@@ -3,14 +3,13 @@
# Copyright (C) 2015 Thomas Chou <thomas@wytron.com.tw>
obj-y += timer-uclass.o
-obj-$(CONFIG_AG101P_TIMER) += ag101p_timer.o
obj-$(CONFIG_ALTERA_TIMER) += altera_timer.o
obj-$(CONFIG_ANDES_PLMT_TIMER) += andes_plmt_timer.o
obj-$(CONFIG_ARC_TIMER) += arc_timer.o
obj-$(CONFIG_AST_TIMER) += ast_timer.o
obj-$(CONFIG_ATCPIT100_TIMER) += atcpit100_timer.o
-obj-$(CONFIG_ATMEL_PIT_TIMER) += atmel_pit_timer.o
-obj-$(CONFIG_ATMEL_TCB_TIMER) += atmel_tcb_timer.o
+obj-$(CONFIG_$(SPL_)ATMEL_PIT_TIMER) += atmel_pit_timer.o
+obj-$(CONFIG_$(SPL_)ATMEL_TCB_TIMER) += atmel_tcb_timer.o
obj-$(CONFIG_CADENCE_TTC_TIMER) += cadence-ttc.o
obj-$(CONFIG_DESIGNWARE_APB_TIMER) += dw-apb-timer.o
obj-$(CONFIG_MPC83XX_TIMER) += mpc83xx_timer.o
diff --git a/drivers/timer/ag101p_timer.c b/drivers/timer/ag101p_timer.c
deleted file mode 100644
index 27cf9b02471..00000000000
--- a/drivers/timer/ag101p_timer.c
+++ /dev/null
@@ -1,117 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Andestech ATFTMR010 timer driver
- *
- * (C) Copyright 2016
- * Rick Chen, NDS32 Software Engineering, rick@andestech.com
- */
-#include <common.h>
-#include <dm.h>
-#include <errno.h>
-#include <timer.h>
-#include <linux/io.h>
-
-/*
- * Timer Control Register
- */
-#define T3_UPDOWN (1 << 11)
-#define T2_UPDOWN (1 << 10)
-#define T1_UPDOWN (1 << 9)
-#define T3_OFENABLE (1 << 8)
-#define T3_CLOCK (1 << 7)
-#define T3_ENABLE (1 << 6)
-#define T2_OFENABLE (1 << 5)
-#define T2_CLOCK (1 << 4)
-#define T2_ENABLE (1 << 3)
-#define T1_OFENABLE (1 << 2)
-#define T1_CLOCK (1 << 1)
-#define T1_ENABLE (1 << 0)
-
-/*
- * Timer Interrupt State & Mask Registers
- */
-#define T3_OVERFLOW (1 << 8)
-#define T3_MATCH2 (1 << 7)
-#define T3_MATCH1 (1 << 6)
-#define T2_OVERFLOW (1 << 5)
-#define T2_MATCH2 (1 << 4)
-#define T2_MATCH1 (1 << 3)
-#define T1_OVERFLOW (1 << 2)
-#define T1_MATCH2 (1 << 1)
-#define T1_MATCH1 (1 << 0)
-
-struct atftmr_timer_regs {
- u32 t1_counter; /* 0x00 */
- u32 t1_load; /* 0x04 */
- u32 t1_match1; /* 0x08 */
- u32 t1_match2; /* 0x0c */
- u32 t2_counter; /* 0x10 */
- u32 t2_load; /* 0x14 */
- u32 t2_match1; /* 0x18 */
- u32 t2_match2; /* 0x1c */
- u32 t3_counter; /* 0x20 */
- u32 t3_load; /* 0x24 */
- u32 t3_match1; /* 0x28 */
- u32 t3_match2; /* 0x2c */
- u32 cr; /* 0x30 */
- u32 int_state; /* 0x34 */
- u32 int_mask; /* 0x38 */
-};
-
-struct atftmr_timer_plat {
- struct atftmr_timer_regs *regs;
-};
-
-static u64 atftmr_timer_get_count(struct udevice *dev)
-{
- struct atftmr_timer_plat *plat = dev_get_plat(dev);
- struct atftmr_timer_regs *const regs = plat->regs;
- u32 val;
- val = readl(&regs->t3_counter);
- return timer_conv_64(val);
-}
-
-static int atftmr_timer_probe(struct udevice *dev)
-{
- struct atftmr_timer_plat *plat = dev_get_plat(dev);
- struct atftmr_timer_regs *const regs = plat->regs;
- u32 cr;
- writel(0, &regs->t3_load);
- writel(0, &regs->t3_counter);
- writel(TIMER_LOAD_VAL, &regs->t3_match1);
- writel(TIMER_LOAD_VAL, &regs->t3_match2);
- /* disable interrupts */
- writel(T3_MATCH1|T3_MATCH2|T3_OVERFLOW , &regs->int_mask);
- cr = readl(&regs->cr);
- cr |= (T3_ENABLE|T3_UPDOWN);
- writel(cr, &regs->cr);
- return 0;
-}
-
-static int atftme_timer_of_to_plat(struct udevice *dev)
-{
- struct atftmr_timer_plat *plat = dev_get_plat(dev);
- plat->regs = map_physmem(dev_read_addr(dev),
- sizeof(struct atftmr_timer_regs),
- MAP_NOCACHE);
- return 0;
-}
-
-static const struct timer_ops ag101p_timer_ops = {
- .get_count = atftmr_timer_get_count,
-};
-
-static const struct udevice_id ag101p_timer_ids[] = {
- { .compatible = "andestech,attmr010" },
- {}
-};
-
-U_BOOT_DRIVER(altera_timer) = {
- .name = "ag101p_timer",
- .id = UCLASS_TIMER,
- .of_match = ag101p_timer_ids,
- .of_to_plat = atftme_timer_of_to_plat,
- .plat_auto = sizeof(struct atftmr_timer_plat),
- .probe = atftmr_timer_probe,
- .ops = &ag101p_timer_ops,
-};
diff --git a/drivers/timer/atcpit100_timer.c b/drivers/timer/atcpit100_timer.c
deleted file mode 100644
index fbc7fac1bba..00000000000
--- a/drivers/timer/atcpit100_timer.c
+++ /dev/null
@@ -1,112 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Andestech ATCPIT100 timer driver
- *
- * (C) Copyright 2016
- * Rick Chen, NDS32 Software Engineering, rick@andestech.com
- */
-#include <common.h>
-#include <dm.h>
-#include <errno.h>
-#include <timer.h>
-#include <linux/io.h>
-
-#define REG32_TMR(x) (*(u32 *) ((plat->regs) + (x>>2)))
-
-/*
- * Definition of register offsets
- */
-
-/* ID and Revision Register */
-#define ID_REV 0x0
-
-/* Configuration Register */
-#define CFG 0x10
-
-/* Interrupt Enable Register */
-#define INT_EN 0x14
-#define CH_INT_EN(c , i) ((1<<i)<<(4*c))
-
-/* Interrupt Status Register */
-#define INT_STA 0x18
-#define CH_INT_STA(c , i) ((1<<i)<<(4*c))
-
-/* Channel Enable Register */
-#define CH_EN 0x1C
-#define CH_TMR_EN(c , t) ((1<<t)<<(4*c))
-
-/* Ch n Control REgister */
-#define CH_CTL(n) (0x20+0x10*n)
-/* Channel clock source , bit 3 , 0:External clock , 1:APB clock */
-#define APB_CLK (1<<3)
-/* Channel mode , bit 0~2 */
-#define TMR_32 1
-#define TMR_16 2
-#define TMR_8 3
-#define PWM 4
-
-#define CH_REL(n) (0x24+0x10*n)
-#define CH_CNT(n) (0x28+0x10*n)
-
-struct atctmr_timer_regs {
- u32 id_rev; /* 0x00 */
- u32 reservd[3]; /* 0x04 ~ 0x0c */
- u32 cfg; /* 0x10 */
- u32 int_en; /* 0x14 */
- u32 int_st; /* 0x18 */
- u32 ch_en; /* 0x1c */
- u32 ch0_ctrl; /* 0x20 */
- u32 ch0_reload; /* 0x24 */
- u32 ch0_cntr; /* 0x28 */
- u32 reservd1; /* 0x2c */
- u32 ch1_ctrl; /* 0x30 */
- u32 ch1_reload; /* 0x34 */
- u32 int_mask; /* 0x38 */
-};
-
-struct atcpit_timer_plat {
- u32 *regs;
-};
-
-static u64 atcpit_timer_get_count(struct udevice *dev)
-{
- struct atcpit_timer_plat *plat = dev_get_plat(dev);
- u32 val;
- val = ~(REG32_TMR(CH_CNT(1))+0xffffffff);
- return timer_conv_64(val);
-}
-
-static int atcpit_timer_probe(struct udevice *dev)
-{
- struct atcpit_timer_plat *plat = dev_get_plat(dev);
- REG32_TMR(CH_REL(1)) = 0xffffffff;
- REG32_TMR(CH_CTL(1)) = APB_CLK|TMR_32;
- REG32_TMR(CH_EN) |= CH_TMR_EN(1 , 0);
- return 0;
-}
-
-static int atcpit_timer_of_to_plat(struct udevice *dev)
-{
- struct atcpit_timer_plat *plat = dev_get_plat(dev);
- plat->regs = map_physmem(dev_read_addr(dev), 0x100 , MAP_NOCACHE);
- return 0;
-}
-
-static const struct timer_ops atcpit_timer_ops = {
- .get_count = atcpit_timer_get_count,
-};
-
-static const struct udevice_id atcpit_timer_ids[] = {
- { .compatible = "andestech,atcpit100" },
- {}
-};
-
-U_BOOT_DRIVER(atcpit100_timer) = {
- .name = "atcpit100_timer",
- .id = UCLASS_TIMER,
- .of_match = atcpit_timer_ids,
- .of_to_plat = atcpit_timer_of_to_plat,
- .plat_auto = sizeof(struct atcpit_timer_plat),
- .probe = atcpit_timer_probe,
- .ops = &atcpit_timer_ops,
-};
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
index a4472da9f18..7785b3744ef 100644
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -8,6 +8,10 @@ obj-y += usb-uclass.o
obj-$(CONFIG_SANDBOX) += usb-sandbox.o
endif
+ifdef CONFIG_$(SPL_TPL_)USB_STORAGE
+obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += usb_bootdev.o
+endif
+
# ohci
obj-$(CONFIG_USB_OHCI_NEW) += ohci-hcd.o
obj-$(CONFIG_USB_ATMEL) += ohci-at91.o
diff --git a/drivers/usb/host/usb_bootdev.c b/drivers/usb/host/usb_bootdev.c
new file mode 100644
index 00000000000..b85f699933d
--- /dev/null
+++ b/drivers/usb/host/usb_bootdev.c
@@ -0,0 +1,61 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Bootdevice for USB
+ *
+ * Copyright 2021 Google LLC
+ * Written by Simon Glass <sjg@chromium.org>
+ */
+
+#include <common.h>
+#include <bootdev.h>
+#include <dm.h>
+#include <usb.h>
+
+static int usb_get_bootflow(struct udevice *dev, struct bootflow_iter *iter,
+ struct bootflow *bflow)
+{
+ struct udevice *blk;
+ int ret;
+
+ ret = bootdev_get_sibling_blk(dev, &blk);
+ /*
+ * If there is no media, indicate that no more partitions should be
+ * checked
+ */
+ if (ret == -EOPNOTSUPP)
+ ret = -ESHUTDOWN;
+ if (ret)
+ return log_msg_ret("blk", ret);
+ assert(blk);
+ ret = bootdev_find_in_blk(dev, blk, iter, bflow);
+ if (ret)
+ return log_msg_ret("find", ret);
+
+ return 0;
+}
+
+static int usb_bootdev_bind(struct udevice *dev)
+{
+ struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev);
+
+ ucp->prio = BOOTDEVP_3_SCAN_SLOW;
+
+ return 0;
+}
+
+struct bootdev_ops usb_bootdev_ops = {
+ .get_bootflow = usb_get_bootflow,
+};
+
+static const struct udevice_id usb_bootdev_ids[] = {
+ { .compatible = "u-boot,bootdev-usb" },
+ { }
+};
+
+U_BOOT_DRIVER(usb_bootdev) = {
+ .name = "usb_bootdev",
+ .id = UCLASS_BOOTDEV,
+ .ops = &usb_bootdev_ops,
+ .bind = usb_bootdev_bind,
+ .of_match = usb_bootdev_ids,
+};
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index 1089cd21f50..c0b4c9fa438 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -4,7 +4,6 @@
# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
obj-$(CONFIG_WDT_AT91) += at91sam9_wdt.o
-obj-$(CONFIG_FTWDT010_WATCHDOG) += ftwdt010_wdt.o
ifneq (,$(filter $(SOC), mx25 mx31 mx35 mx5 mx6 mx7 vf610))
obj-y += imx_watchdog.o
else
diff --git a/drivers/watchdog/ftwdt010_wdt.c b/drivers/watchdog/ftwdt010_wdt.c
deleted file mode 100644
index 6aed41642de..00000000000
--- a/drivers/watchdog/ftwdt010_wdt.c
+++ /dev/null
@@ -1,92 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Watchdog driver for the FTWDT010 Watch Dog Driver
- *
- * (c) Copyright 2004 Faraday Technology Corp. (www.faraday-tech.com)
- * Based on sa1100_wdt.c by Oleg Drokin <green@crimea.edu>
- * Based on SoftDog driver by Alan Cox <alan@redhat.com>
- *
- * Copyright (C) 2011 Andes Technology Corporation
- * Macpaul Lin, Andes Technology Corporation <macpaul@andestech.com>
- *
- * 27/11/2004 Initial release, Faraday.
- * 12/01/2011 Port to u-boot, Macpaul Lin.
- */
-
-#include <common.h>
-#include <log.h>
-#include <watchdog.h>
-#include <asm/io.h>
-#include <faraday/ftwdt010_wdt.h>
-
-/*
- * Set the watchdog time interval.
- * Counter is 32 bit.
- */
-int ftwdt010_wdt_settimeout(unsigned int timeout)
-{
- unsigned int reg;
-
- struct ftwdt010_wdt *wd = (struct ftwdt010_wdt *)CONFIG_FTWDT010_BASE;
-
- debug("Activating WDT..\n");
-
- /* Check if disabled */
- if (readl(&wd->wdcr) & ~FTWDT010_WDCR_ENABLE) {
- printf("sorry, watchdog is disabled\n");
- return -1;
- }
-
- /*
- * In a 66MHz system,
- * if you set WDLOAD as 0x03EF1480 (66000000)
- * the reset timer is 1 second.
- */
- reg = FTWDT010_WDLOAD(timeout * FTWDT010_TIMEOUT_FACTOR);
-
- writel(reg, &wd->wdload);
-
- return 0;
-}
-
-void ftwdt010_wdt_reset(void)
-{
- struct ftwdt010_wdt *wd = (struct ftwdt010_wdt *)CONFIG_FTWDT010_BASE;
-
- /* clear control register */
- writel(0, &wd->wdcr);
-
- /* Write Magic number */
- writel(FTWDT010_WDRESTART_MAGIC, &wd->wdrestart);
-
- /* Enable WDT */
- writel((FTWDT010_WDCR_RST | FTWDT010_WDCR_ENABLE), &wd->wdcr);
-}
-
-void ftwdt010_wdt_disable(void)
-{
- struct ftwdt010_wdt *wd = (struct ftwdt010_wdt *)CONFIG_FTWDT010_BASE;
-
- debug("Deactivating WDT..\n");
-
- /*
- * It was defined with CONFIG_WATCHDOG_NOWAYOUT in Linux
- *
- * Shut off the timer.
- * Lock it in if it's a module and we defined ...NOWAYOUT
- */
- writel(0, &wd->wdcr);
-}
-
-#if defined(CONFIG_HW_WATCHDOG)
-void hw_watchdog_reset(void)
-{
- ftwdt010_wdt_reset();
-}
-
-void hw_watchdog_init(void)
-{
- /* set timer in ms */
- ftwdt010_wdt_settimeout(CONFIG_FTWDT010_HW_TIMEOUT * 1000);
-}
-#endif
diff --git a/examples/standalone/nds32.lds b/examples/standalone/nds32.lds
deleted file mode 100644
index 5a04f43c9a6..00000000000
--- a/examples/standalone/nds32.lds
+++ /dev/null
@@ -1,39 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * Copyright (C) 2011 Andes Technology Corporation
- * Shawn Lin, Andes Technology Corporation <nobuhiro@andestech.com>
- * Macpaul Lin, Andes Technology Corporation <macpaul@andestech.com>
- */
-
-OUTPUT_FORMAT("elf32-nds32", "elf32-nds32", "elf32-nds32")
-OUTPUT_ARCH(nds32)
-ENTRY(_start)
-SECTIONS
-{
- . = ALIGN(4);
- .text :
- {
- *(.text)
- }
-
- . = ALIGN(4);
- .data : { *(.data) }
-
- . = ALIGN(4);
-
- .got : {
- __got_start = .;
- *(.got)
- __got_end = .;
- }
-
- . = ALIGN(4);
- __bss_start = .;
- .bss : { *(.bss) }
- __bss_end = .;
-
- . = ALIGN(4);
- .rela.text : { *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) }
-
- _end = .;
-}
diff --git a/examples/standalone/stubs.c b/examples/standalone/stubs.c
index 5fb460454f2..ce05f41b0ce 100644
--- a/examples/standalone/stubs.c
+++ b/examples/standalone/stubs.c
@@ -161,19 +161,6 @@ gd_t *global_data;
" nop\n" \
" nop\n" \
: : "i"(offsetof(gd_t, jt)), "i"(FO(x)) : "r1", "r2");
-#elif defined(CONFIG_NDS32)
-/*
- * r16 holds the pointer to the global_data. gp is call clobbered.
- * not support reduced register (16 GPR).
- */
-#define EXPORT_FUNC(f, a, x, ...) \
- asm volatile ( \
-" .globl " #x "\n" \
-#x ":\n" \
-" lwi $r16, [$gp + (%0)]\n" \
-" lwi $r16, [$r16 + (%1)]\n" \
-" jr $r16\n" \
- : : "i"(offsetof(gd_t, jt)), "i"(FO(x)) : "$r16");
#elif defined(CONFIG_RISCV)
/*
* gp holds the pointer to the global_data. t0 is call clobbered.
diff --git a/fs/Kconfig b/fs/Kconfig
index cda9f66cc93..aa13d4faa77 100644
--- a/fs/Kconfig
+++ b/fs/Kconfig
@@ -16,6 +16,8 @@ source "fs/fat/Kconfig"
source "fs/jffs2/Kconfig"
+source "fs/sandbox/Kconfig"
+
source "fs/ubifs/Kconfig"
source "fs/cramfs/Kconfig"
diff --git a/fs/fs.c b/fs/fs.c
index b812597ced9..6de1a3eb6d5 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -36,6 +36,11 @@ static int fs_dev_part;
static struct disk_partition fs_partition;
static int fs_type = FS_TYPE_ANY;
+void fs_set_type(int type)
+{
+ fs_type = type;
+}
+
static inline int fs_probe_unsupported(struct blk_desc *fs_dev_desc,
struct disk_partition *fs_partition)
{
diff --git a/fs/sandbox/Kconfig b/fs/sandbox/Kconfig
new file mode 100644
index 00000000000..b2af8482428
--- /dev/null
+++ b/fs/sandbox/Kconfig
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
diff --git a/fs/sandbox/Makefile b/fs/sandbox/Makefile
index 06090519bf4..880d59dd693 100644
--- a/fs/sandbox/Makefile
+++ b/fs/sandbox/Makefile
@@ -9,3 +9,4 @@
# Pavel Bartusek, Sysgo Real-Time Solutions AG, pba@sysgo.de
obj-y := sandboxfs.o
+obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += host_bootdev.o
diff --git a/fs/sandbox/host_bootdev.c b/fs/sandbox/host_bootdev.c
new file mode 100644
index 00000000000..0d12ee4ef74
--- /dev/null
+++ b/fs/sandbox/host_bootdev.c
@@ -0,0 +1,56 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Bootdevice for MMC
+ *
+ * Copyright 2021 Google LLC
+ * Written by Simon Glass <sjg@chromium.org>
+ */
+
+#include <common.h>
+#include <bootdev.h>
+#include <bootflow.h>
+#include <bootmeth.h>
+#include <dm.h>
+#include <fs.h>
+
+static int host_get_bootflow(struct udevice *dev, struct bootflow_iter *iter,
+ struct bootflow *bflow)
+{
+ int ret;
+
+ if (iter->part)
+ return log_msg_ret("max", -ESHUTDOWN);
+
+ bflow->name = strdup(dev->name);
+ if (!bflow->name)
+ return log_msg_ret("name", -ENOMEM);
+
+ ret = bootmeth_check(bflow->method, iter);
+ if (ret)
+ return log_msg_ret("check", ret);
+
+ bflow->state = BOOTFLOWST_MEDIA;
+ bflow->fs_type = FS_TYPE_SANDBOX;
+
+ ret = bootmeth_read_bootflow(bflow->method, bflow);
+ if (ret)
+ return log_msg_ret("method", ret);
+
+ return 0;
+}
+
+struct bootdev_ops host_bootdev_ops = {
+ .get_bootflow = host_get_bootflow,
+};
+
+static const struct udevice_id host_bootdev_ids[] = {
+ { .compatible = "sandbox,bootdev-host" },
+ { }
+};
+
+U_BOOT_DRIVER(host_bootdev) = {
+ .name = "host_bootdev",
+ .id = UCLASS_BOOTDEV,
+ .ops = &host_bootdev_ops,
+ .of_match = host_bootdev_ids,
+};
diff --git a/include/blk.h b/include/blk.h
index dbe9ae219da..9503369db83 100644
--- a/include/blk.h
+++ b/include/blk.h
@@ -434,6 +434,14 @@ int blk_select_hwpart(struct udevice *dev, int hwpart);
int blk_get_from_parent(struct udevice *parent, struct udevice **devp);
/**
+ * blk_get_devtype() - Get the device type of a block device
+ *
+ * @dev: Block device to check
+ * Return: device tree, i.e. the uclass name of its parent, e.g. "mmc"
+ */
+const char *blk_get_devtype(struct udevice *dev);
+
+/**
* blk_get_by_device() - Get the block device descriptor for the given device
* @dev: Instance of a storage device
*
diff --git a/include/bootdev.h b/include/bootdev.h
new file mode 100644
index 00000000000..9fc219839fe
--- /dev/null
+++ b/include/bootdev.h
@@ -0,0 +1,275 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2021 Google LLC
+ * Written by Simon Glass <sjg@chromium.org>
+ */
+
+#ifndef __bootdev_h
+#define __bootdev_h
+
+#include <linux/list.h>
+
+struct bootflow;
+struct bootflow_iter;
+struct udevice;
+
+/**
+ * enum bootdev_prio_t - priority of each bootdev
+ *
+ * These values are associated with each bootdev and set up by the driver.
+ *
+ * Smallest value is the highest priority. By default, bootdevs are scanned from
+ * highest to lowest priority
+ */
+enum bootdev_prio_t {
+ BOOTDEVP_0_INTERNAL_FAST = 10,
+ BOOTDEVP_1_INTERNAL_SLOW = 20,
+ BOOTDEVP_2_SCAN_FAST = 30,
+ BOOTDEVP_3_SCAN_SLOW = 40,
+ BOOTDEVP_4_NET_BASE = 50,
+ BOOTDEVP_5_NET_FALLBACK = 60,
+ BOOTDEVP_6_SYSTEM = 70,
+
+ BOOTDEVP_COUNT,
+};
+
+/**
+ * struct bootdev_uc_plat - uclass information about a bootdev
+ *
+ * This is attached to each device in the bootdev uclass and accessible via
+ * dev_get_uclass_plat(dev)
+ *
+ * @bootflows: List of available bootflows for this bootdev
+ * @piro: Priority of this bootdev
+ */
+struct bootdev_uc_plat {
+ struct list_head bootflow_head;
+ enum bootdev_prio_t prio;
+};
+
+/** struct bootdev_ops - Operations for the bootdev uclass */
+struct bootdev_ops {
+ /**
+ * get_bootflow() - get a bootflow
+ *
+ * @dev: Bootflow device to check
+ * @iter: Provides current dev, part, method to get. Should update
+ * max_part if there is a partition table. Should update state,
+ * subdir, fname, buf, size according to progress
+ * @bflow: Updated bootflow if found
+ * Return: 0 if OK, -ESHUTDOWN if there are no more bootflows on this
+ * device, -ENOSYS if this device doesn't support bootflows,
+ * other -ve value on other error
+ */
+ int (*get_bootflow)(struct udevice *dev, struct bootflow_iter *iter,
+ struct bootflow *bflow);
+};
+
+#define bootdev_get_ops(dev) ((struct bootdev_ops *)(dev)->driver->ops)
+
+/**
+ * bootdev_get_bootflow() - get a bootflow
+ *
+ * @dev: Bootflow device to check
+ * @iter: Provides current part, method to get
+ * @bflow: Returns bootflow if found
+ * Return: 0 if OK, -ESHUTDOWN if there are no more bootflows on this device,
+ * -ENOSYS if this device doesn't support bootflows, other -ve value on
+ * other error
+ */
+int bootdev_get_bootflow(struct udevice *dev, struct bootflow_iter *iter,
+ struct bootflow *bflow);
+
+/**
+ * bootdev_bind() - Bind a new named bootdev device
+ *
+ * @parent: Parent of the new device
+ * @drv_name: Driver name to use for the bootdev device
+ * @name: Name for the device (parent name is prepended)
+ * @devp: the new device (which has not been probed)
+ */
+int bootdev_bind(struct udevice *parent, const char *drv_name, const char *name,
+ struct udevice **devp);
+
+/**
+ * bootdev_find_in_blk() - Find a bootdev in a block device
+ *
+ * @dev: Bootflow device associated with this block device
+ * @blk: Block device to search
+ * @iter: Provides current dev, part, method to get. Should update
+ * max_part if there is a partition table
+ * @bflow: On entry, provides information about the partition and device to
+ * check. On exit, returns bootflow if found
+ * Return: 0 if found, -ESHUTDOWN if no more bootflows, other -ve on error
+ */
+int bootdev_find_in_blk(struct udevice *dev, struct udevice *blk,
+ struct bootflow_iter *iter, struct bootflow *bflow);
+
+/**
+ * bootdev_list() - List all available bootdevs
+ *
+ * @probe: true to probe devices, false to leave them as is
+ */
+void bootdev_list(bool probe);
+
+/**
+ * bootdev_clear_bootflows() - Clear bootflows from a bootdev
+ *
+ * Each bootdev maintains a list of discovered bootflows. This provides a
+ * way to clear it. These bootflows are removed from the global list too.
+ *
+ * @dev: bootdev device to update
+ */
+void bootdev_clear_bootflows(struct udevice *dev);
+
+/**
+ * bootdev_add_bootflow() - Add a bootflow to the bootdev's list
+ *
+ * All fields in @bflow must be set up. Note that @bflow->dev is used to add the
+ * bootflow to that device.
+ *
+ * @dev: Bootdevice device to add to
+ * @bflow: Bootflow to add. Note that fields within bflow must be allocated
+ * since this function takes over ownership of these. This functions makes
+ * a copy of @bflow itself (without allocating its fields again), so the
+ * caller must dispose of the memory used by the @bflow pointer itself
+ * Return: 0 if OK, -ENOMEM if out of memory
+ */
+int bootdev_add_bootflow(struct bootflow *bflow);
+
+/**
+ * bootdev_first_bootflow() - Get the first bootflow from a bootdev
+ *
+ * Returns the first bootflow attached to a bootdev
+ *
+ * @dev: bootdev device
+ * @bflowp: Returns a pointer to the bootflow
+ * Return: 0 if found, -ENOENT if there are no bootflows
+ */
+int bootdev_first_bootflow(struct udevice *dev, struct bootflow **bflowp);
+
+/**
+ * bootdev_next_bootflow() - Get the next bootflow from a bootdev
+ *
+ * Returns the next bootflow attached to a bootdev
+ *
+ * @bflowp: On entry, the last bootflow returned , e.g. from
+ * bootdev_first_bootflow()
+ * Return: 0 if found, -ENOENT if there are no more bootflows
+ */
+int bootdev_next_bootflow(struct bootflow **bflowp);
+
+/**
+ * bootdev_find_by_label() - Look up a bootdev by label
+ *
+ * Each bootdev has a label which contains the media-uclass name and a number,
+ * e.g. 'mmc2'. This looks up the label and returns the associated bootdev
+ *
+ * The lookup is performed based on the media device's sequence number. So for
+ * 'mmc2' this looks for a device in UCLASS_MMC with a dev_seq() of 2.
+ *
+ * @label: Label to look up (e.g. "mmc1" or "mmc0")
+ * @devp: Returns the bootdev device found, or NULL if none (note it does not
+ * return the media device, but its bootdev child)
+ * Return: 0 if OK, -EINVAL if the uclass is not supported by this board,
+ * -ENOENT if there is no device with that number
+ */
+int bootdev_find_by_label(const char *label, struct udevice **devp);
+
+/**
+ * bootdev_find_by_any() - Find a bootdev by name, label or sequence
+ *
+ * @name: name (e.g. "mmc2.bootdev"), label ("mmc2"), or sequence ("2") to find
+ * @devp: returns the device found, on success
+ * Return: 0 if OK, -ve on error
+ */
+int bootdev_find_by_any(const char *name, struct udevice **devp);
+
+/**
+ * bootdev_setup_iter_order() - Set up the ordering of bootdevs to scan
+ *
+ * This sets up the ordering information in @iter, based on the priority of each
+ * bootdev and the bootdev-order property in the bootstd node
+ *
+ * If a single device is requested, no ordering is needed
+ *
+ * @iter: Iterator to update with the order
+ * @devp: On entry, *devp is NULL to scan all, otherwise this is the (single)
+ * device to scan. Returns the first device to use, which is the passed-in
+ * @devp if it was non-NULL
+ * Return: 0 if OK, -ENOENT if no bootdevs, -ENOMEM if out of memory, other -ve
+ * on other error
+ */
+int bootdev_setup_iter_order(struct bootflow_iter *iter, struct udevice **devp);
+
+#if CONFIG_IS_ENABLED(BOOTSTD)
+/**
+ * bootdev_setup_for_dev() - Bind a new bootdev device
+ *
+ * Creates a bootdev device as a child of @parent. This should be called from
+ * the driver's bind() method or its uclass' post_bind() method.
+ *
+ * If a child bootdev already exists, this function does nothing
+ *
+ * @parent: Parent device (e.g. MMC or Ethernet)
+ * @drv_name: Name of bootdev driver to bind
+ * Return: 0 if OK, -ve on error
+ */
+int bootdev_setup_for_dev(struct udevice *parent, const char *drv_name);
+
+/**
+ * bootdev_setup_for_blk() - Bind a new bootdev device for a blk device
+ *
+ * Creates a bootdev device as a sibling of @blk. This should be called from
+ * the driver's bind() method or its uclass' post_bind() method, at the same
+ * time as the bould device is bound
+ *
+ * If a device of the same name already exists, this function does nothing
+ *
+ * @parent: Parent device (e.g. MMC or Ethernet)
+ * @drv_name: Name of bootdev driver to bind
+ * Return: 0 if OK, -ve on error
+ */
+int bootdev_setup_sibling_blk(struct udevice *blk, const char *drv_name);
+
+/**
+ * bootdev_get_sibling_blk() - Locate the block device for a bootdev
+ *
+ * @dev: bootdev to check
+ * @blkp: returns associated block device
+ * Return: 0 if OK, -EINVAL if @dev is not a bootdev device, other -ve on other
+ * error
+ */
+int bootdev_get_sibling_blk(struct udevice *dev, struct udevice **blkp);
+
+/**
+ * bootdev_unbind_dev() - Unbind a bootdev device
+ *
+ * Remove and unbind a bootdev device which is a child of @parent. This should
+ * be called from the driver's unbind() method or its uclass' post_bind()
+ * method.
+ *
+ * @parent: Parent device (e.g. MMC or Ethernet)
+ * Return: 0 if OK, -ve on error
+ */
+int bootdev_unbind_dev(struct udevice *parent);
+#else
+static inline int bootdev_setup_for_dev(struct udevice *parent,
+ const char *drv_name)
+{
+ return 0;
+}
+
+static inline int bootdev_setup_sibling_blk(struct udevice *blk,
+ const char *drv_name)
+{
+ return 0;
+}
+
+static inline int bootdev_unbind_dev(struct udevice *parent)
+{
+ return 0;
+}
+#endif
+
+#endif
diff --git a/include/bootflow.h b/include/bootflow.h
new file mode 100644
index 00000000000..c30ba042a48
--- /dev/null
+++ b/include/bootflow.h
@@ -0,0 +1,310 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2021 Google LLC
+ * Written by Simon Glass <sjg@chromium.org>
+ */
+
+#ifndef __bootflow_h
+#define __bootflow_h
+
+#include <linux/list.h>
+
+/**
+ * enum bootflow_state_t - states that a particular bootflow can be in
+ *
+ * Only bootflows in state BOOTFLOWST_READY can be used to boot.
+ *
+ * See bootflow_state[] for the names for each of these
+ */
+enum bootflow_state_t {
+ BOOTFLOWST_BASE, /**< Nothing known yet */
+ BOOTFLOWST_MEDIA, /**< Media exists */
+ BOOTFLOWST_PART, /**< Partition exists */
+ BOOTFLOWST_FS, /**< Filesystem exists */
+ BOOTFLOWST_FILE, /**< Bootflow file exists */
+ BOOTFLOWST_READY, /**< Bootflow file loaded */
+
+ BOOTFLOWST_COUNT
+};
+
+/**
+ * struct bootflow - information about a bootflow
+ *
+ * This is connected into two separate linked lists:
+ *
+ * bm_sibling - links all bootflows in the same bootdev
+ * glob_sibling - links all bootflows in all bootdevs
+ *
+ * @bm_node: Points to siblings in the same bootdev
+ * @glob_node: Points to siblings in the global list (all bootdev)
+ * @dev: Bootdevice device which produced this bootflow
+ * @blk: Block device which contains this bootflow, NULL if this is a network
+ * device
+ * @part: Partition number (0 for whole device)
+ * @fs_type: Filesystem type (FS_TYPE...) if this is fixed by the media, else 0.
+ * For example, the sandbox host-filesystem bootdev sets this to
+ * FS_TYPE_SANDBOX
+ * @method: Bootmethod device used to perform the boot and read files
+ * @name: Name of bootflow (allocated)
+ * @state: Current state (enum bootflow_state_t)
+ * @subdir: Subdirectory to fetch files from (with trailing /), or NULL if none
+ * @fname: Filename of bootflow file (allocated)
+ * @buf: Bootflow file contents (allocated)
+ * @size: Size of bootflow file in bytes
+ * @err: Error number received (0 if OK)
+ */
+struct bootflow {
+ struct list_head bm_node;
+ struct list_head glob_node;
+ struct udevice *dev;
+ struct udevice *blk;
+ int part;
+ int fs_type;
+ struct udevice *method;
+ char *name;
+ enum bootflow_state_t state;
+ char *subdir;
+ char *fname;
+ char *buf;
+ int size;
+ int err;
+};
+
+/**
+ * enum bootflow_flags_t - flags for the bootflow iterator
+ *
+ * @BOOTFLOWF_FIXED: Only used fixed/internal media
+ * @BOOTFLOWF_SHOW: Show each bootdev before scanning it
+ * @BOOTFLOWF_ALL: Return bootflows with errors as well
+ * @BOOTFLOWF_SINGLE_DEV: Just scan one bootmeth
+ */
+enum bootflow_flags_t {
+ BOOTFLOWF_FIXED = 1 << 0,
+ BOOTFLOWF_SHOW = 1 << 1,
+ BOOTFLOWF_ALL = 1 << 2,
+ BOOTFLOWF_SINGLE_DEV = 1 << 3,
+};
+
+/**
+ * struct bootflow_iter - state for iterating through bootflows
+ *
+ * This starts at with the first bootdev/partition/bootmeth and can be used to
+ * iterate through all of them.
+ *
+ * Iteration starts with the bootdev. The first partition (0, i.e. whole device)
+ * is scanned first. For partition 0, it iterates through all the available
+ * bootmeths to see which one(s) can provide a bootflow. Then it moves to
+ * parition 1 (if there is one) and the process continues. Once all partitions
+ * are examined, it moves to the next bootdev.
+ *
+ * Initially @max_part is 0, meaning that only the whole device (@part=0) can be
+ * used. During scanning, if a partition table is found, then @max_part is
+ * updated to a larger value, no less than the number of available partitions.
+ * This ensures that iteration works through all partitions on the bootdev.
+ *
+ * @flags: Flags to use (see enum bootflow_flags_t)
+ * @dev: Current bootdev
+ * @part: Current partition number (0 for whole device)
+ * @method: Current bootmeth
+ * @max_part: Maximum hardware partition number in @dev, 0 if there is no
+ * partition table
+ * @err: Error obtained from checking the last iteration. This is used to skip
+ * forward (e.g. to skip the current partition because it is not valid)
+ * -ESHUTDOWN: try next bootdev
+ * @num_devs: Number of bootdevs in @dev_order
+ * @cur_dev: Current bootdev number, an index into @dev_order[]
+ * @dev_order: List of bootdevs to scan, in order of priority. The scan starts
+ * with the first one on the list
+ * @num_methods: Number of bootmeth devices in @method_order
+ * @cur_method: Current method number, an index into @method_order
+ * @method_order: List of bootmeth devices to use, in order
+ */
+struct bootflow_iter {
+ int flags;
+ struct udevice *dev;
+ int part;
+ struct udevice *method;
+ int max_part;
+ int err;
+ int num_devs;
+ int cur_dev;
+ struct udevice **dev_order;
+ int num_methods;
+ int cur_method;
+ struct udevice **method_order;
+};
+
+/**
+ * bootflow_iter_init() - Reset a bootflow iterator
+ *
+ * This sets everything to the starting point, ready for use.
+ *
+ * @iter: Place to store private info (inited by this call)
+ * @flags: Flags to use (see enum bootflow_flags_t)
+ */
+void bootflow_iter_init(struct bootflow_iter *iter, int flags);
+
+/**
+ * bootflow_iter_uninit() - Free memory used by an interator
+ *
+ * @iter: Iterator to free
+ */
+void bootflow_iter_uninit(struct bootflow_iter *iter);
+
+/**
+ * bootflow_iter_drop_bootmeth() - Remove a bootmeth from an iterator
+ *
+ * Update the iterator so that the bootmeth will not be used again while this
+ * iterator is in use
+ *
+ * @iter: Iterator to update
+ * @bmeth: Boot method to remove
+ */
+int bootflow_iter_drop_bootmeth(struct bootflow_iter *iter,
+ const struct udevice *bmeth);
+
+/**
+ * bootflow_scan_bootdev() - find the first bootflow in a bootdev
+ *
+ * If @flags includes BOOTFLOWF_ALL then bootflows with errors are returned too
+ *
+ * @dev: Boot device to scan, NULL to work through all of them until it
+ * finds one that * can supply a bootflow
+ * @iter: Place to store private info (inited by this call)
+ * @flags: Flags for bootdev (enum bootflow_flags_t)
+ * @bflow: Place to put the bootflow if found
+ * Return: 0 if found, -ENODEV if no device, other -ve on other error
+ * (iteration can continue)
+ */
+int bootflow_scan_bootdev(struct udevice *dev, struct bootflow_iter *iter,
+ int flags, struct bootflow *bflow);
+
+/**
+ * bootflow_scan_first() - find the first bootflow
+ *
+ * This works through the available bootdev devices until it finds one that
+ * can supply a bootflow. It then returns that
+ *
+ * If @flags includes BOOTFLOWF_ALL then bootflows with errors are returned too
+ *
+ * @iter: Place to store private info (inited by this call), with
+ * @flags: Flags for bootdev (enum bootflow_flags_t)
+ * @bflow: Place to put the bootflow if found
+ * Return: 0 if found, -ENODEV if no device, other -ve on other error (iteration
+ * can continue)
+ */
+int bootflow_scan_first(struct bootflow_iter *iter, int flags,
+ struct bootflow *bflow);
+
+/**
+ * bootflow_scan_next() - find the next bootflow
+ *
+ * This works through the available bootdev devices until it finds one that
+ * can supply a bootflow. It then returns that bootflow
+ *
+ * @iter: Private info (as set up by bootflow_scan_first())
+ * @bflow: Place to put the bootflow if found
+ * Return: 0 if found, -ENODEV if no device, -ESHUTDOWN if no more bootflows,
+ * other -ve on other error (iteration can continue)
+ */
+int bootflow_scan_next(struct bootflow_iter *iter, struct bootflow *bflow);
+
+/**
+ * bootflow_first_glob() - Get the first bootflow from the global list
+ *
+ * Returns the first bootflow in the global list, no matter what bootflow it is
+ * attached to
+ *
+ * @bflowp: Returns a pointer to the bootflow
+ * Return: 0 if found, -ENOENT if there are no bootflows
+ */
+int bootflow_first_glob(struct bootflow **bflowp);
+
+/**
+ * bootflow_next_glob() - Get the next bootflow from the global list
+ *
+ * Returns the next bootflow in the global list, no matter what bootflow it is
+ * attached to
+ *
+ * @bflowp: On entry, the last bootflow returned , e.g. from
+ * bootflow_first_glob()
+ * Return: 0 if found, -ENOENT if there are no more bootflows
+ */
+int bootflow_next_glob(struct bootflow **bflowp);
+
+/**
+ * bootflow_free() - Free memory used by a bootflow
+ *
+ * This frees fields within @bflow, but not the @bflow pointer itself
+ */
+void bootflow_free(struct bootflow *bflow);
+
+/**
+ * bootflow_boot() - boot a bootflow
+ *
+ * @bflow: Bootflow to boot
+ * Return: -EPROTO if bootflow has not been loaded, -ENOSYS if the bootflow
+ * type is not supported, -EFAULT if the boot returned without an error
+ * when we are expecting it to boot, -ENOTSUPP if trying method resulted in
+ * finding out that is not actually supported for this boot and should not
+ * be tried again unless something changes
+ */
+int bootflow_boot(struct bootflow *bflow);
+
+/**
+ * bootflow_run_boot() - Try to boot a bootflow
+ *
+ * @iter: Current iteration (or NULL if none). Used to disable a bootmeth if the
+ * boot returns -ENOTSUPP
+ * @bflow: Bootflow to boot
+ * Return: result of trying to boot
+ */
+int bootflow_run_boot(struct bootflow_iter *iter, struct bootflow *bflow);
+
+/**
+ * bootflow_state_get_name() - Get the name of a bootflow state
+ *
+ * @state: State to check
+ * Return: name, or "?" if invalid
+ */
+const char *bootflow_state_get_name(enum bootflow_state_t state);
+
+/**
+ * bootflow_remove() - Remove a bootflow and free its memory
+ *
+ * This updates the linked lists containing the bootflow then frees it.
+ *
+ * @bflow: Bootflow to remove
+ */
+void bootflow_remove(struct bootflow *bflow);
+
+/**
+ * bootflow_iter_uses_blk_dev() - Check that a bootflow uses a block device
+ *
+ * This checks the bootdev in the bootflow to make sure it uses a block device
+ *
+ * Return: 0 if OK, -ENOTSUPP if some other device is used (e.g. ethernet)
+ */
+int bootflow_iter_uses_blk_dev(const struct bootflow_iter *iter);
+
+/**
+ * bootflow_iter_uses_network() - Check that a bootflow uses a network device
+ *
+ * This checks the bootdev in the bootflow to make sure it uses a network
+ * device
+ *
+ * Return: 0 if OK, -ENOTSUPP if some other device is used (e.g. MMC)
+ */
+int bootflow_iter_uses_network(const struct bootflow_iter *iter);
+
+/**
+ * bootflow_iter_uses_system() - Check that a bootflow uses the bootstd device
+ *
+ * This checks the bootdev in the bootflow to make sure it uses the bootstd
+ * device
+ *
+ * Return: 0 if OK, -ENOTSUPP if some other device is used (e.g. MMC)
+ */
+int bootflow_iter_uses_system(const struct bootflow_iter *iter);
+
+#endif
diff --git a/include/bootmeth.h b/include/bootmeth.h
new file mode 100644
index 00000000000..484e503e338
--- /dev/null
+++ b/include/bootmeth.h
@@ -0,0 +1,234 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2021 Google LLC
+ * Written by Simon Glass <sjg@chromium.org>
+ */
+
+#ifndef __bootmeth_h
+#define __bootmeth_h
+
+struct blk_desc;
+struct bootflow;
+struct bootflow_iter;
+struct udevice;
+
+/**
+ * struct bootmeth_uc_plat - information the uclass keeps about each bootmeth
+ *
+ * @desc: A long description of the bootmeth
+ */
+struct bootmeth_uc_plat {
+ const char *desc;
+};
+
+/** struct bootmeth_ops - Operations for boot methods */
+struct bootmeth_ops {
+ /**
+ * check_supported() - check if a bootmeth supports this bootflow
+ *
+ * This is optional. If not provided, the bootdev is assumed to be
+ * supported
+ *
+ * The bootmeth can check the bootdev (e.g. to make sure it is a
+ * network device) or the partition information. The following fields
+ * in @iter are available:
+ *
+ * name, dev, state, part
+ * max_part may be set if part != 0 (i.e. there is a valid partition
+ * table). Otherwise max_part is 0
+ * method is available but is the same as @dev
+ * the partition has not yet been read, nor has the filesystem been
+ * checked
+ *
+ * It may update only the flags in @iter
+ *
+ * @dev: Bootmethod device to check against
+ * @iter: On entry, provides bootdev, hwpart, part
+ * Return: 0 if OK, -ENOTSUPP if this bootdev is not supported
+ */
+ int (*check)(struct udevice *dev, struct bootflow_iter *iter);
+
+ /**
+ * read_bootflow() - read a bootflow for a device
+ *
+ * @dev: Bootmethod device to use
+ * @bflow: On entry, provides dev, hwpart, part and method.
+ * Returns updated bootflow if found
+ * Return: 0 if OK, -ve on error
+ */
+ int (*read_bootflow)(struct udevice *dev, struct bootflow *bflow);
+
+ /**
+ * read_file() - read a file needed for a bootflow
+ *
+ * Read a file from the same place as the bootflow came from
+ *
+ * @dev: Bootmethod device to use
+ * @bflow: Bootflow providing info on where to read from
+ * @file_path: Path to file (may be absolute or relative)
+ * @addr: Address to load file
+ * @sizep: On entry provides the maximum permitted size; on exit
+ * returns the size of the file
+ * Return: 0 if OK, -ENOSPC if the file is too large for @sizep, other
+ * -ve value if something else goes wrong
+ */
+ int (*read_file)(struct udevice *dev, struct bootflow *bflow,
+ const char *file_path, ulong addr, ulong *sizep);
+
+ /**
+ * boot() - boot a bootflow
+ *
+ * @dev: Bootmethod device to boot
+ * @bflow: Bootflow to boot
+ * Return: does not return on success, since it should boot the
+ * Operating Systemn. Returns -EFAULT if that fails, -ENOTSUPP if
+ * trying method resulted in finding out that is not actually
+ * supported for this boot and should not be tried again unless
+ * something changes, other -ve on other error
+ */
+ int (*boot)(struct udevice *dev, struct bootflow *bflow);
+};
+
+#define bootmeth_get_ops(dev) ((struct bootmeth_ops *)(dev)->driver->ops)
+
+/**
+ * bootmeth_check() - check if a bootmeth supports this bootflow
+ *
+ * This is optional. If not provided, the bootdev is assumed to be
+ * supported
+ *
+ * The bootmeth can check the bootdev (e.g. to make sure it is a
+ * network device) or the partition information. The following fields
+ * in @iter are available:
+ *
+ * name, dev, state, part
+ * max_part may be set if part != 0 (i.e. there is a valid partition
+ * table). Otherwise max_part is 0
+ * method is available but is the same as @dev
+ * the partition has not yet been read, nor has the filesystem been
+ * checked
+ *
+ * It may update only the flags in @iter
+ *
+ * @dev: Bootmethod device to check against
+ * @iter: On entry, provides bootdev, hwpart, part
+ * Return: 0 if OK, -ENOTSUPP if this bootdev is not supported
+ */
+int bootmeth_check(struct udevice *dev, struct bootflow_iter *iter);
+
+/**
+ * bootmeth_read_bootflow() - set up a bootflow for a device
+ *
+ * @dev: Bootmethod device to check
+ * @bflow: On entry, provides dev, hwpart, part and method.
+ * Returns updated bootflow if found
+ * Return: 0 if OK, -ve on error
+ */
+int bootmeth_read_bootflow(struct udevice *dev, struct bootflow *bflow);
+
+/**
+ * bootmeth_read_file() - read a file needed for a bootflow
+ *
+ * Read a file from the same place as the bootflow came from
+ *
+ * @dev: Bootmethod device to use
+ * @bflow: Bootflow providing info on where to read from
+ * @file_path: Path to file (may be absolute or relative)
+ * @addr: Address to load file
+ * @sizep: On entry provides the maximum permitted size; on exit
+ * returns the size of the file
+ * Return: 0 if OK, -ENOSPC if the file is too large for @sizep, other
+ * -ve value if something else goes wrong
+ */
+int bootmeth_read_file(struct udevice *dev, struct bootflow *bflow,
+ const char *file_path, ulong addr, ulong *sizep);
+
+/**
+ * bootmeth_boot() - boot a bootflow
+ *
+ * @dev: Bootmethod device to boot
+ * @bflow: Bootflow to boot
+ * Return: does not return on success, since it should boot the
+ * Operating Systemn. Returns -EFAULT if that fails, other -ve on
+ * other error
+ */
+int bootmeth_boot(struct udevice *dev, struct bootflow *bflow);
+
+/**
+ * bootmeth_setup_iter_order() - Set up the ordering of bootmeths to scan
+ *
+ * This sets up the ordering information in @iter, based on the selected
+ * ordering of the bootmethds in bootstd_priv->bootmeth_order. If there is no
+ * ordering there, then all bootmethods are added
+ *
+ * @iter: Iterator to update with the order
+ * Return: 0 if OK, -ENOENT if no bootdevs, -ENOMEM if out of memory, other -ve
+ * on other error
+ */
+int bootmeth_setup_iter_order(struct bootflow_iter *iter);
+
+/**
+ * bootmeth_set_order() - Set the bootmeth order
+ *
+ * This selects the ordering to use for bootmeths
+ *
+ * @order_str: String containing the ordering. This is a comma-separate list of
+ * bootmeth-device names, e.g. "syslinux,efi". If empty then a default ordering
+ * is used, based on the sequence number of devices (i.e. using aliases)
+ * Return: 0 if OK, -ENODEV if an unknown bootmeth is mentioned, -ENOMEM if
+ * out of memory, -ENOENT if there are no bootmeth devices
+ */
+int bootmeth_set_order(const char *order_str);
+
+/**
+ * bootmeth_try_file() - See we can access a given file
+ *
+ * Check for a file with a given name. If found, the filename is allocated in
+ * @bflow
+ *
+ * Sets the state to BOOTFLOWST_FILE on success. It also calls
+ * fs_set_blk_dev_with_part() so that this does not need to be done by the
+ * caller before reading the file.
+ *
+ * @bflow: Information about file to try
+ * @desc: Block descriptor to read from
+ * @prefix: Filename prefix to prepend to @fname (NULL for none)
+ * @fname: Filename to read
+ * Return: 0 if OK, -ENOMEM if not enough memory to allocate bflow->fname,
+ * other -ve value on other error
+ */
+int bootmeth_try_file(struct bootflow *bflow, struct blk_desc *desc,
+ const char *prefix, const char *fname);
+
+/**
+ * bootmeth_alloc_file() - Allocate and read a bootflow file
+ *
+ * Allocates memory for a bootflow file and reads it in. Sets the state to
+ * BOOTFLOWST_READY on success
+ *
+ * Note that fs_set_blk_dev_with_part() must have been called previously.
+ *
+ * @bflow: Information about file to read
+ * @size_limit: Maximum file size to permit
+ * @align: Allocation alignment (1 for unaligned)
+ * Return: 0 if OK, -E2BIG if file is too large, -ENOMEM if out of memory,
+ * other -ve on other error
+ */
+int bootmeth_alloc_file(struct bootflow *bflow, uint size_limit, uint align);
+
+/**
+ * bootmeth_common_read_file() - Common handler for reading a file
+ *
+ * Reads a named file from the same location as the bootflow file.
+ *
+ * @dev: bootmeth device to read from
+ * @bflow: Bootflow information
+ * @file_path: Path to file
+ * @addr: Address to load file to
+ * @sizep: On entry, the maximum file size to accept, on exit the actual file
+ * size read
+ */
+int bootmeth_common_read_file(struct udevice *dev, struct bootflow *bflow,
+ const char *file_path, ulong addr, ulong *sizep);
+
+#endif
diff --git a/include/bootstd.h b/include/bootstd.h
new file mode 100644
index 00000000000..b002365f4f0
--- /dev/null
+++ b/include/bootstd.h
@@ -0,0 +1,80 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Standard U-Boot boot framework
+ *
+ * Copyright 2021 Google LLC
+ * Written by Simon Glass <sjg@chromium.org>
+ */
+
+#ifndef __bootstd_h
+#define __bootstd_h
+
+struct udevice;
+
+/**
+ * struct bootstd_priv - priv data for the bootstd driver
+ *
+ * This is attached to the (only) bootstd device, so there is only one instance
+ * of this struct. It provides overall information about bootdevs and bootflows.
+ *
+ * @prefixes: NULL-terminated list of prefixes to use for bootflow filenames,
+ * e.g. "/", "/boot/"; NULL if none
+ * @bootdev_order: Order to use for bootdevs (or NULL if none), with each item
+ * being a bootdev label, e.g. "mmc2", "mmc1";
+ * @cur_bootdev: Currently selected bootdev (for commands)
+ * @cur_bootflow: Currently selected bootflow (for commands)
+ * @glob_head: Head for the global list of all bootflows across all bootdevs
+ * @bootmeth_count: Number of bootmeth devices in @bootmeth_order
+ * @bootmeth_order: List of bootmeth devices to use, in order, NULL-terminated
+ */
+struct bootstd_priv {
+ const char **prefixes;
+ const char **bootdev_order;
+ struct udevice *cur_bootdev;
+ struct bootflow *cur_bootflow;
+ struct list_head glob_head;
+ int bootmeth_count;
+ struct udevice **bootmeth_order;
+};
+
+/**
+ * bootstd_get_bootdev_order() - Get the boot-order list
+ *
+ * This reads the boot order, e.g. {"mmc0", "mmc2", NULL}
+ *
+ * The list is alloced by the bootstd driver so should not be freed. That is the
+ * reason for all the const stuff in the function signature
+ *
+ * Return: list of string points, terminated by NULL; or NULL if no boot order
+ */
+const char *const *const bootstd_get_bootdev_order(struct udevice *dev);
+
+/**
+ * bootstd_get_prefixes() - Get the filename-prefixes list
+ *
+ * This reads the prefixes, e.g. {"/", "/bpot", NULL}
+ *
+ * The list is alloced by the bootstd driver so should not be freed. That is the
+ * reason for all the const stuff in the function signature
+ *
+ * Return: list of string points, terminated by NULL; or NULL if no boot order
+ */
+const char *const *const bootstd_get_prefixes(struct udevice *dev);
+
+/**
+ * bootstd_get_priv() - Get the (single) state for the bootstd system
+ *
+ * The state holds a global list of all bootflows that have been found.
+ *
+ * Return: 0 if OK, -ve if the uclass does not exist
+ */
+int bootstd_get_priv(struct bootstd_priv **stdp);
+
+/**
+ * bootstd_clear_glob() - Clear the global list of bootflows
+ *
+ * This removes all bootflows globally and across all bootdevs.
+ */
+void bootstd_clear_glob(void);
+
+#endif
diff --git a/include/configs/adp-ae3xx.h b/include/configs/adp-ae3xx.h
deleted file mode 100644
index 7dd2dc4eb1c..00000000000
--- a/include/configs/adp-ae3xx.h
+++ /dev/null
@@ -1,186 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * Copyright (C) 2011 Andes Technology Corporation
- * Shawn Lin, Andes Technology Corporation <nobuhiro@andestech.com>
- * Macpaul Lin, Andes Technology Corporation <macpaul@andestech.com>
- */
-
-#ifndef __CONFIG_H
-#define __CONFIG_H
-
-#include <asm/arch-ae3xx/ae3xx.h>
-
-/*
- * CPU and Board Configuration Options
- */
-#define CONFIG_USE_INTERRUPT
-
-#define CONFIG_SKIP_TRUNOFF_WATCHDOG
-
-/*
- * Timer
- */
-#define VERSION_CLOCK get_board_sys_clk()
-
-/*
- * Use Externel CLOCK or PCLK
- */
-#undef CONFIG_FTRTC010_EXTCLK
-
-#ifndef CONFIG_FTRTC010_EXTCLK
-#define CONFIG_FTRTC010_PCLK
-#endif
-
-#ifdef CONFIG_FTRTC010_EXTCLK
-#define TIMER_CLOCK 32768 /* CONFIG_FTRTC010_EXTCLK */
-#else
-#define TIMER_CLOCK CONFIG_SYS_HZ /* CONFIG_FTRTC010_PCLK */
-#endif
-
-#define TIMER_LOAD_VAL 0xffffffff
-
-/*
- * Real Time Clock
- */
-#define CONFIG_RTC_FTRTC010
-
-/*
- * Real Time Clock Divider
- * RTC_DIV_COUNT (OSC_CLK/OSC_5MHZ)
- */
-#define OSC_5MHZ (5*1000000)
-#define OSC_CLK (4*OSC_5MHZ)
-#define RTC_DIV_COUNT (0.5) /* Why?? */
-
-/*
- * Serial console configuration
- */
-
-/* FTUART is a high speed NS 16C550A compatible UART, addr: 0x99600000 */
-#define CONFIG_SYS_NS16550_SERIAL
-#define CONFIG_SYS_NS16550_COM1 CONFIG_FTUART010_02_BASE
-#ifndef CONFIG_DM_SERIAL
-#define CONFIG_SYS_NS16550_REG_SIZE -4
-#endif
-#define CONFIG_SYS_NS16550_CLK ((18432000 * 20) / 25) /* AG101P */
-
-/*
- * Miscellaneous configurable options
- */
-
-/*
- * Size of malloc() pool
- */
-/* 512kB is suggested, (CONFIG_ENV_SIZE + 128 * 1024) was not enough */
-
-/*
- * Physical Memory Map
- */
-#define PHYS_SDRAM_0 0x00000000 /* SDRAM Bank #1 */
-
-#define PHYS_SDRAM_1 \
- (PHYS_SDRAM_0 + PHYS_SDRAM_0_SIZE) /* SDRAM Bank #2 */
-
-#define PHYS_SDRAM_0_SIZE 0x20000000 /* 512 MB */
-#define PHYS_SDRAM_1_SIZE 0x20000000 /* 512 MB */
-
-#define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM_0
-
-#define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_SDRAM_BASE + 0xA0000 - \
- GENERATED_GBL_DATA_SIZE)
-
-/*
- * Static memory controller configuration
- */
-#define CONFIG_FTSMC020
-
-#ifdef CONFIG_FTSMC020
-#include <faraday/ftsmc020.h>
-
-#define CONFIG_SYS_FTSMC020_CONFIGS { \
- { FTSMC020_BANK0_CONFIG, FTSMC020_BANK0_TIMING, }, \
- { FTSMC020_BANK1_CONFIG, FTSMC020_BANK1_TIMING, }, \
-}
-
-#ifndef CONFIG_SKIP_LOWLEVEL_INIT /* FLASH is on BANK 0 */
-#define FTSMC020_BANK0_LOWLV_CONFIG (FTSMC020_BANK_ENABLE | \
- FTSMC020_BANK_SIZE_32M | \
- FTSMC020_BANK_MBW_32)
-
-#define FTSMC020_BANK0_LOWLV_TIMING (FTSMC020_TPR_RBE | \
- FTSMC020_TPR_AST(1) | \
- FTSMC020_TPR_CTW(1) | \
- FTSMC020_TPR_ATI(1) | \
- FTSMC020_TPR_AT2(1) | \
- FTSMC020_TPR_WTC(1) | \
- FTSMC020_TPR_AHT(1) | \
- FTSMC020_TPR_TRNA(1))
-#endif
-
-/*
- * FLASH on ADP_AG101P is connected to BANK0
- * Just disalbe the other BANK to avoid detection error.
- */
-#define FTSMC020_BANK0_CONFIG (FTSMC020_BANK_ENABLE | \
- FTSMC020_BANK_BASE(PHYS_FLASH_1) | \
- FTSMC020_BANK_SIZE_32M | \
- FTSMC020_BANK_MBW_32)
-
-#define FTSMC020_BANK0_TIMING (FTSMC020_TPR_AST(3) | \
- FTSMC020_TPR_CTW(3) | \
- FTSMC020_TPR_ATI(0xf) | \
- FTSMC020_TPR_AT2(3) | \
- FTSMC020_TPR_WTC(3) | \
- FTSMC020_TPR_AHT(3) | \
- FTSMC020_TPR_TRNA(0xf))
-
-#define FTSMC020_BANK1_CONFIG (0x00)
-#define FTSMC020_BANK1_TIMING (0x00)
-#endif /* CONFIG_FTSMC020 */
-
-/*
- * FLASH and environment organization
- */
-/* use CFI framework */
-
-#define CONFIG_SYS_FLASH_CFI_WIDTH FLASH_CFI_16BIT
-#define CONFIG_SYS_CFI_FLASH_STATUS_POLL
-
-/* support JEDEC */
-
-/* Do not use CONFIG_FLASH_CFI_LEGACY to detect on board flash */
-#define PHYS_FLASH_1 0x88000000 /* BANK 0 */
-#define CONFIG_SYS_FLASH_BASE PHYS_FLASH_1
-#define CONFIG_SYS_FLASH_BANKS_LIST { PHYS_FLASH_1, }
-
-#define CONFIG_SYS_FLASH_ERASE_TOUT 120000 /* TO for Flash Erase (ms) */
-#define CONFIG_SYS_FLASH_WRITE_TOUT 500 /* TO for Flash Write (ms) */
-
-/* max number of memory banks */
-/*
- * There are 4 banks supported for this Controller,
- * but we have only 1 bank connected to flash on board
- */
-#define CONFIG_SYS_FLASH_BANKS_SIZES {0x4000000}
-
-/* max number of sectors on one chip */
-#define CONFIG_FLASH_SECTOR_SIZE (0x10000*2)
-#define CONFIG_SYS_MAX_FLASH_SECT 512
-
-/* environments */
-
-
-/* SPI FLASH */
-
-/*
- * For booting Linux, the board info and command line data
- * have to be in the first 16 MB of memory, since this is
- * the maximum mapped by the Linux kernel during initialization.
- */
-
-/* Initial Memory map for Linux*/
-#define CONFIG_SYS_BOOTMAPSZ (64 << 20)
-/* Increase max gunzip size */
-#define CONFIG_SYS_BOOTM_LEN (64 << 20)
-
-#endif /* __CONFIG_H */
diff --git a/include/configs/adp-ag101p.h b/include/configs/adp-ag101p.h
deleted file mode 100644
index 3766081c1b8..00000000000
--- a/include/configs/adp-ag101p.h
+++ /dev/null
@@ -1,299 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * Copyright (C) 2011 Andes Technology Corporation
- * Shawn Lin, Andes Technology Corporation <nobuhiro@andestech.com>
- * Macpaul Lin, Andes Technology Corporation <macpaul@andestech.com>
- */
-
-#ifndef __CONFIG_H
-#define __CONFIG_H
-
-#include <asm/arch-ag101/ag101.h>
-
-/*
- * CPU and Board Configuration Options
- */
-#define CONFIG_USE_INTERRUPT
-
-#ifndef CONFIG_SKIP_LOWLEVEL_INIT
-#define CONFIG_MEM_REMAP
-#endif
-
-/*
- * Timer
- */
-#define VERSION_CLOCK get_board_sys_clk()
-
-/*
- * Use Externel CLOCK or PCLK
- */
-#undef CONFIG_FTRTC010_EXTCLK
-
-#ifndef CONFIG_FTRTC010_EXTCLK
-#define CONFIG_FTRTC010_PCLK
-#endif
-
-#ifdef CONFIG_FTRTC010_EXTCLK
-#define TIMER_CLOCK 32768 /* CONFIG_FTRTC010_EXTCLK */
-#else
-#define TIMER_CLOCK CONFIG_SYS_HZ /* CONFIG_FTRTC010_PCLK */
-#endif
-
-#define TIMER_LOAD_VAL 0xffffffff
-
-/*
- * Real Time Clock
- */
-#define CONFIG_RTC_FTRTC010
-
-/*
- * Real Time Clock Divider
- * RTC_DIV_COUNT (OSC_CLK/OSC_5MHZ)
- */
-#define OSC_5MHZ (5*1000000)
-#define OSC_CLK (4*OSC_5MHZ)
-#define RTC_DIV_COUNT (0.5) /* Why?? */
-
-/*
- * Serial console configuration
- */
-
-/* FTUART is a high speed NS 16C550A compatible UART, addr: 0x99600000 */
-#define CONFIG_SYS_NS16550_SERIAL
-#define CONFIG_SYS_NS16550_COM1 CONFIG_FTUART010_02_BASE
-#ifndef CONFIG_DM_SERIAL
-#define CONFIG_SYS_NS16550_REG_SIZE -4
-#endif
-#define CONFIG_SYS_NS16550_CLK ((18432000 * 20) / 25) /* AG101P */
-
-/*
- * Miscellaneous configurable options
- */
-
-/*
- * AHB Controller configuration
- */
-#define CONFIG_FTAHBC020S
-
-#ifdef CONFIG_FTAHBC020S
-#include <faraday/ftahbc020s.h>
-
-/* Address of PHYS_SDRAM_0 before memory remap is at 0x(100)00000 */
-#define CONFIG_SYS_FTAHBC020S_SLAVE_BSR_BASE 0x100
-
-/*
- * CONFIG_SYS_FTAHBC020S_SLAVE_BSR_6: this define is used in lowlevel_init.S,
- * hence we cannot use FTAHBC020S_BSR_SIZE(2048) since it will use ffs() wrote
- * in C language.
- */
-#define CONFIG_SYS_FTAHBC020S_SLAVE_BSR_6 \
- (FTAHBC020S_SLAVE_BSR_BASE(CONFIG_SYS_FTAHBC020S_SLAVE_BSR_BASE) | \
- FTAHBC020S_SLAVE_BSR_SIZE(0xb))
-#endif
-
-/*
- * Watchdog
- */
-#define CONFIG_FTWDT010_WATCHDOG
-
-/*
- * PMU Power controller configuration
- */
-#define CONFIG_PMU
-#define CONFIG_FTPMU010_POWER
-
-#ifdef CONFIG_FTPMU010_POWER
-#include <faraday/ftpmu010.h>
-#define CONFIG_SYS_FTPMU010_PDLLCR0_HCLKOUTDIS 0x0E
-#define CONFIG_SYS_FTPMU010_SDRAMHTC (FTPMU010_SDRAMHTC_EBICTRL_DCSR | \
- FTPMU010_SDRAMHTC_EBIDATA_DCSR | \
- FTPMU010_SDRAMHTC_SDRAMCS_DCSR | \
- FTPMU010_SDRAMHTC_SDRAMCTL_DCSR | \
- FTPMU010_SDRAMHTC_CKE_DCSR | \
- FTPMU010_SDRAMHTC_DQM_DCSR | \
- FTPMU010_SDRAMHTC_SDCLK_DCSR)
-#endif
-
-/*
- * SDRAM controller configuration
- */
-#define CONFIG_FTSDMC021
-
-#ifdef CONFIG_FTSDMC021
-#include <faraday/ftsdmc021.h>
-
-#define CONFIG_SYS_FTSDMC021_TP1 (FTSDMC021_TP1_TRAS(2) | \
- FTSDMC021_TP1_TRP(1) | \
- FTSDMC021_TP1_TRCD(1) | \
- FTSDMC021_TP1_TRF(3) | \
- FTSDMC021_TP1_TWR(1) | \
- FTSDMC021_TP1_TCL(2))
-
-#define CONFIG_SYS_FTSDMC021_TP2 (FTSDMC021_TP2_INI_PREC(4) | \
- FTSDMC021_TP2_INI_REFT(8) | \
- FTSDMC021_TP2_REF_INTV(0x180))
-
-/*
- * CONFIG_SYS_FTSDMC021_CR1: this define is used in lowlevel_init.S,
- * hence we cannot use FTSDMC021_BANK_SIZE(64) since it will use ffs() wrote in
- * C language.
- */
-#define CONFIG_SYS_FTSDMC021_CR1 (FTSDMC021_CR1_DDW(2) | \
- FTSDMC021_CR1_DSZ(3) | \
- FTSDMC021_CR1_MBW(2) | \
- FTSDMC021_CR1_BNKSIZE(6))
-
-#define CONFIG_SYS_FTSDMC021_CR2 (FTSDMC021_CR2_IPREC | \
- FTSDMC021_CR2_IREF | \
- FTSDMC021_CR2_ISMR)
-
-#define CONFIG_SYS_FTSDMC021_BANK0_BASE CONFIG_SYS_FTAHBC020S_SLAVE_BSR_BASE
-#define CONFIG_SYS_FTSDMC021_BANK0_BSR (FTSDMC021_BANK_ENABLE | \
- CONFIG_SYS_FTSDMC021_BANK0_BASE)
-
-#define CONFIG_SYS_FTSDMC021_BANK1_BASE \
- (CONFIG_SYS_FTAHBC020S_SLAVE_BSR_BASE + (PHYS_SDRAM_0_SIZE >> 20))
-#define CONFIG_SYS_FTSDMC021_BANK1_BSR (FTSDMC021_BANK_ENABLE | \
- CONFIG_SYS_FTSDMC021_BANK1_BASE)
-#endif
-
-/*
- * Physical Memory Map
- */
-#ifdef CONFIG_SKIP_LOWLEVEL_INIT
-#define PHYS_SDRAM_0 0x00000000 /* SDRAM Bank #1 */
-#else
-#ifdef CONFIG_MEM_REMAP
-#define PHYS_SDRAM_0 0x00000000 /* SDRAM Bank #1 */
-#else
-#define PHYS_SDRAM_0 0x80000000 /* SDRAM Bank #1 */
-#endif
-#endif
-
-#define PHYS_SDRAM_1 \
- (PHYS_SDRAM_0 + PHYS_SDRAM_0_SIZE) /* SDRAM Bank #2 */
-
-#ifdef CONFIG_SKIP_LOWLEVEL_INIT
-#define PHYS_SDRAM_0_SIZE 0x20000000 /* 512 MB */
-#define PHYS_SDRAM_1_SIZE 0x20000000 /* 512 MB */
-#else
-#ifdef CONFIG_MEM_REMAP
-#define PHYS_SDRAM_0_SIZE 0x20000000 /* 512 MB */
-#define PHYS_SDRAM_1_SIZE 0x20000000 /* 512 MB */
-#else
-#define PHYS_SDRAM_0_SIZE 0x08000000 /* 128 MB */
-#define PHYS_SDRAM_1_SIZE 0x08000000 /* 128 MB */
-#endif
-#endif
-
-#define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM_0
-
-#ifdef CONFIG_MEM_REMAP
-#define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_SDRAM_BASE + 0xA0000 - \
- GENERATED_GBL_DATA_SIZE)
-#else
-#define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_SDRAM_BASE + 0x1000 - \
- GENERATED_GBL_DATA_SIZE)
-#endif /* CONFIG_MEM_REMAP */
-
-/*
- * Static memory controller configuration
- */
-#define CONFIG_FTSMC020
-
-#ifdef CONFIG_FTSMC020
-#include <faraday/ftsmc020.h>
-
-#define CONFIG_SYS_FTSMC020_CONFIGS { \
- { FTSMC020_BANK0_CONFIG, FTSMC020_BANK0_TIMING, }, \
- { FTSMC020_BANK1_CONFIG, FTSMC020_BANK1_TIMING, }, \
-}
-
-#ifndef CONFIG_SKIP_LOWLEVEL_INIT /* FLASH is on BANK 0 */
-#define FTSMC020_BANK0_LOWLV_CONFIG (FTSMC020_BANK_ENABLE | \
- FTSMC020_BANK_SIZE_32M | \
- FTSMC020_BANK_MBW_32)
-
-#define FTSMC020_BANK0_LOWLV_TIMING (FTSMC020_TPR_RBE | \
- FTSMC020_TPR_AST(1) | \
- FTSMC020_TPR_CTW(1) | \
- FTSMC020_TPR_ATI(1) | \
- FTSMC020_TPR_AT2(1) | \
- FTSMC020_TPR_WTC(1) | \
- FTSMC020_TPR_AHT(1) | \
- FTSMC020_TPR_TRNA(1))
-#endif
-
-/*
- * FLASH on ADP_AG101P is connected to BANK0
- * Just disalbe the other BANK to avoid detection error.
- */
-#define FTSMC020_BANK0_CONFIG (FTSMC020_BANK_ENABLE | \
- FTSMC020_BANK_BASE(PHYS_FLASH_1) | \
- FTSMC020_BANK_SIZE_32M | \
- FTSMC020_BANK_MBW_32)
-
-#define FTSMC020_BANK0_TIMING (FTSMC020_TPR_AST(3) | \
- FTSMC020_TPR_CTW(3) | \
- FTSMC020_TPR_ATI(0xf) | \
- FTSMC020_TPR_AT2(3) | \
- FTSMC020_TPR_WTC(3) | \
- FTSMC020_TPR_AHT(3) | \
- FTSMC020_TPR_TRNA(0xf))
-
-#define FTSMC020_BANK1_CONFIG (0x00)
-#define FTSMC020_BANK1_TIMING (0x00)
-#endif /* CONFIG_FTSMC020 */
-
-/*
- * FLASH and environment organization
- */
-/* use CFI framework */
-
-#define CONFIG_SYS_FLASH_CFI_WIDTH FLASH_CFI_16BIT
-#define CONFIG_SYS_CFI_FLASH_STATUS_POLL
-
-/* support JEDEC */
-
-/* Do not use CONFIG_FLASH_CFI_LEGACY to detect on board flash */
-#ifdef CONFIG_SKIP_LOWLEVEL_INIT
-#define PHYS_FLASH_1 0x80000000 /* BANK 0 */
-#else
-#ifdef CONFIG_MEM_REMAP
-#define PHYS_FLASH_1 0x80000000 /* BANK 0 */
-#else
-#define PHYS_FLASH_1 0x00000000 /* BANK 0 */
-#endif
-#endif /* CONFIG_MEM_REMAP */
-
-#define CONFIG_SYS_FLASH_BASE PHYS_FLASH_1
-#define CONFIG_SYS_FLASH_BANKS_LIST { PHYS_FLASH_1, }
-
-#define CONFIG_SYS_FLASH_ERASE_TOUT 120000 /* TO for Flash Erase (ms) */
-#define CONFIG_SYS_FLASH_WRITE_TOUT 500 /* TO for Flash Write (ms) */
-
-/* max number of memory banks */
-/*
- * There are 4 banks supported for this Controller,
- * but we have only 1 bank connected to flash on board
- */
-#define CONFIG_SYS_FLASH_BANKS_SIZES {0x4000000}
-
-/* max number of sectors on one chip */
-#define CONFIG_FLASH_SECTOR_SIZE (0x10000*2)
-#define CONFIG_SYS_MAX_FLASH_SECT 512
-
-/* environments */
-
-/*
- * For booting Linux, the board info and command line data
- * have to be in the first 16 MB of memory, since this is
- * the maximum mapped by the Linux kernel during initialization.
- */
-
-/* Initial Memory map for Linux*/
-#define CONFIG_SYS_BOOTMAPSZ (64 << 20)
-/* Increase max gunzip size */
-#define CONFIG_SYS_BOOTM_LEN (64 << 20)
-
-#endif /* __CONFIG_H */
diff --git a/include/configs/at91-sama5_common.h b/include/configs/at91-sama5_common.h
index 669a8ec7c7a..4631acfd664 100644
--- a/include/configs/at91-sama5_common.h
+++ b/include/configs/at91-sama5_common.h
@@ -15,15 +15,4 @@
#define CONFIG_SYS_AT91_SLOW_CLOCK 32768
#define CONFIG_SYS_AT91_MAIN_CLOCK 12000000 /* from 12 MHz crystal */
-#ifdef CONFIG_SD_BOOT
-#else
-
-#ifdef CONFIG_NAND_BOOT
-/* u-boot env in nand flash */
-#elif CONFIG_SPI_BOOT
-/* u-boot env in serial flash, by default is bus 0 and cs 0 */
-#endif
-
-#endif
-
#endif
diff --git a/include/configs/at91sam9m10g45ek.h b/include/configs/at91sam9m10g45ek.h
index 014a7c98fcc..38b9061080a 100644
--- a/include/configs/at91sam9m10g45ek.h
+++ b/include/configs/at91sam9m10g45ek.h
@@ -40,12 +40,6 @@
#endif
-#ifdef CONFIG_NAND_BOOT
-/* bootstrap + u-boot + env in nandflash */
-#elif CONFIG_SD_BOOT
-/* bootstrap + u-boot + env + linux in mmc */
-#endif
-
/* Defines for SPL */
#define CONFIG_SPL_MAX_SIZE 0x010000
#define CONFIG_SPL_STACK 0x310000
diff --git a/include/configs/at91sam9n12ek.h b/include/configs/at91sam9n12ek.h
index cd7c271cdc7..7d378177b04 100644
--- a/include/configs/at91sam9n12ek.h
+++ b/include/configs/at91sam9n12ek.h
@@ -59,15 +59,6 @@
#define CONFIG_SYS_USB_OHCI_MAX_ROOT_PORTS 1
#endif
-#ifdef CONFIG_SPI_BOOT
-
-/* bootstrap + u-boot + env + linux in dataflash on CS0 */
-
-#elif defined(CONFIG_NAND_BOOT)
-
-/* bootstrap + u-boot + env + linux in nandflash */
-#endif
-
/* SPL */
#define CONFIG_SPL_MAX_SIZE 0x6000
#define CONFIG_SPL_STACK 0x308000
diff --git a/include/configs/sam9x60_curiosity.h b/include/configs/sam9x60_curiosity.h
new file mode 100644
index 00000000000..2708711a4eb
--- /dev/null
+++ b/include/configs/sam9x60_curiosity.h
@@ -0,0 +1,31 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Configuration settings for the SAM9X60 CURIOSITY board.
+ *
+ * Copyright (C) 2022 Microchip Technology Inc. and its subsidiaries
+ *
+ * Author: Durai Manickam KR <durai.manickamkr@microchip.com>
+ */
+
+#ifndef __CONFIG_H__
+#define __CONFIG_H__
+
+#define CONFIG_SYS_AT91_SLOW_CLOCK 32768
+#define CONFIG_SYS_AT91_MAIN_CLOCK 24000000 /* 24 MHz crystal */
+
+#define CONFIG_USART_BASE ATMEL_BASE_DBGU
+#define CONFIG_USART_ID 0 /* ignored in arm */
+
+/* SDRAM */
+#define CONFIG_SYS_SDRAM_BASE 0x20000000
+#define CONFIG_SYS_SDRAM_SIZE 0x8000000 /* 128 MB */
+
+#ifdef CONFIG_SPL_BUILD
+#define CONFIG_SYS_INIT_SP_ADDR 0x218000
+#else
+#define CONFIG_SYS_INIT_SP_ADDR \
+ (CONFIG_SYS_SDRAM_BASE + 16 * 1024 + CONFIG_SYS_MALLOC_F_LEN - \
+ GENERATED_GBL_DATA_SIZE)
+#endif
+
+#endif
diff --git a/include/configs/sam9x60ek.h b/include/configs/sam9x60ek.h
index 772805d6242..c965fcb4e8f 100644
--- a/include/configs/sam9x60ek.h
+++ b/include/configs/sam9x60ek.h
@@ -40,14 +40,4 @@
#define CONFIG_SYS_NAND_READY_PIN AT91_PIN_PD5
#endif
-#ifdef CONFIG_SD_BOOT
-/* bootstrap + u-boot + env + linux in sd card */
-
-#elif defined(CONFIG_NAND_BOOT)
-/* bootstrap + u-boot + env + linux in nandflash */
-
-#elif defined(CONFIG_QSPI_BOOT)
-/* bootstrap + u-boot + env + linux in SPI NOR flash */
-#endif
-
#endif
diff --git a/include/configs/sama5d27_som1_ek.h b/include/configs/sama5d27_som1_ek.h
index f7d8fb63527..b9144584e3e 100644
--- a/include/configs/sama5d27_som1_ek.h
+++ b/include/configs/sama5d27_som1_ek.h
@@ -21,10 +21,6 @@
(0x22000000 + 16 * 1024 - GENERATED_GBL_DATA_SIZE)
#endif
-#ifdef CONFIG_SD_BOOT
-/* bootstrap + u-boot + env in sd card */
-#endif
-
/* SPL */
#define CONFIG_SPL_MAX_SIZE 0x10000
#define CONFIG_SPL_BSS_START_ADDR 0x20000000
diff --git a/include/configs/sama5d2_xplained.h b/include/configs/sama5d2_xplained.h
index 11c13c65d8d..cab6ae50698 100644
--- a/include/configs/sama5d2_xplained.h
+++ b/include/configs/sama5d2_xplained.h
@@ -18,18 +18,6 @@
(0x22000000 + 16 * 1024 - GENERATED_GBL_DATA_SIZE)
#endif
-/* SerialFlash */
-
-#ifdef CONFIG_SD_BOOT
-
-/* bootstrap + u-boot + env in sd card */
-
-#elif CONFIG_SPI_BOOT
-
-/* bootstrap + u-boot + env in sd card, but kernel + dtb in eMMC */
-
-#endif
-
/* SPL */
#define CONFIG_SPL_MAX_SIZE 0x10000
#define CONFIG_SPL_BSS_START_ADDR 0x20000000
diff --git a/include/distro.h b/include/distro.h
new file mode 100644
index 00000000000..2ee145871b2
--- /dev/null
+++ b/include/distro.h
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2021 Google LLC
+ * Written by Simon Glass <sjg@chromium.org>
+ */
+
+#ifndef __distro_h
+#define __distro_h
+
+#define DISTRO_FNAME "extlinux/extlinux.conf"
+
+/**
+ * struct distro_info - useful information for distro_getfile()
+ *
+ * @dev: bootmethod device being used to boot
+ * @bflow: bootflow being booted
+ */
+struct distro_info {
+ struct udevice *dev;
+ struct bootflow *bflow;
+ struct cmd_tbl *cmdtp;
+};
+
+#endif
diff --git a/include/dm/device.h b/include/dm/device.h
index e0f86f5df9f..b474888d025 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -799,7 +799,7 @@ int device_find_first_child_by_uclass(const struct udevice *parent,
struct udevice **devp);
/**
- * device_find_child_by_name() - Find a child by device name
+ * device_find_child_by_namelen() - Find a child by device name
*
* @parent: Parent device to search
* @name: Name to look for
diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h
index 0e26e1d1382..3ba69ad9a08 100644
--- a/include/dm/uclass-id.h
+++ b/include/dm/uclass-id.h
@@ -38,6 +38,9 @@ enum uclass_id {
UCLASS_AXI, /* AXI bus */
UCLASS_BLK, /* Block device */
UCLASS_BOOTCOUNT, /* Bootcount backing store */
+ UCLASS_BOOTDEV, /* Boot device for locating an OS to boot */
+ UCLASS_BOOTMETH, /* Bootmethod for booting an OS */
+ UCLASS_BOOTSTD, /* Standard boot driver */
UCLASS_BUTTON, /* Button */
UCLASS_CACHE, /* Cache controller */
UCLASS_CLK, /* Clock source, e.g. used by peripherals */
@@ -83,6 +86,7 @@ enum uclass_id {
UCLASS_P2SB, /* (x86) Primary-to-Sideband Bus */
UCLASS_PANEL, /* Display panel, such as an LCD */
UCLASS_PANEL_BACKLIGHT, /* Backlight controller for panel */
+ UCLASS_PARTITION, /* Logical disk partition device */
UCLASS_PCH, /* x86 platform controller hub */
UCLASS_PCI, /* PCI bus */
UCLASS_PCI_EP, /* PCI endpoint device */
diff --git a/include/dm/uclass-internal.h b/include/dm/uclass-internal.h
index daf856c03cf..3ddcdd21439 100644
--- a/include/dm/uclass-internal.h
+++ b/include/dm/uclass-internal.h
@@ -155,6 +155,22 @@ int uclass_find_first_device(enum uclass_id id, struct udevice **devp);
int uclass_find_next_device(struct udevice **devp);
/**
+ * uclass_find_device_by_namelen() - Find uclass device based on ID and name
+ *
+ * This searches for a device with the exactly given name.
+ *
+ * The device is NOT probed, it is merely returned.
+ *
+ * @id: ID to look up
+ * @name: name of a device to find
+ * @len: Length of @name (the uclass driver name must have the same length)
+ * @devp: Returns pointer to device (the first one with the name)
+ * Return: 0 if OK, -ve on error
+ */
+int uclass_find_device_by_namelen(enum uclass_id id, const char *name, int len,
+ struct udevice **devp);
+
+/**
* uclass_find_device_by_name() - Find uclass device based on ID and name
*
* This searches for a device with the exactly given name.
diff --git a/include/dm/uclass.h b/include/dm/uclass.h
index aafe6522886..f6c0110b061 100644
--- a/include/dm/uclass.h
+++ b/include/dm/uclass.h
@@ -173,13 +173,13 @@ int uclass_get(enum uclass_id key, struct uclass **ucp);
const char *uclass_get_name(enum uclass_id id);
/**
- * uclass_get_by_name_len() - Look up a uclass by its partial driver name
+ * uclass_get_by_namelen() - Look up a uclass by its driver name
*
* @name: Name to look up
- * @len: Length of the partial name
+ * @len: Length of @name (the uclass driver name must have the same length)
* Return: the associated uclass ID, or UCLASS_INVALID if not found
*/
-enum uclass_id uclass_get_by_name_len(const char *name, int len);
+enum uclass_id uclass_get_by_namelen(const char *name, int len);
/**
* uclass_get_by_name() - Look up a uclass by its driver name
diff --git a/include/efi_loader.h b/include/efi_loader.h
index c52ea59ec7a..ba79a9afb40 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -493,6 +493,8 @@ struct efi_register_notify_event {
/* List of all events registered by RegisterProtocolNotify() */
extern struct list_head efi_register_notify_events;
+/* called at pre-initialization */
+int efi_init_early(void);
/* Initialize efi execution environment */
efi_status_t efi_init_obj_list(void);
/* Install device tree */
@@ -523,8 +525,8 @@ void efi_carve_out_dt_rsv(void *fdt);
void efi_try_purge_kaslr_seed(void *fdt);
/* Called by bootefi to make console interface available */
efi_status_t efi_console_register(void);
-/* Called by bootefi to make all disk storage accessible as EFI objects */
-efi_status_t efi_disk_register(void);
+/* Called by efi_init_obj_list() to initialize efi_disks */
+efi_status_t efi_disk_init(void);
/* Called by efi_init_obj_list() to install EFI_RNG_PROTOCOL */
efi_status_t efi_rng_register(void);
/* Called by efi_init_obj_list() to install EFI_TCG2_PROTOCOL */
diff --git a/include/env_callback.h b/include/env_callback.h
index 05e9516a0f4..d5d2b2fcad6 100644
--- a/include/env_callback.h
+++ b/include/env_callback.h
@@ -57,6 +57,12 @@
#define NET_CALLBACKS
#endif
+#ifdef CONFIG_BOOTSTD
+#define BOOTSTD_CALLBACK "bootmeths:bootmeths,"
+#else
+#define BOOTSTD_CALLBACK
+#endif
+
/*
* This list of callback bindings is static, but may be overridden by defining
* a new association in the ".callbacks" environment variable.
@@ -65,6 +71,7 @@
ENV_DOT_ESCAPE ENV_FLAGS_VAR ":flags," \
"baudrate:baudrate," \
NET_CALLBACKS \
+ BOOTSTD_CALLBACK \
"loadaddr:loadaddr," \
SILENT_CALLBACK \
SPLASHIMAGE_CALLBACK \
diff --git a/include/fs.h b/include/fs.h
index e2beba36b98..b43f16a692f 100644
--- a/include/fs.h
+++ b/include/fs.h
@@ -57,6 +57,17 @@ int do_ext2load(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
*/
int fs_set_blk_dev(const char *ifname, const char *dev_part_str, int fstype);
+/**
+ * fs_set_type() - Tell fs layer which filesystem type is used
+ *
+ * This is needed when reading from a non-block device such as sandbox. It does
+ * a similar job to fs_set_blk_dev() but just sets the filesystem type instead
+ * of detecting it and loading it on the block device
+ *
+ * @type: Filesystem type to use (FS_TYPE...)
+ */
+void fs_set_type(int type);
+
/*
* fs_set_blk_dev_with_part - Set current block device + partition
*
diff --git a/include/mmc.h b/include/mmc.h
index 6bdcce881dd..9b4dc683110 100644
--- a/include/mmc.h
+++ b/include/mmc.h
@@ -956,11 +956,21 @@ int mmc_get_env_dev(void);
* mmc_get_blk_desc() - Get the block descriptor for an MMC device
*
* @mmc: MMC device
- * Return: block device if found, else NULL
+ * Return: block descriptor if found, else NULL
*/
struct blk_desc *mmc_get_blk_desc(struct mmc *mmc);
/**
+ * mmc_get_blk() - Get the block device for an MMC device
+ *
+ * @dev: MMC device
+ * @blkp: Returns pointer to probed block device on sucesss
+ *
+ * Return: 0 on success, -ve on error
+ */
+int mmc_get_blk(struct udevice *dev, struct udevice **blkp);
+
+/**
* mmc_send_ext_csd() - read the extended CSD register
*
* @mmc: MMC device
diff --git a/include/part.h b/include/part.h
index 53cfbdd8767..3a6958dcb2a 100644
--- a/include/part.h
+++ b/include/part.h
@@ -10,6 +10,7 @@
#include <ide.h>
#include <uuid.h>
#include <linker_lists.h>
+#include <linux/errno.h>
#include <linux/list.h>
struct block_drvr {
@@ -86,7 +87,7 @@ struct disk_part {
};
/* Misc _get_dev functions */
-#ifdef CONFIG_PARTITIONS
+#if CONFIG_IS_ENABLED(PARTITIONS)
/**
* blk_get_dev() - get a pointer to a block device given its type and number
*
@@ -103,7 +104,6 @@ struct disk_part {
struct blk_desc *blk_get_dev(const char *ifname, int dev);
struct blk_desc *mg_disk_get_dev(int dev);
-int host_get_dev_err(int dev, struct blk_desc **blk_devp);
/* disk/part.c */
int part_get_info(struct blk_desc *dev_desc, int part,
@@ -275,6 +275,22 @@ static inline int blk_get_device_part_str(const char *ifname,
struct disk_partition *info,
int allow_whole_dev)
{ *dev_desc = NULL; return -1; }
+
+static inline int part_get_info_by_name_type(struct blk_desc *dev_desc,
+ const char *name,
+ struct disk_partition *info,
+ int part_type)
+{
+ return -ENOENT;
+}
+
+static inline int part_get_info_by_name(struct blk_desc *dev_desc,
+ const char *name,
+ struct disk_partition *info)
+{
+ return -ENOENT;
+}
+
static inline int
part_get_info_by_dev_and_name_or_num(const char *dev_iface,
const char *dev_part_str,
@@ -287,6 +303,23 @@ part_get_info_by_dev_and_name_or_num(const char *dev_iface,
}
#endif
+struct udevice;
+/**
+ * part_create_block_devices - Create block devices for disk partitions
+ *
+ * Create UCLASS_PARTITION udevices for each of disk partitions in @parent
+ *
+ * @blk_dev: Whole disk device
+ */
+int part_create_block_devices(struct udevice *blk_dev);
+
+unsigned long dev_read(struct udevice *dev, lbaint_t start,
+ lbaint_t blkcnt, void *buffer);
+unsigned long dev_write(struct udevice *dev, lbaint_t start,
+ lbaint_t blkcnt, const void *buffer);
+unsigned long dev_erase(struct udevice *dev, lbaint_t start,
+ lbaint_t blkcnt);
+
/*
* We don't support printing partition information in SPL and only support
* getting partition information in a few cases.
@@ -496,7 +529,7 @@ int layout_mbr_partitions(struct disk_partition *p, int count,
#endif
-#ifdef CONFIG_PARTITIONS
+#if CONFIG_IS_ENABLED(PARTITIONS)
/**
* part_driver_get_count() - get partition driver count
*
diff --git a/include/sandboxblockdev.h b/include/sandboxblockdev.h
index 4ca9554e38a..dc983f0417b 100644
--- a/include/sandboxblockdev.h
+++ b/include/sandboxblockdev.h
@@ -26,4 +26,6 @@ struct host_block_dev {
*/
int host_dev_bind(int dev, char *filename, bool removable);
+int host_get_dev_err(int dev, struct blk_desc **blk_devp);
+
#endif
diff --git a/include/test/suites.h b/include/test/suites.h
index 6553a765c6a..ee6858a802a 100644
--- a/include/test/suites.h
+++ b/include/test/suites.h
@@ -29,6 +29,8 @@ int cmd_ut_category(const char *name, const char *prefix,
int do_ut_addrmap(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[]);
int do_ut_bootm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
+int do_ut_bootstd(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[]);
int do_ut_bloblist(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[]);
int do_ut_common(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
diff --git a/include/vsprintf.h b/include/vsprintf.h
index 532ef3650bd..e006af200fd 100644
--- a/include/vsprintf.h
+++ b/include/vsprintf.h
@@ -13,9 +13,9 @@
/**
* simple_strtoul - convert a string to an unsigned long
*
- * @param cp The string to be converted
- * @param endp Updated to point to the first character not converted
- * @param base The number base to use (0 for the default)
+ * @cp: The string to be converted
+ * @endp: Updated to point to the first character not converted
+ * @base: The number base to use (0 for the default)
* Return: value decoded from string (0 if invalid)
*
* Converts a string to an unsigned long. If there are invalid characters at
@@ -34,8 +34,8 @@ ulong simple_strtoul(const char *cp, char **endp, unsigned int base);
/**
* hex_strtoul - convert a string in hex to an unsigned long
*
- * @param cp The string to be converted
- * @param endp Updated to point to the first character not converted
+ * @cp: The string to be converted
+ * @endp: Updated to point to the first character not converted
* Return: value decoded from string (0 if invalid)
*
* Converts a hex string to an unsigned long. If there are invalid characters at
@@ -47,8 +47,8 @@ unsigned long hextoul(const char *cp, char **endp);
/**
* dec_strtoul - convert a string in decimal to an unsigned long
*
- * @param cp The string to be converted
- * @param endp Updated to point to the first character not converted
+ * @cp: The string to be converted
+ * @endp: Updated to point to the first character not converted
* Return: value decoded from string (0 if invalid)
*
* Converts a decimal string to an unsigned long. If there are invalid
@@ -59,11 +59,11 @@ unsigned long dectoul(const char *cp, char **endp);
/**
* strict_strtoul - convert a string to an unsigned long strictly
- * @param cp The string to be converted
- * @param base The number base to use (0 for the default)
- * @param res The converted result value
- * Return: 0 if conversion is successful and *res is set to the converted
- * value, otherwise it returns -EINVAL and *res is set to 0.
+ * @cp: The string to be converted
+ * @base: The number base to use (0 for the default)
+ * @res: The converted result value
+ * Return: 0 if conversion is successful and `*res` is set to the converted
+ * value, otherwise it returns -EINVAL and `*res` is set to 0.
*
* strict_strtoul converts a string to an unsigned long only if the
* string is really an unsigned long string, any string containing
@@ -98,8 +98,11 @@ long long simple_strtoll(const char *cp, char **endp, unsigned int base);
* Given a string this finds a trailing number on the string and returns it.
* For example, "abc123" would return 123.
*
- * @str: String to exxamine
- * Return: training number if found, else -1
+ * Note that this does not handle a string without a prefix. See dectoul() for
+ * that case.
+ *
+ * @str: String to examine
+ * Return: trailing number if found, else -1
*/
long trailing_strtol(const char *str);
@@ -111,20 +114,38 @@ long trailing_strtol(const char *str);
* characters between @str and @end - 1 are examined. If @end is NULL, it is
* set to str + strlen(str).
*
- * @str: String to exxamine
+ * @str: String to examine
* @end: Pointer to end of string to examine, or NULL to use the
* whole string
- * Return: training number if found, else -1
+ * Return: trailing number if found, else -1
*/
long trailing_strtoln(const char *str, const char *end);
/**
+ * trailing_strtoln_end() - extract trailing integer from a fixed-length string
+ *
+ * Given a fixed-length string this finds a trailing number on the string
+ * and returns it. For example, "abc123" would return 123. Only the
+ * characters between @str and @end - 1 are examined. If @end is NULL, it is
+ * set to str + strlen(str).
+ *
+ * @str: String to examine
+ * @end: Pointer to end of string to examine, or NULL to use the
+ * whole string
+ * @endp: If non-NULL, this is set to point to the character where the
+ * number starts, e.g. for "mmc0" this would be point to the '0'; if no
+ * trailing number is found, it is set to the end of the string
+ * Return: training number if found, else -1
+ */
+long trailing_strtoln_end(const char *str, const char *end, char const **endp);
+
+/**
* panic() - Print a message and reset/hang
*
* Prints a message on the console(s) and then resets. If CONFIG_PANIC_HANG is
* defined, then it will hang instead of resetting.
*
- * @param fmt: printf() format string for message, which should not include
+ * @fmt: printf() format string for message, which should not include
* \n, followed by arguments
*/
void panic(const char *fmt, ...)
@@ -139,16 +160,16 @@ void panic(const char *fmt, ...)
* This function can be used instead of panic() when your board does not
* already use printf(), * to keep code size small.
*
- * @param fmt: string to display, which should not include \n
+ * @str: string to display, which should not include \n
*/
void panic_str(const char *str) __attribute__ ((noreturn));
/**
* Format a string and place it in a buffer
*
- * @param buf The buffer to place the result into
- * @param fmt The format string to use
- * @param ... Arguments for the format string
+ * @buf: The buffer to place the result into
+ * @fmt: The format string to use
+ * @...: Arguments for the format string
*
* The function returns the number of characters written
* into @buf.
@@ -161,9 +182,9 @@ int sprintf(char *buf, const char *fmt, ...)
/**
* Format a string and place it in a buffer (va_list version)
*
- * @param buf The buffer to place the result into
- * @param fmt The format string to use
- * @param args Arguments for the format string
+ * @buf: The buffer to place the result into
+ * @fmt: The format string to use
+ * @args: Arguments for the format string
* Return: the number of characters which have been written into
* the @buf not including the trailing '\0'.
*
@@ -178,7 +199,7 @@ int vsprintf(char *buf, const char *fmt, va_list args);
*
* This returns a static string containing the decimal representation of the
* given value. The returned value may be overwritten by other calls to other
- * simple_... functions, so should be used immediately
+ * simple... functions, so should be used immediately
*
* @val: Value to convert
* Return: string containing the decimal representation of @val
@@ -190,9 +211,9 @@ char *simple_itoa(ulong val);
*
* This returns a static string containing the hexadecimal representation of the
* given value. The returned value may be overwritten by other calls to other
- * simple_... functions, so should be used immediately
+ * simple... functions, so should be used immediately
*
- * @val: Value to convert
+ * @num: Value to convert
* Return: string containing the hexecimal representation of @val
*/
char *simple_xtoa(ulong num);
@@ -200,10 +221,10 @@ char *simple_xtoa(ulong num);
/**
* Format a string and place it in a buffer
*
- * @param buf The buffer to place the result into
- * @param size The size of the buffer, including the trailing null space
- * @param fmt The format string to use
- * @param ... Arguments for the format string
+ * @buf: The buffer to place the result into
+ * @size: The size of the buffer, including the trailing null space
+ * @fmt: The format string to use
+ * @...: Arguments for the format string
* Return: the number of characters which would be
* generated for the given input, excluding the trailing null,
* as per ISO C99. If the return is greater than or equal to
@@ -217,10 +238,10 @@ int snprintf(char *buf, size_t size, const char *fmt, ...)
/**
* Format a string and place it in a buffer
*
- * @param buf The buffer to place the result into
- * @param size The size of the buffer, including the trailing null space
- * @param fmt The format string to use
- * @param ... Arguments for the format string
+ * @buf: The buffer to place the result into
+ * @size: The size of the buffer, including the trailing null space
+ * @fmt: The format string to use
+ * @...: Arguments for the format string
*
* The return value is the number of characters written into @buf not including
* the trailing '\0'. If @size is == 0 the function returns 0.
@@ -233,10 +254,10 @@ int scnprintf(char *buf, size_t size, const char *fmt, ...)
/**
* Format a string and place it in a buffer (base function)
*
- * @param buf The buffer to place the result into
- * @param size The size of the buffer, including the trailing null space
- * @param fmt The format string to use
- * @param args Arguments for the format string
+ * @buf: The buffer to place the result into
+ * @size: The size of the buffer, including the trailing null space
+ * @fmt: The format string to use
+ * @args: Arguments for the format string
* Return: The number characters which would be generated for the given
* input, excluding the trailing '\0', as per ISO C99. Note that fewer
* characters may be written if this number of characters is >= size.
@@ -258,10 +279,10 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args);
/**
* Format a string and place it in a buffer (va_list version)
*
- * @param buf The buffer to place the result into
- * @param size The size of the buffer, including the trailing null space
- * @param fmt The format string to use
- * @param args Arguments for the format string
+ * @buf: The buffer to place the result into
+ * @size: The size of the buffer, including the trailing null space
+ * @fmt: The format string to use
+ * @args: Arguments for the format string
* Return: the number of characters which have been written into
* the @buf not including the trailing '\0'. If @size is == 0 the function
* returns 0.
@@ -278,8 +299,8 @@ int vscnprintf(char *buf, size_t size, const char *fmt, va_list args);
* This prints a value with grouped digits, like 12,345,678 to make it easier
* to read.
*
- * @val: Value to print
- * @digits: Number of digiits to print
+ * @int_val: Value to print
+ * @digits: Number of digiits to print
*/
void print_grouped_ull(unsigned long long int_val, int digits);
@@ -309,9 +330,9 @@ void str_to_upper(const char *in, char *out, size_t len);
/**
* vsscanf - Unformat a buffer into a list of arguments
- * @buf: input buffer
- * @fmt: format of buffer
- * @args: arguments
+ * @inp: input buffer
+ * @fmt0: format of buffer
+ * @ap: arguments
*/
int vsscanf(const char *inp, char const *fmt0, va_list ap);
diff --git a/lib/Kconfig b/lib/Kconfig
index effe7353656..858be14f091 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -861,7 +861,7 @@ config LIB_ELF
config LMB
bool "Enable the logical memory blocks library (lmb)"
- default y if ARC || ARM || M68K || MICROBLAZE || MIPS || NDS32 || \
+ default y if ARC || ARM || M68K || MICROBLAZE || MIPS || \
NIOS2 || PPC || RISCV || SANDBOX || SH || X86 || XTENSA
help
Support the library logical memory blocks.
diff --git a/lib/efi_driver/efi_block_device.c b/lib/efi_driver/efi_block_device.c
index 04cb3ef0d4e..5baa6f87a37 100644
--- a/lib/efi_driver/efi_block_device.c
+++ b/lib/efi_driver/efi_block_device.c
@@ -35,6 +35,7 @@
#include <malloc.h>
#include <dm/device-internal.h>
#include <dm/root.h>
+#include <dm/tag.h>
/*
* EFI attributes of the udevice handled by this driver.
@@ -107,25 +108,6 @@ static ulong efi_bl_write(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt,
}
/**
- * Create partions for the block device.
- *
- * @handle: EFI handle of the block device
- * @dev: udevice of the block device
- * Return: number of partitions created
- */
-static int efi_bl_bind_partitions(efi_handle_t handle, struct udevice *dev)
-{
- struct blk_desc *desc;
- const char *if_typename;
-
- desc = dev_get_uclass_plat(dev);
- if_typename = blk_get_if_type_name(desc->if_type);
-
- return efi_disk_create_partitions(handle, desc, if_typename,
- desc->devnum, dev->name);
-}
-
-/**
* Create a block device for a handle
*
* @handle: handle
@@ -139,7 +121,6 @@ static int efi_bl_bind(efi_handle_t handle, void *interface)
char *name;
struct efi_object *obj = efi_search_obj(handle);
struct efi_block_io *io = interface;
- int disks;
struct efi_blk_plat *plat;
EFI_PRINT("%s: handle %p, interface %p\n", __func__, handle, io);
@@ -173,15 +154,20 @@ static int efi_bl_bind(efi_handle_t handle, void *interface)
plat->handle = handle;
plat->io = interface;
+ /*
+ * FIXME: necessary because we won't do almost nothing in
+ * efi_disk_create() when called from device_probe().
+ */
+ ret = dev_tag_set_ptr(bdev, DM_TAG_EFI, handle);
+ if (ret)
+ /* FIXME: cleanup for bdev */
+ return ret;
+
ret = device_probe(bdev);
if (ret)
return ret;
EFI_PRINT("%s: block device '%s' created\n", __func__, bdev->name);
- /* Create handles for the partions of the block device */
- disks = efi_bl_bind_partitions(handle, bdev);
- EFI_PRINT("Found %d partitions\n", disks);
-
return 0;
}
diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
index d50cd2563d3..6b245f50a72 100644
--- a/lib/efi_loader/Kconfig
+++ b/lib/efi_loader/Kconfig
@@ -14,8 +14,10 @@ config EFI_LOADER
depends on DM_ETH || !NET
depends on !EFI_APP
default y if !ARM || SYS_CPU = armv7 || SYS_CPU = armv8
+ select DM_EVENT
+ select EVENT_DYNAMIC
select LIB_UUID
- select PARTITION_UUIDS
+ imply PARTITION_UUIDS
select HAVE_BLOCK_DEVICE
select REGEX
imply FAT
@@ -40,6 +42,7 @@ config CMD_BOOTEFI_BOOTMGR
config EFI_SETUP_EARLY
bool
+ default y
choice
prompt "Store for non-volatile UEFI variables"
diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile
index 034d26cf010..aaaa25cefe0 100644
--- a/lib/efi_loader/Makefile
+++ b/lib/efi_loader/Makefile
@@ -68,7 +68,7 @@ obj-y += efi_watchdog.o
obj-$(CONFIG_EFI_ESRT) += efi_esrt.o
obj-$(CONFIG_LCD) += efi_gop.o
obj-$(CONFIG_DM_VIDEO) += efi_gop.o
-obj-$(CONFIG_PARTITIONS) += efi_disk.o
+obj-$(CONFIG_BLK) += efi_disk.o
obj-$(CONFIG_NET) += efi_net.o
obj-$(CONFIG_GENERATE_ACPI_TABLE) += efi_acpi.o
obj-$(CONFIG_GENERATE_SMBIOS_TABLE) += efi_smbios.o
diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c
index 0542aaae16c..50a988c5613 100644
--- a/lib/efi_loader/efi_device_path.c
+++ b/lib/efi_loader/efi_device_path.c
@@ -864,11 +864,16 @@ static void *dp_part_node(void *buf, struct blk_desc *desc, int part)
break;
case SIG_TYPE_GUID:
hddp->signature_type = 2;
+#if CONFIG_IS_ENABLED(PARTITION_UUIDS)
+ /* info.uuid exists only with PARTITION_UUIDS */
if (uuid_str_to_bin(info.uuid,
- hddp->partition_signature, 1))
+ hddp->partition_signature,
+ UUID_STR_FORMAT_GUID)) {
log_warning(
- "Partition no. %d: invalid guid: %s\n",
+ "Partition %d: invalid GUID %s\n",
part, info.uuid);
+ }
+#endif
break;
}
diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c
index c905c12abc2..8fb5b2363c4 100644
--- a/lib/efi_loader/efi_disk.c
+++ b/lib/efi_loader/efi_disk.c
@@ -10,6 +10,9 @@
#include <common.h>
#include <blk.h>
#include <dm.h>
+#include <dm/device-internal.h>
+#include <dm/tag.h>
+#include <event.h>
#include <efi_loader.h>
#include <fs.h>
#include <log.h>
@@ -33,7 +36,7 @@ const efi_guid_t efi_system_partition_guid = PARTITION_SYSTEM_GUID;
* @part: partition
* @volume: simple file system protocol of the partition
* @offset: offset into disk for simple partition
- * @desc: internal block device descriptor
+ * @dev: associated DM device
*/
struct efi_disk_obj {
struct efi_object header;
@@ -45,7 +48,7 @@ struct efi_disk_obj {
unsigned int part;
struct efi_simple_file_system_protocol *volume;
lbaint_t offset;
- struct blk_desc *desc;
+ struct udevice *dev; /* TODO: move it to efi_object */
};
/**
@@ -80,14 +83,12 @@ static efi_status_t efi_disk_rw_blocks(struct efi_block_io *this,
void *buffer, enum efi_disk_direction direction)
{
struct efi_disk_obj *diskobj;
- struct blk_desc *desc;
int blksz;
int blocks;
unsigned long n;
diskobj = container_of(this, struct efi_disk_obj, ops);
- desc = (struct blk_desc *) diskobj->desc;
- blksz = desc->blksz;
+ blksz = diskobj->media.block_size;
blocks = buffer_size / blksz;
lba += diskobj->offset;
@@ -98,10 +99,21 @@ static efi_status_t efi_disk_rw_blocks(struct efi_block_io *this,
if (buffer_size & (blksz - 1))
return EFI_BAD_BUFFER_SIZE;
+#if CONFIG_IS_ENABLED(PARTITIONS)
+ if (direction == EFI_DISK_READ)
+ n = dev_read(diskobj->dev, lba, blocks, buffer);
+ else
+ n = dev_write(diskobj->dev, lba, blocks, buffer);
+#else
+ /* dev is always a block device (UCLASS_BLK) */
+ struct blk_desc *desc;
+
+ desc = dev_get_uclass_plat(diskobj->dev);
if (direction == EFI_DISK_READ)
n = blk_dread(desc, lba, blocks, buffer);
else
n = blk_dwrite(desc, lba, blocks, buffer);
+#endif
/* We don't do interrupts, so check for timers cooperatively */
efi_timer_check();
@@ -443,7 +455,6 @@ static efi_status_t efi_disk_add_dev(
diskobj->ops = block_io_disk_template;
diskobj->ifname = if_typename;
diskobj->dev_index = dev_index;
- diskobj->desc = desc;
/* Fill in EFI IO Media info (for read/write callbacks) */
diskobj->media.removable_media = desc->removable;
@@ -487,103 +498,255 @@ error:
return ret;
}
-/**
- * efi_disk_create_partitions() - create handles and protocols for partitions
+/*
+ * Create a handle for a whole raw disk
+ *
+ * @dev uclass device (UCLASS_BLK)
*
- * Create handles and protocols for the partitions of a block device.
+ * Create an efi_disk object which is associated with @dev.
+ * The type of @dev must be UCLASS_BLK.
*
- * @parent: handle of the parent disk
- * @desc: block device
- * @if_typename: interface type
- * @diskid: device number
- * @pdevname: device name
- * Return: number of partitions created
+ * @return 0 on success, -1 otherwise
*/
-int efi_disk_create_partitions(efi_handle_t parent, struct blk_desc *desc,
- const char *if_typename, int diskid,
- const char *pdevname)
+static int efi_disk_create_raw(struct udevice *dev)
{
- int disks = 0;
- char devname[32] = { 0 }; /* dp->str is u16[32] long */
- int part;
- struct efi_device_path *dp = NULL;
+ struct efi_disk_obj *disk;
+ struct blk_desc *desc;
+ const char *if_typename;
+ int diskid;
efi_status_t ret;
+
+ desc = dev_get_uclass_plat(dev);
+ if_typename = blk_get_if_type_name(desc->if_type);
+ diskid = desc->devnum;
+
+ ret = efi_disk_add_dev(NULL, NULL, if_typename, desc,
+ diskid, NULL, 0, &disk);
+ if (ret != EFI_SUCCESS) {
+ if (ret == EFI_NOT_READY)
+ log_notice("Disk %s not ready\n", dev->name);
+ else
+ log_err("Adding disk for %s failed\n", dev->name);
+
+ return -1;
+ }
+ disk->dev = dev;
+ if (dev_tag_set_ptr(dev, DM_TAG_EFI, &disk->header)) {
+ efi_free_pool(disk->dp);
+ efi_delete_handle(&disk->header);
+
+ return -1;
+ }
+
+ return 0;
+}
+
+/*
+ * Create a handle for a disk partition
+ *
+ * @dev uclass device (UCLASS_PARTITION)
+ *
+ * Create an efi_disk object which is associated with @dev.
+ * The type of @dev must be UCLASS_PARTITION.
+ *
+ * @return 0 on success, -1 otherwise
+ */
+static int efi_disk_create_part(struct udevice *dev)
+{
+ efi_handle_t parent;
+ struct blk_desc *desc;
+ const char *if_typename;
+ struct disk_part *part_data;
+ struct disk_partition *info;
+ unsigned int part;
+ int diskid;
struct efi_handler *handler;
+ struct efi_device_path *dp_parent;
+ struct efi_disk_obj *disk;
+ efi_status_t ret;
+
+ if (dev_tag_get_ptr(dev_get_parent(dev), DM_TAG_EFI, (void **)&parent))
+ return -1;
+
+ desc = dev_get_uclass_plat(dev_get_parent(dev));
+ if_typename = blk_get_if_type_name(desc->if_type);
+ diskid = desc->devnum;
+
+ part_data = dev_get_uclass_plat(dev);
+ part = part_data->partnum;
+ info = &part_data->gpt_part_info;
- /* Get the device path of the parent */
ret = efi_search_protocol(parent, &efi_guid_device_path, &handler);
- if (ret == EFI_SUCCESS)
- dp = handler->protocol_interface;
-
- /* Add devices for each partition */
- for (part = 1; part <= MAX_SEARCH_PARTITIONS; part++) {
- struct disk_partition info;
-
- if (part_get_info(desc, part, &info))
- continue;
- snprintf(devname, sizeof(devname), "%s:%x", pdevname,
- part);
- ret = efi_disk_add_dev(parent, dp, if_typename, desc, diskid,
- &info, part, NULL);
- if (ret != EFI_SUCCESS) {
- log_err("Adding partition %s failed\n", pdevname);
- continue;
- }
- disks++;
+ if (ret != EFI_SUCCESS)
+ return -1;
+ dp_parent = (struct efi_device_path *)handler->protocol_interface;
+
+ ret = efi_disk_add_dev(parent, dp_parent, if_typename, desc, diskid,
+ info, part, &disk);
+ if (ret != EFI_SUCCESS) {
+ log_err("Adding partition for %s failed\n", dev->name);
+ return -1;
+ }
+ disk->dev = dev;
+ if (dev_tag_set_ptr(dev, DM_TAG_EFI, &disk->header)) {
+ efi_free_pool(disk->dp);
+ efi_delete_handle(&disk->header);
+
+ return -1;
}
- return disks;
+ return 0;
}
-/**
- * efi_disk_register() - register block devices
+/*
+ * Create efi_disk objects for a block device
*
- * U-Boot doesn't have a list of all online disk devices. So when running our
- * EFI payload, we scan through all of the potentially available ones and
- * store them in our object pool.
+ * @dev uclass device (UCLASS_BLK)
*
- * This function is called in efi_init_obj_list().
+ * Create efi_disk objects for partitions as well as a raw disk
+ * which is associated with @dev.
+ * The type of @dev must be UCLASS_BLK.
+ * This function is expected to be called at EV_PM_POST_PROBE.
*
- * TODO(sjg@chromium.org): Actually with CONFIG_BLK, U-Boot does have this.
- * Consider converting the code to look up devices as needed. The EFI device
- * could be a child of the UCLASS_BLK block device, perhaps.
+ * @return 0 on success, -1 otherwise
+ */
+static int efi_disk_probe(void *ctx, struct event *event)
+{
+ struct udevice *dev;
+ enum uclass_id id;
+ struct blk_desc *desc;
+ struct udevice *child;
+ int ret;
+
+ dev = event->data.dm.dev;
+ id = device_get_uclass_id(dev);
+
+ /* TODO: We won't support partitions in a partition */
+ if (id != UCLASS_BLK)
+ return 0;
+
+ /*
+ * avoid creating duplicated objects now that efi_driver
+ * has already created an efi_disk at this moment.
+ */
+ desc = dev_get_uclass_plat(dev);
+ if (desc->if_type != IF_TYPE_EFI_LOADER) {
+ ret = efi_disk_create_raw(dev);
+ if (ret)
+ return -1;
+ }
+
+ device_foreach_child(child, dev) {
+ ret = efi_disk_create_part(child);
+ if (ret)
+ return -1;
+ }
+
+ return 0;
+}
+
+/*
+ * Delete an efi_disk object for a whole raw disk
*
- * Return: status code
+ * @dev uclass device (UCLASS_BLK)
+ *
+ * Delete an efi_disk object which is associated with @dev.
+ * The type of @dev must be UCLASS_BLK.
+ *
+ * @return 0 on success, -1 otherwise
*/
-efi_status_t efi_disk_register(void)
+static int efi_disk_delete_raw(struct udevice *dev)
{
- struct efi_disk_obj *disk;
- int disks = 0;
- efi_status_t ret;
+ efi_handle_t handle;
+ struct blk_desc *desc;
+ struct efi_disk_obj *diskobj;
+
+ if (dev_tag_get_ptr(dev, DM_TAG_EFI, (void **)&handle))
+ return -1;
+
+ desc = dev_get_uclass_plat(dev);
+ if (desc->if_type != IF_TYPE_EFI_LOADER) {
+ diskobj = container_of(handle, struct efi_disk_obj, header);
+ efi_free_pool(diskobj->dp);
+ }
+
+ efi_delete_handle(handle);
+ dev_tag_del(dev, DM_TAG_EFI);
+
+ return 0;
+}
+
+/*
+ * Delete an efi_disk object for a disk partition
+ *
+ * @dev uclass device (UCLASS_PARTITION)
+ *
+ * Delete an efi_disk object which is associated with @dev.
+ * The type of @dev must be UCLASS_PARTITION.
+ *
+ * @return 0 on success, -1 otherwise
+ */
+static int efi_disk_delete_part(struct udevice *dev)
+{
+ efi_handle_t handle;
+ struct efi_disk_obj *diskobj;
+
+ if (dev_tag_get_ptr(dev, DM_TAG_EFI, (void **)&handle))
+ return -1;
+
+ diskobj = container_of(handle, struct efi_disk_obj, header);
+
+ efi_free_pool(diskobj->dp);
+ efi_delete_handle(handle);
+ dev_tag_del(dev, DM_TAG_EFI);
+
+ return 0;
+}
+
+/*
+ * Delete an efi_disk object for a block device
+ *
+ * @dev uclass device (UCLASS_BLK or UCLASS_PARTITION)
+ *
+ * Delete an efi_disk object which is associated with @dev.
+ * The type of @dev must be either UCLASS_BLK or UCLASS_PARTITION.
+ * This function is expected to be called at EV_PM_PRE_REMOVE.
+ *
+ * @return 0 on success, -1 otherwise
+ */
+static int efi_disk_remove(void *ctx, struct event *event)
+{
+ enum uclass_id id;
struct udevice *dev;
- for (uclass_first_device_check(UCLASS_BLK, &dev); dev;
- uclass_next_device_check(&dev)) {
- struct blk_desc *desc = dev_get_uclass_plat(dev);
- const char *if_typename = blk_get_if_type_name(desc->if_type);
+ dev = event->data.dm.dev;
+ id = device_get_uclass_id(dev);
- /* Add block device for the full device */
- log_info("Scanning disk %s...\n", dev->name);
- ret = efi_disk_add_dev(NULL, NULL, if_typename,
- desc, desc->devnum, NULL, 0, &disk);
- if (ret == EFI_NOT_READY) {
- log_notice("Disk %s not ready\n", dev->name);
- continue;
- }
- if (ret) {
- log_err("ERROR: failure to add disk device %s, r = %lu\n",
- dev->name, ret & ~EFI_ERROR_MASK);
- continue;
- }
- disks++;
+ if (id == UCLASS_BLK)
+ return efi_disk_delete_raw(dev);
+ else if (id == UCLASS_PARTITION)
+ return efi_disk_delete_part(dev);
+ else
+ return 0;
+}
+
+efi_status_t efi_disk_init(void)
+{
+ int ret;
- /* Partitions show up as block devices in EFI */
- disks += efi_disk_create_partitions(
- &disk->header, desc, if_typename,
- desc->devnum, dev->name);
+ ret = event_register("efi_disk add", EVT_DM_POST_PROBE,
+ efi_disk_probe, NULL);
+ if (ret) {
+ log_err("Event registration for efi_disk add failed\n");
+ return EFI_OUT_OF_RESOURCES;
}
- log_info("Found %d disks\n", disks);
+ ret = event_register("efi_disk del", EVT_DM_PRE_REMOVE,
+ efi_disk_remove, NULL);
+ if (ret) {
+ log_err("Event registration for efi_disk del failed\n");
+ return EFI_OUT_OF_RESOURCES;
+ }
return EFI_SUCCESS;
}
diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c
index eee54e48784..250eeb2fcd6 100644
--- a/lib/efi_loader/efi_setup.c
+++ b/lib/efi_loader/efi_setup.c
@@ -174,20 +174,18 @@ static efi_status_t efi_init_os_indications(void)
&os_indications_supported, false);
}
-
/**
- * efi_init_obj_list() - Initialize and populate EFI object list
+ * __efi_init_early() - handle initialization at early stage
+ *
+ * This function is called in efi_init_obj_list() only if
+ * !CONFIG_EFI_SETUP_EARLY.
*
* Return: status code
*/
-efi_status_t efi_init_obj_list(void)
+static efi_status_t __efi_init_early(void)
{
efi_status_t ret = EFI_SUCCESS;
- /* Initialize once only */
- if (efi_obj_list_initialized != OBJ_LIST_NOT_INITIALIZED)
- return efi_obj_list_initialized;
-
/* Allow unaligned memory access */
allow_unaligned();
@@ -200,11 +198,51 @@ efi_status_t efi_init_obj_list(void)
if (ret != EFI_SUCCESS)
goto out;
-#ifdef CONFIG_PARTITIONS
- ret = efi_disk_register();
- if (ret != EFI_SUCCESS)
- goto out;
-#endif
+ ret = efi_disk_init();
+out:
+ return ret;
+}
+
+/**
+ * efi_init_early() - handle initialization at early stage
+ *
+ * external version of __efi_init_early(); expected to be called in
+ * board_init_r().
+ *
+ * Return: status code
+ */
+int efi_init_early(void)
+{
+ efi_status_t ret;
+
+ ret = __efi_init_early();
+ if (ret != EFI_SUCCESS) {
+ /* never re-init UEFI subsystem */
+ efi_obj_list_initialized = ret;
+ return -1;
+ }
+ return 0;
+}
+
+/**
+ * efi_init_obj_list() - Initialize and populate EFI object list
+ *
+ * Return: status code
+ */
+efi_status_t efi_init_obj_list(void)
+{
+ efi_status_t ret = EFI_SUCCESS;
+
+ /* Initialize once only */
+ if (efi_obj_list_initialized != OBJ_LIST_NOT_INITIALIZED)
+ return efi_obj_list_initialized;
+
+ if (!IS_ENABLED(CONFIG_EFI_SETUP_EARLY)) {
+ ret = __efi_init_early();
+ if (ret != EFI_SUCCESS)
+ goto out;
+ }
+
if (IS_ENABLED(CONFIG_EFI_RNG_PROTOCOL)) {
ret = efi_rng_register();
if (ret != EFI_SUCCESS)
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index e2208cb7d7a..e20f6aad9c2 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -251,14 +251,7 @@ int fdtdec_get_pci_bar32(const struct udevice *dev, struct fdt_pci_addr *addr,
barnum = (barnum - PCI_BASE_ADDRESS_0) / 4;
- /*
- * There is a strange toolchain bug with nds32 which complains about
- * an undefined reference here, even if fdtdec_get_pci_bar32() is never
- * called. An #ifdef seems to be the only fix!
- */
-#if !IS_ENABLED(CONFIG_NDS32)
*bar = dm_pci_read_bar32(dev, barnum);
-#endif
return 0;
}
diff --git a/lib/strto.c b/lib/strto.c
index f1918843765..6462d4fddf1 100644
--- a/lib/strto.c
+++ b/lib/strto.c
@@ -183,22 +183,33 @@ long long simple_strtoll(const char *cp, char **endp, unsigned int base)
return simple_strtoull(cp, endp, base);
}
-long trailing_strtoln(const char *str, const char *end)
+long trailing_strtoln_end(const char *str, const char *end, char const **endp)
{
const char *p;
if (!end)
end = str + strlen(str);
- if (isdigit(end[-1])) {
- for (p = end - 1; p > str; p--) {
- if (!isdigit(*p))
- return dectoul(p + 1, NULL);
- }
+ p = end - 1;
+ if (p > str && isdigit(*p)) {
+ do {
+ if (!isdigit(p[-1])) {
+ if (endp)
+ *endp = p;
+ return dectoul(p, NULL);
+ }
+ } while (--p > str);
}
+ if (endp)
+ *endp = end;
return -1;
}
+long trailing_strtoln(const char *str, const char *end)
+{
+ return trailing_strtoln_end(str, end, NULL);
+}
+
long trailing_strtol(const char *str)
{
return trailing_strtoln(str, NULL);
diff --git a/net/Kconfig b/net/Kconfig
index ef0aa161f73..964a4fe4999 100644
--- a/net/Kconfig
+++ b/net/Kconfig
@@ -25,6 +25,15 @@ config PROT_UDP
Enable a generic udp framework that allows defining a custom
handler for udp protocol.
+config BOOTDEV_ETH
+ bool "Enable bootdev for ethernet"
+ depends on BOOTSTD
+ default y
+ help
+ Provide a bootdev for ethernet so that is it possible to boot
+ an operationg system over the network, using the PXE (Preboot
+ Execution Environment) protocol.
+
config BOOTP_SEND_HOSTNAME
bool "Send hostname to DNS server"
help
diff --git a/net/Makefile b/net/Makefile
index fb3eba840ff..6c812502d3e 100644
--- a/net/Makefile
+++ b/net/Makefile
@@ -12,6 +12,7 @@ obj-$(CONFIG_CMD_DNS) += dns.o
obj-$(CONFIG_DM_DSA) += dsa-uclass.o
ifdef CONFIG_DM_ETH
obj-$(CONFIG_NET) += eth-uclass.o
+obj-$(CONFIG_$(SPL_TPL_)BOOTDEV_ETH) += eth_bootdev.o
else
obj-$(CONFIG_NET) += eth_legacy.o
endif
diff --git a/net/eth-uclass.c b/net/eth-uclass.c
index 58c308f3327..bcefc54ded8 100644
--- a/net/eth-uclass.c
+++ b/net/eth-uclass.c
@@ -8,6 +8,7 @@
#define LOG_CATEGORY UCLASS_ETH
#include <common.h>
+#include <bootdev.h>
#include <bootstage.h>
#include <dm.h>
#include <env.h>
@@ -473,6 +474,8 @@ int eth_initialize(void)
static int eth_post_bind(struct udevice *dev)
{
+ int ret;
+
if (strchr(dev->name, ' ')) {
printf("\nError: eth device name \"%s\" has a space!\n",
dev->name);
@@ -482,6 +485,11 @@ static int eth_post_bind(struct udevice *dev)
#ifdef CONFIG_DM_ETH_PHY
eth_phy_binds_nodes(dev);
#endif
+ if (CONFIG_IS_ENABLED(BOOTDEV_ETH)) {
+ ret = bootdev_setup_for_dev(dev, "eth_bootdev");
+ if (ret)
+ return log_msg_ret("bootdev", ret);
+ }
return 0;
}
diff --git a/net/eth_bootdev.c b/net/eth_bootdev.c
new file mode 100644
index 00000000000..b735966d2bc
--- /dev/null
+++ b/net/eth_bootdev.c
@@ -0,0 +1,101 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Bootdevice for ethernet (uses PXE)
+ *
+ * Copyright 2021 Google LLC
+ * Written by Simon Glass <sjg@chromium.org>
+ */
+
+#include <common.h>
+#include <bootdev.h>
+#include <bootflow.h>
+#include <command.h>
+#include <bootmeth.h>
+#include <distro.h>
+#include <dm.h>
+#include <log.h>
+#include <net.h>
+
+static int eth_get_bootflow(struct udevice *dev, struct bootflow_iter *iter,
+ struct bootflow *bflow)
+{
+ char name[60];
+ int ret;
+
+ /* Must be an Ethernet device */
+ ret = bootflow_iter_uses_network(iter);
+ if (ret)
+ return log_msg_ret("net", ret);
+
+ ret = bootmeth_check(bflow->method, iter);
+ if (ret)
+ return log_msg_ret("check", ret);
+
+ /*
+ * Like distro boot, this assumes there is only one Ethernet device.
+ * In this case, that means that @eth is ignored
+ */
+
+ snprintf(name, sizeof(name), "%s.%d", dev->name, iter->part);
+ bflow->name = strdup(name);
+ if (!bflow->name)
+ return log_msg_ret("name", -ENOMEM);
+
+ /*
+ * There is not a direct interface to the network stack so run
+ * everything through the command-line interpreter for now.
+ *
+ * Don't bother checking the result of dhcp. It can fail with:
+ *
+ * DHCP client bound to address 192.168.4.50 (4 ms)
+ * *** Warning: no boot file name; using 'C0A80432.img'
+ * Using smsc95xx_eth device
+ * TFTP from server 192.168.4.1; our IP address is 192.168.4.50
+ * Filename 'C0A80432.img'.
+ * Load address: 0x200000
+ * Loading: *
+ * TFTP error: 'File not found' (1)
+ *
+ * This is not a real failure, since we don't actually care if the
+ * boot file exists.
+ */
+ log_debug("running dhcp\n");
+ run_command("dhcp", 0);
+ bflow->state = BOOTFLOWST_MEDIA;
+
+ /* See distro_pxe_read_bootflow() for the standard impl of this */
+ log_debug("dhcp complete - reading bootflow with method %s\n",
+ bflow->method->name);
+ ret = bootmeth_read_bootflow(bflow->method, bflow);
+ log_debug("reading bootflow returned %d\n", ret);
+ if (ret)
+ return log_msg_ret("method", ret);
+
+ return 0;
+}
+
+static int eth_bootdev_bind(struct udevice *dev)
+{
+ struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev);
+
+ ucp->prio = BOOTDEVP_4_NET_BASE;
+
+ return 0;
+}
+
+struct bootdev_ops eth_bootdev_ops = {
+ .get_bootflow = eth_get_bootflow,
+};
+
+static const struct udevice_id eth_bootdev_ids[] = {
+ { .compatible = "u-boot,bootdev-eth" },
+ { }
+};
+
+U_BOOT_DRIVER(eth_bootdev) = {
+ .name = "eth_bootdev",
+ .id = UCLASS_BOOTDEV,
+ .ops = &eth_bootdev_ops,
+ .bind = eth_bootdev_bind,
+ .of_match = eth_bootdev_ids,
+};
diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt
index bddf9b134ba..5b882b2670c 100644
--- a/scripts/config_whitelist.txt
+++ b/scripts/config_whitelist.txt
@@ -67,11 +67,6 @@ CONFIG_EXTRA_CLOCK
CONFIG_EXTRA_ENV
CONFIG_EXTRA_ENV_SETTINGS
CONFIG_EXTRA_ENV_SETTINGS_COMMON
-CONFIG_EXT_AHBAPBBRG_BASE
-CONFIG_EXT_AHBPCIBRG_BASE
-CONFIG_EXT_AHBSLAVE01_BASE
-CONFIG_EXT_AHBSLAVE02_BASE
-CONFIG_EXT_USB_HOST_BASE
CONFIG_EXYNOS4
CONFIG_EXYNOS4210
CONFIG_EXYNOS5
@@ -127,34 +122,9 @@ CONFIG_FSL_SERDES
CONFIG_FSL_SERDES1
CONFIG_FSL_SERDES2
CONFIG_FSL_SGMII_RISER
-CONFIG_FTAHBC020S
-CONFIG_FTAHBC020S_BASE
-CONFIG_FTAPBBRG020S_01_BASE
-CONFIG_FTCFC010_BASE
-CONFIG_FTDMAC020_BASE
-CONFIG_FTGPIO010_BASE
-CONFIG_FTIIC010_BASE
-CONFIG_FTINTC010_BASE
-CONFIG_FTLCDC100_BASE
CONFIG_FTMAC100_BASE
-CONFIG_FTPMU010
-CONFIG_FTPMU010_BASE
-CONFIG_FTPMU010_POWER
-CONFIG_FTRTC010_BASE
CONFIG_FTRTC010_EXTCLK
CONFIG_FTRTC010_PCLK
-CONFIG_FTSDMC021
-CONFIG_FTSDMC021_BASE
-CONFIG_FTSMC020
-CONFIG_FTSMC020_BASE
-CONFIG_FTSSP010_01_BASE
-CONFIG_FTSSP010_02_BASE
-CONFIG_FTTMR010_BASE
-CONFIG_FTUART010_01_BASE
-CONFIG_FTUART010_02_BASE
-CONFIG_FTUART010_03_BASE
-CONFIG_FTWDT010_BASE
-CONFIG_FTWDT010_WATCHDOG
CONFIG_GATEWAYIP
CONFIG_GLOBAL_TIMER
CONFIG_GMII
@@ -339,7 +309,6 @@ CONFIG_IRAM_END
CONFIG_IRAM_SIZE
CONFIG_IRAM_STACK
CONFIG_IRAM_TOP
-CONFIG_IRDA_BASE
CONFIG_KEY_REVOCATION
CONFIG_KIRKWOOD_EGIGA_INIT
CONFIG_KIRKWOOD_PCIE_INIT
@@ -410,7 +379,6 @@ CONFIG_MAX_MEM_MAPPED
CONFIG_MAX_RAM_BANK_SIZE
CONFIG_MEMSIZE_IN_BYTES
CONFIG_MEM_INIT_VALUE
-CONFIG_MEM_REMAP
CONFIG_MFG_ENV_SETTINGS
CONFIG_MII_DEFAULT_TSEC
CONFIG_MISC_COMMON
@@ -495,8 +463,6 @@ CONFIG_PM
CONFIG_PMC_BR_PRELIM
CONFIG_PMC_OR_PRELIM
CONFIG_PME_PLAT_CLK_DIV
-CONFIG_PMU
-CONFIG_PMW_BASE
CONFIG_POST
CONFIG_POSTBOOTMENU
CONFIG_POST_EXTERNAL_WORD_FUNCS
@@ -527,10 +493,6 @@ CONFIG_RAMBOOT_SPIFLASH
CONFIG_RAMBOOT_TEXT_BASE
CONFIG_RAMDISK_ADDR
CONFIG_RD_LVL
-CONFIG_RESERVED_01_BASE
-CONFIG_RESERVED_02_BASE
-CONFIG_RESERVED_03_BASE
-CONFIG_RESERVED_04_BASE
CONFIG_RESET_VECTOR_ADDRESS
CONFIG_RESTORE_FLASH
CONFIG_ROCKCHIP_CHIP_TAG
@@ -542,7 +504,6 @@ CONFIG_RTC_DS1337_NOOSC
CONFIG_RTC_DS1338
CONFIG_RTC_DS1374
CONFIG_RTC_DS3231
-CONFIG_RTC_FTRTC010
CONFIG_RTC_MC13XXX
CONFIG_RTC_MCFRRTC
CONFIG_RTC_MXS
@@ -586,7 +547,6 @@ CONFIG_SH_ETHER_USE_PORT
CONFIG_SH_GPIO_PFC
CONFIG_SH_QSPI_BASE
CONFIG_SKIP_LOCAL_MAC_RANDOMIZATION
-CONFIG_SKIP_TRUNOFF_WATCHDOG
CONFIG_SLIC
CONFIG_SMC91111
CONFIG_SMC91111_BASE
@@ -1149,19 +1109,6 @@ CONFIG_SYS_FSL_WDOG_BE
CONFIG_SYS_FSL_WRIOP1_ADDR
CONFIG_SYS_FSL_WRIOP1_MDIO1
CONFIG_SYS_FSL_WRIOP1_MDIO2
-CONFIG_SYS_FTAHBC020S_SLAVE_BSR_6
-CONFIG_SYS_FTAHBC020S_SLAVE_BSR_BASE
-CONFIG_SYS_FTPMU010_PDLLCR0_HCLKOUTDIS
-CONFIG_SYS_FTPMU010_SDRAMHTC
-CONFIG_SYS_FTSDMC021_BANK0_BASE
-CONFIG_SYS_FTSDMC021_BANK0_BSR
-CONFIG_SYS_FTSDMC021_BANK1_BASE
-CONFIG_SYS_FTSDMC021_BANK1_BSR
-CONFIG_SYS_FTSDMC021_CR1
-CONFIG_SYS_FTSDMC021_CR2
-CONFIG_SYS_FTSDMC021_TP1
-CONFIG_SYS_FTSDMC021_TP2
-CONFIG_SYS_FTSMC020_CONFIGS
CONFIG_SYS_GBL_DATA_OFFSET
CONFIG_SYS_GBL_DATA_SIZE
CONFIG_SYS_GIC400_ADDR
@@ -1836,7 +1783,6 @@ CONFIG_USB_ATMEL_CLK_SEL_PLLB
CONFIG_USB_ATMEL_CLK_SEL_UPLL
CONFIG_USB_BOOTING
CONFIG_USB_DEVICE
-CONFIG_USB_DEV_BASE
CONFIG_USB_EHCI_EXYNOS
CONFIG_USB_EHCI_TXFIFO_THRESH
CONFIG_USB_EXT2_BOOT
@@ -1849,7 +1795,6 @@ CONFIG_USB_OHCI_LPC32XX
CONFIG_USB_OHCI_NEW
CONFIG_USB_TTY
CONFIG_USB_XHCI_EXYNOS
-CONFIG_USE_INTERRUPT
CONFIG_USE_ONENAND_BOARD_INIT
CONFIG_U_BOOT_HDR_SIZE
CONFIG_VAR_SIZE_SPL
diff --git a/test/Makefile b/test/Makefile
index b3b2902e2e7..abd605a4351 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -22,6 +22,7 @@ obj-$(CONFIG_UT_TIME) += time_ut.o
obj-y += ut.o
ifeq ($(CONFIG_SPL_BUILD),)
+obj-$(CONFIG_UNIT_TEST) += boot/
obj-$(CONFIG_UNIT_TEST) += common/
obj-$(CONFIG_UNIT_TEST) += lib/
obj-y += log/
diff --git a/test/boot/Makefile b/test/boot/Makefile
new file mode 100644
index 00000000000..1730792b5fa
--- /dev/null
+++ b/test/boot/Makefile
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Copyright 2021 Google LLC
+
+obj-$(CONFIG_BOOTSTD) += bootdev.o bootstd_common.o bootflow.o bootmeth.o
diff --git a/test/boot/bootdev.c b/test/boot/bootdev.c
new file mode 100644
index 00000000000..1c2a79fb108
--- /dev/null
+++ b/test/boot/bootdev.c
@@ -0,0 +1,223 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Test for bootdev functions. All start with 'bootdev'
+ *
+ * Copyright 2021 Google LLC
+ * Written by Simon Glass <sjg@chromium.org>
+ */
+
+#include <common.h>
+#include <bootstd.h>
+#include <dm.h>
+#include <bootdev.h>
+#include <bootflow.h>
+#include <mapmem.h>
+#include <os.h>
+#include <test/suites.h>
+#include <test/ut.h>
+#include "bootstd_common.h"
+
+/* Allow reseting the USB-started flag */
+extern char usb_started;
+
+/* Check 'bootdev list' command */
+static int bootdev_test_cmd_list(struct unit_test_state *uts)
+{
+ int probed;
+
+ console_record_reset_enable();
+ for (probed = 0; probed < 2; probed++) {
+ int probe_ch = probed ? '+' : ' ';
+
+ ut_assertok(run_command(probed ? "bootdev list -p" :
+ "bootdev list", 0));
+ ut_assert_nextline("Seq Probed Status Uclass Name");
+ ut_assert_nextlinen("---");
+ ut_assert_nextline("%3x [ %c ] %6s %-8s %s", 0, probe_ch, "OK",
+ "mmc", "mmc2.bootdev");
+ ut_assert_nextline("%3x [ %c ] %6s %-8s %s", 1, probe_ch, "OK",
+ "mmc", "mmc1.bootdev");
+ ut_assert_nextline("%3x [ %c ] %6s %-8s %s", 2, probe_ch, "OK",
+ "mmc", "mmc0.bootdev");
+ ut_assert_nextlinen("---");
+ ut_assert_nextline("(3 bootdevs)");
+ ut_assert_console_end();
+ }
+
+ return 0;
+}
+BOOTSTD_TEST(bootdev_test_cmd_list, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
+
+/* Check 'bootdev select' and 'info' commands */
+static int bootdev_test_cmd_select(struct unit_test_state *uts)
+{
+ struct bootstd_priv *std;
+
+ /* get access to the CLI's cur_bootdev */
+ ut_assertok(bootstd_get_priv(&std));
+
+ console_record_reset_enable();
+ ut_asserteq(1, run_command("bootdev info", 0));
+ ut_assert_nextlinen("Please use");
+ ut_assert_console_end();
+
+ /* select by sequence */
+ ut_assertok(run_command("bootdev select 0", 0));
+ ut_assert_console_end();
+
+ ut_assertok(run_command("bootdev info", 0));
+ ut_assert_nextline("Name: mmc2.bootdev");
+ ut_assert_nextline("Sequence: 0");
+ ut_assert_nextline("Status: Probed");
+ ut_assert_nextline("Uclass: mmc");
+ ut_assert_nextline("Bootflows: 0 (0 valid)");
+ ut_assert_console_end();
+
+ /* select by bootdev name */
+ ut_assertok(run_command("bootdev select mmc1.bootdev", 0));
+ ut_assert_console_end();
+ ut_assertnonnull(std->cur_bootdev);
+ ut_asserteq_str("mmc1.bootdev", std->cur_bootdev->name);
+
+ /* select by bootdev label*/
+ ut_assertok(run_command("bootdev select mmc1", 0));
+ ut_assert_console_end();
+ ut_assertnonnull(std->cur_bootdev);
+ ut_asserteq_str("mmc1.bootdev", std->cur_bootdev->name);
+
+ /* deselect */
+ ut_assertok(run_command("bootdev select", 0));
+ ut_assert_console_end();
+ ut_assertnull(std->cur_bootdev);
+
+ ut_asserteq(1, run_command("bootdev info", 0));
+ ut_assert_nextlinen("Please use");
+ ut_assert_console_end();
+
+ return 0;
+}
+BOOTSTD_TEST(bootdev_test_cmd_select, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
+
+/* Check bootdev labels */
+static int bootdev_test_labels(struct unit_test_state *uts)
+{
+ struct udevice *dev, *media;
+
+ ut_assertok(bootdev_find_by_label("mmc2", &dev));
+ ut_asserteq(UCLASS_BOOTDEV, device_get_uclass_id(dev));
+ media = dev_get_parent(dev);
+ ut_asserteq(UCLASS_MMC, device_get_uclass_id(media));
+ ut_asserteq_str("mmc2", media->name);
+
+ /* Check invalid uclass */
+ ut_asserteq(-EINVAL, bootdev_find_by_label("fred0", &dev));
+
+ /* Check unknown sequence number */
+ ut_asserteq(-ENOENT, bootdev_find_by_label("mmc6", &dev));
+
+ return 0;
+}
+BOOTSTD_TEST(bootdev_test_labels, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
+
+/* Check bootdev ordering with the bootdev-order property */
+static int bootdev_test_order(struct unit_test_state *uts)
+{
+ struct bootflow_iter iter;
+ struct bootflow bflow;
+
+ /*
+ * First try the order set by the bootdev-order property
+ * Like all sandbox unit tests this relies on the devicetree setting up
+ * the required devices:
+ *
+ * mmc0 - nothing connected
+ * mmc1 - connected to mmc1.img file
+ * mmc2 - nothing connected
+ */
+ ut_assertok(env_set("boot_targets", NULL));
+ ut_assertok(bootflow_scan_first(&iter, 0, &bflow));
+ ut_asserteq(2, iter.num_devs);
+ ut_asserteq_str("mmc2.bootdev", iter.dev_order[0]->name);
+ ut_asserteq_str("mmc1.bootdev", iter.dev_order[1]->name);
+ bootflow_iter_uninit(&iter);
+
+ /* Use the environment variable to override it */
+ ut_assertok(env_set("boot_targets", "mmc1 mmc2"));
+ ut_assertok(bootflow_scan_first(&iter, 0, &bflow));
+ ut_asserteq(2, iter.num_devs);
+ ut_asserteq_str("mmc1.bootdev", iter.dev_order[0]->name);
+ ut_asserteq_str("mmc2.bootdev", iter.dev_order[1]->name);
+ bootflow_iter_uninit(&iter);
+
+ /*
+ * Now drop both orderings, to check the default (prioriy/sequence)
+ * ordering
+ */
+ ut_assertok(env_set("boot_targets", NULL));
+ ut_assertok(bootstd_test_drop_bootdev_order(uts));
+
+ ut_assertok(bootflow_scan_first(&iter, 0, &bflow));
+ ut_asserteq(3, iter.num_devs);
+ ut_asserteq_str("mmc2.bootdev", iter.dev_order[0]->name);
+ ut_asserteq_str("mmc1.bootdev", iter.dev_order[1]->name);
+ ut_asserteq_str("mmc0.bootdev", iter.dev_order[2]->name);
+
+ /*
+ * Check that adding aliases for the bootdevs works. We just fake it by
+ * setting the sequence numbers directly.
+ */
+ iter.dev_order[0]->seq_ = 0;
+ iter.dev_order[1]->seq_ = 3;
+ iter.dev_order[2]->seq_ = 2;
+ bootflow_iter_uninit(&iter);
+
+ ut_assertok(bootflow_scan_first(&iter, 0, &bflow));
+ ut_asserteq(3, iter.num_devs);
+ ut_asserteq_str("mmc2.bootdev", iter.dev_order[0]->name);
+ ut_asserteq_str("mmc0.bootdev", iter.dev_order[1]->name);
+ ut_asserteq_str("mmc1.bootdev", iter.dev_order[2]->name);
+ bootflow_iter_uninit(&iter);
+
+ return 0;
+}
+BOOTSTD_TEST(bootdev_test_order, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
+
+/* Check bootdev ordering with the uclass priority */
+static int bootdev_test_prio(struct unit_test_state *uts)
+{
+ struct bootdev_uc_plat *ucp;
+ struct bootflow_iter iter;
+ struct bootflow bflow;
+ struct udevice *blk;
+
+ /* Start up USB which gives us three additional bootdevs */
+ usb_started = false;
+ ut_assertok(run_command("usb start", 0));
+
+ ut_assertok(bootstd_test_drop_bootdev_order(uts));
+
+ /* 3 MMC and 3 USB bootdevs: MMC should come before USB */
+ console_record_reset_enable();
+ ut_assertok(bootflow_scan_first(&iter, 0, &bflow));
+ ut_asserteq(6, iter.num_devs);
+ ut_asserteq_str("mmc2.bootdev", iter.dev_order[0]->name);
+ ut_asserteq_str("usb_mass_storage.lun0.bootdev",
+ iter.dev_order[3]->name);
+
+ ut_assertok(bootdev_get_sibling_blk(iter.dev_order[3], &blk));
+ ut_asserteq_str("usb_mass_storage.lun0", blk->name);
+
+ /* adjust the priority of the first USB bootdev to the highest */
+ ucp = dev_get_uclass_plat(iter.dev_order[3]);
+ ucp->prio = 1;
+
+ bootflow_iter_uninit(&iter);
+ ut_assertok(bootflow_scan_first(&iter, 0, &bflow));
+ ut_asserteq(6, iter.num_devs);
+ ut_asserteq_str("usb_mass_storage.lun0.bootdev",
+ iter.dev_order[0]->name);
+ ut_asserteq_str("mmc2.bootdev", iter.dev_order[1]->name);
+
+ return 0;
+}
+BOOTSTD_TEST(bootdev_test_prio, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c
new file mode 100644
index 00000000000..1ebb789e97b
--- /dev/null
+++ b/test/boot/bootflow.c
@@ -0,0 +1,400 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Test for bootdev functions. All start with 'bootdev'
+ *
+ * Copyright 2021 Google LLC
+ * Written by Simon Glass <sjg@chromium.org>
+ */
+
+#include <common.h>
+#include <bootdev.h>
+#include <bootflow.h>
+#include <bootstd.h>
+#include <dm.h>
+#include <dm/lists.h>
+#include <test/suites.h>
+#include <test/ut.h>
+#include "bootstd_common.h"
+
+/* Check 'bootflow scan/list' commands */
+static int bootflow_cmd(struct unit_test_state *uts)
+{
+ console_record_reset_enable();
+ ut_assertok(run_command("bootdev select 1", 0));
+ ut_assert_console_end();
+ ut_assertok(run_command("bootflow scan -l", 0));
+ ut_assert_nextline("Scanning for bootflows in bootdev 'mmc1.bootdev'");
+ ut_assert_nextline("Seq Method State Uclass Part Name Filename");
+ ut_assert_nextlinen("---");
+ ut_assert_nextline(" 0 syslinux ready mmc 1 mmc1.bootdev.part_1 /extlinux/extlinux.conf");
+ ut_assert_nextlinen("---");
+ ut_assert_nextline("(1 bootflow, 1 valid)");
+ ut_assert_console_end();
+
+ ut_assertok(run_command("bootflow list", 0));
+ ut_assert_nextline("Showing bootflows for bootdev 'mmc1.bootdev'");
+ ut_assert_nextline("Seq Method State Uclass Part Name Filename");
+ ut_assert_nextlinen("---");
+ ut_assert_nextline(" 0 syslinux ready mmc 1 mmc1.bootdev.part_1 /extlinux/extlinux.conf");
+ ut_assert_nextlinen("---");
+ ut_assert_nextline("(1 bootflow, 1 valid)");
+ ut_assert_console_end();
+
+ return 0;
+}
+BOOTSTD_TEST(bootflow_cmd, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
+
+/* Check 'bootflow scan' with a name / label / seq */
+static int bootflow_cmd_label(struct unit_test_state *uts)
+{
+ console_record_reset_enable();
+ ut_assertok(run_command("bootflow scan -l mmc1", 0));
+ ut_assert_nextline("Scanning for bootflows in bootdev 'mmc1.bootdev'");
+ ut_assert_skip_to_line("(1 bootflow, 1 valid)");
+ ut_assert_console_end();
+
+ ut_assertok(run_command("bootflow scan -l mmc0.bootdev", 0));
+ ut_assert_nextline("Scanning for bootflows in bootdev 'mmc0.bootdev'");
+ ut_assert_skip_to_line("(0 bootflows, 0 valid)");
+ ut_assert_console_end();
+
+ ut_assertok(run_command("bootflow scan -l 0", 0));
+ ut_assert_nextline("Scanning for bootflows in bootdev 'mmc2.bootdev'");
+ ut_assert_skip_to_line("(0 bootflows, 0 valid)");
+ ut_assert_console_end();
+
+ return 0;
+}
+BOOTSTD_TEST(bootflow_cmd_label, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
+
+/* Check 'bootflow scan/list' commands using all bootdevs */
+static int bootflow_cmd_glob(struct unit_test_state *uts)
+{
+ ut_assertok(bootstd_test_drop_bootdev_order(uts));
+
+ console_record_reset_enable();
+ ut_assertok(run_command("bootflow scan -l", 0));
+ ut_assert_nextline("Scanning for bootflows in all bootdevs");
+ ut_assert_nextline("Seq Method State Uclass Part Name Filename");
+ ut_assert_nextlinen("---");
+ ut_assert_nextline("Scanning bootdev 'mmc2.bootdev':");
+ ut_assert_nextline("Scanning bootdev 'mmc1.bootdev':");
+ ut_assert_nextline(" 0 syslinux ready mmc 1 mmc1.bootdev.part_1 /extlinux/extlinux.conf");
+ ut_assert_nextline("Scanning bootdev 'mmc0.bootdev':");
+ ut_assert_nextline("No more bootdevs");
+ ut_assert_nextlinen("---");
+ ut_assert_nextline("(1 bootflow, 1 valid)");
+ ut_assert_console_end();
+
+ ut_assertok(run_command("bootflow list", 0));
+ ut_assert_nextline("Showing all bootflows");
+ ut_assert_nextline("Seq Method State Uclass Part Name Filename");
+ ut_assert_nextlinen("---");
+ ut_assert_nextline(" 0 syslinux ready mmc 1 mmc1.bootdev.part_1 /extlinux/extlinux.conf");
+ ut_assert_nextlinen("---");
+ ut_assert_nextline("(1 bootflow, 1 valid)");
+ ut_assert_console_end();
+
+ return 0;
+}
+BOOTSTD_TEST(bootflow_cmd_glob, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
+
+/* Check 'bootflow scan -e' */
+static int bootflow_cmd_scan_e(struct unit_test_state *uts)
+{
+ ut_assertok(bootstd_test_drop_bootdev_order(uts));
+
+ console_record_reset_enable();
+ ut_assertok(run_command("bootflow scan -ale", 0));
+ ut_assert_nextline("Scanning for bootflows in all bootdevs");
+ ut_assert_nextline("Seq Method State Uclass Part Name Filename");
+ ut_assert_nextlinen("---");
+ ut_assert_nextline("Scanning bootdev 'mmc2.bootdev':");
+ ut_assert_nextline(" 0 syslinux media mmc 0 mmc2.bootdev.whole <NULL>");
+ ut_assert_nextline(" ** No partition found, err=-93");
+ ut_assert_nextline(" 1 efi media mmc 0 mmc2.bootdev.whole <NULL>");
+ ut_assert_nextline(" ** No partition found, err=-93");
+
+ ut_assert_nextline("Scanning bootdev 'mmc1.bootdev':");
+ ut_assert_nextline(" 2 syslinux media mmc 0 mmc1.bootdev.whole <NULL>");
+ ut_assert_nextline(" ** No partition found, err=-2");
+ ut_assert_nextline(" 3 efi media mmc 0 mmc1.bootdev.whole <NULL>");
+ ut_assert_nextline(" ** No partition found, err=-2");
+ ut_assert_nextline(" 4 syslinux ready mmc 1 mmc1.bootdev.part_1 /extlinux/extlinux.conf");
+ ut_assert_nextline(" 5 efi fs mmc 1 mmc1.bootdev.part_1 efi/boot/bootsbox.efi");
+
+ ut_assert_skip_to_line("Scanning bootdev 'mmc0.bootdev':");
+ ut_assert_skip_to_line(" 3f efi media mmc 0 mmc0.bootdev.whole <NULL>");
+ ut_assert_nextline(" ** No partition found, err=-93");
+ ut_assert_nextline("No more bootdevs");
+ ut_assert_nextlinen("---");
+ ut_assert_nextline("(64 bootflows, 1 valid)");
+ ut_assert_console_end();
+
+ ut_assertok(run_command("bootflow list", 0));
+ ut_assert_nextline("Showing all bootflows");
+ ut_assert_nextline("Seq Method State Uclass Part Name Filename");
+ ut_assert_nextlinen("---");
+ ut_assert_nextline(" 0 syslinux media mmc 0 mmc2.bootdev.whole <NULL>");
+ ut_assert_nextline(" 1 efi media mmc 0 mmc2.bootdev.whole <NULL>");
+ ut_assert_skip_to_line(" 4 syslinux ready mmc 1 mmc1.bootdev.part_1 /extlinux/extlinux.conf");
+ ut_assert_skip_to_line(" 3f efi media mmc 0 mmc0.bootdev.whole <NULL>");
+ ut_assert_nextlinen("---");
+ ut_assert_nextline("(64 bootflows, 1 valid)");
+ ut_assert_console_end();
+
+ return 0;
+}
+BOOTSTD_TEST(bootflow_cmd_scan_e, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
+
+/* Check 'bootflow info' */
+static int bootflow_cmd_info(struct unit_test_state *uts)
+{
+ console_record_reset_enable();
+ ut_assertok(run_command("bootdev select 1", 0));
+ ut_assert_console_end();
+ ut_assertok(run_command("bootflow scan", 0));
+ ut_assert_console_end();
+ ut_assertok(run_command("bootflow select 0", 0));
+ ut_assert_console_end();
+ ut_assertok(run_command("bootflow info", 0));
+ ut_assert_nextline("Name: mmc1.bootdev.part_1");
+ ut_assert_nextline("Device: mmc1.bootdev");
+ ut_assert_nextline("Block dev: mmc1.blk");
+ ut_assert_nextline("Method: syslinux");
+ ut_assert_nextline("State: ready");
+ ut_assert_nextline("Partition: 1");
+ ut_assert_nextline("Subdir: (none)");
+ ut_assert_nextline("Filename: /extlinux/extlinux.conf");
+ ut_assert_nextlinen("Buffer: ");
+ ut_assert_nextline("Size: 253 (595 bytes)");
+ ut_assert_nextline("Error: 0");
+ ut_assert_console_end();
+
+ ut_assertok(run_command("bootflow info -d", 0));
+ ut_assert_nextline("Name: mmc1.bootdev.part_1");
+ ut_assert_skip_to_line("Error: 0");
+ ut_assert_nextline("Contents:");
+ ut_assert_nextline("%s", "");
+ ut_assert_nextline("# extlinux.conf generated by appliance-creator");
+ ut_assert_skip_to_line(" initrd /initramfs-5.3.7-301.fc31.armv7hl.img");
+ ut_assert_console_end();
+
+ return 0;
+}
+BOOTSTD_TEST(bootflow_cmd_info, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
+
+/* Check 'bootflow scan -b' to boot the first available bootdev */
+static int bootflow_scan_boot(struct unit_test_state *uts)
+{
+ console_record_reset_enable();
+ ut_assertok(run_command("bootflow scan -b", 0));
+ ut_assert_nextline(
+ "** Booting bootflow 'mmc1.bootdev.part_1' with syslinux");
+ ut_assert_nextline("Ignoring unknown command: ui");
+
+ /*
+ * We expect it to get through to boot although sandbox always returns
+ * -EFAULT as it cannot actually boot the kernel
+ */
+ ut_assert_skip_to_line("sandbox: continuing, as we cannot run Linux");
+ ut_assert_nextline("Boot failed (err=-14)");
+ ut_assert_console_end();
+
+ return 0;
+}
+BOOTSTD_TEST(bootflow_scan_boot, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
+
+/* Check iterating through available bootflows */
+static int bootflow_iter(struct unit_test_state *uts)
+{
+ struct bootflow_iter iter;
+ struct bootflow bflow;
+
+ bootstd_clear_glob();
+
+ /* The first device is mmc2.bootdev which has no media */
+ ut_asserteq(-EPROTONOSUPPORT,
+ bootflow_scan_first(&iter, BOOTFLOWF_ALL, &bflow));
+ ut_asserteq(2, iter.num_methods);
+ ut_asserteq(0, iter.cur_method);
+ ut_asserteq(0, iter.part);
+ ut_asserteq(0, iter.max_part);
+ ut_asserteq_str("syslinux", iter.method->name);
+ ut_asserteq(0, bflow.err);
+
+ /*
+ * This shows MEDIA even though there is none, since int
+ * bootdev_find_in_blk() we call part_get_info() which returns
+ * -EPROTONOSUPPORT. Ideally it would return -EEOPNOTSUPP and we would
+ * know.
+ */
+ ut_asserteq(BOOTFLOWST_MEDIA, bflow.state);
+
+ ut_asserteq(-EPROTONOSUPPORT, bootflow_scan_next(&iter, &bflow));
+ ut_asserteq(2, iter.num_methods);
+ ut_asserteq(1, iter.cur_method);
+ ut_asserteq(0, iter.part);
+ ut_asserteq(0, iter.max_part);
+ ut_asserteq_str("efi", iter.method->name);
+ ut_asserteq(0, bflow.err);
+ ut_asserteq(BOOTFLOWST_MEDIA, bflow.state);
+ bootflow_free(&bflow);
+
+ /* The next device is mmc1.bootdev - at first we use the whole device */
+ ut_asserteq(-ENOENT, bootflow_scan_next(&iter, &bflow));
+ ut_asserteq(2, iter.num_methods);
+ ut_asserteq(0, iter.cur_method);
+ ut_asserteq(0, iter.part);
+ ut_asserteq(0x1e, iter.max_part);
+ ut_asserteq_str("syslinux", iter.method->name);
+ ut_asserteq(0, bflow.err);
+ ut_asserteq(BOOTFLOWST_MEDIA, bflow.state);
+ bootflow_free(&bflow);
+
+ ut_asserteq(-ENOENT, bootflow_scan_next(&iter, &bflow));
+ ut_asserteq(2, iter.num_methods);
+ ut_asserteq(1, iter.cur_method);
+ ut_asserteq(0, iter.part);
+ ut_asserteq(0x1e, iter.max_part);
+ ut_asserteq_str("efi", iter.method->name);
+ ut_asserteq(0, bflow.err);
+ ut_asserteq(BOOTFLOWST_MEDIA, bflow.state);
+ bootflow_free(&bflow);
+
+ /* Then more to partition 1 where we find something */
+ ut_assertok(bootflow_scan_next(&iter, &bflow));
+ ut_asserteq(2, iter.num_methods);
+ ut_asserteq(0, iter.cur_method);
+ ut_asserteq(1, iter.part);
+ ut_asserteq(0x1e, iter.max_part);
+ ut_asserteq_str("syslinux", iter.method->name);
+ ut_asserteq(0, bflow.err);
+ ut_asserteq(BOOTFLOWST_READY, bflow.state);
+ bootflow_free(&bflow);
+
+ ut_asserteq(-ENOENT, bootflow_scan_next(&iter, &bflow));
+ ut_asserteq(2, iter.num_methods);
+ ut_asserteq(1, iter.cur_method);
+ ut_asserteq(1, iter.part);
+ ut_asserteq(0x1e, iter.max_part);
+ ut_asserteq_str("efi", iter.method->name);
+ ut_asserteq(0, bflow.err);
+ ut_asserteq(BOOTFLOWST_FS, bflow.state);
+ bootflow_free(&bflow);
+
+ /* Then more to partition 2 which doesn't exist */
+ ut_asserteq(-ENOENT, bootflow_scan_next(&iter, &bflow));
+ ut_asserteq(2, iter.num_methods);
+ ut_asserteq(0, iter.cur_method);
+ ut_asserteq(2, iter.part);
+ ut_asserteq(0x1e, iter.max_part);
+ ut_asserteq_str("syslinux", iter.method->name);
+ ut_asserteq(0, bflow.err);
+ ut_asserteq(BOOTFLOWST_MEDIA, bflow.state);
+ bootflow_free(&bflow);
+
+ bootflow_iter_uninit(&iter);
+
+ ut_assert_console_end();
+
+ return 0;
+}
+BOOTSTD_TEST(bootflow_iter, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
+
+/* Check using the system bootdev */
+static int bootflow_system(struct unit_test_state *uts)
+{
+ struct udevice *bootstd, *dev;
+
+ /* Add the EFI bootmgr driver */
+ ut_assertok(uclass_first_device_err(UCLASS_BOOTSTD, &bootstd));
+ ut_assertok(device_bind_driver(bootstd, "bootmeth_efi_mgr", "bootmgr",
+ &dev));
+
+ /* Add the system bootdev that it uses */
+ ut_assertok(device_bind_driver(bootstd, "system_bootdev",
+ "system-bootdev", &dev));
+
+ ut_assertok(bootstd_test_drop_bootdev_order(uts));
+
+ /* We should get a single 'bootmgr' method right at the end */
+ bootstd_clear_glob();
+ console_record_reset_enable();
+ ut_assertok(run_command("bootflow scan -l", 0));
+ ut_assert_skip_to_line(" 1 bootmgr ready bootstd 0 <NULL> <NULL>");
+ ut_assert_nextline("No more bootdevs");
+ ut_assert_skip_to_line("(2 bootflows, 2 valid)");
+ ut_assert_console_end();
+
+ return 0;
+}
+BOOTSTD_TEST(bootflow_system, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
+
+/* Check disabling a bootmethod if it requests it */
+static int bootflow_iter_disable(struct unit_test_state *uts)
+{
+ struct udevice *bootstd, *dev;
+ struct bootflow_iter iter;
+ struct bootflow bflow;
+ int i;
+
+ /* Add the EFI bootmgr driver */
+ ut_assertok(uclass_first_device_err(UCLASS_BOOTSTD, &bootstd));
+ ut_assertok(device_bind_driver(bootstd, "bootmeth_sandbox", "sandbox",
+ &dev));
+
+ /* Add the system bootdev that it uses */
+ ut_assertok(device_bind_driver(bootstd, "system_bootdev",
+ "system-bootdev", &dev));
+
+ ut_assertok(bootstd_test_drop_bootdev_order(uts));
+
+ bootstd_clear_glob();
+ ut_assertok(run_command("bootflow scan -lb", 0));
+
+ /* Try to boot the bootmgr flow, which will fail */
+ console_record_reset_enable();
+ ut_assertok(bootflow_scan_first(&iter, 0, &bflow));
+ ut_asserteq(3, iter.num_methods);
+ ut_asserteq_str("sandbox", iter.method->name);
+ ut_asserteq(-ENOTSUPP, bootflow_run_boot(&iter, &bflow));
+
+ ut_assert_skip_to_line("Boot method 'sandbox' failed and will not be retried");
+ ut_assert_console_end();
+
+ /* Check that the sandbox bootmeth has been removed */
+ ut_asserteq(2, iter.num_methods);
+ for (i = 0; i < iter.num_methods; i++)
+ ut_assert(strcmp("sandbox", iter.method_order[i]->name));
+
+ return 0;
+}
+BOOTSTD_TEST(bootflow_iter_disable, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
+
+/* Check 'bootflow boot' to boot a selected bootflow */
+static int bootflow_cmd_boot(struct unit_test_state *uts)
+{
+ console_record_reset_enable();
+ ut_assertok(run_command("bootdev select 1", 0));
+ ut_assert_console_end();
+ ut_assertok(run_command("bootflow scan", 0));
+ ut_assert_console_end();
+ ut_assertok(run_command("bootflow select 0", 0));
+ ut_assert_console_end();
+ ut_asserteq(1, run_command("bootflow boot", 0));
+ ut_assert_nextline(
+ "** Booting bootflow 'mmc1.bootdev.part_1' with syslinux");
+ ut_assert_nextline("Ignoring unknown command: ui");
+
+ /*
+ * We expect it to get through to boot although sandbox always returns
+ * -EFAULT as it cannot actually boot the kernel
+ */
+ ut_assert_skip_to_line("sandbox: continuing, as we cannot run Linux");
+ ut_assert_nextline("Boot failed (err=-14)");
+ ut_assert_console_end();
+
+ return 0;
+}
+BOOTSTD_TEST(bootflow_cmd_boot, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
diff --git a/test/boot/bootmeth.c b/test/boot/bootmeth.c
new file mode 100644
index 00000000000..07776c5368d
--- /dev/null
+++ b/test/boot/bootmeth.c
@@ -0,0 +1,122 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Test for bootdev functions. All start with 'bootdev'
+ *
+ * Copyright 2021 Google LLC
+ * Written by Simon Glass <sjg@chromium.org>
+ */
+
+#include <common.h>
+#include <bootstd.h>
+#include <test/suites.h>
+#include <test/ut.h>
+#include "bootstd_common.h"
+
+/* Check 'bootmeth list' command */
+static int bootmeth_cmd_list(struct unit_test_state *uts)
+{
+ console_record_reset_enable();
+ ut_assertok(run_command("bootmeth list", 0));
+ ut_assert_nextline("Order Seq Name Description");
+ ut_assert_nextlinen("---");
+ ut_assert_nextline(" 0 0 syslinux Syslinux boot from a block device");
+ ut_assert_nextline(" 1 1 efi EFI boot from an .efi file");
+ ut_assert_nextlinen("---");
+ ut_assert_nextline("(2 bootmeths)");
+ ut_assert_console_end();
+
+ return 0;
+}
+BOOTSTD_TEST(bootmeth_cmd_list, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
+
+/* Check 'bootmeth order' command */
+static int bootmeth_cmd_order(struct unit_test_state *uts)
+{
+ /* Select just one bootmethod */
+ console_record_reset_enable();
+ ut_assertok(run_command("bootmeth order syslinux", 0));
+ ut_assert_console_end();
+ ut_assertnonnull(env_get("bootmeths"));
+ ut_asserteq_str("syslinux", env_get("bootmeths"));
+
+ /* Only that one should be listed */
+ ut_assertok(run_command("bootmeth list", 0));
+ ut_assert_nextline("Order Seq Name Description");
+ ut_assert_nextlinen("---");
+ ut_assert_nextline(" 0 0 syslinux Syslinux boot from a block device");
+ ut_assert_nextlinen("---");
+ ut_assert_nextline("(1 bootmeth)");
+ ut_assert_console_end();
+
+ /* Check the -a flag, efi should show as not in the order ("-") */
+ ut_assertok(run_command("bootmeth list -a", 0));
+ ut_assert_nextline("Order Seq Name Description");
+ ut_assert_nextlinen("---");
+ ut_assert_nextline(" 0 0 syslinux Syslinux boot from a block device");
+ ut_assert_nextline(" - 1 efi EFI boot from an .efi file");
+ ut_assert_nextlinen("---");
+ ut_assert_nextline("(2 bootmeths)");
+ ut_assert_console_end();
+
+ /* Check the -a flag with the reverse order */
+ ut_assertok(run_command("bootmeth order \"efi syslinux\"", 0));
+ ut_assert_console_end();
+ ut_assertok(run_command("bootmeth list -a", 0));
+ ut_assert_nextline("Order Seq Name Description");
+ ut_assert_nextlinen("---");
+ ut_assert_nextline(" 1 0 syslinux Syslinux boot from a block device");
+ ut_assert_nextline(" 0 1 efi EFI boot from an .efi file");
+ ut_assert_nextlinen("---");
+ ut_assert_nextline("(2 bootmeths)");
+ ut_assert_console_end();
+
+ /* Now reset the order to empty, which should show all of them again */
+ ut_assertok(run_command("bootmeth order", 0));
+ ut_assert_console_end();
+ ut_assertnull(env_get("bootmeths"));
+ ut_assertok(run_command("bootmeth list", 0));
+ ut_assert_skip_to_line("(2 bootmeths)");
+
+ /* Try reverse order */
+ ut_assertok(run_command("bootmeth order \"efi syslinux\"", 0));
+ ut_assert_console_end();
+ ut_assertok(run_command("bootmeth list", 0));
+ ut_assert_nextline("Order Seq Name Description");
+ ut_assert_nextlinen("---");
+ ut_assert_nextline(" 0 1 efi EFI boot from an .efi file");
+ ut_assert_nextline(" 1 0 syslinux Syslinux boot from a block device");
+ ut_assert_nextlinen("---");
+ ut_assert_nextline("(2 bootmeths)");
+ ut_assertnonnull(env_get("bootmeths"));
+ ut_asserteq_str("efi syslinux", env_get("bootmeths"));
+ ut_assert_console_end();
+
+ return 0;
+}
+BOOTSTD_TEST(bootmeth_cmd_order, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
+
+/* Check 'bootmeths' env var */
+static int bootmeth_env(struct unit_test_state *uts)
+{
+ struct bootstd_priv *std;
+
+ ut_assertok(bootstd_get_priv(&std));
+
+ /* Select just one bootmethod */
+ console_record_reset_enable();
+ ut_assertok(env_set("bootmeths", "syslinux"));
+ ut_asserteq(1, std->bootmeth_count);
+
+ /* Select an invalid bootmethod */
+ ut_asserteq(1, run_command("setenv bootmeths fred", 0));
+ ut_assert_nextline("Unknown bootmeth 'fred'");
+ ut_assert_nextlinen("## Error inserting");
+ ut_assert_console_end();
+
+ ut_assertok(env_set("bootmeths", "efi syslinux"));
+ ut_asserteq(2, std->bootmeth_count);
+ ut_assert_console_end();
+
+ return 0;
+}
+BOOTSTD_TEST(bootmeth_env, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
diff --git a/test/boot/bootstd_common.c b/test/boot/bootstd_common.c
new file mode 100644
index 00000000000..05347d87106
--- /dev/null
+++ b/test/boot/bootstd_common.c
@@ -0,0 +1,35 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Test for bootdev functions. All start with 'bootdev'
+ *
+ * Copyright 2021 Google LLC
+ * Written by Simon Glass <sjg@chromium.org>
+ */
+
+#include <common.h>
+#include <bootstd.h>
+#include <dm.h>
+#include <test/suites.h>
+#include <test/ut.h>
+#include "bootstd_common.h"
+
+int bootstd_test_drop_bootdev_order(struct unit_test_state *uts)
+{
+ struct bootstd_priv *priv;
+ struct udevice *bootstd;
+
+ ut_assertok(uclass_first_device_err(UCLASS_BOOTSTD, &bootstd));
+ priv = dev_get_priv(bootstd);
+ priv->bootdev_order = NULL;
+
+ return 0;
+}
+
+int do_ut_bootstd(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
+{
+ struct unit_test *tests = UNIT_TEST_SUITE_START(bootstd_test);
+ const int n_ents = UNIT_TEST_SUITE_COUNT(bootstd_test);
+
+ return cmd_ut_category("bootstd", "bootstd_test_",
+ tests, n_ents, argc, argv);
+}
diff --git a/test/boot/bootstd_common.h b/test/boot/bootstd_common.h
new file mode 100644
index 00000000000..676ef0a57f9
--- /dev/null
+++ b/test/boot/bootstd_common.h
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Common header file for bootdev, bootflow, bootmeth tests
+ *
+ * Copyright 2021 Google LLC
+ * Written by Simon Glass <sjg@chromium.org>
+ */
+
+#ifndef __bootstd_common_h
+#define __bootstd_common_h
+
+/* Declare a new bootdev test */
+#define BOOTSTD_TEST(_name, _flags) \
+ UNIT_TEST(_name, _flags, bootstd_test)
+
+struct unit_test_state;
+
+/**
+ * bootstd_test_drop_bootdev_order() - Remove the existing boot order
+ *
+ * Drop the boot order so that all bootdevs are used in their alias order
+ *
+ * @uts: Unit test state to use for ut_assert...() functions
+ */
+int bootstd_test_drop_bootdev_order(struct unit_test_state *uts);
+
+#endif
diff --git a/test/cmd_ut.c b/test/cmd_ut.c
index 90b260f72d6..67a13ee32b8 100644
--- a/test/cmd_ut.c
+++ b/test/cmd_ut.c
@@ -28,6 +28,10 @@ int cmd_ut_category(const char *name, const char *prefix,
static struct cmd_tbl cmd_ut_sub[] = {
U_BOOT_CMD_MKENT(all, CONFIG_SYS_MAXARGS, 1, do_ut_all, "", ""),
+#ifdef CONFIG_BOOTSTD
+ U_BOOT_CMD_MKENT(bootstd, CONFIG_SYS_MAXARGS, 1, do_ut_bootstd,
+ "", ""),
+#endif
U_BOOT_CMD_MKENT(common, CONFIG_SYS_MAXARGS, 1, do_ut_common, "", ""),
#if defined(CONFIG_UT_DM)
U_BOOT_CMD_MKENT(dm, CONFIG_SYS_MAXARGS, 1, do_ut_dm, "", ""),
@@ -115,6 +119,9 @@ static char ut_help_text[] =
"ut bloblist - Test bloblist implementation\n"
"ut compression - Test compressors and bootm decompression\n"
#endif
+#ifdef CONFIG_BOOTSTD
+ "ut bootstd - Test standard boot implementation\n"
+#endif
#ifdef CONFIG_UT_DM
"ut dm [test-name]\n"
#endif
diff --git a/test/dm/Makefile b/test/dm/Makefile
index 9a1a904d906..f0a7c97e3d1 100644
--- a/test/dm/Makefile
+++ b/test/dm/Makefile
@@ -102,6 +102,7 @@ obj-y += syscon.o
obj-$(CONFIG_RESET_SYSCON) += syscon-reset.o
obj-$(CONFIG_SYSINFO) += sysinfo.o
obj-$(CONFIG_SYSINFO_GPIO) += sysinfo-gpio.o
+obj-$(CONFIG_UT_DM) += tag.o
obj-$(CONFIG_TEE) += tee.o
obj-$(CONFIG_TIMER) += timer.o
obj-$(CONFIG_DM_USB) += usb.o
diff --git a/test/dm/blk.c b/test/dm/blk.c
index 8556cc7159c..85c3a3bd45c 100644
--- a/test/dm/blk.c
+++ b/test/dm/blk.c
@@ -15,6 +15,9 @@
DECLARE_GLOBAL_DATA_PTR;
+/* Allow resetting the USB-started flag */
+extern char usb_started;
+
/* Test that block devices can be created */
static int dm_test_blk_base(struct unit_test_state *uts)
{
@@ -66,8 +69,11 @@ static int dm_test_blk_usb(struct unit_test_state *uts)
struct udevice *usb_dev, *dev;
struct blk_desc *dev_desc;
+ usb_started = false;
+
/* Get a flash device */
state_set_skip_delays(true);
+ ut_assertok(usb_stop());
ut_assertok(usb_init());
ut_assertok(uclass_get_device(UCLASS_MASS_STORAGE, 0, &usb_dev));
ut_assertok(blk_get_device_by_str("usb", "0", &dev_desc));
diff --git a/test/dm/core.c b/test/dm/core.c
index 0ce0b3c4a2e..ebd504427d1 100644
--- a/test/dm/core.c
+++ b/test/dm/core.c
@@ -1161,6 +1161,8 @@ static int dm_test_uclass_names(struct unit_test_state *uts)
ut_asserteq_str("test", uclass_get_name(UCLASS_TEST));
ut_asserteq(UCLASS_TEST, uclass_get_by_name("test"));
+ ut_asserteq(UCLASS_SPI, uclass_get_by_name("spi"));
+
return 0;
}
DM_TEST(dm_test_uclass_names, UT_TESTF_SCAN_PDATA);
@@ -1258,3 +1260,18 @@ static int dm_test_get_stats(struct unit_test_state *uts)
return 0;
}
DM_TEST(dm_test_get_stats, UT_TESTF_SCAN_FDT);
+
+/* Test uclass_find_device_by_name() */
+static int dm_test_uclass_find_device(struct unit_test_state *uts)
+{
+ struct udevice *dev;
+
+ ut_assertok(uclass_find_device_by_name(UCLASS_I2C, "i2c@0", &dev));
+ ut_asserteq(-ENODEV,
+ uclass_find_device_by_name(UCLASS_I2C, "i2c@0x", &dev));
+ ut_assertok(uclass_find_device_by_namelen(UCLASS_I2C, "i2c@0x", 5,
+ &dev));
+
+ return 0;
+}
+DM_TEST(dm_test_uclass_find_device, UT_TESTF_SCAN_FDT);
diff --git a/test/dm/fastboot.c b/test/dm/fastboot.c
index e7f8c362b85..758538d0e85 100644
--- a/test/dm/fastboot.c
+++ b/test/dm/fastboot.c
@@ -81,9 +81,9 @@ static int dm_test_fastboot_mmc_part(struct unit_test_state *uts)
&part_info, response));
ut_asserteq(0, fastboot_mmc_get_part_info("0.0:0", &fb_dev_desc,
&part_info, response));
- ut_asserteq(0, fastboot_mmc_get_part_info("1", &fb_dev_desc,
+ ut_asserteq(0, fastboot_mmc_get_part_info("2", &fb_dev_desc,
&part_info, response));
- ut_asserteq(0, fastboot_mmc_get_part_info("1.0", &fb_dev_desc,
+ ut_asserteq(0, fastboot_mmc_get_part_info("2.0", &fb_dev_desc,
&part_info, response));
ut_asserteq(1, fastboot_mmc_get_part_info(":1", &fb_dev_desc,
&part_info, response));
diff --git a/test/dm/tag.c b/test/dm/tag.c
new file mode 100644
index 00000000000..8ae8a1fcd65
--- /dev/null
+++ b/test/dm/tag.c
@@ -0,0 +1,84 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * DM tag test
+ *
+ * Copyright (c) 2021 Linaro Limited
+ * Author: AKASHI Takahiro
+ */
+
+#include <common.h>
+#include <dm/tag.h>
+#include <dm/test.h> /* DM_TEST() */
+#include <test/test.h> /* struct unit_test_state */
+#include <test/ut.h> /* assertions */
+
+/*
+ * Test dm_tag_ptr() API
+ */
+static int dm_test_tag_ptr(struct unit_test_state *uts)
+{
+ ulong val;
+ void *ptr = NULL;
+
+ ut_assertok(dev_tag_set_ptr(uts->root, DM_TAG_EFI, &val));
+
+ ut_assertok(dev_tag_get_ptr(uts->root, DM_TAG_EFI, &ptr));
+
+ ut_asserteq_ptr(&val, ptr);
+
+ ut_assertok(dev_tag_del(uts->root, DM_TAG_EFI));
+
+ return 0;
+}
+
+DM_TEST(dm_test_tag_ptr, 0);
+
+/*
+ * Test dm_tag_val() API
+ */
+static int dm_test_tag_val(struct unit_test_state *uts)
+{
+ ulong val1 = 0x12345678, val2 = 0;
+
+ ut_assertok(dev_tag_set_val(uts->root, DM_TAG_EFI, val1));
+
+ ut_assertok(dev_tag_get_val(uts->root, DM_TAG_EFI, &val2));
+
+ ut_asserteq_64(val1, val2);
+
+ ut_assertok(dev_tag_del(uts->root, DM_TAG_EFI));
+
+ return 0;
+}
+
+DM_TEST(dm_test_tag_val, 0);
+
+/*
+ * Test against an invalid tag
+ */
+static int dm_test_tag_inval(struct unit_test_state *uts)
+{
+ ulong val;
+
+ ut_asserteq(-EINVAL, dev_tag_set_ptr(uts->root, DM_TAG_COUNT, &val));
+
+ return 0;
+}
+
+DM_TEST(dm_test_tag_inval, 0);
+
+/*
+ * Test dm_tag_del_all() AP:
+ */
+static int dm_test_tag_del_all(struct unit_test_state *uts)
+{
+ ulong val;
+
+ ut_assertok(dev_tag_set_ptr(uts->root, DM_TAG_EFI, &val));
+
+ ut_assertok(dev_tag_del_all(uts->root));
+
+ return 0;
+}
+
+DM_TEST(dm_test_tag_del_all, 0);
diff --git a/test/print_ut.c b/test/print_ut.c
index 247011f2db0..47a6ce57840 100644
--- a/test/print_ut.c
+++ b/test/print_ut.c
@@ -345,26 +345,6 @@ static int print_do_hex_dump(struct unit_test_state *uts)
}
PRINT_TEST(print_do_hex_dump, UT_TESTF_CONSOLE_REC);
-static int print_itoa(struct unit_test_state *uts)
-{
- ut_asserteq_str("123", simple_itoa(123));
- ut_asserteq_str("0", simple_itoa(0));
- ut_asserteq_str("2147483647", simple_itoa(0x7fffffff));
- ut_asserteq_str("4294967295", simple_itoa(0xffffffff));
-
- /* Use #ifdef here to avoid a compiler warning on 32-bit machines */
-#ifdef CONFIG_PHYS_64BIT
- if (sizeof(ulong) == 8) {
- ut_asserteq_str("9223372036854775807",
- simple_itoa((1UL << 63) - 1));
- ut_asserteq_str("18446744073709551615", simple_itoa(-1));
- }
-#endif /* CONFIG_PHYS_64BIT */
-
- return 0;
-}
-PRINT_TEST(print_itoa, 0);
-
static int snprint(struct unit_test_state *uts)
{
char buf[10] = "xxxxxxxxx";
@@ -391,26 +371,6 @@ static int snprint(struct unit_test_state *uts)
}
PRINT_TEST(snprint, 0);
-static int print_xtoa(struct unit_test_state *uts)
-{
- ut_asserteq_str("7f", simple_xtoa(127));
- ut_asserteq_str("00", simple_xtoa(0));
- ut_asserteq_str("7fffffff", simple_xtoa(0x7fffffff));
- ut_asserteq_str("ffffffff", simple_xtoa(0xffffffff));
-
- /* Use #ifdef here to avoid a compiler warning on 32-bit machines */
-#ifdef CONFIG_PHYS_64BIT
- if (sizeof(ulong) == 8) {
- ut_asserteq_str("7fffffffffffffff",
- simple_xtoa((1UL << 63) - 1));
- ut_asserteq_str("ffffffffffffffff", simple_xtoa(-1));
- }
-#endif /* CONFIG_PHYS_64BIT */
-
- return 0;
-}
-PRINT_TEST(print_xtoa, 0);
-
int do_ut_print(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
{
struct unit_test *tests = UNIT_TEST_SUITE_START(print_test);
diff --git a/test/py/tests/bootstd/mmc1.img.xz b/test/py/tests/bootstd/mmc1.img.xz
new file mode 100644
index 00000000000..4e7f39b830e
--- /dev/null
+++ b/test/py/tests/bootstd/mmc1.img.xz
Binary files differ
diff --git a/test/py/tests/test_ut.py b/test/py/tests/test_ut.py
index 01c2b3ffa12..35fb393c1ff 100644
--- a/test/py/tests/test_ut.py
+++ b/test/py/tests/test_ut.py
@@ -1,9 +1,102 @@
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
+import gzip
+import os
import os.path
import pytest
+import u_boot_utils
+
+def mkdir_cond(dirname):
+ """Create a directory if it doesn't already exist
+
+ Args:
+ dirname: Name of directory to create
+ """
+ if not os.path.exists(dirname):
+ os.mkdir(dirname)
+
+def setup_bootflow_image(u_boot_console):
+ """Create a 20MB disk image with a single FAT partition"""
+ cons = u_boot_console
+ fname = os.path.join(cons.config.source_dir, 'mmc1.img')
+ mnt = os.path.join(cons.config.persistent_data_dir, 'mnt')
+ mkdir_cond(mnt)
+
+ u_boot_utils.run_and_log(cons, 'qemu-img create %s 20M' % fname)
+ u_boot_utils.run_and_log(cons, 'sudo sfdisk %s' % fname,
+ stdin=b'type=c')
+
+ loop = None
+ mounted = False
+ complete = False
+ try:
+ out = u_boot_utils.run_and_log(cons,
+ 'sudo losetup --show -f -P %s' % fname)
+ loop = out.strip()
+ fatpart = '%sp1' % loop
+ u_boot_utils.run_and_log(cons, 'sudo mkfs.vfat %s' % fatpart)
+ u_boot_utils.run_and_log(
+ cons, 'sudo mount -o loop %s %s -o uid=%d,gid=%d' %
+ (fatpart, mnt, os.getuid(), os.getgid()))
+ mounted = True
+
+ vmlinux = 'vmlinuz-5.3.7-301.fc31.armv7hl'
+ initrd = 'initramfs-5.3.7-301.fc31.armv7hl.img'
+ dtbdir = 'dtb-5.3.7-301.fc31.armv7hl'
+ script = '''# extlinux.conf generated by appliance-creator
+ui menu.c32
+menu autoboot Welcome to Fedora-Workstation-armhfp-31-1.9. Automatic boot in # second{,s}. Press a key for options.
+menu title Fedora-Workstation-armhfp-31-1.9 Boot Options.
+menu hidden
+timeout 20
+totaltimeout 600
+
+label Fedora-Workstation-armhfp-31-1.9 (5.3.7-301.fc31.armv7hl)
+ kernel /%s
+ append ro root=UUID=9732b35b-4cd5-458b-9b91-80f7047e0b8a rhgb quiet LANG=en_US.UTF-8 cma=192MB cma=256MB
+ fdtdir /%s/
+ initrd /%s''' % (vmlinux, dtbdir, initrd)
+ ext = os.path.join(mnt, 'extlinux')
+ mkdir_cond(ext)
+
+ with open(os.path.join(ext, 'extlinux.conf'), 'w') as fd:
+ print(script, file=fd)
+
+ inf = os.path.join(cons.config.persistent_data_dir, 'inf')
+ with open(inf, 'wb') as fd:
+ fd.write(gzip.compress(b'vmlinux'))
+ u_boot_utils.run_and_log(cons, 'mkimage -f auto -d %s %s' %
+ (inf, os.path.join(mnt, vmlinux)))
+
+ with open(os.path.join(mnt, initrd), 'w') as fd:
+ print('initrd', file=fd)
+
+ mkdir_cond(os.path.join(mnt, dtbdir))
+
+ dtb_file = os.path.join(mnt, '%s/sandbox.dtb' % dtbdir)
+ u_boot_utils.run_and_log(
+ cons, 'dtc -o %s' % dtb_file, stdin=b'/dts-v1/; / {};')
+ complete = True
+ except ValueError as exc:
+ print('Falled to create image, failing back to prepared copy: %s',
+ str(exc))
+ finally:
+ if mounted:
+ u_boot_utils.run_and_log(cons, 'sudo umount %s' % mnt)
+ if loop:
+ u_boot_utils.run_and_log(cons, 'sudo losetup -d %s' % loop)
+
+ if not complete:
+ # Use a prepared image since we cannot create one
+ infname = os.path.join(cons.config.source_dir,
+ 'test/py/tests/bootstd/mmc1.img.xz')
+ u_boot_utils.run_and_log(
+ cons,
+ ['sh', '-c', 'xz -dc %s >%s' % (infname, fname)])
+
+
@pytest.mark.buildconfigspec('ut_dm')
def test_ut_dm_init(u_boot_console):
"""Initialize data for ut dm tests."""
@@ -21,6 +114,16 @@ def test_ut_dm_init(u_boot_console):
with open(fn, 'wb') as fh:
fh.write(data)
+@pytest.mark.buildconfigspec('cmd_bootflow')
+def test_ut_dm_init_bootstd(u_boot_console):
+ """Initialise data for bootflow tests"""
+
+ setup_bootflow_image(u_boot_console)
+
+ # Restart so that the new mmc1.img is picked up
+ u_boot_console.restart_uboot()
+
+
def test_ut(u_boot_console, ut_subtest):
"""Execute a "ut" subtest.
diff --git a/test/str_ut.c b/test/str_ut.c
index d2840d51524..5a844347c2b 100644
--- a/test/str_ut.c
+++ b/test/str_ut.c
@@ -202,6 +202,78 @@ static int str_dectoul(struct unit_test_state *uts)
}
STR_TEST(str_dectoul, 0);
+static int str_itoa(struct unit_test_state *uts)
+{
+ ut_asserteq_str("123", simple_itoa(123));
+ ut_asserteq_str("0", simple_itoa(0));
+ ut_asserteq_str("2147483647", simple_itoa(0x7fffffff));
+ ut_asserteq_str("4294967295", simple_itoa(0xffffffff));
+
+ /* Use #ifdef here to avoid a compiler warning on 32-bit machines */
+#ifdef CONFIG_PHYS_64BIT
+ if (sizeof(ulong) == 8) {
+ ut_asserteq_str("9223372036854775807",
+ simple_itoa((1UL << 63) - 1));
+ ut_asserteq_str("18446744073709551615", simple_itoa(-1));
+ }
+#endif /* CONFIG_PHYS_64BIT */
+
+ return 0;
+}
+STR_TEST(str_itoa, 0);
+
+static int str_xtoa(struct unit_test_state *uts)
+{
+ ut_asserteq_str("7f", simple_xtoa(127));
+ ut_asserteq_str("00", simple_xtoa(0));
+ ut_asserteq_str("7fffffff", simple_xtoa(0x7fffffff));
+ ut_asserteq_str("ffffffff", simple_xtoa(0xffffffff));
+
+ /* Use #ifdef here to avoid a compiler warning on 32-bit machines */
+#ifdef CONFIG_PHYS_64BIT
+ if (sizeof(ulong) == 8) {
+ ut_asserteq_str("7fffffffffffffff",
+ simple_xtoa((1UL << 63) - 1));
+ ut_asserteq_str("ffffffffffffffff", simple_xtoa(-1));
+ }
+#endif /* CONFIG_PHYS_64BIT */
+
+ return 0;
+}
+STR_TEST(str_xtoa, 0);
+
+static int str_trailing(struct unit_test_state *uts)
+{
+ const char str1[] = "abc123def";
+ const char str2[] = "abc123def456";
+ const char *end;
+
+ ut_asserteq(-1, trailing_strtol(""));
+ ut_asserteq(-1, trailing_strtol("123"));
+ ut_asserteq(123, trailing_strtol("abc123"));
+ ut_asserteq(4, trailing_strtol("12c4"));
+ ut_asserteq(-1, trailing_strtol("abd"));
+ ut_asserteq(-1, trailing_strtol("abc123def"));
+
+ ut_asserteq(-1, trailing_strtoln(str1, NULL));
+ ut_asserteq(123, trailing_strtoln(str1, str1 + 6));
+ ut_asserteq(-1, trailing_strtoln(str1, str1 + 9));
+
+ ut_asserteq(3, trailing_strtol("a3"));
+
+ ut_asserteq(123, trailing_strtoln_end(str1, str1 + 6, &end));
+ ut_asserteq(3, end - str1);
+
+ ut_asserteq(-1, trailing_strtoln_end(str1, str1 + 7, &end));
+ ut_asserteq(7, end - str1);
+
+ ut_asserteq(456, trailing_strtoln_end(str2, NULL, &end));
+ ut_asserteq(9, end - str2);
+
+ return 0;
+}
+STR_TEST(str_trailing, 0);
+
int do_ut_str(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
{
struct unit_test *tests = UNIT_TEST_SUITE_START(str_test);
diff --git a/tools/binman/control.py b/tools/binman/control.py
index d4c8dc89201..ce57dc7efc7 100644
--- a/tools/binman/control.py
+++ b/tools/binman/control.py
@@ -299,10 +299,11 @@ def BeforeReplace(image, allow_resize):
"""
state.PrepareFromLoadedData(image)
image.LoadData()
+ image.CollectBintools()
# If repacking, drop the old offset/size values except for the original
# ones, so we are only left with the constraints.
- if allow_resize:
+ if image.allow_repack and allow_resize:
image.ResetForPack()
diff --git a/tools/binman/entry.py b/tools/binman/entry.py
index 18a7a351054..a07a5888643 100644
--- a/tools/binman/entry.py
+++ b/tools/binman/entry.py
@@ -775,7 +775,7 @@ features to produce new behaviours.
node = self._node
while node.parent:
node = node.parent
- if node.name == 'binman':
+ if node.name in ('binman', '/'):
break
name = '%s.%s' % (node.name, name)
return name
diff --git a/tools/binman/etype/_testing.py b/tools/binman/etype/_testing.py
index 5089de36429..69600487814 100644
--- a/tools/binman/etype/_testing.py
+++ b/tools/binman/etype/_testing.py
@@ -39,6 +39,10 @@ class Entry__testing(Entry):
error if not)
force-bad-datatype: Force a call to GetEntryArgsOrProps() with a bad
data type (generating an error)
+ require-bintool-for-contents: Raise an error if the specified
+ bintool isn't usable in ObtainContents()
+ require-bintool-for-pack: Raise an error if the specified
+ bintool isn't usable in Pack()
"""
def __init__(self, section, etype, node):
super().__init__(section, etype, node)
@@ -82,6 +86,26 @@ class Entry__testing(Entry):
self.return_contents = True
self.contents = b'aa'
+ # Set to the required bintool when collecting bintools.
+ self.bintool_for_contents = None
+ self.require_bintool_for_contents = fdt_util.GetString(self._node,
+ 'require-bintool-for-contents')
+ if self.require_bintool_for_contents == '':
+ self.require_bintool_for_contents = '_testing'
+
+ self.bintool_for_pack = None
+ self.require_bintool_for_pack = fdt_util.GetString(self._node,
+ 'require-bintool-for-pack')
+ if self.require_bintool_for_pack == '':
+ self.require_bintool_for_pack = '_testing'
+
+ def Pack(self, offset):
+ """Figure out how to pack the entry into the section"""
+ if self.require_bintool_for_pack:
+ if self.bintool_for_pack is None:
+ self.Raise("Required bintool unusable in Pack()")
+ return super().Pack(offset)
+
def ObtainContents(self, fake_size=0):
if self.return_unknown_contents or not self.return_contents:
return False
@@ -92,6 +116,9 @@ class Entry__testing(Entry):
self.contents_size = len(self.data)
if self.return_contents_once:
self.return_contents = False
+ if self.require_bintool_for_contents:
+ if self.bintool_for_contents is None:
+ self.Raise("Required bintool unusable in ObtainContents()")
return True
def GetOffsets(self):
@@ -127,3 +154,12 @@ class Entry__testing(Entry):
if not self.never_complete_process_fdt:
self.process_fdt_ready = True
return ready
+
+ def AddBintools(self, btools):
+ """Add the bintools used by this entry type"""
+ if self.require_bintool_for_contents is not None:
+ self.bintool_for_contents = self.AddBintool(btools,
+ self.require_bintool_for_contents)
+ if self.require_bintool_for_pack is not None:
+ self.bintool_for_pack = self.AddBintool(btools,
+ self.require_bintool_for_pack)
diff --git a/tools/binman/etype/fit.py b/tools/binman/etype/fit.py
index e0407715d81..12306623af6 100644
--- a/tools/binman/etype/fit.py
+++ b/tools/binman/etype/fit.py
@@ -380,11 +380,12 @@ class Entry_fit(Entry_section):
# section entries for them here to merge the content subnodes
# together and put the merged contents in the subimage node's
# 'data' property later.
- entry = Entry.Create(self.section, node, etype='section')
+ entry = Entry.Create(self, node, etype='section')
entry.ReadNode()
# The hash subnodes here are for mkimage, not binman.
entry.SetUpdateHash(False)
- self._entries[rel_path] = entry
+ image_name = rel_path[len('/images/'):]
+ self._entries[image_name] = entry
for subnode in node.subnodes:
_add_entries(base_node, depth + 1, subnode)
@@ -630,7 +631,8 @@ class Entry_fit(Entry_section):
has_images = depth == 2 and in_images
if has_images:
- entry = self._priv_entries[rel_path]
+ image_name = rel_path[len('/images/'):]
+ entry = self._priv_entries[image_name]
data = entry.GetData()
fsw.property('data', bytes(data))
@@ -643,12 +645,12 @@ class Entry_fit(Entry_section):
# fsw.add_node() or _add_node() for it.
pass
elif self.GetImage().generate and subnode.name.startswith('@'):
- entry = self._priv_entries.get(subnode_path)
+ entry = self._priv_entries.get(subnode.name)
_gen_node(base_node, subnode, depth, in_images, entry)
# This is a generator (template) entry, so remove it from
# the list of entries used by PackEntries(), etc. Otherwise
# it will appear in the binman output
- to_remove.append(subnode_path)
+ to_remove.append(subnode.name)
else:
with fsw.add_node(subnode.name):
_add_node(base_node, depth + 1, subnode)
@@ -693,7 +695,8 @@ class Entry_fit(Entry_section):
fdt = Fdt.FromData(self.GetData())
fdt.Scan()
- for path, section in self._entries.items():
+ for image_name, section in self._entries.items():
+ path = f"/images/{image_name}"
node = fdt.GetNode(path)
data_prop = node.props.get("data")
diff --git a/tools/binman/etype/section.py b/tools/binman/etype/section.py
index ccac658c183..bd67238b919 100644
--- a/tools/binman/etype/section.py
+++ b/tools/binman/etype/section.py
@@ -788,6 +788,9 @@ class Entry_section(Entry):
data = new_data
return data
+ def WriteData(self, data, decomp=True):
+ self.Raise("Replacing sections is not implemented yet")
+
def WriteChildData(self, child):
return True
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index 4ce181a0666..b5cf549703a 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -3764,6 +3764,13 @@ class TestFunctional(unittest.TestCase):
self.assertEqual(len(kernel_data), int(data_sizes[0].split()[0]))
self.assertEqual(len(fdt1_data), int(data_sizes[1].split()[0]))
+ # Check if entry listing correctly omits /images/
+ image = control.images['image']
+ fit_entry = image.GetEntries()['fit']
+ subentries = list(fit_entry.GetEntries().keys())
+ expected = ['kernel', 'fdt-1']
+ self.assertEqual(expected, subentries)
+
def testSimpleFit(self):
"""Test an image with a FIT inside"""
data = self._DoReadFile('161_fit.dts')
@@ -5523,5 +5530,178 @@ fdt fdtmap Extract the devicetree blob from the fdtmap
with self.assertRaises(ValueError) as e:
data = self._DoReadFile('231_pre_load_invalid_key.dts')
+ def _CheckSafeUniqueNames(self, *images):
+ """Check all entries of given images for unsafe unique names"""
+ for image in images:
+ entries = {}
+ image._CollectEntries(entries, {}, image)
+ for entry in entries.values():
+ uniq = entry.GetUniqueName()
+
+ # Used as part of a filename, so must not be absolute paths.
+ self.assertFalse(os.path.isabs(uniq))
+
+ def testSafeUniqueNames(self):
+ """Test entry unique names are safe in single image configuration"""
+ data = self._DoReadFileRealDtb('230_unique_names.dts')
+
+ orig_image = control.images['image']
+ image_fname = tools.get_output_filename('image.bin')
+ image = Image.FromFile(image_fname)
+
+ self._CheckSafeUniqueNames(orig_image, image)
+
+ def testSafeUniqueNamesMulti(self):
+ """Test entry unique names are safe with multiple images"""
+ data = self._DoReadFileRealDtb('231_unique_names_multi.dts')
+
+ orig_image = control.images['image']
+ image_fname = tools.get_output_filename('image.bin')
+ image = Image.FromFile(image_fname)
+
+ self._CheckSafeUniqueNames(orig_image, image)
+
+ def testReplaceCmdWithBintool(self):
+ """Test replacing an entry that needs a bintool to pack"""
+ data = self._DoReadFileRealDtb('232_replace_with_bintool.dts')
+ expected = U_BOOT_DATA + b'aa'
+ self.assertEqual(expected, data[:len(expected)])
+
+ try:
+ tmpdir, updated_fname = self._SetupImageInTmpdir()
+ fname = os.path.join(tmpdir, 'update-testing.bin')
+ tools.write_file(fname, b'zz')
+ self._DoBinman('replace', '-i', updated_fname,
+ '_testing', '-f', fname)
+
+ data = tools.read_file(updated_fname)
+ expected = U_BOOT_DATA + b'zz'
+ self.assertEqual(expected, data[:len(expected)])
+ finally:
+ shutil.rmtree(tmpdir)
+
+ def testReplaceCmdOtherWithBintool(self):
+ """Test replacing an entry when another needs a bintool to pack"""
+ data = self._DoReadFileRealDtb('232_replace_with_bintool.dts')
+ expected = U_BOOT_DATA + b'aa'
+ self.assertEqual(expected, data[:len(expected)])
+
+ try:
+ tmpdir, updated_fname = self._SetupImageInTmpdir()
+ fname = os.path.join(tmpdir, 'update-u-boot.bin')
+ tools.write_file(fname, b'x' * len(U_BOOT_DATA))
+ self._DoBinman('replace', '-i', updated_fname,
+ 'u-boot', '-f', fname)
+
+ data = tools.read_file(updated_fname)
+ expected = b'x' * len(U_BOOT_DATA) + b'aa'
+ self.assertEqual(expected, data[:len(expected)])
+ finally:
+ shutil.rmtree(tmpdir)
+
+ def testReplaceResizeNoRepackSameSize(self):
+ """Test replacing entries with same-size data without repacking"""
+ expected = b'x' * len(U_BOOT_DATA)
+ data, expected_fdtmap, _ = self._RunReplaceCmd('u-boot', expected)
+ self.assertEqual(expected, data)
+
+ path, fdtmap = state.GetFdtContents('fdtmap')
+ self.assertIsNotNone(path)
+ self.assertEqual(expected_fdtmap, fdtmap)
+
+ def testReplaceResizeNoRepackSmallerSize(self):
+ """Test replacing entries with smaller-size data without repacking"""
+ new_data = b'x'
+ data, expected_fdtmap, _ = self._RunReplaceCmd('u-boot', new_data)
+ expected = new_data.ljust(len(U_BOOT_DATA), b'\0')
+ self.assertEqual(expected, data)
+
+ path, fdtmap = state.GetFdtContents('fdtmap')
+ self.assertIsNotNone(path)
+ self.assertEqual(expected_fdtmap, fdtmap)
+
+ def testExtractFit(self):
+ """Test extracting a FIT section"""
+ self._DoReadFileRealDtb('233_fit_extract_replace.dts')
+ image_fname = tools.get_output_filename('image.bin')
+
+ fit_data = control.ReadEntry(image_fname, 'fit')
+ fit = fdt.Fdt.FromData(fit_data)
+ fit.Scan()
+
+ # Check subentry data inside the extracted fit
+ for node_path, expected in [
+ ('/images/kernel', U_BOOT_DATA),
+ ('/images/fdt-1', U_BOOT_NODTB_DATA),
+ ('/images/scr-1', COMPRESS_DATA),
+ ]:
+ node = fit.GetNode(node_path)
+ data = fit.GetProps(node)['data'].bytes
+ self.assertEqual(expected, data)
+
+ def testExtractFitSubentries(self):
+ """Test extracting FIT section subentries"""
+ self._DoReadFileRealDtb('233_fit_extract_replace.dts')
+ image_fname = tools.get_output_filename('image.bin')
+
+ for entry_path, expected in [
+ ('fit/kernel', U_BOOT_DATA),
+ ('fit/kernel/u-boot', U_BOOT_DATA),
+ ('fit/fdt-1', U_BOOT_NODTB_DATA),
+ ('fit/fdt-1/u-boot-nodtb', U_BOOT_NODTB_DATA),
+ ('fit/scr-1', COMPRESS_DATA),
+ ('fit/scr-1/blob', COMPRESS_DATA),
+ ]:
+ data = control.ReadEntry(image_fname, entry_path)
+ self.assertEqual(expected, data)
+
+ def testReplaceFitSubentryLeafSameSize(self):
+ """Test replacing a FIT leaf subentry with same-size data"""
+ new_data = b'x' * len(U_BOOT_DATA)
+ data, expected_fdtmap, _ = self._RunReplaceCmd(
+ 'fit/kernel/u-boot', new_data,
+ dts='233_fit_extract_replace.dts')
+ self.assertEqual(new_data, data)
+
+ path, fdtmap = state.GetFdtContents('fdtmap')
+ self.assertIsNotNone(path)
+ self.assertEqual(expected_fdtmap, fdtmap)
+
+ def testReplaceFitSubentryLeafBiggerSize(self):
+ """Test replacing a FIT leaf subentry with bigger-size data"""
+ new_data = b'ub' * len(U_BOOT_NODTB_DATA)
+ data, expected_fdtmap, _ = self._RunReplaceCmd(
+ 'fit/fdt-1/u-boot-nodtb', new_data,
+ dts='233_fit_extract_replace.dts')
+ self.assertEqual(new_data, data)
+
+ # Will be repacked, so fdtmap must change
+ path, fdtmap = state.GetFdtContents('fdtmap')
+ self.assertIsNotNone(path)
+ self.assertNotEqual(expected_fdtmap, fdtmap)
+
+ def testReplaceFitSubentryLeafSmallerSize(self):
+ """Test replacing a FIT leaf subentry with smaller-size data"""
+ new_data = b'x'
+ expected = new_data.ljust(len(U_BOOT_NODTB_DATA), b'\0')
+ data, expected_fdtmap, _ = self._RunReplaceCmd(
+ 'fit/fdt-1/u-boot-nodtb', new_data,
+ dts='233_fit_extract_replace.dts')
+ self.assertEqual(expected, data)
+
+ path, fdtmap = state.GetFdtContents('fdtmap')
+ self.assertIsNotNone(path)
+ self.assertEqual(expected_fdtmap, fdtmap)
+
+ @unittest.expectedFailure
+ def testReplaceSectionSimple(self):
+ """Test replacing a simple section with arbitrary data"""
+ new_data = b'w' * len(COMPRESS_DATA + U_BOOT_DATA)
+ data, expected_fdtmap, _ = self._RunReplaceCmd(
+ 'section', new_data,
+ dts='234_replace_section_simple.dts')
+ self.assertEqual(new_data, data)
+
+
if __name__ == "__main__":
unittest.main()
diff --git a/tools/binman/main.py b/tools/binman/main.py
index 9392b59adb1..5fb9404ef6a 100755
--- a/tools/binman/main.py
+++ b/tools/binman/main.py
@@ -9,7 +9,6 @@
"""See README for more information"""
-from distutils.sysconfig import get_python_lib
import os
import site
import sys
@@ -44,12 +43,6 @@ sys.path.insert(2, os.path.join(srctree, 'scripts/dtc/pylibfdt'))
sys.path.insert(2, os.path.join(srctree, 'build-sandbox/scripts/dtc/pylibfdt'))
sys.path.insert(2, os.path.join(srctree, 'build-sandbox_spl/scripts/dtc/pylibfdt'))
-# When running under python-coverage on Ubuntu 16.04, the dist-packages
-# directories are dropped from the python path. Add them in so that we can find
-# the elffile module. We could use site.getsitepackages() here but unfortunately
-# that is not available in a virtualenv.
-sys.path.append(get_python_lib())
-
from binman import cmdline
from binman import control
from patman import test_util
diff --git a/tools/binman/test/230_unique_names.dts b/tools/binman/test/230_unique_names.dts
new file mode 100644
index 00000000000..6780d37f71f
--- /dev/null
+++ b/tools/binman/test/230_unique_names.dts
@@ -0,0 +1,34 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+/dts-v1/;
+
+/ {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ binman {
+ size = <0xc00>;
+ allow-repack;
+
+ u-boot {
+ };
+
+ fdtmap {
+ };
+
+ u-boot2 {
+ type = "u-boot";
+ };
+
+ text {
+ text = "some text";
+ };
+
+ u-boot-dtb {
+ };
+
+ image-header {
+ location = "end";
+ };
+ };
+};
diff --git a/tools/binman/test/231_unique_names_multi.dts b/tools/binman/test/231_unique_names_multi.dts
new file mode 100644
index 00000000000..db63afb445e
--- /dev/null
+++ b/tools/binman/test/231_unique_names_multi.dts
@@ -0,0 +1,38 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+/dts-v1/;
+
+/ {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ binman {
+ multiple-images;
+
+ image {
+ size = <0xc00>;
+ allow-repack;
+
+ u-boot {
+ };
+
+ fdtmap {
+ };
+
+ u-boot2 {
+ type = "u-boot";
+ };
+
+ text {
+ text = "some text";
+ };
+
+ u-boot-dtb {
+ };
+
+ image-header {
+ location = "end";
+ };
+ };
+ };
+};
diff --git a/tools/binman/test/232_replace_with_bintool.dts b/tools/binman/test/232_replace_with_bintool.dts
new file mode 100644
index 00000000000..d7fabd2cd83
--- /dev/null
+++ b/tools/binman/test/232_replace_with_bintool.dts
@@ -0,0 +1,39 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+/dts-v1/;
+
+/ {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ binman {
+ size = <0xc00>;
+ allow-repack;
+
+ u-boot {
+ };
+
+ _testing {
+ require-bintool-for-contents;
+ require-bintool-for-pack;
+ };
+
+ fdtmap {
+ };
+
+ u-boot2 {
+ type = "u-boot";
+ };
+
+ text {
+ text = "some text";
+ };
+
+ u-boot-dtb {
+ };
+
+ image-header {
+ location = "end";
+ };
+ };
+};
diff --git a/tools/binman/test/233_fit_extract_replace.dts b/tools/binman/test/233_fit_extract_replace.dts
new file mode 100644
index 00000000000..b44d05afe1a
--- /dev/null
+++ b/tools/binman/test/233_fit_extract_replace.dts
@@ -0,0 +1,74 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+/dts-v1/;
+
+/ {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ binman {
+ allow-repack;
+
+ fill {
+ size = <0x1000>;
+ fill-byte = [77];
+ };
+
+ fit {
+ description = "test-desc";
+ #address-cells = <1>;
+
+ images {
+ kernel {
+ description = "test u-boot";
+ type = "kernel";
+ arch = "arm64";
+ os = "linux";
+ compression = "none";
+ load = <00000000>;
+ entry = <00000000>;
+
+ u-boot {
+ };
+ };
+
+ fdt-1 {
+ description = "test u-boot-nodtb";
+ type = "flat_dt";
+ arch = "arm64";
+ compression = "none";
+
+ u-boot-nodtb {
+ };
+ };
+
+ scr-1 {
+ description = "test blob";
+ type = "script";
+ arch = "arm64";
+ compression = "none";
+
+ blob {
+ filename = "compress";
+ };
+ };
+ };
+
+ configurations {
+ default = "conf-1";
+
+ conf-1 {
+ description = "Kernel with FDT blob";
+ kernel = "kernel";
+ fdt = "fdt-1";
+ };
+ };
+ };
+
+ u-boot-dtb {
+ };
+
+ fdtmap {
+ };
+ };
+};
diff --git a/tools/binman/test/234_replace_section_simple.dts b/tools/binman/test/234_replace_section_simple.dts
new file mode 100644
index 00000000000..c9d5c328561
--- /dev/null
+++ b/tools/binman/test/234_replace_section_simple.dts
@@ -0,0 +1,23 @@
+// SPDX-License-Identifier: GPL-2.0+
+/dts-v1/;
+
+/ {
+ binman {
+ allow-repack;
+
+ u-boot-dtb {
+ };
+
+ section {
+ blob {
+ filename = "compress";
+ };
+
+ u-boot {
+ };
+ };
+
+ fdtmap {
+ };
+ };
+};
diff --git a/tools/buildman/README b/tools/buildman/README
index bafb3b065ce..49438cb909d 100644
--- a/tools/buildman/README
+++ b/tools/buildman/README
@@ -192,7 +192,6 @@ aarch64: /opt/linaro/gcc-linaro-aarch64-none-elf-4.8-2013.10_linux
[toolchain-alias]
x86: i386
blackfin: bfin
-nds32: nds32le
openrisc: or1k
@@ -468,8 +467,6 @@ arc: https://github.com/foss-for-synopsys-dwc-arc-processors/toolchain/releases/
download/arc-2016.09-release/arc_gnu_2016.09_prebuilt_uclibc_le_archs_linux_install.tar.gz
blackfin: http://sourceforge.net/projects/adi-toolchain/files/
blackfin-toolchain-elf-gcc-4.5-2014R1_45-RC2.x86_64.tar.bz2
-nds32: http://osdk.andestech.com/packages/
- nds32le-linux-glibc-v1.tgz
nios2: http://sourcery.mentor.com/public/gnu_toolchain/nios2-linux-gnu/
sourceryg++-2015.11-27-nios2-linux-gnu-i686-pc-linux-gnu.tar.bz2
sh: http://sourcery.mentor.com/public/gnu_toolchain/sh-linux-gnu/
@@ -483,10 +480,10 @@ Buildman should now be set up to use your new toolchain.
At the time of writing, U-Boot has these architectures:
- arc, arm, blackfin, m68k, microblaze, mips, nds32, nios2, openrisc
+ arc, arm, blackfin, m68k, microblaze, mips, nios2, openrisc
powerpc, sandbox, sh, sparc, x86
-Of these, only arc and nds32 are not available at kernel.org..
+Of these, only arc is not available at kernel.org..
How to run it
diff --git a/tools/buildman/bsettings.py b/tools/buildman/bsettings.py
index e634bbb279b..35bb2c1d03a 100644
--- a/tools/buildman/bsettings.py
+++ b/tools/buildman/bsettings.py
@@ -85,7 +85,6 @@ other = /
# Indicates which toolchain should be used to build for that arch
x86 = i386
blackfin = bfin
-nds32 = nds32le
openrisc = or1k
[make-flags]
diff --git a/tools/buildman/builder.py b/tools/buildman/builder.py
index ecbfa3e361e..aa2ffe16f6c 100644
--- a/tools/buildman/builder.py
+++ b/tools/buildman/builder.py
@@ -1071,7 +1071,6 @@ class Builder:
For example:
powerpc: (622 boards) text -0.0
arm: (285 boards) text -0.0
- nds32: (3 boards) text -8.0
Args:
board_selected: Dict containing boards to summarise, keyed by
diff --git a/tools/docker/Dockerfile b/tools/docker/Dockerfile
index c51e3430137..bbdc6557c2a 100644
--- a/tools/docker/Dockerfile
+++ b/tools/docker/Dockerfile
@@ -29,7 +29,6 @@ RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_
# Manually install other toolchains
RUN wget -O - https://github.com/foss-xtensa/toolchain/releases/download/2020.07/x86_64-2020.07-xtensa-dc233c-elf.tar.gz | tar -C /opt -xz
RUN wget -O - https://github.com/foss-for-synopsys-dwc-arc-processors/toolchain/releases/download/arc-2021.03-release/arc_gnu_2021.03_prebuilt_uclibc_le_archs_linux_install.tar.gz | tar --no-same-owner -C /opt -xz
-RUN wget -O - https://github.com/vincentzwc/prebuilt-nds32-toolchain/releases/download/20180521/nds32le-linux-glibc-v3-upstream.tar.gz | tar -C /opt -xz
# Update and install things from apt now
RUN apt-get update && apt-get install -y \
@@ -227,7 +226,6 @@ RUN /bin/echo -e "[toolchain]\nroot = /usr" > ~/.buildman
RUN /bin/echo -e "kernelorg = /opt/gcc-11.1.0-nolibc/*" >> ~/.buildman
RUN /bin/echo -e "arc = /opt/arc_gnu_2021.03_prebuilt_uclibc_le_archs_linux_install" >> ~/.buildman
RUN /bin/echo -e "\n[toolchain-prefix]\nxtensa = /opt/2020.07/xtensa-dc233c-elf/bin/xtensa-dc233c-elf-" >> ~/.buildman;
-RUN /bin/echo -e "\nnds32 = /opt/nds32le-linux-glibc-v3-upstream/bin/nds32le-linux-" >> ~/.buildman;
RUN /bin/echo -e "\n[toolchain-alias]\nsh = sh2" >> ~/.buildman
RUN /bin/echo -e "\nriscv = riscv64" >> ~/.buildman
RUN /bin/echo -e "\nsandbox = x86_64" >> ~/.buildman