From: "Pali Rohár" <pali@kernel.org>
To: Stefan Roese <sr@denx.de>
Cc: u-boot@lists.denx.de
Subject: [PATCH v2 u-boot-mvebu 3/6] arm: mvebu: Convert BOOT_FROM_* constants to function macros
Date: Wed, 29 Mar 2023 21:03:32 +0200 [thread overview]
Message-ID: <20230329190335.9861-4-pali@kernel.org> (raw)
In-Reply-To: <20230329190335.9861-1-pali@kernel.org>
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>
---
arch/arm/mach-mvebu/cpu.c | 20 ++++++++++----------
arch/arm/mach-mvebu/include/mach/soc.h | 25 ++++++++++++-------------
2 files changed, 22 insertions(+), 23 deletions(-)
diff --git a/arch/arm/mach-mvebu/cpu.c b/arch/arm/mach-mvebu/cpu.c
index 0fcd520c1dbc..1676032682b5 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 3266749836a7..82a98cf9ff57 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
--
2.20.1
next prev parent reply other threads:[~2023-03-29 19:05 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-04 10:50 [PATCH RFC u-boot-mvebu 0/6] arm: mvebu: Fix boot mode detection Pali Rohár
2023-03-04 10:50 ` [PATCH RFC u-boot-mvebu 1/6] arm: mvebu: Remove A38x BOOT_FROM_UART_ALT 0x3f constant Pali Rohár
2023-03-04 10:50 ` [PATCH RFC u-boot-mvebu 2/6] arm: mvebu: Remove A38x BOOT_FROM_SATA 0x22 constant Pali Rohár
2023-03-04 10:50 ` [PATCH RFC u-boot-mvebu 3/6] arm: mvebu: Convert BOOT_FROM_* constants to function macros Pali Rohár
2023-03-05 3:11 ` Martin Rowe
2023-03-05 11:48 ` Pali Rohár
2023-03-27 6:56 ` Stefan Roese
2023-03-04 10:50 ` [PATCH RFC u-boot-mvebu 4/6] arm: mvebu: Define all options for A38x BOOT_FROM_* macros Pali Rohár
2023-03-04 11:20 ` Pali Rohár
2023-03-05 0:06 ` Martin Rowe
2023-03-05 1:00 ` Pali Rohár
2023-03-04 10:50 ` [PATCH RFC u-boot-mvebu 5/6] arm: mvebu: Define all BOOTROM_ERR_MODE_* macros Pali Rohár
2023-03-04 10:50 ` [PATCH RFC u-boot-mvebu 6/6] arm: mvebu: Define all options for AXP BOOT_FROM_* macros Pali Rohár
2023-03-05 4:21 ` [PATCH RFC u-boot-mvebu 0/6] arm: mvebu: Fix boot mode detection Martin Rowe
2023-03-05 11:55 ` Pali Rohár
2023-03-05 22:44 ` Tony Dinh
2023-03-05 22:46 ` Tony Dinh
2023-03-05 22:54 ` Pali Rohár
2023-03-06 0:41 ` Tony Dinh
2023-03-07 0:01 ` Tony Dinh
2023-03-07 0:11 ` Pali Rohár
2023-03-07 4:15 ` Tony Dinh
2023-03-07 7:56 ` Pali Rohár
2023-03-07 20:53 ` Tony Dinh
2023-03-07 20:55 ` Pali Rohár
2023-03-19 3:30 ` Martin Rowe
2023-03-19 16:47 ` Pali Rohár
2023-03-19 18:20 ` Pali Rohár
2023-03-20 12:01 ` Martin Rowe
2023-03-20 17:45 ` Pali Rohár
2023-03-20 21:32 ` Pali Rohár
2023-03-21 8:34 ` Martin Rowe
2023-03-21 17:25 ` Pali Rohár
2023-03-21 19:56 ` Pali Rohár
2023-03-21 20:02 ` Pali Rohár
2023-03-22 11:14 ` Martin Rowe
2023-03-22 18:09 ` Pali Rohár
2023-03-23 11:01 ` Martin Rowe
2023-03-23 18:33 ` Pali Rohár
2023-03-23 19:19 ` Pali Rohár
2023-03-20 19:42 ` Pali Rohár
2023-03-21 8:03 ` Martin Rowe
2023-03-21 8:09 ` Pali Rohár
2023-03-06 6:17 ` Stefan Roese
2023-03-25 13:30 ` Pali Rohár
2023-03-25 19:27 ` Tony Dinh
2023-03-25 20:06 ` Tony Dinh
2023-03-25 23:40 ` Martin Rowe
2023-03-29 19:03 ` [PATCH v2 " Pali Rohár
2023-03-29 19:03 ` [PATCH v2 u-boot-mvebu 1/6] arm: mvebu: Remove A38x BOOT_FROM_UART_ALT 0x3f constant Pali Rohár
2023-03-30 4:55 ` Stefan Roese
2023-03-29 19:03 ` [PATCH v2 u-boot-mvebu 2/6] arm: mvebu: Remove A38x BOOT_FROM_SATA 0x22 constant Pali Rohár
2023-03-30 4:55 ` Stefan Roese
2023-03-29 19:03 ` Pali Rohár [this message]
2023-03-30 4:56 ` [PATCH v2 u-boot-mvebu 3/6] arm: mvebu: Convert BOOT_FROM_* constants to function macros Stefan Roese
2023-03-29 19:03 ` [PATCH v2 u-boot-mvebu 4/6] arm: mvebu: Define all options for A38x BOOT_FROM_* macros Pali Rohár
2023-03-30 4:56 ` Stefan Roese
2023-03-29 19:03 ` [PATCH v2 u-boot-mvebu 5/6] arm: mvebu: Define all BOOTROM_ERR_MODE_* macros Pali Rohár
2023-03-30 4:56 ` Stefan Roese
2023-03-29 19:03 ` [PATCH v2 u-boot-mvebu 6/6] arm: mvebu: Define all options for AXP BOOT_FROM_* macros Pali Rohár
2023-03-30 4:57 ` Stefan Roese
2023-03-30 8:19 ` [PATCH v2 u-boot-mvebu 0/6] arm: mvebu: Fix boot mode detection Stefan Roese
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230329190335.9861-4-pali@kernel.org \
--to=pali@kernel.org \
--cc=sr@denx.de \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.