Lines Matching +full:touchscreen +full:- +full:average +full:- +full:samples
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * STMicroelectronics STMPE811 Touchscreen Driver
25 * with touchscreen controller
45 #define STMPE_TS_NAME "stmpe-ts"
49 * struct stmpe_touch - stmpe811 touch screen controller state
54 * @ave_ctrl: Sample average control
55 * (0 -> 1 sample, 1 -> 2 samples, 2 -> 4 samples, 3 -> 8 samples)
57 * (0 -> 10 us, 1 -> 50 us, 2 -> 100 us, 3 -> 500 us,
58 * 4-> 1 ms, 5 -> 5 ms, 6 -> 10 ms, 7 -> 50 ms)
61 * (0 -> 10 us, 1 -> 100 us, 2 -> 500 us, 3 -> 1 ms,
62 * 4 -> 5 ms, 5 -> 10 ms, 6 for 50 ms, 7 -> 100 ms)
67 * @i_drive: current limit value of the touchscreen drivers
68 * (0 -> 20 mA typical 35 mA max, 1 -> 50 mA typical 80 mA max)
103 int_sta = stmpe_reg_read(ts->stmpe, STMPE_REG_INT_STA); in stmpe_work()
113 timeout--; in stmpe_work()
114 int_sta = stmpe_reg_read(ts->stmpe, STMPE_REG_INT_STA); in stmpe_work()
119 __stmpe_reset_fifo(ts->stmpe); in stmpe_work()
121 input_report_abs(ts->idev, ABS_PRESSURE, 0); in stmpe_work()
122 input_report_key(ts->idev, BTN_TOUCH, 0); in stmpe_work()
123 input_sync(ts->idev); in stmpe_work()
136 cancel_delayed_work_sync(&ts->work); in stmpe_ts_handler()
144 stmpe_set_bits(ts->stmpe, STMPE_REG_TSC_CTRL, in stmpe_ts_handler()
147 stmpe_block_read(ts->stmpe, STMPE_REG_TSC_DATA_XYZ, 4, data_set); in stmpe_ts_handler()
153 input_report_abs(ts->idev, ABS_X, x); in stmpe_ts_handler()
154 input_report_abs(ts->idev, ABS_Y, y); in stmpe_ts_handler()
155 input_report_abs(ts->idev, ABS_PRESSURE, z); in stmpe_ts_handler()
156 input_report_key(ts->idev, BTN_TOUCH, 1); in stmpe_ts_handler()
157 input_sync(ts->idev); in stmpe_ts_handler()
160 __stmpe_reset_fifo(ts->stmpe); in stmpe_ts_handler()
163 stmpe_set_bits(ts->stmpe, STMPE_REG_TSC_CTRL, in stmpe_ts_handler()
167 schedule_delayed_work(&ts->work, msecs_to_jiffies(50)); in stmpe_ts_handler()
176 struct stmpe *stmpe = ts->stmpe; in stmpe_init_hw()
177 struct device *dev = ts->dev; in stmpe_init_hw()
191 tsc_cfg = STMPE_AVE_CTRL(ts->ave_ctrl) | in stmpe_init_hw()
192 STMPE_DET_DELAY(ts->touch_det_delay) | in stmpe_init_hw()
193 STMPE_SETTLING(ts->settling); in stmpe_init_hw()
204 STMPE_FRACTION_Z(0xff), STMPE_FRACTION_Z(ts->fraction_z)); in stmpe_init_hw()
211 STMPE_I_DRIVE(0xff), STMPE_I_DRIVE(ts->i_drive)); in stmpe_init_hw()
239 ret = __stmpe_reset_fifo(ts->stmpe); in stmpe_ts_open()
243 return stmpe_set_bits(ts->stmpe, STMPE_REG_TSC_CTRL, in stmpe_ts_open()
251 cancel_delayed_work_sync(&ts->work); in stmpe_ts_close()
253 stmpe_set_bits(ts->stmpe, STMPE_REG_TSC_CTRL, in stmpe_ts_close()
260 struct device_node *np = pdev->dev.of_node; in stmpe_ts_get_platform_info()
264 if (!of_property_read_u32(np, "st,sample-time", &val)) in stmpe_ts_get_platform_info()
265 ts->stmpe->sample_time = val; in stmpe_ts_get_platform_info()
266 if (!of_property_read_u32(np, "st,mod-12b", &val)) in stmpe_ts_get_platform_info()
267 ts->stmpe->mod_12b = val; in stmpe_ts_get_platform_info()
268 if (!of_property_read_u32(np, "st,ref-sel", &val)) in stmpe_ts_get_platform_info()
269 ts->stmpe->ref_sel = val; in stmpe_ts_get_platform_info()
270 if (!of_property_read_u32(np, "st,adc-freq", &val)) in stmpe_ts_get_platform_info()
271 ts->stmpe->adc_freq = val; in stmpe_ts_get_platform_info()
272 if (!of_property_read_u32(np, "st,ave-ctrl", &val)) in stmpe_ts_get_platform_info()
273 ts->ave_ctrl = val; in stmpe_ts_get_platform_info()
274 if (!of_property_read_u32(np, "st,touch-det-delay", &val)) in stmpe_ts_get_platform_info()
275 ts->touch_det_delay = val; in stmpe_ts_get_platform_info()
277 ts->settling = val; in stmpe_ts_get_platform_info()
278 if (!of_property_read_u32(np, "st,fraction-z", &val)) in stmpe_ts_get_platform_info()
279 ts->fraction_z = val; in stmpe_ts_get_platform_info()
280 if (!of_property_read_u32(np, "st,i-drive", &val)) in stmpe_ts_get_platform_info()
281 ts->i_drive = val; in stmpe_ts_get_platform_info()
287 struct stmpe *stmpe = dev_get_drvdata(pdev->dev.parent); in stmpe_input_probe()
297 ts = devm_kzalloc(&pdev->dev, sizeof(*ts), GFP_KERNEL); in stmpe_input_probe()
299 return -ENOMEM; in stmpe_input_probe()
301 idev = devm_input_allocate_device(&pdev->dev); in stmpe_input_probe()
303 return -ENOMEM; in stmpe_input_probe()
306 ts->stmpe = stmpe; in stmpe_input_probe()
307 ts->idev = idev; in stmpe_input_probe()
308 ts->dev = &pdev->dev; in stmpe_input_probe()
312 INIT_DELAYED_WORK(&ts->work, stmpe_work); in stmpe_input_probe()
314 error = devm_request_threaded_irq(&pdev->dev, ts_irq, in stmpe_input_probe()
318 dev_err(&pdev->dev, "Failed to request IRQ %d\n", ts_irq); in stmpe_input_probe()
326 idev->name = STMPE_TS_NAME; in stmpe_input_probe()
327 idev->phys = STMPE_TS_NAME"/input0"; in stmpe_input_probe()
328 idev->id.bustype = BUS_I2C; in stmpe_input_probe()
330 idev->open = stmpe_ts_open; in stmpe_input_probe()
331 idev->close = stmpe_ts_close; in stmpe_input_probe()
342 dev_err(&pdev->dev, "Could not register input device\n"); in stmpe_input_probe()
353 stmpe_disable(ts->stmpe, STMPE_BLOCK_TOUCHSCREEN); in stmpe_ts_remove()
368 { .compatible = "st,stmpe-ts", },
374 MODULE_DESCRIPTION("STMPEXXX touchscreen driver");