All of lore.kernel.org
 help / color / mirror / Atom feed
From: Liu Gang <Gang.Liu@freescale.com>
To: Kumar Gala <galak@kernel.crashing.org>
Cc: linuxppc-dev@lists.ozlabs.org, linux-gpio@vger.kernel.org,
	agust@denx.de, b07421@freescale.com, linus.walleij@linaro.org,
	r61911@freescale.com
Subject: Re: [PATCH v2] powerpc/gpio: Fix the wrong GPIO input data on MPC8572/MPC8536
Date: Tue, 26 Nov 2013 17:20:44 +0800	[thread overview]
Message-ID: <1385457644.10928.7.camel@linux> (raw)
In-Reply-To: <D582D1B3-B20B-4860-B1DE-DDCD04B5D0BA@kernel.crashing.org>

On Fri, 2013-11-22 at 14:51 -0600, Kumar Gala wrote:
> > drivers/gpio/gpio-mpc8xxx.c | 8 ++++++--
> > 1 file changed, 6 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/gpio/gpio-mpc8xxx.c b/drivers/gpio/gpio-mpc8xxx.c
> > index 914e859..d7d6d72 100644
> > --- a/drivers/gpio/gpio-mpc8xxx.c
> > +++ b/drivers/gpio/gpio-mpc8xxx.c
> > @@ -70,10 +70,14 @@ static int mpc8572_gpio_get(struct gpio_chip *gc, unsigned int gpio)
> > 	u32 val;
> > 	struct of_mm_gpio_chip *mm = to_of_mm_gpio_chip(gc);
> > 	struct mpc8xxx_gpio_chip *mpc8xxx_gc = to_mpc8xxx_gpio_chip(mm);
> > +	u32 out_mask, out_shadow;
> > 
> > -	val = in_be32(mm->regs + GPIO_DAT) & ~in_be32(mm->regs + GPIO_DIR);
> > +	out_mask = in_be32(mm->regs + GPIO_DIR);
> > 
> > -	return (val | mpc8xxx_gc->data) & mpc8xxx_gpio2mask(gpio);
> > +	val = in_be32(mm->regs + GPIO_DAT) & ~out_mask;
> > +	out_shadow = mpc8xxx_gc->data & out_mask;
> > +
> > +	return (val | out_shadow) & mpc8xxx_gpio2mask(gpio);
> > }
> 
> I really think a comment is worth adding here about why we do this.
> 
> - k

Hi, Kumar,
Thanks for your comment. In fact, there already had some comments above
the function:

/* Workaround GPIO 1 errata on MPC8572/MPC8536. The status of GPIOs
 * defined as output cannot be determined by reading GPDAT register,
 * so we use shadow data register instead. The status of input pins
 * is determined by reading GPDAT register.
 */

Best Regards,
Liu Gang







WARNING: multiple messages have this Message-ID (diff)
From: Liu Gang <Gang.Liu@freescale.com>
To: Kumar Gala <galak@kernel.crashing.org>
Cc: b07421@freescale.com, linus.walleij@linaro.org,
	r61911@freescale.com, linux-gpio@vger.kernel.org, agust@denx.de,
	linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH v2] powerpc/gpio: Fix the wrong GPIO input data on MPC8572/MPC8536
Date: Tue, 26 Nov 2013 17:20:44 +0800	[thread overview]
Message-ID: <1385457644.10928.7.camel@linux> (raw)
In-Reply-To: <D582D1B3-B20B-4860-B1DE-DDCD04B5D0BA@kernel.crashing.org>

On Fri, 2013-11-22 at 14:51 -0600, Kumar Gala wrote:
> > drivers/gpio/gpio-mpc8xxx.c | 8 ++++++--
> > 1 file changed, 6 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/gpio/gpio-mpc8xxx.c b/drivers/gpio/gpio-mpc8xxx.c
> > index 914e859..d7d6d72 100644
> > --- a/drivers/gpio/gpio-mpc8xxx.c
> > +++ b/drivers/gpio/gpio-mpc8xxx.c
> > @@ -70,10 +70,14 @@ static int mpc8572_gpio_get(struct gpio_chip *gc, unsigned int gpio)
> > 	u32 val;
> > 	struct of_mm_gpio_chip *mm = to_of_mm_gpio_chip(gc);
> > 	struct mpc8xxx_gpio_chip *mpc8xxx_gc = to_mpc8xxx_gpio_chip(mm);
> > +	u32 out_mask, out_shadow;
> > 
> > -	val = in_be32(mm->regs + GPIO_DAT) & ~in_be32(mm->regs + GPIO_DIR);
> > +	out_mask = in_be32(mm->regs + GPIO_DIR);
> > 
> > -	return (val | mpc8xxx_gc->data) & mpc8xxx_gpio2mask(gpio);
> > +	val = in_be32(mm->regs + GPIO_DAT) & ~out_mask;
> > +	out_shadow = mpc8xxx_gc->data & out_mask;
> > +
> > +	return (val | out_shadow) & mpc8xxx_gpio2mask(gpio);
> > }
> 
> I really think a comment is worth adding here about why we do this.
> 
> - k

Hi, Kumar,
Thanks for your comment. In fact, there already had some comments above
the function:

/* Workaround GPIO 1 errata on MPC8572/MPC8536. The status of GPIOs
 * defined as output cannot be determined by reading GPDAT register,
 * so we use shadow data register instead. The status of input pins
 * is determined by reading GPDAT register.
 */

Best Regards,
Liu Gang

  reply	other threads:[~2013-11-26  9:20 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-22  8:12 [PATCH v2] powerpc/gpio: Fix the wrong GPIO input data on MPC8572/MPC8536 Liu Gang
2013-11-22  8:12 ` Liu Gang
2013-11-22 18:39 ` Scott Wood
2013-11-22 18:39   ` Scott Wood
2013-11-22 20:51 ` Kumar Gala
2013-11-22 20:51   ` Kumar Gala
2013-11-26  9:20   ` Liu Gang [this message]
2013-11-26  9:20     ` Liu Gang
2013-11-29  9:32 ` Linus Walleij
2013-11-29  9:32   ` Linus Walleij
2013-11-29 10:54 ` Anatolij Gustschin
2013-11-29 10:54   ` Anatolij Gustschin
2013-11-29 12:37 ` Linus Walleij
2013-11-29 12:37   ` Linus Walleij

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=1385457644.10928.7.camel@linux \
    --to=gang.liu@freescale.com \
    --cc=agust@denx.de \
    --cc=b07421@freescale.com \
    --cc=galak@kernel.crashing.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.