From: Praveen Talari <praveen.talari@oss.qualcomm.com>
To: Bjorn Andersson <andersson@kernel.org>
Cc: Andi Shyti <andi.shyti@kernel.org>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Mukesh Kumar Savaliya <mukesh.savaliya@oss.qualcomm.com>,
Viken Dadhaniya <viken.dadhaniya@oss.qualcomm.com>,
Konrad Dybcio <konradybcio@kernel.org>,
linux-arm-msm@vger.kernel.org, linux-i2c@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
psodagud@quicinc.com, djaggi@quicinc.com,
quic_msavaliy@quicinc.com, quic_vtanuku@quicinc.com,
quic_arandive@quicinc.com, quic_shazhuss@quicinc.com
Subject: Re: [PATCH v1 12/12] i2c: qcom-geni: Enable I2C on SA8255p Qualcomm platforms
Date: Mon, 1 Dec 2025 22:54:32 +0530 [thread overview]
Message-ID: <473d842f-5d70-4bd9-8cb0-a4c28acd5fe4@oss.qualcomm.com> (raw)
In-Reply-To: <4kjkadmhf67ts4pryhvqdk57b2k27ggwkt2vqdijvhmwygpspb@rpdwcpxpq2up>
Hi Bjorn,
On 11/26/2025 9:22 PM, Bjorn Andersson wrote:
> On Sat, Nov 22, 2025 at 10:30:18AM +0530, Praveen Talari wrote:
>> The Qualcomm automotive SA8255p SoC relies on firmware to configure
>> platform resources, including clocks, interconnects and TLMM.
>> The driver requests resources operations over SCMI using power
>> and performance protocols.
>>
>> The SCMI power protocol enables or disables resources like clocks,
>> interconnect paths, and TLMM (GPIOs) using runtime PM framework APIs,
>> such as resume/suspend, to control power states(on/off).
>>
>> The SCMI performance protocol manages I2C frequency, with each
>> frequency rate represented by a performance level. The driver uses
>> geni_se_set_perf_opp() API to request the desired frequency rate..
>>
>> As part of geni_se_set_perf_opp(), the OPP for the requested frequency
>> is obtained using dev_pm_opp_find_freq_floor() and the performance
>> level is set using dev_pm_opp_set_opp().
>>
>> Signed-off-by: Praveen Talari <praveen.talari@oss.qualcomm.com>
>> ---
>> drivers/i2c/busses/i2c-qcom-geni.c | 46 +++++++++++++++++++++++-------
>> 1 file changed, 35 insertions(+), 11 deletions(-)
>>
>> diff --git a/drivers/i2c/busses/i2c-qcom-geni.c b/drivers/i2c/busses/i2c-qcom-geni.c
>> index a0f68fdd4078..78154879f02d 100644
>> --- a/drivers/i2c/busses/i2c-qcom-geni.c
>> +++ b/drivers/i2c/busses/i2c-qcom-geni.c
>> @@ -82,6 +82,9 @@ struct geni_i2c_desc {
>> char *icc_ddr;
>> bool no_dma_support;
>> unsigned int tx_fifo_depth;
>> + int (*resources_init)(struct geni_se *se);
>> + int (*set_rate)(struct geni_se *se, unsigned long freq);
>> + int (*power_state)(struct geni_se *se, bool state);
>
> You have isolated this quite nicely now, so I'd prefer 3 (four to keep
> power on/off separate) if statements, over these function pointers, at
> this point.
Thank you for the feedback. I understand the preference for if
statements, but function pointers offer better scalability here:
- Qualcomm has various power management schemes (Linux-driven vs
firmware-assisted) across SoCs with more variants coming.
- If statements would require modifying the core driver logic for each
new SoC variant, while function pointers isolate hardware-specific
behavior to dedicated implementations.
- New SoC enablement becomes a matter of adding new function
implementations rather than touching core logic.
Thanks,
Praveen
>
> This saves the future reader from having to remember the combination of
> function pointer targets in the various cases - and allow things like
> "jump to definition" in your editor to still work.
>
>> };
>>
>> #define QCOM_I2C_MIN_NUM_OF_MSGS_MULTI_DESC 2
>> @@ -203,8 +206,9 @@ static int geni_i2c_clk_map_idx(struct geni_i2c_dev *gi2c)
>> return -EINVAL;
>> }
>>
>> -static void qcom_geni_i2c_conf(struct geni_i2c_dev *gi2c)
>> +static int qcom_geni_i2c_conf(struct geni_se *se, unsigned long freq)
>
> This sounds like a qcom_geni_i2c_set_rate() now that it takes a
> frequency argument.
Yes because of function pointer compatible
int (*set_rate)(struct geni_se *se, unsigned long freq);
Thanks,
Praveen
>
> Regards,
> Bjorn
>
>> {
>> + struct geni_i2c_dev *gi2c = dev_get_drvdata(se->dev);
>> const struct geni_i2c_clk_fld *itr = gi2c->clk_fld;
>> u32 val;
>>
>> @@ -217,6 +221,7 @@ static void qcom_geni_i2c_conf(struct geni_i2c_dev *gi2c)
>> val |= itr->t_low_cnt << LOW_COUNTER_SHFT;
>> val |= itr->t_cycle_cnt;
>> writel_relaxed(val, gi2c->se.base + SE_I2C_SCL_COUNTERS);
>> + return 0;
>> }
>>
>> static void geni_i2c_err_misc(struct geni_i2c_dev *gi2c)
>> @@ -908,7 +913,9 @@ static int geni_i2c_xfer(struct i2c_adapter *adap,
>> return ret;
>> }
>>
>> - qcom_geni_i2c_conf(gi2c);
>> + ret = gi2c->dev_data->set_rate(&gi2c->se, gi2c->clk_freq_out);
>> + if (ret)
>> + return ret;
>>
>> if (gi2c->gpi_mode)
>> ret = geni_i2c_gpi_xfer(gi2c, msgs, num);
>> @@ -1041,8 +1048,9 @@ static int geni_i2c_init(struct geni_i2c_dev *gi2c)
>> return ret;
>> }
>>
>> -static int geni_i2c_resources_init(struct geni_i2c_dev *gi2c)
>> +static int geni_i2c_resources_init(struct geni_se *se)
>> {
>> + struct geni_i2c_dev *gi2c = dev_get_drvdata(se->dev);
>> int ret;
>>
>> ret = geni_se_resources_init(&gi2c->se);
>> @@ -1095,7 +1103,7 @@ static int geni_i2c_probe(struct platform_device *pdev)
>> spin_lock_init(&gi2c->lock);
>> platform_set_drvdata(pdev, gi2c);
>>
>> - ret = geni_i2c_resources_init(gi2c);
>> + ret = gi2c->dev_data->resources_init(&gi2c->se);
>> if (ret)
>> return ret;
>>
>> @@ -1165,10 +1173,12 @@ static int __maybe_unused geni_i2c_runtime_suspend(struct device *dev)
>>
>> disable_irq(gi2c->irq);
>>
>> - ret = geni_se_resources_state(&gi2c->se, false);
>> - if (ret) {
>> - enable_irq(gi2c->irq);
>> - return ret;
>> + if (gi2c->dev_data->power_state) {
>> + ret = gi2c->dev_data->power_state(&gi2c->se, false);
>> + if (ret) {
>> + enable_irq(gi2c->irq);
>> + return ret;
>> + }
>> }
>>
>> gi2c->suspended = 1;
>> @@ -1180,9 +1190,11 @@ static int __maybe_unused geni_i2c_runtime_resume(struct device *dev)
>> int ret;
>> struct geni_i2c_dev *gi2c = dev_get_drvdata(dev);
>>
>> - ret = geni_se_resources_state(&gi2c->se, true);
>> - if (ret)
>> - return ret;
>> + if (gi2c->dev_data->power_state) {
>> + ret = gi2c->dev_data->power_state(&gi2c->se, true);
>> + if (ret)
>> + return ret;
>> + }
>>
>> enable_irq(gi2c->irq);
>> gi2c->suspended = 0;
>> @@ -1221,6 +1233,9 @@ static const struct dev_pm_ops geni_i2c_pm_ops = {
>>
>> static const struct geni_i2c_desc geni_i2c = {
>> .icc_ddr = "qup-memory",
>> + .resources_init = geni_i2c_resources_init,
>> + .set_rate = qcom_geni_i2c_conf,
>> + .power_state = geni_se_resources_state,
>> };
>>
>> static const struct geni_i2c_desc i2c_master_hub = {
>> @@ -1228,11 +1243,20 @@ static const struct geni_i2c_desc i2c_master_hub = {
>> .icc_ddr = NULL,
>> .no_dma_support = true,
>> .tx_fifo_depth = 16,
>> + .resources_init = geni_i2c_resources_init,
>> + .set_rate = qcom_geni_i2c_conf,
>> + .power_state = geni_se_resources_state,
>> +};
>> +
>> +static const struct geni_i2c_desc sa8255p_geni_i2c = {
>> + .resources_init = geni_se_domain_attach,
>> + .set_rate = geni_se_set_perf_opp,
>> };
>>
>> static const struct of_device_id geni_i2c_dt_match[] = {
>> { .compatible = "qcom,geni-i2c", .data = &geni_i2c },
>> { .compatible = "qcom,geni-i2c-master-hub", .data = &i2c_master_hub },
>> + { .compatible = "qcom,sa8255p-geni-i2c", .data = &sa8255p_geni_i2c },
>> {}
>> };
>> MODULE_DEVICE_TABLE(of, geni_i2c_dt_match);
>> --
>> 2.34.1
>>
prev parent reply other threads:[~2025-12-01 17:24 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-22 5:00 [PATCH v1 00/12] Enable I2C on SA8255p Qualcomm platforms Praveen Talari
2025-11-22 5:00 ` [PATCH v1 01/12] soc: qcom: geni-se: Refactor geni_icc_get() and make qup-memory ICC path optional Praveen Talari
2025-11-26 15:07 ` Bjorn Andersson
2025-11-27 13:49 ` Praveen Talari
2025-11-22 5:00 ` [PATCH v1 02/12] soc: qcom: geni-se: Add geni_icc_set_bw_ab() function Praveen Talari
2025-11-22 5:00 ` [PATCH v1 03/12] soc: qcom: geni-se: Introduce helper API for resource initialization Praveen Talari
2025-11-23 10:23 ` kernel test robot
2025-11-22 5:00 ` [PATCH v1 04/12] soc: qcom: geni-se: Add geni_se_resource_state() helper Praveen Talari
2025-11-26 15:19 ` Bjorn Andersson
2025-11-28 4:42 ` Praveen Talari
2025-11-22 5:00 ` [PATCH v1 05/12] soc: qcom: geni-se: Introduce helper API for attaching power domains Praveen Talari
2025-11-22 5:00 ` [PATCH v1 06/12] soc: qcom: geni-se: Introduce helper APIs for performance control Praveen Talari
2025-11-22 5:00 ` [PATCH v1 07/12] dt-bindings: i2c: Describe SA8255p Praveen Talari
2025-11-22 11:40 ` Krzysztof Kozlowski
2025-11-25 4:03 ` Praveen Talari
2025-11-25 7:25 ` Krzysztof Kozlowski
2025-11-26 5:02 ` Praveen Talari
2025-12-02 3:42 ` Praveen Talari
2025-11-22 5:00 ` [PATCH v1 08/12] i2c: qcom-geni: Isolate serial engine setup Praveen Talari
2025-11-26 15:30 ` Bjorn Andersson
2025-11-28 6:22 ` Praveen Talari
2025-11-22 5:00 ` [PATCH v1 09/12] i2c: qcom-geni: Move resource initialization to separate function Praveen Talari
2025-11-22 5:00 ` [PATCH v1 10/12] i2c: qcom-geni: Use geni_se_resources_state() API in runtime PM functions Praveen Talari
2025-11-26 15:38 ` Bjorn Andersson
2025-12-01 16:33 ` Praveen Talari
2025-11-22 5:00 ` [PATCH v1 11/12] i2c: qcom-geni: Store of_device_id data in driver private struct Praveen Talari
2025-11-22 5:00 ` [PATCH v1 12/12] i2c: qcom-geni: Enable I2C on SA8255p Qualcomm platforms Praveen Talari
2025-11-23 11:46 ` kernel test robot
2025-11-26 15:52 ` Bjorn Andersson
2025-12-01 17:24 ` Praveen Talari [this message]
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=473d842f-5d70-4bd9-8cb0-a4c28acd5fe4@oss.qualcomm.com \
--to=praveen.talari@oss.qualcomm.com \
--cc=andersson@kernel.org \
--cc=andi.shyti@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=djaggi@quicinc.com \
--cc=konradybcio@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mukesh.savaliya@oss.qualcomm.com \
--cc=psodagud@quicinc.com \
--cc=quic_arandive@quicinc.com \
--cc=quic_msavaliy@quicinc.com \
--cc=quic_shazhuss@quicinc.com \
--cc=quic_vtanuku@quicinc.com \
--cc=robh@kernel.org \
--cc=viken.dadhaniya@oss.qualcomm.com \
/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