MIPS: lantiq: improve pci reset gpio handling
authorJohn Crispin <blogic@openwrt.org>
Sat, 19 Jan 2013 08:54:26 +0000 (08:54 +0000)
committerJohn Crispin <blogic@openwrt.org>
Sat, 16 Feb 2013 23:15:17 +0000 (00:15 +0100)
We need to make sure that the reset gpio is available and also set a sane
default state.

Signed-off-by: John Crispin <blogic@openwrt.org>
Patchwork: http://patchwork.linux-mips.org/patch/4817/

arch/mips/pci/pci-lantiq.c

index 95681789b51e44978c5725701e889abf28da1b00..f32664bbbe17bbeedfe24fcba9758454ec6b396b 100644 (file)
@@ -129,8 +129,16 @@ static int ltq_pci_startup(struct platform_device *pdev)
 
        /* setup reset gpio used by pci */
        reset_gpio = of_get_named_gpio(node, "gpio-reset", 0);
-       if (gpio_is_valid(reset_gpio))
-               devm_gpio_request(&pdev->dev, reset_gpio, "pci-reset");
+       if (gpio_is_valid(reset_gpio)) {
+               int ret = devm_gpio_request(&pdev->dev,
+                                               reset_gpio, "pci-reset");
+               if (ret) {
+                       dev_err(&pdev->dev,
+                               "failed to request gpio %d\n", reset_gpio);
+                       return ret;
+               }
+               gpio_direction_output(reset_gpio, 1);
+       }
 
        /* enable auto-switching between PCI and EBU */
        ltq_pci_w32(0xa, PCI_CR_CLK_CTRL);