stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Scott Wood <scottwood@freescale.com>,
	Anatolij Gustschin <agust@denx.de>,
	Liu Gang <Gang.Liu@freescale.com>,
	Linus Walleij <linus.walleij@linaro.org>
Subject: [PATCH 3.4 12/25] powerpc/gpio: Fix the wrong GPIO input data on MPC8572/MPC8536
Date: Tue, 10 Dec 2013 00:00:20 -0800	[thread overview]
Message-ID: <20131210075931.694949274@linuxfoundation.org> (raw)
In-Reply-To: <20131210075930.808460227@linuxfoundation.org>

3.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Liu Gang <Gang.Liu@freescale.com>

commit 1aeef303b5d9e243c41d5b80f8bb059366514a10 upstream.

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 the code may give the
wrong status of GPIOs defined as input under some scenarios:

1. If some pins were configured as inputs and were asserted
high before booting the kernel, the shadow data has been
initialized with those pin values.
2. Some pins have been configured as output first and have
been set to the high value, then reconfigured as input.

The above cases will make the shadow data for those input
pins to be set to high. Then reading the pin status will
always return high even if the actual pin status is low.

The code should eliminate the effects of the shadow data to
the input pins, and the status of those pins should be
read directly from GPDAT.

Acked-by: Scott Wood <scottwood@freescale.com>
Acked-by: Anatolij Gustschin <agust@denx.de>
Signed-off-by: Liu Gang <Gang.Liu@freescale.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/gpio/gpio-mpc8xxx.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

--- a/drivers/gpio/gpio-mpc8xxx.c
+++ b/drivers/gpio/gpio-mpc8xxx.c
@@ -69,10 +69,14 @@ static int mpc8572_gpio_get(struct 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);
 }
 
 static int mpc8xxx_gpio_get(struct gpio_chip *gc, unsigned int gpio)



  parent reply	other threads:[~2013-12-10  8:00 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-10  8:00 [PATCH 3.4 00/25] 3.4.74-stable review Greg Kroah-Hartman
2013-12-10  8:00 ` [PATCH 3.4 01/25] crypto: scatterwalk - Set the chain pointer indication bit Greg Kroah-Hartman
2013-12-10 14:46   ` Lendacky, Thomas
2013-12-11  2:02     ` Greg Kroah-Hartman
2013-12-11 14:51       ` Tom Lendacky
2013-12-10  8:00 ` [PATCH 3.4 02/25] crypto: ccm - Fix handling of zero plaintext when computing mac Greg Kroah-Hartman
2013-12-10  8:00 ` [PATCH 3.4 03/25] crypto: authenc - Find proper IV address in ablkcipher callback Greg Kroah-Hartman
2013-12-10  8:00 ` [PATCH 3.4 04/25] ASoC: wm8990: Mark the register map as dirty when powering down Greg Kroah-Hartman
2013-12-10  8:00 ` [PATCH 3.4 05/25] ASoC: wm8731: fix dsp mode configuration Greg Kroah-Hartman
2013-12-10  8:00 ` [PATCH 3.4 06/25] SCSI: enclosure: fix WARN_ON in dual path device removing Greg Kroah-Hartman
2013-12-10  8:00 ` [PATCH 3.4 07/25] SCSI: libsas: fix usage of ata_tf_to_fis Greg Kroah-Hartman
2013-12-10  8:00 ` [PATCH 3.4 08/25] SCSI: hpsa: do not discard scsi status on aborted commands Greg Kroah-Hartman
2013-12-10  8:00 ` [PATCH 3.4 09/25] SCSI: hpsa: return 0 from driver probe function on success, not 1 Greg Kroah-Hartman
2013-12-10  8:00 ` [PATCH 3.4 10/25] net: smc91: fix crash regression on the versatile Greg Kroah-Hartman
2013-12-10  8:00 ` [PATCH 3.4 11/25] NFSv4: Update list of irrecoverable errors on DELEGRETURN Greg Kroah-Hartman
2013-12-10  8:00 ` Greg Kroah-Hartman [this message]
2013-12-10  8:00 ` [PATCH 3.4 13/25] irq: Enable all irqs unconditionally in irq_resume Greg Kroah-Hartman
2013-12-10  8:00 ` [PATCH 3.4 14/25] net: update consumers of MSG_MORE to recognize MSG_SENDPAGE_NOTLAST Greg Kroah-Hartman
2013-12-10  8:00 ` [PATCH 3.4 15/25] Input: allow deselecting serio drivers even without CONFIG_EXPERT Greg Kroah-Hartman
2013-12-10  8:00 ` [PATCH 3.4 16/25] Input: mousedev - allow disabling " Greg Kroah-Hartman
2013-12-10  8:00 ` [PATCH 3.4 17/25] um: add missing declaration of getrlimit() and friends Greg Kroah-Hartman
2013-12-10  8:00 ` [PATCH 3.4 18/25] ahci: Add Device IDs for Intel Lynx Point-LP PCH Greg Kroah-Hartman
2013-12-10  8:00 ` [PATCH 3.4 19/25] ahci: AHCI-mode SATA patch for Intel Avoton DeviceIDs Greg Kroah-Hartman
2013-12-10  8:00 ` [PATCH 3.4 20/25] i2c: i801: SMBus " Greg Kroah-Hartman
2013-12-10  8:00 ` [PATCH 3.4 21/25] USB: pl2303: fixed handling of CS5 setting Greg Kroah-Hartman
2013-12-10  8:00 ` [PATCH 3.4 22/25] USB: mos7840: correct " Greg Kroah-Hartman
2013-12-10  8:00 ` [PATCH 3.4 23/25] USB: spcp8x5: " Greg Kroah-Hartman
2013-12-10  8:00 ` [PATCH 3.4 24/25] USB: cdc-acm: Added support for the Lenovo RD02-D400 USB Modem Greg Kroah-Hartman
2013-12-10  8:00 ` [PATCH 3.4 25/25] drivers/char/i8k.c: add Dell XPLS L421X Greg Kroah-Hartman
2013-12-10 17:01 ` [PATCH 3.4 00/25] 3.4.74-stable review Guenter Roeck
2013-12-11  1:17   ` Greg Kroah-Hartman
2013-12-11  1:48 ` Shuah Khan
2013-12-11 21:19 ` Satoru Takeuchi

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=20131210075931.694949274@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=Gang.Liu@freescale.com \
    --cc=agust@denx.de \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=scottwood@freescale.com \
    --cc=stable@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).