pinctrl: moorefield: Fix open-drain pin mode configuration
PATCH 1/2 pinctrl: moorefield: Fix open-drain pin mode configuration
Currently the pin may not be configured as open-drain in some cases because the argument may be 0 for the boolean types of the pin configurations. Fix this by ignoring the argument.
With that, allow to actually restore pin to the push-pull mode.
--- drivers/pinctrl/intel/pinctrl-moorefield.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/pinctrl/intel/pinctrl-moorefield.c +12 -2
@@ -661,6 +661,11 @@ static int mofld_config_get(struct pinctrl_dev *pctldev, unsigned int pin,break ; +case PIN_CONFIG_DRIVE_PUSH_PULL : +if (value &BUFCFG_OD_EN ) +return -EINVAL ; +break ; +case PIN_CONFIG_DRIVE_OPEN_DRAIN :if (!(value &BUFCFG_OD_EN ))return -EINVAL ;
@@ -734,10 +739,14 @@ static int mofld_config_set_pin(struct mofld_pinctrl *mp, unsigned int pin,break ; +case PIN_CONFIG_DRIVE_PUSH_PULL : + mask |=BUFCFG_OD_EN ; + bits &= ~BUFCFG_OD_EN ; +break ; +case PIN_CONFIG_DRIVE_OPEN_DRAIN : mask |=BUFCFG_OD_EN ; -if (arg) - bits |=BUFCFG_OD_EN ; + bits |=BUFCFG_OD_EN ;break ;case PIN_CONFIG_SLEW_RATE :
@@ -769,6 +778,7 @@ static int mofld_config_set(struct pinctrl_dev *pctldev, unsigned int pin,case PIN_CONFIG_BIAS_DISABLE :case PIN_CONFIG_BIAS_PULL_UP :case PIN_CONFIG_BIAS_PULL_DOWN : +case PIN_CONFIG_DRIVE_PUSH_PULL :case PIN_CONFIG_DRIVE_OPEN_DRAIN :case PIN_CONFIG_SLEW_RATE : ret =mofld_config_set_pin (mp, pin, configs[i]);
Signature · 1 line
2.40.0.1.gaa8946217a0b
PATCH 2/2 pinctrl: moorefield: Use BUFCFG_PINMODE_GPIO in ->pin_dbg_show()
Use explicit comparison to BUFCFG_PINMODE_GPIO instead of implying it.
--- drivers/pinctrl/intel/pinctrl-moorefield.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/intel/pinctrl-moorefield.c +1 -1
@@ -504,7 +504,7 @@ static void mofld_pin_dbg_show(struct pinctrl_dev *pctldev, struct seq_file *s, } mode = (value &BUFCFG_PINMODE_MASK ) >>BUFCFG_PINMODE_SHIFT ; -if (!mode) +if (mode ==BUFCFG_PINMODE_GPIO )seq_puts (s,"GPIO " );else seq_printf (s,"mode %d " , mode);
Signature · 1 line
2.40.0.1.gaa8946217a0b
Re: [PATCH v1 2/2] pinctrl: moorefield: Use BUFCFG_PINMODE_GPIO in ->pin_dbg_show()
Quoted 3 lines · Andy Shevchenko
Use explicit comparison to
BUFCFG_PINMODE_GPIOinstead of implying it.Signed-off-by Andy Shevchenko <[email protected]>
Quoted 7 lines · Andy Shevchenko
Currently the pin may not be configured as open-drain in some cases because the argument may be 0 for the boolean types of the pin configurations. Fix this by ignoring the argument.
With that, allow to actually restore pin to the push-pull mode.
Signed-off-by Andy Shevchenko <[email protected]>
BTW, looking at the two drivers they seem to have a lot of commonalities. Perhaps it makes sense to consolidate?
Tue, Jun 06, 2023 at 08:15:47AM +0300, Mika Westerberg kirjoitti:
Quoted 10 lines · Andy Shevchenko
Quoted 7 lines
Currently the pin may not be configured as open-drain in some cases because the argument may be 0 for the boolean types of the pin configurations. Fix this by ignoring the argument.
With that, allow to actually restore pin to the push-pull mode.
Signed-off-by Andy Shevchenko <[email protected]>Acked-by Mika Westerberg <[email protected]>
Thank you!
Quoted 2 lines
BTW, looking at the two drivers they seem to have a lot of commonalities. Perhaps it makes sense to consolidate?
Yes, that's the plan, perhaps for the next cycle.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 10 lines · Mika Westerberg
Quoted 7 lines · Andy Shevchenko
Currently the pin may not be configured as open-drain in some cases because the argument may be 0 for the boolean types of the pin configurations. Fix this by ignoring the argument.
With that, allow to actually restore pin to the push-pull mode.
Signed-off-by Andy Shevchenko <[email protected]>Acked-by Mika Westerberg <[email protected]>
Both pushed to my review and testing queue, thanks!
Signature · 2 lines
With Best Regards, Andy Shevchenko