Lines Matching +full:touchscreen +full:- +full:fuzz +full:- +full:y
29 #define IPROC_TS_NAME "iproc-ts"
95 regmap_read(priv->regmap, reg, &val); \
100 /* Each step is 1024 us. Valid 1-256 */
103 /* Each step is 512 us. Valid 0-255 */
109 * drivers in detection mode. Valid values: 0-11
137 /* Optional standard touchscreen properties. */
174 struct device *dev = &priv->pdev->dev; in ts_reg_dump()
201 u16 y; in iproc_touchscreen_interrupt() local
205 regmap_read(priv->regmap, INTERRUPT_STATUS, &intr_status); in iproc_touchscreen_interrupt()
210 /* Clear all interrupt status bits, write-1-clear */ in iproc_touchscreen_interrupt()
211 regmap_write(priv->regmap, INTERRUPT_STATUS, intr_status); in iproc_touchscreen_interrupt()
214 regmap_read(priv->regmap, CONTROLLER_STATUS, &priv->pen_status); in iproc_touchscreen_interrupt()
215 if (priv->pen_status & TS_PEN_DOWN) in iproc_touchscreen_interrupt()
216 priv->pen_status = PEN_DOWN_STATUS; in iproc_touchscreen_interrupt()
218 priv->pen_status = PEN_UP_STATUS; in iproc_touchscreen_interrupt()
220 input_report_key(priv->idev, BTN_TOUCH, priv->pen_status); in iproc_touchscreen_interrupt()
223 dev_dbg(&priv->pdev->dev, in iproc_touchscreen_interrupt()
224 "pen up-down (%d)\n", priv->pen_status); in iproc_touchscreen_interrupt()
229 for (i = 0; i < priv->cfg_params.fifo_threshold; i++) { in iproc_touchscreen_interrupt()
230 regmap_read(priv->regmap, FIFO_DATA, &raw_coordinate); in iproc_touchscreen_interrupt()
235 * The x and y coordinate are 16 bits each in iproc_touchscreen_interrupt()
236 * with the x in the lower 16 bits and y in the in iproc_touchscreen_interrupt()
241 y = (raw_coordinate >> Y_COORD_SHIFT) & in iproc_touchscreen_interrupt()
246 y = (y >> 4) & 0x0FFF; in iproc_touchscreen_interrupt()
248 /* Adjust x y according to LCD tsc mount angle. */ in iproc_touchscreen_interrupt()
249 if (priv->cfg_params.invert_x) in iproc_touchscreen_interrupt()
250 x = priv->cfg_params.max_x - x; in iproc_touchscreen_interrupt()
252 if (priv->cfg_params.invert_y) in iproc_touchscreen_interrupt()
253 y = priv->cfg_params.max_y - y; in iproc_touchscreen_interrupt()
255 input_report_abs(priv->idev, ABS_X, x); in iproc_touchscreen_interrupt()
256 input_report_abs(priv->idev, ABS_Y, y); in iproc_touchscreen_interrupt()
259 dev_dbg(&priv->pdev->dev, "xy (0x%x 0x%x)\n", x, y); in iproc_touchscreen_interrupt()
264 input_sync(priv->idev); in iproc_touchscreen_interrupt()
277 error = clk_prepare_enable(priv->tsc_clk); in iproc_ts_start()
279 dev_err(&priv->pdev->dev, "%s clk_prepare_enable failed %d\n", in iproc_ts_start()
289 regmap_update_bits(priv->regmap, INTERRUPT_MASK, val, val); in iproc_ts_start()
291 val = priv->cfg_params.fifo_threshold; in iproc_ts_start()
292 regmap_write(priv->regmap, INTERRUPT_THRES, val); in iproc_ts_start()
296 val |= priv->cfg_params.scanning_period << SCANNING_PERIOD_SHIFT; in iproc_ts_start()
297 val |= priv->cfg_params.debounce_timeout << DEBOUNCE_TIMEOUT_SHIFT; in iproc_ts_start()
298 val |= priv->cfg_params.settling_timeout << SETTLING_TIMEOUT_SHIFT; in iproc_ts_start()
299 val |= priv->cfg_params.touch_timeout << TOUCH_TIMEOUT_SHIFT; in iproc_ts_start()
300 regmap_write(priv->regmap, REGCTL1, val); in iproc_ts_start()
304 regmap_update_bits(priv->regmap, INTERRUPT_STATUS, val, val); in iproc_ts_start()
308 val |= priv->cfg_params.average_data << TS_CONTROLLER_AVGDATA_SHIFT; in iproc_ts_start()
316 regmap_update_bits(priv->regmap, REGCTL2, mask, val); in iproc_ts_start()
334 regmap_update_bits(priv->regmap, INTERRUPT_MASK, val, 0); in iproc_ts_stop()
338 regmap_update_bits(priv->regmap, REGCTL2, val, val); in iproc_ts_stop()
340 clk_disable(priv->tsc_clk); in iproc_ts_stop()
345 struct device_node *np = dev->of_node; in iproc_get_tsc_config()
348 priv->cfg_params = iproc_default_config; in iproc_get_tsc_config()
355 dev_err(dev, "scanning_period (%u) must be [1-256]\n", in iproc_get_tsc_config()
357 return -EINVAL; in iproc_get_tsc_config()
359 priv->cfg_params.scanning_period = val; in iproc_get_tsc_config()
364 dev_err(dev, "debounce_timeout (%u) must be [0-255]\n", in iproc_get_tsc_config()
366 return -EINVAL; in iproc_get_tsc_config()
368 priv->cfg_params.debounce_timeout = val; in iproc_get_tsc_config()
373 dev_err(dev, "settling_timeout (%u) must be [0-11]\n", in iproc_get_tsc_config()
375 return -EINVAL; in iproc_get_tsc_config()
377 priv->cfg_params.settling_timeout = val; in iproc_get_tsc_config()
382 dev_err(dev, "touch_timeout (%u) must be [0-255]\n", in iproc_get_tsc_config()
384 return -EINVAL; in iproc_get_tsc_config()
386 priv->cfg_params.touch_timeout = val; in iproc_get_tsc_config()
391 dev_err(dev, "average_data (%u) must be [0-8]\n", val); in iproc_get_tsc_config()
392 return -EINVAL; in iproc_get_tsc_config()
394 priv->cfg_params.average_data = val; in iproc_get_tsc_config()
399 dev_err(dev, "fifo_threshold (%u)) must be [0-31]\n", in iproc_get_tsc_config()
401 return -EINVAL; in iproc_get_tsc_config()
403 priv->cfg_params.fifo_threshold = val; in iproc_get_tsc_config()
407 of_property_read_u32(np, "touchscreen-size-x", &priv->cfg_params.max_x); in iproc_get_tsc_config()
408 of_property_read_u32(np, "touchscreen-size-y", &priv->cfg_params.max_y); in iproc_get_tsc_config()
410 of_property_read_u32(np, "touchscreen-fuzz-x", in iproc_get_tsc_config()
411 &priv->cfg_params.fuzz_x); in iproc_get_tsc_config()
412 of_property_read_u32(np, "touchscreen-fuzz-y", in iproc_get_tsc_config()
413 &priv->cfg_params.fuzz_y); in iproc_get_tsc_config()
415 priv->cfg_params.invert_x = in iproc_get_tsc_config()
416 of_property_read_bool(np, "touchscreen-inverted-x"); in iproc_get_tsc_config()
417 priv->cfg_params.invert_y = in iproc_get_tsc_config()
418 of_property_read_bool(np, "touchscreen-inverted-y"); in iproc_get_tsc_config()
430 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); in iproc_ts_probe()
432 return -ENOMEM; in iproc_ts_probe()
434 /* touchscreen controller memory mapped regs via syscon*/ in iproc_ts_probe()
435 priv->regmap = syscon_regmap_lookup_by_phandle(pdev->dev.of_node, in iproc_ts_probe()
437 if (IS_ERR(priv->regmap)) { in iproc_ts_probe()
438 error = PTR_ERR(priv->regmap); in iproc_ts_probe()
439 dev_err(&pdev->dev, "unable to map I/O memory:%d\n", error); in iproc_ts_probe()
443 priv->tsc_clk = devm_clk_get(&pdev->dev, "tsc_clk"); in iproc_ts_probe()
444 if (IS_ERR(priv->tsc_clk)) { in iproc_ts_probe()
445 error = PTR_ERR(priv->tsc_clk); in iproc_ts_probe()
446 dev_err(&pdev->dev, in iproc_ts_probe()
451 priv->pdev = pdev; in iproc_ts_probe()
452 error = iproc_get_tsc_config(&pdev->dev, priv); in iproc_ts_probe()
454 dev_err(&pdev->dev, "get_tsc_config failed: %d\n", error); in iproc_ts_probe()
458 idev = devm_input_allocate_device(&pdev->dev); in iproc_ts_probe()
460 dev_err(&pdev->dev, "failed to allocate input device\n"); in iproc_ts_probe()
461 return -ENOMEM; in iproc_ts_probe()
464 priv->idev = idev; in iproc_ts_probe()
465 priv->pen_status = PEN_UP_STATUS; in iproc_ts_probe()
468 idev->name = IPROC_TS_NAME; in iproc_ts_probe()
469 idev->dev.parent = &pdev->dev; in iproc_ts_probe()
471 idev->id.bustype = BUS_HOST; in iproc_ts_probe()
472 idev->id.vendor = SERIO_UNKNOWN; in iproc_ts_probe()
473 idev->id.product = 0; in iproc_ts_probe()
474 idev->id.version = 0; in iproc_ts_probe()
476 idev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); in iproc_ts_probe()
477 __set_bit(BTN_TOUCH, idev->keybit); in iproc_ts_probe()
479 input_set_abs_params(idev, ABS_X, X_MIN, priv->cfg_params.max_x, in iproc_ts_probe()
480 priv->cfg_params.fuzz_x, 0); in iproc_ts_probe()
481 input_set_abs_params(idev, ABS_Y, Y_MIN, priv->cfg_params.max_y, in iproc_ts_probe()
482 priv->cfg_params.fuzz_y, 0); in iproc_ts_probe()
484 idev->open = iproc_ts_start; in iproc_ts_probe()
485 idev->close = iproc_ts_stop; in iproc_ts_probe()
495 error = devm_request_irq(&pdev->dev, irq, in iproc_ts_probe()
501 error = input_register_device(priv->idev); in iproc_ts_probe()
503 dev_err(&pdev->dev, in iproc_ts_probe()
512 {.compatible = "brcm,iproc-touchscreen", },
527 MODULE_DESCRIPTION("IPROC Touchscreen driver");