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

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * STMicroelectronics STMPE811 Touchscreen Driver
17 #include <linux/input/touchscreen.h>
26 * with touchscreen controller
46 #define STMPE_TS_NAME "stmpe-ts"
50 * struct stmpe_touch - stmpe811 touch screen controller state
55 * @prop: Touchscreen properties
56 * @ave_ctrl: Sample average control
57 * (0 -> 1 sample, 1 -> 2 samples, 2 -> 4 samples, 3 -> 8 samples)
59 * (0 -> 10 us, 1 -> 50 us, 2 -> 100 us, 3 -> 500 us,
60 * 4-> 1 ms, 5 -> 5 ms, 6 -> 10 ms, 7 -> 50 ms)
63 * (0 -> 10 us, 1 -> 100 us, 2 -> 500 us, 3 -> 1 ms,
64 * 4 -> 5 ms, 5 -> 10 ms, 6 for 50 ms, 7 -> 100 ms)
69 * @i_drive: current limit value of the touchscreen drivers
70 * (0 -> 20 mA typical 35 mA max, 1 -> 50 mA typical 80 mA max)
106 int_sta = stmpe_reg_read(ts->stmpe, STMPE_REG_INT_STA); in stmpe_work()
116 timeout--; in stmpe_work()
117 int_sta = stmpe_reg_read(ts->stmpe, STMPE_REG_INT_STA); in stmpe_work()
122 __stmpe_reset_fifo(ts->stmpe); in stmpe_work()
124 input_report_abs(ts->idev, ABS_PRESSURE, 0); in stmpe_work()
125 input_report_key(ts->idev, BTN_TOUCH, 0); in stmpe_work()
126 input_sync(ts->idev); in stmpe_work()
139 cancel_delayed_work_sync(&ts->work); in stmpe_ts_handler()
147 stmpe_set_bits(ts->stmpe, STMPE_REG_TSC_CTRL, in stmpe_ts_handler()
150 stmpe_block_read(ts->stmpe, STMPE_REG_TSC_DATA_XYZ, 4, data_set); in stmpe_ts_handler()
156 touchscreen_report_pos(ts->idev, &ts->prop, x, y, false); in stmpe_ts_handler()
157 input_report_abs(ts->idev, ABS_PRESSURE, z); in stmpe_ts_handler()
158 input_report_key(ts->idev, BTN_TOUCH, 1); in stmpe_ts_handler()
159 input_sync(ts->idev); in stmpe_ts_handler()
162 __stmpe_reset_fifo(ts->stmpe); in stmpe_ts_handler()
165 stmpe_set_bits(ts->stmpe, STMPE_REG_TSC_CTRL, in stmpe_ts_handler()
169 schedule_delayed_work(&ts->work, msecs_to_jiffies(50)); in stmpe_ts_handler()
178 struct stmpe *stmpe = ts->stmpe; in stmpe_init_hw()
179 struct device *dev = ts->dev; in stmpe_init_hw()
193 tsc_cfg = STMPE_AVE_CTRL(ts->ave_ctrl) | in stmpe_init_hw()
194 STMPE_DET_DELAY(ts->touch_det_delay) | in stmpe_init_hw()
195 STMPE_SETTLING(ts->settling); in stmpe_init_hw()
206 STMPE_FRACTION_Z(0xff), STMPE_FRACTION_Z(ts->fraction_z)); in stmpe_init_hw()
213 STMPE_I_DRIVE(0xff), STMPE_I_DRIVE(ts->i_drive)); in stmpe_init_hw()
241 ret = __stmpe_reset_fifo(ts->stmpe); in stmpe_ts_open()
245 return stmpe_set_bits(ts->stmpe, STMPE_REG_TSC_CTRL, in stmpe_ts_open()
253 cancel_delayed_work_sync(&ts->work); in stmpe_ts_close()
255 stmpe_set_bits(ts->stmpe, STMPE_REG_TSC_CTRL, in stmpe_ts_close()
262 struct device_node *np = pdev->dev.of_node; in stmpe_ts_get_platform_info()
266 if (!of_property_read_u32(np, "st,sample-time", &val)) in stmpe_ts_get_platform_info()
267 ts->stmpe->sample_time = val; in stmpe_ts_get_platform_info()
268 if (!of_property_read_u32(np, "st,mod-12b", &val)) in stmpe_ts_get_platform_info()
269 ts->stmpe->mod_12b = val; in stmpe_ts_get_platform_info()
270 if (!of_property_read_u32(np, "st,ref-sel", &val)) in stmpe_ts_get_platform_info()
271 ts->stmpe->ref_sel = val; in stmpe_ts_get_platform_info()
272 if (!of_property_read_u32(np, "st,adc-freq", &val)) in stmpe_ts_get_platform_info()
273 ts->stmpe->adc_freq = val; in stmpe_ts_get_platform_info()
274 if (!of_property_read_u32(np, "st,ave-ctrl", &val)) in stmpe_ts_get_platform_info()
275 ts->ave_ctrl = val; in stmpe_ts_get_platform_info()
276 if (!of_property_read_u32(np, "st,touch-det-delay", &val)) in stmpe_ts_get_platform_info()
277 ts->touch_det_delay = val; in stmpe_ts_get_platform_info()
279 ts->settling = val; in stmpe_ts_get_platform_info()
280 if (!of_property_read_u32(np, "st,fraction-z", &val)) in stmpe_ts_get_platform_info()
281 ts->fraction_z = val; in stmpe_ts_get_platform_info()
282 if (!of_property_read_u32(np, "st,i-drive", &val)) in stmpe_ts_get_platform_info()
283 ts->i_drive = val; in stmpe_ts_get_platform_info()
289 struct stmpe *stmpe = dev_get_drvdata(pdev->dev.parent); in stmpe_input_probe()
299 ts = devm_kzalloc(&pdev->dev, sizeof(*ts), GFP_KERNEL); in stmpe_input_probe()
301 return -ENOMEM; in stmpe_input_probe()
303 idev = devm_input_allocate_device(&pdev->dev); in stmpe_input_probe()
305 return -ENOMEM; in stmpe_input_probe()
308 ts->stmpe = stmpe; in stmpe_input_probe()
309 ts->idev = idev; in stmpe_input_probe()
310 ts->dev = &pdev->dev; in stmpe_input_probe()
314 INIT_DELAYED_WORK(&ts->work, stmpe_work); in stmpe_input_probe()
316 error = devm_request_threaded_irq(&pdev->dev, ts_irq, in stmpe_input_probe()
320 dev_err(&pdev->dev, "Failed to request IRQ %d\n", ts_irq); in stmpe_input_probe()
328 idev->name = STMPE_TS_NAME; in stmpe_input_probe()
329 idev->phys = STMPE_TS_NAME"/input0"; in stmpe_input_probe()
330 idev->id.bustype = BUS_I2C; in stmpe_input_probe()
332 idev->open = stmpe_ts_open; in stmpe_input_probe()
333 idev->close = stmpe_ts_close; in stmpe_input_probe()
342 touchscreen_parse_properties(idev, false, &ts->prop); in stmpe_input_probe()
346 dev_err(&pdev->dev, "Could not register input device\n"); in stmpe_input_probe()
357 stmpe_disable(ts->stmpe, STMPE_BLOCK_TOUCHSCREEN); in stmpe_ts_remove()
370 { .compatible = "st,stmpe-ts", },
376 MODULE_DESCRIPTION("STMPEXXX touchscreen driver");