Skip to contentSkip to conversation

Support pwm/tach driver for aspeed ast26xx

PATCH RESEND Superseded Billy Tsai 5 participants 16 messages Nov 7, 2023 – Jan 13, 2024 1 message not in the archive

Subsystems (5)

v10 of 14 Superseded Latest is v14 →

lore
Share & tools
lore

Billy Tsai

author reviewer
#0 lore raw

v10 cover Support pwm/tach driver for aspeed ast26xx

Unlike the old design that the register setting of the TACH should based on the configure of the PWM. In ast26xx, the dependency between pwm and tach controller is eliminated and becomes a separate hardware block. One is used to provide pwm output and another is used to monitor the frequency of the input. This driver implements them by exposing two kernel
subsystems: PWM and HWMON. The PWM subsystem can be utilized alongside existing drivers for controlling elements such as fans (pwm-fan.c), beepers (pwm-beeper.c) and so on. Through the HWMON subsystem, the driver provides sysfs interfaces for fan.

Changes since v9:
Change the type of fan-driving-mode to string
Fix some typos and formatting issues.

Changes since v8:
Fix the fail of fan div register setting. (FIELD_GET -> FIELD_PREP) Change the type of tach-ch from uint32_t to uint8-array
Add additional properties and apply constraints to certain properties.

Changes since v7:
Cherry-pick the fan-common.yaml and add the following properties:
- min-rpm
- div
- mode
- tach-ch
Fix the warning which is reported by the kernel test robot.

Changes since v6:
Consolidate the PWM and TACH functionalities into a unified driver.

Changes since v5:
- pwm/tach:
- Remove the utilization of common resources from the parent node.
- Change the concept to 16 PWM/TACH controllers, each with one channel, instead of 1 PWM/TACH controller with 16 channels.
- dt-binding:
- Eliminate the usage of simple-mfd.

Changes since v4:
- pwm:
- Fix the return type of get_status function.
- tach:
- read clk source once and re-use it
- Remove the constants variables
- Allocate tach_channel as array
- Use dev->parent
- dt-binding:
- Fix the order of the patches
- Add example and description for tach child node
- Remove pwm extension property

Changes since v3:
- pwm:
- Remove unnecessary include header
- Fix warning Prefer "GPL" over "GPL v2"
- tach:
- Remove the paremeter min_rpm and max_rpm and return the tach value directly without any polling or delay.
- Fix warning Prefer "GPL" over "GPL v2"
- dt-binding:
- Replace underscore in node names with dashes
- Split per subsystem

Changes since v2:
- pwm:
- Use devm_* api to simplify the error cleanup
- Fix the multi-line alignment problem
- tach:
- Add tach-aspeed-ast2600 to index.rst
- Fix the multi-line alignment problem
- Remove the tach enable/disable when read the rpm
- Fix some coding format issue

Changes since v1:
- tach:
- Add the document tach-aspeed-ast2600.rst
- Use devm_* api to simplify the error cleanup.
- Change hwmon register api to devm_hwmon_device_register_with_info

Billy Tsai (2):
dt-bindings: hwmon: Support Aspeed g6 PWM TACH Control
hwmon: (aspeed-g6-pwm-tacho): Support for ASPEED g6 PWM/Fan tach

Naresh Solanki (1):
dt-bindings: hwmon: fan: Add fan binding to schema

 .../bindings/hwmon/aspeed,g6-pwm-tach.yaml    |  69 +++
 .../devicetree/bindings/hwmon/fan-common.yaml |  78 +++
 Documentation/hwmon/aspeed-g6-pwm-tach.rst    |  26 +
 Documentation/hwmon/index.rst                 |   1 +
 drivers/hwmon/Kconfig                         |  11 +
 drivers/hwmon/Makefile                        |   1 +
 drivers/hwmon/aspeed-g6-pwm-tach.c            | 539 ++++++++++++++++++
 7 files changed, 725 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/hwmon/aspeed,g6-pwm-tach.yaml
 create mode 100644 Documentation/devicetree/bindings/hwmon/fan-common.yaml
 create mode 100644 Documentation/hwmon/aspeed-g6-pwm-tach.rst
 create mode 100644 drivers/hwmon/aspeed-g6-pwm-tach.c
Signature · 1 line
2.25.1
author reviewer
#1 lore raw

PATCH RESEND v10 1/3 dt-bindings: hwmon: fan: Add fan binding to schema

From: Naresh Solanki <[email protected]>

Add common fan properties bindings to a schema.

Bindings for fan controllers can reference the common schema for the fan

child nodes:

patternProperties:

    "^fan@[0-2]":
      type: object
      $ref: fan-common.yaml#
      unevaluatedProperties: false
---
 .../devicetree/bindings/hwmon/fan-common.yaml | 78 +++++++++++++++++++
 1 file changed, 78 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/hwmon/fan-common.yaml
Documentation/devicetree/bindings/hwmon/fan-common.yaml new file +78 -0
new file mode 100644
index 000000000000..be4ce3bd7f22
@@ -0,0 +1,78 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/hwmon/fan-common.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Common Fan Properties
+
+maintainers:
+  - Naresh Solanki <[email protected]>
+  - Billy Tsai <[email protected]>
+
+properties:
+  max-rpm:
+    description:
+      Max RPM supported by fan.
+    $ref: /schemas/types.yaml#/definitions/uint32
+    maximum: 100000
+
+  min-rpm:
+    description:
+      Min RPM supported by fan.
+    $ref: /schemas/types.yaml#/definitions/uint32
+    maximum: 1000
+
+  pulses-per-revolution:
+    description:
+      The number of pulse from fan sensor per revolution.
+    $ref: /schemas/types.yaml#/definitions/uint32
+    maximum: 4
+
+  tach-div:
+    description:
+      Divisor for the tach sampling clock, which determines the sensitivity of the tach pin.
+    $ref: /schemas/types.yaml#/definitions/uint32
+
+  target-rpm:
+    description:
+      The default desired fan speed in RPM.
+    $ref: /schemas/types.yaml#/definitions/uint32
+
+  fan-driving-mode:
+    description:
+      Select the driving mode of the fan.(DC, PWM and so on)
+    $ref: /schemas/types.yaml#/definitions/string
+
+  pwms:
+    description:
+      PWM provider.
+    maxItems: 1
+
+  "#cooling-cells":
+    const: 2
+
+  cooling-levels:
+    description:
+      The control value which correspond to thermal cooling states.
+    $ref: /schemas/types.yaml#/definitions/uint32-array
+
+  tach-ch:
+    description:
+      The tach channel used for the fan.
+    $ref: /schemas/types.yaml#/definitions/uint8-array
+
+  label:
+    description:
+      Optional fan label
+
+  fan-supply:
+    description:
+      Power supply for fan.
+
+  reg:
+    maxItems: 1
+
+additionalProperties: true
+
+...
Signature · 1 line
2.25.1
maintainer Reviewed-by on v10 1/3
#2 lore raw

Re: [PATCH RESEND v10 1/3] dt-bindings: hwmon: fan: Add fan binding to schema

Quoted 15 lines · Billy Tsai

From: Naresh Solanki <[email protected]>

Add common fan properties bindings to a schema.

Bindings for fan controllers can reference the common schema for the fan

child nodes:

patternProperties:

    "^fan@[0-2]":
      type: object
      $ref: fan-common.yaml#
      unevaluatedProperties: false
Quoted 6 lines
---
 .../devicetree/bindings/hwmon/fan-common.yaml | 78 +++++++++++++++++++
 1 file changed, 78 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/hwmon/fan-common.yaml

Looking pretty good to me. It's disappointing that no one else interested in upstreaming their fan controller can be bothered to comment.

Quoted 42 lines
Documentation/devicetree/bindings/hwmon/fan-common.yaml new file +35 -0
new file mode 100644
index 000000000000..be4ce3bd7f22
@@ -0,0 +1,78 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/hwmon/fan-common.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Common Fan Properties
+
+maintainers:
+  - Naresh Solanki <[email protected]>
+  - Billy Tsai <[email protected]>
+
+properties:
+  max-rpm:
+    description:
+      Max RPM supported by fan.
+    $ref: /schemas/types.yaml#/definitions/uint32
+    maximum: 100000
+
+  min-rpm:
+    description:
+      Min RPM supported by fan.
+    $ref: /schemas/types.yaml#/definitions/uint32
+    maximum: 1000
+
+  pulses-per-revolution:
+    description:
+      The number of pulse from fan sensor per revolution.
+    $ref: /schemas/types.yaml#/definitions/uint32
+    maximum: 4
+
+  tach-div:
+    description:
+      Divisor for the tach sampling clock, which determines the sensitivity of the tach pin.
+    $ref: /schemas/types.yaml#/definitions/uint32

Documentation/devicetree/bindings/hwmon/fan-common.yaml line 45

Quoted 10 lines
Documentation/devicetree/bindings/hwmon/fan-common.yaml new file +10 -0
+
+  target-rpm:
+    description:
+      The default desired fan speed in RPM.
+    $ref: /schemas/types.yaml#/definitions/uint32
+
+  fan-driving-mode:
+    description:
+      Select the driving mode of the fan.(DC, PWM and so on)
+    $ref: /schemas/types.yaml#/definitions/string

You need to define the possible values. I assume it's:

enum:
- dc
- pwm
- anything else???

With that,

maintainer
#3 lore raw

Re: [PATCH RESEND v10 1/3] dt-bindings: hwmon: fan: Add fan binding to schema

Quoted 23 lines · Rob Herring
Quoted 15 lines · Billy Tsai

From: Naresh Solanki <[email protected]>

Add common fan properties bindings to a schema.

Bindings for fan controllers can reference the common schema for the fan

child nodes:

   patternProperties:
     "^fan@[0-2]":
       type: object
       $ref: fan-common.yaml#
       unevaluatedProperties: false
Quoted 6 lines
---
  .../devicetree/bindings/hwmon/fan-common.yaml | 78 +++++++++++++++++++
  1 file changed, 78 insertions(+)

create mode 100644 Documentation/devicetree/bindings/hwmon/fan-common.yaml

Quoted 4 lines

Looking pretty good to me. It's disappointing that no one else interested in upstreaming their fan controller can be bothered to comment.

FWIW, I declined to comment since it basically looks ok to me and because at this point I'd rather have something (whatever it is) instead of nothing.

Quoted 55 lines
Quoted 42 lines
Documentation/devicetree/bindings/hwmon/fan-common.yaml new file +35 -0
new file mode 100644
index 000000000000..be4ce3bd7f22
@@ -0,0 +1,78 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/hwmon/fan-common.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Common Fan Properties
+
+maintainers:
+  - Naresh Solanki <[email protected]>
+  - Billy Tsai <[email protected]>
+
+properties:
+  max-rpm:
+    description:
+      Max RPM supported by fan.
+    $ref: /schemas/types.yaml#/definitions/uint32
+    maximum: 100000
+
+  min-rpm:
+    description:
+      Min RPM supported by fan.
+    $ref: /schemas/types.yaml#/definitions/uint32
+    maximum: 1000
+
+  pulses-per-revolution:
+    description:
+      The number of pulse from fan sensor per revolution.
+    $ref: /schemas/types.yaml#/definitions/uint32
+    maximum: 4
+
+  tach-div:
+    description:
+      Divisor for the tach sampling clock, which determines the sensitivity of the tach pin.
+    $ref: /schemas/types.yaml#/definitions/uint32

Documentation/devicetree/bindings/hwmon/fan-common.yaml line 45

Quoted 10 lines
Documentation/devicetree/bindings/hwmon/fan-common.yaml new file +10 -0
+
+  target-rpm:
+    description:
+      The default desired fan speed in RPM.
+    $ref: /schemas/types.yaml#/definitions/uint32
+
+  fan-driving-mode:
+    description:
+      Select the driving mode of the fan.(DC, PWM and so on)
+    $ref: /schemas/types.yaml#/definitions/string

You need to define the possible values. I assume it's:

Quoted 5 lines

enum:
- dc
- pwm
- anything else???

I am not aware of any other possible method. dc and pwm is all I have ever seen.

Guenter

Quoted 3 lines

With that,

author reviewer
#4 lore raw

PATCH RESEND v10 2/3 dt-bindings: hwmon: Support Aspeed g6 PWM TACH Control

In reply to Billy Tsai

Document the compatible for aspeed,ast2600-pwm-tach device, which can support up to 16 PWM outputs and 16 fan tach input.

---
 .../bindings/hwmon/aspeed,g6-pwm-tach.yaml    | 69 +++++++++++++++++++
 1 file changed, 69 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/hwmon/aspeed,g6-pwm-tach.yaml
Documentation/devicetree/bindings/hwmon/aspeed,g6-pwm-tach.yaml new file +69 -0
new file mode 100644
index 000000000000..c615fb10705c
@@ -0,0 +1,69 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# Copyright (C) 2023 Aspeed, Inc.
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/hwmon/aspeed,g6-pwm-tach.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: ASPEED G6 PWM and Fan Tach controller
+
+maintainers:
+  - Billy Tsai <[email protected]>
+
+description: |
+  The ASPEED PWM controller can support up to 16 PWM outputs.
+  The ASPEED Fan Tacho controller can support up to 16 fan tach input.
+  They are independent hardware blocks, which are different from the
+  previous version of the ASPEED chip.
+
+properties:
+  compatible:
+    enum:
+      - aspeed,ast2600-pwm-tach
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+
+  resets:
+    maxItems: 1
+
+  "#pwm-cells":
+    const: 3
+
+patternProperties:
+  "^fan-[0-9]+$":
+    $ref: fan-common.yaml#
+    unevaluatedProperties: false
+    required:
+      - tach-ch
+
+required:
+  - reg
+  - clocks
+  - resets
+  - "#pwm-cells"
+  - compatible
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/clock/aspeed-clock.h>
+    pwm_tach: pwm-tach-controller at 1e610000 {
+      compatible = "aspeed,ast2600-pwm-tach";
+      reg = <0x1e610000 0x100>;
+      clocks = <&syscon ASPEED_CLK_AHB>;
+      resets = <&syscon ASPEED_RESET_PWM>;
+      #pwm-cells = <3>;
+
+      fan-0 {
+        tach-ch = /bits/ 8 <0x0>;
+      };
+
+      fan-1 {
+        tach-ch = /bits/ 8 <0x1 0x2>;
+      };
+    };
Signature · 1 line
2.25.1
maintainer
#5 lore raw

Re: [PATCH RESEND v10 2/3] dt-bindings: hwmon: Support Aspeed g6 PWM TACH Control

Quoted 67 lines · Billy Tsai

Document the compatible for aspeed,ast2600-pwm-tach device, which can support up to 16 PWM outputs and 16 fan tach input.

---
 .../bindings/hwmon/aspeed,g6-pwm-tach.yaml    | 69 +++++++++++++++++++
 1 file changed, 69 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/hwmon/aspeed,g6-pwm-tach.yaml
Documentation/devicetree/bindings/hwmon/aspeed,g6-pwm-tach.yaml new file +52 -0
new file mode 100644
index 000000000000..c615fb10705c
@@ -0,0 +1,69 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# Copyright (C) 2023 Aspeed, Inc.
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/hwmon/aspeed,g6-pwm-tach.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: ASPEED G6 PWM and Fan Tach controller
+
+maintainers:
+  - Billy Tsai <[email protected]>
+
+description: |
+  The ASPEED PWM controller can support up to 16 PWM outputs.
+  The ASPEED Fan Tacho controller can support up to 16 fan tach input.
+  They are independent hardware blocks, which are different from the
+  previous version of the ASPEED chip.
+
+properties:
+  compatible:
+    enum:
+      - aspeed,ast2600-pwm-tach
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+
+  resets:
+    maxItems: 1
+
+  "#pwm-cells":
+    const: 3
+
+patternProperties:
+  "^fan-[0-9]+$":
+    $ref: fan-common.yaml#
+    unevaluatedProperties: false
+    required:
+      - tach-ch
+
+required:
+  - reg
+  - clocks
+  - resets
+  - "#pwm-cells"
+  - compatible
+
+additionalProperties: false
+
+examples:

Documentation/devicetree/bindings/hwmon/aspeed,g6-pwm-tach.yaml line 62

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

I assume there's a PWM connection here? How do you know which PWM? You said the tach channel is independent, so it is not that.

It should not be 0 from 'fan-0' because that's just a meaningless index.

You either need 'pwms' here or you can use 'reg' and the reg value is the PWM channel.

Quoted 10 lines
Documentation/devicetree/bindings/hwmon/aspeed,g6-pwm-tach.yaml new file +7 -0
+        tach-ch = /bits/ 8 <0x0>;
+      };
+
+      fan-1 {
+        tach-ch = /bits/ 8 <0x1 0x2>;
+      };
+    };
Signature · 1 line
2.25.1
author reviewer
#6 lore raw

Re: [PATCH RESEND v10 2/3] dt-bindings: hwmon: Support Aspeed g6 PWM TACH Control

Quoted 81 lines
Quoted 67 lines

Document the compatible for aspeed,ast2600-pwm-tach device, which can support up to 16 PWM outputs and 16 fan tach input.

---
 .../bindings/hwmon/aspeed,g6-pwm-tach.yaml    | 69 +++++++++++++++++++
 1 file changed, 69 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/hwmon/aspeed,g6-pwm-tach.yaml
Documentation/devicetree/bindings/hwmon/aspeed,g6-pwm-tach.yaml new file +52 -0
new file mode 100644
index 000000000000..c615fb10705c
@@ -0,0 +1,69 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# Copyright (C) 2023 Aspeed, Inc.
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/hwmon/aspeed,g6-pwm-tach.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: ASPEED G6 PWM and Fan Tach controller
+
+maintainers:
+  - Billy Tsai <[email protected]>
+
+description: |
+  The ASPEED PWM controller can support up to 16 PWM outputs.
+  The ASPEED Fan Tacho controller can support up to 16 fan tach input.
+  They are independent hardware blocks, which are different from the
+  previous version of the ASPEED chip.
+
+properties:
+  compatible:
+    enum:
+      - aspeed,ast2600-pwm-tach
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+
+  resets:
+    maxItems: 1
+
+  "#pwm-cells":
+    const: 3
+
+patternProperties:
+  "^fan-[0-9]+$":
+    $ref: fan-common.yaml#
+    unevaluatedProperties: false
+    required:
+      - tach-ch
+
+required:
+  - reg
+  - clocks
+  - resets
+  - "#pwm-cells"
+  - compatible
+
+additionalProperties: false
+
+examples:

Documentation/devicetree/bindings/hwmon/aspeed,g6-pwm-tach.yaml line 62

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

I assume there's a PWM connection here? How do you know which PWM? You said the tach channel is independent, so it is not that.

Quoted 4 lines

It should not be 0 from 'fan-0' because that's just a meaningless index.

You either need 'pwms' here or you can use 'reg' and the reg value is the PWM channel.

Hi Rob, this binding is used to export the PWM provider and the Fan monitor (i.e., Tach). If the user wants to add the PWM connection for the fan, it can be done as follows:

fan0: pwm-fan0 {
        compatible = "pwm-fan";
        pwms = <&pwm_tach 0 40000 0>; 
        cooling-min-state = <0>;
        cooling-max-state = <3>;
        #cooling-cells = <2>;
        cooling-levels = <0 15 128 255>;
};

This will reuse the existing PWM fan driver (e.g., pwm-fan.c).

Thanks

Billy

Quoted 10 lines
Quoted 10 lines
Documentation/devicetree/bindings/hwmon/aspeed,g6-pwm-tach.yaml new file +7 -1
+        tach-ch = /bits/ 8 <0x0>;
+      };
+
+      fan-1 {
+        tach-ch = /bits/ 8 <0x1 0x2>;
+      };
+    };
--

2.25.1

maintainer
#7 lore raw

Re: [PATCH RESEND v10 2/3] dt-bindings: hwmon: Support Aspeed g6 PWM TACH Control

Quoted 99 lines · On Mon, Nov 13, 2023 at 8:11?PM Billy Tsai <[email protected]> wrote:
Quoted 82 lines
Quoted 68 lines

Document the compatible for aspeed,ast2600-pwm-tach device, which can support up to 16 PWM outputs and 16 fan tach input.

---
 .../bindings/hwmon/aspeed,g6-pwm-tach.yaml    | 69 +++++++++++++++++++
 1 file changed, 69 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/hwmon/aspeed,g6-pwm-tach.yaml
Documentation/devicetree/bindings/hwmon/aspeed,g6-pwm-tach.yaml new file +52 -0
new file mode 100644
index 000000000000..c615fb10705c
@@ -0,0 +1,69 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# Copyright (C) 2023 Aspeed, Inc.
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/hwmon/aspeed,g6-pwm-tach.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: ASPEED G6 PWM and Fan Tach controller
+
+maintainers:
+  - Billy Tsai <[email protected]>
+
+description: |
+  The ASPEED PWM controller can support up to 16 PWM outputs.
+  The ASPEED Fan Tacho controller can support up to 16 fan tach input.
+  They are independent hardware blocks, which are different from the
+  previous version of the ASPEED chip.
+
+properties:
+  compatible:
+    enum:
+      - aspeed,ast2600-pwm-tach
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+
+  resets:
+    maxItems: 1
+
+  "#pwm-cells":
+    const: 3
+
+patternProperties:
+  "^fan-[0-9]+$":
+    $ref: fan-common.yaml#
+    unevaluatedProperties: false
+    required:
+      - tach-ch
+
+required:
+  - reg
+  - clocks
+  - resets
+  - "#pwm-cells"
+  - compatible
+
+additionalProperties: false
+
+examples:

Documentation/devicetree/bindings/hwmon/aspeed,g6-pwm-tach.yaml line 62

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

I assume there's a PWM connection here? How do you know which PWM? You said the tach channel is independent, so it is not that.

Quoted 4 lines

It should not be 0 from 'fan-0' because that's just a meaningless index.

You either need 'pwms' here or you can use 'reg' and the reg value is the PWM channel.

Hi Rob, this binding is used to export the PWM provider and the Fan monitor (i.e., Tach). If the user wants to add the PWM connection for the fan, it can be done as follows:

fan0: pwm-fan0 {
        compatible = "pwm-fan";
        pwms = <&pwm_tach 0 40000 0>;
        cooling-min-state = <0>;
        cooling-max-state = <3>;
        #cooling-cells = <2>;
        cooling-levels = <0 15 128 255>;
};
Quoted 1 line

This will reuse the existing PWM fan driver (e.g., pwm-fan.c).

I'm confused now. So what are the child nodes you have? You are defining the fan in 2 places? The "pwm-fan" driver supports a tach via an interrupt, so how would this work in your case?

Rob

author reviewer
#8 lore raw

Re: [PATCH RESEND v10 2/3] dt-bindings: hwmon: Support Aspeed g6 PWM TACH Control

Quoted 98 lines
Quoted 98 lines
Quoted 81 lines
Quoted 67 lines

Document the compatible for aspeed,ast2600-pwm-tach device, which can support up to 16 PWM outputs and 16 fan tach input.

---
 .../bindings/hwmon/aspeed,g6-pwm-tach.yaml    | 69 +++++++++++++++++++
 1 file changed, 69 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/hwmon/aspeed,g6-pwm-tach.yaml
Documentation/devicetree/bindings/hwmon/aspeed,g6-pwm-tach.yaml new file +52 -0
new file mode 100644
index 000000000000..c615fb10705c
@@ -0,0 +1,69 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# Copyright (C) 2023 Aspeed, Inc.
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/hwmon/aspeed,g6-pwm-tach.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: ASPEED G6 PWM and Fan Tach controller
+
+maintainers:
+  - Billy Tsai <[email protected]>
+
+description: |
+  The ASPEED PWM controller can support up to 16 PWM outputs.
+  The ASPEED Fan Tacho controller can support up to 16 fan tach input.
+  They are independent hardware blocks, which are different from the
+  previous version of the ASPEED chip.
+
+properties:
+  compatible:
+    enum:
+      - aspeed,ast2600-pwm-tach
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+
+  resets:
+    maxItems: 1
+
+  "#pwm-cells":
+    const: 3
+
+patternProperties:
+  "^fan-[0-9]+$":
+    $ref: fan-common.yaml#
+    unevaluatedProperties: false
+    required:
+      - tach-ch
+
+required:
+  - reg
+  - clocks
+  - resets
+  - "#pwm-cells"
+  - compatible
+
+additionalProperties: false
+
+examples:

Documentation/devicetree/bindings/hwmon/aspeed,g6-pwm-tach.yaml line 62

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

I assume there's a PWM connection here? How do you know which PWM? You said the tach channel is independent, so it is not that.

Quoted 4 lines

It should not be 0 from 'fan-0' because that's just a meaningless index.

You either need 'pwms' here or you can use 'reg' and the reg value is the PWM channel.

Hi Rob, this binding is used to export the PWM provider and the Fan monitor (i.e., Tach). If the user wants to add the PWM connection for the fan, it can be done as follows:

fan0: pwm-fan0 {
        compatible = "pwm-fan";
        pwms = <&pwm_tach 0 40000 0>;
        cooling-min-state = <0>;
        cooling-max-state = <3>;
        #cooling-cells = <2>;
        cooling-levels = <0 15 128 255>;
};
Quoted 5 lines
Quoted 1 line

This will reuse the existing PWM fan driver (e.g., pwm-fan.c).

I'm confused now. So what are the child nodes you have? You are defining the fan in 2 places? The "pwm-fan" driver supports a tach via an interrupt, so how would this work in your case?

Hi Rob,

The tach interrupt for the pwm-fan is option. In our case, the dts just reuse the pwm control function of the pwm-fan, and the part of the tach monitor will be created by our fan child nodes. So the dts will like followings:

// Use to declare the tach monitor for fan.

&pwm_tach {
        fan-0 {
		tach-ch = /bits/ 8 <0x0>;
	};
	fan-1 {
		tach-ch = /bits/ 8 <0x1>;
	};
        ...
}

// Reuse the pwm-fan.c to control the behavior of the PWM for fan.

fan0: pwm-fan0 {
        compatible = "pwm-fan";
        pwms = <&pwm_tach 0 40000 0>;   /* Target freq:25 kHz */
        cooling-min-state = <0>;
        cooling-max-state = <3>;
        #cooling-cells = <2>;
        cooling-levels = <0 15 128 255>;
};
fan1: pwm-fan1 {
        compatible = "pwm-fan";
        pwms = <&pwm_tach 1 40000 0>;   /* Target freq:25 kHz */
        cooling-min-state = <0>;
        cooling-max-state = <3>;
        #cooling-cells = <2>;
        cooling-levels = <0 15 128 255>;
};

Thanks

maintainer
#9 lore raw

Re: [PATCH RESEND v10 2/3] dt-bindings: hwmon: Support Aspeed g6 PWM TACH Control

Quoted 123 lines · On Sun, Nov 26, 2023 at 11:45?PM Billy Tsai <[email protected]> wrote:
Quoted 99 lines
Quoted 99 lines
Quoted 82 lines
Quoted 68 lines

Document the compatible for aspeed,ast2600-pwm-tach device, which can support up to 16 PWM outputs and 16 fan tach input.

---
 .../bindings/hwmon/aspeed,g6-pwm-tach.yaml    | 69 +++++++++++++++++++
 1 file changed, 69 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/hwmon/aspeed,g6-pwm-tach.yaml
Documentation/devicetree/bindings/hwmon/aspeed,g6-pwm-tach.yaml new file +52 -0
new file mode 100644
index 000000000000..c615fb10705c
@@ -0,0 +1,69 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# Copyright (C) 2023 Aspeed, Inc.
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/hwmon/aspeed,g6-pwm-tach.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: ASPEED G6 PWM and Fan Tach controller
+
+maintainers:
+  - Billy Tsai <[email protected]>
+
+description: |
+  The ASPEED PWM controller can support up to 16 PWM outputs.
+  The ASPEED Fan Tacho controller can support up to 16 fan tach input.
+  They are independent hardware blocks, which are different from the
+  previous version of the ASPEED chip.
+
+properties:
+  compatible:
+    enum:
+      - aspeed,ast2600-pwm-tach
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+
+  resets:
+    maxItems: 1
+
+  "#pwm-cells":
+    const: 3
+
+patternProperties:
+  "^fan-[0-9]+$":
+    $ref: fan-common.yaml#
+    unevaluatedProperties: false
+    required:
+      - tach-ch
+
+required:
+  - reg
+  - clocks
+  - resets
+  - "#pwm-cells"
+  - compatible
+
+additionalProperties: false
+
+examples:

Documentation/devicetree/bindings/hwmon/aspeed,g6-pwm-tach.yaml line 62

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

I assume there's a PWM connection here? How do you know which PWM? You said the tach channel is independent, so it is not that.

Quoted 4 lines

It should not be 0 from 'fan-0' because that's just a meaningless index.

You either need 'pwms' here or you can use 'reg' and the reg value is the PWM channel.

Hi Rob, this binding is used to export the PWM provider and the Fan monitor (i.e., Tach). If the user wants to add the PWM connection for the fan, it can be done as follows:

fan0: pwm-fan0 {
        compatible = "pwm-fan";
        pwms = <&pwm_tach 0 40000 0>;
        cooling-min-state = <0>;
        cooling-max-state = <3>;
        #cooling-cells = <2>;
        cooling-levels = <0 15 128 255>;
};
Quoted 5 lines
Quoted 1 line

This will reuse the existing PWM fan driver (e.g., pwm-fan.c).

I'm confused now. So what are the child nodes you have? You are defining the fan in 2 places? The "pwm-fan" driver supports a tach via an interrupt, so how would this work in your case?

Hi Rob,

The tach interrupt for the pwm-fan is option. In our case, the dts just reuse the pwm control function of the pwm-fan, and the part of the tach monitor will be created by our fan child nodes. So the dts will like followings:

// Use to declare the tach monitor for fan.

&pwm_tach {
        fan-0 {
                tach-ch = /bits/ 8 <0x0>;
        };
        fan-1 {
                tach-ch = /bits/ 8 <0x1>;
        };
        ...
}

// Reuse the pwm-fan.c to control the behavior of the PWM for fan.

Quoted 8 lines
fan0: pwm-fan0 {
        compatible = "pwm-fan";
        pwms = <&pwm_tach 0 40000 0>;   /* Target freq:25 kHz */
        cooling-min-state = <0>;
        cooling-max-state = <3>;
        #cooling-cells = <2>;
        cooling-levels = <0 15 128 255>;
};

No, you can't have a fan described by 2 different nodes. Can't you just merge everything from the pwm-fan0 node into the fan-0 node?

Rob

author reviewer
#10 lore raw

PATCH RESEND v10 3/3 hwmon: (aspeed-g6-pwm-tacho): Support for ASPEED g6 PWM/Fan tach

In reply to Billy Tsai

The driver support two functions: PWM and Tachometer. The PWM feature can handle up to 16 output ports, while the Tachometer can monitor to up to 16 input ports as well. This driver implements them by exposing two kernel
subsystems: PWM and HWMON. The PWM subsystem can be utilized alongside existing drivers for controlling elements such as fans (pwm-fan.c), beepers (pwm-beeper.c) and so on. Through the HWMON subsystem, the driver provides sysfs interfaces for fan.

---
 Documentation/hwmon/aspeed-g6-pwm-tach.rst |  26 +
 Documentation/hwmon/index.rst              |   1 +
 drivers/hwmon/Kconfig                      |  11 +
 drivers/hwmon/Makefile                     |   1 +
 drivers/hwmon/aspeed-g6-pwm-tach.c         | 539 +++++++++++++++++++++
 5 files changed, 578 insertions(+)
 create mode 100644 Documentation/hwmon/aspeed-g6-pwm-tach.rst
 create mode 100644 drivers/hwmon/aspeed-g6-pwm-tach.c
Documentation/hwmon/aspeed-g6-pwm-tach.rst new file +26 -0
new file mode 100644
index 000000000000..17398fe397fe
@@ -0,0 +1,26 @@
+.. SPDX-License-Identifier: GPL-2.0-or-later
+
+Kernel driver aspeed-g6-pwm-tach
+=================================
+
+Supported chips:
+	ASPEED AST2600
+
+Authors:
+	<[email protected]>
+
+Description:
+------------
+This driver implements support for ASPEED AST2600 Fan Tacho controller.
+The controller supports up to 16 tachometer inputs.
+
+The driver provides the following sensor accesses in sysfs:
+
+=============== ======= ======================================================
+fanX_input	ro	provide current fan rotation value in RPM as reported
+			by the fan to the device.
+fanX_div	rw	Fan divisor: Supported value are power of 4 (1, 4, 16
+                        64, ... 4194304)
+                        The larger divisor, the less rpm accuracy and the less
+                        affected by fan signal glitch.
+=============== ======= ======================================================
Documentation/hwmon/index.rst +1 -0
index 042e1cf9501b..75b869ff6c53 100644
@@ -44,6 +44,7 @@ Hardware Monitoring Kernel Drivers
    aquacomputer_d5next
    asb100
    asc7621
+   aspeed-g6-pwm-tach
    aspeed-pwm-tacho
    asus_ec_sensors
    asus_wmi_sensors
drivers/hwmon/Kconfig +11 -0
index 307477b8a371..75fbea7e81e2 100644
@@ -412,6 +412,17 @@ config SENSORS_ASPEED
 	  This driver can also be built as a module. If so, the module
 	  will be called aspeed_pwm_tacho.
 
+config SENSORS_ASPEED_G6
+	tristate "ASPEED g6 PWM and Fan tach driver"
+	depends on ARCH_ASPEED || COMPILE_TEST
+	depends on PWM
+	help
+	  This driver provides support for ASPEED G6 PWM and Fan Tach
+	  controllers.
+
+	  This driver can also be built as a module. If so, the module
+	  will be called aspeed_pwm_tacho.
+
 config SENSORS_ATXP1
 	tristate "Attansic ATXP1 VID controller"
 	depends on I2C
drivers/hwmon/Makefile +1 -0
index 3f4b0fda0998..51de5c1d5f1e 100644
@@ -55,6 +55,7 @@ obj-$(CONFIG_SENSORS_ARM_SCPI)	+= scpi-hwmon.o
 obj-$(CONFIG_SENSORS_AS370)	+= as370-hwmon.o
 obj-$(CONFIG_SENSORS_ASC7621)	+= asc7621.o
 obj-$(CONFIG_SENSORS_ASPEED)	+= aspeed-pwm-tacho.o
+obj-$(CONFIG_SENSORS_ASPEED_G6) += aspeed-g6-pwm-tach.o
 obj-$(CONFIG_SENSORS_ATXP1)	+= atxp1.o
 obj-$(CONFIG_SENSORS_AXI_FAN_CONTROL) += axi-fan-control.o
 obj-$(CONFIG_SENSORS_BT1_PVT)	+= bt1-pvt.o
drivers/hwmon/aspeed-g6-pwm-tach.c new file +539 -0

539 lines not on this page · raw message

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

Unlike the old design that the register setting of the TACH should based on the configure of the PWM. In ast26xx, the dependency between pwm and tach controller is eliminated and becomes a separate hardware block. One is used to provide pwm output and another is used to monitor the frequency of the input. This driver implements them by exposing two kernel
subsystems: PWM and HWMON. The PWM subsystem can be utilized alongside existing drivers for controlling elements such as fans (pwm-fan.c), beepers (pwm-beeper.c) and so on. Through the HWMON subsystem, the driver provides sysfs interfaces for fan.

Quoted 4 lines

Changes since v9:
Change the type of fan-driving-mode to string
Fix some typos and formatting issues.

What is the resend about ?

Guenter

A message that is not in the archive (sent off-list or not yet received): SG2PR06MB33658A0B3EA8FD0870D8AC388BA8A@SG2PR06MB3365.apcprd06.prod.outlook.com

maintainer
#13 lore raw
Quoted 16 lines · Billy Tsai
Quoted 14 lines · Billy Tsai
Quoted 14 lines

Unlike the old design that the register setting of the TACH should based on the configure of the PWM. In ast26xx, the dependency between pwm and tach controller is eliminated and becomes a separate hardware block. One is used to provide pwm output and another is used to monitor the frequency of the input. This driver implements them by exposing two kernel
subsystems: PWM and HWMON. The PWM subsystem can be utilized alongside existing drivers for controlling elements such as fans (pwm-fan.c), beepers (pwm-beeper.c) and so on. Through the HWMON subsystem, the driver provides sysfs interfaces for fan.

Changes since v9:
Change the type of fan-driving-mode to string
Fix some typos and formatting issues.

Quoted 7 lines
Quoted 1 line

What is the resend about ?

Hi Guenter,

The reason for the resend is simply to remove the 'Change-Id' in the commit log, which will get the error for running scripts/checkpatch.pl.

You should mention that in the change log, and please _never_ drop the mailing list from your replies.

Thanks,
Guenter

#14 lore raw
In reply to Guenter Roeck
Quoted 11 lines · Guenter Roeck
Quoted 10 lines · Billy Tsai

Unlike the old design that the register setting of the TACH should based on the configure of the PWM. In ast26xx, the dependency between pwm and tach controller is eliminated and becomes a separate hardware block. One is used to provide pwm output and another is used to monitor the frequency of the input. This driver implements them by exposing two kernel
subsystems: PWM and HWMON. The PWM subsystem can be utilized alongside existing drivers for controlling elements such as fans (pwm-fan.c), beepers (pwm-beeper.c) and so on. Through the HWMON subsystem, the driver provides sysfs interfaces for fan.

Quoted 6 lines
Quoted 4 lines

Changes since v9:
Change the type of fan-driving-mode to string
Fix some typos and formatting issues.

What is the resend about ?

And to the original v10 there is a reply by Krzysztof;
see https://lore.kernel.org/linux-pwm/3d9e50db-19f0-43b3-8042-2f80a1e7b79e at linaro.org/ .

I'll mark the original and this resend as "changes-requested" in our patchwork. Probably the most cooperative way to object is to send a v11 and point out the changes compared to v10.

Best regards
Uwe

Signature · 9 lines
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.ozlabs.org/pipermail/linux-aspeed/attachments/20231206/03a10a77/attachment.sig>
#15 lore raw
Quoted 17 lines · Uwe Kleine-K?nig
Quoted 16 lines · Guenter Roeck
Quoted 14 lines · Billy Tsai

Unlike the old design that the register setting of the TACH should based on the configure of the PWM. In ast26xx, the dependency between pwm and tach controller is eliminated and becomes a separate hardware block. One is used to provide pwm output and another is used to monitor the frequency of the input. This driver implements them by exposing two kernel
subsystems: PWM and HWMON. The PWM subsystem can be utilized alongside existing drivers for controlling elements such as fans (pwm-fan.c), beepers (pwm-beeper.c) and so on. Through the HWMON subsystem, the driver provides sysfs interfaces for fan.

Changes since v9:
Change the type of fan-driving-mode to string
Fix some typos and formatting issues.

Quoted 8 lines
Quoted 1 line

What is the resend about ?

And to the original v10 there is a reply by Krzysztof;
see https://lore.kernel.org/linux-pwm/3d9e50db-19f0-43b3-8042-2f80a1e7b79e at linaro.org/ .

I'll mark the original and this resend as "changes-requested" in our patchwork. Probably the most cooperative way to object is to send a v11 and point out the changes compared to v10.

The resend might be fixing issues from v10, but who knows which and how many. In any case it should be v11, not a resend.

Best regards,
Krzysztof

author reviewer
#16 lore raw
Quoted 22 lines · Uwe Kleine-K?nig
Quoted 22 lines · Guenter Roeck
Quoted 11 lines · Billy Tsai
Quoted 10 lines

Unlike the old design that the register setting of the TACH should based on the configure of the PWM. In ast26xx, the dependency between pwm and tach controller is eliminated and becomes a separate hardware block. One is used to provide pwm output and another is used to monitor the frequency of the input. This driver implements them by exposing two kernel
subsystems: PWM and HWMON. The PWM subsystem can be utilized alongside existing drivers for controlling elements such as fans (pwm-fan.c), beepers (pwm-beeper.c) and so on. Through the HWMON subsystem, the driver provides sysfs interfaces for fan.

Quoted 6 lines
Quoted 4 lines

Changes since v9:
Change the type of fan-driving-mode to string
Fix some typos and formatting issues.

What is the resend about ?

And to the original v10 there is a reply by Krzysztof;
see https://lore.kernel.org/linux-pwm/3d9e50db-19f0-43b3-8042-2f80a1e7b79e at linaro.org/ .

Quoted 6 lines
Quoted 3 lines

I'll mark the original and this resend as "changes-requested" in our patchwork. Probably the most cooperative way to object is to send a v11 and point out the changes compared to v10.

The resend might be fixing issues from v10, but who knows which and how many. In any case it should be v11, not a resend.

I apologize for responding to this question inappropriately. I only replied to Guenter and removed the others.
The reason for the resend is simply to remove the 'Change-Id' in the commit log, which triggers an error when running scripts/checkpatch.pl.
It's a minor issue, and I forgot to mention this change in the cover letter.
I sincerely apologize for any confusion.

Best regards,
Billy Tsai