All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vincent Whitchurch <vincent.whitchurch@axis.com>
To: <peda@axentia.se>, <devicetree@vger.kernel.org>
Cc: <kernel@axis.com>, <robh+dt@kernel.org>,
	<linux-kernel@vger.kernel.org>,
	Vincent Whitchurch <vincent.whitchurch@axis.com>
Subject: [PATCH 2/2] mux: gpio: Support settle-time-us property
Date: Mon, 4 Oct 2021 17:36:40 +0200	[thread overview]
Message-ID: <20211004153640.20650-3-vincent.whitchurch@axis.com> (raw)
In-Reply-To: <20211004153640.20650-1-vincent.whitchurch@axis.com>

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@axis.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


  parent reply	other threads:[~2021-10-04 15:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-04 15:36 [PATCH 0/2] Add settle time support to mux-gpio Vincent Whitchurch
2021-10-04 15:36 ` [PATCH 1/2] dt-bindings: mux: gpio-mux: Add property for settle time Vincent Whitchurch
2021-10-04 15:36 ` Vincent Whitchurch [this message]
2021-10-06 12:24 ` [PATCH 0/2] Add settle time support to mux-gpio Peter Rosin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211004153640.20650-3-vincent.whitchurch@axis.com \
    --to=vincent.whitchurch@axis.com \
    --cc=devicetree@vger.kernel.org \
    --cc=kernel@axis.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peda@axentia.se \
    --cc=robh+dt@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.