Skip to contentSkip to conversation

pinctrl: msm: Use dynamic GPIO numbering

PATCH In review Bjorn Andersson 4 participants 7 messages Jan 29, 2018 – Nov 8, 2020

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pinctrl: msm: Use dynamic GPIO numbering

The base of the TLMM gpiochip should not be statically defined as 0, fix this to not artificially restrict the existence of multiple pinctrl-msm devices.

Fixes f365be092572 ("pinctrl: Add Qualcomm TLMM driver")
---
 drivers/pinctrl/qcom/pinctrl-msm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/qcom/pinctrl-msm.c +1 -1
index 495432f3341b..95e5c5ea40af 100644
@@ -818,7 +818,7 @@ static int msm_gpio_init(struct msm_pinctrl *pctrl)
 		return -EINVAL;
 
 	chip = &pctrl->chip;
-	chip->base = 0;
+	chip->base = -1;
 	chip->ngpio = ngpio;
 	chip->label = dev_name(pctrl->dev);
 	chip->parent = pctrl->dev;
Signature · 1 line
2.15.0
#1 lore raw
Quoted 7 lines · Bjorn Andersson

The base of the TLMM gpiochip should not be statically defined as 0, fix this to not artificially restrict the existence of multiple pinctrl-msm devices.

Fixes f365be092572 ("pinctrl: Add Qualcomm TLMM driver")

OK I put this in devel for v4.17, let's see if something explodes in linux-next else we can go with this.

Otherwise we need something that conserves base 0 for singular TLMM drivers and make it -1 for newer platforms with several instances.

Yours,
Linus Walleij

#2 lore raw
Quoted 3 lines · Linus Walleij

Otherwise we need something that conserves base 0 for singular TLMM drivers and make it -1 for newer platforms with several instances.

    static int base = 0;

    chip->base = base;
    base = -1;
Signature · 3 lines
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm
Technologies, Inc.  Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.
#3 lore raw
In reply to Linus Walleij
Quoted 6 lines · Linus Walleij

OK I put this in devel for v4.17, let's see if something explodes in linux-next else we can go with this.

Otherwise we need something that conserves base 0 for singular TLMM drivers and make it -1 for newer platforms with several instances.

I don't see this patch in linusw/linux-gpio.git anywhere. Do you want me to submit another patch that implements this:

    static int base = 0;

    chip->base = base;
    base = -1;

This preserves existing behavior for current drivers.

Signature · 3 lines
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm
Technologies, Inc.  Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.
#4 lore raw
In reply to Bjorn Andersson
Quoted 4 lines · Bjorn Andersson

The base of the TLMM gpiochip should not be statically defined as 0, fix this to not artificially restrict the existence of multiple pinctrl-msm devices.

Can someone please provide the details why this is needed for pinctrl-msm. Is there any msm-chipset using multiple tlmm devices? I m only concerned because, after this change, the use of gpio number from user space has become a little difficult. Can we merge the patch from Timur to maintain the past behavior when multiple tlmm devices are not present, which is most likely the case?

     static int base = 0;

     chip->base = base;
     base = -1;

Regards,
Arun

Quoted 28 lines
Fixes f365be092572 ("pinctrl: Add Qualcomm TLMM driver")
---
 drivers/pinctrl/qcom/pinctrl-msm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/qcom/pinctrl-msm.c +1 -2
index 495432f3341b..95e5c5ea40af 100644
@@ -818,7 +818,7 @@ static int msm_gpio_init(struct msm_pinctrl *pctrl)
                return -EINVAL;
 
        chip = &pctrl->chip;
-       chip->base = 0;
+       chip->base = -1;
        chip->ngpio = ngpio;
        chip->label = dev_name(pctrl->dev);
        chip->parent = pctrl->dev;
--

2.15.0

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#5 lore raw
Quoted 2 lines · Arun KS

Im only concerned because, after this change, the use of gpio number from user space has become a little difficult.

This makes me a bit puzzled so I need to push back a bit here.

What is this userspace and what interface is it using?

We recommend using the GPIO character device with
libgpiod for userspace applications:
https://www.kernel.org/doc/html/latest/driver-api/gpio/using-gpio.html

Is there any problem with this?

sysfs is deprecated for years now:
https://www.kernel.org/doc/html/latest/admin-guide/gpio/sysfs.html

Yours,
Linus Walleij

#6 lore raw
Quoted 6 lines · Linus Walleij
Quoted 2 lines · Arun KS

Im only concerned because, after this change, the use of gpio number from user space has become a little difficult.

Quoted 8 lines

This makes me a bit puzzled so I need to push back a bit here.

What is this userspace and what interface is it using?

We recommend using the GPIO character device with
libgpiod for userspace applications:
https://www.kernel.org/doc/html/latest/driver-api/gpio/using-gpio.html

Thanks Linus. Makes sense. Basically using the gpiochipset and offset to it will solve my problem. Earlier, while using the sysfs interface, it used to be one to one mapping with real gpio numbers.

Regards,
Arun

Quoted 8 lines

Is there any problem with this?

sysfs is deprecated for years now:
https://www.kernel.org/doc/html/latest/admin-guide/gpio/sysfs.html

Yours,
Linus Walleij