.. | .. |
---|
27 | 27 | #include <linux/of.h> |
---|
28 | 28 | #include <linux/of_device.h> |
---|
29 | 29 | #include <linux/sort.h> |
---|
| 30 | +#include <linux/pm_wakeirq.h> |
---|
30 | 31 | |
---|
31 | 32 | #include <linux/mfd/ti_am335x_tscadc.h> |
---|
32 | 33 | |
---|
.. | .. |
---|
46 | 47 | struct titsc { |
---|
47 | 48 | struct input_dev *input; |
---|
48 | 49 | struct ti_tscadc_dev *mfd_tscadc; |
---|
| 50 | + struct device *dev; |
---|
49 | 51 | unsigned int irq; |
---|
50 | 52 | unsigned int wires; |
---|
51 | 53 | unsigned int x_plate_resistance; |
---|
.. | .. |
---|
276 | 278 | if (status & IRQENB_HW_PEN) { |
---|
277 | 279 | ts_dev->pen_down = true; |
---|
278 | 280 | irqclr |= IRQENB_HW_PEN; |
---|
279 | | - pm_stay_awake(ts_dev->mfd_tscadc->dev); |
---|
| 281 | + pm_stay_awake(ts_dev->dev); |
---|
280 | 282 | } |
---|
281 | 283 | |
---|
282 | 284 | if (status & IRQENB_PENUP) { |
---|
.. | .. |
---|
286 | 288 | input_report_key(input_dev, BTN_TOUCH, 0); |
---|
287 | 289 | input_report_abs(input_dev, ABS_PRESSURE, 0); |
---|
288 | 290 | input_sync(input_dev); |
---|
289 | | - pm_relax(ts_dev->mfd_tscadc->dev); |
---|
| 291 | + pm_relax(ts_dev->dev); |
---|
290 | 292 | } else { |
---|
291 | 293 | ts_dev->pen_down = true; |
---|
292 | 294 | } |
---|
.. | .. |
---|
422 | 424 | ts_dev->mfd_tscadc = tscadc_dev; |
---|
423 | 425 | ts_dev->input = input_dev; |
---|
424 | 426 | ts_dev->irq = tscadc_dev->irq; |
---|
| 427 | + ts_dev->dev = &pdev->dev; |
---|
425 | 428 | |
---|
426 | 429 | err = titsc_parse_dt(pdev, ts_dev); |
---|
427 | 430 | if (err) { |
---|
.. | .. |
---|
435 | 438 | dev_err(&pdev->dev, "failed to allocate irq.\n"); |
---|
436 | 439 | goto err_free_mem; |
---|
437 | 440 | } |
---|
| 441 | + |
---|
| 442 | + device_init_wakeup(&pdev->dev, true); |
---|
| 443 | + err = dev_pm_set_wake_irq(&pdev->dev, ts_dev->irq); |
---|
| 444 | + if (err) |
---|
| 445 | + dev_err(&pdev->dev, "irq wake enable failed.\n"); |
---|
438 | 446 | |
---|
439 | 447 | titsc_writel(ts_dev, REG_IRQSTATUS, TSC_IRQENB_MASK); |
---|
440 | 448 | titsc_writel(ts_dev, REG_IRQENABLE, IRQENB_FIFO0THRES); |
---|
.. | .. |
---|
467 | 475 | return 0; |
---|
468 | 476 | |
---|
469 | 477 | err_free_irq: |
---|
| 478 | + dev_pm_clear_wake_irq(&pdev->dev); |
---|
| 479 | + device_init_wakeup(&pdev->dev, false); |
---|
470 | 480 | free_irq(ts_dev->irq, ts_dev); |
---|
471 | 481 | err_free_mem: |
---|
472 | 482 | input_free_device(input_dev); |
---|
.. | .. |
---|
479 | 489 | struct titsc *ts_dev = platform_get_drvdata(pdev); |
---|
480 | 490 | u32 steps; |
---|
481 | 491 | |
---|
| 492 | + dev_pm_clear_wake_irq(&pdev->dev); |
---|
| 493 | + device_init_wakeup(&pdev->dev, false); |
---|
482 | 494 | free_irq(ts_dev->irq, ts_dev); |
---|
483 | 495 | |
---|
484 | 496 | /* total steps followed by the enable mask */ |
---|
.. | .. |
---|
495 | 507 | static int __maybe_unused titsc_suspend(struct device *dev) |
---|
496 | 508 | { |
---|
497 | 509 | struct titsc *ts_dev = dev_get_drvdata(dev); |
---|
498 | | - struct ti_tscadc_dev *tscadc_dev; |
---|
499 | 510 | unsigned int idle; |
---|
500 | 511 | |
---|
501 | | - tscadc_dev = ti_tscadc_dev_get(to_platform_device(dev)); |
---|
502 | | - if (device_may_wakeup(tscadc_dev->dev)) { |
---|
| 512 | + if (device_may_wakeup(dev)) { |
---|
503 | 513 | titsc_writel(ts_dev, REG_IRQSTATUS, TSC_IRQENB_MASK); |
---|
504 | 514 | idle = titsc_readl(ts_dev, REG_IRQENABLE); |
---|
505 | 515 | titsc_writel(ts_dev, REG_IRQENABLE, |
---|
.. | .. |
---|
512 | 522 | static int __maybe_unused titsc_resume(struct device *dev) |
---|
513 | 523 | { |
---|
514 | 524 | struct titsc *ts_dev = dev_get_drvdata(dev); |
---|
515 | | - struct ti_tscadc_dev *tscadc_dev; |
---|
516 | 525 | |
---|
517 | | - tscadc_dev = ti_tscadc_dev_get(to_platform_device(dev)); |
---|
518 | | - if (device_may_wakeup(tscadc_dev->dev)) { |
---|
| 526 | + if (device_may_wakeup(dev)) { |
---|
519 | 527 | titsc_writel(ts_dev, REG_IRQWAKEUP, |
---|
520 | 528 | 0x00); |
---|
521 | 529 | titsc_writel(ts_dev, REG_IRQCLR, IRQENB_HW_PEN); |
---|
522 | | - pm_relax(ts_dev->mfd_tscadc->dev); |
---|
| 530 | + pm_relax(dev); |
---|
523 | 531 | } |
---|
524 | 532 | titsc_step_config(ts_dev); |
---|
525 | 533 | titsc_writel(ts_dev, REG_FIFO0THR, |
---|