]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
Merge branch 'master' of git://git.denx.de/u-boot-i2c
authorWolfgang Denk <wd@denx.de>
Fri, 19 Nov 2010 21:02:40 +0000 (22:02 +0100)
committerWolfgang Denk <wd@denx.de>
Fri, 19 Nov 2010 21:02:40 +0000 (22:02 +0100)
arch/powerpc/cpu/mpc5xxx/i2c.c
post/drivers/i2c.c

index 4f7f71632873318d9989a6babe47e8d6e5af05b4..9fb330f82fcc39397c2c8e35da1d1488d8379b13 100644 (file)
@@ -30,6 +30,7 @@ DECLARE_GLOBAL_DATA_PTR;
 #include <mpc5xxx.h>
 #include <i2c.h>
 
+#if !defined(CONFIG_I2C_MULTI_BUS)
 #if (CONFIG_SYS_I2C_MODULE == 2)
 #define I2C_BASE       MPC5XXX_I2C2
 #elif (CONFIG_SYS_I2C_MODULE == 1)
@@ -37,6 +38,19 @@ DECLARE_GLOBAL_DATA_PTR;
 #else
 #error CONFIG_SYS_I2C_MODULE is not properly configured
 #endif
+#else
+static unsigned int i2c_bus_num __attribute__ ((section (".data"))) =
+                                               CONFIG_SYS_SPD_BUS_NUM;
+static unsigned int i2c_bus_speed[2] = {CONFIG_SYS_I2C_SPEED,
+                                       CONFIG_SYS_I2C_SPEED};
+
+static const  unsigned long i2c_dev[2] = {
+       MPC5XXX_I2C1,
+       MPC5XXX_I2C2,
+};
+
+#define I2C_BASE       ((struct mpc5xxx_i2c *)i2c_dev[i2c_bus_num])
+#endif
 
 #define I2C_TIMEOUT    6667
 #define I2C_RETRIES    3
@@ -439,4 +453,33 @@ Done:
        return ret;
 }
 
+#if defined(CONFIG_I2C_MULTI_BUS)
+int i2c_set_bus_num(unsigned int bus)
+{
+       if (bus > 1)
+               return -1;
+
+       i2c_bus_num = bus;
+       i2c_init(i2c_bus_speed[bus], CONFIG_SYS_I2C_SLAVE);
+       return 0;
+}
+
+int i2c_set_bus_speed(unsigned int speed)
+{
+       i2c_init(speed, CONFIG_SYS_I2C_SLAVE);
+       return 0;
+}
+
+unsigned int i2c_get_bus_num(void)
+{
+       return i2c_bus_num;
+}
+
+unsigned int i2c_get_bus_speed(void)
+{
+       return i2c_bus_speed[i2c_bus_num];
+}
+#endif
+
+
 #endif /* CONFIG_HARD_I2C */
index 4a1b1a49d17bd481e401070ad44b78d69779638b..4cbd9f3703f8f2b9f47cf9ad0626a2dbdbf281dc 100644 (file)
@@ -63,11 +63,12 @@ int i2c_post_test (int flags)
        unsigned int i;
 #ifndef CONFIG_SYS_POST_I2C_ADDRS
        /* Start at address 1, address 0 is the general call address */
-       for (i = 1; i < 128; i++)
+       for (i = 1; i < 128; i++) {
                if (i2c_ignore_device(i))
                        continue;
                if (i2c_probe (i) == 0)
                        return 0;
+       }
 
        /* No devices found */
        return -1;