power: gemini-poweroff: Avoid more spurious poweroffs

Message ID 20180617225819.32586-1-linus.walleij@linaro.org
State Accepted
Commit ada1de89f34ea338fb4406e61dc1a95edcf65213
Headers show
Series
  • power: gemini-poweroff: Avoid more spurious poweroffs
Related show

Commit Message

Linus Walleij June 17, 2018, 10:58 p.m.
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>

---
 drivers/power/reset/gemini-poweroff.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

-- 
2.17.1

Comments

Linus Walleij July 4, 2018, 5:24 p.m. | #1
On Mon, Jun 18, 2018 at 1:00 AM Linus Walleij <linus.walleij@linaro.org> wrote:

> 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>


Ping on this?

Sebastian, can it be applied?

Yours,
Linus Walleij
Sebastian Reichel July 6, 2018, 2:34 p.m. | #2
Hi,

On Mon, Jun 18, 2018 at 12:58:19AM +0200, Linus Walleij wrote:
> 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>

> ---


Thanks, queued to power-supply-fixes.

-- Sebastian

>  drivers/power/reset/gemini-poweroff.c | 12 +++++++++++-

>  1 file changed, 11 insertions(+), 1 deletion(-)

> 

> diff --git a/drivers/power/reset/gemini-poweroff.c b/drivers/power/reset/gemini-poweroff.c

> index 2ac291af1265..90e35c07240a 100644

> --- a/drivers/power/reset/gemini-poweroff.c

> +++ b/drivers/power/reset/gemini-poweroff.c

> @@ -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);

> -- 

> 2.17.1

>

Patch

diff --git a/drivers/power/reset/gemini-poweroff.c b/drivers/power/reset/gemini-poweroff.c
index 2ac291af1265..90e35c07240a 100644
--- a/drivers/power/reset/gemini-poweroff.c
+++ b/drivers/power/reset/gemini-poweroff.c
@@ -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);