[PATCH 4/4] ARM: imx: imx5: Introduce and use UART_BASE_ADDR(n)
Stefano Babic
sbabic at denx.de
Fri May 20 09:30:14 CEST 2022
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 at denx.de>
> Cc: Fabio Estevam <festevam at denx.de>
> Cc: Peng Fan <peng.fan at nxp.com>
> Cc: Stefano Babic <sbabic at 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 at denx.de
=====================================================================
More information about the U-Boot
mailing list