Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965205AbcJWBSb (ORCPT ); Sat, 22 Oct 2016 21:18:31 -0400 Received: from mail-ve1eur01on0102.outbound.protection.outlook.com ([104.47.1.102]:55748 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S965086AbcJWBS0 (ORCPT ); Sat, 22 Oct 2016 21:18:26 -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 v2 0/7] IIO wrapper drivers, dpot-dac and envelope-detector Date: Sun, 23 Oct 2016 00:43:39 +0200 Message-ID: <1477176226-10566-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: DBXPR04CA0046.eurprd04.prod.outlook.com (10.141.8.174) To VI1PR0201MB2317.eurprd02.prod.outlook.com (10.168.63.19) X-MS-Office365-Filtering-Correlation-Id: 84cef3e2-afb1-4de2-866e-08d3faccea52 X-Microsoft-Exchange-Diagnostics: 1;VI1PR0201MB2317;2:jcoT2fgQPCBGk+hF8426Z5C93DvgLSDJhCqX6qvki/CyM6dAsgYVj9cSE52pvnfMxNwJR4nlQWzt4AmIyafQlDYCgYOtUqDQO/DcwgW/KPsy/wznVSP6wi9eNUw32DvonabZdOULcDhIi4YYaTkhSQFZ7MkZGji6Suor9rg5YUxGQtzYk3iCR/lWeEX66MlCvCSkHfJ15RGl+pA/IPa3ew==;3:aA1zQXg4XnrBtwNo8E3nM+frcHekmlbr83+LWS4ZFnClFu07+ez6noijLhmUZoU9xiEZvX7SHGaKMZLPzIF9E0AEcp0tRvBskM90k6swIOyjdky6Y2H5qzh/7DPiAzfLUAKRUfzzd3fzjW/dxr32lQ== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:VI1PR0201MB2317; X-Microsoft-Exchange-Diagnostics: 1;VI1PR0201MB2317;25:fhA0kKIhB5Kg1F8y2akdA94OphXWMDFvAw0nLgGaoj7nkLF146dmrSVZMj4atGgNifwajbNebH6QtC90RxQyiNmrh1JmaKGpceBqdi959AxtmgtkelQ57B0IxqThsy6cI2HBn9lL9ANUuqCzkIHh4CDbFIvwtLxbkdbsr2hpYpIYO31ViQ4dCt0N8R2oVS6k0cBwiUVtZggj3f4JLd/OzweHM002WxpqlY9vVt6cYtfY124xw9J0kk6UDJoR0XfE12+O1Fj33nJP7K63Hj+yTkwxdfuPluwycaDRE1C+SBeRTck7NozcibUKLRpCtnsfOYp8knN2YXzCtz4iViBcJ9t+keZ9YuvoLgPl90O8tDrb2739TvoiT8iIWROXxyFGx4tfqo+O/vIPiw+m2cJNq6ysyxZiUkR4+OGLdCUN0kBbOe2ZvxJpvkMPfWJQUrLagGNF7Aq6XflrLUTCcWctFdvc0RZBH1Vug0g1dJxdxhE4Zw7hpJe71B2paviX8KO4FjvGO8Es+HbN+obdbhSGQnnygeWFuXnVFDCpLLjeu1L44EfmIoxfRAqSnDhZLcWzztTj/w+qXXRmpcE++bOm/96rqi2DugzjqVlPTtPLDx7Napum5vK7RmHJsT9YawUNo+Vj+Zlkw7ZMCrTBYMLUkKMhLoSgkVgOyqdh+mDjHFPLErIrIN+gx1UQGm+WALQ/ZpLOAaki2YGV+Tr285IZGFbN7XxQnv57hjVt/xoAdQrvu+VoNmriPYmaThKWMkBj X-Microsoft-Exchange-Diagnostics: 1;VI1PR0201MB2317;31:PJDWff/Vr1c5ghoiXD+pxE5Dk5YoI84uOsB5acgEBflPfzwuPjQCKmA6pJipI3XnflacNtpPcxKw3Q0jQ3pkmAmd7nx06Wm29SABWDGcoJSXbMBLsPfbfJF1ngda7BdjahFj2sDgDQ+fe+hGsnbKyGf9tRO4SX98RHPqODm2mqurG4xRZMtGVzMdpx943tBhhjMdHYuH/G3+esw13W8e3xwZXbP5Umws3+bOpWOXdw1XdDEnm821jQdgW4AMv3In;4:qpcRm875STUZ3FCFkfBx5CrnwfNFoOhwWvAZpBiJ9JGLlX5NZSyjf0RVqyk/Lc+Lhm4V2HOtUCMaNtnqZq0fDCICTzsjqJxp49cHXLJGTixaQr+/JEsSnIJyOrqQztRJc1zm5VThLMOYRJHtgj/UJkQsxJRoRAQwVxUqYOp9PsHX+b5SuGbcSE6ZU2ECsxSzO83OMf4I391rWQhCtSUnYCnmSG4yQIGa3UCp2+Cqd1rhO9bVOJGEL+fWOYMB2EdAtyjwKJtCigFSwmSC/Pc2t+nHyNlDYaqnJYrDlfREM4g13Bz37y/qY31s2OJhhEwbS8RLXkEZ6MykC/CxlmgfAli0w5WuNl+W6J7HuARKk3sSDphKittWh5B9bkDvLuN1wy8RmodsFBywzkoIV/0czXML1Ty//JwNDNAzJgexhjk5zECGbE3by/SIXs+n8kwF X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040176)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6043046)(6042046);SRVR:VI1PR0201MB2317;BCL:0;PCL:0;RULEID:;SRVR:VI1PR0201MB2317; X-Forefront-PRVS: 01039C93E4 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(4630300001)(6009001)(6069001)(7916002)(189002)(199003)(33646002)(5660300001)(189998001)(74482002)(110136003)(97736004)(19580395003)(68736007)(81156014)(77096005)(8676002)(92566002)(81166006)(50226002)(48376002)(50466002)(50986999)(305945005)(6666003)(42186005)(6916009)(2906002)(36756003)(229853001)(8666005)(2351001)(7736002)(7846002)(105586002)(101416001)(3846002)(5003940100001)(586003)(6116002)(106356001)(4326007)(47776003)(66066001)(86362001)(7059030)(42262002);DIR:OUT;SFP:1102;SCL:1;SRVR:VI1PR0201MB2317;H:localhost.localdomain;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;VI1PR0201MB2317;23:M82iPWS/4Xpwp7/YQeJhYrCGLQmnn9fQtrrBvr0?= =?us-ascii?Q?9EREgBNDefO+j4opdChTZQ91rRcww/Raco0KGeTF+SxHC0SSs/H5TkEoH95c?= =?us-ascii?Q?GitZQzI0blIu/Ce6jeC/86GB7afalEEDd9UbndL0h4CjR8XzgcALIdgPm5hW?= =?us-ascii?Q?H+yjAiukG//BTsnCcv/EqkULlTH/T0kC6U684ZjD48+bAEEDLfeofKy+dYCv?= =?us-ascii?Q?4PrvIjXCMVXaJO1eQ48mMeOMtGCLg2jpFbD/Dc5PnEwKcbBcCNeR72IbQAAk?= =?us-ascii?Q?JuBA5qUCov49svMz90471AiXF2GeDqNMVWAbW+BYzQepxiRxBssertL5Mh83?= =?us-ascii?Q?at4g6W8Wrn2rKqP1tLN3ysX5JHrx2T3CwPOLdmuyNFOrirTlN5npwhwFo3rC?= =?us-ascii?Q?3B79aN20FD0iuYyQ8syJiXh0w/DQbQYZIQNvqLJ7nIzj0KOz29LivmznxwNo?= =?us-ascii?Q?NNxAUfLTgV0hA64b9oWPt2CE2XMUSlhwr0Y0mUi+TqDrrZG3B7Q0iEpmM3mT?= =?us-ascii?Q?DJipV1iuMwjPAS1hqzoJkc21+fZ1DK7zOPYZeS2And2Lmd0Hpg48urwmXRr3?= =?us-ascii?Q?PEsFX0KFxf9VraE2Ui4tBdRRqNg2ily42pGxSv7j53BWaXfixJvCOqJSYJGk?= =?us-ascii?Q?4Ok/GRhP7yToxYqg+CSwF8p3yBj2PET3O7rIAPR8bgxHLRy9aC/5xbrgUxEX?= =?us-ascii?Q?m8OnUbWCDShB8my2IwNIhX1legmDmN6ChxMq/u61rEmFcbUM6SHavF5wSM+2?= =?us-ascii?Q?4bCrseclZj9Sub/E+KD4ua3Zf1z82lLHChMK586JVxsiaEiV5VhhWO+sFdpB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Metadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;VI1PR0201MB2317;7:gz9znM6FPi8bxZmfLGOMkVYLadltdNRI+kXAZFx0pjNdCpuvqTo+5e1bIcicUnX0MwLQJEE9XwZfwh9IpWFyFwxw0Blf9oHUpTz1acJNgyAZWqh6CRNVZ1BVjQobK+zGFkf7ZvLNebrdf15fVEN1gYz5j1P0aFGTfwWm/2EZiPHzOrKgda1lQLOeTXN3zAVcVzweA6GZikOF76uFwjmOvB7v1EmoDStb4qljYzUiJo9CYeXYjAAb3bHBjPkvSw8MP+tVpXpi591DNMDCTHWZBBzwS9HKeP4+slx0NUC2S/rrvHjSfZgkLAp5uz7sOjrCkElT+TEf3QTTs1LDYFyuedSMCqO7P4Ll724afn7phdM= X-OriginatorOrg: axentia.se X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2016 22:43:58.5618 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0201MB2317 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5350 Lines: 112 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. 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 Ok, so the devicetree compatible string for the envelope-detector gained the "axentia,tse850-" prefix, 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 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. Also, perhaps the new device attributes (invert and compare_interval_ms) should really be channel attributes? Cheers, Peter PS. I have not tried to forward port anything else from the thread with the old thread with the initial iio:core patch. Jonathan Cameron (1): iio:core: add a callback to allow drivers to provide _available attributes Peter Rosin (6): 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 ++ .../bindings/iio/adc/envelope-detector.txt | 55 +++ .../devicetree/bindings/iio/dac/dpot-dac.txt | 41 ++ .../devicetree/bindings/vendor-prefixes.txt | 1 + MAINTAINERS | 15 + drivers/iio/adc/Kconfig | 10 + drivers/iio/adc/Makefile | 1 + drivers/iio/adc/envelope-detector.c | 463 +++++++++++++++++++++ drivers/iio/dac/Kconfig | 10 + drivers/iio/dac/Makefile | 1 + drivers/iio/dac/dpot-dac.c | 298 +++++++++++++ drivers/iio/industrialio-core.c | 232 +++++++++-- drivers/iio/potentiometer/mcp4531.c | 104 +++-- include/linux/iio/iio.h | 11 + include/linux/iio/types.h | 5 + 15 files changed, 1216 insertions(+), 67 deletions(-) create mode 100644 Documentation/ABI/testing/sysfs-bus-iio-adc-envelope-detector 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