Skip to content

rust: add hwmon, rtc, leds, watchdog, and nvmem abstractions and drivers - #1250

Open
ZonaTell wants to merge 6 commits into
Rust-for-Linux:rust-nextfrom
ZonaTell:rust-drivers-and-subsystems
Open

rust: add hwmon, rtc, leds, watchdog, and nvmem abstractions and drivers#1250
ZonaTell wants to merge 6 commits into
Rust-for-Linux:rust-nextfrom
ZonaTell:rust-drivers-and-subsystems

Conversation

@ZonaTell

Copy link
Copy Markdown

Summary

This series introduces new safe Rust kernel subsystem abstractions and corresponding in-tree driver implementations across five major subsystems:

  1. I2C & SMBus Helpers (rust/kernel/i2c.rs):

    • Added safe SMBus byte and word read/write helpers (smbus_read_byte_data, smbus_write_byte_data, smbus_read_word_data, smbus_write_word_data).
  2. Hardware Monitoring (HWMON) (rust/kernel/hwmon.rs):

    • Added SensorType, TempAttribute, Operations trait, ChipInfo/ChannelInfo thread-safe wrappers, and RAII Registration.
    • Added LM75 / TMP75 / TMP102 / MCP980x digital temperature sensor driver (drivers/hwmon/lm75_rust.rs) with KUnit arithmetic tests.
  3. Real-Time Clock (RTC) (rust/kernel/rtc.rs):

    • Added RtcTime representation, BCD conversion routines (bcd_to_bin, bin_to_bcd), Operations trait, and class registration.
    • Added PCF8563 / RTC8564 I2C RTC driver (drivers/rtc/rtc_pcf8563_rust.rs) with low-voltage detection.
  4. LED Class & PWM Dimming (rust/kernel/leds.rs):

    • Added Brightness levels, Operations trait (brightness control, blocking callbacks, hardware blinking), and RAII registration.
    • Added NXP PCA9530..PCA9533 LED dimmer driver (drivers/leds/leds_pca9532_rust.rs) with hardware prescaler and PWM blinking.
  5. Watchdog Timer (rust/kernel/watchdog.rs):

    • Added WatchdogFlags, Operations trait (start, stop, ping, set_timeout), and devm_watchdog_register_device wrapper.
    • Added Zodiac Aerospace RAVE I2C watchdog processor driver (drivers/watchdog/ziirave_wdt_rust.rs).
  6. Non-Volatile Memory (NVMEM) (rust/kernel/nvmem.rs):

    • Added NvmemType, Operations trait for byte-level memory reads/writes, and registration.
    • Added Atmel/Microchip AT24 I2C EEPROM driver (drivers/misc/eeprom/at24_rust.rs) supporting 24C02 through 24C512 chips with 8-bit and 16-bit word addressing.

Verification

  • Built cleanly in-tree with strict -D warnings and -D missing-docs.
  • Module load metadata and device tables verified with modinfo.
  • Fixed-point arithmetic validated with KUnit unit tests.

Signed-off-by: Vladyslav Pobigun vladyslav.pobigun@gmail.com

Add helper functions on I2cClient for common SMBus operations:
smbus_read_byte_data, smbus_write_byte_data, smbus_read_word_data,
and smbus_write_word_data.

These helpers provide direct, safe access to standard SMBus register
transactions for I2C device drivers written in Rust.

Signed-off-by: Vladyslav Pobigun <vladyslav.pobigun@gmail.com>
Add safe Rust abstractions for the Hardware Monitoring (HWMON)
subsystem. This allows writing hardware monitoring and temperature
sensor drivers in pure, safe Rust.

Also implement the in-tree LM75 digital temperature sensor driver
utilizing these abstractions, supporting LM75, TMP75, TMP102, and
MCP980x chips with two's complement fixed-point arithmetic and
KUnit tests.

Signed-off-by: Vladyslav Pobigun <vladyslav.pobigun@gmail.com>
Add safe Rust abstractions for the Real-Time Clock (RTC) subsystem,
including RtcTime representation, BCD conversion utilities, and
registration within rtc_class.

Implement the PCF8563/RTC8564 I2C RTC driver in Rust supporting
date and time read/write and low-voltage battery status detection.

Signed-off-by: Vladyslav Pobigun <vladyslav.pobigun@gmail.com>
Add safe Rust abstractions for the LED Class subsystem supporting
brightness control, blocking set callbacks, and hardware blinking.

Implement the NXP PCA9530..PCA9533 LED driver in Rust with PWM
dimming and prescaler-based blinking support.

Signed-off-by: Vladyslav Pobigun <vladyslav.pobigun@gmail.com>
Add safe Rust abstractions for the Watchdog Timer subsystem, supporting
start, stop, ping, and set_timeout operations.

Implement the Zodiac Aerospace RAVE I2C watchdog driver in Rust.

Signed-off-by: Vladyslav Pobigun <vladyslav.pobigun@gmail.com>
Add safe Rust abstractions for the Non-Volatile Memory (NVMEM)
subsystem, supporting read and write operations across memory devices.

Implement the Atmel/Microchip AT24 I2C EEPROM driver in Rust supporting
24C02 through 24C512 chips with 8-bit and 16-bit word addressing.

Signed-off-by: Vladyslav Pobigun <vladyslav.pobigun@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant