Skip to contentSkip to conversation

lis302dl/lis3lv02d: fix click thresholds and add legacy YAML binding

PATCH In review Md Shofiqul Islam 6 participants 12 messages Jun 11 – Jun 12

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v2 cover lis302dl/lis3lv02d: fix click thresholds and add legacy YAML binding

This series addresses the review feedback on v1 of the lis302 binding conversion.

During the audit of upstream board DTS files I found 11 ARM boards referencing st,lis302dl or st,lis3lv02d. This led to two additional findings that the v1 patch missed:

1. A longstanding driver bug: the driver reads st,click-threshold-x/y/z but 5 upstream boards use st,click-thresh-x/y/z (the name from the old .txt documentation). Those boards have had silent click detection failures for years because the driver ignores the misspelled property. Patch 1 fixes this by setting a sensible default of 10 in the driver.

2. Three different compatible strings are used as the primary binding for different boards: st,lis302dl (Nokia N900), st,lis3lv02d (Nokia N950/N9, AM335x Pepper), and st,lis302dl-spi (PXA300 Raumfeld). The v1 patch only included st,lis302dl-spi and st,lis3lv02d.

Changes from v1:
- New patch 1: fix driver click threshold defaults
- New patch 2: remove st,lis302dl-spi and st,lis3lv02d from the deprecated section of st,st-sensors.yaml (duplicate resolution)
- Patch 3 (binding, formerly the only patch):
- Add prominent WARNING at top of description
- Add st,lis302dl compatible (Nokia N900)
- Document both supply naming conventions (Vdd-supply/Vdd_IO-supply and vdd-supply/vddio-supply used by N900)
- Add mount-matrix (Nokia N900)
- Mark all click/irq/wakeup/filter properties as deprecated=true
- Add st,click-thresh-x/y/z as deprecated with a note explaining the misspelling situation
- Remove Jonathan Cameron as maintainer (declined); use Linus Walleij
- Remove driver path reference from description
- Add schema range constraints for axis remapping properties
- Update example to use Nokia N900 (minimal, modern node)

Md Shofiqul Islam (3):
misc: lis3lv02d: set default click detection thresholds
dt-bindings: iio: st,st-sensors: remove lis302dl and lis3lv02d from
deprecated list
dt-bindings: iio: accel: convert lis302 binding to YAML schema (v2)

 .../devicetree/bindings/iio/accel/lis302.txt  | 119 -------
 .../bindings/iio/accel/st,lis302dl.yaml       | 320 ++++++++++++++++++
 .../bindings/iio/st,st-sensors.yaml           |   6 -
 drivers/misc/lis3lv02d/lis3lv02d.c            |   8 +
 4 files changed, 328 insertions(+), 125 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/iio/accel/lis302.txt
 create mode 100644 Documentation/devicetree/bindings/iio/accel/st,lis302dl.yaml

--
2.51.1

#1 lore raw

PATCH v2 1/3 misc: lis3lv02d: set default click detection thresholds

Several upstream board DTS files use st,click-thresh-x/y/z (the name documented in the old lis302.txt binding), but the driver reads st,click-threshold-x/y/z. As a result those boards have had click detection silently broken since the DT properties were added.

Set a default threshold of 10 for all three axes immediately after the platform data allocation so those boards get working click detection without requiring a DT change.

The DT reads for st,click-threshold-x/y/z are unchanged so boards using the correct name can still override the default.

Fixes 6a7740c7f5b2 ("lis3lv02d: add device-tree support")
---
 drivers/misc/lis3lv02d/lis3lv02d.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/misc/lis3lv02d/lis3lv02d.c +8 -0
index 21e8ad0a7444..6a028c1bf866 100644
@@ -956,6 +956,14 @@ int lis3lv02d_init_dt(struct lis3lv02d *lis3)
 	if (!pdata)
 		return -ENOMEM;
 
+	/* Set sensible click threshold defaults. Several upstream board DTS
+	 * files use the misspelled property "st,click-thresh-*" which the
+	 * driver never reads, leaving these at zero. Default to 10 so those
+	 * boards get working click detection without a DT change. */
+	pdata->click_thresh_x = 10;
+	pdata->click_thresh_y = 10;
+	pdata->click_thresh_z = 10;
+
 	if (of_property_read_bool(np, "st,click-single-x"))
 		pdata->click_flags |= LIS3_CLICK_SINGLE_X;
 	if (of_property_read_bool(np, "st,click-double-x"))
Signature · 1 line
2.51.1
#5 lore raw

PATCH v2 2/3 dt-bindings: iio: st,st-sensors: remove lis302dl and lis3lv02d from deprecated list

In reply to Md Shofiqul Islam

st,lis302dl-spi and st,lis3lv02d are being given their own binding in Documentation/devicetree/bindings/iio/accel/st,lis302dl.yaml. Remove them from the deprecated section of st,st-sensors.yaml to eliminate the duplicate compatible string warnings reported by the kernel test robot.

---
 Documentation/devicetree/bindings/iio/st,st-sensors.yaml | 6 ------
 1 file changed, 6 deletions(-)
Documentation/devicetree/bindings/iio/st,st-sensors.yaml +0 -6
index a1a958215cdb..ebe9041f6326 100644
@@ -88,12 +88,6 @@ properties:
         enum:
           - st,lsm303d-imu
           - st,lsm9ds0-imu
-      - description: Deprecated bindings
-        enum:
-          - st,lis302dl-spi
-          - st,lis3lv02d
-        deprecated: true
-
   reg:
     maxItems: 1
 
Signature · 1 line
2.51.1
#7 lore raw

PATCH v2 3/3 dt-bindings: iio: accel: convert lis302 binding to YAML schema (v2)

In reply to Md Shofiqul Islam

Replace the plain text lis302.txt with a YAML schema for the LIS302DL/LIS3LV02D accelerometer family.

Key changes from v1:
- Add a prominent WARNING in the description that this is a legacy binding and must not be copied for new devices
- Add st,lis302dl compatible (used by Nokia N900 / omap3-n900.dts) in addition to st,lis302dl-spi and st,lis3lv02d
- Document both supply naming conventions: Vdd-supply/Vdd_IO-supply (legacy uppercase, used by most boards) and vdd-supply/vddio-supply (modern lowercase, used by Nokia N900)
- Add mount-matrix support (used by Nokia N900)
- Add self-test limit properties st,min-limit-x/y/z and st,max-limit-x/y/z (these legitimately belong in DT as they encode per-board hardware tolerances)
- Mark all click/irq/wakeup/filter properties as deprecated=true. They configure run-time driver behaviour, not hardware, and should not appear in DT for new boards
- Add st,click-thresh-x/y/z as deprecated with an explicit note that this is a misspelling present in several upstream boards; the driver reads st,click-threshold-x/y/z and never reads the short form
- Remove driver path reference from description
- Use schema constraints (minimum/maximum) for axis remapping range
- Remove Jonathan Cameron as maintainer; use Linus Walleij who already maintains the related st,st-sensors binding
- Use example based on actual upstream board (Nokia N900)

Boards using this as primary binding:
st,lis302dl: omap3-n900.dts
st,lis3lv02d: omap3-n950-n9.dtsi, am335x-pepper.dts
st,lis302dl-spi: pxa300-raumfeld-controller.dts

---
 .../devicetree/bindings/iio/accel/lis302.txt  | 119 -------
 .../bindings/iio/accel/st,lis302dl.yaml       | 320 ++++++++++++++++++
 2 files changed, 320 insertions(+), 119 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/iio/accel/lis302.txt
 create mode 100644 Documentation/devicetree/bindings/iio/accel/st,lis302dl.yaml
Documentation/devicetree/bindings/iio/accel/lis302.txt deleted +0 -119
deleted file mode 100644
index 457539647f36..000000000000
@@ -1,119 +0,0 @@
-LIS302 accelerometer devicetree bindings
-
-This device is matched via its bus drivers, and has a number of properties
-that apply in on the generic device (independent from the bus).
-
-
-Required properties for the SPI bindings:
- - compatible: 		should be set to "st,lis3lv02d-spi"
- - reg:			the chipselect index
- - spi-max-frequency:	maximal bus speed, should be set to 1000000 unless
-			constrained by external circuitry
- - interrupts:		the interrupt generated by the device
-
-Required properties for the I2C bindings:
- - compatible:		should be set to "st,lis3lv02d"
- - reg:			i2c slave address
- - Vdd-supply:		The input supply for Vdd
- - Vdd_IO-supply:	The input supply for Vdd_IO
-
-
-Optional properties for all bus drivers:
-
- - st,click-single-{x,y,z}:	if present, tells the device to issue an
-				interrupt on single click events on the
-				x/y/z axis.
- - st,click-double-{x,y,z}:	if present, tells the device to issue an
-				interrupt on double click events on the
-				x/y/z axis.
- - st,click-thresh-{x,y,z}:	set the x/y/z axis threshold
- - st,click-click-time-limit:	click time limit, from 0 to 127.5msec
-				with step of 0.5 msec
- - st,click-latency:		click latency, from 0 to 255 msec with
-				step of 1 msec.
- - st,click-window:		click window, from 0 to 255 msec with
-				step of 1 msec.
- - st,irq{1,2}-disable:		disable IRQ 1/2
- - st,irq{1,2}-ff-wu-1:		raise IRQ 1/2 on FF_WU_1 condition
- - st,irq{1,2}-ff-wu-2:		raise IRQ 1/2 on FF_WU_2 condition
- - st,irq{1,2}-data-ready:	raise IRQ 1/2 on data ready condition
- - st,irq{1,2}-click:		raise IRQ 1/2 on click condition
- - st,irq-open-drain:		consider IRQ lines open-drain
- - st,irq-active-low:		make IRQ lines active low
- - st,wu-duration-1:		duration register for Free-Fall/Wake-Up
-				interrupt 1
- - st,wu-duration-2:		duration register for Free-Fall/Wake-Up
-				interrupt 2
- - st,wakeup-{x,y,z}-{lo,hi}:	set wakeup condition on x/y/z axis for
-				upper/lower limit
- - st,wakeup-threshold:		set wakeup threshold
- - st,wakeup2-{x,y,z}-{lo,hi}:	set wakeup condition on x/y/z axis for
-				upper/lower limit for second wakeup
-				engine.
- - st,wakeup2-threshold:	set wakeup threshold for second wakeup
-				engine.
- - st,highpass-cutoff-hz=:	1, 2, 4 or 8 for 1Hz, 2Hz, 4Hz or 8Hz of
-				highpass cut-off frequency
- - st,hipass{1,2}-disable:	disable highpass 1/2.
- - st,default-rate=:		set the default rate
- - st,axis-{x,y,z}=:		set the axis to map to the three coordinates.
-				Negative values can be used for inverted axis.
- - st,{min,max}-limit-{x,y,z}	set the min/max limits for x/y/z axis
-				(used by self-test)
-
-
-Example for a SPI device node:
-
-	accelerometer@0 {
-		compatible = "st,lis302dl-spi";
-		reg = <0>;
-		spi-max-frequency = <1000000>;
-		interrupt-parent = <&gpio>;
-		interrupts = <104 0>;
-
-		st,click-single-x;
-		st,click-single-y;
-		st,click-single-z;
-		st,click-thresh-x = <10>;
-		st,click-thresh-y = <10>;
-		st,click-thresh-z = <10>;
-		st,irq1-click;
-		st,irq2-click;
-		st,wakeup-x-lo;
-		st,wakeup-x-hi;
-		st,wakeup-y-lo;
-		st,wakeup-y-hi;
-		st,wakeup-z-lo;
-		st,wakeup-z-hi;
-	};
-
-Example for a I2C device node:
-
-	lis331dlh: accelerometer@18 {
-		compatible = "st,lis331dlh", "st,lis3lv02d";
-		reg = <0x18>;
-		Vdd-supply = <&lis3_reg>;
-		Vdd_IO-supply = <&lis3_reg>;
-
-		st,click-single-x;
-		st,click-single-y;
-		st,click-single-z;
-		st,click-thresh-x = <10>;
-		st,click-thresh-y = <10>;
-		st,click-thresh-z = <10>;
-		st,irq1-click;
-		st,irq2-click;
-		st,wakeup-x-lo;
-		st,wakeup-x-hi;
-		st,wakeup-y-lo;
-		st,wakeup-y-hi;
-		st,wakeup-z-lo;
-		st,wakeup-z-hi;
-		st,min-limit-x = <120>;
-		st,min-limit-y = <120>;
-		st,min-limit-z = <140>;
-		st,max-limit-x = <550>;
-		st,max-limit-y = <550>;
-		st,max-limit-z = <750>;
-	};
-
Documentation/devicetree/bindings/iio/accel/st,lis302dl.yaml new file +320 -0

320 lines not on this page · raw message

Signature · 1 line
2.51.1
#2 lore raw

Re: [PATCH v2 1/3] misc: lis3lv02d: set default click detection thresholds

In reply to Md Shofiqul Islam
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:

New issues:
- [High] The patch hardcodes a default click threshold instead of parsing the documented legacy DT property st,click-thresh-*, incorrectly overriding explicitly configured board values.

Pre-existing issues:
- [High] The dynamically allocated struct lis3lv02d_platform_data is leaked on probe error paths and device unbind.
- [High] The return value of lis3lv02d_add_fs is ignored, leading to an invalid pointer address generation and a kernel crash if device creation fails.
- [High] Sysfs hardware access occurs with a runtime PM usage count of zero, risking a race condition with device suspend.
--

commit e23e0f8c271ea91f741e5d3559287f33c9596b0d
Author: Md Shofiqul Islam <[email protected]>

misc: lis3lv02d: set default click detection thresholds

This commit works around an issue where several upstream board DTS files use an undocumented property name for click thresholds. It hardcodes a default value of 10 during the driver's device tree initialization to compensate for the driver reading a misspelled property name.

drivers/misc/lis3lv02d/lis3lv02d.c int lis3lv02d_init_dt(struct lis3lv02d *lis3) · line 959

Quoted 7 lines
drivers/misc/lis3lv02d/lis3lv02d.c +0 -0
index 6957091ab6dee..245bb6249033b 100644
@@ -958,6 +958,14 @@ int lis3lv02d_init_dt(struct lis3lv02d *lis3)
 	if (!pdata)
 		return -ENOMEM;

[Severity: High]
This is a pre-existing issue, but does this code leak the allocated platform data?

When pdata is dynamically allocated via kzalloc() earlier in lis3lv02d_init_dt() and assigned to lis3_dev.pdata, there appears to be no corresponding kfree() in the error teardown paths. For example, if the bus probe fails in lis3lv02d_i2c_probe() due to -EPROBE_DEFER, the allocated memory is never freed:

drivers/misc/lis3lv02d/lis3lv02d_i2c.c:lis3lv02d_i2c_probe() {
    ...
fail:
    if (pdata && pdata->release_resources)
        pdata->release_resources();
    return ret;
}

Since lis3_dev is a static global variable, repeatedly probing and deferring or unbinding and rebinding the driver could continuously leak memory.

drivers/misc/lis3lv02d/lis3lv02d.c int lis3lv02d_init_dt(struct lis3lv02d *lis3) · line 965

Quoted 8 lines
drivers/misc/lis3lv02d/lis3lv02d.c +7 -0
+	/* Set sensible click threshold defaults. Several upstream board DTS
+	 * files use the misspelled property "st,click-thresh-*" which the
+	 * driver never reads, leaving these at zero. Default to 10 so those
+	 * boards get working click detection without a DT change. */
+	pdata->click_thresh_x = 10;
+	pdata->click_thresh_y = 10;
+	pdata->click_thresh_z = 10;

[Severity: High]
Can hardcoding these defaults override explicitly configured board values?

The device tree binding documents st,click-thresh-x/y/z, but the driver erroneously parses st,click-threshold-x/y/z. Instead of updating the driver to parse both properties to respect the DT ABI, this applies an arbitrary default of 10.

If a board correctly configures a different threshold, such as st,click-thresh-x = <8>, will this explicit configuration be ignored and silently forced to 10?

[ ... ]

[Severity: High]
This is a pre-existing issue, but will the lack of a return value check cause a kernel crash if device creation fails?

In lis3lv02d_init_device(), lis3lv02d_add_fs() is called without checking its return value:

drivers/misc/lis3lv02d/lis3lv02d.c:lis3lv02d_init_device() {
    ...
    lis3lv02d_add_fs(lis3);
    err = lis3lv02d_poweron(lis3);
    ...
}

If faux_device_create_with_groups() fails and returns NULL, lis3->fdev remains NULL. When the code later calls lis3lv02d_joystick_enable(), it computes &lis3->fdev->dev and assigns it to input_dev->dev.parent. The offset calculation from a NULL pointer yields an invalid pointer, leading to a NULL pointer dereference when the input subsystem accesses the parent device.

[Severity: High]
This is a pre-existing issue, but is sysfs hardware accessed with a runtime PM usage count of zero?

In sysfs attribute handlers like lis3lv02d_position_show(), lis3lv02d_sysfs_poweron() is called before accessing the hardware:

drivers/misc/lis3lv02d/lis3lv02d.c:lis3lv02d_position_show() {
    ...
    lis3lv02d_sysfs_poweron(lis3);
    mutex_lock(&lis3->mutex);
    lis3lv02d_get_xyz(lis3, &x, &y, &z);
    ...
}

However, lis3lv02d_sysfs_poweron() calls pm_runtime_get_sync(), but then immediately drops the usage count via pm_runtime_put_noidle():

drivers/misc/lis3lv02d/lis3lv02d.c:lis3lv02d_sysfs_poweron() {
    ...
    pm_runtime_put_noidle(lis3->pm_dev);
    pm_schedule_suspend(lis3->pm_dev, LIS3_SYSFS_POWERDOWN_DELAY);
}

This drops the runtime PM usage count to 0 while the I2C/SPI registers are actively being read. Could a concurrent system sleep physically power off the device while communication is occurring, leading to bus lockups or a kernel oops?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#8 lore raw

Re: [PATCH v2 3/3] dt-bindings: iio: accel: convert lis302 binding to YAML schema (v2)

In reply to Md Shofiqul Islam
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider: - [Medium] The `st,lis302dl` compatible string causes a dual-schema validation conflict. - [Medium] The…

Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [Medium] The st,lis302dl compatible string causes a dual-schema validation conflict.
- [Medium] The properties st,click-double-{x,y,z} were incorrectly omitted during the YAML schema conversion.
- [Medium] The schema fails to document the upstream legacy typo st,click-click-time-limit, causing validation failures.
- [Medium] The compatible property incorrectly rejects upstream fallback combinations by strictly requiring a single exact match. --

commit a5b5cff978006324100603bf6453cf1d3ceba157
Author: Md Shofiqul Islam <[email protected]>

dt-bindings: iio: accel: convert lis302 binding to YAML schema (v2)

Replace the plain text lis302.txt with a YAML schema for the LIS302DL/LIS3LV02D accelerometer family.

Quoted 6 lines
Documentation/devicetree/bindings/iio/accel/st,lis302dl.yaml new file +0 -0
new file mode 100644
index 0000000000000..8a19aa1085215
@@ -0,0 +1,320 @@

[ ... ]

Documentation/devicetree/bindings/iio/accel/st,lis302dl.yaml line 30

Quoted 5 lines
Documentation/devicetree/bindings/iio/accel/st,lis302dl.yaml new file +5 -0
+properties:
+  compatible:
+    oneOf:
+      - description: I2C variant (original part)
+        const: st,lis302dl

[Severity: Medium]
Since this compatible string is also present in the existing Documentation/devicetree/bindings/iio/st,st-sensors.yaml, does adding it here cause a dual-schema validation conflict?

If device tree nodes use st,lis302dl and include the legacy properties introduced in this new schema, they might fail dt_binding_check validation against st,st-sensors.yaml because that schema strictly restricts properties.

Documentation/devicetree/bindings/iio/accel/st,lis302dl.yaml line 35

Quoted 5 lines
Documentation/devicetree/bindings/iio/accel/st,lis302dl.yaml new file +5 -0
+      - description: I2C variant (larger range)
+        const: st,lis3lv02d
+      - description: SPI variant; including the bus type in the compatible
+          string is a legacy naming error, do not copy for new bindings
+        const: st,lis302dl-spi

[Severity: Medium]
Will this strict oneOf and const definition incorrectly reject valid upstream device trees that use a multiple-string fallback array?

Numerous upstream device trees (e.g., am335x-evm.dts, omap3-gta04a3.dts) use a fallback array like:

	compatible = "st,lis331dlh", "st,lis3lv02d";

A const rule fails against an array, which will cause these boards to fail schema validation.

Should this be rewritten to support items lists?

[ ... ]

Quoted 4 lines
Documentation/devicetree/bindings/iio/accel/st,lis302dl.yaml new file +4 -0
+  st,click-single-x:
+    type: boolean
+    deprecated: true
+    description: Enable single-click detection on X axis.

Documentation/devicetree/bindings/iio/accel/st,lis302dl.yaml line 100

Quoted 10 lines
Documentation/devicetree/bindings/iio/accel/st,lis302dl.yaml new file +10 -0
+
+  st,click-single-y:
+    type: boolean
+    deprecated: true
+    description: Enable single-click detection on Y axis.
+
+  st,click-single-z:
+    type: boolean
+    deprecated: true
+    description: Enable single-click detection on Z axis.

[Severity: Medium]
Were the properties st,click-double-{x,y,z} omitted from this conversion?

The original lis302.txt binding defined these properties, and the driver at drivers/misc/lis3lv02d/lis3lv02d.c actively parses them via of_property_read_bool().

Since the new schema specifies unevaluatedProperties: false, any device tree correctly utilizing the double-click properties will now fail schema validation.

[ ... ]

Quoted 4 lines
Documentation/devicetree/bindings/iio/accel/st,lis302dl.yaml new file +4 -0
+  st,click-thresh-y:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    deprecated: true
+    description: See st,click-thresh-x.

Documentation/devicetree/bindings/iio/accel/st,lis302dl.yaml line 138

Quoted 10 lines
Documentation/devicetree/bindings/iio/accel/st,lis302dl.yaml new file +10 -0
+
+  st,click-thresh-z:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    deprecated: true
+    description: See st,click-thresh-x.
+
+  st,click-time-limit:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    deprecated: true
+    description: Click time limit in 0.5ms steps (0-127).

[Severity: Medium]
Does the schema need to document the legacy typo st,click-click-time-limit to prevent validation failures?

The conversion correctly maps this to st,click-time-limit, but upstream device trees (e.g., arch/arm/boot/dts/ti/omap/omap3-gta04a3.dts) still use the misspelled property.

Because unevaluatedProperties is set to false, dt_binding_check will now fail for those boards.

Should this typo be accommodated similarly to how the st,click-thresh-x typo was handled?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
#9 lore raw

Re: [PATCH v2 3/3] dt-bindings: iio: accel: convert lis302 binding to YAML schema (v2)

In reply to Md Shofiqul Islam
Quoted 18 lines · Md Shofiqul Islam

Replace the plain text lis302.txt with a YAML schema for the LIS302DL/LIS3LV02D accelerometer family.

Key changes from v1:
- Add a prominent WARNING in the description that this is a legacy binding and must not be copied for new devices
- Add st,lis302dl compatible (used by Nokia N900 / omap3-n900.dts) in addition to st,lis302dl-spi and st,lis3lv02d
- Document both supply naming conventions: Vdd-supply/Vdd_IO-supply (legacy uppercase, used by most boards) and vdd-supply/vddio-supply (modern lowercase, used by Nokia N900)
- Add mount-matrix support (used by Nokia N900)
- Add self-test limit properties st,min-limit-x/y/z and st,max-limit-x/y/z (these legitimately belong in DT as they encode per-board hardware tolerances)
- Mark all click/irq/wakeup/filter properties as deprecated=true. They configure run-time driver behaviour, not hardware, and should not appear in DT for new boards

Quoted 8 lines

- Add st,click-thresh-x/y/z as deprecated with an explicit note that this is a misspelling present in several upstream boards; the driver reads st,click-threshold-x/y/z and never reads the short form
- Remove driver path reference from description
- Use schema constraints (minimum/maximum) for axis remapping range
- Remove Jonathan Cameron as maintainer; use Linus Walleij who already maintains the related st,st-sensors binding
- Use example based on actual upstream board (Nokia N900)

This whole section should be under the --- line.
Please do not send additional versions while discussion is still ongoing on your most recent.

Thanks,
Conor.

Quoted 468 lines

Boards using this as primary binding:
st,lis302dl: omap3-n900.dts
st,lis3lv02d: omap3-n950-n9.dtsi, am335x-pepper.dts
st,lis302dl-spi: pxa300-raumfeld-controller.dts

---
 .../devicetree/bindings/iio/accel/lis302.txt  | 119 -------
 .../bindings/iio/accel/st,lis302dl.yaml       | 320 ++++++++++++++++++
 2 files changed, 320 insertions(+), 119 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/iio/accel/lis302.txt
 create mode 100644 Documentation/devicetree/bindings/iio/accel/st,lis302dl.yaml
Documentation/devicetree/bindings/iio/accel/lis302.txt deleted +0 -119
deleted file mode 100644
index 457539647f36..000000000000
@@ -1,119 +0,0 @@
-LIS302 accelerometer devicetree bindings
-
-This device is matched via its bus drivers, and has a number of properties
-that apply in on the generic device (independent from the bus).
-
-
-Required properties for the SPI bindings:
- - compatible: 		should be set to "st,lis3lv02d-spi"
- - reg:			the chipselect index
- - spi-max-frequency:	maximal bus speed, should be set to 1000000 unless
-			constrained by external circuitry
- - interrupts:		the interrupt generated by the device
-
-Required properties for the I2C bindings:
- - compatible:		should be set to "st,lis3lv02d"
- - reg:			i2c slave address
- - Vdd-supply:		The input supply for Vdd
- - Vdd_IO-supply:	The input supply for Vdd_IO
-
-
-Optional properties for all bus drivers:
-
- - st,click-single-{x,y,z}:	if present, tells the device to issue an
-				interrupt on single click events on the
-				x/y/z axis.
- - st,click-double-{x,y,z}:	if present, tells the device to issue an
-				interrupt on double click events on the
-				x/y/z axis.
- - st,click-thresh-{x,y,z}:	set the x/y/z axis threshold
- - st,click-click-time-limit:	click time limit, from 0 to 127.5msec
-				with step of 0.5 msec
- - st,click-latency:		click latency, from 0 to 255 msec with
-				step of 1 msec.
- - st,click-window:		click window, from 0 to 255 msec with
-				step of 1 msec.
- - st,irq{1,2}-disable:		disable IRQ 1/2
- - st,irq{1,2}-ff-wu-1:		raise IRQ 1/2 on FF_WU_1 condition
- - st,irq{1,2}-ff-wu-2:		raise IRQ 1/2 on FF_WU_2 condition
- - st,irq{1,2}-data-ready:	raise IRQ 1/2 on data ready condition
- - st,irq{1,2}-click:		raise IRQ 1/2 on click condition
- - st,irq-open-drain:		consider IRQ lines open-drain
- - st,irq-active-low:		make IRQ lines active low
- - st,wu-duration-1:		duration register for Free-Fall/Wake-Up
-				interrupt 1
- - st,wu-duration-2:		duration register for Free-Fall/Wake-Up
-				interrupt 2
- - st,wakeup-{x,y,z}-{lo,hi}:	set wakeup condition on x/y/z axis for
-				upper/lower limit
- - st,wakeup-threshold:		set wakeup threshold
- - st,wakeup2-{x,y,z}-{lo,hi}:	set wakeup condition on x/y/z axis for
-				upper/lower limit for second wakeup
-				engine.
- - st,wakeup2-threshold:	set wakeup threshold for second wakeup
-				engine.
- - st,highpass-cutoff-hz=:	1, 2, 4 or 8 for 1Hz, 2Hz, 4Hz or 8Hz of
-				highpass cut-off frequency
- - st,hipass{1,2}-disable:	disable highpass 1/2.
- - st,default-rate=:		set the default rate
- - st,axis-{x,y,z}=:		set the axis to map to the three coordinates.
-				Negative values can be used for inverted axis.
- - st,{min,max}-limit-{x,y,z}	set the min/max limits for x/y/z axis
-				(used by self-test)
-
-
-Example for a SPI device node:
-
-	accelerometer@0 {
-		compatible = "st,lis302dl-spi";
-		reg = <0>;
-		spi-max-frequency = <1000000>;
-		interrupt-parent = <&gpio>;
-		interrupts = <104 0>;
-
-		st,click-single-x;
-		st,click-single-y;
-		st,click-single-z;
-		st,click-thresh-x = <10>;
-		st,click-thresh-y = <10>;
-		st,click-thresh-z = <10>;
-		st,irq1-click;
-		st,irq2-click;
-		st,wakeup-x-lo;
-		st,wakeup-x-hi;
-		st,wakeup-y-lo;
-		st,wakeup-y-hi;
-		st,wakeup-z-lo;
-		st,wakeup-z-hi;
-	};
-
-Example for a I2C device node:
-
-	lis331dlh: accelerometer@18 {
-		compatible = "st,lis331dlh", "st,lis3lv02d";
-		reg = <0x18>;
-		Vdd-supply = <&lis3_reg>;
-		Vdd_IO-supply = <&lis3_reg>;
-
-		st,click-single-x;
-		st,click-single-y;
-		st,click-single-z;
-		st,click-thresh-x = <10>;
-		st,click-thresh-y = <10>;
-		st,click-thresh-z = <10>;
-		st,irq1-click;
-		st,irq2-click;
-		st,wakeup-x-lo;
-		st,wakeup-x-hi;
-		st,wakeup-y-lo;
-		st,wakeup-y-hi;
-		st,wakeup-z-lo;
-		st,wakeup-z-hi;
-		st,min-limit-x = <120>;
-		st,min-limit-y = <120>;
-		st,min-limit-z = <140>;
-		st,max-limit-x = <550>;
-		st,max-limit-y = <550>;
-		st,max-limit-z = <750>;
-	};
-
Documentation/devicetree/bindings/iio/accel/st,lis302dl.yaml new file +320 -0
new file mode 100644
index 000000000000..8a19aa108521
@@ -0,0 +1,320 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/accel/st,lis302dl.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: STMicroelectronics LIS302DL/LIS3LV02D 3-Axis Accelerometer (Legacy Binding)
+
+description: |
+  WARNING: This is a legacy binding for hardware that predates modern DT
+  practices. It is documented as-found in upstream board files. Do NOT use
+  this as a template for new drivers or bindings.
+
+  The driver lives in drivers/misc/lis3lv02d, not in IIO. Many properties
+  listed here represent run-time driver configuration that would normally not
+  appear in device tree. They are documented here only because existing
+  upstream board DTS files use them.
+
+  Compatibles st,lis302dl-spi and st,lis3lv02d were previously listed as
+  deprecated in st,st-sensors.yaml. They are moved here with their actual
+  hardware configuration so validation works correctly.
+
+maintainers:
+  - Linus Walleij <[email protected]>
+
+properties:
+  compatible:
+    oneOf:
+      - description: I2C variant (original part)
+        const: st,lis302dl
+      - description: I2C variant (larger range)
+        const: st,lis3lv02d
+      - description: SPI variant; including the bus type in the compatible
+          string is a legacy naming error, do not copy for new bindings
+        const: st,lis302dl-spi
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    minItems: 1
+    maxItems: 2
+
+  Vdd-supply:
+    description: Main power supply (legacy uppercase name used by most boards).
+
+  Vdd_IO-supply:
+    description: I/O power supply (legacy uppercase name used by most boards).
+
+  vdd-supply:
+    description: Main power supply (modern lowercase name, used by omap3-n900).
+
+  vddio-supply:
+    description: I/O power supply (modern lowercase name, used by omap3-n900).
+
+  mount-matrix:
+    description: 3x3 mounting rotation matrix.
+
+  st,min-limit-x:
+    $ref: /schemas/types.yaml#/definitions/int32
+    description: Minimum acceptable self-test delta for X axis.
+
+  st,min-limit-y:
+    $ref: /schemas/types.yaml#/definitions/int32
+    description: Minimum acceptable self-test delta for Y axis.
+
+  st,min-limit-z:
+    $ref: /schemas/types.yaml#/definitions/int32
+    description: Minimum acceptable self-test delta for Z axis.
+
+  st,max-limit-x:
+    $ref: /schemas/types.yaml#/definitions/int32
+    description: Maximum acceptable self-test delta for X axis.
+
+  st,max-limit-y:
+    $ref: /schemas/types.yaml#/definitions/int32
+    description: Maximum acceptable self-test delta for Y axis.
+
+  st,max-limit-z:
+    $ref: /schemas/types.yaml#/definitions/int32
+    description: Maximum acceptable self-test delta for Z axis.
+
+  # The following properties configure run-time driver behaviour and do not
+  # describe hardware. They are deprecated. Documented here only so that
+  # existing upstream board DTS files pass dt_binding_check.
+
+  st,click-single-x:
+    type: boolean
+    deprecated: true
+    description: Enable single-click detection on X axis.
+
+  st,click-single-y:
+    type: boolean
+    deprecated: true
+    description: Enable single-click detection on Y axis.
+
+  st,click-single-z:
+    type: boolean
+    deprecated: true
+    description: Enable single-click detection on Z axis.
+
+  st,click-threshold-x:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    deprecated: true
+    description: Click threshold X axis. Driver default is used if absent.
+
+  st,click-threshold-y:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    deprecated: true
+    description: Click threshold Y axis. Driver default is used if absent.
+
+  st,click-threshold-z:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    deprecated: true
+    description: Click threshold Z axis. Driver default is used if absent.
+
+  st,click-thresh-x:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    deprecated: true
+    description: |
+      Misspelling of st,click-threshold-x present in several upstream board
+      files. The driver does not read this property; it is silently ignored.
+      Documented here only to avoid dt_binding_check failures on those boards.
+
+  st,click-thresh-y:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    deprecated: true
+    description: See st,click-thresh-x.
+
+  st,click-thresh-z:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    deprecated: true
+    description: See st,click-thresh-x.
+
+  st,click-time-limit:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    deprecated: true
+    description: Click time limit in 0.5ms steps (0-127).
+
+  st,click-latency:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    deprecated: true
+    description: Click latency in 1ms steps (0-255).
+
+  st,click-window:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    deprecated: true
+
+  st,irq1-click:
+    type: boolean
+    deprecated: true
+  st,irq2-click:
+    type: boolean
+    deprecated: true
+  st,irq1-ff-wu-1:
+    type: boolean
+    deprecated: true
+  st,irq1-ff-wu-2:
+    type: boolean
+    deprecated: true
+  st,irq2-ff-wu-1:
+    type: boolean
+    deprecated: true
+  st,irq2-ff-wu-2:
+    type: boolean
+    deprecated: true
+  st,irq1-data-ready:
+    type: boolean
+    deprecated: true
+  st,irq2-data-ready:
+    type: boolean
+    deprecated: true
+  st,irq1-disable:
+    type: boolean
+    deprecated: true
+  st,irq2-disable:
+    type: boolean
+    deprecated: true
+  st,irq-open-drain:
+    type: boolean
+    deprecated: true
+  st,irq-active-low:
+    type: boolean
+    deprecated: true
+
+  st,wakeup-x-lo:
+    type: boolean
+    deprecated: true
+  st,wakeup-x-hi:
+    type: boolean
+    deprecated: true
+  st,wakeup-y-lo:
+    type: boolean
+    deprecated: true
+  st,wakeup-y-hi:
+    type: boolean
+    deprecated: true
+  st,wakeup-z-lo:
+    type: boolean
+    deprecated: true
+  st,wakeup-z-hi:
+    type: boolean
+    deprecated: true
+  st,wakeup-threshold:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    deprecated: true
+
+  st,wakeup2-x-lo:
+    type: boolean
+    deprecated: true
+  st,wakeup2-x-hi:
+    type: boolean
+    deprecated: true
+  st,wakeup2-y-lo:
+    type: boolean
+    deprecated: true
+  st,wakeup2-y-hi:
+    type: boolean
+    deprecated: true
+  st,wakeup2-z-lo:
+    type: boolean
+    deprecated: true
+  st,wakeup2-z-hi:
+    type: boolean
+    deprecated: true
+  st,wakeup2-threshold:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    deprecated: true
+
+  st,wu-duration-1:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    deprecated: true
+  st,wu-duration-2:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    deprecated: true
+
+  st,highpass-cutoff-hz:
+    enum: [1, 2, 4, 8]
+    deprecated: true
+  st,hipass1-disable:
+    type: boolean
+    deprecated: true
+  st,hipass2-disable:
+    type: boolean
+    deprecated: true
+
+  st,default-rate:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    deprecated: true
+
+  st,axis-x:
+    $ref: /schemas/types.yaml#/definitions/int32
+    minimum: -3
+    maximum: 3
+    deprecated: true
+    description: Axis remapping. Replaced by mount-matrix.
+
+  st,axis-y:
+    $ref: /schemas/types.yaml#/definitions/int32
+    minimum: -3
+    maximum: 3
+    deprecated: true
+    description: Axis remapping. Replaced by mount-matrix.
+
+  st,axis-z:
+    $ref: /schemas/types.yaml#/definitions/int32
+    minimum: -3
+    maximum: 3
+    deprecated: true
+    description: Axis remapping. Replaced by mount-matrix.
+
+required:
+  - compatible
+  - reg
+
+allOf:
+  - $ref: /schemas/spi/spi-peripheral-props.yaml#
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        accelerometer@1d {
+            compatible = "st,lis302dl";
+            reg = <0x1d>;
+            vdd-supply = <&vaux1>;
+            vddio-supply = <&vio>;
+            interrupt-parent = <&gpio6>;
+            interrupts = <21 IRQ_TYPE_EDGE_RISING>,
+                         <20 IRQ_TYPE_EDGE_RISING>;
+            mount-matrix = "-1", "0", "0",
+                            "0", "1", "0",
+                            "0", "0", "-1";
+        };
+    };
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+    spi {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        accelerometer@1 {
+            compatible = "st,lis302dl-spi";
+            reg = <1>;
+            spi-max-frequency = <1000000>;
+            interrupt-parent = <&gpio>;
+            interrupts = <104 IRQ_TYPE_EDGE_FALLING>;
+            st,click-single-x;
+            st,click-single-y;
+            st,click-single-z;
+            st,irq1-click;
+            st,irq2-click;
+        };
+    };
+...
Signature · 1 line
2.51.1
#6 lore raw

Re: [PATCH v2 2/3] dt-bindings: iio: st,st-sensors: remove lis302dl and lis3lv02d from deprecated list

In reply to Md Shofiqul Islam
Quoted 2 lines · Md Shofiqul Islam

st,lis302dl-spi and st,lis3lv02d are being given their own binding in Documentation/devicetree/bindings/iio/accel/st,lis302dl.yaml. Remove

This is not supposed to be a separate commit. Removing compatible and making it missing from schemas is not a desired change by itself.

Best regards,
Krzysztof

#10 lore raw

Re: [PATCH v2 3/3] dt-bindings: iio: accel: convert lis302 binding to YAML schema (v2)

In reply to Md Shofiqul Islam
Quoted 2 lines · Md Shofiqul Islam

Replace the plain text lis302.txt with a YAML schema for the LIS302DL/LIS3LV02D accelerometer family.

There is no "YAML schema". There is DT schema. See submitting patches doc in DT dir.

...

Quoted 12 lines
Documentation/devicetree/bindings/iio/accel/st,lis302dl.yaml new file +12 -0
+description: |
+  WARNING: This is a legacy binding for hardware that predates modern DT
+  practices. It is documented as-found in upstream board files. Do NOT use
+  this as a template for new drivers or bindings.
+
+  The driver lives in drivers/misc/lis3lv02d, not in IIO. Many properties
+  listed here represent run-time driver configuration that would normally not
+  appear in device tree. They are documented here only because existing
+  upstream board DTS files use them.
+
+  Compatibles st,lis302dl-spi and st,lis3lv02d were previously listed as
+  deprecated in st,st-sensors.yaml. They are moved here with their actual

Documentation/devicetree/bindings/iio/accel/st,lis302dl.yaml line 30

Quoted 10 lines
Documentation/devicetree/bindings/iio/accel/st,lis302dl.yaml new file +10 -0
+  hardware configuration so validation works correctly.
+
+maintainers:
+  - Linus Walleij <[email protected]>
+
+properties:
+  compatible:
+    oneOf:
+      - description: I2C variant (original part)
+        const: st,lis302dl

This wasn't in the old binding. You need to explain in the commit msg changes done to the binding during conversion.

Documentation/devicetree/bindings/iio/accel/st,lis302dl.yaml line 35

Quoted 5 lines
Documentation/devicetree/bindings/iio/accel/st,lis302dl.yaml new file +5 -0
+      - description: I2C variant (larger range)
+        const: st,lis3lv02d
+      - description: SPI variant; including the bus type in the compatible
+          string is a legacy naming error, do not copy for new bindings
+        const: st,lis302dl-spi

Best regards,
Krzysztof

#11 lore raw

Re: [PATCH v2 3/3] dt-bindings: iio: accel: convert lis302 binding to YAML schema (v2)

In reply to Md Shofiqul Islam

Hi Shofiqul,

thanks for your patch! And thanks for working with the ST MEMS sensors!

Quoted 2 lines · Md Shofiqul Islam

Replace the plain text lis302.txt with a YAML schema for the LIS302DL/LIS3LV02D accelerometer family.

(...)

Documentation/devicetree/bindings/iio/accel/st,lis302dl.yaml line 24

Quoted 2 lines
Documentation/devicetree/bindings/iio/accel/st,lis302dl.yaml new file +2 -0
+maintainers:
+  - Linus Walleij <[email protected]>

Please use my new email address:
Linus Walleij <[email protected]>

I don't mind being listed as maintainer, ideally I think someone at ST should pick this up but I have good relationship with them so this is fine unless someone signs up for the job.

Yours,
Linus Walleij

Reviewed-by on v2 1/3
#3 lore raw

Re: [PATCH v2 1/3] misc: lis3lv02d: set default click detection thresholds

In reply to Md Shofiqul Islam
Quoted 9 lines · Md Shofiqul Islam

Several upstream board DTS files use st,click-thresh-x/y/z (the name documented in the old lis302.txt binding), but the driver reads st,click-threshold-x/y/z. As a result those boards have had click detection silently broken since the DT properties were added.

Set a default threshold of 10 for all three axes immediately after the platform data allocation so those boards get working click detection without requiring a DT change.

Quoted 6 lines

The DT reads for st,click-threshold-x/y/z are unchanged so boards using the correct name can still override the default.

Fixes 6a7740c7f5b2 ("lis3lv02d: add device-tree support")

Yours,
Linus Walleij

maintainer
#4 lore raw

Re: [PATCH v2 1/3] misc: lis3lv02d: set default click detection thresholds

Quoted 11 lines · On Fri, 12 Jun 2026 16:21:56 +0200 Linus Walleij <[email protected]> wrote:
Quoted 9 lines · Md Shofiqul Islam

Several upstream board DTS files use st,click-thresh-x/y/z (the name documented in the old lis302.txt binding), but the driver reads st,click-threshold-x/y/z. As a result those boards have had click detection silently broken since the DT properties were added.

Set a default threshold of 10 for all three axes immediately after the platform data allocation so those boards get working click detection without requiring a DT change.

Quoted 5 lines
Quoted 5 lines

The DT reads for st,click-threshold-x/y/z are unchanged so boards using the correct name can still override the default.

Fixes 6a7740c7f5b2 ("lis3lv02d: add device-tree support")

No blank line here. Tags must always be in one block with no lines in between them.

Quoted 6 lines
Quoted 1 line

Yours,
Linus Walleij