Support pwm/tach driver for aspeed ast26xx
Subsystems (5)
Billy Tsai
reviewerv14 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 v13:
Restore Rob's "Reviewed-by" for fan-common.yaml.
Remove the compatible string in the dts example in aspeed,g6-pwm-tach.yaml. Utilize devm_add_action_or_reset() to assert the reset.
Resolve the compiler error.
Changes since v12:
Merge the pwm-fan configure information into the fan node. Add the of_platform_populate function to the driver to treat the child node as a platform device.
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 | 71 +++ .../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 | 549 ++++++++++++++++++ 7 files changed, 738 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
Billy Tsai
reviewerPATCH v14 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
@@ -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
Re: [PATCH v14 1/3] dt-bindings: hwmon: fan: Add fan binding to schema
Quoted 10 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:
Quoted 8 lines
"^fan@[0-2]": type: object $ref: fan-common.yaml# unevaluatedProperties: falseReviewed-by Rob Herring <[email protected]>Signed-off-by Naresh Solanki <[email protected]>Signed-off-by Billy Tsai <[email protected]>
Applied to hwmon-next. There have been a couple of questions, specifically:
- min-rpm of 1000 seems low. Fans with higher minimum RPM are known to exist.
- A default value of '2' was suggested for pulses-per-revolution.
Those questions can be addressed with subsequent patches if needed.
Guenter
Billy Tsai
reviewerPATCH v14 2/3 dt-bindings: hwmon: Support Aspeed g6 PWM TACH Control
In reply to Billy TsaiDocument 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 | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/aspeed,g6-pwm-tach.yaml
Documentation/devicetree/bindings/hwmon/aspeed,g6-pwm-tach.yaml new file +71 -0
@@ -0,0 +1,71 @@ +# 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>; + pwms = <&pwm_tach 0 40000 0>; + }; + + fan-1 { + tach-ch = /bits/ 8 <0x1 0x2>; + pwms = <&pwm_tach 1 40000 0>; + }; + };
Signature · 1 line
2.25.1
Re: [PATCH v14 2/3] dt-bindings: hwmon: Support Aspeed g6 PWM TACH Control
Quoted 9 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.
Signed-off-by Billy Tsai <[email protected]>--- .../bindings/hwmon/aspeed,g6-pwm-tach.yaml | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/aspeed,g6-pwm-tach.yaml
Re: [PATCH v14 2/3] dt-bindings: hwmon: Support Aspeed g6 PWM TACH Control
In reply to Billy TsaiQuoted 5 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.
Signed-off-by Billy Tsai <[email protected]>Reviewed-by Rob Herring <[email protected]>
Applied.
Thanks,
Guenter
Billy Tsai
reviewerPATCH v14 3/3 hwmon: (aspeed-g6-pwm-tacho): Support for ASPEED g6 PWM/Fan tach
In reply to Billy TsaiThe 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 | 549 +++++++++++++++++++++ 5 files changed, 588 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
@@ -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
@@ -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
@@ -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
@@ -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 +549 -0
549 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [PATCH v14 3/3] hwmon: (aspeed-g6-pwm-tacho): Support for ASPEED g6 PWM/Fan tach
Quoted 19 lines · 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.Signed-off-by Billy Tsai <[email protected]>--- 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 | 549 +++++++++++++++++++++ 5 files changed, 588 insertions(+) create mode 100644 Documentation/hwmon/aspeed-g6-pwm-tach.rst create mode 100644 drivers/hwmon/aspeed-g6-pwm-tach.c
[...]
Quoted 6 lines
drivers/hwmon/aspeed-g6-pwm-tach.c new file +0
-0@@ -0,0 +1,549 @@
[...]
Quoted 9 lines
drivers/hwmon/aspeed-g6-pwm-tach.c new file +9
-0+static void aspeed_pwm_tach_reset_assert (void *data) +{ +struct reset_control *rst = data; + +reset_control_assert (rst); +} + +static int aspeed_pwm_tach_probe (struct platform_device *pdev) +{
[...]
Quoted 11 lines
drivers/hwmon/aspeed-g6-pwm-tach.c new file +11
-0+ priv->reset =devm_reset_control_get_exclusive (dev,NULL ); +if (IS_ERR (priv->reset)) +return dev_err_probe (dev,PTR_ERR (priv->reset), +"Couldn't get reset control\n" ); + + ret =reset_control_deassert (priv->reset); +if (ret) +return dev_err_probe (dev, ret, +"Couldn't deassert reset control\n" ); + ret =devm_add_action_or_reset (dev, aspeed_pwm_tach_reset_assert, + priv->reset);
[...]
drivers/hwmon/aspeed-g6-pwm-tach.c line 523
Quoted 7 lines
drivers/hwmon/aspeed-g6-pwm-tach.c new file +7
-0+} + +static int aspeed_pwm_tach_remove (struct platform_device *pdev) +{ +struct aspeed_pwm_tach_data *priv =platform_get_drvdata (pdev); + +reset_control_assert (priv->reset);
This is already done by aspeed_pwm_tach_reset_assert(), looks like aspeed_pwm_tach_remove() can be removed. With that, priv->reset can become a local variable in aspeed_pwm_tach_probe().
regards
Philipp
Re: [PATCH v14 3/3] hwmon: (aspeed-g6-pwm-tacho): Support for ASPEED g6 PWM/Fan tach
In reply to Billy TsaiQuoted 9 lines · 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.Signed-off-by Billy Tsai <[email protected]>
Applied to hwmon-next. There was an outstanding suggestion:
Quoted 9 lines
drivers/hwmon/aspeed-g6-pwm-tach.c line 523
Quoted 5 lines
drivers/hwmon/aspeed-g6-pwm-tach.c new file +5
-0+static int aspeed_pwm_tach_remove (struct platform_device *pdev) +{ +struct aspeed_pwm_tach_data *priv =platform_get_drvdata (pdev); + +reset_control_assert (priv->reset);This is already done by
aspeed_pwm_tach_reset_assert(), looks likeaspeed_pwm_tach_remove()can be removed. With that,priv->resetcan become a local variable inaspeed_pwm_tach_probe().
I'll be happy to apply a follow-up patch making this change.
Thanks,
Guenter