Skip to contentSkip to conversation

Add Rockchip Soc PWM driver

PATCH Applied Beniamino Galvani 2 participants 6 messages Jun 21, 2014 – Jul 11, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v2 cover Add Rockchip Soc PWM driver

This series adds support for the PWM controller found on Rockchip RK29, RK30 and RK31 SoCs. It is based on the documentation publicly available [0] and kernel sources from Rockchip [1] and has been tested on RK3188.

The last patch, which adds device tree nodes in the dts, depends on the clocks introduced by Heiko in his recent submission of a new clk driver for Rockchip RK3188.

[0] http://dl.radxa.com/rock/docs/hw/ds/Rockchip%20RK30xx%20TRM%20V2.0.pdf
[1] https://github.com/rkchrome/kernel

Changes in v2:
* address comments from Thierry Reding:
- remove dependency on OF
- use NSEC_PER_SEC from time.h
- fix MODULE_DEVICE_TABLE name
- make pwm_ops struct const
- indentation and cosmetics

Beniamino Galvani (3):
pwm: add Rockchip SoC PWM support
pwm: rockchip: document device tree bindings
ARM: dts: rk3xxx: add PWM nodes

 .../devicetree/bindings/pwm/pwm-rockchip.txt       |   17 ++
 arch/arm/boot/dts/rk3188.dtsi                      |   40 +++++
 arch/arm/boot/dts/rk3xxx.dtsi                      |   32 ++++
 drivers/pwm/Kconfig                                |    7 +
 drivers/pwm/Makefile                               |    1 +
 drivers/pwm/pwm-rockchip.c                         |  177 ++++++++++++++++++++
 6 files changed, 274 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pwm/pwm-rockchip.txt
 create mode 100644 drivers/pwm/pwm-rockchip.c
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH v2 1/3 pwm: add Rockchip SoC PWM support

This commit adds a driver for the PWM controller found on Rockchip RK29, RK30 and RK31 SoCs.

---
 drivers/pwm/Kconfig        |    7 ++
 drivers/pwm/Makefile       |    1 +
 drivers/pwm/pwm-rockchip.c |  177 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 185 insertions(+)
 create mode 100644 drivers/pwm/pwm-rockchip.c
drivers/pwm/Kconfig +7 -0
index 4ad7b89..a86879a 100644
@@ -206,6 +206,13 @@ config PWM_RENESAS_TPU
 	  To compile this driver as a module, choose M here: the module
 	  will be called pwm-renesas-tpu.
 
+config PWM_ROCKCHIP
+	tristate "Rockchip PWM support"
+	depends on ARCH_ROCKCHIP
+	help
+	  Generic PWM framework driver for the PWM controller found on
+	  Rockchip SoCs.
+
 config PWM_SAMSUNG
 	tristate "Samsung PWM support"
 	depends on PLAT_SAMSUNG
drivers/pwm/Makefile +1 -0
index 5c86a19..e03e2ae 100644
@@ -18,6 +18,7 @@ obj-$(CONFIG_PWM_PCA9685)	+= pwm-pca9685.o
 obj-$(CONFIG_PWM_PUV3)		+= pwm-puv3.o
 obj-$(CONFIG_PWM_PXA)		+= pwm-pxa.o
 obj-$(CONFIG_PWM_RENESAS_TPU)	+= pwm-renesas-tpu.o
+obj-$(CONFIG_PWM_ROCKCHIP)	+= pwm-rockchip.o
 obj-$(CONFIG_PWM_SAMSUNG)	+= pwm-samsung.o
 obj-$(CONFIG_PWM_SPEAR)		+= pwm-spear.o
 obj-$(CONFIG_PWM_TEGRA)		+= pwm-tegra.o
drivers/pwm/pwm-rockchip.c new file +177 -0

177 lines not on this page · raw message

Signature · 1 line
1.7.10.4
#2 lore raw

Re: [PATCH v2 1/3] pwm: add Rockchip SoC PWM support

Quoted 10 lines · Beniamino Galvani

This commit adds a driver for the PWM controller found on Rockchip RK29, RK30 and RK31 SoCs.

---
 drivers/pwm/Kconfig        |    7 ++
 drivers/pwm/Makefile       |    1 +
 drivers/pwm/pwm-rockchip.c |  177 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 185 insertions(+)
 create mode 100644 drivers/pwm/pwm-rockchip.c

Applied, thanks.

Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140711/259f442e/attachment.sig>

#3 lore raw

PATCH v2 2/3 pwm: rockchip: document device tree bindings

In reply to Beniamino Galvani

This adds binding documentation for Rockchip SoC PWM driver.

---
 .../devicetree/bindings/pwm/pwm-rockchip.txt          |   17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pwm/pwm-rockchip.txt
Documentation/devicetree/bindings/pwm/pwm-rockchip.txt new file +17 -0
new file mode 100644
index 0000000..3182126
@@ -0,0 +1,17 @@
+Rockchip PWM controller
+
+Required properties:
+ - compatible: should be "rockchip,rk2928-pwm"
+ - reg: physical base address and length of the controller's registers
+ - clocks: phandle and clock specifier of the PWM reference clock
+ - #pwm-cells: should be 2. See pwm.txt in this directory for a
+   description of the cell format.
+
+Example:
+
+	pwm0: pwm at 20030000 {
+		compatible = "rockchip,rk2928-pwm";
+		reg = <0x20030000 0x10>;
+		clocks = <&cru PCLK_PWM01>;
+		#pwm-cells = <2>;
+	};
Signature · 1 line
1.7.10.4
#4 lore raw

Re: [PATCH v2 2/3] pwm: rockchip: document device tree bindings

Quoted 7 lines · Beniamino Galvani

This adds binding documentation for Rockchip SoC PWM driver.

---
 .../devicetree/bindings/pwm/pwm-rockchip.txt          |   17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pwm/pwm-rockchip.txt

Applied, thanks.

Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140711/aea631a4/attachment.sig>

#5 lore raw

PATCH v2 3/3 ARM: dts: rk3xxx: add PWM nodes

In reply to Beniamino Galvani

This adds PWM nodes to the Rockchip device trees.

---
 arch/arm/boot/dts/rk3188.dtsi |   40 ++++++++++++++++++++++++++++++++++++++++
 arch/arm/boot/dts/rk3xxx.dtsi |   32 ++++++++++++++++++++++++++++++++
 2 files changed, 72 insertions(+)
arch/arm/boot/dts/rk3188.dtsi +40 -0
index a50a462..a91e205 100644
@@ -114,6 +114,22 @@
 			clock-names = "biu", "ciu";
 		};
 
+		pwm0: pwm at 20030000 {
+			clocks = <&cru PCLK_PWM01>;
+		};
+
+		pwm1: pwm at 20030010 {
+			clocks = <&cru PCLK_PWM01>;
+		};
+
+		pwm2: pwm at 20050020 {
+			clocks = <&cru PCLK_PWM23>;
+		};
+
+		pwm3: pwm at 20050030 {
+			clocks = <&cru PCLK_PWM23>;
+		};
+
 		cru: cru at 20000000 {
 			compatible = "rockchip,rk3188-cru";
 			reg = <0x20000000 0x1000>;
@@ -310,6 +326,30 @@
 							<RK_GPIO3 20 RK_FUNC_1 &pcfg_pull_none>;
 				};
 			};
+
+			pwm0 {
+				pwm0_pins: pwm0-pins {
+					rockchip,pins = <RK_GPIO3 27 RK_FUNC_1 &pcfg_pull_none>;
+				};
+			};
+
+			pwm1 {
+				pwm1_pins: pwm1-pins {
+					rockchip,pins = <RK_GPIO3 28 RK_FUNC_1 &pcfg_pull_none>;
+				};
+			};
+
+			pwm2 {
+				pwm2_pins: pwm2-pins {
+					rockchip,pins = <RK_GPIO3 29 RK_FUNC_1 &pcfg_pull_none>;
+				};
+			};
+
+			pwm3 {
+				pwm3_pins: pwm3-pins {
+					rockchip,pins = <RK_GPIO3 30 RK_FUNC_1 &pcfg_pull_none>;
+				};
+			};
 		};
 	};
 };
arch/arm/boot/dts/rk3xxx.dtsi +32 -0
index 2adf1cc9e..80811bb 100644
@@ -135,5 +135,37 @@
 
 			status = "disabled";
 		};
+
+		pwm0: pwm at 20030000 {
+			compatible = "rockchip,rk2928-pwm";
+			reg = <0x20030000 0x10>;
+			#pwm-cells = <2>;
+			clocks = <&clk_gates7 10>;
+			status = "disabled";
+		};
+
+		pwm1: pwm at 20030010 {
+			compatible = "rockchip,rk2928-pwm";
+			reg = <0x20030010 0x10>;
+			#pwm-cells = <2>;
+			clocks = <&clk_gates7 10>;
+			status = "disabled";
+		};
+
+		pwm2: pwm at 20050020 {
+			compatible = "rockchip,rk2928-pwm";
+			reg = <0x20050020 0x10>;
+			#pwm-cells = <2>;
+			clocks = <&clk_gates7 11>;
+			status = "disabled";
+		};
+
+		pwm3: pwm at 20050030 {
+			compatible = "rockchip,rk2928-pwm";
+			reg = <0x20050030 0x10>;
+			#pwm-cells = <2>;
+			clocks = <&clk_gates7 11>;
+			status = "disabled";
+		};
 	};
 };
Signature · 1 line
1.7.10.4