[U-Boot] [PATCH 4/9 v3] 83xx, i2c: add mux support for fsl_i2c
Kim Phillips
kim.phillips at freescale.com
Mon Feb 23 23:35:48 CET 2009
On Thu, 19 Feb 2009 17:24:09 +0100
Heiko Schocher <hs at denx.de> 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:
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?
Kim
More information about the U-Boot
mailing list