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 C64D7C433F5 for ; Sun, 24 Apr 2022 21:44:29 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 59F5F83DF3; Sun, 24 Apr 2022 23:44:23 +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=1650836663; bh=WTHM0POCAJIsWBPbF+HpqHRMQjtow4J4S8IIzR/pMZI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=r6f1X6uuv+PIR/b/LIC4UQarOV6yQ0yBFuwNpT6lcbIlXMOrG8srpnhvlTgcmJUAz jfZ5Eky0tqUyoj0VjFzG68IYUeJufXeINw2bwWdbdLpgStKZFl1I5Sbmk80WVqUfpH 1Pv8K6T9mITZARor7hdqIKDrXINa42R3Lm33FPqmQhcwjvTxUvCGoL8nAGv+B4WC86 hxSgG603Gs/b2tTo+fXKITcMnySpvRcvW5cFMY/Onfc3t+bGdgkEUvBEY8kOra6ns/ hFKgWKIc8+GN5UphqKM7u2uBKmSpL2EzQQkNGs3zyqzUOKDQk36bNUb4LuPvKDEJgp b+BUz1If89txQ== Received: from tr.lan (ip-86-49-12-201.net.upcbroadband.cz [86.49.12.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id D0EA083DA5; Sun, 24 Apr 2022 23:44:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1650836660; bh=WTHM0POCAJIsWBPbF+HpqHRMQjtow4J4S8IIzR/pMZI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aY8Cmmm/zRS9NbTjkb1N4nfp8K1mrjFlkuVAVTPWolIszPQcKjvCzuDTUZSx9WQ5A ovG9TckkITiVp3UCBAp1Wnz5hT7RQHKbPVRWhbthAAl1znu4y2bb0WfQ4LWTSNh8gE ryflsh2OlNCSGmTJLHrc39+J3MPVslslu7M7i3u1GCRB3/3FdfvPAN2hhoeHO3EmGq /dUaz+xSHvaBjHHLmrradxhd+R5UqUQ1ewhIJR93ZCK/FZXBjDuQvhbWGezHfSq7dY iyVzVGnNR8rCUwrCNpskVxbPCy6JVt2I4qpq8JiN0L9LfB4jBmv1puHy/k9Xfyi2dW OVbKhboBuA/0g== From: Marek Vasut To: u-boot@lists.denx.de Cc: Marek Vasut , Fabio Estevam , Peng Fan , Stefano Babic Subject: [PATCH 2/4] ARM: imx: imx27: Introduce and use UART_BASE_ADDR(n) Date: Sun, 24 Apr 2022 23:44:04 +0200 Message-Id: <20220424214406.52658-2-marex@denx.de> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220424214406.52658-1-marex@denx.de> References: <20220424214406.52658-1-marex@denx.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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 --- 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