ARM: imx: imx8m: Introduce and use UART_BASE_ADDR(n)
Subsystems (2)
PATCH 1/4 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.
--- 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(-)
arch/arm/include/asm/arch-imx8m/imx-regs.h +10 -0
@@ -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
include/configs/imx8mm-cl-iot-gate.h +1 -1
@@ -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
include/configs/imx8mm_beacon.h +1 -1
@@ -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
include/configs/imx8mm_evk.h +1 -1
@@ -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
include/configs/imx8mm_icore_mx8mm.h +1 -1
@@ -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
include/configs/imx8mm_venice.h +1 -1
@@ -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
include/configs/imx8mn_beacon.h +1 -1
@@ -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
include/configs/imx8mn_evk.h +1 -1
@@ -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
include/configs/imx8mn_var_som.h +1 -1
@@ -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
include/configs/imx8mn_venice.h +1 -1
@@ -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
include/configs/imx8mp_evk.h +1 -1
@@ -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
include/configs/imx8mp_rsb3720.h +1 -1
@@ -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
include/configs/imx8mq_cm.h +1 -1
@@ -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
include/configs/imx8mq_evk.h +1 -1
@@ -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
include/configs/imx8mq_phanbell.h +1 -1
@@ -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
include/configs/kontron-sl-mx8mm.h +1 -1
@@ -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
include/configs/kontron_pitx_imx8m.h +1 -1
@@ -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
include/configs/phycore_imx8mm.h +1 -1
@@ -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
include/configs/phycore_imx8mp.h +1 -1
@@ -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
include/configs/pico-imx8mq.h +1 -1
@@ -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
include/configs/verdin-imx8mm.h +1 -1
@@ -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
include/configs/verdin-imx8mp.h +1 -1
@@ -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
Signature · 1 line
2.35.1
PATCH 2/4 ARM: imx: imx27: 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.
--- arch/arm/include/asm/arch-mx27/imx-regs.h | 24 +++++++++++++++++------ include/configs/imx27lite-common.h | 2 +- 2 files changed, 19 insertions(+), 7 deletions(-)
arch/arm/include/asm/arch-mx27/imx-regs.h +18 -6
@@ -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)
include/configs/imx27lite-common.h +1 -1
@@ -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
Signature · 1 line
2.35.1
PATCH 2/4 ARM: imx: imx27: Introduce and use UART_BASE_ADDR(n)
Quoted 13 lines
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 switchingCONFIG_MXC_UART_BASEtoKconfig. 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 usestatic_assertin compound statements, hence this convoluted construct.
Quoted 4 lines
Signed-off-by Marek Vasut <[email protected]>Cc Fabio Estevam <[email protected]>Cc Peng Fan <[email protected]>Cc Stefano Babic <[email protected]>
Applied to u-boot-imx, master, thanks !
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== 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: [email protected] =====================================================================
PATCH 3/4 ARM: imx: imx31: Introduce and use UART_BASE_ADDR(n)
In reply to Marek VasutIntroduce 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.
--- arch/arm/include/asm/arch-mx31/imx-regs.h | 12 ++++++++++++ 1 file changed, 12 insertions(+)
arch/arm/include/asm/arch-mx31/imx-regs.h +12 -0
@@ -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
Signature · 1 line
2.35.1
PATCH 3/4 ARM: imx: imx31: Introduce and use UART_BASE_ADDR(n)
Quoted 13 lines
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 switchingCONFIG_MXC_UART_BASEtoKconfig. 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 usestatic_assertin compound statements, hence this convoluted construct.
Quoted 4 lines
Signed-off-by Marek Vasut <[email protected]>Cc Fabio Estevam <[email protected]>Cc Peng Fan <[email protected]>Cc Stefano Babic <[email protected]>
Applied to u-boot-imx, master, thanks !
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== 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: [email protected] =====================================================================
PATCH 4/4 ARM: imx: imx5: Introduce and use UART_BASE_ADDR(n)
In reply to Marek VasutIntroduce 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.
--- 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(-)
arch/arm/include/asm/arch-mx5/imx-regs.h +23 -0
@@ -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 /*
include/configs/mx51evk.h +1 -1
@@ -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
include/configs/mx53cx9020.h +1 -1
@@ -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
include/configs/mx53loco.h +1 -1
@@ -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
include/configs/usbarmory.h +1 -1
@@ -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
Signature · 1 line
2.35.1
Re: [PATCH 4/4] ARM: imx: imx5: Introduce and use UART_BASE_ADDR(n)
Hi Marek,
Quoted 16 lines · Marek Vasut
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 switchingCONFIG_MXC_UART_BASEtoKconfig. 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 usestatic_assertin compound statements, hence this convoluted construct.
Quoted 5 lines
Signed-off-by Marek Vasut <[email protected]>Cc Fabio Estevam <[email protected]>Cc Peng Fan <[email protected]>Cc Stefano Babic <[email protected]>---
I have not found the reason, but this breaks MX51:
https://source.denx.de/u-boot/custodians/u-boot-imx/-/jobs/436880
Regards,
Stefano
Quoted 93 lines
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(-)arch/arm/include/asm/arch-mx5/imx-regs.h +23
-0@@ -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 /* include/configs/mx51evk.h +1
-1@@ -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 include/configs/mx53cx9020.h +1
-1@@ -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 1include/configs/mx53loco.h +1
-1@@ -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 0include/configs/usbarmory.h +1
-1@@ -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
Signature · 5 lines
===================================================================== 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: [email protected] =====================================================================
Re: [PATCH 4/4] ARM: imx: imx5: Introduce and use UART_BASE_ADDR(n)
Quoted 19 lines · Stefano Babic
Hi Marek,
Quoted 16 lines · Marek Vasut
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 switchingCONFIG_MXC_UART_BASEtoKconfig. 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 usestatic_assertin compound statements, hence this convoluted construct.
Quoted 7 lines
Quoted 5 lines
Signed-off-by Marek Vasut <[email protected]>Cc Fabio Estevam <[email protected]>Cc Peng Fan <[email protected]>Cc Stefano Babic <[email protected]>---
I have not found the reason, but this breaks MX51:
All this UART_BASE_ADDR stuff is postponed, just drop for now.
Re: [PATCH 4/4] ARM: imx: imx5: Introduce and use UART_BASE_ADDR(n)
Quoted 26 lines · Marek Vasut
Quoted 25 lines · Stefano Babic
Hi Marek,
Quoted 21 lines · Marek Vasut
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 switchingCONFIG_MXC_UART_BASEtoKconfig. 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 usestatic_assertin compound statements, hence this convoluted construct.Signed-off-by Marek Vasut <[email protected]>Cc Fabio Estevam <[email protected]>Cc Peng Fan <[email protected]>Cc Stefano Babic <[email protected]>---
Quoted 3 lines
Quoted 1 line
I have not found the reason, but this breaks MX51:
All this
UART_BASE_ADDRstuff is postponed, just drop for now.
Ok, understood - I remove them.
Best regards,
Stefano
Signature · 5 lines
===================================================================== 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: [email protected] =====================================================================
Re: [PATCH 4/4] ARM: imx: imx5: Introduce and use UART_BASE_ADDR(n)
Quoted 27 lines · Stefano Babic
Quoted 26 lines · Marek Vasut
Quoted 25 lines · Stefano Babic
Hi Marek,
Quoted 21 lines · Marek Vasut
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 switchingCONFIG_MXC_UART_BASEtoKconfig. 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 usestatic_assertin compound statements, hence this convoluted construct.Signed-off-by Marek Vasut <[email protected]>Cc Fabio Estevam <[email protected]>Cc Peng Fan <[email protected]>Cc Stefano Babic <[email protected]>---
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
I have not found the reason, but this breaks MX51:
All this
UART_BASE_ADDRstuff 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/[email protected]/
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
Quoted 4 lines
Best regards,
Stefano
Signature · 5 lines
===================================================================== 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: [email protected] =====================================================================
Hi Marek,
Quoted 4 lines · Marek Vasut
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 switchingCONFIG_MXC_UART_BASEtoKconfig. 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
Quoted 11 lines · Fabio Estevam
Hi Marek,
Quoted 4 lines · Marek Vasut
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 switchingCONFIG_MXC_UART_BASEtoKconfig. This is a clean up, no functional change.As
DM_SERIALis mandatory now, we should get rid ofCONFIG_MXC_UART_BASE.I would prefer a patch that removes
CONFIG_MXC_UART_BASEinstead.
DM is mandatory in SPL too ? I doubt it.
Quoted 9 lines · Marek Vasut
Quoted 8 lines · Fabio Estevam
Hi Marek,
Quoted 4 lines · Marek Vasut
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 switchingCONFIG_MXC_UART_BASEtoKconfig. This is a clean up, no functional change.
Quoted 5 lines
Quoted 3 lines
As
DM_SERIALis mandatory now, we should get rid ofCONFIG_MXC_UART_BASE.I would prefer a patch that removes
CONFIG_MXC_UART_BASEinstead.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?
Signature · 1 line
Tom
Quoted 14 lines · Tom Rini
Quoted 13 lines · Marek Vasut
Quoted 11 lines · Fabio Estevam
Hi Marek,
Quoted 4 lines · Marek Vasut
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 switchingCONFIG_MXC_UART_BASEtoKconfig. This is a clean up, no functional change.As
DM_SERIALis mandatory now, we should get rid ofCONFIG_MXC_UART_BASE.I would prefer a patch that removes
CONFIG_MXC_UART_BASEinstead.
Quoted 8 lines
Quoted 1 line
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_BASEstill needs to be moved out ofboard.hfiles (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.
Quoted 24 lines · Marek Vasut
Quoted 14 lines · Tom Rini
Quoted 13 lines · Marek Vasut
Quoted 11 lines · Fabio Estevam
Hi Marek,
Quoted 4 lines · Marek Vasut
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 switchingCONFIG_MXC_UART_BASEtoKconfig. This is a clean up, no functional change.As
DM_SERIALis mandatory now, we should get rid ofCONFIG_MXC_UART_BASE.I would prefer a patch that removes
CONFIG_MXC_UART_BASEinstead.Quoted 8 lines
Quoted 1 line
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_BASEstill needs to be moved out ofboard.hfiles (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?
Quoted 2 lines
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.
Signature · 1 line
Tom
Quoted 8 lines · Tom Rini
Quoted 1 line
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_BASEstill needs to be moved out ofboard.hfiles (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
PATCH 1/4 ARM: imx: imx8m: Introduce and use UART_BASE_ADDR(n)
In reply to Marek VasutQuoted 13 lines
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 switchingCONFIG_MXC_UART_BASEtoKconfig. 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 usestatic_assertin compound statements, hence this convoluted construct.
Quoted 4 lines
Signed-off-by Marek Vasut <[email protected]>Cc Fabio Estevam <[email protected]>Cc Peng Fan <[email protected]>Cc Stefano Babic <[email protected]>
Applied to u-boot-imx, master, thanks !
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== 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: [email protected] =====================================================================