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

ASoC: dwc: add runtime suspend/resume functionality

When DW controller is in master mode, it can disable/enable clock
during the device runtime suspend/resume sequence.

Signed-off-by: Maruthi Bayyavarapu <maruthi.bayyavarapu@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Maruthi Srinivas Bayyavarapu and committed by
Mark Brown
f4830312 8005c49d

+25 -1
+25 -1
sound/soc/dwc/designware_i2s.c
··· 18 18 #include <linux/interrupt.h> 19 19 #include <linux/module.h> 20 20 #include <linux/slab.h> 21 + #include <linux/pm_runtime.h> 21 22 #include <sound/designware_i2s.h> 22 23 #include <sound/pcm.h> 23 24 #include <sound/pcm_params.h> ··· 395 394 }; 396 395 397 396 #ifdef CONFIG_PM 397 + static int dw_i2s_runtime_suspend(struct device *dev) 398 + { 399 + struct dw_i2s_dev *dw_dev = dev_get_drvdata(dev); 400 + 401 + if (dw_dev->capability & DW_I2S_MASTER) 402 + clk_disable(dw_dev->clk); 403 + return 0; 404 + } 405 + 406 + static int dw_i2s_runtime_resume(struct device *dev) 407 + { 408 + struct dw_i2s_dev *dw_dev = dev_get_drvdata(dev); 409 + 410 + if (dw_dev->capability & DW_I2S_MASTER) 411 + clk_enable(dw_dev->clk); 412 + return 0; 413 + } 398 414 399 415 static int dw_i2s_suspend(struct snd_soc_dai *dai) 400 416 { ··· 667 649 goto err_clk_disable; 668 650 } 669 651 } 670 - 652 + pm_runtime_enable(&pdev->dev); 671 653 return 0; 672 654 673 655 err_clk_disable: ··· 683 665 if (dev->capability & DW_I2S_MASTER) 684 666 clk_disable_unprepare(dev->clk); 685 667 668 + pm_runtime_disable(&pdev->dev); 686 669 return 0; 687 670 } 688 671 ··· 696 677 MODULE_DEVICE_TABLE(of, dw_i2s_of_match); 697 678 #endif 698 679 680 + static const struct dev_pm_ops dwc_pm_ops = { 681 + SET_RUNTIME_PM_OPS(dw_i2s_runtime_suspend, dw_i2s_runtime_resume, NULL) 682 + }; 683 + 699 684 static struct platform_driver dw_i2s_driver = { 700 685 .probe = dw_i2s_probe, 701 686 .remove = dw_i2s_remove, 702 687 .driver = { 703 688 .name = "designware-i2s", 704 689 .of_match_table = of_match_ptr(dw_i2s_of_match), 690 + .pm = &dwc_pm_ops, 705 691 }, 706 692 }; 707 693