pinctrl: pxa2xx: Make use of struct pingroup
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Mon, 11 Mar 2024 14:22:48 +0000 (16:22 +0200)
committerLinus Walleij <linus.walleij@linaro.org>
Thu, 28 Mar 2024 08:44:20 +0000 (09:44 +0100)
Since pin control provides a generic data type for the pin group,
use it in the driver.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Message-ID: <20240311142346.1261203-1-andriy.shevchenko@linux.intel.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/pinctrl/pxa/pinctrl-pxa2xx.c
drivers/pinctrl/pxa/pinctrl-pxa2xx.h

index f24bf49fa82bca887191739453663c792aafa0ec..9e34b92ff5f2ddf89d565b87e6926b0af07d70ac 100644 (file)
@@ -32,7 +32,7 @@ static const char *pxa2xx_pctrl_get_group_name(struct pinctrl_dev *pctldev,
                                               unsigned tgroup)
 {
        struct pxa_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
-       struct pxa_pinctrl_group *group = pctl->groups + tgroup;
+       struct pingroup *group = pctl->groups + tgroup;
 
        return group->name;
 }
@@ -43,10 +43,10 @@ static int pxa2xx_pctrl_get_group_pins(struct pinctrl_dev *pctldev,
                                       unsigned *num_pins)
 {
        struct pxa_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
-       struct pxa_pinctrl_group *group = pctl->groups + tgroup;
+       struct pingroup *group = pctl->groups + tgroup;
 
-       *pins = (unsigned *)&group->pin;
-       *num_pins = 1;
+       *pins = group->pins;
+       *num_pins = group->npins;
 
        return 0;
 }
@@ -139,20 +139,18 @@ static int pxa2xx_pmx_set_mux(struct pinctrl_dev *pctldev, unsigned function,
                              unsigned tgroup)
 {
        struct pxa_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
-       struct pxa_pinctrl_group *group = pctl->groups + tgroup;
+       struct pingroup *g = pctl->groups + tgroup;
+       unsigned int pin = g->pins[0];
        struct pxa_desc_function *df;
-       int pin, shift;
        unsigned long flags;
        void __iomem *gafr, *gpdr;
+       int shift;
        u32 val;
 
-
-       df = pxa_desc_by_func_group(pctl, group->name,
-                                   (pctl->functions + function)->name);
+       df = pxa_desc_by_func_group(pctl, g->name, (pctl->functions + function)->name);
        if (!df)
                return -EINVAL;
 
-       pin = group->pin;
        gafr = pctl->base_gafr[pin / 16];
        gpdr = pctl->base_gpdr[pin / 32];
        shift = (pin % 16) << 1;
@@ -186,9 +184,9 @@ static int pxa2xx_pconf_group_get(struct pinctrl_dev *pctldev,
                                  unsigned long *config)
 {
        struct pxa_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
-       struct pxa_pinctrl_group *g = pctl->groups + group;
+       struct pingroup *g = pctl->groups + group;
+       unsigned int pin = g->pins[0];
        unsigned long flags;
-       unsigned pin = g->pin;
        void __iomem *pgsr = pctl->base_pgsr[pin / 32];
        u32 val;
 
@@ -208,9 +206,9 @@ static int pxa2xx_pconf_group_set(struct pinctrl_dev *pctldev,
                                  unsigned num_configs)
 {
        struct pxa_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
-       struct pxa_pinctrl_group *g = pctl->groups + group;
+       struct pingroup *g = pctl->groups + group;
+       unsigned int pin = g->pins[0];
        unsigned long flags;
-       unsigned pin = g->pin;
        void __iomem *pgsr = pctl->base_pgsr[pin / 32];
        int i, is_set = 0;
        u32 val;
@@ -328,8 +326,8 @@ static int pxa2xx_build_groups(struct pxa_pinctrl *pctl)
 static int pxa2xx_build_state(struct pxa_pinctrl *pctl,
                              const struct pxa_desc_pin *ppins, int npins)
 {
-       struct pxa_pinctrl_group *group;
        struct pinctrl_pin_desc *pins;
+       struct pingroup *group;
        int ret, i;
 
        pctl->npins = npins;
@@ -353,7 +351,8 @@ static int pxa2xx_build_state(struct pxa_pinctrl *pctl,
        for (i = 0; i < npins; i++) {
                group = pctl->groups + i;
                group->name = ppins[i].pin.name;
-               group->pin = ppins[i].pin.number;
+               group->pins = &ppins[i].pin.number;
+               group->npins = 1;
        }
 
        ret = pxa2xx_build_functions(pctl);
index a0bdcec5515859e80ec96a21d26494488ad87ffe..b292b79efdf856278673366dedabafe2d1e8e44e 100644 (file)
@@ -52,11 +52,6 @@ struct pxa_desc_pin {
        struct pxa_desc_function        *functions;
 };
 
-struct pxa_pinctrl_group {
-       const char      *name;
-       unsigned        pin;
-};
-
 struct pxa_pinctrl {
        spinlock_t                      lock;
        void __iomem                    **base_gafr;
@@ -68,7 +63,7 @@ struct pxa_pinctrl {
        unsigned                        npins;
        const struct pxa_desc_pin       *ppins;
        unsigned                        ngroups;
-       struct pxa_pinctrl_group        *groups;
+       struct pingroup                 *groups;
        unsigned                        nfuncs;
        struct pinfunction              *functions;
        char                            *name;