Message ID | 1339049394-4816-8-git-send-email-rajeshwari.s@samsung.com |
---|---|
State | New |
Headers | show |
Hi, 2012/6/7 Rajeshwari Shinde <rajeshwari.s@samsung.com>: > This adds multiple i2c channel support for I2C. > > Signed-off-by: Alim Akhtar <alim.akhtar@samsung.com> > Signed-off-by: Rajeshwari Shinde <rajeshwari.s@samsung.com> > Acked-by: Simon Glass <sjg@chromium.org> > --- > drivers/i2c/s3c24x0_i2c.c | 27 +++++++++++++++++++++++++++ > 1 files changed, 27 insertions(+), 0 deletions(-) > > diff --git a/drivers/i2c/s3c24x0_i2c.c b/drivers/i2c/s3c24x0_i2c.c > index a71f147..7521cb8 100644 > --- a/drivers/i2c/s3c24x0_i2c.c > +++ b/drivers/i2c/s3c24x0_i2c.c > @@ -191,6 +191,33 @@ static void i2c_bus_init(struct s3c24x0_i2c *i2c, unsigned int bus) > i2c_ch_init(i2c, CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE); > } > > +/* > + * MULTI BUS I2C support > + */ > + > +#ifdef CONFIG_I2C_MULTI_BUS > +int i2c_set_bus_num(unsigned int bus) > +{ > + struct s3c24x0_i2c *i2c; > + > + if ((bus < 0) || (bus >= CONFIG_MAX_I2C_NUM)) { > + debug("Bad bus: %d\n", bus); > + return -1; > + } > + > + g_current_bus = bus; > + i2c = get_base_i2c(g_current_bus); > + i2c_bus_init(i2c, g_current_bus); This causes duplicated pin configuration whenever calls i2c_set_bus_num(). > + > + return 0; > +} > + > +unsigned int i2c_get_bus_num(void) > +{ > + return g_current_bus; > +} > +#endif Does only EXYNOS5 support CONFIG_I2C_MULTI_BUS? > + > #ifdef CONFIG_EXYNOS5 > void i2c_init(int speed, int slaveadd) > { > -- > 1.7.4.4 > > _______________________________________________ > U-Boot mailing list > U-Boot@lists.denx.de > http://lists.denx.de/mailman/listinfo/u-boot Thanks.
Hi Joonyoung Shim, Thank you for comments. On Fri, Jun 15, 2012 at 12:45 PM, Joonyoung Shim <dofmind@gmail.com> wrote: > Hi, > > 2012/6/7 Rajeshwari Shinde <rajeshwari.s@samsung.com>: >> This adds multiple i2c channel support for I2C. >> >> Signed-off-by: Alim Akhtar <alim.akhtar@samsung.com> >> Signed-off-by: Rajeshwari Shinde <rajeshwari.s@samsung.com> >> Acked-by: Simon Glass <sjg@chromium.org> >> --- >> drivers/i2c/s3c24x0_i2c.c | 27 +++++++++++++++++++++++++++ >> 1 files changed, 27 insertions(+), 0 deletions(-) >> >> diff --git a/drivers/i2c/s3c24x0_i2c.c b/drivers/i2c/s3c24x0_i2c.c >> index a71f147..7521cb8 100644 >> --- a/drivers/i2c/s3c24x0_i2c.c >> +++ b/drivers/i2c/s3c24x0_i2c.c >> @@ -191,6 +191,33 @@ static void i2c_bus_init(struct s3c24x0_i2c *i2c, unsigned int bus) >> i2c_ch_init(i2c, CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE); >> } >> >> +/* >> + * MULTI BUS I2C support >> + */ >> + >> +#ifdef CONFIG_I2C_MULTI_BUS >> +int i2c_set_bus_num(unsigned int bus) >> +{ >> + struct s3c24x0_i2c *i2c; >> + >> + if ((bus < 0) || (bus >= CONFIG_MAX_I2C_NUM)) { >> + debug("Bad bus: %d\n", bus); >> + return -1; >> + } >> + >> + g_current_bus = bus; >> + i2c = get_base_i2c(g_current_bus); >> + i2c_bus_init(i2c, g_current_bus); > > This causes duplicated pin configuration whenever calls i2c_set_bus_num(). > -- Initally we are initialising only for bus 0, When this function gets called with bus id other than 0 we need to initialise that bus. >> + >> + return 0; >> +} >> + >> +unsigned int i2c_get_bus_num(void) >> +{ >> + return g_current_bus; >> +} >> +#endif > > Does only EXYNOS5 support CONFIG_I2C_MULTI_BUS? -- EXYNOS4 also has Multi Bus I2C > >> + >> #ifdef CONFIG_EXYNOS5 >> void i2c_init(int speed, int slaveadd) >> { >> -- >> 1.7.4.4 >> >> _______________________________________________ >> U-Boot mailing list >> U-Boot@lists.denx.de >> http://lists.denx.de/mailman/listinfo/u-boot > > Thanks. > > -- > - Joonyoung Shim > _______________________________________________ > U-Boot mailing list > U-Boot@lists.denx.de > http://lists.denx.de/mailman/listinfo/u-boot Regards, Rajeshwari Shinde.
2012/6/19 Rajeshwari Birje <rajeshwari.birje@gmail.com>: > Hi Joonyoung Shim, > > Thank you for comments. > > On Fri, Jun 15, 2012 at 12:45 PM, Joonyoung Shim <dofmind@gmail.com> wrote: >> Hi, >> >> 2012/6/7 Rajeshwari Shinde <rajeshwari.s@samsung.com>: >>> This adds multiple i2c channel support for I2C. >>> >>> Signed-off-by: Alim Akhtar <alim.akhtar@samsung.com> >>> Signed-off-by: Rajeshwari Shinde <rajeshwari.s@samsung.com> >>> Acked-by: Simon Glass <sjg@chromium.org> >>> --- >>> drivers/i2c/s3c24x0_i2c.c | 27 +++++++++++++++++++++++++++ >>> 1 files changed, 27 insertions(+), 0 deletions(-) >>> >>> diff --git a/drivers/i2c/s3c24x0_i2c.c b/drivers/i2c/s3c24x0_i2c.c >>> index a71f147..7521cb8 100644 >>> --- a/drivers/i2c/s3c24x0_i2c.c >>> +++ b/drivers/i2c/s3c24x0_i2c.c >>> @@ -191,6 +191,33 @@ static void i2c_bus_init(struct s3c24x0_i2c *i2c, unsigned int bus) >>> i2c_ch_init(i2c, CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE); >>> } >>> >>> +/* >>> + * MULTI BUS I2C support >>> + */ >>> + >>> +#ifdef CONFIG_I2C_MULTI_BUS >>> +int i2c_set_bus_num(unsigned int bus) >>> +{ >>> + struct s3c24x0_i2c *i2c; >>> + >>> + if ((bus < 0) || (bus >= CONFIG_MAX_I2C_NUM)) { >>> + debug("Bad bus: %d\n", bus); >>> + return -1; >>> + } >>> + >>> + g_current_bus = bus; >>> + i2c = get_base_i2c(g_current_bus); >>> + i2c_bus_init(i2c, g_current_bus); >> >> This causes duplicated pin configuration whenever calls i2c_set_bus_num(). >> > -- Initally we are initialising only for bus 0, When this function > gets called with bus id other than 0 we need to initialise that bus. The problem is i2c_set_bus_num() can be called many times. If did i2c_bus_init() already, just set g_current_bus.
diff --git a/drivers/i2c/s3c24x0_i2c.c b/drivers/i2c/s3c24x0_i2c.c index a71f147..7521cb8 100644 --- a/drivers/i2c/s3c24x0_i2c.c +++ b/drivers/i2c/s3c24x0_i2c.c @@ -191,6 +191,33 @@ static void i2c_bus_init(struct s3c24x0_i2c *i2c, unsigned int bus) i2c_ch_init(i2c, CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE); } +/* + * MULTI BUS I2C support + */ + +#ifdef CONFIG_I2C_MULTI_BUS +int i2c_set_bus_num(unsigned int bus) +{ + struct s3c24x0_i2c *i2c; + + if ((bus < 0) || (bus >= CONFIG_MAX_I2C_NUM)) { + debug("Bad bus: %d\n", bus); + return -1; + } + + g_current_bus = bus; + i2c = get_base_i2c(g_current_bus); + i2c_bus_init(i2c, g_current_bus); + + return 0; +} + +unsigned int i2c_get_bus_num(void) +{ + return g_current_bus; +} +#endif + #ifdef CONFIG_EXYNOS5 void i2c_init(int speed, int slaveadd) {