Skip to content

Commit 3773c19

Browse files
Michal Simeklinusw
authored andcommitted
gpio: zynq: Do PM initialization earlier to support gpio hogs
GPIO hogs registration is call at the end of gpiochip_add() function. Calling sequence is: gpiochip_add -> of_gpiochip_add -> of_gpiochip_scan_hogs -> gpiod_hog -> gpiochip_request_own_desc -> __gpiod_request -> chip->request -> zynq_gpio_request which calls pm_runtime_get_sync() which returns -13 because PM is not initialized yet. Initialize PM before gpiochip_add is called to fix this issue. Signed-off-by: Michal Simek <michal.simek@xilinx.com> Signed-off-by: Soren Brinkmann <soren.brinkmann@xilinx.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
1 parent 29ab875 commit 3773c19

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

drivers/gpio/gpio-zynq.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -708,23 +708,23 @@ static int zynq_gpio_probe(struct platform_device *pdev)
708708
chip->base = -1;
709709
chip->ngpio = gpio->p_data->ngpio;
710710

711-
/* Enable GPIO clock */
711+
/* Retrieve GPIO clock */
712712
gpio->clk = devm_clk_get(&pdev->dev, NULL);
713713
if (IS_ERR(gpio->clk)) {
714714
dev_err(&pdev->dev, "input clock not found.\n");
715715
return PTR_ERR(gpio->clk);
716716
}
717-
ret = clk_prepare_enable(gpio->clk);
718-
if (ret) {
719-
dev_err(&pdev->dev, "Unable to enable clock.\n");
717+
718+
pm_runtime_enable(&pdev->dev);
719+
ret = pm_runtime_get_sync(&pdev->dev);
720+
if (ret < 0)
720721
return ret;
721-
}
722722

723723
/* report a bug if gpio chip registration fails */
724724
ret = gpiochip_add(chip);
725725
if (ret) {
726726
dev_err(&pdev->dev, "Failed to add gpio chip\n");
727-
goto err_disable_clk;
727+
goto err_pm_put;
728728
}
729729

730730
/* disable interrupts for all banks */
@@ -742,15 +742,14 @@ static int zynq_gpio_probe(struct platform_device *pdev)
742742
gpiochip_set_chained_irqchip(chip, &zynq_gpio_edge_irqchip, gpio->irq,
743743
zynq_gpio_irqhandler);
744744

745-
pm_runtime_set_active(&pdev->dev);
746-
pm_runtime_enable(&pdev->dev);
745+
pm_runtime_put(&pdev->dev);
747746

748747
return 0;
749748

750749
err_rm_gpiochip:
751750
gpiochip_remove(chip);
752-
err_disable_clk:
753-
clk_disable_unprepare(gpio->clk);
751+
err_pm_put:
752+
pm_runtime_put(&pdev->dev);
754753

755754
return ret;
756755
}

0 commit comments

Comments
 (0)