summaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorPali Rohár <pali@kernel.org>2023-03-29 21:03:32 +0200
committerStefan Roese <sr@denx.de>2023-03-30 07:05:20 +0200
commit7ba084c7f81f5b31125fdfdefd8e105dbd0366fe (patch)
tree60b2f76524738ed405598dc2b8a981269a57fb29 /arch
parent4642bb3e76cfc3fe765dbe3174ceaffba94ea1f2 (diff)
downloadu-boot-7ba084c7f81f5b31125fdfdefd8e105dbd0366fe.tar.gz
u-boot-7ba084c7f81f5b31125fdfdefd8e105dbd0366fe.tar.bz2
u-boot-7ba084c7f81f5b31125fdfdefd8e105dbd0366fe.zip
arm: mvebu: Convert BOOT_FROM_* constants to function macros
This allows to merge BOOT_FROM_MMC and BOOT_FROM_MMC_ALT constants to one macro. And also allows to extend other BOOT_FROM_* macros for other variants. Signed-off-by: Pali Rohár <pali@kernel.org> Tested-by: Tony Dinh <mibodhi@gmail.com> Tested-by: Martin Rowe <martin.p.rowe@gmail.com> Reviewed-by: Stefan Roese <sr@denx.de>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/mach-mvebu/cpu.c20
-rw-r--r--arch/arm/mach-mvebu/include/mach/soc.h25
2 files changed, 22 insertions, 23 deletions
diff --git a/arch/arm/mach-mvebu/cpu.c b/arch/arm/mach-mvebu/cpu.c
index 0fcd520c1d..1676032682 100644
--- a/arch/arm/mach-mvebu/cpu.c
+++ b/arch/arm/mach-mvebu/cpu.c
@@ -100,27 +100,27 @@ u32 get_boot_device(void)
val = readl(CFG_SAR_REG); /* SAR - Sample At Reset */
boot_device = (val & BOOT_DEV_SEL_MASK) >> BOOT_DEV_SEL_OFFS;
debug("SAR_REG=0x%08x boot_device=0x%x\n", val, boot_device);
- switch (boot_device) {
#ifdef BOOT_FROM_NAND
- case BOOT_FROM_NAND:
+ if (BOOT_FROM_NAND(boot_device))
return BOOT_DEVICE_NAND;
#endif
#ifdef BOOT_FROM_MMC
- case BOOT_FROM_MMC:
- case BOOT_FROM_MMC_ALT:
+ if (BOOT_FROM_MMC(boot_device))
return BOOT_DEVICE_MMC1;
#endif
- case BOOT_FROM_UART:
+#ifdef BOOT_FROM_UART
+ if (BOOT_FROM_UART(boot_device))
return BOOT_DEVICE_UART;
+#endif
#ifdef BOOT_FROM_SATA
- case BOOT_FROM_SATA:
+ if (BOOT_FROM_SATA(boot_device))
return BOOT_DEVICE_SATA;
#endif
- case BOOT_FROM_SPI:
+#ifdef BOOT_FROM_SPI
+ if (BOOT_FROM_SPI(boot_device))
return BOOT_DEVICE_SPI;
- default:
- return BOOT_DEVICE_BOOTROM;
- };
+#endif
+ return BOOT_DEVICE_BOOTROM;
}
#if defined(CONFIG_DISPLAY_CPUINFO)
diff --git a/arch/arm/mach-mvebu/include/mach/soc.h b/arch/arm/mach-mvebu/include/mach/soc.h
index 3266749836..82a98cf9ff 100644
--- a/arch/arm/mach-mvebu/include/mach/soc.h
+++ b/arch/arm/mach-mvebu/include/mach/soc.h
@@ -143,8 +143,8 @@
#define BOOT_DEV_SEL_OFFS 3
#define BOOT_DEV_SEL_MASK (0x3f << BOOT_DEV_SEL_OFFS)
-#define BOOT_FROM_UART 0x30
-#define BOOT_FROM_SPI 0x38
+#define BOOT_FROM_UART(x) (x == 0x30)
+#define BOOT_FROM_SPI(x) (x == 0x38)
#define CFG_SYS_TCLK ((readl(CFG_SAR_REG) & BIT(20)) ? \
200000000 : 166000000)
@@ -160,12 +160,11 @@
#define BOOT_DEV_SEL_OFFS 4
#define BOOT_DEV_SEL_MASK (0x3f << BOOT_DEV_SEL_OFFS)
-#define BOOT_FROM_NAND 0x0A
-#define BOOT_FROM_SATA 0x2A
-#define BOOT_FROM_UART 0x28
-#define BOOT_FROM_SPI 0x32
-#define BOOT_FROM_MMC 0x30
-#define BOOT_FROM_MMC_ALT 0x31
+#define BOOT_FROM_NAND(x) (x == 0x0A)
+#define BOOT_FROM_SATA(x) (x == 0x2A)
+#define BOOT_FROM_UART(x) (x == 0x28)
+#define BOOT_FROM_SPI(x) (x == 0x32)
+#define BOOT_FROM_MMC(x) (x == 0x30 || x == 0x31)
#define CFG_SYS_TCLK ((readl(CFG_SAR_REG) & BIT(15)) ? \
200000000 : 250000000)
@@ -182,9 +181,9 @@
#define BOOT_DEV_SEL_OFFS 11
#define BOOT_DEV_SEL_MASK (0x7 << BOOT_DEV_SEL_OFFS)
-#define BOOT_FROM_NAND 0x1
-#define BOOT_FROM_UART 0x2
-#define BOOT_FROM_SPI 0x3
+#define BOOT_FROM_NAND(x) (x == 0x1)
+#define BOOT_FROM_UART(x) (x == 0x2)
+#define BOOT_FROM_SPI(x) (x == 0x3)
#define CFG_SYS_TCLK 200000000 /* 200MHz */
#elif defined(CONFIG_ARMADA_XP)
@@ -204,8 +203,8 @@
#define BOOT_DEV_SEL_OFFS 5
#define BOOT_DEV_SEL_MASK (0xf << BOOT_DEV_SEL_OFFS)
-#define BOOT_FROM_UART 0x2
-#define BOOT_FROM_SPI 0x3
+#define BOOT_FROM_UART(x) (x == 0x2)
+#define BOOT_FROM_SPI(x) (x == 0x3)
#define CFG_SYS_TCLK 250000000 /* 250MHz */
#endif