linux/drivers/pinctrl/qcom
Christian Lamparter 38ffd6c9cb pinctrl: msm: fix gpio-hog related boot issues
commit a86caa9ba5 upstream.

Sven Eckelmann reported an issue with the current IPQ4019 pinctrl.
Setting up any gpio-hog in the device-tree for his device would
"kill the bootup completely":

| [    0.477838] msm_serial 78af000.serial: could not find pctldev for node /soc/pinctrl@1000000/serial_pinmux, deferring probe
| [    0.499828] spi_qup 78b5000.spi: could not find pctldev for node /soc/pinctrl@1000000/spi_0_pinmux, deferring probe
| [    1.298883] requesting hog GPIO enable USB2 power (chip 1000000.pinctrl, offset 58) failed, -517
| [    1.299609] gpiochip_add_data: GPIOs 0..99 (1000000.pinctrl) failed to register
| [    1.308589] ipq4019-pinctrl 1000000.pinctrl: Failed register gpiochip
| [    1.316586] msm_serial 78af000.serial: could not find pctldev for node /soc/pinctrl@1000000/serial_pinmux, deferring probe
| [    1.322415] spi_qup 78b5000.spi: could not find pctldev for node /soc/pinctrl@1000000/spi_0_pinmux, deferri

This was also verified on a RT-AC58U (IPQ4018) which would
no longer boot, if a gpio-hog was specified. (Tried forcing
the USB LED PIN (GPIO0) to high.).

The problem is that Pinctrl+GPIO registration is currently
peformed in the following order in pinctrl-msm.c:
	1. pinctrl_register()
	2. gpiochip_add()
	3. gpiochip_add_pin_range()

The actual error code -517 == -EPROBE_DEFER is coming from
pinctrl_get_device_gpio_range(), which is called through:
        gpiochip_add
            of_gpiochip_add
                of_gpiochip_scan_gpios
                    gpiod_hog
                        gpiochip_request_own_desc
                            __gpiod_request
                                chip->request
                                    gpiochip_generic_request
                                       pinctrl_gpio_request
                                          pinctrl_get_device_gpio_range

pinctrl_get_device_gpio_range() is unable to find any valid
pin ranges, since nothing has been added to the pinctrldev_list yet.
so the range can't be found, and the operation fails with -EPROBE_DEFER.

This patch fixes the issue by adding the "gpio-ranges" property to
the pinctrl device node of all upstream Qcom SoC. The pin ranges are
then added by the gpio core.

In order to remain compatible with older, existing DTs (and ACPI)
a check for the "gpio-ranges" property has been added to
msm_gpio_init(). This prevents the driver of adding the same entry
to the pinctrldev_list twice.

Reported-by: Sven Eckelmann <sven.eckelmann@openmesh.com>
Tested-by: Sven Eckelmann <sven.eckelmann@openmesh.com> [ipq4019]
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-02-20 10:20:55 +01:00
..
Kconfig pinctrl: qcom: Add ipq8074 pinctrl driver 2017-06-29 15:12:40 +02:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
pinctrl-apq8064.c pinctrl: qcom: General Purpose clocks for apq8064 2017-08-31 11:32:19 +02:00
pinctrl-apq8084.c
pinctrl-ipq4019.c pinctrl: msm: add support to configure ipq40xx GPIO_PULL bits 2017-08-14 15:00:59 +02:00
pinctrl-ipq8064.c
pinctrl-ipq8074.c pinctrl: qcom: Add ipq8074 pinctrl driver 2017-06-29 15:12:40 +02:00
pinctrl-mdm9615.c pinctrl: qcom: Add support for MDM9615 TLMM 2016-06-29 10:10:52 +02:00
pinctrl-msm8x74.c pinctrl: qcom: msm8974: Add hsic_ctl pinmux 2016-06-29 10:14:46 +02:00
pinctrl-msm8660.c pinctrl: qcom: msm8660: rename some SDC1->SDC4 2017-01-03 09:26:20 +01:00
pinctrl-msm8916.c pinctrl: qcom: Add msm8916 pinctrl driver 2015-01-30 14:35:09 +01:00
pinctrl-msm8960.c
pinctrl-msm8994.c pinctrl: qcom: Add msm8994 pinctrl driver 2016-11-04 23:55:36 +01:00
pinctrl-msm8996.c pinctrl: qcom: Add msm8996 pinctrl driver 2015-12-01 10:29:03 +01:00
pinctrl-msm.c pinctrl: msm: fix gpio-hog related boot issues 2019-02-20 10:20:55 +01:00
pinctrl-msm.h pinctrl: msm: add support to configure ipq40xx GPIO_PULL bits 2017-08-14 15:00:59 +02:00
pinctrl-qdf2xxx.c pinctrl: qcom: qdf2xxx: add names to the gpios 2017-03-16 16:39:04 +01:00
pinctrl-spmi-gpio.c pinctrl: qcom: spmi-gpio: Fix pmic_gpio_config_get() to be compliant 2018-09-26 08:38:13 +02:00
pinctrl-spmi-mpp.c pinctrl: spmi-mpp: Fix pmic_mpp_config_get() to be compliant 2018-11-13 11:14:55 -08:00
pinctrl-ssbi-gpio.c pinctrl: ssbi-gpio: Fix pm8xxx_pin_config_get() to be compliant 2018-11-13 11:14:56 -08:00
pinctrl-ssbi-mpp.c pinctrl: qcom: ssbi: mpp: constify gpio_chip structure 2017-08-14 15:01:01 +02:00