
On Monday, July 12, 2010 00:14:39 Thomas Chou wrote:
Reinhard Meyer wrote:
Whenever possible by the hardware, I make I2C_SDA/SCL(1) do a tri-state and I2C_TRISTATE and I2C_ACTIVE are empty.
Dear Mike,
I traced the i2c-gpio.c of linux and realized that there are potential bus contention with the current soft_i2c.c if the ports are not open-drained.
Reinhard suggested a solution, which was similar to what linux driver does. So I would withdraw my SDA patch.
For our i2c gpio framework, I added these changes and tested on my boards. Please check if it works on yours.
# ifndef I2C_ACTIVE # define I2C_ACTIVE do {} while (0) # endif
# ifndef I2C_TRISTATE # define I2C_TRISTATE do {} while (0) # endif
# ifndef I2C_SDA # 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
I didn't tristate SCL(1) because it cannot be tristated on some nios2 boards. As soft_i2c of u-boot didn't support clock stretching, it shouldn't matter.
this sort of fixed things for me. the problem i was having is that repeated start is not the default behavior for the soft i2c bus master. i thought that this would be the default, but there doesnt seem to be any documentation on the expected standard behavior out of the box.
once i enabled that for all Blackfin boards, soft i2c worked for me. so i posted an updated patch ... if you need some open drain behavior, i think it best to post a patch on top of that. -mike