[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250903080948.3898671-2-quic_mmanikan@quicinc.com>
Date: Wed, 3 Sep 2025 13:39:47 +0530
From: Manikanta Mylavarapu <quic_mmanikan@...cinc.com>
To: <andersson@...nel.org>, <konradybcio@...nel.org>, <robh@...nel.org>,
<krzk+dt@...nel.org>, <conor+dt@...nel.org>,
<quic_msavaliy@...cinc.com>, <quic_vdadhani@...cinc.com>,
<andi.shyti@...nel.org>, <linux-arm-msm@...r.kernel.org>,
<devicetree@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<linux-i2c@...r.kernel.org>
CC: <quic_srichara@...cinc.com>, <quic_varada@...cinc.com>,
<kathiravan.thirumoorthy@....qualcomm.com>
Subject: [PATCH v2 1/2] i2c: qcom-geni: add OPP table support
Add support for reading and configuring the OPP table in the GENI I2C
driver. This enables setting the frequency based on device tree data,
removing dependency on bootloader configuration.
Signed-off-by: Manikanta Mylavarapu <quic_mmanikan@...cinc.com>
---
drivers/i2c/busses/i2c-qcom-geni.c | 27 ++++++++++++++++++++++++---
1 file changed, 24 insertions(+), 3 deletions(-)
diff --git a/drivers/i2c/busses/i2c-qcom-geni.c b/drivers/i2c/busses/i2c-qcom-geni.c
index ff2289b52c84..85b7f25e0c6e 100644
--- a/drivers/i2c/busses/i2c-qcom-geni.c
+++ b/drivers/i2c/busses/i2c-qcom-geni.c
@@ -13,6 +13,7 @@
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
+#include <linux/pm_opp.h>
#include <linux/pm_runtime.h>
#include <linux/soc/qcom/geni-se.h>
#include <linux/spinlock.h>
@@ -779,11 +780,13 @@ static int setup_gpi_dma(struct geni_i2c_dev *gi2c)
static int geni_i2c_probe(struct platform_device *pdev)
{
- struct geni_i2c_dev *gi2c;
+ const struct geni_i2c_desc *desc = NULL;
u32 proto, tx_depth, fifo_disable;
- int ret;
struct device *dev = &pdev->dev;
- const struct geni_i2c_desc *desc = NULL;
+ unsigned long freq = ULONG_MAX;
+ struct geni_i2c_dev *gi2c;
+ struct dev_pm_opp *opp;
+ int ret;
gi2c = devm_kzalloc(dev, sizeof(*gi2c), GFP_KERNEL);
if (!gi2c)
@@ -814,6 +817,24 @@ static int geni_i2c_probe(struct platform_device *pdev)
gi2c->clk_freq_out = I2C_MAX_STANDARD_MODE_FREQ;
}
+ ret = devm_pm_opp_set_clkname(&pdev->dev, "se");
+ if (ret)
+ return ret;
+
+ /* OPP table is optional */
+ ret = devm_pm_opp_of_add_table(dev);
+ if (!ret) {
+ opp = dev_pm_opp_find_freq_floor(dev, &freq);
+ if (IS_ERR(opp))
+ return dev_err_probe(dev, PTR_ERR(opp), "failed to find the frequency\n");
+ dev_pm_opp_put(opp);
+ ret = dev_pm_opp_set_rate(dev, freq);
+ if (ret)
+ return dev_err_probe(dev, ret, "failed to set the rate=%ld\n", freq);
+ } else if (ret && ret != -ENODEV) {
+ return dev_err_probe(&pdev->dev, ret, "invalid OPP table in device tree\n");
+ }
+
if (has_acpi_companion(dev))
ACPI_COMPANION_SET(&gi2c->adap.dev, ACPI_COMPANION(dev));
--
2.34.1
Powered by blists - more mailing lists