Re: [PATCH 4/5] pinctrl: dw: add pinctrl support for dwapb gpio driver
From: ClÃment Leger
Date: Wed Dec 04 2019 - 09:50:09 EST
----- On 4 Dec, 2019, at 13:43, Andy Shevchenko andy.shevchenko@xxxxxxxxx wrote:
> On Wed, Dec 4, 2019 at 12:12 PM Clement Leger <cleger@xxxxxxxxx> wrote:
>>
>> Synopsys designware gpio controller also has pinmuxing functionnality.
>
> DesignWare
> pin muxing
> functionality
>
> (Please, run a spell checker)
>
>> Pinmuxing allows to choose between software and hardware mode. When
>
> Pin muxing
>
>> using hardware mode, an external signal controls the pin output.
>>
>> This patch adds support for pinctrl framework in the gpio driver. This
>
> GPIO
>
>> support is conditionned by the snps,has-pinctrl device tree property.
>
> conditioned
>
>> Indeed, the functionnality can be detected only if the gpio IP has been
>
> functionality
>
>> configured using paremeters encoding which is not always present. If
>
> parameters
>
>> property is present, then the pinctrl will be registered and will
>
>> allow switching to the "hw" functionnality and hence enable the
>
> functionality
>
>> alternate function.
Sorry, I will do some spellchecking before resending the serie.
>
>> +static const struct pinctrl_pin_desc dwapb_pins[] = {
> ...
>> + DWAPB_PINCTRL_PIN(31)
>
> Keep comma in such cases.
>
>> +};
>
> Can't you split adding pin control data to a separate patch?
Yes even if the first one will not be buildable.
>
>> +/* One pin per group */
>> +static const char * const dwapb_gpio_groups[] = {
> ...
>> + "pin31"
>
> Keep comma here.
>
>> +};
>
> 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.
>
>> + dev_info(gpio->dev, "Setting func %s on pin %d",
>> + dwapb_gpio_functions[selector], group);
>
> Noise!
I will remove that.
>
>> + 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.
>
>> + 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?
Do you mean the gpiochip add_pin_ranges callback ?
If so, I will look at it.
>
>> - .name = "gpio-dwapb",
>> + .name = "pinctrl-dwapb",
>
> This will break existing users.
Ok, I will revert that.
Thanks,
>
> --
> With Best Regards,
> Andy Shevchenko