Skip to contentSkip to conversation

IMX: uniform GPIO interface using GPIO framework

PATCH New Stefano Babic 4 participants 25 messages Aug 21, 2011 – Aug 26, 2011

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/14 IMX: uniform GPIO interface using GPIO framework

IMX processors has a slightly different interface to access GPIOs and do not make use of the provided GPIO framework. The patch substitutes mxc_ specific functions and make use of the API in asm/gpio.h

---
 drivers/gpio/mxc_gpio.c |   51 ++++++++++++++++++++++++++++++++++++++---
 drivers/spi/mxc_spi.c   |    8 +++---
 include/mxc_gpio.h      |   57 -----------------------------------------------
 3 files changed, 51 insertions(+), 65 deletions(-)
 delete mode 100644 include/mxc_gpio.h
drivers/gpio/mxc_gpio.c +47 -4
index 6efbb02..a7f36b2 100644
@@ -2,6 +2,9 @@
  * Copyright (C) 2009
  * Guennadi Liakhovetski, DENX Software Engineering, <[email protected]>
  *
+ * Copyright (C) 2011
+ * Stefano Babic, DENX Software Engineering, <[email protected]>
+ *
  * See file CREDITS for list of people who contributed to this
  * project.
  *
@@ -22,10 +25,16 @@
  */
 #include <common.h>
 #include <asm/arch/imx-regs.h>
+#include <asm/gpio.h>
 #include <asm/io.h>
-#include <mxc_gpio.h>
 #include <errno.h>
 
+enum mxc_gpio_direction {
+	MXC_GPIO_DIRECTION_IN,
+	MXC_GPIO_DIRECTION_OUT,
+};
+
+
 /* GPIO port description */
 static unsigned long gpio_ports[] = {
 	[0] = GPIO1_BASE_ADDR,
@@ -41,7 +50,8 @@ static unsigned long gpio_ports[] = {
 #endif
 };
 
-int mxc_gpio_direction(unsigned int gpio, enum mxc_gpio_direction direction)
+static int mxc_gpio_direction(unsigned int gpio,
+	enum mxc_gpio_direction direction)
 {
 	unsigned int port = gpio >> 5;
 	struct gpio_regs *regs;
@@ -68,7 +78,7 @@ int mxc_gpio_direction(unsigned int gpio, enum mxc_gpio_direction direction)
 	return 0;
 }
 
-void mxc_gpio_set(unsigned int gpio, unsigned int value)
+void gpio_set_value(int gpio, int value)
 {
 	unsigned int port = gpio >> 5;
 	struct gpio_regs *regs;
@@ -89,7 +99,7 @@ void mxc_gpio_set(unsigned int gpio, unsigned int value)
 	writel(l, &regs->gpio_dr);
 }
 
-int mxc_gpio_get(unsigned int gpio)
+int gpio_get_value(int gpio)
 {
 	unsigned int port = gpio >> 5;
 	struct gpio_regs *regs;
@@ -106,3 +116,36 @@ int mxc_gpio_get(unsigned int gpio)
 
 	return l;
 }
+
+int gpio_request(int gp, const char *label)
+{
+	unsigned int port = gp >> 5;
+	if (port >= ARRAY_SIZE(gpio_ports))
+		return -EINVAL;
+	return 0;
+}
+
+void gpio_free(int gp)
+{
+}
+
+void gpio_toggle_value(int gp)
+{
+	gpio_set_value(gp, !gpio_get_value(gp));
+}
+
+int gpio_direction_input(int gp)
+{
+	return mxc_gpio_direction(gp, MXC_GPIO_DIRECTION_IN);
+}
+
+int gpio_direction_output(int gp, int value)
+{
+	int ret = mxc_gpio_direction(gp, MXC_GPIO_DIRECTION_OUT);
+
+	if (ret < 0)
+		return ret;
+
+	gpio_set_value(gp, value);
+	return 0;
+}
drivers/spi/mxc_spi.c +4 -4
index 81381d9..2fa7486 100644
@@ -23,7 +23,7 @@
 #include <spi.h>
 #include <asm/errno.h>
 #include <asm/io.h>
-#include <mxc_gpio.h>
+#include <asm/gpio.h>
 #include <asm/arch/imx-regs.h>
 #include <asm/arch/clock.h>
 
@@ -145,14 +145,14 @@ void spi_cs_activate(struct spi_slave *slave)
 {
 	struct mxc_spi_slave *mxcs = to_mxc_spi_slave(slave);
 	if (mxcs->gpio > 0)
-		mxc_gpio_set(mxcs->gpio, mxcs->ss_pol);
+		gpio_set_value(mxcs->gpio, mxcs->ss_pol);
 }
 
 void spi_cs_deactivate(struct spi_slave *slave)
 {
 	struct mxc_spi_slave *mxcs = to_mxc_spi_slave(slave);
 	if (mxcs->gpio > 0)
-		mxc_gpio_set(mxcs->gpio,
+		gpio_set_value(mxcs->gpio,
 			      !(mxcs->ss_pol));
 }
 
@@ -468,7 +468,7 @@ static int decode_cs(struct mxc_spi_slave *mxcs, unsigned int cs)
 	if (cs > 3) {
 		mxcs->gpio = cs >> 8;
 		cs &= 3;
-		ret = mxc_gpio_direction(mxcs->gpio, OUT);
+		ret = gpio_direction_output(mxcs->gpio, 0);
 		if (ret) {
 			printf("mxc_spi: cannot setup gpio %d\n", mxcs->gpio);
 			return -EINVAL;
include/mxc_gpio.h deleted +0 -57

57 lines not on this page · raw message

Signature · 1 line
1.7.1
#1 lore raw

PATCH 2/14 MX25: make use of GPIO framework for MX25 processor

---
 arch/arm/include/asm/arch-mx25/gpio.h     |   45 +++++++++++++++++++++++++++++
 arch/arm/include/asm/arch-mx25/imx-regs.h |   12 --------
 2 files changed, 45 insertions(+), 12 deletions(-)
 create mode 100644 arch/arm/include/asm/arch-mx25/gpio.h
arch/arm/include/asm/arch-mx25/gpio.h new file +45 -0
new file mode 100644
index 0000000..dc6edc7
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2011
+ * Stefano Babic, DENX Software Engineering, <[email protected]>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+
+#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))
+
+/* GPIO registers */
+struct gpio_regs {
+	u32 gpio_dr;	/* data */
+	u32 gpio_dir;	/* direction */
+	u32 psr;	/* pad satus */
+	u32 icr1;	/* interrupt config 1 */
+	u32 icr2;	/* interrupt config 2 */
+	u32 imr;	/* interrupt mask */
+	u32 isr;	/* interrupt status */
+	u32 edge_sel;	/* edge select */
+};
+
+#endif
arch/arm/include/asm/arch-mx25/imx-regs.h +0 -12
index 2ccb445..9e30f7c 100644
@@ -84,18 +84,6 @@ struct esdramc_regs {
 	u32 cdlyl;	/* delay line cycle length debug */
 };
 
-/* GPIO registers */
-struct gpio_regs {
-	u32 gpio_dr;	/* data */
-	u32 gpio_dir;	/* direction */
-	u32 psr;	/* pad satus */
-	u32 icr1;	/* interrupt config 1 */
-	u32 icr2;	/* interrupt config 2 */
-	u32 imr;	/* interrupt mask */
-	u32 isr;	/* interrupt status */
-	u32 edge_sel;	/* edge select */
-};
-
 /* General Purpose Timer (GPT) registers */
 struct gpt_regs {
 	u32 ctrl;   	/* control */
Signature · 1 line
1.7.1
#2 lore raw

PATCH 3/14 MX31: make use of GPIO framework for MX31 processor

In reply to Stefano Babic
---
 arch/arm/include/asm/arch-mx31/gpio.h     |   35 +++++++++++++++++++++++++++++
 arch/arm/include/asm/arch-mx31/imx-regs.h |    7 -----
 2 files changed, 35 insertions(+), 7 deletions(-)
 create mode 100644 arch/arm/include/asm/arch-mx31/gpio.h
arch/arm/include/asm/arch-mx31/gpio.h new file +35 -0
new file mode 100644
index 0000000..95b73bf
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2011
+ * Stefano Babic, DENX Software Engineering, <[email protected]>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+
+#ifndef __ASM_ARCH_MX31_GPIO_H
+#define __ASM_ARCH_MX31_GPIO_H
+
+/* GPIO Registers */
+struct gpio_regs {
+	u32	gpio_dr;
+	u32	gpio_dir;
+	u32	gpio_psr;
+};
+
+#endif
arch/arm/include/asm/arch-mx31/imx-regs.h +0 -7
index 3c8d607..2064870 100644
@@ -57,13 +57,6 @@ struct clock_control_regs {
 	u32 pdr2;
 };
 
-/* GPIO Registers */
-struct gpio_regs {
-	u32	gpio_dr;
-	u32	gpio_dir;
-	u32	gpio_psr;
-};
-
 struct cspi_regs {
 	u32 rxdata;
 	u32 txdata;
Signature · 1 line
1.7.1
#3 lore raw

PATCH 4/14 MX5: make use of GPIO framework for MX5 processor

In reply to Stefano Babic
---
 arch/arm/include/asm/arch-mx5/gpio.h     |   35 ++++++++++++++++++++++++++++++
 arch/arm/include/asm/arch-mx5/imx-regs.h |    7 ------
 2 files changed, 35 insertions(+), 7 deletions(-)
 create mode 100644 arch/arm/include/asm/arch-mx5/gpio.h
arch/arm/include/asm/arch-mx5/gpio.h new file +35 -0
new file mode 100644
index 0000000..1dc34e9
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2011
+ * Stefano Babic, DENX Software Engineering, <[email protected]>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+
+#ifndef __ASM_ARCH_MX5_GPIO_H
+#define __ASM_ARCH_MX5_GPIO_H
+
+/* GPIO registers */
+struct gpio_regs {
+	u32	gpio_dr;
+	u32	gpio_dir;
+	u32	gpio_psr;
+};
+
+#endif
arch/arm/include/asm/arch-mx5/imx-regs.h +0 -7
index fb2c66f..a4e680b 100644
@@ -409,13 +409,6 @@ struct iomuxc {
 };
 #endif
 
-/* GPIO Registers */
-struct gpio_regs {
-	u32	gpio_dr;
-	u32	gpio_dir;
-	u32	gpio_psr;
-};
-
 /* System Reset Controller (SRC) */
 struct src {
 	u32	scr;
Signature · 1 line
1.7.1
#4 lore raw

PATCH 5/14 MX35: make use of GPIO framework for MX35 processor

In reply to Stefano Babic
---
 arch/arm/include/asm/arch-mx35/gpio.h |   40 +++++++++++++++++++++++++++++++++
 1 files changed, 40 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/include/asm/arch-mx35/gpio.h
arch/arm/include/asm/arch-mx35/gpio.h new file +40 -0
new file mode 100644
index 0000000..7bcc3e8
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2011
+ * Stefano Babic, DENX Software Engineering, <[email protected]>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+
+#ifndef __ASM_ARCH_MX35_GPIO_H
+#define __ASM_ARCH_MX35_GPIO_H
+
+/* GPIO registers */
+struct gpio_regs {
+	u32 gpio_dr;	/* data */
+	u32 gpio_dir;	/* direction */
+	u32 psr;	/* pad satus */
+	u32 icr1;	/* interrupt config 1 */
+	u32 icr2;	/* interrupt config 2 */
+	u32 imr;	/* interrupt mask */
+	u32 isr;	/* interrupt status */
+	u32 edge_sel;	/* edge select */
+};
+
+#endif
Signature · 1 line
1.7.1
#5 lore raw

PATCH 6/14 MX31: QONG: make use of GPIO framework

In reply to Stefano Babic
---
 board/davedenx/qong/fpga.c |   10 +++++-----
 board/davedenx/qong/qong.c |   36 +++++++++++++++++-------------------
 2 files changed, 22 insertions(+), 24 deletions(-)
board/davedenx/qong/fpga.c +5 -5
index 789acf0..6536a0b 100644
@@ -25,7 +25,7 @@
 #include <common.h>
 #include <asm/arch/clock.h>
 #include <asm/arch/imx-regs.h>
-#include <mxc_gpio.h>
+#include <asm/gpio.h>
 #include <fpga.h>
 #include <lattice.h>
 #include "qong_fpga.h"
@@ -41,22 +41,22 @@ static void qong_jtag_init(void)
 
 static void qong_fpga_jtag_set_tdi(int value)
 {
-	mxc_gpio_set(QONG_FPGA_TDI_PIN, value);
+	gpio_set_value(QONG_FPGA_TDI_PIN, value);
 }
 
 static void qong_fpga_jtag_set_tms(int value)
 {
-	mxc_gpio_set(QONG_FPGA_TMS_PIN, value);
+	gpio_set_value(QONG_FPGA_TMS_PIN, value);
 }
 
 static void qong_fpga_jtag_set_tck(int value)
 {
-	mxc_gpio_set(QONG_FPGA_TCK_PIN, value);
+	gpio_set_value(QONG_FPGA_TCK_PIN, value);
 }
 
 static int qong_fpga_jtag_get_tdo(void)
 {
-	return mxc_gpio_get(QONG_FPGA_TDO_PIN);
+	return gpio_get_value(QONG_FPGA_TDO_PIN);
 }
 
 lattice_board_specific_func qong_fpga_fns = {
board/davedenx/qong/qong.c +17 -19
index ec22627..99432ed 100644
@@ -28,7 +28,7 @@
 #include <asm/io.h>
 #include <nand.h>
 #include <fsl_pmic.h>
-#include <mxc_gpio.h>
+#include <asm/gpio.h>
 #include "qong_fpga.h"
 #include <watchdog.h>
 
@@ -51,9 +51,9 @@ int dram_init (void)
 
 static void qong_fpga_reset(void)
 {
-	mxc_gpio_set(QONG_FPGA_RST_PIN, 0);
+	gpio_set_value(QONG_FPGA_RST_PIN, 0);
 	udelay(30);
-	mxc_gpio_set(QONG_FPGA_RST_PIN, 1);
+	gpio_set_value(QONG_FPGA_RST_PIN, 1);
 
 	udelay(300);
 }
@@ -76,21 +76,20 @@ int board_early_init_f (void)
 
 	/* FPGA reset  Pin */
 	/* rstn = 0 */
-	mxc_gpio_set(QONG_FPGA_RST_PIN, 0);
-	mxc_gpio_direction(QONG_FPGA_RST_PIN, MXC_GPIO_DIRECTION_OUT);
+	gpio_direction_output(QONG_FPGA_RST_PIN, 0);
 
 	/* set interrupt pin as input */
-	mxc_gpio_direction(QONG_FPGA_IRQ_PIN, MXC_GPIO_DIRECTION_IN);
+	gpio_direction_input(QONG_FPGA_IRQ_PIN);
 
 	/* FPGA JTAG Interface */
 	mx31_gpio_mux(IOMUX_MODE(MUX_CTL_SFS6, MUX_CTL_GPIO));
 	mx31_gpio_mux(IOMUX_MODE(MUX_CTL_SCK6, MUX_CTL_GPIO));
 	mx31_gpio_mux(IOMUX_MODE(MUX_CTL_CAPTURE, MUX_CTL_GPIO));
 	mx31_gpio_mux(IOMUX_MODE(MUX_CTL_COMPARE, MUX_CTL_GPIO));
-	mxc_gpio_direction(QONG_FPGA_TCK_PIN, MXC_GPIO_DIRECTION_OUT);
-	mxc_gpio_direction(QONG_FPGA_TMS_PIN, MXC_GPIO_DIRECTION_OUT);
-	mxc_gpio_direction(QONG_FPGA_TDI_PIN, MXC_GPIO_DIRECTION_OUT);
-	mxc_gpio_direction(QONG_FPGA_TDO_PIN, MXC_GPIO_DIRECTION_IN);
+	gpio_direction_output(QONG_FPGA_TCK_PIN, 0);
+	gpio_direction_output(QONG_FPGA_TMS_PIN, 0);
+	gpio_direction_output(QONG_FPGA_TDI_PIN, 0);
+	gpio_direction_input(QONG_FPGA_TDO_PIN);
 #endif
 
 	/* setup pins for UART1 */
@@ -263,27 +262,26 @@ static void board_nand_setup(void)
 	qong_fpga_reset();
 
 	/* Enable NAND flash */
-	mxc_gpio_set(15, 1);
-	mxc_gpio_set(14, 1);
-	mxc_gpio_direction(15, MXC_GPIO_DIRECTION_OUT);
-	mxc_gpio_direction(16, MXC_GPIO_DIRECTION_IN);
-	mxc_gpio_direction(14, MXC_GPIO_DIRECTION_IN);
-	mxc_gpio_set(15, 0);
+	gpio_set_value(15, 1);
+	gpio_set_value(14, 1);
+	gpio_direction_output(15, 0);
+	gpio_direction_input(16);
+	gpio_direction_input(14);
 
 }
 
 int qong_nand_rdy(void *chip)
 {
 	udelay(1);
-	return mxc_gpio_get(16);
+	return gpio_get_value(16);
 }
 
 void qong_nand_select_chip(struct mtd_info *mtd, int chip)
 {
 	if (chip >= 0)
-		mxc_gpio_set(15, 0);
+		gpio_set_value(15, 0);
 	else
-		mxc_gpio_set(15, 1);
+		gpio_set_value(15, 1);
 
 }
 
Signature · 1 line
1.7.1
#6 lore raw

PATCH 7/14 MX5: efikamx: make use of GPIO framework

In reply to Stefano Babic
---
 board/efikamx/efikamx.c |   62 ++++++++++++++++++----------------------------
 1 files changed, 24 insertions(+), 38 deletions(-)
board/efikamx/efikamx.c +24 -38
index 4b36918..5be1f6c 100644
@@ -27,7 +27,7 @@
 #include <asm/arch/imx-regs.h>
 #include <asm/arch/mx5x_pins.h>
 #include <asm/arch/iomux.h>
-#include <mxc_gpio.h>
+#include <asm/gpio.h>
 #include <asm/errno.h>
 #include <asm/arch/sys_proto.h>
 #include <asm/arch/crm_regs.h>
@@ -76,28 +76,23 @@ u32 get_efika_rev(void)
 	 *      rev1.4: 1,0,0
 	 */
 	mxc_request_iomux(MX51_PIN_NANDF_CS0, IOMUX_CONFIG_GPIO);
-	mxc_gpio_direction(IOMUX_TO_GPIO(MX51_PIN_NANDF_CS0),
-				MXC_GPIO_DIRECTION_OUT);
 	/* set to 1 in order to get correct value on board rev1.1 */
-	mxc_gpio_set(IOMUX_TO_GPIO(MX51_PIN_NANDF_CS0), 1);
+	gpio_direction_output(IOMUX_TO_GPIO(MX51_PIN_NANDF_CS0), 1);
 
 	mxc_request_iomux(MX51_PIN_NANDF_CS0, IOMUX_CONFIG_GPIO);
 	mxc_iomux_set_pad(MX51_PIN_NANDF_CS0, PAD_CTL_100K_PU);
-	mxc_gpio_direction(IOMUX_TO_GPIO(MX51_PIN_NANDF_CS0),
-				MXC_GPIO_DIRECTION_IN);
-	rev |= (!!mxc_gpio_get(IOMUX_TO_GPIO(MX51_PIN_NANDF_CS0))) << 0;
+	gpio_direction_input(IOMUX_TO_GPIO(MX51_PIN_NANDF_CS0));
+	rev |= (!!gpio_get_value(IOMUX_TO_GPIO(MX51_PIN_NANDF_CS0))) << 0;
 
 	mxc_request_iomux(MX51_PIN_NANDF_CS1, IOMUX_CONFIG_GPIO);
 	mxc_iomux_set_pad(MX51_PIN_NANDF_CS1, PAD_CTL_100K_PU);
-	mxc_gpio_direction(IOMUX_TO_GPIO(MX51_PIN_NANDF_CS1),
-				MXC_GPIO_DIRECTION_IN);
-	rev |= (!!mxc_gpio_get(IOMUX_TO_GPIO(MX51_PIN_NANDF_CS1))) << 1;
+	gpio_direction_input(IOMUX_TO_GPIO(MX51_PIN_NANDF_CS1));
+	rev |= (!!gpio_get_value(IOMUX_TO_GPIO(MX51_PIN_NANDF_CS1))) << 1;
 
 	mxc_request_iomux(MX51_PIN_NANDF_RB3, IOMUX_CONFIG_GPIO);
 	mxc_iomux_set_pad(MX51_PIN_NANDF_RB3, PAD_CTL_100K_PU);
-	mxc_gpio_direction(IOMUX_TO_GPIO(MX51_PIN_NANDF_RB3),
-				MXC_GPIO_DIRECTION_IN);
-	rev |= (!!mxc_gpio_get(IOMUX_TO_GPIO(MX51_PIN_NANDF_RB3))) << 2;
+	gpio_direction_input(IOMUX_TO_GPIO(MX51_PIN_NANDF_RB3));
+	rev |= (!!gpio_get_value(IOMUX_TO_GPIO(MX51_PIN_NANDF_RB3))) << 2;
 
 	return (~rev & 0x7) + 1;
 }
@@ -154,15 +149,11 @@ static void setup_iomux_spi(void)
 
 	/* Configure SS0 as a GPIO */
 	mxc_request_iomux(MX51_PIN_CSPI1_SS0, IOMUX_CONFIG_GPIO);
-	mxc_gpio_direction(IOMUX_TO_GPIO(MX51_PIN_CSPI1_SS0),
-				MXC_GPIO_DIRECTION_OUT);
-	mxc_gpio_set(IOMUX_TO_GPIO(MX51_PIN_CSPI1_SS0), 0);
+	gpio_direction_output(IOMUX_TO_GPIO(MX51_PIN_CSPI1_SS0), 0);
 
 	/* Configure SS1 as a GPIO */
 	mxc_request_iomux(MX51_PIN_CSPI1_SS1, IOMUX_CONFIG_GPIO);
-	mxc_gpio_direction(IOMUX_TO_GPIO(MX51_PIN_CSPI1_SS1),
-				MXC_GPIO_DIRECTION_OUT);
-	mxc_gpio_set(IOMUX_TO_GPIO(MX51_PIN_CSPI1_SS1), 1);
+	gpio_direction_output(IOMUX_TO_GPIO(MX51_PIN_CSPI1_SS1), 1);
 
 	/* 000: Select mux mode: ALT0 mux port: SS2 of instance: ecspi1. */
 	mxc_request_iomux(MX51_PIN_CSPI1_RDY, IOMUX_CONFIG_ALT0);
@@ -282,9 +273,9 @@ int board_mmc_getcd(u8 *absent, struct mmc *mmc)
 	struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc->priv;
 
 	if (cfg->esdhc_base == MMC_SDHC1_BASE_ADDR)
-		*absent = mxc_gpio_get(IOMUX_TO_GPIO(MX51_PIN_GPIO1_0));
+		*absent = gpio_get_value(IOMUX_TO_GPIO(MX51_PIN_GPIO1_0));
 	else
-		*absent = mxc_gpio_get(IOMUX_TO_GPIO(MX51_PIN_GPIO1_8));
+		*absent = gpio_get_value(IOMUX_TO_GPIO(MX51_PIN_GPIO1_8));
 
 	return 0;
 }
@@ -307,10 +298,8 @@ int board_mmc_init(bd_t *bis)
 		PAD_CTL_100K_PU | PAD_CTL_ODE_OPENDRAIN_NONE |
 		PAD_CTL_SRE_FAST);
 
-	mxc_gpio_direction(IOMUX_TO_GPIO(MX51_PIN_GPIO1_0),
-				MXC_GPIO_DIRECTION_IN);
-	mxc_gpio_direction(IOMUX_TO_GPIO(MX51_PIN_GPIO1_1),
-				MXC_GPIO_DIRECTION_IN);
+	gpio_direction_input(IOMUX_TO_GPIO(MX51_PIN_GPIO1_0));
+	gpio_direction_input(IOMUX_TO_GPIO(MX51_PIN_GPIO1_1));
 
 	/* Internal SDHC1 IOMUX + SDHC2 IOMUX on old boards */
 	if (get_efika_rev() < EFIKAMX_BOARD_REV_12) {
@@ -389,10 +378,8 @@ int board_mmc_init(bd_t *bis)
 			PAD_CTL_100K_PU | PAD_CTL_ODE_OPENDRAIN_NONE |
 			PAD_CTL_SRE_FAST);
 
-		mxc_gpio_direction(IOMUX_TO_GPIO(MX51_PIN_GPIO1_8),
-					MXC_GPIO_DIRECTION_IN);
-		mxc_gpio_direction(IOMUX_TO_GPIO(MX51_PIN_GPIO1_7),
-					MXC_GPIO_DIRECTION_IN);
+		gpio_direction_input(IOMUX_TO_GPIO(MX51_PIN_GPIO1_8));
+		gpio_direction_input(IOMUX_TO_GPIO(MX51_PIN_GPIO1_7));
 
 		ret = fsl_esdhc_initialize(bis, &esdhc_cfg[0]);
 		if (!ret)
@@ -508,25 +495,24 @@ void setup_iomux_led(void)
 {
 	/* Blue LED */
 	mxc_request_iomux(MX51_PIN_CSI1_D9, IOMUX_CONFIG_ALT3);
-	mxc_gpio_direction(IOMUX_TO_GPIO(MX51_PIN_CSI1_D9),
-				MXC_GPIO_DIRECTION_OUT);
+	gpio_direction_output(IOMUX_TO_GPIO(MX51_PIN_CSI1_D9), 0);
+
 	/* Green LED */
 	mxc_request_iomux(MX51_PIN_CSI1_VSYNC, IOMUX_CONFIG_ALT3);
-	mxc_gpio_direction(IOMUX_TO_GPIO(MX51_PIN_CSI1_VSYNC),
-				MXC_GPIO_DIRECTION_OUT);
+	gpio_direction_output(IOMUX_TO_GPIO(MX51_PIN_CSI1_VSYNC), 0);
+
 	/* Red LED */
 	mxc_request_iomux(MX51_PIN_CSI1_HSYNC, IOMUX_CONFIG_ALT3);
-	mxc_gpio_direction(IOMUX_TO_GPIO(MX51_PIN_CSI1_HSYNC),
-				MXC_GPIO_DIRECTION_OUT);
+	gpio_direction_output(IOMUX_TO_GPIO(MX51_PIN_CSI1_HSYNC), 0);
 }
 
 void efikamx_toggle_led(uint32_t mask)
 {
-	mxc_gpio_set(IOMUX_TO_GPIO(MX51_PIN_CSI1_D9),
+	gpio_set_value(IOMUX_TO_GPIO(MX51_PIN_CSI1_D9),
 			mask & EFIKAMX_LED_BLUE);
-	mxc_gpio_set(IOMUX_TO_GPIO(MX51_PIN_CSI1_VSYNC),
+	gpio_set_value(IOMUX_TO_GPIO(MX51_PIN_CSI1_VSYNC),
 			mask & EFIKAMX_LED_GREEN);
-	mxc_gpio_set(IOMUX_TO_GPIO(MX51_PIN_CSI1_HSYNC),
+	gpio_set_value(IOMUX_TO_GPIO(MX51_PIN_CSI1_HSYNC),
 			mask & EFIKAMX_LED_RED);
 }
 
Signature · 1 line
1.7.1
#7 lore raw

PATCH 7/14 MX5: efikamx: make use of GPIO framework

Quoted 11 lines · Stefano Babic
---
 board/efikamx/efikamx.c |   62

++++++++++++++++++---------------------------- 1 files changed, 24 insertions(+), 38 deletions(-)

board/efikamx/efikamx.c +0 -0
index 4b36918..5be1f6c 100644

[...]

Quoted 9 lines
board/efikamx/efikamx.c +2 -2
@@ -508,25 +495,24 @@ void setup_iomux_led(void)
 {
 	/* Blue LED */
 	mxc_request_iomux(MX51_PIN_CSI1_D9, IOMUX_CONFIG_ALT3);
-	mxc_gpio_direction(IOMUX_TO_GPIO(MX51_PIN_CSI1_D9),
-				MXC_GPIO_DIRECTION_OUT);
+	gpio_direction_output(IOMUX_TO_GPIO(MX51_PIN_CSI1_D9), 0);
+
 	/* Green LED */

board/efikamx/efikamx.c void setup_iomux_led(void) · line 506

Quoted 10 lines
board/efikamx/efikamx.c +3 -4
 	mxc_request_iomux(MX51_PIN_CSI1_VSYNC, IOMUX_CONFIG_ALT3);
-	mxc_gpio_direction(IOMUX_TO_GPIO(MX51_PIN_CSI1_VSYNC),
-				MXC_GPIO_DIRECTION_OUT);
+	gpio_direction_output(IOMUX_TO_GPIO(MX51_PIN_CSI1_VSYNC), 0);
+
 	/* Red LED */
 	mxc_request_iomux(MX51_PIN_CSI1_HSYNC, IOMUX_CONFIG_ALT3);
-	mxc_gpio_direction(IOMUX_TO_GPIO(MX51_PIN_CSI1_HSYNC),
-				MXC_GPIO_DIRECTION_OUT);
+	gpio_direction_output(IOMUX_TO_GPIO(MX51_PIN_CSI1_HSYNC), 0);

I'd be careful about the LEDs here. Anyway, I'll try to test it sometimes soon (begining of next week is ok?). If you won't get any feedback, you can have my Ack.

Quoted 4 lines
board/efikamx/efikamx.c +0 -0
 }
 
 void efikamx_toggle_led(uint32_t mask)
 {

board/efikamx/efikamx.c void setup_iomux_led(void) · line 517

Quoted 10 lines
board/efikamx/efikamx.c +3 -3
-	mxc_gpio_set(IOMUX_TO_GPIO(MX51_PIN_CSI1_D9),
+	gpio_set_value(IOMUX_TO_GPIO(MX51_PIN_CSI1_D9),
 			mask & EFIKAMX_LED_BLUE);
-	mxc_gpio_set(IOMUX_TO_GPIO(MX51_PIN_CSI1_VSYNC),
+	gpio_set_value(IOMUX_TO_GPIO(MX51_PIN_CSI1_VSYNC),
 			mask & EFIKAMX_LED_GREEN);
-	mxc_gpio_set(IOMUX_TO_GPIO(MX51_PIN_CSI1_HSYNC),
+	gpio_set_value(IOMUX_TO_GPIO(MX51_PIN_CSI1_HSYNC),
 			mask & EFIKAMX_LED_RED);
 }

Thanks Stefano, this really helps.

Cheers

#8 lore raw

PATCH 7/14 MX5: efikamx: make use of GPIO framework

Quoted 4 lines · Marek Vasut
Quoted 3 lines · Stefano Babic

---

Hi Marek,

Quoted 3 lines

board/efikamx/efikamx.c void setup_iomux_led(void) · line 506

Quoted 1 line
board/efikamx/efikamx.c +1 -0
+	gpio_direction_output(IOMUX_TO_GPIO(MX51_PIN_CSI1_HSYNC), 0);

I'd be careful about the LEDs here.

Well, I have seen the LEDs were not explicitely initialized. Maybe it relies on the default value of the DR register, that should be zero.

Quoted 2 lines

Anyway, I'll try to test it sometimes soon
(begining of next week is ok?).

Of course, yes. Thanks for testing !

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================
#9 lore raw

PATCH 7/14 MX5: efikamx: make use of GPIO framework

Quoted 12 lines · Stefano Babic
Quoted 4 lines · Marek Vasut
Quoted 3 lines · Stefano Babic

---

Hi Marek,

Quoted 3 lines

board/efikamx/efikamx.c void setup_iomux_led(void) · line 506

Quoted 1 line
board/efikamx/efikamx.c +1 -0
+	gpio_direction_output(IOMUX_TO_GPIO(MX51_PIN_CSI1_HSYNC), 0);

I'd be careful about the LEDs here.

Quoted 7 lines

Well, I have seen the LEDs were not explicitely initialized. Maybe it relies on the default value of the DR register, that should be zero.

Quoted 2 lines

Anyway, I'll try to test it sometimes soon
(begining of next week is ok?).

Of course, yes. Thanks for testing !

Well damn, my efikamx didn't arrive today as planned. You can merge it, according to the schematics it looks ok.

Cheers

Quoted 3 lines

Best regards,
Stefano Babic

#10 lore raw

PATCH 8/14 MX25: zmx25: make use of GPIO framework

In reply to Stefano Babic
CC Matthias Weisser <[email protected]>
---
 board/syteco/zmx25/zmx25.c |   35 ++++++++++++++---------------------
 1 files changed, 14 insertions(+), 21 deletions(-)
board/syteco/zmx25/zmx25.c +14 -21
index f055038..893adc6 100644
@@ -29,7 +29,7 @@
  *
  */
 #include <common.h>
-#include <mxc_gpio.h>
+#include <asm/gpio.h>
 #include <asm/io.h>
 #include <asm/arch/imx-regs.h>
 #include <asm/arch/imx25-pinmux.h>
@@ -56,8 +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] */
-	mxc_gpio_direction(MXC_GPIO_PORT_TO_NUM(3, 15), MXC_GPIO_DIRECTION_OUT);
-	mxc_gpio_set(MXC_GPIO_PORT_TO_NUM(3, 15), 1);
+	gpio_direction_output(MXC_GPIO_PORT_TO_NUM(3, 15), 1);
 
 	/* Setup of input daisy chains for SD card pins*/
 	writel(gpio_mux_mode0_sion, &muxctl->pad_sd1_cmd);
@@ -69,11 +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] */
-	mxc_gpio_direction(MXC_GPIO_PORT_TO_NUM(1, 28), MXC_GPIO_DIRECTION_OUT);
-	mxc_gpio_set(MXC_GPIO_PORT_TO_NUM(1, 28), 1);
+	gpio_direction_output(MXC_GPIO_PORT_TO_NUM(1, 28), 1);
 
 	writel(gpio_mux_mode5, &muxctl->pad_csi_d2); /* USB OC GPIO1[27] */
-	mxc_gpio_direction(MXC_GPIO_PORT_TO_NUM(1, 18), MXC_GPIO_DIRECTION_IN);
+	gpio_direction_input(MXC_GPIO_PORT_TO_NUM(1, 18));
 
 	/* Setup of digital output control pins */
 	writel(gpio_mux_mode5, &muxctl->pad_csi_d8); /* Ouput 1 Ctrl GPIO1[7] */
@@ -85,25 +83,21 @@ int board_init()
 	writel(0, &padctl->pad_csi_d5); /* Ouput 2 Stat pull up off */
 
 	/* Switch both output drivers off */
-	mxc_gpio_set(MXC_GPIO_PORT_TO_NUM(1, 7), 0);
-	mxc_gpio_direction(MXC_GPIO_PORT_TO_NUM(1, 7), MXC_GPIO_DIRECTION_OUT);
-	mxc_gpio_set(MXC_GPIO_PORT_TO_NUM(1, 6), 0);
-	mxc_gpio_direction(MXC_GPIO_PORT_TO_NUM(1, 6), MXC_GPIO_DIRECTION_OUT);
+	gpio_direction_output(MXC_GPIO_PORT_TO_NUM(1, 7), 0);
+	gpio_direction_output(MXC_GPIO_PORT_TO_NUM(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 */
-	mxc_gpio_direction(MXC_GPIO_PORT_TO_NUM(2, 29), MXC_GPIO_DIRECTION_IN);
+	gpio_direction_input(MXC_GPIO_PORT_TO_NUM(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 */
-	mxc_gpio_set(MXC_GPIO_PORT_TO_NUM(4, 21), 0);
-	mxc_gpio_direction(MXC_GPIO_PORT_TO_NUM(4, 21), MXC_GPIO_DIRECTION_OUT);
-	mxc_gpio_set(MXC_GPIO_PORT_TO_NUM(1, 29), 0);
-	mxc_gpio_direction(MXC_GPIO_PORT_TO_NUM(1, 29), MXC_GPIO_DIRECTION_OUT);
+	gpio_direction_output(MXC_GPIO_PORT_TO_NUM(4, 21), 0);
+	gpio_direction_output(MXC_GPIO_PORT_TO_NUM(1, 29), 0);
 
 	/* Setup of CAN1 and CAN2 signals */
 	writel(gpio_mux_mode6, &muxctl->pad_gpio_a);	/* CAN1 TX */
@@ -158,13 +152,12 @@ int board_late_init(void)
 	writel(gpio_mux_mode2, &muxctl->pad_uart2_cts);
 
 	/* assert PHY reset (low) */
-	mxc_gpio_set(MXC_GPIO_PORT_TO_NUM(3, 16), 0);
-	mxc_gpio_direction(MXC_GPIO_PORT_TO_NUM(3, 16), MXC_GPIO_DIRECTION_OUT);
+	gpio_direction_output(MXC_GPIO_PORT_TO_NUM(3, 16), 0);
 
 	udelay(5000);
 
 	/* deassert PHY reset */
-	mxc_gpio_set(MXC_GPIO_PORT_TO_NUM(3, 16), 1);
+	gpio_set_value(MXC_GPIO_PORT_TO_NUM(3, 16), 1);
 
 	udelay(5000);
 #endif
@@ -172,12 +165,12 @@ int board_late_init(void)
 	e = getenv("gs_base_board");
 	if (e != NULL) {
 		if (strcmp(e, "G283") == 0) {
-			int key = mxc_gpio_get(MXC_GPIO_PORT_TO_NUM(2, 29));
+			int key = gpio_get_value(MXC_GPIO_PORT_TO_NUM(2, 29));
 
 			if (key) {
 				/* Switch on both LEDs to inidcate boot mode */
-				mxc_gpio_set(MXC_GPIO_PORT_TO_NUM(1, 29), 0);
-				mxc_gpio_set(MXC_GPIO_PORT_TO_NUM(4, 21), 0);
+				gpio_set_value(MXC_GPIO_PORT_TO_NUM(1, 29), 0);
+				gpio_set_value(MXC_GPIO_PORT_TO_NUM(4, 21), 0);
 
 				setenv("preboot", "run gs_slow_boot");
 			} else
Signature · 1 line
1.7.1
#11 lore raw

PATCH 9/14 MX5: mx53ard: make use of GPIO framework

In reply to Stefano Babic
---
 board/freescale/mx53ard/mx53ard.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
board/freescale/mx53ard/mx53ard.c +4 -4
index 134603a..6e3360b 100644
@@ -31,7 +31,7 @@
 #include <netdev.h>
 #include <mmc.h>
 #include <fsl_esdhc.h>
-#include <mxc_gpio.h>
+#include <asm/gpio.h>
 
 #define ETHERNET_INT		(1 * 32 + 31)  /* GPIO2_31 */
 
@@ -93,9 +93,9 @@ int board_mmc_getcd(u8 *cd, struct mmc *mmc)
 	struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc->priv;
 
 	if (cfg->esdhc_base == MMC_SDHC1_BASE_ADDR)
-		*cd = mxc_gpio_get(1); /*GPIO1_1*/
+		*cd = gpio_get_value(1); /*GPIO1_1*/
 	else
-		*cd = mxc_gpio_get(4); /*GPIO1_4*/
+		*cd = gpio_get_value(4); /*GPIO1_4*/
 
 	return 0;
 }
@@ -176,7 +176,7 @@ static void weim_smc911x_iomux(void)
 {
 	/* ETHERNET_INT as GPIO2_31 */
 	mxc_request_iomux(MX53_PIN_EIM_EB3, IOMUX_CONFIG_ALT1);
-	mxc_gpio_direction(ETHERNET_INT, MXC_GPIO_DIRECTION_IN);
+	gpio_direction_input(ETHERNET_INT);
 
 	/* Data bus */
 	mxc_request_iomux(MX53_PIN_EIM_D16, IOMUX_CONFIG_ALT0);
Signature · 1 line
1.7.1
#12 lore raw

PATCH 10/14 MX5: mx53smd: make use of GPIO framework

In reply to Stefano Babic
---
 board/freescale/mx53smd/mx53smd.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
board/freescale/mx53smd/mx53smd.c +2 -2
index 21b5d14..4a7ee55 100644
@@ -31,7 +31,7 @@
 #include <netdev.h>
 #include <mmc.h>
 #include <fsl_esdhc.h>
-#include <mxc_gpio.h>
+#include <asm/gpio.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -139,7 +139,7 @@ struct fsl_esdhc_cfg esdhc_cfg[1] = {
 
 int board_mmc_getcd(u8 *cd, struct mmc *mmc)
 {
-	*cd = mxc_gpio_get(77); /*GPIO3_13*/
+	*cd = gpio_get_value(77); /*GPIO3_13*/
 
 	return 0;
 }
Signature · 1 line
1.7.1
#13 lore raw

PATCH 11/14 MX5: vision2: make use of GPIO framework

In reply to Stefano Babic
---
 board/ttcontrol/vision2/vision2.c |   71 ++++++++++++++-----------------------
 1 files changed, 27 insertions(+), 44 deletions(-)
board/ttcontrol/vision2/vision2.c +27 -44
index 565c4d0..17a2558 100644
@@ -29,7 +29,7 @@
 #include <asm/arch/mx5x_pins.h>
 #include <asm/arch/crm_regs.h>
 #include <asm/arch/iomux.h>
-#include <mxc_gpio.h>
+#include <asm/gpio.h>
 #include <asm/arch/sys_proto.h>
 #include <asm/errno.h>
 #include <i2c.h>
@@ -69,9 +69,9 @@ void hw_watchdog_reset(void)
 	int val;
 
 	/* toggle watchdog trigger pin */
-	val = mxc_gpio_get(66);
+	val = gpio_get_value(66);
 	val = val ? 0 : 1;
-	mxc_gpio_set(66, val);
+	gpio_set_value(66, val);
 }
 #endif
 
@@ -233,30 +233,22 @@ static void reset_peripherals(int reset)
 	if (reset) {
 
 		/* reset_n is on NANDF_D15 */
-		mxc_gpio_set(89, 0);
-		mxc_gpio_direction(89, MXC_GPIO_DIRECTION_OUT);
+		gpio_direction_output(89, 0);
 
 #ifdef CONFIG_VISION2_HW_1_0
 		/*
 		 * set FEC Configuration lines
 		 * set levels of FEC config lines
 		 */
-		mxc_gpio_set(75, 0);
-		mxc_gpio_set(74, 1);
-		mxc_gpio_set(95, 1);
-		mxc_gpio_direction(75, MXC_GPIO_DIRECTION_OUT);
-		mxc_gpio_direction(74, MXC_GPIO_DIRECTION_OUT);
-		mxc_gpio_direction(95, MXC_GPIO_DIRECTION_OUT);
+		gpio_direction_output(75, 0);
+		gpio_direction_output(74, 1);
+		gpio_direction_output(95, 1);
 
 		/* set direction of FEC config lines */
-		mxc_gpio_set(59, 0);
-		mxc_gpio_set(60, 0);
-		mxc_gpio_set(61, 0);
-		mxc_gpio_set(55, 1);
-		mxc_gpio_direction(59, MXC_GPIO_DIRECTION_OUT);
-		mxc_gpio_direction(60, MXC_GPIO_DIRECTION_OUT);
-		mxc_gpio_direction(61, MXC_GPIO_DIRECTION_OUT);
-		mxc_gpio_direction(55, MXC_GPIO_DIRECTION_OUT);
+		gpio_direction_output(59, 0);
+		gpio_direction_output(60, 0);
+		gpio_direction_output(61, 0);
+		gpio_direction_output(55, 1);
 
 		/* FEC_RXD1 - sel GPIO (2-23) for configuration -> 1 */
 		mxc_request_iomux(MX51_PIN_EIM_EB3, IOMUX_CONFIG_ALT1);
@@ -283,7 +275,7 @@ static void reset_peripherals(int reset)
 			PAD_CTL_DRV_VOT_HIGH | PAD_CTL_DRV_MAX);
 	} else {
 		/* set FEC Control lines */
-		mxc_gpio_direction(89, MXC_GPIO_DIRECTION_IN);
+		gpio_direction_input(89);
 		udelay(500);
 
 #ifdef CONFIG_VISION2_HW_1_0
@@ -438,31 +430,23 @@ static void setup_gpios(void)
 	 * Set GPIO1_4 to high and output; it is used to reset
 	 * the system on reboot
 	 */
-	mxc_gpio_set(4, 1);
-	mxc_gpio_direction(4, MXC_GPIO_DIRECTION_OUT);
+	gpio_direction_output(4, 1);
 
-	mxc_gpio_set(7, 0);
-	mxc_gpio_direction(7, MXC_GPIO_DIRECTION_OUT);
+	gpio_direction_output(7, 0);
 	for (i = 65; i < 71; i++) {
-		mxc_gpio_set(i, 0);
-		mxc_gpio_direction(i, MXC_GPIO_DIRECTION_OUT);
+		gpio_direction_output(i, 0);
 	}
 
-	mxc_gpio_set(94, 0);
-	mxc_gpio_direction(94, MXC_GPIO_DIRECTION_OUT);
+	gpio_direction_output(94, 0);
 
 	/* Set POWER_OFF high */
-	mxc_gpio_set(91, 1);
-	mxc_gpio_direction(91, MXC_GPIO_DIRECTION_OUT);
+	gpio_direction_output(91, 1);
 
-	mxc_gpio_set(90, 0);
-	mxc_gpio_direction(90, MXC_GPIO_DIRECTION_OUT);
+	gpio_direction_output(90, 0);
 
-	mxc_gpio_set(122, 0);
-	mxc_gpio_direction(122, MXC_GPIO_DIRECTION_OUT);
+	gpio_direction_output(122, 0);
 
-	mxc_gpio_set(121, 1);
-	mxc_gpio_direction(121, MXC_GPIO_DIRECTION_OUT);
+	gpio_direction_output(121, 1);
 
 	WATCHDOG_RESET();
 }
@@ -551,7 +535,7 @@ int get_mmc_getcd(u8 *cd, struct mmc *mmc)
 	struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc->priv;
 
 	if (cfg->esdhc_base == MMC_SDHC1_BASE_ADDR)
-		*cd = mxc_gpio_get(0);
+		*cd = gpio_get_value(0);
 	else
 		*cd = 0;
 
@@ -623,8 +607,7 @@ int board_early_init_f(void)
 	init_drive_strength();
 
 	/* Setup debug led */
-	mxc_gpio_set(6, 0);
-	mxc_gpio_direction(6, MXC_GPIO_DIRECTION_OUT);
+	gpio_direction_output(6, 0);
 	mxc_request_iomux(MX51_PIN_GPIO1_6, IOMUX_CONFIG_ALT0);
 	mxc_iomux_set_pad(MX51_PIN_GPIO1_6, PAD_CTL_DRV_MAX | PAD_CTL_SRE_FAST);
 
@@ -644,12 +627,12 @@ int board_early_init_f(void)
 static void backlight(int on)
 {
 	if (on) {
-		mxc_gpio_set(65, 1);
+		gpio_set_value(65, 1);
 		udelay(10000);
-		mxc_gpio_set(68, 1);
+		gpio_set_value(68, 1);
 	} else {
-		mxc_gpio_set(65, 0);
-		mxc_gpio_set(68, 0);
+		gpio_set_value(65, 0);
+		gpio_set_value(68, 0);
 	}
 }
 
@@ -660,7 +643,7 @@ void lcd_enable(void)
 	mxc_request_iomux(MX51_PIN_DI1_PIN2, IOMUX_CONFIG_ALT0);
 	mxc_request_iomux(MX51_PIN_DI1_PIN3, IOMUX_CONFIG_ALT0);
 
-	mxc_gpio_set(2, 1);
+	gpio_set_value(2, 1);
 	mxc_request_iomux(MX51_PIN_GPIO1_2, IOMUX_CONFIG_ALT0);
 
 	ret = mx51_fb_init(&nec_nl6448bc26_09c);
Signature · 1 line
1.7.1
#14 lore raw

PATCH 12/14 MX5: mx53evk: make use of GPIO framework

In reply to Stefano Babic
---
 board/freescale/mx53evk/mx53evk.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
board/freescale/mx53evk/mx53evk.c +3 -3
index 88095dc..81857ff 100644
@@ -33,7 +33,7 @@
 #include <mmc.h>
 #include <fsl_esdhc.h>
 #include <fsl_pmic.h>
-#include <mxc_gpio.h>
+#include <asm/gpio.h>
 #include <mc13892.h>
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -213,9 +213,9 @@ int board_mmc_getcd(u8 *cd, struct mmc *mmc)
 	struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc->priv;
 
 	if (cfg->esdhc_base == MMC_SDHC1_BASE_ADDR)
-		*cd = mxc_gpio_get(77); /*GPIO3_13*/
+		*cd = gpio_get_value(77); /*GPIO3_13*/
 	else
-		*cd = mxc_gpio_get(75); /*GPIO3_11*/
+		*cd = gpio_get_value(75); /*GPIO3_11*/
 
 	return 0;
 }
Signature · 1 line
1.7.1
#15 lore raw

PATCH 12/14 MX5: mx53evk: make use of GPIO framework

2011/8/21 Stefano Babic <[email protected]>:

Quoted 29 lines

---
?board/freescale/mx53evk/mx53evk.c | ? ?6 +++---
?1 files changed, 3 insertions(+), 3 deletions(-)

board/freescale/mx53evk/mx53evk.c +0 -0
index 88095dc..81857ff 100644
@@ -33,7 +33,7 @@

?#include <mmc.h>
?#include <fsl_esdhc.h>
?#include <fsl_pmic.h>

board/freescale/mx53evk/mx53evk.c +1 -1
-#include <mxc_gpio.h>
+#include <asm/gpio.h>

?#include <mc13892.h>

?DECLARE_GLOBAL_DATA_PTR;

board/freescale/mx53evk/mx53evk.c +1 -1
@@ -213,9 +213,9 @@ int board_mmc_getcd(u8 *cd, struct mmc *mmc)
 ? ? ? ?struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc->priv;
 
 ? ? ? ?if (cfg->esdhc_base == MMC_SDHC1_BASE_ADDR)
- ? ? ? ? ? ? ? *cd = mxc_gpio_get(77); /*GPIO3_13*/
+ ? ? ? ? ? ? ? *cd = gpio_get_value(77); /*GPIO3_13*/

? ? ? ?else
- ? ? ? ? ? ? ? *cd = mxc_gpio_get(75); /*GPIO3_11*/
+ ? ? ? ? ? ? ? *cd = gpio_get_value(75); /*GPIO3_11*/

Quoted 2 lines

? ? ? ?return 0;
?}

Quoted 8 lines

--
1.7.1

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

#16 lore raw

PATCH 13/14 MX5: mx53loco: make use of GPIO framework

In reply to Stefano Babic
---
 board/freescale/mx53loco/mx53loco.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
board/freescale/mx53loco/mx53loco.c +3 -3
index 18b388e..ade1006 100644
@@ -34,7 +34,7 @@
 #include <i2c.h>
 #include <mmc.h>
 #include <fsl_esdhc.h>
-#include <mxc_gpio.h>
+#include <asm/gpio.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -146,9 +146,9 @@ int board_mmc_getcd(u8 *cd, struct mmc *mmc)
 	struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc->priv;
 
 	if (cfg->esdhc_base == MMC_SDHC1_BASE_ADDR)
-		*cd = mxc_gpio_get(77); /*GPIO3_13*/
+		*cd = gpio_get_value(77); /*GPIO3_13*/
 	else
-		*cd = mxc_gpio_get(75); /*GPIO3_11*/
+		*cd = gpio_get_value(75); /*GPIO3_11*/
 
 	return 0;
 }
Signature · 1 line
1.7.1
#17 lore raw

PATCH 13/14 MX5: mx53loco: make use of GPIO framework

2011/8/21 Stefano Babic <[email protected]>:

Quoted 29 lines

---
?board/freescale/mx53loco/mx53loco.c | ? ?6 +++--- ?1 files changed, 3 insertions(+), 3 deletions(-)

board/freescale/mx53loco/mx53loco.c +0 -0
index 18b388e..ade1006 100644
@@ -34,7 +34,7 @@

?#include <i2c.h>
?#include <mmc.h>
?#include <fsl_esdhc.h>

board/freescale/mx53loco/mx53loco.c +1 -1
-#include <mxc_gpio.h>
+#include <asm/gpio.h>

?DECLARE_GLOBAL_DATA_PTR;

board/freescale/mx53loco/mx53loco.c +1 -1
@@ -146,9 +146,9 @@ int board_mmc_getcd(u8 *cd, struct mmc *mmc)
 ? ? ? ?struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc->priv;
 
 ? ? ? ?if (cfg->esdhc_base == MMC_SDHC1_BASE_ADDR)
- ? ? ? ? ? ? ? *cd = mxc_gpio_get(77); /*GPIO3_13*/
+ ? ? ? ? ? ? ? *cd = gpio_get_value(77); /*GPIO3_13*/

? ? ? ?else
- ? ? ? ? ? ? ? *cd = mxc_gpio_get(75); /*GPIO3_11*/
+ ? ? ? ? ? ? ? *cd = gpio_get_value(75); /*GPIO3_11*/

Quoted 2 lines

? ? ? ?return 0;
?}

Quoted 8 lines

--
1.7.1

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

#18 lore raw

PATCH 13/14 MX5: mx53loco: make use of GPIO framework

Quoted 4 lines · Jason Liu

2011/8/21 Stefano Babic <[email protected]>:

Quoted 3 lines

---

Hi Jason,

Quoted 2 lines

Thanks for testing !

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================
#19 lore raw

PATCH 14/14 MX35: mx35pdk: make use of GPIO framework

In reply to Stefano Babic
---
 board/freescale/mx35pdk/mx35pdk.c |    5 ++---
 include/configs/mx35pdk.h         |    1 +
 2 files changed, 3 insertions(+), 3 deletions(-)
board/freescale/mx35pdk/mx35pdk.c +2 -3
index a6b5a51..9eefe5e 100644
@@ -34,7 +34,7 @@
 #include <mc9sdz60.h>
 #include <mc13892.h>
 #include <linux/types.h>
-#include <mxc_gpio.h>
+#include <asm/gpio.h>
 #include <asm/arch/sys_proto.h>
 #include <netdev.h>
 
@@ -240,8 +240,7 @@ int board_late_init(void)
 		mxc_request_iomux(MX35_PIN_COMPARE, MUX_CONFIG_GPIO);
 		mxc_iomux_set_input(MUX_IN_GPIO1_IN_5, INPUT_CTL_PATH0);
 
-		mxc_gpio_direction(37, MXC_GPIO_DIRECTION_OUT);
-		mxc_gpio_set(37, 1);
+		gpio_direction_output(37, 1);
 	}
 
 	val = mc9sdz60_reg_read(MC9SDZ60_REG_GPIO_1) | 0x04;
include/configs/mx35pdk.h +1 -0
index 0d4b733..4e9022d 100644
@@ -63,6 +63,7 @@
 #define CONFIG_SYS_I2C_SPEED		100000
 #define CONFIG_SYS_I2C_SLAVE		0xfe
 #define CONFIG_MXC_SPI
+#define CONFIG_MXC_GPIO
 
 
 /*
Signature · 1 line
1.7.1
reviewer
#20 lore raw

PATCH 1/14 IMX: uniform GPIO interface using GPIO framework

In reply to Stefano Babic

Hi Stefano,

Quoted 4 lines · Stefano Babic

IMX processors has a slightly different interface to access GPIOs and do not make use of the provided GPIO framework. The patch substitutes mxc_ specific functions and make use of the API in asm/gpio.h

This is a nice series. I am wondering if mx51evk is missing.

Regards,

Fabio Estevam

#21 lore raw

PATCH 1/14 IMX: uniform GPIO interface using GPIO framework

Quoted 2 lines · Fabio Estevam

Hi Stefano,

Hi Fabio,

Quoted 7 lines · Stefano Babic
Quoted 4 lines

IMX processors has a slightly different interface to access GPIOs and do not make use of the provided GPIO framework. The patch substitutes mxc_ specific functions and make use of the API in asm/gpio.h

This is a nice series. I am wondering if mx51evk is missing.

mx51evk is nastier because it access directly GPIOs register instead of using the driver. I prepared the patch to clean up and I post now as last of the series.

Stefano

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================
#22 lore raw

PATCH 15/15 MX5: mx51evk: make use of GPIO framework

In reply to Stefano Babic
---
 board/freescale/mx51evk/mx51evk.c |   18 +++++-------------
 include/configs/mx51evk.h         |    1 +
 2 files changed, 6 insertions(+), 13 deletions(-)
board/freescale/mx51evk/mx51evk.c +5 -13
index fd7342f..94ea1f2 100644
@@ -22,6 +22,7 @@
 
 #include <common.h>
 #include <asm/io.h>
+#include <asm/gpio.h>
 #include <asm/arch/imx-regs.h>
 #include <asm/arch/mx5x_pins.h>
 #include <asm/arch/iomux.h>
@@ -180,7 +181,6 @@ static void setup_iomux_spi(void)
 static void power_init(void)
 {
 	unsigned int val;
-	unsigned int reg;
 	struct mxc_ccm_reg *mxc_ccm = (struct mxc_ccm_reg *)MXC_CCM_BASE;
 
 	/* Write needed to Power Gate 2 register */
@@ -249,13 +249,7 @@ static void power_init(void)
 	pmic_reg_write(REG_MODE_1, val);
 	udelay(200);
 
-	reg = readl(GPIO2_BASE_ADDR + 0x0);
-	reg &= ~0x4000;  /* Lower reset line */
-	writel(reg, GPIO2_BASE_ADDR + 0x0);
-
-	reg = readl(GPIO2_BASE_ADDR + 0x4);
-	reg |= 0x4000;	/* configure GPIO lines as output */
-	writel(reg, GPIO2_BASE_ADDR + 0x4);
+	gpio_direction_output(46, 0);
 
 	/* Reset the ethernet controller over GPIO */
 	writel(0x1, IOMUXC_BASE_ADDR + 0x0AC);
@@ -267,9 +261,7 @@ static void power_init(void)
 
 	udelay(500);
 
-	reg = readl(GPIO2_BASE_ADDR + 0x0);
-	reg |= 0x4000;
-	writel(reg, GPIO2_BASE_ADDR + 0x0);
+	gpio_set_value(46, 1);
 }
 
 #ifdef CONFIG_FSL_ESDHC
@@ -278,9 +270,9 @@ int board_mmc_getcd(u8 *cd, struct mmc *mmc)
 	struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc->priv;
 
 	if (cfg->esdhc_base == MMC_SDHC1_BASE_ADDR)
-		*cd = readl(GPIO1_BASE_ADDR) & 0x01;
+		*cd = gpio_get_value(0);
 	else
-		*cd = readl(GPIO1_BASE_ADDR) & 0x40;
+		*cd = gpio_get_value(6);
 
 	return 0;
 }
include/configs/mx51evk.h +1 -0
index 3f2aca1..7d05dc8 100644
@@ -60,6 +60,7 @@
  */
 #define CONFIG_MXC_UART
 #define CONFIG_SYS_MX51_UART1
+#define CONFIG_MXC_GPIO
 
 /*
  * SPI Configs
Signature · 1 line
1.7.1
#23 lore raw

PATCH 16/17 MX31: mx31ads: make use of GPIO framework

In reply to Stefano Babic
---
 include/configs/mx31ads.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
include/configs/mx31ads.h +1 -0
index 3c61911..adb2ee1 100644
@@ -65,6 +65,7 @@
 #define CONFIG_MXC_SPI		1
 #define CONFIG_DEFAULT_SPI_BUS	1
 #define CONFIG_DEFAULT_SPI_MODE	(SPI_MODE_0 | SPI_CS_HIGH)
+#define CONFIG_MXC_GPIO
 
 #define CONFIG_FSL_PMIC
 #define CONFIG_FSL_PMIC_BUS	1
Signature · 1 line
1.7.1
#24 lore raw

PATCH 17/17 MX31: imx31_litekit: make use of GPIO framework

In reply to Stefano Babic
---
 include/configs/imx31_litekit.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
include/configs/imx31_litekit.h +1 -0
index 1131db0..b7f1cb3 100644
@@ -63,6 +63,7 @@
 
 #define CONFIG_MXC_UART	1
 #define CONFIG_SYS_MX31_UART1		1
+#define CONFIG_MXC_GPIO
 
 #define CONFIG_HARD_SPI		1
 #define CONFIG_MXC_SPI		1
Signature · 1 line
1.7.1