]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.9.152/mfd-tps6586x-handle-interrupts-on-suspend.patch
Drop nfc patches from older trees
[thirdparty/kernel/stable-queue.git] / releases / 4.9.152 / mfd-tps6586x-handle-interrupts-on-suspend.patch
1 From ac4ca4b9f4623ba5e1ea7a582f286567c611e027 Mon Sep 17 00:00:00 2001
2 From: Jonathan Hunter <jonathanh@nvidia.com>
3 Date: Tue, 13 Nov 2018 08:56:31 +0000
4 Subject: mfd: tps6586x: Handle interrupts on suspend
5
6 From: Jonathan Hunter <jonathanh@nvidia.com>
7
8 commit ac4ca4b9f4623ba5e1ea7a582f286567c611e027 upstream.
9
10 The tps6586x driver creates an irqchip that is used by its various child
11 devices for managing interrupts. The tps6586x-rtc device is one of its
12 children that uses the tps6586x irqchip. When using the tps6586x-rtc as
13 a wake-up device from suspend, the following is seen:
14
15 PM: Syncing filesystems ... done.
16 Freezing user space processes ... (elapsed 0.001 seconds) done.
17 OOM killer disabled.
18 Freezing remaining freezable tasks ... (elapsed 0.000 seconds) done.
19 Disabling non-boot CPUs ...
20 Entering suspend state LP1
21 Enabling non-boot CPUs ...
22 CPU1 is up
23 tps6586x 3-0034: failed to read interrupt status
24 tps6586x 3-0034: failed to read interrupt status
25
26 The reason why the tps6586x interrupt status cannot be read is because
27 the tps6586x interrupt is not masked during suspend and when the
28 tps6586x-rtc interrupt occurs, to wake-up the device, the interrupt is
29 seen before the i2c controller has been resumed in order to read the
30 tps6586x interrupt status.
31
32 The tps6586x-rtc driver sets it's interrupt as a wake-up source during
33 suspend, which gets propagated to the parent tps6586x interrupt.
34 However, the tps6586x-rtc driver cannot disable it's interrupt during
35 suspend otherwise we would never be woken up and so the tps6586x must
36 disable it's interrupt instead.
37
38 Prevent the tps6586x interrupt handler from executing on exiting suspend
39 before the i2c controller has been resumed by disabling the tps6586x
40 interrupt on entering suspend and re-enabling it on resuming from
41 suspend.
42
43 Cc: stable@vger.kernel.org
44 Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
45 Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
46 Tested-by: Dmitry Osipenko <digetx@gmail.com>
47 Acked-by: Thierry Reding <treding@nvidia.com>
48 Signed-off-by: Lee Jones <lee.jones@linaro.org>
49 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
50
51 ---
52 drivers/mfd/tps6586x.c | 24 ++++++++++++++++++++++++
53 1 file changed, 24 insertions(+)
54
55 --- a/drivers/mfd/tps6586x.c
56 +++ b/drivers/mfd/tps6586x.c
57 @@ -594,6 +594,29 @@ static int tps6586x_i2c_remove(struct i2
58 return 0;
59 }
60
61 +static int __maybe_unused tps6586x_i2c_suspend(struct device *dev)
62 +{
63 + struct tps6586x *tps6586x = dev_get_drvdata(dev);
64 +
65 + if (tps6586x->client->irq)
66 + disable_irq(tps6586x->client->irq);
67 +
68 + return 0;
69 +}
70 +
71 +static int __maybe_unused tps6586x_i2c_resume(struct device *dev)
72 +{
73 + struct tps6586x *tps6586x = dev_get_drvdata(dev);
74 +
75 + if (tps6586x->client->irq)
76 + enable_irq(tps6586x->client->irq);
77 +
78 + return 0;
79 +}
80 +
81 +static SIMPLE_DEV_PM_OPS(tps6586x_pm_ops, tps6586x_i2c_suspend,
82 + tps6586x_i2c_resume);
83 +
84 static const struct i2c_device_id tps6586x_id_table[] = {
85 { "tps6586x", 0 },
86 { },
87 @@ -604,6 +627,7 @@ static struct i2c_driver tps6586x_driver
88 .driver = {
89 .name = "tps6586x",
90 .of_match_table = of_match_ptr(tps6586x_of_match),
91 + .pm = &tps6586x_pm_ops,
92 },
93 .probe = tps6586x_i2c_probe,
94 .remove = tps6586x_i2c_remove,