Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp969823iob; Wed, 4 May 2022 11:44:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyXUnPDaLsD0k297sq7b+hACOjiAwjZJqhp1lFv/6KukxVGHPgC0B872wiOPzbkBFtUkK9X X-Received: by 2002:a17:90b:1091:b0:1d8:b371:4b29 with SMTP id gj17-20020a17090b109100b001d8b3714b29mr991871pjb.234.1651689857952; Wed, 04 May 2022 11:44:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651689857; cv=none; d=google.com; s=arc-20160816; b=RNdE8Fe3m/uQQkcAv2qrGr8kMddV7iU56w3A3NKqkTG2OqOtp1Wd4lWmHqmKSXvFPw 4aMste8F5BjwHspcW9AqrxKOHrjlaRZ7CCvyp4wxUQkTBUMBibTYXwSz/Wy24NQTlho0 zJG3L8I8CI6OfHotqT87Tg0IC12gV1nRsExZmPJTaa7QM/Gvg1fcsUUevuPVdbQkCZuM PKz5iZct0iwQZWIG1eCepW9GXQUBCeBkd4MsULzyt1E13dhL/fDnD/Y0bXZ6i44INxhe x3S3VnXAzvgVfQPN0+mpR0Y7Cm8T3bCnzuZ0vtmgAOqcEAa6hzjcjbb716/sVJ0minB4 4tFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :dkim-signature; bh=xUUhuAdWl5ztZDGXsYgh3f41yA2CkH+/W2wG9PAr7kU=; b=bn6PsyPPYQUiLqePwVNVE5uL4xJKngdBdCyh62RWmhro+/wScC75YVpAABFrQgZY7I EbrtNVIlVOfYP764cRWh7bDZLYdUI/FtRn+5aPlp7MoCAklYyUv089jCNBj5LJmkfuS0 A2g/M497xMrOOZSU6Ym1mPO4644YU8xxS+Ky5oKSI0k6CKirp8Ezg1lV3rTixLDrpanc rcpXH04o/2x3yZSIwv9gGBMuq/fa9kEH/ajibcEJrqu/OEn7h0bh7iV2pBC2elhrnim6 I/ljONhLgLjLglF0h8Kzmete8B91kOTi8DtxTRikxCu5xEYHVyGtzidf86Q1C/azGQpD F+0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm3 header.b=wiHx1q5l; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b="b4CD9mu/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cerno.tech Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bk16-20020a17090b081000b001cd5b0dcab5si5547476pjb.12.2022.05.04.11.43.56; Wed, 04 May 2022 11:44:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm3 header.b=wiHx1q5l; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b="b4CD9mu/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cerno.tech Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351110AbiEDOPw (ORCPT + 99 others); Wed, 4 May 2022 10:15:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239972AbiEDOPu (ORCPT ); Wed, 4 May 2022 10:15:50 -0400 Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 142F5419AE; Wed, 4 May 2022 07:12:13 -0700 (PDT) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 75386320027A; Wed, 4 May 2022 10:12:10 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Wed, 04 May 2022 10:12:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm3; t=1651673529; x=1651759929; bh=xUUhuAdWl5 ztZDGXsYgh3f41yA2CkH+/W2wG9PAr7kU=; b=wiHx1q5liF64+jC1h+QiniPKBL t2dX9X2+maVEUh+r7S37r7+EpzQ3ujUGzSre70LRHxqZ3Aw2KbBV7D0wB5qe3zmR UOf3/8GRHvCjpvP1LpjtfAOnmqGSkPqTCBIdbkPQCRZ5paJ3EVwhV7zFfnFhdJ4Z XG1hdve7+c+YHoB1IqJsSeOL59ce4fYQzIsYQurD9eXiGFTp7hgYT76QjZmVGNtJ Jpermg9Be8ZZC1ZzCkCSC6PdPIs0JIaBHgdQi2hUrlhavkLb2UuRyM+JStqAy090 SSs1K8l576D+f7UxxX8Kj8XRLc9JMRS58RZgb+JwgjA7H/v84slLSAG+hSHA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1651673529; x= 1651759929; bh=xUUhuAdWl5ztZDGXsYgh3f41yA2CkH+/W2wG9PAr7kU=; b=b 4CD9mu/DX2GZhwPHXlDAlHSWDPiq6U3YCdxPREQzj+Ixonm9DnW2V0ACn9aRsX/X XWtX2hxcwjKlbxlhpTduqH5ZXlUfC+MYdJUYkqXVg2XRPn6q+iGR7HqXb17lFH70 QyVdoAqIpD26RtMbGuRMehgjazoBPqNGwY05JcNikkfPbm5Y87JvnQdnJyPIfqRu MgiD3TnWJm80yUopP1UNgiXiuneP7tvaGevSLreozrOz6HMZtPk9pLLYcz3peBqX H8UM1Wc+NozWSh1tqbRwLkGjU5LqQFdiUDpkf1J4FtMnXwlSiJnQWXHhITNTei0a whWCUxlxd/aAhRmfsfA2g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrvdelgdejvdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvvefukfhfgggtuggjsehgtderredttddvnecuhfhrohhmpeforgigihhm vgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrfgrth htvghrnhepffekleevgeejieeigeeftddtgfejheekvedvudetgfduudfffeffueekfeeh ueegnecuffhomhgrihhnpehkvghrnhgvlhdrohhrghdplhhinhhugihfohhunhgurdhorh hgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepmhgr gihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 4 May 2022 10:12:07 -0400 (EDT) Date: Wed, 4 May 2022 16:12:04 +0200 From: Maxime Ripard To: Ruslan Zalata Cc: Guenter Roeck , Icenowy Zheng , Jean Delvare , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , linux-kernel@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev Subject: Re: [PATCH v2] hwmon: (sun4i-lradc) Add driver for LRADC found on Allwinner A13/A20 SoC Message-ID: <20220504141204.iqjwa62ije2pedal@houat> References: <20220428210906.29527-1-rz@fabmicro.ru> <20220502110010.q7vvdkdpaiz5acjl@houat> <7433B295-D896-4BF8-87DF-87EB89D7A550@aosc.io> <20220502112112.3ne7zy4b6gggxzoo@houat> <4aabfd63-18e2-65c5-d1c2-d7600afc1c40@roeck-us.net> <97e3af18e947492b1ac968c058ba509f@fabmicro.ru> <20220503161446.tl3qoqqnkzq2f3hn@houat> <18ded45dcd670edcc9eb9811e7c7c034@fabmicro.ru> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="66mbevpbgads7k7l" Content-Disposition: inline In-Reply-To: <18ded45dcd670edcc9eb9811e7c7c034@fabmicro.ru> X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --66mbevpbgads7k7l Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, May 04, 2022 at 02:37:32AM +0500, Ruslan Zalata wrote: > Hi Maxime, >=20 > > At the hardware level, I'd assume you would either use the LRADC as an > > actual ADC, or use it to drive buttons, right? >=20 > Yes, exactly. >=20 > > So I don't think a new device tree binding is such a deal breaker since > > you have to describe it differently anyway. >=20 > ... >=20 > > Since that would be a completely different use-case, the IIO driver > > doesn't have to support input right away, it can be done later if > > needed. > >=20 > > And you could have the two drivers compiled at the same time. >=20 > As I got you right, you propose do add new bindings, say > "allwinner,sun4i-a10-lradc-hwmon" and "allwinner,sun8i-a83t-lradc-hwmon" = for > new driver, which will allow two drivers (hwmon and keyboard) be compiled > and loaded at same time, only that one listed in DT will be instantiated. Compatibles are meant to describe the hardware and remain OS-agnostic, while hwmon is linux-specific so we should probably drop the hwmon from the compatible. But otherwise, yes. > If two are listed at same time, one of the calls to devm_request_irq() > will return with an error preventing second driver to be probed (some > error message would be necessary to let user know what's going on). If > this is ok, I will implement it. >=20 > I think moving this driver to IIO framework is overkill. We use LRADC to > monitor battery temp and state (voltage) and that's what HWMON was made f= or. > It's simple, easy and elegant. Yeah, that's that *you* use it for. If someone wants to use it for some other use, what's going to happen? Will we create a third driver for the exact same controller? That's not reasonable. > IIO, on the other hand, is for data acquisition and is much more > complex beast. Can we stay with HWMON, please ? :) But it's generic, and you can plug hwmon on top of it. So you don't lose any feature, but it also doesn't prevent any one else to use it for some slightly different usecase either. > I looked through the code for a number of iio/adc drivers and I could see > that all of them initiate ADC conversion inside read(), then wait for > completion and return single sample. For me this very flawed approach > because a) much more overhead/load on the system, To monitor a battery? What kind of polling interval do you expect on this? > b) initiating conversion may (and will) take more time than a single > consequent conversion, Ditto, I'd expect to have a request in the order of seconds for a battery, so the setup time will be negligible. > c) samples will be read in irregular periods of time, hence acquired > data will not be consistent for any further processing (like FFT). So, > this whole IIO framework is no way better than HWMON, yet more > complex. At least for ADCs. :-) > > A better approach for an IIO/ADC driver would be to implement some > serialization mechanism to let reads go in sync with updates (IRQs), with > buffering, guaranteeing no same sample is read twice and no sample is los= t. > The read() would return next available sample from buffer with nearly zero > overhead or sleep till data is available. Like this: https://www.kernel.org/doc/html/latest/driver-api/iio/buffers.html ? > And the best way is to extend IIO framework to support ring buffers > mechanism like the one proposed by Analog Devices, but that's a way > different story. Link: https://events.static.linuxfound.org/sites/events/= files/slides/iio_high_speed.pdf Those suggestions were to handle more than a ~100 kilosamples per seconds order of magnitude. How many samples per seconds do you expect to get out from this ADC? Maxime --66mbevpbgads7k7l Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQRcEzekXsqa64kGDp7j7w1vZxhRxQUCYnKJtAAKCRDj7w1vZxhR xdtKAQD8ETOpp5uHBoLQ0BmZsA0blycwGb6XqOpbIuD8ExWyPgD/cak7iCKVEfxm 6SJtMB+QLLQYe4LICLR1en4ssJd5nQQ= =RTTX -----END PGP SIGNATURE----- --66mbevpbgads7k7l--