Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757456AbcJTJ0U (ORCPT ); Thu, 20 Oct 2016 05:26:20 -0400 Received: from mail-db5eur01on0090.outbound.protection.outlook.com ([104.47.2.90]:36692 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755644AbcJTJ0R (ORCPT ); Thu, 20 Oct 2016 05:26:17 -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 0/4] IIO wrapper drivers, dpot-dac and envelope-detector Date: Thu, 20 Oct 2016 11:25:58 +0200 Message-ID: <1476955562-13673-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: DB6P18901CA0022.EURP189.PROD.OUTLOOK.COM (10.169.208.160) To AM5PR0201MB2308.eurprd02.prod.outlook.com (10.169.243.7) X-MS-Office365-Filtering-Correlation-Id: 6d10950b-7661-4647-8bb6-08d3f8cb22f3 X-Microsoft-Exchange-Diagnostics: 1;AM5PR0201MB2308;2:jbuO1rfIz245ObirZCRn0cNT5gADghTnnK2AbfB3SFJ5QI1cxV6KQiNFkVF5BK0A/JIUvj+fr6WTqsLSOCxpDC6lPKgFMtTTdcvZLB0konQ33RoBSm+L8meBevFSA//AXiY0WNzXEBEAsSxuDCjPAR7VNiEtKRPRwOZEqOGW18EywiIsas7AcYBWVx5Zu+Ew70ui0NH11sTNQAYBToeIMg==;3:8rlRGpao6Lj50CEJ5meFCd8TL41OEKNKaHcYF7YjU2ltld1jlGN1OEcCxnCy8V1hZUc08LaopT6uh+oO/QLTJtLhYrNUatytkC7eT/tDQ9e992BrdRILVG+30cpYHNbIOT4tXsNoU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S3FUyZWiZE38ykSsq4Uttnd3i7KfJzRcEF4qDCJAF6vCl2+YvWjzU0kl8B+rQv2tsNahxA8G4cIYgQ3UFT/8eybJmTw5J9YvXOD5lIpORZUhMf37vzYAo8Pqx9QIxvTGQuDWdrlY8RyHhNebpx58C0qjKegNiCWIYGb8FYISoLDifMpKgrYsBb6uw6QRXnRKp3SgduTseS0zSLh7YQOcltuJdgwO 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:AM5PR0201MB2308;BCL:0;PCL:0;RULEID:;SRVR:AM5PR0201MB2308; X-Forefront-PRVS: 01018CB5B3 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(4630300001)(6009001)(6069001)(7916002)(189002)(199003)(52314003)(6116002)(8666005)(77096005)(97736004)(50226002)(2351001)(19580395003)(68736007)(8676002)(229853001)(36756003)(101416001)(66066001)(189998001)(81166006)(81156014)(92566002)(47776003)(50986999)(110136003)(7846002)(6916009)(2906002)(586003)(105586002)(15975445007)(3846002)(6666003)(7736002)(1720100001)(5660300001)(4326007)(50466002)(305945005)(48376002)(74482002)(106356001)(33646002)(86362001)(5003940100001)(42186005)(7059030)(42262002);DIR:OUT;SFP:1102;SCL:1;SRVR:AM5PR0201MB2308;H:localhost.localdomain;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;AM5PR0201MB2308;23:Tr6ASiUcT4JZ47DGEnkK9O0iJT17jyJTNAMxvwm?= =?us-ascii?Q?POS3olvEGAlnk+PObtV7wnEzVl49ktmKXTxU2POQocslrcXMyLsR/pwR3dXN?= =?us-ascii?Q?0W7Bl24VkBza1sbnEMrqyOX35fSi7l/mq3+F9qOq4UMcVdTpvpXV3V5oAXCX?= =?us-ascii?Q?V8tp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b?= =?us-ascii?Q?D1KOSFou2nO3CEj5/1yTxjlZ1iNONWCQoW91t3Xr+SvhF+CAShxJQ8yJEJtO?= =?us-ascii?Q?r8qpDZD5oGcW+8ho2w6kp8VSdRtjAiiisRBcHD4l17MyyFsPoN88Z0PPciNb?= =?us-ascii?Q?KvTVcHDOG2V0DSXE=3D?= X-Microsoft-Exchange-Diagnostics: 1;AM5PR0201MB2308;6:9Fz7vpfdkxeX50mb9cx5ybpcPOFIOQpaffixQnVbj07H8Lys6mtbYOa3DMqTq2cPvxBy5R3aVd3uRiWN3EaT/f0qD3Zwm+OjbX4qr1/9QKc2w3vZ3dJDtyQ3iH6AvQ5WjhZf2mh9hW4ULm8Y42zDZUGr2xTaq1mVQG131TkO/EGxhdW61MrLDjbt1JoV2xzhiebd/9OYF41QeDD3Y3EohXTERVe4FeUZhlF3/BJNeQm7HOELuDeJEdGiwlYj+dTIIsJmSr7DT3RUGO9NpiYWc6I1yUgHpRDwjd/85AC3X298N0UJhL6N27t6ZL8OWJ7ddv69uW94ofynM/HelCEGiw==;5:gOXiFCLiLYqGYFQxW531iVb59JVjQYHCCrT32x+3rpwn8noRS8wAthWGBQuA7PF8bZqcil1O/uD1vPKsEeTNy/KJBHb/uo+Tko+Gy48S1SD27cr4GD3wyGlCQAaP54h8HzZNtJSHGr3W6wGbRg39szAeLq7+xnoZ+jvDRsFuagw=;24:P4LE+cX8WExLRTSy1nHuG/ey7Nq1pAH9b3dnW18QQe/rUjZJ2ugFv4KCQxYNs60wWnabnG94zVFfI2OyB1tIHIdZn7prP/ON257Joy3pKA0= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;AM5PR0201MB2308;7:IebapHgPvs5Y9BPnNKdrU1ZOFgB/wjNeaGReK9VNEuG6U+CZxu51sSt9fwr40WVe9E4z656Uhvi32kZt6rdfqXVsTqDZ4TYUshjGq84o54/iKwVxk7DMOtsLe1hlchtPcXz4ATPLxqrK3LIBVaoKzaxi6YgZlJN4XfNa6EUL6Uv9OKSuvn0N4bM9Mq2tA987hQSArZ8kyjPe/xDXnASM2ynyapOwXjqegSvJc24bGQX0gqz2eV78BsPMo+zqcebZS5RAsZ7p+yj1jdCW+aGCT5UH3gPnejo6BIt1qNvfbo6qozpe1vWXv48xiAR4FLfzFlN5AFYnaRQqKgl0Ap4o0ynHxJJFr3xY00vTq6R1/EM= X-OriginatorOrg: axentia.se X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Oct 2016 09:26:12.5117 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0201MB2308 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3596 Lines: 80 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 :-) Please look over the scale conversion, notably for the fractional log2 case that I don't need myself, so is untested. Maybe I should just remove it? Also, is there some agreed-upon way to dig out the maximum value from an iio channel? If so, "dpot-dac,max-ohms" can be eliminated from the dt bindings, which would have been nice... I'm also wondering if I'm somehow abusing the regulator? I only added it to get rid of a "dpot-dac,max-voltage" thing from the dt bindings. It feels right though, but maybe I should do more with it than check its voltage? What? 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... The envelope detector was previously discussed late last year [1], and this is what I came up with instead of that mess. There are a couple of things to be said about the envelope detector, one question is where it should live? I placed it in the adc directory, but maybe it deserves an iio directory of its own? I'm also a bit worried that the name is a wee bit too generic. But what is a good name? I don't want it to be too long like dac-comp-envelope-detector and something like dac-comp-env-det is just unreadable. Naming is difficult... And suggestions? Another thing is that I'm not 100% satisfied with the fact that you have to decide at instantiation if you are going to invert the search or not (search from below). But in order for that to be selectable at runtime with a channel attribute of some sort, I need to be able to rebind the interrupt to the other edge and I want to do that without releasing the irq and grabbing it again (someone might otherwise steal the irq, making the driver lose the irq all together). I don't see any API to change the irq trigger condition. Is there such a thing? Anyway, despite all the above questions and remarks, this works for me. Please consider applying. Cheers, Peter [1] http://www.gossamer-threads.com/lists/linux/kernel/2320755 Peter Rosin (4): 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 .../bindings/iio/adc/envelope-detector.txt | 65 +++++ .../devicetree/bindings/iio/dac/dpot-dac.txt | 43 +++ MAINTAINERS | 14 + drivers/iio/adc/Kconfig | 10 + drivers/iio/adc/Makefile | 1 + drivers/iio/adc/envelope-detector.c | 305 +++++++++++++++++++++ drivers/iio/dac/Kconfig | 10 + drivers/iio/dac/Makefile | 1 + drivers/iio/dac/dpot-dac.c | 219 +++++++++++++++ 9 files changed, 668 insertions(+) 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