Skip to contentSkip to conversation

hwmon: Add NPCM7xx PWM and Fan driver support

PATCH Applied Tomer Maimon 3 participants 7 messages Jul 3, 2018 – Jul 9, 2018

Subsystems (4)
lore
Share & tools
lore

Tomer Maimon

author maintainer
#0 lore raw

v8 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 and read the fan rpm values.

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 comment from:.
- Rob Herring: https://www.spinics.net/lists/kernel/msg2845438.html

Changes since version 7:
- Modify NPCM7xx sensor configuration description.
- Modify clocks name.
- Modify dt-binding documentation.

Changes since version 6:
- Kconfig, Makefile and definitions alphabetic order.
- Error print prefix remove.
- dt-binding documentation haven't changed.

Changes since version 5:
- Removing unnececery lock.
- Modify dt-binding documentation.

Changes since version 4:
- Releasing Mutex before return from set PWM function.
- dt-binding documentation haven't changed.

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                              |   10 +
 drivers/hwmon/Makefile                             |    1 +
 drivers/hwmon/npcm750-pwm-fan.c                    | 1057 ++++++++++++++++++++
 5 files changed, 1174 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
author maintainer
#1 lore raw

PATCH v8 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 Nuvoton BMC NPCM7XX supports 8 PWM controller outputs and 16 Fan tachometer controller 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
new file mode 100644
index 000000000000..d22da14c696f
@@ -0,0 +1,84 @@
+Nuvoton NPCM7xx PWM and Fan Tacho controller device
+
+The Nuvoton BMC NPCM7XX supports 8 Pulse-width modulation (PWM)
+controller outputs and 16 Fan tachometer controller inputs.
+
+Required properties for pwm-fan node
+- #address-cells : should be 1.
+- #size-cells 	: should be 0.
+- compatible	: "nuvoton,npcm750-pwm-fan" for Poleg NPCM7XX.
+- reg 			: specifies physical base address and size of the registers.
+- reg-names 	: must contain:
+					* "pwm" for the PWM registers.
+ 					* "fan" for the Fan registers.
+- clocks		: phandle of reference clocks.
+- clock-names	: must contain
+					* "pwm" for PWM controller operating clock.
+ 					* "fan" for Fan controller operating clock.
+- 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.
+
+fan subnode format:
+===================
+Under fan subnode can be upto 8 child nodes, each child node representing a fan.
+Each fan 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:
+- reg : specify the PWM output channel.
+	integer value in the range 0 through 7, that represent
+	the PWM channel number that used.
+
+- fan-tach-ch : specify the Fan tach input channel.
+		integer value in the range 0 through 15, that represent
+		the fan tach 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 {
+	#address-cells = <1>;
+	#size-cells = <0>;
+	compatible = "nuvoton,npcm750-pwm-fan";
+	reg = <0x103000 0x2000>,
+		<0x180000 0x8000>;
+	reg-names = "pwm", "fan";
+	clocks = <&clk NPCM7XX_CLK_APB3>,
+		<&clk NPCM7XX_CLK_APB4>;
+	clock-names = "pwm","fan";
+	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>;
+	fan@0 {
+		reg = <0x00>;
+		fan-tach-ch = /bits/ 8 <0x00 0x01>;
+		cooling-levels = <127 255>;
+	};
+	fan@1 {
+		reg = <0x01>;
+		fan-tach-ch = /bits/ 8 <0x02 0x03>;
+	};
+	fan@2 {
+		reg = <0x02>;
+		fan-tach-ch = /bits/ 8 <0x04>;
+	};
+
+};
\ No newline at end of file
Signature · 1 line
2.14.1
maintainer Reviewed-by on v8 1/2
#2 lore raw

Re: [PATCH v8 1/2] dt-binding: hwmon: Add NPCM7xx PWM and Fan controller documentation

Quoted 10 lines · Tomer Maimon

Added device tree binding documentation for Nuvoton BMC NPCM7xx Pulse Width Modulation (PWM) and Fan tach controller. The Nuvoton BMC NPCM7XX supports 8 PWM controller outputs and 16 Fan tachometer controller 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
maintainer Applied
#3 lore raw

Re: [v8, 1/2] dt-binding: hwmon: Add NPCM7xx PWM and Fan controller documentation

In reply to Tomer Maimon
Quoted 7 lines · Tomer Maimon

Added device tree binding documentation for Nuvoton BMC NPCM7xx Pulse Width Modulation (PWM) and Fan tach controller. The Nuvoton BMC NPCM7XX supports 8 PWM controller outputs and 16 Fan tachometer controller inputs.

Applied to hwmon-next; while doing so, fixed a couple of whitespace errors recognixed by git.

Thanks,
Guenter

author maintainer
#4 lore raw

PATCH v8 2/2 hwmon: npcm750: add NPCM7xx PWM and Fan driver

In reply to Tomer Maimon

Add Nuvoton BMC NPCM750/730/715/705 Pulse Width Modulation (PWM) and Fan tacho driver.

The Nuvoton BMC NPCM750/730/715/705 supports 8 PWM controller outputs and 16 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.

---
 Documentation/hwmon/npcm750-pwm-fan |   22 +
 drivers/hwmon/Kconfig               |   10 +
 drivers/hwmon/Makefile              |    1 +
 drivers/hwmon/npcm750-pwm-fan.c     | 1057 +++++++++++++++++++++++++++++++++++
 4 files changed, 1090 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
new file mode 100644
index 000000000000..6156ef7398e6
@@ -0,0 +1,22 @@
+Kernel driver npcm750-pwm-fan
+=============================
+
+Supported chips:
+	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 up to 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 +10 -0
index f10840ad465c..78ba044be574 100644
@@ -1256,6 +1256,16 @@ config SENSORS_NCT7904
 	  This driver can also be built as a module.  If so, the module
 	  will be called nct7904.
 
+config SENSORS_NPCM7XX
+	tristate "Nuvoton NPCM750 and compatible PWM and Fan controllers"
+	imply THERMAL
+	help
+	  This driver provides support for Nuvoton NPCM750/730/715/705 PWM
+          and Fan controllers.
+
+          This driver can also be built as a module. If so, the module
+          will be called npcm750-pwm-fan.
+
 config SENSORS_NSA320
 	tristate "ZyXEL NSA320 and compatible fan speed and temperature sensors"
 	depends on GPIOLIB && OF
drivers/hwmon/Makefile +1 -0
index e7d52a36e6c4..94e6075ba575 100644
@@ -134,6 +134,7 @@ obj-$(CONFIG_SENSORS_NCT6683)	+= nct6683.o
 obj-$(CONFIG_SENSORS_NCT6775)	+= nct6775.o
 obj-$(CONFIG_SENSORS_NCT7802)	+= nct7802.o
 obj-$(CONFIG_SENSORS_NCT7904)	+= nct7904.o
+obj-$(CONFIG_SENSORS_NPCM7XX)	+= npcm750-pwm-fan.o
 obj-$(CONFIG_SENSORS_NSA320)	+= nsa320-hwmon.o
 obj-$(CONFIG_SENSORS_NTC_THERMISTOR)	+= ntc_thermistor.o
 obj-$(CONFIG_SENSORS_PC87360)	+= pc87360.o
drivers/hwmon/npcm750-pwm-fan.c new file +1057 -0

1,057 lines not on this page · raw message

Signature · 1 line
2.14.1
maintainer Applied
#5 lore raw

Re: [v8,2/2] hwmon: npcm750: add NPCM7xx PWM and Fan driver

Quoted 11 lines · Tomer Maimon

Add Nuvoton BMC NPCM750/730/715/705 Pulse Width Modulation (PWM) and Fan tacho driver.

The Nuvoton BMC NPCM750/730/715/705 supports 8 PWM controller outputs and 16 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.

Applied to hwmon-next.

Thanks,
Guenter

author maintainer
#6 lore raw

Re: [v8,2/2] hwmon: npcm750: add NPCM7xx PWM and Fan driver

Great!

thanks a lot!

Tomer

Quoted 18 lines · Guenter Roeck
Quoted 11 lines · Tomer Maimon

Add Nuvoton BMC NPCM750/730/715/705 Pulse Width Modulation (PWM) and Fan tacho driver.

The Nuvoton BMC NPCM750/730/715/705 supports 8 PWM controller outputs and 16 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.

Applied to hwmon-next.

Thanks,
Guenter