public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH V6 - Part 1 - 1/1] mx6q: define GPIO macros for translating between ordinals and port:index
@ 2012-01-31 17:52 Eric Nelson
  2012-01-31 17:52 ` [U-Boot] [PATCH V6 - Part 2 - 0/3] mxc_spi refactoring (for mx6q and mx6qsabrelite) Eric Nelson
                   ` (9 more replies)
  0 siblings, 10 replies; 35+ messages in thread
From: Eric Nelson @ 2012-01-31 17:52 UTC (permalink / raw)
  To: u-boot

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 <eric.nelson@boundarydevices.com>
---
 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 <asm/types.h>
 
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 35+ messages in thread

end of thread, other threads:[~2012-02-09  6:40 UTC | newest]

Thread overview: 35+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-31 17:52 [U-Boot] [PATCH V6 - Part 1 - 1/1] mx6q: define GPIO macros for translating between ordinals and port:index Eric Nelson
2012-01-31 17:52 ` [U-Boot] [PATCH V6 - Part 2 - 0/3] mxc_spi refactoring (for mx6q and mx6qsabrelite) Eric Nelson
2012-01-31 17:52 ` [U-Boot] [PATCH V6 - Part 2 - 1/3] mxc_spi: move machine specifics into CPU headers Eric Nelson
2012-02-01 11:23   ` Jason Hui
2012-02-08 11:23   ` Stefano Babic
2012-01-31 17:52 ` [U-Boot] [PATCH V6 - Part 2 - 2/3] mx6q: Add support for ECSPI through mxc_spi driver Eric Nelson
2012-02-01 11:24   ` Jason Hui
2012-02-08 11:23   ` Stefano Babic
2012-01-31 17:52 ` [U-Boot] [PATCH V6 - Part 2 - 3/3] mx6q: mx6qsabrelite: Add ECSPI support to the Sabrelite platform Eric Nelson
2012-02-01 11:25   ` Jason Hui
2012-02-08 11:23   ` Stefano Babic
2012-01-31 17:52 ` [U-Boot] [PATCH V6 - Part 3 - 0/2] SPI flash enhancements: allow default bus and chip-selects Eric Nelson
2012-01-31 18:11   ` Mike Frysinger
2012-01-31 19:14     ` Eric Nelson
2012-02-01 11:30       ` Stefano Babic
2012-02-01 11:35         ` Dirk Behme
2012-02-01 17:00         ` Mike Frysinger
2012-02-01 19:31           ` Eric Nelson
2012-02-01 21:04             ` Mike Frysinger
2012-02-02  9:18             ` Stefano Babic
2012-02-02 14:56               ` Eric Nelson
2012-02-02 16:32               ` Mike Frysinger
2012-02-03  9:27                 ` Stefano Babic
2012-02-09  6:40     ` Dirk Behme
2012-01-31 17:52 ` [U-Boot] [PATCH V6 - Part 3 - 1/2] sf command: allow default bus and chip selects Eric Nelson
2012-02-01 11:26   ` Jason Hui
2012-01-31 17:52 ` [U-Boot] [PATCH V6 - Part 2 - 2/2] README: Add description of SPI Flash (SF) command configuration Eric Nelson
2012-02-01 11:27   ` Jason Hui
2012-01-31 17:52 ` [U-Boot] [PATCH V6 - Part 4 - 1/1] mx6q: mx6qsabrelite: Provide default serial flash bus and chip-select Eric Nelson
2012-02-01 11:28   ` Jason Hui
2012-02-08 11:23   ` Stefano Babic
2012-01-31 17:52 ` [U-Boot] [PATCH V6 - Part 5 - 1/1] mx6q: mx6qsabrelite: Conditionally define macros for environment in serial flash Eric Nelson
2012-02-01 11:29   ` Jason Hui
2012-02-08 11:23   ` Stefano Babic
2012-02-08 11:23 ` [U-Boot] [PATCH V6 - Part 1 - 1/1] mx6q: define GPIO macros for translating between ordinals and port:index Stefano Babic

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox