public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Peng Fan <van.freenix@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/2] dm: gpio: mxc: fix mxc_gpio_bank_get_value
Date: Tue, 15 Mar 2016 13:48:56 +0800	[thread overview]
Message-ID: <1458020937-994-1-git-send-email-van.freenix@gmail.com> (raw)

When configured a gpio to output direction, directly reading PSR register
can not return the output value, since we did not set SION bit for gpio
iomux. So, we can use data register to reflect what value is outputed.

If not, "regulator status" always return disabled, even if already "regulator
enable":
"
=> regulator enable
=> regulator status
Regulator VSD_3V3 status:
 * enable:         0 (false)
 * value uV:       3300000
 * current uA:     No data available (err: -61)
 * mode id:        Function not implemented (err: -38)
"

Signed-off-by: Peng Fan <van.freenix@gmail.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Stefano Babic <sbabic@denx.de>
Cc: Fabio Estevam <fabio.estevam@nxp.com>
---
 drivers/gpio/mxc_gpio.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpio/mxc_gpio.c b/drivers/gpio/mxc_gpio.c
index 70fe5b6..b6ae3fc 100644
--- a/drivers/gpio/mxc_gpio.c
+++ b/drivers/gpio/mxc_gpio.c
@@ -201,6 +201,9 @@ static void mxc_gpio_bank_set_value(struct gpio_regs *regs, int offset,
 
 static int mxc_gpio_bank_get_value(struct gpio_regs *regs, int offset)
 {
+	if (mxc_gpio_is_output(regs, offset))
+		return (readl(&regs->gpio_dr) >> offset) & 0x01;
+
 	return (readl(&regs->gpio_psr) >> offset) & 0x01;
 }
 
-- 
2.6.2

             reply	other threads:[~2016-03-15  5:48 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-15  5:48 Peng Fan [this message]
2016-03-15  5:48 ` [U-Boot] [PATCH 2/2] dm: gpio: mxc: implement xlate function Peng Fan
2016-03-16  3:32   ` Simon Glass
2016-04-11  5:28     ` Peng Fan
2016-04-11 14:56       ` Eric Nelson
2016-03-15 12:53 ` [U-Boot] [PATCH 1/2] dm: gpio: mxc: fix mxc_gpio_bank_get_value Fabio Estevam
2016-03-16  1:27   ` Peng Fan
2016-03-16 12:48     ` Fabio Estevam
2016-03-17  1:44       ` Peng Fan
2016-04-03 18:09         ` Stefano Babic
2016-04-05  5:04           ` Peng Fan
2016-04-09 18:35             ` Simon Glass

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=1458020937-994-1-git-send-email-van.freenix@gmail.com \
    --to=van.freenix@gmail.com \
    --cc=u-boot@lists.denx.de \
    /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