[U-Boot] [PATCH 1/2] omap3+: Add OMAP support for cmd_gpio

Joe Hershberger joe.hershberger at ni.com
Wed Aug 10 07:17:05 CEST 2011


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 at ni.com>
Cc: Joe Hershberger <joe.hershberger at gmail.com>
Cc: Sandeep Paulraj <s-paulraj at 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



More information about the U-Boot mailing list