summaryrefslogtreecommitdiff
path: root/drivers/i2c
diff options
context:
space:
mode:
authorYork Sun <yorksun@freescale.com>2014-02-10 14:02:52 -0800
committerHeiko Schocher <hs@denx.de>2014-04-29 07:10:27 +0200
commitdec1861be90c948ea9fb771927d3d26a994d2e20 (patch)
tree11faa5e4eaa0a614155e79653e688df3fd57796c /drivers/i2c
parent8854070784450f7ade382c5792b2721fbe27315a (diff)
downloadu-boot-imx-dec1861be90c948ea9fb771927d3d26a994d2e20.zip
u-boot-imx-dec1861be90c948ea9fb771927d3d26a994d2e20.tar.gz
u-boot-imx-dec1861be90c948ea9fb771927d3d26a994d2e20.tar.bz2
driver/mxc_i2c: Move static data structure to global_data
This driver needs a data structure in SRAM before SDRAM is available. This is not alway the case using .data section. Moving this data structure to global_data guarantees it is writable. Signed-off-by: York Sun <yorksun@freescale.com> CC: Troy Kisky <troy.kisky@boundarydevices.com>
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/mxc_i2c.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/drivers/i2c/mxc_i2c.c b/drivers/i2c/mxc_i2c.c
index 595019b..48468d7 100644
--- a/drivers/i2c/mxc_i2c.c
+++ b/drivers/i2c/mxc_i2c.c
@@ -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,
@@ -445,9 +441,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 +487,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 +503,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);