13 #include <linux/kernel.h>
14 #include <linux/module.h>
15 #include <linux/sched.h>
18 #include <linux/device.h>
20 #include <linux/input.h>
21 #include <linux/slab.h>
23 #include <linux/i2c.h>
31 #define STMPE_REG_INT_STA 0x0B
32 #define STMPE_REG_ADC_CTRL1 0x20
33 #define STMPE_REG_ADC_CTRL2 0x21
34 #define STMPE_REG_TSC_CTRL 0x40
35 #define STMPE_REG_TSC_CFG 0x41
36 #define STMPE_REG_FIFO_TH 0x4A
37 #define STMPE_REG_FIFO_STA 0x4B
38 #define STMPE_REG_FIFO_SIZE 0x4C
39 #define STMPE_REG_TSC_DATA_XYZ 0x52
40 #define STMPE_REG_TSC_FRACTION_Z 0x56
41 #define STMPE_REG_TSC_I_DRIVE 0x58
45 #define STMPE_TSC_CTRL_TSC_EN (1<<0)
47 #define STMPE_FIFO_STA_RESET (1<<0)
49 #define STMPE_IRQ_TOUCH_DET 0
51 #define SAMPLE_TIME(x) ((x & 0xf) << 4)
52 #define MOD_12B(x) ((x & 0x1) << 3)
53 #define REF_SEL(x) ((x & 0x1) << 1)
54 #define ADC_FREQ(x) (x & 0x3)
55 #define AVE_CTRL(x) ((x & 0x3) << 6)
56 #define DET_DELAY(x) ((x & 0x7) << 3)
57 #define SETTLING(x) (x & 0x7)
58 #define FRACTION_Z(x) (x & 0x7)
59 #define I_DRIVE(x) (x & 0x1)
60 #define OP_MODE(x) ((x & 0x7) << 1)
62 #define STMPE_TS_NAME "stmpe-ts"
81 static int __stmpe_reset_fifo(
struct stmpe *
stmpe)
118 __stmpe_reset_fifo(ts->
stmpe);
121 input_sync(ts->
idev);
147 x = (data_set[0] << 4) | (data_set[1] >> 4);
148 y = ((data_set[1] & 0xf) << 8) | data_set[2];
154 input_sync(ts->
idev);
157 __stmpe_reset_fifo(ts->
stmpe);
172 u8 adc_ctrl1, adc_ctrl1_mask, tsc_cfg, tsc_cfg_mask;
178 dev_err(dev,
"Could not enable clock for ADC and TS\n");
187 adc_ctrl1_mask, adc_ctrl1);
189 dev_err(dev,
"Could not setup ADC\n");
196 dev_err(dev,
"Could not setup ADC\n");
206 dev_err(dev,
"Could not config touch\n");
213 dev_err(dev,
"Could not config touch\n");
220 dev_err(dev,
"Could not config touch\n");
227 dev_err(dev,
"Could not set FIFO\n");
234 dev_err(dev,
"Could not set mode\n");
241 static int stmpe_ts_open(
struct input_dev *dev)
246 ret = __stmpe_reset_fifo(ts->
stmpe);
254 static void stmpe_ts_close(
struct input_dev *dev)
269 struct input_dev *
idev;
284 idev = input_allocate_device();
290 platform_set_drvdata(pdev, ts);
296 ts_pdata = pdata->
ts;
315 dev_err(&pdev->
dev,
"Failed to request IRQ %d\n", ts_irq);
319 ret = stmpe_init_hw(ts);
328 idev->open = stmpe_ts_open;
329 idev->close = stmpe_ts_close;
331 input_set_drvdata(idev, ts);
335 input_set_abs_params(idev,
ABS_PRESSURE, 0x0, 0xff, 0, 0);
337 ret = input_register_device(idev);
339 dev_err(&pdev->
dev,
"Could not register input device\n");
348 input_free_device(idev);
349 platform_set_drvdata(pdev,
NULL);
358 struct stmpe_touch *ts = platform_get_drvdata(pdev);
365 platform_set_drvdata(pdev,
NULL);
367 input_unregister_device(ts->
idev);
379 .probe = stmpe_input_probe,