summaryrefslogtreecommitdiff
path: root/arch/arm/include/asm/arch-imx8m
diff options
context:
space:
mode:
authorMarek Vasut <marex@denx.de>2022-04-25 00:44:03 +0300
committerStefano Babic <sbabic@denx.de>2022-05-20 10:03:01 +0300
commit52b6b480db314d623eba536f390c0dc879900262 (patch)
treeba7224e1eac1a9b2981a844de1ade9d61b844b89 /arch/arm/include/asm/arch-imx8m
parent16ee0f2afd710854f8fd049d39c1ae99b0cacab7 (diff)
downloadu-boot-52b6b480db314d623eba536f390c0dc879900262.tar.xz
ARM: imx: imx8m: Introduce and use UART_BASE_ADDR(n)
Introduce helper macro UART_BASE_ADDR(n), which returns Nth UART base address. Convert all board configurations to this new macro. This is the first step toward switching CONFIG_MXC_UART_BASE to Kconfig. This is a clean up, no functional change. The new macro contains compile-time test to verify N is in suitable range. The test works such that it multiplies constant N by constant double-negation of size of a non-empty structure, i.e. it multiplies constant N by constant 1 in each successful compilation case. The non-empty structure may contain C11 _Static_assert(), make use of this and place the kernel variant of static assert in there, so that it performs the compile-time check for N in the correct range. Note that it is not possible to directly use static_assert in compound statements, hence this convoluted construct. Signed-off-by: Marek Vasut <marex@denx.de> Cc: Fabio Estevam <festevam@denx.de> Cc: Peng Fan <peng.fan@nxp.com> Cc: Stefano Babic <sbabic@denx.de>
Diffstat (limited to 'arch/arm/include/asm/arch-imx8m')
-rw-r--r--arch/arm/include/asm/arch-imx8m/imx-regs.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/arch/arm/include/asm/arch-imx8m/imx-regs.h b/arch/arm/include/asm/arch-imx8m/imx-regs.h
index b2a8ad77ae..1da75528d4 100644
--- a/arch/arm/include/asm/arch-imx8m/imx-regs.h
+++ b/arch/arm/include/asm/arch-imx8m/imx-regs.h
@@ -48,6 +48,16 @@
#ifdef CONFIG_IMX8MM
#define USDHC3_BASE_ADDR 0x30B60000
#endif
+#define UART_BASE_ADDR(n) ( \
+ !!sizeof(struct { \
+ static_assert((n) >= 1 && (n) <= 4); \
+ int pad; \
+ }) * ( \
+ (n) == 1 ? UART1_BASE_ADDR : \
+ (n) == 2 ? UART2_BASE_ADDR : \
+ (n) == 3 ? UART3_BASE_ADDR : \
+ UART4_BASE_ADDR) \
+ )
#define TZASC_BASE_ADDR 0x32F80000