All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] ARM: imx: imx8m: Introduce and use UART_BASE_ADDR(n)
@ 2022-04-24 21:44 Marek Vasut
  2022-04-24 21:44 ` [PATCH 2/4] ARM: imx: imx27: " Marek Vasut
                   ` (4 more replies)
  0 siblings, 5 replies; 17+ messages in thread
From: Marek Vasut @ 2022-04-24 21:44 UTC (permalink / raw)
  To: u-boot; +Cc: Marek Vasut, Fabio Estevam, Peng Fan, Stefano Babic

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>
---
 arch/arm/include/asm/arch-imx8m/imx-regs.h | 10 ++++++++++
 include/configs/imx8mm-cl-iot-gate.h       |  2 +-
 include/configs/imx8mm_beacon.h            |  2 +-
 include/configs/imx8mm_evk.h               |  2 +-
 include/configs/imx8mm_icore_mx8mm.h       |  2 +-
 include/configs/imx8mm_venice.h            |  2 +-
 include/configs/imx8mn_beacon.h            |  2 +-
 include/configs/imx8mn_evk.h               |  2 +-
 include/configs/imx8mn_var_som.h           |  2 +-
 include/configs/imx8mn_venice.h            |  2 +-
 include/configs/imx8mp_evk.h               |  2 +-
 include/configs/imx8mp_rsb3720.h           |  2 +-
 include/configs/imx8mq_cm.h                |  2 +-
 include/configs/imx8mq_evk.h               |  2 +-
 include/configs/imx8mq_phanbell.h          |  2 +-
 include/configs/kontron-sl-mx8mm.h         |  2 +-
 include/configs/kontron_pitx_imx8m.h       |  2 +-
 include/configs/phycore_imx8mm.h           |  2 +-
 include/configs/phycore_imx8mp.h           |  2 +-
 include/configs/pico-imx8mq.h              |  2 +-
 include/configs/verdin-imx8mm.h            |  2 +-
 include/configs/verdin-imx8mp.h            |  2 +-
 22 files changed, 31 insertions(+), 21 deletions(-)

diff --git a/arch/arm/include/asm/arch-imx8m/imx-regs.h b/arch/arm/include/asm/arch-imx8m/imx-regs.h
index b2a8ad77ae1..1da75528d46 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
 
diff --git a/include/configs/imx8mm-cl-iot-gate.h b/include/configs/imx8mm-cl-iot-gate.h
index c20c32b6951..60746588b73 100644
--- a/include/configs/imx8mm-cl-iot-gate.h
+++ b/include/configs/imx8mm-cl-iot-gate.h
@@ -145,7 +145,7 @@
 #define PHYS_SDRAM			0x40000000
 #define PHYS_SDRAM_SIZE			0x80000000 /* 2GB DDR */
 
-#define CONFIG_MXC_UART_BASE		UART3_BASE_ADDR
+#define CONFIG_MXC_UART_BASE		UART_BASE_ADDR(3)
 
 /* Monitor Command Prompt */
 #define CONFIG_SYS_CBSIZE		2048
diff --git a/include/configs/imx8mm_beacon.h b/include/configs/imx8mm_beacon.h
index 7c17f14964f..573ddaf2952 100644
--- a/include/configs/imx8mm_beacon.h
+++ b/include/configs/imx8mm_beacon.h
@@ -91,7 +91,7 @@
 #define PHYS_SDRAM			0x40000000
 #define PHYS_SDRAM_SIZE		0x80000000 /* 2GB DDR */
 
-#define CONFIG_MXC_UART_BASE		UART2_BASE_ADDR
+#define CONFIG_MXC_UART_BASE		UART_BASE_ADDR(2)
 
 /* Monitor Command Prompt */
 #define CONFIG_SYS_CBSIZE		2048
diff --git a/include/configs/imx8mm_evk.h b/include/configs/imx8mm_evk.h
index 42b78485cfc..bd10406d79d 100644
--- a/include/configs/imx8mm_evk.h
+++ b/include/configs/imx8mm_evk.h
@@ -68,7 +68,7 @@
 #define PHYS_SDRAM                      0x40000000
 #define PHYS_SDRAM_SIZE			0x80000000 /* 2GB DDR */
 
-#define CONFIG_MXC_UART_BASE		UART2_BASE_ADDR
+#define CONFIG_MXC_UART_BASE		UART_BASE_ADDR(2)
 
 /* Monitor Command Prompt */
 #define CONFIG_SYS_CBSIZE		2048
diff --git a/include/configs/imx8mm_icore_mx8mm.h b/include/configs/imx8mm_icore_mx8mm.h
index f521add5b04..b9b24a8c51d 100644
--- a/include/configs/imx8mm_icore_mx8mm.h
+++ b/include/configs/imx8mm_icore_mx8mm.h
@@ -66,7 +66,7 @@
 #define CONFIG_SYS_BOOTM_LEN		SZ_256M
 
 /* UART */
-#define CONFIG_MXC_UART_BASE		UART2_BASE_ADDR
+#define CONFIG_MXC_UART_BASE		UART_BASE_ADDR(2)
 
 /* Monitor Command Prompt */
 #define CONFIG_SYS_CBSIZE		2048
diff --git a/include/configs/imx8mm_venice.h b/include/configs/imx8mm_venice.h
index 1b26e0280e1..f3dad256100 100644
--- a/include/configs/imx8mm_venice.h
+++ b/include/configs/imx8mm_venice.h
@@ -102,7 +102,7 @@
 #define CONFIG_SYS_BOOTM_LEN		SZ_256M
 
 /* UART */
-#define CONFIG_MXC_UART_BASE		UART2_BASE_ADDR
+#define CONFIG_MXC_UART_BASE		UART_BASE_ADDR(2)
 
 /* Monitor Command Prompt */
 #define CONFIG_SYS_CBSIZE		SZ_2K
diff --git a/include/configs/imx8mn_beacon.h b/include/configs/imx8mn_beacon.h
index 41ce3c1c8ce..79c6b1076ff 100644
--- a/include/configs/imx8mn_beacon.h
+++ b/include/configs/imx8mn_beacon.h
@@ -107,7 +107,7 @@
 #define PHYS_SDRAM_SIZE		0x40000000 /* 1GB DDR */
 #endif
 
-#define CONFIG_MXC_UART_BASE		UART2_BASE_ADDR
+#define CONFIG_MXC_UART_BASE		UART_BASE_ADDR(2)
 
 /* Monitor Command Prompt */
 #define CONFIG_SYS_CBSIZE              2048
diff --git a/include/configs/imx8mn_evk.h b/include/configs/imx8mn_evk.h
index 034132225c6..805ae2a7518 100644
--- a/include/configs/imx8mn_evk.h
+++ b/include/configs/imx8mn_evk.h
@@ -75,7 +75,7 @@
 #define PHYS_SDRAM                      0x40000000
 #define PHYS_SDRAM_SIZE			0x80000000 /* 2GB DDR */
 
-#define CONFIG_MXC_UART_BASE		UART2_BASE_ADDR
+#define CONFIG_MXC_UART_BASE		UART_BASE_ADDR(2)
 
 /* Monitor Command Prompt */
 #define CONFIG_SYS_CBSIZE		2048
diff --git a/include/configs/imx8mn_var_som.h b/include/configs/imx8mn_var_som.h
index 318289b76bc..00358892b28 100644
--- a/include/configs/imx8mn_var_som.h
+++ b/include/configs/imx8mn_var_som.h
@@ -64,7 +64,7 @@
 #define PHYS_SDRAM			0x40000000
 #define PHYS_SDRAM_SIZE			SZ_1G /* 1GB DDR */
 
-#define CONFIG_MXC_UART_BASE		UART4_BASE_ADDR
+#define CONFIG_MXC_UART_BASE		UART_BASE_ADDR(4)
 
 /* Monitor Command Prompt */
 #define CONFIG_SYS_CBSIZE		SZ_2K
diff --git a/include/configs/imx8mn_venice.h b/include/configs/imx8mn_venice.h
index a4826779022..dcb5baf6eb4 100644
--- a/include/configs/imx8mn_venice.h
+++ b/include/configs/imx8mn_venice.h
@@ -98,7 +98,7 @@
 #define CONFIG_SYS_BOOTM_LEN		SZ_256M
 
 /* UART */
-#define CONFIG_MXC_UART_BASE		UART2_BASE_ADDR
+#define CONFIG_MXC_UART_BASE		UART_BASE_ADDR(2)
 
 /* Monitor Command Prompt */
 #define CONFIG_SYS_CBSIZE		SZ_2K
diff --git a/include/configs/imx8mp_evk.h b/include/configs/imx8mp_evk.h
index cc8d65cb54e..908ed76f39e 100644
--- a/include/configs/imx8mp_evk.h
+++ b/include/configs/imx8mp_evk.h
@@ -80,7 +80,7 @@
 #define PHYS_SDRAM_2			0x100000000
 #define PHYS_SDRAM_2_SIZE		0xC0000000	/* 3 GB */
 
-#define CONFIG_MXC_UART_BASE		UART2_BASE_ADDR
+#define CONFIG_MXC_UART_BASE		UART_BASE_ADDR(2)
 
 /* Monitor Command Prompt */
 #define CONFIG_SYS_CBSIZE		2048
diff --git a/include/configs/imx8mp_rsb3720.h b/include/configs/imx8mp_rsb3720.h
index c5dd545471e..c0f2824fd4c 100644
--- a/include/configs/imx8mp_rsb3720.h
+++ b/include/configs/imx8mp_rsb3720.h
@@ -169,7 +169,7 @@
 #define PHYS_SDRAM_2_SIZE		0x80000000	/* 2 GB */
 #endif
 
-#define CONFIG_MXC_UART_BASE		UART3_BASE_ADDR
+#define CONFIG_MXC_UART_BASE		UART_BASE_ADDR(3)
 
 /* Monitor Command Prompt */
 #define CONFIG_SYS_CBSIZE		2048
diff --git a/include/configs/imx8mq_cm.h b/include/configs/imx8mq_cm.h
index 989486aa6dc..6eecfc813a4 100644
--- a/include/configs/imx8mq_cm.h
+++ b/include/configs/imx8mq_cm.h
@@ -71,7 +71,7 @@
 #define PHYS_SDRAM                      0x40000000
 #define PHYS_SDRAM_SIZE					0x40000000 /* 1 GB DDR */
 
-#define CONFIG_MXC_UART_BASE		UART1_BASE_ADDR
+#define CONFIG_MXC_UART_BASE		UART_BASE_ADDR(1)
 
 /* Monitor Command Prompt */
 #define CONFIG_SYS_CBSIZE		1024
diff --git a/include/configs/imx8mq_evk.h b/include/configs/imx8mq_evk.h
index f7929e5867e..8596d999257 100644
--- a/include/configs/imx8mq_evk.h
+++ b/include/configs/imx8mq_evk.h
@@ -78,7 +78,7 @@
 #define PHYS_SDRAM                      0x40000000
 #define PHYS_SDRAM_SIZE			0xC0000000 /* 3GB DDR */
 
-#define CONFIG_MXC_UART_BASE		UART1_BASE_ADDR
+#define CONFIG_MXC_UART_BASE		UART_BASE_ADDR(1)
 
 /* Monitor Command Prompt */
 #define CONFIG_SYS_CBSIZE		1024
diff --git a/include/configs/imx8mq_phanbell.h b/include/configs/imx8mq_phanbell.h
index f6410114b76..9cf779b0752 100644
--- a/include/configs/imx8mq_phanbell.h
+++ b/include/configs/imx8mq_phanbell.h
@@ -106,7 +106,7 @@
 #define PHYS_SDRAM                      0x40000000
 #define PHYS_SDRAM_SIZE			0x40000000 /* 1GB DDR */
 
-#define CONFIG_MXC_UART_BASE		UART1_BASE_ADDR
+#define CONFIG_MXC_UART_BASE		UART_BASE_ADDR(1)
 
 /* Monitor Command Prompt */
 #define CONFIG_SYS_CBSIZE		1024
diff --git a/include/configs/kontron-sl-mx8mm.h b/include/configs/kontron-sl-mx8mm.h
index 1b429f7dbe2..8b2a10dda1f 100644
--- a/include/configs/kontron-sl-mx8mm.h
+++ b/include/configs/kontron-sl-mx8mm.h
@@ -28,7 +28,7 @@
 	(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET)
 
 /* Board and environment settings */
-#define CONFIG_MXC_UART_BASE		UART3_BASE_ADDR
+#define CONFIG_MXC_UART_BASE		UART_BASE_ADDR(3)
 #define CONFIG_HOSTNAME			"kontron-mx8mm"
 
 #ifdef CONFIG_USB_EHCI_HCD
diff --git a/include/configs/kontron_pitx_imx8m.h b/include/configs/kontron_pitx_imx8m.h
index e8e92920dcb..182ee590318 100644
--- a/include/configs/kontron_pitx_imx8m.h
+++ b/include/configs/kontron_pitx_imx8m.h
@@ -84,7 +84,7 @@
 #define PHYS_SDRAM                      0x40000000
 #define PHYS_SDRAM_SIZE			0xC0000000 /* 3GB DDR */
 
-#define CONFIG_MXC_UART_BASE		UART3_BASE_ADDR
+#define CONFIG_MXC_UART_BASE		UART_BASE_ADDR(3)
 
 #define CONFIG_SYS_FSL_USDHC_NUM	2
 #define CONFIG_SYS_FSL_ESDHC_ADDR       0
diff --git a/include/configs/phycore_imx8mm.h b/include/configs/phycore_imx8mm.h
index 71f0c42ec0c..46fadd56106 100644
--- a/include/configs/phycore_imx8mm.h
+++ b/include/configs/phycore_imx8mm.h
@@ -84,7 +84,7 @@
 #define PHYS_SDRAM_SIZE                 SZ_2G /* 2GB DDR */
 
 /* UART */
-#define CONFIG_MXC_UART_BASE		UART3_BASE_ADDR
+#define CONFIG_MXC_UART_BASE		UART_BASE_ADDR(3)
 
 /* Monitor Command Prompt */
 #define CONFIG_SYS_CBSIZE		SZ_2K
diff --git a/include/configs/phycore_imx8mp.h b/include/configs/phycore_imx8mp.h
index 0c963b62b3b..eb92c423392 100644
--- a/include/configs/phycore_imx8mp.h
+++ b/include/configs/phycore_imx8mp.h
@@ -84,7 +84,7 @@
 #define PHYS_SDRAM_SIZE			0x80000000
 
 /* UART */
-#define CONFIG_MXC_UART_BASE		UART1_BASE_ADDR
+#define CONFIG_MXC_UART_BASE		UART_BASE_ADDR(1)
 
 /* Monitor Command Prompt */
 #define CONFIG_SYS_CBSIZE		SZ_2K
diff --git a/include/configs/pico-imx8mq.h b/include/configs/pico-imx8mq.h
index 95845276e7b..567b06c4f5d 100644
--- a/include/configs/pico-imx8mq.h
+++ b/include/configs/pico-imx8mq.h
@@ -85,7 +85,7 @@
 #define PHYS_SDRAM			0x40000000
 #define PHYS_SDRAM_SIZE			0x80000000	/* 2 GiB DDR */
 
-#define CONFIG_MXC_UART_BASE		UART1_BASE_ADDR
+#define CONFIG_MXC_UART_BASE		UART_BASE_ADDR(1)
 
 /* Monitor Command Prompt */
 #define CONFIG_SYS_CBSIZE		1024
diff --git a/include/configs/verdin-imx8mm.h b/include/configs/verdin-imx8mm.h
index da3dc95f9ee..130a1ed54d1 100644
--- a/include/configs/verdin-imx8mm.h
+++ b/include/configs/verdin-imx8mm.h
@@ -84,7 +84,7 @@
 #define PHYS_SDRAM_SIZE			SZ_2G /* 2GB DDR */
 
 /* UART */
-#define CONFIG_MXC_UART_BASE		UART1_BASE_ADDR
+#define CONFIG_MXC_UART_BASE		UART_BASE_ADDR(1)
 
 /* Monitor Command Prompt */
 #define CONFIG_SYS_CBSIZE		SZ_2K
diff --git a/include/configs/verdin-imx8mp.h b/include/configs/verdin-imx8mp.h
index 7b7407752c1..33cfd3d2d73 100644
--- a/include/configs/verdin-imx8mp.h
+++ b/include/configs/verdin-imx8mp.h
@@ -101,7 +101,7 @@
 #define PHYS_SDRAM_2_SIZE		(SZ_4G + SZ_1G)
 
 /* UART */
-#define CONFIG_MXC_UART_BASE		UART3_BASE_ADDR
+#define CONFIG_MXC_UART_BASE		UART_BASE_ADDR(3)
 
 /* Monitor Command Prompt */
 #define CONFIG_SYS_CBSIZE		SZ_2K
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 2/4] ARM: imx: imx27: Introduce and use UART_BASE_ADDR(n)
  2022-04-24 21:44 [PATCH 1/4] ARM: imx: imx8m: Introduce and use UART_BASE_ADDR(n) Marek Vasut
@ 2022-04-24 21:44 ` Marek Vasut
  2022-05-20 13:41   ` sbabic
  2022-04-24 21:44 ` [PATCH 3/4] ARM: imx: imx31: " Marek Vasut
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 17+ messages in thread
From: Marek Vasut @ 2022-04-24 21:44 UTC (permalink / raw)
  To: u-boot; +Cc: Marek Vasut, Fabio Estevam, Peng Fan, Stefano Babic

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>
---
 arch/arm/include/asm/arch-mx27/imx-regs.h | 24 +++++++++++++++++------
 include/configs/imx27lite-common.h        |  2 +-
 2 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/arch/arm/include/asm/arch-mx27/imx-regs.h b/arch/arm/include/asm/arch-mx27/imx-regs.h
index d39f6b03508..77794d7d03d 100644
--- a/arch/arm/include/asm/arch-mx27/imx-regs.h
+++ b/arch/arm/include/asm/arch-mx27/imx-regs.h
@@ -179,16 +179,16 @@ struct fuse_bank0_regs {
 #define IMX_TIM2_BASE		(0x04000 + IMX_IO_BASE)
 #define IMX_TIM3_BASE		(0x05000 + IMX_IO_BASE)
 #define IMX_RTC_BASE		(0x07000 + IMX_IO_BASE)
-#define UART1_BASE		(0x0a000 + IMX_IO_BASE)
-#define UART2_BASE		(0x0b000 + IMX_IO_BASE)
-#define UART3_BASE		(0x0c000 + IMX_IO_BASE)
-#define UART4_BASE		(0x0d000 + IMX_IO_BASE)
+#define UART1_BASE_ADDR		(0x0a000 + IMX_IO_BASE)
+#define UART2_BASE_ADDR		(0x0b000 + IMX_IO_BASE)
+#define UART3_BASE_ADDR		(0x0c000 + IMX_IO_BASE)
+#define UART4_BASE_ADDR		(0x0d000 + IMX_IO_BASE)
 #define I2C1_BASE_ADDR		(0x12000 + IMX_IO_BASE)
 #define IMX_GPIO_BASE		(0x15000 + IMX_IO_BASE)
 #define IMX_TIM4_BASE		(0x19000 + IMX_IO_BASE)
 #define IMX_TIM5_BASE		(0x1a000 + IMX_IO_BASE)
-#define IMX_UART5_BASE		(0x1b000 + IMX_IO_BASE)
-#define IMX_UART6_BASE		(0x1c000 + IMX_IO_BASE)
+#define UART5_BASE_ADDR		(0x1b000 + IMX_IO_BASE)
+#define UART6_BASE_ADDR		(0x1c000 + IMX_IO_BASE)
 #define I2C2_BASE_ADDR		(0x1D000 + IMX_IO_BASE)
 #define IMX_TIM6_BASE		(0x1f000 + IMX_IO_BASE)
 #define IMX_AIPI2_BASE		(0x20000 + IMX_IO_BASE)
@@ -204,6 +204,18 @@ struct fuse_bank0_regs {
 
 #define NFC_BASE_ADDR		IMX_NFC_BASE
 
+#define UART_BASE_ADDR(n)	(			\
+	!!sizeof(struct {				\
+		static_assert((n) >= 1 && (n) <= 6);	\
+		int pad;				\
+		}) * (					\
+	(n) == 1 ? UART1_BASE_ADDR :			\
+	(n) == 2 ? UART2_BASE_ADDR :			\
+	(n) == 3 ? UART3_BASE_ADDR :			\
+	(n) == 4 ? UART4_BASE_ADDR :			\
+	(n) == 5 ? UART5_BASE_ADDR :			\
+	UART6_BASE_ADDR)				\
+	)
 
 /* FMCR System Control bit definition*/
 #define UART4_RXD_CTL	(1 << 25)
diff --git a/include/configs/imx27lite-common.h b/include/configs/imx27lite-common.h
index bb53a33a542..6790053bb8d 100644
--- a/include/configs/imx27lite-common.h
+++ b/include/configs/imx27lite-common.h
@@ -70,7 +70,7 @@
 /*
  * Serial Driver info
  */
-#define CONFIG_MXC_UART_BASE	UART1_BASE
+#define CONFIG_MXC_UART_BASE	UART_BASE_ADDR(1)
 
 /*
  * Flash & Environment
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 3/4] ARM: imx: imx31: Introduce and use UART_BASE_ADDR(n)
  2022-04-24 21:44 [PATCH 1/4] ARM: imx: imx8m: Introduce and use UART_BASE_ADDR(n) Marek Vasut
  2022-04-24 21:44 ` [PATCH 2/4] ARM: imx: imx27: " Marek Vasut
@ 2022-04-24 21:44 ` Marek Vasut
  2022-05-20 13:40   ` sbabic
  2022-04-24 21:44 ` [PATCH 4/4] ARM: imx: imx5: " Marek Vasut
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 17+ messages in thread
From: Marek Vasut @ 2022-04-24 21:44 UTC (permalink / raw)
  To: u-boot; +Cc: Marek Vasut, Fabio Estevam, Peng Fan, Stefano Babic

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>
---
 arch/arm/include/asm/arch-mx31/imx-regs.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/include/asm/arch-mx31/imx-regs.h b/arch/arm/include/asm/arch-mx31/imx-regs.h
index 566db549ec6..d5c0ed8e6c2 100644
--- a/arch/arm/include/asm/arch-mx31/imx-regs.h
+++ b/arch/arm/include/asm/arch-mx31/imx-regs.h
@@ -598,6 +598,18 @@ struct esdc_regs {
 #define UART4_BASE	0x43FB0000
 #define UART5_BASE	0x43FB4000
 
+#define UART_BASE_ADDR(n)	(			\
+	!!sizeof(struct {				\
+		static_assert((n) >= 1 && (n) <= 5);	\
+		int pad;				\
+		}) * (					\
+	(n) == 1 ? UART1_BASE :				\
+	(n) == 2 ? UART2_BASE :				\
+	(n) == 3 ? UART3_BASE :				\
+	(n) == 4 ? UART4_BASE :				\
+	UART5_BASE_ADDR)				\
+	)
+
 #define I2C1_BASE_ADDR          0x43f80000
 #define I2C1_CLK_OFFSET		26
 #define I2C2_BASE_ADDR          0x43F98000
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 4/4] ARM: imx: imx5: Introduce and use UART_BASE_ADDR(n)
  2022-04-24 21:44 [PATCH 1/4] ARM: imx: imx8m: Introduce and use UART_BASE_ADDR(n) Marek Vasut
  2022-04-24 21:44 ` [PATCH 2/4] ARM: imx: imx27: " Marek Vasut
  2022-04-24 21:44 ` [PATCH 3/4] ARM: imx: imx31: " Marek Vasut
@ 2022-04-24 21:44 ` Marek Vasut
  2022-05-20  7:30   ` Stefano Babic
  2022-04-25 12:46 ` [PATCH 1/4] ARM: imx: imx8m: " Fabio Estevam
  2022-05-20 13:42 ` sbabic
  4 siblings, 1 reply; 17+ messages in thread
From: Marek Vasut @ 2022-04-24 21:44 UTC (permalink / raw)
  To: u-boot; +Cc: Marek Vasut, Fabio Estevam, Peng Fan, Stefano Babic

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>
---
 arch/arm/include/asm/arch-mx5/imx-regs.h | 23 +++++++++++++++++++++++
 include/configs/mx51evk.h                |  2 +-
 include/configs/mx53cx9020.h             |  2 +-
 include/configs/mx53loco.h               |  2 +-
 include/configs/usbarmory.h              |  2 +-
 5 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/arch/arm/include/asm/arch-mx5/imx-regs.h b/arch/arm/include/asm/arch-mx5/imx-regs.h
index f763749b03c..856bc07e8ae 100644
--- a/arch/arm/include/asm/arch-mx5/imx-regs.h
+++ b/arch/arm/include/asm/arch-mx5/imx-regs.h
@@ -125,6 +125,29 @@
 
 #if defined(CONFIG_MX53)
 #define UART5_BASE_ADDR         (AIPS2_BASE_ADDR + 0x00090000)
+
+#define UART_BASE_ADDR(n)	(			\
+	!!sizeof(struct {				\
+		static_assert((n) >= 1 && (n) <= 5);	\
+		int pad;				\
+		}) * (					\
+	(n) == 1 ? UART1_BASE :				\
+	(n) == 2 ? UART2_BASE :				\
+	(n) == 3 ? UART3_BASE :				\
+	(n) == 4 ? UART4_BASE_ADDR :			\
+	UART5_BASE_ADDR)				\
+	)
+#else	/* i.MX51 */
+#define UART_BASE_ADDR(n)	(			\
+	!!sizeof(struct {				\
+		static_assert((n) >= 1 && (n) <= 4);	\
+		int pad;				\
+		}) * (					\
+	(n) == 1 ? UART1_BASE :				\
+	(n) == 2 ? UART2_BASE :				\
+	(n) == 3 ? UART3_BASE :				\
+	UART4_BASE_ADDR)				\
+	)
 #endif
 
 /*
diff --git a/include/configs/mx51evk.h b/include/configs/mx51evk.h
index ccfe292f6c6..814202e48d0 100644
--- a/include/configs/mx51evk.h
+++ b/include/configs/mx51evk.h
@@ -19,7 +19,7 @@
  */
 #define CONFIG_FSL_IIM
 
-#define CONFIG_MXC_UART_BASE	UART1_BASE
+#define CONFIG_MXC_UART_BASE	UART_BASE_ADDR(1)
 
 /* PMIC Controller */
 #define CONFIG_POWER_SPI
diff --git a/include/configs/mx53cx9020.h b/include/configs/mx53cx9020.h
index fafc5f1adcb..9f2259d2981 100644
--- a/include/configs/mx53cx9020.h
+++ b/include/configs/mx53cx9020.h
@@ -14,7 +14,7 @@
 
 #include <asm/arch/imx-regs.h>
 
-#define CONFIG_MXC_UART_BASE UART2_BASE
+#define CONFIG_MXC_UART_BASE UART_BASE_ADDR(2)
 
 #define CONFIG_FPGA_COUNT 1
 
diff --git a/include/configs/mx53loco.h b/include/configs/mx53loco.h
index 8b9f0a29017..9851f64ee9f 100644
--- a/include/configs/mx53loco.h
+++ b/include/configs/mx53loco.h
@@ -11,7 +11,7 @@
 
 #include <asm/arch/imx-regs.h>
 
-#define CONFIG_MXC_UART_BASE	UART1_BASE
+#define CONFIG_MXC_UART_BASE	UART_BASE_ADDR(1)
 
 /* MMC Configs */
 #define CONFIG_SYS_FSL_ESDHC_ADDR	0
diff --git a/include/configs/usbarmory.h b/include/configs/usbarmory.h
index 0faa656bc63..98b289e7ff1 100644
--- a/include/configs/usbarmory.h
+++ b/include/configs/usbarmory.h
@@ -18,7 +18,7 @@
 #define CONFIG_SYS_CBSIZE	512
 
 /* UART */
-#define CONFIG_MXC_UART_BASE	UART1_BASE
+#define CONFIG_MXC_UART_BASE	UART_BASE_ADDR(1)
 
 /* SD/MMC */
 #define CONFIG_SYS_FSL_ESDHC_ADDR	0
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/4] ARM: imx: imx8m: Introduce and use UART_BASE_ADDR(n)
  2022-04-24 21:44 [PATCH 1/4] ARM: imx: imx8m: Introduce and use UART_BASE_ADDR(n) Marek Vasut
                   ` (2 preceding siblings ...)
  2022-04-24 21:44 ` [PATCH 4/4] ARM: imx: imx5: " Marek Vasut
@ 2022-04-25 12:46 ` Fabio Estevam
  2022-04-25 13:02   ` Marek Vasut
  2022-05-20 13:42 ` sbabic
  4 siblings, 1 reply; 17+ messages in thread
From: Fabio Estevam @ 2022-04-25 12:46 UTC (permalink / raw)
  To: Marek Vasut; +Cc: u-boot, Peng Fan, Stefano Babic, trini

Hi Marek,

On 24/04/2022 18:44, Marek Vasut wrote:
> 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.

As DM_SERIAL is mandatory now, we should get rid of 
CONFIG_MXC_UART_BASE.

I would prefer a patch that removes CONFIG_MXC_UART_BASE instead.

Regards,

Fabio Estevam

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/4] ARM: imx: imx8m: Introduce and use UART_BASE_ADDR(n)
  2022-04-25 12:46 ` [PATCH 1/4] ARM: imx: imx8m: " Fabio Estevam
@ 2022-04-25 13:02   ` Marek Vasut
  2022-04-25 13:05     ` Tom Rini
  0 siblings, 1 reply; 17+ messages in thread
From: Marek Vasut @ 2022-04-25 13:02 UTC (permalink / raw)
  To: Fabio Estevam; +Cc: u-boot, Peng Fan, Stefano Babic, trini

On 4/25/22 14:46, Fabio Estevam wrote:
> Hi Marek,
> 
> On 24/04/2022 18:44, Marek Vasut wrote:
>> 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.
> 
> As DM_SERIAL is mandatory now, we should get rid of CONFIG_MXC_UART_BASE.
> 
> I would prefer a patch that removes CONFIG_MXC_UART_BASE instead.

DM is mandatory in SPL too ? I doubt it.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/4] ARM: imx: imx8m: Introduce and use UART_BASE_ADDR(n)
  2022-04-25 13:02   ` Marek Vasut
@ 2022-04-25 13:05     ` Tom Rini
  2022-04-25 13:13       ` Marek Vasut
  2022-04-25 13:15       ` Fabio Estevam
  0 siblings, 2 replies; 17+ messages in thread
From: Tom Rini @ 2022-04-25 13:05 UTC (permalink / raw)
  To: Marek Vasut; +Cc: Fabio Estevam, u-boot, Peng Fan, Stefano Babic

[-- Attachment #1: Type: text/plain, Size: 1030 bytes --]

On Mon, Apr 25, 2022 at 03:02:29PM +0200, Marek Vasut wrote:
> On 4/25/22 14:46, Fabio Estevam wrote:
> > Hi Marek,
> > 
> > On 24/04/2022 18:44, Marek Vasut wrote:
> > > 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.
> > 
> > As DM_SERIAL is mandatory now, we should get rid of CONFIG_MXC_UART_BASE.
> > 
> > I would prefer a patch that removes CONFIG_MXC_UART_BASE instead.
> 
> DM is mandatory in SPL too ? I doubt it.

It is strongly encouraged, but not mandatory.  It is not used on I guess
imx27/31/5, but is for all of the imx8 families.  So
CONFIG_MXC_UART_BASE still needs to be moved out of board.h files (and
perhaps out of CONFIG namespace since it's not configurable, it's part
of the SoC) and perhaps the path for imx8* is to drop the references
since it's all DM?

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/4] ARM: imx: imx8m: Introduce and use UART_BASE_ADDR(n)
  2022-04-25 13:05     ` Tom Rini
@ 2022-04-25 13:13       ` Marek Vasut
  2022-04-25 13:39         ` Tom Rini
  2022-04-25 13:15       ` Fabio Estevam
  1 sibling, 1 reply; 17+ messages in thread
From: Marek Vasut @ 2022-04-25 13:13 UTC (permalink / raw)
  To: Tom Rini; +Cc: Fabio Estevam, u-boot, Peng Fan, Stefano Babic

On 4/25/22 15:05, Tom Rini wrote:
> On Mon, Apr 25, 2022 at 03:02:29PM +0200, Marek Vasut wrote:
>> On 4/25/22 14:46, Fabio Estevam wrote:
>>> Hi Marek,
>>>
>>> On 24/04/2022 18:44, Marek Vasut wrote:
>>>> 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.
>>>
>>> As DM_SERIAL is mandatory now, we should get rid of CONFIG_MXC_UART_BASE.
>>>
>>> I would prefer a patch that removes CONFIG_MXC_UART_BASE instead.
>>
>> DM is mandatory in SPL too ? I doubt it.
> 
> It is strongly encouraged, but not mandatory.  It is not used on I guess
> imx27/31/5, but is for all of the imx8 families.  So
> CONFIG_MXC_UART_BASE still needs to be moved out of board.h files (and
> perhaps out of CONFIG namespace since it's not configurable, it's part
> of the SoC) and perhaps the path for imx8* is to drop the references
> since it's all DM?

MX8M SPL is not DM serial either. But I think I will just postpone this 
cleanup until I have time to finish it.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/4] ARM: imx: imx8m: Introduce and use UART_BASE_ADDR(n)
  2022-04-25 13:05     ` Tom Rini
  2022-04-25 13:13       ` Marek Vasut
@ 2022-04-25 13:15       ` Fabio Estevam
  1 sibling, 0 replies; 17+ messages in thread
From: Fabio Estevam @ 2022-04-25 13:15 UTC (permalink / raw)
  To: Tom Rini; +Cc: Marek Vasut, u-boot, Peng Fan, Stefano Babic

On 25/04/2022 10:05, Tom Rini wrote:

>> DM is mandatory in SPL too ? I doubt it.
> 
> It is strongly encouraged, but not mandatory.  It is not used on I 
> guess
> imx27/31/5, but is for all of the imx8 families.  So
> CONFIG_MXC_UART_BASE still needs to be moved out of board.h files (and
> perhaps out of CONFIG namespace since it's not configurable, it's part
> of the SoC) and perhaps the path for imx8* is to drop the references
> since it's all DM?

Correct. In the defconfigs where CONFIG_DM_SERIAL=y and CONFIG_SPL_DM=y
are selected the CONFIG_MXC_UART_BASE can be safely dropped.

Regards,

Fabio Estevam

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/4] ARM: imx: imx8m: Introduce and use UART_BASE_ADDR(n)
  2022-04-25 13:13       ` Marek Vasut
@ 2022-04-25 13:39         ` Tom Rini
  0 siblings, 0 replies; 17+ messages in thread
From: Tom Rini @ 2022-04-25 13:39 UTC (permalink / raw)
  To: Marek Vasut; +Cc: Fabio Estevam, u-boot, Peng Fan, Stefano Babic

[-- Attachment #1: Type: text/plain, Size: 1397 bytes --]

On Mon, Apr 25, 2022 at 03:13:53PM +0200, Marek Vasut wrote:
> On 4/25/22 15:05, Tom Rini wrote:
> > On Mon, Apr 25, 2022 at 03:02:29PM +0200, Marek Vasut wrote:
> > > On 4/25/22 14:46, Fabio Estevam wrote:
> > > > Hi Marek,
> > > > 
> > > > On 24/04/2022 18:44, Marek Vasut wrote:
> > > > > 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.
> > > > 
> > > > As DM_SERIAL is mandatory now, we should get rid of CONFIG_MXC_UART_BASE.
> > > > 
> > > > I would prefer a patch that removes CONFIG_MXC_UART_BASE instead.
> > > 
> > > DM is mandatory in SPL too ? I doubt it.
> > 
> > It is strongly encouraged, but not mandatory.  It is not used on I guess
> > imx27/31/5, but is for all of the imx8 families.  So
> > CONFIG_MXC_UART_BASE still needs to be moved out of board.h files (and
> > perhaps out of CONFIG namespace since it's not configurable, it's part
> > of the SoC) and perhaps the path for imx8* is to drop the references
> > since it's all DM?
> 
> MX8M SPL is not DM serial either. But I think I will just postpone this
> cleanup until I have time to finish it.

Right, sorry, I meant DM enabled in SPL to start with.

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 4/4] ARM: imx: imx5: Introduce and use UART_BASE_ADDR(n)
  2022-04-24 21:44 ` [PATCH 4/4] ARM: imx: imx5: " Marek Vasut
@ 2022-05-20  7:30   ` Stefano Babic
  2022-05-20  7:45     ` Marek Vasut
  0 siblings, 1 reply; 17+ messages in thread
From: Stefano Babic @ 2022-05-20  7:30 UTC (permalink / raw)
  To: Marek Vasut, u-boot; +Cc: Fabio Estevam, Peng Fan, Stefano Babic

Hi Marek,

On 24.04.22 23:44, Marek Vasut wrote:
> 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>
> ---

I have not found the reason, but this breaks MX51:

https://source.denx.de/u-boot/custodians/u-boot-imx/-/jobs/436880

Regards,
Stefano


>   arch/arm/include/asm/arch-mx5/imx-regs.h | 23 +++++++++++++++++++++++
>   include/configs/mx51evk.h                |  2 +-
>   include/configs/mx53cx9020.h             |  2 +-
>   include/configs/mx53loco.h               |  2 +-
>   include/configs/usbarmory.h              |  2 +-
>   5 files changed, 27 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/arm/include/asm/arch-mx5/imx-regs.h b/arch/arm/include/asm/arch-mx5/imx-regs.h
> index f763749b03c..856bc07e8ae 100644
> --- a/arch/arm/include/asm/arch-mx5/imx-regs.h
> +++ b/arch/arm/include/asm/arch-mx5/imx-regs.h
> @@ -125,6 +125,29 @@
>   
>   #if defined(CONFIG_MX53)
>   #define UART5_BASE_ADDR         (AIPS2_BASE_ADDR + 0x00090000)
> +
> +#define UART_BASE_ADDR(n)	(			\
> +	!!sizeof(struct {				\
> +		static_assert((n) >= 1 && (n) <= 5);	\
> +		int pad;				\
> +		}) * (					\
> +	(n) == 1 ? UART1_BASE :				\
> +	(n) == 2 ? UART2_BASE :				\
> +	(n) == 3 ? UART3_BASE :				\
> +	(n) == 4 ? UART4_BASE_ADDR :			\
> +	UART5_BASE_ADDR)				\
> +	)
> +#else	/* i.MX51 */
> +#define UART_BASE_ADDR(n)	(			\
> +	!!sizeof(struct {				\
> +		static_assert((n) >= 1 && (n) <= 4);	\
> +		int pad;				\
> +		}) * (					\
> +	(n) == 1 ? UART1_BASE :				\
> +	(n) == 2 ? UART2_BASE :				\
> +	(n) == 3 ? UART3_BASE :				\
> +	UART4_BASE_ADDR)				\
> +	)
>   #endif
>   
>   /*
> diff --git a/include/configs/mx51evk.h b/include/configs/mx51evk.h
> index ccfe292f6c6..814202e48d0 100644
> --- a/include/configs/mx51evk.h
> +++ b/include/configs/mx51evk.h
> @@ -19,7 +19,7 @@
>    */
>   #define CONFIG_FSL_IIM
>   
> -#define CONFIG_MXC_UART_BASE	UART1_BASE
> +#define CONFIG_MXC_UART_BASE	UART_BASE_ADDR(1)
>   
>   /* PMIC Controller */
>   #define CONFIG_POWER_SPI
> diff --git a/include/configs/mx53cx9020.h b/include/configs/mx53cx9020.h
> index fafc5f1adcb..9f2259d2981 100644
> --- a/include/configs/mx53cx9020.h
> +++ b/include/configs/mx53cx9020.h
> @@ -14,7 +14,7 @@
>   
>   #include <asm/arch/imx-regs.h>
>   
> -#define CONFIG_MXC_UART_BASE UART2_BASE
> +#define CONFIG_MXC_UART_BASE UART_BASE_ADDR(2)
>   
>   #define CONFIG_FPGA_COUNT 1
>   
> diff --git a/include/configs/mx53loco.h b/include/configs/mx53loco.h
> index 8b9f0a29017..9851f64ee9f 100644
> --- a/include/configs/mx53loco.h
> +++ b/include/configs/mx53loco.h
> @@ -11,7 +11,7 @@
>   
>   #include <asm/arch/imx-regs.h>
>   
> -#define CONFIG_MXC_UART_BASE	UART1_BASE
> +#define CONFIG_MXC_UART_BASE	UART_BASE_ADDR(1)
>   
>   /* MMC Configs */
>   #define CONFIG_SYS_FSL_ESDHC_ADDR	0
> diff --git a/include/configs/usbarmory.h b/include/configs/usbarmory.h
> index 0faa656bc63..98b289e7ff1 100644
> --- a/include/configs/usbarmory.h
> +++ b/include/configs/usbarmory.h
> @@ -18,7 +18,7 @@
>   #define CONFIG_SYS_CBSIZE	512
>   
>   /* UART */
> -#define CONFIG_MXC_UART_BASE	UART1_BASE
> +#define CONFIG_MXC_UART_BASE	UART_BASE_ADDR(1)
>   
>   /* SD/MMC */
>   #define CONFIG_SYS_FSL_ESDHC_ADDR	0

-- 
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic@denx.de
=====================================================================

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 4/4] ARM: imx: imx5: Introduce and use UART_BASE_ADDR(n)
  2022-05-20  7:30   ` Stefano Babic
@ 2022-05-20  7:45     ` Marek Vasut
  2022-05-20  8:11       ` Stefano Babic
  0 siblings, 1 reply; 17+ messages in thread
From: Marek Vasut @ 2022-05-20  7:45 UTC (permalink / raw)
  To: Stefano Babic, u-boot; +Cc: Fabio Estevam, Peng Fan

On 5/20/22 09:30, Stefano Babic wrote:
> Hi Marek,
> 
> On 24.04.22 23:44, Marek Vasut wrote:
>> 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>
>> ---
> 
> I have not found the reason, but this breaks MX51:

All this UART_BASE_ADDR stuff is postponed, just drop for now.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 4/4] ARM: imx: imx5: Introduce and use UART_BASE_ADDR(n)
  2022-05-20  7:45     ` Marek Vasut
@ 2022-05-20  8:11       ` Stefano Babic
  2022-05-20  8:18         ` Stefano Babic
  0 siblings, 1 reply; 17+ messages in thread
From: Stefano Babic @ 2022-05-20  8:11 UTC (permalink / raw)
  To: Marek Vasut, Stefano Babic, u-boot; +Cc: Fabio Estevam, Peng Fan

On 20.05.22 09:45, Marek Vasut wrote:
> On 5/20/22 09:30, Stefano Babic wrote:
>> Hi Marek,
>>
>> On 24.04.22 23:44, Marek Vasut wrote:
>>> 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>
>>> ---
>>
>> I have not found the reason, but this breaks MX51:
> 
> All this UART_BASE_ADDR stuff is postponed, just drop for now.


Ok, understood - I remove them.

Best regards,
Stefano

-- 
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic@denx.de
=====================================================================

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 4/4] ARM: imx: imx5: Introduce and use UART_BASE_ADDR(n)
  2022-05-20  8:11       ` Stefano Babic
@ 2022-05-20  8:18         ` Stefano Babic
  0 siblings, 0 replies; 17+ messages in thread
From: Stefano Babic @ 2022-05-20  8:18 UTC (permalink / raw)
  To: Stefano Babic, Marek Vasut, u-boot; +Cc: Fabio Estevam, Peng Fan

On 20.05.22 10:11, Stefano Babic wrote:
> On 20.05.22 09:45, Marek Vasut wrote:
>> On 5/20/22 09:30, Stefano Babic wrote:
>>> Hi Marek,
>>>
>>> On 24.04.22 23:44, Marek Vasut wrote:
>>>> 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>
>>>> ---
>>>
>>> I have not found the reason, but this breaks MX51:
>>
>> All this UART_BASE_ADDR stuff is postponed, just drop for now.
> 
> 
> Ok, understood - I remove them.

Well, there is at least one patch depending on this:

http://patchwork.ozlabs.org/project/uboot/patch/20220505074341.24086-2-peng.fan@oss.nxp.com/

I will first try just to remove the i.MX5 patch, it seems to me that the 
MX51 is the only architecture that cannot be built.

Regards,
Stefano

> 
> Best regards,
> Stefano
> 


-- 
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic@denx.de
=====================================================================

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 3/4] ARM: imx: imx31: Introduce and use UART_BASE_ADDR(n)
  2022-04-24 21:44 ` [PATCH 3/4] ARM: imx: imx31: " Marek Vasut
@ 2022-05-20 13:40   ` sbabic
  0 siblings, 0 replies; 17+ messages in thread
From: sbabic @ 2022-05-20 13:40 UTC (permalink / raw)
  To: Marek Vasut, u-boot

> 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>
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

-- 
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic@denx.de
=====================================================================

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 2/4] ARM: imx: imx27: Introduce and use UART_BASE_ADDR(n)
  2022-04-24 21:44 ` [PATCH 2/4] ARM: imx: imx27: " Marek Vasut
@ 2022-05-20 13:41   ` sbabic
  0 siblings, 0 replies; 17+ messages in thread
From: sbabic @ 2022-05-20 13:41 UTC (permalink / raw)
  To: Marek Vasut, u-boot

> 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>
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

-- 
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic@denx.de
=====================================================================

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 1/4] ARM: imx: imx8m: Introduce and use UART_BASE_ADDR(n)
  2022-04-24 21:44 [PATCH 1/4] ARM: imx: imx8m: Introduce and use UART_BASE_ADDR(n) Marek Vasut
                   ` (3 preceding siblings ...)
  2022-04-25 12:46 ` [PATCH 1/4] ARM: imx: imx8m: " Fabio Estevam
@ 2022-05-20 13:42 ` sbabic
  4 siblings, 0 replies; 17+ messages in thread
From: sbabic @ 2022-05-20 13:42 UTC (permalink / raw)
  To: Marek Vasut, u-boot

> 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>
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

-- 
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic@denx.de
=====================================================================

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2022-05-20 13:46 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-24 21:44 [PATCH 1/4] ARM: imx: imx8m: Introduce and use UART_BASE_ADDR(n) Marek Vasut
2022-04-24 21:44 ` [PATCH 2/4] ARM: imx: imx27: " Marek Vasut
2022-05-20 13:41   ` sbabic
2022-04-24 21:44 ` [PATCH 3/4] ARM: imx: imx31: " Marek Vasut
2022-05-20 13:40   ` sbabic
2022-04-24 21:44 ` [PATCH 4/4] ARM: imx: imx5: " Marek Vasut
2022-05-20  7:30   ` Stefano Babic
2022-05-20  7:45     ` Marek Vasut
2022-05-20  8:11       ` Stefano Babic
2022-05-20  8:18         ` Stefano Babic
2022-04-25 12:46 ` [PATCH 1/4] ARM: imx: imx8m: " Fabio Estevam
2022-04-25 13:02   ` Marek Vasut
2022-04-25 13:05     ` Tom Rini
2022-04-25 13:13       ` Marek Vasut
2022-04-25 13:39         ` Tom Rini
2022-04-25 13:15       ` Fabio Estevam
2022-05-20 13:42 ` sbabic

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.