Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mfd: sprd: Add wakeup capability for PMIC IRQ

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>
Tested-by: Chunyan Zhang <chunyan.zhang@unisoc.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>

authored by

Baolin Wang and committed by
Lee Jones
a75bfc82 5f039fa7

+27 -1
+27 -1
drivers/mfd/sprd-sc27xx-spi.c
··· 189 189 ddata->irqs[i].mask = BIT(i); 190 190 191 191 ret = devm_regmap_add_irq_chip(&spi->dev, ddata->regmap, ddata->irq, 192 - IRQF_ONESHOT | IRQF_NO_SUSPEND, 0, 192 + IRQF_ONESHOT, 0, 193 193 &ddata->irq_chip, &ddata->irq_data); 194 194 if (ret) { 195 195 dev_err(&spi->dev, "Failed to add PMIC irq chip %d\n", ret); ··· 202 202 return ret; 203 203 } 204 204 205 + device_init_wakeup(&spi->dev, true); 205 206 return 0; 206 207 } 208 + 209 + #ifdef CONFIG_PM_SLEEP 210 + static int sprd_pmic_suspend(struct device *dev) 211 + { 212 + struct sprd_pmic *ddata = dev_get_drvdata(dev); 213 + 214 + if (device_may_wakeup(dev)) 215 + enable_irq_wake(ddata->irq); 216 + 217 + return 0; 218 + } 219 + 220 + static int sprd_pmic_resume(struct device *dev) 221 + { 222 + struct sprd_pmic *ddata = dev_get_drvdata(dev); 223 + 224 + if (device_may_wakeup(dev)) 225 + disable_irq_wake(ddata->irq); 226 + 227 + return 0; 228 + } 229 + #endif 230 + 231 + static SIMPLE_DEV_PM_OPS(sprd_pmic_pm_ops, sprd_pmic_suspend, sprd_pmic_resume); 207 232 208 233 static const struct of_device_id sprd_pmic_match[] = { 209 234 { .compatible = "sprd,sc2731", .data = &sc2731_data }, ··· 240 215 .driver = { 241 216 .name = "sc27xx-pmic", 242 217 .of_match_table = sprd_pmic_match, 218 + .pm = &sprd_pmic_pm_ops, 243 219 }, 244 220 .probe = sprd_pmic_probe, 245 221 };