Lines Matching +full:adc +full:- +full:ts +full:- +full:wires
4 * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
35 #define MAX_12BIT ((1 << 12) - 1)
51 unsigned int wires; member
62 static unsigned int titsc_readl(struct titsc *ts, unsigned int reg) in titsc_readl() argument
64 return readl(ts->mfd_tscadc->tscadc_base + reg); in titsc_readl()
70 writel(val, tsc->mfd_tscadc->tscadc_base + reg); in titsc_writel()
81 * Get the order in which TSC wires are attached in titsc_config_wires()
84 analog_line[i] = (ts_dev->config_inp[i] & 0xF0) >> 4; in titsc_config_wires()
85 wire_order[i] = ts_dev->config_inp[i] & 0x0F; in titsc_config_wires()
87 return -EINVAL; in titsc_config_wires()
89 return -EINVAL; in titsc_config_wires()
100 return -EINVAL; in titsc_config_wires()
103 ts_dev->bit_xp = bit_cfg; in titsc_config_wires()
104 ts_dev->inp_xp = an_line; in titsc_config_wires()
108 ts_dev->bit_xn = bit_cfg; in titsc_config_wires()
109 ts_dev->inp_xn = an_line; in titsc_config_wires()
113 ts_dev->bit_yp = bit_cfg; in titsc_config_wires()
114 ts_dev->inp_yp = an_line; in titsc_config_wires()
117 ts_dev->bit_yn = bit_cfg; in titsc_config_wires()
118 ts_dev->inp_yn = an_line; in titsc_config_wires()
133 STEPCONFIG_AVG_16 | ts_dev->bit_xp | in titsc_step_config()
135 switch (ts_dev->wires) { in titsc_step_config()
137 config |= STEPCONFIG_INP(ts_dev->inp_yp) | ts_dev->bit_xn; in titsc_step_config()
140 config |= ts_dev->bit_yn | in titsc_step_config()
141 STEPCONFIG_INP_AN4 | ts_dev->bit_xn | in titsc_step_config()
142 ts_dev->bit_yp; in titsc_step_config()
145 config |= STEPCONFIG_INP(ts_dev->inp_yp) | ts_dev->bit_xn; in titsc_step_config()
149 tsc_steps = ts_dev->coordinate_readouts * 2 + 2; in titsc_step_config()
150 first_step = TOTAL_STEPS - tsc_steps; in titsc_step_config()
151 /* Steps 16 to 16-coordinate_readouts is for X */ in titsc_step_config()
154 for (i = end_step - ts_dev->coordinate_readouts; i < end_step; i++) { in titsc_step_config()
161 STEPCONFIG_AVG_16 | ts_dev->bit_yn | in titsc_step_config()
163 switch (ts_dev->wires) { in titsc_step_config()
165 config |= ts_dev->bit_yp | STEPCONFIG_INP(ts_dev->inp_xp); in titsc_step_config()
168 config |= ts_dev->bit_xp | STEPCONFIG_INP_AN4 | in titsc_step_config()
172 config |= ts_dev->bit_yp | STEPCONFIG_INP(ts_dev->inp_xp); in titsc_step_config()
177 end_step = first_step + ts_dev->coordinate_readouts; in titsc_step_config()
189 titsc_writel(ts_dev, REG_CHARGEDELAY, ts_dev->charge_delay); in titsc_step_config()
193 STEPCONFIG_AVG_16 | ts_dev->bit_yp | in titsc_step_config()
194 ts_dev->bit_xn | STEPCONFIG_INM_ADCREFM | in titsc_step_config()
195 STEPCONFIG_INP(ts_dev->inp_xp); in titsc_step_config()
202 STEPCONFIG_AVG_16 | ts_dev->bit_yp | in titsc_step_config()
203 ts_dev->bit_xn | STEPCONFIG_INM_ADCREFM | in titsc_step_config()
204 STEPCONFIG_INP(ts_dev->inp_yn); in titsc_step_config()
209 /* The steps end ... end - readouts * 2 + 2 and bit 0 for TS_Charge */ in titsc_step_config()
214 ts_dev->step_mask = stepenable; in titsc_step_config()
215 am335x_tsc_se_set_cache(ts_dev->mfd_tscadc, ts_dev->step_mask); in titsc_step_config()
220 return *(int *)a - *(int *)b; in titsc_cmp_coord()
228 unsigned int creads = ts_dev->coordinate_readouts; in titsc_read_coordinates()
246 * If co-ordinates readouts is less than 4 then in titsc_read_coordinates()
248 * readouts, sort the co-ordinate samples, drop in titsc_read_coordinates()
264 for (i = 1; i < creads - 1; i++) { in titsc_read_coordinates()
268 ysum /= creads - 2; in titsc_read_coordinates()
269 xsum /= creads - 2; in titsc_read_coordinates()
278 struct input_dev *input_dev = ts_dev->input; in titsc_irq()
285 ts_dev->pen_down = true; in titsc_irq()
287 pm_stay_awake(ts_dev->dev); in titsc_irq()
293 ts_dev->pen_down = false; in titsc_irq()
297 pm_relax(ts_dev->dev); in titsc_irq()
299 ts_dev->pen_down = true; in titsc_irq()
308 * ADC and touchscreen share the IRQ line. in titsc_irq()
309 * FIFO1 interrupts are used by ADC. Handle FIFO0 IRQs here only in titsc_irq()
315 if (ts_dev->pen_down && z1 != 0 && z2 != 0) { in titsc_irq()
319 * x position/4096 * ((z2 / z1) - 1) in titsc_irq()
321 z = z1 - z2; in titsc_irq()
323 z *= ts_dev->x_plate_resistance; in titsc_irq()
340 am335x_tsc_se_set_cache(ts_dev->mfd_tscadc, in titsc_irq()
341 ts_dev->step_mask); in titsc_irq()
350 struct device_node *node = pdev->dev.of_node; in titsc_parse_dt()
354 return -EINVAL; in titsc_parse_dt()
356 err = of_property_read_u32(node, "ti,wires", &ts_dev->wires); in titsc_parse_dt()
359 switch (ts_dev->wires) { in titsc_parse_dt()
365 return -EINVAL; in titsc_parse_dt()
368 err = of_property_read_u32(node, "ti,x-plate-resistance", in titsc_parse_dt()
369 &ts_dev->x_plate_resistance); in titsc_parse_dt()
375 * bogus, miss-spelled version. in titsc_parse_dt()
377 err = of_property_read_u32(node, "ti,coordinate-readouts", in titsc_parse_dt()
378 &ts_dev->coordinate_readouts); in titsc_parse_dt()
380 dev_warn(&pdev->dev, "please use 'ti,coordinate-readouts' instead\n"); in titsc_parse_dt()
381 err = of_property_read_u32(node, "ti,coordiante-readouts", in titsc_parse_dt()
382 &ts_dev->coordinate_readouts); in titsc_parse_dt()
388 if (ts_dev->coordinate_readouts <= 0) { in titsc_parse_dt()
389 dev_warn(&pdev->dev, in titsc_parse_dt()
390 "invalid co-ordinate readouts, resetting it to 5\n"); in titsc_parse_dt()
391 ts_dev->coordinate_readouts = 5; in titsc_parse_dt()
394 err = of_property_read_u32(node, "ti,charge-delay", in titsc_parse_dt()
395 &ts_dev->charge_delay); in titsc_parse_dt()
397 * If ti,charge-delay value is not specified, then use in titsc_parse_dt()
401 ts_dev->charge_delay = CHARGEDLY_OPENDLY; in titsc_parse_dt()
402 dev_warn(&pdev->dev, "ti,charge-delay not specified\n"); in titsc_parse_dt()
405 return of_property_read_u32_array(node, "ti,wire-config", in titsc_parse_dt()
406 ts_dev->config_inp, ARRAY_SIZE(ts_dev->config_inp)); in titsc_parse_dt()
424 dev_err(&pdev->dev, "failed to allocate memory.\n"); in titsc_probe()
425 err = -ENOMEM; in titsc_probe()
429 tscadc_dev->tsc = ts_dev; in titsc_probe()
430 ts_dev->mfd_tscadc = tscadc_dev; in titsc_probe()
431 ts_dev->input = input_dev; in titsc_probe()
432 ts_dev->irq = tscadc_dev->irq; in titsc_probe()
433 ts_dev->dev = &pdev->dev; in titsc_probe()
437 dev_err(&pdev->dev, "Could not find valid DT data.\n"); in titsc_probe()
441 err = request_irq(ts_dev->irq, titsc_irq, in titsc_probe()
442 IRQF_SHARED, pdev->dev.driver->name, ts_dev); in titsc_probe()
444 dev_err(&pdev->dev, "failed to allocate irq.\n"); in titsc_probe()
448 device_init_wakeup(&pdev->dev, true); in titsc_probe()
449 err = dev_pm_set_wake_irq(&pdev->dev, ts_dev->irq); in titsc_probe()
451 dev_err(&pdev->dev, "irq wake enable failed.\n"); in titsc_probe()
458 dev_err(&pdev->dev, "wrong i/p wire configuration\n"); in titsc_probe()
463 ts_dev->coordinate_readouts * 2 + 2 - 1); in titsc_probe()
465 input_dev->name = "ti-tsc"; in titsc_probe()
466 input_dev->dev.parent = &pdev->dev; in titsc_probe()
468 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); in titsc_probe()
469 input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); in titsc_probe()
484 dev_pm_clear_wake_irq(&pdev->dev); in titsc_probe()
485 device_init_wakeup(&pdev->dev, false); in titsc_probe()
486 free_irq(ts_dev->irq, ts_dev); in titsc_probe()
498 dev_pm_clear_wake_irq(&pdev->dev); in titsc_remove()
499 device_init_wakeup(&pdev->dev, false); in titsc_remove()
500 free_irq(ts_dev->irq, ts_dev); in titsc_remove()
503 steps = 2 * ts_dev->coordinate_readouts + 2; in titsc_remove()
504 steps = (1 << steps) - 1; in titsc_remove()
505 am335x_tsc_se_clr(ts_dev->mfd_tscadc, steps); in titsc_remove()
507 input_unregister_device(ts_dev->input); in titsc_remove()
539 ts_dev->coordinate_readouts * 2 + 2 - 1); in titsc_resume()
546 { .compatible = "ti,am3359-tsc", },
555 .name = "TI-am335x-tsc",