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 - add support for OTP variants

This patch adds support for each available OTP variant of the device.
The OTP configuration cannot be read over I2C, so it is derived from
a compatible string instead.

Early revisions of the D0 order code require their OTP-enabled func-
tionality to be manually restored following a soft reset; this patch
accommodates this erratum as well.

Signed-off-by: Jeff LaBundy <jeff@labundy.com>
Link: https://lore.kernel.org/r/ZZMaZbdk6iAKUjlm@nixie71
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Jeff LaBundy and committed by
Dmitry Torokhov
992bbc9e 56c083e3

+89 -3
+89 -3
drivers/input/misc/iqs269a.c
··· 102 102 #define IQS269_MISC_B_TRACKING_UI_ENABLE BIT(4) 103 103 #define IQS269_MISC_B_FILT_STR_SLIDER GENMASK(1, 0) 104 104 105 + #define IQS269_TOUCH_HOLD_SLIDER_SEL 0x89 106 + #define IQS269_TOUCH_HOLD_DEFAULT 0x14 107 + #define IQS269_TOUCH_HOLD_MS_MIN 256 108 + #define IQS269_TOUCH_HOLD_MS_MAX 65280 109 + 105 110 #define IQS269_TIMEOUT_TAP_MS_MAX 4080 106 111 #define IQS269_TIMEOUT_SWIPE_MS_MAX 4080 107 112 #define IQS269_THRESH_SWIPE_MAX 255 ··· 155 150 #define IQS269_HALL_UI_ENABLE BIT(15) 156 151 157 152 #define IQS269_MAX_REG 0xFF 153 + 154 + #define IQS269_OTP_OPTION_DEFAULT 0x00 155 + #define IQS269_OTP_OPTION_TWS 0xD0 156 + #define IQS269_OTP_OPTION_HOLD BIT(7) 158 157 159 158 #define IQS269_NUM_CH 8 160 159 #define IQS269_NUM_SL 2 ··· 324 315 struct input_dev *slider[IQS269_NUM_SL]; 325 316 unsigned int keycode[ARRAY_SIZE(iqs269_events) * IQS269_NUM_CH]; 326 317 unsigned int sl_code[IQS269_NUM_SL][IQS269_NUM_GESTURES]; 318 + unsigned int otp_option; 327 319 unsigned int ch_num; 328 320 bool hall_enable; 329 321 bool ati_current; ··· 334 324 int slider_num) 335 325 { 336 326 int i; 327 + 328 + /* 329 + * Slider 1 is unavailable if the touch-and-hold option is enabled via 330 + * OTP. In that case, the channel selection register is repurposed for 331 + * the touch-and-hold timer ceiling. 332 + */ 333 + if (slider_num && (iqs269->otp_option & IQS269_OTP_OPTION_HOLD)) 334 + return IQS269_SLIDER_NONE; 337 335 338 336 if (!iqs269->sys_reg.slider_select[slider_num]) 339 337 return IQS269_SLIDER_NONE; ··· 583 565 if (fwnode_property_present(ch_node, "azoteq,slider0-select")) 584 566 iqs269->sys_reg.slider_select[0] |= BIT(reg); 585 567 586 - if (fwnode_property_present(ch_node, "azoteq,slider1-select")) 568 + if (fwnode_property_present(ch_node, "azoteq,slider1-select") && 569 + !(iqs269->otp_option & IQS269_OTP_OPTION_HOLD)) 587 570 iqs269->sys_reg.slider_select[1] |= BIT(reg); 588 571 589 572 ch_reg = &iqs269->sys_reg.ch_reg[reg]; ··· 1009 990 sys_reg->blocking = 0; 1010 991 1011 992 sys_reg->slider_select[0] = 0; 1012 - sys_reg->slider_select[1] = 0; 993 + 994 + /* 995 + * If configured via OTP to do so, the device asserts a pulse on the 996 + * GPIO4 pin for approximately 60 ms once a selected channel is held 997 + * in a state of touch for a configurable length of time. 998 + * 999 + * In that case, the register used for slider 1 channel selection is 1000 + * repurposed for the touch-and-hold timer ceiling. 1001 + */ 1002 + if (iqs269->otp_option & IQS269_OTP_OPTION_HOLD) { 1003 + if (!device_property_read_u32(&client->dev, 1004 + "azoteq,touch-hold-ms", &val)) { 1005 + if (val < IQS269_TOUCH_HOLD_MS_MIN || 1006 + val > IQS269_TOUCH_HOLD_MS_MAX) { 1007 + dev_err(&client->dev, 1008 + "Invalid touch-and-hold ceiling: %u\n", 1009 + val); 1010 + return -EINVAL; 1011 + } 1012 + 1013 + sys_reg->slider_select[1] = val / 256; 1014 + } else if (iqs269->ver_info.fw_num < IQS269_VER_INFO_FW_NUM_3) { 1015 + /* 1016 + * The default touch-and-hold timer ceiling initially 1017 + * read from early revisions of silicon is invalid if 1018 + * the device experienced a soft reset between power- 1019 + * on and the read operation. 1020 + * 1021 + * To protect against this case, explicitly cache the 1022 + * default value so that it is restored each time the 1023 + * device is re-initialized. 1024 + */ 1025 + sys_reg->slider_select[1] = IQS269_TOUCH_HOLD_DEFAULT; 1026 + } 1027 + } else { 1028 + sys_reg->slider_select[1] = 0; 1029 + } 1013 1030 1014 1031 sys_reg->event_mask = ~((u8)IQS269_EVENT_MASK_SYS); 1015 1032 ··· 1192 1137 return 0; 1193 1138 } 1194 1139 1140 + static const struct reg_sequence iqs269_tws_init[] = { 1141 + { IQS269_TOUCH_HOLD_SLIDER_SEL, IQS269_TOUCH_HOLD_DEFAULT }, 1142 + { 0xF0, 0x580F }, 1143 + { 0xF0, 0x59EF }, 1144 + }; 1145 + 1195 1146 static int iqs269_dev_init(struct iqs269_private *iqs269) 1196 1147 { 1197 1148 int error; 1198 1149 1199 1150 mutex_lock(&iqs269->lock); 1151 + 1152 + /* 1153 + * Early revisions of silicon require the following workaround in order 1154 + * to restore any OTP-enabled functionality after a soft reset. 1155 + */ 1156 + if (iqs269->otp_option == IQS269_OTP_OPTION_TWS && 1157 + iqs269->ver_info.fw_num < IQS269_VER_INFO_FW_NUM_3) { 1158 + error = regmap_multi_reg_write(iqs269->regmap, iqs269_tws_init, 1159 + ARRAY_SIZE(iqs269_tws_init)); 1160 + if (error) 1161 + goto err_mutex; 1162 + } 1200 1163 1201 1164 error = regmap_update_bits(iqs269->regmap, IQS269_HALL_UI, 1202 1165 IQS269_HALL_UI_ENABLE, ··· 1852 1779 mutex_init(&iqs269->lock); 1853 1780 init_completion(&iqs269->ati_done); 1854 1781 1782 + iqs269->otp_option = (uintptr_t)device_get_match_data(&client->dev); 1783 + 1855 1784 error = regmap_raw_read(iqs269->regmap, IQS269_VER_INFO, 1856 1785 &iqs269->ver_info, sizeof(iqs269->ver_info)); 1857 1786 if (error) ··· 1964 1889 static DEFINE_SIMPLE_DEV_PM_OPS(iqs269_pm, iqs269_suspend, iqs269_resume); 1965 1890 1966 1891 static const struct of_device_id iqs269_of_match[] = { 1967 - { .compatible = "azoteq,iqs269a" }, 1892 + { 1893 + .compatible = "azoteq,iqs269a", 1894 + .data = (void *)IQS269_OTP_OPTION_DEFAULT, 1895 + }, 1896 + { 1897 + .compatible = "azoteq,iqs269a-00", 1898 + .data = (void *)IQS269_OTP_OPTION_DEFAULT, 1899 + }, 1900 + { 1901 + .compatible = "azoteq,iqs269a-d0", 1902 + .data = (void *)IQS269_OTP_OPTION_TWS, 1903 + }, 1968 1904 { } 1969 1905 }; 1970 1906 MODULE_DEVICE_TABLE(of, iqs269_of_match);