All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mfd: sprd: Add wakeup capability for PMIC irq
@ 2020-05-07  6:40 Baolin Wang
  2020-05-25  8:06 ` Chunyan Zhang
  2020-05-26  8:23 ` Lee Jones
  0 siblings, 2 replies; 3+ messages in thread
From: Baolin Wang @ 2020-05-07  6:40 UTC (permalink / raw)
  To: lee.jones; +Cc: orsonzhai, zhang.lyra, baolin.wang7, linux-kernel

When changing to use suspend-to-idle to save power, the PMIC irq can not
wakeup the system due to lack of wakeup capability, which will cause
the sub-irqs (such as power key) of the PMIC can not wake up the system.
Thus we can add the wakeup capability for PMIC irq to solve this issue,
as well as removing the IRQF_NO_SUSPEND flag to allow PMIC irq to be
a wakeup source.

Reported-by: Chunyan Zhang <zhang.lyra@gmail.com>
Signed-off-by: Baolin Wang <baolin.wang7@gmail.com>
---
 drivers/mfd/sprd-sc27xx-spi.c | 30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/drivers/mfd/sprd-sc27xx-spi.c b/drivers/mfd/sprd-sc27xx-spi.c
index ebdf2f1..3064a60 100644
--- a/drivers/mfd/sprd-sc27xx-spi.c
+++ b/drivers/mfd/sprd-sc27xx-spi.c
@@ -256,7 +256,7 @@ static int sprd_pmic_probe(struct spi_device *spi)
 	}
 
 	ret = devm_regmap_add_irq_chip(&spi->dev, ddata->regmap, ddata->irq,
-				       IRQF_ONESHOT | IRQF_NO_SUSPEND, 0,
+				       IRQF_ONESHOT, 0,
 				       &ddata->irq_chip, &ddata->irq_data);
 	if (ret) {
 		dev_err(&spi->dev, "Failed to add PMIC irq chip %d\n", ret);
@@ -272,9 +272,36 @@ static int sprd_pmic_probe(struct spi_device *spi)
 		return ret;
 	}
 
+	device_init_wakeup(&spi->dev, 1);
 	return 0;
 }
 
+#ifdef CONFIG_PM_SLEEP
+static int sprd_pmic_suspend(struct device *dev)
+{
+	struct spi_device *spi = to_spi_device(dev);
+	struct sprd_pmic *ddata = spi_get_drvdata(spi);
+
+	if (device_may_wakeup(dev))
+		enable_irq_wake(ddata->irq);
+
+	return 0;
+}
+
+static int sprd_pmic_resume(struct device *dev)
+{
+	struct spi_device *spi = to_spi_device(dev);
+	struct sprd_pmic *ddata = spi_get_drvdata(spi);
+
+	if (device_may_wakeup(dev))
+		disable_irq_wake(ddata->irq);
+
+	return 0;
+}
+#endif
+
+static SIMPLE_DEV_PM_OPS(sprd_pmic_pm_ops, sprd_pmic_suspend, sprd_pmic_resume);
+
 static const struct of_device_id sprd_pmic_match[] = {
 	{ .compatible = "sprd,sc2731", .data = &sc2731_data },
 	{},
@@ -286,6 +313,7 @@ static int sprd_pmic_probe(struct spi_device *spi)
 		.name = "sc27xx-pmic",
 		.bus = &spi_bus_type,
 		.of_match_table = sprd_pmic_match,
+		.pm = &sprd_pmic_pm_ops,
 	},
 	.probe = sprd_pmic_probe,
 };
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] mfd: sprd: Add wakeup capability for PMIC irq
  2020-05-07  6:40 [PATCH] mfd: sprd: Add wakeup capability for PMIC irq Baolin Wang
@ 2020-05-25  8:06 ` Chunyan Zhang
  2020-05-26  8:23 ` Lee Jones
  1 sibling, 0 replies; 3+ messages in thread
From: Chunyan Zhang @ 2020-05-25  8:06 UTC (permalink / raw)
  To: Baolin Wang; +Cc: Lee Jones, Orson Zhai, Linux Kernel Mailing List

On Thu, 7 May 2020 at 14:40, Baolin Wang <baolin.wang7@gmail.com> wrote:
>
> When changing to use suspend-to-idle to save power, the PMIC irq can not
> wakeup the system due to lack of wakeup capability, which will cause
> the sub-irqs (such as power key) of the PMIC can not wake up the system.
> Thus we can add the wakeup capability for PMIC irq to solve this issue,
> as well as removing the IRQF_NO_SUSPEND flag to allow PMIC irq to be
> a wakeup source.
>
> Reported-by: Chunyan Zhang <zhang.lyra@gmail.com>
> Signed-off-by: Baolin Wang <baolin.wang7@gmail.com>

Thanks for fixing this issue, with this patch, power key can wakeup
s2idle correctly on my sprd board.

Tested-by: Chunyan Zhang <chunyan.zhang@unisoc.com>

> ---
>  drivers/mfd/sprd-sc27xx-spi.c | 30 +++++++++++++++++++++++++++++-
>  1 file changed, 29 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mfd/sprd-sc27xx-spi.c b/drivers/mfd/sprd-sc27xx-spi.c
> index ebdf2f1..3064a60 100644
> --- a/drivers/mfd/sprd-sc27xx-spi.c
> +++ b/drivers/mfd/sprd-sc27xx-spi.c
> @@ -256,7 +256,7 @@ static int sprd_pmic_probe(struct spi_device *spi)
>         }
>
>         ret = devm_regmap_add_irq_chip(&spi->dev, ddata->regmap, ddata->irq,
> -                                      IRQF_ONESHOT | IRQF_NO_SUSPEND, 0,
> +                                      IRQF_ONESHOT, 0,
>                                        &ddata->irq_chip, &ddata->irq_data);
>         if (ret) {
>                 dev_err(&spi->dev, "Failed to add PMIC irq chip %d\n", ret);
> @@ -272,9 +272,36 @@ static int sprd_pmic_probe(struct spi_device *spi)
>                 return ret;
>         }
>
> +       device_init_wakeup(&spi->dev, 1);
>         return 0;
>  }
>
> +#ifdef CONFIG_PM_SLEEP
> +static int sprd_pmic_suspend(struct device *dev)
> +{
> +       struct spi_device *spi = to_spi_device(dev);
> +       struct sprd_pmic *ddata = spi_get_drvdata(spi);
> +
> +       if (device_may_wakeup(dev))
> +               enable_irq_wake(ddata->irq);
> +
> +       return 0;
> +}
> +
> +static int sprd_pmic_resume(struct device *dev)
> +{
> +       struct spi_device *spi = to_spi_device(dev);
> +       struct sprd_pmic *ddata = spi_get_drvdata(spi);
> +
> +       if (device_may_wakeup(dev))
> +               disable_irq_wake(ddata->irq);
> +
> +       return 0;
> +}
> +#endif
> +
> +static SIMPLE_DEV_PM_OPS(sprd_pmic_pm_ops, sprd_pmic_suspend, sprd_pmic_resume);
> +
>  static const struct of_device_id sprd_pmic_match[] = {
>         { .compatible = "sprd,sc2731", .data = &sc2731_data },
>         {},
> @@ -286,6 +313,7 @@ static int sprd_pmic_probe(struct spi_device *spi)
>                 .name = "sc27xx-pmic",
>                 .bus = &spi_bus_type,
>                 .of_match_table = sprd_pmic_match,
> +               .pm = &sprd_pmic_pm_ops,
>         },
>         .probe = sprd_pmic_probe,
>  };
> --
> 1.9.1
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mfd: sprd: Add wakeup capability for PMIC irq
  2020-05-07  6:40 [PATCH] mfd: sprd: Add wakeup capability for PMIC irq Baolin Wang
  2020-05-25  8:06 ` Chunyan Zhang
@ 2020-05-26  8:23 ` Lee Jones
  1 sibling, 0 replies; 3+ messages in thread
From: Lee Jones @ 2020-05-26  8:23 UTC (permalink / raw)
  To: Baolin Wang; +Cc: orsonzhai, zhang.lyra, linux-kernel

On Thu, 07 May 2020, Baolin Wang wrote:

> When changing to use suspend-to-idle to save power, the PMIC irq can not
> wakeup the system due to lack of wakeup capability, which will cause
> the sub-irqs (such as power key) of the PMIC can not wake up the system.
> Thus we can add the wakeup capability for PMIC irq to solve this issue,
> as well as removing the IRQF_NO_SUSPEND flag to allow PMIC irq to be
> a wakeup source.
> 
> Reported-by: Chunyan Zhang <zhang.lyra@gmail.com>
> Signed-off-by: Baolin Wang <baolin.wang7@gmail.com>
> ---
>  drivers/mfd/sprd-sc27xx-spi.c | 30 +++++++++++++++++++++++++++++-
>  1 file changed, 29 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mfd/sprd-sc27xx-spi.c b/drivers/mfd/sprd-sc27xx-spi.c
> index ebdf2f1..3064a60 100644
> --- a/drivers/mfd/sprd-sc27xx-spi.c
> +++ b/drivers/mfd/sprd-sc27xx-spi.c
> @@ -256,7 +256,7 @@ static int sprd_pmic_probe(struct spi_device *spi)
>  	}
>  
>  	ret = devm_regmap_add_irq_chip(&spi->dev, ddata->regmap, ddata->irq,
> -				       IRQF_ONESHOT | IRQF_NO_SUSPEND, 0,
> +				       IRQF_ONESHOT, 0,
>  				       &ddata->irq_chip, &ddata->irq_data);
>  	if (ret) {
>  		dev_err(&spi->dev, "Failed to add PMIC irq chip %d\n", ret);
> @@ -272,9 +272,36 @@ static int sprd_pmic_probe(struct spi_device *spi)
>  		return ret;
>  	}
>  
> +	device_init_wakeup(&spi->dev, 1);

This is a bool.  Please use 'true'.

>  	return 0;
>  }
>  
> +#ifdef CONFIG_PM_SLEEP
> +static int sprd_pmic_suspend(struct device *dev)
> +{
> +	struct spi_device *spi = to_spi_device(dev);
> +	struct sprd_pmic *ddata = spi_get_drvdata(spi);

Why don't you just use:

  dev_get_drvdata(dev)

... and skip the superfluous step?

> +	if (device_may_wakeup(dev))
> +		enable_irq_wake(ddata->irq);
> +
> +	return 0;
> +}
> +
> +static int sprd_pmic_resume(struct device *dev)
> +{
> +	struct spi_device *spi = to_spi_device(dev);
> +	struct sprd_pmic *ddata = spi_get_drvdata(spi);

As above.

> +	if (device_may_wakeup(dev))
> +		disable_irq_wake(ddata->irq);
> +
> +	return 0;
> +}
> +#endif
> +
> +static SIMPLE_DEV_PM_OPS(sprd_pmic_pm_ops, sprd_pmic_suspend, sprd_pmic_resume);
> +
>  static const struct of_device_id sprd_pmic_match[] = {
>  	{ .compatible = "sprd,sc2731", .data = &sc2731_data },
>  	{},
> @@ -286,6 +313,7 @@ static int sprd_pmic_probe(struct spi_device *spi)
>  		.name = "sc27xx-pmic",
>  		.bus = &spi_bus_type,
>  		.of_match_table = sprd_pmic_match,
> +		.pm = &sprd_pmic_pm_ops,
>  	},
>  	.probe = sprd_pmic_probe,
>  };

-- 
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-05-26  8:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-07  6:40 [PATCH] mfd: sprd: Add wakeup capability for PMIC irq Baolin Wang
2020-05-25  8:06 ` Chunyan Zhang
2020-05-26  8:23 ` Lee Jones

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.