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

Commit e4b541e1 authored by Dilip Kota's avatar Dilip Kota Committed by Sana Venkat Raju
Browse files

qup_i2c: Handle scenario if runtime PM is disable



If runtime PM is not supported, make sure
the I2C clock and GPIOs enabled at the start
of the transfer(RD/WR)
This is done by i2c_qup_pm_resume_runtime()

CRs-Fixed: 492194
Change-Id: Iaa901a0f0d0cd58318e3f6dd64e1db73c73b630f
Signed-off-by: default avatarDilip Kota <c_dkota@codeaurora.org>
Signed-off-by: default avatarSana Venkat Raju <c_vsana@codeaurora.org>
parent a40ca38d
Loading
Loading
Loading
Loading
+23 −11
Original line number Diff line number Diff line
@@ -192,6 +192,10 @@ struct qup_i2c_dev {
	struct qup_i2c_clk_path_vote clk_path_vote;
};

#ifdef CONFIG_PM
static int i2c_qup_pm_resume_runtime(struct device *device);
#endif

#ifdef DEBUG
static void
qup_print_status(struct qup_i2c_dev *dev)
@@ -944,7 +948,13 @@ qup_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
	long timeout;
	int err;

	/* Alternate if runtime power management is disabled */
	if (!pm_runtime_enabled(dev->dev)) {
		dev_dbg(dev->dev, "Runtime PM is disabled\n");
		i2c_qup_pm_resume_runtime(dev->dev);
	} else {
		pm_runtime_get_sync(dev->dev);
	}
	mutex_lock(&dev->mlock);

	if (dev->suspended) {
@@ -1754,22 +1764,24 @@ static int qup_i2c_suspend(struct device *device)
	if (!pm_runtime_enabled(device) || !pm_runtime_suspended(device)) {
		dev_dbg(device, "system suspend");
		i2c_qup_pm_suspend_runtime(device);
		/*
		 * set the device's runtime PM status to 'suspended'
		 */
		pm_runtime_disable(device);
		pm_runtime_set_suspended(device);
		pm_runtime_enable(device);
	}
	return 0;
}

static int qup_i2c_resume(struct device *device)
{
	int ret = 0;
	if (!pm_runtime_enabled(device) || !pm_runtime_suspended(device)) {
	/*
	 * Rely on runtime-PM to call resume in case it is enabled
	 * Even if it's not enabled, rely on 1st client transaction to do
	 * clock ON and gpio configuration
	 */
	dev_dbg(device, "system resume");
		ret = i2c_qup_pm_resume_runtime(device);
		if (!ret) {
			pm_runtime_mark_last_busy(device);
			pm_request_autosuspend(device);
		}
		return ret;
	}
	return 0;
}
#endif /* CONFIG_PM */