Commit 8661ab5b authored by Shengjiu Wang's avatar Shengjiu Wang Committed by Mark Brown

ASoC: imx-audmux: Add driver suspend and resume to support MEGA Fast

For i.MX6 SoloX, there is a mode of the SoC to shutdown all power
source of modules during system suspend and resume procedure.
Thus, AUDMUX needs to save all the values of registers before the
system suspend and restore them after the system resume.
Signed-off-by: default avatarShengjiu Wang <shengjiu.wang@nxp.com>
Link: https://lore.kernel.org/r/1565931794-7218-1-git-send-email-shengjiu.wang@nxp.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 554b75bd
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
static struct clk *audmux_clk; static struct clk *audmux_clk;
static void __iomem *audmux_base; static void __iomem *audmux_base;
static u32 *regcache;
static u32 reg_max;
#define IMX_AUDMUX_V2_PTCR(x) ((x) * 8) #define IMX_AUDMUX_V2_PTCR(x) ((x) * 8)
#define IMX_AUDMUX_V2_PDCR(x) ((x) * 8 + 4) #define IMX_AUDMUX_V2_PDCR(x) ((x) * 8 + 4)
...@@ -317,8 +319,23 @@ static int imx_audmux_probe(struct platform_device *pdev) ...@@ -317,8 +319,23 @@ static int imx_audmux_probe(struct platform_device *pdev)
if (of_id) if (of_id)
pdev->id_entry = of_id->data; pdev->id_entry = of_id->data;
audmux_type = pdev->id_entry->driver_data; audmux_type = pdev->id_entry->driver_data;
if (audmux_type == IMX31_AUDMUX)
switch (audmux_type) {
case IMX31_AUDMUX:
audmux_debugfs_init(); audmux_debugfs_init();
reg_max = 14;
break;
case IMX21_AUDMUX:
reg_max = 6;
break;
default:
dev_err(&pdev->dev, "unsupported version!\n");
return -EINVAL;
}
regcache = devm_kzalloc(&pdev->dev, sizeof(u32) * reg_max, GFP_KERNEL);
if (!regcache)
return -ENOMEM;
if (of_id) if (of_id)
imx_audmux_parse_dt_defaults(pdev, pdev->dev.of_node); imx_audmux_parse_dt_defaults(pdev, pdev->dev.of_node);
...@@ -334,12 +351,47 @@ static int imx_audmux_remove(struct platform_device *pdev) ...@@ -334,12 +351,47 @@ static int imx_audmux_remove(struct platform_device *pdev)
return 0; return 0;
} }
#ifdef CONFIG_PM_SLEEP
static int imx_audmux_suspend(struct device *dev)
{
int i;
clk_prepare_enable(audmux_clk);
for (i = 0; i < reg_max; i++)
regcache[i] = readl(audmux_base + i * 4);
clk_disable_unprepare(audmux_clk);
return 0;
}
static int imx_audmux_resume(struct device *dev)
{
int i;
clk_prepare_enable(audmux_clk);
for (i = 0; i < reg_max; i++)
writel(regcache[i], audmux_base + i * 4);
clk_disable_unprepare(audmux_clk);
return 0;
}
#endif /* CONFIG_PM_SLEEP */
static const struct dev_pm_ops imx_audmux_pm = {
SET_SYSTEM_SLEEP_PM_OPS(imx_audmux_suspend, imx_audmux_resume)
};
static struct platform_driver imx_audmux_driver = { static struct platform_driver imx_audmux_driver = {
.probe = imx_audmux_probe, .probe = imx_audmux_probe,
.remove = imx_audmux_remove, .remove = imx_audmux_remove,
.id_table = imx_audmux_ids, .id_table = imx_audmux_ids,
.driver = { .driver = {
.name = DRIVER_NAME, .name = DRIVER_NAME,
.pm = &imx_audmux_pm,
.of_match_table = imx_audmux_dt_ids, .of_match_table = imx_audmux_dt_ids,
} }
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment