devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Cosmin Tanislav <demonsingur@gmail.com>
Cc: cosmin.tanislav@analog.com, Lars-Peter Clausen <lars@metafoo.de>,
	Michael Hennerich <Michael.Hennerich@analog.com>,
	Rob Herring <robh+dt@kernel.org>,
	linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] dt-bindings: iio: add AD74413R
Date: Thu, 28 Oct 2021 15:48:58 +0100	[thread overview]
Message-ID: <20211028154858.3fc865ff@jic23-huawei> (raw)
In-Reply-To: <20211028134849.3664969-2-demonsingur@gmail.com>

On Thu, 28 Oct 2021 16:48:44 +0300
Cosmin Tanislav <demonsingur@gmail.com> wrote:

> Add device tree bindings for AD74413R.
Hi Cosmin,

Welcome to IIO.

Nice to give a tiny bit of description of the device in here
to expand on what the patch title told us.

Some comments inline.

Thanks,

Jonathan
> 
> Signed-off-by: Cosmin Tanislav <cosmin.tanislav@analog.com>
> ---
>  .../bindings/iio/addac/adi,ad74413r.yaml      | 163 ++++++++++++++++++
>  include/dt-bindings/iio/addac/adi,ad74413r.h  |  30 ++++
>  2 files changed, 193 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/iio/addac/adi,ad74413r.yaml
>  create mode 100644 include/dt-bindings/iio/addac/adi,ad74413r.h
> 
> diff --git a/Documentation/devicetree/bindings/iio/addac/adi,ad74413r.yaml b/Documentation/devicetree/bindings/iio/addac/adi,ad74413r.yaml
> new file mode 100644
> index 000000000000..ed4ee3047fbe
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/iio/addac/adi,ad74413r.yaml
> @@ -0,0 +1,163 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/iio/addac/adi,ad74413r.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Analog Devices AD74413R/AD74412R device driver

Bindings always describe hardware, not drivers (so we don't expect to
see the word driver in them).

> +
> +maintainers:
> +  - Cosmin Tanislav <cosmin.tanislav@analog.com>
> +
> +description: |
> +  The AD74413R and AD74412R are quad-channel software configurable input/output
> +  solutions for building and process control applications. They contain
> +  functionality for analog output, analog input, digital input, resistance
> +  temperature detector, and thermocouple measurements integrated
> +  into a single chip solution with an SPI interface.
> +  The devices feature a 16-bit ADC and four configurable 13-bit DACs to provide
> +  four configurable input/output channels and a suite of diagnostic functions.
> +
> +properties:
> +  compatible:
> +    enum:
> +      - adi,ad74413r
> +      - adi,ad74412r

Alphabetical / numeric order preferred.

> +
> +  reg:
> +    maxItems: 1
> +
> +  '#address-cells':
> +    const: 1
> +
> +  '#size-cells':
> +    const: 0
> +
> +  spi-max-frequency:
> +    maximum: 1000000
> +
> +  spi-cpol: true
> +
> +  interrupts:
> +    maxItems: 1
> +
> +  refin-supply:
> +    description:
> +      Reference voltage regulator.
Name pretty much tells us everything in the description.

    refin-supply: true

is enough here I think.

> +
> +  adi,rsense-resistance-ohms:
> +    $ref: /schemas/types.yaml#/definitions/uint32

I think the automatic units stuff in dt-schema should remove the need for
a ref here.

> +    description:
> +      RSense resistance values in Ohms.
> +
> +required:
> +  - compatible
> +  - reg
> +  - spi-max-frequency
> +  - spi-cpol
> +  - refin-supply
> +  - adi,rsense-resistance-ohm
> +
> +additionalProperties: false
> +
> +patternProperties:
> +  "^channel@[0-3]$":
> +    type: object
> +    description: Represents the external channels which are connected to the device.
> +
> +    properties:
> +      reg:
> +        description: |
> +          The channel number. It can have up to 4 channels numbered from 0 to 3.
> +        maxItems: 1
> +        minimum: 0
> +        maximum: 3
> +
> +      adi,ch-func:
> +        $ref: /schemas/types.yaml#/definitions/uint32
> +        description: |
> +          Channel function.
> +          HART functions are not supported on AD74412R.

Ideally enforce that with suitable conditional statements in this binding schema.

> +          0 - CH_FUNC_HIGH_IMPEDANCE
> +          1 - CH_FUNC_VOLTAGE_OUTPUT
> +          2 - CH_FUNC_CURRENT_OUTPUT
> +          3 - CH_FUNC_VOLTAGE_INPUT
> +          4 - CH_FUNC_CURRENT_INPUT_EXT_POWER
> +          5 - CH_FUNC_CURRENT_INPUT_LOOP_POWER
> +          6 - CH_FUNC_RESISTANCE_INPUT
> +          7 - CH_FUNC_DIGITAL_INPUT_LOGIC
> +          8 - CH_FUNC_DIGITAL_INPUT_LOOP_POWER
> +          9 - CH_FUNC_CURRENT_INPUT_EXT_POWER_HART
> +          10 - CH_FUNC_CURRENT_INPUT_LOOP_POWER_HART

I'm not a great fan of large enums, but it is a bit hard to
work out a scheme that would be better for this so I guess we are
stuck with this.

> +        maxItems: 1
> +        minimum: 0
> +        maximum: 10
> +
> +      adi,gpo-config:
> +        $ref: /schemas/types.yaml#/definitions/uint32
> +        description: |
> +          GPO config.

GPO is what exactly?

> +          0 - GPO_CONFIG_100K_PULL_DOWN
> +          1 - GPO_CONFIG_LOGIC

Interesting that you have defined 2 in the header... 
Why not here?

> +          3 - GPO_CONFIG_DEBOUNCED_COMPARATOR
> +          4 - GPO_CONFIG_HIGH_IMPEDANCE
> +        maxItems: 1
> +        enum: [0, 1, 3, 4]
> +
> +    required:
> +      - reg

	This is fine if we have a default specified for the other elements
such as what type of channel this is.

> +
> +examples:
> +  - |
> +    spi0 {
> +      #address-cells = <1>;
> +      #size-cells = <0>;
> +
> +      cs-gpios = <&gpio 17 GPIO_ACTIVE_LOW>;
> +      status = "okay";
> +
> +      ad74413r@0 {
> +        compatible = "adi,ad74413r";
> +        reg = <0>;
> +        spi-max-frequency = <1000000>;
> +        spi-cpol;
> +
> +        #address-cells = <1>;
> +        #size-cells = <0>;
> +
> +        interrupt-parent = <&gpio>;
> +        interrupts = <26 0>;
> +
> +        refin-supply = <&ad74413r_refin>;
> +        adi,rsense-resistance-ohm = <100>;
> +
> +        channel@0 {
> +          reg = <0>;
> +
> +          adi,ch-func = <CH_FUNC_VOLTAGE_OUTPUT>;
> +          adi,gpo-config = <GPO_CONFIG_LOGIC>;
> +        };
> +
> +        channel@1 {
> +          reg = <1>;
> +
> +          adi,ch-func = <CH_FUNC_CURRENT_OUTPUT>;
> +          adi,gpo-config = <GPO_CONFIG_LOGIC>;
> +        };
> +
> +        channel@2 {
> +          reg = <2>;
> +
> +          adi,ch-func = <CH_FUNC_VOLTAGE_INPUT>;
> +          adi,gpo-config = <GPO_CONFIG_DEBOUNCED_COMPARATOR>;
> +        };
> +
> +        channel@3 {
> +          reg = <3>;
> +
> +          adi,ch-func = <CH_FUNC_CURRENT_INPUT_EXT_POWER>;
> +          adi,gpo-config = <GPO_CONFIG_DEBOUNCED_COMPARATOR>;
> +        };
> +      };
> +    };
> +...
> diff --git a/include/dt-bindings/iio/addac/adi,ad74413r.h b/include/dt-bindings/iio/addac/adi,ad74413r.h
> new file mode 100644
> index 000000000000..bde558d9731c
> --- /dev/null
> +++ b/include/dt-bindings/iio/addac/adi,ad74413r.h
> @@ -0,0 +1,30 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +
> +#ifndef _DT_BINDINGS_ADI_AD74413R_H
> +#define _DT_BINDINGS_ADI_AD74413R_H
> +
> +#define GPO_CONFIG_100K_PULL_DOWN		0x0
> +#define GPO_CONFIG_LOGIC				0x1
> +#define GPO_CONFIG_LOGIC_PARALLEL		0x2
> +#define GPO_CONFIG_DEBOUNCED_COMPARATOR	0x3
> +#define GPO_CONFIG_HIGH_IMPEDANCE		0x4
> +
> +#define GPO_CONFIG_MIN		GPO_CONFIG_100K_PULL_DOWN
> +#define GPO_CONFIG_MAX		GPO_CONFIG_HIGH_IMPEDANCE
> +
> +#define CH_FUNC_HIGH_IMPEDANCE					0x0
> +#define CH_FUNC_VOLTAGE_OUTPUT					0x1
> +#define CH_FUNC_CURRENT_OUTPUT					0x2
> +#define CH_FUNC_VOLTAGE_INPUT					0x3
> +#define CH_FUNC_CURRENT_INPUT_EXT_POWER			0x4
> +#define CH_FUNC_CURRENT_INPUT_LOOP_POWER		0x5
> +#define CH_FUNC_RESISTANCE_INPUT				0x6
> +#define CH_FUNC_DIGITAL_INPUT_LOGIC				0x7
> +#define CH_FUNC_DIGITAL_INPUT_LOOP_POWER		0x8
> +#define CH_FUNC_CURRENT_INPUT_EXT_POWER_HART	0x9
> +#define CH_FUNC_CURRENT_INPUT_LOOP_POWER_HART	0xA
> +
> +#define CH_FUNC_MIN		CH_FUNC_HIGH_IMPEDANCE
> +#define CH_FUNC_MAX		CH_FUNC_CURRENT_INPUT_LOOP_POWER_HART
> +
> +#endif /* _DT_BINDINGS_ADI_AD74413R_H */


  reply	other threads:[~2021-10-28 14:44 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-28 13:48 [PATCH 1/3] iio: add adddac subdirectory Cosmin Tanislav
2021-10-28 13:48 ` [PATCH 2/3] dt-bindings: iio: add AD74413R Cosmin Tanislav
2021-10-28 14:48   ` Jonathan Cameron [this message]
2021-10-28 13:48 ` [PATCH 3/3] iio: addac: add AD74413R driver Cosmin Tanislav
2021-10-28 15:58   ` Jonathan Cameron
     [not found]     ` <CAA+onPPObFeXQwJ450M=5Ue3uE6Cui0M0X49qgn_U1D6su=BcA@mail.gmail.com>
2021-10-30 15:54       ` Jonathan Cameron
     [not found]         ` <CAA+onPN89FJwUFRc3P7ROxPW1qcbSFSq9XxyA-UZw6Mx3XEO-A@mail.gmail.com>
2021-11-03 17:33           ` Jonathan Cameron
2021-10-31 22:47   ` kernel test robot
2021-10-28 13:56 ` [PATCH v2 1/3] iio: add adddac subdirectory Cosmin Tanislav
2021-10-28 13:56   ` [PATCH v2 2/3] dt-bindings: iio: add AD74413R Cosmin Tanislav
2021-10-28 19:08     ` Rob Herring
2021-10-28 13:56   ` [PATCH v2 3/3] iio: addac: add AD74413R driver Cosmin Tanislav
2021-10-28 16:02   ` [PATCH v2 1/3] iio: add adddac subdirectory Jonathan Cameron
2021-10-29  8:00   ` Sa, Nuno
2021-10-30 15:59     ` 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=20211028154858.3fc865ff@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=Michael.Hennerich@analog.com \
    --cc=cosmin.tanislav@analog.com \
    --cc=demonsingur@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --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 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).