Thread (9 messages) 9 messages, 3 authors, 2021-10-28
STALE1699d

[PATCH 2/2] i2c: i2c-mux-gpio: Add support 'select-delay' property

From: Horatiu Vultur <horatiu.vultur@microchip.com>
Date: 2021-10-13 14:13:16
Also in: linux-i2c, lkml
Subsystem: generic gpio i2c multiplexer driver, i2c muxes, i2c subsystem, the rest · Maintainers: Peter Korsgaard, Peter Rosin, Andi Shyti, Linus Torvalds

Use select-delay property to add a delay once the mux state is changed.
This is required on some platforms to allow the GPIO signals to get
stabilized.

Signed-off-by: Lars Povlsen <redacted>
Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>
---
 drivers/i2c/muxes/i2c-mux-gpio.c | 7 +++++++
 1 file changed, 7 insertions(+)
diff --git a/drivers/i2c/muxes/i2c-mux-gpio.c b/drivers/i2c/muxes/i2c-mux-gpio.c
index bac415a52b78..1cc69eb67221 100644
--- a/drivers/i2c/muxes/i2c-mux-gpio.c
+++ b/drivers/i2c/muxes/i2c-mux-gpio.c
@@ -13,6 +13,8 @@
 #include <linux/slab.h>
 #include <linux/bits.h>
 #include <linux/gpio/consumer.h>
+#include <linux/delay.h>
+
 /* FIXME: stop poking around inside gpiolib */
 #include "../../gpio/gpiolib.h"
 
@@ -20,6 +22,7 @@ struct gpiomux {
 	struct i2c_mux_gpio_platform_data data;
 	int ngpios;
 	struct gpio_desc **gpios;
+	int select_delay;
 };
 
 static void i2c_mux_gpio_set(const struct gpiomux *mux, unsigned val)
@@ -29,6 +32,8 @@ static void i2c_mux_gpio_set(const struct gpiomux *mux, unsigned val)
 	values[0] = val;
 
 	gpiod_set_array_value_cansleep(mux->ngpios, mux->gpios, NULL, values);
+	if (mux->select_delay)
+		udelay(mux->select_delay);
 }
 
 static int i2c_mux_gpio_select(struct i2c_mux_core *muxc, u32 chan)
@@ -153,6 +158,8 @@ static int i2c_mux_gpio_probe_fw(struct gpiomux *mux,
 	if (fwnode_property_read_u32(dev->fwnode, "idle-state", &mux->data.idle))
 		mux->data.idle = I2C_MUX_GPIO_NO_IDLE;
 
+	fwnode_property_read_u32(dev->fwnode, "select-delay", &mux->select_delay);
+
 	return 0;
 }
 
-- 
2.33.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help