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 CECD5C433EF for ; Sun, 24 Apr 2022 21:44:47 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 243F383E33; Sun, 24 Apr 2022 23:44:31 +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=1650836671; bh=T+OzPouc+FGnj5nYATu55auXb+ltb3F3NZOoRG4827k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=UpS+hvuT6xzeLJftqkiBhAOpFi13ot249SuDqhllP647t+mg4jWsozoGEP0b27K+F 2oo/fYrUXtONuSsPpmp3MdUUD7zTk7vUrztgBdw8gkPJurSU2DvjEmpejcynTTdgKj JYKbde/2VeC30OQSywKrj9DJWj1O0xJxZjfQ33FP0l4uWDOEcPhBQIbknOnkT3xqtR HUzgSCaFw9R+hpMzTatZh68ul+VIPjIPiK1JisS5lyERnMcwhxhRBL4Rxg7vnACMwY 0O1Cbwh0aVE22xVNOc8ZTJgHdQx3LTZBQJDs2WmjtoZMXRS5usYn/E6tWypKvFvSuZ gZhVl8gBXsGvQ== 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 8636283DE1; Sun, 24 Apr 2022 23:44:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1650836660; bh=T+OzPouc+FGnj5nYATu55auXb+ltb3F3NZOoRG4827k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wOfNmNiWMA+V8o012BUKZVS06H5oYB0bq4gLbjKLkJrjcZcF53Bybdi40ni7buLEc GAHj50SLjQc39QQFbnS0sAbP7tnIFiqciw0dIR0x+/iEIDcMRB6ZW1PdGe8yJybLYZ pF+L1Gp318RxwhcalVJ4VlY9yHX7ucExMkJ9CxRRsiTnNAm63jSmlwl+i/59TEXyvu nvho8dx7U14d3Q19dtpafXxPBci5W69IG4bhg025mZPgRBOTBUujRHpaq89cbrQr+p mLnp0NBzyq72hsR1xv18A5I3Zojm5xyCkKD7EgosShQBRKxGAxAOtdfnTTnsZjwtHJ HUXRIryAigWlQ== From: Marek Vasut To: u-boot@lists.denx.de Cc: Marek Vasut , Fabio Estevam , Peng Fan , Stefano Babic Subject: [PATCH 4/4] ARM: imx: imx5: Introduce and use UART_BASE_ADDR(n) Date: Sun, 24 Apr 2022 23:44:06 +0200 Message-Id: <20220424214406.52658-4-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-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 -- 2.35.1