]> git.sur5r.net Git - u-boot/commitdiff
i2c: add CONFIG_I2C_MULTI_BUS for soft_i2c and mpc8260 i2c driver.
authorHeiko Schocher <hs@denx.de>
Wed, 15 Oct 2008 07:34:45 +0000 (09:34 +0200)
committerWolfgang Denk <wd@denx.de>
Sat, 18 Oct 2008 19:54:01 +0000 (21:54 +0200)
Signed-off-by: Heiko Schocher <hs@denx.de>
cpu/mpc8260/i2c.c
drivers/i2c/soft_i2c.c

index c3af7b6d839ee6f9f21f137beff5c9775d222e95..335177fad61016add36745c80e3a9d2fe8c6fcb1 100644 (file)
 
 DECLARE_GLOBAL_DATA_PTR;
 
+#if defined(CONFIG_I2C_MULTI_BUS)
+static unsigned int i2c_bus_num __attribute__ ((section ("data"))) = 0;
+#endif /* CONFIG_I2C_MULTI_BUS */
+
 /* uSec to wait between polls of the i2c */
 #define DELAY_US       100
 /* uSec to wait for the CPM to start processing the buffer */
@@ -765,4 +769,36 @@ i2c_reg_write(uchar chip, uchar reg, uchar val)
        i2c_write(chip, reg, 1, &val, 1);
 }
 
+#if defined(CONFIG_I2C_MULTI_BUS)
+/*
+ * Functions for multiple I2C bus handling
+ */
+unsigned int i2c_get_bus_num(void)
+{
+       return i2c_bus_num;
+}
+
+int i2c_set_bus_num(unsigned int bus)
+{
+       if (bus >= CFG_MAX_I2C_BUS)
+               return -1;
+       i2c_bus_num = bus;
+
+       return 0;
+}
+/* TODO: add 100/400k switching */
+unsigned int i2c_get_bus_speed(void)
+{
+       return CFG_I2C_SPEED;
+}
+
+int i2c_set_bus_speed(unsigned int speed)
+{
+       if (speed != CFG_I2C_SPEED)
+               return -1;
+
+       return 0;
+}
+
+#endif /* CONFIG_I2C_MULTI_BUS */
 #endif /* CONFIG_HARD_I2C */
index 23db2ee8ff4375be62c0800ca87edfa39bee601c..57736da42486d2c8384b8d4c8f24dd3c4a1dad44 100644 (file)
@@ -68,6 +68,10 @@ DECLARE_GLOBAL_DATA_PTR;
 #define PRINTD(fmt,args...)
 #endif
 
+#if defined(CONFIG_I2C_MULTI_BUS)
+static unsigned int i2c_bus_num __attribute__ ((section ("data"))) = 0;
+#endif /* CONFIG_I2C_MULTI_BUS */
+
 /*-----------------------------------------------------------------------
  * Local functions
  */
@@ -230,6 +234,38 @@ static int write_byte(uchar data)
        return(nack);   /* not a nack is an ack */
 }
 
+#if defined(CONFIG_I2C_MULTI_BUS)
+/*
+ * Functions for multiple I2C bus handling
+ */
+unsigned int i2c_get_bus_num(void)
+{
+       return i2c_bus_num;
+}
+
+int i2c_set_bus_num(unsigned int bus)
+{
+       if (bus >= CFG_MAX_I2C_BUS)
+               return -1;
+       i2c_bus_num = bus;
+
+       return 0;
+}
+
+/* TODO: add 100/400k switching */
+unsigned int i2c_get_bus_speed(void)
+{
+       return CFG_I2C_SPEED;
+}
+
+int i2c_set_bus_speed(unsigned int speed)
+{
+       if (speed != CFG_I2C_SPEED)
+               return -1;
+
+       return 0;
+}
+#endif
 
 /*-----------------------------------------------------------------------
  * if ack == I2C_ACK, ACK the byte so can continue reading, else