Message ID | 20241025-kselftest-gpio-set-get-config-v2-1-040d748840bb@collabora.com |
---|---|
State | New |
Headers | show |
Series | Verify bias functionality for pinctrl_paris driver through new gpio test | expand |
On Sat, Oct 26, 2024 at 4:06 AM Nícolas F. R. A. Prado <nfraprado@collabora.com> wrote: > > Currently the set_config callback in the gpio_chip registered by the > pinctrl_paris driver only supports configuring a single parameter on > specific pins (the input debounce of the EINT controller, on pins that > support it), even though many other configurations are already > implemented and available through the pinctrl API for configuration of > pins by the Devicetree and other drivers. > > Expose all configurations currently implemented through the GPIO API so > they can also be set from userspace, which is particularly useful to > allow testing them from userspace. > > Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com> Reviewed-by: Chen-Yu Tsai <wenst@chromium.org> > --- > drivers/pinctrl/mediatek/pinctrl-paris.c | 26 +++++++++++++------------- > 1 file changed, 13 insertions(+), 13 deletions(-) > > diff --git a/drivers/pinctrl/mediatek/pinctrl-paris.c b/drivers/pinctrl/mediatek/pinctrl-paris.c > index 87e958d827bf939aa6006794287698be4936f25e..c9455de266a447ab7f5446c1511bef0ef9c9128e 100644 > --- a/drivers/pinctrl/mediatek/pinctrl-paris.c > +++ b/drivers/pinctrl/mediatek/pinctrl-paris.c > @@ -255,10 +255,9 @@ static int mtk_pinconf_get(struct pinctrl_dev *pctldev, > return err; > } > > -static int mtk_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin, > - enum pin_config_param param, u32 arg) > +static int mtk_paris_pin_config_set(struct mtk_pinctrl *hw, unsigned int pin, > + enum pin_config_param param, u32 arg) > { > - struct mtk_pinctrl *hw = pinctrl_dev_get_drvdata(pctldev); > const struct mtk_pin_desc *desc; > int err = -ENOTSUPP; > u32 reg; > @@ -795,9 +794,9 @@ static int mtk_pconf_group_set(struct pinctrl_dev *pctldev, unsigned group, > int i, ret; > > for (i = 0; i < num_configs; i++) { > - ret = mtk_pinconf_set(pctldev, grp->pin, > - pinconf_to_config_param(configs[i]), > - pinconf_to_config_argument(configs[i])); > + ret = mtk_paris_pin_config_set(hw, grp->pin, > + pinconf_to_config_param(configs[i]), > + pinconf_to_config_argument(configs[i])); > if (ret < 0) > return ret; > > @@ -937,18 +936,19 @@ static int mtk_gpio_set_config(struct gpio_chip *chip, unsigned int offset, > { > struct mtk_pinctrl *hw = gpiochip_get_data(chip); > const struct mtk_pin_desc *desc; > - u32 debounce; > + enum pin_config_param param = pinconf_to_config_param(config); > + u32 arg = pinconf_to_config_argument(config); > > desc = (const struct mtk_pin_desc *)&hw->soc->pins[offset]; > > - if (!hw->eint || > - pinconf_to_config_param(config) != PIN_CONFIG_INPUT_DEBOUNCE || > - desc->eint.eint_n == EINT_NA) > - return -ENOTSUPP; > + if (param == PIN_CONFIG_INPUT_DEBOUNCE) { > + if (!hw->eint || desc->eint.eint_n == EINT_NA) > + return -ENOTSUPP; > > - debounce = pinconf_to_config_argument(config); > + return mtk_eint_set_debounce(hw->eint, desc->eint.eint_n, arg); > + } > > - return mtk_eint_set_debounce(hw->eint, desc->eint.eint_n, debounce); > + return mtk_paris_pin_config_set(hw, offset, param, arg); > } > > static int mtk_build_gpiochip(struct mtk_pinctrl *hw) > > -- > 2.47.0 > >
diff --git a/drivers/pinctrl/mediatek/pinctrl-paris.c b/drivers/pinctrl/mediatek/pinctrl-paris.c index 87e958d827bf939aa6006794287698be4936f25e..c9455de266a447ab7f5446c1511bef0ef9c9128e 100644 --- a/drivers/pinctrl/mediatek/pinctrl-paris.c +++ b/drivers/pinctrl/mediatek/pinctrl-paris.c @@ -255,10 +255,9 @@ static int mtk_pinconf_get(struct pinctrl_dev *pctldev, return err; } -static int mtk_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin, - enum pin_config_param param, u32 arg) +static int mtk_paris_pin_config_set(struct mtk_pinctrl *hw, unsigned int pin, + enum pin_config_param param, u32 arg) { - struct mtk_pinctrl *hw = pinctrl_dev_get_drvdata(pctldev); const struct mtk_pin_desc *desc; int err = -ENOTSUPP; u32 reg; @@ -795,9 +794,9 @@ static int mtk_pconf_group_set(struct pinctrl_dev *pctldev, unsigned group, int i, ret; for (i = 0; i < num_configs; i++) { - ret = mtk_pinconf_set(pctldev, grp->pin, - pinconf_to_config_param(configs[i]), - pinconf_to_config_argument(configs[i])); + ret = mtk_paris_pin_config_set(hw, grp->pin, + pinconf_to_config_param(configs[i]), + pinconf_to_config_argument(configs[i])); if (ret < 0) return ret; @@ -937,18 +936,19 @@ static int mtk_gpio_set_config(struct gpio_chip *chip, unsigned int offset, { struct mtk_pinctrl *hw = gpiochip_get_data(chip); const struct mtk_pin_desc *desc; - u32 debounce; + enum pin_config_param param = pinconf_to_config_param(config); + u32 arg = pinconf_to_config_argument(config); desc = (const struct mtk_pin_desc *)&hw->soc->pins[offset]; - if (!hw->eint || - pinconf_to_config_param(config) != PIN_CONFIG_INPUT_DEBOUNCE || - desc->eint.eint_n == EINT_NA) - return -ENOTSUPP; + if (param == PIN_CONFIG_INPUT_DEBOUNCE) { + if (!hw->eint || desc->eint.eint_n == EINT_NA) + return -ENOTSUPP; - debounce = pinconf_to_config_argument(config); + return mtk_eint_set_debounce(hw->eint, desc->eint.eint_n, arg); + } - return mtk_eint_set_debounce(hw->eint, desc->eint.eint_n, debounce); + return mtk_paris_pin_config_set(hw, offset, param, arg); } static int mtk_build_gpiochip(struct mtk_pinctrl *hw)
Currently the set_config callback in the gpio_chip registered by the pinctrl_paris driver only supports configuring a single parameter on specific pins (the input debounce of the EINT controller, on pins that support it), even though many other configurations are already implemented and available through the pinctrl API for configuration of pins by the Devicetree and other drivers. Expose all configurations currently implemented through the GPIO API so they can also be set from userspace, which is particularly useful to allow testing them from userspace. Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com> --- drivers/pinctrl/mediatek/pinctrl-paris.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)