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 93177C433EF for ; Sun, 24 Apr 2022 21:44:38 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 07E2D83E03; Sun, 24 Apr 2022 23:44:29 +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=1650836669; bh=v2Z/E+7lIlpXgMNzUfWsMyWY6xeGBeCLPi7d3GNCqIc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Cx9AHUoaezaN7p0VVtWtJ4yILrtQHgM5gg/v2inM5DTfIwWWoNqH22CAJI4qYJjxw bv/ma6579ZYT0BqJzm5kgmV5/bdLKwDPCdOXZMEGT79C4nI3XlaqhZve4Loa3ZHn8e x4QRRo9vBvtgMOC4K2/vCjyrIU9SzlvwY9nVydkvIKmMrOkFpzEvhPSSqFDTEK57AY mzqfOQKhdTdBpHKK3C6wsUEbajtJ1OnNXdA5QCRmmrQ2igUlYJtGyoALVr/aOw4ijD vPsNadwOIfMigYXZiYh71kwbS1MvANUDmEzLwj9lB7Xq5xLRMFVfAIbsLbGVofh7Nd EBa3HpkhbZkJg== 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 335AB83DD4; 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=v2Z/E+7lIlpXgMNzUfWsMyWY6xeGBeCLPi7d3GNCqIc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LFpzStnKXw87tkydVwW17ml6e0eU2HfYtu8ocqesuRZ7vrl2DN7ozdB1zk+Mx1aRl QrLymoXJup6UQCp3NDR/56d2JD7OYj+WEIo3GrLZamimKEzaUWS1GR66whkcuNmTto GFywlpgBQ/1T8WVE6azwaVJo7Y3hFZk89T6fZS9pDTVMMeST31492u0tPROyN1oahB S4wGcjbZyiEOyKVi9VEKWuKCVnzUV58Nqm7I1BrV9IPXZUp+DVtj5hFyX1sS48Ldea T+viHfjSppMDoXN9rdPCSwlcjn/Hu+TuQbOuX2GJd3owXXqgvCJ1/PaXf2J2slOxbK aeyU9KP0KPR/Q== From: Marek Vasut To: u-boot@lists.denx.de Cc: Marek Vasut , Fabio Estevam , Peng Fan , Stefano Babic Subject: [PATCH 3/4] ARM: imx: imx31: Introduce and use UART_BASE_ADDR(n) Date: Sun, 24 Apr 2022 23:44:05 +0200 Message-Id: <20220424214406.52658-3-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-mx31/imx-regs.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/arch/arm/include/asm/arch-mx31/imx-regs.h b/arch/arm/include/asm/arch-mx31/imx-regs.h index 566db549ec6..d5c0ed8e6c2 100644 --- a/arch/arm/include/asm/arch-mx31/imx-regs.h +++ b/arch/arm/include/asm/arch-mx31/imx-regs.h @@ -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 -- 2.35.1