Skip to contentSkip to conversation

iio: add Open Sensor Fusion IIO driver

RFC PATCH Superseded Jinseob Kim 3 participants 16 messages Jun 7 – Jun 14

Subsystems (3)

v4 of 11 Superseded Latest is v11 →

lore
Share & tools
lore
#0 lore raw

v4 cover iio: add Open Sensor Fusion IIO driver

This RFC series adds an Industrial I/O driver for Open Sensor Fusion sensor aggregation devices.

Open Sensor Fusion is an open hardware project for sensor aggregation devices. The Linux IIO driver is an initial host-side implementation for OSF devices. The driver receives OSF frames over UART, uses device capability reports to discover supported sensor streams, and exposes supported raw sensor data through IIO devices.

This series is still marked RFC because the DT binding identity, the supported OSF protocol subset, and protocol extension and backward compatibility rules are still under review. The v4 series intentionally models the Linux device as a generic Open Sensor Fusion device rather than an OSF GREEN board-specific device. OSF GREEN is the prototype board used for current runtime testing, not the Linux DT compatible or driver identity.

The current wire format uses the OSF0 magic for protocol major version 0. That is kept as an internal wire-format detail for compatibility with existing firmware, tools, and runtime smoke evidence. The public driver identity remains Open Sensor Fusion / OSF, with protocol versioning handled by the protocol major/minor fields.

Project links:
https://www.opensensorfusion.org/
https://github.com/opensensorfusion
https://github.com/opensensorfusion/opensensorfusion-hardware
https://github.com/opensensorfusion/opensensorfusion-linux

Runtime testing so far has used an OSF GREEN prototype connected to a Raspberry Pi over UART. On Raspberry Pi 6.12.75+rpt-rpi-v8, the driver registered osf-accel, osf-gyro, osf-magn, and osf-temp from a capability report. Raw reads and software kfifo buffer reads were tested for all four IIO devices.

Changes since v3:

* Explain why the series is still RFC.
* Move the DT binding out of iio/imu because the device is a sensor aggregation device rather than an IMU.
* Replace the OSF GREEN board-specific compatible with the generic opensensorfusion,osf compatible.
* Treat OSF GREEN as tested prototype hardware / board model information, not as the Linux compatible string.
* Rename the kernel documentation to open-sensor-fusion.rst and reduce it to a driver-facing overview.
* Add the IIO documentation toctree entry.
* Keep full protocol details and compatibility rules in project documentation rather than duplicating the full wire specification in the kernel tree.
* Avoid using OSF0 as the public driver identity; keep it only as the current wire magic for protocol major version 0.
* Add FourCC-style wire magic handling in the decoder.
* Use GENMASK() for the capability flags mask.
* Clarify signed 32-bit little-endian sample decoding.
* Stop counting normal partial UART receive waits as partial frame errors.
* Avoid decoding complete frames twice in the stream/core path.
* Remove the local scan[] bounce before iio_push_to_buffers_with_ts_unaligned() and pass the values buffer directly.
* Remove the meaningless temperature available_scan_masks entry.
* Update MAINTAINERS paths for the new binding and documentation names.

Jinseob Kim (6):
dt-bindings: iio: add Open Sensor Fusion device
Documentation: iio: add Open Sensor Fusion driver overview
iio: osf: add protocol decoding
iio: osf: add stream parser
iio: osf: add UART transport
iio: osf: register IIO devices from capabilities

 .../iio/imu/opensensorfusion,osf-green.yaml   |  43 ---
 .../bindings/iio/opensensorfusion,osf.yaml    |  43 +++
 Documentation/iio/index.rst                   |   1 +
 .../iio/open-sensor-fusion-protocol-v0.rst    | 308 ------------------
 Documentation/iio/open-sensor-fusion.rst      |  62 ++++
 MAINTAINERS                                   |  26 +-
 drivers/iio/opensensorfusion/Kconfig          |   4 +-
 drivers/iio/opensensorfusion/osf_core.c       |   9 +-
 drivers/iio/opensensorfusion/osf_iio.c        |  15 +-
 drivers/iio/opensensorfusion/osf_protocol.c   |   4 +-
 drivers/iio/opensensorfusion/osf_protocol.h   |   4 +-
 drivers/iio/opensensorfusion/osf_serdev.c     |   2 +-
 drivers/iio/opensensorfusion/osf_stream.c     |  38 +--
 13 files changed, 145 insertions(+), 414 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/iio/imu/opensensorfusion,osf-green.yaml
 create mode 100644 Documentation/devicetree/bindings/iio/opensensorfusion,osf.yaml
 delete mode 100644 Documentation/iio/open-sensor-fusion-protocol-v0.rst
 create mode 100644 Documentation/iio/open-sensor-fusion.rst
Signature · 1 line
2.43.0
#1 lore raw

RFC PATCH v4 1/6 dt-bindings: iio: add Open Sensor Fusion device

Describe the OSF sensor aggregation hub.

Use the generic opensensorfusion,osf compatible.

---
 .../iio/imu/opensensorfusion,osf-green.yaml   | 43 -------------------
 .../bindings/iio/opensensorfusion,osf.yaml    | 43 +++++++++++++++++++
 MAINTAINERS                                   | 27 ++++++------
 3 files changed, 57 insertions(+), 56 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/iio/imu/opensensorfusion,osf-green.yaml
 create mode 100644 Documentation/devicetree/bindings/iio/opensensorfusion,osf.yaml
Documentation/devicetree/bindings/iio/imu/opensensorfusion,osf-green.yaml deleted +0 -43
deleted file mode 100644
index 626b41fb0..000000000
@@ -1,43 +0,0 @@
-# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
-%YAML 1.2
----
-$id: http://devicetree.org/schemas/iio/imu/opensensorfusion,osf-green.yaml#
-$schema: http://devicetree.org/meta-schemas/core.yaml#
-
-title: OSF GREEN sensor aggregation board
-
-maintainers:
-  - Jinseob Kim <[email protected]>
-
-description: |
-  OSF GREEN is an STM32F405-based sensor aggregation board from the Open
-  Sensor Fusion open hardware project. It sends OSF0 capability, status, and
-  sample frames to a host over a UART link.
-
-  Open Sensor Fusion is not a generic industry standard. Public project and
-  hardware documentation is available at:
-
-    https://github.com/opensensorfusion
-    https://github.com/opensensorfusion/opensensorfusion-hardware
-
-allOf:
-  - $ref: /schemas/serial/serial-peripheral-props.yaml#
-
-properties:
-  compatible:
-    const: opensensorfusion,osf-green
-
-required:
-  - compatible
-
-unevaluatedProperties: false
-
-examples:
-  - |
-    serial {
-        sensor {
-            compatible = "opensensorfusion,osf-green";
-        };
-    };
-
-...
Documentation/devicetree/bindings/iio/opensensorfusion,osf.yaml new file +43 -0

43 lines not on this page · raw message

MAINTAINERS +14 -13
index 56181470d..e227b9aff 100644
@@ -19977,19 +19977,6 @@ F:	Documentation/networking/oa-tc6-framework.rst
 F:	drivers/net/ethernet/oa_tc6.c
 F:	include/linux/oa_tc6.h
 
-OPEN SENSOR FUSION IIO DRIVER
-M:	Jinseob Kim <[email protected]>
-S:	Maintained
-F:	Documentation/devicetree/bindings/iio/imu/opensensorfusion,osf-green.yaml
-F:	Documentation/iio/open-sensor-fusion-protocol-v0.rst
-F:	drivers/iio/opensensorfusion/Kconfig
-F:	drivers/iio/opensensorfusion/Makefile
-F:	drivers/iio/opensensorfusion/osf_core.*
-F:	drivers/iio/opensensorfusion/osf_iio.*
-F:	drivers/iio/opensensorfusion/osf_protocol.*
-F:	drivers/iio/opensensorfusion/osf_serdev.c
-F:	drivers/iio/opensensorfusion/osf_stream.*
-
 OPEN FIRMWARE AND FLATTENED DEVICE TREE
 M:	Rob Herring <[email protected]>
 M:	Saravana Kannan <[email protected]>
@@ -20024,6 +20011,20 @@ F:	Documentation/devicetree/
 F:	arch/*/boot/dts/
 F:	include/dt-bindings/
 
+OPEN SENSOR FUSION IIO DRIVER
+M:	Jinseob Kim <[email protected]>
+S:	Maintained
+F:	Documentation/devicetree/bindings/iio/opensensorfusion,osf.yaml
+F:	Documentation/iio/open-sensor-fusion-protocol-v0.rst
+F:	drivers/iio/opensensorfusion/Kconfig
+F:	drivers/iio/opensensorfusion/Makefile
+F:	drivers/iio/opensensorfusion/osf_core.*
+F:	drivers/iio/opensensorfusion/osf_iio.*
+F:	drivers/iio/opensensorfusion/osf_protocol.*
+F:	drivers/iio/opensensorfusion/osf_serdev.c
+F:	drivers/iio/opensensorfusion/osf_stream.*
+
+
 OPENCOMPUTE PTP CLOCK DRIVER
 M:	Vadim Fedorenko <[email protected]>
 L:	[email protected]
Signature · 1 line
2.43.0
#2 lore raw

Re: [PATCH RFC v4 1/6] dt-bindings: iio: add Open Sensor Fusion device

Jonathan/IIO folks,

Quoted 28 lines · Jinseob Kim
Documentation/devicetree/bindings/iio/opensensorfusion,osf.yaml new file +22 -0
new file mode 100644
index 000000000..a4049715a
@@ -0,0 +1,43 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/opensensorfusion,osf.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Open Sensor Fusion Sensor Aggregation Hub
+
+maintainers:
+  - Jinseob Kim <[email protected]>
+
+description: |
+  Open Sensor Fusion is a sensor aggregation hub. The hub exposes an OSF
+  protocol data stream over its host interface and may report capabilities and
+  samples for multiple sensor classes. The Linux driver discovers the actual
+  sensor channels from OSF capability reports instead of describing those
+  sensors in Device Tree.
+
+  Open Sensor Fusion is not a generic industry standard. Public project
+  documentation is available at:
+
+    https://github.com/opensensorfusion

Documentation/devicetree/bindings/iio/opensensorfusion,osf.yaml line 32

Quoted 10 lines
Documentation/devicetree/bindings/iio/opensensorfusion,osf.yaml new file +10 -0
+
+allOf:
+  - $ref: /schemas/serial/serial-peripheral-props.yaml#
+
+properties:
+  compatible:
+    const: opensensorfusion,osf
+
+required:
+  - compatible

Do you think it makes sense to permit a regulator here, so that the "host" OS can power on/off the board running the osf stack?

Quoted 11 lines
Documentation/devicetree/bindings/iio/opensensorfusion,osf.yaml new file +11 -0
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    serial {
+        sensor {
+            compatible = "opensensorfusion,osf";
+        };
+    };
+...
#3 lore raw

Re: [PATCH RFC v4 1/6] dt-bindings: iio: add Open Sensor Fusion device

Quoted 2 lines

Do you think it makes sense to permit a regulator here, so that the "host" OS can power on/off the board running the osf stack?

From the OSF hardware side, yes, that makes sense.

The current prototype used for testing is powered independently, but an OSF device may also be integrated as a host-powered UART peripheral. In that case allowing the host to control the board supply through an optional regulator would be useful.

Unless the IIO side prefers otherwise, I will add an optional supply property to the binding and matching optional regulator handling in the driver in the next revision.

Jinseob

2026년 6월 10일 (수) 오전 1:19, Conor Dooley <[email protected]>님이 작성:

Quoted 58 lines

Jonathan/IIO folks,

Quoted 28 lines · Jinseob Kim
Documentation/devicetree/bindings/iio/opensensorfusion,osf.yaml new file +22 -0
new file mode 100644
index 000000000..a4049715a
@@ -0,0 +1,43 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/opensensorfusion,osf.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Open Sensor Fusion Sensor Aggregation Hub
+
+maintainers:
+  - Jinseob Kim <[email protected]>
+
+description: |
+  Open Sensor Fusion is a sensor aggregation hub. The hub exposes an OSF
+  protocol data stream over its host interface and may report capabilities and
+  samples for multiple sensor classes. The Linux driver discovers the actual
+  sensor channels from OSF capability reports instead of describing those
+  sensors in Device Tree.
+
+  Open Sensor Fusion is not a generic industry standard. Public project
+  documentation is available at:
+
+    https://github.com/opensensorfusion

Documentation/devicetree/bindings/iio/opensensorfusion,osf.yaml line 32

Quoted 10 lines
Documentation/devicetree/bindings/iio/opensensorfusion,osf.yaml new file +10 -0
+
+allOf:
+  - $ref: /schemas/serial/serial-peripheral-props.yaml#
+
+properties:
+  compatible:
+    const: opensensorfusion,osf
+
+required:
+  - compatible

Do you think it makes sense to permit a regulator here, so that the "host" OS can power on/off the board running the osf stack?

Quoted 11 lines
Documentation/devicetree/bindings/iio/opensensorfusion,osf.yaml new file +11 -0
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    serial {
+        sensor {
+            compatible = "opensensorfusion,osf";
+        };
+    };
+...
maintainer
#4 lore raw

Re: [PATCH RFC v4 1/6] dt-bindings: iio: add Open Sensor Fusion device

Quoted 5 lines · On Wed, 10 Jun 2026 18:33:54 +0900 Kim Jinseob <[email protected]> wrote:
Quoted 2 lines

Do you think it makes sense to permit a regulator here, so that the "host" OS can power on/off the board running the osf stack?

From the OSF hardware side, yes, that makes sense.

Quoted 8 lines

The current prototype used for testing is powered independently, but an OSF device may also be integrated as a host-powered UART peripheral. In that case allowing the host to control the board supply through an optional regulator would be useful.

Unless the IIO side prefers otherwise, I will add an optional supply property to the binding and matching optional regulator handling in the driver in the next revision.

When a device needs power, the regulator is required, not optional from a binding point of view. If it is always one people can use a fixed regulator to represent it.

Now from a driver point of view, the regulator framework in linux provides stub regulators for missing ones - on assumption they are always on. So we can just request the regulators in the driver. Keep it simple for now and use a devm_regulator_get_enable() in probe so we have power on for all the time the driver is loaded. Can do fancy stuff later when you have a board where the power is controlled.

Quoted 63 lines

Jinseob

2026년 6월 10일 (수) 오전 1:19, Conor Dooley <[email protected]>님이 작성:

Quoted 58 lines

Jonathan/IIO folks,

Quoted 28 lines · Jinseob Kim
Documentation/devicetree/bindings/iio/opensensorfusion,osf.yaml new file +22 -0
new file mode 100644
index 000000000..a4049715a
@@ -0,0 +1,43 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/opensensorfusion,osf.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Open Sensor Fusion Sensor Aggregation Hub
+
+maintainers:
+  - Jinseob Kim <[email protected]>
+
+description: |
+  Open Sensor Fusion is a sensor aggregation hub. The hub exposes an OSF
+  protocol data stream over its host interface and may report capabilities and
+  samples for multiple sensor classes. The Linux driver discovers the actual
+  sensor channels from OSF capability reports instead of describing those
+  sensors in Device Tree.
+
+  Open Sensor Fusion is not a generic industry standard. Public project
+  documentation is available at:
+
+    https://github.com/opensensorfusion

Documentation/devicetree/bindings/iio/opensensorfusion,osf.yaml line 32

Quoted 10 lines
Documentation/devicetree/bindings/iio/opensensorfusion,osf.yaml new file +10 -0
+
+allOf:
+  - $ref: /schemas/serial/serial-peripheral-props.yaml#
+
+properties:
+  compatible:
+    const: opensensorfusion,osf
+
+required:
+  - compatible  

Do you think it makes sense to permit a regulator here, so that the "host" OS can power on/off the board running the osf stack?

Quoted 11 lines
Documentation/devicetree/bindings/iio/opensensorfusion,osf.yaml new file +11 -0
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    serial {
+        sensor {
+            compatible = "opensensorfusion,osf";
+        };
+    };
+...  
#5 lore raw

Re: [PATCH RFC v4 1/6] dt-bindings: iio: add Open Sensor Fusion device

2026년 6월 15일 (월) 오전 2:55, Jonathan Cameron <[email protected]>님이 작성:

Quoted 7 lines

On Wed, 10 Jun 2026 18:33:54 +0900
Kim Jinseob <[email protected]> wrote:

When a device needs power, the regulator is required, not optional from a binding point of view. If it is always one people can use a fixed regulator to represent it.

Quoted 6 lines

Now from a driver point of view, the regulator framework in linux provides stub regulators for missing ones - on assumption they are always on. So we can just request the regulators in the driver. Keep it simple for now and use a devm_regulator_get_enable() in probe so we have power on for all the time the driver is loaded. Can do fancy stuff later when you have a board where the power is controlled.

Understood, thanks.

I will make vcc-supply a required property in the binding and use devm_regulator_get_enable() in probe in the next revision, keeping the power handling simple for now.

Jinseob

maintainer
#6 lore raw

Re: [PATCH RFC v4 1/6] dt-bindings: iio: add Open Sensor Fusion device

In reply to Jinseob Kim
Quoted 5 lines · On Mon, 8 Jun 2026 08:43:38 +0900 Jinseob Kim <[email protected]> wrote:

Describe the OSF sensor aggregation hub.

Use the generic opensensorfusion,osf compatible.

This seems to be a patch against an earlier version of your series. Make sure this applies directly on the upstream kernel (release or rc1 typically depending on which is most recent).

Jonathan

Quoted 14 lines
---
 .../iio/imu/opensensorfusion,osf-green.yaml   | 43 -------------------
 .../bindings/iio/opensensorfusion,osf.yaml    | 43 +++++++++++++++++++
 MAINTAINERS                                   | 27 ++++++------
 3 files changed, 57 insertions(+), 56 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/iio/imu/opensensorfusion,osf-green.yaml
 create mode 100644 Documentation/devicetree/bindings/iio/opensensorfusion,osf.yaml
Documentation/devicetree/bindings/iio/imu/opensensorfusion,osf-green.yaml deleted +0 -0
deleted file mode 100644
index 626b41fb0..000000000

Documentation/devicetree/bindings/iio/imu/opensensorfusion,osf-green.yaml line 5

Quoted 5 lines
Documentation/devicetree/bindings/iio/imu/opensensorfusion,osf-green.yaml deleted +0 -5
@@ -1,43 +0,0 @@
-# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
-%YAML 1.2
----
-$id: http://devicetree.org/schemas/iio/imu/opensensorfusion,osf-green.yaml#
-$schema: http://devicetree.org/meta-schemas/core.yaml#

As above. There shouldn't be anything to remove!

Quoted 31 lines
MAINTAINERS +3 -13
index 56181470d..e227b9aff 100644
@@ -19977,19 +19977,6 @@ F:	Documentation/networking/oa-tc6-framework.rst
 F:	drivers/net/ethernet/oa_tc6.c
 F:	include/linux/oa_tc6.h
 
-OPEN SENSOR FUSION IIO DRIVER
-M:	Jinseob Kim <[email protected]>
-S:	Maintained
-F:	Documentation/devicetree/bindings/iio/imu/opensensorfusion,osf-green.yaml
-F:	Documentation/iio/open-sensor-fusion-protocol-v0.rst
-F:	drivers/iio/opensensorfusion/Kconfig
-F:	drivers/iio/opensensorfusion/Makefile
-F:	drivers/iio/opensensorfusion/osf_core.*
-F:	drivers/iio/opensensorfusion/osf_iio.*
-F:	drivers/iio/opensensorfusion/osf_protocol.*
-F:	drivers/iio/opensensorfusion/osf_serdev.c
-F:	drivers/iio/opensensorfusion/osf_stream.*
-
 OPEN FIRMWARE AND FLATTENED DEVICE TREE
 M:	Rob Herring <[email protected]>
 M:	Saravana Kannan <[email protected]>
@@ -20024,6 +20011,20 @@ F:	Documentation/devicetree/
 F:	arch/*/boot/dts/
 F:	include/dt-bindings/
 
+OPEN SENSOR FUSION IIO DRIVER
+M:	Jinseob Kim <[email protected]>
+S:	Maintained

MAINTAINERS F: Documentation/devicetree/ · line 20026

Quoted 10 lines
MAINTAINERS +10 -0
+F:	Documentation/devicetree/bindings/iio/opensensorfusion,osf.yaml
+F:	Documentation/iio/open-sensor-fusion-protocol-v0.rst
+F:	drivers/iio/opensensorfusion/Kconfig
+F:	drivers/iio/opensensorfusion/Makefile
+F:	drivers/iio/opensensorfusion/osf_core.*
+F:	drivers/iio/opensensorfusion/osf_iio.*
+F:	drivers/iio/opensensorfusion/osf_protocol.*
+F:	drivers/iio/opensensorfusion/osf_serdev.c
+F:	drivers/iio/opensensorfusion/osf_stream.*
+

One blank line.

Quoted 4 lines
MAINTAINERS +1 -0
+
 OPENCOMPUTE PTP CLOCK DRIVER
 M:	Vadim Fedorenko <[email protected]>
 L:	[email protected]
#7 lore raw

RFC PATCH v4 2/6 Documentation: iio: add Open Sensor Fusion driver overview

In reply to Jinseob Kim

Add a short driver-facing overview.

Leave full protocol details to project docs.

---
 Documentation/iio/index.rst                   |   1 +
 .../iio/open-sensor-fusion-protocol-v0.rst    | 308 ------------------
 Documentation/iio/open-sensor-fusion.rst      |  62 ++++
 MAINTAINERS                                   |   3 +-
 4 files changed, 64 insertions(+), 310 deletions(-)
 delete mode 100644 Documentation/iio/open-sensor-fusion-protocol-v0.rst
 create mode 100644 Documentation/iio/open-sensor-fusion.rst
Documentation/iio/index.rst +1 -0
index ba3e609c6..2713ec5e0 100644
@@ -38,4 +38,5 @@ Industrial I/O Kernel Drivers
    adxl345
    bno055
    ep93xx_adc
+   open-sensor-fusion
    opt4060
Documentation/iio/open-sensor-fusion-protocol-v0.rst deleted +0 -308

308 lines not on this page · raw message

Documentation/iio/open-sensor-fusion.rst new file +62 -0

62 lines not on this page · raw message

MAINTAINERS +1 -2
index e227b9aff..2ddefc42d 100644
@@ -20015,7 +20015,7 @@ OPEN SENSOR FUSION IIO DRIVER
 M:	Jinseob Kim <[email protected]>
 S:	Maintained
 F:	Documentation/devicetree/bindings/iio/opensensorfusion,osf.yaml
-F:	Documentation/iio/open-sensor-fusion-protocol-v0.rst
+F:	Documentation/iio/open-sensor-fusion.rst
 F:	drivers/iio/opensensorfusion/Kconfig
 F:	drivers/iio/opensensorfusion/Makefile
 F:	drivers/iio/opensensorfusion/osf_core.*
@@ -20024,7 +20024,6 @@ F:	drivers/iio/opensensorfusion/osf_protocol.*
 F:	drivers/iio/opensensorfusion/osf_serdev.c
 F:	drivers/iio/opensensorfusion/osf_stream.*
 
-
 OPENCOMPUTE PTP CLOCK DRIVER
 M:	Vadim Fedorenko <[email protected]>
 L:	[email protected]
Signature · 1 line
2.43.0
maintainer
#8 lore raw

Re: [PATCH RFC v4 2/6] Documentation: iio: add Open Sensor Fusion driver overview

Quoted 5 lines · On Mon, 8 Jun 2026 08:43:39 +0900 Jinseob Kim <[email protected]> wrote:

Add a short driver-facing overview.

Leave full protocol details to project docs.

Same issue on needing this series to be against a suitable tree, not on top of your previous version.

Quoted 24 lines
---
 Documentation/iio/index.rst                   |   1 +
 .../iio/open-sensor-fusion-protocol-v0.rst    | 308 ------------------
 Documentation/iio/open-sensor-fusion.rst      |  62 ++++
 MAINTAINERS                                   |   3 +-
 4 files changed, 64 insertions(+), 310 deletions(-)
 delete mode 100644 Documentation/iio/open-sensor-fusion-protocol-v0.rst
 create mode 100644 Documentation/iio/open-sensor-fusion.rst
MAINTAINERS +1 -1
index e227b9aff..2ddefc42d 100644
@@ -20015,7 +20015,7 @@ OPEN SENSOR FUSION IIO DRIVER
 M:	Jinseob Kim <[email protected]>
 S:	Maintained
 F:	Documentation/devicetree/bindings/iio/opensensorfusion,osf.yaml
-F:	Documentation/iio/open-sensor-fusion-protocol-v0.rst
+F:	Documentation/iio/open-sensor-fusion.rst
 F:	drivers/iio/opensensorfusion/Kconfig
 F:	drivers/iio/opensensorfusion/Makefile
 F:	drivers/iio/opensensorfusion/osf_core.*

MAINTAINERS F: drivers/iio/opensensorfusion/osf_protocol.* · line 20027

Quoted 4 lines
MAINTAINERS +0 -1
@@ -20024,7 +20024,6 @@ F:	drivers/iio/opensensorfusion/osf_protocol.*
 F:	drivers/iio/opensensorfusion/osf_serdev.c
 F:	drivers/iio/opensensorfusion/osf_stream.*
 
-

Check your series for things like this right before sending (we all make mistakes like this when building up series!) It clearly belongs in the previous patch.

Quoted 3 lines
MAINTAINERS +0 -0
 OPENCOMPUTE PTP CLOCK DRIVER
 M:	Vadim Fedorenko <[email protected]>
 L:	[email protected]
#9 lore raw

Re: [PATCH RFC v4 2/6] Documentation: iio: add Open Sensor Fusion driver overview

Quoted 2 lines

Same issue on needing this series to be against a suitable tree, not on top of your previous version.

Understood, thanks.

I will regenerate the next revision as a full standalone series against a clean upstream base, not on top of the previous version.

I will also check the final diffstat before sending so files from earlier versions are not removed, and fold the MAINTAINERS cleanup into the correct patch.

Thanks,

Jinseob

#10 lore raw

RFC PATCH v4 3/6 iio: osf: add protocol decoding

In reply to Jinseob Kim

Use a FourCC-style wire magic comparison.

Document signed little-endian sample handling.

---
 drivers/iio/opensensorfusion/osf_protocol.c | 4 +++-
 drivers/iio/opensensorfusion/osf_protocol.h | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)
drivers/iio/opensensorfusion/osf_protocol.c +3 -1
index ed91d3dd5..5bee545f3 100644
@@ -11,6 +11,7 @@
 
 #define OSF_CRC32_INIT		GENMASK(31, 0)
 #define OSF_CRC32_XOROUT	GENMASK(31, 0)
+#define OSF_FRAME_MAGIC		0x3046534f /* "OSF0" little-endian */
 
 static bool osf_sensor_type_valid(u16 sensor_type)
 {
@@ -38,7 +39,7 @@ int osf_protocol_decode_frame(const u8 *buf, size_t len,
 	if (len < OSF_FRAME_MIN_LEN)
 		return -EMSGSIZE;
 
-	if (buf[0] != 'O' || buf[1] != 'S' || buf[2] != 'F' || buf[3] != '0')
+	if (get_unaligned_le32(buf) != OSF_FRAME_MAGIC)
 		return -EPROTO;
 
 	major = buf[4];
@@ -136,6 +137,7 @@ int osf_protocol_sensor_sample_value(const struct osf_sensor_sample *sample,
 	if (index >= sample->channel_count)
 		return -ERANGE;
 
+	/* Samples are little-endian two's-complement signed values. */
 	*value = (s32)get_unaligned_le32(sample->samples + index * sizeof(s32));
 
 	return 0;
drivers/iio/opensensorfusion/osf_protocol.h +3 -1
index 4b6fb131a..c62c2c254 100644
@@ -2,6 +2,7 @@
 #ifndef _OSF_PROTOCOL_H
 #define _OSF_PROTOCOL_H
 
+#include <linux/bits.h>
 #include <linux/types.h>
 
 #define OSF_PROTOCOL_MAJOR		0
@@ -14,7 +15,7 @@
 #define OSF_DEVICE_STATUS_LEN		20
 #define OSF_CAP_REPORT_BASE_LEN		4
 #define OSF_CAP_SENSOR_ENTRY_LEN		20
-#define OSF_CAPABILITY_FLAGS_MASK	0x00000003U
+#define OSF_CAPABILITY_FLAGS_MASK	GENMASK(1, 0)
 
 enum osf_message_type {
 	OSF_MSG_SENSOR_SAMPLE		= 0x0001,
@@ -44,6 +45,7 @@ struct osf_frame {
 	u64 sequence;
 	u64 timestamp_us;
 	u32 flags;
+	/* payload points into the caller-owned frame buffer. */
 	const u8 *payload;
 	u32 crc;
 };
Signature · 1 line
2.43.0
#11 lore raw

RFC PATCH v4 4/6 iio: osf: add stream parser

In reply to Jinseob Kim

Keep the parser focused on frame assembly.

Let the core decode complete frames once.

---
 drivers/iio/opensensorfusion/osf_stream.c | 38 ++++++-----------------
 1 file changed, 9 insertions(+), 29 deletions(-)
drivers/iio/opensensorfusion/osf_stream.c +9 -29
index a2739c987..957f73716 100644
@@ -62,8 +62,6 @@ static size_t osf_stream_discard_to_magic(struct osf_stream *stream)
 
 static int osf_stream_process(struct osf_stream *stream)
 {
-	struct osf_frame frame;
-	size_t decoded_len;
 	size_t discarded;
 	size_t frame_len;
 	u32 payload_len;
@@ -82,10 +80,8 @@ static int osf_stream_process(struct osf_stream *stream)
 		if (!stream->len)
 			break;
 
-		if (stream->len < OSF_FRAME_HEADER_LEN) {
-			stream->stats.partial_frames++;
+		if (stream->len < OSF_FRAME_HEADER_LEN)
 			break;
-		}
 
 		if (get_unaligned_le16(stream->buf + 6) !=
 		    OSF_FRAME_HEADER_LEN) {
@@ -106,34 +102,18 @@ static int osf_stream_process(struct osf_stream *stream)
 		}
 
 		frame_len = OSF_FRAME_HEADER_LEN + payload_len + OSF_FRAME_CRC_LEN;
-		if (stream->len < frame_len) {
-			stream->stats.partial_frames++;
+		if (stream->len < frame_len)
 			break;
-		}
-
-		ret = osf_protocol_decode_frame(stream->buf, frame_len, &frame,
-						&decoded_len);
-		if (ret) {
-			if (ret == -EBADMSG)
-				stream->stats.bad_crc_frames++;
-			stream->stats.dropped_bytes++;
-			osf_stream_drop_invalid_head(stream);
-			if (!first_err)
-				first_err = ret;
-			continue;
-		}
-
-		if (decoded_len != frame_len) {
-			stream->stats.dropped_bytes++;
-			osf_stream_drop_invalid_head(stream);
-			if (!first_err)
-				first_err = -EMSGSIZE;
-			continue;
-		}
 
 		ret = osf_core_receive_frame(stream->osf, stream->buf, frame_len);
 		if (ret) {
-			osf_stream_discard(stream, frame_len);
+			if (ret == -EBADMSG) {
+				stream->stats.bad_crc_frames++;
+				stream->stats.dropped_bytes++;
+				osf_stream_drop_invalid_head(stream);
+			} else {
+				osf_stream_discard(stream, frame_len);
+			}
 			if (!first_err)
 				first_err = ret;
 			continue;
Signature · 1 line
2.43.0
#12 lore raw

RFC PATCH v4 5/6 iio: osf: add UART transport

In reply to Jinseob Kim

Use the generic Open Sensor Fusion compatible.

Avoid board-specific DT compatibles.

---
 drivers/iio/opensensorfusion/Kconfig      | 4 ++--
 drivers/iio/opensensorfusion/osf_serdev.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/iio/opensensorfusion/Kconfig +2 -2
index 957caed2b..8b9376d28 100644
@@ -10,5 +10,5 @@ config OPEN_SENSOR_FUSION
 	help
 	  Build the Open Sensor Fusion UART IIO driver.
 
-	  The driver receives OSF0 frames over a serdev UART and registers
-	  IIO devices for supported capability entries.
+	  The driver receives OSF protocol frames over a serdev UART and
+	  registers IIO devices for supported capability entries.
drivers/iio/opensensorfusion/osf_serdev.c +1 -1
index 1ac93548d..fd36acd1b 100644
@@ -91,7 +91,7 @@ static void osf_serdev_remove(struct serdev_device *serdev)
 }
 
 static const struct of_device_id osf_serdev_of_match[] = {
-	{ .compatible = "opensensorfusion,osf-green" },
+	{ .compatible = "opensensorfusion,osf" },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, osf_serdev_of_match);
Signature · 1 line
2.43.0
#13 lore raw

RFC PATCH v4 6/6 iio: osf: register IIO devices from capabilities

In reply to Jinseob Kim

Clean up the IIO sample push path.

Drop the redundant temperature scan mask.

---
 drivers/iio/opensensorfusion/osf_core.c |  9 +++++----
 drivers/iio/opensensorfusion/osf_iio.c  | 15 +++------------
 2 files changed, 8 insertions(+), 16 deletions(-)
drivers/iio/opensensorfusion/osf_core.c +5 -4
index e0a12de01..61ef55646 100644
@@ -293,10 +293,11 @@ int osf_core_read_latest_sample(struct osf_device *osf, u16 sensor_type,
 		    latest->sensor_index != sensor_index)
 			continue;
 
-		if (latest->valid && channel < latest->channel_count) {
-			*value = latest->values[channel];
-			ret = 0;
-		}
+		if (!latest->valid || channel >= latest->channel_count)
+			break;
+
+		*value = latest->values[channel];
+		ret = 0;
 		break;
 	}
 	mutex_unlock(&osf->latest_lock);
drivers/iio/opensensorfusion/osf_iio.c +3 -12
index 5e5099878..3da3f2bda 100644
@@ -6,7 +6,6 @@
 #include <linux/iio/buffer.h>
 #include <linux/iio/iio.h>
 #include <linux/iio/kfifo_buf.h>
-#include <linux/string.h>
 #include <linux/types.h>
 #include <linux/units.h>
 
@@ -89,10 +88,6 @@ static const unsigned long osf_3axis_available_scan_masks[] = {
 	0
 };
 
-static const unsigned long osf_temp_available_scan_masks[] = {
-	BIT(0),
-	0
-};
 
 static const struct osf_iio_sensor_spec osf_iio_sensor_specs[] = {
 	{
@@ -125,7 +120,6 @@ static const struct osf_iio_sensor_spec osf_iio_sensor_specs[] = {
 		.name = "osf-temp",
 		.channels = osf_temp_channels,
 		.num_channels = ARRAY_SIZE(osf_temp_channels),
-		.available_scan_masks = osf_temp_available_scan_masks,
 	},
 };
 
@@ -265,21 +259,18 @@ int osf_iio_push_sample(struct iio_dev *indio_dev, const s32 *values,
 			unsigned int channel_count)
 {
 	struct osf_iio_state *state = iio_priv(indio_dev);
-	s32 scan[OSF_MAX_SAMPLE_CHANNELS] = { };
 	s64 timestamp;
 
 	if (channel_count != state->spec->channel_count)
 		return -EPROTO;
 
-	memcpy(scan, values, channel_count * sizeof(*values));
-
-	/* Buffer state can change here; IIO rechecks it during the push path. */
+	/* This is only a fast path; IIO rechecks buffer state while pushing. */
 	if (!iio_buffer_enabled(indio_dev))
 		return 0;
 
 	timestamp = iio_get_time_ns(indio_dev);
 
-	return iio_push_to_buffers_with_ts_unaligned(indio_dev, scan,
-						     channel_count * sizeof(*scan),
+	return iio_push_to_buffers_with_ts_unaligned(indio_dev, values,
+						     channel_count * sizeof(*values),
 						     timestamp);
 }
Signature · 1 line
2.43.0
#14 lore raw
In reply to Jinseob Kim

Hey,

Quoted 9 lines · Jinseob Kim

This RFC series adds an Industrial I/O driver for Open Sensor Fusion sensor aggregation devices.

Open Sensor Fusion is an open hardware project for sensor aggregation devices. The Linux IIO driver is an initial host-side implementation for OSF devices. The driver receives OSF frames over UART, uses device capability reports to discover supported sensor streams, and exposes supported raw sensor data through IIO devices.

Quoted 7 lines

This series is still marked RFC because the DT binding identity, the supported OSF protocol subset, and protocol extension and backward compatibility rules are still under review. The v4 series intentionally models the Linux device as a generic Open Sensor Fusion device rather than an OSF GREEN board-specific device. OSF GREEN is the prototype board used for current runtime testing, not the Linux DT compatible or driver identity.

Other than the fact that new revisions must not be sent as a diff on top of a prior revision, please stop sending new versions without actually replying to my v1 comments. In particular:

| What does "v0" mean here? Is the data format not complete yet?
| Are versions of the protocol likely to be backwards compatible?
| Will the device identify what version of the protocol it implements?

This version drops mention of v0 in the binding, but I don't know if that means the version is fully discoverable or if you've moved to a stable revision etc. You need to spell this stuff out to us, I'm not going to read a github repository to figure this out - I have hundreds of patches to get through every day. It's your responsibility to explain it all.

Quoted 2 lines

The current wire format uses the OSF0 magic for protocol major version 0. That is kept as an internal wire-format detail for

For example, what does "OSF0 magic" mean? Is that a detectable version number in a consistent place across revisions? Or will OSF1 magic be incompatible. From a devicetree point of view, that's important because if the magic is in different places in different revisions, the compatible needs to convey what revision the device implements.

Quoted 3 lines

compatibility with existing firmware, tools, and runtime smoke evidence. The public driver identity remains Open Sensor Fusion / OSF, with protocol versioning handled by the protocol major/minor fields.

This sounds like versioning is discoverable, but you need to spell this out in the commit message for the binding.

Thanks,
Conor.

Quoted 73 lines

Project links:
https://www.opensensorfusion.org/
https://github.com/opensensorfusion
https://github.com/opensensorfusion/opensensorfusion-hardware
https://github.com/opensensorfusion/opensensorfusion-linux

Runtime testing so far has used an OSF GREEN prototype connected to a Raspberry Pi over UART. On Raspberry Pi 6.12.75+rpt-rpi-v8, the driver registered osf-accel, osf-gyro, osf-magn, and osf-temp from a capability report. Raw reads and software kfifo buffer reads were tested for all four IIO devices.

Changes since v3:

* Explain why the series is still RFC.
* Move the DT binding out of iio/imu because the device is a sensor aggregation device rather than an IMU.
* Replace the OSF GREEN board-specific compatible with the generic opensensorfusion,osf compatible.
* Treat OSF GREEN as tested prototype hardware / board model information, not as the Linux compatible string.
* Rename the kernel documentation to open-sensor-fusion.rst and reduce it to a driver-facing overview.
* Add the IIO documentation toctree entry.
* Keep full protocol details and compatibility rules in project documentation rather than duplicating the full wire specification in the kernel tree.
* Avoid using OSF0 as the public driver identity; keep it only as the current wire magic for protocol major version 0.
* Add FourCC-style wire magic handling in the decoder.
* Use GENMASK() for the capability flags mask.
* Clarify signed 32-bit little-endian sample decoding.
* Stop counting normal partial UART receive waits as partial frame errors.
* Avoid decoding complete frames twice in the stream/core path.
* Remove the local scan[] bounce before iio_push_to_buffers_with_ts_unaligned() and pass the values buffer directly.
* Remove the meaningless temperature available_scan_masks entry.
* Update MAINTAINERS paths for the new binding and documentation names.

Jinseob Kim (6):
dt-bindings: iio: add Open Sensor Fusion device
Documentation: iio: add Open Sensor Fusion driver overview
iio: osf: add protocol decoding
iio: osf: add stream parser
iio: osf: add UART transport
iio: osf: register IIO devices from capabilities

 .../iio/imu/opensensorfusion,osf-green.yaml   |  43 ---
 .../bindings/iio/opensensorfusion,osf.yaml    |  43 +++
 Documentation/iio/index.rst                   |   1 +
 .../iio/open-sensor-fusion-protocol-v0.rst    | 308 ------------------
 Documentation/iio/open-sensor-fusion.rst      |  62 ++++
 MAINTAINERS                                   |  26 +-
 drivers/iio/opensensorfusion/Kconfig          |   4 +-
 drivers/iio/opensensorfusion/osf_core.c       |   9 +-
 drivers/iio/opensensorfusion/osf_iio.c        |  15 +-
 drivers/iio/opensensorfusion/osf_protocol.c   |   4 +-
 drivers/iio/opensensorfusion/osf_protocol.h   |   4 +-
 drivers/iio/opensensorfusion/osf_serdev.c     |   2 +-
 drivers/iio/opensensorfusion/osf_stream.c     |  38 +--
 13 files changed, 145 insertions(+), 414 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/iio/imu/opensensorfusion,osf-green.yaml
 create mode 100644 Documentation/devicetree/bindings/iio/opensensorfusion,osf.yaml
 delete mode 100644 Documentation/iio/open-sensor-fusion-protocol-v0.rst
 create mode 100644 Documentation/iio/open-sensor-fusion.rst
Signature · 1 line
2.43.0
#15 lore raw
Quoted 3 lines

Other than the fact that new revisions must not be sent as a diff on top of a prior revision, please stop sending new versions without actually replying to my v1 comments.

You are right, sorry for the noise.

I made a process mistake here. I prepared v4 on top of the previously sent series instead of preparing it as a full standalone replacement series from the proper base. I will not ask you to review v4 in that form, and I will prepare the next revision as a full series from a clean base.

I also should have answered your protocol versioning questions directly before sending another revision.

Quoted 3 lines

What does "v0" mean here? Is the data format not complete yet? Are versions of the protocol likely to be backwards compatible? Will the device identify what version of the protocol it implements?

The current OSF wire header starts with a fixed 4-byte magic, "OSF0", at a fixed offset. The same header also carries explicit protocol_major and protocol_minor fields at fixed offsets.

For the currently supported firmware and driver, protocol_major is 0. The "0" in "OSF0" is intended to denote the current major wire-format revision, not the Linux driver identity.

The binding is intended for devices implementing this discoverable OSF header layout. The driver currently supports protocol major version 0. Minor version changes are intended to be backward compatible. Incompatible wire-format changes require a new protocol_major value.

If a future major revision cannot be discovered using the same fixed header layout, or is not compatible with this binding, it should use a new compatible string.

I will spell this out in the binding commit message and documentation in the next revision.

Jinseob