Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp1193491lqj; Mon, 3 Jun 2024 13:08:03 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXtXn9j7CpP2zNenLNOoCDVWrmdRJrc5ZPQOXnvXyHvSB3GSh0Z/oz6p6/VDzzAg5tUCn2EYB903p8bKJEq29qudGgBmjyc18wPVrBBMA== X-Google-Smtp-Source: AGHT+IF1jCzMB1xIGqZYkpc2RXb0032xpACA7BuvYJg1Ty0SFB4NfI7FMpBLfC5W/MUzF3KOp9kf X-Received: by 2002:a05:6e02:2145:b0:374:97b4:dbea with SMTP id e9e14a558f8ab-37497b4dfbemr74497695ab.23.1717445283275; Mon, 03 Jun 2024 13:08:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717445283; cv=pass; d=google.com; s=arc-20160816; b=dKOHKehqUKKupodacFnWg8+WTo5PRaVqpff8V/pZDKToE/f28DJNgvibxtpMPspfv9 Vjv/lvdZ0B+TjJRhEG84RdhJdX62P921zJtuvggNRzHP/O9liSIoH04RPjAAJZCI5FrU C2Ti6m7fj62XuhlRFcHH0ovR8oIXoelBxmRY+E1hz3b1IqQAYLNlgCALwJ8H8OKRd9JW ChEtpbc+ZiiLCBiuN1Nw6KbCXMSzs9EBsZTkHFwl4hqlREXPzfe8EM8m3Qf8/eCaWeC9 XYLff1gJRwKZcw6X2euJ34t01EAlX5J9IahymXAiMrSrqS4lCLMzwSyAF9nfEe3ntAKT uSYg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=Ly0421BV22MROVZfKN8bJuAjzv5eY36VyOmFq0qxvtU=; fh=FH+qPOqc1BGcW7OlmsMfPBTRRn2SdiO9SB+EA5WEXS8=; b=Q1vsSN/0Dub1I2dtq60r9y8oQM5xKRiZouN4A0s01YRZnPoQArij74p+EgjO4E0akf q+lSWC3V1hLg0p5ETJLDcWWXTykpcgWoLdC05mt5nsPX0RWKXyND075rGNEKUPzOPJX9 jRtwigsnm8x2PBFEDlK1d+C5Yw8p2/Xsk+CohNy6GDLmnSY6S1tMoLV0TgS9+FObH++o wvw/cp0zx0gn8yy7bLXwqQ3LY8zdmKXizEVpouyPKNjUjcEAsa95rVDtSuhcw7VkY4FI 1eboKdP+Kcm63+h+zv6Y4f7pMVRI/unVXwtV23g9iEWutb1RAJEt9HXsCEDfJAOc/1sC 4oMQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eF6ixkfd; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-199674-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199674-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-6c37dbffd12si6080870a12.4.2024.06.03.13.08.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 13:08:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-199674-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eF6ixkfd; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-199674-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199674-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 99472282487 for ; Mon, 3 Jun 2024 20:08:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B360E13B582; Mon, 3 Jun 2024 20:07:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="eF6ixkfd" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BFF3A46A4; Mon, 3 Jun 2024 20:07:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717445272; cv=none; b=WD7qxMBLOJwm7P7u2lR2Rht60Li3Xw8NmEJPgekKlNtZaav8tgNheEfdW6pU4We9y5yZ+wgbWV1jCyVoWNiWcC76Kf3blL0qbrBlv80xYbwP3NotkN6IbiRcYP4Jr4PSbJaklehnMOm+Ujh4BKG37/nYK7bWcsIw7ZLCKEuk4mY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717445272; c=relaxed/simple; bh=xbP3NEx923MmK1rOGQkQZGfcDONB0sYHOQ7X3kICkbs=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=SZ90zojiUPbSJ627NnAMBvzko9AHmOmmORtNjlbQ+ddGIulkoy8hxIXRR3w6Aj4mokdVG2OapeJ+WzUBuG6STbWY0S6pK170o17AbJJLLskBIU9VwnSnNP/r7ZhfadppKvAgvSDGrJWHrlCLyPc794WIXtS8h7B9NRRP1IYuQU8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eF6ixkfd; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B66D8C2BD10; Mon, 3 Jun 2024 20:07:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717445272; bh=xbP3NEx923MmK1rOGQkQZGfcDONB0sYHOQ7X3kICkbs=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=eF6ixkfdNG3aSUtnYDQ+Hr0Niz083LutVFYg5zYucMgoEnG37y4QDmQVAZAM3PmLc EIkLwBJ6pdcWxGOiNsTvmFaT9zeQVnkrZ8PIR1XlxH/cURC+/VK9SZQZ4+1VAZ5R8V OdheL7QY48b/DWwbfCvS1hx7CKY/Ve0gY1cHqv48YR/dL9wbWhUQ46FOkUph1X0YbJ Nmvmq94Eu/SzRMJFiZKh9Mtz5vVGvzCWezgLeY2GIJpmXD06sN6Z9sIEHrZesPL9AQ iDy0inifqx+eGmUILYOi2OTX/05+Nm/PUG5639trow7w1dueju5tBBKBlLeXKRsINL WVrpDKFKWk8pw== Date: Mon, 3 Jun 2024 21:07:38 +0100 From: Jonathan Cameron To: "Ceclan, Dumitru" Cc: Dumitru Ceclan via B4 Relay , dumitru.ceclan@analog.com, Lars-Peter Clausen , Michael Hennerich , Rob Herring , Krzysztof Kozlowski , Conor Dooley , David Lechner , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 6/6] iio: adc: ad7173: Add support for AD411x devices Message-ID: <20240603210738.3880f1cc@jic23-huawei> In-Reply-To: <93ebe75b-5a7d-4d69-9515-7cbeb66c8e7e@gmail.com> References: <20240531-ad4111-v4-0-64607301c057@analog.com> <20240531-ad4111-v4-6-64607301c057@analog.com> <20240601201912.32fe3524@jic23-huawei> <93ebe75b-5a7d-4d69-9515-7cbeb66c8e7e@gmail.com> X-Mailer: Claws Mail 4.2.0 (GTK 3.24.42; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Mon, 3 Jun 2024 13:11:33 +0300 "Ceclan, Dumitru" wrote: > On 01/06/2024 22:19, Jonathan Cameron wrote: > > On Fri, 31 May 2024 22:42:32 +0300 > > Dumitru Ceclan via B4 Relay wrote: > > > >> From: Dumitru Ceclan > >> > >> Add support for AD4111/AD4112/AD4114/AD4115/AD4116. > >> > >> The AD411X family encompasses a series of low power, low noise, 24-bit, > >> sigma-delta analog-to-digital converters that offer a versatile range of > >> specifications. > >> > >> This family of ADCs integrates an analog front end suitable for processing > >> both fully differential and single-ended, bipolar voltage inputs > >> addressing a wide array of industrial and instrumentation requirements. > >> > >> - All ADCs have inputs with a precision voltage divider with a division > >> ratio of 10. > >> - AD4116 has 5 low level inputs without a voltage divider. > >> - AD4111 and AD4112 support current inputs (0 mA to 20 mA) using a 50ohm > >> shunt resistor. > >> > >> Signed-off-by: Dumitru Ceclan > > Hi Dumitru, > > > > A follow on comment on the validation code. > > Also there is some good docs for the sampling frequency but are they > > actually related to the rest of this change? They also raise > > questions about ABI compliance that we may want to deal with as > > a follow up patch. > > > > A few other trivial things inline. > > > > This is looking pretty good, so hopefully we'll get the last few corners > > sorted in v5. > > > > Thanks, > > > > Jonathan > > > > > >> --- > >> drivers/iio/adc/ad7173.c | 336 +++++++++++++++++++++++++++++++++++++++++++---- > >> 1 file changed, 307 insertions(+), 29 deletions(-) > >> > >> diff --git a/drivers/iio/adc/ad7173.c b/drivers/iio/adc/ad7173.c > >> index ed8ff8c5f343..91ff984eedf4 100644 > >> --- a/drivers/iio/adc/ad7173.c > >> +++ b/drivers/iio/adc/ad7173.c > >> @@ -1,8 +1,9 @@ > > > >> #define AD7173_INTERFACE_DATA_STAT BIT(6) > >> @@ -125,26 +132,46 @@ > >> #define AD7173_VOLTAGE_INT_REF_uV 2500000 > >> #define AD7173_TEMP_SENSIIVITY_uV_per_C 477 > >> #define AD7177_ODR_START_VALUE 0x07 > >> +#define AD4111_SHUNT_RESISTOR_OHM 50 > >> +#define AD4111_DIVIDER_RATIO 10 > >> +#define AD411X_VCOM_INPUT 0X10 > > > > AD4111_VCOM_INPUT . Looks like one wildcard escaped an earlier edit? > > > >> +#define AD4111_CURRENT_CHAN_CUTOFF 16 > >> > >> @@ -736,6 +918,21 @@ static int ad7173_write_raw(struct iio_dev *indio_dev, > >> return ret; > >> > >> switch (info) { > >> + /* > >> + * This attribute sets the sampling frequency to each channel individually. > > > > frequency for each channel? > > > >> + * There are no issues for raw or buffered reads of an individual channel. > >> + * > >> + * When multiple channels are enabled in buffered mode, the effective > >> + * sampling rate of a channel is lowered in correlation to the number > >> + * of channels enabled and the sampling rate of the other channels. > >> + * > >> + * Example: 3 channels enabled with rates CH1:6211sps CH2,CH3:10sps > >> + * While the reading of CH1 takes only 0.16ms, the reading of CH2 and CH3 > >> + * will take 100ms each. > >> + * > >> + * This will cause the reading of CH1 to be actually done once every > >> + * 200.16ms, an effective rate of 4.99sps. > > > > Hmm. This is a bit unfortunate as if I understand correctly that's not really what > > people will expect when they configure the sampling frequency. However I can't immediately > > think of a better solution. You could let userspace write a value that is cached > > then attempt to get as near as possible as channels are enabled. > > > > Still this looks like a documentation enhancement of existing behavior > > in which case any functional change can be in a future patch. > > However I don't think the docs update belongs in this patch unless > > I'm missing some reason for it? > > > > Well, it would seem like this exact behaviour is already documented: > > " > What: /sys/bus/iio/devices/iio:deviceX/in_voltageX_sampling_frequency > What: /sys/bus/iio/devices/iio:deviceX/in_powerY_sampling_frequency > What: /sys/bus/iio/devices/iio:deviceX/in_currentZ_sampling_frequency > KernelVersion: 5.20 > Contact: linux-iio@vger.kernel.org > Description: > Some devices have separate controls of sampling frequency for > individual channels. If multiple channels are enabled in a scan, > then the sampling_frequency of the scan may be computed from the > per channel sampling frequencies. > " I guess we've hit this before and added very specific documentation around this that I'd forgotten about. Thanks for pointing it out! > Does it still make sense to keep this comment here? But if kept, yeah, a different patch I think there is no harm in having the additional info. Not as if everyone will check the ABI docs whilst trying to understand the driver code. I didn't for one :( Jonathan > > ...