Lines Matching +full:i2c +full:- +full:retry +full:- +full:count
1 // SPDX-License-Identifier: GPL-2.0-only
9 * are undocumented. This is essentially a cleaned-up version of the
11 * device-specific functions replated with generic functions wherever
18 #include <linux/i2c.h>
37 /* Data generic to all (supported and non-supported) controllers. */
76 gpiod_set_value_cansleep(ts_data->reset_gpio, 1); in hyn_reset_proc()
78 gpiod_set_value_cansleep(ts_data->reset_gpio, 0); in hyn_reset_proc()
88 ts_data->chip->report_touch(client); in hyn_interrupt_handler()
94 * The vendor driver would retry twice before failing to read or write
95 * to the i2c device.
114 return ret < 0 ? ret : -EIO; in cst3xx_i2c_write()
123 .addr = client->addr, in cst3xx_i2c_read_register()
129 .addr = client->addr, in cst3xx_i2c_read_register()
138 ret = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs)); in cst3xx_i2c_read_register()
142 err = ret < 0 ? ret : -EIO; in cst3xx_i2c_read_register()
143 dev_err(&client->dev, "Error reading %d bytes from 0x%04x: %d (%d)\n", in cst3xx_i2c_read_register()
167 * Read register for check-code to determine if device detected in cst3xx_firmware_info()
176 if ((tmp & 0xffff0000) != ts_data->chip->ic_chkcode) { in cst3xx_firmware_info()
177 dev_err(&client->dev, "%s ic mismatch, chkcode is %u\n", in cst3xx_firmware_info()
179 return -ENODEV; in cst3xx_firmware_info()
192 dev_err(&client->dev, "Device firmware missing\n"); in cst3xx_firmware_info()
193 return -ENODEV; in cst3xx_firmware_info()
212 u8 retry; in cst3xx_bootloader_enter() local
216 for (retry = 0; retry < 5; retry++) { in cst3xx_bootloader_enter()
217 hyn_reset_proc(client, (7 + retry)); in cst3xx_bootloader_enter()
239 dev_err(&client->dev, "%s unable to enter bootloader mode\n", in cst3xx_bootloader_enter()
241 return -ENODEV; in cst3xx_bootloader_enter()
252 input_mt_slot(ts_data->input_dev, id); in cst3xx_report_contact()
253 input_mt_report_slot_state(ts_data->input_dev, MT_TOOL_FINGER, 1); in cst3xx_report_contact()
254 touchscreen_report_pos(ts_data->input_dev, &ts_data->prop, x, y, true); in cst3xx_report_contact()
255 input_report_abs(ts_data->input_dev, ABS_MT_TOUCH_MAJOR, w); in cst3xx_report_contact()
266 dev_err(&client->dev, in cst3xx_finish_touch_read()
280 * a touch count byte, a check byte, and then a second check byte after
306 dev_err(&client->dev, "cst3xx touch read failure\n"); in cst3xx_touch_report()
324 dev_err(&client->dev, "cst3xx touch read failure\n"); in cst3xx_touch_report()
338 if (ts_data->chip->max_touch_num < finger_id) { in cst3xx_touch_report()
339 dev_err(&client->dev, "cst3xx touch read failure\n"); in cst3xx_touch_report()
354 input_mt_sync_frame(ts_data->input_dev); in cst3xx_touch_report()
355 input_sync(ts_data->input_dev); in cst3xx_touch_report()
363 ts_data->input_dev = devm_input_allocate_device(&client->dev); in cst3xx_input_dev_int()
364 if (!ts_data->input_dev) { in cst3xx_input_dev_int()
365 dev_err(&client->dev, "Failed to allocate input device\n"); in cst3xx_input_dev_int()
366 return -ENOMEM; in cst3xx_input_dev_int()
369 ts_data->input_dev->name = "Hynitron cst3xx Touchscreen"; in cst3xx_input_dev_int()
370 ts_data->input_dev->phys = "input/ts"; in cst3xx_input_dev_int()
371 ts_data->input_dev->id.bustype = BUS_I2C; in cst3xx_input_dev_int()
373 input_set_drvdata(ts_data->input_dev, ts_data); in cst3xx_input_dev_int()
375 input_set_capability(ts_data->input_dev, EV_ABS, ABS_MT_POSITION_X); in cst3xx_input_dev_int()
376 input_set_capability(ts_data->input_dev, EV_ABS, ABS_MT_POSITION_Y); in cst3xx_input_dev_int()
377 input_set_abs_params(ts_data->input_dev, ABS_MT_TOUCH_MAJOR, in cst3xx_input_dev_int()
380 touchscreen_parse_properties(ts_data->input_dev, true, &ts_data->prop); in cst3xx_input_dev_int()
382 if (!ts_data->prop.max_x || !ts_data->prop.max_y) { in cst3xx_input_dev_int()
383 dev_err(&client->dev, in cst3xx_input_dev_int()
385 ts_data->prop.max_x, ts_data->prop.max_y); in cst3xx_input_dev_int()
386 ts_data->prop.max_x = 1152; in cst3xx_input_dev_int()
387 ts_data->prop.max_y = 1920; in cst3xx_input_dev_int()
388 input_abs_set_max(ts_data->input_dev, in cst3xx_input_dev_int()
389 ABS_MT_POSITION_X, ts_data->prop.max_x); in cst3xx_input_dev_int()
390 input_abs_set_max(ts_data->input_dev, in cst3xx_input_dev_int()
391 ABS_MT_POSITION_Y, ts_data->prop.max_y); in cst3xx_input_dev_int()
394 err = input_mt_init_slots(ts_data->input_dev, in cst3xx_input_dev_int()
395 ts_data->chip->max_touch_num, in cst3xx_input_dev_int()
398 dev_err(&client->dev, in cst3xx_input_dev_int()
403 err = input_register_device(ts_data->input_dev); in cst3xx_input_dev_int()
405 dev_err(&client->dev, in cst3xx_input_dev_int()
418 ts_data = devm_kzalloc(&client->dev, sizeof(*ts_data), GFP_KERNEL); in hyn_probe()
420 return -ENOMEM; in hyn_probe()
422 ts_data->client = client; in hyn_probe()
425 ts_data->chip = device_get_match_data(&client->dev); in hyn_probe()
426 if (!ts_data->chip) in hyn_probe()
427 return -EINVAL; in hyn_probe()
429 ts_data->reset_gpio = devm_gpiod_get(&client->dev, in hyn_probe()
431 err = PTR_ERR_OR_ZERO(ts_data->reset_gpio); in hyn_probe()
433 dev_err(&client->dev, "request reset gpio failed: %d\n", err); in hyn_probe()
439 err = ts_data->chip->bootloader_enter(client); in hyn_probe()
443 err = ts_data->chip->init_input(client); in hyn_probe()
447 err = ts_data->chip->firmware_info(client); in hyn_probe()
451 err = devm_request_threaded_irq(&client->dev, client->irq, in hyn_probe()
456 dev_err(&client->dev, "failed to request IRQ: %d\n", err); in hyn_probe()
476 MODULE_DEVICE_TABLE(i2c, hyn_tpd_id);
486 .name = "Hynitron-TS",