Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0897d6fc authored by Prudhvi Yarlagadda's avatar Prudhvi Yarlagadda
Browse files

spi: spi_qsd: Add Shared EE property check for spi



Add Shared EE property check for spi to support dual EE use case.
Have the prepare_message/unprepare_message API support for spi
for Dual EE use case so that client can have control for spi
driver get_sync, put_sync by calling the APIs pm_runtime_get_sync
and pm_runtime_put_sync_suspend and use them when switching to
other EEs. This will allow client driver to remove the delay/wait
time while switching between the secure and non-secure EEs.

Change-Id: I465bc4b9036b3b9701a876825412b55b4d4134c7
Signed-off-by: default avatarPrudhvi Yarlagadda <pyarlaga@codeaurora.org>
parent 3fc748c6
Loading
Loading
Loading
Loading
+82 −15
Original line number Diff line number Diff line
@@ -1704,28 +1704,82 @@ static int msm_spi_transfer_one(struct spi_master *master,
	return status_error;
}

static int msm_spi_prepare_transfer_hardware(struct spi_master *master)
static int msm_spi_pm_get_sync(struct device *dev)
{
	struct msm_spi	*dd = spi_master_get_devdata(master);
	int resume_state = 0;

	resume_state = pm_runtime_get_sync(dd->dev);
	if (resume_state < 0)
		goto spi_finalize;
	int ret;

	/*
	 * Counter-part of system-suspend when runtime-pm is not enabled.
	 * This way, resume can be left empty and device will be put in
	 * active mode only if client requests anything on the bus
	 */
	if (!pm_runtime_enabled(dd->dev))
		resume_state = msm_spi_pm_resume_runtime(dd->dev);
	if (!pm_runtime_enabled(dev)) {
		dev_info(dev, "%s: pm_runtime not enabled\n", __func__);
		ret = msm_spi_pm_resume_runtime(dev);
	} else {
		ret = pm_runtime_get_sync(dev);
	}

	return ret;
}

static int msm_spi_pm_put_sync(struct device *dev)
{
	int ret = 0;

	if (!pm_runtime_enabled(dev)) {
		dev_info(dev, "%s: pm_runtime not enabled\n", __func__);
		ret = msm_spi_pm_suspend_runtime(dev);
	} else {
		pm_runtime_mark_last_busy(dev);
		pm_runtime_put_autosuspend(dev);
	}

	return ret;
}

static int msm_spi_prepare_message(struct spi_master *master,
					struct spi_message *spi_msg)
{
	struct msm_spi *dd = spi_master_get_devdata(master);
	int resume_state;

	resume_state = msm_spi_pm_get_sync(dd->dev);
	if (resume_state < 0)
		return resume_state;

	return 0;
}

static int msm_spi_unprepare_message(struct spi_master *master,
					struct spi_message *spi_msg)
{
	struct msm_spi *dd = spi_master_get_devdata(master);
	int ret;

	ret = msm_spi_pm_put_sync(dd->dev);
	if (ret < 0)
		return ret;

	return 0;
}

static int msm_spi_prepare_transfer_hardware(struct spi_master *master)
{
	struct msm_spi *dd = spi_master_get_devdata(master);
	int resume_state;

	if (!dd->pdata->shared_ee) {
		resume_state = msm_spi_pm_get_sync(dd->dev);
		if (resume_state < 0)
			goto spi_finalize;

		if (dd->suspended) {
			resume_state = -EBUSY;
			goto spi_finalize;
		}
	}

	return 0;

spi_finalize:
@@ -1736,9 +1790,14 @@ static int msm_spi_prepare_transfer_hardware(struct spi_master *master)
static int msm_spi_unprepare_transfer_hardware(struct spi_master *master)
{
	struct msm_spi	*dd = spi_master_get_devdata(master);
	int ret;

	if (!dd->pdata->shared_ee) {
		ret = msm_spi_pm_put_sync(dd->dev);
		if (ret < 0)
			return ret;
	}

	pm_runtime_mark_last_busy(dd->dev);
	pm_runtime_put_autosuspend(dd->dev);
	return 0;
}

@@ -2234,6 +2293,8 @@ static struct msm_spi_platform_data *msm_spi_dt_to_pdata(
			&pdata->rt_priority,		 DT_OPT,  DT_BOOL,  0},
		{"qcom,shared",
			&pdata->is_shared,		 DT_OPT,  DT_BOOL,  0},
		{"qcom,shared_ee",
			&pdata->shared_ee,		 DT_OPT,  DT_BOOL,  0},
		{NULL,  NULL,                            0,       0,        0},
		};

@@ -2557,6 +2618,12 @@ static int msm_spi_probe(struct platform_device *pdev)
		goto err_probe_reqmem;
	}

	/* This property is required for Dual EE use case of spi */
	if (dd->pdata->shared_ee) {
		master->prepare_message = msm_spi_prepare_message;
		master->unprepare_message = msm_spi_unprepare_message;
	}

	pm_runtime_set_autosuspend_delay(&pdev->dev, MSEC_PER_SEC);
	pm_runtime_use_autosuspend(&pdev->dev);
	pm_runtime_enable(&pdev->dev);
+5 −1
Original line number Diff line number Diff line
@@ -35,7 +35,10 @@
 * @bam_producer_pipe_index BAM producer pipe
 * @rt_priority true if RT thread
 * @use_pinctrl true if pinctrl library is used
 * @is_shared true when qup is shared between ee's
 * @is_shared true when qup is shared between ee's and client driver is not
	in control of spi pm_runtime_get_sync/put_sync.
 * @shared_ee true when qup is shared between ee's and client driver is in
	control of spi pm_runtime_get_sync/put_sync.
 */
struct msm_spi_platform_data {
	u32 max_clock_speed;
@@ -54,4 +57,5 @@ struct msm_spi_platform_data {
	bool rt_priority;
	bool use_pinctrl;
	bool is_shared;
	bool shared_ee;
};