[U-Boot] [PATCH] i2c: fix SDA contention in read_byte()

Thomas Chou thomas at wytron.com.tw
Mon Jul 12 07:51:48 CEST 2010


Reinhard Meyer wrote:
> Its even simpler, provided the  hardware can do open collector. Here was 
> my solution for AVR32AP7000:
> 

Then we could add a config for open drain similar to that of linux driver.

# ifndef I2C_SDA
#  ifdef CONFIG_SOFT_I2C_GPIO_SDA_IS_OPEN_DRAIN
#   define I2C_SDA(bit) gpio_set_value(CONFIG_SOFT_I2C_GPIO_SDA, bit)
#  else
#   define I2C_SDA(bit) \
     if (bit) {                        \
         gpio_direction_input(CONFIG_SOFT_I2C_GPIO_SDA);    \
     } else {                        \
         gpio_direction_output(CONFIG_SOFT_I2C_GPIO_SDA, 0);\
     }
#  endif
# endif

BTW, will you be interested in using common gpio framework for avr32 family?

Cheers,
Thomas


More information about the U-Boot mailing list