From patchwork Tue Jan 31 17:52:01 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Nelson X-Patchwork-Id: 138822 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 54A9B1007D2 for ; Wed, 1 Feb 2012 04:52:40 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B0BC3280E0; Tue, 31 Jan 2012 18:52:38 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id uoAM7rhTsrZP; Tue, 31 Jan 2012 18:52:38 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 42CDC280DD; Tue, 31 Jan 2012 18:52:34 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E4E20280C7 for ; Tue, 31 Jan 2012 18:52:25 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cv29Dkq49Dz4 for ; Tue, 31 Jan 2012 18:52:23 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail.integraonline.com (relay1.integra.net [204.130.255.180]) by theia.denx.de (Postfix) with SMTP id 3FBC7280A7 for ; Tue, 31 Jan 2012 18:52:21 +0100 (CET) Received: (qmail 14851 invoked from network); 31 Jan 2012 17:52:17 -0000 Received: from unknown (HELO ericsony.example.org) (70.96.116.236) by relay1.integra.net with SMTP; 31 Jan 2012 17:52:17 -0000 From: Eric Nelson To: u-boot@lists.denx.de Date: Tue, 31 Jan 2012 10:52:01 -0700 Message-Id: <1328032330-20883-1-git-send-email-eric.nelson@boundarydevices.com> X-Mailer: git-send-email 1.7.1 Cc: fabio.estevam@freescale.com, dirk.behme@de.bosch.com, matthias.fuchs@esd.eu, jason.hui@linaro.org Subject: [U-Boot] [PATCH V6 - Part 1 - 1/1] mx6q: define GPIO macros for translating between ordinals and port:index X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de The interface to the mxc_gpio driver uses integer (ordinal) values to refer to all GPIOs on the i.MX processors. The registers themselves and much of the i.MX documentation are banked in groups of 32, and these macros allow the use of the port:index numbering for clarity. GPIO_NUMBER() converts to ordinal value from port:index GPIO_PORT() returns the port of an ordinal value GPIO_INDEX() returns the index or offset of the ordinal. Discussion on the mailing list at http://lists.denx.de/pipermail/u-boot/2012-January/116927.html Signed-off-by: Eric Nelson Signed-off-by: Eric Nelson --- arch/arm/include/asm/arch-mx6/imx-regs.h | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/arch/arm/include/asm/arch-mx6/imx-regs.h b/arch/arm/include/asm/arch-mx6/imx-regs.h index 5227b44..8a9eeb4 100644 --- a/arch/arm/include/asm/arch-mx6/imx-regs.h +++ b/arch/arm/include/asm/arch-mx6/imx-regs.h @@ -164,6 +164,10 @@ #define IRAM_SIZE 0x00040000 #define IMX_IIM_BASE OCOTP_BASE_ADDR +#define GPIO_NUMBER(port, index) ((((port)-1)*32)+((index)&31)) +#define GPIO_TO_PORT(number) (((number)/32)+1) +#define GPIO_TO_INDEX(number) ((number)&31) + #if !(defined(__KERNEL_STRICT_NAMES) || defined(__ASSEMBLY__)) #include