Skip to contentSkip to conversation

Support pwm/tach driver for aspeed ast26xx

PATCH Superseded Billy Tsai 3 participants 12 messages Jan 8, 2024 – Jan 16, 2024

Subsystems (5)

v12 of 14 Superseded Latest is v14 →

lore
Share & tools
lore

Billy Tsai

author reviewer
#0 lore raw

v12 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 v11:
Fix the compiler error of the driver.
The owner member has to be moved to struct pwm_chip.

Changes since v10:
Add the enum for the 'fan-driving-mode' properties in the fan-common.yaml.

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 |  79 +++
 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            | 538 ++++++++++++++++++
 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 v12 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 | 79 +++++++++++++++++++
 1 file changed, 79 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/hwmon/fan-common.yaml
Documentation/devicetree/bindings/hwmon/fan-common.yaml new file +79 -0
new file mode 100644
index 000000000000..0fb738081699
@@ -0,0 +1,79 @@
+# 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
+    enum: [ dc, pwm ]
+
+  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 v12 1/3
#2 lore raw

Re: [PATCH v12 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 7 lines
---
 .../devicetree/bindings/hwmon/fan-common.yaml | 79 +++++++++++++++++++
 1 file changed, 79 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/hwmon/fan-common.yaml
#3 lore raw

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

In reply to Billy Tsai
Quoted 7 lines · Billy Tsai
Documentation/devicetree/bindings/hwmon/fan-common.yaml new file +7 -0
+  pwms:
+    description:
+      PWM provider.
+    maxItems: 1
+
+  "#cooling-cells":
+    const: 2

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

Quoted 10 lines
Documentation/devicetree/bindings/hwmon/fan-common.yaml new file +10 -0
+
+  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

What is the tach-channel and why is it different from pwm specifier?

Best regards,
Krzysztof

author reviewer
#4 lore raw

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

Quoted 11 lines
Quoted 11 lines
Documentation/devicetree/bindings/hwmon/fan-common.yaml new file +11 -0
+  pwms:
+    description:
+      PWM provider.
+    maxItems: 1
+
+  "#cooling-cells":
+    const: 2
+
+  cooling-levels:
+    description:
+      The control value which correspond to thermal cooling states.
Quoted 8 lines

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

Quoted 6 lines
Documentation/devicetree/bindings/hwmon/fan-common.yaml new file +6 -0
+    $ref: /schemas/types.yaml#/definitions/uint32-array
+
+  tach-ch:
+    description:
+      The tach channel used for the fan.
+    $ref: /schemas/types.yaml#/definitions/uint8-array

What is the tach-channel and why is it different from pwm specifier?

Hi Krzysztof,

Using the Aspeed SoC as an example, our SoC features 16 PWMs and 16 tachometer channels that can be employed to control and monitor fans. The "tach-ch" parameter is utilized to specify which tachometer channel is being used to monitor a specific fan. The "pwms" parameter is utilized to specify which pwm channel is being used to control a specific fan.

Thanks
Best regards,
Billy Tsai

author reviewer
#5 lore raw

PATCH v12 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
#6 lore raw

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

Quoted 73 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 +58 -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>;

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

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

NAK on this based on how you are using pwm-fan in v10 discussion. See my comments there.

Rob

author reviewer
#7 lore raw

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

Quoted 78 lines
Quoted 78 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 +63 -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>;
Quoted 8 lines

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

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

NAK on this based on how you are using pwm-fan in v10 discussion. See my comments there.

Okay, I will merge everything from the pwm-fan0 node into the fan-0 node and add the 'simple-bus' to the compatible string of the pwm_tach node.

Thanks

Billy Tsai

#8 lore raw

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

Quoted 21 lines · Billy Tsai
Quoted 12 lines
Quoted 12 lines
Documentation/devicetree/bindings/hwmon/aspeed,g6-pwm-tach.yaml new file +12 -0
+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>;
Quoted 8 lines

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

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

NAK on this based on how you are using pwm-fan in v10 discussion. See my comments there.

Quoted 2 lines

Okay, I will merge everything from the pwm-fan0 node into the fan-0 node and add the 'simple-bus' to the compatible string of the pwm_tach node.

What simple-bus has anything to do with it? This is not a bus. Just to
remind: we talk about bindings, not driver.

Best regards,
Krzysztof

author reviewer
#9 lore raw

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

Quoted 18 lines
Quoted 18 lines
Quoted 17 lines
Quoted 17 lines
Documentation/devicetree/bindings/hwmon/aspeed,g6-pwm-tach.yaml new file +17 -0
+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>;
+      };
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

NAK on this based on how you are using pwm-fan in v10 discussion. See my comments there.

Okay, I will merge everything from the pwm-fan0 node into the fan-0 node and add the 'simple-bus' to the compatible string of the pwm_tach node.

What simple-bus has anything to do with it? This is not a bus. Just to
remind: we talk about bindings, not driver.

Hi Krzysztof,

If I want to create a dt-binding to indicate that the child nodes should be treated as platform devices, which will be probed based on the compatible string, can I add "simple-bus" for our pwm_tach node like the following?

pwm_tach: pwm-tach-controller at 1e610000 {
        compatible = "aspeed,ast2600-pwm-tach", "simple-bus";
        reg = <0x1e610000 0x100>;
        clocks = <&syscon ASPEED_CLK_AHB>;
        resets = <&syscon ASPEED_RESET_PWM>;
        #pwm-cells = <3>;
  
        fan-0 {
          tach-ch = /bits/ 8 <0x0>;
          compatible = "pwm-fan";
          pwms = <&pwm_tach 0 40000 0>;
        };
  
        fan-1 {
          tach-ch = /bits/ 8 <0x1 0x2>;
          compatible = "pwm-fan";
          pwms = <&pwm_tach 1 40000 0>;
        };
      };

Or do you have any other suggestions for describing this in the dt-bindings?

Thanks

Billy Tsai.

#10 lore raw

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

Quoted 24 lines · Billy Tsai
Quoted 23 lines
Quoted 23 lines
Quoted 12 lines
Quoted 12 lines
Documentation/devicetree/bindings/hwmon/aspeed,g6-pwm-tach.yaml new file +12 -0
+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>;
Quoted 8 lines

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

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

NAK on this based on how you are using pwm-fan in v10 discussion. See my comments there.

Okay, I will merge everything from the pwm-fan0 node into the fan-0 node and add the 'simple-bus' to the compatible string of the pwm_tach node.

Quoted 7 lines
Quoted 2 lines

What simple-bus has anything to do with it? This is not a bus. Just to
remind: we talk about bindings, not driver.

Hi Krzysztof,

If I want to create a dt-binding to indicate that the child nodes should be treated as platform devices, which will be probed based on the

probed? Bindings do not probe. You ignored:
"we talk about bindings, not driver."

Quoted 2 lines

compatible string, can I add "simple-bus" for our pwm_tach node like the following?

No, because this is not a bus.

Quoted 19 lines
pwm_tach: pwm-tach-controller at 1e610000 {
        compatible = "aspeed,ast2600-pwm-tach", "simple-bus";
        reg = <0x1e610000 0x100>;
        clocks = <&syscon ASPEED_CLK_AHB>;
        resets = <&syscon ASPEED_RESET_PWM>;
        #pwm-cells = <3>;
  
        fan-0 {
          tach-ch = /bits/ 8 <0x0>;
          compatible = "pwm-fan";
          pwms = <&pwm_tach 0 40000 0>;
        };
  
        fan-1 {
          tach-ch = /bits/ 8 <0x1 0x2>;
          compatible = "pwm-fan";
          pwms = <&pwm_tach 1 40000 0>;
        };
      };
Quoted 1 line

Or do you have any other suggestions for describing this in the dt-bindings?

There is no need to describe it in the bindings. The existing compatible describes it sufficiently. Your pwms now duplicate the tach-ch... I don't understand what you want to achieve here in terms of hardware description (again, please steer away from talking about Linux drivers and probing, it's not related).

Best regards,
Krzysztof

author reviewer
#11 lore raw

PATCH v12 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         | 538 +++++++++++++++++++++
 5 files changed, 577 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 72f4e6065bae..f5ff380f7c9d 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 cf27523eed5a..546a47a5880b 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 e84bd9685b5c..92b150682828 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 +538 -0

538 lines not on this page · raw message

Signature · 1 line
2.25.1