Lines Matching refs:bt541

212 static u16 zinitix_get_u16_reg(struct bt541_ts_data *bt541, u16 vreg)  in zinitix_get_u16_reg()  argument
214 struct i2c_client *client = bt541->client; in zinitix_get_u16_reg()
225 static int zinitix_init_touch(struct bt541_ts_data *bt541) in zinitix_init_touch() argument
227 struct i2c_client *client = bt541->client; in zinitix_init_touch()
242 if (!bt541->have_versioninfo) { in zinitix_init_touch()
243 bt541->chip_revision = zinitix_get_u16_reg(bt541, in zinitix_init_touch()
245 bt541->firmware_version = zinitix_get_u16_reg(bt541, in zinitix_init_touch()
247 bt541->regdata_version = zinitix_get_u16_reg(bt541, in zinitix_init_touch()
249 bt541->have_versioninfo = true; in zinitix_init_touch()
253 bt541->chip_revision, bt541->firmware_version, in zinitix_init_touch()
254 bt541->regdata_version); in zinitix_init_touch()
260 switch (bt541->chip_revision & ZINITIX_CHIP_BTX0X_MASK) { in zinitix_init_touch()
262 bt541->icon_status_reg = ZINITIX_BT4X2_ICON_STATUS_REG; in zinitix_init_touch()
266 bt541->icon_status_reg = ZINITIX_BT4X3_ICON_STATUS_REG; in zinitix_init_touch()
270 bt541->icon_status_reg = ZINITIX_BT4X4_ICON_STATUS_REG; in zinitix_init_touch()
274 bt541->icon_status_reg = ZINITIX_BT5XX_ICON_STATUS_REG; in zinitix_init_touch()
288 bt541->prop.max_x); in zinitix_init_touch()
293 bt541->prop.max_y); in zinitix_init_touch()
303 bt541->num_keycodes); in zinitix_init_touch()
308 bt541->zinitix_mode); in zinitix_init_touch()
313 bt541->zinitix_mode); in zinitix_init_touch()
318 if (bt541->num_keycodes) in zinitix_init_touch()
334 static int zinitix_init_regulators(struct bt541_ts_data *bt541) in zinitix_init_regulators() argument
336 struct device *dev = &bt541->client->dev; in zinitix_init_regulators()
345 bt541->supplies[0].supply = "vdd"; in zinitix_init_regulators()
346 bt541->supplies[1].supply = "vddo"; in zinitix_init_regulators()
349 bt541->supplies[0].supply = "vcca"; in zinitix_init_regulators()
350 bt541->supplies[1].supply = "vdd"; in zinitix_init_regulators()
353 ARRAY_SIZE(bt541->supplies), in zinitix_init_regulators()
354 bt541->supplies); in zinitix_init_regulators()
363 static int zinitix_send_power_on_sequence(struct bt541_ts_data *bt541) in zinitix_send_power_on_sequence() argument
366 struct i2c_client *client = bt541->client; in zinitix_send_power_on_sequence()
403 static void zinitix_report_finger(struct bt541_ts_data *bt541, int slot, in zinitix_report_finger() argument
410 dev_dbg(&bt541->client->dev, "unknown finger event %#02x\n", in zinitix_report_finger()
418 input_mt_slot(bt541->input_dev, slot); in zinitix_report_finger()
419 if (input_mt_report_slot_state(bt541->input_dev, MT_TOOL_FINGER, in zinitix_report_finger()
421 touchscreen_report_pos(bt541->input_dev, in zinitix_report_finger()
422 &bt541->prop, x, y, true); in zinitix_report_finger()
423 input_report_abs(bt541->input_dev, in zinitix_report_finger()
425 dev_dbg(&bt541->client->dev, "finger %d %s (%u, %u)\n", in zinitix_report_finger()
429 dev_dbg(&bt541->client->dev, "finger %d up (%u, %u)\n", in zinitix_report_finger()
434 static void zinitix_report_keys(struct bt541_ts_data *bt541, u16 icon_events) in zinitix_report_keys() argument
438 for (i = 0; i < bt541->num_keycodes; i++) in zinitix_report_keys()
439 input_report_key(bt541->input_dev, in zinitix_report_keys()
440 bt541->keycodes[i], icon_events & BIT(i)); in zinitix_report_keys()
445 struct bt541_ts_data *bt541 = bt541_handler; in zinitix_ts_irq_handler() local
446 struct i2c_client *client = bt541->client; in zinitix_ts_irq_handler()
455 error = zinitix_read_data(bt541->client, ZINITIX_POINT_STATUS_REG, in zinitix_ts_irq_handler()
463 error = zinitix_read_data(bt541->client, bt541->icon_status_reg, in zinitix_ts_irq_handler()
470 zinitix_report_keys(bt541, le16_to_cpu(icon_events)); in zinitix_ts_irq_handler()
479 zinitix_report_finger(bt541, i, p); in zinitix_ts_irq_handler()
482 input_mt_sync_frame(bt541->input_dev); in zinitix_ts_irq_handler()
483 input_sync(bt541->input_dev); in zinitix_ts_irq_handler()
486 zinitix_write_cmd(bt541->client, ZINITIX_CLEAR_INT_STATUS_CMD); in zinitix_ts_irq_handler()
490 static int zinitix_start(struct bt541_ts_data *bt541) in zinitix_start() argument
494 error = regulator_bulk_enable(ARRAY_SIZE(bt541->supplies), in zinitix_start()
495 bt541->supplies); in zinitix_start()
497 dev_err(&bt541->client->dev, in zinitix_start()
504 error = zinitix_send_power_on_sequence(bt541); in zinitix_start()
506 dev_err(&bt541->client->dev, in zinitix_start()
511 error = zinitix_init_touch(bt541); in zinitix_start()
513 dev_err(&bt541->client->dev, in zinitix_start()
518 enable_irq(bt541->client->irq); in zinitix_start()
523 static int zinitix_stop(struct bt541_ts_data *bt541) in zinitix_stop() argument
527 disable_irq(bt541->client->irq); in zinitix_stop()
529 error = regulator_bulk_disable(ARRAY_SIZE(bt541->supplies), in zinitix_stop()
530 bt541->supplies); in zinitix_stop()
532 dev_err(&bt541->client->dev, in zinitix_stop()
542 struct bt541_ts_data *bt541 = input_get_drvdata(dev); in zinitix_input_open() local
544 return zinitix_start(bt541); in zinitix_input_open()
549 struct bt541_ts_data *bt541 = input_get_drvdata(dev); in zinitix_input_close() local
551 zinitix_stop(bt541); in zinitix_input_close()
554 static int zinitix_init_input_dev(struct bt541_ts_data *bt541) in zinitix_init_input_dev() argument
560 input_dev = devm_input_allocate_device(&bt541->client->dev); in zinitix_init_input_dev()
562 dev_err(&bt541->client->dev, in zinitix_init_input_dev()
567 input_set_drvdata(input_dev, bt541); in zinitix_init_input_dev()
568 bt541->input_dev = input_dev; in zinitix_init_input_dev()
576 if (bt541->num_keycodes) { in zinitix_init_input_dev()
577 input_dev->keycode = bt541->keycodes; in zinitix_init_input_dev()
578 input_dev->keycodemax = bt541->num_keycodes; in zinitix_init_input_dev()
579 input_dev->keycodesize = sizeof(bt541->keycodes[0]); in zinitix_init_input_dev()
580 for (i = 0; i < bt541->num_keycodes; i++) in zinitix_init_input_dev()
581 input_set_capability(input_dev, EV_KEY, bt541->keycodes[i]); in zinitix_init_input_dev()
589 touchscreen_parse_properties(input_dev, true, &bt541->prop); in zinitix_init_input_dev()
590 if (!bt541->prop.max_x || !bt541->prop.max_y) { in zinitix_init_input_dev()
591 dev_err(&bt541->client->dev, in zinitix_init_input_dev()
599 dev_err(&bt541->client->dev, in zinitix_init_input_dev()
606 dev_err(&bt541->client->dev, in zinitix_init_input_dev()
616 struct bt541_ts_data *bt541; in zinitix_ts_probe() local
625 bt541 = devm_kzalloc(&client->dev, sizeof(*bt541), GFP_KERNEL); in zinitix_ts_probe()
626 if (!bt541) in zinitix_ts_probe()
629 bt541->client = client; in zinitix_ts_probe()
630 i2c_set_clientdata(client, bt541); in zinitix_ts_probe()
632 error = zinitix_init_regulators(bt541); in zinitix_ts_probe()
642 client->name, bt541); in zinitix_ts_probe()
649 bt541->num_keycodes = device_property_count_u32(&client->dev, in zinitix_ts_probe()
651 if (bt541->num_keycodes < 0) { in zinitix_ts_probe()
653 bt541->num_keycodes); in zinitix_ts_probe()
654 return bt541->num_keycodes; in zinitix_ts_probe()
655 } else if (bt541->num_keycodes > ARRAY_SIZE(bt541->keycodes)) { in zinitix_ts_probe()
657 bt541->num_keycodes); in zinitix_ts_probe()
663 bt541->keycodes, in zinitix_ts_probe()
664 bt541->num_keycodes); in zinitix_ts_probe()
673 error = zinitix_init_input_dev(bt541); in zinitix_ts_probe()
681 &bt541->zinitix_mode); in zinitix_ts_probe()
684 bt541->zinitix_mode = DEFAULT_TOUCH_POINT_MODE; in zinitix_ts_probe()
687 if (bt541->zinitix_mode != 2) { in zinitix_ts_probe()
694 bt541->zinitix_mode); in zinitix_ts_probe()
704 struct bt541_ts_data *bt541 = i2c_get_clientdata(client); in zinitix_suspend() local
706 mutex_lock(&bt541->input_dev->mutex); in zinitix_suspend()
708 if (input_device_enabled(bt541->input_dev)) in zinitix_suspend()
709 zinitix_stop(bt541); in zinitix_suspend()
711 mutex_unlock(&bt541->input_dev->mutex); in zinitix_suspend()
719 struct bt541_ts_data *bt541 = i2c_get_clientdata(client); in zinitix_resume() local
722 mutex_lock(&bt541->input_dev->mutex); in zinitix_resume()
724 if (input_device_enabled(bt541->input_dev)) in zinitix_resume()
725 ret = zinitix_start(bt541); in zinitix_resume()
727 mutex_unlock(&bt541->input_dev->mutex); in zinitix_resume()