[PATCH v8 0/5] iio: add Open Sensor Fusion IIO driver

Jinseob Kim posted 5 patches 1 month, 1 week ago
.../bindings/iio/opensensorfusion,osf.yaml    |  52 ++
.../devicetree/bindings/vendor-prefixes.yaml  |   2 +
Documentation/iio/index.rst                   |   1 +
Documentation/iio/open-sensor-fusion.rst      |  72 +++
MAINTAINERS                                   |   8 +
drivers/iio/Kconfig                           |   1 +
drivers/iio/Makefile                          |   1 +
drivers/iio/opensensorfusion/Kconfig          |  27 +
drivers/iio/opensensorfusion/Makefile         |   7 +
drivers/iio/opensensorfusion/osf_core.c       | 393 ++++++++++++++
drivers/iio/opensensorfusion/osf_core.h       |  70 +++
drivers/iio/opensensorfusion/osf_core_test.c  | 493 ++++++++++++++++++
drivers/iio/opensensorfusion/osf_iio.c        | 304 +++++++++++
drivers/iio/opensensorfusion/osf_iio.h        |  22 +
drivers/iio/opensensorfusion/osf_protocol.c   | 224 ++++++++
drivers/iio/opensensorfusion/osf_protocol.h   | 101 ++++
drivers/iio/opensensorfusion/osf_serdev.c     | 124 +++++
drivers/iio/opensensorfusion/osf_stream.c     | 231 ++++++++
drivers/iio/opensensorfusion/osf_stream.h     |  53 ++
19 files changed, 2186 insertions(+)
create mode 100644 Documentation/devicetree/bindings/iio/opensensorfusion,osf.yaml
create mode 100644 Documentation/iio/open-sensor-fusion.rst
create mode 100644 drivers/iio/opensensorfusion/Kconfig
create mode 100644 drivers/iio/opensensorfusion/Makefile
create mode 100644 drivers/iio/opensensorfusion/osf_core.c
create mode 100644 drivers/iio/opensensorfusion/osf_core.h
create mode 100644 drivers/iio/opensensorfusion/osf_core_test.c
create mode 100644 drivers/iio/opensensorfusion/osf_iio.c
create mode 100644 drivers/iio/opensensorfusion/osf_iio.h
create mode 100644 drivers/iio/opensensorfusion/osf_protocol.c
create mode 100644 drivers/iio/opensensorfusion/osf_protocol.h
create mode 100644 drivers/iio/opensensorfusion/osf_serdev.c
create mode 100644 drivers/iio/opensensorfusion/osf_stream.c
create mode 100644 drivers/iio/opensensorfusion/osf_stream.h
[PATCH v8 0/5] iio: add Open Sensor Fusion IIO driver
Posted by Jinseob Kim 1 month, 1 week ago
Open Sensor Fusion (OSF) is a physical sensor board that reports
measurements over UART.  Add a serdev driver using the generic
"opensensorfusion,osf" compatible.

The compatible is intentionally independent of a board model or firmware
revision.  A fixed wire header carries the protocol version, while a
capability report discovers the available sensors and channels at runtime.
Supported capabilities are exposed as four IIO devices: accelerometer,
gyroscope, magnetometer, and temperature.

Changes since v7:

  - Separate wire decoding from support policy.  Validate the protocol
    major and reserved header bytes after frame authentication, and ignore
    unsupported capability entries without discarding supported entries.
  - Harden resynchronization: unauthenticated candidates discard one head
    byte, while authenticated frames consume the complete frame for every
    handled, ignored, or rejected outcome.
  - Retain split one-, two-, and three-byte magic prefixes across UART
    callbacks, and use an opaque callback so the stream parser does not
    depend on the driver added by patch 5.
  - Zero-initialize explicitly aligned IIO scans, use
    iio_push_to_buffers_with_ts(), and simplify the buffered fast path and
    one-axis versus three-axis handling.
  - Commit a sensor sample to the direct-read cache only after the
    registered IIO channel and buffer path accepts it.  A rejected
    CRC-valid sample therefore cannot change direct RAW state or the last
    accepted sequence.
  - Add focused KUnit coverage for accepted, ignored, rejected, and
    malformed sample paths and protection against invalid-sample cache-slot
    exhaustion.  Run the same suite against pre-fix ordering as a negative
    control.
  - Consolidate MAINTAINERS coverage under
    F: drivers/iio/opensensorfusion/.

Static and build validation completed for the corrected source includes
git diff --check, scripts/checkpatch.pl --strict with no errors or warnings
on all five patches, four passing focused KUnit cases, the expected two
failures when the same tests are run against the pre-fix core, the targeted
DT binding check with dtschema 2026.6, the IIO documentation build with no
OSF-specific warnings, clean W=1 GCC and Clang module builds, per-patch
build checks, and clean-base application with an identical final tree.

Pre-audit v8 hardware validation used a Raspberry Pi 4 over UART with a
physical OSF board.  It covered serdev probe and bind, capability
discovery, direct raw reads, a 66.5-second simultaneous buffered capture of all four IIO
devices, and unload and reload.  The capture delivered 919 accelerometer
samples and 918 samples from each of the gyroscope, magnetometer, and
temperature devices, without a kernel warning, OOPS, or IIO overrun.

A focused post-audit Raspberry Pi regression then exercised the corrected
ARM64 module in a one-shot tryboot without installing it or changing boot
artifacts.  Both the first load and reload registered four IIO devices and
passed direct raw reads.  A 12.0005-second simultaneous buffered capture
delivered 165 accelerometer, 165 gyroscope, 166 magnetometer, and 166
temperature records, with no read errors, timestamp regressions, or
critical dmesg findings.  Unload, reload, and final cleanup passed, and one
normal reboot restored the stock kernel with the OSF module and devices
absent.

A validation-only debug build from the pre-audit v8 development source was
used solely to observe internal parser and DEVICE_STATUS counters.
All parser error counters stayed at zero, and all 94 DEVICE_STATUS reports had a zero
dropped-frame count.  The submitted source exposes no debug counter ABI.

This series is based on the IIO testing branch at
a9fa85254feee2b52b2bb4fbb4920ece47dfd6f8.

Previous revisions:

v1: https://lore.kernel.org/r/20260520072843.3593-1-kimjinseob88@gmail.com
v2: https://lore.kernel.org/r/20260524085312.15369-1-kimjinseob88@gmail.com
v3: https://lore.kernel.org/r/20260529121005.1470-1-kimjinseob88@gmail.com
v4: https://lore.kernel.org/r/20260607234343.22109-1-kimjinseob88@gmail.com
v5: https://lore.kernel.org/r/20260616072242.3942-1-kimjinseob88@gmail.com
v6: https://lore.kernel.org/r/20260628191337.937-1-kimjinseob88@gmail.com
v7: https://lore.kernel.org/r/20260707014525.1015-1-kimjinseob88@gmail.com

Jinseob Kim (5):
  dt-bindings: iio: add Open Sensor Fusion device
  Documentation: iio: add Open Sensor Fusion driver overview
  iio: osf: add protocol decoding
  iio: osf: add authenticated stream parser
  iio: osf: add UART IIO driver

 .../bindings/iio/opensensorfusion,osf.yaml    |  52 ++
 .../devicetree/bindings/vendor-prefixes.yaml  |   2 +
 Documentation/iio/index.rst                   |   1 +
 Documentation/iio/open-sensor-fusion.rst      |  72 +++
 MAINTAINERS                                   |   8 +
 drivers/iio/Kconfig                           |   1 +
 drivers/iio/Makefile                          |   1 +
 drivers/iio/opensensorfusion/Kconfig          |  27 +
 drivers/iio/opensensorfusion/Makefile         |   7 +
 drivers/iio/opensensorfusion/osf_core.c       | 393 ++++++++++++++
 drivers/iio/opensensorfusion/osf_core.h       |  70 +++
 drivers/iio/opensensorfusion/osf_core_test.c  | 493 ++++++++++++++++++
 drivers/iio/opensensorfusion/osf_iio.c        | 304 +++++++++++
 drivers/iio/opensensorfusion/osf_iio.h        |  22 +
 drivers/iio/opensensorfusion/osf_protocol.c   | 224 ++++++++
 drivers/iio/opensensorfusion/osf_protocol.h   | 101 ++++
 drivers/iio/opensensorfusion/osf_serdev.c     | 124 +++++
 drivers/iio/opensensorfusion/osf_stream.c     | 231 ++++++++
 drivers/iio/opensensorfusion/osf_stream.h     |  53 ++
 19 files changed, 2186 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/opensensorfusion,osf.yaml
 create mode 100644 Documentation/iio/open-sensor-fusion.rst
 create mode 100644 drivers/iio/opensensorfusion/Kconfig
 create mode 100644 drivers/iio/opensensorfusion/Makefile
 create mode 100644 drivers/iio/opensensorfusion/osf_core.c
 create mode 100644 drivers/iio/opensensorfusion/osf_core.h
 create mode 100644 drivers/iio/opensensorfusion/osf_core_test.c
 create mode 100644 drivers/iio/opensensorfusion/osf_iio.c
 create mode 100644 drivers/iio/opensensorfusion/osf_iio.h
 create mode 100644 drivers/iio/opensensorfusion/osf_protocol.c
 create mode 100644 drivers/iio/opensensorfusion/osf_protocol.h
 create mode 100644 drivers/iio/opensensorfusion/osf_serdev.c
 create mode 100644 drivers/iio/opensensorfusion/osf_stream.c
 create mode 100644 drivers/iio/opensensorfusion/osf_stream.h

-- 
2.43.0
Re: [PATCH v8 0/5] iio: add Open Sensor Fusion IIO driver
Posted by Jonathan Cameron 1 month, 1 week ago
On Thu, 20 Aug 2026 14:06:03 +0900
Jinseob Kim <kimjinseob88@gmail.com> wrote:

> Open Sensor Fusion (OSF) is a physical sensor board that reports
> measurements over UART.  Add a serdev driver using the generic
> "opensensorfusion,osf" compatible.
> 
> The compatible is intentionally independent of a board model or firmware
> revision.  A fixed wire header carries the protocol version, while a
> capability report discovers the available sensors and channels at runtime.
> Supported capabilities are exposed as four IIO devices: accelerometer,
> gyroscope, magnetometer, and temperature.
> 

Sashiko has one reasonable sounding comment
https://sashiko.dev/#/patchset/20260820050608.5440-1-kimjinseob88%40gmail.com

What this cover letter is missing is any info on maturity of the
specification.  Is this at a stage where merging it to Linux
makes sense, or are there still elements on the spec side that need
to be resolved?

I'll take a fresh look anyway given it has been a while since
the last version, but others may make their decisions based on that
statement of how mature things are.

Jonathan
Re: [PATCH v8 0/5] iio: add Open Sensor Fusion IIO driver
Posted by Kim Jinseob 2 weeks, 1 day ago
Hi Jonathan

> What this cover letter is missing is any info on maturity of the
> specification.  Is this at a stage where merging it to Linux
> makes sense, or are there still elements on the spec side that need
> to be resolved?

my intention is to preserve compatibility across firmware updates by
keeping existing message layouts, lengths and field meanings, including
units, unchanged. Incompatible changes would require a new protocol
major and corresponding driver support.

The remaining specification work is to reconcile the draft differences
on reserved fields, extensions and magnetometer units. I will document
the agreed rules and compatibility policy in a versioned specification
referenced by v10.

Thanks,

Jinseob

2026년 8월 21일 (금) 오전 11:33, Jonathan Cameron <jic23@kernel.org>님이 작성:
>
> On Thu, 20 Aug 2026 14:06:03 +0900
> Jinseob Kim <kimjinseob88@gmail.com> wrote:
>
> > Open Sensor Fusion (OSF) is a physical sensor board that reports
> > measurements over UART.  Add a serdev driver using the generic
> > "opensensorfusion,osf" compatible.
> >
> > The compatible is intentionally independent of a board model or firmware
> > revision.  A fixed wire header carries the protocol version, while a
> > capability report discovers the available sensors and channels at runtime.
> > Supported capabilities are exposed as four IIO devices: accelerometer,
> > gyroscope, magnetometer, and temperature.
> >
>
> Sashiko has one reasonable sounding comment
> https://sashiko.dev/#/patchset/20260820050608.5440-1-kimjinseob88%40gmail.com
>
> What this cover letter is missing is any info on maturity of the
> specification.  Is this at a stage where merging it to Linux
> makes sense, or are there still elements on the spec side that need
> to be resolved?
>
> I'll take a fresh look anyway given it has been a while since
> the last version, but others may make their decisions based on that
> statement of how mature things are.
>
> Jonathan