diff mbox

[U-Boot,v2] MX: Set a common gpio.h for all i.MX

Message ID 1345365644-13780-1-git-send-email-sbabic@denx.de
State Changes Requested
Delegated to: Stefano Babic
Headers show

Commit Message

Stefano Babic Aug. 19, 2012, 8:40 a.m. UTC
Signed-off-by: Stefano Babic <sbabic@denx.de>
---
Changes in v2:
- call the macro IMX_GPIO_NR  as in kernel (Fabio Estevam)
- change psr in gpio_psr (Benoit Thebaudeau)
- drop MXC_GPIO_PORT_TO_NUM and use common macro (Benoit Thebaudeau)

 arch/arm/include/asm/arch-mx25/gpio.h         |    5 -----
 arch/arm/include/asm/imx-common/gpio.h        |    4 ++--
 board/freescale/mx6qsabrelite/mx6qsabrelite.c |   28 ++++++++++++-------------
 board/karo/tx25/tx25.c                        |   10 ++++-----
 board/syteco/zmx25/zmx25.c                    |   26 +++++++++++------------
 include/configs/mx6qsabrelite.h               |    2 +-
 6 files changed, 35 insertions(+), 40 deletions(-)
diff mbox

Patch

diff --git a/arch/arm/include/asm/arch-mx25/gpio.h b/arch/arm/include/asm/arch-mx25/gpio.h
index 5ab1f6d..61c0b0d 100644
--- a/arch/arm/include/asm/arch-mx25/gpio.h
+++ b/arch/arm/include/asm/arch-mx25/gpio.h
@@ -25,11 +25,6 @@ 
 #ifndef __ASM_ARCH_MX25_GPIO_H
 #define __ASM_ARCH_MX25_GPIO_H
 
-/* Converts a GPIO port number and the internal bit position
- * to the GPIO number
- */
-#define MXC_GPIO_PORT_TO_NUM(port, bit) (((port - 1) << 5) + (bit & 0x1f))
-
 #include <asm/imx-common/gpio.h>
 
 #endif
diff --git a/arch/arm/include/asm/imx-common/gpio.h b/arch/arm/include/asm/imx-common/gpio.h
index fcc25e8..65226d9 100644
--- a/arch/arm/include/asm/imx-common/gpio.h
+++ b/arch/arm/include/asm/imx-common/gpio.h
@@ -30,10 +30,10 @@ 
 struct gpio_regs {
 	u32 gpio_dr;	/* data */
 	u32 gpio_dir;	/* direction */
-	u32 psr;	/* pad satus */
+	u32 gpio_psr;	/* pad satus */
 };
 #endif
 
-#define GPIO_NUMBER(port, index)		((((port)-1)*32)+((index)&31))
+#define IMX_GPIO_NR(port, index)		((((port)-1)*32)+((index)&31))
 
 #endif
diff --git a/board/freescale/mx6qsabrelite/mx6qsabrelite.c b/board/freescale/mx6qsabrelite/mx6qsabrelite.c
index 01e5083..72f4294 100644
--- a/board/freescale/mx6qsabrelite/mx6qsabrelite.c
+++ b/board/freescale/mx6qsabrelite/mx6qsabrelite.c
@@ -85,12 +85,12 @@  struct i2c_pads_info i2c_pad_info0 = {
 	.scl = {
 		.i2c_mode = MX6Q_PAD_EIM_D21__I2C1_SCL | PC,
 		.gpio_mode = MX6Q_PAD_EIM_D21__GPIO_3_21 | PC,
-		.gp = GPIO_NUMBER(3, 21)
+		.gp = IMX_GPIO_NR(3, 21)
 	},
 	.sda = {
 		.i2c_mode = MX6Q_PAD_EIM_D28__I2C1_SDA | PC,
 		.gpio_mode = MX6Q_PAD_EIM_D28__GPIO_3_28 | PC,
-		.gp = GPIO_NUMBER(3, 28)
+		.gp = IMX_GPIO_NR(3, 28)
 	}
 };
 
@@ -99,12 +99,12 @@  struct i2c_pads_info i2c_pad_info1 = {
 	.scl = {
 		.i2c_mode = MX6Q_PAD_KEY_COL3__I2C2_SCL | PC,
 		.gpio_mode = MX6Q_PAD_KEY_COL3__GPIO_4_12 | PC,
-		.gp = GPIO_NUMBER(4, 12)
+		.gp = IMX_GPIO_NR(4, 12)
 	},
 	.sda = {
 		.i2c_mode = MX6Q_PAD_KEY_ROW3__I2C2_SDA | PC,
 		.gpio_mode = MX6Q_PAD_KEY_ROW3__GPIO_4_13 | PC,
-		.gp = GPIO_NUMBER(4, 13)
+		.gp = IMX_GPIO_NR(4, 13)
 	}
 };
 
@@ -113,12 +113,12 @@  struct i2c_pads_info i2c_pad_info2 = {
 	.scl = {
 		.i2c_mode = MX6Q_PAD_GPIO_5__I2C3_SCL | PC,
 		.gpio_mode = MX6Q_PAD_GPIO_5__GPIO_1_5 | PC,
-		.gp = GPIO_NUMBER(1, 5)
+		.gp = IMX_GPIO_NR(1, 5)
 	},
 	.sda = {
 		.i2c_mode = MX6Q_PAD_GPIO_16__I2C3_SDA | PC,
 		.gpio_mode = MX6Q_PAD_GPIO_16__GPIO_7_11 | PC,
-		.gp = GPIO_NUMBER(7, 11)
+		.gp = IMX_GPIO_NR(7, 11)
 	}
 };
 
@@ -227,9 +227,9 @@  int board_ehci_hcd_init(int port)
 	imx_iomux_v3_setup_multiple_pads(usb_pads, ARRAY_SIZE(usb_pads));
 
 	/* Reset USB hub */
-	gpio_direction_output(GPIO_NUMBER(7, 12), 0);
+	gpio_direction_output(IMX_GPIO_NR(7, 12), 0);
 	mdelay(2);
-	gpio_set_value(GPIO_NUMBER(7, 12), 1);
+	gpio_set_value(IMX_GPIO_NR(7, 12), 1);
 
 	return 0;
 }
@@ -411,12 +411,12 @@  struct button_key {
 };
 
 static struct button_key const buttons[] = {
-	{"back",	GPIO_NUMBER(2, 2),	'B'},
-	{"home",	GPIO_NUMBER(2, 4),	'H'},
-	{"menu",	GPIO_NUMBER(2, 1),	'M'},
-	{"search",	GPIO_NUMBER(2, 3),	'S'},
-	{"volup",	GPIO_NUMBER(7, 13),	'V'},
-	{"voldown",	GPIO_NUMBER(4, 5),	'v'},
+	{"back",	IMX_GPIO_NR(2, 2),	'B'},
+	{"home",	IMX_GPIO_NR(2, 4),	'H'},
+	{"menu",	IMX_GPIO_NR(2, 1),	'M'},
+	{"search",	IMX_GPIO_NR(2, 3),	'S'},
+	{"volup",	IMX_GPIO_NR(7, 13),	'V'},
+	{"voldown",	IMX_GPIO_NR(4, 5),	'v'},
 };
 
 /*
diff --git a/board/karo/tx25/tx25.c b/board/karo/tx25/tx25.c
index 07fd98d..0fd41c7 100644
--- a/board/karo/tx25/tx25.c
+++ b/board/karo/tx25/tx25.c
@@ -34,8 +34,8 @@ 
 DECLARE_GLOBAL_DATA_PTR;
 
 #ifdef CONFIG_FEC_MXC
-#define GPIO_FEC_RESET_B	MXC_GPIO_PORT_TO_NUM(4, 7)
-#define GPIO_FEC_ENABLE_B	MXC_GPIO_PORT_TO_NUM(4, 9)
+#define GPIO_FEC_RESET_B	IMX_GPIO_NR(4, 7)
+#define GPIO_FEC_ENABLE_B	IMX_GPIO_NR(4, 9)
 void tx25_fec_init(void)
 {
 	struct iomuxc_mux_ctl *muxctl;
@@ -103,9 +103,9 @@  void tx25_fec_init(void)
 	/*
 	 * set each to 1 and make each an output
 	 */
-	gpio_direction_output(MXC_GPIO_PORT_TO_NUM(3, 10), 1);
-	gpio_direction_output(MXC_GPIO_PORT_TO_NUM(3, 11), 1);
-	gpio_direction_output(MXC_GPIO_PORT_TO_NUM(3, 12), 1);
+	gpio_direction_output(IMX_GPIO_NR(3, 10), 1);
+	gpio_direction_output(IMX_GPIO_NR(3, 11), 1);
+	gpio_direction_output(IMX_GPIO_NR(3, 12), 1);
 
 	mdelay(22);		/* this value came from RedBoot */
 
diff --git a/board/syteco/zmx25/zmx25.c b/board/syteco/zmx25/zmx25.c
index c56b195..fe5589d 100644
--- a/board/syteco/zmx25/zmx25.c
+++ b/board/syteco/zmx25/zmx25.c
@@ -56,7 +56,7 @@  int board_init()
 
 	/* Setup of core volatage selection pin to run at 1.4V */
 	writel(gpio_mux_mode5, &muxctl->pad_ext_armclk); /* VCORE GPIO3[15] */
-	gpio_direction_output(MXC_GPIO_PORT_TO_NUM(3, 15), 1);
+	gpio_direction_output(IMX_GPIO_NR(3, 15), 1);
 
 	/* Setup of input daisy chains for SD card pins*/
 	writel(gpio_mux_mode0_sion, &muxctl->pad_sd1_cmd);
@@ -68,10 +68,10 @@  int board_init()
 
 	/* Setup of digital output for USB power and OC */
 	writel(gpio_mux_mode5, &muxctl->pad_csi_d3); /* USB Power GPIO1[28] */
-	gpio_direction_output(MXC_GPIO_PORT_TO_NUM(1, 28), 1);
+	gpio_direction_output(IMX_GPIO_NR(1, 28), 1);
 
 	writel(gpio_mux_mode5, &muxctl->pad_csi_d2); /* USB OC GPIO1[27] */
-	gpio_direction_input(MXC_GPIO_PORT_TO_NUM(1, 18));
+	gpio_direction_input(IMX_GPIO_NR(1, 18));
 
 	/* Setup of digital output control pins */
 	writel(gpio_mux_mode5, &muxctl->pad_csi_d8); /* Ouput 1 Ctrl GPIO1[7] */
@@ -83,21 +83,21 @@  int board_init()
 	writel(0, &padctl->pad_csi_d5); /* Ouput 2 Stat pull up off */
 
 	/* Switch both output drivers off */
-	gpio_direction_output(MXC_GPIO_PORT_TO_NUM(1, 7), 0);
-	gpio_direction_output(MXC_GPIO_PORT_TO_NUM(1, 6), 0);
+	gpio_direction_output(IMX_GPIO_NR(1, 7), 0);
+	gpio_direction_output(IMX_GPIO_NR(1, 6), 0);
 
 	/* Setup of key input pin GPIO2[29]*/
 	writel(gpio_mux_mode5 | MX25_PIN_MUX_SION, &muxctl->pad_kpp_row0);
 	writel(0, &padctl->pad_kpp_row0); /* Key pull up off */
-	gpio_direction_input(MXC_GPIO_PORT_TO_NUM(2, 29));
+	gpio_direction_input(IMX_GPIO_NR(2, 29));
 
 	/* Setup of status LED outputs */
 	writel(gpio_mux_mode5, &muxctl->pad_csi_d9);	/* GPIO4[21] */
 	writel(gpio_mux_mode5, &muxctl->pad_csi_d4);	/* GPIO1[29] */
 
 	/* Switch both LEDs off */
-	gpio_direction_output(MXC_GPIO_PORT_TO_NUM(4, 21), 0);
-	gpio_direction_output(MXC_GPIO_PORT_TO_NUM(1, 29), 0);
+	gpio_direction_output(IMX_GPIO_NR(4, 21), 0);
+	gpio_direction_output(IMX_GPIO_NR(1, 29), 0);
 
 	/* Setup of CAN1 and CAN2 signals */
 	writel(gpio_mux_mode6, &muxctl->pad_gpio_a);	/* CAN1 TX */
@@ -148,12 +148,12 @@  int board_late_init(void)
 	writel(gpio_mux_mode2, &muxctl->pad_uart2_cts);
 
 	/* assert PHY reset (low) */
-	gpio_direction_output(MXC_GPIO_PORT_TO_NUM(3, 16), 0);
+	gpio_direction_output(IMX_GPIO_NR(3, 16), 0);
 
 	udelay(5000);
 
 	/* deassert PHY reset */
-	gpio_set_value(MXC_GPIO_PORT_TO_NUM(3, 16), 1);
+	gpio_set_value(IMX_GPIO_NR(3, 16), 1);
 
 	udelay(5000);
 #endif
@@ -161,12 +161,12 @@  int board_late_init(void)
 	e = getenv("gs_base_board");
 	if (e != NULL) {
 		if (strcmp(e, "G283") == 0) {
-			int key = gpio_get_value(MXC_GPIO_PORT_TO_NUM(2, 29));
+			int key = gpio_get_value(IMX_GPIO_NR(2, 29));
 
 			if (key) {
 				/* Switch on both LEDs to inidcate boot mode */
-				gpio_set_value(MXC_GPIO_PORT_TO_NUM(1, 29), 0);
-				gpio_set_value(MXC_GPIO_PORT_TO_NUM(4, 21), 0);
+				gpio_set_value(IMX_GPIO_NR(1, 29), 0);
+				gpio_set_value(IMX_GPIO_NR(4, 21), 0);
 
 				setenv("preboot", "run gs_slow_boot");
 			} else
diff --git a/include/configs/mx6qsabrelite.h b/include/configs/mx6qsabrelite.h
index 700268e..0c7a8c0 100644
--- a/include/configs/mx6qsabrelite.h
+++ b/include/configs/mx6qsabrelite.h
@@ -54,7 +54,7 @@ 
 #define CONFIG_SPI_FLASH_SST
 #define CONFIG_MXC_SPI
 #define CONFIG_SF_DEFAULT_BUS  0
-#define CONFIG_SF_DEFAULT_CS   (0|(GPIO_NUMBER(3, 19)<<8))
+#define CONFIG_SF_DEFAULT_CS   (0|(IMX_GPIO_NR(3, 19)<<8))
 #define CONFIG_SF_DEFAULT_SPEED 25000000
 #define CONFIG_SF_DEFAULT_MODE (SPI_MODE_0)
 #endif