From mboxrd@z Thu Jan 1 00:00:00 1970 From: Heiko Schocher Date: Tue, 24 Feb 2009 08:00:55 +0100 Subject: [U-Boot] [PATCH 4/9 v3] 83xx, i2c: add mux support for fsl_i2c In-Reply-To: <20090223163548.7bcc21b6.kim.phillips@freescale.com> References: <499D87A9.3060004@denx.de> <20090223163548.7bcc21b6.kim.phillips@freescale.com> Message-ID: <49A39B27.8010208@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hello Kim, Kim Phillips wrote: > On Thu, 19 Feb 2009 17:24:09 +0100 > Heiko Schocher wrote: > >> @@ -369,6 +370,23 @@ i2c_probe(uchar chip) >> >> int i2c_set_bus_num(unsigned int bus) >> { >> +#if defined(CONFIG_I2C_MUX) >> + if (bus < CONFIG_SYS_MAX_I2C_BUS) { >> + i2c_bus_num = bus; >> + } else { > > [1] > >> + int ret; >> + >> + ret = i2x_mux_select_mux(bus); >> + if (ret == 0) { >> + /* with CONFIG_I2C_MUX only I2C Controller 1 >> + * is usable >> + */ >> + i2c_bus_num = 0; >> + i2c_bus_num_mux = bus; >> + } else >> + return ret; >> + } > > how about > > ret = i2x_... > if (ret) > return ret; > /* with... > >> +#else >> #ifdef CONFIG_SYS_I2C2_OFFSET >> if (bus > 1) { >> #else >> @@ -378,7 +396,7 @@ int i2c_set_bus_num(unsigned int bus) >> } >> >> i2c_bus_num = bus; >> - >> +#endif > > reuse code and moved the ifdef up, then [1] would just be: Ok. > if (bus >= CONFIG_SYS_MAX_I2C_BUS) { > >> return 0; >> } >> >> @@ -396,7 +414,11 @@ int i2c_set_bus_speed(unsigned int speed) >> >> unsigned int i2c_get_bus_num(void) >> { >> +#if defined(CONFIG_I2C_MUX) >> + return i2c_bus_num_mux; >> +#else >> return i2c_bus_num; >> +#endif >> } > > I don't get this mux variant - why aren't we reusing i2c_bus_num in the > mux case? Good question, have to think about it. bye Heiko -- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany