Lines Matching refs:ts

295 static int raydium_i2c_query_ts_bootloader_info(struct raydium_data *ts)
297 struct i2c_client *client = ts->client;
326 ts->info.hw_ver = cpu_to_le32(hw_ver);
327 ts->info.main_ver = 0xff;
328 ts->info.sub_ver = 0xff;
333 static int raydium_i2c_query_ts_info(struct raydium_data *ts)
335 struct i2c_client *client = ts->client;
352 if (ts->report_data && ts->pkg_size != data_info.pkg_size) {
355 ts->pkg_size, data_info.pkg_size);
357 ts->pkg_size = data_info.pkg_size;
358 ts->report_size = ts->pkg_size - RM_PACKET_CRC_SIZE;
361 ts->contact_size = data_info.tp_info_size;
362 ts->data_bank_addr = le32_to_cpu(data_info.data_bank_addr);
366 ts->data_bank_addr, ts->report_size, ts->contact_size);
375 &ts->info, sizeof(ts->info));
386 static int raydium_i2c_check_fw_status(struct raydium_data *ts)
388 struct i2c_client *client = ts->client;
397 ts->boot_mode = RAYDIUM_TS_BLDR;
399 ts->boot_mode = RAYDIUM_TS_MAIN;
406 static int raydium_i2c_initialize(struct raydium_data *ts)
408 struct i2c_client *client = ts->client;
415 error = raydium_i2c_check_fw_status(ts);
422 if (ts->boot_mode == RAYDIUM_TS_BLDR ||
423 ts->boot_mode == RAYDIUM_TS_MAIN) {
429 ts->boot_mode = RAYDIUM_TS_BLDR;
431 if (ts->boot_mode == RAYDIUM_TS_BLDR)
432 raydium_i2c_query_ts_bootloader_info(ts);
434 raydium_i2c_query_ts_info(ts);
694 static int raydium_i2c_do_update_firmware(struct raydium_data *ts,
697 struct i2c_client *client = ts->client;
711 error = raydium_i2c_check_fw_status(ts);
717 if (ts->boot_mode == RAYDIUM_TS_MAIN) {
721 error = raydium_i2c_check_fw_status(ts);
729 if (ts->boot_mode == RAYDIUM_TS_BLDR)
734 if (ts->boot_mode == RAYDIUM_TS_MAIN) {
785 error = raydium_i2c_check_fw_status(ts);
793 if (ts->boot_mode != RAYDIUM_TS_MAIN) {
815 static int raydium_i2c_fw_update(struct raydium_data *ts)
817 struct i2c_client *client = ts->client;
823 le32_to_cpu(ts->info.hw_ver));
837 error = raydium_i2c_do_update_firmware(ts, fw);
840 ts->boot_mode = RAYDIUM_TS_BLDR;
844 error = raydium_i2c_initialize(ts);
849 ts->boot_mode = RAYDIUM_TS_BLDR;
853 ts->boot_mode = RAYDIUM_TS_MAIN;
867 static void raydium_mt_event(struct raydium_data *ts)
871 for (i = 0; i < ts->report_size / ts->contact_size; i++) {
872 u8 *contact = &ts->report_data[ts->contact_size * i];
876 input_mt_slot(ts->input, i);
877 input_mt_report_slot_state(ts->input, MT_TOOL_FINGER, state);
882 input_report_abs(ts->input, ABS_MT_POSITION_X,
884 input_report_abs(ts->input, ABS_MT_POSITION_Y,
886 input_report_abs(ts->input, ABS_MT_PRESSURE,
892 input_report_abs(ts->input, ABS_MT_TOUCH_MAJOR, max(wx, wy));
893 input_report_abs(ts->input, ABS_MT_TOUCH_MINOR, min(wx, wy));
896 input_mt_sync_frame(ts->input);
897 input_sync(ts->input);
902 struct raydium_data *ts = _dev;
907 if (ts->boot_mode != RAYDIUM_TS_MAIN)
910 error = raydium_i2c_read(ts->client, ts->data_bank_addr,
911 ts->report_data, ts->pkg_size);
915 fw_crc = get_unaligned_le16(&ts->report_data[ts->report_size]);
916 calc_crc = raydium_calc_chksum(ts->report_data, ts->report_size);
918 dev_warn(&ts->client->dev,
924 raydium_mt_event(ts);
934 struct raydium_data *ts = i2c_get_clientdata(client);
936 return sprintf(buf, "%d.%d\n", ts->info.main_ver, ts->info.sub_ver);
943 struct raydium_data *ts = i2c_get_clientdata(client);
945 return sprintf(buf, "%#04x\n", le32_to_cpu(ts->info.hw_ver));
953 struct raydium_data *ts = i2c_get_clientdata(client);
956 ts->boot_mode == RAYDIUM_TS_MAIN ?
965 struct raydium_data *ts = i2c_get_clientdata(client);
968 error = mutex_lock_interruptible(&ts->sysfs_mutex);
972 error = raydium_i2c_fw_update(ts);
974 mutex_unlock(&ts->sysfs_mutex);
984 struct raydium_data *ts = i2c_get_clientdata(client);
988 error = mutex_lock_interruptible(&ts->sysfs_mutex);
997 mutex_unlock(&ts->sysfs_mutex);
1017 static int raydium_i2c_power_on(struct raydium_data *ts)
1021 if (!ts->reset_gpio)
1024 gpiod_set_value_cansleep(ts->reset_gpio, 1);
1026 error = regulator_enable(ts->avdd);
1028 dev_err(&ts->client->dev,
1033 error = regulator_enable(ts->vccio);
1035 regulator_disable(ts->avdd);
1036 dev_err(&ts->client->dev,
1044 gpiod_set_value_cansleep(ts->reset_gpio, 0);
1056 struct raydium_data *ts = _data;
1058 if (ts->reset_gpio) {
1059 gpiod_set_value_cansleep(ts->reset_gpio, 1);
1060 regulator_disable(ts->vccio);
1061 regulator_disable(ts->avdd);
1068 struct raydium_data *ts;
1077 ts = devm_kzalloc(&client->dev, sizeof(*ts), GFP_KERNEL);
1078 if (!ts)
1081 mutex_init(&ts->sysfs_mutex);
1083 ts->client = client;
1084 i2c_set_clientdata(client, ts);
1086 ts->avdd = devm_regulator_get(&client->dev, "avdd");
1087 if (IS_ERR(ts->avdd))
1088 return dev_err_probe(&client->dev, PTR_ERR(ts->avdd),
1091 ts->vccio = devm_regulator_get(&client->dev, "vccio");
1092 if (IS_ERR(ts->vccio))
1093 return dev_err_probe(&client->dev, PTR_ERR(ts->vccio),
1096 ts->reset_gpio = devm_gpiod_get_optional(&client->dev, "reset",
1098 if (IS_ERR(ts->reset_gpio))
1099 return dev_err_probe(&client->dev, PTR_ERR(ts->reset_gpio),
1102 error = raydium_i2c_power_on(ts);
1107 raydium_i2c_power_off, ts);
1121 error = raydium_i2c_initialize(ts);
1127 ts->report_data = devm_kmalloc(&client->dev,
1128 ts->pkg_size, GFP_KERNEL);
1129 if (!ts->report_data)
1132 ts->input = devm_input_allocate_device(&client->dev);
1133 if (!ts->input) {
1138 ts->input->name = "Raydium Touchscreen";
1139 ts->input->id.bustype = BUS_I2C;
1141 input_set_abs_params(ts->input, ABS_MT_POSITION_X,
1142 0, le16_to_cpu(ts->info.x_max), 0, 0);
1143 input_set_abs_params(ts->input, ABS_MT_POSITION_Y,
1144 0, le16_to_cpu(ts->info.y_max), 0, 0);
1145 input_abs_set_res(ts->input, ABS_MT_POSITION_X, ts->info.x_res);
1146 input_abs_set_res(ts->input, ABS_MT_POSITION_Y, ts->info.y_res);
1148 input_set_abs_params(ts->input, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0);
1149 input_set_abs_params(ts->input, ABS_MT_PRESSURE, 0, 255, 0, 0);
1151 error = input_mt_init_slots(ts->input, RM_MAX_TOUCH_NUM,
1159 error = input_register_device(ts->input);
1168 IRQF_ONESHOT, client->name, ts);
1192 struct raydium_data *ts = i2c_get_clientdata(client);
1195 if (ts->boot_mode != RAYDIUM_TS_MAIN)
1203 raydium_i2c_power_off(ts);
1212 struct raydium_data *ts = i2c_get_clientdata(client);
1217 raydium_i2c_power_on(ts);
1218 raydium_i2c_initialize(ts);