Skip to content

Commit 38a592e

Browse files
andy-shevWolfram Sang
authored andcommitted
i2c: rcar: Consolidate timings calls in rcar_i2c_clock_calculate()
Move i2c_parse_fw_timings() to rcar_i2c_clock_calculate() to consolidate timings calls in one place. While here, replace hard coded values with standard bus frequency definitions. Signed-off-by: Andy Shevchenko <[email protected]> Tested-by: Wolfram Sang <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
1 parent 263a564 commit 38a592e

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

drivers/i2c/busses/i2c-rcar.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -235,17 +235,20 @@ static int rcar_i2c_bus_barrier(struct rcar_i2c_priv *priv)
235235
return i2c_recover_bus(&priv->adap);
236236
}
237237

238-
static int rcar_i2c_clock_calculate(struct rcar_i2c_priv *priv, struct i2c_timings *t)
238+
static int rcar_i2c_clock_calculate(struct rcar_i2c_priv *priv)
239239
{
240240
u32 scgd, cdf, round, ick, sum, scl, cdf_width;
241241
unsigned long rate;
242242
struct device *dev = rcar_i2c_priv_to_dev(priv);
243+
struct i2c_timings i2c_t = {
244+
.bus_freq_hz = I2C_MAX_STANDARD_MODE_FREQ,
245+
.scl_fall_ns = 35,
246+
.scl_rise_ns = 200,
247+
.scl_int_delay_ns = 50,
248+
}, *t = &i2c_t;
243249

244250
/* Fall back to previously used values if not supplied */
245-
t->bus_freq_hz = t->bus_freq_hz ?: 100000;
246-
t->scl_fall_ns = t->scl_fall_ns ?: 35;
247-
t->scl_rise_ns = t->scl_rise_ns ?: 200;
248-
t->scl_int_delay_ns = t->scl_int_delay_ns ?: 50;
251+
i2c_parse_fw_timings(dev, &i2c_t, false);
249252

250253
switch (priv->devtype) {
251254
case I2C_RCAR_GEN1:
@@ -920,7 +923,6 @@ static int rcar_i2c_probe(struct platform_device *pdev)
920923
struct rcar_i2c_priv *priv;
921924
struct i2c_adapter *adap;
922925
struct device *dev = &pdev->dev;
923-
struct i2c_timings i2c_t = { 0 };
924926
int ret;
925927

926928
/* Otherwise logic will break because some bytes must always use PIO */
@@ -957,8 +959,6 @@ static int rcar_i2c_probe(struct platform_device *pdev)
957959
i2c_set_adapdata(adap, priv);
958960
strlcpy(adap->name, pdev->name, sizeof(adap->name));
959961

960-
i2c_parse_fw_timings(dev, &i2c_t, false);
961-
962962
/* Init DMA */
963963
sg_init_table(&priv->sg, 1);
964964
priv->dma_direction = DMA_NONE;
@@ -967,7 +967,7 @@ static int rcar_i2c_probe(struct platform_device *pdev)
967967
/* Activate device for clock calculation */
968968
pm_runtime_enable(dev);
969969
pm_runtime_get_sync(dev);
970-
ret = rcar_i2c_clock_calculate(priv, &i2c_t);
970+
ret = rcar_i2c_clock_calculate(priv);
971971
if (ret < 0)
972972
goto out_pm_put;
973973

0 commit comments

Comments
 (0)