Lines Matching refs:ts

66 static int himax_read_config(struct himax_ts_data *ts, u32 address, u32 *dst)
70 error = regmap_write(ts->regmap, HIMAX_REG_CFG_SET_ADDR, address);
74 error = regmap_write(ts->regmap, HIMAX_REG_CFG_INIT_READ, 0x0);
78 error = regmap_read(ts->regmap, HIMAX_REG_CFG_READ_VALUE, dst);
85 static void himax_reset(struct himax_ts_data *ts)
87 gpiod_set_value_cansleep(ts->gpiod_rst, 1);
91 gpiod_set_value_cansleep(ts->gpiod_rst, 0);
100 static int himax_read_product_id(struct himax_ts_data *ts, u32 *product_id)
104 error = himax_read_config(ts, HIMAX_CFG_PRODUCT_ID, product_id);
112 static int himax_check_product_id(struct himax_ts_data *ts)
117 error = himax_read_product_id(ts, &product_id);
121 dev_dbg(&ts->client->dev, "Product id: %x\n", product_id);
128 dev_err(&ts->client->dev,
134 static int himax_input_register(struct himax_ts_data *ts)
138 ts->input_dev = devm_input_allocate_device(&ts->client->dev);
139 if (!ts->input_dev) {
140 dev_err(&ts->client->dev, "Failed to allocate input device\n");
144 ts->input_dev->name = "Himax Touchscreen";
146 input_set_capability(ts->input_dev, EV_ABS, ABS_MT_POSITION_X);
147 input_set_capability(ts->input_dev, EV_ABS, ABS_MT_POSITION_Y);
148 input_set_abs_params(ts->input_dev, ABS_MT_WIDTH_MAJOR, 0, 200, 0, 0);
149 input_set_abs_params(ts->input_dev, ABS_MT_TOUCH_MAJOR, 0, 200, 0, 0);
151 touchscreen_parse_properties(ts->input_dev, true, &ts->props);
153 error = input_mt_init_slots(ts->input_dev, HIMAX_MAX_POINTS,
156 dev_err(&ts->client->dev,
161 error = input_register_device(ts->input_dev);
163 dev_err(&ts->client->dev,
179 static bool himax_process_event_point(struct himax_ts_data *ts,
191 input_mt_slot(ts->input_dev, point_index);
192 input_mt_report_slot_state(ts->input_dev, MT_TOOL_FINGER, true);
193 touchscreen_report_pos(ts->input_dev, &ts->props, x, y, true);
194 input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, w);
195 input_report_abs(ts->input_dev, ABS_MT_WIDTH_MAJOR, w);
199 static void himax_process_event(struct himax_ts_data *ts,
206 if (himax_process_event_point(ts, event, i))
210 input_mt_sync_frame(ts->input_dev);
211 input_sync(ts->input_dev);
214 static bool himax_verify_checksum(struct himax_ts_data *ts,
225 dev_err(&ts->client->dev, "Wrong event checksum: %04x\n",
233 static int himax_handle_input(struct himax_ts_data *ts)
238 error = regmap_raw_read(ts->regmap, HIMAX_REG_READ_EVENT, &event,
241 dev_err(&ts->client->dev, "Failed to read input event: %d\n",
250 if (himax_verify_checksum(ts, &event))
251 himax_process_event(ts, &event);
259 struct himax_ts_data *ts = dev_id;
261 error = himax_handle_input(ts);
272 struct himax_ts_data *ts;
279 ts = devm_kzalloc(dev, sizeof(*ts), GFP_KERNEL);
280 if (!ts)
283 i2c_set_clientdata(client, ts);
284 ts->client = client;
286 ts->regmap = devm_regmap_init_i2c(client, &himax_regmap_config);
287 error = PTR_ERR_OR_ZERO(ts->regmap);
293 ts->gpiod_rst = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
294 error = PTR_ERR_OR_ZERO(ts->gpiod_rst);
300 himax_reset(ts);
302 error = himax_check_product_id(ts);
306 error = himax_input_register(ts);
312 client->name, ts);
321 struct himax_ts_data *ts = dev_get_drvdata(dev);
323 disable_irq(ts->client->irq);
329 struct himax_ts_data *ts = dev_get_drvdata(dev);
331 enable_irq(ts->client->irq);