Skip to content

Commit bb2b262

Browse files
Anson-HuangJassiBrar
authored andcommitted
mailbox: imx: Add runtime PM callback to handle MU clocks
Some of i.MX8M SoCs have MU clock, they need to be managed in runtime to make sure the MU clock can be off in runtime, add runtime PM callback to handle MU clock. And on i.MX8MP, the MU clock is combined with power domain and runtime PM is enabled for the clock driver, during noirq suspend/resume phase, runtime PM is disabled by device suspend, but the MU context save/restore needs to enable MU clock for register access, calling clock prepare/enable will trigger runtime resume failure and lead to system suspend failed. Actually, the MU context save/restore is ONLY necessary for SCU IPC MU, other MUs especially on i.MX8MP platforms which have MU clock assigned, they need to runtime request/free mailbox channel in the consumer driver, so no need to save/restore MU context for them, hence it can avoid this issue, so the MU context save/restore is ONLY applied to i.MX platforms MU instance without clock present. Signed-off-by: Anson Huang <[email protected]> Signed-off-by: Jassi Brar <[email protected]>
1 parent ba5f9fa commit bb2b262

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

drivers/mailbox/imx-mailbox.c

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -536,18 +536,20 @@ static int imx_mu_probe(struct platform_device *pdev)
536536
if (ret < 0)
537537
goto disable_runtime_pm;
538538

539+
clk_disable_unprepare(priv->clk);
540+
539541
return 0;
540542

541543
disable_runtime_pm:
542544
pm_runtime_disable(dev);
545+
clk_disable_unprepare(priv->clk);
543546
return ret;
544547
}
545548

546549
static int imx_mu_remove(struct platform_device *pdev)
547550
{
548551
struct imx_mu_priv *priv = platform_get_drvdata(pdev);
549552

550-
clk_disable_unprepare(priv->clk);
551553
pm_runtime_disable(priv->dev);
552554

553555
return 0;
@@ -595,7 +597,8 @@ static int imx_mu_suspend_noirq(struct device *dev)
595597
{
596598
struct imx_mu_priv *priv = dev_get_drvdata(dev);
597599

598-
priv->xcr = imx_mu_read(priv, priv->dcfg->xCR);
600+
if (!priv->clk)
601+
priv->xcr = imx_mu_read(priv, priv->dcfg->xCR);
599602

600603
return 0;
601604
}
@@ -612,15 +615,38 @@ static int imx_mu_resume_noirq(struct device *dev)
612615
* send failed, may lead to system freeze. This issue
613616
* is observed by testing freeze mode suspend.
614617
*/
615-
if (!imx_mu_read(priv, priv->dcfg->xCR))
618+
if (!imx_mu_read(priv, priv->dcfg->xCR) && !priv->clk)
616619
imx_mu_write(priv, priv->xcr, priv->dcfg->xCR);
617620

618621
return 0;
619622
}
620623

624+
static int imx_mu_runtime_suspend(struct device *dev)
625+
{
626+
struct imx_mu_priv *priv = dev_get_drvdata(dev);
627+
628+
clk_disable_unprepare(priv->clk);
629+
630+
return 0;
631+
}
632+
633+
static int imx_mu_runtime_resume(struct device *dev)
634+
{
635+
struct imx_mu_priv *priv = dev_get_drvdata(dev);
636+
int ret;
637+
638+
ret = clk_prepare_enable(priv->clk);
639+
if (ret)
640+
dev_err(dev, "failed to enable clock\n");
641+
642+
return ret;
643+
}
644+
621645
static const struct dev_pm_ops imx_mu_pm_ops = {
622646
SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(imx_mu_suspend_noirq,
623647
imx_mu_resume_noirq)
648+
SET_RUNTIME_PM_OPS(imx_mu_runtime_suspend,
649+
imx_mu_runtime_resume, NULL)
624650
};
625651

626652
static struct platform_driver imx_mu_driver = {

0 commit comments

Comments
 (0)