Skip to content

Commit eb5d4c0

Browse files
lsun100intel-lab-lkp
authored andcommitted
mmc: sdhci-of-dwcmshc: Add runtime PM operations
This commit implements the runtime PM operations to disable eMMC card clock when idle. Reviewed-by: David Thompson <davthompson@nvidia.com> Signed-off-by: Liming Sun <limings@nvidia.com>
1 parent fe15c26 commit eb5d4c0

File tree

1 file changed

+55
-1
lines changed

1 file changed

+55
-1
lines changed

drivers/mmc/host/sdhci-of-dwcmshc.c

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <linux/module.h>
1616
#include <linux/of.h>
1717
#include <linux/of_device.h>
18+
#include <linux/pm_runtime.h>
1819
#include <linux/reset.h>
1920
#include <linux/sizes.h>
2021

@@ -539,6 +540,8 @@ static int dwcmshc_probe(struct platform_device *pdev)
539540
sdhci_enable_v4_mode(host);
540541
#endif
541542

543+
pm_runtime_enable(dev);
544+
542545
host->mmc->caps |= MMC_CAP_WAIT_WHILE_BUSY;
543546

544547
err = sdhci_setup_host(host);
@@ -639,7 +642,58 @@ static int dwcmshc_resume(struct device *dev)
639642
}
640643
#endif
641644

642-
static SIMPLE_DEV_PM_OPS(dwcmshc_pmops, dwcmshc_suspend, dwcmshc_resume);
645+
#ifdef CONFIG_PM
646+
647+
#ifdef CONFIG_ACPI
648+
static void dwcmshc_enable_card_clk(struct sdhci_host *host)
649+
{
650+
u16 ctrl;
651+
652+
ctrl = sdhci_readw(host, SDHCI_CLOCK_CONTROL);
653+
ctrl |= SDHCI_CLOCK_CARD_EN;
654+
sdhci_writew(host, ctrl, SDHCI_CLOCK_CONTROL);
655+
}
656+
657+
static void dwcmshc_disable_card_clk(struct sdhci_host *host)
658+
{
659+
u16 ctrl;
660+
661+
ctrl = sdhci_readw(host, SDHCI_CLOCK_CONTROL);
662+
ctrl &= ~SDHCI_CLOCK_CARD_EN;
663+
sdhci_writew(host, ctrl, SDHCI_CLOCK_CONTROL);
664+
}
665+
#endif
666+
667+
static int dwcmshc_runtime_suspend(struct device *dev)
668+
{
669+
struct sdhci_host *host = dev_get_drvdata(dev);
670+
int ret = 0;
671+
672+
ret = sdhci_runtime_suspend_host(host);
673+
if (!ret)
674+
dwcmshc_disable_card_clk(host);
675+
676+
return ret;
677+
}
678+
679+
static int dwcmshc_runtime_resume(struct device *dev)
680+
{
681+
struct sdhci_host *host = dev_get_drvdata(dev);
682+
int ret = 0;
683+
684+
dwcmshc_enable_card_clk(host);
685+
ret = sdhci_runtime_resume_host(host, 0);
686+
687+
return ret;
688+
}
689+
690+
#endif
691+
692+
static const struct dev_pm_ops dwcmshc_pmops = {
693+
SET_SYSTEM_SLEEP_PM_OPS(dwcmshc_suspend, dwcmshc_resume)
694+
SET_RUNTIME_PM_OPS(dwcmshc_runtime_suspend,
695+
dwcmshc_runtime_resume, NULL)
696+
};
643697

644698
static struct platform_driver sdhci_dwcmshc_driver = {
645699
.driver = {

0 commit comments

Comments
 (0)