Lines Matching +full:touchscreen +full:- +full:average +full:- +full:samples

1 // SPDX-License-Identifier: GPL-2.0
3 * Rohm BU21029 touchscreen controller driver
5 * Copyright (C) 2015-2018 Bosch Sicherheitssysteme GmbH
16 #include <linux/input/touchscreen.h>
25 * +--------+--------+--------+--------+--------+--------+--------+--------+
27 * +--------+--------+--------+--------+--------+--------+--------+--------+
29 * +--------+--------+--------+--------+--------+--------+--------+--------+
31 * +--------+--------+--------+--------+--------+--------+--------+--------+
33 * +--------+--------+--------+--------+--------+--------+--------+--------+
35 * +--------+--------+--------+--------+--------+--------+--------+--------+
44 * +--------+--------+--------+--------+--------+--------+--------+--------+
46 * +--------+--------+--------+--------+--------+--------+--------+--------+
48 * +--------+--------+--------+--------+--------+--------+--------+--------+
59 * +--------+--------+--------+--------+--------+--------+--------+--------+
61 * +--------+--------+--------+--------+--------+--------+--------+--------+
63 * +--------+--------+--------+--------+--------+--------+--------+--------+
64 * MAV: 0 = median average filter off
65 * 1 = median average filter on (*)
66 * AVE: AVE+1 = number of average samples for MAV,
68 * SMPL: SMPL+1 = number of conversion samples for MAV (=7)
75 * +--------+--------+--------+--------+--------+--------+--------+--------+
77 * +--------+--------+--------+--------+--------+--------+--------+--------+
79 * +--------+--------+--------+--------+--------+--------+--------+--------+
91 * +--------+--------+--------+--------+--------+--------+--------+--------+
93 * +--------+--------+--------+--------+--------+--------+--------+--------+
95 * +--------+--------+--------+--------+--------+--------+--------+--------+
100 * PU90K: 0 = internal pull-up resistance for touch detection is ~50kohms (*)
101 * 1 = internal pull-up resistance for touch detection is ~90kohms
112 * +--------+--------+--------+--------+--------+--------+--------+--------+
114 * +--------+--------+--------+--------+--------+--------+--------+--------+
116 * +--------+--------+--------+--------+--------+--------+--------+--------+
125 * +--------+--------+--------+--------+--------+--------+--------+--------+
127 * +--------+--------+--------+--------+--------+--------+--------+--------+
129 * +--------+--------+--------+--------+--------+--------+--------+--------+
152 #define MAX_12BIT ((1 << 12) - 1)
169 s32 max_pressure = input_abs_get_max(bu21029->in_dev, ABS_PRESSURE); in bu21029_touch_report()
173 * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ in bu21029_touch_report()
175 * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ in bu21029_touch_report()
177 * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ in bu21029_touch_report()
179 * +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ in bu21029_touch_report()
189 * Rz = Rx * (x/Q) * ((z2/z1) - 1), where in bu21029_touch_report()
190 * Rx is x-plate resistance, in bu21029_touch_report()
194 rz = z2 - z1; in bu21029_touch_report()
196 rz *= bu21029->x_plate_ohms; in bu21029_touch_report()
200 touchscreen_report_pos(bu21029->in_dev, &bu21029->prop, in bu21029_touch_report()
202 input_report_abs(bu21029->in_dev, ABS_PRESSURE, in bu21029_touch_report()
203 max_pressure - rz); in bu21029_touch_report()
204 input_report_key(bu21029->in_dev, BTN_TOUCH, 1); in bu21029_touch_report()
205 input_sync(bu21029->in_dev); in bu21029_touch_report()
214 input_report_abs(bu21029->in_dev, ABS_PRESSURE, 0); in bu21029_touch_release()
215 input_report_key(bu21029->in_dev, BTN_TOUCH, 0); in bu21029_touch_release()
216 input_sync(bu21029->in_dev); in bu21029_touch_release()
229 error = i2c_smbus_read_i2c_block_data(bu21029->client, BU21029_AUTOSCAN, in bu21029_touch_soft_irq()
237 mod_timer(&bu21029->timer, in bu21029_touch_soft_irq()
246 if (bu21029->reset_gpios) { in bu21029_put_chip_in_reset()
247 gpiod_set_value_cansleep(bu21029->reset_gpios, 1); in bu21029_put_chip_in_reset()
255 struct i2c_client *i2c = bu21029->client; in bu21029_start_chip()
269 error = regulator_enable(bu21029->vdd); in bu21029_start_chip()
271 dev_err(&i2c->dev, "failed to power up chip: %d", error); in bu21029_start_chip()
276 if (bu21029->reset_gpios) { in bu21029_start_chip()
277 gpiod_set_value_cansleep(bu21029->reset_gpios, 0); in bu21029_start_chip()
284 dev_err(&i2c->dev, "failed to read HW ID\n"); in bu21029_start_chip()
289 dev_err(&i2c->dev, in bu21029_start_chip()
291 error = -ENODEV; in bu21029_start_chip()
300 dev_err(&i2c->dev, in bu21029_start_chip()
310 dev_err(&i2c->dev, "failed to start autoscan\n"); in bu21029_start_chip()
314 enable_irq(bu21029->client->irq); in bu21029_start_chip()
319 regulator_disable(bu21029->vdd); in bu21029_start_chip()
327 disable_irq(bu21029->client->irq); in bu21029_stop_chip()
328 del_timer_sync(&bu21029->timer); in bu21029_stop_chip()
331 regulator_disable(bu21029->vdd); in bu21029_stop_chip()
341 if (!i2c_check_functionality(client->adapter, in bu21029_probe()
345 dev_err(&client->dev, in bu21029_probe()
347 return -EIO; in bu21029_probe()
350 bu21029 = devm_kzalloc(&client->dev, sizeof(*bu21029), GFP_KERNEL); in bu21029_probe()
352 return -ENOMEM; in bu21029_probe()
354 error = device_property_read_u32(&client->dev, "rohm,x-plate-ohms", in bu21029_probe()
355 &bu21029->x_plate_ohms); in bu21029_probe()
357 dev_err(&client->dev, in bu21029_probe()
358 "invalid 'x-plate-ohms' supplied: %d\n", error); in bu21029_probe()
362 bu21029->vdd = devm_regulator_get(&client->dev, "vdd"); in bu21029_probe()
363 if (IS_ERR(bu21029->vdd)) { in bu21029_probe()
364 error = PTR_ERR(bu21029->vdd); in bu21029_probe()
365 if (error != -EPROBE_DEFER) in bu21029_probe()
366 dev_err(&client->dev, in bu21029_probe()
371 bu21029->reset_gpios = devm_gpiod_get_optional(&client->dev, in bu21029_probe()
373 if (IS_ERR(bu21029->reset_gpios)) { in bu21029_probe()
374 error = PTR_ERR(bu21029->reset_gpios); in bu21029_probe()
375 if (error != -EPROBE_DEFER) in bu21029_probe()
376 dev_err(&client->dev, in bu21029_probe()
381 in_dev = devm_input_allocate_device(&client->dev); in bu21029_probe()
383 dev_err(&client->dev, "unable to allocate input device\n"); in bu21029_probe()
384 return -ENOMEM; in bu21029_probe()
387 bu21029->client = client; in bu21029_probe()
388 bu21029->in_dev = in_dev; in bu21029_probe()
389 timer_setup(&bu21029->timer, bu21029_touch_release, 0); in bu21029_probe()
391 in_dev->name = DRIVER_NAME; in bu21029_probe()
392 in_dev->id.bustype = BUS_I2C; in bu21029_probe()
393 in_dev->open = bu21029_start_chip; in bu21029_probe()
394 in_dev->close = bu21029_stop_chip; in bu21029_probe()
400 touchscreen_parse_properties(in_dev, false, &bu21029->prop); in bu21029_probe()
404 irq_set_status_flags(client->irq, IRQ_NOAUTOEN); in bu21029_probe()
405 error = devm_request_threaded_irq(&client->dev, client->irq, in bu21029_probe()
409 dev_err(&client->dev, in bu21029_probe()
416 dev_err(&client->dev, in bu21029_probe()
432 mutex_lock(&bu21029->in_dev->mutex); in bu21029_suspend()
433 if (bu21029->in_dev->users) in bu21029_suspend()
434 bu21029_stop_chip(bu21029->in_dev); in bu21029_suspend()
435 mutex_unlock(&bu21029->in_dev->mutex); in bu21029_suspend()
447 mutex_lock(&bu21029->in_dev->mutex); in bu21029_resume()
448 if (bu21029->in_dev->users) in bu21029_resume()
449 bu21029_start_chip(bu21029->in_dev); in bu21029_resume()
450 mutex_unlock(&bu21029->in_dev->mutex); in bu21029_resume()
483 MODULE_DESCRIPTION("Rohm BU21029 touchscreen controller driver");