From patchwork Mon Apr 23 21:08:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Rosin X-Patchwork-Id: 903169 Return-Path: X-Original-To: incoming-dt@patchwork.ozlabs.org Delivered-To: patchwork-incoming-dt@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=devicetree-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=axentia.se Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=axentia.se header.i=@axentia.se header.b="bl3Cq2V6"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40VJwC0W4qz9s02 for ; Tue, 24 Apr 2018 07:08:27 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932163AbeDWVIY (ORCPT ); Mon, 23 Apr 2018 17:08:24 -0400 Received: from mail-he1eur01on0114.outbound.protection.outlook.com ([104.47.0.114]:9689 "EHLO EUR01-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932157AbeDWVIX (ORCPT ); Mon, 23 Apr 2018 17:08:23 -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=1bwCuGGD1IZFDBX7uPOR8e9isCFZL5XDzXbX2TklDcs=; b=bl3Cq2V6ygGTI11ud7zPhEUnfewQ6E+oAxm2g88vUHRI95h06V4/sK36g9fYfmQr92jM4KaYPdIekwfM0cfkPwbFyPOOEPdMBqxM4Xlr4bwEPR3LQtx2ZdI12ZjeB5F9SQi6SW+QeQShcfTGCjJnBV2yJ9i6BAImhJCBQdjSgmw= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=peda@axentia.se; Received: from orc.pedanet (85.226.244.23) by HE1PR0202MB2779.eurprd02.prod.outlook.com (2603:10a6:3:e8::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.696.13; Mon, 23 Apr 2018 21:08:17 +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" , Greg Kroah-Hartman , Mauro Carvalho Chehab , Linus Walleij , Andrew Morton , Randy Dunlap , "Andrew F . Davis" , Fabio Estevam , linux-iio@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v4 0/4] iio: add unit-converter Date: Mon, 23 Apr 2018 23:08:05 +0200 Message-Id: <20180423210809.29586-1-peda@axentia.se> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 X-Originating-IP: [85.226.244.23] X-ClientProxiedBy: CWLP265CA0150.GBRP265.PROD.OUTLOOK.COM (2603:10a6:401:52::18) To HE1PR0202MB2779.eurprd02.prod.outlook.com (2603:10a6:3:e8::21) X-MS-PublicTrafficType: Email X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(7021125)(5600026)(4534165)(7022125)(4603075)(4627221)(201702281549075)(7048125)(7024125)(7027125)(7028125)(7023125)(2017052603328)(7153060)(7193020); SRVR:HE1PR0202MB2779; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0202MB2779; 3:+m2xlZLgj7fCJhrqzum9x1rZ8tAMz5NNhL0/ga3TaM/UlbMcSxsLZi2PArn+sLAAd2j1gJW989MqIO7VUTqP85sxTbq5htyCPlICynCoGN+dnrmrmJRwIMzX3XaP5/x3QbLtcbykrN9pmmgFs9Nep4LyMoTo7rgPh7FDFUQVPnOclrbCyM+HTl9ZHILdr8MxMOfx+ZfK2uzDaUO4PUnsVxzSbhLATK0qY1+4xb6ZH36dYsEC0rMSaWjqUICFxtkY; 25:Dv9cEiS7rAX5KxV9Ei+kCDfDb6zq4EMwerqfEKuvFie8EuIECcHXED9qDeIlpAj7d7bksyydVgxMTrT8T39/xnQcMhpgDjD7uTgIMMR2wtyS9pWpU/Ve2DBm/IQU/KaCVKuzRQ57oCxXoaVi+dWIb1iwWxW2KPjYEGZ9c7bf2vepMmXo9jP+vLyn1x8cv2u1IVJBdzk9QxFn488ASmp8joL9fMZ9A5qlvMS7k7FEMdXk61xghcnHkjieWWDlOq9JHWPJbGJNvMbwHcFXy76LkSBF05vECfBkq4LJoUMyPlVsrEvMphCUSVFaXyGcRzkFvZYOSru+/vFGB6Hvpfhwtg==; 31:nQYJhuhtFJVd9BPD6wLkXK8+5etFX3A6SUMlWTl2PvIWvm2lg8kxeeI4BeUGL+z0HmMh+w7FVmM/HiAiDoLUEPujUugQMoHBB6uWYiWKPsWQbMNc1nF38eVyO+yeuzk+9nCyw4u7Q9Xs0U7/ZbRRNoKpzy3sn7GBw7QrWvkgeXnMLCtZvr4VJimcknayVinKLy2/a6buG5qRMNifDXQiXIj2WaWuYARWuKjebRQ2YaY= X-MS-TrafficTypeDiagnostic: HE1PR0202MB2779: X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(788757137089); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(8121501046)(5005006)(3231232)(944501410)(52105095)(3002001)(10201501046)(93006095)(93001095)(6041310)(20161123560045)(20161123558120)(20161123562045)(2016111802025)(20161123564045)(6072148)(6043046)(201708071742011); SRVR:HE1PR0202MB2779; BCL:0; PCL:0; RULEID:; SRVR:HE1PR0202MB2779; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0202MB2779; 4:vp+7UBAJfKuTH0BlRwuuBlIXTrmPEXEZq+ovteDZU4bVsrEKrhoDaODuu+Il5+iWV44VEoB2S/VOJl7tHhktfuRa/osd90MdqQlYdpOCECf6Ph7odNkzSwX853xmnu66aT6yu9Psgy/3srSxax1HNCXbZmY4DMTFmmbH7tECru4pHlWTitcq38X9UHWD4QEJo+nVANuLQjKhytf3ZfKdt2l2k77VwT36GzFgsyn/sWCm5kBly+a3PTocwgM4Z6fudcT1QOpXG4OhET10tYspf+9NuRTu7LeI6uwZaHG0ADRf39Hl8wjJ/jPeksFvaD+6 X-Forefront-PRVS: 06515DA04B X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(366004)(39840400004)(376002)(396003)(39380400002)(346002)(7736002)(5660300001)(8676002)(81166006)(305945005)(53936002)(25786009)(4326008)(8666007)(6512007)(39060400002)(6306002)(956004)(51416003)(2616005)(386003)(52116002)(54906003)(6506007)(8936002)(50226002)(86362001)(476003)(316002)(36756003)(16586007)(966005)(26005)(2906002)(1076002)(59450400001)(6116002)(16526019)(3846002)(186003)(478600001)(7416002)(48376002)(6666003)(6916009)(66066001)(6486002)(47776003)(2361001)(2351001)(74482002)(50466002)(42262002); DIR:OUT; SFP:1102; SCL:1; SRVR:HE1PR0202MB2779; H:orc.pedanet; FPR:; SPF:None; LANG:en; MLV:ovrnspm; PTR:InfoNoRecords; Received-SPF: None (protection.outlook.com: axentia.se does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HE1PR0202MB2779; 23:cYtK0+1E27n17UT6IIfUjlTtmDuWVkz9Z4vfw14?= LdC7li5qWlNwKZV43VnriG8zCL/KQ2X70vAIckFMFgQWxlMnUvg7ef5j8LtcNSW0q6jQnyGbYRo6C3AWq4IPJ5Da5mj8tYO6SELc6AScQ2lBYdZnpycysF743kMKBvyDMQy4IHxCZArub4ptYcbP2UMiviaDi0k8Q6oGOBCdEUWsmmEW79h+g7G6/7CUR4n20gXSSiCpolhOeV6RkEN8A7IhnmeeufhPiEcOIGZRgCbAtoUzly0L1rlXvu0+EX5YRs/EzIWTFsVJVaGwSavX0zTdAVCIeMz1ntN69pRAvgRtu7Rh5DKWm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Microsoft-Exchange-Diagnostics: 1; HE1PR0202MB2779; 6:Ru3zBOtFQf8xQSYQGiswp08HQDNYq0BMx8/MZ74LjO1ytmCFn/P9vPV5agT6DcH8nmJ9/BEJ8/b7tWq35E21FrxTaMV8gNNiU02MFP9XJokItDYqdszAMWqPbvGA2w97snXlPS45Gr+4HRTM2hyyJ1KfdV2XJvhurHlGgGvZj905UphhyhSY+jLWxOpGbAgz6zNpF71n5wibymAA6DR5N95RcsfPWc1tTVOKiXcxvhfYl4Ps9h/CnUUlUx7y2XFqOsi9vniKZQyaebRLs4UsApeFVwFg0zpMqLzjKZypo7CILrNpBBqicKif51RrY8lLYHgjStdaaybzUKaiXDcOs5Snr9T1ePrDXTPUPN/G2DLH2VacZFnqndLvw8KzPVXPcLJMA+ZTSMKpJeMwb7YDqxPXmbv2dGXAdSOPw8+HHs7BZOhyOJ2NifHlUg9D4GlNwPoV2LkN8ASOlKDrzB+eoA==; 5:6NalQyQc33MinBe4kfz9P+6KKbn6RgkXXNPGQ2r46HpIdQlAdCo3+0pmellBtO4GPM58g7HnXUx7T3Q32GOQlNpWMok26uxuNYj/jr2VphARTUlb1lodWRlPMy2whgH/1BHZPX4uNIDLrU0u25lyP70BBi0pTB0uRwo3ZRJfK68=; 24:cU7kvVYgvAgf3POqFwMC8GEyLmEFtDpHUYNpH8kPpYhrWalmf+NkF9tcfFNZaxUg471QFNHoATme6KaWsYNvqke72nWlQLBQnRo7Leo/o30= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; HE1PR0202MB2779; 7:d/9dVIJfzjNCpRqGeKoXQkmLxelbTEsyvST3ISLjy3jBTaJrsILIuqZD77By/cXaFFBD0MFOteEUFphkE+VhIAtVBis9qoK/c7poSyQ1Yaye/01w/QGjhO+HQSwcyn6ay8sxVN1dZ9SA3gKtNMc44fCg4mCY59IezAawxUZgRR285Nnsn/ojoQf+VW4PfeVaEIKreyYfMbpSv5cCjk4Mt/42F55LEbaaYQJpSDuX3LscI96zJsA3mh5ffRj3STJn X-MS-Office365-Filtering-Correlation-Id: 9b392979-8225-4042-c2da-08d5a95e56b0 X-OriginatorOrg: axentia.se X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Apr 2018 21:08:17.4706 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9b392979-8225-4042-c2da-08d5a95e56b0 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4ee68585-03e1-4785-942a-df9c1871a234 X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0202MB2779 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Hi! This driver implements support for voltage dividers, current sense shunts and current sense amplifiers. It's pretty generic and should be easily adaptable to other linear scaling purposes. Cheers, Peter Changes since v3: https://lkml.org/lkml/2018/4/10/614 - Split the bindings patch for voltage-divider and current-sense-shunt in two, thus retaining the tag from Rob on the latter, when the former got a major update. The voltage-divider binding is now clear of its history from the generic io-channel-unit-converter binding roots (v1 of the series) and makes much more sense on its own (IMHO). - Incorporate the confusing followup patches that added current sense amplification to the series. - Drop the adi,lt6106 binding from that followup and replace it with a generic current-sense-amplifier binding. - Adjust the driver to the above, and also rename it to iio-rescale as unit-converter was perhaps a little bit too generic even for the driver name. Changes since v2: https://lkml.org/lkml/2018/4/3/461 - Rename from current-sence-circuit to current-sense-shunt (this should also fix all the typing problems I had with curciut). - Describe the shunt resistance directly (instead of indirectly in the form of a quotient). - Add a ->props() op to struct unit_converter_cfg to enable simple separation of properties for different converters. - Shuffle the code around to minimize forward declarations. - Drop the unused indio member from struct unit_converter. - Drop error report on iio driver registration failure. Changes since v1: https://lkml.org/lkml/2018/3/19/801 - Put the driver in the new afe category (Analog Front Ends) and do not move the iio-mux driver. - Do not refer to the source channel as "parent", use "source" instead. - Have the DT compatible drive the target unit, instead of relying on a "type" DT-property for that. - In the DT bindings, use an unnamed source channel. - Do not set up writes to _RAW (sorry Phil) as I don't need it and have not tested it. It's easy to add back if needed. - Fail if the source channel does not support _RAW or _SCALE. - Fix various spelling issues. - Fix various code style issues. Peter Rosin (4): dt-bindings: iio: afe: add binding for current-sense-shunt dt-bindings: iio: afe: add binding for voltage-divider dt-bindings: iio: afe: add binding for current-sense-amplifier iio: afe: rescale: new driver .../bindings/iio/afe/current-sense-amplifier.txt | 26 ++ .../bindings/iio/afe/current-sense-shunt.txt | 41 +++ .../bindings/iio/afe/voltage-divider.txt | 53 +++ MAINTAINERS | 9 + drivers/iio/Kconfig | 1 + drivers/iio/Makefile | 1 + drivers/iio/afe/Kconfig | 19 ++ drivers/iio/afe/Makefile | 6 + drivers/iio/afe/iio-rescale.c | 359 +++++++++++++++++++++ 9 files changed, 515 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/afe/current-sense-amplifier.txt create mode 100644 Documentation/devicetree/bindings/iio/afe/current-sense-shunt.txt create mode 100644 Documentation/devicetree/bindings/iio/afe/voltage-divider.txt create mode 100644 drivers/iio/afe/Kconfig create mode 100644 drivers/iio/afe/Makefile create mode 100644 drivers/iio/afe/iio-rescale.c