pinctrl: qcom: ssbi-gpio: fix gpio-hog related boot issues
Subsystems (5)
PATCH 1/1 pinctrl: qcom: ssbi-gpio: fix gpio-hog related boot issues
When attempting to setup up a gpio hog, device probing will repeatedly fail with -EPROBE_DEFERED errors. It is caused by a circular dependency between the gpio and pinctrl frameworks. If the gpio-ranges property is present in device tree, then the gpio framework will handle the gpio pin registration and eliminate the circular dependency.
See Christian Lamparter's commit a86caa9ba5d7 ("pinctrl: msm: fix gpio-hog related boot issues") for a detailed commit message that explains the issue in much more detail. The code comment in this commit came from Christian's commit.
I did not test this change against any hardware supported by this particular driver, however I was able to validate this same fix works for pinctrl-spmi-gpio.c using a LG Nexus 5 (hammerhead) phone.
---
For the patch and discussion regarding pinctrl-spmi-gpio.c, see
https://lore.kernel.org/lkml/[email protected]/
drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-)
drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c +17 -6
@@ -762,12 +762,23 @@ static int pm8xxx_gpio_probe(struct platform_device *pdev)return ret; } - ret =gpiochip_add_pin_range (&pctrl->chip, -dev_name (pctrl->dev), -0 ,0 , pctrl->chip.ngpio); -if (ret) { -dev_err (pctrl->dev,"failed to add pin range\n" ); - goto unregister_gpiochip; +/* +* For DeviceTree-supported systems, the gpio core checks the +* pinctrl's device node for the "gpio-ranges" property. +* If it is present, it takes care of adding the pin ranges +* for the driver. In this case the driver can skip ahead. +* +* In order to remain compatible with older, existing DeviceTree +* files which don't set the "gpio-ranges" property or systems that +* utilize ACPI the driver has to call gpiochip_add_pin_range(). +*/ +if (!of_property_read_bool (pctrl->dev->of_node,"gpio-ranges" )) { + ret =gpiochip_add_pin_range (&pctrl->chip,dev_name (pctrl->dev), +0 ,0 , pctrl->chip.ngpio); +if (ret) { +dev_err (pctrl->dev,"failed to add pin range\n" ); + goto unregister_gpiochip; + } }platform_set_drvdata (pdev, pctrl);
Signature · 1 line
2.17.2
Quoted 11 lines · Brian Masney
When attempting to setup up a gpio hog, device probing will repeatedly fail with -EPROBE_DEFERED errors. It is caused by a circular dependency between the gpio and pinctrl frameworks. If the gpio-ranges property is present in device tree, then the gpio framework will handle the gpio pin registration and eliminate the circular dependency.
See Christian Lamparter's commit
a86caa9ba5d7("pinctrl: msm: fix gpio-hog related boot issues") for a detailed commit message that explains the issue in much more detail. The code comment in this commit came from Christian's commit.
Quoted 5 lines
I did not test this change against any hardware supported by this particular driver, however I was able to validate this same fix works for
pinctrl-spmi-gpio.cusing a LG Nexus 5 (hammerhead) phone.Signed-off-by Brian Masney <[email protected]>
Regards,
Bjorn
Quoted 44 lines
---
For the patch and discussion regardingpinctrl-spmi-gpio.c, see
https://lore.kernel.org/lkml/[email protected]/drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-)drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c +17
-6@@ -762,12 +762,23 @@ static int pm8xxx_gpio_probe(struct platform_device *pdev)return ret; } - ret =gpiochip_add_pin_range (&pctrl->chip, -dev_name (pctrl->dev), -0 ,0 , pctrl->chip.ngpio); -if (ret) { -dev_err (pctrl->dev,"failed to add pin range\n" ); - goto unregister_gpiochip; +/* +* For DeviceTree-supported systems, the gpio core checks the +* pinctrl's device node for the "gpio-ranges" property. +* If it is present, it takes care of adding the pin ranges +* for the driver. In this case the driver can skip ahead. +* +* In order to remain compatible with older, existing DeviceTree +* files which don't set the "gpio-ranges" property or systems that +* utilize ACPI the driver has to call gpiochip_add_pin_range(). +*/ +if (!of_property_read_bool (pctrl->dev->of_node,"gpio-ranges" )) { + ret =gpiochip_add_pin_range (&pctrl->chip,dev_name (pctrl->dev), +0 ,0 , pctrl->chip.ngpio); +if (ret) { +dev_err (pctrl->dev,"failed to add pin range\n" ); + goto unregister_gpiochip; + } }platform_set_drvdata (pdev, pctrl);Signature · 1 line
2.17.2
Quoted 11 lines · Brian Masney
When attempting to setup up a gpio hog, device probing will repeatedly fail with -EPROBE_DEFERED errors. It is caused by a circular dependency between the gpio and pinctrl frameworks. If the gpio-ranges property is present in device tree, then the gpio framework will handle the gpio pin registration and eliminate the circular dependency.
See Christian Lamparter's commit
a86caa9ba5d7("pinctrl: msm: fix gpio-hog related boot issues") for a detailed commit message that explains the issue in much more detail. The code comment in this commit came from Christian's commit.
Quoted 5 lines
I did not test this change against any hardware supported by this particular driver, however I was able to validate this same fix works for
pinctrl-spmi-gpio.cusing a LG Nexus 5 (hammerhead) phone.Signed-off-by Brian Masney <[email protected]>
Patch applied.
Yours,
Linus Walleij