Skip to content

Commit 77956cf

Browse files
committed
Merge tag 'pwm/for-6.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/ukleinek/linux
Pull pwm updates from Uwe Kleine-König: "In addition to the usual mix of core cleanups, driver changes, minor fixes and device tree updates the highlight this cycle is Rust support for the core and a first Rust driver both provided by Michal Wilczynski. Michal wrote about these changes on https://mwilczynski.dev/posts/bringing-rust-to-the-pwm-subsystem/ which is a nice read" * tag 'pwm/for-6.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/ukleinek/linux: (22 commits) pwm: rzg2l-gpt: Allow checking period_tick cache value only if sibling channel is enabled pwm: bcm2835: Make sure the channel is enabled after pwm_request() pwm: mediatek: Make use of struct_size macro pwm: mediatek: Remove unneeded semicolon pwm: airoha: Add support for EN7581 SoC pwm: mediatek: Convert to waveform API pwm: max7360: Clean MAX7360 code pwm: Drop unused function pwm_apply_args() pwm: Use %u to printf unsigned int pwm_chip::npwm and pwm_chip::id pwm: Simplify printf to emit chip->npwm in $debugfs/pwm pwm: th1520: Use module_pwm_platform_driver! macro pwm: th1520: Fix clippy warning for redundant struct field init pwm: Fix Rust formatting dt-bindings: pwm: thead: Add T-HEAD TH1520 PWM controller pwm: Add Rust driver for T-HEAD TH1520 SoC rust: pwm: Fix broken intra-doc link rust: pwm: Drop wrapping of PWM polarity and state rust: pwm: Add module_pwm_platform_driver! macro rust: pwm: Add complete abstraction layer rust: pwm: Add Kconfig and basic data structures ...
2 parents 0426584 + fae00ea commit 77956cf

18 files changed

Lines changed: 2071 additions & 175 deletions

File tree

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/pwm/thead,th1520-pwm.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: T-HEAD TH1520 PWM controller
8+
9+
maintainers:
10+
- Michal Wilczynski <m.wilczynski@samsung.com>
11+
12+
allOf:
13+
- $ref: pwm.yaml#
14+
15+
properties:
16+
compatible:
17+
const: thead,th1520-pwm
18+
19+
reg:
20+
maxItems: 1
21+
22+
clocks:
23+
items:
24+
- description: SoC PWM clock
25+
26+
"#pwm-cells":
27+
const: 3
28+
29+
required:
30+
- compatible
31+
- reg
32+
- clocks
33+
34+
unevaluatedProperties: false
35+
36+
examples:
37+
- |
38+
#include <dt-bindings/clock/thead,th1520-clk-ap.h>
39+
soc {
40+
#address-cells = <2>;
41+
#size-cells = <2>;
42+
pwm@ffec01c000 {
43+
compatible = "thead,th1520-pwm";
44+
reg = <0xff 0xec01c000 0x0 0x4000>;
45+
clocks = <&clk CLK_PWM>;
46+
#pwm-cells = <3>;
47+
};
48+
};

MAINTAINERS

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20871,6 +20871,14 @@ F: include/linux/pwm.h
2087120871
F: include/linux/pwm_backlight.h
2087220872
K: pwm_(config|apply_might_sleep|apply_atomic|ops)
2087320873

20874+
PWM SUBSYSTEM BINDINGS [RUST]
20875+
M: Michal Wilczynski <m.wilczynski@samsung.com>
20876+
L: linux-pwm@vger.kernel.org
20877+
L: rust-for-linux@vger.kernel.org
20878+
S: Maintained
20879+
F: rust/helpers/pwm.c
20880+
F: rust/kernel/pwm.rs
20881+
2087420882
PXA GPIO DRIVER
2087520883
M: Robert Jarzmik <robert.jarzmik@free.fr>
2087620884
L: linux-gpio@vger.kernel.org
@@ -22293,6 +22301,7 @@ F: Documentation/devicetree/bindings/firmware/thead,th1520-aon.yaml
2229322301
F: Documentation/devicetree/bindings/mailbox/thead,th1520-mbox.yaml
2229422302
F: Documentation/devicetree/bindings/net/thead,th1520-gmac.yaml
2229522303
F: Documentation/devicetree/bindings/pinctrl/thead,th1520-pinctrl.yaml
22304+
F: Documentation/devicetree/bindings/pwm/thead,th1520-pwm.yaml
2229622305
F: Documentation/devicetree/bindings/reset/thead,th1520-reset.yaml
2229722306
F: arch/riscv/boot/dts/thead/
2229822307
F: drivers/clk/thead/clk-th1520-ap.c
@@ -22303,6 +22312,7 @@ F: drivers/pinctrl/pinctrl-th1520.c
2230322312
F: drivers/pmdomain/thead/
2230422313
F: drivers/power/reset/th1520-aon-reboot.c
2230522314
F: drivers/power/sequencing/pwrseq-thead-gpu.c
22315+
F: drivers/pwm/pwm_th1520.rs
2230622316
F: drivers/reset/reset-th1520.c
2230722317
F: include/dt-bindings/clock/thead,th1520-clk-ap.h
2230822318
F: include/dt-bindings/power/thead,th1520-power.h

drivers/pwm/Kconfig

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,16 @@ config PWM_ADP5585
6363
This option enables support for the PWM function found in the Analog
6464
Devices ADP5585.
6565

66+
config PWM_AIROHA
67+
tristate "Airoha PWM support"
68+
depends on ARCH_AIROHA || COMPILE_TEST
69+
select REGMAP_MMIO
70+
help
71+
Generic PWM framework driver for Airoha SoC.
72+
73+
To compile this driver as a module, choose M here: the module
74+
will be called pwm-airoha.
75+
6676
config PWM_APPLE
6777
tristate "Apple SoC PWM support"
6878
depends on ARCH_APPLE || COMPILE_TEST
@@ -748,6 +758,17 @@ config PWM_TEGRA
748758
To compile this driver as a module, choose M here: the module
749759
will be called pwm-tegra.
750760

761+
config PWM_TH1520
762+
tristate "TH1520 PWM support"
763+
depends on RUST
764+
select RUST_PWM_ABSTRACTIONS
765+
help
766+
This option enables the driver for the PWM controller found on the
767+
T-HEAD TH1520 SoC.
768+
769+
To compile this driver as a module, choose M here; the module
770+
will be called pwm-th1520. If you are unsure, say N.
771+
751772
config PWM_TIECAP
752773
tristate "ECAP PWM support"
753774
depends on ARCH_OMAP2PLUS || ARCH_DAVINCI_DA8XX || ARCH_KEYSTONE || ARCH_K3 || COMPILE_TEST
@@ -819,4 +840,16 @@ config PWM_XILINX
819840
To compile this driver as a module, choose M here: the module
820841
will be called pwm-xilinx.
821842

843+
config RUST_PWM_ABSTRACTIONS
844+
bool
845+
depends on RUST
846+
help
847+
This option enables the safe Rust abstraction layer for the PWM
848+
subsystem. It provides idiomatic wrappers and traits necessary for
849+
writing PWM controller drivers in Rust.
850+
851+
The abstractions handle resource management (like memory and reference
852+
counting) and provide safe interfaces to the underlying C core,
853+
allowing driver logic to be written in safe Rust.
854+
822855
endif

drivers/pwm/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
obj-$(CONFIG_PWM) += core.o
33
obj-$(CONFIG_PWM_AB8500) += pwm-ab8500.o
44
obj-$(CONFIG_PWM_ADP5585) += pwm-adp5585.o
5+
obj-$(CONFIG_PWM_AIROHA) += pwm-airoha.o
56
obj-$(CONFIG_PWM_APPLE) += pwm-apple.o
67
obj-$(CONFIG_PWM_ARGON_FAN_HAT) += pwm-argon-fan-hat.o
78
obj-$(CONFIG_PWM_ATMEL) += pwm-atmel.o
@@ -68,6 +69,7 @@ obj-$(CONFIG_PWM_STMPE) += pwm-stmpe.o
6869
obj-$(CONFIG_PWM_SUN4I) += pwm-sun4i.o
6970
obj-$(CONFIG_PWM_SUNPLUS) += pwm-sunplus.o
7071
obj-$(CONFIG_PWM_TEGRA) += pwm-tegra.o
72+
obj-$(CONFIG_PWM_TH1520) += pwm_th1520.o
7173
obj-$(CONFIG_PWM_TIECAP) += pwm-tiecap.o
7274
obj-$(CONFIG_PWM_TIEHRPWM) += pwm-tiehrpwm.o
7375
obj-$(CONFIG_PWM_TWL) += pwm-twl.o

drivers/pwm/core.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1608,12 +1608,13 @@ void pwmchip_put(struct pwm_chip *chip)
16081608
}
16091609
EXPORT_SYMBOL_GPL(pwmchip_put);
16101610

1611-
static void pwmchip_release(struct device *pwmchip_dev)
1611+
void pwmchip_release(struct device *pwmchip_dev)
16121612
{
16131613
struct pwm_chip *chip = pwmchip_from_dev(pwmchip_dev);
16141614

16151615
kfree(chip);
16161616
}
1617+
EXPORT_SYMBOL_GPL(pwmchip_release);
16171618

16181619
struct pwm_chip *pwmchip_alloc(struct device *parent, unsigned int npwm, size_t sizeof_priv)
16191620
{
@@ -2696,11 +2697,10 @@ static int pwm_seq_show(struct seq_file *s, void *v)
26962697
{
26972698
struct pwm_chip *chip = v;
26982699

2699-
seq_printf(s, "%s%d: %s/%s, %d PWM device%s\n",
2700+
seq_printf(s, "%s%u: %s/%s, npwm: %u\n",
27002701
(char *)s->private, chip->id,
27012702
pwmchip_parent(chip)->bus ? pwmchip_parent(chip)->bus->name : "no-bus",
2702-
dev_name(pwmchip_parent(chip)), chip->npwm,
2703-
(chip->npwm != 1) ? "s" : "");
2703+
dev_name(pwmchip_parent(chip)), chip->npwm);
27042704

27052705
pwm_dbg_show(chip, s);
27062706

0 commit comments

Comments
 (0)