Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp1442926lqh; Mon, 6 May 2024 07:56:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXFMH2X9WUIp09mBKmW/MM7GVXrvkakNnQXee9gzF6+cKsHkP8Q9DyCCpGr025sy1b8KLjFteS3NwGLc3D2YcS95UnGLpW+skiBzkHtmA== X-Google-Smtp-Source: AGHT+IG/LRd8x0xY8jSTgyOEf/yFg8F27AB1uQaNrnR84rZOiUmZCT/9PFAWjkBMCKIfH9u4VDXw X-Received: by 2002:a05:6358:724a:b0:17f:89f2:5c18 with SMTP id i10-20020a056358724a00b0017f89f25c18mr12099751rwa.6.1715007370045; Mon, 06 May 2024 07:56:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715007370; cv=pass; d=google.com; s=arc-20160816; b=n+aXjofV6YDruOO+cqeiJW6774u1jw0yP3tt+ODTnrjW1+ZZmf2SdXk9y2zkVe9fcf YDu75HovtSurf9dajjI3ydFbYolDje38ZUYlcLXVVJIPQovheoZkkQbSUyn1N8QH725F TAYP24jEA65VtKiZ8e/+G2VYArHwJiwp2tX6HWYij0aBDmQASUX8mLr7qqxAE5GWBgcA ya1MzTzm+wcTbQV3WgkpmNPM3/9pP0NljM2KwFdYuu3+XPwU8AMcEhO/ujhg5NVbtZkM 0hWdZVoaefzUksvpAHX1ax2Q/1ls22fyRHOlX/dsLFpG8ZA/G7oyHntXcuY8De8tQDuo W1GA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=JcJFzkfee7mBqZtFVJndFmi3NW8+eQHyeH5MZMzFDxI=; fh=M7ILHLl9Lj29GPqg0++fkGEdtcGEFRhRiI3B7DH6Kag=; b=TE/NP6NQx1Ssq0S4In4En8qpl6AIR9W35EplFGu2tI7a96t4WgBcaVJU33X+ui2Tix iEaqZmURFPYYYG6unypPARe8X24vny9aPMLz5xlMqp51hFMlYWrolw3Lsc+CnfdUuR7K yI5T1EBaxUgfdWFnVBRjgE+YkLWiuxT5l5Tj62A+8B90qthOJJYz5oQ1Tqb2Cls4UUaA qr+HeOunVt7VjUXcBUsUwUX+L/SODQ4gNzy2Phn0PIsNS2YYw7lY5hZQkEzmmmDpSWcA HrA17irncBqG98TNraAOn0jPeQo2VDdlRe7l9qfQK0wXceTF5fDIdnlCOXXqQfF+ly4K zalw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=vA3nbQRs; arc=pass (i=1 spf=pass spfdomain=baylibre.com dkim=pass dkdomain=baylibre-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-170014-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170014-linux.lists.archive=gmail.com@vger.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 b10-20020a631b4a000000b005b7160263f2si8280409pgm.154.2024.05.06.07.56.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 07:56:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-170014-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=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=vA3nbQRs; arc=pass (i=1 spf=pass spfdomain=baylibre.com dkim=pass dkdomain=baylibre-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-170014-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170014-linux.lists.archive=gmail.com@vger.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 2CD04286927 for ; Mon, 6 May 2024 14:45:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E8F29154C0A; Mon, 6 May 2024 14:44:41 +0000 (UTC) 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="vA3nbQRs" Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com [209.85.208.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 A3BD7153BF2 for ; Mon, 6 May 2024 14:44:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715006681; cv=none; b=qZOR9cwtyxE+Z+nJt3WXPzA+3VyVZ8E6LgfbkBC8MmgVunFIQMi4bLV6EB9MEW6UEFvi6J3dogLqUCsp14JRoqsaej43FMOkWdxO06j3xAOYsLPDccngGC/LS6gULHXrLRFartzXS/msaJhfbrpjT2SklpsBKeWw4bb/5Dp/En4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715006681; c=relaxed/simple; bh=gcmU5KHDsIgDieHwyShq1qbTDOmmXgqU5v7T+celYzc=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=WzrVBpbBkwylMEjMbwcyUoV6/u6xIR9UTCGZ3TcrY92Ct+SmnDD5FfpfJR0HQOXm5IMhYSgdAKo3xJ3Hn9dw8o5nEYDd3KanwM9JMQsj9NnyyadoKxyjDxuUJ5WsMOeVejfLGrsFUEUZReRY7c62gguanCmvVGyFyAGLcOFclQE= 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=vA3nbQRs; arc=none smtp.client-ip=209.85.208.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 Received: by mail-lj1-f169.google.com with SMTP id 38308e7fff4ca-2e060d49f87so15598341fa.0 for ; Mon, 06 May 2024 07:44:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1715006677; x=1715611477; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=JcJFzkfee7mBqZtFVJndFmi3NW8+eQHyeH5MZMzFDxI=; b=vA3nbQRsL7ul/HhZjlTMujvouLngKlIbzmiRj4GkQAhhQLeSu7j84+V1XjRQjKqW66 Twd7Em3bAsarV0bStk9vkrSpEX5CK+AEtRqtZXBC95kc2ANgDVgOL1tQ99DG303LHXe1 op9tOqk82bh3Aol7qAzdZVihEJHiOxIVMqC1u9y+IY7oEo+fvssLn1zYuRPOj/Fv0dAH 4QgN6Sv7Eyps0AhUmkmyBuJI89NYmU9x3hlA8jsHb635G24brpSIKkp1mjqsOh5C/tg3 URXEzZP3+v3JOLhY033M+KGA5HSNNLlKF0OOlLhZfs7R1ndKq+7xlKFs4Re6FFAyyeYI Qo0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715006677; x=1715611477; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JcJFzkfee7mBqZtFVJndFmi3NW8+eQHyeH5MZMzFDxI=; b=Kv7lk1MsLcfClnqHLQEM76a6KGbiAAGOvfy/fzeqIIbDvPfP5AqgYN73eXtU7GElfh mGONU9kSntWm75i/yU/cGGPJSLaqbc72N4Ncfr8aIkJROUmYF9f5DK8ltpXIfiENy13B VteLN4wkjJTQmyEIEEu+91SKMf0K21gZtX8qQepVv593VKQ79OZVaeL9CcSHI5AhaSia IzHBT80jid/q1cMyE5jXKAHec+U4RqlJtmLQsz9jl4F8Lwf9ZICxpPoFqZBkbsNXTGjj Ph8fDETbnLRLLZf/ePBOuNh0JLH7pFVzsLss1FL5ABP7xDyW4WdjuaWNLf6MXxRdvxV9 YOeg== X-Forwarded-Encrypted: i=1; AJvYcCU7p+s8S9/3dzD5y59FsnNIafaNVQd5scA9lzpnsjsyPK36KveHxieYblPkBiOv4oYyfBULAagCLYQqA8EVltp8jysyosl03Xfo16ta X-Gm-Message-State: AOJu0YxV7RRjESYrl6jSR69Sl7MGKAGtha9+rNigJjyKIKBHgqt3/Tma Bf7OkZ3vXDk1Oc6+ON7F9IceJIWicKvEoqvJBqS3QGy+wTBQzww976v/NCDILyJCx80f72wTeq2 eSAiXbos2RhTU6glUMqW7Rb7htdSEWYRvNvRyXw== X-Received: by 2002:a2e:7312:0:b0:2e1:d95b:3735 with SMTP id o18-20020a2e7312000000b002e1d95b3735mr3227506ljc.11.1715006676759; Mon, 06 May 2024 07:44:36 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240501-adding-new-ad738x-driver-v6-0-3c0741154728@baylibre.com> <20240501-adding-new-ad738x-driver-v6-10-3c0741154728@baylibre.com> <20240506144616.0b90664b@jic23-huawei> In-Reply-To: <20240506144616.0b90664b@jic23-huawei> From: David Lechner Date: Mon, 6 May 2024 09:44:25 -0500 Message-ID: Subject: Re: [PATCH RFC v6 10/10] iio: adc: ad7380: add support for resolution boost To: Jonathan Cameron Cc: =?UTF-8?B?TnVubyBTw6E=?= , Julien Stephan , Lars-Peter Clausen , Michael Hennerich , =?UTF-8?B?TnVubyBTw6E=?= , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Liam Girdwood , Mark Brown , kernel test robot , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable FYI, Julien is AFK for a bit so I'll try to respond to the non-trivial comm= ents. On Mon, May 6, 2024 at 8:46=E2=80=AFAM Jonathan Cameron = wrote: > > On Mon, 06 May 2024 10:55:46 +0200 > Nuno S=C3=A1 wrote: > > > On Wed, 2024-05-01 at 16:55 +0200, Julien Stephan wrote: > > > ad738x chips are able to use an additional 2 bits of resolution when > > > using oversampling. The 14-bits chips can have up to 16 bits of > > > resolution and the 16-bits chips can have up to 18 bits of resolution= . > > > > > > In order to dynamically allow to enable/disable the resolution boost > > > feature, we have to set iio realbits/storagebits to the maximum per c= hips. > > > This means that for iio, data will always be on the higher resolution > > > available, and to cope with that we adjust the iio scale and iio offs= et > > > depending on the resolution boost status. > > > > > > The available scales can be displayed using the regular _scale_availa= ble > > > attributes and can be set by writing the regular _scale attribute. > > > The available scales depend on the oversampling status. > > > > > > Signed-off-by: Julien Stephan > > > > > > --- > > > > > > In order to support the resolution boost (additional 2 bits of resolu= tion) > > > we need to set realbits/storagebits to the maximum value i.e : > > > - realbits =3D 16 + 2 =3D 18, and storagebits =3D 32 for 16-bits ch= ips > > > - realbits =3D 14 + 2 =3D 16, and storagebits =3D 16 for 14-bits ch= ips > > > > > > For 14-bits chips this does not have a major impact, but this > > > has the drawback of forcing 16-bits chip users to always use 32-bits > > > words in buffers even if they are not using oversampling and resoluti= on > > > boost. Is there a better way of implementing this? For example > > > implementing dynamic scan_type? > > > > > > > Yeah, I don't think it's that bad in this case. But maybe dynamic scan = types is > > something we may need at some point yes (or IOW that I would like to se= e supported > > :)). We do some ADCs (eg: ad4630) where we use questionably use FW prop= erties to set > > a specific operating mode exactly because we have a different data layo= ut (scan > > elements) depending on the mode. > > Yeah. Fixed scan modes were somewhat of a bad design decision a long time= back. > However, the big advantage is that it got people to think hard about whet= her it is > worth supporting low precision modes. For slow devices it very rarely is = and > forcing people to make a decision and the advantage we never supported > low precision on those parts. > > Having said that there are good reasons for dynamic resolution changing > (the main one being the storage case you have here) so I'd be happy to > see some patches adding it. It might be easier than I've always thought > to bolt on. > > This and inkernel event consumers have been the two significant features > where I keep expecting it to happen, but every time people decide they re= ally > don't care enough to make them work :( > Supposing we knew someone willing and able :-) ... Do you have any specific requirements for how dynamic resolution changing should work? Any particular sticky points we should watch out for? I'm assuming this would just affect the bufferY/*_type attributes, i.e. if you write a channel scale attribute to change the resolution, then the scan_type info may change and the bufferY/*_type would need to be read again.