Message ID | 1340338339-11626-18-git-send-email-troy.kisky@boundarydevices.com |
---|---|
State | Superseded |
Delegated to: | Heiko Schocher |
Headers | show |
Dear Troy Kisky, > Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com> > --- > drivers/i2c/mxc_i2c.c | 17 +++++++++++++++++ > 1 file changed, 17 insertions(+) > > diff --git a/drivers/i2c/mxc_i2c.c b/drivers/i2c/mxc_i2c.c > index 339bb6f..5d18752 100644 > --- a/drivers/i2c/mxc_i2c.c > +++ b/drivers/i2c/mxc_i2c.c > @@ -407,6 +407,23 @@ static void toggle_i2c(void *base) > p->toggle_fn(p->toggle_data); > } > > +#ifdef CONFIG_I2C_MULTI_BUS > +unsigned int i2c_get_bus_num(void) > +{ > + return g_bus; Is this global variable? If so, it won't work before relocation. And i2c can be enabled before relocation. > +} > + > +int i2c_set_bus_num(unsigned bus_idx) > +{ > + if (bus_idx >= ARRAY_SIZE(g_parms)) > + return -1; > + if (!g_parms[bus_idx].base) > + return -1; > + g_bus = bus_idx; > + return 0; > +} > +#endif > + > int i2c_read(uchar chip, uint addr, int alen, uchar *buf, int len) > { > return bus_i2c_read(get_base(), chip, addr, alen, buf, len); Best regards, Marek Vasut
On 6/22/2012 10:09 AM, Marek Vasut wrote: > Dear Troy Kisky, > >> Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com> >> --- >> drivers/i2c/mxc_i2c.c | 17 +++++++++++++++++ >> 1 file changed, 17 insertions(+) >> >> diff --git a/drivers/i2c/mxc_i2c.c b/drivers/i2c/mxc_i2c.c >> index 339bb6f..5d18752 100644 >> --- a/drivers/i2c/mxc_i2c.c >> +++ b/drivers/i2c/mxc_i2c.c >> @@ -407,6 +407,23 @@ static void toggle_i2c(void *base) >> p->toggle_fn(p->toggle_data); >> } >> >> +#ifdef CONFIG_I2C_MULTI_BUS >> +unsigned int i2c_get_bus_num(void) >> +{ >> + return g_bus; > Is this global variable? If so, it won't work before relocation. And i2c can be > enabled before relocation. Correct and correct. If you need i2c working before relocation, you cannot enable MULTI_BUS. Should I put this in struct global_data to remove this restriction? > >> +} >> + >> +int i2c_set_bus_num(unsigned bus_idx) >> +{ >> + if (bus_idx >= ARRAY_SIZE(g_parms)) >> + return -1; >> + if (!g_parms[bus_idx].base) >> + return -1; >> + g_bus = bus_idx; >> + return 0; >> +} >> +#endif >> + >> int i2c_read(uchar chip, uint addr, int alen, uchar *buf, int len) >> { >> return bus_i2c_read(get_base(), chip, addr, alen, buf, len); > Best regards, > Marek Vasut >
On Fri, Jun 22, 2012 at 2:41 PM, Troy Kisky <troy.kisky@boundarydevices.com> wrote: > > Correct and correct. If you need i2c working before relocation, you cannot > enable MULTI_BUS. That sounds like a really strong limitation of MULTI_BUS. i2c is necessary for SPD, which is needed to initialize DDR.
diff --git a/drivers/i2c/mxc_i2c.c b/drivers/i2c/mxc_i2c.c index 339bb6f..5d18752 100644 --- a/drivers/i2c/mxc_i2c.c +++ b/drivers/i2c/mxc_i2c.c @@ -407,6 +407,23 @@ static void toggle_i2c(void *base) p->toggle_fn(p->toggle_data); } +#ifdef CONFIG_I2C_MULTI_BUS +unsigned int i2c_get_bus_num(void) +{ + return g_bus; +} + +int i2c_set_bus_num(unsigned bus_idx) +{ + if (bus_idx >= ARRAY_SIZE(g_parms)) + return -1; + if (!g_parms[bus_idx].base) + return -1; + g_bus = bus_idx; + return 0; +} +#endif + int i2c_read(uchar chip, uint addr, int alen, uchar *buf, int len) { return bus_i2c_read(get_base(), chip, addr, alen, buf, len);
Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com> --- drivers/i2c/mxc_i2c.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)