Lines Matching +full:stmpe +full:- +full:adc
27 #include <linux/mfd/stmpe.h>
63 #define STMPE_TS_NAME "stmpe-ts"
67 * struct stmpe_touch - stmpe811 touch screen controller state
68 * @stmpe: pointer back to STMPE MFD container
72 * @sample_time: ADC converstion time in number of clock.
73 * (0 -> 36 clocks, 1 -> 44 clocks, 2 -> 56 clocks, 3 -> 64 clocks,
74 * 4 -> 80 clocks, 5 -> 96 clocks, 6 -> 144 clocks),
76 * @mod_12b: ADC Bit mode (0 -> 10bit ADC, 1 -> 12bit ADC)
77 * @ref_sel: ADC reference source
78 * (0 -> internal reference, 1 -> external reference)
79 * @adc_freq: ADC Clock speed
80 * (0 -> 1.625 MHz, 1 -> 3.25 MHz, 2 || 3 -> 6.5 MHz)
82 * (0 -> 1 sample, 1 -> 2 samples, 2 -> 4 samples, 3 -> 8 samples)
84 * (0 -> 10 us, 1 -> 50 us, 2 -> 100 us, 3 -> 500 us,
85 * 4-> 1 ms, 5 -> 5 ms, 6 -> 10 ms, 7 -> 50 ms)
88 * (0 -> 10 us, 1 -> 100 us, 2 -> 500 us, 3 -> 1 ms,
89 * 4 -> 5 ms, 5 -> 10 ms, 6 for 50 ms, 7 -> 100 ms)
95 * (0 -> 20 mA typical 35 mA max, 1 -> 50 mA typical 80 mA max)
98 struct stmpe *stmpe; member
113 static int __stmpe_reset_fifo(struct stmpe *stmpe) in __stmpe_reset_fifo() argument
117 ret = stmpe_set_bits(stmpe, STMPE_REG_FIFO_STA, in __stmpe_reset_fifo()
122 return stmpe_set_bits(stmpe, STMPE_REG_FIFO_STA, in __stmpe_reset_fifo()
134 int_sta = stmpe_reg_read(ts->stmpe, STMPE_REG_INT_STA); in stmpe_work()
144 timeout--; in stmpe_work()
145 int_sta = stmpe_reg_read(ts->stmpe, STMPE_REG_INT_STA); in stmpe_work()
150 __stmpe_reset_fifo(ts->stmpe); in stmpe_work()
152 input_report_abs(ts->idev, ABS_PRESSURE, 0); in stmpe_work()
153 input_report_key(ts->idev, BTN_TOUCH, 0); in stmpe_work()
154 input_sync(ts->idev); in stmpe_work()
167 cancel_delayed_work_sync(&ts->work); in stmpe_ts_handler()
175 stmpe_set_bits(ts->stmpe, STMPE_REG_TSC_CTRL, in stmpe_ts_handler()
178 stmpe_block_read(ts->stmpe, STMPE_REG_TSC_DATA_XYZ, 4, data_set); in stmpe_ts_handler()
184 input_report_abs(ts->idev, ABS_X, x); in stmpe_ts_handler()
185 input_report_abs(ts->idev, ABS_Y, y); in stmpe_ts_handler()
186 input_report_abs(ts->idev, ABS_PRESSURE, z); in stmpe_ts_handler()
187 input_report_key(ts->idev, BTN_TOUCH, 1); in stmpe_ts_handler()
188 input_sync(ts->idev); in stmpe_ts_handler()
191 __stmpe_reset_fifo(ts->stmpe); in stmpe_ts_handler()
194 stmpe_set_bits(ts->stmpe, STMPE_REG_TSC_CTRL, in stmpe_ts_handler()
198 schedule_delayed_work(&ts->work, msecs_to_jiffies(50)); in stmpe_ts_handler()
207 struct stmpe *stmpe = ts->stmpe; in stmpe_init_hw() local
208 struct device *dev = ts->dev; in stmpe_init_hw()
210 ret = stmpe_enable(stmpe, STMPE_BLOCK_TOUCHSCREEN | STMPE_BLOCK_ADC); in stmpe_init_hw()
212 dev_err(dev, "Could not enable clock for ADC and TS\n"); in stmpe_init_hw()
216 adc_ctrl1 = SAMPLE_TIME(ts->sample_time) | MOD_12B(ts->mod_12b) | in stmpe_init_hw()
217 REF_SEL(ts->ref_sel); in stmpe_init_hw()
220 ret = stmpe_set_bits(stmpe, STMPE_REG_ADC_CTRL1, in stmpe_init_hw()
223 dev_err(dev, "Could not setup ADC\n"); in stmpe_init_hw()
227 ret = stmpe_set_bits(stmpe, STMPE_REG_ADC_CTRL2, in stmpe_init_hw()
228 ADC_FREQ(0xff), ADC_FREQ(ts->adc_freq)); in stmpe_init_hw()
230 dev_err(dev, "Could not setup ADC\n"); in stmpe_init_hw()
234 tsc_cfg = AVE_CTRL(ts->ave_ctrl) | DET_DELAY(ts->touch_det_delay) | in stmpe_init_hw()
235 SETTLING(ts->settling); in stmpe_init_hw()
238 ret = stmpe_set_bits(stmpe, STMPE_REG_TSC_CFG, tsc_cfg_mask, tsc_cfg); in stmpe_init_hw()
244 ret = stmpe_set_bits(stmpe, STMPE_REG_TSC_FRACTION_Z, in stmpe_init_hw()
245 FRACTION_Z(0xff), FRACTION_Z(ts->fraction_z)); in stmpe_init_hw()
251 ret = stmpe_set_bits(stmpe, STMPE_REG_TSC_I_DRIVE, in stmpe_init_hw()
252 I_DRIVE(0xff), I_DRIVE(ts->i_drive)); in stmpe_init_hw()
259 ret = stmpe_reg_write(stmpe, STMPE_REG_FIFO_TH, 1); in stmpe_init_hw()
265 ret = stmpe_set_bits(stmpe, STMPE_REG_TSC_CTRL, in stmpe_init_hw()
280 ret = __stmpe_reset_fifo(ts->stmpe); in stmpe_ts_open()
284 return stmpe_set_bits(ts->stmpe, STMPE_REG_TSC_CTRL, in stmpe_ts_open()
292 cancel_delayed_work_sync(&ts->work); in stmpe_ts_close()
294 stmpe_set_bits(ts->stmpe, STMPE_REG_TSC_CTRL, in stmpe_ts_close()
301 struct device_node *np = pdev->dev.of_node; in stmpe_ts_get_platform_info()
305 if (!of_property_read_u32(np, "st,sample-time", &val)) in stmpe_ts_get_platform_info()
306 ts->sample_time = val; in stmpe_ts_get_platform_info()
307 if (!of_property_read_u32(np, "st,mod-12b", &val)) in stmpe_ts_get_platform_info()
308 ts->mod_12b = val; in stmpe_ts_get_platform_info()
309 if (!of_property_read_u32(np, "st,ref-sel", &val)) in stmpe_ts_get_platform_info()
310 ts->ref_sel = val; in stmpe_ts_get_platform_info()
311 if (!of_property_read_u32(np, "st,adc-freq", &val)) in stmpe_ts_get_platform_info()
312 ts->adc_freq = val; in stmpe_ts_get_platform_info()
313 if (!of_property_read_u32(np, "st,ave-ctrl", &val)) in stmpe_ts_get_platform_info()
314 ts->ave_ctrl = val; in stmpe_ts_get_platform_info()
315 if (!of_property_read_u32(np, "st,touch-det-delay", &val)) in stmpe_ts_get_platform_info()
316 ts->touch_det_delay = val; in stmpe_ts_get_platform_info()
318 ts->settling = val; in stmpe_ts_get_platform_info()
319 if (!of_property_read_u32(np, "st,fraction-z", &val)) in stmpe_ts_get_platform_info()
320 ts->fraction_z = val; in stmpe_ts_get_platform_info()
321 if (!of_property_read_u32(np, "st,i-drive", &val)) in stmpe_ts_get_platform_info()
322 ts->i_drive = val; in stmpe_ts_get_platform_info()
328 struct stmpe *stmpe = dev_get_drvdata(pdev->dev.parent); in stmpe_input_probe() local
338 ts = devm_kzalloc(&pdev->dev, sizeof(*ts), GFP_KERNEL); in stmpe_input_probe()
340 return -ENOMEM; in stmpe_input_probe()
342 idev = devm_input_allocate_device(&pdev->dev); in stmpe_input_probe()
344 return -ENOMEM; in stmpe_input_probe()
347 ts->stmpe = stmpe; in stmpe_input_probe()
348 ts->idev = idev; in stmpe_input_probe()
349 ts->dev = &pdev->dev; in stmpe_input_probe()
353 INIT_DELAYED_WORK(&ts->work, stmpe_work); in stmpe_input_probe()
355 error = devm_request_threaded_irq(&pdev->dev, ts_irq, in stmpe_input_probe()
359 dev_err(&pdev->dev, "Failed to request IRQ %d\n", ts_irq); in stmpe_input_probe()
367 idev->name = STMPE_TS_NAME; in stmpe_input_probe()
368 idev->phys = STMPE_TS_NAME"/input0"; in stmpe_input_probe()
369 idev->id.bustype = BUS_I2C; in stmpe_input_probe()
371 idev->open = stmpe_ts_open; in stmpe_input_probe()
372 idev->close = stmpe_ts_close; in stmpe_input_probe()
383 dev_err(&pdev->dev, "Could not register input device\n"); in stmpe_input_probe()
394 stmpe_disable(ts->stmpe, STMPE_BLOCK_TOUCHSCREEN); in stmpe_ts_remove()
409 { .compatible = "st,stmpe-ts", },