Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

i2c: mux: gpio: Add support for the 'settle-time-us' property

Some hardware need some time to switch from a bus to another. This can
cause the first transfers following the selection of a bus to fail.
There is no way to configure this kind of waiting time in the driver.

Add support for the 'settle-time-us' device-tree property. When set,
the i2c_mux_gpio_select() applies a delay before returning, leaving
enough time to the hardware to switch to the new bus.

Signed-off-by: Bastien Curutchet <bastien.curutchet@bootlin.com>
Reviewed-by: Andi Shyti <andi.shyti@kernel.org>
Acked-by: Peter Rosin <peda@axentia.se>
Signed-off-by: Andi Shyti <andi.shyti@kernel.org>

authored by

Bastien Curutchet and committed by
Andi Shyti
45b8ee71 a618d86d

+8
+6
drivers/i2c/muxes/i2c-mux-gpio.c
··· 6 6 */ 7 7 8 8 #include <linux/bits.h> 9 + #include <linux/delay.h> 9 10 #include <linux/gpio/consumer.h> 10 11 #include <linux/gpio/driver.h> 11 12 #include <linux/i2c.h> ··· 37 36 struct gpiomux *mux = i2c_mux_priv(muxc); 38 37 39 38 i2c_mux_gpio_set(mux, chan); 39 + 40 + if (mux->data.settle_time) 41 + fsleep(mux->data.settle_time); 40 42 41 43 return 0; 42 44 } ··· 119 115 120 116 if (device_property_read_u32(dev, "idle-state", &mux->data.idle)) 121 117 mux->data.idle = I2C_MUX_GPIO_NO_IDLE; 118 + 119 + device_property_read_u32(dev, "settle-time-us", &mux->data.settle_time); 122 120 123 121 return 0; 124 122 }
+2
include/linux/platform_data/i2c-mux-gpio.h
··· 19 19 * position 20 20 * @n_values: Number of multiplexer positions (busses to instantiate) 21 21 * @idle: Bitmask to write to MUX when idle or GPIO_I2CMUX_NO_IDLE if not used 22 + * @settle_time: Delay to wait when a new bus is selected 22 23 */ 23 24 struct i2c_mux_gpio_platform_data { 24 25 int parent; ··· 27 26 const unsigned *values; 28 27 int n_values; 29 28 unsigned idle; 29 + u32 settle_time; 30 30 }; 31 31 32 32 #endif /* _LINUX_I2C_MUX_GPIO_H */