From nobody Thu Dec 18 09:45:22 2025 Received: from mail-qk1-f169.google.com (mail-qk1-f169.google.com [209.85.222.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 64BBE1A9B45 for ; Thu, 9 Jan 2025 18:47:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736448455; cv=none; b=IMJmImdeRE5OyW7T5MoRNFDVpc/OrszIw/rnjvzTPuJiGJTChF1WONoaS3E1wmY2vLH9ZXU17reKlRP/+ZL9PBMZLETv3Zffq66JjlqT5H0lM0S9jny8QrUJihD2tt+tbiLHB97xF8RecsO+jrpm/vY6pn0+A2Ip1t/Zwhqk0fg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736448455; c=relaxed/simple; bh=Ma8HaBPEK9LBfvT3QeN1X7ugzAmaSGzcmCUpk/9AAyw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nZpn/TgTbyXsm0hQjoUFtKk+aye8uCbUzpLt1WGYQiMV01PHLLT7s/N1fMNak6Gx2BtVq2b1QbEcght/Ipr6pVzqpYHTrlbdt6FMe0Qc2X9zcyoYwZFWsl8cG9bOaztybTbqCibeB7eAYmTuYHYt6wCFyh2qGteGpIv/pv6O2Jg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=LlkJ8fE1; arc=none smtp.client-ip=209.85.222.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="LlkJ8fE1" Received: by mail-qk1-f169.google.com with SMTP id af79cd13be357-7b6e4d38185so109275785a.0 for ; Thu, 09 Jan 2025 10:47:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1736448452; x=1737053252; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=p2jerrcD1nGClFF+pwwbUr/tdkat4xQ5wJ8skGDMH+c=; b=LlkJ8fE1zrlltokdVNr5foQV0Ck7gsEGj7hcGkEC+vbDdpIc+sSoOteXFWubmVm/2m Nlj3CXnaRIaUzuorQLS1TwGXF0p7tSSwlqeG1BTijqe8+EO3vB/PW6rdHIa7+hKHUSte nUpSgRT4ZLncIVLHM3tf9om6hlvhYjcCI9CohNhfUVio9JSLQCLyjBd+HlQfEpcKU2YO cH2tvDZi+Pm8daKuF9bQ0jrBMK0OQUNAX0A5KjWhX6I2Rcywo5Lc4IK+WM4M2cnIiiE5 xxaQ70DWmCIBn6syOnMipxRwA7i2TXNgCwbK8F+/ERSRbrXKgHXh/OkkBvI1FcubywqU 5Pmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736448452; x=1737053252; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=p2jerrcD1nGClFF+pwwbUr/tdkat4xQ5wJ8skGDMH+c=; b=n3kvqrpQ1HqBEbBE4WxrbV5CCgxKqRBlDfzxifL3cja2j57Mc3IT+a/hTLgl+w8jBL J8z04arPLPS5jzvWvo/YpeaAIG8I56Tj/8TnvniL7IT2815gIUzHuVoJwHTc0LKyyPAn vcia9F2fg3eclJn70bw0aU2GuH51G1175eAmhrqcx6PuTUqJUTXWasrKYy0+hE8p7jjn KJYqUt8N12Kkr9y7UxrtfrtZ0Evtq2a9R/InSU15bMoqmWp+sR3SC+Yk2CJMFRy9QUIn nK1GiPbIuovk6M6jbd3mbwVvjlCSKIxbD4sJRyxSsjsNZdFOhp13Pc8MwFnHik9eryx0 r8eg== X-Forwarded-Encrypted: i=1; AJvYcCWLvrzmJOiRGA2Lsc7rwzNxd6oXWzB2WTX9BlJvlxPumR/vI7K/XqXhw7IXyUD1fTk9xL5CDbAqw58ZVYQ=@vger.kernel.org X-Gm-Message-State: AOJu0YzMhMoOjSN98ngpJsMAA5x1zpTCm4OXlv3lxyQ8LgEeyZ+Eh3zR dC+OovA+DqV/RUq2R5TdGFTJmLH2kyN83LdC3UGPbgGMGpaz1GD4eIWfwV6CxtA= X-Gm-Gg: ASbGncueKmZSAFC6kLbmp7BRNKKxYM6AzKjCNXyI+QsT09RTNVRAPPIYanLk9aQTz5b eTMNHq1kFxV+R5eq+l8xzQrISmPevsGDSIIDPB8T+ez/CD5HE7pdqBX4Yf7QBlV8fPnsahLj5gB qIdW7w3BeBo0WB9Aw3WKyJVGmqOmYi13eyx9gJLnLcuMPq6hk9wVQphL5tAw7k8p6L4WpDmn0+c QNGSLyhQFPIAHY0qvnkgqVdCkVZNkEgttcdPQvs+rCHm5UrAOcQLR63tG8Krm5OL1ntuhmsmbEl BZV7P3kffVzMVIjl X-Google-Smtp-Source: AGHT+IGSh0OJ2ICJcgUrCCwD1CmO6Yk4iQVFhsuyeLSR7nuNJe3mJA1AXgnAS5hrWhV6frPSVt2d0w== X-Received: by 2002:a05:620a:4102:b0:7b6:d383:3cca with SMTP id af79cd13be357-7bcd9716e59mr1230536985a.35.1736448452291; Thu, 09 Jan 2025 10:47:32 -0800 (PST) Received: from localhost (d24-150-219-207.home.cgocable.net. [24.150.219.207]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7bce3248945sm94309785a.42.2025.01.09.10.47.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2025 10:47:31 -0800 (PST) From: Trevor Gamblin Date: Thu, 09 Jan 2025 13:47:24 -0500 Subject: [PATCH v2 2/2] doc: iio: ad4695: describe oversampling support 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="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250109-ad4695-oversampling-v2-2-a46ac487082c@baylibre.com> References: <20250109-ad4695-oversampling-v2-0-a46ac487082c@baylibre.com> In-Reply-To: <20250109-ad4695-oversampling-v2-0-a46ac487082c@baylibre.com> To: Michael Hennerich , =?utf-8?q?Nuno_S=C3=A1?= , David Lechner , Lars-Peter Clausen , Jonathan Cameron , Jonathan Corbet Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Trevor Gamblin X-Mailer: b4 0.14.1 Add a section to the ad4695 documentation describing how to use the oversampling feature. Also add some clarification on how the oversampling ratio influences effective sample rate in the offload section. Signed-off-by: Trevor Gamblin --- Documentation/iio/ad4695.rst | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/Documentation/iio/ad4695.rst b/Documentation/iio/ad4695.rst index ead0faadff4b..f40593bcc37d 100644 --- a/Documentation/iio/ad4695.rst +++ b/Documentation/iio/ad4695.rst @@ -179,12 +179,38 @@ Gain/offset calibration System calibration is supported using the channel gain and offset register= s via the ``calibscale`` and ``calibbias`` attributes respectively. =20 +Oversampling +------------ + +The chip supports per-channel oversampling when SPI offload is being used,= with +available oversampling ratios (OSR) of 1 (default), 4, 16, and 64. Enabli= ng +oversampling on a channel raises the effective number of bits of sampled d= ata to +17 (OSR =3D=3D 4), 18 (16), or 19 (64), respectively. This can be set via = the +``oversampling_ratio`` attribute. + +Setting the oversampling ratio for a channel also changes the sample rate = for +that channel, since it requires multiple conversions per 1 sample. Specifi= cally, +the new sampling frequency is the PWM sampling frequency divided by the +particular OSR. This is set automatically by the driver when setting the +``oversampling_ratio`` attribute. For example, if the device's current +``sampling_frequency`` is 10000 and an OSR of 4 is set on channel ``voltag= e0``, +the new reported sampling rate for that channel will be 2500 (ignoring PWM= API +rounding), while all others will remain at 10000. Subsequently setting the +sampling frequency to a higher value on that channel will adjust the CNV t= rigger +period for all channels, e.g. if ``voltage0``'s sampling frequency is adju= sted +from 2500 (with an OSR of 4) to 10000, the value reported by +``in_voltage0_sampling_frequency`` will be 10000, but all other channels w= ill +now report 40000. + +For simplicity, the sampling frequency of the device should be set (consid= ering +the highest desired OSR value to be used) first, before configuring oversa= mpling +for specific channels. + Unimplemented features ---------------------- =20 - Additional wiring modes - Threshold events -- Oversampling - GPIO support - CRC support =20 @@ -233,3 +259,11 @@ words, it is the value of the ``in_voltageY_sampling_f= requency`` attribute divided by the number of enabled channels. So if 4 channels are enabled, w= ith the ``in_voltageY_sampling_frequency`` attributes set to 1 MHz, the effect= ive sample rate is 250 kHz. + +With oversampling enabled, the effective sample rate also depends on the O= SR +assigned to each channel. For example, if one of the 4 channels mentioned = in the +previous case is configured with an OSR of 4, the effective sample rate fo= r that +channel becomes (1 MHz / 4 ) =3D 250 kHz. The effective sample rate for all +four channels is then 1 / ( (3 / 1 MHz) + ( 1 / 250 kHz) ) ~=3D 142.9 kHz.= Note +that in this case "sample" refers to one read of all enabled channels (i.e= . one +full cycle through the auto-sequencer). --=20 2.39.5