Lines Matching +full:i2c +full:- +full:retry +full:- +full:count

1 // SPDX-License-Identifier: GPL-2.0-only
6 #include <linux/i2c.h>
72 .addr = ts->client->addr, in imagis_i2c_read_reg()
77 .addr = ts->client->addr, in imagis_i2c_read_reg()
84 int retry = IST3038C_I2C_RETRY_COUNT; in imagis_i2c_read_reg() local
86 /* Retry in case the controller fails to respond */ in imagis_i2c_read_reg()
88 ret = i2c_transfer(ts->client->adapter, msg, ARRAY_SIZE(msg)); in imagis_i2c_read_reg()
94 error = ret < 0 ? ret : -EIO; in imagis_i2c_read_reg()
95 dev_err(&ts->client->dev, in imagis_i2c_read_reg()
96 "%s - i2c_transfer failed: %d (%d)\n", in imagis_i2c_read_reg()
98 } while (--retry); in imagis_i2c_read_reg()
111 error = imagis_i2c_read_reg(ts, ts->tdata->interrupt_msg_cmd, &intr_message); in imagis_interrupt()
113 dev_err(&ts->client->dev, in imagis_interrupt()
120 dev_err(&ts->client->dev, in imagis_interrupt()
121 "finger count %d is more than maximum supported\n", in imagis_interrupt()
129 if (ts->tdata->protocol_b) in imagis_interrupt()
131 ts->tdata->touch_coord_cmd + (i * 4), in imagis_interrupt()
135 ts->tdata->touch_coord_cmd, &finger_status); in imagis_interrupt()
137 dev_err(&ts->client->dev, in imagis_interrupt()
143 input_mt_slot(ts->input_dev, i); in imagis_interrupt()
144 input_mt_report_slot_state(ts->input_dev, MT_TOOL_FINGER, in imagis_interrupt()
146 touchscreen_report_pos(ts->input_dev, &ts->prop, in imagis_interrupt()
150 input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, in imagis_interrupt()
156 for (int i = 0; i < ts->num_keycodes; i++) in imagis_interrupt()
157 input_report_key(ts->input_dev, ts->keycodes[i], in imagis_interrupt()
160 input_mt_sync_frame(ts->input_dev); in imagis_interrupt()
161 input_sync(ts->input_dev); in imagis_interrupt()
171 regulator_bulk_disable(ARRAY_SIZE(ts->supplies), ts->supplies); in imagis_power_off()
178 error = regulator_bulk_enable(ARRAY_SIZE(ts->supplies), ts->supplies); in imagis_power_on()
195 enable_irq(ts->client->irq); in imagis_start()
202 disable_irq(ts->client->irq); in imagis_stop()
228 input_dev = devm_input_allocate_device(&ts->client->dev); in imagis_init_input_dev()
230 return -ENOMEM; in imagis_init_input_dev()
232 ts->input_dev = input_dev; in imagis_init_input_dev()
234 input_dev->name = "Imagis capacitive touchscreen"; in imagis_init_input_dev()
235 input_dev->phys = "input/ts"; in imagis_init_input_dev()
236 input_dev->id.bustype = BUS_I2C; in imagis_init_input_dev()
237 input_dev->open = imagis_input_open; in imagis_init_input_dev()
238 input_dev->close = imagis_input_close; in imagis_init_input_dev()
245 if (ts->tdata->touch_keys_supported) { in imagis_init_input_dev()
246 ts->num_keycodes = of_property_read_variable_u32_array( in imagis_init_input_dev()
247 ts->client->dev.of_node, "linux,keycodes", in imagis_init_input_dev()
248 ts->keycodes, 0, ARRAY_SIZE(ts->keycodes)); in imagis_init_input_dev()
249 if (ts->num_keycodes <= 0) { in imagis_init_input_dev()
250 ts->keycodes[0] = KEY_APPSELECT; in imagis_init_input_dev()
251 ts->keycodes[1] = KEY_BACK; in imagis_init_input_dev()
252 ts->num_keycodes = 2; in imagis_init_input_dev()
255 input_dev->keycodemax = ts->num_keycodes; in imagis_init_input_dev()
256 input_dev->keycodesize = sizeof(ts->keycodes[0]); in imagis_init_input_dev()
257 input_dev->keycode = ts->keycodes; in imagis_init_input_dev()
260 for (int i = 0; i < ts->num_keycodes; i++) in imagis_init_input_dev()
261 input_set_capability(input_dev, EV_KEY, ts->keycodes[i]); in imagis_init_input_dev()
263 touchscreen_parse_properties(input_dev, true, &ts->prop); in imagis_init_input_dev()
264 if (!ts->prop.max_x || !ts->prop.max_y) { in imagis_init_input_dev()
265 dev_err(&ts->client->dev, in imagis_init_input_dev()
266 "Touchscreen-size-x and/or touchscreen-size-y not set in dts\n"); in imagis_init_input_dev()
267 return -EINVAL; in imagis_init_input_dev()
274 dev_err(&ts->client->dev, in imagis_init_input_dev()
281 dev_err(&ts->client->dev, in imagis_init_input_dev()
291 struct i2c_client *client = ts->client; in imagis_init_regulators()
293 ts->supplies[0].supply = "vdd"; in imagis_init_regulators()
294 ts->supplies[1].supply = "vddio"; in imagis_init_regulators()
295 return devm_regulator_bulk_get(&client->dev, in imagis_init_regulators()
296 ARRAY_SIZE(ts->supplies), in imagis_init_regulators()
297 ts->supplies); in imagis_init_regulators()
300 static int imagis_probe(struct i2c_client *i2c) in imagis_probe() argument
302 struct device *dev = &i2c->dev; in imagis_probe()
308 return -ENOMEM; in imagis_probe()
310 ts->client = i2c; in imagis_probe()
312 ts->tdata = device_get_match_data(dev); in imagis_probe()
313 if (!ts->tdata) { in imagis_probe()
315 return -EINVAL; in imagis_probe()
336 error = imagis_i2c_read_reg(ts, ts->tdata->whoami_cmd, &chip_id); in imagis_probe()
342 if (chip_id != ts->tdata->whoami_val) { in imagis_probe()
344 return -EINVAL; in imagis_probe()
347 error = devm_request_threaded_irq(dev, i2c->irq, in imagis_probe()
350 "imagis-touchscreen", ts); in imagis_probe()
353 i2c->irq, error); in imagis_probe()
370 mutex_lock(&ts->input_dev->mutex); in imagis_suspend()
372 if (input_device_enabled(ts->input_dev)) in imagis_suspend()
375 mutex_unlock(&ts->input_dev->mutex); in imagis_suspend()
386 mutex_lock(&ts->input_dev->mutex); in imagis_resume()
388 if (input_device_enabled(ts->input_dev)) in imagis_resume()
391 mutex_unlock(&ts->input_dev->mutex); in imagis_resume()
443 .name = "imagis-touchscreen",