power: gemini-poweroff: Avoid more spurious poweroffs
authorLinus Walleij <linus.walleij@linaro.org>
Sun, 17 Jun 2018 22:58:19 +0000 (00:58 +0200)
committerSebastian Reichel <sebastian.reichel@collabora.co.uk>
Fri, 6 Jul 2018 14:34:01 +0000 (16:34 +0200)
Even after the previous fix I have experienced more spurious
poweroffs on the gemini SoC. After this fix it finally seems
to go away.

Fixes: f7a388d6cd1c ("power: reset: Add a driver for the Gemini poweroff")
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
drivers/power/reset/gemini-poweroff.c

index 2ac291a..90e35c0 100644 (file)
@@ -130,7 +130,17 @@ static int gemini_poweroff_probe(struct platform_device *pdev)
        val |= GEMINI_CTRL_ENABLE;
        writel(val, gpw->base + GEMINI_PWC_CTRLREG);
 
-       /* Now that the state machine is active, clear the IRQ */
+       /* Clear the IRQ */
+       val = readl(gpw->base + GEMINI_PWC_CTRLREG);
+       val |= GEMINI_CTRL_IRQ_CLR;
+       writel(val, gpw->base + GEMINI_PWC_CTRLREG);
+
+       /* Wait for this to clear */
+       val = readl(gpw->base + GEMINI_PWC_STATREG);
+       while (val & 0x70U)
+               val = readl(gpw->base + GEMINI_PWC_STATREG);
+
+       /* Clear the IRQ again */
        val = readl(gpw->base + GEMINI_PWC_CTRLREG);
        val |= GEMINI_CTRL_IRQ_CLR;
        writel(val, gpw->base + GEMINI_PWC_CTRLREG);