Lines Matching +full:am3359 +full:- +full:adc

4  * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
36 #define MAX_12BIT ((1 << 12) - 1)
65 return readl(ts->mfd_tscadc->tscadc_base + reg); in titsc_readl()
71 writel(val, tsc->mfd_tscadc->tscadc_base + reg); in titsc_writel()
85 analog_line[i] = (ts_dev->config_inp[i] & 0xF0) >> 4; in titsc_config_wires()
86 wire_order[i] = ts_dev->config_inp[i] & 0x0F; in titsc_config_wires()
88 return -EINVAL; in titsc_config_wires()
90 return -EINVAL; in titsc_config_wires()
101 return -EINVAL; in titsc_config_wires()
104 ts_dev->bit_xp = bit_cfg; in titsc_config_wires()
105 ts_dev->inp_xp = an_line; in titsc_config_wires()
109 ts_dev->bit_xn = bit_cfg; in titsc_config_wires()
110 ts_dev->inp_xn = an_line; in titsc_config_wires()
114 ts_dev->bit_yp = bit_cfg; in titsc_config_wires()
115 ts_dev->inp_yp = an_line; in titsc_config_wires()
118 ts_dev->bit_yn = bit_cfg; in titsc_config_wires()
119 ts_dev->inp_yn = an_line; in titsc_config_wires()
134 STEPCONFIG_AVG_16 | ts_dev->bit_xp | in titsc_step_config()
136 switch (ts_dev->wires) { in titsc_step_config()
138 config |= STEPCONFIG_INP(ts_dev->inp_yp) | ts_dev->bit_xn; in titsc_step_config()
141 config |= ts_dev->bit_yn | in titsc_step_config()
142 STEPCONFIG_INP_AN4 | ts_dev->bit_xn | in titsc_step_config()
143 ts_dev->bit_yp; in titsc_step_config()
146 config |= STEPCONFIG_INP(ts_dev->inp_yp) | ts_dev->bit_xn; in titsc_step_config()
150 tsc_steps = ts_dev->coordinate_readouts * 2 + 2; in titsc_step_config()
151 first_step = TOTAL_STEPS - tsc_steps; in titsc_step_config()
152 /* Steps 16 to 16-coordinate_readouts is for X */ in titsc_step_config()
155 for (i = end_step - ts_dev->coordinate_readouts; i < end_step; i++) { in titsc_step_config()
163 STEPCONFIG_AVG_16 | ts_dev->bit_yn | in titsc_step_config()
165 switch (ts_dev->wires) { in titsc_step_config()
167 config |= ts_dev->bit_yp | STEPCONFIG_INP(ts_dev->inp_xp); in titsc_step_config()
170 config |= ts_dev->bit_xp | STEPCONFIG_INP_AN4 | in titsc_step_config()
174 config |= ts_dev->bit_yp | STEPCONFIG_INP(ts_dev->inp_xp); in titsc_step_config()
179 end_step = first_step + ts_dev->coordinate_readouts; in titsc_step_config()
191 titsc_writel(ts_dev, REG_CHARGEDELAY, ts_dev->charge_delay); in titsc_step_config()
195 STEPCONFIG_AVG_16 | ts_dev->bit_yp | in titsc_step_config()
196 ts_dev->bit_xn | STEPCONFIG_INM_ADCREFM | in titsc_step_config()
197 STEPCONFIG_INP(ts_dev->inp_xp); in titsc_step_config()
204 STEPCONFIG_AVG_16 | ts_dev->bit_yp | in titsc_step_config()
205 ts_dev->bit_xn | STEPCONFIG_INM_ADCREFM | in titsc_step_config()
206 STEPCONFIG_INP(ts_dev->inp_yn); in titsc_step_config()
211 /* The steps end ... end - readouts * 2 + 2 and bit 0 for TS_Charge */ in titsc_step_config()
216 ts_dev->step_mask = stepenable; in titsc_step_config()
217 am335x_tsc_se_set_cache(ts_dev->mfd_tscadc, ts_dev->step_mask); in titsc_step_config()
222 return *(int *)a - *(int *)b; in titsc_cmp_coord()
230 unsigned int creads = ts_dev->coordinate_readouts; in titsc_read_coordinates()
248 * If co-ordinates readouts is less than 4 then in titsc_read_coordinates()
250 * readouts, sort the co-ordinate samples, drop in titsc_read_coordinates()
266 for (i = 1; i < creads - 1; i++) { in titsc_read_coordinates()
270 ysum /= creads - 2; in titsc_read_coordinates()
271 xsum /= creads - 2; in titsc_read_coordinates()
280 struct input_dev *input_dev = ts_dev->input; in titsc_irq()
287 ts_dev->pen_down = true; in titsc_irq()
289 pm_stay_awake(ts_dev->dev); in titsc_irq()
295 ts_dev->pen_down = false; in titsc_irq()
299 pm_relax(ts_dev->dev); in titsc_irq()
301 ts_dev->pen_down = true; in titsc_irq()
310 * ADC and touchscreen share the IRQ line. in titsc_irq()
311 * FIFO1 interrupts are used by ADC. Handle FIFO0 IRQs here only in titsc_irq()
317 if (ts_dev->pen_down && z1 != 0 && z2 != 0) { in titsc_irq()
321 * x position/4096 * ((z2 / z1) - 1) in titsc_irq()
323 z = z1 - z2; in titsc_irq()
325 z *= ts_dev->x_plate_resistance; in titsc_irq()
342 am335x_tsc_se_set_cache(ts_dev->mfd_tscadc, in titsc_irq()
343 ts_dev->step_mask); in titsc_irq()
352 struct device_node *node = pdev->dev.of_node; in titsc_parse_dt()
356 return -EINVAL; in titsc_parse_dt()
358 err = of_property_read_u32(node, "ti,wires", &ts_dev->wires); in titsc_parse_dt()
361 switch (ts_dev->wires) { in titsc_parse_dt()
367 return -EINVAL; in titsc_parse_dt()
370 err = of_property_read_u32(node, "ti,x-plate-resistance", in titsc_parse_dt()
371 &ts_dev->x_plate_resistance); in titsc_parse_dt()
377 * bogus, miss-spelled version. in titsc_parse_dt()
379 err = of_property_read_u32(node, "ti,coordinate-readouts", in titsc_parse_dt()
380 &ts_dev->coordinate_readouts); in titsc_parse_dt()
382 dev_warn(&pdev->dev, "please use 'ti,coordinate-readouts' instead\n"); in titsc_parse_dt()
383 err = of_property_read_u32(node, "ti,coordiante-readouts", in titsc_parse_dt()
384 &ts_dev->coordinate_readouts); in titsc_parse_dt()
390 if (ts_dev->coordinate_readouts <= 0) { in titsc_parse_dt()
391 dev_warn(&pdev->dev, in titsc_parse_dt()
392 "invalid co-ordinate readouts, resetting it to 5\n"); in titsc_parse_dt()
393 ts_dev->coordinate_readouts = 5; in titsc_parse_dt()
396 err = of_property_read_u32(node, "ti,charge-delay", in titsc_parse_dt()
397 &ts_dev->charge_delay); in titsc_parse_dt()
399 * If ti,charge-delay value is not specified, then use in titsc_parse_dt()
403 ts_dev->charge_delay = CHARGEDLY_OPENDLY; in titsc_parse_dt()
404 dev_warn(&pdev->dev, "ti,charge-delay not specified\n"); in titsc_parse_dt()
407 return of_property_read_u32_array(node, "ti,wire-config", in titsc_parse_dt()
408 ts_dev->config_inp, ARRAY_SIZE(ts_dev->config_inp)); in titsc_parse_dt()
426 dev_err(&pdev->dev, "failed to allocate memory.\n"); in titsc_probe()
427 err = -ENOMEM; in titsc_probe()
431 tscadc_dev->tsc = ts_dev; in titsc_probe()
432 ts_dev->mfd_tscadc = tscadc_dev; in titsc_probe()
433 ts_dev->input = input_dev; in titsc_probe()
434 ts_dev->irq = tscadc_dev->irq; in titsc_probe()
435 ts_dev->dev = &pdev->dev; in titsc_probe()
439 dev_err(&pdev->dev, "Could not find valid DT data.\n"); in titsc_probe()
443 err = request_irq(ts_dev->irq, titsc_irq, in titsc_probe()
444 IRQF_SHARED, pdev->dev.driver->name, ts_dev); in titsc_probe()
446 dev_err(&pdev->dev, "failed to allocate irq.\n"); in titsc_probe()
450 device_init_wakeup(&pdev->dev, true); in titsc_probe()
451 err = dev_pm_set_wake_irq(&pdev->dev, ts_dev->irq); in titsc_probe()
453 dev_err(&pdev->dev, "irq wake enable failed.\n"); in titsc_probe()
460 dev_err(&pdev->dev, "wrong i/p wire configuration\n"); in titsc_probe()
465 ts_dev->coordinate_readouts * 2 + 2 - 1); in titsc_probe()
467 input_dev->name = "ti-tsc"; in titsc_probe()
468 input_dev->dev.parent = &pdev->dev; in titsc_probe()
470 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); in titsc_probe()
471 input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); in titsc_probe()
486 dev_pm_clear_wake_irq(&pdev->dev); in titsc_probe()
487 device_init_wakeup(&pdev->dev, false); in titsc_probe()
488 free_irq(ts_dev->irq, ts_dev); in titsc_probe()
500 dev_pm_clear_wake_irq(&pdev->dev); in titsc_remove()
501 device_init_wakeup(&pdev->dev, false); in titsc_remove()
502 free_irq(ts_dev->irq, ts_dev); in titsc_remove()
505 steps = 2 * ts_dev->coordinate_readouts + 2; in titsc_remove()
506 steps = (1 << steps) - 1; in titsc_remove()
507 am335x_tsc_se_clr(ts_dev->mfd_tscadc, steps); in titsc_remove()
509 input_unregister_device(ts_dev->input); in titsc_remove()
542 ts_dev->coordinate_readouts * 2 + 2 - 1); in titsc_resume()
549 { .compatible = "ti,am3359-tsc", },
558 .name = "TI-am335x-tsc",