aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Rini2023-10-24 19:12:21 -0400
committerTom Rini2023-10-24 19:12:21 -0400
commitfb428b61819444b9337075f49c72f326f5d12085 (patch)
tree59ad3b6c3df52508641f485591d5af5029b02d9a
parent5cab3515f8c9796015739c1750b8933291c816be (diff)
parent35dc728a3cd14338b5fa0b6f231aa555077c98a1 (diff)
Merge branch '2023-10-24-assorted-general-fixes-and-updates'
- Remove common.h in a number of places and make checkpatch.pl complain about its use in all cases, allow the mbr command to handle 4 primary partitions, fix an issue with the pstore command, fix a problem with cli parsing of escape sequences, remove and ignore more files, allow for the serial port to be flushed with every print (for debugging), and add SCMI power domain support.
-rw-r--r--.gitignore7
-rw-r--r--Makefile6
-rw-r--r--arch/Kconfig2
-rw-r--r--arch/arc/lib/bootm.c1
-rw-r--r--arch/arc/lib/cache.c1
-rw-r--r--arch/arc/lib/cpu.c1
-rw-r--r--arch/arc/lib/init_helpers.c1
-rw-r--r--arch/arc/lib/interrupts.c2
-rw-r--r--arch/arc/lib/relocate.c1
-rw-r--r--arch/arc/lib/reset.c1
-rw-r--r--arch/m68k/cpu/mcf523x/cpu.c1
-rw-r--r--arch/m68k/cpu/mcf523x/cpu_init.c1
-rw-r--r--arch/m68k/cpu/mcf523x/interrupts.c1
-rw-r--r--arch/m68k/cpu/mcf523x/speed.c1
-rw-r--r--arch/m68k/cpu/mcf52x2/cpu.c1
-rw-r--r--arch/m68k/cpu/mcf52x2/cpu_init.c3
-rw-r--r--arch/m68k/cpu/mcf52x2/interrupts.c1
-rw-r--r--arch/m68k/cpu/mcf52x2/speed.c1
-rw-r--r--arch/m68k/cpu/mcf530x/cpu.c1
-rw-r--r--arch/m68k/cpu/mcf530x/cpu_init.c1
-rw-r--r--arch/m68k/cpu/mcf530x/interrupts.c1
-rw-r--r--arch/m68k/cpu/mcf530x/speed.c1
-rw-r--r--arch/m68k/cpu/mcf532x/cpu.c1
-rw-r--r--arch/m68k/cpu/mcf532x/cpu_init.c1
-rw-r--r--arch/m68k/cpu/mcf532x/interrupts.c1
-rw-r--r--arch/m68k/cpu/mcf532x/speed.c1
-rw-r--r--arch/m68k/cpu/mcf5445x/cpu.c1
-rw-r--r--arch/m68k/cpu/mcf5445x/cpu_init.c1
-rw-r--r--arch/m68k/cpu/mcf5445x/dspi.c1
-rw-r--r--arch/m68k/cpu/mcf5445x/interrupts.c1
-rw-r--r--arch/m68k/cpu/mcf5445x/speed.c1
-rw-r--r--arch/m68k/cpu/mcf5445x/start.S1
-rw-r--r--arch/m68k/include/asm/immap.h1
-rw-r--r--arch/m68k/include/asm/immap_520x.h1
-rw-r--r--arch/m68k/include/asm/immap_5235.h1
-rw-r--r--arch/m68k/include/asm/immap_5272.h1
-rw-r--r--arch/m68k/include/asm/immap_5275.h1
-rw-r--r--arch/m68k/include/asm/immap_5282.h1
-rw-r--r--arch/m68k/include/asm/immap_5301x.h1
-rw-r--r--arch/m68k/include/asm/immap_5307.h2
-rw-r--r--arch/m68k/include/asm/immap_5329.h1
-rw-r--r--arch/m68k/include/asm/immap_5441x.h1
-rw-r--r--arch/m68k/lib/bdinfo.c3
-rw-r--r--arch/m68k/lib/bootm.c1
-rw-r--r--arch/m68k/lib/cache.c2
-rw-r--r--arch/m68k/lib/fec.c2
-rw-r--r--arch/m68k/lib/interrupts.c2
-rw-r--r--arch/m68k/lib/time.c1
-rw-r--r--arch/m68k/lib/traps.c1
-rw-r--r--arch/microblaze/cpu/cache.c1
-rw-r--r--arch/microblaze/cpu/cpuinfo.c1
-rw-r--r--arch/microblaze/cpu/exception.c2
-rw-r--r--arch/microblaze/cpu/interrupts.c3
-rw-r--r--arch/microblaze/cpu/pvr.c1
-rw-r--r--arch/microblaze/cpu/relocate.c3
-rw-r--r--arch/microblaze/cpu/spl.c1
-rw-r--r--arch/microblaze/include/asm/cpuinfo.h2
-rw-r--r--arch/microblaze/lib/bootm.c1
-rw-r--r--arch/mips/cpu/cpu.c1
-rw-r--r--arch/mips/cpu/interrupts.c1
-rw-r--r--arch/mips/cpu/time.c1
-rw-r--r--arch/mips/include/asm/cacheops.h1
-rw-r--r--arch/mips/lib/boot.c1
-rw-r--r--arch/mips/lib/bootm.c1
-rw-r--r--arch/mips/lib/cache.c1
-rw-r--r--arch/mips/lib/reloc.c1
-rw-r--r--arch/mips/lib/spl.c1
-rw-r--r--arch/mips/lib/stack.c1
-rw-r--r--arch/mips/lib/traps.c3
-rw-r--r--arch/mips/mach-ath79/ar933x/clk.c1
-rw-r--r--arch/mips/mach-ath79/ar933x/ddr.c1
-rw-r--r--arch/mips/mach-ath79/ar934x/clk.c1
-rw-r--r--arch/mips/mach-ath79/ar934x/cpu.c2
-rw-r--r--arch/mips/mach-ath79/ar934x/ddr.c1
-rw-r--r--arch/mips/mach-ath79/cpu.c1
-rw-r--r--arch/mips/mach-ath79/dram.c1
-rw-r--r--arch/mips/mach-ath79/qca953x/clk.c1
-rw-r--r--arch/mips/mach-ath79/qca953x/ddr.c1
-rw-r--r--arch/mips/mach-ath79/qca956x/clk.c1
-rw-r--r--arch/mips/mach-ath79/qca956x/cpu.c2
-rw-r--r--arch/mips/mach-ath79/qca956x/ddr.c1
-rw-r--r--arch/mips/mach-ath79/reset.c1
-rw-r--r--arch/mips/mach-bmips/dram.c1
-rw-r--r--arch/mips/mach-jz47xx/jz4780/gpio.c1
-rw-r--r--arch/mips/mach-jz47xx/jz4780/jz4780.c1
-rw-r--r--arch/mips/mach-jz47xx/jz4780/pll.c1
-rw-r--r--arch/mips/mach-jz47xx/jz4780/reset.c1
-rw-r--r--arch/mips/mach-jz47xx/jz4780/sdram.c1
-rw-r--r--arch/mips/mach-jz47xx/jz4780/timer.c1
-rw-r--r--arch/mips/mach-mscc/cpu.c1
-rw-r--r--arch/mips/mach-mscc/dram.c1
-rw-r--r--arch/mips/mach-mscc/gpio.c1
-rw-r--r--arch/mips/mach-mscc/include/mach/ddr.h1
-rw-r--r--arch/mips/mach-mscc/phy.c1
-rw-r--r--arch/mips/mach-mscc/reset.c2
-rw-r--r--arch/mips/mach-mtmips/cpu.c1
-rw-r--r--arch/mips/mach-mtmips/ddr_cal.c1
-rw-r--r--arch/mips/mach-mtmips/ddr_init.c1
-rw-r--r--arch/mips/mach-mtmips/mt7628/ddr.c1
-rw-r--r--arch/mips/mach-mtmips/mt7628/init.c1
-rw-r--r--arch/mips/mach-mtmips/mt7628/serial.c1
-rw-r--r--arch/mips/mach-mtmips/spl.c1
-rw-r--r--arch/mips/mach-pic32/cpu.c1
-rw-r--r--arch/mips/mach-pic32/reset.c1
-rw-r--r--arch/riscv/cpu/andesv5/cache.c1
-rw-r--r--arch/riscv/cpu/andesv5/cpu.c1
-rw-r--r--arch/riscv/cpu/andesv5/spl.c1
-rw-r--r--arch/riscv/cpu/cpu.c1
-rw-r--r--arch/riscv/cpu/fu540/dram.c1
-rw-r--r--arch/riscv/cpu/fu740/dram.c1
-rw-r--r--arch/riscv/cpu/generic/cpu.c1
-rw-r--r--arch/riscv/cpu/generic/dram.c1
-rw-r--r--arch/riscv/cpu/jh7110/dram.c1
-rw-r--r--arch/riscv/cpu/jh7110/spl.c1
-rw-r--r--arch/riscv/cpu/mtrap.S1
-rw-r--r--arch/riscv/cpu/start.S1
-rw-r--r--arch/riscv/include/asm/arch-andes/csr.h1
-rw-r--r--arch/riscv/include/asm/arch-jh7110/eeprom.h2
-rw-r--r--arch/riscv/include/asm/dma-mapping.h1
-rw-r--r--arch/riscv/include/asm/smp.h2
-rw-r--r--arch/riscv/lib/aclint_ipi.c1
-rw-r--r--arch/riscv/lib/andes_plicsw.c1
-rw-r--r--arch/riscv/lib/asm-offsets.c1
-rw-r--r--arch/riscv/lib/boot.c3
-rw-r--r--arch/riscv/lib/bootm.c1
-rw-r--r--arch/riscv/lib/cache.c1
-rw-r--r--arch/riscv/lib/fdt_fixup.c1
-rw-r--r--arch/riscv/lib/image.c1
-rw-r--r--arch/riscv/lib/interrupts.c1
-rw-r--r--arch/riscv/lib/reset.c1
-rw-r--r--arch/riscv/lib/sbi.c2
-rw-r--r--arch/riscv/lib/sbi_ipi.c1
-rw-r--r--arch/riscv/lib/sifive_cache.c2
-rw-r--r--arch/riscv/lib/smp.c1
-rw-r--r--arch/riscv/lib/spl.c1
-rw-r--r--arch/sandbox/dts/test.dts14
-rw-r--r--arch/sandbox/include/asm/scmi_test.h21
-rw-r--r--board/AndesTech/ae350/ae350.c2
-rw-r--r--board/abilis/tb100/tb100.c1
-rw-r--r--board/sifive/unmatched/hifive-platform-i2c-eeprom.c1
-rw-r--r--board/sifive/unmatched/unmatched.c1
-rw-r--r--board/synopsys/axs10x/axs10x.c1
-rw-r--r--board/synopsys/emsdp/emsdp.c1
-rw-r--r--board/synopsys/hsdk/clk-lib.h1
-rw-r--r--board/synopsys/hsdk/env-lib.c2
-rw-r--r--board/synopsys/hsdk/env-lib.h1
-rw-r--r--board/synopsys/hsdk/hsdk.c1
-rw-r--r--board/synopsys/iot_devkit/iot_devkit.c1
-rw-r--r--board/synopsys/nsim/nsim.c1
-rw-r--r--board/xilinx/microblaze-generic/microblaze-generic.c1
-rw-r--r--cmd/pstore.c10
-rw-r--r--common/Kconfig10
-rw-r--r--common/cli_getch.c2
-rw-r--r--configs/sandbox_defconfig3
-rw-r--r--configs/sandbox_flattree_defconfig2
-rw-r--r--disk/part_dos.c2
-rw-r--r--drivers/firmware/scmi/Makefile1
-rw-r--r--drivers/firmware/scmi/pwdom.c188
-rw-r--r--drivers/firmware/scmi/sandbox-scmi_agent.c265
-rw-r--r--drivers/firmware/scmi/sandbox-scmi_devices.c10
-rw-r--r--drivers/firmware/scmi/scmi_agent-uclass.c11
-rw-r--r--drivers/power/domain/Kconfig7
-rw-r--r--drivers/power/domain/Makefile1
-rw-r--r--drivers/power/domain/scmi-power-domain.c192
-rw-r--r--drivers/serial/serial-uclass.c28
-rw-r--r--include/bootstage.h1
-rw-r--r--include/cache.h2
-rw-r--r--include/cpu.h2
-rw-r--r--include/scmi_agent-uclass.h2
-rw-r--r--include/scmi_protocols.h178
-rw-r--r--include/test/suites.h1
-rwxr-xr-xscripts/checkpatch.pl10
-rw-r--r--test/cmd/Makefile1
-rw-r--r--test/cmd/mbr.c481
-rw-r--r--test/cmd_ut.c4
-rw-r--r--test/common/cread.c12
-rw-r--r--test/dm/scmi.c103
-rw-r--r--test/py/tests/test_ut.py7
-rw-r--r--tools/patman/test_checkpatch.py58
179 files changed, 1657 insertions, 160 deletions
diff --git a/.gitignore b/.gitignore
index 84051b7bfde..a1a79e92fee 100644
--- a/.gitignore
+++ b/.gitignore
@@ -44,8 +44,10 @@ fit-dtb.blob*
/MLO*
/SPL*
/System.map
-/u-boot*
/boards.cfg
+/mkimage-in-simple-bin*
+/simple-bin*
+/u-boot*
/*.log
#
@@ -59,12 +61,15 @@ fit-dtb.blob*
# Generated files
#
/spl/
+/tools/generated/
/tpl/
/defconfig
#
# Generated include files
#
+/include/autoconf.mk*
+/include/config.h
/include/config/
/include/generated/
diff --git a/Makefile b/Makefile
index aa054ff4761..8a04dfcf363 100644
--- a/Makefile
+++ b/Makefile
@@ -2156,15 +2156,15 @@ CLEAN_DIRS += $(MODVERDIR) \
$(foreach d, spl tpl vpl, $(patsubst %,$d/%, \
$(filter-out include, $(shell ls -1 $d 2>/dev/null))))
-CLEAN_FILES += include/bmp_logo.h include/bmp_logo_data.h \
- include/generated/env.* drivers/video/u_boot_logo.S \
+CLEAN_FILES += include/autoconf.mk* include/bmp_logo.h include/bmp_logo_data.h \
+ include/config.h include/generated/env.* drivers/video/u_boot_logo.S \
tools/version.h u-boot* MLO* SPL System.map fit-dtb.blob* \
u-boot-ivt.img.log u-boot-dtb.imx.log SPL.log u-boot.imx.log \
lpc32xx-* bl31.c bl31.elf bl31_*.bin image.map tispl.bin* \
idbloader.img flash.bin flash.log defconfig keep-syms-lto.c \
mkimage-out.spl.mkimage mkimage.spl.mkimage imx-boot.map \
itb.fit.fit itb.fit.itb itb.map spl.map mkimage-out.rom.mkimage \
- mkimage.rom.mkimage rom.map simple-bin.map simple-bin-spi.map \
+ mkimage.rom.mkimage mkimage-in-simple-bin* rom.map simple-bin* \
idbloader-spi.img lib/efi_loader/helloworld_efi.S *.itb
# Directories & files removed with 'make mrproper'
diff --git a/arch/Kconfig b/arch/Kconfig
index 19f2891ba1c..4f5b75129f3 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -208,6 +208,8 @@ config SANDBOX
imply PHYSMEM
imply GENERATE_ACPI_TABLE
imply BINMAN
+ imply CMD_MBR
+ imply CMD_MMC
config SH
bool "SuperH architecture"
diff --git a/arch/arc/lib/bootm.c b/arch/arc/lib/bootm.c
index 2dd003445f8..44ec5864a1c 100644
--- a/arch/arc/lib/bootm.c
+++ b/arch/arc/lib/bootm.c
@@ -3,7 +3,6 @@
* Copyright (C) 2013-2014 Synopsys, Inc. All rights reserved.
*/
-#include <common.h>
#include <bootstage.h>
#include <env.h>
#include <image.h>
diff --git a/arch/arc/lib/cache.c b/arch/arc/lib/cache.c
index d97a5787424..22e748868a7 100644
--- a/arch/arc/lib/cache.c
+++ b/arch/arc/lib/cache.c
@@ -4,7 +4,6 @@
*/
#include <config.h>
-#include <common.h>
#include <cpu_func.h>
#include <asm/global_data.h>
#include <linux/bitops.h>
diff --git a/arch/arc/lib/cpu.c b/arch/arc/lib/cpu.c
index 15678579618..803dfd42558 100644
--- a/arch/arc/lib/cpu.c
+++ b/arch/arc/lib/cpu.c
@@ -3,7 +3,6 @@
* Copyright (C) 2013-2014, 2018 Synopsys, Inc. All rights reserved.
*/
-#include <common.h>
#include <clock_legacy.h>
#include <init.h>
#include <malloc.h>
diff --git a/arch/arc/lib/init_helpers.c b/arch/arc/lib/init_helpers.c
index 023eae19075..858b388cc0b 100644
--- a/arch/arc/lib/init_helpers.c
+++ b/arch/arc/lib/init_helpers.c
@@ -5,7 +5,6 @@
#include <init.h>
#include <asm/cache.h>
-#include <common.h>
int init_cache_f_r(void)
{
diff --git a/arch/arc/lib/interrupts.c b/arch/arc/lib/interrupts.c
index db21fbb1142..523b44cb95a 100644
--- a/arch/arc/lib/interrupts.c
+++ b/arch/arc/lib/interrupts.c
@@ -3,8 +3,8 @@
* Copyright (C) 2013-2014 Synopsys, Inc. All rights reserved.
*/
-#include <common.h>
#include <irq_func.h>
+#include <vsprintf.h>
#include <asm/arcregs.h>
#include <asm/ptrace.h>
diff --git a/arch/arc/lib/relocate.c b/arch/arc/lib/relocate.c
index fd6f4fbc930..95b6d5150c7 100644
--- a/arch/arc/lib/relocate.c
+++ b/arch/arc/lib/relocate.c
@@ -3,7 +3,6 @@
* Copyright (C) 2013-2014 Synopsys, Inc. All rights reserved.
*/
-#include <common.h>
#include <elf.h>
#include <log.h>
#include <asm/sections.h>
diff --git a/arch/arc/lib/reset.c b/arch/arc/lib/reset.c
index b8589d0f0a4..fa60fa96338 100644
--- a/arch/arc/lib/reset.c
+++ b/arch/arc/lib/reset.c
@@ -4,7 +4,6 @@
*/
#include <command.h>
-#include <common.h>
#include <cpu_func.h>
__weak void reset_cpu(void)
diff --git a/arch/m68k/cpu/mcf523x/cpu.c b/arch/m68k/cpu/mcf523x/cpu.c
index bef67767b42..c843a381ea1 100644
--- a/arch/m68k/cpu/mcf523x/cpu.c
+++ b/arch/m68k/cpu/mcf523x/cpu.c
@@ -8,7 +8,6 @@
* TsiChung Liew (Tsi-Chung.Liew@freescale.com)
*/
-#include <common.h>
#include <init.h>
#include <net.h>
#include <vsprintf.h>
diff --git a/arch/m68k/cpu/mcf523x/cpu_init.c b/arch/m68k/cpu/mcf523x/cpu_init.c
index 10be73822fa..a05cbdcb385 100644
--- a/arch/m68k/cpu/mcf523x/cpu_init.c
+++ b/arch/m68k/cpu/mcf523x/cpu_init.c
@@ -8,7 +8,6 @@
* TsiChung Liew (Tsi-Chung.Liew@freescale.com)
*/
-#include <common.h>
#include <cpu_func.h>
#include <init.h>
#include <watchdog.h>
diff --git a/arch/m68k/cpu/mcf523x/interrupts.c b/arch/m68k/cpu/mcf523x/interrupts.c
index 09c7f9e67cc..46c9207a93b 100644
--- a/arch/m68k/cpu/mcf523x/interrupts.c
+++ b/arch/m68k/cpu/mcf523x/interrupts.c
@@ -6,7 +6,6 @@
*/
/* CPU specific interrupt routine */
-#include <common.h>
#include <irq_func.h>
#include <asm/immap.h>
#include <asm/io.h>
diff --git a/arch/m68k/cpu/mcf523x/speed.c b/arch/m68k/cpu/mcf523x/speed.c
index 6b08a12af0b..2eb43cc7eb9 100644
--- a/arch/m68k/cpu/mcf523x/speed.c
+++ b/arch/m68k/cpu/mcf523x/speed.c
@@ -8,7 +8,6 @@
* TsiChung Liew (Tsi-Chung.Liew@freescale.com)
*/
-#include <common.h>
#include <clock_legacy.h>
#include <asm/global_data.h>
#include <asm/processor.h>
diff --git a/arch/m68k/cpu/mcf52x2/cpu.c b/arch/m68k/cpu/mcf52x2/cpu.c
index 5042a38b3e9..6bfde5e9bd7 100644
--- a/arch/m68k/cpu/mcf52x2/cpu.c
+++ b/arch/m68k/cpu/mcf52x2/cpu.c
@@ -13,7 +13,6 @@
* Copyright (C) 2012 Freescale Semiconductor, Inc. All Rights Reserved.
*/
-#include <common.h>
#include <init.h>
#include <net.h>
#include <vsprintf.h>
diff --git a/arch/m68k/cpu/mcf52x2/cpu_init.c b/arch/m68k/cpu/mcf52x2/cpu_init.c
index 99eb61f1675..4506eb39edf 100644
--- a/arch/m68k/cpu/mcf52x2/cpu_init.c
+++ b/arch/m68k/cpu/mcf52x2/cpu_init.c
@@ -17,7 +17,7 @@
* Copyright (C) 2008 Arthur Shipkowski (art@videon-central.com)
*/
-#include <common.h>
+#include <config.h>
#include <cpu_func.h>
#include <init.h>
#include <watchdog.h>
@@ -25,7 +25,6 @@
#include <asm/io.h>
#if defined(CONFIG_CMD_NET)
-#include <config.h>
#include <net.h>
#include <asm/fec.h>
#endif
diff --git a/arch/m68k/cpu/mcf52x2/interrupts.c b/arch/m68k/cpu/mcf52x2/interrupts.c
index c5ed0600736..264bdc7d6c7 100644
--- a/arch/m68k/cpu/mcf52x2/interrupts.c
+++ b/arch/m68k/cpu/mcf52x2/interrupts.c
@@ -7,7 +7,6 @@
* TsiChung Liew (Tsi-Chung.Liew@freescale.com)
*/
-#include <common.h>
#include <irq_func.h>
#include <watchdog.h>
#include <asm/processor.h>
diff --git a/arch/m68k/cpu/mcf52x2/speed.c b/arch/m68k/cpu/mcf52x2/speed.c
index 6c7628252b5..538e4c623d4 100644
--- a/arch/m68k/cpu/mcf52x2/speed.c
+++ b/arch/m68k/cpu/mcf52x2/speed.c
@@ -7,7 +7,6 @@
* Hayden Fraser (Hayden.Fraser@freescale.com)
*/
-#include <common.h>
#include <clock_legacy.h>
#include <asm/global_data.h>
#include <asm/processor.h>
diff --git a/arch/m68k/cpu/mcf530x/cpu.c b/arch/m68k/cpu/mcf530x/cpu.c
index 53a25d8362c..92a0ef76895 100644
--- a/arch/m68k/cpu/mcf530x/cpu.c
+++ b/arch/m68k/cpu/mcf530x/cpu.c
@@ -4,7 +4,6 @@
*
*/
-#include <common.h>
#include <command.h>
#include <init.h>
#include <vsprintf.h>
diff --git a/arch/m68k/cpu/mcf530x/cpu_init.c b/arch/m68k/cpu/mcf530x/cpu_init.c
index dad47d87ab3..8f6e668d103 100644
--- a/arch/m68k/cpu/mcf530x/cpu_init.c
+++ b/arch/m68k/cpu/mcf530x/cpu_init.c
@@ -4,7 +4,6 @@
*
*/
-#include <common.h>
#include <cpu_func.h>
#include <init.h>
#include <watchdog.h>
diff --git a/arch/m68k/cpu/mcf530x/interrupts.c b/arch/m68k/cpu/mcf530x/interrupts.c
index 11686202dc7..99cf8638503 100644
--- a/arch/m68k/cpu/mcf530x/interrupts.c
+++ b/arch/m68k/cpu/mcf530x/interrupts.c
@@ -4,7 +4,6 @@
*
*/
-#include <common.h>
#include <irq_func.h>
#include <asm/immap.h>
#include <asm/io.h>
diff --git a/arch/m68k/cpu/mcf530x/speed.c b/arch/m68k/cpu/mcf530x/speed.c
index c8d079016f2..6542fc43ab1 100644
--- a/arch/m68k/cpu/mcf530x/speed.c
+++ b/arch/m68k/cpu/mcf530x/speed.c
@@ -4,7 +4,6 @@
*
*/
-#include <common.h>
#include <clock_legacy.h>
#include <asm/global_data.h>
#include <asm/processor.h>
diff --git a/arch/m68k/cpu/mcf532x/cpu.c b/arch/m68k/cpu/mcf532x/cpu.c
index 18d20a89265..6973af9d045 100644
--- a/arch/m68k/cpu/mcf532x/cpu.c
+++ b/arch/m68k/cpu/mcf532x/cpu.c
@@ -8,7 +8,6 @@
* TsiChung Liew (Tsi-Chung.Liew@freescale.com)
*/
-#include <common.h>
#include <init.h>
#include <net.h>
#include <vsprintf.h>
diff --git a/arch/m68k/cpu/mcf532x/cpu_init.c b/arch/m68k/cpu/mcf532x/cpu_init.c
index 844d2cd7600..62a45f96314 100644
--- a/arch/m68k/cpu/mcf532x/cpu_init.c
+++ b/arch/m68k/cpu/mcf532x/cpu_init.c
@@ -8,7 +8,6 @@
* TsiChung Liew (Tsi-Chung.Liew@freescale.com)
*/
-#include <common.h>
#include <cpu_func.h>
#include <init.h>
#include <watchdog.h>
diff --git a/arch/m68k/cpu/mcf532x/interrupts.c b/arch/m68k/cpu/mcf532x/interrupts.c
index 4f72fa88e58..e37893c3e53 100644
--- a/arch/m68k/cpu/mcf532x/interrupts.c
+++ b/arch/m68k/cpu/mcf532x/interrupts.c
@@ -6,7 +6,6 @@
*/
/* CPU specific interrupt routine */
-#include <common.h>
#include <irq_func.h>
#include <asm/immap.h>
#include <asm/io.h>
diff --git a/arch/m68k/cpu/mcf532x/speed.c b/arch/m68k/cpu/mcf532x/speed.c
index 32ffac08135..166916526eb 100644
--- a/arch/m68k/cpu/mcf532x/speed.c
+++ b/arch/m68k/cpu/mcf532x/speed.c
@@ -8,7 +8,6 @@
* TsiChung Liew (Tsi-Chung.Liew@freescale.com)
*/
-#include <common.h>
#include <clock_legacy.h>
#include <asm/global_data.h>
#include <asm/processor.h>
diff --git a/arch/m68k/cpu/mcf5445x/cpu.c b/arch/m68k/cpu/mcf5445x/cpu.c
index d9a71c6b920..b811ac355e4 100644
--- a/arch/m68k/cpu/mcf5445x/cpu.c
+++ b/arch/m68k/cpu/mcf5445x/cpu.c
@@ -8,7 +8,6 @@
* TsiChung Liew (Tsi-Chung.Liew@freescale.com)
*/
-#include <common.h>
#include <init.h>
#include <net.h>
#include <vsprintf.h>
diff --git a/arch/m68k/cpu/mcf5445x/cpu_init.c b/arch/m68k/cpu/mcf5445x/cpu_init.c
index bc3a2f3aed6..3277617120c 100644
--- a/arch/m68k/cpu/mcf5445x/cpu_init.c
+++ b/arch/m68k/cpu/mcf5445x/cpu_init.c
@@ -8,7 +8,6 @@
* TsiChung Liew (Tsi-Chung.Liew@freescale.com)
*/
-#include <common.h>
#include <cpu_func.h>
#include <init.h>
#include <watchdog.h>
diff --git a/arch/m68k/cpu/mcf5445x/dspi.c b/arch/m68k/cpu/mcf5445x/dspi.c
index 456af171a4e..13eb6ecee10 100644
--- a/arch/m68k/cpu/mcf5445x/dspi.c
+++ b/arch/m68k/cpu/mcf5445x/dspi.c
@@ -6,7 +6,6 @@
* CPU specific dspi routines
*/
-#include <common.h>
#include <asm/immap.h>
#include <asm/io.h>
diff --git a/arch/m68k/cpu/mcf5445x/interrupts.c b/arch/m68k/cpu/mcf5445x/interrupts.c
index 400f3dee879..913290086dc 100644
--- a/arch/m68k/cpu/mcf5445x/interrupts.c
+++ b/arch/m68k/cpu/mcf5445x/interrupts.c
@@ -9,7 +9,6 @@
*/
/* CPU specific interrupt routine */
-#include <common.h>
#include <irq_func.h>
#include <asm/immap.h>
#include <asm/io.h>
diff --git a/arch/m68k/cpu/mcf5445x/speed.c b/arch/m68k/cpu/mcf5445x/speed.c
index 5c78eb98349..41cb9e999ad 100644
--- a/arch/m68k/cpu/mcf5445x/speed.c
+++ b/arch/m68k/cpu/mcf5445x/speed.c
@@ -5,7 +5,6 @@
* TsiChung Liew (Tsi-Chung.Liew@freescale.com)
*/
-#include <common.h>
#include <clock_legacy.h>
#include <asm/global_data.h>
#include <asm/processor.h>
diff --git a/arch/m68k/cpu/mcf5445x/start.S b/arch/m68k/cpu/mcf5445x/start.S
index 5c3bfff7918..f0264671d38 100644
--- a/arch/m68k/cpu/mcf5445x/start.S
+++ b/arch/m68k/cpu/mcf5445x/start.S
@@ -7,7 +7,6 @@
* TsiChung Liew (Tsi-Chung.Liew@freescale.com)
*/
-#include <common.h>
#include <asm-offsets.h>
#include <config.h>
#include <asm/cache.h>
diff --git a/arch/m68k/include/asm/immap.h b/arch/m68k/include/asm/immap.h
index aafa4f40cb3..411b00899c2 100644
--- a/arch/m68k/include/asm/immap.h
+++ b/arch/m68k/include/asm/immap.h
@@ -9,6 +9,7 @@
#ifndef __IMMAP_H
#define __IMMAP_H
+#include <config.h>
#if defined(CONFIG_MCF520x)
#include <asm/immap_520x.h>
#include <asm/m520x.h>
diff --git a/arch/m68k/include/asm/immap_520x.h b/arch/m68k/include/asm/immap_520x.h
index 7c7443b9688..d3c2f4a4091 100644
--- a/arch/m68k/include/asm/immap_520x.h
+++ b/arch/m68k/include/asm/immap_520x.h
@@ -36,6 +36,7 @@
#define MMAP_GPIO (CFG_SYS_MBAR + 0x000A4000)
#define MMAP_SDRAM (CFG_SYS_MBAR + 0x000A8000)
+#include <linux/types.h>
#include <asm/coldfire/crossbar.h>
#include <asm/coldfire/edma.h>
#include <asm/coldfire/eport.h>
diff --git a/arch/m68k/include/asm/immap_5235.h b/arch/m68k/include/asm/immap_5235.h
index a1825c2a944..d9b0be1d7d4 100644
--- a/arch/m68k/include/asm/immap_5235.h
+++ b/arch/m68k/include/asm/immap_5235.h
@@ -46,6 +46,7 @@
#define MMAP_ETPU (CFG_SYS_MBAR + 0x001D0000)
#define MMAP_CAN2 (CFG_SYS_MBAR + 0x001F0000)
+#include <linux/types.h>
#include <asm/coldfire/eport.h>
#include <asm/coldfire/flexbus.h>
#include <asm/coldfire/flexcan.h>
diff --git a/arch/m68k/include/asm/immap_5272.h b/arch/m68k/include/asm/immap_5272.h
index c5c3cc75125..5378ed1aac1 100644
--- a/arch/m68k/include/asm/immap_5272.h
+++ b/arch/m68k/include/asm/immap_5272.h
@@ -27,6 +27,7 @@
#define MMAP_FEC (CFG_SYS_MBAR + 0x00000840)
#define MMAP_USB (CFG_SYS_MBAR + 0x00001000)
+#include <linux/types.h>
#include <asm/coldfire/pwm.h>
/* System configuration registers */
diff --git a/arch/m68k/include/asm/immap_5275.h b/arch/m68k/include/asm/immap_5275.h
index 9b8d71d30d4..c4cce3f94f1 100644
--- a/arch/m68k/include/asm/immap_5275.h
+++ b/arch/m68k/include/asm/immap_5275.h
@@ -49,6 +49,7 @@
#define MMAP_USB (CFG_SYS_MBAR + 0x001C0000)
#define MMAP_PWM0 (CFG_SYS_MBAR + 0x001D0000)
+#include <linux/types.h>
#include <asm/coldfire/eport.h>
#include <asm/coldfire/flexbus.h>
#include <asm/coldfire/intctrl.h>
diff --git a/arch/m68k/include/asm/immap_5282.h b/arch/m68k/include/asm/immap_5282.h
index f810a4dd5cb..e5f400e6ae3 100644
--- a/arch/m68k/include/asm/immap_5282.h
+++ b/arch/m68k/include/asm/immap_5282.h
@@ -45,6 +45,7 @@
#define MMAP_CFMC (CFG_SYS_MBAR + 0x001D0000)
#define MMAP_CFMMEM (CFG_SYS_MBAR + 0x04000000)
+#include <linux/types.h>
#include <asm/coldfire/eport.h>
#include <asm/coldfire/flexbus.h>
#include <asm/coldfire/flexcan.h>
diff --git a/arch/m68k/include/asm/immap_5301x.h b/arch/m68k/include/asm/immap_5301x.h
index e1f7858b100..3ade4f04756 100644
--- a/arch/m68k/include/asm/immap_5301x.h
+++ b/arch/m68k/include/asm/immap_5301x.h
@@ -50,6 +50,7 @@
#define MMAP_IIM (CFG_SYS_MBAR + 0x000C8000)
#define MMAP_ESDHC (CFG_SYS_MBAR + 0x000CC000)
+#include <linux/types.h>
#include <asm/coldfire/crossbar.h>
#include <asm/coldfire/dspi.h>
#include <asm/coldfire/edma.h>
diff --git a/arch/m68k/include/asm/immap_5307.h b/arch/m68k/include/asm/immap_5307.h
index d6442d95b4b..d96dd146efb 100644
--- a/arch/m68k/include/asm/immap_5307.h
+++ b/arch/m68k/include/asm/immap_5307.h
@@ -17,6 +17,8 @@
#define MMAP_UART1 (CFG_SYS_MBAR + 0x00000200)
#define MMAP_GPIO (CFG_SYS_MBAR + 0x00000244)
+#include <linux/types.h>
+
typedef struct sim {
u8 rsr;
u8 sypcr;
diff --git a/arch/m68k/include/asm/immap_5329.h b/arch/m68k/include/asm/immap_5329.h
index dbf3a2260ee..6f1795a207a 100644
--- a/arch/m68k/include/asm/immap_5329.h
+++ b/arch/m68k/include/asm/immap_5329.h
@@ -51,6 +51,7 @@
#define MMAP_SSI 0xFC0BC000
#define MMAP_PLL 0xFC0C0000
+#include <linux/types.h>
#include <asm/coldfire/crossbar.h>
#include <asm/coldfire/edma.h>
#include <asm/coldfire/eport.h>
diff --git a/arch/m68k/include/asm/immap_5441x.h b/arch/m68k/include/asm/immap_5441x.h
index 708d0db755a..c8f3effe240 100644
--- a/arch/m68k/include/asm/immap_5441x.h
+++ b/arch/m68k/include/asm/immap_5441x.h
@@ -76,6 +76,7 @@
#define MMAP_CCM 0xEC090000
#define MMAP_GPIO 0xEC094000
+#include <linux/types.h>
#include <asm/coldfire/crossbar.h>
#include <asm/coldfire/dspi.h>
#include <asm/coldfire/edma.h>
diff --git a/arch/m68k/lib/bdinfo.c b/arch/m68k/lib/bdinfo.c
index 0b4629f1c8a..3719f11c03c 100644
--- a/arch/m68k/lib/bdinfo.c
+++ b/arch/m68k/lib/bdinfo.c
@@ -6,8 +6,9 @@
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
*/
-#include <common.h>
+#include <config.h>
#include <init.h>
+#include <asm/u-boot.h>
#include <asm/global_data.h>
DECLARE_GLOBAL_DATA_PTR;
diff --git a/arch/m68k/lib/bootm.c b/arch/m68k/lib/bootm.c
index f18bed235d4..79d8b34c0d5 100644
--- a/arch/m68k/lib/bootm.c
+++ b/arch/m68k/lib/bootm.c
@@ -4,7 +4,6 @@
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
*/
-#include <common.h>
#include <bootstage.h>
#include <command.h>
#include <env.h>
diff --git a/arch/m68k/lib/cache.c b/arch/m68k/lib/cache.c
index 57e5632fdb5..de04124404c 100644
--- a/arch/m68k/lib/cache.c
+++ b/arch/m68k/lib/cache.c
@@ -4,7 +4,7 @@
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
*/
-#include <common.h>
+#include <config.h>
#include <cpu_func.h>
#include <asm/immap.h>
#include <asm/cache.h>
diff --git a/arch/m68k/lib/fec.c b/arch/m68k/lib/fec.c
index eecea7a0235..d6f238e4b34 100644
--- a/arch/m68k/lib/fec.c
+++ b/arch/m68k/lib/fec.c
@@ -3,8 +3,8 @@
* (C) 2019 Angelo Dureghello <angelo.dureghello@timesys.com>
*/
-#include <common.h>
#include <asm/global_data.h>
+#include <linux/errno.h>
#include <linux/libfdt.h>
#include <fdt_support.h>
diff --git a/arch/m68k/lib/interrupts.c b/arch/m68k/lib/interrupts.c
index 799daab5612..175ec689533 100644
--- a/arch/m68k/lib/interrupts.c
+++ b/arch/m68k/lib/interrupts.c
@@ -7,7 +7,7 @@
* TsiChung Liew (Tsi-Chung.Liew@freescale.com)
*/
-#include <common.h>
+#include <stdio.h>
#include <irq_func.h>
#include <watchdog.h>
#include <asm/processor.h>
diff --git a/arch/m68k/lib/time.c b/arch/m68k/lib/time.c
index 61db1e6c500..4249488c01d 100644
--- a/arch/m68k/lib/time.c
+++ b/arch/m68k/lib/time.c
@@ -6,7 +6,6 @@
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
*/
-#include <common.h>
#include <init.h>
#include <irq_func.h>
#include <time.h>
diff --git a/arch/m68k/lib/traps.c b/arch/m68k/lib/traps.c
index 28fe803928e..c283351181d 100644
--- a/arch/m68k/lib/traps.c
+++ b/arch/m68k/lib/traps.c
@@ -7,7 +7,6 @@
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
*/
-#include <common.h>
#include <init.h>
#include <watchdog.h>
#include <command.h>
diff --git a/arch/microblaze/cpu/cache.c b/arch/microblaze/cpu/cache.c
index 829e6c7ae60..75ec0a8fd24 100644
--- a/arch/microblaze/cpu/cache.c
+++ b/arch/microblaze/cpu/cache.c
@@ -5,7 +5,6 @@
* Michal SIMEK <monstr@monstr.eu>
*/
-#include <common.h>
#include <cpu_func.h>
#include <asm/asm.h>
#include <asm/cache.h>
diff --git a/arch/microblaze/cpu/cpuinfo.c b/arch/microblaze/cpu/cpuinfo.c
index 6b15d6ca41c..2bfdf767f3a 100644
--- a/arch/microblaze/cpu/cpuinfo.c
+++ b/arch/microblaze/cpu/cpuinfo.c
@@ -2,7 +2,6 @@
/*
* Copyright (C) 2022, Ovidiu Panait <ovpanait@gmail.com>
*/
-#include <common.h>
#include <asm/cpuinfo.h>
#include <asm/global_data.h>
diff --git a/arch/microblaze/cpu/exception.c b/arch/microblaze/cpu/exception.c
index 9414776afa7..6b329fc7b3a 100644
--- a/arch/microblaze/cpu/exception.c
+++ b/arch/microblaze/cpu/exception.c
@@ -5,8 +5,8 @@
* Michal SIMEK <monstr@monstr.eu>
*/
-#include <common.h>
#include <hang.h>
+#include <stdio.h>
#include <asm/asm.h>
void _hw_exception_handler (void)
diff --git a/arch/microblaze/cpu/interrupts.c b/arch/microblaze/cpu/interrupts.c
index ac53208bda6..244f7fd15eb 100644
--- a/arch/microblaze/cpu/interrupts.c
+++ b/arch/microblaze/cpu/interrupts.c
@@ -7,7 +7,8 @@
* Yasushi SHOJI <yashi@atmark-techno.com>
*/
-#include <common.h>
+#include <log.h>
+#include <vsprintf.h>
#include <asm/asm.h>
void enable_interrupts(void)
diff --git a/arch/microblaze/cpu/pvr.c b/arch/microblaze/cpu/pvr.c
index 23c0f912d43..71aea0b9380 100644
--- a/arch/microblaze/cpu/pvr.c
+++ b/arch/microblaze/cpu/pvr.c
@@ -2,7 +2,6 @@
/*
* Copyright (C) 2022, Ovidiu Panait <ovpanait@gmail.com>
*/
-#include <common.h>
#include <asm/asm.h>
#include <asm/pvr.h>
diff --git a/arch/microblaze/cpu/relocate.c b/arch/microblaze/cpu/relocate.c
index 7a15fb2ec39..e46fe5bdd5d 100644
--- a/arch/microblaze/cpu/relocate.c
+++ b/arch/microblaze/cpu/relocate.c
@@ -4,8 +4,9 @@
* Michal Simek <michal.simek@amd.com>
*/
-#include <common.h>
#include <elf.h>
+#include <log.h>
+#include <linux/types.h>
#define R_MICROBLAZE_NONE 0
#define R_MICROBLAZE_32 1
diff --git a/arch/microblaze/cpu/spl.c b/arch/microblaze/cpu/spl.c
index c21beafdb81..cb224bd2542 100644
--- a/arch/microblaze/cpu/spl.c
+++ b/arch/microblaze/cpu/spl.c
@@ -5,7 +5,6 @@
* Michal Simek <michal.simek@amd.com>
*/
-#include <common.h>
#include <command.h>
#include <image.h>
#include <log.h>
diff --git a/arch/microblaze/include/asm/cpuinfo.h b/arch/microblaze/include/asm/cpuinfo.h
index 3c58e52217c..fbd9418a2f8 100644
--- a/arch/microblaze/include/asm/cpuinfo.h
+++ b/arch/microblaze/include/asm/cpuinfo.h
@@ -6,6 +6,8 @@
#ifndef __ASM_MICROBLAZE_CPUINFO_H
#define __ASM_MICROBLAZE_CPUINFO_H
+#include <linux/types.h>
+
/**
* struct microblaze_cpuinfo - CPU info for microblaze processor core.
*
diff --git a/arch/microblaze/lib/bootm.c b/arch/microblaze/lib/bootm.c
index 930384f4015..f3ec4b741b8 100644
--- a/arch/microblaze/lib/bootm.c
+++ b/arch/microblaze/lib/bootm.c
@@ -7,7 +7,6 @@
* Yasushi SHOJI <yashi@atmark-techno.com>
*/
-#include <common.h>
#include <bootstage.h>
#include <command.h>
#include <cpu_func.h>
diff --git a/arch/mips/cpu/cpu.c b/arch/mips/cpu/cpu.c
index f0e20da28f7..acfc9dc43f1 100644
--- a/arch/mips/cpu/cpu.c
+++ b/arch/mips/cpu/cpu.c
@@ -4,7 +4,6 @@
* Wolfgang Denk, DENX Software Engineering, <wd@denx.de>
*/
-#include <common.h>
#include <command.h>
#include <init.h>
#include <linux/compiler.h>
diff --git a/arch/mips/cpu/interrupts.c b/arch/mips/cpu/interrupts.c
index b3ba9aaeae1..f7f9a185ed4 100644
--- a/arch/mips/cpu/interrupts.c
+++ b/arch/mips/cpu/interrupts.c
@@ -4,7 +4,6 @@
* Wolfgang Denk, DENX Software Engineering, <wd@denx.de>
*/
-#include <common.h>
#include <irq_func.h>
int interrupt_init(void)
diff --git a/arch/mips/cpu/time.c b/arch/mips/cpu/time.c
index 5e7a7144d02..210709d3b81 100644
--- a/arch/mips/cpu/time.c
+++ b/arch/mips/cpu/time.c
@@ -4,7 +4,6 @@
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
*/
-#include <common.h>
#include <time.h>
#include <asm/mipsregs.h>
diff --git a/arch/mips/include/asm/cacheops.h b/arch/mips/include/asm/cacheops.h
index 641e2ad58de..c1015c885e1 100644
--- a/arch/mips/include/asm/cacheops.h
+++ b/arch/mips/include/asm/cacheops.h
@@ -11,6 +11,7 @@
#include <asm/cache.h>
#ifndef __ASSEMBLY__
+#include <linux/types.h>
static inline void mips_cache(int op, const volatile void *addr)
{
diff --git a/arch/mips/lib/boot.c b/arch/mips/lib/boot.c
index 1b29d637ce9..749625aa974 100644
--- a/arch/mips/lib/boot.c
+++ b/arch/mips/lib/boot.c
@@ -3,7 +3,6 @@
* Copyright (C) 2020 Stefan Roese <sr@denx.de>
*/
-#include <common.h>
#include <command.h>
#include <cpu_func.h>
#include <asm/global_data.h>
diff --git a/arch/mips/lib/bootm.c b/arch/mips/lib/bootm.c
index ab92bd06b0e..d6d2f7d9d03 100644
--- a/arch/mips/lib/bootm.c
+++ b/arch/mips/lib/bootm.c
@@ -4,7 +4,6 @@
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
*/
-#include <common.h>
#include <bootstage.h>
#include <env.h>
#include <image.h>
diff --git a/arch/mips/lib/cache.c b/arch/mips/lib/cache.c
index d23b38d6b93..d365578b926 100644
--- a/arch/mips/lib/cache.c
+++ b/arch/mips/lib/cache.c
@@ -4,7 +4,6 @@
* Wolfgang Denk, DENX Software Engineering, <wd@denx.de>
*/
-#include <common.h>
#include <cpu_func.h>
#include <malloc.h>
#include <asm/cache.h>
diff --git a/arch/mips/lib/reloc.c b/arch/mips/lib/reloc.c
index 9cf6809f406..69dd63a31d2 100644
--- a/arch/mips/lib/reloc.c
+++ b/arch/mips/lib/reloc.c
@@ -26,7 +26,6 @@
* terminating R_MIPS_NONE reloc includes no offset.
*/
-#include <common.h>
#include <cpu_func.h>
#include <init.h>
#include <asm/relocs.h>
diff --git a/arch/mips/lib/spl.c b/arch/mips/lib/spl.c
index f96fda5b2de..b4087546dd1 100644
--- a/arch/mips/lib/spl.c
+++ b/arch/mips/lib/spl.c
@@ -3,7 +3,6 @@
* Copyright (C) 2020 Stefan Roese <sr@denx.de>
*/
-#include <common.h>
#include <cpu_func.h>
#include <log.h>
#include <spl.h>
diff --git a/arch/mips/lib/stack.c b/arch/mips/lib/stack.c
index 930d21856d9..5797271ae94 100644
--- a/arch/mips/lib/stack.c
+++ b/arch/mips/lib/stack.c
@@ -1,6 +1,5 @@
// SPDX-License-Identifier: GPL-2.0+
-#include <common.h>
#include <init.h>
#include <log.h>
#include <asm/global_data.h>
diff --git a/arch/mips/lib/traps.c b/arch/mips/lib/traps.c
index 7a682f256a6..40469d1be09 100644
--- a/arch/mips/lib/traps.c
+++ b/arch/mips/lib/traps.c
@@ -10,9 +10,9 @@
* Copyright (C) 2014, Imagination Technologies Ltd.
*/
-#include <common.h>
#include <asm/global_data.h>
#include <asm/ptrace.h>
+#include <config.h>
#include <cpu_func.h>
#include <hang.h>
#include <init.h>
@@ -20,6 +20,7 @@
#include <asm/mipsregs.h>
#include <asm/addrspace.h>
#include <asm/system.h>
+#include <asm/u-boot.h>
DECLARE_GLOBAL_DATA_PTR;
diff --git a/arch/mips/mach-ath79/ar933x/clk.c b/arch/mips/mach-ath79/ar933x/clk.c
index 68d48939d7d..86fc40a657e 100644
--- a/arch/mips/mach-ath79/ar933x/clk.c
+++ b/arch/mips/mach-ath79/ar933x/clk.c
@@ -3,7 +3,6 @@
* Copyright (C) 2015-2016 Wills Wang <wills.wang@live.com>
*/
-#include <common.h>
#include <clock_legacy.h>
#include <asm/global_data.h>
#include <asm/io.h>
diff --git a/arch/mips/mach-ath79/ar933x/ddr.c b/arch/mips/mach-ath79/ar933x/ddr.c
index 09166ecf8f0..a932efbfbd7 100644
--- a/arch/mips/mach-ath79/ar933x/ddr.c
+++ b/arch/mips/mach-ath79/ar933x/ddr.c
@@ -4,7 +4,6 @@
* Based on Atheros LSDK/QSDK
*/
-#include <common.h>
#include <asm/io.h>
#include <asm/addrspace.h>
#include <asm/types.h>
diff --git a/arch/mips/mach-ath79/ar934x/clk.c b/arch/mips/mach-ath79/ar934x/clk.c
index 6ed4057353a..bdaa6839a2b 100644
--- a/arch/mips/mach-ath79/ar934x/clk.c
+++ b/arch/mips/mach-ath79/ar934x/clk.c
@@ -3,7 +3,6 @@
* Copyright (C) 2016 Marek Vasut <marex@denx.de>
*/
-#include <common.h>
#include <clock_legacy.h>
#include <command.h>
#include <hang.h>
diff --git a/arch/mips/mach-ath79/ar934x/cpu.c b/arch/mips/mach-ath79/ar934x/cpu.c
index 7daac036714..f2e4ef191eb 100644
--- a/arch/mips/mach-ath79/ar934x/cpu.c
+++ b/arch/mips/mach-ath79/ar934x/cpu.c
@@ -3,7 +3,5 @@
* Copyright (C) 2016 Marek Vasut <marex@denx.de>
*/
-#include <common.h>
-
/* The lowlevel_init() is not needed on AR934x */
void lowlevel_init(void) {}
diff --git a/arch/mips/mach-ath79/ar934x/ddr.c b/arch/mips/mach-ath79/ar934x/ddr.c
index 9df48b97ef4..e260783d959 100644
--- a/arch/mips/mach-ath79/ar934x/ddr.c
+++ b/arch/mips/mach-ath79/ar934x/ddr.c
@@ -5,7 +5,6 @@
* Based on RAM init sequence by Piotr Dymacz <pepe2k@gmail.com>
*/
-#include <common.h>
#include <asm/global_data.h>
#include <asm/io.h>
#include <asm/addrspace.h>
diff --git a/arch/mips/mach-ath79/cpu.c b/arch/mips/mach-ath79/cpu.c
index 79f419088a9..24160ef1152 100644
--- a/arch/mips/mach-ath79/cpu.c
+++ b/arch/mips/mach-ath79/cpu.c
@@ -3,7 +3,6 @@
* Copyright (C) 2015-2016 Wills Wang <wills.wang@live.com>
*/
-#include <common.h>
#include <init.h>
#include <asm/io.h>
#include <asm/addrspace.h>
diff --git a/arch/mips/mach-ath79/dram.c b/arch/mips/mach-ath79/dram.c
index 545b1199e10..247691d3378 100644
--- a/arch/mips/mach-ath79/dram.c
+++ b/arch/mips/mach-ath79/dram.c
@@ -3,7 +3,6 @@
* Copyright (C) 2015-2016 Wills Wang <wills.wang@live.com>
*/
-#include <common.h>
#include <init.h>
#include <asm/global_data.h>
#include <linux/sizes.h>
diff --git a/arch/mips/mach-ath79/qca953x/clk.c b/arch/mips/mach-ath79/qca953x/clk.c
index f5438ef1c8d..379085f1ff7 100644
--- a/arch/mips/mach-ath79/qca953x/clk.c
+++ b/arch/mips/mach-ath79/qca953x/clk.c
@@ -3,7 +3,6 @@
* Copyright (C) 2015-2016 Wills Wang <wills.wang@live.com>
*/
-#include <common.h>
#include <clock_legacy.h>
#include <asm/global_data.h>
#include <asm/io.h>
diff --git a/arch/mips/mach-ath79/qca953x/ddr.c b/arch/mips/mach-ath79/qca953x/ddr.c
index 78f2370e09c..0eb69d3a0fb 100644
--- a/arch/mips/mach-ath79/qca953x/ddr.c
+++ b/arch/mips/mach-ath79/qca953x/ddr.c
@@ -4,7 +4,6 @@
* Based on Atheros LSDK/QSDK
*/
-#include <common.h>
#include <asm/io.h>
#include <asm/addrspace.h>
#include <asm/types.h>
diff --git a/arch/mips/mach-ath79/qca956x/clk.c b/arch/mips/mach-ath79/qca956x/clk.c
index 6a58dba91f3..6138a915efc 100644
--- a/arch/mips/mach-ath79/qca956x/clk.c
+++ b/arch/mips/mach-ath79/qca956x/clk.c
@@ -3,7 +3,6 @@
* Copyright (C) 2019 Rosy Song <rosysong@rosinson.com>
*/
-#include <common.h>
#include <clock_legacy.h>
#include <log.h>
#include <asm/global_data.h>
diff --git a/arch/mips/mach-ath79/qca956x/cpu.c b/arch/mips/mach-ath79/qca956x/cpu.c
index 08a8c84e72d..7da8d0e60f1 100644
--- a/arch/mips/mach-ath79/qca956x/cpu.c
+++ b/arch/mips/mach-ath79/qca956x/cpu.c
@@ -3,7 +3,5 @@
* Copyright (C) 2019 Rosy Song <rosysong@rosinson.com>
*/
-#include <common.h>
-
/* The lowlevel_init() is not needed on QCA956X */
void lowlevel_init(void) {}
diff --git a/arch/mips/mach-ath79/qca956x/ddr.c b/arch/mips/mach-ath79/qca956x/ddr.c
index f9cf8daa224..2e46e24f483 100644
--- a/arch/mips/mach-ath79/qca956x/ddr.c
+++ b/arch/mips/mach-ath79/qca956x/ddr.c
@@ -5,7 +5,6 @@
* Based on QSDK
*/
-#include <common.h>
#include <asm/global_data.h>
#include <asm/io.h>
#include <asm/addrspace.h>
diff --git a/arch/mips/mach-ath79/reset.c b/arch/mips/mach-ath79/reset.c
index 6cd5e77fd15..62da8b92a7d 100644
--- a/arch/mips/mach-ath79/reset.c
+++ b/arch/mips/mach-ath79/reset.c
@@ -4,7 +4,6 @@
* Copyright (C) 2018-2019 Rosy Song <rosysong@rosinson.com>
*/
-#include <common.h>
#include <linux/bitops.h>
#include <linux/delay.h>
#include <linux/errno.h>
diff --git a/arch/mips/mach-bmips/dram.c b/arch/mips/mach-bmips/dram.c
index bba6cd6f4aa..eec8b44e47e 100644
--- a/arch/mips/mach-bmips/dram.c
+++ b/arch/mips/mach-bmips/dram.c
@@ -4,7 +4,6 @@
* Copyright (C) 2017 Álvaro Fernández Rojas <noltari@gmail.com>
*/
-#include <common.h>
#include <init.h>
#include <log.h>
#include <ram.h>
diff --git a/arch/mips/mach-jz47xx/jz4780/gpio.c b/arch/mips/mach-jz47xx/jz4780/gpio.c
index d4884e7fa9f..7f6717efc16 100644
--- a/arch/mips/mach-jz47xx/jz4780/gpio.c
+++ b/arch/mips/mach-jz47xx/jz4780/gpio.c
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: GPL-2.0+
#include <config.h>
-#include <common.h>
#include <asm/io.h>
#include <linux/bitops.h>
#include <mach/jz4780.h>
diff --git a/arch/mips/mach-jz47xx/jz4780/jz4780.c b/arch/mips/mach-jz47xx/jz4780/jz4780.c
index 56fdf04bca9..1d6fb6a4e27 100644
--- a/arch/mips/mach-jz47xx/jz4780/jz4780.c
+++ b/arch/mips/mach-jz47xx/jz4780/jz4780.c
@@ -7,7 +7,6 @@
*/
#include <config.h>
-#include <common.h>
#include <cpu_func.h>
#include <hang.h>
#include <image.h>
diff --git a/arch/mips/mach-jz47xx/jz4780/pll.c b/arch/mips/mach-jz47xx/jz4780/pll.c
index 4519b478ccb..8ef00f99a10 100644
--- a/arch/mips/mach-jz47xx/jz4780/pll.c
+++ b/arch/mips/mach-jz47xx/jz4780/pll.c
@@ -7,7 +7,6 @@
*/
#include <config.h>
-#include <common.h>
#include <asm/io.h>
#include <linux/bitops.h>
#include <linux/delay.h>
diff --git a/arch/mips/mach-jz47xx/jz4780/reset.c b/arch/mips/mach-jz47xx/jz4780/reset.c
index bf6addccb5d..d2e9eb79e6d 100644
--- a/arch/mips/mach-jz47xx/jz4780/reset.c
+++ b/arch/mips/mach-jz47xx/jz4780/reset.c
@@ -7,7 +7,6 @@
*/
#include <config.h>
-#include <common.h>
#include <asm/io.h>
#include <linux/bitops.h>
#include <mach/jz4780.h>
diff --git a/arch/mips/mach-jz47xx/jz4780/sdram.c b/arch/mips/mach-jz47xx/jz4780/sdram.c
index 690f3c5601d..09296ee21ad 100644
--- a/arch/mips/mach-jz47xx/jz4780/sdram.c
+++ b/arch/mips/mach-jz47xx/jz4780/sdram.c
@@ -9,7 +9,6 @@
* Copyright (c) 2006-2013 Ingenic Semiconductor
*/
-#include <common.h>
#include <hang.h>
#include <init.h>
#include <asm/io.h>
diff --git a/arch/mips/mach-jz47xx/jz4780/timer.c b/arch/mips/mach-jz47xx/jz4780/timer.c
index 82bb9e8c3bf..94ef505f18f 100644
--- a/arch/mips/mach-jz47xx/jz4780/timer.c
+++ b/arch/mips/mach-jz47xx/jz4780/timer.c
@@ -7,7 +7,6 @@
*/
#include <config.h>
-#include <common.h>
#include <div64.h>
#include <init.h>
#include <irq_func.h>
diff --git a/arch/mips/mach-mscc/cpu.c b/arch/mips/mach-mscc/cpu.c
index d484eb92c41..22b1b98e0ef 100644
--- a/arch/mips/mach-mscc/cpu.c
+++ b/arch/mips/mach-mscc/cpu.c
@@ -3,7 +3,6 @@
* Copyright (c) 2018 Microsemi Corporation
*/
-#include <common.h>
#include <init.h>
#include <asm/global_data.h>
#include <linux/bitops.h>
diff --git a/arch/mips/mach-mscc/dram.c b/arch/mips/mach-mscc/dram.c
index f7fbd33cc4b..c7c2040a11a 100644
--- a/arch/mips/mach-mscc/dram.c
+++ b/arch/mips/mach-mscc/dram.c
@@ -3,7 +3,6 @@
* Copyright (c) 2018 Microsemi Corporation
*/
-#include <common.h>
#include <init.h>
#include <asm/global_data.h>
diff --git a/arch/mips/mach-mscc/gpio.c b/arch/mips/mach-mscc/gpio.c
index d6b4c5d7684..6cd0e2436e7 100644
--- a/arch/mips/mach-mscc/gpio.c
+++ b/arch/mips/mach-mscc/gpio.c
@@ -3,7 +3,6 @@
* Copyright (c) 2018 Microsemi Corporation
*/
-#include <common.h>
#include <asm/io.h>
#include <linux/bitops.h>
diff --git a/arch/mips/mach-mscc/include/mach/ddr.h b/arch/mips/mach-mscc/include/mach/ddr.h
index 75fb3ca00d2..3ba33d27c17 100644
--- a/arch/mips/mach-mscc/include/mach/ddr.h
+++ b/arch/mips/mach-mscc/include/mach/ddr.h
@@ -6,6 +6,7 @@
#ifndef __ASM_MACH_DDR_H
#define __ASM_MACH_DDR_H
+#include <config.h>
#include <asm/cacheops.h>
#include <asm/io.h>
#include <asm/reboot.h>
diff --git a/arch/mips/mach-mscc/phy.c b/arch/mips/mach-mscc/phy.c
index 83d3e5bdd28..444d1f5315d 100644
--- a/arch/mips/mach-mscc/phy.c
+++ b/arch/mips/mach-mscc/phy.c
@@ -3,7 +3,6 @@
* Copyright (c) 2018 Microsemi Corporation
*/
-#include <common.h>
#include <log.h>
#include <asm/io.h>
diff --git a/arch/mips/mach-mscc/reset.c b/arch/mips/mach-mscc/reset.c
index a1214573b51..ca9a7c679d9 100644
--- a/arch/mips/mach-mscc/reset.c
+++ b/arch/mips/mach-mscc/reset.c
@@ -3,8 +3,6 @@
* Copyright (c) 2018 Microsemi Corporation
*/
-#include <common.h>
-
#include <asm/sections.h>
#include <asm/io.h>
diff --git a/arch/mips/mach-mtmips/cpu.c b/arch/mips/mach-mtmips/cpu.c
index e88dab10c76..243938a0ebb 100644
--- a/arch/mips/mach-mtmips/cpu.c
+++ b/arch/mips/mach-mtmips/cpu.c
@@ -3,7 +3,6 @@
* Copyright (C) 2018 Stefan Roese <sr@denx.de>
*/
-#include <common.h>
#include <event.h>
#include <init.h>
#include <malloc.h>
diff --git a/arch/mips/mach-mtmips/ddr_cal.c b/arch/mips/mach-mtmips/ddr_cal.c
index 762619a960f..e2e1760a646 100644
--- a/arch/mips/mach-mtmips/ddr_cal.c
+++ b/arch/mips/mach-mtmips/ddr_cal.c
@@ -5,7 +5,6 @@
* Author: Weijie Gao <weijie.gao@mediatek.com>
*/
-#include <common.h>
#include <asm/addrspace.h>
#include <asm/cacheops.h>
#include <asm/global_data.h>
diff --git a/arch/mips/mach-mtmips/ddr_init.c b/arch/mips/mach-mtmips/ddr_init.c
index 9c986daea6f..cab53561e42 100644
--- a/arch/mips/mach-mtmips/ddr_init.c
+++ b/arch/mips/mach-mtmips/ddr_init.c
@@ -5,7 +5,6 @@
* Author: Weijie Gao <weijie.gao@mediatek.com>
*/
-#include <common.h>
#include <linux/bitops.h>
#include <linux/delay.h>
#include <linux/io.h>
diff --git a/arch/mips/mach-mtmips/mt7628/ddr.c b/arch/mips/mach-mtmips/mt7628/ddr.c
index 4e72459906e..198bf262f92 100644
--- a/arch/mips/mach-mtmips/mt7628/ddr.c
+++ b/arch/mips/mach-mtmips/mt7628/ddr.c
@@ -5,7 +5,6 @@
* Author: Weijie Gao <weijie.gao@mediatek.com>
*/
-#include <common.h>
#include <asm/addrspace.h>
#include <asm/global_data.h>
#include <linux/bitops.h>
diff --git a/arch/mips/mach-mtmips/mt7628/init.c b/arch/mips/mach-mtmips/mt7628/init.c
index 6b535129df1..2996fd9ef4e 100644
--- a/arch/mips/mach-mtmips/mt7628/init.c
+++ b/arch/mips/mach-mtmips/mt7628/init.c
@@ -5,7 +5,6 @@
* Author: Weijie Gao <weijie.gao@mediatek.com>
*/
-#include <common.h>
#include <clk.h>
#include <dm.h>
#include <asm/global_data.h>
diff --git a/arch/mips/mach-mtmips/mt7628/serial.c b/arch/mips/mach-mtmips/mt7628/serial.c
index e5f3f87a673..11a2149e127 100644
--- a/arch/mips/mach-mtmips/mt7628/serial.c
+++ b/arch/mips/mach-mtmips/mt7628/serial.c
@@ -5,7 +5,6 @@
* Author: Weijie Gao <weijie.gao@mediatek.com>
*/
-#include <common.h>
#include <asm/io.h>
#include "mt7628.h"
diff --git a/arch/mips/mach-mtmips/spl.c b/arch/mips/mach-mtmips/spl.c
index fe5b49e702f..0208bc423df 100644
--- a/arch/mips/mach-mtmips/spl.c
+++ b/arch/mips/mach-mtmips/spl.c
@@ -5,7 +5,6 @@
* Author: Weijie Gao <weijie.gao@mediatek.com>
*/
-#include <common.h>
#include <init.h>
#include <spl.h>
#include <asm/sections.h>
diff --git a/arch/mips/mach-pic32/cpu.c b/arch/mips/mach-pic32/cpu.c
index 7ed306e045e..dbf8c9cd221 100644
--- a/arch/mips/mach-pic32/cpu.c
+++ b/arch/mips/mach-pic32/cpu.c
@@ -4,7 +4,6 @@
* Purna Chandra Mandal <purna.mandal@microchip.com>
*
*/
-#include <common.h>
#include <clk.h>
#include <dm.h>
#include <event.h>
diff --git a/arch/mips/mach-pic32/reset.c b/arch/mips/mach-pic32/reset.c
index 8071b13f7b4..efd6985b44a 100644
--- a/arch/mips/mach-pic32/reset.c
+++ b/arch/mips/mach-pic32/reset.c
@@ -4,7 +4,6 @@
*
*/
-#include <common.h>
#include <asm/io.h>
#include <mach/pic32.h>
diff --git a/arch/riscv/cpu/andesv5/cache.c b/arch/riscv/cpu/andesv5/cache.c
index 40d77f671c8..269bb27f75a 100644
--- a/arch/riscv/cpu/andesv5/cache.c
+++ b/arch/riscv/cpu/andesv5/cache.c
@@ -6,7 +6,6 @@
#include <asm/csr.h>
#include <asm/asm.h>
-#include <common.h>
#include <cache.h>
#include <cpu_func.h>
#include <dm.h>
diff --git a/arch/riscv/cpu/andesv5/cpu.c b/arch/riscv/cpu/andesv5/cpu.c
index 06e379bcb1f..63bc24cdfc7 100644
--- a/arch/riscv/cpu/andesv5/cpu.c
+++ b/arch/riscv/cpu/andesv5/cpu.c
@@ -5,7 +5,6 @@
*/
/* CPU specific code */
-#include <common.h>
#include <cpu_func.h>
#include <irq_func.h>
#include <asm/cache.h>
diff --git a/arch/riscv/cpu/andesv5/spl.c b/arch/riscv/cpu/andesv5/spl.c
index 413849043b1..a13dc4095a4 100644
--- a/arch/riscv/cpu/andesv5/spl.c
+++ b/arch/riscv/cpu/andesv5/spl.c
@@ -3,7 +3,6 @@
* Copyright (C) 2023 Andes Technology Corporation
* Rick Chen, Andes Technology Corporation <rick@andestech.com>
*/
-#include <common.h>
#include <cpu_func.h>
#include <hang.h>
#include <init.h>
diff --git a/arch/riscv/cpu/cpu.c b/arch/riscv/cpu/cpu.c
index c1a9638c1ab..ebd39cb41a6 100644
--- a/arch/riscv/cpu/cpu.c
+++ b/arch/riscv/cpu/cpu.c
@@ -3,7 +3,6 @@
* Copyright (C) 2018, Bin Meng <bmeng.cn@gmail.com>
*/
-#include <common.h>
#include <cpu.h>
#include <dm.h>
#include <dm/lists.h>
diff --git a/arch/riscv/cpu/fu540/dram.c b/arch/riscv/cpu/fu540/dram.c
index 94d8018407e..7b5a3471ac8 100644
--- a/arch/riscv/cpu/fu540/dram.c
+++ b/arch/riscv/cpu/fu540/dram.c
@@ -3,7 +3,6 @@
* Copyright (C) 2018, Bin Meng <bmeng.cn@gmail.com>
*/
-#include <common.h>
#include <fdtdec.h>
#include <init.h>
#include <asm/global_data.h>
diff --git a/arch/riscv/cpu/fu740/dram.c b/arch/riscv/cpu/fu740/dram.c
index 8657fcd165c..61f551763f1 100644
--- a/arch/riscv/cpu/fu740/dram.c
+++ b/arch/riscv/cpu/fu740/dram.c
@@ -3,7 +3,6 @@
* Copyright (C) 2018, Bin Meng <bmeng.cn@gmail.com>
*/
-#include <common.h>
#include <fdtdec.h>
#include <init.h>
#include <linux/sizes.h>
diff --git a/arch/riscv/cpu/generic/cpu.c b/arch/riscv/cpu/generic/cpu.c
index d78e1a3453a..f13c18942f3 100644
--- a/arch/riscv/cpu/generic/cpu.c
+++ b/arch/riscv/cpu/generic/cpu.c
@@ -3,7 +3,6 @@
* Copyright (C) 2018, Bin Meng <bmeng.cn@gmail.com>
*/
-#include <common.h>
#include <irq_func.h>
#include <asm/cache.h>
diff --git a/arch/riscv/cpu/generic/dram.c b/arch/riscv/cpu/generic/dram.c
index 1b51bae9b66..91007c0a3d3 100644
--- a/arch/riscv/cpu/generic/dram.c
+++ b/arch/riscv/cpu/generic/dram.c
@@ -3,7 +3,6 @@
* Copyright (C) 2018, Bin Meng <bmeng.cn@gmail.com>
*/
-#include <common.h>
#include <fdtdec.h>
#include <init.h>
#include <asm/global_data.h>
diff --git a/arch/riscv/cpu/jh7110/dram.c b/arch/riscv/cpu/jh7110/dram.c
index 1a9fa46d14b..664b9b93eb6 100644
--- a/arch/riscv/cpu/jh7110/dram.c
+++ b/arch/riscv/cpu/jh7110/dram.c
@@ -4,7 +4,6 @@
* Author: Yanhong Wang <yanhong.wang@starfivetech.com>
*/
-#include <common.h>
#include <fdtdec.h>
#include <init.h>
#include <linux/sizes.h>
diff --git a/arch/riscv/cpu/jh7110/spl.c b/arch/riscv/cpu/jh7110/spl.c
index 4047b10efe8..6bdf8b9c72f 100644
--- a/arch/riscv/cpu/jh7110/spl.c
+++ b/arch/riscv/cpu/jh7110/spl.c
@@ -3,7 +3,6 @@
* Copyright (C) 2022 StarFive Technology Co., Ltd.
* Author: Yanhong Wang<yanhong.wang@starfivetech.com>
*/
-#include <common.h>
#include <asm/arch/eeprom.h>
#include <asm/csr.h>
#include <asm/sections.h>
diff --git a/arch/riscv/cpu/mtrap.S b/arch/riscv/cpu/mtrap.S
index e40c7bd3f4f..6eb3ed1d5a8 100644
--- a/arch/riscv/cpu/mtrap.S
+++ b/arch/riscv/cpu/mtrap.S
@@ -11,7 +11,6 @@
* Copyright (C) 2018, Bin Meng <bmeng.cn@gmail.com>
*/
-#include <common.h>
#include <asm/encoding.h>
#ifdef CONFIG_32BIT
diff --git a/arch/riscv/cpu/start.S b/arch/riscv/cpu/start.S
index 30cf6743701..6cecadfac56 100644
--- a/arch/riscv/cpu/start.S
+++ b/arch/riscv/cpu/start.S
@@ -11,7 +11,6 @@
#include <asm-offsets.h>
#include <config.h>
-#include <common.h>
#include <elf.h>
#include <system-constants.h>
#include <asm/encoding.h>
diff --git a/arch/riscv/include/asm/arch-andes/csr.h b/arch/riscv/include/asm/arch-andes/csr.h
index c7ed920cde5..393d51c6dde 100644
--- a/arch/riscv/include/asm/arch-andes/csr.h
+++ b/arch/riscv/include/asm/arch-andes/csr.h
@@ -7,6 +7,7 @@
#define _ASM_ANDES_CSR_H
#include <asm/asm.h>
+#include <linux/bitops.h>
#include <linux/const.h>
#define CSR_MCACHE_CTL 0x7ca
diff --git a/arch/riscv/include/asm/arch-jh7110/eeprom.h b/arch/riscv/include/asm/arch-jh7110/eeprom.h
index f354d5c60cd..d2776d5b6cb 100644
--- a/arch/riscv/include/asm/arch-jh7110/eeprom.h
+++ b/arch/riscv/include/asm/arch-jh7110/eeprom.h
@@ -7,6 +7,8 @@
#ifndef _ASM_RISCV_EEPROM_H
#define _ASM_RISCV_EEPROM_H
+#include <linux/types.h>
+
u8 get_pcb_revision_from_eeprom(void);
u32 get_ddr_size_from_eeprom(void);
diff --git a/arch/riscv/include/asm/dma-mapping.h b/arch/riscv/include/asm/dma-mapping.h
index 6ecadab41cd..d0cc5d7c775 100644
--- a/arch/riscv/include/asm/dma-mapping.h
+++ b/arch/riscv/include/asm/dma-mapping.h
@@ -9,7 +9,6 @@
#ifndef __ASM_RISCV_DMA_MAPPING_H
#define __ASM_RISCV_DMA_MAPPING_H
-#include <common.h>
#include <linux/types.h>
#include <asm/cache.h>
#include <cpu_func.h>
diff --git a/arch/riscv/include/asm/smp.h b/arch/riscv/include/asm/smp.h
index 4284a332e98..ee749dd1195 100644
--- a/arch/riscv/include/asm/smp.h
+++ b/arch/riscv/include/asm/smp.h
@@ -7,6 +7,8 @@
#ifndef _ASM_RISCV_SMP_H
#define _ASM_RISCV_SMP_H
+#include <linux/types.h>
+
/**
* struct ipi_data - Inter-processor interrupt (IPI) data structure
*
diff --git a/arch/riscv/lib/aclint_ipi.c b/arch/riscv/lib/aclint_ipi.c
index 90b8e128cb1..dcd7e5e6b34 100644
--- a/arch/riscv/lib/aclint_ipi.c
+++ b/arch/riscv/lib/aclint_ipi.c
@@ -8,7 +8,6 @@
* associated with software and timer interrupts.
*/
-#include <common.h>
#include <dm.h>
#include <regmap.h>
#include <syscon.h>
diff --git a/arch/riscv/lib/andes_plicsw.c b/arch/riscv/lib/andes_plicsw.c
index 6fd49e873b1..6a63661312a 100644
--- a/arch/riscv/lib/andes_plicsw.c
+++ b/arch/riscv/lib/andes_plicsw.c
@@ -8,7 +8,6 @@
* similar to RISC-V PLIC.
*/
-#include <common.h>
#include <dm.h>
#include <asm/global_data.h>
#include <dm/device-internal.h>
diff --git a/arch/riscv/lib/asm-offsets.c b/arch/riscv/lib/asm-offsets.c
index 452dfcea97f..875bb9a6d98 100644
--- a/arch/riscv/lib/asm-offsets.c
+++ b/arch/riscv/lib/asm-offsets.c
@@ -8,7 +8,6 @@
* assembly language modules.
*/
-#include <common.h>
#include <asm/global_data.h>
#include <linux/kbuild.h>
diff --git a/arch/riscv/lib/boot.c b/arch/riscv/lib/boot.c
index 778d011f7ce..03014c56dce 100644
--- a/arch/riscv/lib/boot.c
+++ b/arch/riscv/lib/boot.c
@@ -4,8 +4,7 @@
* Rick Chen, Andes Technology Corporation <rick@andestech.com>
*/
-#include <common.h>
-#include <command.h>
+#include <asm/u-boot.h>
unsigned long do_go_exec(ulong (*entry)(int, char * const []),
int argc, char *const argv[])
diff --git a/arch/riscv/lib/bootm.c b/arch/riscv/lib/bootm.c
index cc30efc9049..f9e1e18ae02 100644
--- a/arch/riscv/lib/bootm.c
+++ b/arch/riscv/lib/bootm.c
@@ -6,7 +6,6 @@
* Rick Chen, Andes Technology Corporation <rick@andestech.com>
*/
-#include <common.h>
#include <bootstage.h>
#include <command.h>
#include <dm.h>
diff --git a/arch/riscv/lib/cache.c b/arch/riscv/lib/cache.c
index 686e699efbc..c46b49eb0ac 100644
--- a/arch/riscv/lib/cache.c
+++ b/arch/riscv/lib/cache.c
@@ -4,7 +4,6 @@
* Rick Chen, Andes Technology Corporation <rick@andestech.com>
*/
-#include <common.h>
#include <cpu_func.h>
void invalidate_icache_all(void)
diff --git a/arch/riscv/lib/fdt_fixup.c b/arch/riscv/lib/fdt_fixup.c
index 36c16e9be2a..c658e72bd39 100644
--- a/arch/riscv/lib/fdt_fixup.c
+++ b/arch/riscv/lib/fdt_fixup.c
@@ -6,7 +6,6 @@
#define LOG_CATEGORY LOGC_ARCH
-#include <common.h>
#include <fdt_support.h>
#include <log.h>
#include <mapmem.h>
diff --git a/arch/riscv/lib/image.c b/arch/riscv/lib/image.c
index a65a5b8d17c..a82f48e9a50 100644
--- a/arch/riscv/lib/image.c
+++ b/arch/riscv/lib/image.c
@@ -6,7 +6,6 @@
* Based on arm/lib/image.c
*/
-#include <common.h>
#include <image.h>
#include <mapmem.h>
#include <errno.h>
diff --git a/arch/riscv/lib/interrupts.c b/arch/riscv/lib/interrupts.c
index e966afa7e3e..02dbcfd4238 100644
--- a/arch/riscv/lib/interrupts.c
+++ b/arch/riscv/lib/interrupts.c
@@ -10,7 +10,6 @@
*/
#include <linux/compat.h>
-#include <common.h>
#include <efi_loader.h>
#include <hang.h>
#include <irq_func.h>
diff --git a/arch/riscv/lib/reset.c b/arch/riscv/lib/reset.c
index 8779c619cc5..712e1bdb8e1 100644
--- a/arch/riscv/lib/reset.c
+++ b/arch/riscv/lib/reset.c
@@ -3,7 +3,6 @@
* Copyright (C) 2018, Bin Meng <bmeng.cn@gmail.com>
*/
-#include <common.h>
#include <command.h>
#include <hang.h>
diff --git a/arch/riscv/lib/sbi.c b/arch/riscv/lib/sbi.c
index 55a3bc3b5c9..35a7d3b12f5 100644
--- a/arch/riscv/lib/sbi.c
+++ b/arch/riscv/lib/sbi.c
@@ -7,7 +7,7 @@
* Taken from Linux arch/riscv/kernel/sbi.c
*/
-#include <common.h>
+#include <errno.h>
#include <asm/encoding.h>
#include <asm/sbi.h>
diff --git a/arch/riscv/lib/sbi_ipi.c b/arch/riscv/lib/sbi_ipi.c
index d02e2b4c488..511d3816da8 100644
--- a/arch/riscv/lib/sbi_ipi.c
+++ b/arch/riscv/lib/sbi_ipi.c
@@ -4,7 +4,6 @@
* Lukas Auer <lukas.auer@aisec.fraunhofer.de>
*/
-#include <common.h>
#include <asm/encoding.h>
#include <asm/sbi.h>
diff --git a/arch/riscv/lib/sifive_cache.c b/arch/riscv/lib/sifive_cache.c
index 28154878fcc..39b0248c323 100644
--- a/arch/riscv/lib/sifive_cache.c
+++ b/arch/riscv/lib/sifive_cache.c
@@ -3,9 +3,9 @@
* Copyright (C) 2021 SiFive, Inc
*/
-#include <common.h>
#include <cache.h>
#include <cpu_func.h>
+#include <log.h>
#include <dm.h>
void enable_caches(void)
diff --git a/arch/riscv/lib/smp.c b/arch/riscv/lib/smp.c
index f3cd8b9044a..a692f065edd 100644
--- a/arch/riscv/lib/smp.c
+++ b/arch/riscv/lib/smp.c
@@ -4,7 +4,6 @@
* Lukas Auer <lukas.auer@aisec.fraunhofer.de>
*/
-#include <common.h>
#include <cpu_func.h>
#include <dm.h>
#include <asm/barrier.h>
diff --git a/arch/riscv/lib/spl.c b/arch/riscv/lib/spl.c
index 9b242ed8212..9a7a4f6ac8d 100644
--- a/arch/riscv/lib/spl.c
+++ b/arch/riscv/lib/spl.c
@@ -3,7 +3,6 @@
* Copyright (C) 2019 Fraunhofer AISEC,
* Lukas Auer <lukas.auer@aisec.fraunhofer.de>
*/
-#include <common.h>
#include <cpu_func.h>
#include <hang.h>
#include <init.h>
diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index e4303473563..5b54651a1da 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -41,6 +41,7 @@
mmc3 = "/mmc3";
mmc4 = "/mmc4";
mmc5 = "/mmc5";
+ mmc6 = "/mmc6";
pci0 = &pci0;
pci1 = &pci1;
pci2 = &pci2;
@@ -732,6 +733,11 @@
#address-cells = <1>;
#size-cells = <0>;
+ pwrdom_scmi: protocol@11 {
+ reg = <0x11>;
+ #power-domain-cells = <1>;
+ };
+
clk_scmi: protocol@14 {
reg = <0x14>;
#clock-cells = <1>;
@@ -1102,6 +1108,13 @@
filename = "mmc5.img";
};
+ /* This is used for mbr tests */
+ mmc6 {
+ status = "disabled";
+ compatible = "sandbox,mmc";
+ filename = "mmc6.img";
+ };
+
pch {
compatible = "sandbox,pch";
};
@@ -1639,6 +1652,7 @@
sandbox_scmi {
compatible = "sandbox,scmi-devices";
+ power-domains = <&pwrdom_scmi 2>;
clocks = <&clk_scmi 2>, <&clk_scmi 0>;
resets = <&reset_scmi 3>;
regul0-supply = <&regul0_scmi>;
diff --git a/arch/sandbox/include/asm/scmi_test.h b/arch/sandbox/include/asm/scmi_test.h
index ccb0df6c148..619f8f5098c 100644
--- a/arch/sandbox/include/asm/scmi_test.h
+++ b/arch/sandbox/include/asm/scmi_test.h
@@ -6,11 +6,23 @@
#ifndef __SANDBOX_SCMI_TEST_H
#define __SANDBOX_SCMI_TEST_H
+#include <power-domain.h>
+
struct udevice;
struct sandbox_scmi_agent;
struct sandbox_scmi_service;
/**
+ * struct sandbox_scmi_pwd
+ * @id: Identifier of the power domain used in the SCMI protocol
+ * @pstate:: Power state of the domain
+ */
+struct sandbox_scmi_pwd {
+ uint id;
+ u32 pstate;
+};
+
+/**
* struct sandbox_scmi_clk - Simulated clock exposed by SCMI
* @id: Identifier of the clock used in the SCMI protocol
* @enabled: Clock state: true if enabled, false if disabled
@@ -45,6 +57,8 @@ struct sandbox_scmi_voltd {
/**
* struct sandbox_scmi_agent - Simulated SCMI service seen by SCMI agent
+ * @pwdom_version: Implemented power domain protocol version
+ * @pwdom_count: Simulated power domains array size
* @clk: Simulated clocks
* @clk_count: Simulated clocks array size
* @reset: Simulated reset domains
@@ -53,6 +67,9 @@ struct sandbox_scmi_voltd {
* @voltd_count: Simulated voltage domains array size
*/
struct sandbox_scmi_agent {
+ int pwdom_version;
+ struct sandbox_scmi_pwd *pwdom;
+ size_t pwdom_count;
struct sandbox_scmi_clk *clk;
size_t clk_count;
struct sandbox_scmi_reset *reset;
@@ -71,6 +88,8 @@ struct sandbox_scmi_service {
/**
* struct sandbox_scmi_devices - Reference to devices probed through SCMI
+ * @pwdom: Array of power domains
+ * @pwdom_count: Number of power domains probed
* @clk: Array the clock devices
* @clk_count: Number of clock devices probed
* @reset: Array the reset controller devices
@@ -79,6 +98,8 @@ struct sandbox_scmi_service {
* @regul_count: Number of regulator devices probed
*/
struct sandbox_scmi_devices {
+ struct power_domain *pwdom;
+ size_t pwdom_count;
struct clk *clk;
size_t clk_count;
struct reset_ctl *reset;
diff --git a/board/AndesTech/ae350/ae350.c b/board/AndesTech/ae350/ae350.c
index d78ee403e6c..772c6bf1ee3 100644
--- a/board/AndesTech/ae350/ae350.c
+++ b/board/AndesTech/ae350/ae350.c
@@ -4,7 +4,7 @@
* Rick Chen, Andes Technology Corporation <rick@andestech.com>
*/
-#include <common.h>
+#include <config.h>
#include <cpu_func.h>
#include <flash.h>
#include <image.h>
diff --git a/board/abilis/tb100/tb100.c b/board/abilis/tb100/tb100.c
index 89e73225a7d..3dc9e14ef8c 100644
--- a/board/abilis/tb100/tb100.c
+++ b/board/abilis/tb100/tb100.c
@@ -3,7 +3,6 @@
* (C) Copyright 2014 Pierrick Hascoet, Abilis Systems
*/
-#include <common.h>
#include <cpu_func.h>
#include <net.h>
#include <netdev.h>
diff --git a/board/sifive/unmatched/hifive-platform-i2c-eeprom.c b/board/sifive/unmatched/hifive-platform-i2c-eeprom.c
index c82fb5763ec..d25c24b08b3 100644
--- a/board/sifive/unmatched/hifive-platform-i2c-eeprom.c
+++ b/board/sifive/unmatched/hifive-platform-i2c-eeprom.c
@@ -9,7 +9,6 @@
* Timur Tabi (timur@freescale.com)
*/
-#include <common.h>
#include <command.h>
#include <env.h>
#include <i2c.h>
diff --git a/board/sifive/unmatched/unmatched.c b/board/sifive/unmatched/unmatched.c
index 6675548c2bf..c8696270ba2 100644
--- a/board/sifive/unmatched/unmatched.c
+++ b/board/sifive/unmatched/unmatched.c
@@ -6,7 +6,6 @@
* Pragnesh Patel <pragnesh.patel@sifive.com>
*/
-#include <common.h>
#include <cpu_func.h>
#include <dm.h>
#include <asm/sections.h>
diff --git a/board/synopsys/axs10x/axs10x.c b/board/synopsys/axs10x/axs10x.c
index 75e4d037623..95297a18357 100644
--- a/board/synopsys/axs10x/axs10x.c
+++ b/board/synopsys/axs10x/axs10x.c
@@ -3,7 +3,6 @@
* Copyright (C) 2013-2014 Synopsys, Inc. All rights reserved.
*/
-#include <common.h>
#include <cpu_func.h>
#include <dwmmc.h>
#include <init.h>
diff --git a/board/synopsys/emsdp/emsdp.c b/board/synopsys/emsdp/emsdp.c
index a3cee23411d..adec7d32199 100644
--- a/board/synopsys/emsdp/emsdp.c
+++ b/board/synopsys/emsdp/emsdp.c
@@ -3,7 +3,6 @@
* Copyright (C) 2018 Synopsys, Inc. All rights reserved.
*/
-#include <common.h>
#include <command.h>
#include <cpu_func.h>
#include <dwmmc.h>
diff --git a/board/synopsys/hsdk/clk-lib.h b/board/synopsys/hsdk/clk-lib.h
index 970bcd4a17e..e1140a10b23 100644
--- a/board/synopsys/hsdk/clk-lib.h
+++ b/board/synopsys/hsdk/clk-lib.h
@@ -7,7 +7,6 @@
#ifndef __BOARD_CLK_LIB_H
#define __BOARD_CLK_LIB_H
-#include <common.h>
#include <linux/bitops.h>
enum clk_ctl_ops {
diff --git a/board/synopsys/hsdk/env-lib.c b/board/synopsys/hsdk/env-lib.c
index d85e8167332..85a2249f17f 100644
--- a/board/synopsys/hsdk/env-lib.c
+++ b/board/synopsys/hsdk/env-lib.c
@@ -7,6 +7,8 @@
#include "env-lib.h"
#include <env.h>
#include <log.h>
+#include <vsprintf.h>
+#include <linux/errno.h>
#include <linux/printk.h>
#define MAX_CMD_LEN 25
diff --git a/board/synopsys/hsdk/env-lib.h b/board/synopsys/hsdk/env-lib.h
index 48c17c4d4f6..cabca1d0f3d 100644
--- a/board/synopsys/hsdk/env-lib.h
+++ b/board/synopsys/hsdk/env-lib.h
@@ -7,7 +7,6 @@
#ifndef __BOARD_ENV_LIB_H
#define __BOARD_ENV_LIB_H
-#include <common.h>
#include <config.h>
#include <linux/kernel.h>
diff --git a/board/synopsys/hsdk/hsdk.c b/board/synopsys/hsdk/hsdk.c
index 6cbc89ae787..8eb10f2226f 100644
--- a/board/synopsys/hsdk/hsdk.c
+++ b/board/synopsys/hsdk/hsdk.c
@@ -4,7 +4,6 @@
* Author: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
*/
-#include <common.h>
#include <command.h>
#include <config.h>
#include <cpu_func.h>
diff --git a/board/synopsys/iot_devkit/iot_devkit.c b/board/synopsys/iot_devkit/iot_devkit.c
index 650958f94c2..dec49e3ce5d 100644
--- a/board/synopsys/iot_devkit/iot_devkit.c
+++ b/board/synopsys/iot_devkit/iot_devkit.c
@@ -3,7 +3,6 @@
* Copyright (C) 2018 Synopsys, Inc. All rights reserved.
*/
-#include <common.h>
#include <cpu_func.h>
#include <init.h>
#include <malloc.h>
diff --git a/board/synopsys/nsim/nsim.c b/board/synopsys/nsim/nsim.c
index 00e5cc36414..5953b365fd2 100644
--- a/board/synopsys/nsim/nsim.c
+++ b/board/synopsys/nsim/nsim.c
@@ -3,7 +3,6 @@
* Copyright (C) 2020 Synopsys, Inc. All rights reserved.
*/
-#include <common.h>
#include <init.h>
#include <dm/device.h>
#include <virtio_types.h>
diff --git a/board/xilinx/microblaze-generic/microblaze-generic.c b/board/xilinx/microblaze-generic/microblaze-generic.c
index a427ac94a17..2b035d53589 100644
--- a/board/xilinx/microblaze-generic/microblaze-generic.c
+++ b/board/xilinx/microblaze-generic/microblaze-generic.c
@@ -10,7 +10,6 @@
* header files
*/
-#include <common.h>
#include <config.h>
#include <env.h>
#include <init.h>
diff --git a/cmd/pstore.c b/cmd/pstore.c
index cd6f6feb2fd..9795eea2dbc 100644
--- a/cmd/pstore.c
+++ b/cmd/pstore.c
@@ -486,6 +486,8 @@ void fdt_fixup_pstore(void *blob)
{
char node[32];
int nodeoffset; /* node offset from libfdt */
+ u32 addr_cells_root;
+ u32 size_cells_root;
u32 addr_cells;
u32 size_cells;
@@ -495,6 +497,8 @@ void fdt_fixup_pstore(void *blob)
log_err("fdt_path_offset() returned %s\n", fdt_strerror(nodeoffset));
return;
}
+ addr_cells_root = fdt_getprop_u32_default_node(blob, nodeoffset, 0, "#address-cells", 2);
+ size_cells_root = fdt_getprop_u32_default_node(blob, nodeoffset, 0, "#size-cells", 2);
nodeoffset = fdt_find_or_add_subnode(blob, nodeoffset, "reserved-memory");
if (nodeoffset < 0) {
@@ -503,8 +507,10 @@ void fdt_fixup_pstore(void *blob)
return;
}
- addr_cells = fdt_getprop_u32_default_node(blob, nodeoffset, 0, "#address-cells", 2);
- size_cells = fdt_getprop_u32_default_node(blob, nodeoffset, 0, "#size-cells", 2);
+ addr_cells = fdt_getprop_u32_default_node(blob, nodeoffset, 0,
+ "#address-cells", addr_cells_root);
+ size_cells = fdt_getprop_u32_default_node(blob, nodeoffset, 0,
+ "#size-cells", size_cells_root);
fdt_setprop_u32(blob, nodeoffset, "#address-cells", addr_cells);
fdt_setprop_u32(blob, nodeoffset, "#size-cells", size_cells);
diff --git a/common/Kconfig b/common/Kconfig
index 93c96f23b01..43701fe9e89 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -224,6 +224,16 @@ config CONSOLE_FLUSH_SUPPORT
help
This enables compilation of flush() function for console flush support.
+config CONSOLE_FLUSH_ON_NEWLINE
+ bool "Flush console buffer on every newline character"
+ depends on DM_SERIAL
+ help
+ This makes the serial core code flush the console device
+ whenever a newline (\n) character has been emitted. This can
+ be especially useful when "printf debugging", as otherwise
+ lots of output could still be in the UART's FIFO by the time
+ one hits the code which causes the CPU to hang or reset.
+
config CONSOLE_MUX
bool "Enable console multiplexing"
default y if VIDEO || LCD
diff --git a/common/cli_getch.c b/common/cli_getch.c
index 61d4cb261b8..0ee79087774 100644
--- a/common/cli_getch.c
+++ b/common/cli_getch.c
@@ -46,6 +46,8 @@ static int cli_ch_esc(struct cli_ch_state *cch, int ichar,
case 1:
if (ichar == '[' || ichar == 'O')
act = ESC_SAVE;
+ else
+ act = ESC_CONVERTED;
break;
case 2:
switch (ichar) {
diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index 03475a5a292..e3a2f9eb170 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -73,8 +73,6 @@ CONFIG_CMD_IDE=y
CONFIG_CMD_I2C=y
CONFIG_CMD_LOADM=y
CONFIG_CMD_LSBLK=y
-CONFIG_CMD_MBR=y
-CONFIG_CMD_MMC=y
CONFIG_CMD_MUX=y
CONFIG_CMD_OSD=y
CONFIG_CMD_PCI=y
@@ -242,6 +240,7 @@ CONFIG_PINCTRL_SANDBOX=y
CONFIG_PINCTRL_SINGLE=y
CONFIG_POWER_DOMAIN=y
CONFIG_SANDBOX_POWER_DOMAIN=y
+CONFIG_SCMI_POWER_DOMAIN=y
CONFIG_DM_PMIC=y
CONFIG_PMIC_ACT8846=y
CONFIG_DM_PMIC_PFUZE100=y
diff --git a/configs/sandbox_flattree_defconfig b/configs/sandbox_flattree_defconfig
index 29ae4532c50..44ab80725fc 100644
--- a/configs/sandbox_flattree_defconfig
+++ b/configs/sandbox_flattree_defconfig
@@ -47,10 +47,12 @@ CONFIG_CMD_MBR=y
CONFIG_CMD_MMC=y
CONFIG_CMD_OSD=y
CONFIG_CMD_PCI=y
+CONFIG_CMD_READ=y
CONFIG_CMD_REMOTEPROC=y
CONFIG_CMD_SPI=y
CONFIG_CMD_TEMPERATURE=y
CONFIG_CMD_USB=y
+CONFIG_CMD_WRITE=y
CONFIG_BOOTP_DNS2=y
CONFIG_CMD_TFTPPUT=y
CONFIG_CMD_TFTPSRV=y
diff --git a/disk/part_dos.c b/disk/part_dos.c
index 33374384373..567ead7511d 100644
--- a/disk/part_dos.c
+++ b/disk/part_dos.c
@@ -466,7 +466,7 @@ int layout_mbr_partitions(struct disk_partition *p, int count,
ext = &p[i];
}
- if (count < 4)
+ if (count <= 4)
return 0;
if (!ext) {
diff --git a/drivers/firmware/scmi/Makefile b/drivers/firmware/scmi/Makefile
index 1a23d498170..dae42863589 100644
--- a/drivers/firmware/scmi/Makefile
+++ b/drivers/firmware/scmi/Makefile
@@ -4,4 +4,5 @@ obj-y += smt.o
obj-$(CONFIG_SCMI_AGENT_SMCCC) += smccc_agent.o
obj-$(CONFIG_SCMI_AGENT_MAILBOX) += mailbox_agent.o
obj-$(CONFIG_SCMI_AGENT_OPTEE) += optee_agent.o
+obj-$(CONFIG_SCMI_POWER_DOMAIN) += pwdom.o
obj-$(CONFIG_SANDBOX) += sandbox-scmi_agent.o sandbox-scmi_devices.o
diff --git a/drivers/firmware/scmi/pwdom.c b/drivers/firmware/scmi/pwdom.c
new file mode 100644
index 00000000000..de2ba4755ac
--- /dev/null
+++ b/drivers/firmware/scmi/pwdom.c
@@ -0,0 +1,188 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * SCMI Power domain management protocol
+ *
+ * Copyright (C) 2023 Linaro Limited
+ * author: AKASHI Takahiro <takahiro.akashi@linaro.org>
+ */
+
+#include <dm.h>
+#include <malloc.h>
+#include <scmi_agent.h>
+#include <scmi_protocols.h>
+#include <string.h>
+#include <asm/types.h>
+
+int scmi_pwd_protocol_attrs(struct udevice *dev, int *num_pwdoms,
+ u64 *stats_addr, size_t *stats_len)
+{
+ struct scmi_pwd_protocol_attrs_out out;
+ struct scmi_msg msg = {
+ .protocol_id = SCMI_PROTOCOL_ID_POWER_DOMAIN,
+ .message_id = SCMI_PROTOCOL_ATTRIBUTES,
+ .out_msg = (u8 *)&out,
+ .out_msg_sz = sizeof(out),
+ };
+ int ret;
+
+ if (!dev || !num_pwdoms || !stats_addr || !stats_len)
+ return -EINVAL;
+
+ ret = devm_scmi_process_msg(dev, &msg);
+ if (ret)
+ return ret;
+ if (out.status)
+ return scmi_to_linux_errno(out.status);
+
+ *num_pwdoms = SCMI_PWD_PROTO_ATTRS_NUM_PWD(out.attributes);
+ *stats_addr = ((u64)out.stats_addr_high << 32) + out.stats_addr_low;
+ *stats_len = out.stats_len;
+
+ return 0;
+}
+
+int scmi_pwd_protocol_message_attrs(struct udevice *dev, s32 message_id,
+ u32 *attributes)
+{
+ struct scmi_pwd_protocol_msg_attrs_out out;
+ struct scmi_msg msg = {
+ .protocol_id = SCMI_PROTOCOL_ID_POWER_DOMAIN,
+ .message_id = SCMI_PROTOCOL_MESSAGE_ATTRIBUTES,
+ .in_msg = (u8 *)&message_id,
+ .in_msg_sz = sizeof(message_id),
+ .out_msg = (u8 *)&out,
+ .out_msg_sz = sizeof(out),
+ };
+ int ret;
+
+ if (!dev || !attributes)
+ return -EINVAL;
+
+ ret = devm_scmi_process_msg(dev, &msg);
+ if (ret)
+ return ret;
+ if (out.status)
+ return scmi_to_linux_errno(out.status);
+
+ *attributes = out.attributes;
+
+ return 0;
+}
+
+int scmi_pwd_attrs(struct udevice *dev, u32 domain_id, u32 *attributes,
+ u8 **name)
+{
+ struct scmi_pwd_attrs_out out;
+ struct scmi_msg msg = {
+ .protocol_id = SCMI_PROTOCOL_ID_POWER_DOMAIN,
+ .message_id = SCMI_PWD_ATTRIBUTES,
+ .in_msg = (u8 *)&domain_id,
+ .in_msg_sz = sizeof(domain_id),
+ .out_msg = (u8 *)&out,
+ .out_msg_sz = sizeof(out),
+ };
+ int ret;
+
+ if (!dev || !attributes || !name)
+ return -EINVAL;
+
+ ret = devm_scmi_process_msg(dev, &msg);
+ if (ret)
+ return ret;
+ if (out.status)
+ return scmi_to_linux_errno(out.status);
+
+ *name = strdup(out.name);
+ if (!*name)
+ return -ENOMEM;
+
+ *attributes = out.attributes;
+
+ return 0;
+}
+
+int scmi_pwd_state_set(struct udevice *dev, u32 flags, u32 domain_id,
+ u32 pstate)
+{
+ struct scmi_pwd_state_set_in in;
+ s32 status;
+ struct scmi_msg msg = {
+ .protocol_id = SCMI_PROTOCOL_ID_POWER_DOMAIN,
+ .message_id = SCMI_PWD_STATE_SET,
+ .in_msg = (u8 *)&in,
+ .in_msg_sz = sizeof(in),
+ .out_msg = (u8 *)&status,
+ .out_msg_sz = sizeof(status),
+ };
+ int ret;
+
+ if (!dev)
+ return -EINVAL;
+
+ in.flags = flags;
+ in.domain_id = domain_id;
+ in.pstate = pstate;
+ ret = devm_scmi_process_msg(dev, &msg);
+ if (ret)
+ return ret;
+ if (status)
+ return scmi_to_linux_errno(status);
+
+ return 0;
+}
+
+int scmi_pwd_state_get(struct udevice *dev, u32 domain_id, u32 *pstate)
+{
+ struct scmi_pwd_state_get_out out;
+ struct scmi_msg msg = {
+ .protocol_id = SCMI_PROTOCOL_ID_POWER_DOMAIN,
+ .message_id = SCMI_PWD_STATE_GET,
+ .in_msg = (u8 *)&domain_id,
+ .in_msg_sz = sizeof(domain_id),
+ .out_msg = (u8 *)&out,
+ .out_msg_sz = sizeof(out),
+ };
+ int ret;
+
+ if (!dev || !pstate)
+ return -EINVAL;
+
+ ret = devm_scmi_process_msg(dev, &msg);
+ if (ret)
+ return ret;
+ if (out.status)
+ return scmi_to_linux_errno(out.status);
+
+ *pstate = out.pstate;
+
+ return 0;
+}
+
+int scmi_pwd_name_get(struct udevice *dev, u32 domain_id, u8 **name)
+{
+ struct scmi_pwd_name_get_out out;
+ struct scmi_msg msg = {
+ .protocol_id = SCMI_PROTOCOL_ID_POWER_DOMAIN,
+ .message_id = SCMI_PWD_NAME_GET,
+ .in_msg = (u8 *)&domain_id,
+ .in_msg_sz = sizeof(domain_id),
+ .out_msg = (u8 *)&out,
+ .out_msg_sz = sizeof(out),
+ };
+ int ret;
+
+ if (!dev || !name)
+ return -EINVAL;
+
+ ret = devm_scmi_process_msg(dev, &msg);
+ if (ret)
+ return ret;
+ if (out.status)
+ return scmi_to_linux_errno(out.status);
+
+ *name = strdup(out.extended_name);
+ if (!*name)
+ return -ENOMEM;
+
+ return 0;
+}
diff --git a/drivers/firmware/scmi/sandbox-scmi_agent.c b/drivers/firmware/scmi/sandbox-scmi_agent.c
index eb567dd900d..9f5f497e0a6 100644
--- a/drivers/firmware/scmi/sandbox-scmi_agent.c
+++ b/drivers/firmware/scmi/sandbox-scmi_agent.c
@@ -43,6 +43,8 @@
#define SANDBOX_SCMI_AGENT_NAME "OSPM"
#define SANDBOX_SCMI_PLATFORM_NAME "platform"
+#define SANDBOX_SCMI_PWD_PROTOCOL_VERSION SCMI_PWD_PROTOCOL_VERSION
+
/**
* struct sandbox_channel - Description of sandbox transport
* @channel_id: Channel identifier
@@ -64,6 +66,7 @@ struct scmi_channel {
};
static u8 protocols[] = {
+ SCMI_PROTOCOL_ID_POWER_DOMAIN,
SCMI_PROTOCOL_ID_CLOCK,
SCMI_PROTOCOL_ID_RESET_DOMAIN,
SCMI_PROTOCOL_ID_VOLTAGE_DOMAIN,
@@ -71,6 +74,12 @@ static u8 protocols[] = {
#define NUM_PROTOCOLS ARRAY_SIZE(protocols)
+static struct sandbox_scmi_pwd scmi_pwdom[] = {
+ { .id = 0 },
+ { .id = 1 },
+ { .id = 2 },
+};
+
static struct sandbox_scmi_clk scmi_clk[] = {
{ .rate = 333 },
{ .rate = 200 },
@@ -458,6 +467,238 @@ static int sandbox_scmi_base_reset_agent_configuration(struct udevice *dev,
return 0;
}
+/* Power Domain Management Protocol */
+
+/**
+ * sandbox_scmi_pwd_protocol_version - implement SCMI_PROTOCOL_VERSION
+ * @dev: SCMI device
+ * @msg: SCMI message
+ *
+ * Implement SCMI_PROTOCOL_VERSION command.
+ *
+ * Return: 0 on success, error code on failure
+ */
+static int sandbox_scmi_pwd_protocol_version(struct udevice *dev,
+ struct scmi_msg *msg)
+{
+ struct scmi_protocol_version_out *out = NULL;
+
+ if (!msg->out_msg || msg->out_msg_sz < sizeof(*out))
+ return -EINVAL;
+
+ out = (struct scmi_protocol_version_out *)msg->out_msg;
+ out->version = SANDBOX_SCMI_PWD_PROTOCOL_VERSION;
+ out->status = SCMI_SUCCESS;
+
+ return 0;
+}
+
+/**
+ * sandbox_scmi_pwd_protocol_attribs - implement SCMI_PWD_PROTOCOL_ATTRS
+ * @dev: SCMI device
+ * @msg: SCMI message
+ *
+ * Implement SCMI_PWD_PROTOCOL_ATTRS command.
+ *
+ * Return: 0 on success, error code on failure
+ */
+static int sandbox_scmi_pwd_protocol_attribs(struct udevice *dev,
+ struct scmi_msg *msg)
+{
+ struct scmi_pwd_protocol_attrs_out *out;
+
+ if (!msg->out_msg || msg->out_msg_sz < sizeof(*out))
+ return -EINVAL;
+
+ out = (struct scmi_pwd_protocol_attrs_out *)msg->out_msg;
+
+ out->attributes = ARRAY_SIZE(scmi_pwdom);
+ out->stats_addr_low = 0;
+ out->stats_addr_high = 0;
+ out->stats_len = 0;
+ out->status = SCMI_SUCCESS;
+
+ return 0;
+}
+
+/**
+ * sandbox_scmi_pwd_protocol_msg_attribs - implement
+ SCMI_PWD_PROTOCOL_MESSAGE_ATTRS
+ * @dev: SCMI device
+ * @msg: SCMI message
+ *
+ * Implement SCMI_PWD_PROTOCOL_MESSAGE_ATTRS command.
+ *
+ * Return: 0 on success, error code on failure
+ */
+static int sandbox_scmi_pwd_protocol_msg_attribs(struct udevice *dev,
+ struct scmi_msg *msg)
+{
+ u32 message_id;
+ struct scmi_pwd_protocol_msg_attrs_out *out;
+
+ if (!msg->in_msg || msg->in_msg_sz < sizeof(message_id) ||
+ !msg->out_msg || msg->out_msg_sz < sizeof(*out))
+ return -EINVAL;
+
+ message_id = *(u32 *)msg->in_msg;
+
+ out = (struct scmi_pwd_protocol_msg_attrs_out *)msg->out_msg;
+ if (message_id <= SCMI_PWD_STATE_GET ||
+ message_id == SCMI_PWD_NAME_GET) {
+ out->attributes = 0;
+ out->status = SCMI_SUCCESS;
+ } else {
+ out->status = SCMI_NOT_FOUND;
+ }
+
+ return 0;
+}
+
+/**
+ * sandbox_scmi_pwd_attribs - implement SCMI_PWD_ATTRS
+ * @dev: SCMI device
+ * @msg: SCMI message
+ *
+ * Implement SCMI_PWD_ATTRS command.
+ *
+ * Return: 0 on success, error code on failure
+ */
+static int sandbox_scmi_pwd_attribs(struct udevice *dev, struct scmi_msg *msg)
+{
+ u32 domain_id;
+ struct scmi_pwd_attrs_out *out;
+
+ if (!msg->in_msg || msg->in_msg_sz < sizeof(domain_id) ||
+ !msg->out_msg || msg->out_msg_sz < sizeof(*out))
+ return -EINVAL;
+
+ domain_id = *(u32 *)msg->in_msg;
+ out = (struct scmi_pwd_attrs_out *)msg->out_msg;
+
+ if (domain_id > ARRAY_SIZE(scmi_pwdom)) {
+ out->status = SCMI_NOT_FOUND;
+
+ return 0;
+ }
+
+ out->attributes =
+ SCMI_PWD_ATTR_PSTATE_SYNC | SCMI_PWD_ATTR_EXTENDED_NAME;
+ /* just 15-char + NULL */
+ snprintf(out->name, SCMI_PWD_NAME_LENGTH_MAX, "power-domain--%d",
+ domain_id);
+ out->status = SCMI_SUCCESS;
+
+ return 0;
+}
+
+/**
+ * sandbox_scmi_pwd_state_set - implement SCMI_PWD_STATE_SET
+ * @dev: SCMI device
+ * @msg: SCMI message
+ *
+ * Implement SCMI_PWD_STATE_SET command.
+ *
+ * Return: 0 on success, error code on failure
+ */
+static int sandbox_scmi_pwd_state_set(struct udevice *dev, struct scmi_msg *msg)
+{
+ struct scmi_pwd_state_set_in *in;
+ s32 *status;
+
+ if (!msg->in_msg || msg->in_msg_sz < sizeof(in) ||
+ !msg->out_msg || msg->out_msg_sz < sizeof(*status))
+ return -EINVAL;
+
+ in = (struct scmi_pwd_state_set_in *)msg->in_msg;
+ status = (s32 *)msg->out_msg;
+
+ if (in->domain_id > ARRAY_SIZE(scmi_pwdom)) {
+ *status = SCMI_NOT_FOUND;
+
+ return 0;
+ }
+
+ if ((in->flags & SCMI_PWD_SET_FLAGS_ASYNC) ||
+ (in->pstate != SCMI_PWD_PSTATE_TYPE_LOST && in->pstate)) {
+ *status = SCMI_INVALID_PARAMETERS;
+
+ return 0;
+ }
+
+ scmi_pwdom[in->domain_id].pstate = in->pstate;
+ *status = SCMI_SUCCESS;
+
+ return 0;
+}
+
+/**
+ * sandbox_scmi_pwd_state_get - implement SCMI_PWD_STATE_GET
+ * @dev: SCMI device
+ * @msg: SCMI message
+ *
+ * Implement SCMI_PWD_STATE_GET command.
+ *
+ * Return: 0 on success, error code on failure
+ */
+static int sandbox_scmi_pwd_state_get(struct udevice *dev, struct scmi_msg *msg)
+{
+ u32 domain_id;
+ struct scmi_pwd_state_get_out *out;
+
+ if (!msg->in_msg || msg->in_msg_sz < sizeof(domain_id) ||
+ !msg->out_msg || msg->out_msg_sz < sizeof(*out))
+ return -EINVAL;
+
+ domain_id = *(u32 *)msg->in_msg;
+ out = (struct scmi_pwd_state_get_out *)msg->out_msg;
+
+ if (domain_id > ARRAY_SIZE(scmi_pwdom)) {
+ out->status = SCMI_NOT_FOUND;
+
+ return 0;
+ }
+
+ out->pstate = scmi_pwdom[domain_id].pstate;
+ out->status = SCMI_SUCCESS;
+
+ return 0;
+}
+
+/**
+ * sandbox_scmi_pwd_name_get - implement SCMI_PWD_NAME_GET
+ * @dev: SCMI device
+ * @msg: SCMI message
+ *
+ * Implement SCMI_PWD_NAME_GET command.
+ *
+ * Return: 0 on success, error code on failure
+ */
+static int sandbox_scmi_pwd_name_get(struct udevice *dev, struct scmi_msg *msg)
+{
+ u32 domain_id;
+ struct scmi_pwd_name_get_out *out;
+
+ if (!msg->in_msg || msg->in_msg_sz < sizeof(domain_id) ||
+ !msg->out_msg || msg->out_msg_sz < sizeof(*out))
+ return -EINVAL;
+
+ domain_id = *(u32 *)msg->in_msg;
+ out = (struct scmi_pwd_name_get_out *)msg->out_msg;
+
+ if (domain_id > ARRAY_SIZE(scmi_pwdom)) {
+ out->status = SCMI_NOT_FOUND;
+
+ return 0;
+ }
+
+ snprintf(out->extended_name, SCMI_PWD_EXTENDED_NAME_MAX,
+ "power-domain--%d-extended", domain_id);
+ out->status = SCMI_SUCCESS;
+
+ return 0;
+}
+
/* Clock Protocol */
static int sandbox_scmi_clock_protocol_attribs(struct udevice *dev,
@@ -918,6 +1159,26 @@ static int sandbox_scmi_test_process_msg(struct udevice *dev,
break;
}
break;
+ case SCMI_PROTOCOL_ID_POWER_DOMAIN:
+ switch (msg->message_id) {
+ case SCMI_PROTOCOL_VERSION:
+ return sandbox_scmi_pwd_protocol_version(dev, msg);
+ case SCMI_PROTOCOL_ATTRIBUTES:
+ return sandbox_scmi_pwd_protocol_attribs(dev, msg);
+ case SCMI_PROTOCOL_MESSAGE_ATTRIBUTES:
+ return sandbox_scmi_pwd_protocol_msg_attribs(dev, msg);
+ case SCMI_PWD_ATTRIBUTES:
+ return sandbox_scmi_pwd_attribs(dev, msg);
+ case SCMI_PWD_STATE_SET:
+ return sandbox_scmi_pwd_state_set(dev, msg);
+ case SCMI_PWD_STATE_GET:
+ return sandbox_scmi_pwd_state_get(dev, msg);
+ case SCMI_PWD_NAME_GET:
+ return sandbox_scmi_pwd_name_get(dev, msg);
+ default:
+ break;
+ }
+ break;
case SCMI_PROTOCOL_ID_CLOCK:
switch (msg->message_id) {
case SCMI_PROTOCOL_ATTRIBUTES:
@@ -960,7 +1221,6 @@ static int sandbox_scmi_test_process_msg(struct udevice *dev,
break;
}
break;
- case SCMI_PROTOCOL_ID_POWER_DOMAIN:
case SCMI_PROTOCOL_ID_SYSTEM:
case SCMI_PROTOCOL_ID_PERF:
case SCMI_PROTOCOL_ID_SENSOR:
@@ -993,6 +1253,9 @@ static int sandbox_scmi_test_probe(struct udevice *dev)
struct sandbox_scmi_agent *agent = dev_get_priv(dev);
*agent = (struct sandbox_scmi_agent){
+ .pwdom_version = SANDBOX_SCMI_PWD_PROTOCOL_VERSION,
+ .pwdom = scmi_pwdom,
+ .pwdom_count = ARRAY_SIZE(scmi_pwdom),
.clk = scmi_clk,
.clk_count = ARRAY_SIZE(scmi_clk),
.reset = scmi_reset,
diff --git a/drivers/firmware/scmi/sandbox-scmi_devices.c b/drivers/firmware/scmi/sandbox-scmi_devices.c
index 9baeb469ec0..facb5b06ffb 100644
--- a/drivers/firmware/scmi/sandbox-scmi_devices.c
+++ b/drivers/firmware/scmi/sandbox-scmi_devices.c
@@ -29,12 +29,14 @@
/*
* struct sandbox_scmi_device_priv - Storage for device handles used by test
+ * @pwdom: Power domain device
* @clk: Array of clock instances used by tests
* @reset_clt: Array of the reset controller instances used by tests
* @regulators: Array of regulator device references used by the tests
* @devices: Resources exposed by sandbox_scmi_devices_ctx()
*/
struct sandbox_scmi_device_priv {
+ struct power_domain pwdom;
struct clk clk[SCMI_TEST_DEVICES_CLK_COUNT];
struct reset_ctl reset_ctl[SCMI_TEST_DEVICES_RD_COUNT];
struct udevice *regulators[SCMI_TEST_DEVICES_VOLTD_COUNT];
@@ -77,6 +79,8 @@ static int sandbox_scmi_devices_probe(struct udevice *dev)
size_t n;
priv->devices = (struct sandbox_scmi_devices){
+ .pwdom = &priv->pwdom,
+ .pwdom_count = 1,
.clk = priv->clk,
.clk_count = SCMI_TEST_DEVICES_CLK_COUNT,
.reset = priv->reset_ctl,
@@ -85,6 +89,12 @@ static int sandbox_scmi_devices_probe(struct udevice *dev)
.regul_count = SCMI_TEST_DEVICES_VOLTD_COUNT,
};
+ ret = power_domain_get_by_index(dev, priv->devices.pwdom, 0);
+ if (ret) {
+ dev_err(dev, "%s: Failed on power domain\n", __func__);
+ return ret;
+ }
+
for (n = 0; n < SCMI_TEST_DEVICES_CLK_COUNT; n++) {
ret = clk_get_by_index(dev, n, priv->devices.clk + n);
if (ret) {
diff --git a/drivers/firmware/scmi/scmi_agent-uclass.c b/drivers/firmware/scmi/scmi_agent-uclass.c
index 6f585b96f74..0f1003e167e 100644
--- a/drivers/firmware/scmi/scmi_agent-uclass.c
+++ b/drivers/firmware/scmi/scmi_agent-uclass.c
@@ -86,6 +86,9 @@ struct udevice *scmi_get_protocol(struct udevice *dev,
case SCMI_PROTOCOL_ID_BASE:
proto = priv->base_dev;
break;
+ case SCMI_PROTOCOL_ID_POWER_DOMAIN:
+ proto = priv->pwdom_dev;
+ break;
case SCMI_PROTOCOL_ID_CLOCK:
proto = priv->clock_dev;
break;
@@ -133,6 +136,9 @@ static int scmi_add_protocol(struct udevice *dev,
case SCMI_PROTOCOL_ID_BASE:
priv->base_dev = proto;
break;
+ case SCMI_PROTOCOL_ID_POWER_DOMAIN:
+ priv->pwdom_dev = proto;
+ break;
case SCMI_PROTOCOL_ID_CLOCK:
priv->clock_dev = proto;
break;
@@ -405,6 +411,11 @@ static int scmi_bind_protocols(struct udevice *dev)
drv = NULL;
name = ofnode_get_name(node);
switch (protocol_id) {
+ case SCMI_PROTOCOL_ID_POWER_DOMAIN:
+ if (CONFIG_IS_ENABLED(SCMI_POWER_DOMAIN) &&
+ scmi_protocol_is_supported(dev, protocol_id))
+ drv = DM_DRIVER_GET(scmi_power_domain);
+ break;
case SCMI_PROTOCOL_ID_CLOCK:
if (CONFIG_IS_ENABLED(CLK_SCMI) &&
scmi_protocol_is_supported(dev, protocol_id))
diff --git a/drivers/power/domain/Kconfig b/drivers/power/domain/Kconfig
index 411c210756a..bd82d2f7044 100644
--- a/drivers/power/domain/Kconfig
+++ b/drivers/power/domain/Kconfig
@@ -83,6 +83,13 @@ config SANDBOX_POWER_DOMAIN
simply accepts requests to power on/off various HW modules without
actually doing anything beyond a little error checking.
+config SCMI_POWER_DOMAIN
+ bool "Enable SCMI power domain driver"
+ depends on POWER_DOMAIN && SCMI_FIRMWARE
+ help
+ Enable power domain implementation based on SCMI power domain
+ management protocol.
+
config TEGRA186_POWER_DOMAIN
bool "Enable Tegra186 BPMP-based power domain driver"
depends on TEGRA186_BPMP
diff --git a/drivers/power/domain/Makefile b/drivers/power/domain/Makefile
index aa5a4ba57cd..2daab73eb75 100644
--- a/drivers/power/domain/Makefile
+++ b/drivers/power/domain/Makefile
@@ -15,6 +15,7 @@ obj-$(CONFIG_MESON_EE_POWER_DOMAIN) += meson-ee-pwrc.o
obj-$(CONFIG_MESON_SECURE_POWER_DOMAIN) += meson-secure-pwrc.o
obj-$(CONFIG_SANDBOX_POWER_DOMAIN) += sandbox-power-domain.o
obj-$(CONFIG_SANDBOX_POWER_DOMAIN) += sandbox-power-domain-test.o
+obj-$(CONFIG_SCMI_POWER_DOMAIN) += scmi-power-domain.o
obj-$(CONFIG_TEGRA186_POWER_DOMAIN) += tegra186-power-domain.o
obj-$(CONFIG_TI_SCI_POWER_DOMAIN) += ti-sci-power-domain.o
obj-$(CONFIG_TI_POWER_DOMAIN) += ti-power-domain.o
diff --git a/drivers/power/domain/scmi-power-domain.c b/drivers/power/domain/scmi-power-domain.c
new file mode 100644
index 00000000000..3cd0f075d95
--- /dev/null
+++ b/drivers/power/domain/scmi-power-domain.c
@@ -0,0 +1,192 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * SCMI Power domain driver
+ *
+ * Copyright (C) 2023 Linaro Limited
+ * author: AKASHI Takahiro <takahiro.akashi@linaro.org>
+ */
+
+#include <dm.h>
+#include <malloc.h>
+#include <power-domain.h>
+#include <power-domain-uclass.h>
+#include <scmi_agent.h>
+#include <scmi_protocols.h>
+#include <dm/device_compat.h>
+
+/**
+ * struct scmi_pwd_properties
+ * @attributes: Power domain attributes
+ * @name: Name of the domain
+ */
+struct scmi_pwd_properties {
+ u32 attributes;
+ u8 *name; /* not used now */
+};
+
+/**
+ * struct scmi_power_domain_priv
+ * @num_pwdoms: Number of power domains
+ * @prop: Pointer to domain's properties
+ * @stats_addr: Address of statistics memory region
+ * @stats_len: Length of statistics memory region
+ */
+struct scmi_power_domain_priv {
+ int num_pwdoms;
+ struct scmi_pwd_properties *prop;
+ u64 stats_addr;
+ size_t stats_len;
+};
+
+/**
+ * async_is_supported - check asynchronous transition
+ * @attributes: Power domain attributes
+ *
+ * Determine if the power transition can be done asynchronously.
+ *
+ * Return: true if supported, false if not
+ */
+static bool async_is_supported(u32 attributes)
+{
+ if (attributes & SCMI_PWD_ATTR_PSTATE_ASYNC)
+ return true;
+
+ /* TODO: check attributes && SCMI_PWD_ATTR_PSTATE_SYNC */
+ return false;
+}
+
+/**
+ * scmi_power_domain_on - Enable the power domain
+ * @power_domain: Power domain
+ *
+ * Turn on the power domain.
+ *
+ * Return: 0 on success, error code on failure
+ */
+static int scmi_power_domain_on(struct power_domain *power_domain)
+{
+ struct scmi_power_domain_priv *priv = dev_get_priv(power_domain->dev);
+ u32 flags, pstate;
+ int ret;
+
+ if (power_domain->id > priv->num_pwdoms)
+ return -EINVAL;
+
+ if (async_is_supported(priv->prop[power_domain->id].attributes))
+ flags = SCMI_PWD_SET_FLAGS_ASYNC;
+ else
+ flags = 0;
+
+ /* ON */
+ pstate = 0;
+
+ ret = scmi_pwd_state_set(power_domain->dev, flags, power_domain->id,
+ pstate);
+ if (ret) {
+ dev_err(power_domain->dev, "failed to set the state on (%d)\n",
+ ret);
+ return ret;
+ }
+
+ return 0;
+}
+
+/**
+ * scmi_power_domain_off - Disable the power domain
+ * @power_domain: Power domain
+ *
+ * Turn off the power domain.
+ *
+ * Return: 0 on success, error code on failure
+ */
+static int scmi_power_domain_off(struct power_domain *power_domain)
+{
+ struct scmi_power_domain_priv *priv = dev_get_priv(power_domain->dev);
+ u32 flags, pstate;
+ int ret;
+
+ if (power_domain->id > priv->num_pwdoms)
+ return -EINVAL;
+
+ if (async_is_supported(priv->prop[power_domain->id].attributes))
+ flags = SCMI_PWD_SET_FLAGS_ASYNC;
+ else
+ flags = 0;
+
+ /* OFF */
+ pstate = SCMI_PWD_PSTATE_TYPE_LOST;
+
+ ret = scmi_pwd_state_set(power_domain->dev, flags, power_domain->id,
+ pstate);
+ if (ret) {
+ dev_err(power_domain->dev, "failed to set the state off (%d)\n",
+ ret);
+ return ret;
+ }
+
+ return 0;
+}
+
+/**
+ * scmi_power_domain_probe - Probe the power domain
+ * @dev: Power domain device
+ *
+ * Probe the power domain and initialize the properties.
+ *
+ * Return: 0 on success, error code on failure
+ */
+static int scmi_power_domain_probe(struct udevice *dev)
+{
+ struct scmi_power_domain_priv *priv = dev_get_priv(dev);
+ u32 version;
+ int i, ret;
+
+ ret = devm_scmi_of_get_channel(dev);
+ if (ret) {
+ dev_err(dev, "failed to get channel (%d)\n", ret);
+ return ret;
+ }
+
+ ret = scmi_generic_protocol_version(dev, SCMI_PROTOCOL_ID_POWER_DOMAIN,
+ &version);
+
+ ret = scmi_pwd_protocol_attrs(dev, &priv->num_pwdoms, &priv->stats_addr,
+ &priv->stats_len);
+ if (ret) {
+ dev_err(dev, "failed to get protocol attributes (%d)\n", ret);
+ return ret;
+ }
+
+ priv->prop = calloc(sizeof(*priv->prop), priv->num_pwdoms);
+ if (!priv->prop)
+ return -ENOMEM;
+
+ for (i = 0; i < priv->num_pwdoms; i++) {
+ ret = scmi_pwd_attrs(dev, i, &priv->prop[i].attributes,
+ &priv->prop[i].name);
+ if (ret) {
+ dev_err(dev, "failed to get attributes pwd:%d (%d)\n",
+ i, ret);
+ for (i--; i >= 0; i--)
+ free(priv->prop[i].name);
+ free(priv->prop);
+
+ return ret;
+ }
+ }
+
+ return 0;
+}
+
+struct power_domain_ops scmi_power_domain_ops = {
+ .on = scmi_power_domain_on,
+ .off = scmi_power_domain_off,
+};
+
+U_BOOT_DRIVER(scmi_power_domain) = {
+ .name = "scmi_power_domain",
+ .id = UCLASS_POWER_DOMAIN,
+ .ops = &scmi_power_domain_ops,
+ .probe = scmi_power_domain_probe,
+ .priv_auto = sizeof(struct scmi_power_domain_priv),
+};
diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c
index 4a2da7a3317..df6a387284a 100644
--- a/drivers/serial/serial-uclass.c
+++ b/drivers/serial/serial-uclass.c
@@ -182,6 +182,16 @@ int serial_initialize(void)
return serial_init();
}
+static void _serial_flush(struct udevice *dev)
+{
+ struct dm_serial_ops *ops = serial_get_ops(dev);
+
+ if (!ops->pending)
+ return;
+ while (ops->pending(dev, false) > 0)
+ ;
+}
+
static void _serial_putc(struct udevice *dev, char ch)
{
struct dm_serial_ops *ops = serial_get_ops(dev);
@@ -193,6 +203,9 @@ static void _serial_putc(struct udevice *dev, char ch)
do {
err = ops->putc(dev, ch);
} while (err == -EAGAIN);
+
+ if (IS_ENABLED(CONFIG_CONSOLE_FLUSH_ON_NEWLINE) && ch == '\n')
+ _serial_flush(dev);
}
static int __serial_puts(struct udevice *dev, const char *str, size_t len)
@@ -231,22 +244,13 @@ static void _serial_puts(struct udevice *dev, const char *str)
if (*newline && __serial_puts(dev, "\r\n", 2))
return;
+ if (IS_ENABLED(CONFIG_CONSOLE_FLUSH_ON_NEWLINE) && *newline)
+ _serial_flush(dev);
+
str += len + !!*newline;
} while (*str);
}
-#ifdef CONFIG_CONSOLE_FLUSH_SUPPORT
-static void _serial_flush(struct udevice *dev)
-{
- struct dm_serial_ops *ops = serial_get_ops(dev);
-
- if (!ops->pending)
- return;
- while (ops->pending(dev, false) > 0)
- ;
-}
-#endif
-
static int __serial_getc(struct udevice *dev)
{
struct dm_serial_ops *ops = serial_get_ops(dev);
diff --git a/include/bootstage.h b/include/bootstage.h
index f9376c320c9..affb0e5c6a6 100644
--- a/include/bootstage.h
+++ b/include/bootstage.h
@@ -11,6 +11,7 @@
#ifndef _BOOTSTAGE_H
#define _BOOTSTAGE_H
+#include <linux/types.h>
#include <linux/kconfig.h>
/* Flags for each bootstage record */
diff --git a/include/cache.h b/include/cache.h
index b12fec25915..296ae3c8b48 100644
--- a/include/cache.h
+++ b/include/cache.h
@@ -6,6 +6,8 @@
#ifndef __CACHE_H
#define __CACHE_H
+#include <linux/types.h>
+
struct udevice;
/*
diff --git a/include/cpu.h b/include/cpu.h
index be02a167129..2077ff30634 100644
--- a/include/cpu.h
+++ b/include/cpu.h
@@ -7,6 +7,8 @@
#ifndef __CPU_H
#define __CPU_H
+#include <linux/types.h>
+
struct udevice;
/**
diff --git a/include/scmi_agent-uclass.h b/include/scmi_agent-uclass.h
index 35d96069645..33e0e18c30d 100644
--- a/include/scmi_agent-uclass.h
+++ b/include/scmi_agent-uclass.h
@@ -23,6 +23,7 @@ struct scmi_channel;
* @agent_name: Agent name
* @agent_id: Identifier of agent
* @base_dev: SCMI base protocol device
+ * @pwdom_dev: SCMI power domain management protocol device
* @clock_dev: SCMI clock protocol device
* @resetdom_dev: SCMI reset domain protocol device
* @voltagedom_dev: SCMI voltage domain protocol device
@@ -38,6 +39,7 @@ struct scmi_agent_priv {
u8 *agent_name;
u32 agent_id;
struct udevice *base_dev;
+ struct udevice *pwdom_dev;
struct udevice *clock_dev;
struct udevice *resetdom_dev;
struct udevice *voltagedom_dev;
diff --git a/include/scmi_protocols.h b/include/scmi_protocols.h
index 163647a57b9..7abb2a6f36b 100644
--- a/include/scmi_protocols.h
+++ b/include/scmi_protocols.h
@@ -545,6 +545,184 @@ int scmi_base_reset_agent_configuration(struct udevice *dev, u32 agent_id,
u32 flags);
/*
+ * SCMI Power Domain Management Protocol
+ */
+
+#define SCMI_PWD_PROTOCOL_VERSION 0x30000
+#define SCMI_PWD_PSTATE_TYPE_LOST BIT(30)
+#define SCMI_PWD_PSTATE_ID GENMASK(27, 0)
+
+enum scmi_power_domain_message_id {
+ SCMI_PWD_ATTRIBUTES = 0x3,
+ SCMI_PWD_STATE_SET = 0x4,
+ SCMI_PWD_STATE_GET = 0x5,
+ SCMI_PWD_STATE_NOTIFY = 0x6,
+ SCMI_PWD_STATE_CHANGE_REQUESTED_NOTIFY = 0x7,
+ SCMI_PWD_NAME_GET = 0x8,
+};
+
+/**
+ * struct scmi_pwd_protocol_attrs_out
+ * @status: SCMI command status
+ * @attributes: Protocol attributes
+ * @stats_addr_low: Lower 32 bits of address of statistics memory region
+ * @stats_addr_high: Higher 32 bits of address of statistics memory region
+ * @stats_len: Length of statistics memory region
+ */
+struct scmi_pwd_protocol_attrs_out {
+ s32 status;
+ u32 attributes;
+ u32 stats_addr_low;
+ u32 stats_addr_high;
+ u32 stats_len;
+};
+
+#define SCMI_PWD_PROTO_ATTRS_NUM_PWD(attributes) ((attributes) & GENMASK(15, 0))
+
+/**
+ * struct scmi_pwd_protocol_msg_attrs_out
+ * @status: SCMI command status
+ * @attributes: Message-specific attributes
+ */
+struct scmi_pwd_protocol_msg_attrs_out {
+ s32 status;
+ u32 attributes;
+};
+
+#define SCMI_PWD_NAME_LENGTH_MAX 16
+
+/**
+ * struct scmi_pwd_attrs_out
+ * @status: SCMI command status
+ * @attributes: Power domain attributes
+ * @name: Name of power domain
+ */
+struct scmi_pwd_attrs_out {
+ s32 status;
+ u32 attributes;
+ u8 name[SCMI_PWD_NAME_LENGTH_MAX];
+};
+
+#define SCMI_PWD_ATTR_PSTATE_CHANGE_NOTIFY BIT(31)
+#define SCMI_PWD_ATTR_PSTATE_ASYNC BIT(30)
+#define SCMI_PWD_ATTR_PSTATE_SYNC BIT(29)
+#define SCMI_PWD_ATTR_PSTATE_CHANGE_RQ_NOTIFY BIT(28)
+#define SCMI_PWD_ATTR_EXTENDED_NAME BIT(27)
+
+/**
+ * struct scmi_pwd_state_set_in
+ * @flags: Flags
+ * @domain_id: Identifier of power domain
+ * @pstate: Power state of the domain
+ */
+struct scmi_pwd_state_set_in {
+ u32 flags;
+ u32 domain_id;
+ u32 pstate;
+};
+
+#define SCMI_PWD_SET_FLAGS_ASYNC BIT(0)
+
+/**
+ * struct scmi_pwd_state_get_out
+ * @status: SCMI command status
+ * @pstate: Power state of the domain
+ */
+struct scmi_pwd_state_get_out {
+ s32 status;
+ u32 pstate;
+};
+
+#define SCMI_PWD_EXTENDED_NAME_MAX 64
+/**
+ * struct scmi_pwd_name_get_out
+ * @status: SCMI command status
+ * @flags: Parameter flags
+ * @extended_name: Extended name of power domain
+ */
+struct scmi_pwd_name_get_out {
+ s32 status;
+ u32 flags;
+ u8 extended_name[SCMI_PWD_EXTENDED_NAME_MAX];
+};
+
+/**
+ * scmi_pwd_protocol_attrs - get protocol attributes
+ * @dev: SCMI protocol device
+ * @num_pwdoms: Number of power domains
+ * @stats_addr: Address of statistics memory region
+ * @stats_len: Length of statistics memory region
+ *
+ * Obtain the protocol attributes, the number of power domains and
+ * the information of statistics memory region.
+ *
+ * Return: 0 on success, error code on failure
+ */
+int scmi_pwd_protocol_attrs(struct udevice *dev, int *num_pwdoms,
+ u64 *stats_addr, size_t *stats_len);
+/**
+ * scmi_pwd_protocol_message_attrs - get message-specific attributes
+ * @dev: SCMI protocol device
+ * @message_id: SCMI message ID
+ * @attributes: Message-specific attributes
+ *
+ * Obtain the message-specific attributes in @attributes.
+ *
+ * Return: 0 on success, error code on failure
+ */
+int scmi_pwd_protocol_message_attrs(struct udevice *dev, s32 message_id,
+ u32 *attributes);
+/**
+ * scmi_pwd_attrs - get power domain attributes
+ * @dev: SCMI protocol device
+ * @domain_id: Identifier of power domain
+ * @attributes: Power domain attributes
+ * @name: Name of power domain
+ *
+ * Obtain the attributes of the given power domain, @domain_id, in @attributes
+ * as well as its name in @name.
+ *
+ * Return: 0 on success, error code on failure
+ */
+int scmi_pwd_attrs(struct udevice *dev, u32 message_id, u32 *attributes,
+ u8 **name);
+/**
+ * scmi_pwd_state_set - set power state
+ * @dev: SCMI protocol device
+ * @flags: Parameter flags
+ * @domain_id: Identifier of power domain
+ * @pstate: Power state
+ *
+ * Change the power state of the given power domain, @domain_id.
+ *
+ * Return: 0 on success, error code on failure
+ */
+int scmi_pwd_state_set(struct udevice *dev, u32 flags, u32 domain_id,
+ u32 pstate);
+/**
+ * scmi_pwd_state_get - get power state
+ * @dev: SCMI protocol device
+ * @domain_id: Identifier of power domain
+ * @pstate: Power state
+ *
+ * Obtain the power state of the given power domain, @domain_id.
+ *
+ * Return: 0 on success, error code on failure
+ */
+int scmi_pwd_state_get(struct udevice *dev, u32 domain_id, u32 *pstate);
+/**
+ * scmi_pwd_name_get - get extended name
+ * @dev: SCMI protocol device
+ * @domain_id: Identifier of power domain
+ * @name: Extended name of the domain
+ *
+ * Obtain the extended name of the given power domain, @domain_id, in @name.
+ *
+ * Return: 0 on success, error code on failure
+ */
+int scmi_pwd_name_get(struct udevice *dev, u32 domain_id, u8 **name);
+
+/*
* SCMI Clock Protocol
*/
diff --git a/include/test/suites.h b/include/test/suites.h
index 1c7dc65966a..51acbe47b2f 100644
--- a/include/test/suites.h
+++ b/include/test/suites.h
@@ -45,6 +45,7 @@ int do_ut_font(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
int do_ut_lib(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
int do_ut_loadm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
int do_ut_log(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[]);
+int do_ut_mbr(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
int do_ut_mem(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
int do_ut_optee(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
int do_ut_overlay(struct cmd_tbl *cmdtp, int flag, int argc,
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 488d73a0ed7..b8eb57f38c7 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2636,12 +2636,18 @@ sub u_boot_line {
"All CONFIG symbols are managed by Kconfig\n" . $herecurr);
}
- # Don't put common.h and dm.h in header files
- if ($realfile =~ /\.h$/ && $rawline =~ /^\+#include\s*<(common|dm)\.h>*/) {
+ # Don't put dm.h in header files
+ if ($realfile =~ /\.h$/ && $rawline =~ /^\+#include\s*<dm\.h>*/) {
ERROR("BARRED_INCLUDE_IN_HDR",
"Avoid including common.h and dm.h in header files\n" . $herecurr);
}
+ # Don't add common.h to files
+ if ($rawline =~ /^\+#include\s*<common\.h>*/) {
+ ERROR("BARRED_INCLUDE_COMMON_H",
+ "Do not add common.h to files\n" . $herecurr);
+ }
+
# Do not disable fdt / initrd relocation
if ($rawline =~ /^\+.*(fdt|initrd)_high=0xffffffff/) {
ERROR("DISABLE_FDT_OR_INITRD_RELOC",
diff --git a/test/cmd/Makefile b/test/cmd/Makefile
index 8d70ac510a5..e296ba1192b 100644
--- a/test/cmd/Makefile
+++ b/test/cmd/Makefile
@@ -24,6 +24,7 @@ obj-$(CONFIG_CMD_PINMUX) += pinmux.o
obj-$(CONFIG_CMD_PWM) += pwm.o
obj-$(CONFIG_CMD_SEAMA) += seama.o
ifdef CONFIG_SANDBOX
+obj-$(CONFIG_CMD_MBR) += mbr.o
obj-$(CONFIG_CMD_READ) += rw.o
obj-$(CONFIG_CMD_SETEXPR) += setexpr.o
obj-$(CONFIG_ARM_FFA_TRANSPORT) += armffa.o
diff --git a/test/cmd/mbr.c b/test/cmd/mbr.c
new file mode 100644
index 00000000000..5d7402154d1
--- /dev/null
+++ b/test/cmd/mbr.c
@@ -0,0 +1,481 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Tests for mbr command
+ *
+ * Copyright 2023 Matrox Video
+ * Written by Alex Gendin <agendin@matrox.com>
+ */
+
+#include <dm.h>
+#include <console.h>
+#include <dm/test.h>
+#include <mapmem.h>
+#include <part.h>
+#include <asm/global_data.h>
+#include <dm/device-internal.h>
+#include <dm/lists.h>
+#include <test/suites.h>
+#include <test/ut.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+/*
+ * Requirements for running test manually:
+ * mmc6.img - File size needs to be at least 12 MiB
+ *
+ * Command to create mmc6.img:
+ * $ dd if=/dev/zero of=mmc6.img bs=12M count=1
+ *
+ * To run this test manually, place mmc6.img into the same directory as u-boot,
+ * then run:
+ * $ ./u-boot -Tc 'ut mbr'
+ *
+ * To run this test as part of U-Boot test:
+ * $ ./test/py/test.py --bd sandbox --build -k ut_dm -v
+ * Note: mmc6.img will be created by the test suit.
+ */
+
+static char * mbr_parts_header = "setenv mbr_parts '";
+static char * mbr_parts_p1 = "uuid_disk=0x12345678;name=p1,start=8M,bootable,size=1M,id=0x0e";
+static char * mbr_parts_p2 = ";name=p2,size=1M,id=0x0e";
+static char * mbr_parts_p3 = ";name=p3,size=1M,id=0x0e";
+static char * mbr_parts_p4 = ";name=p4,size=1M,id=0x0e";
+static char * mbr_parts_p5 = ";name=[ext],size=2M,id=0x05;name=p5,size=1M,id=0x0e";
+static char * mbr_parts_tail = "'";
+
+/*
+ * One MBR partition
+000001b0 00 00 00 00 00 00 00 00 78 56 34 12 00 00 80 05 |........xV4.....|
+000001c0 05 01 0e 25 24 01 00 40 00 00 00 08 00 00 00 00 |...%$..@........|
+000001d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
+000001e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
+000001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa |..............U.|
+*/
+static unsigned mbr_cmp_start = 0x1B8;
+static unsigned mbr_cmp_size = 0x48;
+static unsigned char mbr_parts_ref_p1[] = {
+ 0x78, 0x56, 0x34, 0x12, 0x00, 0x00, 0x80, 0x05,
+0x05, 0x01, 0x0e, 0x25, 0x24, 0x01, 0x00, 0x40, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0xaa
+};
+
+/*
+ * Two MBR partitions
+000001b0 00 00 00 00 00 00 00 00 78 56 34 12 00 00 80 05 |........xV4.....|
+000001c0 05 01 0e 25 24 01 00 40 00 00 00 08 00 00 00 25 |...%$..@.......%|
+000001d0 25 01 0e 46 05 01 00 48 00 00 00 08 00 00 00 00 |%..F...H........|
+000001e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
+000001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa |..............U.|
+*/
+static unsigned char mbr_parts_ref_p2[] = {
+ 0x78, 0x56, 0x34, 0x12, 0x00, 0x00, 0x80, 0x05,
+0x05, 0x01, 0x0e, 0x25, 0x24, 0x01, 0x00, 0x40, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x25,
+0x25, 0x01, 0x0e, 0x46, 0x05, 0x01, 0x00, 0x48, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0xaa
+};
+
+/*
+ * Three MBR partitions
+000001b0 00 00 00 00 00 00 00 00 78 56 34 12 00 00 80 05 |........xV4.....|
+000001c0 05 01 0e 25 24 01 00 40 00 00 00 08 00 00 00 25 |...%$..@.......%|
+000001d0 25 01 0e 46 05 01 00 48 00 00 00 08 00 00 00 46 |%..F...H.......F|
+000001e0 06 01 0e 66 25 01 00 50 00 00 00 08 00 00 00 00 |...f%..P........|
+000001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa |..............U.|
+*/
+static unsigned char mbr_parts_ref_p3[] = {
+ 0x78, 0x56, 0x34, 0x12, 0x00, 0x00, 0x80, 0x05,
+0x05, 0x01, 0x0e, 0x25, 0x24, 0x01, 0x00, 0x40, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x25,
+0x25, 0x01, 0x0e, 0x46, 0x05, 0x01, 0x00, 0x48, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x46,
+0x06, 0x01, 0x0e, 0x66, 0x25, 0x01, 0x00, 0x50, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0xaa
+};
+
+/*
+ * Four MBR partitions
+000001b0 00 00 00 00 00 00 00 00 78 56 34 12 00 00 80 05 |........xV4.....|
+000001c0 05 01 0e 25 24 01 00 40 00 00 00 08 00 00 00 25 |...%$..@.......%|
+000001d0 25 01 0e 46 05 01 00 48 00 00 00 08 00 00 00 46 |%..F...H.......F|
+000001e0 06 01 0e 66 25 01 00 50 00 00 00 08 00 00 00 66 |...f%..P.......f|
+000001f0 26 01 0e 87 06 01 00 58 00 00 00 08 00 00 55 aa |&......X......U.|
+*/
+static unsigned char mbr_parts_ref_p4[] = {
+ 0x78, 0x56, 0x34, 0x12, 0x00, 0x00, 0x80, 0x05,
+0x05, 0x01, 0x0e, 0x25, 0x24, 0x01, 0x00, 0x40, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x25,
+0x25, 0x01, 0x0e, 0x46, 0x05, 0x01, 0x00, 0x48, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x46,
+0x06, 0x01, 0x0e, 0x66, 0x25, 0x01, 0x00, 0x50, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x66,
+0x26, 0x01, 0x0e, 0x87, 0x06, 0x01, 0x00, 0x58, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x55, 0xaa
+};
+
+/*
+ * Five MBR partitions
+000001b0 00 00 00 00 00 00 00 00 78 56 34 12 00 00 80 05 |........xV4.....|
+000001c0 05 01 0e 25 24 01 00 40 00 00 00 08 00 00 00 25 |...%$..@.......%|
+000001d0 25 01 0e 46 05 01 00 48 00 00 00 08 00 00 00 46 |%..F...H.......F|
+000001e0 06 01 0e 66 25 01 00 50 00 00 00 08 00 00 00 66 |...f%..P.......f|
+000001f0 26 01 05 a7 26 01 00 58 00 00 00 10 00 00 55 aa |&...&..X......U.|
+*/
+static unsigned char mbr_parts_ref_p5[] = {
+ 0x78, 0x56, 0x34, 0x12, 0x00, 0x00, 0x80, 0x05,
+0x05, 0x01, 0x0e, 0x25, 0x24, 0x01, 0x00, 0x40, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x25,
+0x25, 0x01, 0x0e, 0x46, 0x05, 0x01, 0x00, 0x48, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x46,
+0x06, 0x01, 0x0e, 0x66, 0x25, 0x01, 0x00, 0x50, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x66,
+0x26, 0x01, 0x05, 0xa7, 0x26, 0x01, 0x00, 0x58, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x55, 0xaa
+};
+static unsigned ebr_cmp_start = 0x1B8;
+static unsigned ebr_cmp_size = 0x48;
+/*
+ * EBR
+00b001b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 87 |................|
+00b001c0 07 01 0e a7 26 01 00 08 00 00 00 08 00 00 00 00 |....&...........|
+00b001d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
+00b001e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
+00b001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa |..............U.|
+*/
+static unsigned char ebr_parts_ref_p5[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x87,
+0x07, 0x01, 0x0e, 0xa7, 0x26, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0xaa
+};
+
+/* Fill write buffers with pseudo-random data */
+static void init_write_buffers(char *mbr_wb, size_t mbr_wb_size,
+ char *ebr_wb, size_t ebr_wb_size, unsigned seed)
+{
+ while (mbr_wb_size--) {
+ *mbr_wb++ = seed;
+ seed *= 43;
+ seed += 17 + mbr_wb_size/4;
+ }
+ while (ebr_wb_size--) {
+ *ebr_wb++ = seed;
+ seed *= 43;
+ seed += 17 + ebr_wb_size/4;
+ }
+}
+
+/* Build string with MBR partition(s) layout */
+static unsigned build_mbr_parts(char *buf, size_t buf_size, unsigned num_parts)
+{
+ size_t bytes_remaining, cur_str_size;
+ char * cur_buf;
+
+ if (!num_parts || num_parts > 5 || !buf)
+ return 1;
+
+ cur_buf = buf;
+ *cur_buf = '\0';
+ bytes_remaining = buf_size;
+
+ cur_str_size = sizeof(mbr_parts_header);
+ if (cur_str_size + 1 > bytes_remaining)
+ return 1;
+ strcat(cur_buf, mbr_parts_header);
+ bytes_remaining -= cur_str_size;
+
+ if (num_parts >= 1) {
+ cur_str_size = sizeof(mbr_parts_p1);
+ if (cur_str_size + 1 > bytes_remaining)
+ return 1;
+ strcat(cur_buf, mbr_parts_p1);
+ bytes_remaining -= cur_str_size;
+
+ if (num_parts >= 2) {
+ cur_str_size = sizeof(mbr_parts_p2);
+ if (cur_str_size + 1 > bytes_remaining)
+ return 1;
+ strcat(cur_buf, mbr_parts_p2);
+ bytes_remaining -= cur_str_size;
+
+ if (num_parts >= 3) {
+ cur_str_size = sizeof(mbr_parts_p3);
+ if (cur_str_size + 1 > bytes_remaining)
+ return 1;
+ strcat(cur_buf, mbr_parts_p3);
+ bytes_remaining -= cur_str_size;
+
+ if (num_parts == 4) {
+ cur_str_size = sizeof(mbr_parts_p4);
+ if (cur_str_size + 1 > bytes_remaining)
+ return 1;
+ strcat(cur_buf, mbr_parts_p4);
+ bytes_remaining -= cur_str_size;
+
+ }
+ else if (num_parts == 5) {
+ cur_str_size = sizeof(mbr_parts_p5);
+ if (cur_str_size + 1 > bytes_remaining)
+ return 1;
+ strcat(cur_buf, mbr_parts_p5);
+ bytes_remaining -= cur_str_size;
+
+ }
+ else if (num_parts > 5)
+ return 1;
+ }
+ }
+ }
+
+ cur_str_size = sizeof(mbr_parts_tail);
+ if (cur_str_size + 1 > bytes_remaining)
+ return 1;
+ strcat(cur_buf, mbr_parts_tail);
+
+ return 0;
+}
+
+static int mbr_test_run(struct unit_test_state *uts)
+{
+ struct blk_desc *mmc_dev_desc;
+ unsigned char mbr_wbuf[512], ebr_wbuf[512], rbuf[512];
+ char mbr_parts_buf[256];
+ ulong mbr_wa, ebr_wa, ra, ebr_blk, mbr_parts_max;
+ struct udevice *dev;
+ ofnode root, node;
+
+ /* Enable the mmc6 node for this test */
+ root = oftree_root(oftree_default());
+ node = ofnode_find_subnode(root, "mmc6");
+ ut_assert(ofnode_valid(node));
+ ut_assertok(lists_bind_fdt(gd->dm_root, node, &dev, NULL, false));
+
+ mbr_parts_max = sizeof('\0') + 2 +
+ strlen(mbr_parts_header) +
+ strlen(mbr_parts_p1) +
+ strlen(mbr_parts_p2) +
+ strlen(mbr_parts_p3) +
+ max(strlen(mbr_parts_p4), strlen(mbr_parts_p5)) +
+ strlen(mbr_parts_tail);
+ ut_assertf(sizeof(mbr_parts_buf) >= mbr_parts_max, "Buffer avail: %ld; buffer req: %ld\n",
+ sizeof(mbr_parts_buf), mbr_parts_max);
+
+ mbr_wa = map_to_sysmem(mbr_wbuf);
+ ebr_wa = map_to_sysmem(ebr_wbuf);
+ ra = map_to_sysmem(rbuf);
+ ebr_blk = (ulong)0xB00000 / 0x200;
+
+ /* Make sure mmc6 exists */
+ ut_asserteq(6, blk_get_device_by_str("mmc", "6", &mmc_dev_desc));
+ ut_assertok(console_record_reset_enable());
+ ut_assertok(run_commandf("mmc dev 6"));
+ ut_assert_nextline("switch to partitions #0, OK");
+ ut_assert_nextline("mmc6 is current device");
+ ut_assertok(ut_check_console_end(uts));
+
+ /* Make sure mmc6 is 12+ MiB in size */
+ ut_assertok(run_commandf("mmc read 0x%lx 0x%lx 1", ra, (ulong)0xBFFE00 / 0x200));
+
+ /* Test one MBR partition */
+ init_write_buffers(mbr_wbuf, sizeof(mbr_wbuf), ebr_wbuf, sizeof(ebr_wbuf), __LINE__);
+ ut_assertok(build_mbr_parts(mbr_parts_buf, sizeof(mbr_parts_buf), 1));
+ ut_assertok(run_commandf("write mmc 6:0 0x%lx 0 1", mbr_wa));
+ memset(rbuf, 0, sizeof(rbuf));
+ ut_assertok(run_commandf("read mmc 6:0 0x%lx 0 1", ra));
+ ut_assertok(memcmp(mbr_wbuf, rbuf, 512));
+ ut_assertok(run_commandf("write mmc 6:0 0x%lx 0x%lx 1", ebr_wa, ebr_blk));
+ memset(rbuf, 0, sizeof(rbuf));
+ ut_assertok(run_commandf("read mmc 6:0 0x%lx 0x%lx 1", ra, ebr_blk));
+ ut_assertok(memcmp(ebr_wbuf, rbuf, 512));
+ ut_assertok(console_record_reset_enable());
+ ut_assertf(0 == run_commandf(mbr_parts_buf), "Invalid partitions string: %s\n", mbr_parts_buf);
+ ut_assertok(run_commandf("mbr write mmc 6"));
+ ut_assert_nextline("MBR: write success!");
+ ut_assertok(run_commandf("mbr verify mmc 6"));
+ ut_assert_nextline("MBR: verify success!");
+ memset(rbuf, 0, sizeof(rbuf));
+ ut_assertok(run_commandf("read mmc 6:0 0x%lx 0x%lx 1", ra, ebr_blk));
+ ut_assertok(memcmp(ebr_wbuf, rbuf, 512));
+ ut_assertok(ut_check_console_end(uts));
+ /*
+ 000001b0 00 00 00 00 00 00 00 00 78 56 34 12 00 00 80 05 |........xV4.....|
+ 000001c0 05 01 0e 25 24 01 00 40 00 00 00 08 00 00 00 00 |...%$..@........|
+ 000001d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
+ 000001e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
+ 000001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa |..............U.|
+ */
+ memset(rbuf, 0, sizeof(rbuf));
+ ut_assertok(run_commandf("read mmc 6:0 0x%lx 0 1", ra));
+ for (unsigned i = 0; i < mbr_cmp_size; i++) {
+ ut_assertf(rbuf[mbr_cmp_start + i] == mbr_parts_ref_p1[i],
+ "1P MBR+0x%04X: expected 0x%02X, actual: 0x%02X\n",
+ mbr_cmp_start + i, mbr_parts_ref_p1[i], rbuf[mbr_cmp_start + i]);
+ }
+
+ /* Test two MBR partitions */
+ init_write_buffers(mbr_wbuf, sizeof(mbr_wbuf), ebr_wbuf, sizeof(ebr_wbuf), __LINE__);
+ ut_assertok(build_mbr_parts(mbr_parts_buf, sizeof(mbr_parts_buf), 2));
+ ut_assertok(run_commandf("write mmc 6:0 0x%lx 0 1", mbr_wa));
+ memset(rbuf, 0, sizeof(rbuf));
+ ut_assertok(run_commandf("read mmc 6:0 0x%lx 0 1", ra));
+ ut_assertok(memcmp(mbr_wbuf, rbuf, 512));
+ ut_assertok(run_commandf("write mmc 6:0 0x%lx 0x%lx 1", ebr_wa, ebr_blk));
+ memset(rbuf, 0, sizeof(rbuf));
+ ut_assertok(run_commandf("read mmc 6:0 0x%lx 0x%lx 1", ra, ebr_blk));
+ ut_assertok(memcmp(ebr_wbuf, rbuf, 512));
+ ut_assertok(console_record_reset_enable());
+ ut_assertf(0 == run_commandf(mbr_parts_buf), "Invalid partitions string: %s\n", mbr_parts_buf);
+ ut_assertok(run_commandf("mbr write mmc 6"));
+ ut_assert_nextline("MBR: write success!");
+ ut_assertok(run_commandf("mbr verify mmc 6"));
+ ut_assert_nextline("MBR: verify success!");
+ memset(rbuf, 0, sizeof(rbuf));
+ ut_assertok(run_commandf("read mmc 6:0 0x%lx 0x%lx 1", ra, ebr_blk));
+ ut_assertok(memcmp(ebr_wbuf, rbuf, 512));
+ ut_assertok(ut_check_console_end(uts));
+ /*
+ 000001b0 00 00 00 00 00 00 00 00 78 56 34 12 00 00 80 05 |........xV4.....|
+ 000001c0 05 01 0e 25 24 01 00 40 00 00 00 08 00 00 00 25 |...%$..@.......%|
+ 000001d0 25 01 0e 46 05 01 00 48 00 00 00 08 00 00 00 00 |%..F...H........|
+ 000001e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
+ 000001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa |..............U.|
+ */
+ memset(rbuf, 0, sizeof(rbuf));
+ ut_assertok(run_commandf("read mmc 6:0 0x%lx 0 1", ra));
+ for (unsigned i = 0; i < mbr_cmp_size; i++) {
+ ut_assertf(rbuf[mbr_cmp_start + i] == mbr_parts_ref_p2[i],
+ "2P MBR+0x%04X: expected 0x%02X, actual: 0x%02X\n",
+ mbr_cmp_start + i, mbr_parts_ref_p2[i], rbuf[mbr_cmp_start + i]);
+ }
+
+ /* Test three MBR partitions */
+ init_write_buffers(mbr_wbuf, sizeof(mbr_wbuf), ebr_wbuf, sizeof(ebr_wbuf), __LINE__);
+ ut_assertok(build_mbr_parts(mbr_parts_buf, sizeof(mbr_parts_buf), 3));
+ ut_assertok(run_commandf("write mmc 6:0 0x%lx 0 1", mbr_wa));
+ memset(rbuf, 0, sizeof(rbuf));
+ ut_assertok(run_commandf("read mmc 6:0 0x%lx 0 1", ra));
+ ut_assertok(memcmp(mbr_wbuf, rbuf, 512));
+ ut_assertok(run_commandf("write mmc 6:0 0x%lx 0x%lx 1", ebr_wa, ebr_blk));
+ memset(rbuf, 0, sizeof(rbuf));
+ ut_assertok(run_commandf("read mmc 6:0 0x%lx 0x%lx 1", ra, ebr_blk));
+ ut_assertok(memcmp(ebr_wbuf, rbuf, 512));
+ ut_assertok(console_record_reset_enable());
+ ut_assertf(0 == run_commandf(mbr_parts_buf), "Invalid partitions string: %s\n", mbr_parts_buf);
+ ut_assertok(run_commandf("mbr write mmc 6"));
+ ut_assert_nextline("MBR: write success!");
+ ut_assertok(run_commandf("mbr verify mmc 6"));
+ ut_assert_nextline("MBR: verify success!");
+ memset(rbuf, 0, sizeof(rbuf));
+ ut_assertok(run_commandf("read mmc 6:0 0x%lx 0x%lx 1", ra, ebr_blk));
+ ut_assertok(memcmp(ebr_wbuf, rbuf, 512));
+ ut_assertok(ut_check_console_end(uts));
+ /*
+ 000001b0 00 00 00 00 00 00 00 00 78 56 34 12 00 00 80 05 |........xV4.....|
+ 000001c0 05 01 0e 25 24 01 00 40 00 00 00 08 00 00 00 25 |...%$..@.......%|
+ 000001d0 25 01 0e 46 05 01 00 48 00 00 00 08 00 00 00 46 |%..F...H.......F|
+ 000001e0 06 01 0e 66 25 01 00 50 00 00 00 08 00 00 00 00 |...f%..P........|
+ 000001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa |..............U.|
+ */
+ memset(rbuf, 0, sizeof(rbuf));
+ ut_assertok(run_commandf("read mmc 6:0 0x%lx 0 1", ra));
+ for (unsigned i = 0; i < mbr_cmp_size; i++) {
+ ut_assertf(rbuf[mbr_cmp_start + i] == mbr_parts_ref_p3[i],
+ "3P MBR+0x%04X: expected 0x%02X, actual: 0x%02X\n",
+ mbr_cmp_start + i, mbr_parts_ref_p3[i], rbuf[mbr_cmp_start + i]);
+ }
+
+ /* Test four MBR partitions */
+ init_write_buffers(mbr_wbuf, sizeof(mbr_wbuf), ebr_wbuf, sizeof(ebr_wbuf), __LINE__);
+ ut_assertok(build_mbr_parts(mbr_parts_buf, sizeof(mbr_parts_buf), 4));
+ ut_assertok(run_commandf("write mmc 6:0 0x%lx 0 1", mbr_wa));
+ memset(rbuf, 0, sizeof(rbuf));
+ ut_assertok(run_commandf("read mmc 6:0 0x%lx 0 1", ra));
+ ut_assertok(memcmp(mbr_wbuf, rbuf, 512));
+ ut_assertok(run_commandf("write mmc 6:0 0x%lx 0x%lx 1", ebr_wa, ebr_blk));
+ memset(rbuf, 0, sizeof(rbuf));
+ ut_assertok(run_commandf("read mmc 6:0 0x%lx 0x%lx 1", ra, ebr_blk));
+ ut_assertok(memcmp(ebr_wbuf, rbuf, 512));
+ ut_assertok(console_record_reset_enable());
+ ut_assertf(0 == run_commandf(mbr_parts_buf), "Invalid partitions string: %s\n", mbr_parts_buf);
+ ut_assertok(run_commandf("mbr write mmc 6"));
+ ut_assert_nextline("MBR: write success!");
+ ut_assertok(run_commandf("mbr verify mmc 6"));
+ ut_assert_nextline("MBR: verify success!");
+ memset(rbuf, 0, sizeof(rbuf));
+ ut_assertok(run_commandf("read mmc 6:0 0x%lx 0x%lx 1", ra, ebr_blk));
+ ut_assertok(memcmp(ebr_wbuf, rbuf, 512));
+ ut_assertok(ut_check_console_end(uts));
+ /*
+ 000001b0 00 00 00 00 00 00 00 00 78 56 34 12 00 00 80 05 |........xV4.....|
+ 000001c0 05 01 0e 25 24 01 00 40 00 00 00 08 00 00 00 25 |...%$..@.......%|
+ 000001d0 25 01 0e 46 05 01 00 48 00 00 00 08 00 00 00 46 |%..F...H.......F|
+ 000001e0 06 01 0e 66 25 01 00 50 00 00 00 08 00 00 00 66 |...f%..P.......f|
+ 000001f0 26 01 0e 87 06 01 00 58 00 00 00 08 00 00 55 aa |&......X......U.|
+ */
+ memset(rbuf, 0, sizeof(rbuf));
+ ut_assertok(run_commandf("read mmc 6:0 0x%lx 0 1", ra));
+ for (unsigned i = 0; i < mbr_cmp_size; i++) {
+ ut_assertf(rbuf[mbr_cmp_start + i] == mbr_parts_ref_p4[i],
+ "4P MBR+0x%04X: expected 0x%02X, actual: 0x%02X\n",
+ mbr_cmp_start + i, mbr_parts_ref_p4[i], rbuf[mbr_cmp_start + i]);
+ }
+
+ /* Test five MBR partitions */
+ init_write_buffers(mbr_wbuf, sizeof(mbr_wbuf), ebr_wbuf, sizeof(ebr_wbuf), __LINE__);
+ ut_assertok(build_mbr_parts(mbr_parts_buf, sizeof(mbr_parts_buf), 5));
+ ut_assertok(run_commandf("write mmc 6:0 0x%lx 0 1", mbr_wa));
+ memset(rbuf, 0, sizeof(rbuf));
+ ut_assertok(run_commandf("read mmc 6:0 0x%lx 0 1", ra));
+ ut_assertok(memcmp(mbr_wbuf, rbuf, 512));
+ ut_assertok(run_commandf("write mmc 6:0 0x%lx 0x%lx 1", ebr_wa, ebr_blk));
+ memset(rbuf, 0, sizeof(rbuf));
+ ut_assertok(run_commandf("read mmc 6:0 0x%lx 0x%lx 1", ra, ebr_blk));
+ ut_assertok(memcmp(ebr_wbuf, rbuf, 512));
+ ut_assertok(console_record_reset_enable());
+ ut_assertf(0 == run_commandf(mbr_parts_buf), "Invalid partitions string: %s\n", mbr_parts_buf);
+ ut_assertf(0 == run_commandf("mbr write mmc 6"), "Invalid partitions string: %s\n", mbr_parts_buf);
+ ut_assert_nextline("MBR: write success!");
+ ut_assertok(run_commandf("mbr verify mmc 6"));
+ ut_assert_nextline("MBR: verify success!");
+ ut_assertok(ut_check_console_end(uts));
+ /*
+ 000001b0 00 00 00 00 00 00 00 00 78 56 34 12 00 00 80 05 |........xV4.....|
+ 000001c0 05 01 0e 25 24 01 00 40 00 00 00 08 00 00 00 25 |...%$..@.......%|
+ 000001d0 25 01 0e 46 05 01 00 48 00 00 00 08 00 00 00 46 |%..F...H.......F|
+ 000001e0 06 01 0e 66 25 01 00 50 00 00 00 08 00 00 00 66 |...f%..P.......f|
+ 000001f0 26 01 05 a7 26 01 00 58 00 00 00 10 00 00 55 aa |&...&..X......U.|
+ */
+ memset(rbuf, 0, sizeof(rbuf));
+ ut_assertok(run_commandf("read mmc 6:0 0x%lx 0 1", ra));
+ for (unsigned i = 0; i < mbr_cmp_size; i++) {
+ ut_assertf(rbuf[mbr_cmp_start + i] == mbr_parts_ref_p5[i],
+ "5P MBR+0x%04X: expected 0x%02X, actual: 0x%02X\n",
+ mbr_cmp_start + i, mbr_parts_ref_p5[i], rbuf[mbr_cmp_start + i]);
+ }
+ /*
+ 00b001b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 87 |................|
+ 00b001c0 07 01 0e a7 26 01 00 08 00 00 00 08 00 00 00 00 |....&...........|
+ 00b001d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
+ 00b001e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
+ 00b001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa |..............U.|
+ */
+ memset(rbuf, 0, sizeof(rbuf));
+ ut_assertok(run_commandf("read mmc 6:0 0x%lx 0x%lx 1", ra, ebr_blk));
+ for (unsigned i = 0; i < ebr_cmp_size; i++) {
+ ut_assertf(rbuf[ebr_cmp_start + i] == ebr_parts_ref_p5[i],
+ "5P EBR+0x%04X: expected 0x%02X, actual: 0x%02X\n",
+ ebr_cmp_start + i, ebr_parts_ref_p5[i], rbuf[ebr_cmp_start + i]);
+ }
+
+ return 0;
+}
+
+/* Declare mbr test */
+UNIT_TEST(mbr_test_run, UT_TESTF_CONSOLE_REC, mbr_test);
+
+int do_ut_mbr(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
+{
+ struct unit_test *tests = UNIT_TEST_SUITE_START(mbr_test);
+ const int n_ents = UNIT_TEST_SUITE_COUNT(mbr_test);
+
+ return cmd_ut_category("mbr", "mbr_test_", tests, n_ents, argc, argv);
+}
+
+static int dm_test_cmd_mbr(struct unit_test_state *uts)
+{
+ return mbr_test_run(uts);
+}
+
+DM_TEST(dm_test_cmd_mbr, UT_TESTF_SCAN_FDT | UT_TESTF_CONSOLE_REC);
diff --git a/test/cmd_ut.c b/test/cmd_ut.c
index 477d4759521..0343d472176 100644
--- a/test/cmd_ut.c
+++ b/test/cmd_ut.c
@@ -87,6 +87,10 @@ static struct cmd_tbl cmd_ut_sub[] = {
#ifdef CONFIG_UT_LOG
U_BOOT_CMD_MKENT(log, CONFIG_SYS_MAXARGS, 1, do_ut_log, "", ""),
#endif
+#if defined(CONFIG_SANDBOX) && defined(CONFIG_CMD_MBR) && defined(CONFIG_CMD_MMC) \
+ && defined(CONFIG_MMC_SANDBOX) && defined(CONFIG_MMC_WRITE)
+ U_BOOT_CMD_MKENT(mbr, CONFIG_SYS_MAXARGS, 1, do_ut_mbr, "", ""),
+#endif
U_BOOT_CMD_MKENT(mem, CONFIG_SYS_MAXARGS, 1, do_ut_mem, "", ""),
#if defined(CONFIG_SANDBOX) && defined(CONFIG_CMD_SETEXPR)
U_BOOT_CMD_MKENT(setexpr, CONFIG_SYS_MAXARGS, 1, do_ut_setexpr, "",
diff --git a/test/common/cread.c b/test/common/cread.c
index 2fdd29a265f..4edc7739604 100644
--- a/test/common/cread.c
+++ b/test/common/cread.c
@@ -43,6 +43,12 @@ static int cli_ch_test(struct unit_test_state *uts)
ut_asserteq('a', cli_ch_process(cch, 'a'));
ut_asserteq(0, cli_ch_process(cch, 0));
+ /* unexpected 'Esc' */
+ ut_asserteq('a', cli_ch_process(cch, 'a'));
+ ut_asserteq(0, cli_ch_process(cch, '\e'));
+ ut_asserteq('b', cli_ch_process(cch, 'b'));
+ ut_asserteq(0, cli_ch_process(cch, 0));
+
return 0;
}
COMMON_TEST(cli_ch_test, 0);
@@ -80,6 +86,12 @@ static int cread_test(struct unit_test_state *uts)
ut_asserteq(7, cli_readline_into_buffer("-> ", buf, 1));
ut_asserteq_str("abc\e[Xx", buf);
+ /* unexpected 'Esc' */
+ *buf = '\0';
+ ut_asserteq(7, console_in_puts("abc\eXx\n"));
+ ut_asserteq(5, cli_readline_into_buffer("-> ", buf, 1));
+ ut_asserteq_str("abcXx", buf);
+
/* check timeout, should be between 1000 and 1050ms */
start = get_timer(0);
*buf = '\0';
diff --git a/test/dm/scmi.c b/test/dm/scmi.c
index d4ff60e0006..da45314f2e4 100644
--- a/test/dm/scmi.c
+++ b/test/dm/scmi.c
@@ -206,6 +206,109 @@ static int dm_test_scmi_base(struct unit_test_state *uts)
DM_TEST(dm_test_scmi_base, UT_TESTF_SCAN_FDT);
+static int dm_test_scmi_power_domains(struct unit_test_state *uts)
+{
+ struct sandbox_scmi_agent *agent;
+ struct sandbox_scmi_devices *scmi_devices;
+ struct udevice *agent_dev, *pwd, *dev;
+ u32 version, count, attributes, pstate;
+ u64 stats_addr;
+ size_t stats_len;
+ u8 *name;
+ int ret;
+
+ /* preparation */
+ ut_assertok(load_sandbox_scmi_test_devices(uts, &agent, &dev));
+ ut_assertnonnull(agent);
+ scmi_devices = sandbox_scmi_devices_ctx(dev);
+ ut_assertnonnull(scmi_devices);
+ ut_asserteq(2, scmi_devices->pwdom->id); /* in test.dts */
+
+ ut_assertok(uclass_get_device_by_name(UCLASS_SCMI_AGENT, "scmi",
+ &agent_dev));
+ ut_assertnonnull(agent_dev);
+ pwd = scmi_get_protocol(agent_dev, SCMI_PROTOCOL_ID_POWER_DOMAIN);
+ ut_assertnonnull(pwd);
+
+ /*
+ * SCMI Power domain management protocol interfaces
+ */
+ /* version */
+ ret = scmi_generic_protocol_version(pwd, SCMI_PROTOCOL_ID_POWER_DOMAIN,
+ &version);
+ ut_assertok(ret);
+ ut_asserteq(agent->pwdom_version, version);
+
+ /* protocol attributes */
+ ret = scmi_pwd_protocol_attrs(pwd, &count, &stats_addr, &stats_len);
+ ut_assertok(ret);
+ ut_asserteq(agent->pwdom_count, count);
+ ut_asserteq(0, stats_len);
+
+ /* protocol message attributes */
+ ret = scmi_pwd_protocol_message_attrs(pwd, SCMI_PWD_STATE_SET,
+ &attributes);
+ ut_assertok(ret);
+ ret = scmi_pwd_protocol_message_attrs(pwd, SCMI_PWD_STATE_NOTIFY,
+ &attributes);
+ ut_asserteq(-ENOENT, ret); /* the protocol not supported */
+
+ /* power domain attributes */
+ ret = scmi_pwd_attrs(pwd, 0, &attributes, &name);
+ ut_assertok(ret);
+ ut_asserteq_str("power-domain--0", name);
+ free(name);
+
+ ret = scmi_pwd_attrs(pwd, 10, &attributes, &name);
+ ut_asserteq(-ENOENT, ret); /* domain-10 doesn't exist */
+
+ /* power domain state set/get */
+ ret = scmi_pwd_state_set(pwd, 0, 0, 0);
+ ut_assertok(ret);
+ ret = scmi_pwd_state_get(pwd, 0, &pstate);
+ ut_assertok(ret);
+ ut_asserteq(0, pstate); /* ON */
+
+ ret = scmi_pwd_state_set(pwd, 0, 0, SCMI_PWD_PSTATE_TYPE_LOST);
+ ut_assertok(ret);
+ ret = scmi_pwd_state_get(pwd, 0, &pstate);
+ ut_assertok(ret);
+ ut_asserteq(SCMI_PWD_PSTATE_TYPE_LOST, pstate); /* OFF */
+
+ ret = scmi_pwd_state_set(pwd, 0, 10, 0);
+ ut_asserteq(-ENOENT, ret);
+
+ /* power domain name get */
+ ret = scmi_pwd_name_get(pwd, 0, &name);
+ ut_assertok(ret);
+ ut_asserteq_str("power-domain--0-extended", name);
+ free(name);
+
+ ret = scmi_pwd_name_get(pwd, 10, &name);
+ ut_asserteq(-ENOENT, ret); /* domain-10 doesn't exist */
+
+ /*
+ * U-Boot driver model interfaces
+ */
+ /* power_domain_on */
+ ret = power_domain_on(scmi_devices->pwdom);
+ ut_assertok(ret);
+ ret = scmi_pwd_state_get(pwd, scmi_devices->pwdom->id, &pstate);
+ ut_assertok(ret);
+ ut_asserteq(0, pstate); /* ON */
+
+ /* power_domain_off */
+ ret = power_domain_off(scmi_devices->pwdom);
+ ut_assertok(ret);
+ ret = scmi_pwd_state_get(pwd, scmi_devices->pwdom->id, &pstate);
+ ut_assertok(ret);
+ ut_asserteq(SCMI_PWD_PSTATE_TYPE_LOST, pstate); /* OFF */
+
+ return release_sandbox_scmi_test_devices(uts, dev);
+}
+
+DM_TEST(dm_test_scmi_power_domains, UT_TESTF_SCAN_FDT);
+
static int dm_test_scmi_clocks(struct unit_test_state *uts)
{
struct sandbox_scmi_agent *agent;
diff --git a/test/py/tests/test_ut.py b/test/py/tests/test_ut.py
index 82932a662bf..1d9149a3f68 100644
--- a/test/py/tests/test_ut.py
+++ b/test/py/tests/test_ut.py
@@ -433,7 +433,6 @@ def setup_cedit_file(cons):
u_boot_utils.run_and_log(
cons, f'{expo_tool} -e {inhname} -l {infname} -o {outfname}')
-
@pytest.mark.buildconfigspec('ut_dm')
def test_ut_dm_init(u_boot_console):
"""Initialize data for ut dm tests."""
@@ -463,6 +462,12 @@ def test_ut_dm_init(u_boot_console):
fs_helper.mk_fs(u_boot_console.config, 'ext2', 0x200000, '2MB')
fs_helper.mk_fs(u_boot_console.config, 'fat32', 0x100000, '1MB')
+ mmc_dev = 6
+ fn = os.path.join(u_boot_console.config.source_dir, f'mmc{mmc_dev}.img')
+ data = b'\x00' * (12 * 1024 * 1024)
+ 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"""
diff --git a/tools/patman/test_checkpatch.py b/tools/patman/test_checkpatch.py
index a8bb364e42b..0a8f7408f14 100644
--- a/tools/patman/test_checkpatch.py
+++ b/tools/patman/test_checkpatch.py
@@ -18,19 +18,47 @@ from patman import commit
class Line:
+ """Single changed line in one file in a patch
+
+ Args:
+ fname (str): Filename containing the added line
+ text (str): Text of the added line
+ """
def __init__(self, fname, text):
self.fname = fname
self.text = text
class PatchMaker:
+ """Makes a patch for checking with checkpatch.pl
+
+ The idea here is to create a patch which adds one line in one file,
+ intended to provoke a checkpatch error or warning. The base patch is empty
+ (i.e. invalid), so you should call add_line() to add at least one line.
+ """
def __init__(self):
+ """Set up the PatchMaker object
+
+ Properties:
+ lines (list of Line): List of lines to add to the patch. Note that
+ each line has both a file and some text associated with it,
+ since for simplicity we just add a single line for each file
+ """
self.lines = []
def add_line(self, fname, text):
+ """Add to the list of filename/line pairs"""
self.lines.append(Line(fname, text))
def get_patch_text(self):
+ """Build the patch text
+
+ Takes a base patch and adds a diffstat and patch for each filename/line
+ pair in the list.
+
+ Returns:
+ str: Patch text ready for submission to checkpatch
+ """
base = '''From 125b77450f4c66b8fd9654319520bbe795c9ef31 Mon Sep 17 00:00:00 2001
From: Simon Glass <sjg@chromium.org>
Date: Sun, 14 Jun 2020 09:45:14 -0600
@@ -75,6 +103,11 @@ Signed-off-by: Simon Glass <sjg@chromium.org>
return '\n'.join(lines)
def get_patch(self):
+ """Get the patch text and write it into a temporary file
+
+ Returns:
+ str: Filename containing the patch
+ """
inhandle, inname = tempfile.mkstemp()
infd = os.fdopen(inhandle, 'w')
infd.write(self.get_patch_text())
@@ -82,6 +115,22 @@ Signed-off-by: Simon Glass <sjg@chromium.org>
return inname
def run_checkpatch(self):
+ """Run checkpatch on the patch file
+
+ Returns:
+ namedtuple containing:
+ ok: False=failure, True=ok
+ problems: List of problems, each a dict:
+ 'type'; error or warning
+ 'msg': text message
+ 'file' : filename
+ 'line': line number
+ errors: Number of errors
+ warnings: Number of warnings
+ checks: Number of checks
+ lines: Number of lines
+ stdout: Full output of checkpatch
+ """
return checkpatch.check_patch(self.get_patch(), show_types=True)
@@ -238,7 +287,7 @@ index 0000000..2234c87
+ * passed to kernel in the ATAGs
+ */
+
-+#include <common.h>
++#include <config.h>
+
+struct bootstage_record {
+ u32 time_us;
@@ -401,10 +450,15 @@ index 0000000..2234c87
def test_barred_include_in_hdr(self):
"""Test for using a barred include in a header file"""
pm = PatchMaker()
- #pm.add_line('include/myfile.h', '#include <common.h>')
pm.add_line('include/myfile.h', '#include <dm.h>')
self.check_single_message(pm, 'BARRED_INCLUDE_IN_HDR', 'error')
+ def test_barred_include_common_h(self):
+ """Test for adding common.h to a file"""
+ pm = PatchMaker()
+ pm.add_line('include/myfile.h', '#include <common.h>')
+ self.check_single_message(pm, 'BARRED_INCLUDE_COMMON_H', 'error')
+
def test_config_is_enabled_config(self):
"""Test for accidental CONFIG_IS_ENABLED(CONFIG_*) calls"""
pm = PatchMaker()