public inbox for devicetree@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/7] iio: adc: hx711: add HX710B support
@ 2026-04-27 10:09 Piyush Patle
  2026-04-27 10:09 ` [PATCH v4 1/7] dt-bindings: iio: adc: avia-hx711: add avia,hx710b compatible Piyush Patle
                   ` (6 more replies)
  0 siblings, 7 replies; 20+ messages in thread
From: Piyush Patle @ 2026-04-27 10:09 UTC (permalink / raw)
  To: ak, jic23
  Cc: dlechner, nuno.sa, andy, robh, krzk+dt, conor+dt, linux-iio,
	devicetree, linux-kernel

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


^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2026-04-27 15:29 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-27 10:09 [PATCH v4 0/7] iio: adc: hx711: add HX710B support Piyush Patle
2026-04-27 10:09 ` [PATCH v4 1/7] dt-bindings: iio: adc: avia-hx711: add avia,hx710b compatible Piyush Patle
2026-04-27 15:29   ` David Lechner
2026-04-27 10:09 ` [PATCH v4 2/7] iio: adc: hx711: move scale computation to per-device storage Piyush Patle
2026-04-27 14:02   ` Andy Shevchenko
2026-04-27 10:09 ` [PATCH v4 3/7] iio: adc: hx711: update Kconfig, module description and file header Piyush Patle
2026-04-27 10:26   ` Joshua Crofts
2026-04-27 13:46     ` Andy Shevchenko
2026-04-27 13:49       ` Joshua Crofts
2026-04-27 13:58   ` Andy Shevchenko
2026-04-27 14:19     ` Andy Shevchenko
2026-04-27 10:09 ` [PATCH v4 4/7] iio: adc: hx711: introduce hx711_chip_info per-variant structure Piyush Patle
2026-04-27 14:08   ` Andy Shevchenko
2026-04-27 14:14     ` Andy Shevchenko
2026-04-27 10:09 ` [PATCH v4 5/7] iio: adc: hx711: pass trailing pulse count into hx711_read() Piyush Patle
2026-04-27 14:12   ` Andy Shevchenko
2026-04-27 10:09 ` [PATCH v4 6/7] iio: adc: hx711: pass iio_chan_spec to hx711_reset_read() Piyush Patle
2026-04-27 14:16   ` Andy Shevchenko
2026-04-27 10:09 ` [PATCH v4 7/7] iio: adc: hx711: add support for HX710B Piyush Patle
2026-04-27 14:34   ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox