Skip to content

Commit 17fab47

Browse files
andy-shevlinusw
authored andcommitted
pinctrl: intel: Set pin direction properly
There are two bits in the PADCFG0 register to configure direction, one per TX/RX buffers. For now we wrongly assume that the GPIO is always requested before it is being used, which is not true when the GPIO is used through irqchip. In this case the GPIO is never requested and we never enable RX buffer for it. Fix this by setting both bits accordingly. Reported-by: Jarkko Nikula <[email protected]> Signed-off-by: Andy Shevchenko <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
1 parent ecc8995 commit 17fab47

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

drivers/pinctrl/intel/pinctrl-intel.c

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,21 @@ static int intel_pinmux_set_mux(struct pinctrl_dev *pctldev, unsigned function,
353353
return 0;
354354
}
355355

356+
static void __intel_gpio_set_direction(void __iomem *padcfg0, bool input)
357+
{
358+
u32 value;
359+
360+
value = readl(padcfg0);
361+
if (input) {
362+
value &= ~PADCFG0_GPIORXDIS;
363+
value |= PADCFG0_GPIOTXDIS;
364+
} else {
365+
value &= ~PADCFG0_GPIOTXDIS;
366+
value |= PADCFG0_GPIORXDIS;
367+
}
368+
writel(value, padcfg0);
369+
}
370+
356371
static int intel_gpio_request_enable(struct pinctrl_dev *pctldev,
357372
struct pinctrl_gpio_range *range,
358373
unsigned pin)
@@ -375,11 +390,11 @@ static int intel_gpio_request_enable(struct pinctrl_dev *pctldev,
375390
/* Disable SCI/SMI/NMI generation */
376391
value &= ~(PADCFG0_GPIROUTIOXAPIC | PADCFG0_GPIROUTSCI);
377392
value &= ~(PADCFG0_GPIROUTSMI | PADCFG0_GPIROUTNMI);
378-
/* Disable TX buffer and enable RX (this will be input) */
379-
value &= ~PADCFG0_GPIORXDIS;
380-
value |= PADCFG0_GPIOTXDIS;
381393
writel(value, padcfg0);
382394

395+
/* Disable TX buffer and enable RX (this will be input) */
396+
__intel_gpio_set_direction(padcfg0, true);
397+
383398
raw_spin_unlock_irqrestore(&pctrl->lock, flags);
384399

385400
return 0;
@@ -392,18 +407,11 @@ static int intel_gpio_set_direction(struct pinctrl_dev *pctldev,
392407
struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);
393408
void __iomem *padcfg0;
394409
unsigned long flags;
395-
u32 value;
396410

397411
raw_spin_lock_irqsave(&pctrl->lock, flags);
398412

399413
padcfg0 = intel_get_padcfg(pctrl, pin, PADCFG0);
400-
401-
value = readl(padcfg0);
402-
if (input)
403-
value |= PADCFG0_GPIOTXDIS;
404-
else
405-
value &= ~PADCFG0_GPIOTXDIS;
406-
writel(value, padcfg0);
414+
__intel_gpio_set_direction(padcfg0, input);
407415

408416
raw_spin_unlock_irqrestore(&pctrl->lock, flags);
409417

0 commit comments

Comments
 (0)