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

Configure Feed

Select the types of activity you want to include in your feed.

Input: iqs269a - do not poll during suspend or resume

Polling the device while it transitions from automatic to manual
power mode switching may keep the device from actually finishing
the transition. The process appears to time out depending on the
polling rate and the device's core clock frequency.

This is ultimately unnecessary in the first place; instead it is
sufficient to write the desired mode during initialization, then
disable automatic switching at suspend. This eliminates the need
to ensure the device is prepared for a manual change and removes
the 'suspend_mode' variable.

Similarly, polling the device while it transitions from one mode
to another under manual control may time out as well. This added
step does not appear to be necessary either, so drop it.

Fixes: 04e49867fad1 ("Input: add support for Azoteq IQS269A")
Signed-off-by: Jeff LaBundy <jeff@labundy.com>
Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Link: https://lore.kernel.org/r/Y7Rs+eEXlRw4Vq57@nixie71
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Jeff LaBundy and committed by
Dmitry Torokhov
18ab69c8 3689abfc

+31 -87
+31 -87
drivers/input/misc/iqs269a.c
··· 148 148 #define IQS269_ATI_POLL_TIMEOUT_US (iqs269->delay_mult * 500000) 149 149 #define IQS269_ATI_STABLE_DELAY_MS (iqs269->delay_mult * 150) 150 150 151 - #define IQS269_PWR_MODE_POLL_SLEEP_US IQS269_ATI_POLL_SLEEP_US 152 - #define IQS269_PWR_MODE_POLL_TIMEOUT_US IQS269_ATI_POLL_TIMEOUT_US 153 - 154 151 #define iqs269_irq_wait() usleep_range(200, 250) 155 152 156 153 enum iqs269_local_cap_size { ··· 292 295 struct input_dev *keypad; 293 296 struct input_dev *slider[IQS269_NUM_SL]; 294 297 unsigned int keycode[ARRAY_SIZE(iqs269_events) * IQS269_NUM_CH]; 295 - unsigned int suspend_mode; 296 298 unsigned int delay_mult; 297 299 unsigned int ch_num; 298 300 bool hall_enable; ··· 763 767 iqs269->hall_enable = device_property_present(&client->dev, 764 768 "azoteq,hall-enable"); 765 769 766 - if (!device_property_read_u32(&client->dev, "azoteq,suspend-mode", 767 - &val)) { 768 - if (val > IQS269_SYS_SETTINGS_PWR_MODE_MAX) { 769 - dev_err(&client->dev, "Invalid suspend mode: %u\n", 770 - val); 771 - return -EINVAL; 772 - } 773 - 774 - iqs269->suspend_mode = val; 775 - } 776 - 777 770 error = regmap_raw_read(iqs269->regmap, IQS269_SYS_SETTINGS, sys_reg, 778 771 sizeof(*sys_reg)); 779 772 if (error) ··· 989 1004 general &= ~IQS269_SYS_SETTINGS_ULP_AUTO; 990 1005 general &= ~IQS269_SYS_SETTINGS_DIS_AUTO; 991 1006 general &= ~IQS269_SYS_SETTINGS_PWR_MODE_MASK; 1007 + 1008 + if (!device_property_read_u32(&client->dev, "azoteq,suspend-mode", 1009 + &val)) { 1010 + if (val > IQS269_SYS_SETTINGS_PWR_MODE_MAX) { 1011 + dev_err(&client->dev, "Invalid suspend mode: %u\n", 1012 + val); 1013 + return -EINVAL; 1014 + } 1015 + 1016 + general |= (val << IQS269_SYS_SETTINGS_PWR_MODE_SHIFT); 1017 + } 992 1018 993 1019 if (!device_property_read_u32(&client->dev, "azoteq,ulp-update", 994 1020 &val)) { ··· 1683 1687 return error; 1684 1688 } 1685 1689 1690 + static u16 iqs269_general_get(struct iqs269_private *iqs269) 1691 + { 1692 + u16 general = be16_to_cpu(iqs269->sys_reg.general); 1693 + 1694 + general &= ~IQS269_SYS_SETTINGS_REDO_ATI; 1695 + general &= ~IQS269_SYS_SETTINGS_ACK_RESET; 1696 + 1697 + return general | IQS269_SYS_SETTINGS_DIS_AUTO; 1698 + } 1699 + 1686 1700 static int iqs269_suspend(struct device *dev) 1687 1701 { 1688 1702 struct iqs269_private *iqs269 = dev_get_drvdata(dev); 1689 1703 struct i2c_client *client = iqs269->client; 1690 - unsigned int val; 1691 1704 int error; 1705 + u16 general = iqs269_general_get(iqs269); 1692 1706 1693 - if (!iqs269->suspend_mode) 1707 + if (!(general & IQS269_SYS_SETTINGS_PWR_MODE_MASK)) 1694 1708 return 0; 1695 1709 1696 1710 disable_irq(client->irq); 1697 1711 1698 - /* 1699 - * Automatic power mode switching must be disabled before the device is 1700 - * forced into any particular power mode. In this case, the device will 1701 - * transition into normal-power mode. 1702 - */ 1703 - error = regmap_update_bits(iqs269->regmap, IQS269_SYS_SETTINGS, 1704 - IQS269_SYS_SETTINGS_DIS_AUTO, ~0); 1705 - if (error) 1706 - goto err_irq; 1712 + error = regmap_write(iqs269->regmap, IQS269_SYS_SETTINGS, general); 1707 1713 1708 - /* 1709 - * The following check ensures the device has completed its transition 1710 - * into normal-power mode before a manual mode switch is performed. 1711 - */ 1712 - error = regmap_read_poll_timeout(iqs269->regmap, IQS269_SYS_FLAGS, val, 1713 - !(val & IQS269_SYS_FLAGS_PWR_MODE_MASK), 1714 - IQS269_PWR_MODE_POLL_SLEEP_US, 1715 - IQS269_PWR_MODE_POLL_TIMEOUT_US); 1716 - if (error) 1717 - goto err_irq; 1718 - 1719 - error = regmap_update_bits(iqs269->regmap, IQS269_SYS_SETTINGS, 1720 - IQS269_SYS_SETTINGS_PWR_MODE_MASK, 1721 - iqs269->suspend_mode << 1722 - IQS269_SYS_SETTINGS_PWR_MODE_SHIFT); 1723 - if (error) 1724 - goto err_irq; 1725 - 1726 - /* 1727 - * This last check ensures the device has completed its transition into 1728 - * the desired power mode to prevent any spurious interrupts from being 1729 - * triggered after iqs269_suspend has already returned. 1730 - */ 1731 - error = regmap_read_poll_timeout(iqs269->regmap, IQS269_SYS_FLAGS, val, 1732 - (val & IQS269_SYS_FLAGS_PWR_MODE_MASK) 1733 - == (iqs269->suspend_mode << 1734 - IQS269_SYS_FLAGS_PWR_MODE_SHIFT), 1735 - IQS269_PWR_MODE_POLL_SLEEP_US, 1736 - IQS269_PWR_MODE_POLL_TIMEOUT_US); 1737 - 1738 - err_irq: 1739 1714 iqs269_irq_wait(); 1740 1715 enable_irq(client->irq); 1741 1716 ··· 1717 1750 { 1718 1751 struct iqs269_private *iqs269 = dev_get_drvdata(dev); 1719 1752 struct i2c_client *client = iqs269->client; 1720 - unsigned int val; 1721 1753 int error; 1754 + u16 general = iqs269_general_get(iqs269); 1722 1755 1723 - if (!iqs269->suspend_mode) 1756 + if (!(general & IQS269_SYS_SETTINGS_PWR_MODE_MASK)) 1724 1757 return 0; 1725 1758 1726 1759 disable_irq(client->irq); 1727 1760 1728 - error = regmap_update_bits(iqs269->regmap, IQS269_SYS_SETTINGS, 1729 - IQS269_SYS_SETTINGS_PWR_MODE_MASK, 0); 1730 - if (error) 1731 - goto err_irq; 1761 + error = regmap_write(iqs269->regmap, IQS269_SYS_SETTINGS, 1762 + general & ~IQS269_SYS_SETTINGS_PWR_MODE_MASK); 1763 + if (!error) 1764 + error = regmap_write(iqs269->regmap, IQS269_SYS_SETTINGS, 1765 + general & ~IQS269_SYS_SETTINGS_DIS_AUTO); 1732 1766 1733 - /* 1734 - * This check ensures the device has returned to normal-power mode 1735 - * before automatic power mode switching is re-enabled. 1736 - */ 1737 - error = regmap_read_poll_timeout(iqs269->regmap, IQS269_SYS_FLAGS, val, 1738 - !(val & IQS269_SYS_FLAGS_PWR_MODE_MASK), 1739 - IQS269_PWR_MODE_POLL_SLEEP_US, 1740 - IQS269_PWR_MODE_POLL_TIMEOUT_US); 1741 - if (error) 1742 - goto err_irq; 1743 - 1744 - error = regmap_update_bits(iqs269->regmap, IQS269_SYS_SETTINGS, 1745 - IQS269_SYS_SETTINGS_DIS_AUTO, 0); 1746 - if (error) 1747 - goto err_irq; 1748 - 1749 - /* 1750 - * This step reports any events that may have been "swallowed" as a 1751 - * result of polling PWR_MODE (which automatically acknowledges any 1752 - * pending interrupts). 1753 - */ 1754 - error = iqs269_report(iqs269); 1755 - 1756 - err_irq: 1757 1767 iqs269_irq_wait(); 1758 1768 enable_irq(client->irq); 1759 1769