Lines Matching +full:full +full:- +full:pwr +full:- +full:cycle +full:- +full:in +full:- +full:suspend

1 // SPDX-License-Identifier: GPL-2.0+
8 * inductive keys as well as Hall-effect switches, and one for each of the two
225 .name = "event-prox",
231 .name = "event-prox-alt",
238 .name = "event-touch",
244 .name = "event-touch-alt",
251 .name = "event-deep",
257 .name = "event-deep-alt",
339 * Slider 1 is unavailable if the touch-and-hold option is enabled via in iqs269_slider_type()
340 * OTP. In that case, the channel selection register is repurposed for in iqs269_slider_type()
341 * the touch-and-hold timer ceiling. in iqs269_slider_type()
343 if (slider_num && (iqs269->otp_option & IQS269_OTP_OPTION_HOLD)) in iqs269_slider_type()
346 if (!iqs269->sys_reg.slider_select[slider_num]) in iqs269_slider_type()
350 if (iqs269->sl_code[slider_num][i] != KEY_RESERVED) in iqs269_slider_type()
359 struct iqs269_ch_reg *ch_reg = iqs269->sys_reg.ch_reg; in iqs269_ati_mode_set()
363 return -EINVAL; in iqs269_ati_mode_set()
366 return -EINVAL; in iqs269_ati_mode_set()
368 mutex_lock(&iqs269->lock); in iqs269_ati_mode_set()
376 iqs269->ati_current = false; in iqs269_ati_mode_set()
378 mutex_unlock(&iqs269->lock); in iqs269_ati_mode_set()
386 struct iqs269_ch_reg *ch_reg = iqs269->sys_reg.ch_reg; in iqs269_ati_mode_get()
390 return -EINVAL; in iqs269_ati_mode_get()
392 mutex_lock(&iqs269->lock); in iqs269_ati_mode_get()
394 mutex_unlock(&iqs269->lock); in iqs269_ati_mode_get()
405 struct iqs269_ch_reg *ch_reg = iqs269->sys_reg.ch_reg; in iqs269_ati_base_set()
409 return -EINVAL; in iqs269_ati_base_set()
429 return -EINVAL; in iqs269_ati_base_set()
432 mutex_lock(&iqs269->lock); in iqs269_ati_base_set()
440 iqs269->ati_current = false; in iqs269_ati_base_set()
442 mutex_unlock(&iqs269->lock); in iqs269_ati_base_set()
450 struct iqs269_ch_reg *ch_reg = iqs269->sys_reg.ch_reg; in iqs269_ati_base_get()
454 return -EINVAL; in iqs269_ati_base_get()
456 mutex_lock(&iqs269->lock); in iqs269_ati_base_get()
458 mutex_unlock(&iqs269->lock); in iqs269_ati_base_get()
478 return -EINVAL; in iqs269_ati_base_get()
485 struct iqs269_ch_reg *ch_reg = iqs269->sys_reg.ch_reg; in iqs269_ati_target_set()
489 return -EINVAL; in iqs269_ati_target_set()
492 return -EINVAL; in iqs269_ati_target_set()
494 mutex_lock(&iqs269->lock); in iqs269_ati_target_set()
502 iqs269->ati_current = false; in iqs269_ati_target_set()
504 mutex_unlock(&iqs269->lock); in iqs269_ati_target_set()
512 struct iqs269_ch_reg *ch_reg = iqs269->sys_reg.ch_reg; in iqs269_ati_target_get()
516 return -EINVAL; in iqs269_ati_target_get()
518 mutex_lock(&iqs269->lock); in iqs269_ati_target_get()
520 mutex_unlock(&iqs269->lock); in iqs269_ati_target_get()
538 return -EINVAL; in iqs269_parse_mask()
548 return -EINVAL; in iqs269_parse_mask()
559 struct i2c_client *client = iqs269->client; in iqs269_parse_chan()
568 dev_err(&client->dev, "Failed to read channel number: %d\n", in iqs269_parse_chan()
572 dev_err(&client->dev, "Invalid channel number: %u\n", reg); in iqs269_parse_chan()
573 return -EINVAL; in iqs269_parse_chan()
576 iqs269->sys_reg.active |= BIT(reg); in iqs269_parse_chan()
577 if (!fwnode_property_present(ch_node, "azoteq,reseed-disable")) in iqs269_parse_chan()
578 iqs269->sys_reg.reseed |= BIT(reg); in iqs269_parse_chan()
580 if (fwnode_property_present(ch_node, "azoteq,blocking-enable")) in iqs269_parse_chan()
581 iqs269->sys_reg.blocking |= BIT(reg); in iqs269_parse_chan()
583 if (fwnode_property_present(ch_node, "azoteq,slider0-select")) in iqs269_parse_chan()
584 iqs269->sys_reg.slider_select[0] |= BIT(reg); in iqs269_parse_chan()
586 if (fwnode_property_present(ch_node, "azoteq,slider1-select") && in iqs269_parse_chan()
587 !(iqs269->otp_option & IQS269_OTP_OPTION_HOLD)) in iqs269_parse_chan()
588 iqs269->sys_reg.slider_select[1] |= BIT(reg); in iqs269_parse_chan()
590 ch_reg = &iqs269->sys_reg.ch_reg[reg]; in iqs269_parse_chan()
592 error = iqs269_parse_mask(ch_node, "azoteq,rx-enable", in iqs269_parse_chan()
593 &ch_reg->rx_enable); in iqs269_parse_chan()
595 dev_err(&client->dev, "Invalid channel %u RX enable mask: %d\n", in iqs269_parse_chan()
600 error = iqs269_parse_mask(ch_node, "azoteq,tx-enable", in iqs269_parse_chan()
601 &ch_reg->tx_enable); in iqs269_parse_chan()
603 dev_err(&client->dev, "Invalid channel %u TX enable mask: %d\n", in iqs269_parse_chan()
608 engine_a = be16_to_cpu(ch_reg->engine_a); in iqs269_parse_chan()
609 engine_b = be16_to_cpu(ch_reg->engine_b); in iqs269_parse_chan()
612 if (fwnode_property_present(ch_node, "azoteq,meas-cap-decrease")) in iqs269_parse_chan()
616 if (fwnode_property_present(ch_node, "azoteq,rx-float-inactive")) in iqs269_parse_chan()
621 if (!fwnode_property_read_u32(ch_node, "azoteq,local-cap-size", &val)) { in iqs269_parse_chan()
635 dev_err(&client->dev, in iqs269_parse_chan()
638 return -EINVAL; in iqs269_parse_chan()
643 if (fwnode_property_present(ch_node, "azoteq,invert-enable")) in iqs269_parse_chan()
646 if (!fwnode_property_read_u32(ch_node, "azoteq,proj-bias", &val)) { in iqs269_parse_chan()
648 dev_err(&client->dev, in iqs269_parse_chan()
651 return -EINVAL; in iqs269_parse_chan()
658 if (!fwnode_property_read_u32(ch_node, "azoteq,sense-mode", &val)) { in iqs269_parse_chan()
660 dev_err(&client->dev, in iqs269_parse_chan()
663 return -EINVAL; in iqs269_parse_chan()
670 if (!fwnode_property_read_u32(ch_node, "azoteq,sense-freq", &val)) { in iqs269_parse_chan()
672 dev_err(&client->dev, in iqs269_parse_chan()
675 return -EINVAL; in iqs269_parse_chan()
683 if (fwnode_property_present(ch_node, "azoteq,static-enable")) in iqs269_parse_chan()
686 ch_reg->engine_a = cpu_to_be16(engine_a); in iqs269_parse_chan()
687 ch_reg->engine_b = cpu_to_be16(engine_b); in iqs269_parse_chan()
689 if (!fwnode_property_read_u32(ch_node, "azoteq,ati-mode", &val)) { in iqs269_parse_chan()
692 dev_err(&client->dev, in iqs269_parse_chan()
698 if (!fwnode_property_read_u32(ch_node, "azoteq,ati-base", &val)) { in iqs269_parse_chan()
701 dev_err(&client->dev, in iqs269_parse_chan()
707 if (!fwnode_property_read_u32(ch_node, "azoteq,ati-target", &val)) { in iqs269_parse_chan()
710 dev_err(&client->dev, in iqs269_parse_chan()
717 error = iqs269_parse_mask(ch_node, "azoteq,assoc-select", in iqs269_parse_chan()
718 &ch_reg->assoc_select); in iqs269_parse_chan()
720 dev_err(&client->dev, "Invalid channel %u association: %d\n", in iqs269_parse_chan()
725 if (!fwnode_property_read_u32(ch_node, "azoteq,assoc-weight", &val)) { in iqs269_parse_chan()
727 dev_err(&client->dev, in iqs269_parse_chan()
730 return -EINVAL; in iqs269_parse_chan()
733 ch_reg->assoc_weight = val; in iqs269_parse_chan()
744 dev_err(&client->dev, in iqs269_parse_chan()
748 return -EINVAL; in iqs269_parse_chan()
751 ch_reg->thresh[iqs269_events[i].th_offs] = val; in iqs269_parse_chan()
755 u8 *hyst = &ch_reg->hyst; in iqs269_parse_chan()
758 dev_err(&client->dev, in iqs269_parse_chan()
762 return -EINVAL; in iqs269_parse_chan()
778 if (error == -EINVAL) { in iqs269_parse_chan()
781 dev_err(&client->dev, in iqs269_parse_chan()
789 if (iqs269->hall_enable) { in iqs269_parse_chan()
790 iqs269->switches[i].code = val; in iqs269_parse_chan()
791 iqs269->switches[i].enabled = true; in iqs269_parse_chan()
796 if (iqs269->hall_enable) in iqs269_parse_chan()
801 iqs269->keycode[i * IQS269_NUM_CH + reg] = val; in iqs269_parse_chan()
804 iqs269->sys_reg.event_mask &= ~iqs269_events[i].mask; in iqs269_parse_chan()
812 struct iqs269_sys_reg *sys_reg = &iqs269->sys_reg; in iqs269_parse_prop()
813 struct i2c_client *client = iqs269->client; in iqs269_parse_prop()
818 iqs269->hall_enable = device_property_present(&client->dev, in iqs269_parse_prop()
819 "azoteq,hall-enable"); in iqs269_parse_prop()
821 error = regmap_raw_read(iqs269->regmap, IQS269_SYS_SETTINGS, sys_reg, in iqs269_parse_prop()
826 if (!device_property_read_u32(&client->dev, "azoteq,filt-str-lp-lta", in iqs269_parse_prop()
829 dev_err(&client->dev, "Invalid filter strength: %u\n", in iqs269_parse_prop()
831 return -EINVAL; in iqs269_parse_prop()
834 sys_reg->filter &= ~IQS269_FILT_STR_LP_LTA_MASK; in iqs269_parse_prop()
835 sys_reg->filter |= (val << IQS269_FILT_STR_LP_LTA_SHIFT); in iqs269_parse_prop()
838 if (!device_property_read_u32(&client->dev, "azoteq,filt-str-lp-cnt", in iqs269_parse_prop()
841 dev_err(&client->dev, "Invalid filter strength: %u\n", in iqs269_parse_prop()
843 return -EINVAL; in iqs269_parse_prop()
846 sys_reg->filter &= ~IQS269_FILT_STR_LP_CNT_MASK; in iqs269_parse_prop()
847 sys_reg->filter |= (val << IQS269_FILT_STR_LP_CNT_SHIFT); in iqs269_parse_prop()
850 if (!device_property_read_u32(&client->dev, "azoteq,filt-str-np-lta", in iqs269_parse_prop()
853 dev_err(&client->dev, "Invalid filter strength: %u\n", in iqs269_parse_prop()
855 return -EINVAL; in iqs269_parse_prop()
858 sys_reg->filter &= ~IQS269_FILT_STR_NP_LTA_MASK; in iqs269_parse_prop()
859 sys_reg->filter |= (val << IQS269_FILT_STR_NP_LTA_SHIFT); in iqs269_parse_prop()
862 if (!device_property_read_u32(&client->dev, "azoteq,filt-str-np-cnt", in iqs269_parse_prop()
865 dev_err(&client->dev, "Invalid filter strength: %u\n", in iqs269_parse_prop()
867 return -EINVAL; in iqs269_parse_prop()
870 sys_reg->filter &= ~IQS269_FILT_STR_NP_CNT_MASK; in iqs269_parse_prop()
871 sys_reg->filter |= val; in iqs269_parse_prop()
874 if (!device_property_read_u32(&client->dev, "azoteq,rate-np-ms", in iqs269_parse_prop()
877 dev_err(&client->dev, "Invalid report rate: %u\n", val); in iqs269_parse_prop()
878 return -EINVAL; in iqs269_parse_prop()
881 sys_reg->rate_np = val; in iqs269_parse_prop()
884 if (!device_property_read_u32(&client->dev, "azoteq,rate-lp-ms", in iqs269_parse_prop()
887 dev_err(&client->dev, "Invalid report rate: %u\n", val); in iqs269_parse_prop()
888 return -EINVAL; in iqs269_parse_prop()
891 sys_reg->rate_lp = val; in iqs269_parse_prop()
894 if (!device_property_read_u32(&client->dev, "azoteq,rate-ulp-ms", in iqs269_parse_prop()
897 dev_err(&client->dev, "Invalid report rate: %u\n", val); in iqs269_parse_prop()
898 return -EINVAL; in iqs269_parse_prop()
901 sys_reg->rate_ulp = val / 16; in iqs269_parse_prop()
904 if (!device_property_read_u32(&client->dev, "azoteq,timeout-pwr-ms", in iqs269_parse_prop()
907 dev_err(&client->dev, "Invalid timeout: %u\n", val); in iqs269_parse_prop()
908 return -EINVAL; in iqs269_parse_prop()
911 sys_reg->timeout_pwr = val / 512; in iqs269_parse_prop()
914 if (!device_property_read_u32(&client->dev, "azoteq,timeout-lta-ms", in iqs269_parse_prop()
917 dev_err(&client->dev, "Invalid timeout: %u\n", val); in iqs269_parse_prop()
918 return -EINVAL; in iqs269_parse_prop()
921 sys_reg->timeout_lta = val / 512; in iqs269_parse_prop()
924 misc_a = be16_to_cpu(sys_reg->misc_a); in iqs269_parse_prop()
925 misc_b = be16_to_cpu(sys_reg->misc_b); in iqs269_parse_prop()
928 if (device_property_present(&client->dev, "azoteq,ati-band-disable")) in iqs269_parse_prop()
932 if (device_property_present(&client->dev, "azoteq,ati-lp-only")) in iqs269_parse_prop()
936 if (device_property_present(&client->dev, "azoteq,ati-band-tighten")) in iqs269_parse_prop()
940 if (device_property_present(&client->dev, "azoteq,filt-disable")) in iqs269_parse_prop()
943 if (!device_property_read_u32(&client->dev, "azoteq,gpio3-select", in iqs269_parse_prop()
946 dev_err(&client->dev, "Invalid GPIO3 selection: %u\n", in iqs269_parse_prop()
948 return -EINVAL; in iqs269_parse_prop()
956 if (device_property_present(&client->dev, "azoteq,dual-direction")) in iqs269_parse_prop()
959 if (!device_property_read_u32(&client->dev, "azoteq,tx-freq", &val)) { in iqs269_parse_prop()
961 dev_err(&client->dev, in iqs269_parse_prop()
963 return -EINVAL; in iqs269_parse_prop()
971 if (device_property_present(&client->dev, "azoteq,global-cap-increase")) in iqs269_parse_prop()
974 if (!device_property_read_u32(&client->dev, "azoteq,reseed-select", in iqs269_parse_prop()
977 dev_err(&client->dev, "Invalid reseed selection: %u\n", in iqs269_parse_prop()
979 return -EINVAL; in iqs269_parse_prop()
987 if (device_property_present(&client->dev, "azoteq,tracking-enable")) in iqs269_parse_prop()
990 if (!device_property_read_u32(&client->dev, "azoteq,filt-str-slider", in iqs269_parse_prop()
993 dev_err(&client->dev, "Invalid filter strength: %u\n", in iqs269_parse_prop()
995 return -EINVAL; in iqs269_parse_prop()
1002 sys_reg->misc_a = cpu_to_be16(misc_a); in iqs269_parse_prop()
1003 sys_reg->misc_b = cpu_to_be16(misc_b); in iqs269_parse_prop()
1005 sys_reg->active = 0; in iqs269_parse_prop()
1006 sys_reg->reseed = 0; in iqs269_parse_prop()
1008 sys_reg->blocking = 0; in iqs269_parse_prop()
1010 sys_reg->slider_select[0] = 0; in iqs269_parse_prop()
1015 * in a state of touch for a configurable length of time. in iqs269_parse_prop()
1017 * In that case, the register used for slider 1 channel selection is in iqs269_parse_prop()
1018 * repurposed for the touch-and-hold timer ceiling. in iqs269_parse_prop()
1020 if (iqs269->otp_option & IQS269_OTP_OPTION_HOLD) { in iqs269_parse_prop()
1021 if (!device_property_read_u32(&client->dev, in iqs269_parse_prop()
1022 "azoteq,touch-hold-ms", &val)) { in iqs269_parse_prop()
1025 dev_err(&client->dev, in iqs269_parse_prop()
1026 "Invalid touch-and-hold ceiling: %u\n", in iqs269_parse_prop()
1028 return -EINVAL; in iqs269_parse_prop()
1031 sys_reg->slider_select[1] = val / 256; in iqs269_parse_prop()
1032 } else if (iqs269->ver_info.fw_num < IQS269_VER_INFO_FW_NUM_3) { in iqs269_parse_prop()
1034 * The default touch-and-hold timer ceiling initially in iqs269_parse_prop()
1036 * the device experienced a soft reset between power- in iqs269_parse_prop()
1041 * device is re-initialized. in iqs269_parse_prop()
1043 sys_reg->slider_select[1] = IQS269_TOUCH_HOLD_DEFAULT; in iqs269_parse_prop()
1046 sys_reg->slider_select[1] = 0; in iqs269_parse_prop()
1049 sys_reg->event_mask = ~((u8)IQS269_EVENT_MASK_SYS); in iqs269_parse_prop()
1051 device_for_each_child_node_scoped(&client->dev, ch_node) { in iqs269_parse_prop()
1058 * Volunteer all active channels to participate in ATI when REDO-ATI is in iqs269_parse_prop()
1061 sys_reg->redo_ati = sys_reg->active; in iqs269_parse_prop()
1063 general = be16_to_cpu(sys_reg->general); in iqs269_parse_prop()
1065 if (device_property_present(&client->dev, "azoteq,clk-div")) in iqs269_parse_prop()
1069 * Configure the device to automatically switch between normal and low- in iqs269_parse_prop()
1070 * power modes as a function of sensing activity. Ultra-low-power mode, in iqs269_parse_prop()
1071 * if enabled, is reserved for suspend. in iqs269_parse_prop()
1077 if (!device_property_read_u32(&client->dev, "azoteq,suspend-mode", in iqs269_parse_prop()
1080 dev_err(&client->dev, "Invalid suspend mode: %u\n", in iqs269_parse_prop()
1082 return -EINVAL; in iqs269_parse_prop()
1088 if (!device_property_read_u32(&client->dev, "azoteq,ulp-update", in iqs269_parse_prop()
1091 dev_err(&client->dev, "Invalid update rate: %u\n", val); in iqs269_parse_prop()
1092 return -EINVAL; in iqs269_parse_prop()
1099 if (device_property_present(&client->dev, "linux,keycodes")) { in iqs269_parse_prop()
1101 int count = device_property_count_u32(&client->dev, in iqs269_parse_prop()
1104 dev_err(&client->dev, "Too many keycodes present\n"); in iqs269_parse_prop()
1105 return -EINVAL; in iqs269_parse_prop()
1107 dev_err(&client->dev, "Failed to count keycodes: %d\n", in iqs269_parse_prop()
1112 error = device_property_read_u32_array(&client->dev, in iqs269_parse_prop()
1114 *iqs269->sl_code, count); in iqs269_parse_prop()
1116 dev_err(&client->dev, "Failed to read keycodes: %d\n", in iqs269_parse_prop()
1121 if (device_property_present(&client->dev, in iqs269_parse_prop()
1122 "azoteq,gesture-swipe")) in iqs269_parse_prop()
1129 if (iqs269->ver_info.fw_num < IQS269_VER_INFO_FW_NUM_3) in iqs269_parse_prop()
1132 if (!device_property_read_u32(&client->dev, in iqs269_parse_prop()
1133 "azoteq,timeout-tap-ms", &val)) { in iqs269_parse_prop()
1135 dev_err(&client->dev, "Invalid timeout: %u\n", in iqs269_parse_prop()
1137 return -EINVAL; in iqs269_parse_prop()
1140 sys_reg->timeout_tap = val / (16 / scale); in iqs269_parse_prop()
1143 if (!device_property_read_u32(&client->dev, in iqs269_parse_prop()
1144 "azoteq,timeout-swipe-ms", in iqs269_parse_prop()
1147 dev_err(&client->dev, "Invalid timeout: %u\n", in iqs269_parse_prop()
1149 return -EINVAL; in iqs269_parse_prop()
1152 sys_reg->timeout_swipe = val / (16 / scale); in iqs269_parse_prop()
1155 if (!device_property_read_u32(&client->dev, in iqs269_parse_prop()
1156 "azoteq,thresh-swipe", &val)) { in iqs269_parse_prop()
1158 dev_err(&client->dev, "Invalid threshold: %u\n", in iqs269_parse_prop()
1160 return -EINVAL; in iqs269_parse_prop()
1163 sys_reg->thresh_swipe = val; in iqs269_parse_prop()
1166 sys_reg->event_mask &= ~IQS269_EVENT_MASK_GESTURE; in iqs269_parse_prop()
1170 if (device_property_present(&client->dev, "azoteq,reseed-offset")) in iqs269_parse_prop()
1176 * As per the datasheet, enable streaming during normal-power mode if in iqs269_parse_prop()
1177 * raw coordinates will be read from either slider. In that case, the in iqs269_parse_prop()
1178 * device returns to event mode during low-power mode. in iqs269_parse_prop()
1187 sys_reg->general = cpu_to_be16(general); in iqs269_parse_prop()
1202 mutex_lock(&iqs269->lock); in iqs269_dev_init()
1205 * Early revisions of silicon require the following workaround in order in iqs269_dev_init()
1206 * to restore any OTP-enabled functionality after a soft reset. in iqs269_dev_init()
1208 if (iqs269->otp_option == IQS269_OTP_OPTION_TWS && in iqs269_dev_init()
1209 iqs269->ver_info.fw_num < IQS269_VER_INFO_FW_NUM_3) { in iqs269_dev_init()
1210 error = regmap_multi_reg_write(iqs269->regmap, iqs269_tws_init, in iqs269_dev_init()
1216 error = regmap_update_bits(iqs269->regmap, IQS269_HALL_UI, in iqs269_dev_init()
1218 iqs269->hall_enable ? ~0 : 0); in iqs269_dev_init()
1222 error = regmap_raw_write(iqs269->regmap, IQS269_SYS_SETTINGS, in iqs269_dev_init()
1223 &iqs269->sys_reg, sizeof(iqs269->sys_reg)); in iqs269_dev_init()
1233 iqs269->ati_current = true; in iqs269_dev_init()
1236 mutex_unlock(&iqs269->lock); in iqs269_dev_init()
1243 struct i2c_client *client = iqs269->client; in iqs269_input_init()
1247 iqs269->keypad = devm_input_allocate_device(&client->dev); in iqs269_input_init()
1248 if (!iqs269->keypad) in iqs269_input_init()
1249 return -ENOMEM; in iqs269_input_init()
1251 iqs269->keypad->keycodemax = ARRAY_SIZE(iqs269->keycode); in iqs269_input_init()
1252 iqs269->keypad->keycode = iqs269->keycode; in iqs269_input_init()
1253 iqs269->keypad->keycodesize = sizeof(*iqs269->keycode); in iqs269_input_init()
1255 iqs269->keypad->name = "iqs269a_keypad"; in iqs269_input_init()
1256 iqs269->keypad->id.bustype = BUS_I2C; in iqs269_input_init()
1259 sw_code = iqs269->switches[i].code; in iqs269_input_init()
1262 keycode = iqs269->keycode[i * IQS269_NUM_CH + j]; in iqs269_input_init()
1265 * Hall-effect sensing repurposes a pair of dedicated in iqs269_input_init()
1270 if (iqs269->hall_enable && in iqs269_input_init()
1271 iqs269->switches[i].enabled) in iqs269_input_init()
1272 input_set_capability(iqs269->keypad, in iqs269_input_init()
1277 if (iqs269->hall_enable) in iqs269_input_init()
1283 input_set_capability(iqs269->keypad, in iqs269_input_init()
1293 iqs269->slider[i] = devm_input_allocate_device(&client->dev); in iqs269_input_init()
1294 if (!iqs269->slider[i]) in iqs269_input_init()
1295 return -ENOMEM; in iqs269_input_init()
1297 iqs269->slider[i]->keycodemax = ARRAY_SIZE(iqs269->sl_code[i]); in iqs269_input_init()
1298 iqs269->slider[i]->keycode = iqs269->sl_code[i]; in iqs269_input_init()
1299 iqs269->slider[i]->keycodesize = sizeof(**iqs269->sl_code); in iqs269_input_init()
1301 iqs269->slider[i]->name = i ? "iqs269a_slider_1" in iqs269_input_init()
1303 iqs269->slider[i]->id.bustype = BUS_I2C; in iqs269_input_init()
1306 if (iqs269->sl_code[i][j] != KEY_RESERVED) in iqs269_input_init()
1307 input_set_capability(iqs269->slider[i], EV_KEY, in iqs269_input_init()
1308 iqs269->sl_code[i][j]); in iqs269_input_init()
1311 * Present the slider as a narrow trackpad if one or more chan- in iqs269_input_init()
1316 input_set_capability(iqs269->slider[i], in iqs269_input_init()
1318 input_set_abs_params(iqs269->slider[i], in iqs269_input_init()
1322 error = input_register_device(iqs269->slider[i]); in iqs269_input_init()
1324 dev_err(&client->dev, in iqs269_input_init()
1335 struct i2c_client *client = iqs269->client; in iqs269_report()
1342 error = regmap_raw_read(iqs269->regmap, IQS269_SYS_FLAGS, &flags, in iqs269_report()
1345 dev_err(&client->dev, "Failed to read device status: %d\n", in iqs269_report()
1352 * in the event of an I2C communication error. In this case, the device in iqs269_report()
1356 dev_err(&client->dev, "Unexpected device reset\n"); in iqs269_report()
1360 dev_err(&client->dev, in iqs269_report()
1361 "Failed to re-initialize device: %d\n", error); in iqs269_report()
1371 error = regmap_raw_read(iqs269->regmap, IQS269_SLIDER_X, in iqs269_report()
1374 dev_err(&client->dev, in iqs269_report()
1389 input_report_key(iqs269->slider[i], in iqs269_report()
1390 iqs269->sl_code[i][j], in iqs269_report()
1398 input_sync(iqs269->slider[i]); in iqs269_report()
1402 * release cycle so as to emulate a full keystroke. in iqs269_report()
1406 input_report_key(iqs269->slider[i], in iqs269_report()
1407 iqs269->sl_code[i][j], in iqs269_report()
1413 * The slider is considered to be in a state of touch in iqs269_report()
1414 * if any selected channels are in a state of touch. in iqs269_report()
1417 state &= iqs269->sys_reg.slider_select[i]; in iqs269_report()
1419 input_report_key(iqs269->slider[i], BTN_TOUCH, state); in iqs269_report()
1422 input_report_abs(iqs269->slider[i], in iqs269_report()
1427 input_sync(iqs269->slider[i]); in iqs269_report()
1437 sw_code = iqs269->switches[i].code; in iqs269_report()
1440 keycode = iqs269->keycode[i * IQS269_NUM_CH + j]; in iqs269_report()
1444 if (iqs269->hall_enable && in iqs269_report()
1445 iqs269->switches[i].enabled) in iqs269_report()
1446 input_report_switch(iqs269->keypad, in iqs269_report()
1452 if (iqs269->hall_enable) in iqs269_report()
1457 input_report_key(iqs269->keypad, keycode, in iqs269_report()
1463 input_sync(iqs269->keypad); in iqs269_report()
1469 complete_all(&iqs269->ati_done); in iqs269_report()
1495 struct i2c_client *client = iqs269->client; in counts_show()
1499 if (!iqs269->ati_current || iqs269->hall_enable) in counts_show()
1500 return -EPERM; in counts_show()
1502 if (!completion_done(&iqs269->ati_done)) in counts_show()
1503 return -EBUSY; in counts_show()
1510 disable_irq(client->irq); in counts_show()
1512 error = regmap_raw_read(iqs269->regmap, in counts_show()
1513 IQS269_CHx_COUNTS + iqs269->ch_num * 2, in counts_show()
1517 enable_irq(client->irq); in counts_show()
1529 struct iqs269_ch_reg *ch_reg = iqs269->sys_reg.ch_reg; in hall_bin_show()
1530 struct i2c_client *client = iqs269->client; in hall_bin_show()
1534 disable_irq(client->irq); in hall_bin_show()
1536 error = regmap_read(iqs269->regmap, IQS269_CAL_DATA_A, &val); in hall_bin_show()
1539 enable_irq(client->irq); in hall_bin_show()
1557 return -EINVAL; in hall_bin_show()
1568 return sysfs_emit(buf, "%u\n", iqs269->hall_enable); in hall_enable_show()
1583 mutex_lock(&iqs269->lock); in hall_enable_store()
1585 iqs269->hall_enable = val; in hall_enable_store()
1586 iqs269->ati_current = false; in hall_enable_store()
1588 mutex_unlock(&iqs269->lock); in hall_enable_store()
1598 return sysfs_emit(buf, "%u\n", iqs269->ch_num); in ch_number_show()
1614 return -EINVAL; in ch_number_store()
1616 iqs269->ch_num = val; in ch_number_store()
1625 struct iqs269_ch_reg *ch_reg = iqs269->sys_reg.ch_reg; in rx_enable_show()
1627 return sysfs_emit(buf, "%u\n", ch_reg[iqs269->ch_num].rx_enable); in rx_enable_show()
1635 struct iqs269_ch_reg *ch_reg = iqs269->sys_reg.ch_reg; in rx_enable_store()
1644 return -EINVAL; in rx_enable_store()
1646 mutex_lock(&iqs269->lock); in rx_enable_store()
1648 ch_reg[iqs269->ch_num].rx_enable = val; in rx_enable_store()
1649 iqs269->ati_current = false; in rx_enable_store()
1651 mutex_unlock(&iqs269->lock); in rx_enable_store()
1663 error = iqs269_ati_mode_get(iqs269, iqs269->ch_num, &val); in ati_mode_show()
1682 error = iqs269_ati_mode_set(iqs269, iqs269->ch_num, val); in ati_mode_store()
1696 error = iqs269_ati_base_get(iqs269, iqs269->ch_num, &val); in ati_base_show()
1715 error = iqs269_ati_base_set(iqs269, iqs269->ch_num, val); in ati_base_store()
1729 error = iqs269_ati_target_get(iqs269, iqs269->ch_num, &val); in ati_target_show()
1748 error = iqs269_ati_target_set(iqs269, iqs269->ch_num, val); in ati_target_store()
1761 iqs269->ati_current && in ati_trigger_show()
1762 completion_done(&iqs269->ati_done)); in ati_trigger_show()
1770 struct i2c_client *client = iqs269->client; in ati_trigger_store()
1781 disable_irq(client->irq); in ati_trigger_store()
1782 reinit_completion(&iqs269->ati_done); in ati_trigger_store()
1787 enable_irq(client->irq); in ati_trigger_store()
1792 if (!wait_for_completion_timeout(&iqs269->ati_done, in ati_trigger_store()
1794 return -ETIMEDOUT; in ati_trigger_store()
1834 iqs269 = devm_kzalloc(&client->dev, sizeof(*iqs269), GFP_KERNEL); in iqs269_probe()
1836 return -ENOMEM; in iqs269_probe()
1839 iqs269->client = client; in iqs269_probe()
1841 iqs269->regmap = devm_regmap_init_i2c(client, &iqs269_regmap_config); in iqs269_probe()
1842 if (IS_ERR(iqs269->regmap)) { in iqs269_probe()
1843 error = PTR_ERR(iqs269->regmap); in iqs269_probe()
1844 dev_err(&client->dev, "Failed to initialize register map: %d\n", in iqs269_probe()
1849 mutex_init(&iqs269->lock); in iqs269_probe()
1850 init_completion(&iqs269->ati_done); in iqs269_probe()
1852 iqs269->otp_option = (uintptr_t)device_get_match_data(&client->dev); in iqs269_probe()
1854 error = regmap_raw_read(iqs269->regmap, IQS269_VER_INFO, in iqs269_probe()
1855 &iqs269->ver_info, sizeof(iqs269->ver_info)); in iqs269_probe()
1859 if (iqs269->ver_info.prod_num != IQS269_VER_INFO_PROD_NUM) { in iqs269_probe()
1860 dev_err(&client->dev, "Unrecognized product number: 0x%02X\n", in iqs269_probe()
1861 iqs269->ver_info.prod_num); in iqs269_probe()
1862 return -EINVAL; in iqs269_probe()
1871 dev_err(&client->dev, "Failed to initialize device: %d\n", in iqs269_probe()
1880 error = devm_request_threaded_irq(&client->dev, client->irq, in iqs269_probe()
1882 client->name, iqs269); in iqs269_probe()
1884 dev_err(&client->dev, "Failed to request IRQ: %d\n", error); in iqs269_probe()
1888 if (!wait_for_completion_timeout(&iqs269->ati_done, in iqs269_probe()
1890 dev_err(&client->dev, "Failed to complete ATI\n"); in iqs269_probe()
1891 return -ETIMEDOUT; in iqs269_probe()
1898 error = input_register_device(iqs269->keypad); in iqs269_probe()
1900 dev_err(&client->dev, "Failed to register keypad: %d\n", error); in iqs269_probe()
1909 u16 general = be16_to_cpu(iqs269->sys_reg.general); in iqs269_general_get()
1920 struct i2c_client *client = iqs269->client; in iqs269_suspend()
1927 disable_irq(client->irq); in iqs269_suspend()
1929 error = regmap_write(iqs269->regmap, IQS269_SYS_SETTINGS, general); in iqs269_suspend()
1932 enable_irq(client->irq); in iqs269_suspend()
1940 struct i2c_client *client = iqs269->client; in iqs269_resume()
1947 disable_irq(client->irq); in iqs269_resume()
1949 error = regmap_write(iqs269->regmap, IQS269_SYS_SETTINGS, in iqs269_resume()
1952 error = regmap_write(iqs269->regmap, IQS269_SYS_SETTINGS, in iqs269_resume()
1956 enable_irq(client->irq); in iqs269_resume()
1969 .compatible = "azoteq,iqs269a-00",
1973 .compatible = "azoteq,iqs269a-d0",