|
|
@@ -16,14 +16,17 @@
|
|
|
#include <linux/kernel.h>
|
|
|
#include <linux/module.h>
|
|
|
#include <linux/err.h>
|
|
|
+#include <linux/io.h>
|
|
|
#include <linux/of_device.h>
|
|
|
#include <linux/of_address.h>
|
|
|
#include <linux/of_reserved_mem.h>
|
|
|
#include <linux/platform_device.h>
|
|
|
+#include <linux/pm_runtime.h>
|
|
|
#include <linux/dma-mapping.h>
|
|
|
#include <linux/remoteproc.h>
|
|
|
#include <linux/mailbox_client.h>
|
|
|
#include <linux/omap-mailbox.h>
|
|
|
+#include <linux/omap-iommu.h>
|
|
|
#include <linux/regmap.h>
|
|
|
#include <linux/mfd/syscon.h>
|
|
|
#include <clocksource/timer-ti-dm.h>
|
|
|
@@ -37,6 +40,9 @@
|
|
|
#define OMAP_RPROC_DSP_LOCAL_MEM_OFFSET (0x00800000)
|
|
|
#define OMAP_RPROC_IPU_L2RAM_DEV_ADDR (0x20000000)
|
|
|
|
|
|
+/* default auto-suspend delay (ms) */
|
|
|
+#define DEFAULT_AUTOSUSPEND_DELAY 10000
|
|
|
+
|
|
|
/**
|
|
|
* struct omap_rproc_boot_data - boot data structure for the DSP omap rprocs
|
|
|
* @syscon: regmap handle for the system control configuration module
|
|
|
@@ -83,7 +89,12 @@ struct omap_rproc_timer {
|
|
|
* @num_mems: number of internal memory regions
|
|
|
* @num_timers: number of rproc timer(s)
|
|
|
* @timers: timer(s) info used by rproc
|
|
|
+ * @autosuspend_delay: auto-suspend delay value to be used for runtime pm
|
|
|
+ * @need_resume: if true a resume is needed in the system resume callback
|
|
|
* @rproc: rproc handle
|
|
|
+ * @pm_comp: completion primitive to sync for suspend response
|
|
|
+ * @standby_addr: kernel address of the register having module standby status
|
|
|
+ * @suspend_acked: state machine flag to store the suspend request ack
|
|
|
*/
|
|
|
struct omap_rproc {
|
|
|
struct mbox_chan *mbox;
|
|
|
@@ -93,17 +104,24 @@ struct omap_rproc {
|
|
|
int num_mems;
|
|
|
int num_timers;
|
|
|
struct omap_rproc_timer *timers;
|
|
|
+ int autosuspend_delay;
|
|
|
+ bool need_resume;
|
|
|
struct rproc *rproc;
|
|
|
+ struct completion pm_comp;
|
|
|
+ void __iomem *standby_addr;
|
|
|
+ bool suspend_acked;
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* struct omap_rproc_dev_data - device data for the omap remote processor
|
|
|
* @device_name: device name of the remote processor
|
|
|
* @fw_name: firmware name to use
|
|
|
+ * @autosuspend_delay: custom auto-suspend delay value in milliseconds
|
|
|
*/
|
|
|
struct omap_rproc_dev_data {
|
|
|
const char *device_name;
|
|
|
const char *fw_name;
|
|
|
+ int autosuspend_delay;
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
@@ -344,6 +362,11 @@ static void omap_rproc_mbox_callback(struct mbox_client *client, void *data)
|
|
|
case RP_MBOX_ECHO_REPLY:
|
|
|
dev_info(dev, "received echo reply from %s\n", name);
|
|
|
break;
|
|
|
+ case RP_MBOX_SUSPEND_ACK:
|
|
|
+ case RP_MBOX_SUSPEND_CANCEL:
|
|
|
+ oproc->suspend_acked = msg == RP_MBOX_SUSPEND_ACK;
|
|
|
+ complete(&oproc->pm_comp);
|
|
|
+ break;
|
|
|
default:
|
|
|
if (msg >= RP_MBOX_READY && msg < RP_MBOX_END_MSG)
|
|
|
return;
|
|
|
@@ -364,11 +387,23 @@ static void omap_rproc_kick(struct rproc *rproc, int vqid)
|
|
|
struct device *dev = rproc->dev.parent;
|
|
|
int ret;
|
|
|
|
|
|
+ /* wake up the rproc before kicking it */
|
|
|
+ ret = pm_runtime_get_sync(dev);
|
|
|
+ if (WARN_ON(ret < 0)) {
|
|
|
+ dev_err(dev, "pm_runtime_get_sync() failed during kick, ret = %d\n",
|
|
|
+ ret);
|
|
|
+ pm_runtime_put_noidle(dev);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
/* send the index of the triggered virtqueue in the mailbox payload */
|
|
|
ret = mbox_send_message(oproc->mbox, (void *)vqid);
|
|
|
if (ret < 0)
|
|
|
dev_err(dev, "failed to send mailbox message, status = %d\n",
|
|
|
ret);
|
|
|
+
|
|
|
+ pm_runtime_mark_last_busy(dev);
|
|
|
+ pm_runtime_put_autosuspend(dev);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -461,6 +496,19 @@ static int omap_rproc_start(struct rproc *rproc)
|
|
|
goto reset_timers;
|
|
|
}
|
|
|
|
|
|
+ /*
|
|
|
+ * remote processor is up, so update the runtime pm status and
|
|
|
+ * enable the auto-suspend. The device usage count is incremented
|
|
|
+ * manually for balancing it for auto-suspend
|
|
|
+ */
|
|
|
+ pm_runtime_set_active(dev);
|
|
|
+ pm_runtime_set_autosuspend_delay(dev, oproc->autosuspend_delay);
|
|
|
+ pm_runtime_use_autosuspend(dev);
|
|
|
+ pm_runtime_get_noresume(dev);
|
|
|
+ pm_runtime_enable(dev);
|
|
|
+ pm_runtime_mark_last_busy(dev);
|
|
|
+ pm_runtime_put_autosuspend(dev);
|
|
|
+
|
|
|
return 0;
|
|
|
|
|
|
reset_timers:
|
|
|
@@ -479,17 +527,49 @@ static int omap_rproc_stop(struct rproc *rproc)
|
|
|
struct omap_rproc *oproc = rproc->priv;
|
|
|
int ret;
|
|
|
|
|
|
+ /*
|
|
|
+ * cancel any possible scheduled runtime suspend by incrementing
|
|
|
+ * the device usage count, and resuming the device. The remoteproc
|
|
|
+ * also needs to be woken up if suspended, to avoid the remoteproc
|
|
|
+ * OS to continue to remember any context that it has saved, and
|
|
|
+ * avoid potential issues in misindentifying a subsequent device
|
|
|
+ * reboot as a power restore boot
|
|
|
+ */
|
|
|
+ ret = pm_runtime_get_sync(dev);
|
|
|
+ if (ret < 0) {
|
|
|
+ pm_runtime_put_noidle(dev);
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+
|
|
|
ret = pdata->device_shutdown(pdev);
|
|
|
if (ret)
|
|
|
- return ret;
|
|
|
+ goto out;
|
|
|
|
|
|
ret = omap_rproc_disable_timers(rproc, true);
|
|
|
if (ret)
|
|
|
- return ret;
|
|
|
+ goto enable_device;
|
|
|
|
|
|
mbox_free_channel(oproc->mbox);
|
|
|
|
|
|
+ /*
|
|
|
+ * update the runtime pm states and status now that the remoteproc
|
|
|
+ * has stopped
|
|
|
+ */
|
|
|
+ pm_runtime_disable(dev);
|
|
|
+ pm_runtime_dont_use_autosuspend(dev);
|
|
|
+ pm_runtime_put_noidle(dev);
|
|
|
+ pm_runtime_set_suspended(dev);
|
|
|
+
|
|
|
return 0;
|
|
|
+
|
|
|
+enable_device:
|
|
|
+ pdata->device_enable(pdev);
|
|
|
+out:
|
|
|
+ /* schedule the next auto-suspend */
|
|
|
+ pm_runtime_mark_last_busy(dev);
|
|
|
+ pm_runtime_put_autosuspend(dev);
|
|
|
+ return ret;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
@@ -534,6 +614,289 @@ static const struct rproc_ops omap_rproc_ops = {
|
|
|
.da_to_va = omap_rproc_da_to_va,
|
|
|
};
|
|
|
|
|
|
+#ifdef CONFIG_PM
|
|
|
+static bool _is_rproc_in_standby(struct omap_rproc *oproc)
|
|
|
+{
|
|
|
+ static int standby_mask = (1 << 18);
|
|
|
+
|
|
|
+ return readl(oproc->standby_addr) & standby_mask;
|
|
|
+}
|
|
|
+
|
|
|
+/* 1 sec is long enough time to let the remoteproc side suspend the device */
|
|
|
+#define DEF_SUSPEND_TIMEOUT 1000
|
|
|
+static int _omap_rproc_suspend(struct rproc *rproc, bool auto_suspend)
|
|
|
+{
|
|
|
+ struct device *dev = rproc->dev.parent;
|
|
|
+ struct platform_device *pdev = to_platform_device(dev);
|
|
|
+ struct omap_rproc_pdata *pdata = dev_get_platdata(dev);
|
|
|
+ struct omap_rproc *oproc = rproc->priv;
|
|
|
+ unsigned long to = msecs_to_jiffies(DEF_SUSPEND_TIMEOUT);
|
|
|
+ unsigned long ta = jiffies + to;
|
|
|
+ u32 suspend_msg = auto_suspend ?
|
|
|
+ RP_MBOX_SUSPEND_AUTO : RP_MBOX_SUSPEND_SYSTEM;
|
|
|
+ int ret;
|
|
|
+
|
|
|
+ reinit_completion(&oproc->pm_comp);
|
|
|
+ oproc->suspend_acked = false;
|
|
|
+ ret = mbox_send_message(oproc->mbox, (void *)suspend_msg);
|
|
|
+ if (ret < 0) {
|
|
|
+ dev_err(dev, "PM mbox_send_message failed: %d\n", ret);
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+
|
|
|
+ ret = wait_for_completion_timeout(&oproc->pm_comp, to);
|
|
|
+ if (!oproc->suspend_acked)
|
|
|
+ return -EBUSY;
|
|
|
+
|
|
|
+ /*
|
|
|
+ * The remoteproc side is returning the ACK message before saving the
|
|
|
+ * context, because the context saving is performed within a SYS/BIOS
|
|
|
+ * function, and it cannot have any inter-dependencies against the IPC
|
|
|
+ * layer. Also, as the SYS/BIOS needs to preserve properly the processor
|
|
|
+ * register set, sending this ACK or signalling the completion of the
|
|
|
+ * context save through a shared memory variable can never be the
|
|
|
+ * absolute last thing to be executed on the remoteproc side, and the
|
|
|
+ * MPU cannot use the ACK message as a sync point to put the remoteproc
|
|
|
+ * into reset. The only way to ensure that the remote processor has
|
|
|
+ * completed saving the context is to check that the module has reached
|
|
|
+ * STANDBY state (after saving the context, the SYS/BIOS executes the
|
|
|
+ * appropriate target-specific WFI instruction causing the module to
|
|
|
+ * enter STANDBY).
|
|
|
+ */
|
|
|
+ while (!_is_rproc_in_standby(oproc)) {
|
|
|
+ if (time_after(jiffies, ta))
|
|
|
+ return -ETIME;
|
|
|
+ schedule();
|
|
|
+ }
|
|
|
+
|
|
|
+ ret = pdata->device_shutdown(pdev);
|
|
|
+ if (ret)
|
|
|
+ return ret;
|
|
|
+
|
|
|
+ ret = omap_rproc_disable_timers(rproc, false);
|
|
|
+ if (ret) {
|
|
|
+ dev_err(dev, "disabling timers during suspend failed %d\n",
|
|
|
+ ret);
|
|
|
+ goto enable_device;
|
|
|
+ }
|
|
|
+
|
|
|
+ /*
|
|
|
+ * IOMMUs would have to be disabled specifically for runtime suspend.
|
|
|
+ * They are handled automatically through System PM callbacks for
|
|
|
+ * regular system suspend
|
|
|
+ */
|
|
|
+ if (auto_suspend) {
|
|
|
+ ret = omap_iommu_domain_deactivate(rproc->domain);
|
|
|
+ if (ret) {
|
|
|
+ dev_err(dev, "iommu domain deactivate failed %d\n",
|
|
|
+ ret);
|
|
|
+ goto enable_timers;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return 0;
|
|
|
+
|
|
|
+enable_timers:
|
|
|
+ /* ignore errors on re-enabling code */
|
|
|
+ omap_rproc_enable_timers(rproc, false);
|
|
|
+enable_device:
|
|
|
+ pdata->device_enable(pdev);
|
|
|
+ return ret;
|
|
|
+}
|
|
|
+
|
|
|
+static int _omap_rproc_resume(struct rproc *rproc, bool auto_suspend)
|
|
|
+{
|
|
|
+ struct device *dev = rproc->dev.parent;
|
|
|
+ struct platform_device *pdev = to_platform_device(dev);
|
|
|
+ struct omap_rproc_pdata *pdata = dev_get_platdata(dev);
|
|
|
+ struct omap_rproc *oproc = rproc->priv;
|
|
|
+ int ret;
|
|
|
+
|
|
|
+ /*
|
|
|
+ * IOMMUs would have to be enabled specifically for runtime resume.
|
|
|
+ * They would have been already enabled automatically through System
|
|
|
+ * PM callbacks for regular system resume
|
|
|
+ */
|
|
|
+ if (auto_suspend) {
|
|
|
+ ret = omap_iommu_domain_activate(rproc->domain);
|
|
|
+ if (ret) {
|
|
|
+ dev_err(dev, "omap_iommu activate failed %d\n", ret);
|
|
|
+ goto out;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /* boot address could be lost after suspend, so restore it */
|
|
|
+ if (oproc->boot_data) {
|
|
|
+ ret = omap_rproc_write_dsp_boot_addr(rproc);
|
|
|
+ if (ret) {
|
|
|
+ dev_err(dev, "boot address restore failed %d\n", ret);
|
|
|
+ goto suspend_iommu;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ ret = omap_rproc_enable_timers(rproc, false);
|
|
|
+ if (ret) {
|
|
|
+ dev_err(dev, "enabling timers during resume failed %d\n",
|
|
|
+ ret);
|
|
|
+ goto suspend_iommu;
|
|
|
+ }
|
|
|
+
|
|
|
+ ret = pdata->device_enable(pdev);
|
|
|
+ if (ret)
|
|
|
+ goto disable_timers;
|
|
|
+
|
|
|
+ return 0;
|
|
|
+
|
|
|
+disable_timers:
|
|
|
+ omap_rproc_disable_timers(rproc, false);
|
|
|
+suspend_iommu:
|
|
|
+ if (auto_suspend)
|
|
|
+ omap_iommu_domain_deactivate(rproc->domain);
|
|
|
+out:
|
|
|
+ return ret;
|
|
|
+}
|
|
|
+
|
|
|
+static int __maybe_unused omap_rproc_suspend(struct device *dev)
|
|
|
+{
|
|
|
+ struct platform_device *pdev = to_platform_device(dev);
|
|
|
+ struct rproc *rproc = platform_get_drvdata(pdev);
|
|
|
+ struct omap_rproc *oproc = rproc->priv;
|
|
|
+ int ret = 0;
|
|
|
+
|
|
|
+ mutex_lock(&rproc->lock);
|
|
|
+ if (rproc->state == RPROC_OFFLINE)
|
|
|
+ goto out;
|
|
|
+
|
|
|
+ if (rproc->state == RPROC_SUSPENDED)
|
|
|
+ goto out;
|
|
|
+
|
|
|
+ if (rproc->state != RPROC_RUNNING) {
|
|
|
+ ret = -EBUSY;
|
|
|
+ goto out;
|
|
|
+ }
|
|
|
+
|
|
|
+ ret = _omap_rproc_suspend(rproc, false);
|
|
|
+ if (ret) {
|
|
|
+ dev_err(dev, "suspend failed %d\n", ret);
|
|
|
+ goto out;
|
|
|
+ }
|
|
|
+
|
|
|
+ /*
|
|
|
+ * remoteproc is running at the time of system suspend, so remember
|
|
|
+ * it so as to wake it up during system resume
|
|
|
+ */
|
|
|
+ oproc->need_resume = 1;
|
|
|
+ rproc->state = RPROC_SUSPENDED;
|
|
|
+
|
|
|
+ /*
|
|
|
+ * update the runtime pm status to be suspended, without decrementing
|
|
|
+ * the device usage count
|
|
|
+ */
|
|
|
+ pm_runtime_disable(dev);
|
|
|
+ pm_runtime_set_suspended(dev);
|
|
|
+out:
|
|
|
+ mutex_unlock(&rproc->lock);
|
|
|
+ return ret;
|
|
|
+}
|
|
|
+
|
|
|
+static int __maybe_unused omap_rproc_resume(struct device *dev)
|
|
|
+{
|
|
|
+ struct platform_device *pdev = to_platform_device(dev);
|
|
|
+ struct rproc *rproc = platform_get_drvdata(pdev);
|
|
|
+ struct omap_rproc *oproc = rproc->priv;
|
|
|
+ int ret = 0;
|
|
|
+
|
|
|
+ mutex_lock(&rproc->lock);
|
|
|
+ if (rproc->state == RPROC_OFFLINE)
|
|
|
+ goto out;
|
|
|
+
|
|
|
+ if (rproc->state != RPROC_SUSPENDED) {
|
|
|
+ ret = -EBUSY;
|
|
|
+ goto out;
|
|
|
+ }
|
|
|
+
|
|
|
+ /*
|
|
|
+ * remoteproc was auto-suspended at the time of system suspend,
|
|
|
+ * so no need to wake-up the processor (leave it in suspended
|
|
|
+ * state, will be woken up during a subsequent runtime_resume)
|
|
|
+ */
|
|
|
+ if (!oproc->need_resume)
|
|
|
+ goto out;
|
|
|
+
|
|
|
+ ret = _omap_rproc_resume(rproc, false);
|
|
|
+ if (ret) {
|
|
|
+ dev_err(dev, "resume failed %d\n", ret);
|
|
|
+ goto out;
|
|
|
+ }
|
|
|
+ oproc->need_resume = false;
|
|
|
+
|
|
|
+ rproc->state = RPROC_RUNNING;
|
|
|
+
|
|
|
+ /*
|
|
|
+ * update the runtime pm status to be active, without incrementing
|
|
|
+ * the device usage count
|
|
|
+ */
|
|
|
+ pm_runtime_set_active(dev);
|
|
|
+ pm_runtime_enable(dev);
|
|
|
+ pm_runtime_mark_last_busy(dev);
|
|
|
+out:
|
|
|
+ mutex_unlock(&rproc->lock);
|
|
|
+ return ret;
|
|
|
+}
|
|
|
+
|
|
|
+static int omap_rproc_runtime_suspend(struct device *dev)
|
|
|
+{
|
|
|
+ struct rproc *rproc = dev_get_drvdata(dev);
|
|
|
+ struct omap_rproc *oproc = rproc->priv;
|
|
|
+ int ret;
|
|
|
+
|
|
|
+ if (WARN_ON(rproc->state != RPROC_RUNNING)) {
|
|
|
+ dev_err(dev, "rproc cannot be runtime suspended when not running!\n");
|
|
|
+ return -EBUSY;
|
|
|
+ }
|
|
|
+
|
|
|
+ /*
|
|
|
+ * do not even attempt suspend if the remote processor is not
|
|
|
+ * idled for runtime auto-suspend
|
|
|
+ */
|
|
|
+ if (!_is_rproc_in_standby(oproc)) {
|
|
|
+ ret = -EBUSY;
|
|
|
+ goto abort;
|
|
|
+ }
|
|
|
+
|
|
|
+ ret = _omap_rproc_suspend(rproc, true);
|
|
|
+ if (ret)
|
|
|
+ goto abort;
|
|
|
+
|
|
|
+ rproc->state = RPROC_SUSPENDED;
|
|
|
+ return 0;
|
|
|
+
|
|
|
+abort:
|
|
|
+ pm_runtime_mark_last_busy(dev);
|
|
|
+ return ret;
|
|
|
+}
|
|
|
+
|
|
|
+static int omap_rproc_runtime_resume(struct device *dev)
|
|
|
+{
|
|
|
+ struct rproc *rproc = dev_get_drvdata(dev);
|
|
|
+ int ret;
|
|
|
+
|
|
|
+ if (WARN_ON(rproc->state != RPROC_SUSPENDED)) {
|
|
|
+ dev_err(dev, "rproc cannot be runtime resumed if not suspended!\n");
|
|
|
+ return -EBUSY;
|
|
|
+ }
|
|
|
+
|
|
|
+ ret = _omap_rproc_resume(rproc, true);
|
|
|
+ if (ret) {
|
|
|
+ dev_err(dev, "runtime resume failed %d\n", ret);
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+
|
|
|
+ rproc->state = RPROC_RUNNING;
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+#endif /* CONFIG_PM */
|
|
|
+
|
|
|
static const struct omap_rproc_dev_data omap4_dsp_dev_data = {
|
|
|
.device_name = "dsp",
|
|
|
.fw_name = "omap4-dsp-fw.xe64T",
|
|
|
@@ -607,6 +970,33 @@ static const struct of_device_id omap_rproc_of_match[] = {
|
|
|
};
|
|
|
MODULE_DEVICE_TABLE(of, omap_rproc_of_match);
|
|
|
|
|
|
+static int omap_rproc_get_autosuspend_delay(struct platform_device *pdev)
|
|
|
+{
|
|
|
+ struct device_node *np = pdev->dev.of_node;
|
|
|
+ const struct omap_rproc_dev_data *data;
|
|
|
+ int delay = -EINVAL;
|
|
|
+
|
|
|
+ data = of_device_get_match_data(&pdev->dev);
|
|
|
+ if (!data)
|
|
|
+ return -ENODEV;
|
|
|
+
|
|
|
+ if (!of_device_is_compatible(np, "ti,dra7-dsp") &&
|
|
|
+ !of_device_is_compatible(np, "ti,dra7-ipu")) {
|
|
|
+ delay = data->autosuspend_delay;
|
|
|
+ goto out;
|
|
|
+ }
|
|
|
+
|
|
|
+ for (; data && data->device_name; data++) {
|
|
|
+ if (!strcmp(dev_name(&pdev->dev), data->device_name)) {
|
|
|
+ delay = data->autosuspend_delay;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+out:
|
|
|
+ return (delay > 0) ? delay : DEFAULT_AUTOSUSPEND_DELAY;
|
|
|
+}
|
|
|
+
|
|
|
static const char *omap_rproc_get_firmware(struct platform_device *pdev)
|
|
|
{
|
|
|
struct device_node *np = pdev->dev.of_node;
|
|
|
@@ -754,6 +1144,7 @@ static int omap_rproc_probe(struct platform_device *pdev)
|
|
|
struct omap_rproc *oproc;
|
|
|
struct rproc *rproc;
|
|
|
const char *firmware;
|
|
|
+ u32 standby_addr = 0;
|
|
|
int ret;
|
|
|
|
|
|
if (!np) {
|
|
|
@@ -761,6 +1152,16 @@ static int omap_rproc_probe(struct platform_device *pdev)
|
|
|
return -ENODEV;
|
|
|
}
|
|
|
|
|
|
+ /*
|
|
|
+ * self-manage the ordering dependencies between omap_device_enable/idle
|
|
|
+ * and omap_device_assert/deassert_hardreset API during runtime suspend
|
|
|
+ * and resume, rather than relying on the order in omap_device layer.
|
|
|
+ */
|
|
|
+ if (pdev->dev.pm_domain) {
|
|
|
+ dev_dbg(&pdev->dev, "device pm_domain is being reset for this remoteproc device\n");
|
|
|
+ pdev->dev.pm_domain = NULL;
|
|
|
+ }
|
|
|
+
|
|
|
if (!pdata || !pdata->device_enable || !pdata->device_shutdown) {
|
|
|
dev_err(&pdev->dev, "platform data is either missing or incomplete\n");
|
|
|
return -ENODEV;
|
|
|
@@ -818,6 +1219,26 @@ static int omap_rproc_probe(struct platform_device *pdev)
|
|
|
oproc->num_timers);
|
|
|
}
|
|
|
|
|
|
+ init_completion(&oproc->pm_comp);
|
|
|
+ oproc->autosuspend_delay = omap_rproc_get_autosuspend_delay(pdev);
|
|
|
+ if (oproc->autosuspend_delay < 0) {
|
|
|
+ ret = oproc->autosuspend_delay;
|
|
|
+ goto free_rproc;
|
|
|
+ }
|
|
|
+
|
|
|
+ ret = of_property_read_u32(np, "ti,rproc-standby-info", &standby_addr);
|
|
|
+ if (ret || !standby_addr) {
|
|
|
+ ret = !standby_addr ? -EINVAL : ret;
|
|
|
+ goto free_rproc;
|
|
|
+ }
|
|
|
+
|
|
|
+ oproc->standby_addr = devm_ioremap(&pdev->dev, standby_addr,
|
|
|
+ sizeof(u32));
|
|
|
+ if (!oproc->standby_addr) {
|
|
|
+ ret = -ENOMEM;
|
|
|
+ goto free_rproc;
|
|
|
+ }
|
|
|
+
|
|
|
ret = of_reserved_mem_device_init(&pdev->dev);
|
|
|
if (ret) {
|
|
|
dev_err(&pdev->dev, "device does not have specific CMA pool\n");
|
|
|
@@ -853,11 +1274,18 @@ static int omap_rproc_remove(struct platform_device *pdev)
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
+static const struct dev_pm_ops omap_rproc_pm_ops = {
|
|
|
+ SET_SYSTEM_SLEEP_PM_OPS(omap_rproc_suspend, omap_rproc_resume)
|
|
|
+ SET_RUNTIME_PM_OPS(omap_rproc_runtime_suspend,
|
|
|
+ omap_rproc_runtime_resume, NULL)
|
|
|
+};
|
|
|
+
|
|
|
static struct platform_driver omap_rproc_driver = {
|
|
|
.probe = omap_rproc_probe,
|
|
|
.remove = omap_rproc_remove,
|
|
|
.driver = {
|
|
|
.name = "omap-rproc",
|
|
|
+ .pm = &omap_rproc_pm_ops,
|
|
|
.of_match_table = omap_rproc_of_match,
|
|
|
},
|
|
|
};
|