* [PATCH] ARM: i.MX: Add lowlevel gpio functions
@ 2014-01-31 14:24 Sascha Hauer
0 siblings, 0 replies; only message in thread
From: Sascha Hauer @ 2014-01-31 14:24 UTC (permalink / raw)
To: barebox
Some boards need gpio functions very early and also sometimes
is useful to toggle gpios during early code debug. This adds a header
file for setting i.MX gpios early.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
arch/arm/mach-imx/include/mach/imx-gpio.h | 48 +++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+)
create mode 100644 arch/arm/mach-imx/include/mach/imx-gpio.h
diff --git a/arch/arm/mach-imx/include/mach/imx-gpio.h b/arch/arm/mach-imx/include/mach/imx-gpio.h
new file mode 100644
index 0000000..5e673be
--- /dev/null
+++ b/arch/arm/mach-imx/include/mach/imx-gpio.h
@@ -0,0 +1,48 @@
+#ifndef __MACH_IMX_GPIO_H
+#define __MACH_IMX_GPIO_H
+
+#include <io.h>
+
+/*
+ * i.MX lowlevel gpio functions. Only for use with lowlevel code. Use
+ * regular gpio functions outside of lowlevel code!
+ */
+
+static inline void imx_gpio_direction_output(void __iomem *gdir, void __iomem *dr,
+ int gpio, int value)
+{
+ uint32_t val;
+
+ val = readl(gdir);
+ val |= 1 << gpio;
+ writel(val, gdir);
+
+ val = readl(dr);
+ if (value)
+ val |= 1 << gpio;
+ else
+ val &= ~(1 << gpio);
+
+ writel(val, dr);
+}
+
+static inline void imx1_gpio_direction_output(void *base, int gpio, int value)
+{
+ imx_gpio_direction_output(base + 0x0, base + 0x1c, gpio, value);
+}
+
+#define imx21_gpio_direction_output(base, gpio, value) imx1_gpio_direction_output(base, gpio,value)
+#define imx27_gpio_direction_output(base, gpio, value) imx1_gpio_direction_output(base, gpio,value)
+
+static inline void imx31_gpio_direction_output(void *base, int gpio, int value)
+{
+ imx_gpio_direction_output(base + 0x4, base + 0x0, gpio, value);
+}
+
+#define imx25_gpio_direction_output(base, gpio, value) imx31_gpio_direction_output(base, gpio,value)
+#define imx35_gpio_direction_output(base, gpio, value) imx31_gpio_direction_output(base, gpio,value)
+#define imx51_gpio_direction_output(base, gpio, value) imx31_gpio_direction_output(base, gpio,value)
+#define imx53_gpio_direction_output(base, gpio, value) imx31_gpio_direction_output(base, gpio,value)
+#define imx6_gpio_direction_output(base, gpio, value) imx31_gpio_direction_output(base, gpio,value)
+
+#endif /* __MACH_IMX_GPIO_H */
--
1.8.5.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2014-01-31 15:02 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-31 14:24 [PATCH] ARM: i.MX: Add lowlevel gpio functions Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox