hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/drivers/input/touchscreen/ti_am335x_tsc.c
....@@ -27,6 +27,7 @@
2727 #include <linux/of.h>
2828 #include <linux/of_device.h>
2929 #include <linux/sort.h>
30
+#include <linux/pm_wakeirq.h>
3031
3132 #include <linux/mfd/ti_am335x_tscadc.h>
3233
....@@ -46,6 +47,7 @@
4647 struct titsc {
4748 struct input_dev *input;
4849 struct ti_tscadc_dev *mfd_tscadc;
50
+ struct device *dev;
4951 unsigned int irq;
5052 unsigned int wires;
5153 unsigned int x_plate_resistance;
....@@ -276,7 +278,7 @@
276278 if (status & IRQENB_HW_PEN) {
277279 ts_dev->pen_down = true;
278280 irqclr |= IRQENB_HW_PEN;
279
- pm_stay_awake(ts_dev->mfd_tscadc->dev);
281
+ pm_stay_awake(ts_dev->dev);
280282 }
281283
282284 if (status & IRQENB_PENUP) {
....@@ -286,7 +288,7 @@
286288 input_report_key(input_dev, BTN_TOUCH, 0);
287289 input_report_abs(input_dev, ABS_PRESSURE, 0);
288290 input_sync(input_dev);
289
- pm_relax(ts_dev->mfd_tscadc->dev);
291
+ pm_relax(ts_dev->dev);
290292 } else {
291293 ts_dev->pen_down = true;
292294 }
....@@ -422,6 +424,7 @@
422424 ts_dev->mfd_tscadc = tscadc_dev;
423425 ts_dev->input = input_dev;
424426 ts_dev->irq = tscadc_dev->irq;
427
+ ts_dev->dev = &pdev->dev;
425428
426429 err = titsc_parse_dt(pdev, ts_dev);
427430 if (err) {
....@@ -435,6 +438,11 @@
435438 dev_err(&pdev->dev, "failed to allocate irq.\n");
436439 goto err_free_mem;
437440 }
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");
438446
439447 titsc_writel(ts_dev, REG_IRQSTATUS, TSC_IRQENB_MASK);
440448 titsc_writel(ts_dev, REG_IRQENABLE, IRQENB_FIFO0THRES);
....@@ -467,6 +475,8 @@
467475 return 0;
468476
469477 err_free_irq:
478
+ dev_pm_clear_wake_irq(&pdev->dev);
479
+ device_init_wakeup(&pdev->dev, false);
470480 free_irq(ts_dev->irq, ts_dev);
471481 err_free_mem:
472482 input_free_device(input_dev);
....@@ -479,6 +489,8 @@
479489 struct titsc *ts_dev = platform_get_drvdata(pdev);
480490 u32 steps;
481491
492
+ dev_pm_clear_wake_irq(&pdev->dev);
493
+ device_init_wakeup(&pdev->dev, false);
482494 free_irq(ts_dev->irq, ts_dev);
483495
484496 /* total steps followed by the enable mask */
....@@ -495,11 +507,9 @@
495507 static int __maybe_unused titsc_suspend(struct device *dev)
496508 {
497509 struct titsc *ts_dev = dev_get_drvdata(dev);
498
- struct ti_tscadc_dev *tscadc_dev;
499510 unsigned int idle;
500511
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)) {
503513 titsc_writel(ts_dev, REG_IRQSTATUS, TSC_IRQENB_MASK);
504514 idle = titsc_readl(ts_dev, REG_IRQENABLE);
505515 titsc_writel(ts_dev, REG_IRQENABLE,
....@@ -512,14 +522,12 @@
512522 static int __maybe_unused titsc_resume(struct device *dev)
513523 {
514524 struct titsc *ts_dev = dev_get_drvdata(dev);
515
- struct ti_tscadc_dev *tscadc_dev;
516525
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)) {
519527 titsc_writel(ts_dev, REG_IRQWAKEUP,
520528 0x00);
521529 titsc_writel(ts_dev, REG_IRQCLR, IRQENB_HW_PEN);
522
- pm_relax(ts_dev->mfd_tscadc->dev);
530
+ pm_relax(dev);
523531 }
524532 titsc_step_config(ts_dev);
525533 titsc_writel(ts_dev, REG_FIFO0THR,