Lines Matching +full:touchscreen +full:- +full:fuzz +full:- +full:y

1 // SPDX-License-Identifier: GPL-2.0-only
22 #define IPROC_TS_NAME "iproc-ts"
88 regmap_read(priv->regmap, reg, &val); \
93 /* Each step is 1024 us. Valid 1-256 */
96 /* Each step is 512 us. Valid 0-255 */
102 * drivers in detection mode. Valid values: 0-11
130 /* Optional standard touchscreen properties. */
167 struct device *dev = &priv->pdev->dev; in ts_reg_dump()
194 u16 y; in iproc_touchscreen_interrupt() local
198 regmap_read(priv->regmap, INTERRUPT_STATUS, &intr_status); in iproc_touchscreen_interrupt()
203 /* Clear all interrupt status bits, write-1-clear */ in iproc_touchscreen_interrupt()
204 regmap_write(priv->regmap, INTERRUPT_STATUS, intr_status); in iproc_touchscreen_interrupt()
207 regmap_read(priv->regmap, CONTROLLER_STATUS, &priv->pen_status); in iproc_touchscreen_interrupt()
208 if (priv->pen_status & TS_PEN_DOWN) in iproc_touchscreen_interrupt()
209 priv->pen_status = PEN_DOWN_STATUS; in iproc_touchscreen_interrupt()
211 priv->pen_status = PEN_UP_STATUS; in iproc_touchscreen_interrupt()
213 input_report_key(priv->idev, BTN_TOUCH, priv->pen_status); in iproc_touchscreen_interrupt()
216 dev_dbg(&priv->pdev->dev, in iproc_touchscreen_interrupt()
217 "pen up-down (%d)\n", priv->pen_status); in iproc_touchscreen_interrupt()
222 for (i = 0; i < priv->cfg_params.fifo_threshold; i++) { in iproc_touchscreen_interrupt()
223 regmap_read(priv->regmap, FIFO_DATA, &raw_coordinate); in iproc_touchscreen_interrupt()
228 * The x and y coordinate are 16 bits each in iproc_touchscreen_interrupt()
229 * with the x in the lower 16 bits and y in the in iproc_touchscreen_interrupt()
234 y = (raw_coordinate >> Y_COORD_SHIFT) & in iproc_touchscreen_interrupt()
239 y = (y >> 4) & 0x0FFF; in iproc_touchscreen_interrupt()
241 /* Adjust x y according to LCD tsc mount angle. */ in iproc_touchscreen_interrupt()
242 if (priv->cfg_params.invert_x) in iproc_touchscreen_interrupt()
243 x = priv->cfg_params.max_x - x; in iproc_touchscreen_interrupt()
245 if (priv->cfg_params.invert_y) in iproc_touchscreen_interrupt()
246 y = priv->cfg_params.max_y - y; in iproc_touchscreen_interrupt()
248 input_report_abs(priv->idev, ABS_X, x); in iproc_touchscreen_interrupt()
249 input_report_abs(priv->idev, ABS_Y, y); in iproc_touchscreen_interrupt()
252 dev_dbg(&priv->pdev->dev, "xy (0x%x 0x%x)\n", x, y); in iproc_touchscreen_interrupt()
257 input_sync(priv->idev); in iproc_touchscreen_interrupt()
270 error = clk_prepare_enable(priv->tsc_clk); in iproc_ts_start()
272 dev_err(&priv->pdev->dev, "%s clk_prepare_enable failed %d\n", in iproc_ts_start()
282 regmap_update_bits(priv->regmap, INTERRUPT_MASK, val, val); in iproc_ts_start()
284 val = priv->cfg_params.fifo_threshold; in iproc_ts_start()
285 regmap_write(priv->regmap, INTERRUPT_THRES, val); in iproc_ts_start()
289 val |= priv->cfg_params.scanning_period << SCANNING_PERIOD_SHIFT; in iproc_ts_start()
290 val |= priv->cfg_params.debounce_timeout << DEBOUNCE_TIMEOUT_SHIFT; in iproc_ts_start()
291 val |= priv->cfg_params.settling_timeout << SETTLING_TIMEOUT_SHIFT; in iproc_ts_start()
292 val |= priv->cfg_params.touch_timeout << TOUCH_TIMEOUT_SHIFT; in iproc_ts_start()
293 regmap_write(priv->regmap, REGCTL1, val); in iproc_ts_start()
297 regmap_update_bits(priv->regmap, INTERRUPT_STATUS, val, val); in iproc_ts_start()
301 val |= priv->cfg_params.average_data << TS_CONTROLLER_AVGDATA_SHIFT; in iproc_ts_start()
309 regmap_update_bits(priv->regmap, REGCTL2, mask, val); in iproc_ts_start()
327 regmap_update_bits(priv->regmap, INTERRUPT_MASK, val, 0); in iproc_ts_stop()
331 regmap_update_bits(priv->regmap, REGCTL2, val, val); in iproc_ts_stop()
333 clk_disable(priv->tsc_clk); in iproc_ts_stop()
338 struct device_node *np = dev->of_node; in iproc_get_tsc_config()
341 priv->cfg_params = iproc_default_config; in iproc_get_tsc_config()
348 dev_err(dev, "scanning_period (%u) must be [1-256]\n", in iproc_get_tsc_config()
350 return -EINVAL; in iproc_get_tsc_config()
352 priv->cfg_params.scanning_period = val; in iproc_get_tsc_config()
357 dev_err(dev, "debounce_timeout (%u) must be [0-255]\n", in iproc_get_tsc_config()
359 return -EINVAL; in iproc_get_tsc_config()
361 priv->cfg_params.debounce_timeout = val; in iproc_get_tsc_config()
366 dev_err(dev, "settling_timeout (%u) must be [0-11]\n", in iproc_get_tsc_config()
368 return -EINVAL; in iproc_get_tsc_config()
370 priv->cfg_params.settling_timeout = val; in iproc_get_tsc_config()
375 dev_err(dev, "touch_timeout (%u) must be [0-255]\n", in iproc_get_tsc_config()
377 return -EINVAL; in iproc_get_tsc_config()
379 priv->cfg_params.touch_timeout = val; in iproc_get_tsc_config()
384 dev_err(dev, "average_data (%u) must be [0-8]\n", val); in iproc_get_tsc_config()
385 return -EINVAL; in iproc_get_tsc_config()
387 priv->cfg_params.average_data = val; in iproc_get_tsc_config()
392 dev_err(dev, "fifo_threshold (%u)) must be [0-31]\n", in iproc_get_tsc_config()
394 return -EINVAL; in iproc_get_tsc_config()
396 priv->cfg_params.fifo_threshold = val; in iproc_get_tsc_config()
400 of_property_read_u32(np, "touchscreen-size-x", &priv->cfg_params.max_x); in iproc_get_tsc_config()
401 of_property_read_u32(np, "touchscreen-size-y", &priv->cfg_params.max_y); in iproc_get_tsc_config()
403 of_property_read_u32(np, "touchscreen-fuzz-x", in iproc_get_tsc_config()
404 &priv->cfg_params.fuzz_x); in iproc_get_tsc_config()
405 of_property_read_u32(np, "touchscreen-fuzz-y", in iproc_get_tsc_config()
406 &priv->cfg_params.fuzz_y); in iproc_get_tsc_config()
408 priv->cfg_params.invert_x = in iproc_get_tsc_config()
409 of_property_read_bool(np, "touchscreen-inverted-x"); in iproc_get_tsc_config()
410 priv->cfg_params.invert_y = in iproc_get_tsc_config()
411 of_property_read_bool(np, "touchscreen-inverted-y"); in iproc_get_tsc_config()
423 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); in iproc_ts_probe()
425 return -ENOMEM; in iproc_ts_probe()
427 /* touchscreen controller memory mapped regs via syscon*/ in iproc_ts_probe()
428 priv->regmap = syscon_regmap_lookup_by_phandle(pdev->dev.of_node, in iproc_ts_probe()
430 if (IS_ERR(priv->regmap)) { in iproc_ts_probe()
431 error = PTR_ERR(priv->regmap); in iproc_ts_probe()
432 dev_err(&pdev->dev, "unable to map I/O memory:%d\n", error); in iproc_ts_probe()
436 priv->tsc_clk = devm_clk_get(&pdev->dev, "tsc_clk"); in iproc_ts_probe()
437 if (IS_ERR(priv->tsc_clk)) { in iproc_ts_probe()
438 error = PTR_ERR(priv->tsc_clk); in iproc_ts_probe()
439 dev_err(&pdev->dev, in iproc_ts_probe()
444 priv->pdev = pdev; in iproc_ts_probe()
445 error = iproc_get_tsc_config(&pdev->dev, priv); in iproc_ts_probe()
447 dev_err(&pdev->dev, "get_tsc_config failed: %d\n", error); in iproc_ts_probe()
451 idev = devm_input_allocate_device(&pdev->dev); in iproc_ts_probe()
453 dev_err(&pdev->dev, "failed to allocate input device\n"); in iproc_ts_probe()
454 return -ENOMEM; in iproc_ts_probe()
457 priv->idev = idev; in iproc_ts_probe()
458 priv->pen_status = PEN_UP_STATUS; in iproc_ts_probe()
461 idev->name = IPROC_TS_NAME; in iproc_ts_probe()
462 idev->dev.parent = &pdev->dev; in iproc_ts_probe()
464 idev->id.bustype = BUS_HOST; in iproc_ts_probe()
465 idev->id.vendor = SERIO_UNKNOWN; in iproc_ts_probe()
466 idev->id.product = 0; in iproc_ts_probe()
467 idev->id.version = 0; in iproc_ts_probe()
469 idev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); in iproc_ts_probe()
470 __set_bit(BTN_TOUCH, idev->keybit); in iproc_ts_probe()
472 input_set_abs_params(idev, ABS_X, X_MIN, priv->cfg_params.max_x, in iproc_ts_probe()
473 priv->cfg_params.fuzz_x, 0); in iproc_ts_probe()
474 input_set_abs_params(idev, ABS_Y, Y_MIN, priv->cfg_params.max_y, in iproc_ts_probe()
475 priv->cfg_params.fuzz_y, 0); in iproc_ts_probe()
477 idev->open = iproc_ts_start; in iproc_ts_probe()
478 idev->close = iproc_ts_stop; in iproc_ts_probe()
488 error = devm_request_irq(&pdev->dev, irq, in iproc_ts_probe()
494 error = input_register_device(priv->idev); in iproc_ts_probe()
496 dev_err(&pdev->dev, in iproc_ts_probe()
505 {.compatible = "brcm,iproc-touchscreen", },
520 MODULE_DESCRIPTION("IPROC Touchscreen driver");