public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Muchamad Coirul Anwar <muchamadcoirulanwar@gmail.com>
To: jic23@kernel.org, linux-iio@vger.kernel.org,
	rust-for-linux@vger.kernel.org, devicetree@vger.kernel.org
Cc: branstj@gmail.com, lars@metafoo.de, ojeda@kernel.org,
	robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org,
	igor.korotin.linux@gmail.com, linux-kernel@vger.kernel.org,
	Muchamad Coirul Anwar <muchamadcoirulanwar@gmail.com>
Subject: [RFC PATCH v2 0/4] iio: position: add Rust driver for ams AS5600
Date: Wed, 29 Apr 2026 20:22:26 +0700	[thread overview]
Message-ID: <20260429132234.30514-1-muchamadcoirulanwar@gmail.com> (raw)

This is v2 of the Rust driver for the ams AS5600 12-bit magnetic rotary
position sensor. v1 was a probe-only stub; this version adds minimal
Rust IIO abstractions and exposes in_angl_raw and in_angl_scale via
sysfs.

Link: https://lore.kernel.org/linux-iio/20260419151327.26306-1-muchamadcoirulanwar@gmail.com/

Changes since RFC v1:
  - Moved magnet validation from probe() to read_raw() per Jonathan's
    feedback. probe() now only verifies I2C communication.
  - Added minimal Rust IIO abstractions (rust/kernel/iio.rs) wrapping
    iio_device_alloc, iio_device_register, and the read_raw callback.
  - Added OF device table for devicetree matching (ams,as5600).
  - Replaced hex bit masks with kernel::bits::bit_u8() per Miguel's
    pointer.
  - Replaced magic numbers with bindings constants
    (iio_chan_info_enum_*, INDIO_DIRECT_MODE).
  - Downgraded log messages to dev_dbg!(), removed unbind noise.
  - Added devicetree binding documentation.
  - iio_info vtable is now a compile-time const.
  - Uses iio_device_alloc with PinnedDrop instead of devm_* to avoid
    lifetime conflicts with Rust's ownership model.

The IIO abstraction design was informed by earlier unpublished work
from Brandon Saint-John.

The IIO abstraction is intentionally minimal: it supports read_raw
with IIO_VAL_INT, IIO_VAL_INT_PLUS_NANO, IIO_VAL_INT_PLUS_MICRO,
and IIO_VAL_FRACTIONAL. write_raw and buffer support are left for
future work.

Muchamad Coirul Anwar (4):
  i2c: rust: add smbus_read_byte_data and smbus_read_word_data
  rust: add minimal IIO subsystem abstractions
  dt-bindings: iio: position: add ams,as5600
  iio: position: add Rust driver for ams AS5600

Signed-off-by: Muchamad Coirul Anwar <muchamadcoirulanwar@gmail.com>
---
Tested on BeagleBone Black (AM335x), kernel v7.0.0-rc3,
AS5600 on i2c-2 (0x36) at 3.3V, diametric neodymium magnet.

  $ cat /sys/bus/iio/devices/iio:device0/in_angl_raw
  3296
  $ cat /sys/bus/iio/devices/iio:device0/in_angl_raw
  1675
  $ cat /sys/bus/iio/devices/iio:device0/in_angl_raw
  468

  $ cat /sys/bus/iio/devices/iio:device0/in_angl_scale
  0.001533981

Magnet removed:

  $ cat /sys/bus/iio/devices/iio:device0/in_angl_raw
  cat: '/sys/bus/iio/devices/iio:device0/in_angl_raw': No data available

Muchamad Coirul Anwar (4):
  i2c: rust: add smbus_read_byte_data and smbus_read_word_data
  rust: add minimal IIO subsystem abstractions
  dt-bindings: iio: position: add ams,as5600
  iio: position: add Rust driver for ams AS5600

 .../bindings/iio/position/ams,as5600.yaml     |  40 ++++
 drivers/iio/position/Kconfig                  |  14 ++
 drivers/iio/position/Makefile                 |   1 +
 drivers/iio/position/as5600.rs                | 129 +++++
 rust/bindings/bindings_helper.h               |   2 +
 rust/kernel/i2c.rs                            |  24 +
 rust/kernel/iio.rs                            | 224 ++++++++++
 rust/kernel/lib.rs                            |   2 +
 8 files changed, 436 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/position/ams,as5600.yaml
 create mode 100644 drivers/iio/position/as5600.rs
 create mode 100644 rust/kernel/iio.rs

-- 
2.50.0


             reply	other threads:[~2026-04-29 13:22 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-29 13:22 Muchamad Coirul Anwar [this message]
2026-04-29 13:22 ` [RFC PATCH v2 1/4] i2c: rust: add smbus_read_byte_data and smbus_read_word_data Muchamad Coirul Anwar
2026-05-04 10:29   ` Igor Korotin
2026-04-29 13:22 ` [RFC PATCH v2 2/4] rust: add minimal IIO subsystem abstractions Muchamad Coirul Anwar
2026-04-29 13:22 ` [RFC PATCH v2 3/4] dt-bindings: iio: position: add ams,as5600 Muchamad Coirul Anwar
2026-04-29 13:46   ` Krzysztof Kozlowski
2026-04-29 13:22 ` [RFC PATCH v2 4/4] iio: position: add Rust driver for ams AS5600 Muchamad Coirul Anwar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260429132234.30514-1-muchamadcoirulanwar@gmail.com \
    --to=muchamadcoirulanwar@gmail.com \
    --cc=branstj@gmail.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=igor.korotin.linux@gmail.com \
    --cc=jic23@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ojeda@kernel.org \
    --cc=robh@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox