Lines Matching +full:client +full:- +full:id
1 // SPDX-License-Identifier: GPL-2.0
64 struct i2c_client *client; member
78 u8 id:4, reserved_bit4:1, type:2, pressed:1; member
90 struct i2c_client *client = data->client; in __mms114_read_reg() local
99 xfer[0].addr = client->addr; in __mms114_read_reg()
100 xfer[0].flags = client->flags & I2C_M_TEN; in __mms114_read_reg()
105 xfer[1].addr = client->addr; in __mms114_read_reg()
106 xfer[1].flags = (client->flags & I2C_M_TEN) | I2C_M_RD; in __mms114_read_reg()
110 error = i2c_transfer(client->adapter, xfer, 2); in __mms114_read_reg()
112 dev_err(&client->dev, in __mms114_read_reg()
114 return error < 0 ? error : -EIO; in __mms114_read_reg()
127 return data->cache_mode_control; in mms114_read_reg()
136 struct i2c_client *client = data->client; in mms114_write_reg() local
143 error = i2c_master_send(client, buf, 2); in mms114_write_reg()
145 dev_err(&client->dev, in mms114_write_reg()
147 return error < 0 ? error : -EIO; in mms114_write_reg()
152 data->cache_mode_control = val; in mms114_write_reg()
159 struct i2c_client *client = data->client; in mms114_process_mt() local
160 struct input_dev *input_dev = data->input_dev; in mms114_process_mt()
161 unsigned int id; in mms114_process_mt() local
165 if (touch->id > MMS114_MAX_TOUCH) { in mms114_process_mt()
166 dev_err(&client->dev, "Wrong touch id (%d)\n", touch->id); in mms114_process_mt()
170 if (touch->type != MMS114_TYPE_TOUCHSCREEN) { in mms114_process_mt()
171 dev_err(&client->dev, "Wrong touch type (%d)\n", touch->type); in mms114_process_mt()
175 id = touch->id - 1; in mms114_process_mt()
176 x = touch->x_lo | touch->x_hi << 8; in mms114_process_mt()
177 y = touch->y_lo | touch->y_hi << 8; in mms114_process_mt()
179 dev_dbg(&client->dev, in mms114_process_mt()
180 "id: %d, type: %d, pressed: %d, x: %d, y: %d, width: %d, strength: %d\n", in mms114_process_mt()
181 id, touch->type, touch->pressed, in mms114_process_mt()
182 x, y, touch->width, touch->strength); in mms114_process_mt()
184 input_mt_slot(input_dev, id); in mms114_process_mt()
185 input_mt_report_slot_state(input_dev, MT_TOOL_FINGER, touch->pressed); in mms114_process_mt()
187 if (touch->pressed) { in mms114_process_mt()
188 touchscreen_report_pos(input_dev, &data->props, x, y, true); in mms114_process_mt()
189 input_report_abs(input_dev, ABS_MT_TOUCH_MAJOR, touch->width); in mms114_process_mt()
190 input_report_abs(input_dev, ABS_MT_PRESSURE, touch->strength); in mms114_process_mt()
197 struct input_dev *input_dev = data->input_dev; in mms114_interrupt()
204 mutex_lock(&input_dev->mutex); in mms114_interrupt()
206 mutex_unlock(&input_dev->mutex); in mms114_interrupt()
209 mutex_unlock(&input_dev->mutex); in mms114_interrupt()
216 if (data->type == TYPE_MMS134S || data->type == TYPE_MMS136) in mms114_interrupt()
229 input_mt_report_pointer_emulation(data->input_dev, true); in mms114_interrupt()
230 input_sync(data->input_dev); in mms114_interrupt()
255 struct device *dev = &data->client->dev; in mms114_get_version()
260 switch (data->type) { in mms114_get_version()
275 group = i2c_smbus_read_byte_data(data->client, in mms114_get_version()
301 const struct touchscreen_properties *props = &data->props; in mms114_setup_regs()
310 if (data->type != TYPE_MMS114 && data->type != TYPE_MMS134S && in mms114_setup_regs()
311 data->type != TYPE_MMS136) in mms114_setup_regs()
318 val = (props->max_x >> 8) & 0xf; in mms114_setup_regs()
319 val |= ((props->max_y >> 8) & 0xf) << 4; in mms114_setup_regs()
324 val = props->max_x & 0xff; in mms114_setup_regs()
329 val = props->max_x & 0xff; in mms114_setup_regs()
334 if (data->contact_threshold) { in mms114_setup_regs()
336 data->contact_threshold); in mms114_setup_regs()
341 if (data->moving_threshold) { in mms114_setup_regs()
343 data->moving_threshold); in mms114_setup_regs()
353 struct i2c_client *client = data->client; in mms114_start() local
356 error = regulator_enable(data->core_reg); in mms114_start()
358 dev_err(&client->dev, "Failed to enable avdd: %d\n", error); in mms114_start()
362 error = regulator_enable(data->io_reg); in mms114_start()
364 dev_err(&client->dev, "Failed to enable vdd: %d\n", error); in mms114_start()
365 regulator_disable(data->core_reg); in mms114_start()
373 regulator_disable(data->io_reg); in mms114_start()
374 regulator_disable(data->core_reg); in mms114_start()
378 enable_irq(client->irq); in mms114_start()
385 struct i2c_client *client = data->client; in mms114_stop() local
388 disable_irq(client->irq); in mms114_stop()
390 error = regulator_disable(data->io_reg); in mms114_stop()
392 dev_warn(&client->dev, "Failed to disable vdd: %d\n", error); in mms114_stop()
394 error = regulator_disable(data->core_reg); in mms114_stop()
396 dev_warn(&client->dev, "Failed to disable avdd: %d\n", error); in mms114_stop()
415 struct device *dev = &data->client->dev; in mms114_parse_legacy_bindings()
416 struct touchscreen_properties *props = &data->props; in mms114_parse_legacy_bindings()
418 if (device_property_read_u32(dev, "x-size", &props->max_x)) { in mms114_parse_legacy_bindings()
419 dev_dbg(dev, "failed to get legacy x-size property\n"); in mms114_parse_legacy_bindings()
420 return -EINVAL; in mms114_parse_legacy_bindings()
423 if (device_property_read_u32(dev, "y-size", &props->max_y)) { in mms114_parse_legacy_bindings()
424 dev_dbg(dev, "failed to get legacy y-size property\n"); in mms114_parse_legacy_bindings()
425 return -EINVAL; in mms114_parse_legacy_bindings()
428 device_property_read_u32(dev, "contact-threshold", in mms114_parse_legacy_bindings()
429 &data->contact_threshold); in mms114_parse_legacy_bindings()
430 device_property_read_u32(dev, "moving-threshold", in mms114_parse_legacy_bindings()
431 &data->moving_threshold); in mms114_parse_legacy_bindings()
433 if (device_property_read_bool(dev, "x-invert")) in mms114_parse_legacy_bindings()
434 props->invert_x = true; in mms114_parse_legacy_bindings()
435 if (device_property_read_bool(dev, "y-invert")) in mms114_parse_legacy_bindings()
436 props->invert_y = true; in mms114_parse_legacy_bindings()
438 props->swap_x_y = false; in mms114_parse_legacy_bindings()
443 static int mms114_probe(struct i2c_client *client, in mms114_probe() argument
444 const struct i2c_device_id *id) in mms114_probe() argument
451 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { in mms114_probe()
452 dev_err(&client->dev, "Not supported I2C adapter\n"); in mms114_probe()
453 return -ENODEV; in mms114_probe()
456 data = devm_kzalloc(&client->dev, sizeof(struct mms114_data), in mms114_probe()
458 input_dev = devm_input_allocate_device(&client->dev); in mms114_probe()
460 dev_err(&client->dev, "Failed to allocate memory\n"); in mms114_probe()
461 return -ENOMEM; in mms114_probe()
464 data->client = client; in mms114_probe()
465 data->input_dev = input_dev; in mms114_probe()
467 match_data = device_get_match_data(&client->dev); in mms114_probe()
469 return -EINVAL; in mms114_probe()
471 data->type = (enum mms_type)match_data; in mms114_probe()
479 touchscreen_parse_properties(input_dev, true, &data->props); in mms114_probe()
480 if (!data->props.max_x || !data->props.max_y) { in mms114_probe()
481 dev_dbg(&client->dev, in mms114_probe()
488 0, data->props.max_x, 0, 0); in mms114_probe()
490 0, data->props.max_y, 0, 0); in mms114_probe()
493 if (data->type == TYPE_MMS114 || data->type == TYPE_MMS134S || in mms114_probe()
494 data->type == TYPE_MMS136) { in mms114_probe()
499 data->moving_threshold = input_abs_get_fuzz(input_dev, in mms114_probe()
501 data->contact_threshold = input_abs_get_fuzz(input_dev, in mms114_probe()
508 input_dev->name = devm_kasprintf(&client->dev, GFP_KERNEL, in mms114_probe()
510 data->type); in mms114_probe()
511 if (!input_dev->name) in mms114_probe()
512 return -ENOMEM; in mms114_probe()
514 input_dev->id.bustype = BUS_I2C; in mms114_probe()
515 input_dev->dev.parent = &client->dev; in mms114_probe()
516 input_dev->open = mms114_input_open; in mms114_probe()
517 input_dev->close = mms114_input_close; in mms114_probe()
525 i2c_set_clientdata(client, data); in mms114_probe()
527 data->core_reg = devm_regulator_get(&client->dev, "avdd"); in mms114_probe()
528 if (IS_ERR(data->core_reg)) { in mms114_probe()
529 error = PTR_ERR(data->core_reg); in mms114_probe()
530 dev_err(&client->dev, in mms114_probe()
535 data->io_reg = devm_regulator_get(&client->dev, "vdd"); in mms114_probe()
536 if (IS_ERR(data->io_reg)) { in mms114_probe()
537 error = PTR_ERR(data->io_reg); in mms114_probe()
538 dev_err(&client->dev, in mms114_probe()
543 error = devm_request_threaded_irq(&client->dev, client->irq, in mms114_probe()
546 dev_name(&client->dev), data); in mms114_probe()
548 dev_err(&client->dev, "Failed to register interrupt\n"); in mms114_probe()
552 error = input_register_device(data->input_dev); in mms114_probe()
554 dev_err(&client->dev, "Failed to register input device\n"); in mms114_probe()
563 struct i2c_client *client = to_i2c_client(dev); in mms114_suspend() local
564 struct mms114_data *data = i2c_get_clientdata(client); in mms114_suspend()
565 struct input_dev *input_dev = data->input_dev; in mms114_suspend()
566 int id; in mms114_suspend() local
569 for (id = 0; id < MMS114_MAX_TOUCH; id++) { in mms114_suspend()
570 input_mt_slot(input_dev, id); in mms114_suspend()
577 mutex_lock(&input_dev->mutex); in mms114_suspend()
580 mutex_unlock(&input_dev->mutex); in mms114_suspend()
587 struct i2c_client *client = to_i2c_client(dev); in mms114_resume() local
588 struct mms114_data *data = i2c_get_clientdata(client); in mms114_resume()
589 struct input_dev *input_dev = data->input_dev; in mms114_resume()
592 mutex_lock(&input_dev->mutex); in mms114_resume()
596 mutex_unlock(&input_dev->mutex); in mms114_resume()
600 mutex_unlock(&input_dev->mutex); in mms114_resume()