pinctrl: baytrail: Rectify debounce support

The commit 658b476c74 ("pinctrl: baytrail: Add debounce configuration")
implements debounce for Baytrail pin control, but seems wasn't tested properly.

The register which keeps debounce value is separated from the configuration
one. Writing wrong values to the latter will guarantee wrong behaviour of the
driver and even might break something physically.

Besides above there is missed case how to disable it, which is actually done
through the bit in configuration register.

Rectify implementation here by using proper register for debounce value.

Fixes: 658b476c74 ("pinctrl: baytrail: Add debounce configuration")
Cc: Cristina Ciocan <cristina.ciocan@intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
Andy Shevchenko 2017-01-10 16:38:52 +02:00 коммит произвёл Linus Walleij
Родитель 17fab47369
Коммит 04ff5a095d
1 изменённых файлов: 17 добавлений и 11 удалений

Просмотреть файл

@ -1092,6 +1092,7 @@ static int byt_pin_config_get(struct pinctrl_dev *pctl_dev, unsigned int offset,
enum pin_config_param param = pinconf_to_config_param(*config); enum pin_config_param param = pinconf_to_config_param(*config);
void __iomem *conf_reg = byt_gpio_reg(vg, offset, BYT_CONF0_REG); void __iomem *conf_reg = byt_gpio_reg(vg, offset, BYT_CONF0_REG);
void __iomem *val_reg = byt_gpio_reg(vg, offset, BYT_VAL_REG); void __iomem *val_reg = byt_gpio_reg(vg, offset, BYT_VAL_REG);
void __iomem *db_reg = byt_gpio_reg(vg, offset, BYT_DEBOUNCE_REG);
unsigned long flags; unsigned long flags;
u32 conf, pull, val, debounce; u32 conf, pull, val, debounce;
u16 arg = 0; u16 arg = 0;
@ -1128,7 +1129,7 @@ static int byt_pin_config_get(struct pinctrl_dev *pctl_dev, unsigned int offset,
return -EINVAL; return -EINVAL;
raw_spin_lock_irqsave(&vg->lock, flags); raw_spin_lock_irqsave(&vg->lock, flags);
debounce = readl(byt_gpio_reg(vg, offset, BYT_DEBOUNCE_REG)); debounce = readl(db_reg);
raw_spin_unlock_irqrestore(&vg->lock, flags); raw_spin_unlock_irqrestore(&vg->lock, flags);
switch (debounce & BYT_DEBOUNCE_PULSE_MASK) { switch (debounce & BYT_DEBOUNCE_PULSE_MASK) {
@ -1176,6 +1177,7 @@ static int byt_pin_config_set(struct pinctrl_dev *pctl_dev,
unsigned int param, arg; unsigned int param, arg;
void __iomem *conf_reg = byt_gpio_reg(vg, offset, BYT_CONF0_REG); void __iomem *conf_reg = byt_gpio_reg(vg, offset, BYT_CONF0_REG);
void __iomem *val_reg = byt_gpio_reg(vg, offset, BYT_VAL_REG); void __iomem *val_reg = byt_gpio_reg(vg, offset, BYT_VAL_REG);
void __iomem *db_reg = byt_gpio_reg(vg, offset, BYT_DEBOUNCE_REG);
unsigned long flags; unsigned long flags;
u32 conf, val, debounce; u32 conf, val, debounce;
int i, ret = 0; int i, ret = 0;
@ -1238,36 +1240,40 @@ static int byt_pin_config_set(struct pinctrl_dev *pctl_dev,
break; break;
case PIN_CONFIG_INPUT_DEBOUNCE: case PIN_CONFIG_INPUT_DEBOUNCE:
debounce = readl(byt_gpio_reg(vg, offset, debounce = readl(db_reg);
BYT_DEBOUNCE_REG)); debounce &= ~BYT_DEBOUNCE_PULSE_MASK;
conf &= ~BYT_DEBOUNCE_PULSE_MASK;
switch (arg) { switch (arg) {
case 0:
conf &= BYT_DEBOUNCE_EN;
break;
case 375: case 375:
conf |= BYT_DEBOUNCE_PULSE_375US; debounce |= BYT_DEBOUNCE_PULSE_375US;
break; break;
case 750: case 750:
conf |= BYT_DEBOUNCE_PULSE_750US; debounce |= BYT_DEBOUNCE_PULSE_750US;
break; break;
case 1500: case 1500:
conf |= BYT_DEBOUNCE_PULSE_1500US; debounce |= BYT_DEBOUNCE_PULSE_1500US;
break; break;
case 3000: case 3000:
conf |= BYT_DEBOUNCE_PULSE_3MS; debounce |= BYT_DEBOUNCE_PULSE_3MS;
break; break;
case 6000: case 6000:
conf |= BYT_DEBOUNCE_PULSE_6MS; debounce |= BYT_DEBOUNCE_PULSE_6MS;
break; break;
case 12000: case 12000:
conf |= BYT_DEBOUNCE_PULSE_12MS; debounce |= BYT_DEBOUNCE_PULSE_12MS;
break; break;
case 24000: case 24000:
conf |= BYT_DEBOUNCE_PULSE_24MS; debounce |= BYT_DEBOUNCE_PULSE_24MS;
break; break;
default: default:
ret = -EINVAL; ret = -EINVAL;
} }
if (!ret)
writel(debounce, db_reg);
break; break;
default: default:
ret = -ENOTSUPP; ret = -ENOTSUPP;