mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Alexander Shiyan <shc_work@mail.ru>
To: barebox@lists.infradead.org
Subject: [PATCH] GPIO: i.MX: Implement get_direction()
Date: Mon,  7 Apr 2014 18:17:39 +0400	[thread overview]
Message-ID: <1396880259-26502-1-git-send-email-shc_work@mail.ru> (raw)

Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
---
 drivers/gpio/gpio-imx.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/gpio/gpio-imx.c b/drivers/gpio/gpio-imx.c
index a71492a..d32638c 100644
--- a/drivers/gpio/gpio-imx.c
+++ b/drivers/gpio/gpio-imx.c
@@ -113,11 +113,21 @@ static int imx_gpio_get_value(struct gpio_chip *chip, unsigned gpio)
 	return val & (1 << gpio) ? 1 : 0;
 }
 
+static int imx_get_direction(struct gpio_chip *chip, unsigned offset)
+{
+	struct imx_gpio_chip *imxgpio = container_of(chip, struct imx_gpio_chip, chip);
+	void __iomem *base = imxgpio->base;
+	u32 val = readl(base + imxgpio->regs->gdir);
+
+	return (val & (1 << offset)) ? GPIOF_DIR_OUT : GPIOF_DIR_IN;
+}
+
 static struct gpio_ops imx_gpio_ops = {
 	.direction_input = imx_gpio_direction_input,
 	.direction_output = imx_gpio_direction_output,
 	.get = imx_gpio_get_value,
 	.set = imx_gpio_set_value,
+	.get_direction = imx_get_direction,
 };
 
 static int imx_gpio_probe(struct device_d *dev)
-- 
1.8.3.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

             reply	other threads:[~2014-04-07 14:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-07 14:17 Alexander Shiyan [this message]
2014-04-08  6:11 ` 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=1396880259-26502-1-git-send-email-shc_work@mail.ru \
    --to=shc_work@mail.ru \
    --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