From nobody Fri Dec 19 17:55:48 2025 Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) (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 57B541F463A for ; Mon, 26 May 2025 10:04:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748253886; cv=none; b=tb7EGBVPGKB/7WiXQYFBd4FcWfEVAI+Dbs0E9V+Jpomi328Plou/E8rB5leA96bL3rEKk3s4QxGq3k8+7o7BZaI1b65PoE0Ro3U7SRfLGIDH8Y0wVBGs4CefOjMcqCO4wSxYMgE2lFlnqBgE/0N9yWcXyqYH/pRf5Mg7EflKBFQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748253886; c=relaxed/simple; bh=vFlQmUYfvlbdocc1660HFvFkLaTTtU9EJLRp4LGDp64=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=YdmP3Y71ebaTn9EVWFVxccCyT/QyHjQder1k1TLJHRwOL9xq6/aLH8EcujK+fuGcGktT/ENoEeP6CpP9R9BtqcswDaSCP30TBTYxq0KODzaZIWiQIF7IY+9FWVpesMtL2vBUKp7GCPceqS1UF8nX419kcL7ls27MpitflEYc4xs= 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=SgetagGs; arc=none smtp.client-ip=209.85.221.47 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="SgetagGs" Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-3a4d877dfb3so922481f8f.1 for ; Mon, 26 May 2025 03:04:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1748253882; x=1748858682; 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=q8aakW4/a4S4nlb27SNIiYOlQ/gC3M9NtCJYtqbcxPc=; b=SgetagGs8PSOW6gjJUzHNSL5KPbyJ1sL9I2V/IWqwD9YnWWb+38p2+oQ5gavmbAq2R Cos+w2j0ZKhg7kX6jByUIJe0/VkA0DW7Gh+YevRwbNaSY6L+AsWY6l7Hh6ctUTCK34Fa zYwtbajXaADGRALvhHLSEQLtgfD7E6zJvvSP27ZJcJH9aSK3nrTHNGAfVLQ1QIkCGZ92 VOzV4eNytJypC2RL+fhijepz5q6co6urg0mTcKb0/fglon9LLv3etlyz2oXCNUMzdv1A 7iDLafPdp561ZoLxGNWDMhRB+PHnnU18E3shRmU4hudOlmx75TP1k1fWSzzovZUCOoed pj8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748253882; x=1748858682; 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=q8aakW4/a4S4nlb27SNIiYOlQ/gC3M9NtCJYtqbcxPc=; b=Ddlxte+uURhMcEHh4yYalhbpbHjE9ULaVgsmTGM/6hX6yRmc7g321wvlStAvi1YUjI 0wgAlMc9EHf373Eo1PwQLvYRLMfep2FsokT5etYUat3zlwQuDYbdnbhCQGtY3P354UrY Jq5eKgYxsycu9R6fufXF5oxP+ewbjAvnuBQ9XKcq4ow+NJgDEAEqtJVD1MMdl3wVq16x l3+8j+klwp98XC3/zjYtKtWqktMA5mxqZEl9oVnz19LICHeUgvkOaU5ywqpFaODcOXMx zCIn4un/V9aqTNFztPHhpj6ov7LwYYVpN3Hj/s4rz1hQ2v7HUKSdxXO3eqQDXgb/zeIC /iFQ== X-Forwarded-Encrypted: i=1; AJvYcCUnKCzX9RsGm2o/rMVc8PmvpCPLs59xRBziRWNDVqfWD1FiwRSftECMhzEgN8IxZA9zMLI54nNOZh8uHi0=@vger.kernel.org X-Gm-Message-State: AOJu0YyeMO/eQzLFwi/lRuSaZcLGLhY3ReFowgjIQEjS08T/Zb2GttVc q/VgdS9y8xF1MkFM8iqOR3YWmYBGiANwuPkG9GecyoORxazxpSgi8FTZ1zUdRqZEtMA= X-Gm-Gg: ASbGncvxwFpgfOEXjwtz0kuD8cYrhVCT7mKVOCxPxlpigjbwHILQ3LNdWYWnE5PazPJ ePzTCrqT0HuGNpK+ouh3dJ+v+1I3cfbyOGE5e3D8mjBulYEmSi5RJNB5z/CBJUfTXTYEcjM5XNN w/on7zi6F08vo5b03aERQdcmCS4RuEpTsKfKM720pogLtFkYD6/UeCkp7WlOIWoWCIJ12gXd92S flkTZAMHl9lyY0gxFX9ux7Pl/tXCWHQf7hYD2h1vLijc9dtzqJb673BPJo3pnY8rP4MUddPB6uY oOXkZ5G9BNwKGgmH2ltddjog3+6oak6307bh/uTRex1sC9tGpOocRWfTworBBNK8qpj7Ub1pc3R dzND2HnPUiMLOri+A1KaEZFT3ufVa528= X-Google-Smtp-Source: AGHT+IHV9Jp069LZjK2ZpV1/c9KQ2bNBfj2JjLVwtRuY/y1IZo9228sqOpSdgVRYYQ5s3ofRpZ1qNg== X-Received: by 2002:a05:6000:2890:b0:3a4:d7ba:940f with SMTP id ffacd0b85a97d-3a4d7ba9678mr2708636f8f.8.1748253882426; Mon, 26 May 2025 03:04:42 -0700 (PDT) Received: from [192.168.0.2] (host-80-116-51-117.retail.telecomitalia.it. [80.116.51.117]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3a35ca888fcsm36141834f8f.78.2025.05.26.03.04.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 May 2025 03:04:41 -0700 (PDT) From: Angelo Dureghello X-Google-Original-From: Angelo Dureghello Date: Mon, 26 May 2025 12:03:16 +0200 Subject: [PATCH v7 1/6] Documentation: ABI: IIO: add calibconv_delay documentation 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: <20250526-wip-bl-ad7606-calibration-v7-1-b487022ce199@baylibre.com> References: <20250526-wip-bl-ad7606-calibration-v7-0-b487022ce199@baylibre.com> In-Reply-To: <20250526-wip-bl-ad7606-calibration-v7-0-b487022ce199@baylibre.com> To: Jonathan Cameron , David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko , Lars-Peter Clausen , Michael Hennerich , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Hennerich , devicetree@vger.kernel.org, Angelo Dureghello X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1850; i=adureghello@baylibre.com; h=from:subject:message-id; bh=m1V9a4luyCqmxst4hAeMv2hk5LxVMC81ZTSMIekPDQ4=; b=owGbwMvMwCXGf3bn1e/btlsznlZLYsgwscm+fy5Mqzei19Suf4fkFLsQo8JKtimLciJnL1fVv jD/l71ZRykLgxgXg6yYIktdYoRJ6O1QKeUFjLNh5rAygQxh4OIUgIlcuMHIcCtPn2N1a1fJdps5 zQYczLLeXObN5X1tyVenx8b8/N27ieF/za/ClMUGpWdEI1I6DNz1f95U+JrCdjH5T39aaHUP6ww eAA== X-Developer-Key: i=adureghello@baylibre.com; a=openpgp; fpr=703CDFAD8B573EB00850E38366D1CB9419AF3953 From: Angelo Dureghello Add new IIO "convdelay" documentation. The ad7606 implements a phase calibation feature, in nanoseconds. Being this a time delay, using the convdelay suffix. Signed-off-by: Angelo Dureghello --- Documentation/ABI/testing/sysfs-bus-iio | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/te= sting/sysfs-bus-iio index ef52c427a015cf47bb9847782e13afbee01e9f31..7e59cbd5acb85fd0909c1d56f9d= 76a84933d418a 100644 --- a/Documentation/ABI/testing/sysfs-bus-iio +++ b/Documentation/ABI/testing/sysfs-bus-iio @@ -559,6 +559,30 @@ Description: - a small discrete set of values like "0 2 4 6 8" - a range specified as "[min step max]" =20 +What: /sys/bus/iio/devices/iio:deviceX/in_voltageY_convdelay +KernelVersion: 6.16 +Contact: linux-iio@vger.kernel.org +Description: + Delay of start of conversion from common reference point shared + by all channels. Can be writable when used to compensate for + delay variation introduced by external filters feeding a + simultaneous sampling ADC. + + E.g., for the ad7606 ADC series, this value is intended as a + configurable time delay in seconds, to correct delay introduced + by an optional external filtering circuit. + +What: /sys/bus/iio/devices/iio:deviceX/in_voltageY_convdelay_available +KernelVersion: 6.16 +Contact: linux-iio@vger.kernel.org +Description: + Available values of convdelay. Maybe expressed as: + + - a range specified as "[min step max]" + + If shared across all channels, _convdelay_available + is used. + What: /sys/bus/iio/devices/iio:deviceX/in_accel_x_calibscale What: /sys/bus/iio/devices/iio:deviceX/in_accel_y_calibscale What: /sys/bus/iio/devices/iio:deviceX/in_accel_z_calibscale --=20 2.49.0 From nobody Fri Dec 19 17:55:48 2025 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (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 E67F21F4C94 for ; Mon, 26 May 2025 10:04:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748253887; cv=none; b=nKVSHBbybf23RBrcy5hlqZYtikR9Nw3g41xNkX51ddHAmokjd4na/C0L5RtUn24fE+E0O+SH6YdNPD2eWO6EgX2t18QH2bG+UEAy++rePbePERuh5cm5dl+58FBrAgBFfhw8q0YOOqaCWVXulZcN5gTuhk59XLTWyDThvTnvu6Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748253887; c=relaxed/simple; bh=8DecWNX9a+g7ci97Vv7IU6U85+eTrGoiJDNqhMLAwD0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=kqnEQ7CYRfwKU2EAqXyAXIAUQrq72tyEX5iA3pPU7R3a1MjLYie3L3ixL6p/j2BpG/0VAZ9KpMnHY1urbk06S+8QcQ3OkWbii30NfrTp3YGXRu9i6JRlFq367PshYAR/zWZAjI7G/9v4Zvb8g6VborQ7th0SuKGBFI3XNhVDk7A= 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=poVyDTgq; arc=none smtp.client-ip=209.85.128.51 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="poVyDTgq" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-43cfe574976so15362095e9.1 for ; Mon, 26 May 2025 03:04:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1748253884; x=1748858684; 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=gQIoahuutc2qqjFxwM4CJBJC7cg2fQ/5cUj9Q0XSXuA=; b=poVyDTgqw+zz+w5FMFviTkNxA7NFu8dORMQmv+3wvDYXcAIckkKIVBaufODYroq4Uh 4GhEgbrNqeOB/iybIa/CxCm5fLcLxxbybU3v5WlQNGRWIuSMiVP65eZfiUSO3bV23jCc 8SDuQd9YT0TxxjJzrIIQEcrC5OuEmD9aFgI1/hjuC+wr3gJoV1MkfpCIeEBrWSMUTWvK soJGnCJ97+OAaLGkx1btu7TrcIi7KASz5h8wZil9l7t6tZWBz1P37lRxMSWZtMrJozJd 0sZQyyoiESlQy0tfbHX86YWH8i+DNBqz3ROtCqcfkMVq/mxWBgM9cnBR7mXi799AS4aU BnOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748253884; x=1748858684; 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=gQIoahuutc2qqjFxwM4CJBJC7cg2fQ/5cUj9Q0XSXuA=; b=k5NQJ2V/wowbg+6d499VGXVmPXk7RMY3NnoYgfJen6KyIn/qIVTMjNrU3WB+BbtrBa nyB6r/82+U3b488EhQ/CU36PCSR/m3oHHtfvIULmQt4CKgdbH69uS385UcSqnWwSyNNH CQWhlcOfU/Y76e4T8QnBFKmCVQhrw0MfXHnuGeAa6KxUY+lZyeOnY8q1QjGV/2BJdEGO /f0ESXge192GhEoOJcDjfTiACX8AJSNJ1YflT/MQVPRkxNypsWFelAaAgYBrlp5YVlJM inw7WE/IaJVh6wdh5Fy626NtUXakvUx7nwXifuWfpb+pjjJh97pS/IukE1MlzMDDYl2n tC9A== X-Forwarded-Encrypted: i=1; AJvYcCWEuZrQsO8BMk6AHz5t4K4mF2/qFCkS+QWNHGQgT6Okw2gaWFg6JmLZfuJF0TxICgUFF/6w9cIk4MxmIkI=@vger.kernel.org X-Gm-Message-State: AOJu0YxYHeDezB5mIG/irBbULplhko7AJwcCUfoOo/4QbV1oTB6cfh/u m2accU9NDRB2vPyJ9PqXxK/nhSqSkPdu8FG3pfucf4s+BBTDLh56dMMoVs7J0Bf9zXM= X-Gm-Gg: ASbGnctTOmBfPNXZYI7Mi2HgFn2h5tPxOFm03VXi4GqJgJE0DENhA5kjQUu/qJ18dkp TvkWx+HiL1Uw02o5tAWZ6FP+WdchflC5IbU/TCW4dLS999ntKe41+ZysrRBgffO80vcoufuBkv2 +faiw3v3Bbbc7rqofIK21bk06mn4O/JRQpUfCwZ/qWL6bCLf8VyUrlPoPdij5BfYuT9P5odhgeU 91CbSGYcSAdgSa2CqEveoTwtK5h+7scGETi67I4pJT6GITQ0eFqE1Rx+oi9w6Bx4bBsk3TaLILO nS91GoE/NxVEV/i5qu5moPfjoNbKBevTc4jdIbLXTmIkYt3BLjH01RWvB8MZtGNmJB5FCA0CXzW dyKHG1e/3OL9DzlwsRtYqRN+sxTWrVvk= X-Google-Smtp-Source: AGHT+IHYhcuJ5tJUzW+X1N6tLbm3m4NFLOMHI70/u9217nBb1JvAuUOsKFYkUSxnI3msJC2yE8u0Pg== X-Received: by 2002:a05:6000:4211:b0:3a3:7bad:29cb with SMTP id ffacd0b85a97d-3a4cb499ce9mr7666683f8f.52.1748253884092; Mon, 26 May 2025 03:04:44 -0700 (PDT) Received: from [192.168.0.2] (host-80-116-51-117.retail.telecomitalia.it. [80.116.51.117]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3a35ca888fcsm36141834f8f.78.2025.05.26.03.04.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 May 2025 03:04:43 -0700 (PDT) From: Angelo Dureghello X-Google-Original-From: Angelo Dureghello Date: Mon, 26 May 2025 12:03:17 +0200 Subject: [PATCH v7 2/6] iio: core: add ADC delay calibration definition 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: <20250526-wip-bl-ad7606-calibration-v7-2-b487022ce199@baylibre.com> References: <20250526-wip-bl-ad7606-calibration-v7-0-b487022ce199@baylibre.com> In-Reply-To: <20250526-wip-bl-ad7606-calibration-v7-0-b487022ce199@baylibre.com> To: Jonathan Cameron , David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko , Lars-Peter Clausen , Michael Hennerich , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Hennerich , devicetree@vger.kernel.org, Angelo Dureghello X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1303; i=adureghello@baylibre.com; h=from:subject:message-id; bh=4Hb5fAw6wk9UOyjGvMGWLBgqM5yKlaYwdF7azoNoMts=; b=owGbwMvMwCXGf3bn1e/btlsznlZLYsgwsck+Y36919jPLE56vYtxsKVOoPxZ0YUJmbsMZYT27 D98c8L7jlIWBjEuBlkxRZa6xAiT0NuhUsoLGGfDzGFlAhnCwMUpABMRrGb4xXR166u8b6/zXyc2 z2cQsgqZmpa/YfefM//nze98mTpj6wuGfwqn6tht+/hjAn4zSbQkH0tan7q5dZVvgY79w6Itgsv 9OQE= X-Developer-Key: i=adureghello@baylibre.com; a=openpgp; fpr=703CDFAD8B573EB00850E38366D1CB9419AF3953 From: Angelo Dureghello ADCs as ad7606 implement a phase calibration as a delay. Add such definition, needed for ad7606. Signed-off-by: Angelo Dureghello --- drivers/iio/industrialio-core.c | 1 + include/linux/iio/types.h | 1 + 2 files changed, 2 insertions(+) diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-cor= e.c index 178e99b111debc59a247fcc3a6037e429db3bebf..f13c3aa470d774bfe655d6a9fb0= 0c263789db637 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -188,6 +188,7 @@ static const char * const iio_chan_info_postfix[] =3D { [IIO_CHAN_INFO_CALIBAMBIENT] =3D "calibambient", [IIO_CHAN_INFO_ZEROPOINT] =3D "zeropoint", [IIO_CHAN_INFO_TROUGH] =3D "trough_raw", + [IIO_CHAN_INFO_CONVDELAY] =3D "convdelay", }; /** * iio_device_id() - query the unique ID for the device diff --git a/include/linux/iio/types.h b/include/linux/iio/types.h index d89982c98368cf72c0fc30fa66ab001e48af4e8b..ad2761efcc8315e1f9907d2a715= 9447fb463333e 100644 --- a/include/linux/iio/types.h +++ b/include/linux/iio/types.h @@ -69,6 +69,7 @@ enum iio_chan_info_enum { IIO_CHAN_INFO_CALIBAMBIENT, IIO_CHAN_INFO_ZEROPOINT, IIO_CHAN_INFO_TROUGH, + IIO_CHAN_INFO_CONVDELAY, }; =20 #endif /* _IIO_TYPES_H_ */ --=20 2.49.0 From nobody Fri Dec 19 17:55:48 2025 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (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 982E01F561D for ; Mon, 26 May 2025 10:04:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748253889; cv=none; b=OBVt8sBSVXN8vGDK3X94mh8WzDjnsFlYSpsp5Y0+MxZP6wXN2cOn7YoGAzK/QWYceqAhOwZFXv3xKxTtMIF+GFFgzEk7X4exgvkwu3PmGJ46rMGgkG8nIAX/nWVLBOxNsKW87ZxrYBqzaJJHoMVcrSBW0TG7rKR3kPVX2l7qFas= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748253889; c=relaxed/simple; bh=2azLLT6Wl9lmdAY2gUDc3q4we51Qw8kCL+zkngW3kNk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=gYknjqEgNY3+VM1pJ+HwpJ81cdmVeAXkAFKpY80NxNdfVeKyQx2zAPtAcvfFg46P2Yw7xazOKyeub/WaWpsMlBcICXk88nm9Ii5YasjRgU8r6YQdtZd9ROparhleIg4VwFmVa+rXFwIqys31SQXjh2lwzwdLBKzOzyn4Zfc5wns= 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=AFKn0j3i; arc=none smtp.client-ip=209.85.128.45 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="AFKn0j3i" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-443a787bd14so22265555e9.1 for ; Mon, 26 May 2025 03:04:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1748253886; x=1748858686; 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=wMvWRztU2bT3jdc78LuAKwUny9eARoeuG/PTskSOq+A=; b=AFKn0j3iXMjtVOrfOAVQ7RyuCaxsefYnupI0snh3sb3Mq8U/k02XvKpb88iVeUtMxX uwCUlXX9hiLN6XbMOAciGSwt0/18npsNMv5+MskTf1rDPZjC0E1Se30dc/yruBWqGKL0 eNxiJreQ243Ml70wCTFDokBG5lS2TbuXSgSKl4MsaY3kpQcwdh1RaZgfRT7jH9O1M1Gm BgT7v01gdvxDsrlWoSt2XcwFrAflQonsThdFiBmFVsfzyK4QzFBgbeU3/LJFcX81kL4t iPvq1mVXjZi1tghiGHsmi7m7eOHyFIFLOAt0mH0arHcnLoCMksBH7z5dwDHRiWHOHgsX 3ReQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748253886; x=1748858686; 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=wMvWRztU2bT3jdc78LuAKwUny9eARoeuG/PTskSOq+A=; b=Wr5uD5jrlJ9roDbMeCBfiAbo8NPe030tl6Alg3lkExVR6UIXva/fC05CbZTP0yOQ0E cBlHZ2N63PiMLIHoQqK3jbMACDGVM6FyCV3zuRrOkg+JtBQ76XtqNxgDFgbfKwVi52CB b+HtW0UIgxLZA7H2ePQ9Macbq4Em7udndU2qJBAFtMWb4StBxOkpI5HKY9GsaIr+/uG8 FBCDKnnzXVHYM8aYF3HHYp19WWrRVbdbtHK/YByvUVYKVWTGBfplcBE8k/sH5fJrU3hw XkSvJY25MQZEwlSH9PSMoWw+xD46uCgA+4LbwXRuo93snTbCIsfT8tguv9rlSae+Btdc 6vMw== X-Forwarded-Encrypted: i=1; AJvYcCXjGpxT0Hmwg4Y00/DdkXdmMbR/I1dL/CSJrg6RNoq0ilWEzTcoeJ8zcg4nFfxQr26t/PO66NcGVtSrSYQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yxv7MXGARomkdkBRl98bcm3bbSL7+BQnIPUxzJ6HjuG6vzUdQty OlcAWRteyvIAIm2vYFU7vQ121F/d+GEFPv3ju97uV4dMIP7UifMnyy6lDQrHRxbq+d4= X-Gm-Gg: ASbGncvjIkzcVmTxkP3Cu4Sac5kKfL27jmxTzY/zkBQ7GOuXhfulB5ajQ607EJh14fc ciAqCBrU58ueWxnQzfrelxb1rOnD8Q5827ZIYZJ0jRXu1B58wYICsbGiNV1jvL2xUvDNIdPIFNu w50qcDW6/Gc8/gebe8M9jSP0xM8pUsKvyIzPIxZ9X9LWKzLA/bL5x+kvUh3DPtMVklioeaVsx+4 E/bqxq1dc5r9Mmq2nO3mkiN8UsrbChGzV7P9eMkPLjteA2/cnJpX0ZdB+sg6AA0HaP43CWmvg1a /2+w48DOzUVrcoN3NfyGuUcatOpHjvM183zJJcULWIZ4BUMT+Roi81Vtl9sGyD5kowJvTQoX5yu Wkf29aX5D68eh5naJsaWsWQ2Cs16/kRY= X-Google-Smtp-Source: AGHT+IE7Sk6MrfGHd3O49qN4Wa60Xv/AfdNvaB0B+9efGH3Ug55F7/ta01Bz1zfRDys201MY42YW8g== X-Received: by 2002:a5d:4ec9:0:b0:3a4:d0ed:2554 with SMTP id ffacd0b85a97d-3a4d0ed2760mr4943668f8f.9.1748253885718; Mon, 26 May 2025 03:04:45 -0700 (PDT) Received: from [192.168.0.2] (host-80-116-51-117.retail.telecomitalia.it. [80.116.51.117]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3a35ca888fcsm36141834f8f.78.2025.05.26.03.04.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 May 2025 03:04:45 -0700 (PDT) From: Angelo Dureghello X-Google-Original-From: Angelo Dureghello Date: Mon, 26 May 2025 12:03:18 +0200 Subject: [PATCH v7 3/6] iio: adc: ad7606: add offset and phase calibration 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: <20250526-wip-bl-ad7606-calibration-v7-3-b487022ce199@baylibre.com> References: <20250526-wip-bl-ad7606-calibration-v7-0-b487022ce199@baylibre.com> In-Reply-To: <20250526-wip-bl-ad7606-calibration-v7-0-b487022ce199@baylibre.com> To: Jonathan Cameron , David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko , Lars-Peter Clausen , Michael Hennerich , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Hennerich , devicetree@vger.kernel.org, Angelo Dureghello X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=9455; i=adureghello@baylibre.com; h=from:subject:message-id; bh=m8KvlzK04oJDHf4rtyOO7VisfkGK5WgMZB7GZsUOf6s=; b=owGbwMvMwCXGf3bn1e/btlsznlZLYsgwscl+YL5VSG0G74HU/NOnvuqqHljoHXyu8e5LvYrVn fLbw83fdJSyMIhxMciKKbLUJUaYhN4OlVJewDgbZg4rE8gQBi5OAZjIvEKG/zkr5n54nz/fzUta 1evRrLVOk8w0l0YleG+3cYmYdTN0bzkjw5623QfDyz/d5krif104b8mkF8XnVv9bOXPulrwZd1f r9HIAAA== X-Developer-Key: i=adureghello@baylibre.com; a=openpgp; fpr=703CDFAD8B573EB00850E38366D1CB9419AF3953 From: Angelo Dureghello Add support for offset and phase calibration, only for devices that support software mode, that are: ad7606b ad7606c-16 ad7606c-18 Tested-by: David Lechner Reviewed-by: Nuno S=C3=A1 Signed-off-by: Angelo Dureghello --- drivers/iio/adc/ad7606.c | 160 +++++++++++++++++++++++++++++++++++++++++++= ++++ drivers/iio/adc/ad7606.h | 9 +++ 2 files changed, 169 insertions(+) diff --git a/drivers/iio/adc/ad7606.c b/drivers/iio/adc/ad7606.c index 185243dee86ed2e9ebc43b578003d0c010e97a9f..9a9bef0cfbb37138f71ba5b1bab= eaa423eaf4d5a 100644 --- a/drivers/iio/adc/ad7606.c +++ b/drivers/iio/adc/ad7606.c @@ -95,6 +95,22 @@ static const unsigned int ad7616_oversampling_avail[8] = =3D { 1, 2, 4, 8, 16, 32, 64, 128, }; =20 +static const int ad7606_calib_offset_avail[3] =3D { + -128, 1, 127, +}; + +static const int ad7606c_18bit_calib_offset_avail[3] =3D { + -512, 4, 508, +}; + +static const int ad7606b_calib_phase_avail[][2] =3D { + { 0, 0 }, { 0, 1250 }, { 0, 318750 }, +}; + +static const int ad7606c_calib_phase_avail[][2] =3D { + { 0, 0 }, { 0, 1000 }, { 0, 255000 }, +}; + static int ad7606c_18bit_chan_scale_setup(struct iio_dev *indio_dev, struct iio_chan_spec *chan); static int ad7606c_16bit_chan_scale_setup(struct iio_dev *indio_dev, @@ -164,6 +180,8 @@ const struct ad7606_chip_info ad7606b_info =3D { .scale_setup_cb =3D ad7606_16bit_chan_scale_setup, .sw_setup_cb =3D ad7606b_sw_mode_setup, .offload_storagebits =3D 32, + .calib_offset_avail =3D ad7606_calib_offset_avail, + .calib_phase_avail =3D ad7606b_calib_phase_avail, }; EXPORT_SYMBOL_NS_GPL(ad7606b_info, "IIO_AD7606"); =20 @@ -177,6 +195,8 @@ const struct ad7606_chip_info ad7606c_16_info =3D { .scale_setup_cb =3D ad7606c_16bit_chan_scale_setup, .sw_setup_cb =3D ad7606b_sw_mode_setup, .offload_storagebits =3D 32, + .calib_offset_avail =3D ad7606_calib_offset_avail, + .calib_phase_avail =3D ad7606c_calib_phase_avail, }; EXPORT_SYMBOL_NS_GPL(ad7606c_16_info, "IIO_AD7606"); =20 @@ -226,6 +246,8 @@ const struct ad7606_chip_info ad7606c_18_info =3D { .scale_setup_cb =3D ad7606c_18bit_chan_scale_setup, .sw_setup_cb =3D ad7606b_sw_mode_setup, .offload_storagebits =3D 32, + .calib_offset_avail =3D ad7606c_18bit_calib_offset_avail, + .calib_phase_avail =3D ad7606c_calib_phase_avail, }; EXPORT_SYMBOL_NS_GPL(ad7606c_18_info, "IIO_AD7606"); =20 @@ -681,6 +703,40 @@ static int ad7606_scan_direct(struct iio_dev *indio_de= v, unsigned int ch, return ret; } =20 +static int ad7606_get_calib_offset(struct ad7606_state *st, int ch, int *v= al) +{ + int ret; + + ret =3D st->bops->reg_read(st, AD7606_CALIB_OFFSET(ch)); + if (ret < 0) + return ret; + + *val =3D st->chip_info->calib_offset_avail[0] + + ret * st->chip_info->calib_offset_avail[1]; + + return 0; +} + +static int ad7606_get_calib_phase(struct ad7606_state *st, int ch, int *va= l, + int *val2) +{ + int ret; + + ret =3D st->bops->reg_read(st, AD7606_CALIB_PHASE(ch)); + if (ret < 0) + return ret; + + *val =3D 0; + + /* + * ad7606b: phase delay from 0 to 318.75 =CE=BCs in steps of 1.25 =CE=BCs. + * ad7606c-16/18: phase delay from 0 =C2=B5s to 255 =C2=B5s in steps of 1= =C2=B5s. + */ + *val2 =3D ret * st->chip_info->calib_phase_avail[1][1]; + + return 0; +} + static int ad7606_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int *val, @@ -715,6 +771,22 @@ static int ad7606_read_raw(struct iio_dev *indio_dev, pwm_get_state(st->cnvst_pwm, &cnvst_pwm_state); *val =3D DIV_ROUND_CLOSEST_ULL(NSEC_PER_SEC, cnvst_pwm_state.period); return IIO_VAL_INT; + case IIO_CHAN_INFO_CALIBBIAS: + if (!iio_device_claim_direct(indio_dev)) + return -EBUSY; + ret =3D ad7606_get_calib_offset(st, chan->scan_index, val); + iio_device_release_direct(indio_dev); + if (ret) + return ret; + return IIO_VAL_INT; + case IIO_CHAN_INFO_CONVDELAY: + if (!iio_device_claim_direct(indio_dev)) + return -EBUSY; + ret =3D ad7606_get_calib_phase(st, chan->scan_index, val, val2); + iio_device_release_direct(indio_dev); + if (ret) + return ret; + return IIO_VAL_INT_PLUS_NANO; } return -EINVAL; } @@ -765,6 +837,64 @@ static int ad7606_write_os_hw(struct iio_dev *indio_de= v, int val) return 0; } =20 +static int ad7606_set_calib_offset(struct ad7606_state *st, int ch, int va= l) +{ + int start_val, step_val, stop_val; + int offset; + + start_val =3D st->chip_info->calib_offset_avail[0]; + step_val =3D st->chip_info->calib_offset_avail[1]; + stop_val =3D st->chip_info->calib_offset_avail[2]; + + if (val < start_val || val > stop_val) + return -EINVAL; + + offset =3D (val - start_val) / step_val; + + return st->bops->reg_write(st, AD7606_CALIB_OFFSET(ch), offset); +} + +static int ad7606_set_calib_phase(struct ad7606_state *st, int ch, int val, + int val2) +{ + int wreg, start_ns, step_ns, stop_ns; + + if (val !=3D 0) + return -EINVAL; + + start_ns =3D st->chip_info->calib_phase_avail[0][1]; + step_ns =3D st->chip_info->calib_phase_avail[1][1]; + stop_ns =3D st->chip_info->calib_phase_avail[2][1]; + + /* + * ad7606b: phase delay from 0 to 318.75 =CE=BCs in steps of 1.25 =CE=BCs. + * ad7606c-16/18: phase delay from 0 =C2=B5s to 255 =C2=B5s in steps of 1= =C2=B5s. + */ + if (val2 < start_ns || val2 > stop_ns) + return -EINVAL; + + wreg =3D val2 / step_ns; + + return st->bops->reg_write(st, AD7606_CALIB_PHASE(ch), wreg); +} + +static int ad7606_write_raw_get_fmt(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, long info) +{ + switch (info) { + case IIO_CHAN_INFO_SCALE: + return IIO_VAL_INT_PLUS_MICRO; + case IIO_CHAN_INFO_SAMP_FREQ: + case IIO_CHAN_INFO_OVERSAMPLING_RATIO: + case IIO_CHAN_INFO_CALIBBIAS: + return IIO_VAL_INT; + case IIO_CHAN_INFO_CONVDELAY: + return IIO_VAL_INT_PLUS_NANO; + default: + return -EINVAL; + } +} + static int ad7606_write_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int val, @@ -818,6 +948,18 @@ static int ad7606_write_raw(struct iio_dev *indio_dev, if (val < 0 && val2 !=3D 0) return -EINVAL; return ad7606_set_sampling_freq(st, val); + case IIO_CHAN_INFO_CALIBBIAS: + if (!iio_device_claim_direct(indio_dev)) + return -EBUSY; + ret =3D ad7606_set_calib_offset(st, chan->scan_index, val); + iio_device_release_direct(indio_dev); + return ret; + case IIO_CHAN_INFO_CONVDELAY: + if (!iio_device_claim_direct(indio_dev)) + return -EBUSY; + ret =3D ad7606_set_calib_phase(st, chan->scan_index, val, val2); + iio_device_release_direct(indio_dev); + return ret; default: return -EINVAL; } @@ -996,6 +1138,14 @@ static int ad7606_read_avail(struct iio_dev *indio_de= v, *type =3D IIO_VAL_INT_PLUS_MICRO; =20 return IIO_AVAIL_LIST; + case IIO_CHAN_INFO_CALIBBIAS: + *vals =3D st->chip_info->calib_offset_avail; + *type =3D IIO_VAL_INT; + return IIO_AVAIL_RANGE; + case IIO_CHAN_INFO_CONVDELAY: + *vals =3D (const int *)st->chip_info->calib_phase_avail; + *type =3D IIO_VAL_INT_PLUS_NANO; + return IIO_AVAIL_RANGE; } return -EINVAL; } @@ -1058,6 +1208,7 @@ static const struct iio_info ad7606_info_sw_mode =3D { .read_raw =3D &ad7606_read_raw, .write_raw =3D &ad7606_write_raw, .read_avail =3D &ad7606_read_avail, + .write_raw_get_fmt =3D ad7606_write_raw_get_fmt, .debugfs_reg_access =3D &ad7606_reg_access, .validate_trigger =3D &ad7606_validate_trigger, .update_scan_mode =3D &ad7606_update_scan_mode, @@ -1250,6 +1401,15 @@ static int ad7606_probe_channels(struct iio_dev *ind= io_dev) chan->info_mask_separate_available |=3D BIT(IIO_CHAN_INFO_SCALE); =20 + if (st->chip_info->calib_offset_avail) { + chan->info_mask_separate |=3D + BIT(IIO_CHAN_INFO_CALIBBIAS) | + BIT(IIO_CHAN_INFO_CONVDELAY); + chan->info_mask_separate_available |=3D + BIT(IIO_CHAN_INFO_CALIBBIAS) | + BIT(IIO_CHAN_INFO_CONVDELAY); + } + /* * All chips with software mode support oversampling, * so we skip the oversampling_available check. And the diff --git a/drivers/iio/adc/ad7606.h b/drivers/iio/adc/ad7606.h index 441e62c521bcbea69b4f70bb2d55f65334d22276..f613583a7fa4095115b0b28e3f8= e51cd32b93524 100644 --- a/drivers/iio/adc/ad7606.h +++ b/drivers/iio/adc/ad7606.h @@ -40,6 +40,11 @@ #define AD7606_RANGE_CH_ADDR(ch) (0x03 + ((ch) >> 1)) #define AD7606_OS_MODE 0x08 =20 +#define AD7606_CALIB_GAIN(ch) (0x09 + (ch)) +#define AD7606_CALIB_GAIN_MASK GENMASK(5, 0) +#define AD7606_CALIB_OFFSET(ch) (0x11 + (ch)) +#define AD7606_CALIB_PHASE(ch) (0x19 + (ch)) + struct ad7606_state; =20 typedef int (*ad7606_scale_setup_cb_t)(struct iio_dev *indio_dev, @@ -61,6 +66,8 @@ typedef int (*ad7606_sw_setup_cb_t)(struct iio_dev *indio= _dev); * @init_delay_ms: required delay in milliseconds for initialization * after a restart * @offload_storagebits: storage bits used by the offload hw implementation + * @calib_offset_avail: pointer to offset calibration range/limits array + * @calib_phase_avail: pointer to phase calibration range/limits array */ struct ad7606_chip_info { unsigned int max_samplerate; @@ -74,6 +81,8 @@ struct ad7606_chip_info { bool os_req_reset; unsigned long init_delay_ms; u8 offload_storagebits; + const int *calib_offset_avail; + const int (*calib_phase_avail)[2]; }; =20 /** --=20 2.49.0 From nobody Fri Dec 19 17:55:48 2025 Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (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 2264F1F8691 for ; Mon, 26 May 2025 10:04:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748253891; cv=none; b=NhVN9VrEoACyFUPmi2XwMD69Hh3SWgSFMw7XUuGEuhdjtDBQFkhOP1f7NQW0L1T8zFA9hP69/6eVztqs/5rnhz7Sk3jKSBzVgCx109gx/KsxJpWnoU2crq+48TqEQSIYymwWLVhrjAKu5/Wq8whKcZtu/MHUCye6W1NxONGhtf0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748253891; c=relaxed/simple; bh=NtotUFQE861trIH/6KVUMJlh1RHFkSekY2PpGsDNTzs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=t5iCSYbvWx/QODDYymCi1kJEtIR3OJaHE6xOx381kuOBVQQqQL8uMnrMp6YU7w78KijMGeSuHiJLNtVMZKKoo3q/5oV7+Z+oz8G1pJhBeKItz5dqOb0vjoa2AKyYpqsDFVkNbKOyAvA7KkdQixG7R0+8YgQJQFCeQhEE3eVxokA= 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=o0jsoBbf; arc=none smtp.client-ip=209.85.221.48 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="o0jsoBbf" Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-3a4c95fc276so2563441f8f.3 for ; Mon, 26 May 2025 03:04:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1748253887; x=1748858687; 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=SSPYC82OHD2BI/YU/tjmuoLa3AQcRKZBypSGl/10x2A=; b=o0jsoBbftCNkm1tWipDjGTD4d77bFelWzlz6BthrIpxIG6KsMoDaXdQIT1nikyuWvC KDHJj6/fi+zgd8BDJXYcEJIBVmATe4/oukrqYaf8+9EubpjpOtJepwO5CIexNEsbdNSv RShnFJkPu4/FZjJKBucR0E3ABFdCHdxMzXke0AJ4sXjfaoRoTTYdTydYLs+2pSOoWx7M qALfEaoRZof6wM1oAWV8KJwSSFVb1L0v0tG6IZ0/jD5KZyE43nfB8+ws1A4bMa75Ij/U SEmmX/DxylLJ2XB++C308ZzR2ziFCm8SsCN099n6xhPUTnYD6DYcMfLoUSCguSrrJBjD I0+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748253887; x=1748858687; 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=SSPYC82OHD2BI/YU/tjmuoLa3AQcRKZBypSGl/10x2A=; b=r553dSvOXtALCh9F2SOKflI3h4wLk1FrNc87mBJpNRagCs4ChzldpoRGZHMnID1D08 aTQ3hpXsaMKpLLodrilCfxds0Qc0Y2HU9fGwX3c869awEvohV/dGQMRz11cNp1Bxc7pv 2GdunU/m4RbjxeQisHcx9H6yCg1EstaFr7Q9tLp7FnzL4Us+tg490amtYhtrwOOS2XUa u8coyCpNgTjVd6KUp/9s0VzgzM2sJi8CRM0oS/mjxpubYRsp4EWBpgj5T+VIqHvN/LT+ u9GWfYVo6QNBB8W1dvwo4WNWHuIB+5RO2r3PjMalktmyLqR4rbnTjTxQ2W1Qv/ULzvlf /MlQ== X-Forwarded-Encrypted: i=1; AJvYcCVyPNiYrIXt6p0AeNZKX5ImgQ0YL6ewQMcx7sChLPNfX795/Px77/TRwvaQDKyNkT6gkoi+tJocpGVgDcw=@vger.kernel.org X-Gm-Message-State: AOJu0Ywwm9mK6wFzl/krE+h8B7J2DavYHHTWPfU5NrZnNTup/338BauM nAggeqPfj//q/0t7lw5i4gMutXwQPcsq1LDWC4fGyvoCrnBN2RcrDZLyJdKjNW1CUQg= X-Gm-Gg: ASbGnctj9W6RCBQvkzrdyZqXLBPTJWH9WOChlL7w3i4lR5Ko7xPw+Ycsd0m0NxGOcmC edSSrHI+qJRPRFXH923F0UYIp8PTpUkhJjqarv0kGhMP/UQ9ikE74U6zEJBTKGHFQRb6Pw7m5EH 9MXFuah//u+a/8qzgoSnfkpFE40qWgR2578kK7FlDrMgU2bGIBDvqZSlt8SJS+TbqAVM3/H2XL5 ulllR6rUUAwy633vkycjIDbgFiGPPKId6fFt7YGTuSjf9KCKr4ItsOulFfE6LvG6Ev8TbyjadUX EEkwQOKQdZeCPRx5/izxJU2dHT1D9osjfn5Fg+eBQWwc982P7f+N4gaEZFjfjsHz/Bz8mhLwUtZ 5jrgNJb1ZMK8zUY5scO+z8udAPUUKXVE= X-Google-Smtp-Source: AGHT+IH5plmi/nUPxQdrlk4OSitIClXHq8w8SJjzpUHQhcFP5Y1Dghxteg5xfgt3S0UQCdsVUQLQUg== X-Received: by 2002:a05:6000:2892:b0:3a4:cf40:ff37 with SMTP id ffacd0b85a97d-3a4cf4101e6mr5909723f8f.6.1748253887401; Mon, 26 May 2025 03:04:47 -0700 (PDT) Received: from [192.168.0.2] (host-80-116-51-117.retail.telecomitalia.it. [80.116.51.117]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3a35ca888fcsm36141834f8f.78.2025.05.26.03.04.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 May 2025 03:04:46 -0700 (PDT) From: Angelo Dureghello X-Google-Original-From: Angelo Dureghello Date: Mon, 26 May 2025 12:03:19 +0200 Subject: [PATCH v7 4/6] dt-bindings: iio: adc: adi,ad7606: add gain calibration 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: <20250526-wip-bl-ad7606-calibration-v7-4-b487022ce199@baylibre.com> References: <20250526-wip-bl-ad7606-calibration-v7-0-b487022ce199@baylibre.com> In-Reply-To: <20250526-wip-bl-ad7606-calibration-v7-0-b487022ce199@baylibre.com> To: Jonathan Cameron , David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko , Lars-Peter Clausen , Michael Hennerich , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Hennerich , devicetree@vger.kernel.org, Angelo Dureghello , Conor Dooley X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2030; i=adureghello@baylibre.com; h=from:subject:message-id; bh=mK1GoQiX2hS20/yC/1czrPjfc5t1uAwSltJDkMx72Mc=; b=owGbwMvMwCXGf3bn1e/btlsznlZLYsgwscn+47Uo1r+qtv2vk92tO4w3d8x6OcNKorl5y4QnR 2ubFeoqO0pZGMS4GGTFFFnqEiNMQm+HSikvYJwNM4eVCWQIAxenAEzEwJWRYaGo7zPOxheliWcn TsxfZdl46eGml/5XFXTnrZvgv6Uo+gMjw2mmFzqCGWf7Jj8V2ivwc2/hjqTVib57YqwV+Da9aZu RwQ8A X-Developer-Key: i=adureghello@baylibre.com; a=openpgp; fpr=703CDFAD8B573EB00850E38366D1CB9419AF3953 From: Angelo Dureghello Add gain calibration support by a per-channel resistor value. Acked-by: Conor Dooley Signed-off-by: Angelo Dureghello --- .../devicetree/bindings/iio/adc/adi,ad7606.yaml | 29 ++++++++++++++++++= ++++ 1 file changed, 29 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/adc/adi,ad7606.yaml b/Do= cumentation/devicetree/bindings/iio/adc/adi,ad7606.yaml index 29f12d650442b8ff2eb455306ce59a0e87867ddd..6926f5f090ad6bbbe7bfd9327dc= 5ae17dafcd1fd 100644 --- a/Documentation/devicetree/bindings/iio/adc/adi,ad7606.yaml +++ b/Documentation/devicetree/bindings/iio/adc/adi,ad7606.yaml @@ -204,6 +204,15 @@ patternProperties: considered a bipolar differential channel. Otherwise it is bipol= ar single-ended. =20 + adi,rfilter-ohms: + description: + For ADCs that supports gain calibration, this property must be s= et to + the value of the external RFilter resistor. Proper gain error + correction is applied based on this value. + default: 0 + minimum: 0 + maximum: 64512 + required: - reg - bipolar @@ -256,6 +265,25 @@ allOf: properties: adi,oversampling-ratio-gpios: false =20 + - if: + properties: + compatible: + contains: + enum: + - adi,ad7605-4 + - adi,ad7606-4 + - adi,ad7606-6 + - adi,ad7606-8 + - adi,ad7607 + - adi,ad7608 + - adi,ad7609 + - adi,ad7616 + then: + patternProperties: + "^channel@[0-9a-f]+$": + properties: + adi,rfilter-ohms: false + - if: properties: compatible: @@ -398,6 +426,7 @@ examples: reg =3D <8>; diff-channels =3D <8 8>; bipolar; + adi,rfilter-ohms =3D <2048>; }; =20 }; --=20 2.49.0 From nobody Fri Dec 19 17:55:48 2025 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (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 BCAC61F8EF6 for ; Mon, 26 May 2025 10:04:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748253892; cv=none; b=Q5MqU+iOKJnSW6da7WvNs8iH3nZY9lVhG5K6toHLjtxwXq06cd0Q/73KkwwAuQG+FuSGEtK7/qEuoOLnHIMLG+gXGViuYmU3bbXQemxvFvnW43QQ8OWCjR30tLapBTWgxFy6G2iYS9gUqtQIiDqY8sSTdXrPrDut+s56fv9hxxk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748253892; c=relaxed/simple; bh=G/PHL2H0hCT1vJawFGnuZDviCmco7m1K7dYprLhxJYc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=OUyCOLCi9e+e1XLNvyhMfC7MRrqEE3fViApXWx5Q26cnUp1v6YEaaOdOL/wBE28zReE4bvOXVxVAOsDzqi8g6zWUgmf/vF9sAUdn8xkA0YdQPSj5jnMWNalCOhMu91P53yuLzt3eJ20ohozzCcu/RdMttGzkOLs1xe99ACWYQmM= 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=KXB3e99F; arc=none smtp.client-ip=209.85.128.44 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="KXB3e99F" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-441d1ed82faso15735825e9.0 for ; Mon, 26 May 2025 03:04:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1748253889; x=1748858689; 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=L1cI5SBD7MAWLfTRQEXjlnF27Z0y/aSH849T67R+rYk=; b=KXB3e99FGF1qMzkt23oiJUXYA9k/OwdBog+tgP4k63Mm9jf9x+DQmezeCPJB5IIx2D dYDko93fSKXfDkEICWt3pO3237OJVfYiJpWAUPMm4me/TwQXJFMCYtI+7rnspJaVMu1G 74hiwfX2Hjfo/7YCEovhRZ/tVajMH/JGiSm0b1B+BlORdj6GQg+Qbh7xB7ydc/W6J7mW WmG9suiIotiSPS4fh2GVyLmw5yiugKBErexR7FrW1eAHBaxUC1V7FnCpWVjLlqUvGCoY w0kj3bcY6YJbVC4l5xLZvkabSwCoue6npnDLaKLMZr7GL2igZbEyz1NXYD5SDHLdslgg duow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748253889; x=1748858689; 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=L1cI5SBD7MAWLfTRQEXjlnF27Z0y/aSH849T67R+rYk=; b=E+0Fo/xVx4V6xb5TJXj9fPeC6e1BUl24IfRjt1w5LSrONUVobKeKrdqXG0741j4/6f E7O+qJ0TCkkNzzX54ANwtpB4LCYJ7FDUMi06tigB6fKJZolBbCdfEpV6VU+8NpVUqGYj lArKI6bOiAf83qfgh8V9HPwznqzNSUdkkkszb2S+uOGZ5Z02l6YZoA8Cj+ca/uMxo3rO HrquuXuWPHuqagFfSPwknyGoZU0wO3OrywNoDTVJr9MVpF33SkpmxUuMD17wYEG1r8Aq 07EVckS0F13XChHU7YPVTEsPnUCfuvM0Ombm3lOqqWzE6n8TNjrhEpUO5GDsQpkLgiDG 3B0Q== X-Forwarded-Encrypted: i=1; AJvYcCWSpc4Z7oIWZrP0UtsIV0eV2iLTimGqiOdt96IymbSb1Vax4CYkNVUnFc6ah/N6Rb7s9F7AULGLMXwDW4w=@vger.kernel.org X-Gm-Message-State: AOJu0YzF9DqELnOZta7q9Zly8qKx1kEv2W0u2Dcc7IXH4ayyZte70Daz ikQ9ETpFzF2Uavbs9IeXbouR+pBaOGEQ0lvcvvkHUR9pmE9wE2rPAvM5t38EN5Syq9Q= X-Gm-Gg: ASbGnctNfka+erS/oeYR7X5/lyPcwgse6ro43sEClun7VKeL8XWqUxH2zfkruYLc8tn TJ5DMsRygyX40MWNRVmhl81BRc96GU1nTwN8axgOiUEVQh857j/dDZfgO16THtm1xtIpNpQxRnG aSmbWdPiWo6v5ujdgms9SwYkI19KnZJjAMVxTjgtlmtMaKBRWKwWkKWXUIazwff+FtArNKTnxca XDD9j8OlHaf5ww95OELFvoRnlSGL2zQm3E0xOcm+z/EBMEDH+MS8N8uuecG+tfCmQdbue1PXSZJ g3PuE3rhI/d/OishYzBpGGCXSeZJRdEgHqg0XSj2twAI5jkiEBHb7udOuEmDtM/MwnLp+p+Vepa aVTdwbipeF5PSn3C9mePtH2EfIAfwDIo= X-Google-Smtp-Source: AGHT+IF6mIEWndbTmsmJpL6uEi7nCS8HyYelPhOXO26l0/vLChjcCpiljRuyV20XEkmMAv/G/rTqCQ== X-Received: by 2002:a5d:64c5:0:b0:391:3aaf:1d5f with SMTP id ffacd0b85a97d-3a4cb4c6b6amr7756998f8f.52.1748253888985; Mon, 26 May 2025 03:04:48 -0700 (PDT) Received: from [192.168.0.2] (host-80-116-51-117.retail.telecomitalia.it. [80.116.51.117]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3a35ca888fcsm36141834f8f.78.2025.05.26.03.04.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 May 2025 03:04:48 -0700 (PDT) From: Angelo Dureghello X-Google-Original-From: Angelo Dureghello Date: Mon, 26 May 2025 12:03:20 +0200 Subject: [PATCH v7 5/6] iio: adc: ad7606: exit for invalid fdt dt_schema properties 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: <20250526-wip-bl-ad7606-calibration-v7-5-b487022ce199@baylibre.com> References: <20250526-wip-bl-ad7606-calibration-v7-0-b487022ce199@baylibre.com> In-Reply-To: <20250526-wip-bl-ad7606-calibration-v7-0-b487022ce199@baylibre.com> To: Jonathan Cameron , David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko , Lars-Peter Clausen , Michael Hennerich , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Hennerich , devicetree@vger.kernel.org, Angelo Dureghello X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1153; i=adureghello@baylibre.com; h=from:subject:message-id; bh=rfCHNvDJGZ9CfpNWbsvNZme06fPzQKFo7DAhEkye3IU=; b=owGbwMvMwCXGf3bn1e/btlsznlZLYsgwscm+2v1T8ol0YNBhvvbjfEkvOALyAjny9P0etAV9O Odwp+1bRykLgxgXg6yYIktdYoRJ6O1QKeUFjLNh5rAygQxh4OIUgIl8KWb4pzo9WHbnmyN2Bcrd z3p0jzFP2z1XryXLPjr209wrjV2LxBgZuqQN1t1mc9TelL5SyFGohb1IYdOMoKtX77tKXr8nc9+ eDQA= X-Developer-Key: i=adureghello@baylibre.com; a=openpgp; fpr=703CDFAD8B573EB00850E38366D1CB9419AF3953 From: Angelo Dureghello Fix ad7606_get_chan_config() fdt parsing function to exit for error in case of invalid dt_schema values. Idea is to not proceed when there are values that are not allowed under the dt_schema. Signed-off-by: Angelo Dureghello --- drivers/iio/adc/ad7606.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/iio/adc/ad7606.c b/drivers/iio/adc/ad7606.c index 9a9bef0cfbb37138f71ba5b1babeaa423eaf4d5a..e0a666cc0e14255754e74daa9e1= e88bc4ad1665c 100644 --- a/drivers/iio/adc/ad7606.c +++ b/drivers/iio/adc/ad7606.c @@ -319,15 +319,13 @@ static int ad7606_get_chan_config(struct iio_dev *ind= io_dev, int ch, =20 ret =3D fwnode_property_read_u32(child, "reg", ®); if (ret) - continue; + return ret; =20 /* channel number (here) is from 1 to num_channels */ - if (reg < 1 || reg > num_channels) { - dev_warn(dev, - "Invalid channel number (ignoring): %d\n", reg); - continue; - } + if (reg < 1 || reg > num_channels) + return -EINVAL; =20 + /* Loop until we are in the right channel. */ if (reg !=3D (ch + 1)) continue; =20 --=20 2.49.0 From nobody Fri Dec 19 17:55:48 2025 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (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 47B9E1F4C96 for ; Mon, 26 May 2025 10:04:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748253895; cv=none; b=W+qk0Jy19cMUJ16sywJslom5O7NqEYJ/VgFg1zBiRVeDXqROo3ND9TfbcdbfLA1ZvzFh8rqd0DPbWkvs/Shi8uYSDQBhF/x+2xdtsf7myvbAJO3LUlTELl7CQiKqdq9eLMz8Vdn6e8BDlKcrFFCc5F3OApchxZkgVeTXj70EWic= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748253895; c=relaxed/simple; bh=+6B4Ob+yfzec6F/Q3oyJRE9udnynOrOuj3LLQ6kkxsA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nOz+7ZiJY5aXRk/Bo5KER9+zv6X1Mc5uiiXBi/LS1Nfl5KM2THTItohQT/HaowR3MIWxZlTIMWdbsjf7REk/VO0oKZdGTa5S+Pmq9b+ZZ/O+RCt19alLDKr7rkF0YWIB3YHliLyNdfSkv0FjCVwJo9MKqkCv55Q+TYFKIbsS3bk= 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=tlwiup4Y; arc=none smtp.client-ip=209.85.128.51 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="tlwiup4Y" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-43cfe574976so15363025e9.1 for ; Mon, 26 May 2025 03:04:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1748253890; x=1748858690; 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=W0tSdZHx7w1B//uEapJ6mnjhDL7NbW0bow2VA9wTvIw=; b=tlwiup4Ym9MTVzU/Yje7LUL6h/0fWuSxaY1FDCAIekR/6/D+585vYbKMqcUKJLe979 c6+omtoUshiEEcGLErB2ARAgtuyMix+0hok/iCgVx5RjS4kNWOzs30kWQz7Ln3r1Dg4x a7X42pcl2kBLETttmW1KD2Xc7vF3MRCNywcibWg9zyf57LrJI0rbVA/x0m/D74Ehy7AB r83/pOfuwx2F60J1cq8ySWd1DNhQB+kuUMumYra46Z5ftQ4LlGuFd4QnBKgHD3inVZp6 hjxkPHP5zQJohB9YRRUb2kfComv9UGRmH9E29t8cIUpGU48oCSUbAGnHyizJV45Y8jeY VVNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748253890; x=1748858690; 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=W0tSdZHx7w1B//uEapJ6mnjhDL7NbW0bow2VA9wTvIw=; b=srM+TeWEPkm5dzI9M8PJe4giGi2expDUzHhc2nvaujOcFEGtrVqTDbKNOPQtKhy27x aqid/PKtobWn+zQ7YX/MjuHY2+8KjdwGkFzomV+aL5Uu17VzI9Rz/+GeW+9kSEvV3DlS 8sbKIRt0cysbcbCrzNWpg6bVzySQsFOnMGyIHpfEdU24FJyez/vtxRZwLTFu9XVURWbu PPzoR494df2vjk8E3rI5G+dSPGC1krInTUg0Rj3ANC3DLUTJIhcxX/9SdR4FFD5Oz1HH 9vhW9mtUPrxTKrLEvJI4ua/0VRzYlqRm/kday8qVrhUQ2eU5TlqQZz9YupNowhbE3ghz wQ6g== X-Forwarded-Encrypted: i=1; AJvYcCVg8JdhgApnwWWlvroWyU5RzXiQWfVSBtfy5sKZNvSJ8KcnxZNOYiUgdzp1hQhq38p2H49AMQXkg3etvdo=@vger.kernel.org X-Gm-Message-State: AOJu0Yyy7a/9I44v8Dt07MtdumhXjcE8YLkD2BkgfHdVu4BhkVW5qF31 264HBQDM4LcKsu7cWDdc0AjNG4Bvlyt5D483brdg7uVqBlkpCr200PHqlUYD+cIc630= X-Gm-Gg: ASbGncsog2Cuhu3Uuiy6v+pU6UbJoy/drJbyM7w2loAuN8mvUup9ZwIK87cS7z2wjHb Nf7/NRkxDJVI+TlKCx2hcPBN3x6KYVXDmN7GzYpCpAaQfJBMbzpD/SurFw+93jErRmL3wQZpqvw ErHdCZNpHQwUwb+ei0bkleRxmy1ZSMVtAy2+EhTG5XSP0dwsf5KsammSYj6t38uS8csA+63fCsZ 2Hm4fWoX/gwShXT6wYJCzNGqAtrI+OUlt3GZjwsHbU1BY9Gl+TOLYF2SsBmdobS5lTXcGnXcOIH FlvU9ELP8spCQC2Bo7k7ERcvDCY7+rOwlH5UV9Cq8oTvEnrxDfNHAsIaNoX15L9KtWi311E7ZmG m5CkqpBCh7Hzd/CcL0mxkTYH/5XS8Pas= X-Google-Smtp-Source: AGHT+IGaJt2vHpqfKlS5cBDtDHQGsqtmwZDKEFRfCosf+8OmOWWt9tc/0NIdrcJ31CrE9tEfO9+IzQ== X-Received: by 2002:a05:600c:4fc9:b0:43c:ec4c:25b4 with SMTP id 5b1f17b1804b1-44c91ad70d0mr93867775e9.10.1748253890567; Mon, 26 May 2025 03:04:50 -0700 (PDT) Received: from [192.168.0.2] (host-80-116-51-117.retail.telecomitalia.it. [80.116.51.117]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3a35ca888fcsm36141834f8f.78.2025.05.26.03.04.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 May 2025 03:04:50 -0700 (PDT) From: Angelo Dureghello X-Google-Original-From: Angelo Dureghello Date: Mon, 26 May 2025 12:03:21 +0200 Subject: [PATCH v7 6/6] iio: adc: ad7606: add gain calibration 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: <20250526-wip-bl-ad7606-calibration-v7-6-b487022ce199@baylibre.com> References: <20250526-wip-bl-ad7606-calibration-v7-0-b487022ce199@baylibre.com> In-Reply-To: <20250526-wip-bl-ad7606-calibration-v7-0-b487022ce199@baylibre.com> To: Jonathan Cameron , David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko , Lars-Peter Clausen , Michael Hennerich , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Hennerich , devicetree@vger.kernel.org, Angelo Dureghello X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=5427; i=adureghello@baylibre.com; h=from:subject:message-id; bh=2enztWCaqivWNg+b+KQz77hVRXgwpcSxoo97MZwtRNU=; b=owGbwMvMwCXGf3bn1e/btlsznlZLYsgwscnepuFy44nCxIgXm87tebY6bIvu82tRyW5Hdu9TN plYLxdq0VHKwiDGxSArpshSlxhhEno7VEp5AeNsmDmsTCBDGLg4BWAiv3sY/tdMPfr8w9zq+U/b DQKPbQ2+fVwgoW+dWMGk1Lrc4OhzgVUM/ywKUhMS3hpZSzVI7xWfJ9Kpf+5I8fldDD7/z/jcssr N5QQA X-Developer-Key: i=adureghello@baylibre.com; a=openpgp; fpr=703CDFAD8B573EB00850E38366D1CB9419AF3953 From: Angelo Dureghello Add gain calibration support, using resistor values set on devicetree, values to be set accordingly with ADC external RFilter, as explained in the ad7606c-16 datasheet, rev0, page 37. Usage example in the fdt yaml documentation. Tested-by: David Lechner Reviewed-by: Nuno S=C3=A1 Signed-off-by: Angelo Dureghello --- drivers/iio/adc/ad7606.c | 48 ++++++++++++++++++++++++++++++++++++++++++++= ++++ drivers/iio/adc/ad7606.h | 3 +++ 2 files changed, 51 insertions(+) diff --git a/drivers/iio/adc/ad7606.c b/drivers/iio/adc/ad7606.c index e0a666cc0e14255754e74daa9e1e88bc4ad1665c..3fe035d25024c174cb546f2e4b7= 06b573abbe761 100644 --- a/drivers/iio/adc/ad7606.c +++ b/drivers/iio/adc/ad7606.c @@ -33,6 +33,10 @@ =20 #include "ad7606.h" =20 +#define AD7606_CALIB_GAIN_MIN 0 +#define AD7606_CALIB_GAIN_STEP 1024 +#define AD7606_CALIB_GAIN_MAX (63 * AD7606_CALIB_GAIN_STEP) + /* * Scales are computed as 5000/32768 and 10000/32768 respectively, * so that when applied to the raw values they provide mV values. @@ -125,6 +129,7 @@ static int ad7609_chan_scale_setup(struct iio_dev *indi= o_dev, struct iio_chan_spec *chan); static int ad7616_sw_mode_setup(struct iio_dev *indio_dev); static int ad7606b_sw_mode_setup(struct iio_dev *indio_dev); +static int ad7606_chan_calib_gain_setup(struct iio_dev *indio_dev); =20 const struct ad7606_chip_info ad7605_4_info =3D { .max_samplerate =3D 300 * KILO, @@ -180,6 +185,7 @@ const struct ad7606_chip_info ad7606b_info =3D { .scale_setup_cb =3D ad7606_16bit_chan_scale_setup, .sw_setup_cb =3D ad7606b_sw_mode_setup, .offload_storagebits =3D 32, + .calib_gain_setup_cb =3D ad7606_chan_calib_gain_setup, .calib_offset_avail =3D ad7606_calib_offset_avail, .calib_phase_avail =3D ad7606b_calib_phase_avail, }; @@ -195,6 +201,7 @@ const struct ad7606_chip_info ad7606c_16_info =3D { .scale_setup_cb =3D ad7606c_16bit_chan_scale_setup, .sw_setup_cb =3D ad7606b_sw_mode_setup, .offload_storagebits =3D 32, + .calib_gain_setup_cb =3D ad7606_chan_calib_gain_setup, .calib_offset_avail =3D ad7606_calib_offset_avail, .calib_phase_avail =3D ad7606c_calib_phase_avail, }; @@ -246,6 +253,7 @@ const struct ad7606_chip_info ad7606c_18_info =3D { .scale_setup_cb =3D ad7606c_18bit_chan_scale_setup, .sw_setup_cb =3D ad7606b_sw_mode_setup, .offload_storagebits =3D 32, + .calib_gain_setup_cb =3D ad7606_chan_calib_gain_setup, .calib_offset_avail =3D ad7606c_18bit_calib_offset_avail, .calib_phase_avail =3D ad7606c_calib_phase_avail, }; @@ -355,6 +363,39 @@ static int ad7606_get_chan_config(struct iio_dev *indi= o_dev, int ch, return 0; } =20 +static int ad7606_chan_calib_gain_setup(struct iio_dev *indio_dev) +{ + struct ad7606_state *st =3D iio_priv(indio_dev); + unsigned int num_channels =3D st->chip_info->num_adc_channels; + struct device *dev =3D st->dev; + int ret; + + device_for_each_child_node_scoped(dev, child) { + u32 reg, r_gain; + + ret =3D fwnode_property_read_u32(child, "reg", ®); + if (ret) + return ret; + + /* Chan reg is a 1-based index. */ + if (reg < 1 || reg > num_channels) + return ret; + + r_gain =3D 0; + ret =3D fwnode_property_read_u32(child, "adi,rfilter-ohms", + &r_gain); + if (r_gain > AD7606_CALIB_GAIN_MAX) + return -EINVAL; + + ret =3D st->bops->reg_write(st, AD7606_CALIB_GAIN(reg - 1), + DIV_ROUND_CLOSEST(r_gain, AD7606_CALIB_GAIN_STEP)); + if (ret) + return ret; + } + + return 0; +} + static int ad7606c_18bit_chan_scale_setup(struct iio_dev *indio_dev, struct iio_chan_spec *chan) { @@ -1444,6 +1485,13 @@ static int ad7606_probe_channels(struct iio_dev *ind= io_dev) if (slow_bus) channels[i] =3D (struct iio_chan_spec)IIO_CHAN_SOFT_TIMESTAMP(i); =20 + /* Setting up gain calibration for all channels. */ + if (st->sw_mode_en && st->chip_info->calib_offset_avail) { + ret =3D st->chip_info->calib_gain_setup_cb(indio_dev); + if (ret) + return ret; + } + indio_dev->channels =3D channels; =20 return 0; diff --git a/drivers/iio/adc/ad7606.h b/drivers/iio/adc/ad7606.h index f613583a7fa4095115b0b28e3f8e51cd32b93524..6313eea2bd0ccf97222a50dc26d= 8ec65042d0db7 100644 --- a/drivers/iio/adc/ad7606.h +++ b/drivers/iio/adc/ad7606.h @@ -50,6 +50,7 @@ struct ad7606_state; typedef int (*ad7606_scale_setup_cb_t)(struct iio_dev *indio_dev, struct iio_chan_spec *chan); typedef int (*ad7606_sw_setup_cb_t)(struct iio_dev *indio_dev); +typedef int (*ad7606_calib_gain_setup_cb_t)(struct iio_dev *indio_dev); =20 /** * struct ad7606_chip_info - chip specific information @@ -66,6 +67,7 @@ typedef int (*ad7606_sw_setup_cb_t)(struct iio_dev *indio= _dev); * @init_delay_ms: required delay in milliseconds for initialization * after a restart * @offload_storagebits: storage bits used by the offload hw implementation + * @calib_gain_setup_cb: callback to setup of gain calibration * @calib_offset_avail: pointer to offset calibration range/limits array * @calib_phase_avail: pointer to phase calibration range/limits array */ @@ -81,6 +83,7 @@ struct ad7606_chip_info { bool os_req_reset; unsigned long init_delay_ms; u8 offload_storagebits; + ad7606_calib_gain_setup_cb_t calib_gain_setup_cb; const int *calib_offset_avail; const int (*calib_phase_avail)[2]; }; --=20 2.49.0