]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
iMX51: introduce IMX_GPIO_NR
authorArnaud Patard (Rtp) <arnaud.patard@rtp-net.org>
Fri, 26 Nov 2010 14:20:52 +0000 (15:20 +0100)
committerSascha Hauer <s.hauer@pengutronix.de>
Fri, 3 Dec 2010 10:05:16 +0000 (11:05 +0100)
Currently, to define a GPIO number, we're using something like :

#define EFIKAMX_PCBID0         (2*32 + 16)

to define GPIO 3 16.

This is not really readable and it's error prone imho (note the 3 vs 2).
So, I'm introducing a new macro to define this in a better way. Now, the
code sample become :

#define EFIKAMX_PCBID0         IMX_GPIO_NR(3, 16)

v2:
- move to gpio.h
- add parens & spaces
- switch to IMX_GPIO_NR instead of MX51_GPIO_NR

Signed-off-by: Arnaud Patard <arnaud.patard@rtp-net.org>
Cc: Amit Kucheria <amit.kucheria@linaro.org>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Eric BĂ©nard <eric@eukrea.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
arch/arm/mach-mx5/board-cpuimx51.c
arch/arm/mach-mx5/board-cpuimx51sd.c
arch/arm/mach-mx5/board-mx51_babbage.c
arch/arm/mach-mx5/board-mx51_efikamx.c
arch/arm/mach-mx5/eukrea_mbimx51-baseboard.c
arch/arm/mach-mx5/eukrea_mbimxsd-baseboard.c
arch/arm/plat-mxc/include/mach/gpio.h

index 5ff5522ff6fddfe7c10956b2dc77006eaf75a102..6ab002d08a5667808cc557af51c1114341b9fc23 100644 (file)
 #include "devices-imx51.h"
 #include "devices.h"
 
-#define CPUIMX51_USBH1_STP     (0*32 + 27)
-#define CPUIMX51_QUARTA_GPIO   (2*32 + 28)
-#define CPUIMX51_QUARTB_GPIO   (2*32 + 25)
-#define CPUIMX51_QUARTC_GPIO   (2*32 + 26)
-#define CPUIMX51_QUARTD_GPIO   (2*32 + 27)
+#define CPUIMX51_USBH1_STP     IMX_GPIO_NR(1, 27)
+#define CPUIMX51_QUARTA_GPIO   IMX_GPIO_NR(3, 28)
+#define CPUIMX51_QUARTB_GPIO   IMX_GPIO_NR(3, 25)
+#define CPUIMX51_QUARTC_GPIO   IMX_GPIO_NR(3, 26)
+#define CPUIMX51_QUARTD_GPIO   IMX_GPIO_NR(3, 27)
 #define CPUIMX51_QUARTA_IRQ    (MXC_INTERNAL_IRQS + CPUIMX51_QUARTA_GPIO)
 #define CPUIMX51_QUARTB_IRQ    (MXC_INTERNAL_IRQS + CPUIMX51_QUARTB_GPIO)
 #define CPUIMX51_QUARTC_IRQ    (MXC_INTERNAL_IRQS + CPUIMX51_QUARTC_GPIO)
index ff1f45e96c3233d6c60e1db19a76830c9c41bafc..8e71c19b90197c9602c211e6d2469e7b14e87621 100644 (file)
 #include "devices-imx51.h"
 #include "devices.h"
 
-#define USBH1_RST              (1*32 + 28)
-#define ETH_RST                        (1*32 + 31)
-#define TSC2007_IRQGPIO                (2*32 + 12)
-#define CAN_IRQGPIO            (0*32 + 1)
-#define CAN_RST                        (3*32 + 15)
-#define CAN_NCS                        (3*32 + 24)
-#define CAN_RXOBF              (0*32 + 4)
-#define CAN_RX1BF              (0*32 + 6)
-#define CAN_TXORTS             (0*32 + 7)
-#define CAN_TX1RTS             (0*32 + 8)
-#define CAN_TX2RTS             (0*32 + 9)
-#define I2C_SCL                        (3*32 + 16)
-#define I2C_SDA                        (3*32 + 17)
+#define USBH1_RST              IMX_GPIO_NR(2, 28)
+#define ETH_RST                        IMX_GPIO_NR(2, 31)
+#define TSC2007_IRQGPIO                IMX_GPIO_NR(3, 12)
+#define CAN_IRQGPIO            IMX_GPIO_NR(1, 1)
+#define CAN_RST                        IMX_GPIO_NR(4, 15)
+#define CAN_NCS                        IMX_GPIO_NR(4, 24)
+#define CAN_RXOBF              IMX_GPIO_NR(1, 4)
+#define CAN_RX1BF              IMX_GPIO_NR(1, 6)
+#define CAN_TXORTS             IMX_GPIO_NR(1, 7)
+#define CAN_TX1RTS             IMX_GPIO_NR(1, 8)
+#define CAN_TX2RTS             IMX_GPIO_NR(1, 9)
+#define I2C_SCL                        IMX_GPIO_NR(4, 16)
+#define I2C_SDA                        IMX_GPIO_NR(4, 17)
 
 /* USB_CTRL_1 */
 #define MX51_USB_CTRL_1_OFFSET         0x10
@@ -243,7 +243,7 @@ static struct spi_board_info cpuimx51sd_spi_device[] = {
                .mode           = SPI_MODE_0,
                .chip_select     = 0,
                .platform_data   = &mcp251x_info,
-               .irq             = gpio_to_irq(0 * 32 + 1)
+               .irq             = gpio_to_irq(CAN_IRQGPIO)
        },
 };
 
index ef328433df8000d0af093672adf8e2edf083b40c..6442579c4ac5772316682fa7310fefc002ce8a04 100644 (file)
 #include "devices.h"
 #include "cpu_op-mx51.h"
 
-#define BABBAGE_USB_HUB_RESET  (0*32 + 7)      /* GPIO_1_7 */
-#define BABBAGE_USBH1_STP      (0*32 + 27)     /* GPIO_1_27 */
-#define BABBAGE_PHY_RESET      (1*32 + 5)      /* GPIO_2_5 */
-#define BABBAGE_FEC_PHY_RESET  (1*32 + 14)     /* GPIO_2_14 */
-#define BABBAGE_POWER_KEY      (1*32 + 21)     /* GPIO_2_21 */
-#define BABBAGE_ECSPI1_CS0     (3*32 + 24)     /* GPIO_4_24 */
-#define BABBAGE_ECSPI1_CS1     (3*32 + 25)     /* GPIO_4_25 */
+#define BABBAGE_USB_HUB_RESET  IMX_GPIO_NR(1, 7)
+#define BABBAGE_USBH1_STP      IMX_GPIO_NR(1, 27)
+#define BABBAGE_PHY_RESET      IMX_GPIO_NR(2, 5)
+#define BABBAGE_FEC_PHY_RESET  IMX_GPIO_NR(2, 14)
+#define BABBAGE_POWER_KEY      IMX_GPIO_NR(2, 21)
+#define BABBAGE_ECSPI1_CS0     IMX_GPIO_NR(4, 24)
+#define BABBAGE_ECSPI1_CS1     IMX_GPIO_NR(4, 25)
 
 /* USB_CTRL_1 */
 #define MX51_USB_CTRL_1_OFFSET                 0x10
index 3a4607bb79b50b633772e2d726ed4ee61f4cf2e3..5ab21a0036c14f4b6f539c5a59c99e05088d0e49 100644 (file)
 
 #define        MX51_USB_PLL_DIV_24_MHZ 0x01
 
-#define EFIKAMX_PCBID0         (2*32 + 16)
-#define EFIKAMX_PCBID1         (2*32 + 17)
-#define EFIKAMX_PCBID2         (2*32 + 11)
+#define EFIKAMX_PCBID0         IMX_GPIO_NR(3, 16)
+#define EFIKAMX_PCBID1         IMX_GPIO_NR(3, 17)
+#define EFIKAMX_PCBID2         IMX_GPIO_NR(3, 11)
 
-#define EFIKAMX_BLUE_LED       (2*32 + 13)
-#define EFIKAMX_GREEN_LED      (2*32 + 14)
-#define EFIKAMX_RED_LED                (2*32 + 15)
+#define EFIKAMX_BLUE_LED       IMX_GPIO_NR(3, 13)
+#define EFIKAMX_GREEN_LED      IMX_GPIO_NR(3, 14)
+#define EFIKAMX_RED_LED                IMX_GPIO_NR(3, 15)
 
-#define EFIKAMX_POWER_KEY      (1*32 + 31)
+#define EFIKAMX_POWER_KEY      IMX_GPIO_NR(2, 31)
 
-#define EFIKAMX_SPI_CS0                (3*32 + 24)
-#define EFIKAMX_SPI_CS1                (3*32 + 25)
+#define EFIKAMX_SPI_CS0                IMX_GPIO_NR(4, 24)
+#define EFIKAMX_SPI_CS1                IMX_GPIO_NR(4, 25)
 
 /* board 1.1 doesn't have same reset gpio */
-#define EFIKAMX_RESET1_1       (2*32 + 2)
-#define EFIKAMX_RESET          (0*32 + 4)
+#define EFIKAMX_RESET1_1       IMX_GPIO_NR(3, 2)
+#define EFIKAMX_RESET          IMX_GPIO_NR(1, 4)
 
 /* the pci ids pin have pull up. they're driven low according to board id */
 #define MX51_PAD_PCBID0        IOMUX_PAD(0x518, 0x130, 3, 0x0,   0, PAD_CTL_PUS_100K_UP)
index b830967f4bec1298d81bea9c82cf48ffdfbc42e4..94c293f217f78be31a390ab298212abdf7c0f925 100644 (file)
 #include "devices-imx51.h"
 #include "devices.h"
 
-#define MBIMX51_TSC2007_GPIO   (2*32 + 30)
+#define MBIMX51_TSC2007_GPIO   IMX_GPIO_NR(3, 30)
 #define MBIMX51_TSC2007_IRQ    (MXC_INTERNAL_IRQS + MBIMX51_TSC2007_GPIO)
-#define MBIMX51_LED0           (2*32 + 5)
-#define MBIMX51_LED1           (2*32 + 6)
-#define MBIMX51_LED2           (2*32 + 7)
-#define MBIMX51_LED3           (2*32 + 8)
+#define MBIMX51_LED0           IMX_GPIO_NR(3, 5)
+#define MBIMX51_LED1           IMX_GPIO_NR(3, 6)
+#define MBIMX51_LED2           IMX_GPIO_NR(3, 7)
+#define MBIMX51_LED3           IMX_GPIO_NR(3, 8)
 
 static struct gpio_led mbimx51_leds[] = {
        {
index 2751b11ead896ce346c453f7fd9a02392c89d4f9..c6c232019bb792ea54b8e7908d98e2dc63ebf2a3 100644 (file)
@@ -70,8 +70,8 @@ static iomux_v3_cfg_t eukrea_mbimxsd_pads[] = {
        MX51_PAD_SD1_DATA3__SD1_DATA3,
 };
 
-#define GPIO_LED1      (2 * 32 + 30)
-#define GPIO_SWITCH1   (2 * 32 + 31)
+#define GPIO_LED1      IMX_GPIO_NR(3, 30)
+#define GPIO_SWITCH1   IMX_GPIO_NR(3, 31)
 
 static struct gpio_led eukrea_mbimxsd_leds[] = {
        {
index af33b74f569ebb5b0c959f1f80f3b415df2059ae..0044e2f1bea8211daa84d10090d5a41aacb80f09 100644 (file)
 #include <mach/hardware.h>
 #include <asm-generic/gpio.h>
 
+
+/* There's a off-by-one betweem the gpio bank number and the gpiochip */
+/* range e.g. GPIO_1_5 is gpio 5 under linux */
+#define IMX_GPIO_NR(bank, nr)          (((bank) - 1) * 32 + (nr))
+
 /* use gpiolib dispatchers */
 #define gpio_get_value         __gpio_get_value
 #define gpio_set_value         __gpio_set_value