Skip to content

Commit 19b60f8

Browse files
Michal SmulskiBartosz Golaszewski
authored andcommitted
gpio: mpc8xxx: latch GPIOs state on module load when configured as output
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 <[email protected]> Signed-off-by: Bartosz Golaszewski <[email protected]>
1 parent 61c65a8 commit 19b60f8

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

drivers/gpio/gpio-mpc8xxx.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,8 +375,12 @@ static int mpc8xxx_probe(struct platform_device *pdev)
375375
if (of_device_is_compatible(np, "fsl,qoriq-gpio") ||
376376
of_device_is_compatible(np, "fsl,ls1028a-gpio") ||
377377
of_device_is_compatible(np, "fsl,ls1088a-gpio") ||
378-
is_acpi_node(fwnode))
378+
is_acpi_node(fwnode)) {
379379
gc->write_reg(mpc8xxx_gc->regs + GPIO_IBE, 0xffffffff);
380+
/* Also, latch state of GPIOs configured as output by bootloader. */
381+
gc->bgpio_data = gc->read_reg(mpc8xxx_gc->regs + GPIO_DAT) &
382+
gc->read_reg(mpc8xxx_gc->regs + GPIO_DIR);
383+
}
380384

381385
ret = devm_gpiochip_add_data(&pdev->dev, gc, mpc8xxx_gc);
382386
if (ret) {

0 commit comments

Comments
 (0)