Commit 39b707fa authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Linus Walleij

pinctrl: nomadik: Convert drivers to use struct pingroup and PINCTRL_PINGROUP()

The pin control header provides struct pingroup and PINCTRL_PINGROUP() macro.
Utilize them instead of open coded variants in the driver.
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20220621112904.65674-1-andriy.shevchenko@linux.intel.comSigned-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 0e3db163
...@@ -303,23 +303,20 @@ static const unsigned usbhs_c_1_pins[] = { STN8815_PIN_E21, STN8815_PIN_E20, ...@@ -303,23 +303,20 @@ static const unsigned usbhs_c_1_pins[] = { STN8815_PIN_E21, STN8815_PIN_E20,
STN8815_PIN_C16, STN8815_PIN_A15, STN8815_PIN_C16, STN8815_PIN_A15,
STN8815_PIN_D17, STN8815_PIN_C17 }; STN8815_PIN_D17, STN8815_PIN_C17 };
#define STN8815_PIN_GROUP(a, b) { .name = #a, .pins = a##_pins, \
.npins = ARRAY_SIZE(a##_pins), .altsetting = b }
static const struct nmk_pingroup nmk_stn8815_groups[] = { static const struct nmk_pingroup nmk_stn8815_groups[] = {
STN8815_PIN_GROUP(u0txrx_a_1, NMK_GPIO_ALT_A), NMK_PIN_GROUP(u0txrx_a_1, NMK_GPIO_ALT_A),
STN8815_PIN_GROUP(u0ctsrts_a_1, NMK_GPIO_ALT_A), NMK_PIN_GROUP(u0ctsrts_a_1, NMK_GPIO_ALT_A),
STN8815_PIN_GROUP(u0modem_a_1, NMK_GPIO_ALT_A), NMK_PIN_GROUP(u0modem_a_1, NMK_GPIO_ALT_A),
STN8815_PIN_GROUP(mmcsd_a_1, NMK_GPIO_ALT_A), NMK_PIN_GROUP(mmcsd_a_1, NMK_GPIO_ALT_A),
STN8815_PIN_GROUP(mmcsd_b_1, NMK_GPIO_ALT_B), NMK_PIN_GROUP(mmcsd_b_1, NMK_GPIO_ALT_B),
STN8815_PIN_GROUP(u1_a_1, NMK_GPIO_ALT_A), NMK_PIN_GROUP(u1_a_1, NMK_GPIO_ALT_A),
STN8815_PIN_GROUP(i2c1_a_1, NMK_GPIO_ALT_A), NMK_PIN_GROUP(i2c1_a_1, NMK_GPIO_ALT_A),
STN8815_PIN_GROUP(i2c0_a_1, NMK_GPIO_ALT_A), NMK_PIN_GROUP(i2c0_a_1, NMK_GPIO_ALT_A),
STN8815_PIN_GROUP(u1_b_1, NMK_GPIO_ALT_B), NMK_PIN_GROUP(u1_b_1, NMK_GPIO_ALT_B),
STN8815_PIN_GROUP(i2cusb_b_1, NMK_GPIO_ALT_B), NMK_PIN_GROUP(i2cusb_b_1, NMK_GPIO_ALT_B),
STN8815_PIN_GROUP(clcd_16_23_b_1, NMK_GPIO_ALT_B), NMK_PIN_GROUP(clcd_16_23_b_1, NMK_GPIO_ALT_B),
STN8815_PIN_GROUP(usbfs_b_1, NMK_GPIO_ALT_B), NMK_PIN_GROUP(usbfs_b_1, NMK_GPIO_ALT_B),
STN8815_PIN_GROUP(usbhs_c_1, NMK_GPIO_ALT_C), NMK_PIN_GROUP(usbhs_c_1, NMK_GPIO_ALT_C),
}; };
/* We use this macro to define the groups applicable to a function */ /* We use this macro to define the groups applicable to a function */
......
...@@ -1179,17 +1179,17 @@ static const char *nmk_get_group_name(struct pinctrl_dev *pctldev, ...@@ -1179,17 +1179,17 @@ static const char *nmk_get_group_name(struct pinctrl_dev *pctldev,
{ {
struct nmk_pinctrl *npct = pinctrl_dev_get_drvdata(pctldev); struct nmk_pinctrl *npct = pinctrl_dev_get_drvdata(pctldev);
return npct->soc->groups[selector].name; return npct->soc->groups[selector].grp.name;
} }
static int nmk_get_group_pins(struct pinctrl_dev *pctldev, unsigned selector, static int nmk_get_group_pins(struct pinctrl_dev *pctldev, unsigned selector,
const unsigned **pins, const unsigned **pins,
unsigned *num_pins) unsigned *npins)
{ {
struct nmk_pinctrl *npct = pinctrl_dev_get_drvdata(pctldev); struct nmk_pinctrl *npct = pinctrl_dev_get_drvdata(pctldev);
*pins = npct->soc->groups[selector].pins; *pins = npct->soc->groups[selector].grp.pins;
*num_pins = npct->soc->groups[selector].npins; *npins = npct->soc->groups[selector].grp.npins;
return 0; return 0;
} }
...@@ -1531,7 +1531,7 @@ static int nmk_pmx_set(struct pinctrl_dev *pctldev, unsigned function, ...@@ -1531,7 +1531,7 @@ static int nmk_pmx_set(struct pinctrl_dev *pctldev, unsigned function,
if (g->altsetting < 0) if (g->altsetting < 0)
return -EINVAL; return -EINVAL;
dev_dbg(npct->dev, "enable group %s, %u pins\n", g->name, g->npins); dev_dbg(npct->dev, "enable group %s, %u pins\n", g->grp.name, g->grp.npins);
/* /*
* If we're setting altfunc C by setting both AFSLA and AFSLB to 1, * If we're setting altfunc C by setting both AFSLA and AFSLB to 1,
...@@ -1566,26 +1566,26 @@ static int nmk_pmx_set(struct pinctrl_dev *pctldev, unsigned function, ...@@ -1566,26 +1566,26 @@ static int nmk_pmx_set(struct pinctrl_dev *pctldev, unsigned function,
* Then mask the pins that need to be sleeping now when we're * Then mask the pins that need to be sleeping now when we're
* switching to the ALT C function. * switching to the ALT C function.
*/ */
for (i = 0; i < g->npins; i++) for (i = 0; i < g->grp.npins; i++)
slpm[g->pins[i] / NMK_GPIO_PER_CHIP] &= ~BIT(g->pins[i]); slpm[g->grp.pins[i] / NMK_GPIO_PER_CHIP] &= ~BIT(g->grp.pins[i]);
nmk_gpio_glitch_slpm_init(slpm); nmk_gpio_glitch_slpm_init(slpm);
} }
for (i = 0; i < g->npins; i++) { for (i = 0; i < g->grp.npins; i++) {
struct nmk_gpio_chip *nmk_chip; struct nmk_gpio_chip *nmk_chip;
unsigned bit; unsigned bit;
nmk_chip = find_nmk_gpio_from_pin(g->pins[i]); nmk_chip = find_nmk_gpio_from_pin(g->grp.pins[i]);
if (!nmk_chip) { if (!nmk_chip) {
dev_err(npct->dev, dev_err(npct->dev,
"invalid pin offset %d in group %s at index %d\n", "invalid pin offset %d in group %s at index %d\n",
g->pins[i], g->name, i); g->grp.pins[i], g->grp.name, i);
goto out_glitch; goto out_glitch;
} }
dev_dbg(npct->dev, "setting pin %d to altsetting %d\n", g->pins[i], g->altsetting); dev_dbg(npct->dev, "setting pin %d to altsetting %d\n", g->grp.pins[i], g->altsetting);
clk_enable(nmk_chip->clk); clk_enable(nmk_chip->clk);
bit = g->pins[i] % NMK_GPIO_PER_CHIP; bit = g->grp.pins[i] % NMK_GPIO_PER_CHIP;
/* /*
* If the pin is switching to altfunc, and there was an * If the pin is switching to altfunc, and there was an
* interrupt installed on it which has been lazy disabled, * interrupt installed on it which has been lazy disabled,
...@@ -1608,7 +1608,7 @@ static int nmk_pmx_set(struct pinctrl_dev *pctldev, unsigned function, ...@@ -1608,7 +1608,7 @@ static int nmk_pmx_set(struct pinctrl_dev *pctldev, unsigned function,
* then some bits in PRCM GPIOCR registers must be cleared. * then some bits in PRCM GPIOCR registers must be cleared.
*/ */
if ((g->altsetting & NMK_GPIO_ALT_C) == NMK_GPIO_ALT_C) if ((g->altsetting & NMK_GPIO_ALT_C) == NMK_GPIO_ALT_C)
nmk_prcm_altcx_set_mode(npct, g->pins[i], nmk_prcm_altcx_set_mode(npct, g->grp.pins[i],
g->altsetting >> NMK_GPIO_ALT_CX_SHIFT); g->altsetting >> NMK_GPIO_ALT_CX_SHIFT);
} }
......
...@@ -105,21 +105,21 @@ struct nmk_function { ...@@ -105,21 +105,21 @@ struct nmk_function {
/** /**
* struct nmk_pingroup - describes a Nomadik pin group * struct nmk_pingroup - describes a Nomadik pin group
* @name: the name of this specific pin group * @grp: Generic data of the pin group (name and pins)
* @pins: an array of discrete physical pins used in this group, taken
* from the driver-local pin enumeration space
* @num_pins: the number of pins in this group array, i.e. the number of
* elements in .pins so we can iterate over that array
* @altsetting: the altsetting to apply to all pins in this group to * @altsetting: the altsetting to apply to all pins in this group to
* configure them to be used by a function * configure them to be used by a function
*/ */
struct nmk_pingroup { struct nmk_pingroup {
const char *name; struct pingroup grp;
const unsigned int *pins;
const unsigned npins;
int altsetting; int altsetting;
}; };
#define NMK_PIN_GROUP(a, b) \
{ \
.grp = PINCTRL_PINGROUP(#a, a##_pins, ARRAY_SIZE(a##_pins)), \
.altsetting = b, \
}
/** /**
* struct nmk_pinctrl_soc_data - Nomadik pin controller per-SoC configuration * struct nmk_pinctrl_soc_data - Nomadik pin controller per-SoC configuration
* @pins: An array describing all pins the pin controller affects. * @pins: An array describing all pins the pin controller affects.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment