MLK-23618-13: clk: imx: 8qxp-acm: Support pm runtime
Support pm runtime, that power domain of ACM can enter suspend. Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com> Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com>5.4-rM2-2.2.x-imx-squashed
parent
3864790e2a
commit
c1ed1dd2bf
|
@ -13,13 +13,16 @@
|
|||
#include <linux/platform_device.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/pm_domain.h>
|
||||
#include <linux/pm_runtime.h>
|
||||
|
||||
#include "clk.h"
|
||||
#include "clk-scu.h"
|
||||
#include "clk-imx-acm-utils.h"
|
||||
|
||||
#include <dt-bindings/clock/imx8-clock.h>
|
||||
|
||||
struct imx8qxp_acm_priv {
|
||||
struct clk_imx_acm_pm_domains dev_pm;
|
||||
void __iomem *reg;
|
||||
u32 regs[0x20];
|
||||
};
|
||||
|
@ -90,7 +93,7 @@ static int imx8qxp_acm_clk_probe(struct platform_device *pdev)
|
|||
struct resource *res;
|
||||
struct clk **clks;
|
||||
void __iomem *base;
|
||||
int num_domains;
|
||||
int ret;
|
||||
int i;
|
||||
|
||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
|
@ -119,23 +122,12 @@ static int imx8qxp_acm_clk_probe(struct platform_device *pdev)
|
|||
|
||||
clks = clk_data->clks;
|
||||
|
||||
num_domains = of_count_phandle_with_args(dev->of_node, "power-domains",
|
||||
"#power-domain-cells");
|
||||
for (i = 0; i < num_domains; i++) {
|
||||
struct device *pd_dev;
|
||||
struct device_link *link;
|
||||
ret = clk_imx_acm_attach_pm_domains(&pdev->dev, &priv->dev_pm);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
pd_dev = dev_pm_domain_attach_by_id(&pdev->dev, i);
|
||||
if (IS_ERR(pd_dev))
|
||||
return PTR_ERR(pd_dev);
|
||||
|
||||
link = device_link_add(&pdev->dev, pd_dev,
|
||||
DL_FLAG_STATELESS |
|
||||
DL_FLAG_PM_RUNTIME |
|
||||
DL_FLAG_RPM_ACTIVE);
|
||||
if (IS_ERR(link))
|
||||
return PTR_ERR(link);
|
||||
}
|
||||
pm_runtime_enable(&pdev->dev);
|
||||
pm_runtime_get_sync(&pdev->dev);
|
||||
|
||||
clks[IMX_ADMA_EXT_AUD_MCLK0] = imx_clk_fixed("ext_aud_mclk0", 0);
|
||||
clks[IMX_ADMA_EXT_AUD_MCLK1] = imx_clk_fixed("ext_aud_mclk1", 0);
|
||||
|
@ -176,7 +168,22 @@ static int imx8qxp_acm_clk_probe(struct platform_device *pdev)
|
|||
i, PTR_ERR(clks[i]));
|
||||
}
|
||||
|
||||
return of_clk_add_provider(np, of_clk_src_onecell_get, clk_data);
|
||||
ret = of_clk_add_provider(np, of_clk_src_onecell_get, clk_data);
|
||||
|
||||
pm_runtime_put_sync(&pdev->dev);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int imx8qxp_acm_clk_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct imx8qxp_acm_priv *priv = dev_get_drvdata(&pdev->dev);
|
||||
|
||||
pm_runtime_disable(&pdev->dev);
|
||||
|
||||
clk_imx_acm_detach_pm_domains(&pdev->dev, &priv->dev_pm);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct of_device_id imx8qxp_acm_match[] = {
|
||||
|
@ -184,7 +191,7 @@ static const struct of_device_id imx8qxp_acm_match[] = {
|
|||
{ /* sentinel */ }
|
||||
};
|
||||
|
||||
static int __maybe_unused imx8qxp_acm_suspend(struct device *dev)
|
||||
static int __maybe_unused imx8qxp_acm_runtime_suspend(struct device *dev)
|
||||
{
|
||||
struct imx8qxp_acm_priv *priv = dev_get_drvdata(dev);
|
||||
|
||||
|
@ -205,7 +212,7 @@ static int __maybe_unused imx8qxp_acm_suspend(struct device *dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int __maybe_unused imx8qxp_acm_resume(struct device *dev)
|
||||
static int __maybe_unused imx8qxp_acm_runtime_resume(struct device *dev)
|
||||
{
|
||||
struct imx8qxp_acm_priv *priv = dev_get_drvdata(dev);
|
||||
|
||||
|
@ -227,8 +234,10 @@ static int __maybe_unused imx8qxp_acm_resume(struct device *dev)
|
|||
}
|
||||
|
||||
const struct dev_pm_ops imx8qxp_acm_pm_ops = {
|
||||
SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(imx8qxp_acm_suspend,
|
||||
imx8qxp_acm_resume)
|
||||
SET_RUNTIME_PM_OPS(imx8qxp_acm_runtime_suspend,
|
||||
imx8qxp_acm_runtime_resume, NULL)
|
||||
SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
|
||||
pm_runtime_force_resume)
|
||||
};
|
||||
|
||||
static struct platform_driver imx8qxp_acm_clk_driver = {
|
||||
|
@ -239,6 +248,7 @@ static struct platform_driver imx8qxp_acm_clk_driver = {
|
|||
.suppress_bind_attrs = true,
|
||||
},
|
||||
.probe = imx8qxp_acm_clk_probe,
|
||||
.remove = imx8qxp_acm_clk_remove,
|
||||
};
|
||||
|
||||
static int __init imx8qxp_acm_init(void)
|
||||
|
|
Loading…
Reference in New Issue