From: Rob Herring <robh@kernel.org>
To: Olivier Moysan <olivier.moysan@foss.st.com>
Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>,
Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>,
Fabrice Gasnier <fabrice.gasnier@st.com>,
Jonathan Cameron <jic23@kernel.org>,
Lars-Peter Clausen <lars@metafoo.de>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
alsa-devel@alsa-project.org, devicetree@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, linux-iio@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-stm32@st-md-mailman.stormreply.com
Subject: Re: [PATCH 1/7] dt-bindings: iio: adc: add generic channel binding
Date: Tue, 21 Sep 2021 12:08:33 -0500 [thread overview]
Message-ID: <YUoRkepuJXRghzih@robh.at.kernel.org> (raw)
In-Reply-To: <20210908155452.25458-2-olivier.moysan@foss.st.com>
On Wed, Sep 08, 2021 at 05:54:46PM +0200, Olivier Moysan wrote:
> Add ADC generic channel binding. This binding should
> be used as an alternate to legacy channel properties
> whenever possible.
> ADC generic channel binding allows to identify supported
> internal channels through the following reserved label names:
> "vddcore", "vrefint" and "vbat".
> This binding also allows to set a different sampling time
> for each channel.
>
> Signed-off-by: Olivier Moysan <olivier.moysan@foss.st.com>
> ---
> Note: The schema here is too permissive as either legacy or generic
> channels properties are required. These properties are mutually
> exclusive, however all attempts to describe this constraint are
> failing. In particular the following schemas and their variants have
> shown unsucessful.
>
> oneOf:
> - anyOf:
> - required:
> - st,adc-channels
> - required:
> - st,adc-diff-channels
> - anyOf:
> - required:
> - $nodename
>
> - if:
> patternProperties:
> "^channel@([0-9]|1[0-9])$":
> type: object
This is considered true when you don't match this property. You would
need 'required', but that doesn't work for patterns. That's a
json-schema limitation that's on their radar to address.
My advice is just mark the legacy nodes 'deprecated'. That doesn't do
anything yet, but I plan to add a 'disallow deprecated properties/nodes'
mode.
> then:
> properties:
> st,adc-channels: false
> st,adc-diff-channels: false
> else:
> - anyOf:
> - required:
> - st,adc-channels
> - required:
> - st,adc-diff-channels
> ---
> .../bindings/iio/adc/st,stm32-adc.yaml | 100 ++++++++++++++++--
> 1 file changed, 93 insertions(+), 7 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/iio/adc/st,stm32-adc.yaml b/Documentation/devicetree/bindings/iio/adc/st,stm32-adc.yaml
> index a58334c3bb76..a1f6cbe144ba 100644
> --- a/Documentation/devicetree/bindings/iio/adc/st,stm32-adc.yaml
> +++ b/Documentation/devicetree/bindings/iio/adc/st,stm32-adc.yaml
> @@ -222,6 +222,12 @@ patternProperties:
> '#io-channel-cells':
> const: 1
>
> + '#address-cells':
> + const: 1
> +
> + '#size-cells':
> + const: 0
> +
> interrupts:
> description: |
> IRQ Line for the ADC instance. Valid values are:
> @@ -265,7 +271,9 @@ patternProperties:
> <vinp vinn>, <vinp vinn>,... vinp and vinn are numbered from 0 to 19.
>
> Note: At least one of "st,adc-channels" or "st,adc-diff-channels" is
> - required. Both properties can be used together. Some channels can be
> + required if no adc generic channel is defined. These legacy channel
> + properties are exclusive with adc generic channel bindings.
> + Both properties can be used together. Some channels can be
> used as single-ended and some other ones as differential (mixed). But
> channels can't be configured both as single-ended and differential.
> $ref: /schemas/types.yaml#/definitions/uint32-matrix
> @@ -290,6 +298,44 @@ patternProperties:
> each channel.
> $ref: /schemas/types.yaml#/definitions/uint32-array
>
> + patternProperties:
> + "^channel@([0-9]|1[0-9])$":
> + type: object
> + $ref: "adc.yaml"
> + description: |
> + Represents the external channels which are connected to the ADC.
> +
> + properties:
> + reg:
> + items:
> + minimum: 0
> + maximum: 19
> +
> + label:
> + description: |
> + Unique name to identify which channel this is.
> + Reserved label names "vddcore", "vrefint" and "vbat"
> + are used to identify internal channels with matching names.
> +
> + diff-channels:
> + $ref: /schemas/types.yaml#/definitions/uint32-array
> + items:
> + minimum: 0
> + maximum: 19
> +
> + st,min-sample-time-nsecs:
> + $ref: /schemas/types.yaml#/definitions/uint32
> + description: |
> + Minimum sampling time in nanoseconds. Depending on hardware (board)
> + e.g. high/low analog input source impedance, fine tune of ADC
> + sampling time may be recommended.
> +
> + required:
> + - reg
> +
> + dependencies:
> + $nodename: [ '#address-cells', '#size-cells' ]
Drop this. $nodename is not a real property.
> +
> allOf:
> - if:
> properties:
> @@ -369,12 +415,6 @@ patternProperties:
>
> additionalProperties: false
>
> - anyOf:
> - - required:
> - - st,adc-channels
> - - required:
> - - st,adc-diff-channels
> -
> required:
> - compatible
> - reg
> @@ -451,4 +491,50 @@ examples:
> // other adc child node follow...
> };
>
> + - |
> + // Example 3: with stm32mp157c to setup ADC2 with:
> + // - internal channels 13, 14, 15.
> + #include <dt-bindings/interrupt-controller/arm-gic.h>
> + #include <dt-bindings/clock/stm32mp1-clks.h>
> + adc122: adc@48003000 {
> + compatible = "st,stm32mp1-adc-core";
> + reg = <0x48003000 0x400>;
> + interrupts = <GIC_SPI 18 IRQ_TYPE_LEVEL_HIGH>,
> + <GIC_SPI 90 IRQ_TYPE_LEVEL_HIGH>;
> + clocks = <&rcc ADC12>, <&rcc ADC12_K>;
> + clock-names = "bus", "adc";
> + booster-supply = <&booster>;
> + vdd-supply = <&vdd>;
> + vdda-supply = <&vdda>;
> + vref-supply = <&vref>;
> + st,syscfg = <&syscfg>;
> + interrupt-controller;
> + #interrupt-cells = <1>;
> + #address-cells = <1>;
> + #size-cells = <0>;
> + adc@100 {
> + compatible = "st,stm32mp1-adc";
> + #io-channel-cells = <1>;
> + reg = <0x100>;
> + interrupts = <1>;
> + #address-cells = <1>;
> + #size-cells = <0>;
> + channel@13 {
> + reg = <13>;
> + label = "vrefint";
> + st,min-sample-time-nsecs = <9000>;
> + };
> + channel@14 {
> + reg = <14>;
> + label = "vddcore";
> + st,min-sample-time-nsecs = <9000>;
> + };
> + channel@15 {
> + reg = <15>;
> + label = "vbat";
> + st,min-sample-time-nsecs = <9000>;
> + };
> + };
> + };
> +
> ...
> --
> 2.17.1
>
>
next prev parent reply other threads:[~2021-09-21 17:08 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-08 15:54 [PATCH 0/7] add internal channels support Olivier Moysan
2021-09-08 15:54 ` [PATCH 1/7] dt-bindings: iio: adc: add generic channel binding Olivier Moysan
2021-09-11 15:51 ` Jonathan Cameron
2021-09-21 17:08 ` Rob Herring [this message]
2021-09-08 15:54 ` [PATCH 2/7] dt-bindings: iio: adc: add nvmem support for vrefint internal channel Olivier Moysan
2021-09-21 17:10 ` Rob Herring
2021-09-08 15:54 ` [PATCH 3/7] iio: adc stm32-adc: split channel init into several routines Olivier Moysan
2021-09-08 15:54 ` [PATCH 4/7] iio: adc: stm32-adc: add support of generic channels binding Olivier Moysan
2021-09-11 16:08 ` Jonathan Cameron
2021-09-08 15:54 ` [PATCH 5/7] iio: adc: stm32-adc: add support of internal channels Olivier Moysan
2021-09-11 16:17 ` Jonathan Cameron
2021-09-08 15:54 ` [PATCH 6/7] iio: adc: stm32-adc: add vrefint calibration support Olivier Moysan
2021-09-11 16:28 ` Jonathan Cameron
2021-09-15 10:02 ` Olivier MOYSAN
2021-09-18 18:42 ` Jonathan Cameron
2021-09-22 7:53 ` Olivier MOYSAN
2021-09-26 12:09 ` Jonathan Cameron
2021-09-08 15:54 ` [PATCH 7/7] iio: adc: stm32-adc: use generic binding for sample-time Olivier Moysan
2021-09-11 15:44 ` [PATCH 0/7] add internal channels support Jonathan Cameron
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=YUoRkepuJXRghzih@robh.at.kernel.org \
--to=robh@kernel.org \
--cc=alexandre.torgue@foss.st.com \
--cc=alsa-devel@alsa-project.org \
--cc=arnaud.pouliquen@foss.st.com \
--cc=devicetree@vger.kernel.org \
--cc=fabrice.gasnier@st.com \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=olivier.moysan@foss.st.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).