Skip to contentSkip to conversation

Add settle time support to iio-mux

PATCH In review Vincent Whitchurch 5 participants 21 messages Oct 7, 2021 – Oct 21, 2021

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v2 cover Add settle time support to iio-mux

On one of our boards we use gpio-mux with iio-mux to read voltages using an ADC from a few different channels, and on this board the input voltage needs some time to stabilize after a switch of the mux.

This series add devicetree and driver support for this kind of hardware which requries a settle time after muxing.

v1 -> v2:
- Move property support to iio-mux and delay handling to mux core as suggested by Peter.

v1: https://lore.kernel.org/all/[email protected]/

Vincent Whitchurch (3):
mux: add support for delay after muxing
dt-bindings: iio: io-channel-mux: Add property for settle time
iio: multiplexer: iio-mux: Support settle-time-us property

 .../iio/multiplexer/io-channel-mux.yaml       |  5 +++
 drivers/iio/multiplexer/iio-mux.c             |  7 +++-
 drivers/mux/core.c                            | 36 ++++++++++++++++---
 include/linux/mux/consumer.h                  | 23 +++++++++---
 include/linux/mux/driver.h                    |  4 +++
 5 files changed, 65 insertions(+), 10 deletions(-)
Signature · 1 line
2.28.0
#1 lore raw

PATCH v2 1/3 mux: add support for delay after muxing

Hardware may require some time for the muxed analog signals to settle after the muxing is changed. Allow users of the mux subsystem to specify this delay with the new mux_control_select_delay() function (and the _try equivalent).

---
 drivers/mux/core.c           | 36 +++++++++++++++++++++++++++++++-----
 include/linux/mux/consumer.h | 23 +++++++++++++++++++----
 include/linux/mux/driver.h   |  4 ++++
 3 files changed, 54 insertions(+), 9 deletions(-)
drivers/mux/core.c +31 -5
index 1fb22388e7e0..dee6945e92f7 100644
@@ -9,6 +9,7 @@
 
 #define pr_fmt(fmt) "mux-core: " fmt
 
+#include <linux/delay.h>
 #include <linux/device.h>
 #include <linux/err.h>
 #include <linux/export.h>
@@ -116,6 +117,7 @@ struct mux_chip *mux_chip_alloc(struct device *dev,
 		sema_init(&mux->lock, 1);
 		mux->cached_state = MUX_CACHE_UNKNOWN;
 		mux->idle_state = MUX_IDLE_AS_IS;
+		mux->last_change = ktime_get();
 	}
 
 	device_initialize(&mux_chip->dev);
@@ -129,6 +131,8 @@ static int mux_control_set(struct mux_control *mux, int state)
 	int ret = mux->chip->ops->set(mux, state);
 
 	mux->cached_state = ret < 0 ? MUX_CACHE_UNKNOWN : state;
+	if (ret >= 0)
+		mux->last_change = ktime_get();
 
 	return ret;
 }
@@ -314,10 +318,25 @@ static int __mux_control_select(struct mux_control *mux, int state)
 	return ret;
 }
 
+static void mux_control_delay(struct mux_control *mux, unsigned int delay_us)
+{
+	ktime_t delayend;
+	s64 remaining;
+
+	if (!delay_us)
+		return;
+
+	delayend = ktime_add_us(mux->last_change, delay_us);
+	remaining = ktime_us_delta(delayend, ktime_get());
+	if (remaining > 0)
+		fsleep(remaining);
+}
+
 /**
- * mux_control_select() - Select the given multiplexer state.
+ * mux_control_select_delay() - Select the given multiplexer state.
  * @mux: The mux-control to request a change of state from.
  * @state: The new requested state.
+ * @delay_us: The time to delay (in microseconds) if the mux state is changed.
  *
  * On successfully selecting the mux-control state, it will be locked until
  * there is a call to mux_control_deselect(). If the mux-control is already
@@ -331,7 +350,8 @@ static int __mux_control_select(struct mux_control *mux, int state)
  * Return: 0 when the mux-control state has the requested state or a negative
  * errno on error.
  */
-int mux_control_select(struct mux_control *mux, unsigned int state)
+int mux_control_select_delay(struct mux_control *mux, unsigned int state,
+			     unsigned int delay_us)
 {
 	int ret;
 
@@ -340,18 +360,21 @@ int mux_control_select(struct mux_control *mux, unsigned int state)
 		return ret;
 
 	ret = __mux_control_select(mux, state);
+	if (ret >= 0)
+		mux_control_delay(mux, delay_us);
 
 	if (ret < 0)
 		up(&mux->lock);
 
 	return ret;
 }
-EXPORT_SYMBOL_GPL(mux_control_select);
+EXPORT_SYMBOL_GPL(mux_control_select_delay);
 
 /**
  * mux_control_try_select() - Try to select the given multiplexer state.
  * @mux: The mux-control to request a change of state from.
  * @state: The new requested state.
+ * @delay_us: The time to delay (in microseconds) if the mux state is changed.
  *
  * On successfully selecting the mux-control state, it will be locked until
  * mux_control_deselect() called.
@@ -363,7 +386,8 @@ EXPORT_SYMBOL_GPL(mux_control_select);
  * Return: 0 when the mux-control state has the requested state or a negative
  * errno on error. Specifically -EBUSY if the mux-control is contended.
  */
-int mux_control_try_select(struct mux_control *mux, unsigned int state)
+int mux_control_try_select_delay(struct mux_control *mux, unsigned int state,
+				 unsigned int delay_us)
 {
 	int ret;
 
@@ -371,13 +395,15 @@ int mux_control_try_select(struct mux_control *mux, unsigned int state)
 		return -EBUSY;
 
 	ret = __mux_control_select(mux, state);
+	if (ret >= 0)
+		mux_control_delay(mux, delay_us);
 
 	if (ret < 0)
 		up(&mux->lock);
 
 	return ret;
 }
-EXPORT_SYMBOL_GPL(mux_control_try_select);
+EXPORT_SYMBOL_GPL(mux_control_try_select_delay);
 
 /**
  * mux_control_deselect() - Deselect the previously selected multiplexer state.
include/linux/mux/consumer.h +19 -4
index 5fc6bb2fefad..7a09b040ac39 100644
@@ -16,10 +16,25 @@ struct device;
 struct mux_control;
 
 unsigned int mux_control_states(struct mux_control *mux);
-int __must_check mux_control_select(struct mux_control *mux,
-				    unsigned int state);
-int __must_check mux_control_try_select(struct mux_control *mux,
-					unsigned int state);
+int __must_check mux_control_select_delay(struct mux_control *mux,
+					  unsigned int state,
+					  unsigned int delay_us);
+int __must_check mux_control_try_select_delay(struct mux_control *mux,
+					      unsigned int state,
+					      unsigned int delay_us);
+
+static inline int __must_check mux_control_select(struct mux_control *mux,
+						  unsigned int state)
+{
+	return mux_control_select_delay(mux, state, 0);
+}
+
+static inline int __must_check mux_control_try_select(struct mux_control *mux,
+						      unsigned int state)
+{
+	return mux_control_try_select_delay(mux, state, 0);
+}
+
 int mux_control_deselect(struct mux_control *mux);
 
 struct mux_control *mux_control_get(struct device *dev, const char *mux_name);
include/linux/mux/driver.h +4 -0
index 627a2c6bc02d..18824064f8c0 100644
@@ -12,6 +12,7 @@
 
 #include <dt-bindings/mux/mux.h>
 #include <linux/device.h>
+#include <linux/ktime.h>
 #include <linux/semaphore.h>
 
 struct mux_chip;
@@ -33,6 +34,7 @@ struct mux_control_ops {
  * @states:		The number of mux controller states.
  * @idle_state:		The mux controller state to use when inactive, or one
  *			of MUX_IDLE_AS_IS and MUX_IDLE_DISCONNECT.
+ * @last_change:	Timestamp of last change
  *
  * Mux drivers may only change @states and @idle_state, and may only do so
  * between allocation and registration of the mux controller. Specifically,
@@ -47,6 +49,8 @@ struct mux_control {
 
 	unsigned int states;
 	int idle_state;
+
+	ktime_t last_change;
 };
 
 /**
Signature · 1 line
2.28.0
#2 lore raw

PATCH v2 2/3 dt-bindings: iio: io-channel-mux: Add property for settle time

In reply to Vincent Whitchurch

Hardware may require some time for the muxed analog signals to settle after the muxing is changed. Allow this time to be specified in the devicetree.

---
 .../devicetree/bindings/iio/multiplexer/io-channel-mux.yaml  | 5 +++++
 1 file changed, 5 insertions(+)
Documentation/devicetree/bindings/iio/multiplexer/io-channel-mux.yaml +5 -0
index 870b043406d8..5a7328042c76 100644
@@ -39,6 +39,11 @@ properties:
     description:
       List of strings, labeling the mux controller states.
 
+  settle-time-us:
+    default: 0
+    description:
+      Time required for analog signals to settle after muxing.
+
 required:
   - compatible
   - io-channels
Signature · 1 line
2.28.0
maintainer
#3 lore raw

Re: [PATCH v2 2/3] dt-bindings: iio: io-channel-mux: Add property for settle time

Quoted 9 lines · Vincent Whitchurch

Hardware may require some time for the muxed analog signals to settle after the muxing is changed. Allow this time to be specified in the devicetree.

---
 .../devicetree/bindings/iio/multiplexer/io-channel-mux.yaml  | 5 +++++
 1 file changed, 5 insertions(+)

Running 'make dtbs_check' with the schema in this patch gives the following warnings. Consider if they are expected or the schema is incorrect. These may not be new warnings.

Note that it is not yet a requirement to have 0 warnings for dtbs_check. This will change in the future.

Full log is available here: https://patchwork.ozlabs.org/patch/1537724

adc0mux: '#io-channel-cells' does not match any of the regexes: 'pinctrl-[0-9]+'
arch/arm/boot/dts/aspeed-bmc-ampere-mtjade.dt.yaml

adc10mux: '#io-channel-cells' does not match any of the regexes: 'pinctrl-[0-9]+'
arch/arm/boot/dts/aspeed-bmc-ampere-mtjade.dt.yaml

adc11mux: '#io-channel-cells' does not match any of the regexes: 'pinctrl-[0-9]+'
arch/arm/boot/dts/aspeed-bmc-ampere-mtjade.dt.yaml

adc12mux: '#io-channel-cells' does not match any of the regexes: 'pinctrl-[0-9]+'
arch/arm/boot/dts/aspeed-bmc-ampere-mtjade.dt.yaml

adc13mux: '#io-channel-cells' does not match any of the regexes: 'pinctrl-[0-9]+'
arch/arm/boot/dts/aspeed-bmc-ampere-mtjade.dt.yaml

adc1mux: '#io-channel-cells' does not match any of the regexes: 'pinctrl-[0-9]+'
arch/arm/boot/dts/aspeed-bmc-ampere-mtjade.dt.yaml

adc2mux: '#io-channel-cells' does not match any of the regexes: 'pinctrl-[0-9]+'
arch/arm/boot/dts/aspeed-bmc-ampere-mtjade.dt.yaml

adc3mux: '#io-channel-cells' does not match any of the regexes: 'pinctrl-[0-9]+'
arch/arm/boot/dts/aspeed-bmc-ampere-mtjade.dt.yaml

adc4mux: '#io-channel-cells' does not match any of the regexes: 'pinctrl-[0-9]+'
arch/arm/boot/dts/aspeed-bmc-ampere-mtjade.dt.yaml

adc5mux: '#io-channel-cells' does not match any of the regexes: 'pinctrl-[0-9]+'
arch/arm/boot/dts/aspeed-bmc-ampere-mtjade.dt.yaml

adc6mux: '#io-channel-cells' does not match any of the regexes: 'pinctrl-[0-9]+'
arch/arm/boot/dts/aspeed-bmc-ampere-mtjade.dt.yaml

adc7mux: '#io-channel-cells' does not match any of the regexes: 'pinctrl-[0-9]+'
arch/arm/boot/dts/aspeed-bmc-ampere-mtjade.dt.yaml

adc8mux: '#io-channel-cells' does not match any of the regexes: 'pinctrl-[0-9]+'
arch/arm/boot/dts/aspeed-bmc-ampere-mtjade.dt.yaml

adc9mux: '#io-channel-cells' does not match any of the regexes: 'pinctrl-[0-9]+'
arch/arm/boot/dts/aspeed-bmc-ampere-mtjade.dt.yaml

envelope-detector-mux: channels: ['', '', 'sync-1', 'in', 'out', 'sync-2', 'sys-reg', 'ana-reg'] has non-unique elements

	arch/arm/boot/dts/at91-tse850-3.dt.yaml
#4 lore raw

Re: [PATCH v2 2/3] dt-bindings: iio: io-channel-mux: Add property for settle time

Quoted 11 lines · Rob Herring
Quoted 9 lines · Vincent Whitchurch

Hardware may require some time for the muxed analog signals to settle after the muxing is changed. Allow this time to be specified in the devicetree.

---
 .../devicetree/bindings/iio/multiplexer/io-channel-mux.yaml  | 5 +++++
 1 file changed, 5 insertions(+)
Quoted 3 lines

Running 'make dtbs_check' with the schema in this patch gives the following warnings. Consider if they are expected or the schema is incorrect. These may not be new warnings.

Yes, these are not new warnings.

Quoted 11 lines

Note that it is not yet a requirement to have 0 warnings for dtbs_check. This will change in the future.

Full log is available here: https://patchwork.ozlabs.org/patch/1537724

adc0mux: '#io-channel-cells' does not match any of the regexes: 'pinctrl-[0-9]+'
arch/arm/boot/dts/aspeed-bmc-ampere-mtjade.dt.yaml

adc10mux: '#io-channel-cells' does not match any of the regexes: 'pinctrl-[0-9]+'
arch/arm/boot/dts/aspeed-bmc-ampere-mtjade.dt.yaml

[...]

I think the fix for these is to add a "#io-channel-cells": const 1 to the schema.

Quoted 2 lines

envelope-detector-mux: channels: ['', '', 'sync-1', 'in', 'out', 'sync-2', 'sys-reg', 'ana-reg'] has non-unique elements

	arch/arm/boot/dts/at91-tse850-3.dt.yaml

This one looks like an error in that particular devicetree.

#5 lore raw

Re: [PATCH v2 2/3] dt-bindings: iio: io-channel-mux: Add property for settle time

Quoted 27 lines · Vincent Whitchurch
Quoted 11 lines · Rob Herring
Quoted 9 lines · Vincent Whitchurch

Hardware may require some time for the muxed analog signals to settle after the muxing is changed. Allow this time to be specified in the devicetree.

---
 .../devicetree/bindings/iio/multiplexer/io-channel-mux.yaml  | 5 +++++
 1 file changed, 5 insertions(+)
Quoted 3 lines

Running 'make dtbs_check' with the schema in this patch gives the following warnings. Consider if they are expected or the schema is incorrect. These may not be new warnings.

Yes, these are not new warnings.

Quoted 9 lines

Note that it is not yet a requirement to have 0 warnings for dtbs_check. This will change in the future.

Full log is available here: https://patchwork.ozlabs.org/patch/1537724

adc0mux: '#io-channel-cells' does not match any of the regexes: 'pinctrl-[0-9]+'
arch/arm/boot/dts/aspeed-bmc-ampere-mtjade.dt.yaml

Quoted 6 lines
Quoted 2 lines

adc10mux: '#io-channel-cells' does not match any of the regexes: 'pinctrl-[0-9]+'
arch/arm/boot/dts/aspeed-bmc-ampere-mtjade.dt.yaml

[...]

I think the fix for these is to add a "#io-channel-cells": const 1 to the schema.

Agreed.

Quoted 5 lines
Quoted 2 lines

envelope-detector-mux: channels: ['', '', 'sync-1', 'in', 'out', 'sync-2', 'sys-reg', 'ana-reg'] has non-unique elements

	arch/arm/boot/dts/at91-tse850-3.dt.yaml

This one looks like an error in that particular devicetree.

The double '' is intentional; this mux is 8-way but only 6 legs are connected, with the first two unused. I don't know how or where to make changes to dodge the warning. I don't want to put names on things that do not exist, and the iio-mux driver is using empty names as a hint to not configure any child channel for those indices that have empty names. If e.g. channels 0-5 are in use, then this is not a problem since you can just end early with 6 names instead of 8, but alas, channels 2-7 was what the hw-crowd fancied in this case.

Cheers,
Peter

maintainer
#6 lore raw

Re: [PATCH v2 2/3] dt-bindings: iio: io-channel-mux: Add property for settle time

Quoted 43 lines · Peter Rosin
Quoted 27 lines · Vincent Whitchurch
Quoted 11 lines · Rob Herring
Quoted 9 lines · Vincent Whitchurch

Hardware may require some time for the muxed analog signals to settle after the muxing is changed. Allow this time to be specified in the devicetree.

---
 .../devicetree/bindings/iio/multiplexer/io-channel-mux.yaml  | 5 +++++
 1 file changed, 5 insertions(+)
Quoted 3 lines

Running 'make dtbs_check' with the schema in this patch gives the following warnings. Consider if they are expected or the schema is incorrect. These may not be new warnings.

Yes, these are not new warnings.

Quoted 9 lines

Note that it is not yet a requirement to have 0 warnings for dtbs_check. This will change in the future.

Full log is available here: https://patchwork.ozlabs.org/patch/1537724

adc0mux: '#io-channel-cells' does not match any of the regexes: 'pinctrl-[0-9]+'
arch/arm/boot/dts/aspeed-bmc-ampere-mtjade.dt.yaml

Quoted 6 lines
Quoted 2 lines

adc10mux: '#io-channel-cells' does not match any of the regexes: 'pinctrl-[0-9]+'
arch/arm/boot/dts/aspeed-bmc-ampere-mtjade.dt.yaml

[...]

I think the fix for these is to add a "#io-channel-cells": const 1 to the schema.

Agreed.

Quoted 5 lines
Quoted 2 lines

envelope-detector-mux: channels: ['', '', 'sync-1', 'in', 'out', 'sync-2', 'sys-reg', 'ana-reg'] has non-unique elements

     arch/arm/boot/dts/at91-tse850-3.dt.yaml

This one looks like an error in that particular devicetree.

Quoted 8 lines

The double '' is intentional; this mux is 8-way but only 6 legs are connected, with the first two unused. I don't know how or where to make changes to dodge the warning. I don't want to put names on things that do not exist, and the iio-mux driver is using empty names as a hint to not configure any child channel for those indices that have empty names. If e.g. channels 0-5 are in use, then this is not a problem since you can just end early with 6 names instead of 8, but alas, channels 2-7 was what the hw-crowd fancied in this case.

There's a specific string type for this: non-unique-string-array

Unfortunately, no way to say unique or empty strings.

Rob

#7 lore raw

[PATCH 4/3] dt-bindings: iio: io-channel-mux: add optional #io-channel-cells

In reply to Rob Herring

Needed for in-kernel use of the child channels of the mux.

Fixes problems like this, reported by dtbs_check:
adc0mux: '#io-channel-cells' does not match any of the regexes: 'pinctrl-[0-9]+'
arch/arm/boot/dts/aspeed-bmc-ampere-mtjade.dt.yaml

---
 .../devicetree/bindings/iio/multiplexer/io-channel-mux.yaml    | 3 +++
 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/iio/multiplexer/io-channel-mux.yaml +3 -0
index 5a7328042c76..80b6229a6fad 100644
@@ -44,6 +44,9 @@ properties:
     description:
       Time required for analog signals to settle after muxing.
 
+  "#io-channel-cells":
+    const: 1
+
 required:
   - compatible
   - io-channels
Signature · 1 line
2.20.1
maintainer Acked-by
#8 lore raw

Re: [PATCH 4/3] dt-bindings: iio: io-channel-mux: add optional #io-channel-cells

Quoted 6 lines · Peter Rosin

Needed for in-kernel use of the child channels of the mux.

Fixes problems like this, reported by dtbs_check:
adc0mux: '#io-channel-cells' does not match any of the regexes: 'pinctrl-[0-9]+'
arch/arm/boot/dts/aspeed-bmc-ampere-mtjade.dt.yaml

Quoted 6 lines
---
 .../devicetree/bindings/iio/multiplexer/io-channel-mux.yaml    | 3 +++
 1 file changed, 3 insertions(+)
#9 lore raw

[PATCH 5/3] dt-bindings: iio: io-channel-mux: allow duplicate channel, labels

In reply to Vincent Whitchurch

This is needed since an empty channel label is used to indicate an unused channel, and there can be more that one of those.

Fixes the following problem reported by dtbs_check:
envelope-detector-mux: channels: ['', '', 'sync-1', 'in', 'out', 'sync-2', 'sys-reg', 'ana-reg'] has non-unique elements

	arch/arm/boot/dts/at91-tse850-3.dt.yaml
---
 .../devicetree/bindings/iio/multiplexer/io-channel-mux.yaml  | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/iio/multiplexer/io-channel-mux.yaml +3 -2
index 80b6229a6fad..611ad4444cf0 100644
@@ -35,9 +35,10 @@ properties:
   mux-control-names: true
 
   channels:
-    $ref: /schemas/types.yaml#/definitions/string-array
+    $ref: /schemas/types.yaml#/definitions/non-unique-string-array
     description:
-      List of strings, labeling the mux controller states.
+      List of strings, labeling the mux controller states. An empty
+      string for a state means that the channel is not available.
 
   settle-time-us:
     default: 0
Signature · 1 line
2.20.1
maintainer Acked-by
#10 lore raw

Re: [PATCH 5/3] dt-bindings: iio: io-channel-mux: allow duplicate channel, labels

Quoted 5 lines · Peter Rosin

This is needed since an empty channel label is used to indicate an unused channel, and there can be more that one of those.

Fixes the following problem reported by dtbs_check:
envelope-detector-mux: channels: ['', '', 'sync-1', 'in', 'out', 'sync-2', 'sys-reg', 'ana-reg'] has non-unique elements

Quoted 8 lines
	arch/arm/boot/dts/at91-tse850-3.dt.yaml
---
 .../devicetree/bindings/iio/multiplexer/io-channel-mux.yaml  | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
maintainer
#11 lore raw

Re: [PATCH 5/3] dt-bindings: iio: io-channel-mux: allow duplicate channel, labels

Quoted 8 lines · On Tue, 19 Oct 2021 16:25:49 -0500 Rob Herring <[email protected]> wrote:
Quoted 7 lines · Peter Rosin

This is needed since an empty channel label is used to indicate an unused channel, and there can be more that one of those.

Fixes the following problem reported by dtbs_check:
envelope-detector-mux: channels: ['', '', 'sync-1', 'in', 'out', 'sync-2', 'sys-reg', 'ana-reg'] has non-unique elements

	arch/arm/boot/dts/at91-tse850-3.dt.yaml
Quoted 8 lines
Quoted 6 lines
---
 .../devicetree/bindings/iio/multiplexer/io-channel-mux.yaml  | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

4 + 5 applied to the togreg branch of iio.git and pushed out as testing for 0-day to give it a dry run.

Thanks,

Jonathan

maintainer Reviewed-by on v2 2/3
#12 lore raw

Re: [PATCH v2 2/3] dt-bindings: iio: io-channel-mux: Add property for settle time

In reply to Vincent Whitchurch
Quoted 9 lines · Vincent Whitchurch

Hardware may require some time for the muxed analog signals to settle after the muxing is changed. Allow this time to be specified in the devicetree.

---
 .../devicetree/bindings/iio/multiplexer/io-channel-mux.yaml  | 5 +++++
 1 file changed, 5 insertions(+)
#13 lore raw

PATCH v2 3/3 iio: multiplexer: iio-mux: Support settle-time-us property

In reply to Vincent Whitchurch

If the devicetree specifies that the hardware requires a settle time, pass this time on to the mux APIs.

---
 drivers/iio/multiplexer/iio-mux.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/iio/multiplexer/iio-mux.c +6 -1
index d54ae5cbe51b..f422d44377df 100644
@@ -33,6 +33,7 @@ struct mux {
 	struct iio_chan_spec *chan;
 	struct iio_chan_spec_ext_info *ext_info;
 	struct mux_child *child;
+	u32 delay_us;
 };
 
 static int iio_mux_select(struct mux *mux, int idx)
@@ -42,7 +43,8 @@ static int iio_mux_select(struct mux *mux, int idx)
 	int ret;
 	int i;
 
-	ret = mux_control_select(mux->control, chan->channel);
+	ret = mux_control_select_delay(mux->control, chan->channel,
+				       mux->delay_us);
 	if (ret < 0) {
 		mux->cached_state = -1;
 		return ret;
@@ -392,6 +394,9 @@ static int mux_probe(struct platform_device *pdev)
 	mux->parent = parent;
 	mux->cached_state = -1;
 
+	mux->delay_us = 0;
+	of_property_read_u32(np, "settle-time-us", &mux->delay_us);
+
 	indio_dev->name = dev_name(dev);
 	indio_dev->info = &mux_info;
 	indio_dev->modes = INDIO_DIRECT_MODE;
Signature · 1 line
2.28.0
Reviewed-by Acked-by on the v2 series
#14 lore raw
In reply to Vincent Whitchurch
Quoted 6 lines · Vincent Whitchurch

On one of our boards we use gpio-mux with iio-mux to read voltages using an ADC from a few different channels, and on this board the input voltage needs some time to stabilize after a switch of the mux.

This series add devicetree and driver support for this kind of hardware which requries a settle time after muxing.

I have a board with the very same problem. And a similar solution, but you beat me with upstreaming. I've switched to your patchset.

Whole series

Quoted 19 lines

v1 -> v2:
- Move property support to iio-mux and delay handling to mux core as suggested by Peter.

v1: https://lore.kernel.org/all/[email protected]/

Vincent Whitchurch (3):
mux: add support for delay after muxing
dt-bindings: iio: io-channel-mux: Add property for settle time
iio: multiplexer: iio-mux: Support settle-time-us property

  .../iio/multiplexer/io-channel-mux.yaml       |  5 +++
  drivers/iio/multiplexer/iio-mux.c             |  7 +++-
  drivers/mux/core.c                            | 36 ++++++++++++++++---
  include/linux/mux/consumer.h                  | 23 +++++++++---
  include/linux/mux/driver.h                    |  4 +++
  5 files changed, 65 insertions(+), 10 deletions(-)
Reviewed-by Tested-by
#15 lore raw
Quoted 8 lines · Lars-Peter Clausen
Quoted 6 lines · Vincent Whitchurch

On one of our boards we use gpio-mux with iio-mux to read voltages using an ADC from a few different channels, and on this board the input voltage needs some time to stabilize after a switch of the mux.

This series add devicetree and driver support for this kind of hardware which requries a settle time after muxing.

Quoted 7 lines

I have a board with the very same problem. And a similar solution, but you beat me with upstreaming. I've switched to your patchset.

Whole series

Oh, I just realized I messed up. I meant to write

maintainer
#16 lore raw
Quoted 17 lines · On Tue, 19 Oct 2021 09:03:00 +0200 Lars-Peter Clausen <[email protected]> wrote:
Quoted 16 lines · Lars-Peter Clausen
Quoted 9 lines · Vincent Whitchurch

On one of our boards we use gpio-mux with iio-mux to read voltages using an ADC
from a few different channels, and on this board the input voltage needs some
time to stabilize after a switch of the mux.

This series add devicetree and driver support for this kind of hardware which
requries a settle time after muxing.

I have a board with the very same problem. And a similar solution, but you beat me with upstreaming. I've switched to your patchset.

Whole series

Quoted 8 lines
Quoted 3 lines

Oh, I just realized I messed up. I meant to write

Fixed up.

Thanks,

Jonathan

Acked-by on the v2 series
#17 lore raw
In reply to Vincent Whitchurch

Hi Vincent!

Quoted 18 lines · Vincent Whitchurch

On one of our boards we use gpio-mux with iio-mux to read voltages using an ADC from a few different channels, and on this board the input voltage needs some time to stabilize after a switch of the mux.

This series add devicetree and driver support for this kind of hardware which requries a settle time after muxing.

v1 -> v2:
- Move property support to iio-mux and delay handling to mux core as suggested by Peter.

v1: https://lore.kernel.org/all/[email protected]/

Vincent Whitchurch (3):
mux: add support for delay after muxing
dt-bindings: iio: io-channel-mux: Add property for settle time
iio: multiplexer: iio-mux: Support settle-time-us property

Quoted 7 lines
 .../iio/multiplexer/io-channel-mux.yaml       |  5 +++
 drivers/iio/multiplexer/iio-mux.c             |  7 +++-
 drivers/mux/core.c                            | 36 ++++++++++++++++---
 include/linux/mux/consumer.h                  | 23 +++++++++---
 include/linux/mux/driver.h                    |  4 +++
 5 files changed, 65 insertions(+), 10 deletions(-)

This looks really nice, thank you! The only question I see is if it should go via my (virtually unused) mux tree or via the iio tree. Yes, the meat is in mux/core.c, but I'm happy to just ack these patches and have Jonathan handle them. But, I'm also fine with handling it in the mux tree (but I'm getting old and forgetful, and it's been so many moons that I need to re-learn the steps).

Jonathan, you or me? If you, you can add:

Cheers,
Peter

maintainer
#18 lore raw
Quoted 36 lines · On Sat, 9 Oct 2021 01:09:56 +0200 Peter Rosin <[email protected]> wrote:

Hi Vincent!

Quoted 18 lines · Vincent Whitchurch

On one of our boards we use gpio-mux with iio-mux to read voltages using an ADC from a few different channels, and on this board the input voltage needs some time to stabilize after a switch of the mux.

This series add devicetree and driver support for this kind of hardware which requries a settle time after muxing.

v1 -> v2:
- Move property support to iio-mux and delay handling to mux core as suggested by Peter.

v1: https://lore.kernel.org/all/[email protected]/

Vincent Whitchurch (3):
mux: add support for delay after muxing
dt-bindings: iio: io-channel-mux: Add property for settle time
iio: multiplexer: iio-mux: Support settle-time-us property

Quoted 7 lines
 .../iio/multiplexer/io-channel-mux.yaml       |  5 +++
 drivers/iio/multiplexer/iio-mux.c             |  7 +++-
 drivers/mux/core.c                            | 36 ++++++++++++++++---
 include/linux/mux/consumer.h                  | 23 +++++++++---
 include/linux/mux/driver.h                    |  4 +++
 5 files changed, 65 insertions(+), 10 deletions(-)

This looks really nice, thank you! The only question I see is if it should go via my (virtually unused) mux tree or via the iio tree. Yes, the meat is in mux/core.c, but I'm happy to just ack these patches and have Jonathan handle them. But, I'm also fine with handling it in the mux tree (but I'm getting old and forgetful, and it's been so many moons that I need to re-learn the steps).

Quoted 3 lines

Jonathan, you or me? If you, you can add:

I don't really mind, but the 4/3 and 5/3 have broken my b4 based flow + Rob hasn't yet given an Ack on those two, so I'll not pick any of them up just yet. I can sort out the two oddly numbered patches if Rob is happy, though they'll probably not have the nice link tags that b4 automates.

Note Rob didn't actually say he was happy with patch 2 yet as far as I can tell.

Thanks,

Jonathan

Quoted 3 lines

Cheers,
Peter

#19 lore raw
Quoted 41 lines · Jonathan Cameron
Quoted 38 lines · On Sat, 9 Oct 2021 01:09:56 +0200 Peter Rosin <[email protected]> wrote:

Hi Vincent!

Quoted 18 lines · Vincent Whitchurch

On one of our boards we use gpio-mux with iio-mux to read voltages using an ADC from a few different channels, and on this board the input voltage needs some time to stabilize after a switch of the mux.

This series add devicetree and driver support for this kind of hardware which requries a settle time after muxing.

v1 -> v2:
- Move property support to iio-mux and delay handling to mux core as suggested by Peter.

v1: https://lore.kernel.org/all/[email protected]/

Vincent Whitchurch (3):
mux: add support for delay after muxing
dt-bindings: iio: io-channel-mux: Add property for settle time
iio: multiplexer: iio-mux: Support settle-time-us property

Quoted 7 lines
 .../iio/multiplexer/io-channel-mux.yaml       |  5 +++
 drivers/iio/multiplexer/iio-mux.c             |  7 +++-
 drivers/mux/core.c                            | 36 ++++++++++++++++---
 include/linux/mux/consumer.h                  | 23 +++++++++---
 include/linux/mux/driver.h                    |  4 +++
 5 files changed, 65 insertions(+), 10 deletions(-)

This looks really nice, thank you! The only question I see is if it should go via my (virtually unused) mux tree or via the iio tree. Yes, the meat is in mux/core.c, but I'm happy to just ack these patches and have Jonathan handle them. But, I'm also fine with handling it in the mux tree (but I'm getting old and forgetful, and it's been so many moons that I need to re-learn the steps).

Jonathan, you or me? If you, you can add:

Quoted 8 lines
Quoted 1 line

I don't really mind, but the 4/3 and 5/3 have broken my b4 based flow + Rob hasn't yet given an Ack on those two, so I'll not pick any of them up just yet. I can sort out the two oddly numbered patches if Rob is happy, though they'll probably not have the nice link tags that b4 automates.

Note Rob didn't actually say he was happy with patch 2 yet as far as I can tell.

Getting Rob's ack on 2/3 is of course a prerequisite to 1/3 and 3/3.

Just ignore 4/3 and 5/3 if they are holding things back or are making things difficult in any way. I'll resend them later if need be, as they really have very little to do with this series.

With hindsight I should probably have sent them as a fresh series, and I can re-post them as such immediately if that helps? But then again, maybe that just muddies the water even further...

Cheers,
Peter

maintainer
#20 lore raw
Quoted 44 lines · On Sun, 17 Oct 2021 23:08:06 +0200 Peter Rosin <[email protected]> wrote:
Quoted 43 lines · Jonathan Cameron
Quoted 39 lines · On Sat, 9 Oct 2021 01:09:56 +0200 Peter Rosin <[email protected]> wrote:

Hi Vincent!

Quoted 18 lines · Vincent Whitchurch

On one of our boards we use gpio-mux with iio-mux to read voltages using an ADC from a few different channels, and on this board the input voltage needs some time to stabilize after a switch of the mux.

This series add devicetree and driver support for this kind of hardware which requries a settle time after muxing.

v1 -> v2:
- Move property support to iio-mux and delay handling to mux core as suggested by Peter.

v1: https://lore.kernel.org/all/[email protected]/

Vincent Whitchurch (3):
mux: add support for delay after muxing
dt-bindings: iio: io-channel-mux: Add property for settle time
iio: multiplexer: iio-mux: Support settle-time-us property

Quoted 7 lines
 .../iio/multiplexer/io-channel-mux.yaml       |  5 +++
 drivers/iio/multiplexer/iio-mux.c             |  7 +++-
 drivers/mux/core.c                            | 36 ++++++++++++++++---
 include/linux/mux/consumer.h                  | 23 +++++++++---
 include/linux/mux/driver.h                    |  4 +++
 5 files changed, 65 insertions(+), 10 deletions(-)

This looks really nice, thank you! The only question I see is if it should go via my (virtually unused) mux tree or via the iio tree. Yes, the meat is in mux/core.c, but I'm happy to just ack these patches and have Jonathan handle them. But, I'm also fine with handling it in the mux tree (but I'm getting old and forgetful, and it's been so many moons that I need to re-learn the steps).

Jonathan, you or me? If you, you can add:

Quoted 8 lines
Quoted 6 lines

I don't really mind, but the 4/3 and 5/3 have broken my b4 based flow + Rob hasn't yet given an Ack on those two, so I'll not pick any of them up just yet. I can sort out the two oddly numbered patches if Rob is happy, though they'll probably not have the nice link tags that b4 automates.

Note Rob didn't actually say he was happy with patch 2 yet as far as I can tell.

Getting Rob's ack on 2/3 is of course a prerequisite to 1/3 and 3/3.

Given Rob has now given that, I'll queue these 3 patches up.

Applied to the iio-togreg branch of iio.git and pushed out as testing for 0-day to poke at.

Quoted 8 lines

Just ignore 4/3 and 5/3 if they are holding things back or are making things difficult in any way. I'll resend them later if need be, as they really have very little to do with this series.

With hindsight I should probably have sent them as a fresh series, and I can re-post them as such immediately if that helps? But then again, maybe that just muddies the water even further...

Let's deal with those two separately. I can pick them off list if Rob is happy with those two. The dt bindings patchwork has them as needing review so I'm sure they'll get it shortly.

Thanks,

Jonathan

Quoted 3 lines

Cheers,
Peter