Skip to content

Commit af7e3ee

Browse files
committed
pinctrl: intel: Disable input and output buffer when switching to GPIO
It's possible scenario that pin has been in different mode, while the respective GPIO register has a leftover output buffer enabled. In such case when we request GPIO it will switch to GPIO mode, and thus to output with unknown value, followed by switching to input mode. This can produce a glitch on the pin. Disable input and output buffer when switching to GPIO to avoid potential glitches. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
1 parent 293428f commit af7e3ee

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

‎drivers/pinctrl/intel/pinctrl-intel.c‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,11 +435,20 @@ static void intel_gpio_set_gpio_mode(void __iomem *padcfg0)
435435
{
436436
u32 value;
437437

438+
value = readl(padcfg0);
439+
438440
/* Put the pad into GPIO mode */
439-
value = readl(padcfg0) & ~PADCFG0_PMODE_MASK;
441+
value &= ~PADCFG0_PMODE_MASK;
442+
value |= PADCFG0_PMODE_GPIO;
443+
444+
/* Disable input and output buffers */
445+
value &= ~PADCFG0_GPIORXDIS;
446+
value &= ~PADCFG0_GPIOTXDIS;
447+
440448
/* Disable SCI/SMI/NMI generation */
441449
value &= ~(PADCFG0_GPIROUTIOXAPIC | PADCFG0_GPIROUTSCI);
442450
value &= ~(PADCFG0_GPIROUTSMI | PADCFG0_GPIROUTNMI);
451+
443452
writel(value, padcfg0);
444453
}
445454

@@ -1036,6 +1045,9 @@ static int intel_gpio_irq_type(struct irq_data *d, unsigned int type)
10361045

10371046
intel_gpio_set_gpio_mode(reg);
10381047

1048+
/* Disable TX buffer and enable RX (this will be input) */
1049+
__intel_gpio_set_direction(reg, true);
1050+
10391051
value = readl(reg);
10401052

10411053
value &= ~(PADCFG0_RXEVCFG_MASK | PADCFG0_RXINV);

0 commit comments

Comments
 (0)