Support for ASPEED AST2400/AST2500 PWM and Fan Tach driver
v4 cover Support for ASPEED AST2400/AST2500 PWM and Fan Tach driver
Support for ASPEED AST2400/AST2500 PWM and Fan Tach driver.
Patches based on the upstream tag 4.9. Changes made in Version 4 are indicated in the individual patches.
The AST2400/AST2500 PWM controller can support 8 PWM output ports. The AST2400/AST2500 Fan Tach controller can support 16 tachometer inputs. The hwmon driver provides sysfs entries through which the user can configure the duty cycle for the particular PWM output port and read the fan rpm value for the particular tachometer input.
Added devicetree binding documentation for AST2400/AST2500 PWM and Fan Tach support.
Tested on Zaius board (which has AST2500 chip) and observed that when duty cycle is lowered then the fan speed is lowered and lower fan rpm value( corresponding to the duty cycle) is reported and when the duty cycle is increased then the fan speed increases and higher fan rpm value(corresponding to the duty cycle) is reported.
Jaghathiswari Rankappagounder Natarajan (2):
Documentation: dt-bindings: Document bindings for ASPEED
AST2400/AST2500 PWM and Fan tach controller device driver
drivers: hwmon: Support for ASPEED PWM/Fan tach
.../devicetree/bindings/hwmon/aspeed-pwm-tacho.txt | 86 ++ Documentation/hwmon/aspeed-pwm-tacho | 22 + drivers/hwmon/Kconfig | 9 + drivers/hwmon/Makefile | 1 + drivers/hwmon/aspeed-pwm-tacho.c | 866 +++++++++++++++++++++ 5 files changed, 984 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/aspeed-pwm-tacho.txt create mode 100644 Documentation/hwmon/aspeed-pwm-tacho create mode 100644 drivers/hwmon/aspeed-pwm-tacho.c
--
2.12.0.246.ga2ecc84866-goog
PATCH v4 1/2 Documentation: dt-bindings: Document bindings for ASPEED AST2400/AST2500 PWM and Fan tach controller device driver
This binding provides interface for adding values related to ASPEED AST2400/2500 PWM and Fan tach controller support.
The PWM controller can support upto 8 PWM output ports. The Fan tach controller can support upto 16 tachometer inputs.
---
v4:
- Used 'reg'
v3:
- Made the structure more common
v2:
- Removed '_' in node and property names
- Gave some explanation for the properties used
.../devicetree/bindings/hwmon/aspeed-pwm-tacho.txt | 86 ++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/aspeed-pwm-tacho.txt
Documentation/devicetree/bindings/hwmon/aspeed-pwm-tacho.txt new file +86 -0
@@ -0,0 +1,86 @@ +ASPEED AST2400/AST2500 PWM and Fan Tacho controller device driver + +The ASPEED PWM controller can support upto 8 PWM outputs. The ASPEED Fan Tacho +controller can support upto 16 Fan tachometer inputs. + +There can be upto 8 fans supported. Each fan can have one PWM output and +one/two Fan tach inputs. + +Required properties for pwm-tacho node: +- #address-cells : should be 1. + +- #size-cells : should be 1. + +- reg : address and length of the register set for the device. + +- pinctrl-names : a pinctrl state named "default" must be defined. + +- pinctrl-0 : phandle referencing pin configuration of the PWM ports. + +- compatible : should be "aspeed,aspeed2400-pwm-tacho" for AST2400 or + "aspeed,aspeed2500-pwm-tacho" for AST2500. + +- clocks : a fixed clock providing input clock frequency(PWM + and Fan Tach clock) + +fan subnode format: +=================== +Under fan subnode there can upto 8 child nodes, with each child node +representing a fan. If there are 8 fans each fan can have one PWM port and +one/two Fan tach inputs. + +Required properties for each child node: +- reg : should specify PWM source port. + integer value in the range 0 to 7 with 0 indicating PWM port A and + 7 indicating PWM port H. + + Atleast one tach subnode is required. Each tach subnode represents a fan + tach input. + tach subnode format: + -------------------- + Required properties for each child node: + - fan-ctrl-gpios : should specify the tachometer input GPIO pin on the hardware. + Fan Tachometer function can only work when GPIO is in + ”input mode”. + + - fan-tach-ch : should specify the Fan tach input channel. + integer value in the range 0 through 15, with 0 indicating + Fan tach channel 0 and 15 indicating Fan tach channel 15. + +Examples: + +pwmtachofixedclk: fixedclk { + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-frequency = <24000000>; +} + +pwmtacho: pwmtachocontroller@1e786000 { + #address-cells = <1>; + #size-cells = <1>; + reg = <0x1E786000 0x1000>; + compatible = "aspeed,aspeed2500-pwm-tacho"; + clocks = <&pwmtachofixedclk>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_pwm0_default &pinctrl_pwm1_default>; + + fan0 { + reg = /bits/ 8 <0x00>; + tach0 { + fan-ctrl-gpios = <&gpio ASPEED_GPIO(O, 0) GPIO_ACTIVE_HIGH>; + fan-tach-ch = /bits/ 8 <0x00>; + }; + }; + + fan1 { + reg = /bits/ 8 <0x01>; + tach0 { + fan-ctrl-gpios = <&gpio ASPEED_GPIO(O, 1) GPIO_ACTIVE_HIGH>; + fan-tach-ch = /bits/ 8 <0x01>; + }; + tach1 { + fan-ctrl-gpios = <&gpio ASPEED_GPIO(O, 2) GPIO_ACTIVE_HIGH>; + fan-tach-ch = /bits/ 8 <0x02>; + }; + }; +};
--
2.12.0.246.ga2ecc84866-goog
Re: [PATCH linux v4 1/2] Documentation: dt-bindings: Document bindings for ASPEED AST2400/AST2500 PWM and Fan tach controller device driver
Hello
Quoted 2 lines · Jaghathiswari Rankappagounder Natarajan
+- compatible : should be "aspeed,aspeed2400-pwm-tacho" for AST2400 or + "aspeed,aspeed2500-pwm-tacho" for AST2500.
Shouldn't this be "aspeed,ast2400-pwm-tacho" and "aspeed,ast2500-pwm-tacho", as this is the naming scheme used for all the other AST2x00 devices currently present in "aspeed-g[45].dtsi"?
Dave
Rob Herring
maintainerRe: [PATCH linux v4 1/2] Documentation: dt-bindings: Document bindings for ASPEED AST2400/AST2500 PWM and Fan tach controller device driver
In reply to Jaghathiswari Rankappagounder NatarajanQuoted 61 lines · Jaghathiswari Rankappagounder Natarajan
This binding provides interface for adding values related to ASPEED AST2400/2500 PWM and Fan tach controller support.
The PWM controller can support upto 8 PWM output ports. The Fan tach controller can support upto 16 tachometer inputs.---
v4:
- Used 'reg'v3:
- Made the structure more commonv2:
- Removed '_' in node and property names
- Gave some explanation for the properties used.../devicetree/bindings/hwmon/aspeed-pwm-tacho.txt | 86 ++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/aspeed-pwm-tacho.txtDocumentation/devicetree/bindings/hwmon/aspeed-pwm-tacho.txt new file +34
-0@@ -0,0 +1,86 @@ +ASPEED AST2400/AST2500 PWM and Fan Tacho controller device driver + +The ASPEED PWM controller can support upto 8 PWM outputs. The ASPEED Fan Tacho +controller can support upto 16 Fan tachometer inputs. + +There can be upto 8 fans supported. Each fan can have one PWM output and +one/two Fan tach inputs. + +Required properties for pwm-tacho node: +- #address-cells : should be 1. + +- #size-cells : should be 1. + +- reg : address and length of the register set for the device. + +- pinctrl-names : a pinctrl state named "default" must be defined. + +- pinctrl-0 : phandle referencing pin configuration of the PWM ports. + +- compatible : should be "aspeed,aspeed2400-pwm-tacho" for AST2400 or + "aspeed,aspeed2500-pwm-tacho" for AST2500. + +- clocks : a fixed clock providing input clock frequency(PWM + and Fan Tach clock) + +fan subnode format: +=================== +Under fan subnode there can upto 8 child nodes, with each child node +representing a fan. If there are 8 fans each fan can have one PWM port and +one/two Fan tach inputs. + +Required properties for each child node: +- reg : should specify PWM source port. + integer value in the range 0 to 7 with 0 indicating PWM port A and
Documentation/devicetree/bindings/hwmon/aspeed-pwm-tacho.txt line 44
Quoted 10 lines
Documentation/devicetree/bindings/hwmon/aspeed-pwm-tacho.txt new file +10
-0+ 7 indicating PWM port H. + + Atleast one tach subnode is required. Each tach subnode represents a fan + tach input. + tach subnode format: + -------------------- + Required properties for each child node: + - fan-ctrl-gpios : should specify the tachometer input GPIO pin on the hardware. + Fan Tachometer function can only work when GPIO is in + ”input mode”.
As I mentioned on the last version, this sounds like pin-muxing, not actual GPIO usage.
Documentation/devicetree/bindings/hwmon/aspeed-pwm-tacho.txt line 48
Quoted 4 lines
Documentation/devicetree/bindings/hwmon/aspeed-pwm-tacho.txt new file +4
-0+ + - fan-tach-ch : should specify the Fan tach input channel. + integer value in the range 0 through 15, with 0 indicating + Fan tach channel 0 and 15 indicating Fan tach channel 15.
These 2 also need aspeed vendor prefixes.
This could become a property under the fan node as a list of tach channels if fan-ctrl-gpios goes away.
Quoted 9 lines
Documentation/devicetree/bindings/hwmon/aspeed-pwm-tacho.txt new file +9
-0+ +Examples: + +pwmtachofixedclk: fixedclk { + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-frequency = <24000000>; +} +
Documentation/devicetree/bindings/hwmon/aspeed-pwm-tacho.txt line 67
Quoted 10 lines
Documentation/devicetree/bindings/hwmon/aspeed-pwm-tacho.txt new file +10
-0+pwmtacho: pwmtachocontroller@1e786000 { + #address-cells = <1>; + #size-cells = <1>; + reg = <0x1E786000 0x1000>; + compatible = "aspeed,aspeed2500-pwm-tacho"; + clocks = <&pwmtachofixedclk>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_pwm0_default &pinctrl_pwm1_default>; + + fan0 {
fan@0
Documentation/devicetree/bindings/hwmon/aspeed-pwm-tacho.txt line 68
Quoted 1 line
Documentation/devicetree/bindings/hwmon/aspeed-pwm-tacho.txt new file +1
-0+ reg = /bits/ 8 <0x00>;
reg is 32-bits.
Documentation/devicetree/bindings/hwmon/aspeed-pwm-tacho.txt line 75
Quoted 7 lines
Documentation/devicetree/bindings/hwmon/aspeed-pwm-tacho.txt new file +7
-0+ tach0 { + fan-ctrl-gpios = <&gpio ASPEED_GPIO(O, 0) GPIO_ACTIVE_HIGH>; + fan-tach-ch = /bits/ 8 <0x00>; + }; + }; + + fan1 {
fan@1
Quoted 14 lines
Documentation/devicetree/bindings/hwmon/aspeed-pwm-tacho.txt new file +11
-1+ reg = /bits/ 8 <0x01>; + tach0 { + fan-ctrl-gpios = <&gpio ASPEED_GPIO(O, 1) GPIO_ACTIVE_HIGH>; + fan-tach-ch = /bits/ 8 <0x01>; + }; + tach1 { + fan-ctrl-gpios = <&gpio ASPEED_GPIO(O, 2) GPIO_ACTIVE_HIGH>; + fan-tach-ch = /bits/ 8 <0x02>; + }; + }; +}; --2.12.0.246.ga2ecc84866-goog
PATCH v4 2/2 drivers: hwmon: Support for ASPEED PWM/Fan tach
In reply to Jaghathiswari Rankappagounder NatarajanThe ASPEED AST2400/2500 PWM controller supports 8 PWM output ports. The ASPEED AST2400/2500 Fan tach controller supports 16 tachometer inputs. The device driver matches on the device tree node. The configuration values are read from the device tree and written to the respective registers. The driver provides a sysfs entries through which the user can configure the duty-cycle value (ranging from 0 to 100 percent) and read the fan tach rpm value.
---
v4:
- Modified this driver to suit the representation in the devicetree
v3:
- Only sent out device tree documentation; did not send this driver
v2:
- Used BIT()
- Used regmap
- Avoided division when raw data is 0
- Removed empty lines between declaration
- Removed macros; Used two attribute groups and used is_visible callback
- Returned error when properties are undefined
- Removed .owner field
- Used PTR_ERR_OR_ZERO
- Removed explicit of_node_put for child nodes
Documentation/hwmon/aspeed-pwm-tacho | 22 + drivers/hwmon/Kconfig | 9 + drivers/hwmon/Makefile | 1 + drivers/hwmon/aspeed-pwm-tacho.c | 866 +++++++++++++++++++++++++++++++++++ 4 files changed, 898 insertions(+) create mode 100644 Documentation/hwmon/aspeed-pwm-tacho create mode 100644 drivers/hwmon/aspeed-pwm-tacho.c
Documentation/hwmon/aspeed-pwm-tacho new file +22 -0
@@ -0,0 +1,22 @@ +Kernel driver aspeed-pwm-tacho +============================== + +Supported chips: + ASPEED AST2400/2500 + +Authors: + <[email protected]> + +Description: +------------ +This driver implements support for ASPEED AST2400/2500 PWM and Fan Tacho +controller. The PWM controller supports upto 8 PWM outputs. The Fan tacho +controller supports upto 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. + +pwmX rw get or set PWM fan control value. This is an integer + value between 0(off) and 255(full speed).
drivers/hwmon/Kconfig +9 -0
@@ -341,6 +341,15 @@ config SENSORS_ASB100 This driver can also be built as a module. If so, the module will be called asb100. +config SENSORS_ASPEED + tristate "ASPEED AST2400/AST2500 PWM and Fan tach driver" + help + This driver provides support for ASPEED AST2400/AST2500 PWM + and Fan Tacho 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
@@ -46,6 +46,7 @@ obj-$(CONFIG_SENSORS_ADT7475) += adt7475.o obj-$(CONFIG_SENSORS_APPLESMC) += applesmc.o obj-$(CONFIG_SENSORS_ARM_SCPI) += scpi-hwmon.o obj-$(CONFIG_SENSORS_ASC7621) += asc7621.o +obj-$(CONFIG_SENSORS_ASPEED) += aspeed-pwm-tacho.o obj-$(CONFIG_SENSORS_ATXP1) += atxp1.o obj-$(CONFIG_SENSORS_CORETEMP) += coretemp.o obj-$(CONFIG_SENSORS_DA9052_ADC)+= da9052-hwmon.o
drivers/hwmon/aspeed-pwm-tacho.c new file +866 -0
866 lines not on this page · raw message
--
2.12.0.246.ga2ecc84866-goog