]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
i2c: rcar: rework hw init
authorWolfram Sang <wsa+renesas@sang-engineering.com>
Thu, 19 Nov 2015 15:56:42 +0000 (16:56 +0100)
committerWolfram Sang <wsa@the-dreams.de>
Mon, 30 Nov 2015 13:20:04 +0000 (14:20 +0100)
We don't need to init HW before every transfer since we know the HW
state then. HW init at probe time is enough. While here, add setting the
clock register which belongs to init HW. Also, set MDBS bit since not
setting it is prohibited according to the manual.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
drivers/i2c/busses/i2c-rcar.c

index dac0f5d194534184274e4a5a50f7a750aec4d4d4..efc8de6cc8a2f9251451f940b78e95f618681707 100644 (file)
@@ -144,9 +144,10 @@ static void rcar_i2c_init(struct rcar_i2c_priv *priv)
 {
        /* reset master mode */
        rcar_i2c_write(priv, ICMIER, 0);
-       rcar_i2c_write(priv, ICMCR, 0);
+       rcar_i2c_write(priv, ICMCR, MDBS);
        rcar_i2c_write(priv, ICMSR, 0);
-       rcar_i2c_write(priv, ICMAR, 0);
+       /* start clock */
+       rcar_i2c_write(priv, ICCCR, priv->icccr);
 }
 
 static int rcar_i2c_bus_barrier(struct rcar_i2c_priv *priv)
@@ -496,16 +497,6 @@ static int rcar_i2c_master_xfer(struct i2c_adapter *adap,
 
        pm_runtime_get_sync(dev);
 
-       /*-------------- spin lock -----------------*/
-       spin_lock_irqsave(&priv->lock, flags);
-
-       rcar_i2c_init(priv);
-       /* start clock */
-       rcar_i2c_write(priv, ICCCR, priv->icccr);
-
-       spin_unlock_irqrestore(&priv->lock, flags);
-       /*-------------- spin unlock -----------------*/
-
        ret = rcar_i2c_bus_barrier(priv);
        if (ret < 0)
                goto out;
@@ -666,6 +657,7 @@ static int rcar_i2c_probe(struct platform_device *pdev)
        if (ret < 0)
                goto out_pm_put;
 
+       rcar_i2c_init(priv);
        pm_runtime_put(dev);
 
        irq = platform_get_irq(pdev, 0);