Skip to contentSkip to conversation

mediatek: pwm: add pwm driver for MediaTek SoCs

PATCH In review Sam Shih 3 participants 8 messages Feb 21, 2020 – Apr 21, 2020

Subsystems (4)
lore
Share & tools
lore

Sam Shih

author
#0 lore raw

cover mediatek: pwm: add pwm driver for MediaTek SoCs

Add pwm support for MediaTek SoCs: mt7622, mt7623 and mt7629, also fix mt7622 and mt7623 boot problem caused by BINMAN_FDT

Sam Shih (3):
mediatek: pwm: add pwm driver for MediaTek SoCs
arm: dts: add pwm support for MediaTek SoCs
arm: mediatek: remove unuse binman config

 arch/arm/Kconfig               |   1 -
 arch/arm/dts/mt7622.dtsi       |  19 ++++
 arch/arm/dts/mt7623.dtsi       |  17 +++
 arch/arm/dts/mt7629.dtsi       |  16 +++
 arch/arm/mach-mediatek/Kconfig |   1 +
 drivers/pwm/Kconfig            |   7 ++
 drivers/pwm/Makefile           |   1 +
 drivers/pwm/pwm-mtk.c          | 188 +++++++++++++++++++++++++++++++++
 8 files changed, 249 insertions(+), 1 deletion(-)
 create mode 100644 drivers/pwm/pwm-mtk.c
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH 1/3 mediatek: pwm: add pwm driver for MediaTek SoCs

This driver support the standard PWM API for
MediaTek MT7623, MT7622 and MT7629 SoCs

---
 drivers/pwm/Kconfig   |   7 ++
 drivers/pwm/Makefile  |   1 +
 drivers/pwm/pwm-mtk.c | 188 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 196 insertions(+)
 create mode 100644 drivers/pwm/pwm-mtk.c
drivers/pwm/Kconfig +7 -0
index 1f36fc78fa..edb3f0f538 100644
@@ -23,6 +23,13 @@ config PWM_IMX
 	help
 	  This PWM is found i.MX27 and later i.MX SoCs.
 
+config PWM_MTK
+	bool "Enable support for MediaTek PWM"
+	depends on DM_PWM
+	help
+	  This PWM is found on MT7622, MT7623, and MT7629. It supports a
+	  programmable period and duty cycle.
+
 config PWM_ROCKCHIP
 	bool "Enable support for the Rockchip PWM"
 	depends on DM_PWM
drivers/pwm/Makefile +1 -0
index a837c35ed2..2c3a069006 100644
@@ -12,6 +12,7 @@ obj-$(CONFIG_DM_PWM)		+= pwm-uclass.o
 
 obj-$(CONFIG_PWM_EXYNOS)	+= exynos_pwm.o
 obj-$(CONFIG_PWM_IMX)		+= pwm-imx.o pwm-imx-util.o
+obj-$(CONFIG_PWM_MTK)		+= pwm-mtk.o
 obj-$(CONFIG_PWM_ROCKCHIP)	+= rk_pwm.o
 obj-$(CONFIG_PWM_SANDBOX)	+= sandbox_pwm.o
 obj-$(CONFIG_PWM_TEGRA)		+= tegra_pwm.o
drivers/pwm/pwm-mtk.c new file +188 -0

188 lines not on this page · raw message

Signature · 1 line
2.17.1
#2 lore raw

PATCH 1/3 mediatek: pwm: add pwm driver for MediaTek SoCs

Quoted 4 lines · Sam Shih

This driver support the standard PWM API for
MediaTek MT7623, MT7622 and MT7629 SoCs

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200421/831eb41c/attachment.sig>
author
#3 lore raw

PATCH 2/3 arm: dts: add pwm support for MediaTek SoCs

In reply to Sam Shih

This patch add pwm support for mt7622, mt7623 and mt7629 SoCs

---
 arch/arm/dts/mt7622.dtsi | 19 +++++++++++++++++++
 arch/arm/dts/mt7623.dtsi | 17 +++++++++++++++++
 arch/arm/dts/mt7629.dtsi | 16 ++++++++++++++++
 3 files changed, 52 insertions(+)
arch/arm/dts/mt7622.dtsi +19 -0
index 1e8ec9b48b..f9ce0c6c3e 100644
@@ -227,4 +227,23 @@
 		#clock-cells = <1>;
 	};
 
+	pwm: pwm at 11006000 {
+		compatible = "mediatek,mt7622-pwm";
+		reg = <0x11006000 0x1000>;
+		#clock-cells = <1>;
+		#pwm-cells = <2>;
+		interrupts = <GIC_SPI 77 IRQ_TYPE_LEVEL_LOW>;
+		clocks = <&topckgen CLK_TOP_PWM_SEL>,
+			 <&pericfg CLK_PERI_PWM_PD>,
+			 <&pericfg CLK_PERI_PWM1_PD>,
+			 <&pericfg CLK_PERI_PWM2_PD>,
+			 <&pericfg CLK_PERI_PWM3_PD>,
+			 <&pericfg CLK_PERI_PWM4_PD>,
+			 <&pericfg CLK_PERI_PWM5_PD>,
+			 <&pericfg CLK_PERI_PWM6_PD>;
+		clock-names = "top", "main", "pwm1", "pwm2", "pwm3", "pwm4",
+			      "pwm5", "pwm6";
+		status = "disabled";
+	};
+
 };
arch/arm/dts/mt7623.dtsi +17 -0
index 1f45dea575..0452889ef8 100644
@@ -400,4 +400,21 @@
 		mediatek,ethsys = <&ethsys>;
 		status = "disabled";
 	};
+
+	pwm: pwm at 11006000 {
+		compatible = "mediatek,mt7623-pwm";
+		reg = <0x11006000 0x1000>;
+		#clock-cells = <1>;
+		#pwm-cells = <2>;
+		clocks = <&topckgen CLK_TOP_PWM_SEL>,
+			 <&pericfg CLK_PERI_PWM>,
+			 <&pericfg CLK_PERI_PWM1>,
+			 <&pericfg CLK_PERI_PWM2>,
+			 <&pericfg CLK_PERI_PWM3>,
+			 <&pericfg CLK_PERI_PWM4>,
+			 <&pericfg CLK_PERI_PWM5>;
+		clock-names = "top", "main", "pwm1", "pwm2", "pwm3", "pwm4",
+			      "pwm5";
+		status = "disabled";
+	};
 };
arch/arm/dts/mt7629.dtsi +16 -0
index a33a74a556..644d2da4a8 100644
@@ -281,4 +281,20 @@
 		reg = <0x1b130000 0x1000>;
 		#clock-cells = <1>;
 	};
+
+	pwm: pwm at 11006000 {
+		compatible = "mediatek,mt7629-pwm";
+		reg = <0x11006000 0x1000>;
+		#clock-cells = <1>;
+		#pwm-cells = <2>;
+		interrupts = <GIC_SPI 77 IRQ_TYPE_LEVEL_LOW>;
+		clocks = <&topckgen CLK_TOP_PWM_SEL>,
+			 <&pericfg CLK_PERI_PWM_PD>,
+			 <&pericfg CLK_PERI_PWM1_PD>;
+		clock-names = "top", "main", "pwm1";
+		assigned-clocks = <&topckgen CLK_TOP_PWM_SEL>;
+		assigned-clock-parents = <&topckgen CLK_TOP_UNIVPLL2_D4>;
+		status = "disabled";
+	};
+
 };
Signature · 1 line
2.17.1
#4 lore raw

PATCH 2/3 arm: dts: add pwm support for MediaTek SoCs

Quoted 3 lines · Sam Shih

This patch add pwm support for mt7622, mt7623 and mt7629 SoCs

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200421/dbae7e40/attachment.sig>
author
#5 lore raw

PATCH 3/3 arm: mediatek: remove unuse binman config

In reply to Sam Shih

The binman-option BINMAN_FDT is introduced by this commit:
commit 3c10dc95bdd0 ("binman: Add a library to access binman entries") BINMAN_FDT being selected when BINMAN=y that resulting in mt7623 and mt7622 are unable to boot. The root cause of this issue is commit:
commit cbd2fba1eca1 ("arm: MediaTek: add basic support for MT7629 boards") select BINMAN=y in all mediatek SoCs, and others mediatek SoCs not expect to use BINMAN_FDT.
This patch remove BINMAN=y option when ARCH_MEDIATEK=y and move this to the specify SoCs part config.

---
 arch/arm/Kconfig               | 1 -
 arch/arm/mach-mediatek/Kconfig | 1 +
 2 files changed, 1 insertion(+), 1 deletion(-)
arch/arm/Kconfig +0 -1
index 8d9f7fcce7..9ca3d90aa2 100644
@@ -778,7 +778,6 @@ config ARCH_MESON
 
 config ARCH_MEDIATEK
 	bool "MediaTek SoCs"
-	select BINMAN
 	select DM
 	select OF_CONTROL
 	select SPL_DM if SPL
arch/arm/mach-mediatek/Kconfig +1 -0
index 17b84db5a8..0042e57017 100644
@@ -36,6 +36,7 @@ config TARGET_MT7629
 	bool "MediaTek MT7629 SoC"
 	select CPU_V7A
 	select SPL
+	select BINMAN
 	help
 	  The MediaTek MT7629 is a ARM-based SoC with a dual-core Cortex-A7
 	  including DDR3, crypto engine, 3x3 11n/ac Wi-Fi, Gigabit Ethernet,
Signature · 1 line
2.17.1
#6 lore raw

Aw: [PATCH 3/3] arm: mediatek: remove unuse binman config

Hi Sam

thank you for the Patch fixing the binman_fdt issue on bananapi r2/r64.

but i think this should be posted separately because it's not related to pwm. I hope Tom will pick up it soon (independ of pwm driver) to fix 2020-04.

regards Frank

#7 lore raw

cover mediatek: pwm: add pwm driver for MediaTek SoCs

In reply to Sam Shih

tested pwm on bananapi r64 (with LED on gpio pins 9 as GND + 11 as pwm) with commands

BPI-R64> pwm 0 config 1000000000 500000000
BPI-R64> pwm 0 enable

also no boot-problem after last Patch (removed my temporary workaround)

only a small typo in last patches subject (missing d in unused):

arm: mediatek: remove unuse binman config

regards Frank