Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756959AbcJXBOM (ORCPT ); Sun, 23 Oct 2016 21:14:12 -0400 Received: from mail-db5eur01on0094.outbound.protection.outlook.com ([104.47.2.94]:31488 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754475AbcJXBOK (ORCPT ); Sun, 23 Oct 2016 21:14:10 -0400 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=peda@axentia.se; From: Peter Rosin To: CC: Peter Rosin , Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , "Peter Meerwald-Stadler" , Rob Herring , "Mark Rutland" , , Subject: [PATCH v3 0/8] IIO wrapper drivers, dpot-dac and envelope-detector Date: Mon, 24 Oct 2016 00:39:33 +0200 Message-ID: <1477262381-7800-1-git-send-email-peda@axentia.se> X-Mailer: git-send-email 2.1.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [217.210.101.82] X-ClientProxiedBy: DB5PR08CA0016.eurprd08.prod.outlook.com (10.163.102.154) To DB6PR0201MB2312.eurprd02.prod.outlook.com (10.169.222.151) X-MS-Office365-Filtering-Correlation-Id: d545ab6f-343b-4523-86f2-08d3fb9583c3 X-Microsoft-Exchange-Diagnostics: 1;DB6PR0201MB2312;2:zAmY5KnA6CYRwiDOzzUmyrbzWJFU3EAJDk2ecFtOKHV32GPOXL2VFR5I6OQknFrMKsPUeuKJiXeVbKjTfFbRUD8vf5xoNolONqPl5JeHm5uKEHx+ZoQs04YoyG2j3HAxpnRzYiKSWnW4ABHwn2bIoAPOl/vJcK908t1lGH1N+sU3STBp9zyOziIY3nQ7VjO/IW6mAwMtqE2ajj+7kYX+nQ==;3:GkByWIgRCmW+Ozn0/QYAVEEI8WCvd9z9pkKe8qC8m6Nf8PDu86c81OnZYNA7CTj+OETTHKrthbNileaYWFE2Fh7rtyjnIvJlKkOg2THSfa1VuTfXjB6cBsoyKmmU4uTI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D4iC8jVFDMlf5DzM9bOwVDSrBZ/c4GUk+Zihi6WQPJkaAItSY4VtcFJ1QrKO4o985yvHRjNd9VmIORD5ksLg2TrOzj7Cde7dN08rLOKwzBVlb8oqFHGZXK1cUA91lmKHf4OxGipQRhC89jmR3zGZ6Kuts4ttsxnBTq3x+UjV6pMuZ2xbdl2FzjUSov9W8SUY2Cc51xV X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040176)(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001)(6043046)(6042046);SRVR:DB6PR0201MB2312;BCL:0;PCL:0;RULEID:;SRVR:DB6PR0201MB2312; X-Forefront-PRVS: 0104247462 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(4630300001)(6009001)(6069001)(7916002)(189002)(199003)(5660300001)(68736007)(4326007)(97736004)(50226002)(5003940100001)(2906002)(77096005)(81156014)(92566002)(81166006)(8676002)(101416001)(6116002)(3846002)(586003)(86362001)(189998001)(19580395003)(66066001)(47776003)(6916009)(6666003)(7846002)(8666005)(7736002)(33646002)(50986999)(110136003)(48376002)(305945005)(50466002)(36756003)(74482002)(229853001)(2351001)(42186005)(106356001)(105586002)(7059030)(42262002);DIR:OUT;SFP:1102;SCL:1;SRVR:DB6PR0201MB2312;H:localhost.localdomain;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;DB6PR0201MB2312;23:oIFcSdTsW5p/AZesvA9CyGxoWiCWmxYSOhq9Op3?= =?us-ascii?Q?WaKUIvjCSvjgodCepLDMXCRnHHCILNNdnhn1foFsYhrwg/hpu6u1CzSFmZzS?= =?us-ascii?Q?hqhA+67T18XN6RH1X3HYp+bjW8HILJmFuHjEcL1yeVkE/wRDVA5R9u7cyAPK?= =?us-ascii?Q?4MyVhFN7psKIMG6IyyEcsnIbGBsPD+QuSPaWx180d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6nIO+Mu9j/eemL70T3KTFIgbGDKI2vLAEgVR8DaQCaPSzQyAwLPqFVmBhGXQMLDn89d3Byu+zybWv7HbH3Hfu1UmoaATiuHkpb2tj6PpmOsbVm/53KQhCg= X-OriginatorOrg: axentia.se X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Oct 2016 22:39:55.7690 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0201MB2312 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 6847 Lines: 141 Hi! These two drivers share the fact that they wrap another iio channel, and I use the first in combination with the second, which is why I'm submitting them as a pair. The first driver is a simple wrapper converting an iio dpot into an iio dac. It only changes the unit and scale. It also does not add any fancy iio buffer support that I don't need. I suppose that can be added. By someone else :-) The second driver (the envelope detector) is more involved. It also explains why I need the dpot-dac driver. I wanted the envelope detector to be generic and work with any dac, but I had a dpot... But before those two new drivers, there is some infrastructure added to provide available values for a channel. Ok, so the devicetree compatible string for the envelope-detector gained the "axentia,tse850-" prefix in v2, but at the same time the driver also gained generality that in my mind puts it in about the same position as the dpot-dac driver. The driver really has very little to do with the specifics of the TSE-850. But at the same time there are more ways to build an envelope detector compared to the obviousness of building a dac from a dpot... One thing I still don't like is that the irq needs to be changed for cases where it is only ever interesting with the 'invert' variant, and it may not work to set up the irq the wrong way first. For the TSE-850, this does not matter, since we have a mux on the envelope detector input and can make use of both 'invert' and 'normal' for different signals (we could have gotten by with only 'invert' since the only signals we are measuring that are 'normal' are also DC signals and can thus be detected both from below and from above), but it is nice to have it both ways. The only way out of this is a devicetree thing. I suppose it will have to be added by whomever needs it whenever that is... I also wonder if the "new" *_available ABI should perhaps be documented for all variants directly in sysfs-bus-iio instead of doing it ina driver specific maner that I did? But that can be fixed later by someone more capable than me :-) v2 -> v3 - add some missing @foo comments in iio.h in the initial forward ported patch - killed some buffer overflow problems in the initial forward ported patch - add inkern.c helpers for the new available attributes to avoid viral boilerplating in the future (also add support for finding max of IIO_AVAIL_LISTs of IIO_VAL_INTs) - add ABI docs for new ABI of mcp4531 (out_resistance_raw_available) and an example in the commit message dpot-dac: - two more counts of s/assumed the that the/assumed that the/ *blush* - add ABI docs for new ABI (out_voltageY_raw_available) envelope detector: - move device attributes 'compare_interval_ms' and 'invert' to extended channel attributes (out_altvoltage0_compare_interval and out_altvoltage0_invert) as they really are about the channel and not the device - kill "dpot-dac,max-ohms = <100000>;" in the devicetree example v1 -> v2 - provide out_resistanceX_raw_available channel attribute in mcp4531 dpot dpot-dac: - change Vref to vref - the module will be called dpot-dac (in Kconfig help) - removed a 'the' - removed (s64) cast - make the channel indexed, makes libiio find the channel (tested with 0.5) - add a comment on how integer scale is converted to fractional scale and clarify the code a bit - dig out max-ohms by looking at scale and maximum available raw value from the dpot channel and drop the 'dpot-dac,max-ohms' devicetree property - provide out_voltageX_raw_available channel attribute envelope-detector: - change compatible from envelope-detector to axentia,tse850-envelope-detector - remove envelope-detector,invert and envelope-detector,comp-interval-ms from devicetree and add them as iio device attributes instead - make the channel indexed, makes libiio find the channel (tested with 0.5) - reorder struct envelope to better indicate what is covered by read_lock - add comment on interaction between envelope_detector_comp_latch (renamed from envelope_detector_latch) and envelope_detector_comp_isr (renamed from envelope_detector_isr) - fixup a problem in envelope_detector_comp_latch where interrupts pending from when the interrupt has been disabled interferes with expected operation - slight rewrite of the initial high/low assignments - use a better name when requesting the interrupt - dig out dac_max by looking at scale and maximum available raw value from the dac channel and drop the 'envelope-detector,dac-max' devicetree property Cheers, Peter Jonathan Cameron (1): iio:core: add a callback to allow drivers to provide _available attributes Peter Rosin (7): iio: inkern: add helpers to query available values from channels iio: mcp4531: provide range of available raw values dt-bindings: add axentia to vendor-prefixes dt-bindings: iio: document dpot-dac bindings iio: dpot-dac: DAC driver based on a digital potentiometer dt-bindings: iio: document envelope-detector bindings iio: envelope-detector: ADC driver based on a DAC and a comparator .../testing/sysfs-bus-iio-adc-envelope-detector | 36 ++ .../ABI/testing/sysfs-bus-iio-dac-dpot-dac | 8 + .../testing/sysfs-bus-iio-potentiometer-mcp4531 | 8 + .../bindings/iio/adc/envelope-detector.txt | 54 +++ .../devicetree/bindings/iio/dac/dpot-dac.txt | 41 ++ .../devicetree/bindings/vendor-prefixes.txt | 1 + MAINTAINERS | 17 + drivers/iio/adc/Kconfig | 10 + drivers/iio/adc/Makefile | 1 + drivers/iio/adc/envelope-detector.c | 422 +++++++++++++++++++++ drivers/iio/dac/Kconfig | 10 + drivers/iio/dac/Makefile | 1 + drivers/iio/dac/dpot-dac.c | 267 +++++++++++++ drivers/iio/industrialio-core.c | 259 +++++++++++-- drivers/iio/inkern.c | 97 +++++ drivers/iio/potentiometer/mcp4531.c | 104 +++-- include/linux/iio/consumer.h | 29 ++ include/linux/iio/iio.h | 46 +++ include/linux/iio/types.h | 5 + 19 files changed, 1341 insertions(+), 75 deletions(-) create mode 100644 Documentation/ABI/testing/sysfs-bus-iio-adc-envelope-detector create mode 100644 Documentation/ABI/testing/sysfs-bus-iio-dac-dpot-dac create mode 100644 Documentation/ABI/testing/sysfs-bus-iio-potentiometer-mcp4531 create mode 100644 Documentation/devicetree/bindings/iio/adc/envelope-detector.txt create mode 100644 Documentation/devicetree/bindings/iio/dac/dpot-dac.txt create mode 100644 drivers/iio/adc/envelope-detector.c create mode 100644 drivers/iio/dac/dpot-dac.c -- 2.1.4