Commit 38a592e2 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Wolfram Sang

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: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: default avatarWolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
parent 263a5646
...@@ -235,17 +235,20 @@ static int rcar_i2c_bus_barrier(struct rcar_i2c_priv *priv) ...@@ -235,17 +235,20 @@ static int rcar_i2c_bus_barrier(struct rcar_i2c_priv *priv)
return i2c_recover_bus(&priv->adap); 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; u32 scgd, cdf, round, ick, sum, scl, cdf_width;
unsigned long rate; unsigned long rate;
struct device *dev = rcar_i2c_priv_to_dev(priv); struct device *dev = rcar_i2c_priv_to_dev(priv);
struct i2c_timings i2c_t = {
.bus_freq_hz = I2C_MAX_STANDARD_MODE_FREQ,
.scl_fall_ns = 35,
.scl_rise_ns = 200,
.scl_int_delay_ns = 50,
}, *t = &i2c_t;
/* Fall back to previously used values if not supplied */ /* Fall back to previously used values if not supplied */
t->bus_freq_hz = t->bus_freq_hz ?: 100000; i2c_parse_fw_timings(dev, &i2c_t, false);
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;
switch (priv->devtype) { switch (priv->devtype) {
case I2C_RCAR_GEN1: case I2C_RCAR_GEN1:
...@@ -920,7 +923,6 @@ static int rcar_i2c_probe(struct platform_device *pdev) ...@@ -920,7 +923,6 @@ static int rcar_i2c_probe(struct platform_device *pdev)
struct rcar_i2c_priv *priv; struct rcar_i2c_priv *priv;
struct i2c_adapter *adap; struct i2c_adapter *adap;
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct i2c_timings i2c_t = { 0 };
int ret; int ret;
/* Otherwise logic will break because some bytes must always use PIO */ /* Otherwise logic will break because some bytes must always use PIO */
...@@ -957,8 +959,6 @@ static int rcar_i2c_probe(struct platform_device *pdev) ...@@ -957,8 +959,6 @@ static int rcar_i2c_probe(struct platform_device *pdev)
i2c_set_adapdata(adap, priv); i2c_set_adapdata(adap, priv);
strlcpy(adap->name, pdev->name, sizeof(adap->name)); strlcpy(adap->name, pdev->name, sizeof(adap->name));
i2c_parse_fw_timings(dev, &i2c_t, false);
/* Init DMA */ /* Init DMA */
sg_init_table(&priv->sg, 1); sg_init_table(&priv->sg, 1);
priv->dma_direction = DMA_NONE; priv->dma_direction = DMA_NONE;
...@@ -967,7 +967,7 @@ static int rcar_i2c_probe(struct platform_device *pdev) ...@@ -967,7 +967,7 @@ static int rcar_i2c_probe(struct platform_device *pdev)
/* Activate device for clock calculation */ /* Activate device for clock calculation */
pm_runtime_enable(dev); pm_runtime_enable(dev);
pm_runtime_get_sync(dev); pm_runtime_get_sync(dev);
ret = rcar_i2c_clock_calculate(priv, &i2c_t); ret = rcar_i2c_clock_calculate(priv);
if (ret < 0) if (ret < 0)
goto out_pm_put; goto out_pm_put;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment