hwmon: Add NPCM7xx PWM and Fan driver support
Tomer Maimon
maintainerv4 cover hwmon: Add NPCM7xx PWM and Fan driver support
This patch set adds Pulse Width Modulation (PWM) and Fan tacho support for the Nuvoton NPCM750/730/715/705 Baseboard Management Controller (BMC).
The Nuvoton BMC NPCM750/730/715/705 has two identical PWM controller modules, each module has four PWM controller outputs and eight identical Fan controller modules, each module has two Fan controller inputs.
The hwmon driver provides sysfs entries through which the user can configure and get the duty cycle between 0 (disable the specific PWM) to 255 of particular PWM output port.
The driver support cooling device creation, that could be bound to a thermal zone for the thermal control.
The NPCM750 PWM and Fan driver tested on NPCM750 evaluation board.
Addressed comments from:.
- Guenter Roeck: https://www.spinics.net/lists/devicetree/msg235294.html
Changes since version 3:
- Fixing incorrect word spelling.
- Removing npcm7xx_ in variable declarations.
- All variable declarations in structure on a single line.
- Removing variable unnecessary initialization.
- dt-binding documentation haven't changed.
Changes since version 2:
- Adding hwmon documentation
- Using dev_function instead pr_function
- Removing all typecast
- Removing unused definitions
- Adding () in macros parameters.
- dt-binding documentation haven't changed
Changes since version 1:
- Rename driver name
- Adding Fan Controller support
- Adding cooling device support
- Modifying dt-binding documentation for Fan and cooling binding
Tomer Maimon (2):
dt-binding: hwmon: Add NPCM7xx PWM and Fan controller documentation
hwmon: npcm750: add NPCM7xx PWM and Fan driver
.../devicetree/bindings/hwmon/npcm750-pwm-fan.txt | 84 ++ Documentation/hwmon/npcm750-pwm-fan | 22 + drivers/hwmon/Kconfig | 7 + drivers/hwmon/Makefile | 1 + drivers/hwmon/npcm750-pwm-fan.c | 1070 ++++++++++++++++++++ 5 files changed, 1184 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt create mode 100644 Documentation/hwmon/npcm750-pwm-fan create mode 100644 drivers/hwmon/npcm750-pwm-fan.c
Signature · 1 line
2.14.1
Tomer Maimon
maintainerPATCH v4 1/2 dt-binding: hwmon: Add NPCM7xx PWM and Fan controller documentation
Added device tree binding documentation for Nuvoton BMC NPCM7xx Pulse Width Modulation (PWM) and Fan tach controller. The PWM controller can support upto 8 PWM output ports. The Fan tach controller can support upto 16 tachometer inputs.
--- .../devicetree/bindings/hwmon/npcm750-pwm-fan.txt | 84 ++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt new file +84 -0
@@ -0,0 +1,84 @@ +Nuvoton NPCM7xx PWM and Fan Tacho controller device driver + +The NPCM7xx has two identical Pulse-width modulation (PWM) controller modules, +Each PWM module has four PWM controller outputs, Totally 8 PWM controller outputs. + +The NPCM7xx has eight identical Fan tachometer controller modules, +Each Fan module has two Fan controller inputs, Totally 16 Fan controller inputs. + +Required properties for pwm-fan node: +- compatible : "nuvoton,npcm750-pwm-fan" for Poleg NPCM7XX. +- reg : specifies physical base address and size of the registers. +- reg-names : must contain: + * "pwm-base" for the PWM registers. + * "fan-base" for the Fan registers. +- clocks : phandle of reference clocks. +- clock-names : must contain + * "clk_apb3" for clock of PWM controller. + * "clk_apb4" for clock of Fan controller. +- interrupts : contain the Fan interrupts with flags for falling edge. +- pinctrl-names : a pinctrl state named "default" must be defined. +- pinctrl-0 : phandle referencing pin configuration of the PWM and Fan + controller ports. + +pwm subnode format: +=================== +Under pwm subnode can be upto 8 child nodes, each child node representing a PWM channel. +Each pwm subnode must have one PWM channel and atleast one Fan tach channel. + +For PWM channel can be configured cooling-levels to create cooling device. +Cooling device could be bound to a thermal zone for the thermal control. + +Required properties for each child node: +- pwm-ch : specify the PWM output channel. + integer value in the range 0 through 7, that represent + the PWM channel number that used. + +- fan-ch : specify the Fan input channel. + integer value in the range 0 through 15, that represent + the Fan channel number that used. + + At least one Fan tach input channel is required + +Optional property for each child node: +- cooling-levels: PWM duty cycle values in a range from 0 to 255 + which correspond to thermal cooling states. + +Examples: + +pwm_fan:pwm_fan_controller@103000 { + compatible = "nuvoton,npcm750-pwm-fan"; + reg = <0x103000 0x2000>, + <0x180000 0x8000>; + reg-names = "pwm_base", "fan_base"; + clocks = <&clk NPCM7XX_CLK_APB3>, + <&clk NPCM7XX_CLK_APB4>; + clock-names = "clk_apb3","clk_apb4"; + interrupts = <GIC_SPI 96 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 97 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 98 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 99 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 100 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 101 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 102 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 103 IRQ_TYPE_LEVEL_HIGH>; + pinctrl-names = "default"; + pinctrl-0 = <&pwm0_pins &pwm1_pins &pwm2_pins + &fanin0_pins &fanin1_pins &fanin2_pins + &fanin3_pins &fanin4_pins>; + + pwm@0 { + pwm-ch = /bits/ 8 <0x00>; + fan-ch = /bits/ 8 <0x00 0x01>; + cooling-levels = <127 255>; + }; + pwm@1 { + pwm-ch = /bits/ 8 <0x01>; + fan-ch = /bits/ 8 <0x02 0x03>; + }; + pwm@2 { + pwm-ch = /bits/ 8 <0x02>; + fan-ch = /bits/ 8 <0x04>; + }; + +};
Signature · 1 line
2.14.1
Rob Herring
maintainerRe: [PATCH v4 1/2] dt-binding: hwmon: Add NPCM7xx PWM and Fan controller documentation
Quoted 17 lines · Tomer Maimon
Added device tree binding documentation for Nuvoton BMC NPCM7xx Pulse Width Modulation (PWM) and Fan tach controller. The PWM controller can support upto 8 PWM output ports. The Fan tach controller can support upto 16 tachometer inputs.
Signed-off-by Tomer Maimon <[email protected]>--- .../devicetree/bindings/hwmon/npcm750-pwm-fan.txt | 84 ++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txtDocumentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt new file +0
-0
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt line 1
Quoted 1 line
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt new file +1
-0@@ -0,0 +1,84 @@ +Nuvoton NPCM7xx PWM and Fan Tacho controller device driver
Bindings are for h/w, not drivers.
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt line 7
Quoted 6 lines
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt new file +6
-0+ +The NPCM7xx has two identical Pulse-width modulation (PWM) controller modules, +Each PWM module has four PWM controller outputs, Totally 8 PWM controller outputs. + +The NPCM7xx has eight identical Fan tachometer controller modules, +Each Fan module has two Fan controller inputs, Totally 16 Fan controller inputs.
Have you looked at other fan ctrlr bindings?f This looks like similar h/w to ASpeed. Really, I'd like to see a common doc that describes the structure and common properties.
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt line 14
Quoted 7 lines
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt new file +7
-0+ +Required properties for pwm-fan node: +- compatible : "nuvoton,npcm750-pwm-fan" for Poleg NPCM7XX. +- reg : specifies physical base address and size of the registers. +- reg-names : must contain: + * "pwm-base" for the PWM registers. + * "fan-base" for the Fan registers.
'-base' is redundant. And your example doesn't match.
Quoted 15 lines
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt new file +15
-0+- clocks : phandle of reference clocks. +- clock-names : must contain + * "clk_apb3" for clock of PWM controller. + * "clk_apb4" for clock of Fan controller. +- interrupts : contain the Fan interrupts with flags for falling edge. +- pinctrl-names : a pinctrl state named "default" must be defined. +- pinctrl-0 : phandle referencing pin configuration of the PWM and Fan + controller ports. + +pwm subnode format: +=================== +Under pwm subnode can be upto 8 child nodes, each child node representing a PWM channel. +Each pwm subnode must have one PWM channel and atleast one Fan tach channel. + +For PWM channel can be configured cooling-levels to create cooling device.
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt line 39
Quoted 10 lines
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt new file +10
-0+Cooling device could be bound to a thermal zone for the thermal control. + +Required properties for each child node: +- pwm-ch : specify the PWM output channel. + integer value in the range 0 through 7, that represent + the PWM channel number that used. + +- fan-ch : specify the Fan input channel. + integer value in the range 0 through 15, that represent + the Fan channel number that used.
This is really the tach channel.
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt line 49
Quoted 10 lines
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt new file +10
-0+ + At least one Fan tach input channel is required + +Optional property for each child node: +- cooling-levels: PWM duty cycle values in a range from 0 to 255 + which correspond to thermal cooling states. + +Examples: + +pwm_fan:pwm_fan_controller@103000 {
fan-controller@...
Quoted 11 lines
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt new file +11
-0+ compatible = "nuvoton,npcm750-pwm-fan"; + reg = <0x103000 0x2000>, + <0x180000 0x8000>; + reg-names = "pwm_base", "fan_base"; + clocks = <&clk NPCM7XX_CLK_APB3>, + <&clk NPCM7XX_CLK_APB4>; + clock-names = "clk_apb3","clk_apb4"; + interrupts = <GIC_SPI 96 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 97 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 98 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 99 IRQ_TYPE_LEVEL_HIGH>,
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt line 70
Quoted 10 lines
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt new file +10
-0+ <GIC_SPI 100 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 101 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 102 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 103 IRQ_TYPE_LEVEL_HIGH>; + pinctrl-names = "default"; + pinctrl-0 = <&pwm0_pins &pwm1_pins &pwm2_pins + &fanin0_pins &fanin1_pins &fanin2_pins + &fanin3_pins &fanin4_pins>; + + pwm@0 {
The sub-nodes should be "fan" nodes.
A unit-address without reg property is not valid.
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt line 71
Quoted 1 line
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt new file +1
-0+ pwm-ch = /bits/ 8 <0x00>;
Use 'reg' like ASpeed binding.
Quoted 4 lines
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt new file +4
-0+ fan-ch = /bits/ 8 <0x00 0x01>; + cooling-levels = <127 255>; + }; + pwm@1 {
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt line 84
Quoted 10 lines
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt new file +9
-0+ pwm-ch = /bits/ 8 <0x01>; + fan-ch = /bits/ 8 <0x02 0x03>; + }; + pwm@2 { + pwm-ch = /bits/ 8 <0x02>; + fan-ch = /bits/ 8 <0x04>; + }; + +};
^^^
Quoted 7 lines
Signature · 6 lines
2.14.1 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Tomer Maimon
maintainerRe: [PATCH v4 1/2] dt-binding: hwmon: Add NPCM7xx PWM and Fan controller documentation
Hi Rob,
Quoted 29 lines · Rob Herring
Quoted 8 lines · Tomer Maimon
Added device tree binding documentation for Nuvoton BMC NPCM7xx Pulse Width Modulation (PWM) and Fan tach controller. The PWM controller can support upto 8 PWM output ports. The Fan tach controller can support upto 16 tachometer inputs.
Signed-off-by Tomer Maimon <[email protected]>--- .../devicetree/bindings/hwmon/npcm750-pwm-fan.txt | 84++++++++++++++++++++++
Quoted 2 lines
1 file changed, 84 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt
Review
Quoted 2 lines
(quoted diff) +0
-0
b/Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txtDocumentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt line 1
Quoted 6 lines
new file mode 100644
index 000000000000..a9eacda34f92Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt new file +1
-0@@ -0,0 +1,84 @@ +Nuvoton NPCM7xx PWM and Fan Tacho controller device driverBindings are for h/w, not drivers.
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt line 3
Quoted 2 lines
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt new file +2
-0+ +The NPCM7xx has two identical Pulse-width modulation (PWM) controllermodules,
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt line 4
Quoted 1 line
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt new file +1
-0+Each PWM module has four PWM controller outputs, Totally 8 PWM
Quoted 9 lines
controller outputs.
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt
Quoted 3 lines
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt new file +3
-0+ +The NPCM7xx has eight identical Fan tachometer controller modules, +Each Fan module has two Fan controller inputs, Totally 16 Fancontroller inputs.
Have you looked at other fan ctrlr bindings?f This looks like similar h/w to ASpeed. Really, I'd like to see a common doc that describes the
We do not have the same H/W as Aspeed, I believe in the near future we will need to add
more DT properties that will used only in the NPCM7xx module.
structure and common properties.
Quoted 1 line
what do you mean by common structure and common properties?
Quoted 90 lines
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt
Quoted 4 lines
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt new file +4
-0+ +Required properties for pwm-fan node: +- compatible : "nuvoton,npcm750-pwm-fan" for Poleg NPCM7XX. +- reg : specifies physical base address and sizeof the registers.
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt line 14
Quoted 3 lines
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt new file +3
-0+- reg-names : must contain: + * "pwm-base" for the PWM registers. + * "fan-base" for the Fan registers.'-base' is redundant. And your example doesn't match.
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt
Quoted 3 lines
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt new file +3
-0+- clocks : phandle of reference clocks. +- clock-names : must contain + * "clk_apb3" for clock of PWMcontroller.
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt line 18
Quoted 1 line
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt new file +1
-0+ * "clk_apb4" for clock of Fancontroller.
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt
Quoted 8 lines
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt new file +8
-0+- interrupts : contain the Fan interrupts with flags for falling edge. +- pinctrl-names : a pinctrl state named "default" must be defined. +- pinctrl-0 : phandle referencing pin configuration of the PWM and Fan + controller ports. + +pwm subnode format: +=================== +Under pwm subnode can be upto 8 child nodes, each child noderepresenting a PWM channel.
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt line 27
Quoted 1 line
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt new file +1
-0+Each pwm subnode must have one PWM channel and atleast one Fan tachchannel.
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt line 29
Quoted 2 lines
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt new file +2
-0+ +For PWM channel can be configured cooling-levels to create coolingdevice.
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt
Quoted 5 lines
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt new file +5
-0+Cooling device could be bound to a thermal zone for the thermal control. + +Required properties for each child node: +- pwm-ch : specify the PWM output channel. + integer value in the range 0 through 7, thatrepresent
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt
Quoted 4 lines
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt new file +4
-0+ the PWM channel number that used. + +- fan-ch : specify the Fan input channel. + integer value in the range 0 through 15, thatrepresent
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt line 39
Quoted 1 line
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt new file +1
-0+ the Fan channel number that used.This is really the tach channel.
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt line 49
Quoted 10 lines
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt new file +10
-0+ + At least one Fan tach input channel is required + +Optional property for each child node: +- cooling-levels: PWM duty cycle values in a range from 0 to 255 + which correspond to thermal cooling states. + +Examples: + +pwm_fan:pwm_fan_controller@103000 {fan-controller@...
Quoted 11 lines
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt new file +11
-0+ compatible = "nuvoton,npcm750-pwm-fan"; + reg = <0x103000 0x2000>, + <0x180000 0x8000>; + reg-names = "pwm_base", "fan_base"; + clocks = <&clk NPCM7XX_CLK_APB3>, + <&clk NPCM7XX_CLK_APB4>; + clock-names = "clk_apb3","clk_apb4"; + interrupts = <GIC_SPI 96 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 97 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 98 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 99 IRQ_TYPE_LEVEL_HIGH>,Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt line 70
Quoted 10 lines
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt new file +10
-0+ <GIC_SPI 100 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 101 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 102 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 103 IRQ_TYPE_LEVEL_HIGH>; + pinctrl-names = "default"; + pinctrl-0 = <&pwm0_pins &pwm1_pins &pwm2_pins + &fanin0_pins &fanin1_pins &fanin2_pins + &fanin3_pins &fanin4_pins>; + + pwm@0 {The sub-nodes should be "fan" nodes.
A unit-address without reg property is not valid.
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt line 71
Quoted 1 line
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt new file +1
-0+ pwm-ch = /bits/ 8 <0x00>;Use 'reg' like ASpeed binding.
Quoted 24 lines
Quoted 4 lines
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt new file +4
-0+ fan-ch = /bits/ 8 <0x00 0x01>; + cooling-levels = <127 255>; + }; + pwm@1 {Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt line 84
Quoted 10 lines
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt new file +9
-0+ pwm-ch = /bits/ 8 <0x01>; + fan-ch = /bits/ 8 <0x02 0x03>; + }; + pwm@2 { + pwm-ch = /bits/ 8 <0x02>; + fan-ch = /bits/ 8 <0x04>; + }; + +};^^^
Quoted 7 lines
--
2.14.1--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Thanks!
Tomer
Rob Herring
maintainerRe: [PATCH v4 1/2] dt-binding: hwmon: Add NPCM7xx PWM and Fan controller documentation
Quoted 39 lines · Tomer Maimon
Hi Rob,
Quoted 23 lines · Rob Herring
Quoted 17 lines · Tomer Maimon
Added device tree binding documentation for Nuvoton BMC NPCM7xx Pulse Width Modulation (PWM) and Fan tach controller. The PWM controller can support upto 8 PWM output ports. The Fan tach controller can support upto 16 tachometer inputs.
Signed-off-by Tomer Maimon <[email protected]>--- .../devicetree/bindings/hwmon/npcm750-pwm-fan.txt | 84 ++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txtDocumentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt new file +0
-0Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt line 1
Quoted 1 line
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt new file +1
-0@@ -0,0 +1,84 @@ +Nuvoton NPCM7xx PWM and Fan Tacho controller device driverBindings are for h/w, not drivers.
Quoted 9 lines
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt line 7
Quoted 6 lines
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt new file +6
-0+ +The NPCM7xx has two identical Pulse-width modulation (PWM) controller modules, +Each PWM module has four PWM controller outputs, Totally 8 PWM controller outputs. + +The NPCM7xx has eight identical Fan tachometer controller modules, +Each Fan module has two Fan controller inputs, Totally 16 Fan controller inputs.Have you looked at other fan ctrlr bindings?f This looks like similar h/w to ASpeed. Really, I'd like to see a common doc that describes the
Quoted 2 lines
We do not have the same H/W as Aspeed, I believe in the near future we will need to add more DT properties that will used only in the NPCM7xx module.
I didn't say it was the same. Both are multi-channel PWMs with tach inputs. Presumably, they can attach to the same types of fans as there are only a limited number of types of fans and none of them are specific to any fan controller.
Quoted 4 lines
Quoted 1 line
structure and common properties.
what do you mean by common structure and common properties?
When we have multiple bindings for the same class of device/hw, we define all the common parts in a common binding doc. This often doesn't happen at first, so we end up with a variety of bindings until we see some commonality.
In this case, for structure, having sub-nodes for fans. As fans are not specific to the controllers, their node should not be defined by the controller binding. It's also how you describe the fan type, number of fans, the PWM connections, the tach connections, etc.
Rob
Tomer Maimon
maintainerRe: [PATCH v4 1/2] dt-binding: hwmon: Add NPCM7xx PWM and Fan controller documentation
Hi Rob,
Quoted 65 lines · Rob Herring
Quoted 15 lines · Tomer Maimon
Hi Rob,
Quoted 10 lines · Rob Herring
Quoted 8 lines · Tomer Maimon
Added device tree binding documentation for Nuvoton BMC NPCM7xx Pulse Width Modulation (PWM) and Fan tach controller. The PWM controller can support upto 8 PWM output ports. The Fan tach controller can support upto 16 tachometer inputs.
Signed-off-by Tomer Maimon <[email protected]>--- .../devicetree/bindings/hwmon/npcm750-pwm-fan.txt | 84++++++++++++++++++++++
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
1 file changed, 84 insertions(+) create mode 100644 Documentation/devicetree/
bindings/hwmon/npcm750-pwm-fan.txtQuoted 2 lines
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +0
-0
b/Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txtQuoted 11 lines
Quoted 11 lines
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt line 1
Quoted 6 lines
new file mode 100644
index 000000000000..a9eacda34f92Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt new file +1
-0@@ -0,0 +1,84 @@ +Nuvoton NPCM7xx PWM and Fan Tacho controller device driverBindings are for h/w, not drivers.
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt line 3
Quoted 2 lines
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt new file +2
-0+ +The NPCM7xx has two identical Pulse-width modulation (PWM)controller modules,
Quoted 1 line
Quoted 1 line
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt line 4
Quoted 1 line
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt new file +1
-0+Each PWM module has four PWM controller outputs, Totally 8 PWMcontroller outputs.
Quoted 3 lines
Quoted 3 lines
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt
Quoted 3 lines
Documentation/devicetree/bindings/hwmon/npcm750-pwm-fan.txt new file +3
-0+ +The NPCM7xx has eight identical Fan tachometer controller modules, +Each Fan module has two Fan controller inputs, Totally 16 Fancontroller inputs.
Quoted 6 lines
Quoted 3 lines
Have you looked at other fan ctrlr bindings?f This looks like similar h/w to ASpeed. Really, I'd like to see a common doc that describes the
We do not have the same H/W as Aspeed, I believe in the near future we
will need to add
Quoted 1 line
more DT properties that will used only in the NPCM7xx module.
I didn't say it was the same. Both are multi-channel PWMs with tach inputs. Presumably, they can attach to the same types of fans as there are only a limited number of types of fans and none of them are specific to any fan controller.
Quoted 4 lines
Quoted 1 line
structure and common properties.
what do you mean by common structure and common properties?
When we have multiple bindings for the same class of device/hw, we define all the common parts in a common binding doc. This often doesn't happen at first, so we end up with a variety of bindings until we see some commonality.
Quoted 7 lines
In this case, for structure, having sub-nodes for fans. As fans are not specific to the controllers, their node should not be defined by the controller binding. It's also how you describe the fan type, number of fans, the PWM connections, the tach connections, etc.
Rob
Thanks a lot for the clarification, indeed we can do a common binding doc. is it O.K. for now to stay with the same binding document (V5 - that i will send toady),
and later on we will work on creating common binding document for the fan-nodes.
also I will like to know how to represent the fan-nodes properties in the common
binding document,
the property name "aspeed,fan-tach-ch" is something related Aspeed.
Do I need to ask the Aspeed hwmon maintainer to modify his driver to use fan-tach-ch
property?
or to mention both fan-tach properties (NPCM and Aspeed) in the common binding document ?
Thanks,
Tomer
Tomer Maimon
maintainerPATCH v4 2/2 hwmon: npcm750: add NPCM7xx PWM and Fan driver
In reply to Tomer MaimonAdd Nuvoton BMC NPCM750/730/715/705 Pulse Width Modulation (PWM) and Fan tacho driver.
The Nuvoton BMC NPCM750/730/715/705 has two identical PWM controller modules, each module has four PWM controller outputs and eight identical Fan controller modules, each module has two Fan controller inputs.
The driver provides a sysfs entries through which the user can configure the duty-cycle value from 0(off) and 255(full speed) and read the fan tacho rpm value.
The driver support cooling device creation, that could be bound to a thermal zone for the thermal control.
--- Documentation/hwmon/npcm750-pwm-fan | 22 + drivers/hwmon/Kconfig | 7 + drivers/hwmon/Makefile | 1 + drivers/hwmon/npcm750-pwm-fan.c | 1070 +++++++++++++++++++++++++++++++++++ 4 files changed, 1100 insertions(+) create mode 100644 Documentation/hwmon/npcm750-pwm-fan create mode 100644 drivers/hwmon/npcm750-pwm-fan.c
Documentation/hwmon/npcm750-pwm-fan new file +22 -0
@@ -0,0 +1,22 @@ +Kernel driver npcm750-pwm-fan +============================= + +Supported chip: + NUVOTON NPCM750/730/715/705 + +Authors: + <[email protected]> + +Description: +------------ +This driver implements support for NUVOTON NPCM7XX PWM and Fan Tacho +controller. The PWM controller supports upto 8 PWM outputs. The Fan tacho +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. + +pwmX rw get or set PWM fan control value. This is an integer + value between 0(off) and 255(full speed).
drivers/hwmon/Kconfig +7 -0
@@ -1888,6 +1888,13 @@ config SENSORS_XGENE If you say yes here you get support for the temperature and power sensors for APM X-Gene SoC. +config SENSORS_NPCM7XX + tristate "Nuvoton NPCM7XX PWM and Fan driver" + depends on THERMAL || THERMAL=n + help + This driver provides support for Nuvoton NPCM7XX PWM and Fan + controllers. + if ACPI comment "ACPI drivers"
drivers/hwmon/Makefile +1 -0
@@ -174,6 +174,7 @@ obj-$(CONFIG_SENSORS_W83L786NG) += w83l786ng.o obj-$(CONFIG_SENSORS_WM831X) += wm831x-hwmon.o obj-$(CONFIG_SENSORS_WM8350) += wm8350-hwmon.o obj-$(CONFIG_SENSORS_XGENE) += xgene-hwmon.o +obj-$(CONFIG_SENSORS_NPCM7XX) += npcm750-pwm-fan.o obj-$(CONFIG_PMBUS) += pmbus/
drivers/hwmon/npcm750-pwm-fan.c new file +1070 -0
1,070 lines not on this page · raw message
Signature · 1 line
2.14.1
Re: [PATCH v4 2/2] hwmon: npcm750: add NPCM7xx PWM and Fan driver
Hi Tomer,
I love your patch! Perhaps something to improve:
[auto build test WARNING on hwmon/hwmon-next]
[also build test WARNING on v4.18-rc2 next-20180622]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Tomer-Maimon/dt-binding-hwmon-Add-NPCM7xx-PWM-and-Fan-controller-documentation/20180624-205017 base: https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git hwmon-next
New smatch warnings:drivers/hwmon/npcm750-pwm-fan.c:261 npcm7xx_pwm_config_set() warn: inconsistent returns 'mutex:&data->pwm_lock[module]'.
Locked on: line 245
Unlocked on: line 261
Old smatch warnings:drivers/hwmon/npcm750-pwm-fan.c:836 npcm7xx_pwm_cz_set_cur_state() warn: potential spectre issue 'cdev->cooling_levels'
# https://github.com/0day-ci/linux/commit/5ef6a0a11de5f3f0711993a20b13820cc0884c7e
git remote add linux-review https://github.com/0day-ci/linux
git remote update linux-review
git checkout 5ef6a0a11de5f3f0711993a20b13820cc0884c7e
vim +261 drivers/hwmon/npcm750-pwm-fan.c
5ef6a0a1 Tomer Maimon 2018-06-24 210
5ef6a0a1 Tomer Maimon 2018-06-24 211 static int npcm7xx_pwm_config_set(struct npcm7xx_pwm_fan_data *data,
5ef6a0a1 Tomer Maimon 2018-06-24 212 int channel, u16 val)
5ef6a0a1 Tomer Maimon 2018-06-24 213 {
5ef6a0a1 Tomer Maimon 2018-06-24 214 u32 pwm_ch = (channel % NPCM7XX_PWM_MAX_CHN_NUM_IN_A_MODULE);
5ef6a0a1 Tomer Maimon 2018-06-24 215 u32 module = (channel / NPCM7XX_PWM_MAX_CHN_NUM_IN_A_MODULE);
5ef6a0a1 Tomer Maimon 2018-06-24 216 u32 tmp_buf, ctrl_en_bit, env_bit;
5ef6a0a1 Tomer Maimon 2018-06-24 217
5ef6a0a1 Tomer Maimon 2018-06-24 218 /*
5ef6a0a1 Tomer Maimon 2018-06-24 219 * Config PWM Comparator register for setting duty cycle
5ef6a0a1 Tomer Maimon 2018-06-24 220 */
5ef6a0a1 Tomer Maimon 2018-06-24 221 mutex_lock(&data->pwm_lock[module]);
5ef6a0a1 Tomer Maimon 2018-06-24 222
5ef6a0a1 Tomer Maimon 2018-06-24 223 /* write new CMR value */
5ef6a0a1 Tomer Maimon 2018-06-24 224 iowrite32(val, NPCM7XX_PWM_REG_CMRx(data->pwm_base, module, pwm_ch));
5ef6a0a1 Tomer Maimon 2018-06-24 225 tmp_buf = ioread32(NPCM7XX_PWM_REG_CR(data->pwm_base, module));
5ef6a0a1 Tomer Maimon 2018-06-24 226
5ef6a0a1 Tomer Maimon 2018-06-24 227 switch (pwm_ch) {
5ef6a0a1 Tomer Maimon 2018-06-24 228 case 0:
5ef6a0a1 Tomer Maimon 2018-06-24 229 ctrl_en_bit = NPCM7XX_PWM_CTRL_CH0_EN_BIT;
5ef6a0a1 Tomer Maimon 2018-06-24 230 env_bit = NPCM7XX_PWM_CTRL_CH0_INV_BIT;
5ef6a0a1 Tomer Maimon 2018-06-24 231 break;
5ef6a0a1 Tomer Maimon 2018-06-24 232 case 1:
5ef6a0a1 Tomer Maimon 2018-06-24 233 ctrl_en_bit = NPCM7XX_PWM_CTRL_CH1_EN_BIT;
5ef6a0a1 Tomer Maimon 2018-06-24 234 env_bit = NPCM7XX_PWM_CTRL_CH1_INV_BIT;
5ef6a0a1 Tomer Maimon 2018-06-24 235 break;
5ef6a0a1 Tomer Maimon 2018-06-24 236 case 2:
5ef6a0a1 Tomer Maimon 2018-06-24 237 ctrl_en_bit = NPCM7XX_PWM_CTRL_CH2_EN_BIT;
5ef6a0a1 Tomer Maimon 2018-06-24 238 env_bit = NPCM7XX_PWM_CTRL_CH2_INV_BIT;
5ef6a0a1 Tomer Maimon 2018-06-24 239 break;
5ef6a0a1 Tomer Maimon 2018-06-24 240 case 3:
5ef6a0a1 Tomer Maimon 2018-06-24 241 ctrl_en_bit = NPCM7XX_PWM_CTRL_CH3_EN_BIT;
5ef6a0a1 Tomer Maimon 2018-06-24 242 env_bit = NPCM7XX_PWM_CTRL_CH3_INV_BIT;
5ef6a0a1 Tomer Maimon 2018-06-24 243 break;
5ef6a0a1 Tomer Maimon 2018-06-24 244 default:
5ef6a0a1 Tomer Maimon 2018-06-24 245 return -ENODEV;
^^^^^^^^^^^^^^
5ef6a0a1 Tomer Maimon 2018-06-24 246 }
5ef6a0a1 Tomer Maimon 2018-06-24 247
5ef6a0a1 Tomer Maimon 2018-06-24 248 if (val == 0) {
5ef6a0a1 Tomer Maimon 2018-06-24 249 /* Disable PWM */
5ef6a0a1 Tomer Maimon 2018-06-24 250 tmp_buf &= ~ctrl_en_bit;
5ef6a0a1 Tomer Maimon 2018-06-24 251 tmp_buf |= env_bit;
5ef6a0a1 Tomer Maimon 2018-06-24 252 } else {
5ef6a0a1 Tomer Maimon 2018-06-24 253 /* Enable PWM */
5ef6a0a1 Tomer Maimon 2018-06-24 254 tmp_buf |= ctrl_en_bit;
5ef6a0a1 Tomer Maimon 2018-06-24 255 tmp_buf &= ~env_bit;
5ef6a0a1 Tomer Maimon 2018-06-24 256 }
5ef6a0a1 Tomer Maimon 2018-06-24 257
5ef6a0a1 Tomer Maimon 2018-06-24 258 iowrite32(tmp_buf, NPCM7XX_PWM_REG_CR(data->pwm_base, module));
5ef6a0a1 Tomer Maimon 2018-06-24 259 mutex_unlock(&data->pwm_lock[module]);
5ef6a0a1 Tomer Maimon 2018-06-24 260 5ef6a0a1 Tomer Maimon 2018-06-24 @261 return 0;5ef6a0a1 Tomer Maimon 2018-06-24 262 }5ef6a0a1 Tomer Maimon 2018-06-24 263