[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20211004153640.20650-3-vincent.whitchurch@axis.com>
Date: Mon, 4 Oct 2021 17:36:40 +0200
From: Vincent Whitchurch <vincent.whitchurch@...s.com>
To: <peda@...ntia.se>, <devicetree@...r.kernel.org>
CC: <kernel@...s.com>, <robh+dt@...nel.org>,
<linux-kernel@...r.kernel.org>,
Vincent Whitchurch <vincent.whitchurch@...s.com>
Subject: [PATCH 2/2] mux: gpio: Support settle-time-us property
If the devicetree specifies that the hardware requires a settle time,
add an appropriate delay after the mux GPIOs are set.
Signed-off-by: Vincent Whitchurch <vincent.whitchurch@...s.com>
---
drivers/mux/gpio.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/mux/gpio.c b/drivers/mux/gpio.c
index cc5f2c1861d4..17d7e03e39f0 100644
--- a/drivers/mux/gpio.c
+++ b/drivers/mux/gpio.c
@@ -8,6 +8,7 @@
*/
#include <linux/bitmap.h>
+#include <linux/delay.h>
#include <linux/err.h>
#include <linux/gpio/consumer.h>
#include <linux/mod_devicetable.h>
@@ -18,12 +19,14 @@
struct mux_gpio {
struct gpio_descs *gpios;
+ u32 delay;
};
static int mux_gpio_set(struct mux_control *mux, int state)
{
struct mux_gpio *mux_gpio = mux_chip_priv(mux->chip);
DECLARE_BITMAP(values, BITS_PER_TYPE(state));
+ u32 delay = mux_gpio->delay;
u32 value = state;
bitmap_from_arr32(values, &value, BITS_PER_TYPE(value));
@@ -32,6 +35,9 @@ static int mux_gpio_set(struct mux_control *mux, int state)
mux_gpio->gpios->desc,
mux_gpio->gpios->info, values);
+ if (delay)
+ fsleep(delay);
+
return 0;
}
@@ -72,6 +78,9 @@ static int mux_gpio_probe(struct platform_device *pdev)
WARN_ON(pins != mux_gpio->gpios->ndescs);
mux_chip->mux->states = BIT(pins);
+ mux_gpio->delay = 0;
+ device_property_read_u32(dev, "settle-time-us", &mux_gpio->delay);
+
ret = device_property_read_u32(dev, "idle-state", (u32 *)&idle_state);
if (ret >= 0 && idle_state != MUX_IDLE_AS_IS) {
if (idle_state < 0 || idle_state >= mux_chip->mux->states) {
--
2.28.0
Powered by blists - more mailing lists