Received: by 10.213.65.68 with SMTP id h4csp1237519imn; Sat, 24 Mar 2018 07:08:05 -0700 (PDT) X-Google-Smtp-Source: AG47ELsX3HlWqSxY8gNYAnNpm0qjSkuR4ew8doLO20M2kGvPMZ91RMf3B+7h8HLblTlVH7NxevZR X-Received: by 10.99.125.87 with SMTP id m23mr23221832pgn.297.1521900485165; Sat, 24 Mar 2018 07:08:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521900485; cv=none; d=google.com; s=arc-20160816; b=LR2vv4H261hLwuDjf1WKIoxehIdCkvFOuYm7MXbJfjtNkKr2r5XBdJDEV8kuX7sNFv Jfl+ajQn62nXePdW9YeI8fZLLIrx5YhWX0b14RwjkT5XgLSrKkfLbSekY23h+pfjXSIl sgY97DNI4pR5q1ryrJU3qsG2FMniaXxIntbjfcm2k6QvbHUIq5Sf8mj6ik1c//riRFUx 5DUP/7JpnCSEAr+HgTm1KaQ4eCRAuTctVidt/iddXMcsv5iP6cNSCGuc5DX6ZtM+VWVD BpaEX4qv50I5B280xC9wH/kg+es8YCuuuKGTOTW3ZRBL4CXdZthUkLWJpVLOughpzhvQ VUVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :arc-authentication-results; bh=aVHH283nd6O2jWVHdOqDypY6b8ZCW4hOxN0oUJuWvpQ=; b=VoXnGlYeCOtDBx4/0MEmV1k5UWERM7siBJyOgC95erUFFdG2WsGQBhXdlkJvqu5LgV 5Tb2ejIBdpBTClij5LS1nhlAw5IDpqlVb/4IvGdku/ckhZG7T5e28/O5afe1HWMGhq4v RQQb7Xuhcy85USqlfxtGJ0HBYqfvpJKomZJruN7BD7+YI4KThbW3bLCzvE5Jmq3t7owQ gjwbuYRxx81Gqj3jInkBZOvqFfljNEtoU3YLXdiuvwvvJ77r/uWA5WbLyWBrz5KY/W2r piRRrQUN/K0C2Dazxg/b78kFCFCiMKzTZ87X9d1MtCaGVr4DYIAybd+CfmCbd8AqjMeQ fHEw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y15si7661320pgs.71.2018.03.24.07.07.50; Sat, 24 Mar 2018 07:08:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752125AbeCXOGz (ORCPT + 99 others); Sat, 24 Mar 2018 10:06:55 -0400 Received: from saturn.retrosnub.co.uk ([46.235.226.198]:40754 "EHLO saturn.retrosnub.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751891AbeCXOGx (ORCPT ); Sat, 24 Mar 2018 10:06:53 -0400 Received: from archlinux (cpc91196-cmbg18-2-0-cust659.5-4.cable.virginm.net [81.96.234.148]) by saturn.retrosnub.co.uk (Postfix; Retrosnub mail submission) with ESMTPSA id 7BB339E6A6C; Sat, 24 Mar 2018 14:06:49 +0000 (GMT) Date: Sat, 24 Mar 2018 14:06:48 +0000 From: Jonathan Cameron To: Peter Rosin Cc: linux-kernel@vger.kernel.org, Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Rob Herring , Mark Rutland , "David S. Miller" , Mauro Carvalho Chehab , Greg Kroah-Hartman , Linus Walleij , Randy Dunlap , linux-iio@vger.kernel.org, devicetree@vger.kernel.org Subject: Re: [PATCH 2/3] dt-bindings: iio: wrapper: add io-channel-unit-converter Message-ID: <20180324140648.116b6b00@archlinux> In-Reply-To: <20180324135319.4ba6ce92@archlinux> References: <20180319170246.26830-1-peda@axentia.se> <20180319170246.26830-3-peda@axentia.se> <20180324135319.4ba6ce92@archlinux> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 24 Mar 2018 13:53:19 +0000 Jonathan Cameron wrote: > On Mon, 19 Mar 2018 18:02:45 +0100 > Peter Rosin wrote: > > > Allow linear scaling and modification of the type of an io-channel. > > > > When an ADC channel measures the midpoint of a voltage divider, the > > interesting voltage is often the voltage over the full resistance > > of the divider. Likewise, measuring the voltage over a resistor is > > often a way to get to the current through it. > > > > This binding allows description of such hardware which is external > > to the ADC. > > > > Signed-off-by: Peter Rosin > > --- > > .../iio/wrapper/io-channel-unit-converter.txt | 84 ++++++++++++++++++++++ > Hmm. I'm not convinced by the naming really though I can see where you care > coming from as it can effectively use a voltage ADC to measure a current. > > Lets see if the devicetree people or anyone else has a suggestion on this. > > Could go with AFE as that is how a chip doing this would normally be described. > It's just that here we are doing it in old fashioned resistors... > > There are a few unusual elements in here binding wise so definitely looking > for input on the bindings! > > Thanks, > > Jonathan > > > MAINTAINERS | 6 ++ > > 2 files changed, 90 insertions(+) > > create mode 100644 Documentation/devicetree/bindings/iio/wrapper/io-channel-unit-converter.txt > > > > diff --git a/Documentation/devicetree/bindings/iio/wrapper/io-channel-unit-converter.txt b/Documentation/devicetree/bindings/iio/wrapper/io-channel-unit-converter.txt > > new file mode 100644 > > index 000000000000..23af661abe32 > > --- /dev/null > > +++ b/Documentation/devicetree/bindings/iio/wrapper/io-channel-unit-converter.txt > > @@ -0,0 +1,84 @@ > > +I/O channel unit converter bindings > > + > > +Allow linear scaling and modification of the type of an io-channel. > I can certainly conceive that we will have simple non linear cases in future > though they get awfully hard to describe so we can tackle that when it > happens. > > > + > > +When an ADC channel measures the midpoint of a voltage divider, the > > +interesting voltage is often the voltage over the full resistance > > +of the divider. Likewise, measuring the voltage over a resistor is > > +often a way to get to the current through it. > > + > > +Required properties: > > +- compatible : "io-channel-unit-converter" > > +- io-channels : Channel node of the parent channel. > > +- io-channel-names : Should be "parent". > > + > > +Optional properties: > > +- numerator : The parent channel scale is multiplied by this value (default 1). > > +- denominator : The parent channel scale is divided by this value (default 1). > > +- type : The type of the wrapped channel is modified to this type. The default > > + is to use the same type as the parent channel. Recognized types are: > > + "voltage" > > + "current" > > + > > +Example 1: > > +The system voltage is circa 12V, but divided down with a 22/200 > > +voltage divider to adjust it to the ADC range. > > + > > +SYSV ADC GND > > + + + + > > + | .-----. | .----. | > > + '--| 200 |-+-| 22 |--' > > + '-----' '----' > > + > > +sysv { > > + compatible = "io-channel-unit-converter"; > > + io-channles = <&maxadc 1>; > > + io-channel-names = "parent"; > > + > > + /* multiply the ADC voltage by 222/22 to get the system voltage */ > > + numerator = <222>; /* 200 + 22 */ > > + denominator = <22>; > > +} > > + > > +&spi { > > + maxadc: adc@0 { > > + compatible = "maxim,max1027"; > > + reg = <0>; > > + #io-channel-cells = <1>; > > + interrupt-parent = <&gpio5>; > > + interrupts = <15 IRQ_TYPE_EDGE_RISING>; > > + spi-max-frequency = <1000000>; > > + }; > > +}; > > + > > +Example 2: > > +The system current is measured by measuring the voltage over a > > +3.3 ohm resistor. > > + > > +sysi { > > + compatible = "io-channel-unit-converter"; > > + io-channles = <&tiadc 0>; io-channels and same above. > > + io-channel-names = "parent"; > > + > > + /* divide the ADC voltage by 33/10 (i.e. 3.3) to get current */ > > + numerator = <10>; > > + denominator = <33>; > > + type = "current"; > > +} > > + > > +&i2c { > > + tiadc: adc@48 { > > + compatible = "ti,ads1015"; > > + reg = <0x48>; > > + #io-channel-cells = <1>; > > + > > + #address-cells = <1>; > > + #size-cells = <0>; > > + > > + channel@0 { /* IN0,IN1 differential */ > > + reg = <0>; > > + ti,gain = <1>; > > + ti,datarate = <4>; > > + }; > > + }; > > +}; > > diff --git a/MAINTAINERS b/MAINTAINERS > > index 96e5503bfb60..5dd555c7b1b0 100644 > > --- a/MAINTAINERS > > +++ b/MAINTAINERS > > @@ -6884,6 +6884,12 @@ F: drivers/staging/iio/ > > F: include/linux/iio/ > > F: tools/iio/ > > > > +IIO UNIT CONVERTER > > +M: Peter Rosin > > +L: linux-iio@vger.kernel.org > > +S: Maintained > > +F: Documentation/devicetree/bindings/iio/wrapper/io-channel-unit-converter.txt > > + > > IKANOS/ADI EAGLE ADSL USB DRIVER > > M: Matthieu Castet > > M: Stanislaw Gruszka > > -- > To unsubscribe from this list: send the line "unsubscribe linux-iio" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html