Re: [PATCH v3 0/5] iio: magnetometer: add driver for QST QMC5883P

From: Andy Shevchenko

Date: Mon Apr 20 2026 - 05:18:26 EST


On Sun, Apr 19, 2026 at 10:32:09PM +0000, Hardik Phalet wrote:
> This series adds an IIO driver for the QST QMC5883P, a 3-axis
> anisotropic magneto-resistive (AMR) magnetometer with a 16-bit ADC,
> communicating over I2C. To my knowledge there is no existing
> upstream driver for this device (see "Prior-art register-map check"
> below).
>
> The driver supports:
> - Raw magnetic field readings on X, Y and Z axes
> - Four full-scale ranges (+/-2 G, +/-8 G, +/-12 G, +/-30 G),
> selectable via IIO_CHAN_INFO_SCALE
> - Four output data rates (10, 50, 100, 200 Hz), selectable via
> IIO_CHAN_INFO_SAMP_FREQ
> - Four oversampling ratios (1, 2, 4, 8), selectable via
> IIO_CHAN_INFO_OVERSAMPLING_RATIO
> - Runtime PM with a 2 s autosuspend delay
> - System suspend/resume delegated to the runtime callbacks
>
> Regmap with an rbtree cache is used throughout. CTRL_1 and CTRL_2

I'm not sure this paragraph answers the question "why not maple tree?"

> bit fields are accessed via regmap_field to avoid read-modify-write
> races. The STATUS register is marked precious so regmap never reads
> it speculatively and clears the DRDY/OVFL bits unexpectedly.
>
> The probe-time init sequence is: soft reset, wait 300 us for POR
> to complete, deassert reset, drop the register cache so subsequent
> RMW writes read fresh values, then enter normal mode. 300 us
> comfortably covers the 250 us POR time given in the datasheet.
>
> Patches:
> 1/5 - dt-bindings: vendor-prefixes: Add QST Corporation
> 2/5 - dt-bindings: iio: magnetometer: QSTCORP QMC5883P
> 3/5 - iio: magnetometer: add driver for QST QMC5883P
> 4/5 - iio: magnetometer: qmc5883p: add oversampling ratio support
> 5/5 - iio: magnetometer: qmc5883p: add PM support
>
> Patches 4 and 5 are split out from the main driver so that the core
> (1-3) can be reviewed and picked independently, per review feedback
> on v2. 4/5 exposes the CTRL_1 OSR field via
> IIO_CHAN_INFO_OVERSAMPLING_RATIO. 5/5 adds runtime PM that puts the
> chip into MODE_SUSPEND when idle and wakes it to MODE_NORMAL on
> demand.

--
With Best Regards,
Andy Shevchenko