Re: [PATCH 2/3] dt-bindings: iio: st,st-sensors: add st,fullscale-mg

From: Jonathan Cameron

Date: Sun Jun 14 2026 - 14:45:06 EST


On Fri, 5 Jun 2026 12:08:42 +0200
Herman van Hazendonk <github.com@xxxxxxxxxx> wrote:

> Add an optional st,fullscale-mg property that selects the initial
> full-scale range of an ST MEMS sensor at probe time, expressed in
> milligauss for magnetometers (and analogous engineering units for
> other ST sensor families that may grow this property in the future).
>
> The property is purely additive: if absent, drivers fall back to
> their existing chip default, and if present but unsupported by the
> specific sensor the driver warns and falls back. No existing in-tree
> DTS is affected.
>
> The motivating case is the LSM303DLH magnetometer on the HP TouchPad
> (apq8060 / tenderloin) where the kernel's chip-default +/-1.3 G range
> saturates the X axis to the chip's 0xF000 overflow sentinel out of
> probe, because the chip is mounted close to surrounding power planes
> and picks up enough DC bias to exceed the smallest range. The driver
> core hardcodes fs_avl[0] as the starting range, so userspace cannot
> recover without racing the driver to write the in_magn_x_scale sysfs
> attribute after probe. st,fullscale-mg lets the device tree declare
> a wider initial range up-front and avoids the race entirely.

I'm trying to understand what you mean here by racing.

If we get this overflow condition the chip is wedged until reset, or
userspace simply has to change the range to recover?

I'm wondering if a UDEV rule is sufficient in theory to fix this.

I'm not necessarily against having the range in DT as it is effectively
hardware dependent but just want to make sure I fully understand the issue.

Jonathan



>
> Signed-off-by: Herman van Hazendonk <github.com@xxxxxxxxxx>
> ---
> .../devicetree/bindings/iio/st,st-sensors.yaml | 18 ++++++++++++++++++
> 1 file changed, 18 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/iio/st,st-sensors.yaml b/Documentation/devicetree/bindings/iio/st,st-sensors.yaml
> index a1a958215cdb..335f38e9f78f 100644
> --- a/Documentation/devicetree/bindings/iio/st,st-sensors.yaml
> +++ b/Documentation/devicetree/bindings/iio/st,st-sensors.yaml
> @@ -126,6 +126,24 @@ properties:
> mount-matrix:
> description: an optional 3x3 mounting rotation matrix.
>
> + st,fullscale-mg:
> + description: |
> + Selects the initial sensor full-scale at probe time, expressed in
> + milligauss for magnetometers (or analogous engineering units for
> + other sensor families that may grow this property in the future).
> + The value must match one of the sensor-specific full-scale ranges
> + supported by the chip; if the chip does not support the requested
> + range the driver falls back to its built-in default.
> +
> + This is intended for boards where the magnetometer chip picks up
> + enough DC bias from nearby PCB structures (power planes, ferrous
> + shields, etc.) that the kernel's chip-default highest-sensitivity
> + range saturates one or more axes to the chip's overflow sentinel,
> + and userspace observes that axis as permanently stuck. Declaring
> + a wider initial range avoids the saturation at the cost of a
> + slightly coarser quantisation.
> + $ref: /schemas/types.yaml#/definitions/uint32
> +
> allOf:
> - if:
> properties: