]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - drivers/i2c/mxc_i2c.c
Merge branch 'agust@denx.de' of git://git.denx.de/u-boot-staging
[karo-tx-uboot.git] / drivers / i2c / mxc_i2c.c
index 595019b3b8874601437e5c38d6b9b9793d1d0a92..c14797ce0ed9d5961481d763e195ef0fe4e7cdd7 100644 (file)
@@ -22,6 +22,8 @@
 #include <i2c.h>
 #include <watchdog.h>
 
+DECLARE_GLOBAL_DATA_PTR;
+
 #ifdef I2C_QUIRK_REG
 struct mxc_i2c_regs {
        uint8_t         iadr;
@@ -411,12 +413,6 @@ struct sram_data {
        struct i2c_parms i2c_data[3];
 };
 
-/*
- * For SPL boot some boards need i2c before SDRAM is initialized so force
- * variables to live in SRAM
- */
-static struct sram_data __attribute__((section(".data"))) srdata;
-
 static void * const i2c_bases[] = {
 #if defined(CONFIG_MX25)
        (void *)IMX_I2C_BASE,
@@ -433,6 +429,11 @@ static void * const i2c_bases[] = {
        (void *)I2C3_BASE_ADDR
 #elif defined(CONFIG_VF610)
        (void *)I2C0_BASE_ADDR
+#elif defined(CONFIG_FSL_LSCH3)
+       (void *)I2C1_BASE_ADDR,
+       (void *)I2C2_BASE_ADDR,
+       (void *)I2C3_BASE_ADDR,
+       (void *)I2C4_BASE_ADDR
 #else
 #error "architecture not supported"
 #endif
@@ -445,9 +446,10 @@ void *i2c_get_base(struct i2c_adapter *adap)
 
 static struct i2c_parms *i2c_get_parms(void *base)
 {
+       struct sram_data *srdata = (void *)gd->srdata;
        int i = 0;
-       struct i2c_parms *p = srdata.i2c_data;
-       while (i < ARRAY_SIZE(srdata.i2c_data)) {
+       struct i2c_parms *p = srdata->i2c_data;
+       while (i < ARRAY_SIZE(srdata->i2c_data)) {
                if (p->base == base)
                        return p;
                p++;
@@ -490,8 +492,9 @@ static int mxc_i2c_probe(struct i2c_adapter *adap, uint8_t chip)
 void bus_i2c_init(void *base, int speed, int unused,
                int (*idle_bus_fn)(void *p), void *idle_bus_data)
 {
+       struct sram_data *srdata = (void *)gd->srdata;
        int i = 0;
-       struct i2c_parms *p = srdata.i2c_data;
+       struct i2c_parms *p = srdata->i2c_data;
        if (!base)
                return;
        for (;;) {
@@ -505,7 +508,7 @@ void bus_i2c_init(void *base, int speed, int unused,
                }
                p++;
                i++;
-               if (i >= ARRAY_SIZE(srdata.i2c_data))
+               if (i >= ARRAY_SIZE(srdata->i2c_data))
                        return;
        }
        bus_i2c_set_bus_speed(base, speed);