[PW_SID:993398] [v14,1/7] pwm: Export pwmchip_release for external use - #808
[PW_SID:993398] [v14,1/7] pwm: Export pwmchip_release for external use#808linux-riscv-bot wants to merge 7 commits into
pwmchip_release for external use#808Conversation
The upcoming Rust abstraction layer for the PWM subsystem uses a custom `dev->release` handler to safely manage the lifetime of its driver data. To prevent leaking the memory of the `struct pwm_chip` (allocated by `pwmchip_alloc`), this custom handler must also call the original `pwmchip_release` function to complete the cleanup. Make `pwmchip_release` a global, exported function so that it can be called from the Rust FFI bridge. This involves removing the `static` keyword, adding a prototype to the public header, and exporting the symbol. Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Introduce the foundational support for PWM abstractions in Rust. This commit adds the `RUST_PWM_ABSTRACTIONS` Kconfig option to enable the feature, along with the necessary build-system support and C helpers. It also introduces the first set of safe wrappers for the PWM subsystem, covering the basic data carrying C structs and enums: - `Polarity`: A safe wrapper for `enum pwm_polarity`. - `Waveform`: A wrapper for `struct pwm_waveform`. - `Args`: A wrapper for `struct pwm_args`. - `State`: A wrapper for `struct pwm_state`. These types provide memory safe, idiomatic Rust representations of the core PWM data structures and form the building blocks for the abstractions that will follow. Tested-by: Drew Fustini <fustini@kernel.org> Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com> Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Introduce a comprehensive abstraction layer for the PWM subsystem to enable writing drivers in Rust. Because `Device`, `Chip`, and `PwmOps` all refer to each other, they form a single, indivisible unit with circular dependencies. They are introduced together in this single commit to create a complete, compilable abstraction layer. The main components are: - Data Wrappers: Safe, idiomatic wrappers for core C types like `pwm_device`, and `pwm_chip`. - PwmOps Trait: An interface that drivers can implement to provide their hardware-specific logic, mirroring the C `pwm_ops` interface. - FFI VTable and Adapter: A bridge to connect the high-level PwmOps trait to the C kernel's pwm_ops vtable. - Allocation and Lifetime Management: A high-level `Chip::new()` API to safely allocate a chip and a `Registration` guard that integrates with `devres` to manage the chip's registration with the PWM core. An `AlwaysRefCounted` implementation and a custom release handler prevent memory leaks by managing the chip's lifetime and freeing driver data correctly. Reviewed-by: Danilo Krummrich <dakr@kernel.org> Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
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. Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Add the Device Tree binding documentation for the T-HEAD TH1520 SoC PWM controller. Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Tested-by: Drew Fustini <fustini@kernel.org> Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Add the Device Tree node for the T-HEAD TH1520 SoC's PWM controller. Reviewed-by: Drew Fustini <fustini@kernel.org> Tested-by: Drew Fustini <fustini@kernel.org> Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Add Device Tree nodes to enable a PWM controlled fan and it's associated thermal management for the Lichee Pi 4A board. This enables temperature-controlled active cooling for the Lichee Pi 4A board based on SoC temperature. Reviewed-by: Drew Fustini <fustini@kernel.org> Tested-by: Drew Fustini <fustini@kernel.org> Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
|
Patch 1: "[v14,1/7] pwm: Export |
|
Patch 1: "[v14,1/7] pwm: Export |
|
Patch 1: "[v14,1/7] pwm: Export |
|
Patch 1: "[v14,1/7] pwm: Export |
|
Patch 1: "[v14,1/7] pwm: Export |
|
Patch 1: "[v14,1/7] pwm: Export |
|
Patch 1: "[v14,1/7] pwm: Export |
|
Patch 1: "[v14,1/7] pwm: Export |
|
Patch 1: "[v14,1/7] pwm: Export |
|
Patch 1: "[v14,1/7] pwm: Export |
|
Patch 1: "[v14,1/7] pwm: Export |
|
Patch 1: "[v14,1/7] pwm: Export |
|
Patch 2: "[v14,2/7] rust: pwm: Add Kconfig and basic data structures" |
|
Patch 2: "[v14,2/7] rust: pwm: Add Kconfig and basic data structures" |
|
Patch 2: "[v14,2/7] rust: pwm: Add Kconfig and basic data structures" |
|
Patch 2: "[v14,2/7] rust: pwm: Add Kconfig and basic data structures" |
|
Patch 2: "[v14,2/7] rust: pwm: Add Kconfig and basic data structures" |
|
Patch 2: "[v14,2/7] rust: pwm: Add Kconfig and basic data structures" |
|
Patch 2: "[v14,2/7] rust: pwm: Add Kconfig and basic data structures" |
|
Patch 2: "[v14,2/7] rust: pwm: Add Kconfig and basic data structures" |
|
Patch 2: "[v14,2/7] rust: pwm: Add Kconfig and basic data structures" |
|
Patch 2: "[v14,2/7] rust: pwm: Add Kconfig and basic data structures" |
|
Patch 2: "[v14,2/7] rust: pwm: Add Kconfig and basic data structures" |
|
Patch 5: "[v14,5/7] dt-bindings: pwm: thead: Add T-HEAD TH1520 PWM controller" |
|
Patch 5: "[v14,5/7] dt-bindings: pwm: thead: Add T-HEAD TH1520 PWM controller" |
|
Patch 5: "[v14,5/7] dt-bindings: pwm: thead: Add T-HEAD TH1520 PWM controller" |
|
Patch 5: "[v14,5/7] dt-bindings: pwm: thead: Add T-HEAD TH1520 PWM controller" |
|
Patch 6: "[v14,6/7] riscv: dts: thead: Add PWM controller node" |
|
Patch 6: "[v14,6/7] riscv: dts: thead: Add PWM controller node" |
|
Patch 6: "[v14,6/7] riscv: dts: thead: Add PWM controller node" |
|
Patch 6: "[v14,6/7] riscv: dts: thead: Add PWM controller node" |
|
Patch 6: "[v14,6/7] riscv: dts: thead: Add PWM controller node" |
|
Patch 6: "[v14,6/7] riscv: dts: thead: Add PWM controller node" |
|
Patch 6: "[v14,6/7] riscv: dts: thead: Add PWM controller node" |
|
Patch 6: "[v14,6/7] riscv: dts: thead: Add PWM controller node" |
|
Patch 6: "[v14,6/7] riscv: dts: thead: Add PWM controller node" |
|
Patch 6: "[v14,6/7] riscv: dts: thead: Add PWM controller node" |
|
Patch 6: "[v14,6/7] riscv: dts: thead: Add PWM controller node" |
|
Patch 6: "[v14,6/7] riscv: dts: thead: Add PWM controller node" |
|
Patch 7: "[v14,7/7] riscv: dts: thead: Add PWM fan and thermal control" |
|
Patch 7: "[v14,7/7] riscv: dts: thead: Add PWM fan and thermal control" |
|
Patch 7: "[v14,7/7] riscv: dts: thead: Add PWM fan and thermal control" |
|
Patch 7: "[v14,7/7] riscv: dts: thead: Add PWM fan and thermal control" |
|
Patch 7: "[v14,7/7] riscv: dts: thead: Add PWM fan and thermal control" |
|
Patch 7: "[v14,7/7] riscv: dts: thead: Add PWM fan and thermal control" |
|
Patch 7: "[v14,7/7] riscv: dts: thead: Add PWM fan and thermal control" |
|
Patch 7: "[v14,7/7] riscv: dts: thead: Add PWM fan and thermal control" |
|
Patch 7: "[v14,7/7] riscv: dts: thead: Add PWM fan and thermal control" |
|
Patch 7: "[v14,7/7] riscv: dts: thead: Add PWM fan and thermal control" |
|
Patch 7: "[v14,7/7] riscv: dts: thead: Add PWM fan and thermal control" |
|
Patch 7: "[v14,7/7] riscv: dts: thead: Add PWM fan and thermal control" |
PR for series 993398 applied to workflow__riscv__fixes
Name: [v14,1/7] pwm: Export
pwmchip_releasefor external useURL: https://patchwork.kernel.org/project/linux-riscv/list/?series=993398
Version: 14