2021-10-07 13:48:34

by Vincent Whitchurch

[permalink] [raw]
Subject: [PATCH v2 0/3] 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(-)

--
2.28.0


2021-10-07 13:49:19

by Vincent Whitchurch

[permalink] [raw]
Subject: [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).

Signed-off-by: Vincent Whitchurch <[email protected]>
---
drivers/mux/core.c | 36 +++++++++++++++++++++++++++++++-----
include/linux/mux/consumer.h | 23 +++++++++++++++++++----
include/linux/mux/driver.h | 4 ++++
3 files changed, 54 insertions(+), 9 deletions(-)

diff --git a/drivers/mux/core.c b/drivers/mux/core.c
index 1fb22388e7e0..dee6945e92f7 100644
--- a/drivers/mux/core.c
+++ b/drivers/mux/core.c
@@ -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.
diff --git a/include/linux/mux/consumer.h b/include/linux/mux/consumer.h
index 5fc6bb2fefad..7a09b040ac39 100644
--- a/include/linux/mux/consumer.h
+++ b/include/linux/mux/consumer.h
@@ -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);
diff --git a/include/linux/mux/driver.h b/include/linux/mux/driver.h
index 627a2c6bc02d..18824064f8c0 100644
--- a/include/linux/mux/driver.h
+++ b/include/linux/mux/driver.h
@@ -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;
};

/**
--
2.28.0

2021-10-07 13:51:17

by Vincent Whitchurch

[permalink] [raw]
Subject: [PATCH v2 3/3] iio: multiplexer: iio-mux: Support settle-time-us property

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

Signed-off-by: Vincent Whitchurch <[email protected]>
---
drivers/iio/multiplexer/iio-mux.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/multiplexer/iio-mux.c b/drivers/iio/multiplexer/iio-mux.c
index d54ae5cbe51b..f422d44377df 100644
--- a/drivers/iio/multiplexer/iio-mux.c
+++ b/drivers/iio/multiplexer/iio-mux.c
@@ -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;
--
2.28.0

2021-10-07 15:45:41

by Vincent Whitchurch

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

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.

Signed-off-by: Vincent Whitchurch <[email protected]>
---
.../devicetree/bindings/iio/multiplexer/io-channel-mux.yaml | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/Documentation/devicetree/bindings/iio/multiplexer/io-channel-mux.yaml b/Documentation/devicetree/bindings/iio/multiplexer/io-channel-mux.yaml
index 870b043406d8..5a7328042c76 100644
--- a/Documentation/devicetree/bindings/iio/multiplexer/io-channel-mux.yaml
+++ b/Documentation/devicetree/bindings/iio/multiplexer/io-channel-mux.yaml
@@ -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
--
2.28.0

2021-10-08 02:50:43

by Rob Herring (Arm)

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

On Thu, 07 Oct 2021 15:46:40 +0200, Vincent Whitchurch wrote:
> 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.
>
> Signed-off-by: Vincent Whitchurch <[email protected]>
> ---
> .../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

2021-10-08 13:57:14

by Vincent Whitchurch

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

On Fri, Oct 08, 2021 at 04:46:12AM +0200, Rob Herring wrote:
> On Thu, 07 Oct 2021 15:46:40 +0200, Vincent Whitchurch wrote:
> > 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.
> >
> > Signed-off-by: Vincent Whitchurch <[email protected]>
> > ---
> > .../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.

Yes, these are not 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
[...]

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

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

2021-10-08 15:29:39

by Peter Rosin

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

On 2021-10-08 15:56, Vincent Whitchurch wrote:
> On Fri, Oct 08, 2021 at 04:46:12AM +0200, Rob Herring wrote:
>> On Thu, 07 Oct 2021 15:46:40 +0200, Vincent Whitchurch wrote:
>>> 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.
>>>
>>> Signed-off-by: Vincent Whitchurch <[email protected]>
>>> ---
>>> .../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.
>
> Yes, these are not 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
> [...]
>
> I think the fix for these is to add a "#io-channel-cells": const 1 to
> the schema.

Agreed.

>> 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

2021-10-08 19:15:45

by Rob Herring (Arm)

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

On Fri, Oct 8, 2021 at 10:27 AM Peter Rosin <[email protected]> wrote:
>
> On 2021-10-08 15:56, Vincent Whitchurch wrote:
> > On Fri, Oct 08, 2021 at 04:46:12AM +0200, Rob Herring wrote:
> >> On Thu, 07 Oct 2021 15:46:40 +0200, Vincent Whitchurch wrote:
> >>> 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.
> >>>
> >>> Signed-off-by: Vincent Whitchurch <[email protected]>
> >>> ---
> >>> .../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.
> >
> > Yes, these are not 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
> > [...]
> >
> > I think the fix for these is to add a "#io-channel-cells": const 1 to
> > the schema.
>
> Agreed.
>
> >> 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.

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

Unfortunately, no way to say unique or empty strings.

Rob

2021-10-08 19:20:52

by Lars-Peter Clausen

[permalink] [raw]
Subject: Re: [PATCH v2 0/3] Add settle time support to iio-mux

On 10/7/21 3:46 PM, Vincent Whitchurch wrote:
> 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

Reviewed-by: Lars-Peter Clausen <[email protected]>

Acked-by: Lars-Peter Clausen <[email protected]>


>
> 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(-)
>

2021-10-08 22:12:31

by Peter Rosin

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

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

Suggested-by: Vincent Whitchurch <[email protected]>
Signed-off-by: Peter Rosin <[email protected]>
---
.../devicetree/bindings/iio/multiplexer/io-channel-mux.yaml | 3 +++
1 file changed, 3 insertions(+)

diff --git a/Documentation/devicetree/bindings/iio/multiplexer/io-channel-mux.yaml b/Documentation/devicetree/bindings/iio/multiplexer/io-channel-mux.yaml
index 5a7328042c76..80b6229a6fad 100644
--- a/Documentation/devicetree/bindings/iio/multiplexer/io-channel-mux.yaml
+++ b/Documentation/devicetree/bindings/iio/multiplexer/io-channel-mux.yaml
@@ -44,6 +44,9 @@ properties:
description:
Time required for analog signals to settle after muxing.

+ "#io-channel-cells":
+ const: 1
+
required:
- compatible
- io-channels
--
2.20.1

2021-10-08 22:12:49

by Peter Rosin

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

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

Suggested-by: Rob Herring <[email protected]>
Signed-off-by: Peter Rosin <[email protected]>
---
.../devicetree/bindings/iio/multiplexer/io-channel-mux.yaml | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/iio/multiplexer/io-channel-mux.yaml b/Documentation/devicetree/bindings/iio/multiplexer/io-channel-mux.yaml
index 80b6229a6fad..611ad4444cf0 100644
--- a/Documentation/devicetree/bindings/iio/multiplexer/io-channel-mux.yaml
+++ b/Documentation/devicetree/bindings/iio/multiplexer/io-channel-mux.yaml
@@ -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
--
2.20.1

2021-10-08 23:13:07

by Peter Rosin

[permalink] [raw]
Subject: Re: [PATCH v2 0/3] Add settle time support to iio-mux

Hi Vincent!

On 2021-10-07 15:46, Vincent Whitchurch wrote:
> 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(-)
>

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:

Acked-by: Peter Rosin <[email protected]>

Cheers,
Peter

2021-10-18 03:47:52

by Peter Rosin

[permalink] [raw]
Subject: Re: [PATCH v2 0/3] Add settle time support to iio-mux

On 2021-10-17 19:31, Jonathan Cameron wrote:
> On Sat, 9 Oct 2021 01:09:56 +0200
> Peter Rosin <[email protected]> wrote:
>
>> Hi Vincent!
>>
>> On 2021-10-07 15:46, Vincent Whitchurch wrote:
>>> 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(-)
>>>
>>
>> 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:
>>
>> Acked-by: Peter Rosin <[email protected]>
>
> 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

2021-10-18 03:47:51

by Jonathan Cameron

[permalink] [raw]
Subject: Re: [PATCH v2 0/3] Add settle time support to iio-mux

On Sat, 9 Oct 2021 01:09:56 +0200
Peter Rosin <[email protected]> wrote:

> Hi Vincent!
>
> On 2021-10-07 15:46, Vincent Whitchurch wrote:
> > 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(-)
> >
>
> 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:
>
> Acked-by: Peter Rosin <[email protected]>

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

>
> Cheers,
> Peter

2021-10-18 19:54:48

by Rob Herring (Arm)

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

On Thu, 07 Oct 2021 15:46:40 +0200, Vincent Whitchurch wrote:
> 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.
>
> Signed-off-by: Vincent Whitchurch <[email protected]>
> ---
> .../devicetree/bindings/iio/multiplexer/io-channel-mux.yaml | 5 +++++
> 1 file changed, 5 insertions(+)
>

Reviewed-by: Rob Herring <[email protected]>

2021-10-18 20:10:42

by Jonathan Cameron

[permalink] [raw]
Subject: Re: [PATCH v2 0/3] Add settle time support to iio-mux

On Sun, 17 Oct 2021 23:08:06 +0200
Peter Rosin <[email protected]> wrote:

> On 2021-10-17 19:31, Jonathan Cameron wrote:
> > On Sat, 9 Oct 2021 01:09:56 +0200
> > Peter Rosin <[email protected]> wrote:
> >
> >> Hi Vincent!
> >>
> >> On 2021-10-07 15:46, Vincent Whitchurch wrote:
> >>> 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(-)
> >>>
> >>
> >> 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:
> >>
> >> Acked-by: Peter Rosin <[email protected]>
> >
> > 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.

>
> 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

>
> Cheers,
> Peter

2021-10-19 07:06:00

by Lars-Peter Clausen

[permalink] [raw]
Subject: Re: [PATCH v2 0/3] Add settle time support to iio-mux

On 10/8/21 9:19 PM, Lars-Peter Clausen wrote:
> On 10/7/21 3:46 PM, Vincent Whitchurch wrote:
>> 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
>
> Reviewed-by: Lars-Peter Clausen <[email protected]>
>
> Acked-by: Lars-Peter Clausen <[email protected]>
Oh, I just realized I messed up. I meant to write

Reviewed-by: Lars-Peter Clausen <[email protected]>
Tested-by: Lars-Peter Clausen <[email protected]>

2021-10-19 21:27:20

by Rob Herring (Arm)

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

On Sat, 09 Oct 2021 00:11:21 +0200, Peter Rosin wrote:
> 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
>
> Suggested-by: Vincent Whitchurch <[email protected]>
> Signed-off-by: Peter Rosin <[email protected]>
> ---
> .../devicetree/bindings/iio/multiplexer/io-channel-mux.yaml | 3 +++
> 1 file changed, 3 insertions(+)
>

Acked-by: Rob Herring <[email protected]>

2021-10-19 21:30:35

by Rob Herring (Arm)

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

On Sat, 09 Oct 2021 00:11:30 +0200, Peter Rosin wrote:
> 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
>
> Suggested-by: Rob Herring <[email protected]>
> Signed-off-by: Peter Rosin <[email protected]>
> ---
> .../devicetree/bindings/iio/multiplexer/io-channel-mux.yaml | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>

Acked-by: Rob Herring <[email protected]>

2021-10-20 16:46:41

by Jonathan Cameron

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

On Tue, 19 Oct 2021 16:25:49 -0500
Rob Herring <[email protected]> wrote:

> On Sat, 09 Oct 2021 00:11:30 +0200, Peter Rosin wrote:
> > 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
> >
> > Suggested-by: Rob Herring <[email protected]>
> > Signed-off-by: Peter Rosin <[email protected]>
> > ---
> > .../devicetree/bindings/iio/multiplexer/io-channel-mux.yaml | 5 +++--
> > 1 file changed, 3 insertions(+), 2 deletions(-)
> >
>
> Acked-by: Rob Herring <[email protected]>

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

2021-10-21 19:37:00

by Jonathan Cameron

[permalink] [raw]
Subject: Re: [PATCH v2 0/3] Add settle time support to iio-mux

On Tue, 19 Oct 2021 09:03:00 +0200
Lars-Peter Clausen <[email protected]> wrote:

> On 10/8/21 9:19 PM, Lars-Peter Clausen wrote:
> > On 10/7/21 3:46 PM, Vincent Whitchurch wrote:
> >> 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
> >
> > Reviewed-by: Lars-Peter Clausen <[email protected]>
> >
> > Acked-by: Lars-Peter Clausen <[email protected]>
> Oh, I just realized I messed up. I meant to write
>
> Reviewed-by: Lars-Peter Clausen <[email protected]>
> Tested-by: Lars-Peter Clausen <[email protected]>
>
Fixed up.

Thanks,

Jonathan