Skip to contentSkip to conversation

mfd: sprd: Add wakeup capability for PMIC irq

PATCH Superseded Chunyan Zhang 2 participants 5 messages May 27, 2020 – Jun 5, 2020

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Chunyan Zhang

author reviewer
#0 lore raw

PATCH v2 1/1 mfd: sprd: Add wakeup capability for PMIC irq

From: Baolin Wang <[email protected]>

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.

---
Changes from v1:
* addressed comments from Lee;
* added tested-by from Chunyan.
(This patch is rebased on branch for-mfd-next)

---
 drivers/mfd/sprd-sc27xx-spi.c | 28 +++++++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)
drivers/mfd/sprd-sc27xx-spi.c +27 -1
index 33336cde4724..adb4a1b13332 100644
@@ -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,34 @@ static int sprd_pmic_probe(struct spi_device *spi)
 		return ret;
 	}
 
+	device_init_wakeup(&spi->dev, true);
 	return 0;
 }
 
+#ifdef CONFIG_PM_SLEEP
+static int sprd_pmic_suspend(struct device *dev)
+{
+	struct sprd_pmic *ddata = dev_get_drvdata(dev);
+
+	if (device_may_wakeup(dev))
+		enable_irq_wake(ddata->irq);
+
+	return 0;
+}
+
+static int sprd_pmic_resume(struct device *dev)
+{
+	struct sprd_pmic *ddata = dev_get_drvdata(dev);
+
+	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 },
 	{},
@@ -285,6 +310,7 @@ static struct spi_driver sprd_pmic_driver = {
 	.driver = {
 		.name = "sc27xx-pmic",
 		.of_match_table = sprd_pmic_match,
+		.pm = &sprd_pmic_pm_ops,
 	},
 	.probe = sprd_pmic_probe,
 };
Signature · 1 line
2.20.1
author reviewer
#1 lore raw

Hi Lee,

Quoted 10 lines · Chunyan Zhang

From: Baolin Wang <[email protected]>

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.

Quoted 8 lines

---
Changes from v1:
* addressed comments from Lee;
* added tested-by from Chunyan.
(This patch is rebased on branch for-mfd-next)

Could you please pick up this patch if there's no more comments :)

Thanks,
Chunyan

Quoted 63 lines
---
 drivers/mfd/sprd-sc27xx-spi.c | 28 +++++++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)
drivers/mfd/sprd-sc27xx-spi.c +27 -2
index 33336cde4724..adb4a1b13332 100644
@@ -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,34 @@ static int sprd_pmic_probe(struct spi_device *spi)
                return ret;
        }
 
+       device_init_wakeup(&spi->dev, true);
        return 0;
 }
 
+#ifdef CONFIG_PM_SLEEP
+static int sprd_pmic_suspend(struct device *dev)
+{
+       struct sprd_pmic *ddata = dev_get_drvdata(dev);
+
+       if (device_may_wakeup(dev))
+               enable_irq_wake(ddata->irq);
+
+       return 0;
+}
+
+static int sprd_pmic_resume(struct device *dev)
+{
+       struct sprd_pmic *ddata = dev_get_drvdata(dev);
+
+       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 },
        {},
@@ -285,6 +310,7 @@ static struct spi_driver sprd_pmic_driver = {
        .driver = {
                .name = "sc27xx-pmic",
                .of_match_table = sprd_pmic_match,
+               .pm = &sprd_pmic_pm_ops,
        },
        .probe = sprd_pmic_probe,
 };
--

2.20.1

#2 lore raw
Quoted 22 lines · Chunyan Zhang

Hi Lee,

Quoted 10 lines · Chunyan Zhang

From: Baolin Wang <[email protected]>

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.

Quoted 8 lines

---
Changes from v1:
* addressed comments from Lee;
* added tested-by from Chunyan.
(This patch is rebased on branch for-mfd-next)

Quoted 1 line

Could you please pick up this patch if there's no more comments :)

Please don't send contentless nags. Your patch is in my queue.

The merge-window is currently open, which is a) a busy time for Maintainers and b) a time where some of us take a little breather before the next release. Please wait until -rc1 has been released before sending out your [RESENDS].

Quoted 61 lines
Quoted 61 lines
---
 drivers/mfd/sprd-sc27xx-spi.c | 28 +++++++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)
drivers/mfd/sprd-sc27xx-spi.c +27 -1
index 33336cde4724..adb4a1b13332 100644
@@ -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,34 @@ static int sprd_pmic_probe(struct spi_device *spi)
                return ret;
        }
 
+       device_init_wakeup(&spi->dev, true);
        return 0;
 }
 
+#ifdef CONFIG_PM_SLEEP
+static int sprd_pmic_suspend(struct device *dev)
+{
+       struct sprd_pmic *ddata = dev_get_drvdata(dev);
+
+       if (device_may_wakeup(dev))
+               enable_irq_wake(ddata->irq);
+
+       return 0;
+}
+
+static int sprd_pmic_resume(struct device *dev)
+{
+       struct sprd_pmic *ddata = dev_get_drvdata(dev);
+
+       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 },
        {},
@@ -285,6 +310,7 @@ static struct spi_driver sprd_pmic_driver = {
        .driver = {
                .name = "sc27xx-pmic",
                .of_match_table = sprd_pmic_match,
+               .pm = &sprd_pmic_pm_ops,
        },
        .probe = sprd_pmic_probe,
 };
Signature · 4 lines
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
author reviewer
#3 lore raw
Quoted 25 lines · Lee Jones
Quoted 22 lines · Chunyan Zhang

Hi Lee,

Quoted 18 lines · Chunyan Zhang

From: Baolin Wang <[email protected]>

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.

---
Changes from v1:
* addressed comments from Lee;
* added tested-by from Chunyan.
(This patch is rebased on branch for-mfd-next)

Quoted 5 lines
Quoted 1 line

Could you please pick up this patch if there's no more comments :)

Please don't send contentless nags. Your patch is in my queue.

The merge-window is currently open, which is a) a busy time for

I understand that very much, and also appreciate all maintainer's works for the great opensource project.
And just because of that I know you're busy during merge-window, I was worried that this patch was left out, since I didn't see it at mfd-next.
I apologize if the last email made you unhappay. I will not send reminder email to you anymore.

Best regards,
Chunyan

Quoted 71 lines

Maintainers and b) a time where some of us take a little breather before the next release. Please wait until -rc1 has been released before sending out your [RESENDS].

Quoted 53 lines
Quoted 53 lines
---
 drivers/mfd/sprd-sc27xx-spi.c | 28 +++++++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)
drivers/mfd/sprd-sc27xx-spi.c +26 -1
index 33336cde4724..adb4a1b13332 100644
@@ -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,34 @@ static int sprd_pmic_probe(struct spi_device *spi)
                return ret;
        }
 
+       device_init_wakeup(&spi->dev, true);
        return 0;
 }
 
+#ifdef CONFIG_PM_SLEEP
+static int sprd_pmic_suspend(struct device *dev)
+{
+       struct sprd_pmic *ddata = dev_get_drvdata(dev);
+
+       if (device_may_wakeup(dev))
+               enable_irq_wake(ddata->irq);
+
+       return 0;
+}
+
+static int sprd_pmic_resume(struct device *dev)
+{
+       struct sprd_pmic *ddata = dev_get_drvdata(dev);
+
+       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 },
        {},
@@ -285,6 +310,7 @@ static struct spi_driver sprd_pmic_driver = {
Quoted 8 lines

drivers/mfd/sprd-sc27xx-spi.c static struct spi_driver sprd_pmic_driver = { · line 316

Quoted 8 lines
drivers/mfd/sprd-sc27xx-spi.c +1 -0
        .driver = {
                .name = "sc27xx-pmic",
                .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
#4 lore raw
Quoted 30 lines · Chunyan Zhang
Quoted 29 lines · Lee Jones
Quoted 22 lines · Chunyan Zhang

Hi Lee,

Quoted 10 lines · Chunyan Zhang

From: Baolin Wang <[email protected]>

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.

Quoted 8 lines

---
Changes from v1:
* addressed comments from Lee;
* added tested-by from Chunyan.
(This patch is rebased on branch for-mfd-next)

Quoted 1 line

Could you please pick up this patch if there's no more comments :)

Please don't send contentless nags. Your patch is in my queue.

Quoted 7 lines
Quoted 1 line

The merge-window is currently open, which is a) a busy time for

I understand that very much, and also appreciate all maintainer's works for the great opensource project.
And just because of that I know you're busy during merge-window, I was worried that this patch was left out, since I didn't see it at mfd-next.

It was left out, as it was sent during -rc7. Very few patches sent to late in the release cycle are applied during this time, since it leaves too little time to soak in -next.

The patch should make it into the next kernel release (v5.9) without issue.

Quoted 2 lines

I apologize if the last email made you unhappay. I will not send reminder email to you anymore.

If more than 2 weeks have passed and you genuinely believe your patch has been forgotten. The correct means to solve the issue is to submit a [RESEND].

Quoted 3 lines
Quoted 3 lines

Maintainers and b) a time where some of us take a little breather before the next release. Please wait until -rc1 has been released before sending out your [RESENDS].

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