1 From da443bc125265cae24a0e5f7d1c7bba196a9319f Mon Sep 17 00:00:00 2001
2 From: Linus Walleij <linus.walleij@linaro.org>
3 Date: Thu, 22 Feb 2018 08:34:35 +0100
4 Subject: [PATCH 26/31] power: gemini-poweroff: Avoid spurious poweroff
6 On the D-Link DIR-685 we get spurious poweroff from
7 infrared. Since that block (CIR) doesn't even have a
8 driver this can be safely ignored, we can revisit this
9 code once we have a device supporting CIR.
11 On the D-Link DNS-313 we get spurious poweroff from
12 the power button. This appears to be an initialization
13 issue: we need to enable the block (start the state
14 machine) before we clear any dangling IRQ.
16 This patch fixes both issues.
18 Fixes: f7a388d6cd1c ("power: reset: Add a driver for the Gemini poweroff")
19 Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
22 - Fix both issues and rename the patch.
23 - Proper commit message with specifics.
25 drivers/power/reset/gemini-poweroff.c | 30 +++++++++++++++++-------------
26 1 file changed, 17 insertions(+), 13 deletions(-)
28 --- a/drivers/power/reset/gemini-poweroff.c
29 +++ b/drivers/power/reset/gemini-poweroff.c
30 @@ -47,8 +47,12 @@ static irqreturn_t gemini_powerbutton_in
34 - dev_info(gpw->dev, "infrared poweroff\n");
35 - orderly_poweroff(true);
37 + * We do not yet have a driver for the infrared
38 + * controller so it can cause spurious poweroff
39 + * events. Ignore those for now.
41 + dev_info(gpw->dev, "infrared poweroff - ignored\n");
44 dev_info(gpw->dev, "RTC poweroff\n");
45 @@ -116,7 +120,17 @@ static int gemini_poweroff_probe(struct
49 - /* Clear the power management IRQ */
51 + * Enable the power controller. This is crucial on Gemini
52 + * systems: if this is not done, pressing the power button
53 + * will result in unconditional poweroff without any warning.
54 + * This makes the kernel handle the poweroff.
56 + val = readl(gpw->base + GEMINI_PWC_CTRLREG);
57 + val |= GEMINI_CTRL_ENABLE;
58 + writel(val, gpw->base + GEMINI_PWC_CTRLREG);
60 + /* Now that the state machine is active, clear the IRQ */
61 val = readl(gpw->base + GEMINI_PWC_CTRLREG);
62 val |= GEMINI_CTRL_IRQ_CLR;
63 writel(val, gpw->base + GEMINI_PWC_CTRLREG);
64 @@ -129,16 +143,6 @@ static int gemini_poweroff_probe(struct
65 pm_power_off = gemini_poweroff;
69 - * Enable the power controller. This is crucial on Gemini
70 - * systems: if this is not done, pressing the power button
71 - * will result in unconditional poweroff without any warning.
72 - * This makes the kernel handle the poweroff.
74 - val = readl(gpw->base + GEMINI_PWC_CTRLREG);
75 - val |= GEMINI_CTRL_ENABLE;
76 - writel(val, gpw->base + GEMINI_PWC_CTRLREG);
78 dev_info(dev, "Gemini poweroff driver registered\n");