diff options
| author | oder_chiou@realtek.com <oder_chiou@realtek.com> | 2017-11-08 02:04:21 -0500 |
|---|---|---|
| committer | Mark Brown <broonie@kernel.org> | 2017-11-08 16:29:05 -0500 |
| commit | 58f1c07d23cddbc4c8aa99a214934eb7d33e8523 (patch) | |
| tree | 0f5852e326cc2af1e2b17dd25969529ce3ec9528 | |
| parent | c4a71ff78e668a75a4a3cfd9ebbfbd5cbe8da5fb (diff) | |
ASoC: rt5514: Voice wakeup support.
If the rt5514 Wake on Voice device is opened while suspended, it will
be able to wake up the system when a voice command is detected.
This patch also supports user-space policy to override wakeup behavior
by /sys/bus/spi/drivers/rt5514/spi2.0/power/wakeup.
Signed-off-by: Chinyue Chen <chinyue@chromium.org>
Signed-off-by: Oder Chiou <oder_chiou@realtek.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
| -rw-r--r-- | sound/soc/codecs/rt5514-spi.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/sound/soc/codecs/rt5514-spi.c b/sound/soc/codecs/rt5514-spi.c index 0896817ffc3f..d03756913dd9 100644 --- a/sound/soc/codecs/rt5514-spi.c +++ b/sound/soc/codecs/rt5514-spi.c | |||
| @@ -456,9 +456,35 @@ static int rt5514_spi_probe(struct spi_device *spi) | |||
| 456 | return ret; | 456 | return ret; |
| 457 | } | 457 | } |
| 458 | 458 | ||
| 459 | device_init_wakeup(&spi->dev, true); | ||
| 460 | |||
| 461 | return 0; | ||
| 462 | } | ||
| 463 | |||
| 464 | static int rt5514_suspend(struct device *dev) | ||
| 465 | { | ||
| 466 | int irq = to_spi_device(dev)->irq; | ||
| 467 | |||
| 468 | if (device_may_wakeup(dev)) | ||
| 469 | enable_irq_wake(irq); | ||
| 470 | |||
| 459 | return 0; | 471 | return 0; |
| 460 | } | 472 | } |
| 461 | 473 | ||
| 474 | static int rt5514_resume(struct device *dev) | ||
| 475 | { | ||
| 476 | int irq = to_spi_device(dev)->irq; | ||
| 477 | |||
| 478 | if (device_may_wakeup(dev)) | ||
| 479 | disable_irq_wake(irq); | ||
| 480 | |||
| 481 | return 0; | ||
| 482 | } | ||
| 483 | |||
| 484 | static const struct dev_pm_ops rt5514_pm_ops = { | ||
| 485 | SET_SYSTEM_SLEEP_PM_OPS(rt5514_suspend, rt5514_resume) | ||
| 486 | }; | ||
| 487 | |||
| 462 | static const struct of_device_id rt5514_of_match[] = { | 488 | static const struct of_device_id rt5514_of_match[] = { |
| 463 | { .compatible = "realtek,rt5514", }, | 489 | { .compatible = "realtek,rt5514", }, |
| 464 | {}, | 490 | {}, |
| @@ -468,6 +494,7 @@ MODULE_DEVICE_TABLE(of, rt5514_of_match); | |||
| 468 | static struct spi_driver rt5514_spi_driver = { | 494 | static struct spi_driver rt5514_spi_driver = { |
| 469 | .driver = { | 495 | .driver = { |
| 470 | .name = "rt5514", | 496 | .name = "rt5514", |
| 497 | .pm = &rt5514_pm_ops, | ||
| 471 | .of_match_table = of_match_ptr(rt5514_of_match), | 498 | .of_match_table = of_match_ptr(rt5514_of_match), |
| 472 | }, | 499 | }, |
| 473 | .probe = rt5514_spi_probe, | 500 | .probe = rt5514_spi_probe, |
