public inbox for devicetree@vger.kernel.org
 help / color / mirror / Atom feed
From: Drew Fustini <pdp7pdp7@gmail.com>
To: Michal Wilczynski <m.wilczynski@samsung.com>
Cc: "Uwe Kleine-König" <ukleinek@kernel.org>,
	"Miguel Ojeda" <ojeda@kernel.org>,
	"Alex Gaynor" <alex.gaynor@gmail.com>,
	"Boqun Feng" <boqun.feng@gmail.com>,
	"Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <benno.lossin@proton.me>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"Alice Ryhl" <aliceryhl@google.com>,
	"Trevor Gross" <tmgross@umich.edu>,
	"Danilo Krummrich" <dakr@kernel.org>,
	"Drew Fustini" <drew@pdp7.com>, "Guo Ren" <guoren@kernel.org>,
	"Fu Wei" <wefu@redhat.com>, "Rob Herring" <robh@kernel.org>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	"Conor Dooley" <conor+dt@kernel.org>,
	"Paul Walmsley" <paul.walmsley@sifive.com>,
	"Palmer Dabbelt" <palmer@dabbelt.com>,
	"Albert Ou" <aou@eecs.berkeley.edu>,
	"Alexandre Ghiti" <alex@ghiti.fr>,
	"Marek Szyprowski" <m.szyprowski@samsung.com>,
	linux-kernel@vger.kernel.org, linux-pwm@vger.kernel.org,
	rust-for-linux@vger.kernel.org, linux-riscv@lists.infradead.org,
	devicetree@vger.kernel.org
Subject: Re: [PATCH RFC 0/6] Rust Abstractions for PWM subsystem with TH1520 PWM driver
Date: Sat, 24 May 2025 15:21:52 -0700	[thread overview]
Message-ID: <aDJGgLZ9tITwGBxq@x1> (raw)
In-Reply-To: <20250524-rust-next-pwm-working-fan-for-sending-v1-0-bdd2d5094ff7@samsung.com>

On Sat, May 24, 2025 at 11:14:54PM +0200, Michal Wilczynski wrote:
> This patch series introduces Rust support for the T-HEAD TH1520 PWM
> controller and demonstrates its use for fan control on the Sipeed Lichee
> Pi 4A board.
> 
> The primary goal of this patch series is to introduce a basic set of
> Rust abstractions for the Linux PWM subsystem. As a first user and
> practical demonstration of these abstractions, the series also provides
> a functional PWM driver for the T-HEAD TH1520 SoC. This allows control
> of its PWM channels and ultimately enables temperature controlled fan
> support for the Lichee Pi 4A board. This work aims to explore the use of
> Rust for PWM drivers and lay a foundation for potential future
> Rust based PWM drivers.
> 
> The series is structured as follows:
> 
> Patch 1/6: Introduce basic PWM abstractions
> This patch lays the groundwork by adding a Kconfig option for Rust PWM
> abstractions, necessary C helper functions, and a new Rust module
> (rust/kernel/pwm.rs). This module provides initial safe wrappers for
> core PWM data structures (Chip, Device, State, Args, Polarity) and
> functions (devm_chip_alloc, devm_chip_add), along with a basic PwmOps
> trait focusing on the .apply callback needed by PWM chip providers.
> 
> Patch 2/6: Add PWM driver for TH1520 SoC
> This introduces the Rust based PWM driver for the T-HEAD TH1520 SoC.
> It implements the PwmOps trait using the abstractions from the first
> patch and handles the specifics of the TH1520 hardware for configuring
> period, duty cycle, and polarity. Resource management leverages devm
> for the PWM chip and Rust DevRes for I/O memory, and RAII for clock
> handling.
> 
> Patch 3/6: dt-bindings: Add PWM T-HEAD controller dt-binding
> This patch adds the Device Tree binding documentation for the T-HEAD
> TH1520 PWM controller.
> 
> Patch 4/6: riscv: dts: thead:: Add PWM controller node
> This patch adds the actual Device Tree node for the TH1520 PWM controller.
> 
> Patch 5/6: riscv: dts: thead: Add PVT node
> Add pvt node for thermal sensor.
> 
> Patch 6/6: riscv: dts: thead: Add PWM fan and thermal control
> This final patch adds the Device Tree configuration for a PWM controlled
> fan to the Sipeed Lichee Pi 4A board DTS file. 
> 
> Testing:
> Tested on the TH1520 SoC. The fan works correctly.
> 
> Points for Discussion:
> The rust/kernel/pwm.rs abstraction layer is currently minimal,
> focusing on the immediate needs of this driver. Feedback on its design,
> scope, and potential for generalization would be highly appreciated.
> General feedback on the Rust implementation, FFI wrapping patterns, and
> adherence to kernel development practices is very welcome.
> 
> The patches are based on rust-next, with some dependencies which are not
> merged yet - platform Io support [1] and clk abstractions [2]. 
> 
> Reference repository with all the patches together can be found on
> github [3].
> 
> [1] - https://lore.kernel.org/rust-for-linux/20250509-topics-tyr-platform_iomem-v8-0-e9f1725a40da@collabora.com/
> [2] - https://lore.kernel.org/rust-for-linux/0ec0250c1170a8a6efb2db7a6cb49ae974d7ce05.1747634382.git.viresh.kumar@linaro.org/ 
> [3] - https://github.com/mwilczy/linux/commits/rust-next-pwm-working-fan-for-sending/

Thanks for the patch series. It will be great to have PWM working
upstream.

I've not built Linux with Rust before, so I'm going through the quick
start [1]. I've also never built Linux with LLVM before but clang seems
like the best compiler to use for Rust. Are you using LLVM?

Drew

[1] https://docs.kernel.org/rust/quick-start.html

  parent reply	other threads:[~2025-05-24 22:21 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20250524211519eucas1p218997c69b98b14d3af2eb6bf4e9d3187@eucas1p2.samsung.com>
2025-05-24 21:14 ` [PATCH RFC 0/6] Rust Abstractions for PWM subsystem with TH1520 PWM driver Michal Wilczynski
2025-05-24 21:14   ` [PATCH RFC 1/6] rust: Add basic PWM abstractions Michal Wilczynski
2025-05-25 11:49     ` Danilo Krummrich
2025-05-27 11:32       ` Michal Wilczynski/Kernel (PLT) /SRPOL/Engineer/Samsung Electronics
2025-05-26  7:53     ` Uwe Kleine-König
2025-05-26 14:02       ` Michal Wilczynski
2025-05-24 21:14   ` [PATCH RFC 2/6] pwm: Add Rust driver for T-HEAD TH1520 SoC Michal Wilczynski
2025-05-25 12:03     ` Danilo Krummrich
2025-05-27 12:44       ` Michal Wilczynski/Kernel (PLT) /SRPOL/Engineer/Samsung Electronics
2025-05-27 13:00         ` Danilo Krummrich
2025-05-27 13:57         ` Uwe Kleine-König
2025-06-05 10:39     ` Uwe Kleine-König
2025-06-06 14:08       ` Michal Wilczynski
2025-06-06 15:21         ` Miguel Ojeda
2025-06-06 16:41           ` Michal Wilczynski
2025-06-06 20:09         ` Benno Lossin
2025-05-24 21:14   ` [PATCH RFC 3/6] dt-bindings: pwm: thead: Add T-HEAD TH1520 PWM controller Michal Wilczynski
2025-05-24 21:14   ` [PATCH RFC 4/6] riscv: dts: thead: Add PWM controller node Michal Wilczynski
2025-05-24 21:14   ` [PATCH RFC 5/6] riscv: dts: thead: Add PVT node Michal Wilczynski
2025-05-27  8:00     ` Drew Fustini
2025-05-27  8:54       ` Michal Wilczynski/Kernel (PLT) /SRPOL/Engineer/Samsung Electronics
2025-06-01  7:50       ` Michal Wilczynski
2025-06-01 17:32         ` Drew Fustini
2025-06-09 18:49           ` Michal Wilczynski
2025-06-09 22:09             ` Drew Fustini
2025-05-24 21:15   ` [PATCH RFC 6/6] riscv: dts: thead: Add PWM fan and thermal control Michal Wilczynski
2025-05-24 22:21   ` Drew Fustini [this message]
2025-05-26  8:22     ` [PATCH RFC 0/6] Rust Abstractions for PWM subsystem with TH1520 PWM driver Michal Wilczynski
2025-05-26  9:01       ` Benno Lossin
2025-06-08 16:58         ` Drew Fustini
2025-06-08 17:14           ` Miguel Ojeda
2025-06-08 19:58             ` Drew Fustini
2025-06-08 20:47               ` Miguel Ojeda

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=aDJGgLZ9tITwGBxq@x1 \
    --to=pdp7pdp7@gmail.com \
    --cc=a.hindborg@kernel.org \
    --cc=alex.gaynor@gmail.com \
    --cc=alex@ghiti.fr \
    --cc=aliceryhl@google.com \
    --cc=aou@eecs.berkeley.edu \
    --cc=benno.lossin@proton.me \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=conor+dt@kernel.org \
    --cc=dakr@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=drew@pdp7.com \
    --cc=gary@garyguo.net \
    --cc=guoren@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=m.szyprowski@samsung.com \
    --cc=m.wilczynski@samsung.com \
    --cc=ojeda@kernel.org \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    --cc=robh@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tmgross@umich.edu \
    --cc=ukleinek@kernel.org \
    --cc=wefu@redhat.com \
    /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