Skip to content

Commit 283c5ce

Browse files
superm1linusw
authored andcommitted
pinctrl: amd: Unify debounce handling into amd_pinconf_set()
Debounce handling is done in two different entry points in the driver. Unify this to make sure that it's always handled the same. Tested-by: Jan Visser <starquake@linuxeverywhere.org> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> Link: https://lore.kernel.org/r/20230705133005.577-5-mario.limonciello@amd.com Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
1 parent 3f62312 commit 283c5ce

File tree

1 file changed

+5
-16
lines changed

1 file changed

+5
-16
lines changed

drivers/pinctrl/pinctrl-amd.c

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -116,16 +116,12 @@ static void amd_gpio_set_value(struct gpio_chip *gc, unsigned offset, int value)
116116
raw_spin_unlock_irqrestore(&gpio_dev->lock, flags);
117117
}
118118

119-
static int amd_gpio_set_debounce(struct gpio_chip *gc, unsigned offset,
120-
unsigned debounce)
119+
static int amd_gpio_set_debounce(struct amd_gpio *gpio_dev, unsigned int offset,
120+
unsigned int debounce)
121121
{
122122
u32 time;
123123
u32 pin_reg;
124124
int ret = 0;
125-
unsigned long flags;
126-
struct amd_gpio *gpio_dev = gpiochip_get_data(gc);
127-
128-
raw_spin_lock_irqsave(&gpio_dev->lock, flags);
129125

130126
/* Use special handling for Pin0 debounce */
131127
if (offset == 0) {
@@ -184,7 +180,6 @@ static int amd_gpio_set_debounce(struct gpio_chip *gc, unsigned offset,
184180
pin_reg &= ~(DB_CNTRl_MASK << DB_CNTRL_OFF);
185181
}
186182
writel(pin_reg, gpio_dev->base + offset * 4);
187-
raw_spin_unlock_irqrestore(&gpio_dev->lock, flags);
188183

189184
return ret;
190185
}
@@ -782,9 +777,8 @@ static int amd_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin,
782777

783778
switch (param) {
784779
case PIN_CONFIG_INPUT_DEBOUNCE:
785-
pin_reg &= ~DB_TMR_OUT_MASK;
786-
pin_reg |= arg & DB_TMR_OUT_MASK;
787-
break;
780+
ret = amd_gpio_set_debounce(gpio_dev, pin, arg);
781+
goto out_unlock;
788782

789783
case PIN_CONFIG_BIAS_PULL_DOWN:
790784
pin_reg &= ~BIT(PULL_DOWN_ENABLE_OFF);
@@ -811,6 +805,7 @@ static int amd_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin,
811805

812806
writel(pin_reg, gpio_dev->base + pin*4);
813807
}
808+
out_unlock:
814809
raw_spin_unlock_irqrestore(&gpio_dev->lock, flags);
815810

816811
return ret;
@@ -857,12 +852,6 @@ static int amd_gpio_set_config(struct gpio_chip *gc, unsigned int pin,
857852
{
858853
struct amd_gpio *gpio_dev = gpiochip_get_data(gc);
859854

860-
if (pinconf_to_config_param(config) == PIN_CONFIG_INPUT_DEBOUNCE) {
861-
u32 debounce = pinconf_to_config_argument(config);
862-
863-
return amd_gpio_set_debounce(gc, pin, debounce);
864-
}
865-
866855
return amd_pinconf_set(gpio_dev->pctrl, pin, &config, 1);
867856
}
868857

0 commit comments

Comments
 (0)