Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1268776iob; Fri, 29 Apr 2022 01:15:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwIL+EBIni8qYeUdpwgQo2q75b1AHNh7bOu9e93pg8Y0Z9Wju0T8JxjXggz+H2u7hbfGO94 X-Received: by 2002:a63:4d1:0:b0:3c1:630d:b6b with SMTP id 200-20020a6304d1000000b003c1630d0b6bmr8232005pge.623.1651220104991; Fri, 29 Apr 2022 01:15:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651220104; cv=none; d=google.com; s=arc-20160816; b=l3k8GgdMwapevG0IJ3Oynr2ggB6YhTda4Sb0Bt07obKo0x0QyEpLNTYM4AeCO08Jp4 LHVJk/nFu6XXMkeOiB4YcQjoVAUqSEPSKEs9sPA6sMrBeMyptFxHrNXOF9ngU3AIaiE/ LPG89uqHE0x8TIR77samCuFcbxKryVBO1kCIOXA+NbL3JPk+9wiOY0OYmHNKTJ9ZMhrR 9WUToJFn9ECIPDtYk59FrGn33DzGsypQbD8koXnBCdNK50WIrrESuxFpb2653bw31Gu2 GZ78/k31qXpd1rocTvItE1+Wy2momDah721XrocARZpFWwm6echmcvpTWhhw1Xt9SAOy x7lA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:subject :references:cc:to:from:content-language:user-agent:mime-version:date :message-id:sender:dkim-signature; bh=X/KcFNZhAHoZ1H6Tr4WvcjaMczJznMSErZBotqKY3jk=; b=WKEpwjgSF54rggL/t+IPGRVw5UjLd9i3BiuautI33YtakDqP66XyUKbgfquM3KxmSQ zwMdI2GGimo56dUkwh4tB4+NquG4rNHw0JnGoYnTrTd2bteGda9tZKnQACcG9Bw5q1Ct Iy4RZ6wo1BgVlpt0nkMKCqQvi2cDCCUtzdVMI0tjJ7tNaPS5btgADsh6GSP3lUY0BWZp QSRf2XLwCtLHmzPcFaksVMHWuBSliYeG0EnAqYqh5nZ0lbYgIn6pLqjEgya8cQ6z6AsT za7yoEycNWwSFEkwkQRfJo+kDn8BYUPoKWtlYahfa7WabqWy7DzwRVy92ZyYJKMAFGfe nCQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=PxhNjBOw; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t20-20020a63d254000000b0039d300cade6si6350409pgi.679.2022.04.29.01.14.49; Fri, 29 Apr 2022 01:15:04 -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=@gmail.com header.s=20210112 header.b=PxhNjBOw; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354383AbiD2GHW (ORCPT + 99 others); Fri, 29 Apr 2022 02:07:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345038AbiD2GHT (ORCPT ); Fri, 29 Apr 2022 02:07:19 -0400 Received: from mail-oi1-x22a.google.com (mail-oi1-x22a.google.com [IPv6:2607:f8b0:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42922B899A; Thu, 28 Apr 2022 23:04:02 -0700 (PDT) Received: by mail-oi1-x22a.google.com with SMTP id y63so7584622oia.7; Thu, 28 Apr 2022 23:04:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:message-id:date:mime-version:user-agent:content-language :from:to:cc:references:subject:in-reply-to:content-transfer-encoding; bh=X/KcFNZhAHoZ1H6Tr4WvcjaMczJznMSErZBotqKY3jk=; b=PxhNjBOw2ylbQzoWSUcKoIuVMYGb/l6sxtEDteNu6AO+5YMtyA256PNa3JlRIRzM+L ijSIySGeJpUHMeXZTKHsagxc/ujgW+UfOit8Xhfp0WtlPe/tGMEsbntzX149xTm+Ewic njMJr3IjP6E8YT38D97JampAL4qtJ7h7T36pulJNSiy9qSxN10NFsKStjF3H/oHT33QK E/RoWon0gJ6V5OC1x6Ukk7545Tn3PzgVRsSC7Q/gedvTBhSbDewSG9jdr+f6ndDW4HAG 8O6LZm2d5LwL7k1kwdzVrSVIt7fWf+QpJ2iyi0OeYDSc9rT25u5SSLRKE1O3FEguyZ02 zqJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:message-id:date:mime-version:user-agent :content-language:from:to:cc:references:subject:in-reply-to :content-transfer-encoding; bh=X/KcFNZhAHoZ1H6Tr4WvcjaMczJznMSErZBotqKY3jk=; b=WrvkiuecLdZ8EAiE82+QKzFX3Fzt/7H3LgeaHLWQTGV4mVVuTMIKP1bKV+MmvTL4e6 ZB+VWQaN60aq6zL0zL822cGU+tPvCVfIorrbYtKqyl8xr+K0aGhxtXXS3eWrJWoP12ah lTHeXgpff1HjQWiq2xnQwa1K+tnEUAeHdonCQSm2Ja75ppOaC60salvw6h5lizMZSeJa VE6PUWeWBsg2MF6ZyZSEG3R7fiH2G48thdziZya7kgd9uDOzj0EaMPVbGhTToUTu/GGh 2Ts5b/hqJq3eJv9ZTGeHl25BdjuE339eePvTKR8KKqm2lZi/IxzVT0ImrvX7XOrZn+kG CD0A== X-Gm-Message-State: AOAM530k+Mrff2+b1tU+VfMVzmI7Jb6NerRmPgqa0snCdVAHxZ85Q8WU vt3mA64hvJ19iaOgC+qhyzo= X-Received: by 2002:a05:6808:1912:b0:325:74c4:35e3 with SMTP id bf18-20020a056808191200b0032574c435e3mr788022oib.61.1651212241626; Thu, 28 Apr 2022 23:04:01 -0700 (PDT) Received: from ?IPV6:2600:1700:e321:62f0:329c:23ff:fee3:9d7c? ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id a8-20020a4ad5c8000000b0035eb4e5a6c6sm429034oot.28.2022.04.28.23.03.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 28 Apr 2022 23:04:00 -0700 (PDT) Sender: Guenter Roeck Message-ID: <59e91f45-7263-eb41-4b47-db217af54910@roeck-us.net> Date: Thu, 28 Apr 2022 23:03:58 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Content-Language: en-US From: Guenter Roeck To: Ruslan Zalata Cc: 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 References: <20220428210906.29527-1-rz@fabmicro.ru> Subject: Re: [PATCH v2] hwmon: (sun4i-lradc) Add driver for LRADC found on Allwinner A13/A20 SoC In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=no 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 On 4/28/22 22:32, Guenter Roeck wrote: > On 4/28/22 17:28, Ruslan Zalata wrote: >> Thank you Guenter for your valuable time. >> >> I have added update_interval option (it's in ms units, right?) and fixed all other issues you pointed to. Will test it on real hardware and send third version of the patch for review. >> >> Regarding IRQ. Alternatively the driver would need to sit and poll conversion ready bit in a loop which might cause a much worse load on system, is not it ? Anyway, the real problem with this piece of hardware is that there's no "conversion ready bit" provided, the only way to know data ready status is to receive an interrupt. >> > > Not necessarily. The data does not have to be "current", after all, > if the hardware is able to continuously convert. If not, the question > is how long a conversion takes. If it doesn't take too long, it would > be better to initiate a conversion and then wait for the completion. > >> I think it still needs a semaphore/seqlock to synchronize conversions and reads. I.e. two consequent reads should not return same old value. Although it's not an issue in my case, but could be a problem for others. >> > Why ? That happens for almost all hwmon devices. They will all report > the most recent conversion value. Some of them can take seconds > to complete a new conversion, so the reported value is always "old" > for a given defition of old (ie any time smaller than a conversion > interval). > > Sigh. Looks like I'll have to dig up the documentation and read about > the ADC myself. > I did, for both A13 and A20. The ADC supports continuous mode. That means it can be configured accordingly, and reading the ADC value just returns the most recent conversion value. There is absolutely no need to keep reading the conversion values using interrupts. Also, +struct lradc_variant { + u32 bits; + u32 resolution; + u32 vref; +}; is unnecessary because the values are the same for both supported chips. That means that defines can and should be used. Yes, I can see that A83T uses a different voltage, but even that doesn't need a structure - the voltage can be set in struct sun4i_lradc_data if/when needed, and the resolution and number of bits is still the same. Guenter