From patchwork Mon Mar 19 17:02:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Rosin X-Patchwork-Id: 10293359 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7077A600F6 for ; Mon, 19 Mar 2018 17:04:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5F8BE2947A for ; Mon, 19 Mar 2018 17:04:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 541E529480; Mon, 19 Mar 2018 17:04:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 657F82947A for ; Mon, 19 Mar 2018 17:04:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935149AbeCSREC (ORCPT ); Mon, 19 Mar 2018 13:04:02 -0400 Received: from mail-eopbgr40097.outbound.protection.outlook.com ([40.107.4.97]:58137 "EHLO EUR03-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S967771AbeCSRDJ (ORCPT ); Mon, 19 Mar 2018 13:03:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axentia.se; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=i5/NejLF4XGn2i0rVul3vjTViH1ZChEn33tyyhmybcA=; b=i8BiOWlt1/whLm9W/xgvfnhXVv5seh4hakFbafDdLO61TKxxBQ+L1qOY7G3TximvhsZPOVbAJEazLDMyeYeu5Az25T+CJHEfssO5iYUizOR3j09F7O5PKuxPyae2rzKVrS3yoQGMzdQcJB2oyqdyNs+RqSCjrWuz6NmfMDFc04w= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=peda@axentia.se; Received: from orc.pedanet (85.226.244.23) by AM4PR0202MB2769.eurprd02.prod.outlook.com (2603:10a6:200:8c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.588.14; Mon, 19 Mar 2018 17:03:06 +0000 From: Peter Rosin To: linux-kernel@vger.kernel.org Cc: Peter Rosin , Jonathan Cameron , 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: [PATCH 2/3] dt-bindings: iio: wrapper: add io-channel-unit-converter Date: Mon, 19 Mar 2018 18:02:45 +0100 Message-Id: <20180319170246.26830-3-peda@axentia.se> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180319170246.26830-1-peda@axentia.se> References: <20180319170246.26830-1-peda@axentia.se> MIME-Version: 1.0 X-Originating-IP: [85.226.244.23] X-ClientProxiedBy: HE1P190CA0048.EURP190.PROD.OUTLOOK.COM (2603:10a6:7:52::37) To AM4PR0202MB2769.eurprd02.prod.outlook.com (2603:10a6:200:8c::19) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c7d876a0-a86f-4987-8965-08d58dbb4941 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(7021125)(5600026)(4604075)(4534165)(7022125)(4603075)(4627221)(201702281549075)(7048125)(7024125)(7027125)(7028125)(7023125)(2017052603328)(7153060)(7193020); SRVR:AM4PR0202MB2769; X-Microsoft-Exchange-Diagnostics: 1; AM4PR0202MB2769; 3:Vla372PF7EwSq17jUkM71TRzBwvfRQxMWeHOmeZTq/5YoqfwzQEuqWVYf6YBxxN8YhvjopwemieA4GAfUJHYDxDS2TwN0bn3HFavG+CYRgAbgSZ0J3e+3tIJ19PDrNUmxQ6MIU/uoRLeE/QvxGGQTqrI94YoTMrH6p5kIf6zqt3ZC0o6lZf03FoP3GqfdH6syt+wPIdgoh8+Zwora5QuZ9YCRK+SUEZEYjbZTYaFcXkkiLHxlE+20OabT+ozKmEG; 25:f5CG3vS6XBmFvpb1DzABOq+m56EqHnCl7Q6iNfjhHH/0a3h4+gh1iZy1Hnhxxpt7ksCCiB0eGiS8idZ0a3OKfiaODfL1oBAZLc2QQt7klPAEIT7LoPtd7xJcwrvEHgk5qpb41YLMla4remA38ie8HBy5xsF2XSZdMMT4Yow2G/59ykAhvoU6DoX0/G8pKKhppL7bIpISHhU3vf1TSUFzz/nC+qZnHiMMc1+eObopvPze4XPLe+dYR08YvWG246KyaB1RRacEKtF0GEu6pVUrtvwDNukPKed172ne/aDm2ppdcAm+PKYm5pSuu6dBXpIHLTnWqqV1glx4LKX7pLnBXA==; 31:ilh0NNNuSiNRWz4GD2NfiIxibPYThGJiEfqh4+XtP2Taf/NpAtInCzW7sAAd5GeXhzabmz9dUk8bfG0iPQ32AyPJA5mo9qDKoF5qPZYRwkLGME2ZBYzb+ymrVuHofTvLi6L1/CP+EOEVj051etRrnhTb1S+bKK8Dz0iYuGWSqDhOIi7xUIBHQFviJMUvXJ4WHTDCYQyBl+32X/7/LnVbdIFZQiyceHs+WuGDdqgXc7M= X-MS-TrafficTypeDiagnostic: AM4PR0202MB2769: X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(191636701735510)(9452136761055); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(3002001)(3231221)(944501300)(52105095)(10201501046)(6041310)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(2016111802025)(6072148)(6043046)(201708071742011); SRVR:AM4PR0202MB2769; BCL:0; PCL:0; RULEID:; SRVR:AM4PR0202MB2769; X-Microsoft-Exchange-Diagnostics: 1; AM4PR0202MB2769; 4:YJoJT8wy8KhXidfnTetIvB/QSZNTTRc+8maNC+zB+qast4keEwp7mH6hfh1qSoGBREcIjz3YEJ5ZEZX+os+efvwH5FxxNx3sU+me1+GR/+TTAAPlno/YTHuPYDPXzyI0TxbhEwPjv9rOVsnfDlfLVnp77+IKtSDoALDcZvkbvklr8s82XEBJDbBJKLcOw79DWDEFABizkKCYWNo25MgXjC/g16DIy0myrbeCZblkSxckJJ4mouwJ451qT4kDp94C1w3B/P3zO9IiRo6DapKY8vaNPzvn/0N5KlzyhcInuRcWcSeBpu56gSFZFqnXNLk6fXK9zu7k0T8F/1zZxipYq8P29qK6nH2QXeCuikeMYh8= X-Forefront-PRVS: 06167FAD59 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(366004)(376002)(396003)(39830400003)(39380400002)(346002)(199004)(189003)(76176011)(36756003)(48376002)(68736007)(50466002)(50226002)(66066001)(8936002)(6486002)(53936002)(51416003)(8666007)(52116002)(6512007)(7736002)(305945005)(105586002)(478600001)(3846002)(6116002)(2351001)(1076002)(2361001)(97736004)(6666003)(6916009)(54906003)(2950100002)(16586007)(74482002)(26005)(2906002)(4326008)(7416002)(386003)(6506007)(86362001)(81166006)(81156014)(8676002)(47776003)(16526019)(25786009)(186003)(316002)(5660300001)(106356001)(42262002)(15866825006); DIR:OUT; SFP:1102; SCL:1; SRVR:AM4PR0202MB2769; H:orc.pedanet; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: axentia.se does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM4PR0202MB2769; 23:E1TISt3YqhoZwdc0juGOXFo3BfEPRw8FuKrHKSV?= =?us-asc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BdC3jJL8odiTp9aG/FOYY2KvEtTLR8=; 5:wgTlMpMFNsIZDFihRmtX1s1G53MT0cskYL0xa7NFRcf0VF1WxLHqGUoz3g4SGNFm6Es6os2m3XsaM6rLgTcNmcAEHewvRmnmetGAIGvmy4jXvw+ZiRnHNil7cIFprLGj/bfmMdkDzQWkKndOKExG5q1+vfAlNYlSAPjqO43tHEY=; 24:99BXMicWiJftvIXsMykPVcNXwdwFXL9iNGxxGsCQ/xKd/bLzaez25/zMz1ZqJ6prBAysCmJB054Y7GJWHWlFrLJI9Zl2TKhhhoh8r/BKLFk=; 7:ltE98YGUiTmWDdlv18mVaKhVNoq8MDCMfO15amJFLko7gqgUwaTTY+/hrUInz1c3Ds4r6Tl8ZM6n2BaTON4EuULvcev5zstyBW/lCEHVhlwtZ/V9lsKQaU+Vpem0CpCHtwM+DRYSLe0rOgG0r96DQ3Ion6ExX4WeWDIggZDShfrxbEEOnbjmKRG+DVp+AInDIgPPEkgoGdwS+McI9nIttoHKuCrWDOmzSqyh9NzLQV9z3K7a098juOrDmYwXg1FC SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: axentia.se X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Mar 2018 17:03:06.1118 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c7d876a0-a86f-4987-8965-08d58dbb4941 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4ee68585-03e1-4785-942a-df9c1871a234 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR0202MB2769 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 ++++++++++++++++++++++ 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. + +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-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