Skip to contentSkip to conversation

Support pwm driver for aspeed ast26xx

PATCH Superseded Billy Tsai 2 participants 5 messages May 6, 2021 – May 7, 2021

Subsystems (4)

v3 of 14 Superseded Latest is v14 →

lore
Share & tools
lore

Billy Tsai

author reviewer
#0 lore raw

v3 cover Support pwm driver for aspeed ast26xx

The legacy driver of aspeed pwm is binding with tach controller and it doesn't follow the pwm framworks usage. In addition, the pwm register usage of the 6th generation of ast26xx has drastic change. So these patch serials add the new aspeed pwm driver to fix up the problem above.

Changes since v2:
- Remove the tach node, #address-cells and #size-cells from pwm-tach.yaml
- Add clocks and reset properties to pwm-tach.yaml
- Kconfig/Makfile sorted alphabetically
- pwm-aspeed-g6.c suggested by Uwe Kleine-König
- Add more hardware descriptions at top of the driver.
- Remove unused api request and free
- Move the initialize settings of all pwm channel to probe.
- Change the method of getting the approximate period.
- Read the hardware register values to fill the state for .get_state()

Changes since v1:
- Fix the dt_binding_check fail suggested by Rob Herring
- Add depends to PWM_ASPEED_G6 configure suggested by Uwe Kleine-Konig
- pwm-aspeed-g6.c suggested by Uwe Kleine-König
- Fix license header
- Use bitfiled.h macro to define register fields
- Implement .remove device function
- Implement .get_state pwm api

Billy Tsai (2):
dt-bindings: Add bindings for aspeed pwm-tach and pwm.
pwm: Add Aspeed ast2600 PWM support

 .../bindings/mfd/aspeed,ast2600-pwm-tach.yaml |  55 +++
 .../bindings/pwm/aspeed,ast2600-pwm.yaml      |  41 ++
 drivers/pwm/Kconfig                           |   8 +
 drivers/pwm/Makefile                          |   1 +
 drivers/pwm/pwm-aspeed-g6.c                   | 368 ++++++++++++++++++
 5 files changed, 473 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/aspeed,ast2600-pwm-tach.yaml
 create mode 100644 Documentation/devicetree/bindings/pwm/aspeed,ast2600-pwm.yaml
 create mode 100644 drivers/pwm/pwm-aspeed-g6.c
Signature · 1 line
2.25.1
author reviewer
#1 lore raw

PATCH v3 1/2 dt-bindings: Add bindings for aspeed pwm-tach and pwm.

This patch adds device bindings for aspeed pwm-tach device which is a multi-function device include pwn and tach function and pwm device which should be the sub-node of pwm-tach device.

---
 .../bindings/mfd/aspeed,ast2600-pwm-tach.yaml | 55 +++++++++++++++++++
 .../bindings/pwm/aspeed,ast2600-pwm.yaml      | 41 ++++++++++++++
 2 files changed, 96 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/aspeed,ast2600-pwm-tach.yaml
 create mode 100644 Documentation/devicetree/bindings/pwm/aspeed,ast2600-pwm.yaml
Documentation/devicetree/bindings/mfd/aspeed,ast2600-pwm-tach.yaml new file +55 -0
new file mode 100644
index 000000000000..9626bbd50acd
@@ -0,0 +1,55 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# Copyright (C) 2021 ASPEED, Inc.
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mfd/aspeed,ast2600-pwm-tach.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: PWM Tach controller Device Tree Bindings
+
+description: |
+  The PWM Tach controller is represented as a multi-function device which
+  includes:
+    PWM
+    Tach
+
+maintainers:
+  - Billy Tsai <[email protected]>
+
+properties:
+  compatible:
+    items:
+      - enum:
+          - aspeed,ast2600-pwm-tach
+      - const: syscon
+      - const: simple-mfd
+  reg:
+    maxItems: 1
+  clocks:
+    maxItems: 1
+  resets:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - resets
+
+additionalProperties:
+  type: object
+
+examples:
+  - |
+    #include <dt-bindings/clock/ast2600-clock.h>
+    pwm_tach: pwm_tach@1e610000 {
+      compatible = "aspeed,ast2600-pwm-tach", "syscon", "simple-mfd";
+      reg = <0x1e610000 0x100>;
+      clocks = <&syscon ASPEED_CLK_AHB>;
+      resets = <&syscon ASPEED_RESET_PWM>;
+
+      pwm: pwm {
+        compatible = "aspeed,ast2600-pwm";
+        #pwm-cells = <3>;
+      };
+    };
Documentation/devicetree/bindings/pwm/aspeed,ast2600-pwm.yaml new file +41 -0

41 lines not on this page · raw message

Signature · 1 line
2.25.1
maintainer
#2 lore raw

Re: [v3 1/2] dt-bindings: Add bindings for aspeed pwm-tach and pwm.

Quoted 61 lines · Billy Tsai

This patch adds device bindings for aspeed pwm-tach device which is a multi-function device include pwn and tach function and pwm device which should be the sub-node of pwm-tach device.

---
 .../bindings/mfd/aspeed,ast2600-pwm-tach.yaml | 55 +++++++++++++++++++
 .../bindings/pwm/aspeed,ast2600-pwm.yaml      | 41 ++++++++++++++
 2 files changed, 96 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/aspeed,ast2600-pwm-tach.yaml
 create mode 100644 Documentation/devicetree/bindings/pwm/aspeed,ast2600-pwm.yaml
Documentation/devicetree/bindings/mfd/aspeed,ast2600-pwm-tach.yaml new file +43 -0
new file mode 100644
index 000000000000..9626bbd50acd
@@ -0,0 +1,55 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# Copyright (C) 2021 ASPEED, Inc.
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mfd/aspeed,ast2600-pwm-tach.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: PWM Tach controller Device Tree Bindings
+
+description: |
+  The PWM Tach controller is represented as a multi-function device which
+  includes:
+    PWM
+    Tach
+
+maintainers:
+  - Billy Tsai <[email protected]>
+
+properties:
+  compatible:
+    items:
+      - enum:
+          - aspeed,ast2600-pwm-tach
+      - const: syscon
+      - const: simple-mfd
+  reg:
+    maxItems: 1
+  clocks:
+    maxItems: 1
+  resets:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - resets
+
+additionalProperties:
+  type: object
+
+examples:
+  - |

Documentation/devicetree/bindings/mfd/aspeed,ast2600-pwm-tach.yaml line 53

Quoted 10 lines
Documentation/devicetree/bindings/mfd/aspeed,ast2600-pwm-tach.yaml new file +10 -0
+    #include <dt-bindings/clock/ast2600-clock.h>
+    pwm_tach: pwm_tach at 1e610000 {
+      compatible = "aspeed,ast2600-pwm-tach", "syscon", "simple-mfd";
+      reg = <0x1e610000 0x100>;
+      clocks = <&syscon ASPEED_CLK_AHB>;
+      resets = <&syscon ASPEED_RESET_PWM>;
+
+      pwm: pwm {
+        compatible = "aspeed,ast2600-pwm";
+        #pwm-cells = <3>;

There's no need for a child node here. Just put #pwm-cells in the parent node.

Of course this all looks incomplete if you ever plan to hook up fans and have more than 1 PWM and Tach signal.

Quoted 2 lines
Documentation/devicetree/bindings/mfd/aspeed,ast2600-pwm-tach.yaml new file +2 -0
+      };
+    };
author reviewer
#3 lore raw

PATCH v3 2/2 pwm: Add Aspeed ast2600 PWM support

In reply to Billy Tsai

This patch add the support of PWM controller which can be found at aspeed ast2600 soc. The pwm supoorts up to 16 channels and it's part function of multi-function device "pwm-tach controller".

---
 drivers/pwm/Kconfig         |   8 +
 drivers/pwm/Makefile        |   1 +
 drivers/pwm/pwm-aspeed-g6.c | 368 ++++++++++++++++++++++++++++++++++++
 3 files changed, 377 insertions(+)
 create mode 100644 drivers/pwm/pwm-aspeed-g6.c
drivers/pwm/Kconfig +8 -0
index 63be5362fd3a..b0964b9a3273 100644
@@ -51,6 +51,14 @@ config PWM_AB8500
 	  To compile this driver as a module, choose M here: the module
 	  will be called pwm-ab8500.
 
+config PWM_ASPEED_G6
+	tristate "ASPEEDG6 PWM support"
+	depends on ARCH_ASPEED || COMPILE_TEST
+	help
+	  Generic PWM framework driver for ASPEED G6 SoC.
+
+	  This driver provides support for ASPEED G6 PWM controllers.
+
 config PWM_ATMEL
 	tristate "Atmel PWM support"
 	depends on OF
drivers/pwm/Makefile +1 -0
index cbdcd55d69ee..29d22d806e68 100644
@@ -2,6 +2,7 @@
 obj-$(CONFIG_PWM)		+= core.o
 obj-$(CONFIG_PWM_SYSFS)		+= sysfs.o
 obj-$(CONFIG_PWM_AB8500)	+= pwm-ab8500.o
+obj-$(CONFIG_PWM_ASPEED_G6)	+= pwm-aspeed-g6.o
 obj-$(CONFIG_PWM_ATMEL)		+= pwm-atmel.o
 obj-$(CONFIG_PWM_ATMEL_HLCDC_PWM)	+= pwm-atmel-hlcdc.o
 obj-$(CONFIG_PWM_ATMEL_TCB)	+= pwm-atmel-tcb.o
drivers/pwm/pwm-aspeed-g6.c new file +368 -0

368 lines not on this page · raw message

Signature · 1 line
2.25.1
maintainer
#4 lore raw
In reply to Billy Tsai
Quoted 7 lines · Billy Tsai

The legacy driver of aspeed pwm is binding with tach controller and it doesn't follow the pwm framworks usage. In addition, the pwm register usage of the 6th generation of ast26xx has drastic change. So these patch serials add the new aspeed pwm driver to fix up the problem above.

Changes since v2:
- Remove the tach node, #address-cells and #size-cells from pwm-tach.yaml

So you don't need tach functions, they don't need it to be described in DT any more, or you plan to add them back later? The last one is not acceptable.

Quoted 36 lines

- Add clocks and reset properties to pwm-tach.yaml
- Kconfig/Makfile sorted alphabetically
- pwm-aspeed-g6.c suggested by Uwe Kleine-K?nig
- Add more hardware descriptions at top of the driver.
- Remove unused api request and free
- Move the initialize settings of all pwm channel to probe.
- Change the method of getting the approximate period.
- Read the hardware register values to fill the state for .get_state()

Changes since v1:
- Fix the dt_binding_check fail suggested by Rob Herring
- Add depends to PWM_ASPEED_G6 configure suggested by Uwe Kleine-Konig
- pwm-aspeed-g6.c suggested by Uwe Kleine-K?nig
- Fix license header
- Use bitfiled.h macro to define register fields
- Implement .remove device function
- Implement .get_state pwm api

Billy Tsai (2):
dt-bindings: Add bindings for aspeed pwm-tach and pwm.
pwm: Add Aspeed ast2600 PWM support

 .../bindings/mfd/aspeed,ast2600-pwm-tach.yaml |  55 +++
 .../bindings/pwm/aspeed,ast2600-pwm.yaml      |  41 ++
 drivers/pwm/Kconfig                           |   8 +
 drivers/pwm/Makefile                          |   1 +
 drivers/pwm/pwm-aspeed-g6.c                   | 368 ++++++++++++++++++
 5 files changed, 473 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/aspeed,ast2600-pwm-tach.yaml
 create mode 100644 Documentation/devicetree/bindings/pwm/aspeed,ast2600-pwm.yaml
 create mode 100644 drivers/pwm/pwm-aspeed-g6.c
Signature · 1 line
2.25.1