[PATCH v7 2/2] pinctrl: nuvoton: add NPCM8XX pinctrl and GPIO driver

Linus Walleij linus.walleij at linaro.org
Tue Sep 12 00:02:53 AEST 2023


On Mon, Aug 28, 2023 at 4:09 PM Tomer Maimon <tmaimon77 at gmail.com> wrote:

> Add pinctrl and GPIO controller driver support to Arbel BMC NPCM8XX SoC.
>
> Arbel BMC NPCM8XX pinctrl driver based on Poleg NPCM7XX, except the
> pin mux mapping difference the NPCM8XX GPIO supports adjust debounce
> period time.
>
> Signed-off-by: Tomer Maimon <tmaimon77 at gmail.com>

As mentioned the patch is already applied, consider the following
as nitpicks you can address in followup patches.

> +struct npcm8xx_gpio {
> +       struct gpio_chip        gc;
> +       void __iomem            *base;
> +       struct debounce_time    debounce;
> +       int                     irqbase;

You're not really using this are you? Delete it.
Also the assignment further down: you do not use it I think.

> +       int                     irq;

You're not using this either. Delete it.

> +       struct irq_chip         irq_chip;

Not this either. Delete it.

> +static int npcm8xx_dt_node_to_map(struct pinctrl_dev *pctldev,
> +                                 struct device_node *np_config,
> +                                 struct pinctrl_map **map,
> +                                 u32 *num_maps)
> +{
> +       return pinconf_generic_dt_node_to_map(pctldev, np_config,
> +                                             map, num_maps,
> +                                             PIN_MAP_TYPE_INVALID);
> +}
> +
> +static void npcm8xx_dt_free_map(struct pinctrl_dev *pctldev,
> +                               struct pinctrl_map *map, u32 num_maps)
> +{
> +       kfree(map);
> +}

Can't you just call the generic functions directly?

> +static const struct pinctrl_ops npcm8xx_pinctrl_ops = {
> +       .get_groups_count = npcm8xx_get_groups_count,
> +       .get_group_name = npcm8xx_get_group_name,
> +       .get_group_pins = npcm8xx_get_group_pins,
> +       .dt_node_to_map = npcm8xx_dt_node_to_map,
> +       .dt_free_map = npcm8xx_dt_free_map,

Here?

(...)
> +static int npcm8xx_gpio_request_enable(struct pinctrl_dev *pctldev,
> +                                      struct pinctrl_gpio_range *range,
> +                                      unsigned int offset)
> +{
> +       struct npcm8xx_pinctrl *npcm = pinctrl_dev_get_drvdata(pctldev);
> +       const unsigned int *pin = &offset;
> +       int mode = fn_gpio;
> +
> +       if (pin[0] >= 183 && pin[0] <= 189)
> +               mode = pincfg[pin[0]].fn0;

These magic numbers should really be definies.

> +static void npcm8xx_gpio_request_free(struct pinctrl_dev *pctldev,
> +                                     struct pinctrl_gpio_range *range,
> +                                     unsigned int offset)
> +{
> +       struct npcm8xx_pinctrl *npcm = pinctrl_dev_get_drvdata(pctldev);
> +       int virq;
> +
> +       virq = irq_find_mapping(npcm->domain, offset);
> +       if (virq)
> +               irq_dispose_mapping(virq);
> +}

I would just rename "virq" to "irq", it is a Linux IRQ, not really
"virtual" which is what the "v" sometimes stand for.

Yours,
Linus Walleij


More information about the openbmc mailing list