Lines Matching full:ts
293 static int raydium_i2c_query_ts_info(struct raydium_data *ts) in raydium_i2c_query_ts_info() argument
295 struct i2c_client *client = ts->client; in raydium_i2c_query_ts_info()
312 if (ts->report_data && ts->pkg_size != data_info.pkg_size) { in raydium_i2c_query_ts_info()
315 ts->pkg_size, data_info.pkg_size); in raydium_i2c_query_ts_info()
317 ts->pkg_size = data_info.pkg_size; in raydium_i2c_query_ts_info()
318 ts->report_size = ts->pkg_size - RM_PACKET_CRC_SIZE; in raydium_i2c_query_ts_info()
321 ts->contact_size = data_info.tp_info_size; in raydium_i2c_query_ts_info()
322 ts->data_bank_addr = le32_to_cpu(data_info.data_bank_addr); in raydium_i2c_query_ts_info()
326 ts->data_bank_addr, ts->report_size, ts->contact_size); in raydium_i2c_query_ts_info()
335 &ts->info, sizeof(ts->info)); in raydium_i2c_query_ts_info()
346 static int raydium_i2c_check_fw_status(struct raydium_data *ts) in raydium_i2c_check_fw_status() argument
348 struct i2c_client *client = ts->client; in raydium_i2c_check_fw_status()
357 ts->boot_mode = RAYDIUM_TS_BLDR; in raydium_i2c_check_fw_status()
359 ts->boot_mode = RAYDIUM_TS_MAIN; in raydium_i2c_check_fw_status()
366 static int raydium_i2c_initialize(struct raydium_data *ts) in raydium_i2c_initialize() argument
368 struct i2c_client *client = ts->client; in raydium_i2c_initialize()
375 error = raydium_i2c_check_fw_status(ts); in raydium_i2c_initialize()
382 if (ts->boot_mode == RAYDIUM_TS_BLDR || in raydium_i2c_initialize()
383 ts->boot_mode == RAYDIUM_TS_MAIN) { in raydium_i2c_initialize()
389 ts->boot_mode = RAYDIUM_TS_BLDR; in raydium_i2c_initialize()
391 if (ts->boot_mode == RAYDIUM_TS_BLDR) { in raydium_i2c_initialize()
392 ts->info.hw_ver = cpu_to_le32(0xffffffffUL); in raydium_i2c_initialize()
393 ts->info.main_ver = 0xff; in raydium_i2c_initialize()
394 ts->info.sub_ver = 0xff; in raydium_i2c_initialize()
396 raydium_i2c_query_ts_info(ts); in raydium_i2c_initialize()
657 static int raydium_i2c_do_update_firmware(struct raydium_data *ts, in raydium_i2c_do_update_firmware() argument
660 struct i2c_client *client = ts->client; in raydium_i2c_do_update_firmware()
674 error = raydium_i2c_check_fw_status(ts); in raydium_i2c_do_update_firmware()
680 if (ts->boot_mode == RAYDIUM_TS_MAIN) { in raydium_i2c_do_update_firmware()
684 error = raydium_i2c_check_fw_status(ts); in raydium_i2c_do_update_firmware()
692 if (ts->boot_mode == RAYDIUM_TS_BLDR) in raydium_i2c_do_update_firmware()
697 if (ts->boot_mode == RAYDIUM_TS_MAIN) { in raydium_i2c_do_update_firmware()
748 error = raydium_i2c_check_fw_status(ts); in raydium_i2c_do_update_firmware()
756 if (ts->boot_mode != RAYDIUM_TS_MAIN) { in raydium_i2c_do_update_firmware()
778 static int raydium_i2c_fw_update(struct raydium_data *ts) in raydium_i2c_fw_update() argument
780 struct i2c_client *client = ts->client; in raydium_i2c_fw_update()
786 le32_to_cpu(ts->info.hw_ver)); in raydium_i2c_fw_update()
800 error = raydium_i2c_do_update_firmware(ts, fw); in raydium_i2c_fw_update()
803 ts->boot_mode = RAYDIUM_TS_BLDR; in raydium_i2c_fw_update()
807 error = raydium_i2c_initialize(ts); in raydium_i2c_fw_update()
812 ts->boot_mode = RAYDIUM_TS_BLDR; in raydium_i2c_fw_update()
816 ts->boot_mode = RAYDIUM_TS_MAIN; in raydium_i2c_fw_update()
830 static void raydium_mt_event(struct raydium_data *ts) in raydium_mt_event() argument
834 for (i = 0; i < ts->report_size / ts->contact_size; i++) { in raydium_mt_event()
835 u8 *contact = &ts->report_data[ts->contact_size * i]; in raydium_mt_event()
839 input_mt_slot(ts->input, i); in raydium_mt_event()
840 input_mt_report_slot_state(ts->input, MT_TOOL_FINGER, state); in raydium_mt_event()
845 input_report_abs(ts->input, ABS_MT_POSITION_X, in raydium_mt_event()
847 input_report_abs(ts->input, ABS_MT_POSITION_Y, in raydium_mt_event()
849 input_report_abs(ts->input, ABS_MT_PRESSURE, in raydium_mt_event()
855 input_report_abs(ts->input, ABS_MT_TOUCH_MAJOR, max(wx, wy)); in raydium_mt_event()
856 input_report_abs(ts->input, ABS_MT_TOUCH_MINOR, min(wx, wy)); in raydium_mt_event()
859 input_mt_sync_frame(ts->input); in raydium_mt_event()
860 input_sync(ts->input); in raydium_mt_event()
865 struct raydium_data *ts = _dev; in raydium_i2c_irq() local
870 if (ts->boot_mode != RAYDIUM_TS_MAIN) in raydium_i2c_irq()
873 error = raydium_i2c_read(ts->client, ts->data_bank_addr, in raydium_i2c_irq()
874 ts->report_data, ts->pkg_size); in raydium_i2c_irq()
878 fw_crc = get_unaligned_le16(&ts->report_data[ts->report_size]); in raydium_i2c_irq()
879 calc_crc = raydium_calc_chksum(ts->report_data, ts->report_size); in raydium_i2c_irq()
881 dev_warn(&ts->client->dev, in raydium_i2c_irq()
887 raydium_mt_event(ts); in raydium_i2c_irq()
897 struct raydium_data *ts = i2c_get_clientdata(client); in raydium_i2c_fw_ver_show() local
899 return sprintf(buf, "%d.%d\n", ts->info.main_ver, ts->info.sub_ver); in raydium_i2c_fw_ver_show()
906 struct raydium_data *ts = i2c_get_clientdata(client); in raydium_i2c_hw_ver_show() local
908 return sprintf(buf, "%#04x\n", le32_to_cpu(ts->info.hw_ver)); in raydium_i2c_hw_ver_show()
916 struct raydium_data *ts = i2c_get_clientdata(client); in raydium_i2c_boot_mode_show() local
919 ts->boot_mode == RAYDIUM_TS_MAIN ? in raydium_i2c_boot_mode_show()
928 struct raydium_data *ts = i2c_get_clientdata(client); in raydium_i2c_update_fw_store() local
931 error = mutex_lock_interruptible(&ts->sysfs_mutex); in raydium_i2c_update_fw_store()
935 error = raydium_i2c_fw_update(ts); in raydium_i2c_update_fw_store()
937 mutex_unlock(&ts->sysfs_mutex); in raydium_i2c_update_fw_store()
947 struct raydium_data *ts = i2c_get_clientdata(client); in raydium_i2c_calibrate_store() local
951 error = mutex_lock_interruptible(&ts->sysfs_mutex); in raydium_i2c_calibrate_store()
960 mutex_unlock(&ts->sysfs_mutex); in raydium_i2c_calibrate_store()
983 static int raydium_i2c_power_on(struct raydium_data *ts) in raydium_i2c_power_on() argument
987 if (!ts->reset_gpio) in raydium_i2c_power_on()
990 gpiod_set_value_cansleep(ts->reset_gpio, 1); in raydium_i2c_power_on()
992 error = regulator_enable(ts->avdd); in raydium_i2c_power_on()
994 dev_err(&ts->client->dev, in raydium_i2c_power_on()
999 error = regulator_enable(ts->vccio); in raydium_i2c_power_on()
1001 regulator_disable(ts->avdd); in raydium_i2c_power_on()
1002 dev_err(&ts->client->dev, in raydium_i2c_power_on()
1010 gpiod_set_value_cansleep(ts->reset_gpio, 0); in raydium_i2c_power_on()
1022 struct raydium_data *ts = _data; in raydium_i2c_power_off() local
1024 if (ts->reset_gpio) { in raydium_i2c_power_off()
1025 gpiod_set_value_cansleep(ts->reset_gpio, 1); in raydium_i2c_power_off()
1026 regulator_disable(ts->vccio); in raydium_i2c_power_off()
1027 regulator_disable(ts->avdd); in raydium_i2c_power_off()
1035 struct raydium_data *ts; in raydium_i2c_probe() local
1044 ts = devm_kzalloc(&client->dev, sizeof(*ts), GFP_KERNEL); in raydium_i2c_probe()
1045 if (!ts) in raydium_i2c_probe()
1048 mutex_init(&ts->sysfs_mutex); in raydium_i2c_probe()
1050 ts->client = client; in raydium_i2c_probe()
1051 i2c_set_clientdata(client, ts); in raydium_i2c_probe()
1053 ts->avdd = devm_regulator_get(&client->dev, "avdd"); in raydium_i2c_probe()
1054 if (IS_ERR(ts->avdd)) { in raydium_i2c_probe()
1055 error = PTR_ERR(ts->avdd); in raydium_i2c_probe()
1062 ts->vccio = devm_regulator_get(&client->dev, "vccio"); in raydium_i2c_probe()
1063 if (IS_ERR(ts->vccio)) { in raydium_i2c_probe()
1064 error = PTR_ERR(ts->vccio); in raydium_i2c_probe()
1071 ts->reset_gpio = devm_gpiod_get_optional(&client->dev, "reset", in raydium_i2c_probe()
1073 if (IS_ERR(ts->reset_gpio)) { in raydium_i2c_probe()
1074 error = PTR_ERR(ts->reset_gpio); in raydium_i2c_probe()
1081 error = raydium_i2c_power_on(ts); in raydium_i2c_probe()
1085 error = devm_add_action(&client->dev, raydium_i2c_power_off, ts); in raydium_i2c_probe()
1089 raydium_i2c_power_off(ts); in raydium_i2c_probe()
1100 error = raydium_i2c_initialize(ts); in raydium_i2c_probe()
1106 ts->report_data = devm_kmalloc(&client->dev, in raydium_i2c_probe()
1107 ts->pkg_size, GFP_KERNEL); in raydium_i2c_probe()
1108 if (!ts->report_data) in raydium_i2c_probe()
1111 ts->input = devm_input_allocate_device(&client->dev); in raydium_i2c_probe()
1112 if (!ts->input) { in raydium_i2c_probe()
1117 ts->input->name = "Raydium Touchscreen"; in raydium_i2c_probe()
1118 ts->input->id.bustype = BUS_I2C; in raydium_i2c_probe()
1120 input_set_abs_params(ts->input, ABS_MT_POSITION_X, in raydium_i2c_probe()
1121 0, le16_to_cpu(ts->info.x_max), 0, 0); in raydium_i2c_probe()
1122 input_set_abs_params(ts->input, ABS_MT_POSITION_Y, in raydium_i2c_probe()
1123 0, le16_to_cpu(ts->info.y_max), 0, 0); in raydium_i2c_probe()
1124 input_abs_set_res(ts->input, ABS_MT_POSITION_X, ts->info.x_res); in raydium_i2c_probe()
1125 input_abs_set_res(ts->input, ABS_MT_POSITION_Y, ts->info.y_res); in raydium_i2c_probe()
1127 input_set_abs_params(ts->input, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0); in raydium_i2c_probe()
1128 input_set_abs_params(ts->input, ABS_MT_PRESSURE, 0, 255, 0, 0); in raydium_i2c_probe()
1130 error = input_mt_init_slots(ts->input, RM_MAX_TOUCH_NUM, in raydium_i2c_probe()
1138 error = input_register_device(ts->input); in raydium_i2c_probe()
1147 IRQF_ONESHOT, client->name, ts); in raydium_i2c_probe()
1179 struct raydium_data *ts = i2c_get_clientdata(client); in raydium_i2c_suspend() local
1182 if (ts->boot_mode != RAYDIUM_TS_MAIN) in raydium_i2c_suspend()
1190 ts->wake_irq_enabled = (enable_irq_wake(client->irq) == 0); in raydium_i2c_suspend()
1192 raydium_i2c_power_off(ts); in raydium_i2c_suspend()
1201 struct raydium_data *ts = i2c_get_clientdata(client); in raydium_i2c_resume() local
1204 if (ts->wake_irq_enabled) in raydium_i2c_resume()
1208 raydium_i2c_power_on(ts); in raydium_i2c_resume()
1209 raydium_i2c_initialize(ts); in raydium_i2c_resume()