From: Michael Grzeschik <m.grzeschik@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH v2 1/2] ARM: i.MX: Add lowlevel gpio input functions
Date: Mon, 19 Mar 2018 10:21:19 +0100 [thread overview]
Message-ID: <20180319092120.11773-2-m.grzeschik@pengutronix.de> (raw)
In-Reply-To: <20180319092120.11773-1-m.grzeschik@pengutronix.de>
This adds the function to set direction input and read the values
in the header file for setting i.MX gpios early.
Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
---
arch/arm/mach-imx/include/mach/imx-gpio.h | 46 +++++++++++++++++++++++++++----
1 file changed, 41 insertions(+), 5 deletions(-)
diff --git a/arch/arm/mach-imx/include/mach/imx-gpio.h b/arch/arm/mach-imx/include/mach/imx-gpio.h
index 5e673beef9..891c33a3f4 100644
--- a/arch/arm/mach-imx/include/mach/imx-gpio.h
+++ b/arch/arm/mach-imx/include/mach/imx-gpio.h
@@ -8,15 +8,21 @@
* regular gpio functions outside of lowlevel code!
*/
-static inline void imx_gpio_direction_output(void __iomem *gdir, void __iomem *dr,
- int gpio, int value)
+static inline void imx_gpio_direction(void __iomem *gdir, void __iomem *dr,
+ int gpio, int out, int value)
{
uint32_t val;
val = readl(gdir);
- val |= 1 << gpio;
+ if (out)
+ val |= 1 << gpio;
+ else
+ val &= ~(1 << gpio);
writel(val, gdir);
+ if (!out)
+ return;
+
val = readl(dr);
if (value)
val |= 1 << gpio;
@@ -28,7 +34,7 @@ static inline void imx_gpio_direction_output(void __iomem *gdir, void __iomem *d
static inline void imx1_gpio_direction_output(void *base, int gpio, int value)
{
- imx_gpio_direction_output(base + 0x0, base + 0x1c, gpio, value);
+ imx_gpio_direction(base + 0x0, base + 0x1c, gpio, 1, value);
}
#define imx21_gpio_direction_output(base, gpio, value) imx1_gpio_direction_output(base, gpio,value)
@@ -36,7 +42,7 @@ static inline void imx1_gpio_direction_output(void *base, int gpio, int value)
static inline void imx31_gpio_direction_output(void *base, int gpio, int value)
{
- imx_gpio_direction_output(base + 0x4, base + 0x0, gpio, value);
+ imx_gpio_direction(base + 0x4, base + 0x0, gpio, 1, value);
}
#define imx25_gpio_direction_output(base, gpio, value) imx31_gpio_direction_output(base, gpio,value)
@@ -45,4 +51,34 @@ static inline void imx31_gpio_direction_output(void *base, int gpio, int 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)
+static inline void imx1_gpio_direction_input(void *base, int gpio, int value)
+{
+ imx_gpio_direction(base + 0x0, base + 0x1c, gpio, 0, 0);
+}
+
+#define imx21_gpio_direction_input(base, gpio, value) imx1_gpio_direction_input(base, gpio)
+#define imx27_gpio_direction_input(base, gpio, value) imx1_gpio_direction_input(base, gpio)
+
+static inline void imx31_gpio_direction_input(void *base, int gpio)
+{
+ imx_gpio_direction(base + 0x4, base + 0x0, gpio, 0, 0);
+}
+
+#define imx25_gpio_direction_input(base, gpio, value) imx31_gpio_direction_input(base, gpio)
+#define imx35_gpio_direction_input(base, gpio, value) imx31_gpio_direction_input(base, gpio)
+#define imx51_gpio_direction_input(base, gpio, value) imx31_gpio_direction_input(base, gpio)
+#define imx53_gpio_direction_input(base, gpio, value) imx31_gpio_direction_input(base, gpio)
+#define imx6_gpio_direction_input(base, gpio) imx31_gpio_direction_input(base, gpio)
+
+#define imx1_gpio_val(base, gpio) readl(base + 0x1c) & (1 << gpio) ? 1 : 0
+#define imx21_gpio_val(base, gpio) imx1_gpio_val(base, gpio)
+#define imx27_gpio_val(base, gpio) imx1_gpio_val(base, gpio)
+
+#define imx31_gpio_val(base, gpio) readl(base) & (1 << gpio) ? 1 : 0
+#define imx25_gpio_val(base, gpio) imx31_gpio_val(base, gpio)
+#define imx35_gpio_val(base, gpio) imx31_gpio_val(base, gpio)
+#define imx51_gpio_val(base, gpio) imx31_gpio_val(base, gpio)
+#define imx53_gpio_val(base, gpio) imx31_gpio_val(base, gpio)
+#define imx6_gpio_val(base, gpio) imx31_gpio_val(base, gpio)
+
#endif /* __MACH_IMX_GPIO_H */
--
2.16.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2018-03-19 9:21 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-19 9:21 [PATCH v2 0/2] Add support for kontron samx6i boards Michael Grzeschik
2018-03-19 9:21 ` Michael Grzeschik [this message]
2018-03-19 9:21 ` [PATCH v2 2/2] boards: samx6: add initial support for kontron samx6i Michael Grzeschik
2018-03-19 11:48 ` Michael Grzeschik
2018-03-21 8:04 ` [PATCH v2 0/2] Add support for kontron samx6i boards Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180319092120.11773-2-m.grzeschik@pengutronix.de \
--to=m.grzeschik@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox