* [PATCH v2 0/1] gpio: mpc8xxx: latch GPIOs state on module load when configured as output
@ 2023-06-01 23:01 msmulski2
2023-06-01 23:02 ` [PATCH v2 1/1] " msmulski2
0 siblings, 1 reply; 3+ messages in thread
From: msmulski2 @ 2023-06-01 23:01 UTC (permalink / raw)
To: linus.walleij; +Cc: brgl, linux-gpio, linux-kernel, Michal Smulski
From: Michal Smulski <michal.smulski@ooma.com>
Changes between v1 and v2:
* moved comments closer to the added code for clarity.
Michal Smulski (1):
gpio: mpc8xxx: latch GPIOs state on module load when configured as
output
drivers/gpio/gpio-mpc8xxx.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2 1/1] gpio: mpc8xxx: latch GPIOs state on module load when configured as output
2023-06-01 23:01 [PATCH v2 0/1] gpio: mpc8xxx: latch GPIOs state on module load when configured as output msmulski2
@ 2023-06-01 23:02 ` msmulski2
2023-06-16 9:11 ` Bartosz Golaszewski
0 siblings, 1 reply; 3+ messages in thread
From: msmulski2 @ 2023-06-01 23:02 UTC (permalink / raw)
To: linus.walleij; +Cc: brgl, linux-gpio, linux-kernel, Michal Smulski
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2 1/1] gpio: mpc8xxx: latch GPIOs state on module load when configured as output
2023-06-01 23:02 ` [PATCH v2 1/1] " msmulski2
@ 2023-06-16 9:11 ` Bartosz Golaszewski
0 siblings, 0 replies; 3+ messages in thread
From: Bartosz Golaszewski @ 2023-06-16 9:11 UTC (permalink / raw)
To: msmulski2; +Cc: linus.walleij, linux-gpio, linux-kernel, Michal Smulski
On Fri, Jun 2, 2023 at 1:02 AM <msmulski2@gmail.com> wrote:
>
> 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
>
Applied, thanks!
Bart
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-06-16 9:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-01 23:01 [PATCH v2 0/1] gpio: mpc8xxx: latch GPIOs state on module load when configured as output msmulski2
2023-06-01 23:02 ` [PATCH v2 1/1] " msmulski2
2023-06-16 9:11 ` Bartosz Golaszewski
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).