mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: msmulski2@gmail.com
To: linus.walleij@linaro.org
Cc: brgl@bgdev.pl, linux-gpio@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Michal Smulski <michal.smulski@ooma.com>
Subject: [PATCH v2 1/1] gpio: mpc8xxx: latch GPIOs state on module load when configured as output
Date: Thu,  1 Jun 2023 16:02:00 -0700	[thread overview]
Message-ID: <20230601230200.6128-2-msmulski2@gmail.com> (raw)
In-Reply-To: <20230601230200.6128-1-msmulski2@gmail.com>

From: Michal Smulski <michal.smulski@ooma.com>

Qoriq and related devices allow reading out state of GPIO set as output.
However, currently on driver's init, all outputs are configured as driven
low. So, any changes to GPIO confiuration will drive all pins (configured
as output) as output-low.
This patch latches state of output GPIOs before any GPIO configuration
takes place. This preserves any output settings done prior to loading
the driver (for example, by u-boot).

Signed-off-by: Michal Smulski <michal.smulski@ooma.com>
---
 drivers/gpio/gpio-mpc8xxx.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-mpc8xxx.c b/drivers/gpio/gpio-mpc8xxx.c
index 3eb08cd1fdc0..6340e738c912 100644
--- a/drivers/gpio/gpio-mpc8xxx.c
+++ b/drivers/gpio/gpio-mpc8xxx.c
@@ -375,8 +375,12 @@ static int mpc8xxx_probe(struct platform_device *pdev)
 	if (of_device_is_compatible(np, "fsl,qoriq-gpio") ||
 	    of_device_is_compatible(np, "fsl,ls1028a-gpio") ||
 	    of_device_is_compatible(np, "fsl,ls1088a-gpio") ||
-	    is_acpi_node(fwnode))
+	    is_acpi_node(fwnode)) {
 		gc->write_reg(mpc8xxx_gc->regs + GPIO_IBE, 0xffffffff);
+		/* Also, latch state of GPIOs configured as output by bootloader. */
+		gc->bgpio_data = gc->read_reg(mpc8xxx_gc->regs + GPIO_DAT) &
+			gc->read_reg(mpc8xxx_gc->regs + GPIO_DIR);
+	}
 
 	ret = devm_gpiochip_add_data(&pdev->dev, gc, mpc8xxx_gc);
 	if (ret) {
-- 
2.34.1


  reply	other threads:[~2023-06-01 23:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-01 23:01 [PATCH v2 0/1] " msmulski2
2023-06-01 23:02 ` msmulski2 [this message]
2023-06-16  9:11   ` [PATCH v2 1/1] " Bartosz Golaszewski

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=20230601230200.6128-2-msmulski2@gmail.com \
    --to=msmulski2@gmail.com \
    --cc=brgl@bgdev.pl \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michal.smulski@ooma.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

Powered by JetHome