From: Anatolij Gustschin <agust@denx.de>
To: Liu Gang <Gang.Liu@freescale.com>
Cc: linux-gpio@vger.kernel.org, linus.walleij@linaro.org,
linuxppc-dev@lists.ozlabs.org, r61911@freescale.com,
b07421@freescale.com
Subject: Re: [PATCH] powerpc/gpio: Fix the wrong GPIO input data on MPC8572/MPC8536
Date: Tue, 19 Nov 2013 16:32:30 +0100 [thread overview]
Message-ID: <20131119163230.70964d1f@crub> (raw)
In-Reply-To: <1384499789-3631-1-git-send-email-Gang.Liu@freescale.com>
On Fri, 15 Nov 2013 15:16:29 +0800
Liu Gang <Gang.Liu@freescale.com> wrote:
> For MPC8572/MPC8536, the status of GPIOs defined as output
> cannot be determined by reading GPDAT register, so the code
> use shadow data register instead. But if the input pins are
> asserted high, they will always read high due to the shadow
> data, even if the pins are set to low.
Could you please add a better description of the problem?
I'm having some difficulties to understand the last sentence
above. Does the issue appear if some pins were configured as
inputs and were asserted high before booting the kernel, and
therefore the shadow data has been initialized with these pin
values?
Or does the issue appear if some pin has been configured as output
first and has been set to the high value, then reconfigured as
input? Now reading the pin state will always return high even
if the actual pin state is low?
It seems the issue will appear in both cases. If so, please add
this information to the commit message.
> So the input pins should be read directly from GPDAT, not
> the shadow data.
>
> Signed-off-by: Liu Gang <Gang.Liu@freescale.com>
> ---
> drivers/gpio/gpio-mpc8xxx.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/gpio/gpio-mpc8xxx.c b/drivers/gpio/gpio-mpc8xxx.c
> index 9ae29cc..1d4ac75 100644
> --- a/drivers/gpio/gpio-mpc8xxx.c
> +++ b/drivers/gpio/gpio-mpc8xxx.c
> @@ -71,6 +71,7 @@ static int mpc8572_gpio_get(struct gpio_chip *gc, unsigned int gpio)
> struct mpc8xxx_gpio_chip *mpc8xxx_gc = to_mpc8xxx_gpio_chip(mm);
>
> val = in_be32(mm->regs + GPIO_DAT) & ~in_be32(mm->regs + GPIO_DIR);
> + mpc8xxx_gc->data &= in_be32(mm->regs + GPIO_DIR);
we can reduce one in_be32() call here, i.e.
u32 out_mask;
...
out_mask = in_be32(mm->regs + GPIO_DIR);
val = in_be32(mm->regs + GPIO_DAT) & ~out_mask;
mpc8xxx_gc->data &= out_mask;
> return (val | mpc8xxx_gc->data) & mpc8xxx_gpio2mask(gpio);
> }
Thanks,
Anatolij
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office@denx.de
next prev parent reply other threads:[~2013-11-19 15:32 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-15 7:16 [PATCH] powerpc/gpio: Fix the wrong GPIO input data on MPC8572/MPC8536 Liu Gang
2013-11-19 9:49 ` Linus Walleij
2013-11-19 15:32 ` Anatolij Gustschin [this message]
2013-11-20 2:07 ` Liu Gang
2013-11-19 22:51 ` Scott Wood
2013-11-20 2:54 ` Liu Gang
2013-11-21 0:32 ` Scott Wood
2013-11-22 4:47 ` Liu Gang
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=20131119163230.70964d1f@crub \
--to=agust@denx.de \
--cc=Gang.Liu@freescale.com \
--cc=b07421@freescale.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=r61911@freescale.com \
/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;
as well as URLs for NNTP newsgroup(s).