-
Notifications
You must be signed in to change notification settings - Fork 7.6k
drivers: i2c: Add support for clock stretching in the i2c-gpio module. #90076
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
drivers: i2c: Add support for clock stretching in the i2c-gpio module. #90076
Conversation
21f73b6
to
182d0f0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems reasonable to me, would suggest using microsecond timeouts not millisecond, and using the WAIT_FOR macro, but otherwise looks nice
182d0f0
to
5426ec9
Compare
5426ec9
to
77a922f
Compare
drivers/i2c/i2c_bitbang.c
Outdated
@@ -60,6 +64,8 @@ int i2c_bitbang_configure(struct i2c_bitbang *context, uint32_t dev_config) | |||
return -ENOTSUP; | |||
} | |||
|
|||
context->delays[T_CLK_STR] = | |||
MS_TO_SYS_CLOCK_HW_CYCLES(CONFIG_I2C_GPIO_CLOCK_STRETCHING_TIMEOUT_MS); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this also be guarded by CONFIG_I2C_GPIO_CLOCK_STRETCHING? Do you have a different perspective on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is now obsolete since it was transformed to WAIT_US() macro.
drivers/i2c/i2c_bitbang.h
Outdated
@@ -28,7 +32,7 @@ struct i2c_bitbang_io { | |||
struct i2c_bitbang { | |||
const struct i2c_bitbang_io *io; | |||
void *io_context; | |||
uint32_t delays[2]; | |||
uint32_t delays[3]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you define ARRAY_SIZE as a macro that sets the size to 3 when clock stretching is enabled, and to 2 otherwise
For example :
#define I2C_GPIO_SIZE 2
#define I2C_GPIO_CLK_STR_SIZE 3
##ifdef CONFIG_I2C_GPIO_CLOCK_STRETCHING
#define ARRAY_SIZE I2C_GPIO_CLK_STR_SIZE
else
#define ARRAY_SIZE I2C_GPIO_SIZE
#endif
Some I2C peripherals like TI charger or gauge chips need support for I2C clock stretching. This patch includes that and makes these modules usable with I2C emulation over GPIO. Signed-off-by: Bas van Loon <[email protected]>
77a922f
to
5630707
Compare
|
Some I2C peripherals like TI charger or gauge chips need support for I2C clock stretching. This patch includes that and makes these modules usable with I2C emulation over GPIO.