public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/2] omap: Don't use gpio_free to change direction to input
@ 2011-10-06 20:45 Joe Hershberger
  2011-10-06 20:45 ` [U-Boot] [PATCH 2/2] omap4_panda: Build in cmd_gpio support on panda Joe Hershberger
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Joe Hershberger @ 2011-10-06 20:45 UTC (permalink / raw)
  To: u-boot

gpio_free() should not have the side effect of setting the line to input since this prevents the gpio command from being able to set a line as output.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Cc: Joe Hershberger <joe.hershberger@gmail.com>
Cc: Sandeep Paulraj <s-paulraj@ti.com>
---
 arch/arm/cpu/armv7/omap-common/gpio.c |    7 -------
 board/logicpd/zoom2/debug_board.c     |    1 -
 board/logicpd/zoom2/zoom2.c           |    1 -
 board/overo/overo.c                   |    7 +------
 board/ti/beagle/beagle.c              |    6 ------
 5 files changed, 1 insertions(+), 21 deletions(-)

diff --git a/arch/arm/cpu/armv7/omap-common/gpio.c b/arch/arm/cpu/armv7/omap-common/gpio.c
index e62c6f4..75a02da 100644
--- a/arch/arm/cpu/armv7/omap-common/gpio.c
+++ b/arch/arm/cpu/armv7/omap-common/gpio.c
@@ -237,11 +237,4 @@ int gpio_request(int gpio, const char *label)
  */
 void gpio_free(unsigned gpio)
 {
-	const struct gpio_bank *bank;
-
-	if (check_gpio(gpio) < 0)
-		return;
-	bank = get_gpio_bank(gpio);
-
-	_set_gpio_direction(bank, get_gpio_index(gpio), 1);
 }
diff --git a/board/logicpd/zoom2/debug_board.c b/board/logicpd/zoom2/debug_board.c
index 33aa600..071e7f9 100644
--- a/board/logicpd/zoom2/debug_board.c
+++ b/board/logicpd/zoom2/debug_board.c
@@ -40,7 +40,6 @@ static void zoom2_debug_board_detect (void)
 		 */
 		gpio_direction_input(158);
 		val = gpio_get_value(158);
-		gpio_free(158);
 	}
 
 	if (!val)
diff --git a/board/logicpd/zoom2/zoom2.c b/board/logicpd/zoom2/zoom2.c
index 21964c2..be3083d 100644
--- a/board/logicpd/zoom2/zoom2.c
+++ b/board/logicpd/zoom2/zoom2.c
@@ -95,7 +95,6 @@ void zoom2_identify(void)
 
 		gpio_direction_input(94);
 		val = gpio_get_value(94);
-		gpio_free(94);
 
 		if (val)
 			revision = ZOOM2_REVISION_BETA;
diff --git a/board/overo/overo.c b/board/overo/overo.c
index 850dfee..bdbd7f3 100644
--- a/board/overo/overo.c
+++ b/board/overo/overo.c
@@ -118,10 +118,6 @@ int get_board_revision(void)
 		revision = gpio_get_value(115) << 2 |
 			   gpio_get_value(113) << 1 |
 			   gpio_get_value(112);
-
-		gpio_free(112);
-		gpio_free(113);
-		gpio_free(115);
 	} else {
 		printf("Error: unable to acquire board revision GPIOs\n");
 		revision = -1;
@@ -153,8 +149,7 @@ int get_sdio2_config(void)
 				sdio_direct = 0;
 		}
 
-		gpio_free(130);
-		gpio_free(139);
+		gpio_direction_input(130);
 	} else {
 		printf("Error: unable to acquire sdio2 clk GPIOs\n");
 		sdio_direct = -1;
diff --git a/board/ti/beagle/beagle.c b/board/ti/beagle/beagle.c
index aa5047c..9482c5e 100644
--- a/board/ti/beagle/beagle.c
+++ b/board/ti/beagle/beagle.c
@@ -127,10 +127,6 @@ int get_board_revision(void)
 		revision = gpio_get_value(173) << 2 |
 			   gpio_get_value(172) << 1 |
 			   gpio_get_value(171);
-
-		gpio_free(171);
-		gpio_free(172);
-		gpio_free(173);
 	} else {
 		printf("Error: unable to acquire board revision GPIOs\n");
 		revision = -1;
@@ -522,8 +518,6 @@ int do_userbutton(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 		printf("NOT pressed.\n");
 	}
 
-	gpio_free(gpio);
-
 	return !button;
 }
 
-- 
1.6.0.2

^ permalink raw reply related	[flat|nested] 8+ messages in thread
* [U-Boot] [PATCH 1/2] omap3+: Add OMAP support for cmd_gpio
@ 2011-08-10  5:17 Joe Hershberger
  2011-08-16 22:17 ` [U-Boot] [PATCH v2 2/2] omap4_panda: Build in cmd_gpio support on panda Joe Hershberger
  0 siblings, 1 reply; 8+ messages in thread
From: Joe Hershberger @ 2011-08-10  5:17 UTC (permalink / raw)
  To: u-boot

Add a shim driver to drivers/gpio that maps the standard GPIO API to the OMAP GPIO API
Empty gpio.h is needed in the asm/arch dirs for omap3 and omap4 due to include in asm/gpio.h

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Cc: Joe Hershberger <joe.hershberger@gmail.com>
Cc: Sandeep Paulraj <s-paulraj@ti.com>
---
 arch/arm/include/asm/arch-omap3/gpio.h |    1 +
 arch/arm/include/asm/arch-omap4/gpio.h |    1 +
 drivers/gpio/Makefile                  |    1 +
 drivers/gpio/omap_gpio.c               |   69 ++++++++++++++++++++++++++++++++
 4 files changed, 72 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/include/asm/arch-omap3/gpio.h
 create mode 100644 arch/arm/include/asm/arch-omap4/gpio.h
 create mode 100644 drivers/gpio/omap_gpio.c

diff --git a/arch/arm/include/asm/arch-omap3/gpio.h b/arch/arm/include/asm/arch-omap3/gpio.h
new file mode 100644
index 0000000..fdeeadb
--- /dev/null
+++ b/arch/arm/include/asm/arch-omap3/gpio.h
@@ -0,0 +1 @@
+/* gpio.h */
diff --git a/arch/arm/include/asm/arch-omap4/gpio.h b/arch/arm/include/asm/arch-omap4/gpio.h
new file mode 100644
index 0000000..fdeeadb
--- /dev/null
+++ b/arch/arm/include/asm/arch-omap4/gpio.h
@@ -0,0 +1 @@
+/* gpio.h */
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
index 62ec97d..f9bef58 100644
--- a/drivers/gpio/Makefile
+++ b/drivers/gpio/Makefile
@@ -31,6 +31,7 @@ COBJS-$(CONFIG_MARVELL_MFP)	+= mvmfp.o
 COBJS-$(CONFIG_MXC_GPIO)	+= mxc_gpio.o
 COBJS-$(CONFIG_PCA953X)		+= pca953x.o
 COBJS-$(CONFIG_S5P)		+= s5p_gpio.o
+COBJS-$(CONFIG_OMAP_GPIO)	+= omap_gpio.o
 COBJS-$(CONFIG_TEGRA2_GPIO)	+= tegra2_gpio.o
 COBJS-$(CONFIG_DA8XX_GPIO)	+= da8xx_gpio.o
 
diff --git a/drivers/gpio/omap_gpio.c b/drivers/gpio/omap_gpio.c
new file mode 100644
index 0000000..4873065
--- /dev/null
+++ b/drivers/gpio/omap_gpio.c
@@ -0,0 +1,69 @@
+/*
+ * Adapter to OMAP GPIO handling.
+ *
+ * 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
+ */
+
+#include <common.h>
+#include <asm/omap_gpio.h>
+
+/*
+ * Generic_GPIO primitives.
+ */
+
+int gpio_request(int gp, const char *label)
+{
+	return omap_request_gpio(gp);
+}
+
+void gpio_free(int gp)
+{
+}
+
+/* set GPIO pin 'gp' as an input */
+int gpio_direction_input(int gp)
+{
+	omap_set_gpio_direction(gp, 1);
+	return 0;
+}
+
+void gpio_toggle_value(int gp)
+{
+	omap_set_gpio_dataout(gp, !omap_get_gpio_datain(gp));
+}
+
+/* set GPIO pin 'gp' as an output, with polarity 'value' */
+int gpio_direction_output(int gp, int value)
+{
+	omap_set_gpio_dataout(gp, value);
+	omap_set_gpio_direction(gp, 0);
+	return 0;
+}
+
+/* read GPIO IN value of pin 'gp' */
+int gpio_get_value(int gp)
+{
+	return omap_get_gpio_datain(gp);
+}
+
+/* write GPIO OUT value to pin 'gp' */
+void gpio_set_value(int gp, int value)
+{
+	omap_set_gpio_dataout(gp, value);
+}
-- 
1.6.0.2

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

end of thread, other threads:[~2011-10-12 20:31 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-06 20:45 [U-Boot] [PATCH 1/2] omap: Don't use gpio_free to change direction to input Joe Hershberger
2011-10-06 20:45 ` [U-Boot] [PATCH 2/2] omap4_panda: Build in cmd_gpio support on panda Joe Hershberger
2011-10-06 21:50 ` [U-Boot] [PATCH v2 1/2] omap: Don't use gpio_free to change direction to input Joe Hershberger
2011-10-06 21:50 ` [U-Boot] [PATCH v2 2/2] omap4_panda: Build in cmd_gpio support on panda Joe Hershberger
2011-10-09 10:47   ` Igor Grinberg
2011-10-12 20:31     ` [U-Boot] [PATCH v3 1/2] omap: Don't use gpio_free to change direction to input Joe Hershberger
2011-10-12 20:31     ` [U-Boot] [PATCH v3 2/2] omap4_panda: Build in cmd_gpio support on panda Joe Hershberger
  -- strict thread matches above, loose matches on Subject: below --
2011-08-10  5:17 [U-Boot] [PATCH 1/2] omap3+: Add OMAP support for cmd_gpio Joe Hershberger
2011-08-16 22:17 ` [U-Boot] [PATCH v2 2/2] omap4_panda: Build in cmd_gpio support on panda Joe Hershberger

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