Thomas Gleixner | 2874c5f | 2019-05-27 08:55:01 +0200 | [diff] [blame^] | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
Viresh Kumar | 2bd942f | 2012-11-09 23:56:59 -0800 | [diff] [blame] | 2 | /* |
| 3 | * STMicroelectronics STMPE811 Touchscreen Driver |
Luotao Fu | f94add3 | 2010-07-02 14:10:29 +0200 | [diff] [blame] | 4 | * |
| 5 | * (C) 2010 Luotao Fu <l.fu@pengutronix.de> |
| 6 | * All rights reserved. |
Luotao Fu | f94add3 | 2010-07-02 14:10:29 +0200 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #include <linux/kernel.h> |
| 10 | #include <linux/module.h> |
| 11 | #include <linux/sched.h> |
| 12 | #include <linux/interrupt.h> |
Luotao Fu | f94add3 | 2010-07-02 14:10:29 +0200 | [diff] [blame] | 13 | #include <linux/device.h> |
Vipul Kumar Samar | 037db52 | 2012-11-22 23:42:12 -0800 | [diff] [blame] | 14 | #include <linux/of.h> |
Luotao Fu | f94add3 | 2010-07-02 14:10:29 +0200 | [diff] [blame] | 15 | #include <linux/platform_device.h> |
| 16 | #include <linux/input.h> |
| 17 | #include <linux/slab.h> |
| 18 | #include <linux/delay.h> |
| 19 | #include <linux/i2c.h> |
| 20 | #include <linux/workqueue.h> |
| 21 | |
| 22 | #include <linux/mfd/stmpe.h> |
| 23 | |
| 24 | /* Register layouts and functionalities are identical on all stmpexxx variants |
| 25 | * with touchscreen controller |
| 26 | */ |
| 27 | #define STMPE_REG_INT_STA 0x0B |
Luotao Fu | f94add3 | 2010-07-02 14:10:29 +0200 | [diff] [blame] | 28 | #define STMPE_REG_TSC_CTRL 0x40 |
| 29 | #define STMPE_REG_TSC_CFG 0x41 |
| 30 | #define STMPE_REG_FIFO_TH 0x4A |
| 31 | #define STMPE_REG_FIFO_STA 0x4B |
| 32 | #define STMPE_REG_FIFO_SIZE 0x4C |
| 33 | #define STMPE_REG_TSC_DATA_XYZ 0x52 |
| 34 | #define STMPE_REG_TSC_FRACTION_Z 0x56 |
| 35 | #define STMPE_REG_TSC_I_DRIVE 0x58 |
| 36 | |
| 37 | #define OP_MOD_XYZ 0 |
| 38 | |
| 39 | #define STMPE_TSC_CTRL_TSC_EN (1<<0) |
| 40 | |
| 41 | #define STMPE_FIFO_STA_RESET (1<<0) |
| 42 | |
| 43 | #define STMPE_IRQ_TOUCH_DET 0 |
| 44 | |
Luotao Fu | f94add3 | 2010-07-02 14:10:29 +0200 | [diff] [blame] | 45 | #define STMPE_TS_NAME "stmpe-ts" |
| 46 | #define XY_MASK 0xfff |
| 47 | |
Linus Walleij | 564a68d | 2016-02-22 11:37:49 -0800 | [diff] [blame] | 48 | /** |
| 49 | * struct stmpe_touch - stmpe811 touch screen controller state |
| 50 | * @stmpe: pointer back to STMPE MFD container |
| 51 | * @idev: registered input device |
| 52 | * @work: a work item used to scan the device |
| 53 | * @dev: a pointer back to the MFD cell struct device* |
Linus Walleij | 564a68d | 2016-02-22 11:37:49 -0800 | [diff] [blame] | 54 | * @ave_ctrl: Sample average control |
| 55 | * (0 -> 1 sample, 1 -> 2 samples, 2 -> 4 samples, 3 -> 8 samples) |
| 56 | * @touch_det_delay: Touch detect interrupt delay |
| 57 | * (0 -> 10 us, 1 -> 50 us, 2 -> 100 us, 3 -> 500 us, |
| 58 | * 4-> 1 ms, 5 -> 5 ms, 6 -> 10 ms, 7 -> 50 ms) |
| 59 | * recommended is 3 |
| 60 | * @settling: Panel driver settling time |
| 61 | * (0 -> 10 us, 1 -> 100 us, 2 -> 500 us, 3 -> 1 ms, |
| 62 | * 4 -> 5 ms, 5 -> 10 ms, 6 for 50 ms, 7 -> 100 ms) |
| 63 | * recommended is 2 |
| 64 | * @fraction_z: Length of the fractional part in z |
| 65 | * (fraction_z ([0..7]) = Count of the fractional part) |
| 66 | * recommended is 7 |
| 67 | * @i_drive: current limit value of the touchscreen drivers |
| 68 | * (0 -> 20 mA typical 35 mA max, 1 -> 50 mA typical 80 mA max) |
| 69 | */ |
Luotao Fu | f94add3 | 2010-07-02 14:10:29 +0200 | [diff] [blame] | 70 | struct stmpe_touch { |
| 71 | struct stmpe *stmpe; |
| 72 | struct input_dev *idev; |
| 73 | struct delayed_work work; |
| 74 | struct device *dev; |
Luotao Fu | f94add3 | 2010-07-02 14:10:29 +0200 | [diff] [blame] | 75 | u8 ave_ctrl; |
| 76 | u8 touch_det_delay; |
| 77 | u8 settling; |
| 78 | u8 fraction_z; |
| 79 | u8 i_drive; |
| 80 | }; |
| 81 | |
| 82 | static int __stmpe_reset_fifo(struct stmpe *stmpe) |
| 83 | { |
| 84 | int ret; |
| 85 | |
| 86 | ret = stmpe_set_bits(stmpe, STMPE_REG_FIFO_STA, |
| 87 | STMPE_FIFO_STA_RESET, STMPE_FIFO_STA_RESET); |
| 88 | if (ret) |
| 89 | return ret; |
| 90 | |
| 91 | return stmpe_set_bits(stmpe, STMPE_REG_FIFO_STA, |
| 92 | STMPE_FIFO_STA_RESET, 0); |
| 93 | } |
| 94 | |
| 95 | static void stmpe_work(struct work_struct *work) |
| 96 | { |
| 97 | int int_sta; |
| 98 | u32 timeout = 40; |
| 99 | |
| 100 | struct stmpe_touch *ts = |
| 101 | container_of(work, struct stmpe_touch, work.work); |
| 102 | |
| 103 | int_sta = stmpe_reg_read(ts->stmpe, STMPE_REG_INT_STA); |
| 104 | |
| 105 | /* |
| 106 | * touch_det sometimes get desasserted or just get stuck. This appears |
| 107 | * to be a silicon bug, We still have to clearify this with the |
| 108 | * manufacture. As a workaround We release the key anyway if the |
| 109 | * touch_det keeps coming in after 4ms, while the FIFO contains no value |
| 110 | * during the whole time. |
| 111 | */ |
| 112 | while ((int_sta & (1 << STMPE_IRQ_TOUCH_DET)) && (timeout > 0)) { |
| 113 | timeout--; |
| 114 | int_sta = stmpe_reg_read(ts->stmpe, STMPE_REG_INT_STA); |
| 115 | udelay(100); |
| 116 | } |
| 117 | |
| 118 | /* reset the FIFO before we report release event */ |
| 119 | __stmpe_reset_fifo(ts->stmpe); |
| 120 | |
| 121 | input_report_abs(ts->idev, ABS_PRESSURE, 0); |
Vipul Kumar Samar | 7488b1b | 2012-12-16 23:10:56 -0800 | [diff] [blame] | 122 | input_report_key(ts->idev, BTN_TOUCH, 0); |
Luotao Fu | f94add3 | 2010-07-02 14:10:29 +0200 | [diff] [blame] | 123 | input_sync(ts->idev); |
| 124 | } |
| 125 | |
| 126 | static irqreturn_t stmpe_ts_handler(int irq, void *data) |
| 127 | { |
| 128 | u8 data_set[4]; |
| 129 | int x, y, z; |
| 130 | struct stmpe_touch *ts = data; |
| 131 | |
| 132 | /* |
| 133 | * Cancel scheduled polling for release if we have new value |
| 134 | * available. Wait if the polling is already running. |
| 135 | */ |
| 136 | cancel_delayed_work_sync(&ts->work); |
| 137 | |
| 138 | /* |
| 139 | * The FIFO sometimes just crashes and stops generating interrupts. This |
| 140 | * appears to be a silicon bug. We still have to clearify this with |
| 141 | * the manufacture. As a workaround we disable the TSC while we are |
| 142 | * collecting data and flush the FIFO after reading |
| 143 | */ |
| 144 | stmpe_set_bits(ts->stmpe, STMPE_REG_TSC_CTRL, |
| 145 | STMPE_TSC_CTRL_TSC_EN, 0); |
| 146 | |
| 147 | stmpe_block_read(ts->stmpe, STMPE_REG_TSC_DATA_XYZ, 4, data_set); |
| 148 | |
| 149 | x = (data_set[0] << 4) | (data_set[1] >> 4); |
| 150 | y = ((data_set[1] & 0xf) << 8) | data_set[2]; |
| 151 | z = data_set[3]; |
| 152 | |
| 153 | input_report_abs(ts->idev, ABS_X, x); |
| 154 | input_report_abs(ts->idev, ABS_Y, y); |
| 155 | input_report_abs(ts->idev, ABS_PRESSURE, z); |
Vipul Kumar Samar | 7488b1b | 2012-12-16 23:10:56 -0800 | [diff] [blame] | 156 | input_report_key(ts->idev, BTN_TOUCH, 1); |
Luotao Fu | f94add3 | 2010-07-02 14:10:29 +0200 | [diff] [blame] | 157 | input_sync(ts->idev); |
| 158 | |
| 159 | /* flush the FIFO after we have read out our values. */ |
| 160 | __stmpe_reset_fifo(ts->stmpe); |
| 161 | |
| 162 | /* reenable the tsc */ |
| 163 | stmpe_set_bits(ts->stmpe, STMPE_REG_TSC_CTRL, |
| 164 | STMPE_TSC_CTRL_TSC_EN, STMPE_TSC_CTRL_TSC_EN); |
| 165 | |
| 166 | /* start polling for touch_det to detect release */ |
Marek Vasut | 9ceeb59 | 2015-05-07 22:25:49 -0700 | [diff] [blame] | 167 | schedule_delayed_work(&ts->work, msecs_to_jiffies(50)); |
Luotao Fu | f94add3 | 2010-07-02 14:10:29 +0200 | [diff] [blame] | 168 | |
| 169 | return IRQ_HANDLED; |
| 170 | } |
| 171 | |
Bill Pemberton | 5298cc4 | 2012-11-23 21:38:25 -0800 | [diff] [blame] | 172 | static int stmpe_init_hw(struct stmpe_touch *ts) |
Luotao Fu | f94add3 | 2010-07-02 14:10:29 +0200 | [diff] [blame] | 173 | { |
| 174 | int ret; |
Philippe Schenker | 88f29d0 | 2018-12-21 14:46:33 +0100 | [diff] [blame] | 175 | u8 tsc_cfg, tsc_cfg_mask; |
Luotao Fu | f94add3 | 2010-07-02 14:10:29 +0200 | [diff] [blame] | 176 | struct stmpe *stmpe = ts->stmpe; |
| 177 | struct device *dev = ts->dev; |
| 178 | |
| 179 | ret = stmpe_enable(stmpe, STMPE_BLOCK_TOUCHSCREEN | STMPE_BLOCK_ADC); |
| 180 | if (ret) { |
| 181 | dev_err(dev, "Could not enable clock for ADC and TS\n"); |
| 182 | return ret; |
| 183 | } |
| 184 | |
Philippe Schenker | 88f29d0 | 2018-12-21 14:46:33 +0100 | [diff] [blame] | 185 | ret = stmpe811_adc_common_init(stmpe); |
Luotao Fu | f94add3 | 2010-07-02 14:10:29 +0200 | [diff] [blame] | 186 | if (ret) { |
Philippe Schenker | 88f29d0 | 2018-12-21 14:46:33 +0100 | [diff] [blame] | 187 | stmpe_disable(stmpe, STMPE_BLOCK_TOUCHSCREEN | STMPE_BLOCK_ADC); |
Luotao Fu | f94add3 | 2010-07-02 14:10:29 +0200 | [diff] [blame] | 188 | return ret; |
| 189 | } |
| 190 | |
Philippe Schenker | 063755a | 2018-12-21 14:46:31 +0100 | [diff] [blame] | 191 | tsc_cfg = STMPE_AVE_CTRL(ts->ave_ctrl) | |
| 192 | STMPE_DET_DELAY(ts->touch_det_delay) | |
| 193 | STMPE_SETTLING(ts->settling); |
| 194 | tsc_cfg_mask = STMPE_AVE_CTRL(0xff) | STMPE_DET_DELAY(0xff) | |
| 195 | STMPE_SETTLING(0xff); |
Luotao Fu | f94add3 | 2010-07-02 14:10:29 +0200 | [diff] [blame] | 196 | |
| 197 | ret = stmpe_set_bits(stmpe, STMPE_REG_TSC_CFG, tsc_cfg_mask, tsc_cfg); |
| 198 | if (ret) { |
| 199 | dev_err(dev, "Could not config touch\n"); |
| 200 | return ret; |
| 201 | } |
| 202 | |
| 203 | ret = stmpe_set_bits(stmpe, STMPE_REG_TSC_FRACTION_Z, |
Philippe Schenker | 063755a | 2018-12-21 14:46:31 +0100 | [diff] [blame] | 204 | STMPE_FRACTION_Z(0xff), STMPE_FRACTION_Z(ts->fraction_z)); |
Luotao Fu | f94add3 | 2010-07-02 14:10:29 +0200 | [diff] [blame] | 205 | if (ret) { |
| 206 | dev_err(dev, "Could not config touch\n"); |
| 207 | return ret; |
| 208 | } |
| 209 | |
| 210 | ret = stmpe_set_bits(stmpe, STMPE_REG_TSC_I_DRIVE, |
Philippe Schenker | 063755a | 2018-12-21 14:46:31 +0100 | [diff] [blame] | 211 | STMPE_I_DRIVE(0xff), STMPE_I_DRIVE(ts->i_drive)); |
Luotao Fu | f94add3 | 2010-07-02 14:10:29 +0200 | [diff] [blame] | 212 | if (ret) { |
| 213 | dev_err(dev, "Could not config touch\n"); |
| 214 | return ret; |
| 215 | } |
| 216 | |
| 217 | /* set FIFO to 1 for single point reading */ |
| 218 | ret = stmpe_reg_write(stmpe, STMPE_REG_FIFO_TH, 1); |
| 219 | if (ret) { |
| 220 | dev_err(dev, "Could not set FIFO\n"); |
| 221 | return ret; |
| 222 | } |
| 223 | |
| 224 | ret = stmpe_set_bits(stmpe, STMPE_REG_TSC_CTRL, |
Philippe Schenker | 063755a | 2018-12-21 14:46:31 +0100 | [diff] [blame] | 225 | STMPE_OP_MODE(0xff), STMPE_OP_MODE(OP_MOD_XYZ)); |
Luotao Fu | f94add3 | 2010-07-02 14:10:29 +0200 | [diff] [blame] | 226 | if (ret) { |
| 227 | dev_err(dev, "Could not set mode\n"); |
| 228 | return ret; |
| 229 | } |
| 230 | |
| 231 | return 0; |
| 232 | } |
| 233 | |
| 234 | static int stmpe_ts_open(struct input_dev *dev) |
| 235 | { |
| 236 | struct stmpe_touch *ts = input_get_drvdata(dev); |
| 237 | int ret = 0; |
| 238 | |
| 239 | ret = __stmpe_reset_fifo(ts->stmpe); |
| 240 | if (ret) |
| 241 | return ret; |
| 242 | |
| 243 | return stmpe_set_bits(ts->stmpe, STMPE_REG_TSC_CTRL, |
| 244 | STMPE_TSC_CTRL_TSC_EN, STMPE_TSC_CTRL_TSC_EN); |
| 245 | } |
| 246 | |
| 247 | static void stmpe_ts_close(struct input_dev *dev) |
| 248 | { |
| 249 | struct stmpe_touch *ts = input_get_drvdata(dev); |
| 250 | |
| 251 | cancel_delayed_work_sync(&ts->work); |
| 252 | |
| 253 | stmpe_set_bits(ts->stmpe, STMPE_REG_TSC_CTRL, |
| 254 | STMPE_TSC_CTRL_TSC_EN, 0); |
| 255 | } |
| 256 | |
Vipul Kumar Samar | 037db52 | 2012-11-22 23:42:12 -0800 | [diff] [blame] | 257 | static void stmpe_ts_get_platform_info(struct platform_device *pdev, |
| 258 | struct stmpe_touch *ts) |
Luotao Fu | f94add3 | 2010-07-02 14:10:29 +0200 | [diff] [blame] | 259 | { |
Vipul Kumar Samar | 037db52 | 2012-11-22 23:42:12 -0800 | [diff] [blame] | 260 | struct device_node *np = pdev->dev.of_node; |
Dmitry Torokhov | e4b88e1 | 2015-05-22 13:44:33 -0700 | [diff] [blame] | 261 | u32 val; |
Vipul Kumar Samar | 037db52 | 2012-11-22 23:42:12 -0800 | [diff] [blame] | 262 | |
Dmitry Torokhov | e4b88e1 | 2015-05-22 13:44:33 -0700 | [diff] [blame] | 263 | if (np) { |
Vipul Kumar Samar | 037db52 | 2012-11-22 23:42:12 -0800 | [diff] [blame] | 264 | if (!of_property_read_u32(np, "st,sample-time", &val)) |
Philippe Schenker | 88f29d0 | 2018-12-21 14:46:33 +0100 | [diff] [blame] | 265 | ts->stmpe->sample_time = val; |
Vipul Kumar Samar | 037db52 | 2012-11-22 23:42:12 -0800 | [diff] [blame] | 266 | if (!of_property_read_u32(np, "st,mod-12b", &val)) |
Philippe Schenker | 88f29d0 | 2018-12-21 14:46:33 +0100 | [diff] [blame] | 267 | ts->stmpe->mod_12b = val; |
Vipul Kumar Samar | 037db52 | 2012-11-22 23:42:12 -0800 | [diff] [blame] | 268 | if (!of_property_read_u32(np, "st,ref-sel", &val)) |
Philippe Schenker | 88f29d0 | 2018-12-21 14:46:33 +0100 | [diff] [blame] | 269 | ts->stmpe->ref_sel = val; |
Vipul Kumar Samar | 037db52 | 2012-11-22 23:42:12 -0800 | [diff] [blame] | 270 | if (!of_property_read_u32(np, "st,adc-freq", &val)) |
Philippe Schenker | 88f29d0 | 2018-12-21 14:46:33 +0100 | [diff] [blame] | 271 | ts->stmpe->adc_freq = val; |
Vipul Kumar Samar | 037db52 | 2012-11-22 23:42:12 -0800 | [diff] [blame] | 272 | if (!of_property_read_u32(np, "st,ave-ctrl", &val)) |
| 273 | ts->ave_ctrl = val; |
| 274 | if (!of_property_read_u32(np, "st,touch-det-delay", &val)) |
| 275 | ts->touch_det_delay = val; |
| 276 | if (!of_property_read_u32(np, "st,settling", &val)) |
| 277 | ts->settling = val; |
| 278 | if (!of_property_read_u32(np, "st,fraction-z", &val)) |
| 279 | ts->fraction_z = val; |
| 280 | if (!of_property_read_u32(np, "st,i-drive", &val)) |
| 281 | ts->i_drive = val; |
| 282 | } |
| 283 | } |
| 284 | |
Bill Pemberton | 5298cc4 | 2012-11-23 21:38:25 -0800 | [diff] [blame] | 285 | static int stmpe_input_probe(struct platform_device *pdev) |
Vipul Kumar Samar | 037db52 | 2012-11-22 23:42:12 -0800 | [diff] [blame] | 286 | { |
Dmitry Torokhov | e4b88e1 | 2015-05-22 13:44:33 -0700 | [diff] [blame] | 287 | struct stmpe *stmpe = dev_get_drvdata(pdev->dev.parent); |
Luotao Fu | f94add3 | 2010-07-02 14:10:29 +0200 | [diff] [blame] | 288 | struct stmpe_touch *ts; |
| 289 | struct input_dev *idev; |
Viresh Kumar | 2bd942f | 2012-11-09 23:56:59 -0800 | [diff] [blame] | 290 | int error; |
Kulikov Vasiliy | 3faeb35 | 2010-07-15 22:43:54 +0400 | [diff] [blame] | 291 | int ts_irq; |
Luotao Fu | f94add3 | 2010-07-02 14:10:29 +0200 | [diff] [blame] | 292 | |
| 293 | ts_irq = platform_get_irq_byname(pdev, "FIFO_TH"); |
| 294 | if (ts_irq < 0) |
| 295 | return ts_irq; |
| 296 | |
Viresh Kumar | 2bd942f | 2012-11-09 23:56:59 -0800 | [diff] [blame] | 297 | ts = devm_kzalloc(&pdev->dev, sizeof(*ts), GFP_KERNEL); |
| 298 | if (!ts) |
| 299 | return -ENOMEM; |
Luotao Fu | f94add3 | 2010-07-02 14:10:29 +0200 | [diff] [blame] | 300 | |
Viresh Kumar | 2bd942f | 2012-11-09 23:56:59 -0800 | [diff] [blame] | 301 | idev = devm_input_allocate_device(&pdev->dev); |
| 302 | if (!idev) |
| 303 | return -ENOMEM; |
Luotao Fu | f94add3 | 2010-07-02 14:10:29 +0200 | [diff] [blame] | 304 | |
| 305 | platform_set_drvdata(pdev, ts); |
Dmitry Torokhov | e4b88e1 | 2015-05-22 13:44:33 -0700 | [diff] [blame] | 306 | ts->stmpe = stmpe; |
Luotao Fu | f94add3 | 2010-07-02 14:10:29 +0200 | [diff] [blame] | 307 | ts->idev = idev; |
| 308 | ts->dev = &pdev->dev; |
| 309 | |
Vipul Kumar Samar | 037db52 | 2012-11-22 23:42:12 -0800 | [diff] [blame] | 310 | stmpe_ts_get_platform_info(pdev, ts); |
Luotao Fu | f94add3 | 2010-07-02 14:10:29 +0200 | [diff] [blame] | 311 | |
| 312 | INIT_DELAYED_WORK(&ts->work, stmpe_work); |
| 313 | |
Viresh Kumar | 2bd942f | 2012-11-09 23:56:59 -0800 | [diff] [blame] | 314 | error = devm_request_threaded_irq(&pdev->dev, ts_irq, |
| 315 | NULL, stmpe_ts_handler, |
| 316 | IRQF_ONESHOT, STMPE_TS_NAME, ts); |
| 317 | if (error) { |
Luotao Fu | f94add3 | 2010-07-02 14:10:29 +0200 | [diff] [blame] | 318 | dev_err(&pdev->dev, "Failed to request IRQ %d\n", ts_irq); |
Viresh Kumar | 2bd942f | 2012-11-09 23:56:59 -0800 | [diff] [blame] | 319 | return error; |
Luotao Fu | f94add3 | 2010-07-02 14:10:29 +0200 | [diff] [blame] | 320 | } |
| 321 | |
Viresh Kumar | 2bd942f | 2012-11-09 23:56:59 -0800 | [diff] [blame] | 322 | error = stmpe_init_hw(ts); |
| 323 | if (error) |
| 324 | return error; |
Luotao Fu | f94add3 | 2010-07-02 14:10:29 +0200 | [diff] [blame] | 325 | |
| 326 | idev->name = STMPE_TS_NAME; |
Vipul Kumar Samar | b8d52e2 | 2012-11-10 00:08:20 -0800 | [diff] [blame] | 327 | idev->phys = STMPE_TS_NAME"/input0"; |
Luotao Fu | f94add3 | 2010-07-02 14:10:29 +0200 | [diff] [blame] | 328 | idev->id.bustype = BUS_I2C; |
Luotao Fu | f94add3 | 2010-07-02 14:10:29 +0200 | [diff] [blame] | 329 | |
| 330 | idev->open = stmpe_ts_open; |
| 331 | idev->close = stmpe_ts_close; |
| 332 | |
| 333 | input_set_drvdata(idev, ts); |
| 334 | |
Dmitry Torokhov | e4b88e1 | 2015-05-22 13:44:33 -0700 | [diff] [blame] | 335 | input_set_capability(idev, EV_KEY, BTN_TOUCH); |
Luotao Fu | f94add3 | 2010-07-02 14:10:29 +0200 | [diff] [blame] | 336 | input_set_abs_params(idev, ABS_X, 0, XY_MASK, 0, 0); |
| 337 | input_set_abs_params(idev, ABS_Y, 0, XY_MASK, 0, 0); |
| 338 | input_set_abs_params(idev, ABS_PRESSURE, 0x0, 0xff, 0, 0); |
| 339 | |
Viresh Kumar | 2bd942f | 2012-11-09 23:56:59 -0800 | [diff] [blame] | 340 | error = input_register_device(idev); |
| 341 | if (error) { |
Luotao Fu | f94add3 | 2010-07-02 14:10:29 +0200 | [diff] [blame] | 342 | dev_err(&pdev->dev, "Could not register input device\n"); |
Viresh Kumar | 2bd942f | 2012-11-09 23:56:59 -0800 | [diff] [blame] | 343 | return error; |
Luotao Fu | f94add3 | 2010-07-02 14:10:29 +0200 | [diff] [blame] | 344 | } |
| 345 | |
Viresh Kumar | 2bd942f | 2012-11-09 23:56:59 -0800 | [diff] [blame] | 346 | return 0; |
Luotao Fu | f94add3 | 2010-07-02 14:10:29 +0200 | [diff] [blame] | 347 | } |
| 348 | |
Bill Pemberton | e2619cf | 2012-11-23 21:50:47 -0800 | [diff] [blame] | 349 | static int stmpe_ts_remove(struct platform_device *pdev) |
Luotao Fu | f94add3 | 2010-07-02 14:10:29 +0200 | [diff] [blame] | 350 | { |
| 351 | struct stmpe_touch *ts = platform_get_drvdata(pdev); |
Luotao Fu | f94add3 | 2010-07-02 14:10:29 +0200 | [diff] [blame] | 352 | |
| 353 | stmpe_disable(ts->stmpe, STMPE_BLOCK_TOUCHSCREEN); |
| 354 | |
Luotao Fu | f94add3 | 2010-07-02 14:10:29 +0200 | [diff] [blame] | 355 | return 0; |
| 356 | } |
| 357 | |
| 358 | static struct platform_driver stmpe_ts_driver = { |
| 359 | .driver = { |
Dmitry Torokhov | f91a3f0 | 2015-05-22 13:09:11 -0700 | [diff] [blame] | 360 | .name = STMPE_TS_NAME, |
| 361 | }, |
Luotao Fu | f94add3 | 2010-07-02 14:10:29 +0200 | [diff] [blame] | 362 | .probe = stmpe_input_probe, |
Bill Pemberton | 1cb0aa8 | 2012-11-23 21:27:39 -0800 | [diff] [blame] | 363 | .remove = stmpe_ts_remove, |
Luotao Fu | f94add3 | 2010-07-02 14:10:29 +0200 | [diff] [blame] | 364 | }; |
JJ Ding | cdcc96e | 2011-11-29 11:14:13 -0800 | [diff] [blame] | 365 | module_platform_driver(stmpe_ts_driver); |
Luotao Fu | f94add3 | 2010-07-02 14:10:29 +0200 | [diff] [blame] | 366 | |
Dmitry Torokhov | f91a3f0 | 2015-05-22 13:09:11 -0700 | [diff] [blame] | 367 | static const struct of_device_id stmpe_ts_ids[] = { |
| 368 | { .compatible = "st,stmpe-ts", }, |
| 369 | { }, |
| 370 | }; |
| 371 | MODULE_DEVICE_TABLE(of, stmpe_ts_ids); |
Dmitry Torokhov | f91a3f0 | 2015-05-22 13:09:11 -0700 | [diff] [blame] | 372 | |
Luotao Fu | f94add3 | 2010-07-02 14:10:29 +0200 | [diff] [blame] | 373 | MODULE_AUTHOR("Luotao Fu <l.fu@pengutronix.de>"); |
| 374 | MODULE_DESCRIPTION("STMPEXXX touchscreen driver"); |
| 375 | MODULE_LICENSE("GPL"); |