diff options
| author | Michal Wilczynski <m.wilczynski@samsung.com> | 2025-10-16 15:38:04 +0200 |
|---|---|---|
| committer | Uwe Kleine-König <ukleinek@kernel.org> | 2025-11-13 10:21:01 +0100 |
| commit | e03724aac758f71c6cda208ea3d1afd0bbb6d9aa (patch) | |
| tree | 846be3c4243017dcdcae7c07ed98e161aa7945be /rust/kernel/task.rs | |
| parent | 51b4c0f9749d96d56887896383141e97916ac91b (diff) | |
pwm: Add Rust driver for T-HEAD TH1520 SoC
Introduce a PWM driver for the T-HEAD TH1520 SoC, written in Rust and
utilizing the safe PWM abstractions from the preceding commit.
The driver implements the pwm::PwmOps trait using the modern waveform
API (round_waveform_tohw, write_waveform, etc.) to support configuration
of period, duty cycle, and polarity for the TH1520's PWM channels.
Resource management is handled using idiomatic Rust patterns. The PWM
chip object is allocated via pwm::Chip::new and its registration with
the PWM core is managed by the pwm::Registration RAII guard. This
ensures pwmchip_remove is always called when the driver unbinds,
preventing resource leaks. Device managed resources are used for the
MMIO region, and the clock lifecycle is correctly managed in the
driver's private data Drop implementation.
The driver's core logic is written entirely in safe Rust, with no unsafe
blocks, except for the Send and Sync implementations for the driver
data, which are explained in the comments.
Reviewed-by: Elle Rhumsaa <elle@weathered-steel.dev>
Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com>
Link: https://patch.msgid.link/20251016-rust-next-pwm-working-fan-for-sending-v16-4-a5df2405d2bd@samsung.com
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
Diffstat (limited to 'rust/kernel/task.rs')
0 files changed, 0 insertions, 0 deletions
