i2c: designware_i2c: Integrate set_speed() into dw_i2c_set_bus_speed()
authorStefan Roese <sr@denx.de>
Thu, 21 Apr 2016 06:19:39 +0000 (08:19 +0200)
committerHeiko Schocher <hs@denx.de>
Mon, 25 Apr 2016 05:31:28 +0000 (07:31 +0200)
Integrating set_speed() into dw_i2c_set_bus_speed() will make the
conversion to DM easier for this driver.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Cc: Marek Vasut <marex@denx.de>
Cc: Heiko Schocher <hs@denx.de>
drivers/i2c/designware_i2c.c

index d5b3e29e88ae139e149388c35fd00c3541ed8ad6..035bf23dfcc730916f90090bbf606f49d3e169ce 100644 (file)
@@ -56,16 +56,25 @@ static void dw_i2c_enable(struct i2c_regs *i2c_base, bool enable)
 }
 
 /*
- * set_speed - Set the i2c speed mode (standard, high, fast)
- * @i2c_spd:   required i2c speed mode
+ * i2c_set_bus_speed - Set the i2c speed
+ * @speed:     required i2c speed
  *
- * Set the i2c speed mode (standard, high, fast)
+ * Set the i2c speed.
  */
-static void set_speed(struct i2c_adapter *adap, int i2c_spd)
+static unsigned int dw_i2c_set_bus_speed(struct i2c_adapter *adap,
+                                        unsigned int speed)
 {
        struct i2c_regs *i2c_base = i2c_get_base(adap);
        unsigned int cntl;
        unsigned int hcnt, lcnt;
+       int i2c_spd;
+
+       if (speed >= I2C_MAX_SPEED)
+               i2c_spd = IC_SPEED_MODE_MAX;
+       else if (speed >= I2C_FAST_SPEED)
+               i2c_spd = IC_SPEED_MODE_FAST;
+       else
+               i2c_spd = IC_SPEED_MODE_STANDARD;
 
        /* to set speed cltr must be disabled */
        dw_i2c_enable(i2c_base, false);
@@ -103,27 +112,7 @@ static void set_speed(struct i2c_adapter *adap, int i2c_spd)
 
        /* Enable back i2c now speed set */
        dw_i2c_enable(i2c_base, true);
-}
-
-/*
- * i2c_set_bus_speed - Set the i2c speed
- * @speed:     required i2c speed
- *
- * Set the i2c speed.
- */
-static unsigned int dw_i2c_set_bus_speed(struct i2c_adapter *adap,
-                                        unsigned int speed)
-{
-       int i2c_spd;
-
-       if (speed >= I2C_MAX_SPEED)
-               i2c_spd = IC_SPEED_MODE_MAX;
-       else if (speed >= I2C_FAST_SPEED)
-               i2c_spd = IC_SPEED_MODE_FAST;
-       else
-               i2c_spd = IC_SPEED_MODE_STANDARD;
 
-       set_speed(adap, i2c_spd);
        adap->speed = speed;
 
        return 0;