From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0DA0CC433EF for ; Fri, 20 May 2022 07:30:19 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9157C83608; Fri, 20 May 2022 09:30:16 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1653031816; bh=SRhuHy+U8SOUX0HTkTZQTGSd9nCFi5ugpQcFJKK/z5A=; h=Date:Subject:To:Cc:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=uEvuFm44DWOjOAUtdBXpBFoTFvg6p1bI/Vc+QRx+GlNctAbUtL585QPkY3mJUYFz3 gHz/AaL14hEQHIgZR1AGSa0DHYJfIJEkxEHlSH4YTwOHCXgvIvFouQ7Oh/izJ5kRcJ S33/cr/zJAfd75PkVsgul2c3J3WnJyk7YiypjWforiHyzNiajwLNN06hUH7uk8nJ6+ PiQfKa7ZAILhJcmhezCtutPRyKU5VmVoX296OtdXv3m8zinIqP+/NN+Bf6+KpMs+wz b6ynuBclIRjsh3/oUVxwEQbAJZC/zB8zER1kFai7G9fnkPrwXj90MP2YlzxZ+JbwbT Zbgjh8j8pI2VA== Received: from [IPV6:2001:a61:60db:7a01:2a3d:378a:daeb:e028] (unknown [IPv6:2001:a61:60db:7a01:2a3d:378a:daeb:e028]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: sbabic@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 82F8D81111; Fri, 20 May 2022 09:30:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1653031814; bh=SRhuHy+U8SOUX0HTkTZQTGSd9nCFi5ugpQcFJKK/z5A=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=aSrowzokdwU7bztrd4SlPqF2lrJesf9HGq+QOiLDSPUmOCUy0jzS4eG8V5hr1TpnC 3c6ckCCiKp4YqZKP7TN9J0nlCLZTTUlsZQuV6YsLt/OD7P9rWrdn+dgRaGtJ2gCFjb 83E0F70MQ3cZa5ZUvOIo9/8CziWsihMvbJX6MKXZZ0K1y870sQEIs4XL4LWnu692bf VrJX/qDXVhYpasaoAQg6sfTZ5Hr3Dg8veAvf621R9PYcwUDQnpg+H+wWZOy6106K83 mya0PqKthpw6mteGueCxBqymuR7dbnQzHkhOBMkJvwax8QMSD7wKMSEUotkrdh0zLN rkAD0F+R0abWQ== Message-ID: <9cb83ca7-9c2b-e04c-9100-508695f40ddd@denx.de> Date: Fri, 20 May 2022 09:30:14 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 Subject: Re: [PATCH 4/4] ARM: imx: imx5: Introduce and use UART_BASE_ADDR(n) Content-Language: en-US To: Marek Vasut , u-boot@lists.denx.de Cc: Fabio Estevam , Peng Fan , Stefano Babic References: <20220424214406.52658-1-marex@denx.de> <20220424214406.52658-4-marex@denx.de> From: Stefano Babic In-Reply-To: <20220424214406.52658-4-marex@denx.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean 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 > Cc: Fabio Estevam > Cc: Peng Fan > Cc: Stefano Babic > --- 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 > > -#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 > > -#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 =====================================================================