From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) (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 1C0B827603C for ; Mon, 27 Apr 2026 10:10:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777284604; cv=none; b=nuZhiAqku/6KLZCyzftfcX2LJPjKSEX/jJd2ecvTpUwBdfF6hEsPnuRslfsCn2/P5RDDlrlfbTxxM5QT6D2DU28FbQyueerDDzh+DJRbTj8e0vthJoovlEWv/rih/6xwgy6qrk8oEfyu+tZSJq2CIcpvWB4sMCzV4i78oQN/sIw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777284604; c=relaxed/simple; bh=PFD2iL3lpSvNkhMI6YUePwdFN+Bl2X+7rN4+GU/fR9o=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=ixcQt9xq8QMu1GQgkIr615C7iG1+F2+yT7H+3L1P1dyJ7duLNYXMPvZ3IFfevd1R4lD6U8XWv7Yiq3zLjBmgEjmmsWA3prVmZGUEzfcQtLxKhxesfOMyk8aEUVRi1niBcMUdHAGn2RK4UT3QcZ6V+0D9frDImkv3pJwEzVllx9w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=c6LtIQii; arc=none smtp.client-ip=209.85.210.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="c6LtIQii" Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-82fbf5d4dc2so6163991b3a.1 for ; Mon, 27 Apr 2026 03:10:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777284601; x=1777889401; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=MVjZJGi1bRfvcXa1V21Dt9zuEIBVC1nCvcLpxsqr/7I=; b=c6LtIQiiyUSLjyzovRZmBcso1MrYhtU88fvm9ZAxe2EiNnr/8LRBm6jchPjaRPTxVX TvfHPN3X53GjixhJhWH4XeTglM+sNB3Hr4Eg/a1dEcb0lMyv0NJAPkBMzqWHKL3W1duU zbY9fXrcG7RdfVicXCNY1JDbEJAwNQ3zJkYsiVuMtTYhCx6yQgzaelImyzVh7E789fK4 GZrGK/NWG9yzKPXBZ/O50KifPIp1GTchNVv5JyTFqHjAFqvhGjC304mzk5Sr8baBM7b/ KlXn2p0VjWeuirEILWcK+NlhpC0+2Db6egPxvKz0oMdi1mG9aQZtpZKKULyjaNY11CUH zgzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777284601; x=1777889401; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=MVjZJGi1bRfvcXa1V21Dt9zuEIBVC1nCvcLpxsqr/7I=; b=Yjn8aeJCzDZfrTsLk9iexqrCjHz9jxHnZ+liRKyH0o0OcmMn/JEaQ+5YrDn46E0+pX in6hIhXn8CGLQGrorA/SpwM+fGzyx0zcDkCFVnUSVdYd7HH/V+zk/yjE9Tp5jY9BxGUc aWoH9yPwMaAbY3EZW87ICwmSco5ZYb55Z5G013UtGut/xKycgIP8kQOPg+9nK+Erbd33 fXSO/IWjpX8EIRQLNGyNeuQtryB1QbMCrCUALXDtdd2qEr+nhufSBx1E9G59bgoHSiJc cUt7zJcHB4c2IuVQFpQ46E+ROgVL5Fxl+ZOpyPtAZNXFFC4xJZPGmWH3yZnS9UE5xCJ4 BFKQ== X-Forwarded-Encrypted: i=1; AFNElJ/HS7rrMNqjD7nXazEo/WUv7GblQJJdU5i9DylrZZNNc+tFngxcgB8VxR1uwqfT/l4esd8eNhqUhXCMRKM=@vger.kernel.org X-Gm-Message-State: AOJu0Yxze6bvkk6L/3A2MbXPmFrJBWWZopUbsqTBEDxEE4Mzq9EofHxU 4KEu1Po6pn+ImIafJO6VHRM17mAhpj9vkFNXCCpvEZ4NLY3WNkDxHqyw X-Gm-Gg: AeBDievubThIe89duRxeNCTVRKed0D60ZXd9PtDjb+SsJg9RwYGNFfUzbiuMsiOfMax bEv5vf4PXnTkM/GCwsuBWqQuij4C6wsMpJYNoKoDhXrOGzgdeBVqOKqQ0BALUHVUV+OpDxWIGPR Ss1AwraWQwwct9Go3xR3OT5g6MP2Yxano5o0tNiafzw/ioqNZafImIbEw7G39s2dyQx0fQfmjMp Jyb0RBOlQu1XcJAG0xbur7IsNG/Lr+30WwM9lgqijLIEbsaEWPNKbMVDBP4DQD8uGC9V8Seoq52 zHdxg7ptzCKvzJvckAFGylJ07WuWuVjtjc9VjSLTnn0QB3TjpkO2T6ayP7Q965tcrcRurJw0IO8 ZKxOXupB0YGIkM1Q9WHdmY3auDf4udfzivoush3TinfsckPOTmO5P/X56DG3I1MBgsQBAzXby6x +JZ81BubUlly0z2YFm1/aOi5yB/30abwgxZ+ZoIn5q7IcLgp14U5b0bA44l0hVKugK+C0W5aLR/ 1RPda3shRk8UqOuF1gbzAeAhAX1jmUakv6+B09UqeM5tQwTKQ== X-Received: by 2002:a05:6a00:4186:b0:82c:21b8:4a1f with SMTP id d2e1a72fcca58-82f8c7dd163mr46226289b3a.5.1777284601404; Mon, 27 Apr 2026 03:10:01 -0700 (PDT) Received: from lord-daniel-VivoBook-ASUSLaptop-K3502ZA-S3502ZA.. ([2405:201:31:d016:e577:22da:dc9:7f6c]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82f8ebba485sm39534225b3a.38.2026.04.27.03.09.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Apr 2026 03:10:00 -0700 (PDT) From: Piyush Patle To: ak@it-klinger.de, jic23@kernel.org Cc: dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 0/7] iio: adc: hx711: add HX710B support Date: Mon, 27 Apr 2026 15:39:31 +0530 Message-ID: <20260427100950.33936-1-piyushpatle228@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Add support for the HX710B ADC, a variant of the HX711 with the same GPIO interface but a different channel and gain model. The first patch updates the devicetree binding to add the `avia,hx710b` compatible, document the variant-specific hardware behaviour, and add chip-specific supply properties (avdd-supply, dvdd-supply, vsup-supply, vref-supply), the RATE pin for the HX711, and allOf constraints forbidding HX711-only properties on HX710B nodes and vice versa. The second patch fixes a pre-existing bug: hx711_gain_to_scale[].scale is a global array overwritten on each probe call, which breaks multiple sensor instances that have different AVDD supplies. This is fixed by moving the scale into a per-device array. Patches 3-6 split the v3 refactor into smaller independent steps as requested by Andy Shevchenko: text cleanup (Kconfig, header, MODULE_DESCRIPTION), chip_info introduction, trailing-pulse parametrisation of hx711_read(), and iio_chan_spec * signature for hx711_reset_read(). The final patch adds HX710B support using that infrastructure. Trailing pulse counts from Table 3 of the HX710B datasheet are stored in chan->address. Three channels are exposed: two differential inputs (10 SPS and 40 SPS) and a DVDD-AVDD supply monitor (40 SPS). The driver probes vref-supply first for the ADC reference and falls back to avdd-supply when the VREF pin is tied to AVDD on the board. Tested on PocketBeagle2 with an HX710B breakout module. The device probed successfully, all three channels returned stable raw readings, and alternating reads confirmed channel switching between the differential input and the DVDD-AVDD supply monitor path. Build-tested with: - make -s W=1 drivers/iio/adc/hx711.o - pahole -C hx711_chip_info drivers/iio/adc/hx711.o pahole reports hx711_chip_info as 40 bytes with no internal holes. The remaining 7 bytes are tail padding from 8-byte pointer alignment. Changes in v4: - Fix pre-existing global scale mutation bug (new patch 2). - Split the v3 refactor patch into four independent patches (patches 3-6) as requested by Andy Shevchenko. - Keep hx711_chip_info fields in their final order from introduction; the HX710B patch only appends new fields without reordering. - Add vref-supply binding and probe path for HX710B VREF pin. - Add a third HX710B channel (27 pulses, differential 40 SPS) from Table 3 of the datasheet. - Use .channel = 2 for the supply monitor to avoid indexing clash with .channel2 = 1 of the differential pair. - Remove dvdd-supply from the HX710B forbidden list in the binding; the HX710B has a DVDD supply and the DVDD-AVDD channel relies on it. - Add NULL guard on device_get_match_data() return value. - Fix checkpatch alignment in multi-line hx711_read() calls. Changes in v3: - See individual patch changelogs for full details. - dt-bindings: remove vref-supply wording; drop repeated clock-frequency default text; restore example node name; remove the extra HX710B example - driver: split the hx711_chip_info refactor from the HX710B support patch; fix signedness; update channel_set only after successful channel switching; keep HX710B scale based on the documented fixed gain of 128; add direct ARRAY_SIZE/types includes; use pahole to verify and improve hx711_chip_info field ordering - Reworked Kconfig text to use "HX711 and compatible ADCs" and list supported AVIA ADCs one per line. - Restored/updated driver header and module description wording while keeping the bitbanging context. Changes in v2: - See individual patch changelogs for full details. - dt-bindings: add dvdd-supply, vsup-supply, rate-gpios; allOf if/then for HX710B; fix clock-frequency description; remove dead vendor URL; clarify AVDD as voltage reference on both chips - driver: fix pulse count bug ({25,26}->{1,2}); move counts to chan->address; add fixed_gain flag; add .differential/.channel2; remove NULL check; drop reset_channel; pass iio_chan_spec * directly Piyush Patle (7): dt-bindings: iio: adc: avia-hx711: add avia,hx710b compatible iio: adc: hx711: move scale computation to per-device storage iio: adc: hx711: update Kconfig, module description and file header iio: adc: hx711: introduce hx711_chip_info per-variant structure iio: adc: hx711: pass trailing pulse count into hx711_read() iio: adc: hx711: pass iio_chan_spec to hx711_reset_read() iio: adc: hx711: add support for HX710B .../bindings/iio/adc/avia-hx711.yaml | 82 +++++- drivers/iio/adc/Kconfig | 8 +- drivers/iio/adc/hx711.c | 278 ++++++++++++++---- 3 files changed, 297 insertions(+), 71 deletions(-) -- 2.43.0