pinctrl: dw: add pinctrl support for dwapb gpio driver
Subsystems (2)
PATCH 4/5 pinctrl: dw: add pinctrl support for dwapb gpio driver
Synopsys designware gpio controller also has pinmuxing functionnality. Pinmuxing allows to choose between software and hardware mode. When using hardware mode, an external signal controls the pin output.
This patch adds support for pinctrl framework in the gpio driver. This support is conditionned by the snps,has-pinctrl device tree property. Indeed, the functionnality can be detected only if the gpio IP has been configured using paremeters encoding which is not always present. If property is present, then the pinctrl will be registered and will allow switching to the "hw" functionnality and hence enable the alternate function.
--- drivers/pinctrl/dw/Kconfig | 2 + drivers/pinctrl/dw/pinctrl-dwapb.c | 263 ++++++++++++++++++++++++++++++- include/linux/platform_data/gpio-dwapb.h | 1 + 3 files changed, 260 insertions(+), 6 deletions(-)
drivers/pinctrl/dw/Kconfig +2 -0
@@ -4,6 +4,8 @@ config GPIO_DWAPB select GPIOLIB select GPIOLIB_IRQCHIP select GPIO_GENERIC + select PINMUX + select GENERIC_PINCONF help Say Y or M here to build support for the Synopsys DesignWare APB GPIO block.
drivers/pinctrl/dw/pinctrl-dwapb.c +257 -6
327 lines not on this page · raw message
include/linux/platform_data/gpio-dwapb.h +1 -0
@@ -14,6 +14,7 @@ struct dwapb_port_property {int irq[32 ];bool has_irq;bool irq_shared; +bool has_pinctrl; };struct dwapb_platform_data {
Signature · 1 line
2.15.0.276.g89ea799
Quoted 2 lines · Clement Leger
Synopsys designware gpio controller also has pinmuxing functionnality.
DesignWare
pin muxing
functionality
(Please, run a spell checker)
Quoted 1 line
Pinmuxing allows to choose between software and hardware mode. When
Pin muxing
Quoted 3 lines
using hardware mode, an external signal controls the pin output.
This patch adds support for pinctrl framework in the gpio driver. This
GPIO
Quoted 1 line
support is conditionned by the snps,has-pinctrl device tree property.
conditioned
Quoted 1 line
Indeed, the functionnality can be detected only if the gpio IP has been
functionality
Quoted 1 line
configured using paremeters encoding which is not always present. If
parameters
Quoted 3 lines
property is present, then the pinctrl will be registered and will
allow switching to the "hw" functionnality and hence enable the
functionality
Quoted 3 lines
alternate function.
+static const struct
pinctrl_pin_descdwapb_pins[] = {
...
Quoted 1 line
+
DWAPB_PINCTRL_PIN(31)
Keep comma in such cases.
Quoted 1 line
+};
Can't you split adding pin control data to a separate patch?
Quoted 2 lines
drivers/pinctrl/dw/pinctrl-dwapb.c +2
-0+/* One pin per group */ +static const char *const dwapb_gpio_groups[] = {
...
Quoted 1 line
+ "pin31"
Keep comma here.
Quoted 1 line
+};
Can't we generate these lists dynamically?
drivers/pinctrl/dw/pinctrl-dwapb.c static void dwapb_irq_teardown(struct dwapb_gpio *gpio) · line 657
Quoted 2 lines
drivers/pinctrl/dw/pinctrl-dwapb.c +2
-0+dev_info (gpio->dev,"Setting func %s on pin %d" , + dwapb_gpio_functions[selector], group);
Noise!
drivers/pinctrl/dw/pinctrl-dwapb.c static void dwapb_irq_teardown(struct dwapb_gpio *gpio) · line 715
Quoted 5 lines
drivers/pinctrl/dw/pinctrl-dwapb.c +5
-0+ ret =pinctrl_enable (port->pctl); +if (ret) { +dev_err (gpio->dev,"pinctrl enable failed\n" ); +return ret; + }
Not sure why it's needed at all.
drivers/pinctrl/dw/pinctrl-dwapb.c static void dwapb_irq_teardown(struct dwapb_gpio *gpio) · line 725
Quoted 9 lines
drivers/pinctrl/dw/pinctrl-dwapb.c +9
-0+ range = &port->range; + range->name =dev_name (gpio->dev); + range->id = port->idx; + range->pin_base =0 ; + range->base = port->gc.base; + range->npins = pp->ngpio; + range->gc = &port->gc; + +pinctrl_add_gpio_range (port->pctl, range);
Can you use new callback for this?
drivers/pinctrl/dw/pinctrl-dwapb.c static SIMPLE_DEV_PM_OPS(dwapb_gpio_pm_ops, dwapb_gpio_suspend, · line 1076
Quoted 2 lines
drivers/pinctrl/dw/pinctrl-dwapb.c +1
-1- .name = "gpio-dwapb", + .name = "pinctrl-dwapb",
This will break existing users.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 30 lines · ----- On 4 Dec, 2019, at 13:43, Andy Shevchenko [email protected] wrote:
Quoted 2 lines · Clement Leger
Synopsys designware gpio controller also has pinmuxing functionnality.
DesignWare
pin muxing
functionality(Please, run a spell checker)
Quoted 1 line
Pinmuxing allows to choose between software and hardware mode. When
Pin muxing
Quoted 3 lines
using hardware mode, an external signal controls the pin output.
This patch adds support for pinctrl framework in the gpio driver. This
GPIO
Quoted 1 line
support is conditionned by the snps,has-pinctrl device tree property.
conditioned
Quoted 1 line
Indeed, the functionnality can be detected only if the gpio IP has been
functionality
Quoted 1 line
configured using paremeters encoding which is not always present. If
Quoted 9 lines
parameters
Quoted 3 lines
property is present, then the pinctrl will be registered and will
allow switching to the "hw" functionnality and hence enable the
functionality
Quoted 1 line
alternate function.
Sorry, I will do some spellchecking before resending the serie.
Quoted 10 lines
Quoted 2 lines
+static const struct
pinctrl_pin_descdwapb_pins[] = {...
Quoted 1 line
+
DWAPB_PINCTRL_PIN(31)Keep comma in such cases.
Quoted 1 line
+};
Can't you split adding pin control data to a separate patch?
Yes even if the first one will not be buildable.
Quoted 11 lines
Quoted 3 lines
drivers/pinctrl/dw/pinctrl-dwapb.c +2
-0+/* One pin per group */ +static const char *const dwapb_gpio_groups[] = {...
Quoted 1 line
+ "pin31"
Keep comma here.
Quoted 1 line
+};
Can't we generate these lists dynamically?
Indeed, these list could be dynamically generated. However, since they can be shared between all pinctrl instances of this driver I thought it was better to keep them common and simply restrict the number of pins at pinctrl registration. But as I said, I can generate them if you want.
Quoted 5 lines
drivers/pinctrl/dw/pinctrl-dwapb.c static void dwapb_irq_teardown(struct dwapb_gpio *gpio) · line 657
Quoted 3 lines
drivers/pinctrl/dw/pinctrl-dwapb.c +2
-0+dev_info (gpio->dev,"Setting func %s on pin %d" , + dwapb_gpio_functions[selector], group);Noise!
I will remove that.
Quoted 8 lines
drivers/pinctrl/dw/pinctrl-dwapb.c static void dwapb_irq_teardown(struct dwapb_gpio *gpio) · line 715
Quoted 6 lines
drivers/pinctrl/dw/pinctrl-dwapb.c +5
-0+ ret =pinctrl_enable (port->pctl); +if (ret) { +dev_err (gpio->dev,"pinctrl enable failed\n" ); +return ret; + }Not sure why it's needed at all.
I saw a comment over "pinctrl_register" in pinctrl.h saying:
/* Please use pinctrl_register_and_init() and pinctrl_enable() instead */
So I switched to pinctrl_register_and_init + pinctrl_enable.
Quoted 11 lines
drivers/pinctrl/dw/pinctrl-dwapb.c static void dwapb_irq_teardown(struct dwapb_gpio *gpio) · line 725
Quoted 10 lines
drivers/pinctrl/dw/pinctrl-dwapb.c +9
-0+ range = &port->range; + range->name =dev_name (gpio->dev); + range->id = port->idx; + range->pin_base =0 ; + range->base = port->gc.base; + range->npins = pp->ngpio; + range->gc = &port->gc; + +pinctrl_add_gpio_range (port->pctl, range);
Quoted 1 line
Can you use new callback for this?
Do you mean the gpiochip add_pin_ranges callback ? If so, I will look at it.
Quoted 5 lines
drivers/pinctrl/dw/pinctrl-dwapb.c static SIMPLE_DEV_PM_OPS(dwapb_gpio_pm_ops, dwapb_gpio_suspend, · line 1076
Quoted 3 lines
drivers/pinctrl/dw/pinctrl-dwapb.c +1
-1- .name = "gpio-dwapb", + .name = "pinctrl-dwapb",This will break existing users.
Ok, I will revert that.
Thanks,
Quoted 4 lines
--
With Best Regards,
Andy Shevchenko
Quoted 6 lines · Clément Leger
Quoted 3 lines · ----- On 4 Dec, 2019, at 13:43, Andy Shevchenko [email protected] wrote:
On Wed, Dec 4, 2019 at 12:12 PM Clement Leger <[email protected]> wrote:
Can't you split adding pin control data to a separate patch?
Yes even if the first one will not be buildable.
It will. Just split it wisely.
I'm preparing Intel Lynxpoint conversion (you may see the approach here [1]) and I stumbled over similar problem.
Quoted 7 lines
Quoted 1 line
Can't we generate these lists dynamically?
Indeed, these list could be dynamically generated. However, since they can be shared between all pinctrl instances of this driver I thought it was better to keep them common and simply restrict the number of pins at pinctrl registration. But as I said, I can generate them if you want.
OK, let's wait for subsys maintainers to comment on this.
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
drivers/pinctrl/dw/pinctrl-dwapb.c +5
-0+ ret =pinctrl_enable (port->pctl); +if (ret) { +dev_err (gpio->dev,"pinctrl enable failed\n" ); +return ret; + }
Quoted 7 lines
Quoted 1 line
Not sure why it's needed at all.
I saw a comment over "
pinctrl_register" inpinctrl.hsaying:/* Please use
pinctrl_register_and_init()andpinctrl_enable()instead */So I switched to
pinctrl_register_and_init+pinctrl_enable.
I read the code and do not see any evidence you have to use above. Do you plan to do something in between of those two calls?
Quoted 4 lines
Quoted 1 line
Can you use new callback for this?
Do you mean the gpiochip
add_pin_rangescallback ? If so, I will look at it.
I meant ->add_pin_ranges() which is part of GPIO chip structure.
Quoted 6 lines
Quoted 4 lines
drivers/pinctrl/dw/pinctrl-dwapb.c static SIMPLE_DEV_PM_OPS(dwapb_gpio_pm_ops, dwapb_gpio_suspend, · line 1076
Quoted 2 lines
drivers/pinctrl/dw/pinctrl-dwapb.c +1
-1- .name = "gpio-dwapb", + .name = "pinctrl-dwapb",This will break existing users.
Ok, I will revert that.
You may fix users at the same time.
Either fine with me.
--
With Best Regards,
Andy Shevchenko