Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

pinctrl: intel: Restore the pins that used to be in Direct IRQ mode

If the firmware mangled the register contents too much,
check the saved value for the Direct IRQ mode. If it
matches, we will restore the pin state.

Reported-by: Jim Minter <jimminter@microsoft.com>
Fixes: 6989ea4881c8 ("pinctrl: intel: Save and restore pins in "direct IRQ" mode")
Tested-by: Jim Minter <jimminter@microsoft.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Link: https://lore.kernel.org/r/20230206141558.20916-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Andy Shevchenko and committed by
Linus Walleij
a8520be3 5921b250

+13 -3
+13 -3
drivers/pinctrl/intel/pinctrl-intel.c
··· 1709 1709 EXPORT_SYMBOL_GPL(intel_pinctrl_get_soc_data); 1710 1710 1711 1711 #ifdef CONFIG_PM_SLEEP 1712 + static bool __intel_gpio_is_direct_irq(u32 value) 1713 + { 1714 + return (value & PADCFG0_GPIROUTIOXAPIC) && (value & PADCFG0_GPIOTXDIS) && 1715 + (__intel_gpio_get_gpio_mode(value) == PADCFG0_PMODE_GPIO); 1716 + } 1717 + 1712 1718 static bool intel_pinctrl_should_save(struct intel_pinctrl *pctrl, unsigned int pin) 1713 1719 { 1714 1720 const struct pin_desc *pd = pin_desc_get(pctrl->pctldev, pin); ··· 1748 1742 * See https://bugzilla.kernel.org/show_bug.cgi?id=214749. 1749 1743 */ 1750 1744 value = readl(intel_get_padcfg(pctrl, pin, PADCFG0)); 1751 - if ((value & PADCFG0_GPIROUTIOXAPIC) && (value & PADCFG0_GPIOTXDIS) && 1752 - (__intel_gpio_get_gpio_mode(value) == PADCFG0_PMODE_GPIO)) 1745 + if (__intel_gpio_is_direct_irq(value)) 1753 1746 return true; 1754 1747 1755 1748 return false; ··· 1878 1873 for (i = 0; i < pctrl->soc->npins; i++) { 1879 1874 const struct pinctrl_pin_desc *desc = &pctrl->soc->pins[i]; 1880 1875 1881 - if (!intel_pinctrl_should_save(pctrl, desc->number)) 1876 + if (!(intel_pinctrl_should_save(pctrl, desc->number) || 1877 + /* 1878 + * If the firmware mangled the register contents too much, 1879 + * check the saved value for the Direct IRQ mode. 1880 + */ 1881 + __intel_gpio_is_direct_irq(pads[i].padcfg0))) 1882 1882 continue; 1883 1883 1884 1884 intel_restore_padcfg(pctrl, desc->number, PADCFG0, pads[i].padcfg0);