Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions Documentation/devicetree/bindings/pwm/thead,th1520-pwm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/pwm/thead,th1520-pwm.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: T-HEAD TH1520 PWM controller

maintainers:
- Michal Wilczynski <m.wilczynski@samsung.com>

allOf:
- $ref: pwm.yaml#

properties:
compatible:
const: thead,th1520-pwm

reg:
maxItems: 1

clocks:
items:
- description: SoC PWM clock

"#pwm-cells":
const: 3

required:
- compatible
- reg
- clocks

unevaluatedProperties: false

examples:
- |
#include <dt-bindings/clock/thead,th1520-clk-ap.h>
soc {
#address-cells = <2>;
#size-cells = <2>;
pwm@ffec01c000 {
compatible = "thead,th1520-pwm";
reg = <0xff 0xec01c000 0x0 0x4000>;
clocks = <&clk CLK_PWM>;
#pwm-cells = <3>;
};
};
8 changes: 8 additions & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -20070,6 +20070,12 @@ F: include/linux/pwm.h
F: include/linux/pwm_backlight.h
K: pwm_(config|apply_might_sleep|apply_atomic|ops)

PWM SUBSYSTEM BINDINGS [RUST]
M: Michal Wilczynski <m.wilczynski@samsung.com>
S: Maintained
F: rust/helpers/pwm.c
F: rust/kernel/pwm.rs

PXA GPIO DRIVER
M: Robert Jarzmik <robert.jarzmik@free.fr>
L: linux-gpio@vger.kernel.org
Expand Down Expand Up @@ -21385,6 +21391,7 @@ F: Documentation/devicetree/bindings/firmware/thead,th1520-aon.yaml
F: Documentation/devicetree/bindings/mailbox/thead,th1520-mbox.yaml
F: Documentation/devicetree/bindings/net/thead,th1520-gmac.yaml
F: Documentation/devicetree/bindings/pinctrl/thead,th1520-pinctrl.yaml
F: Documentation/devicetree/bindings/pwm/thead,th1520-pwm.yaml
F: Documentation/devicetree/bindings/reset/thead,th1520-reset.yaml
F: arch/riscv/boot/dts/thead/
F: drivers/clk/thead/clk-th1520-ap.c
Expand All @@ -21393,6 +21400,7 @@ F: drivers/mailbox/mailbox-th1520.c
F: drivers/net/ethernet/stmicro/stmmac/dwmac-thead.c
F: drivers/pinctrl/pinctrl-th1520.c
F: drivers/pmdomain/thead/
F: drivers/pwm/pwm_th1520.rs
F: drivers/reset/reset-th1520.c
F: include/dt-bindings/clock/thead,th1520-clk-ap.h
F: include/dt-bindings/power/thead,th1520-power.h
Expand Down
67 changes: 67 additions & 0 deletions arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,76 @@
chosen {
stdout-path = "serial0:115200n8";
};

thermal-zones {
cpu-thermal {
polling-delay = <1000>;
polling-delay-passive = <1000>;
thermal-sensors = <&pvt 0>;

trips {
fan_config0: fan-trip0 {
temperature = <39000>;
hysteresis = <5000>;
type = "active";
};

fan_config1: fan-trip1 {
temperature = <50000>;
hysteresis = <5000>;
type = "active";
};

fan_config2: fan-trip2 {
temperature = <60000>;
hysteresis = <5000>;
type = "active";
};
};

cooling-maps {
map-active-0 {
cooling-device = <&fan 1 1>;
trip = <&fan_config0>;
};

map-active-1 {
cooling-device = <&fan 2 2>;
trip = <&fan_config1>;
};

map-active-2 {
cooling-device = <&fan 3 3>;
trip = <&fan_config2>;
};
};
};
};

fan: pwm-fan {
pinctrl-names = "default";
pinctrl-0 = <&fan_pins>;
compatible = "pwm-fan";
#cooling-cells = <2>;
pwms = <&pwm 1 10000000 0>;
cooling-levels = <0 66 196 255>;
};

};

&padctrl0_apsys {
fan_pins: fan-0 {
pwm1-pins {
pins = "GPIO3_3"; /* PWM1 */
function = "pwm";
bias-disable;
drive-strength = <25>;
input-disable;
input-schmitt-disable;
slew-rate = <0>;
};
};

uart0_pins: uart0-0 {
tx-pins {
pins = "UART0_TXD";
Expand Down
18 changes: 18 additions & 0 deletions arch/riscv/boot/dts/thead/th1520.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,13 @@
status = "disabled";
};

pwm: pwm@ffec01c000 {
compatible = "thead,th1520-pwm";
reg = <0xff 0xec01c000 0x0 0x4000>;
clocks = <&clk CLK_PWM>;
#pwm-cells = <3>;
};

clk: clock-controller@ffef010000 {
compatible = "thead,th1520-clk-ap";
reg = <0xff 0xef010000 0x0 0x1000>;
Expand Down Expand Up @@ -662,6 +669,17 @@
thead,pad-group = <1>;
};

pvt: pvt@fffff4e000 {
compatible = "moortec,mr75203";
reg = <0xff 0xfff4e000 0x0 0x80>,
<0xff 0xfff4e080 0x0 0x100>,
<0xff 0xfff4e180 0x0 0x680>,
<0xff 0xfff4e800 0x0 0x600>;
reg-names = "common", "ts", "pd", "vm";
clocks = <&aonsys_clk>;
#thermal-sensor-cells = <1>;
};

gpio@fffff52000 {
compatible = "snps,dw-apb-gpio";
reg = <0xff 0xfff52000 0x0 0x1000>;
Expand Down
5 changes: 3 additions & 2 deletions drivers/clk/thead/clk-th1520-ap.c
Original file line number Diff line number Diff line change
Expand Up @@ -792,11 +792,12 @@ static CCU_GATE(CLK_AON2CPU_A2X, aon2cpu_a2x_clk, "aon2cpu-a2x", axi4_cpusys2_ac
0x134, BIT(8), 0);
static CCU_GATE(CLK_X2X_CPUSYS, x2x_cpusys_clk, "x2x-cpusys", axi4_cpusys2_aclk_pd,
0x134, BIT(7), 0);
static CCU_GATE(CLK_CPU2AON_X2H, cpu2aon_x2h_clk, "cpu2aon-x2h", axi_aclk_pd, 0x138, BIT(8), 0);
static CCU_GATE(CLK_CPU2AON_X2H, cpu2aon_x2h_clk, "cpu2aon-x2h", axi_aclk_pd,
0x138, BIT(8), CLK_IGNORE_UNUSED);
static CCU_GATE(CLK_CPU2PERI_X2H, cpu2peri_x2h_clk, "cpu2peri-x2h", axi4_cpusys2_aclk_pd,
0x140, BIT(9), CLK_IGNORE_UNUSED);
static CCU_GATE(CLK_PERISYS_APB1_HCLK, perisys_apb1_hclk, "perisys-apb1-hclk", perisys_ahb_hclk_pd,
0x150, BIT(9), 0);
0x150, BIT(9), CLK_IGNORE_UNUSED);
static CCU_GATE(CLK_PERISYS_APB2_HCLK, perisys_apb2_hclk, "perisys-apb2-hclk", perisys_ahb_hclk_pd,
0x150, BIT(10), CLK_IGNORE_UNUSED);
static CCU_GATE(CLK_PERISYS_APB3_HCLK, perisys_apb3_hclk, "perisys-apb3-hclk", perisys_ahb_hclk_pd,
Expand Down
23 changes: 23 additions & 0 deletions drivers/pwm/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,16 @@ config PWM_TEGRA
To compile this driver as a module, choose M here: the module
will be called pwm-tegra.

config PWM_TH1520
tristate "TH1520 PWM support"
depends on RUST_PWM_ABSTRACTIONS
help
This option enables the driver for the PWM controller found on the
T-HEAD TH1520 SoC.

To compile this driver as a module, choose M here; the module
will be called pwm-th1520. If you are unsure, say N.

config PWM_TIECAP
tristate "ECAP PWM support"
depends on ARCH_OMAP2PLUS || ARCH_DAVINCI_DA8XX || ARCH_KEYSTONE || ARCH_K3 || COMPILE_TEST
Expand Down Expand Up @@ -790,4 +800,17 @@ config PWM_XILINX
To compile this driver as a module, choose M here: the module
will be called pwm-xilinx.

config RUST_PWM_ABSTRACTIONS
bool "Rust PWM abstractions support"
depends on RUST
depends on PWM=y
help
This option enables the safe Rust abstraction layer for the PWM
subsystem. It provides idiomatic wrappers and traits necessary for
writing PWM controller drivers in Rust.

The abstractions handle resource management (like memory and reference
counting) and provide safe interfaces to the underlying C core,
allowing driver logic to be written in safe Rust.

endif
1 change: 1 addition & 0 deletions drivers/pwm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ obj-$(CONFIG_PWM_STMPE) += pwm-stmpe.o
obj-$(CONFIG_PWM_SUN4I) += pwm-sun4i.o
obj-$(CONFIG_PWM_SUNPLUS) += pwm-sunplus.o
obj-$(CONFIG_PWM_TEGRA) += pwm-tegra.o
obj-$(CONFIG_PWM_TH1520) += pwm_th1520.o
obj-$(CONFIG_PWM_TIECAP) += pwm-tiecap.o
obj-$(CONFIG_PWM_TIEHRPWM) += pwm-tiehrpwm.o
obj-$(CONFIG_PWM_TWL) += pwm-twl.o
Expand Down
Loading
Loading