Re: [PATCH 6/7] i2c: qcom-geni: Use common GENI resource initialization helper
From: Praveen Talari
Date: Tue Aug 25 2026 - 09:44:46 EST
Hi Mukesh
On 24-08-2026 18:42, Mukesh Savaliya wrote:
On 8/5/2026 1:27 AM, Praveen Talari wrote:
[...]
@@ -228,10 +228,13 @@ static int qcom_geni_i2c_conf(struct geni_se *se, unsigned long freq)
val |= itr->t_low_cnt << LOW_COUNTER_SHFT;
val |= itr->t_cycle_cnt;
writel_relaxed(val, gi2c->se.base + SE_I2C_SCL_COUNTERS);
+
trace_geni_i2c_bus_setup(gi2c->se.dev, gi2c->clk_freq_out,
itr->clk_div, itr->t_high_cnt,
itr->t_low_cnt, itr->t_cycle_cnt);
- return 0;
+
This looks wrong to me.
First accessed registers and then we are setting ICC vote ? we should enable resources first.
At this point the hardware resources are already enabled and the ICC call only updates
the interconnect bandwidth vote. Therefore there is no dependency requiring the
ICC vote to be issued before these register accesses.
Okay let me review it and update.
+ return geni_icc_set_bw_ab(&gi2c->se, GENI_DEFAULT_BW, GENI_DEFAULT_BW,
+ Bps_to_icc(gi2c->clk_freq_out));
}
static void geni_i2c_err_misc(struct geni_i2c_dev *gi2c)
@@ -1100,24 +1103,6 @@ static int geni_i2c_init(struct geni_i2c_dev *gi2c)
return ret;
}
-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);
- if (ret)
- return ret;
-
- ret = geni_i2c_clk_map_idx(gi2c);
- if (ret)
- return dev_err_probe(gi2c->se.dev, ret, "Invalid clk frequency %d Hz\n",
- gi2c->clk_freq_out);
-
- return geni_icc_set_bw_ab(&gi2c->se, GENI_DEFAULT_BW, GENI_DEFAULT_BW,
- Bps_to_icc(gi2c->clk_freq_out));
-}
-
static int geni_i2c_probe(struct platform_device *pdev)
{
struct geni_i2c_dev *gi2c;
@@ -1188,6 +1173,11 @@ static int geni_i2c_probe(struct platform_device *pdev)
if (ret < 0)
return ret;
+ ret = geni_i2c_clk_map_idx(gi2c);
+ if (ret)
+ return dev_err_probe(gi2c->se.dev, ret, "Invalid clk frequency %d Hz\n",
+ gi2c->clk_freq_out);
+
why not move to geni_i2c_init() ?
Check recent patch @ i2c: qcom-geni: add I2C frequency table for 32 MHz firmware-based SEs.
Let's agree to move there, to avoid issue.
ret = i2c_add_adapter(&gi2c->adap);
if (ret)
return dev_err_probe(dev, ret, "Error adding i2c adapter\n");
@@ -1281,7 +1271,7 @@ static const struct dev_pm_ops geni_i2c_pm_ops = {
};
static const struct geni_i2c_desc geni_i2c = {
- .resources_init = geni_i2c_resources_init,
+ .resources_init = geni_se_resources_init,
why to add common driver function to i2c ? and also spi, uart ?
The goal was to provide a common helper that avoids duplicating
the same logic across multiple consumer drivers. As a side note,
this refactoring was done based on Konrad's earlier suggestion to
consolidate the functionality into a generic implementation.
Can we not call that function from within i2c specific hookup function ? i think design wise should keep i2c as local function.
Also driver specific anything can be managed in local function.
.set_rate = qcom_geni_i2c_conf,
.power_on = geni_se_resources_activate,
.power_off = geni_se_resources_deactivate,
@@ -1290,7 +1280,7 @@ static const struct geni_i2c_desc geni_i2c = {
static const struct geni_i2c_desc i2c_master_hub = {
.no_dma_support = true,
.tx_fifo_depth = 16,
- .resources_init = geni_i2c_resources_init,
+ .resources_init = geni_se_resources_init,
.set_rate = qcom_geni_i2c_conf,
.power_on = geni_se_resources_activate,
.power_off = geni_se_resources_deactivate,