diff --git a/drivers/mailbox/omap-mailbox.c b/drivers/mailbox/omap-mailbox.c index 17fe6545875d..105e40a5e903 100644 --- a/drivers/mailbox/omap-mailbox.c +++ b/drivers/mailbox/omap-mailbox.c @@ -379,7 +379,7 @@ static int omap_mbox_resume(struct device *dev) #endif static const struct dev_pm_ops omap_mbox_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(omap_mbox_suspend, omap_mbox_resume) + LATE_SYSTEM_SLEEP_PM_OPS(omap_mbox_suspend, omap_mbox_resume) }; static const struct omap_mbox_match_data omap2_data = { MBOX_INTR_CFG_TYPE1, true }; diff --git a/drivers/remoteproc/ti_k3_common.c b/drivers/remoteproc/ti_k3_common.c index 89969cf74c23..6102d8ed05ce 100644 --- a/drivers/remoteproc/ti_k3_common.c +++ b/drivers/remoteproc/ti_k3_common.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -230,6 +231,9 @@ int k3_rproc_request_mbox(struct rproc *rproc) struct k3_rproc *kproc = rproc->priv; struct mbox_client *client = &kproc->client; struct device *dev = kproc->dev; + struct platform_device *mbox_pdev; + struct device_node *np = dev_of_node(dev); + struct device_node *mbox_np; client->dev = dev; client->tx_done = NULL; @@ -242,6 +246,22 @@ int k3_rproc_request_mbox(struct rproc *rproc) return dev_err_probe(dev, PTR_ERR(kproc->mbox), "mbox_request_channel failed\n"); + mbox_np = of_parse_phandle(np, "mboxes", 0); + if (!mbox_np) { + dev_err(dev, "failed to get mboxes\n"); + return -ENODEV; + } + + mbox_pdev = of_find_device_by_node(mbox_np); + of_node_put(mbox_np); + if(!mbox_pdev) { + dev_err(dev, "mailbox device not yet ready\n"); + return -EPROBE_DEFER; + } + + /* Ensure mailbox is suspended after remoteproc */ + device_link_add(dev, &mbox_pdev->dev, DL_FLAG_AUTOREMOVE_SUPPLIER); + return 0; } EXPORT_SYMBOL_GPL(k3_rproc_request_mbox); diff --git a/drivers/remoteproc/ti_k3_r5_remoteproc.c b/drivers/remoteproc/ti_k3_r5_remoteproc.c index 4242e78a47f1..c8f88dd77af5 100644 --- a/drivers/remoteproc/ti_k3_r5_remoteproc.c +++ b/drivers/remoteproc/ti_k3_r5_remoteproc.c @@ -1917,6 +1917,9 @@ static int k3_r5_cluster_of_init(struct platform_device *pdev) struct k3_r5_cluster *cluster = platform_get_drvdata(pdev); struct device *dev = &pdev->dev; struct device_node *np = dev_of_node(dev); + struct device_node *child_np; + struct device_node *mbox_np; + struct platform_device *mbox_pdev; struct platform_device *cpdev; struct device_node *child; struct k3_r5_core *core; @@ -1931,6 +1934,27 @@ static int k3_r5_cluster_of_init(struct platform_device *pdev) goto fail; } + child_np = dev_of_node(&cpdev->dev); + + mbox_np = of_parse_phandle(child_np, "mboxes", 0); + if (!mbox_np) { + dev_err(dev, "failed to get mboxes\n"); + ret = -ENODEV; + goto fail; + } + + mbox_pdev = of_find_device_by_node(mbox_np); + of_node_put(mbox_np); + if (!mbox_pdev) { + dev_err(dev, "mailbox device not yet ready\n"); + ret = -EPROBE_DEFER; + goto fail; + } + + /* Ensure mailbox is suspended after remoteproc */ + device_link_add(dev, &mbox_pdev->dev, + DL_FLAG_AUTOREMOVE_SUPPLIER); + ret = k3_r5_core_of_init(cpdev); if (ret) { dev_err(dev, "k3_r5_core_of_init failed, ret = %d\n",