Skip to content

Commit 45b8ee7

Browse files
bastien-curutchetAndi Shyti
authored andcommitted
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 <[email protected]> Reviewed-by: Andi Shyti <[email protected]> Acked-by: Peter Rosin <[email protected]> Signed-off-by: Andi Shyti <[email protected]>
1 parent a618d86 commit 45b8ee7

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

drivers/i2c/muxes/i2c-mux-gpio.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77

88
#include <linux/bits.h>
9+
#include <linux/delay.h>
910
#include <linux/gpio/consumer.h>
1011
#include <linux/gpio/driver.h>
1112
#include <linux/i2c.h>
@@ -37,6 +38,9 @@ static int i2c_mux_gpio_select(struct i2c_mux_core *muxc, u32 chan)
3738

3839
i2c_mux_gpio_set(mux, chan);
3940

41+
if (mux->data.settle_time)
42+
fsleep(mux->data.settle_time);
43+
4044
return 0;
4145
}
4246

@@ -116,6 +120,8 @@ static int i2c_mux_gpio_probe_fw(struct gpiomux *mux,
116120
if (device_property_read_u32(dev, "idle-state", &mux->data.idle))
117121
mux->data.idle = I2C_MUX_GPIO_NO_IDLE;
118122

123+
device_property_read_u32(dev, "settle-time-us", &mux->data.settle_time);
124+
119125
return 0;
120126
}
121127

include/linux/platform_data/i2c-mux-gpio.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@
1919
* position
2020
* @n_values: Number of multiplexer positions (busses to instantiate)
2121
* @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
2223
*/
2324
struct i2c_mux_gpio_platform_data {
2425
int parent;
2526
int base_nr;
2627
const unsigned *values;
2728
int n_values;
2829
unsigned idle;
30+
u32 settle_time;
2931
};
3032

3133
#endif /* _LINUX_I2C_MUX_GPIO_H */

0 commit comments

Comments
 (0)