From: Georgi Djakov <georgi.djakov@linaro.org>
To: linux-pm@vger.kernel.org
Cc: gregkh@linuxfoundation.org, rjw@rjwysocki.net,
robh+dt@kernel.org, mturquette@baylibre.com,
khilman@baylibre.com, vincent.guittot@linaro.org,
skannan@codeaurora.org, bjorn.andersson@linaro.org,
amit.kucheria@linaro.org, seansw@qti.qualcomm.com,
daidavid1@codeaurora.org, evgreen@chromium.org,
mark.rutland@arm.com, lorenzo.pieralisi@arm.com,
abailon@baylibre.com, maxime.ripard@bootlin.com, arnd@arndb.de,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-arm-msm@vger.kernel.org, wsa@the-dreams.de,
linux-i2c@vger.kernel.org, georgi.djakov@linaro.org
Subject: [RFC] i2c: qup: Use the interconnect API
Date: Thu, 20 Sep 2018 11:29:03 -0700 [thread overview]
Message-ID: <20180920182903.19991-1-georgi.djakov@linaro.org> (raw)
The interconnect API provides an interface for consumer drivers to express
their bandwidth needs in the SoC. This data is aggregated and the on-chip
interconnect hardware is configured to the appropriate power/performance
profile.
Use the interconnect API to get() the path between the endpoints used for
data transfers by the I2C QUP and report the needed bandwidth based on the
i2c mode.
Signed-off-by: Georgi Djakov <georgi.djakov@linaro.org>
---
This patch depends on the interconnect API: https://lkml.org/lkml/2018/8/31/444
TODO: Use a macro for converting and rounding to icc units instead of
converting between kilobits, kilobytes etc. in the consumer drivers.
drivers/i2c/busses/i2c-qup.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/drivers/i2c/busses/i2c-qup.c b/drivers/i2c/busses/i2c-qup.c
index c86c3ae1318f..436747a74dc6 100644
--- a/drivers/i2c/busses/i2c-qup.c
+++ b/drivers/i2c/busses/i2c-qup.c
@@ -14,6 +14,7 @@
#include <linux/dma-mapping.h>
#include <linux/err.h>
#include <linux/i2c.h>
+#include <linux/interconnect.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/module.h>
@@ -280,6 +281,11 @@ struct qup_i2c_dev {
void (*read_rx_fifo)(struct qup_i2c_dev *qup);
/* function to write tags in tx fifo for i2c read transfer */
void (*write_rx_tags)(struct qup_i2c_dev *qup);
+
+ /* frequency mode standard */
+ u32 clk_freq;
+ /* interconnect path to scale according to bandwidth needs */
+ struct icc_path *path;
};
static irqreturn_t qup_i2c_interrupt(int irq, void *dev)
@@ -1657,6 +1663,16 @@ static void qup_i2c_disable_clocks(struct qup_i2c_dev *qup)
clk_disable_unprepare(qup->pclk);
}
+static void qup_i2c_enable_icc(struct qup_i2c_dev *qup)
+{
+ icc_set(qup->path, 0, qup->clk_freq / 8000);
+}
+
+static void qup_i2c_disable_icc(struct qup_i2c_dev *qup)
+{
+ icc_set(qup->path, 0, 0);
+}
+
static const struct acpi_device_id qup_i2c_acpi_match[] = {
{ "QCOM8010"},
{ },
@@ -1784,6 +1800,10 @@ static int qup_i2c_probe(struct platform_device *pdev)
}
ACPI_COMPANION_SET(&qup->adap.dev, ACPI_COMPANION(qup->dev));
} else {
+ qup->path = of_icc_get(qup->dev, "i2c-mem");
+ if (IS_ERR(qup->path))
+ return PTR_ERR(qup->path);
+
qup->clk = devm_clk_get(qup->dev, "core");
if (IS_ERR(qup->clk)) {
dev_err(qup->dev, "Could not get core clock\n");
@@ -1795,6 +1815,8 @@ static int qup_i2c_probe(struct platform_device *pdev)
dev_err(qup->dev, "Could not get iface clock\n");
return PTR_ERR(qup->pclk);
}
+ qup->clk_freq = clk_freq;
+ qup_i2c_enable_icc(qup);
qup_i2c_enable_clocks(qup);
src_clk_freq = clk_get_rate(qup->clk);
}
@@ -1927,6 +1949,7 @@ static int qup_i2c_remove(struct platform_device *pdev)
disable_irq(qup->irq);
qup_i2c_disable_clocks(qup);
+ icc_put(qup->path);
i2c_del_adapter(&qup->adap);
pm_runtime_disable(qup->dev);
pm_runtime_set_suspended(qup->dev);
@@ -1939,6 +1962,7 @@ static int qup_i2c_pm_suspend_runtime(struct device *device)
struct qup_i2c_dev *qup = dev_get_drvdata(device);
dev_dbg(device, "pm_runtime: suspending...\n");
+ qup_i2c_disable_icc(qup);
qup_i2c_disable_clocks(qup);
return 0;
}
@@ -1948,6 +1972,7 @@ static int qup_i2c_pm_resume_runtime(struct device *device)
struct qup_i2c_dev *qup = dev_get_drvdata(device);
dev_dbg(device, "pm_runtime: resuming...\n");
+ qup_i2c_enable_icc(qup);
qup_i2c_enable_clocks(qup);
return 0;
}
next reply other threads:[~2018-09-20 18:29 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-20 18:29 Georgi Djakov [this message]
2018-10-19 17:37 ` [RFC] i2c: qup: Use the interconnect API Evan Green
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180920182903.19991-1-georgi.djakov@linaro.org \
--to=georgi.djakov@linaro.org \
--cc=abailon@baylibre.com \
--cc=amit.kucheria@linaro.org \
--cc=arnd@arndb.de \
--cc=bjorn.andersson@linaro.org \
--cc=daidavid1@codeaurora.org \
--cc=devicetree@vger.kernel.org \
--cc=evgreen@chromium.org \
--cc=gregkh@linuxfoundation.org \
--cc=khilman@baylibre.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=lorenzo.pieralisi@arm.com \
--cc=mark.rutland@arm.com \
--cc=maxime.ripard@bootlin.com \
--cc=mturquette@baylibre.com \
--cc=rjw@rjwysocki.net \
--cc=robh+dt@kernel.org \
--cc=seansw@qti.qualcomm.com \
--cc=skannan@codeaurora.org \
--cc=vincent.guittot@linaro.org \
--cc=wsa@the-dreams.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).