linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: "József Horváth" <info@ministro.hu>
Cc: Lars-Peter Clausen <lars@metafoo.de>,
	Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
	Rob Herring <robh+dt@kernel.org>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>, Heiko Stuebner <heiko@sntech.de>,
	Andy Shevchenko <andy.shevchenko@gmail.com>,
	Alex Dewar <alex.dewar90@gmail.com>,
	Gene Chen <gene_chen@richtek.com>,
	Saravanan Sekar <sravanhome@gmail.com>,
	Lee Jones <lee.jones@linaro.org>,
	linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] dt-bindings: iio: adc: devicetree bindings for texas instruments ads7142 iio driver
Date: Mon, 3 May 2021 11:30:08 +0100	[thread overview]
Message-ID: <20210503113008.751560b1@jic23-huawei> (raw)
In-Reply-To: <20210502211020.GB32610@dev>

On Sun, 2 May 2021 21:10:20 +0000
József Horváth <info@ministro.hu> wrote:

Hi József,

> >   
> > > +
> > > +  "#address-cells":
> > > +    const: 1
> > > +
> > > +  "#size-cells":
> > > +    const: 0
> > > +
> > > +  "#io-channel-cells":
> > > +    const: 1
> > > +
> > > +  ti,osc-sel:
> > > +    description: |
> > > +      If present, the driver selects the high speed oscillator.
> > > +      See chapter 7.3.5 Oscillator and Timing Control in datasheet.
> > > +    type: boolean  
> > 
> > This looks connected to the possible sampling frequencies when in various autonomous modes.
> > Should it be controlled by userspace?  
> 
> The sampling frequency is controlled with the osc-sel and n-clk.
> I'll remove n-clk from sysfs.

Not sure I follow that.  I think we should only have these controlled via
sysfs.  It will be a bit complex as two related controls, but that is a common situation
and there is usually a sensible combination of options that makes sense.

For example, if we can meet the sampling frequency requested with the lower
power oscillator we go for that.

> 
> >   
> > > +
> > > +  ti,n-clk:
> > > +    description: |
> > > +      nCLK is number of clocks in one conversion cycle.
> > > +      See chapter 7.3.5 Oscillator and Timing Control in datasheet.  
> > 
> > Sounds like a policy decision for userspace.
> >   
> > > +    $ref: /schemas/types.yaml#/definitions/uint32
> > > +    maximum: 255
> > > +    minimum: 0
> > > +
> > > +  ti,monitoring-mode:
> > > +    description: |
> > > +      If present, the driver selects the autonomous monitoring mode with pre alert data.
> > > +      See chapter 7.4 Device Functional Modes in datasheet.  
> > 
> > As mentioned in the driver review, this looks like something we should control from userspace
> > not dt to me.
> >   
> 
> I would keep this here, but it will be an enum.

Sorry, but no.  As mentioned in the driver thread, this doesn't sound like
a characteristic of the hardware (board etc) so it doesn't belong in DT.
It may be challenging to implement an interface that makes sense, but
that doesn't mean we can avoid doing it.

> 
> > > +    type: boolean
> > > +
> > > +patternProperties:
> > > +  "^channel@[0-1]$":
> > > +    $ref: "adc.yaml"
> > > +    type: object
> > > +    description: |
> > > +      Represents the external channels which are connected to the ADC.
> > > +    properties:
> > > +      reg:
> > > +        description: |
> > > +          The channel number.
> > > +        items:
> > > +          minimum: 0
> > > +          maximum: 1
> > > +      "ti,threshold-falling":
> > > +        description: The low threshold for channel  
> > 
> > For these, we need a strong argument presented in this doc for why they are not
> > a question of policy (and hence why they should be in dt at all).  
> 
> I'll remove all threshold and hysteresys from dt.
> 
> >   
> > > +        $ref: /schemas/types.yaml#/definitions/uint32
> > > +        maximum: 4095
> > > +        minimum: 0
> > > +      "ti,threshold-rising":
> > > +        description: The high threshold for channel
> > > +        $ref: /schemas/types.yaml#/definitions/uint32
> > > +        maximum: 4095
> > > +        minimum: 0
> > > +      "ti,hysteresis":
> > > +        description: The hysteresis for both comparators for channel
> > > +        $ref: /schemas/types.yaml#/definitions/uint32
> > > +        maximum: 63
> > > +        minimum: 0
> > > +
> > > +    required:
> > > +      - reg
> > > +
> > > +    additionalProperties: false
> > > +
> > > +allOf:
> > > +  - if:
> > > +      required:
> > > +        - ti,monitoring-mode
> > > +    then:
> > > +      required:
> > > +        - interrupts
> > > +
> > > +required:
> > > +  - compatible
> > > +  - "#io-channel-cells"
> > > +
> > > +additionalProperties: false
> > > +
> > > +examples:
> > > +  - |
> > > +    i2c {
> > > +      #address-cells = <1>;
> > > +      #size-cells = <0>;
> > > +      adc@18 {  
> > 
> > I would not bother having two examples.  The second one covers more things afterall
> > and the binding makes it clear what is required.
> >   
> 
> I do this because of the conditional requirement of interrupts.

Understood, but that is clearly expressed by the 'required' above.
It's easy enough to understand how to not have parts that aren't
required without an example.

> 
> > > +        compatible = "ti,ads7142";
> > > +        reg = <0x18>;
> > > +        #address-cells = <1>;
> > > +        #size-cells = <0>;
> > > +        #io-channel-cells = <1>;
> > > +
> > > +        vref-supply = <&vdd_3v3_reg>;
> > > +        power-supply = <&vdd_1v8_reg>;
> > > +
> > > +        channel@0 {
> > > +          reg = <0>;
> > > +        };
> > > +
> > > +        channel@1 {
> > > +          reg = <1>;
> > > +        };
> > > +      };
> > > +    };
> > > +  - |
> > > +    i2c {
> > > +      #address-cells = <1>;
> > > +      #size-cells = <0>;
> > > +      adc@1f {
> > > +        compatible = "ti,ads7142";
> > > +        reg = <0x1f>;
> > > +        #address-cells = <1>;
> > > +        #size-cells = <0>;
> > > +
> > > +        #io-channel-cells = <1>;
> > > +
> > > +        vref-supply = <&vdd_3v3_reg>;
> > > +        power-supply = <&vdd_1v8_reg>;
> > > +
> > > +        interrupt-parent = <&gpio>;
> > > +        interrupts = <7 2>;
> > > +
> > > +        ti,monitoring-mode;
> > > +
> > > +        channel@0 {
> > > +          reg = <0>;
> > > +          ti,threshold-falling = <1000>;
> > > +          ti,threshold-rising = <2000>;
> > > +          ti,hysteresis = <20>;
> > > +        };
> > > +
> > > +        channel@1 {
> > > +          reg = <1>;
> > > +          ti,threshold-falling = <100>;
> > > +          ti,threshold-rising = <2500>;
> > > +          ti,hysteresis = <0>;
> > > +        };
> > > +      };
> > > +    };
> > > +...
> > > +  
> >   


  reply	other threads:[~2021-05-03 10:29 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-01 18:24 [PATCH 1/2] iio: adc: driver for texas instruments ads7142 Jozsef Horvath
2021-05-01 18:25 ` [PATCH 2/2] dt-bindings: iio: adc: devicetree bindings for texas instruments ads7142 iio driver Jozsef Horvath
2021-05-02 17:22   ` Jonathan Cameron
2021-05-02 21:10     ` József Horváth
2021-05-03 10:30       ` Jonathan Cameron [this message]
2021-05-03 19:42         ` József Horváth
2021-05-02 17:14 ` [PATCH 1/2] iio: adc: driver for texas instruments ads7142 Jonathan Cameron
2021-05-02 20:48   ` József Horváth
2021-05-03 10:26     ` Jonathan Cameron
2021-05-03 19:33       ` József Horváth

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=20210503113008.751560b1@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=alex.dewar90@gmail.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=gene_chen@richtek.com \
    --cc=heiko@sntech.de \
    --cc=info@ministro.hu \
    --cc=lars@metafoo.de \
    --cc=lee.jones@linaro.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmeerw@pmeerw.net \
    --cc=robh+dt@kernel.org \
    --cc=sravanhome@gmail.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).