aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input
diff options
context:
space:
mode:
authorFabio Estevam <fabio.estevam@freescale.com>2012-10-04 00:21:30 -0400
committerSamuel Ortiz <sameo@linux.intel.com>2012-11-20 06:21:11 -0500
commit8f520803d2a5dda0cf099c13cbf50ecf575d0341 (patch)
tree66198c0b2991030b397c2a3984d678f158054639 /drivers/input
parent8bad1abd6303476d6f77878aa8ea737d5d1b625c (diff)
Input: da9052_tsi.c: Fix interrupt handling
Currently da9062_tsi does not probe and it fails as follows: da9052 1-0048: Unable to determine device interrupts Use the new da9052 irq functions and allow the driver to probe and operate correctly. Tested on mx53qsb board using 'evtest' tool. Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com> Cc: <linux-input@vger.kernel.org> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/input')
-rw-r--r--drivers/input/touchscreen/da9052_tsi.c59
1 files changed, 20 insertions, 39 deletions
diff --git a/drivers/input/touchscreen/da9052_tsi.c b/drivers/input/touchscreen/da9052_tsi.c
index e8df341090c0..53133efe0418 100644
--- a/drivers/input/touchscreen/da9052_tsi.c
+++ b/drivers/input/touchscreen/da9052_tsi.c
@@ -27,8 +27,6 @@ struct da9052_tsi {
27 struct input_dev *dev; 27 struct input_dev *dev;
28 struct delayed_work ts_pen_work; 28 struct delayed_work ts_pen_work;
29 struct mutex mutex; 29 struct mutex mutex;
30 unsigned int irq_pendwn;
31 unsigned int irq_datardy;
32 bool stopped; 30 bool stopped;
33 bool adc_on; 31 bool adc_on;
34}; 32};
@@ -45,8 +43,8 @@ static irqreturn_t da9052_ts_pendwn_irq(int irq, void *data)
45 43
46 if (!tsi->stopped) { 44 if (!tsi->stopped) {
47 /* Mask PEN_DOWN event and unmask TSI_READY event */ 45 /* Mask PEN_DOWN event and unmask TSI_READY event */
48 disable_irq_nosync(tsi->irq_pendwn); 46 da9052_disable_irq_nosync(tsi->da9052, DA9052_IRQ_PENDOWN);
49 enable_irq(tsi->irq_datardy); 47 da9052_enable_irq(tsi->da9052, DA9052_IRQ_TSIREADY);
50 48
51 da9052_ts_adc_toggle(tsi, true); 49 da9052_ts_adc_toggle(tsi, true);
52 50
@@ -137,8 +135,8 @@ static void da9052_ts_pen_work(struct work_struct *work)
137 return; 135 return;
138 136
139 /* Mask TSI_READY event and unmask PEN_DOWN event */ 137 /* Mask TSI_READY event and unmask PEN_DOWN event */
140 disable_irq(tsi->irq_datardy); 138 da9052_disable_irq(tsi->da9052, DA9052_IRQ_TSIREADY);
141 enable_irq(tsi->irq_pendwn); 139 da9052_enable_irq(tsi->da9052, DA9052_IRQ_PENDOWN);
142 } 140 }
143 } 141 }
144} 142}
@@ -197,7 +195,7 @@ static int da9052_ts_input_open(struct input_dev *input_dev)
197 mb(); 195 mb();
198 196
199 /* Unmask PEN_DOWN event */ 197 /* Unmask PEN_DOWN event */
200 enable_irq(tsi->irq_pendwn); 198 da9052_enable_irq(tsi->da9052, DA9052_IRQ_PENDOWN);
201 199
202 /* Enable Pen Detect Circuit */ 200 /* Enable Pen Detect Circuit */
203 return da9052_reg_update(tsi->da9052, DA9052_TSI_CONT_A_REG, 201 return da9052_reg_update(tsi->da9052, DA9052_TSI_CONT_A_REG,
@@ -210,11 +208,11 @@ static void da9052_ts_input_close(struct input_dev *input_dev)
210 208
211 tsi->stopped = true; 209 tsi->stopped = true;
212 mb(); 210 mb();
213 disable_irq(tsi->irq_pendwn); 211 da9052_disable_irq(tsi->da9052, DA9052_IRQ_PENDOWN);
214 cancel_delayed_work_sync(&tsi->ts_pen_work); 212 cancel_delayed_work_sync(&tsi->ts_pen_work);
215 213
216 if (tsi->adc_on) { 214 if (tsi->adc_on) {
217 disable_irq(tsi->irq_datardy); 215 da9052_disable_irq(tsi->da9052, DA9052_IRQ_TSIREADY);
218 da9052_ts_adc_toggle(tsi, false); 216 da9052_ts_adc_toggle(tsi, false);
219 217
220 /* 218 /*
@@ -222,7 +220,7 @@ static void da9052_ts_input_close(struct input_dev *input_dev)
222 * twice and we need to enable it to keep enable/disable 220 * twice and we need to enable it to keep enable/disable
223 * counter balanced. IRQ is still off though. 221 * counter balanced. IRQ is still off though.
224 */ 222 */
225 enable_irq(tsi->irq_pendwn); 223 da9052_enable_irq(tsi->da9052, DA9052_IRQ_PENDOWN);
226 } 224 }
227 225
228 /* Disable Pen Detect Circuit */ 226 /* Disable Pen Detect Circuit */
@@ -234,21 +232,12 @@ static int __devinit da9052_ts_probe(struct platform_device *pdev)
234 struct da9052 *da9052; 232 struct da9052 *da9052;
235 struct da9052_tsi *tsi; 233 struct da9052_tsi *tsi;
236 struct input_dev *input_dev; 234 struct input_dev *input_dev;
237 int irq_pendwn;
238 int irq_datardy;
239 int error; 235 int error;
240 236
241 da9052 = dev_get_drvdata(pdev->dev.parent); 237 da9052 = dev_get_drvdata(pdev->dev.parent);
242 if (!da9052) 238 if (!da9052)
243 return -EINVAL; 239 return -EINVAL;
244 240
245 irq_pendwn = platform_get_irq_byname(pdev, "PENDWN");
246 irq_datardy = platform_get_irq_byname(pdev, "TSIRDY");
247 if (irq_pendwn < 0 || irq_datardy < 0) {
248 dev_err(da9052->dev, "Unable to determine device interrupts\n");
249 return -ENXIO;
250 }
251
252 tsi = kzalloc(sizeof(struct da9052_tsi), GFP_KERNEL); 241 tsi = kzalloc(sizeof(struct da9052_tsi), GFP_KERNEL);
253 input_dev = input_allocate_device(); 242 input_dev = input_allocate_device();
254 if (!tsi || !input_dev) { 243 if (!tsi || !input_dev) {
@@ -258,8 +247,6 @@ static int __devinit da9052_ts_probe(struct platform_device *pdev)
258 247
259 tsi->da9052 = da9052; 248 tsi->da9052 = da9052;
260 tsi->dev = input_dev; 249 tsi->dev = input_dev;
261 tsi->irq_pendwn = da9052->irq_base + irq_pendwn;
262 tsi->irq_datardy = da9052->irq_base + irq_datardy;
263 tsi->stopped = true; 250 tsi->stopped = true;
264 INIT_DELAYED_WORK(&tsi->ts_pen_work, da9052_ts_pen_work); 251 INIT_DELAYED_WORK(&tsi->ts_pen_work, da9052_ts_pen_work);
265 252
@@ -287,31 +274,25 @@ static int __devinit da9052_ts_probe(struct platform_device *pdev)
287 /* Disable ADC */ 274 /* Disable ADC */
288 da9052_ts_adc_toggle(tsi, false); 275 da9052_ts_adc_toggle(tsi, false);
289 276
290 error = request_threaded_irq(tsi->irq_pendwn, 277 error = da9052_request_irq(tsi->da9052, DA9052_IRQ_PENDOWN,
291 NULL, da9052_ts_pendwn_irq, 278 "pendown-irq", da9052_ts_pendwn_irq, tsi);
292 IRQF_TRIGGER_LOW | IRQF_ONESHOT,
293 "PENDWN", tsi);
294 if (error) { 279 if (error) {
295 dev_err(tsi->da9052->dev, 280 dev_err(tsi->da9052->dev,
296 "Failed to register PENDWN IRQ %d, error = %d\n", 281 "Failed to register PENDWN IRQ: %d\n", error);
297 tsi->irq_pendwn, error);
298 goto err_free_mem; 282 goto err_free_mem;
299 } 283 }
300 284
301 error = request_threaded_irq(tsi->irq_datardy, 285 error = da9052_request_irq(tsi->da9052, DA9052_IRQ_TSIREADY,
302 NULL, da9052_ts_datardy_irq, 286 "tsiready-irq", da9052_ts_datardy_irq, tsi);
303 IRQF_TRIGGER_LOW | IRQF_ONESHOT,
304 "TSIRDY", tsi);
305 if (error) { 287 if (error) {
306 dev_err(tsi->da9052->dev, 288 dev_err(tsi->da9052->dev,
307 "Failed to register TSIRDY IRQ %d, error = %d\n", 289 "Failed to register TSIRDY IRQ :%d\n", error);
308 tsi->irq_datardy, error);
309 goto err_free_pendwn_irq; 290 goto err_free_pendwn_irq;
310 } 291 }
311 292
312 /* Mask PEN_DOWN and TSI_READY events */ 293 /* Mask PEN_DOWN and TSI_READY events */
313 disable_irq(tsi->irq_pendwn); 294 da9052_disable_irq(tsi->da9052, DA9052_IRQ_PENDOWN);
314 disable_irq(tsi->irq_datardy); 295 da9052_disable_irq(tsi->da9052, DA9052_IRQ_TSIREADY);
315 296
316 error = da9052_configure_tsi(tsi); 297 error = da9052_configure_tsi(tsi);
317 if (error) 298 if (error)
@@ -326,9 +307,9 @@ static int __devinit da9052_ts_probe(struct platform_device *pdev)
326 return 0; 307 return 0;
327 308
328err_free_datardy_irq: 309err_free_datardy_irq:
329 free_irq(tsi->irq_datardy, tsi); 310 da9052_free_irq(tsi->da9052, DA9052_IRQ_TSIREADY, tsi);
330err_free_pendwn_irq: 311err_free_pendwn_irq:
331 free_irq(tsi->irq_pendwn, tsi); 312 da9052_free_irq(tsi->da9052, DA9052_IRQ_PENDOWN, tsi);
332err_free_mem: 313err_free_mem:
333 kfree(tsi); 314 kfree(tsi);
334 input_free_device(input_dev); 315 input_free_device(input_dev);
@@ -342,8 +323,8 @@ static int __devexit da9052_ts_remove(struct platform_device *pdev)
342 323
343 da9052_reg_write(tsi->da9052, DA9052_LDO9_REG, 0x19); 324 da9052_reg_write(tsi->da9052, DA9052_LDO9_REG, 0x19);
344 325
345 free_irq(tsi->irq_pendwn, tsi); 326 da9052_free_irq(tsi->da9052, DA9052_IRQ_TSIREADY, tsi);
346 free_irq(tsi->irq_datardy, tsi); 327 da9052_free_irq(tsi->da9052, DA9052_IRQ_PENDOWN, tsi);
347 328
348 input_unregister_device(tsi->dev); 329 input_unregister_device(tsi->dev);
349 kfree(tsi); 330 kfree(tsi);