diff options
Diffstat (limited to 'drivers/i2c/busses/i2c-rcar.c')
-rw-r--r-- | drivers/i2c/busses/i2c-rcar.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c index 879f0e61a496..3b5397aa4ca6 100644 --- a/drivers/i2c/busses/i2c-rcar.c +++ b/drivers/i2c/busses/i2c-rcar.c @@ -235,17 +235,20 @@ static int rcar_i2c_bus_barrier(struct rcar_i2c_priv *priv) return i2c_recover_bus(&priv->adap); } -static int rcar_i2c_clock_calculate(struct rcar_i2c_priv *priv, struct i2c_timings *t) +static int rcar_i2c_clock_calculate(struct rcar_i2c_priv *priv) { u32 scgd, cdf, round, ick, sum, scl, cdf_width; unsigned long rate; struct device *dev = rcar_i2c_priv_to_dev(priv); + struct i2c_timings t = { + .bus_freq_hz = I2C_MAX_STANDARD_MODE_FREQ, + .scl_fall_ns = 35, + .scl_rise_ns = 200, + .scl_int_delay_ns = 50, + }; /* Fall back to previously used values if not supplied */ - t->bus_freq_hz = t->bus_freq_hz ?: 100000; - t->scl_fall_ns = t->scl_fall_ns ?: 35; - t->scl_rise_ns = t->scl_rise_ns ?: 200; - t->scl_int_delay_ns = t->scl_int_delay_ns ?: 50; + i2c_parse_fw_timings(dev, &t, false); switch (priv->devtype) { case I2C_RCAR_GEN1: @@ -291,7 +294,7 @@ static int rcar_i2c_clock_calculate(struct rcar_i2c_priv *priv, struct i2c_timin * = F[sum * ick / 1000000000] * = F[(ick / 1000000) * sum / 1000] */ - sum = t->scl_fall_ns + t->scl_rise_ns + t->scl_int_delay_ns; + sum = t.scl_fall_ns + t.scl_rise_ns + t.scl_int_delay_ns; round = (ick + 500000) / 1000000 * sum; round = (round + 500) / 1000; @@ -309,7 +312,7 @@ static int rcar_i2c_clock_calculate(struct rcar_i2c_priv *priv, struct i2c_timin */ for (scgd = 0; scgd < 0x40; scgd++) { scl = ick / (20 + (scgd * 8) + round); - if (scl <= t->bus_freq_hz) + if (scl <= t.bus_freq_hz) goto scgd_find; } dev_err(dev, "it is impossible to calculate best SCL\n"); @@ -317,7 +320,7 @@ static int rcar_i2c_clock_calculate(struct rcar_i2c_priv *priv, struct i2c_timin scgd_find: dev_dbg(dev, "clk %d/%d(%lu), round %u, CDF:0x%x, SCGD: 0x%x\n", - scl, t->bus_freq_hz, rate, round, cdf, scgd); + scl, t.bus_freq_hz, rate, round, cdf, scgd); /* keep icccr value */ priv->icccr = scgd << cdf_width | cdf; @@ -920,7 +923,6 @@ static int rcar_i2c_probe(struct platform_device *pdev) struct rcar_i2c_priv *priv; struct i2c_adapter *adap; struct device *dev = &pdev->dev; - struct i2c_timings i2c_t; int ret; /* Otherwise logic will break because some bytes must always use PIO */ @@ -957,8 +959,6 @@ static int rcar_i2c_probe(struct platform_device *pdev) i2c_set_adapdata(adap, priv); strlcpy(adap->name, pdev->name, sizeof(adap->name)); - i2c_parse_fw_timings(dev, &i2c_t, false); - /* Init DMA */ sg_init_table(&priv->sg, 1); priv->dma_direction = DMA_NONE; @@ -967,7 +967,7 @@ static int rcar_i2c_probe(struct platform_device *pdev) /* Activate device for clock calculation */ pm_runtime_enable(dev); pm_runtime_get_sync(dev); - ret = rcar_i2c_clock_calculate(priv, &i2c_t); + ret = rcar_i2c_clock_calculate(priv); if (ret < 0) goto out_pm_put; |