All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/9] hwmon: thermal: Odroid U3: Provide support for Odroid U3 fan
@ 2014-12-18 10:13 ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-18 10:13 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki,
	Lukasz Majewski

Presented patches add support for Odroid's U3 optional CPU FAN, which uses PWM
subsystem for low level control.

After successful probe it registers itself as a cooling device for thermal
subsystem. To preserve ability to use this fan as a PWM device a stub for
thermal_of_cooling_device_register() has been added.

Moreover, some entries to device tree description for Exynos4412 and in
particular Odroid U3 have been added.

Those patches were tested on Exynos4412 - Odroid U3 board.

Patches were applied on:

linux-soc-thermal/next branch
SHA1: c42c7a44c7a543dcb388c1ee1a798e6ed76ad8cf

with following preceding patch series:
'thermal: exynos: Thermal code rework to use device tree'
http://www.spinics.net/lists/linux-samsung-soc/msg37719.html

Presented code utilize reworked Exynos thermal subsystem.


Kamil Debski (1):
  ARM: dts: Add pwm-fan node to the Odroid-U3 board

Lukasz Majewski (8):
  thermal: Provide stub for thermal_of_cooling_device_register()
    function
  hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a
    cooling device
  hwmon: thermal: dts: Add properties to use pwm-fan device as a cooling
    device in Odroid U3
  hwmon: thermal: Extract __set_pwm() function to only modify PWM duty
    cycle
  hwmon: thermal: Read PWM FAN configuration from device tree
  hwmon: thermal: Code for using PWM FAN as a cooling device
  hwmon: thermal: Provide 'default-pulse-width' property to setup FAN on
    boot
  hwmon: thermal: dts: Disable FAN on boot on the Odroid U3

 .../devicetree/bindings/hwmon/pwm-fan.txt          |  28 +++
 arch/arm/boot/dts/exynos4.dtsi                     |   2 +-
 arch/arm/boot/dts/exynos4412-odroidu3.dts          |  45 +++++
 drivers/hwmon/pwm-fan.c                            | 195 +++++++++++++++++----
 include/linux/thermal.h                            |  14 +-
 5 files changed, 249 insertions(+), 35 deletions(-)

-- 
2.0.0.rc2


^ permalink raw reply	[flat|nested] 329+ messages in thread

* [PATCH 0/9] hwmon: thermal: Odroid U3: Provide support for Odroid U3 fan
@ 2014-12-18 10:13 ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-18 10:13 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki,
	Lukasz Majewski

Presented patches add support for Odroid's U3 optional CPU FAN, which uses PWM
subsystem for low level control.

After successful probe it registers itself as a cooling device for thermal
subsystem. To preserve ability to use this fan as a PWM device a stub for
thermal_of_cooling_device_register() has been added.

Moreover, some entries to device tree description for Exynos4412 and in
particular Odroid U3 have been added.

Those patches were tested on Exynos4412 - Odroid U3 board.

Patches were applied on:

linux-soc-thermal/next branch
SHA1: c42c7a44c7a543dcb388c1ee1a798e6ed76ad8cf

with following preceding patch series:
'thermal: exynos: Thermal code rework to use device tree'
http://www.spinics.net/lists/linux-samsung-soc/msg37719.html

Presented code utilize reworked Exynos thermal subsystem.


Kamil Debski (1):
  ARM: dts: Add pwm-fan node to the Odroid-U3 board

Lukasz Majewski (8):
  thermal: Provide stub for thermal_of_cooling_device_register()
    function
  hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a
    cooling device
  hwmon: thermal: dts: Add properties to use pwm-fan device as a cooling
    device in Odroid U3
  hwmon: thermal: Extract __set_pwm() function to only modify PWM duty
    cycle
  hwmon: thermal: Read PWM FAN configuration from device tree
  hwmon: thermal: Code for using PWM FAN as a cooling device
  hwmon: thermal: Provide 'default-pulse-width' property to setup FAN on
    boot
  hwmon: thermal: dts: Disable FAN on boot on the Odroid U3

 .../devicetree/bindings/hwmon/pwm-fan.txt          |  28 +++
 arch/arm/boot/dts/exynos4.dtsi                     |   2 +-
 arch/arm/boot/dts/exynos4412-odroidu3.dts          |  45 +++++
 drivers/hwmon/pwm-fan.c                            | 195 +++++++++++++++++----
 include/linux/thermal.h                            |  14 +-
 5 files changed, 249 insertions(+), 35 deletions(-)

-- 
2.0.0.rc2


^ permalink raw reply	[flat|nested] 329+ messages in thread

* [lm-sensors] [PATCH 0/9] hwmon: thermal: Odroid U3: Provide support for Odroid U3 fan
@ 2014-12-18 10:13 ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-18 10:13 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki,
	Lukasz Majewski

Presented patches add support for Odroid's U3 optional CPU FAN, which uses PWM
subsystem for low level control.

After successful probe it registers itself as a cooling device for thermal
subsystem. To preserve ability to use this fan as a PWM device a stub for
thermal_of_cooling_device_register() has been added.

Moreover, some entries to device tree description for Exynos4412 and in
particular Odroid U3 have been added.

Those patches were tested on Exynos4412 - Odroid U3 board.

Patches were applied on:

linux-soc-thermal/next branch
SHA1: c42c7a44c7a543dcb388c1ee1a798e6ed76ad8cf

with following preceding patch series:
'thermal: exynos: Thermal code rework to use device tree'
http://www.spinics.net/lists/linux-samsung-soc/msg37719.html

Presented code utilize reworked Exynos thermal subsystem.


Kamil Debski (1):
  ARM: dts: Add pwm-fan node to the Odroid-U3 board

Lukasz Majewski (8):
  thermal: Provide stub for thermal_of_cooling_device_register()
    function
  hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a
    cooling device
  hwmon: thermal: dts: Add properties to use pwm-fan device as a cooling
    device in Odroid U3
  hwmon: thermal: Extract __set_pwm() function to only modify PWM duty
    cycle
  hwmon: thermal: Read PWM FAN configuration from device tree
  hwmon: thermal: Code for using PWM FAN as a cooling device
  hwmon: thermal: Provide 'default-pulse-width' property to setup FAN on
    boot
  hwmon: thermal: dts: Disable FAN on boot on the Odroid U3

 .../devicetree/bindings/hwmon/pwm-fan.txt          |  28 +++
 arch/arm/boot/dts/exynos4.dtsi                     |   2 +-
 arch/arm/boot/dts/exynos4412-odroidu3.dts          |  45 +++++
 drivers/hwmon/pwm-fan.c                            | 195 +++++++++++++++++----
 include/linux/thermal.h                            |  14 +-
 5 files changed, 249 insertions(+), 35 deletions(-)

-- 
2.0.0.rc2


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 329+ messages in thread

* [PATCH 1/9] thermal: Provide stub for thermal_of_cooling_device_register() function
  2014-12-18 10:13 ` Lukasz Majewski
  (?)
@ 2014-12-18 10:13   ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-18 10:13 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki,
	Lukasz Majewski

Odroid U3 fan can work without being registered as OF cooling device
(with CONFIG_THERMAL_OF disabled).
In this situation it can be controlled via PWM entry at
/sys/class/hwmon/hwmon0/pwm1.

Therefore, the thermal_of_cooling_device_register() function needs a stub
to allow clean compilation.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 include/linux/thermal.h | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index 99be7fc..54dce0e 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -328,6 +328,10 @@ thermal_zone_of_sensor_register(struct device *dev, int id, void *data,
 				const struct thermal_zone_of_device_ops *ops);
 void thermal_zone_of_sensor_unregister(struct device *dev,
 				       struct thermal_zone_device *tz);
+struct thermal_cooling_device *
+thermal_of_cooling_device_register(struct device_node *np,
+				   char *type, void *devdata,
+				   const struct thermal_cooling_device_ops *);
 #else
 static inline struct thermal_zone_device *
 thermal_zone_of_sensor_register(struct device *dev, int id, void *data,
@@ -342,6 +346,13 @@ void thermal_zone_of_sensor_unregister(struct device *dev,
 {
 }
 
+static inline struct thermal_cooling_device *
+thermal_of_cooling_device_register(struct device_node *np,
+				   char *type, void *devdata,
+				   const struct thermal_cooling_device_ops *ops)
+{
+	return NULL;
+}
 #endif
 struct thermal_zone_device *thermal_zone_device_register(const char *, int, int,
 		void *, struct thermal_zone_device_ops *,
@@ -357,9 +368,6 @@ void thermal_zone_device_update(struct thermal_zone_device *);
 
 struct thermal_cooling_device *thermal_cooling_device_register(char *, void *,
 		const struct thermal_cooling_device_ops *);
-struct thermal_cooling_device *
-thermal_of_cooling_device_register(struct device_node *np, char *, void *,
-				   const struct thermal_cooling_device_ops *);
 void thermal_cooling_device_unregister(struct thermal_cooling_device *);
 struct thermal_zone_device *thermal_zone_get_zone_by_name(const char *name);
 int thermal_zone_get_temp(struct thermal_zone_device *tz, unsigned long *temp);
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH 1/9] thermal: Provide stub for thermal_of_cooling_device_register() function
@ 2014-12-18 10:13   ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-18 10:13 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki,
	Lukasz Majewski

Odroid U3 fan can work without being registered as OF cooling device
(with CONFIG_THERMAL_OF disabled).
In this situation it can be controlled via PWM entry at
/sys/class/hwmon/hwmon0/pwm1.

Therefore, the thermal_of_cooling_device_register() function needs a stub
to allow clean compilation.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 include/linux/thermal.h | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index 99be7fc..54dce0e 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -328,6 +328,10 @@ thermal_zone_of_sensor_register(struct device *dev, int id, void *data,
 				const struct thermal_zone_of_device_ops *ops);
 void thermal_zone_of_sensor_unregister(struct device *dev,
 				       struct thermal_zone_device *tz);
+struct thermal_cooling_device *
+thermal_of_cooling_device_register(struct device_node *np,
+				   char *type, void *devdata,
+				   const struct thermal_cooling_device_ops *);
 #else
 static inline struct thermal_zone_device *
 thermal_zone_of_sensor_register(struct device *dev, int id, void *data,
@@ -342,6 +346,13 @@ void thermal_zone_of_sensor_unregister(struct device *dev,
 {
 }
 
+static inline struct thermal_cooling_device *
+thermal_of_cooling_device_register(struct device_node *np,
+				   char *type, void *devdata,
+				   const struct thermal_cooling_device_ops *ops)
+{
+	return NULL;
+}
 #endif
 struct thermal_zone_device *thermal_zone_device_register(const char *, int, int,
 		void *, struct thermal_zone_device_ops *,
@@ -357,9 +368,6 @@ void thermal_zone_device_update(struct thermal_zone_device *);
 
 struct thermal_cooling_device *thermal_cooling_device_register(char *, void *,
 		const struct thermal_cooling_device_ops *);
-struct thermal_cooling_device *
-thermal_of_cooling_device_register(struct device_node *np, char *, void *,
-				   const struct thermal_cooling_device_ops *);
 void thermal_cooling_device_unregister(struct thermal_cooling_device *);
 struct thermal_zone_device *thermal_zone_get_zone_by_name(const char *name);
 int thermal_zone_get_temp(struct thermal_zone_device *tz, unsigned long *temp);
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [lm-sensors] [PATCH 1/9] thermal: Provide stub for thermal_of_cooling_device_register() function
@ 2014-12-18 10:13   ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-18 10:13 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki,
	Lukasz Majewski

Odroid U3 fan can work without being registered as OF cooling device
(with CONFIG_THERMAL_OF disabled).
In this situation it can be controlled via PWM entry at
/sys/class/hwmon/hwmon0/pwm1.

Therefore, the thermal_of_cooling_device_register() function needs a stub
to allow clean compilation.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 include/linux/thermal.h | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index 99be7fc..54dce0e 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -328,6 +328,10 @@ thermal_zone_of_sensor_register(struct device *dev, int id, void *data,
 				const struct thermal_zone_of_device_ops *ops);
 void thermal_zone_of_sensor_unregister(struct device *dev,
 				       struct thermal_zone_device *tz);
+struct thermal_cooling_device *
+thermal_of_cooling_device_register(struct device_node *np,
+				   char *type, void *devdata,
+				   const struct thermal_cooling_device_ops *);
 #else
 static inline struct thermal_zone_device *
 thermal_zone_of_sensor_register(struct device *dev, int id, void *data,
@@ -342,6 +346,13 @@ void thermal_zone_of_sensor_unregister(struct device *dev,
 {
 }
 
+static inline struct thermal_cooling_device *
+thermal_of_cooling_device_register(struct device_node *np,
+				   char *type, void *devdata,
+				   const struct thermal_cooling_device_ops *ops)
+{
+	return NULL;
+}
 #endif
 struct thermal_zone_device *thermal_zone_device_register(const char *, int, int,
 		void *, struct thermal_zone_device_ops *,
@@ -357,9 +368,6 @@ void thermal_zone_device_update(struct thermal_zone_device *);
 
 struct thermal_cooling_device *thermal_cooling_device_register(char *, void *,
 		const struct thermal_cooling_device_ops *);
-struct thermal_cooling_device *
-thermal_of_cooling_device_register(struct device_node *np, char *, void *,
-				   const struct thermal_cooling_device_ops *);
 void thermal_cooling_device_unregister(struct thermal_cooling_device *);
 struct thermal_zone_device *thermal_zone_get_zone_by_name(const char *name);
 int thermal_zone_get_temp(struct thermal_zone_device *tz, unsigned long *temp);
-- 
2.0.0.rc2


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH 2/9] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling device
  2014-12-18 10:13 ` Lukasz Majewski
  (?)
@ 2014-12-18 10:13   ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-18 10:13 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki,
	Lukasz Majewski

Several new properties to allow PWM fan working as a cooling device have been
combined into this single commit.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 .../devicetree/bindings/hwmon/pwm-fan.txt          | 28 ++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
index 610757c..3877810 100644
--- a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
+++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
@@ -3,10 +3,38 @@ Bindings for a fan connected to the PWM lines
 Required properties:
 - compatible	: "pwm-fan"
 - pwms		: the PWM that is used to control the PWM fan
+- cooling-pwm-values      : PWM duty cycle values relative to
+			    cooling-max-pwm-value correspondig to
+			    proper cooling states
+- default-pulse-width     : Property specifying default pulse width for FAN
+			    at system boot (zero to disable FAN on boot).
+			    Allowed range is 0 to 255
+
+Thorough description of the following bindings:
+		cooling-min-state = <0>;
+		cooling-max-state = <3>;
+		#cooling-cells = <2>;
+		thermal-zone {
+			cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				     trip = <&cpu_alert1>;
+				     cooling-device = <&fan0 0 1>;
+				};
+			};
+		};
+
+for PWM FAN used as cooling device can be found at:
+./Documentation/devicetree/bindings/thermal/thermal.txt
 
 Example:
 	pwm-fan {
 		compatible = "pwm-fan";
 		status = "okay";
 		pwms = <&pwm 0 10000 0>;
+		cooling-min-state = <0>;
+		cooling-max-state = <3>;
+		#cooling-cells = <2>;
+		cooling-pwm-values = <0 102 170 255>;
+		default-pulse-width = <0>;
 	};
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH 2/9] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling device
@ 2014-12-18 10:13   ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-18 10:13 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki,
	Lukasz Majewski

Several new properties to allow PWM fan working as a cooling device have been
combined into this single commit.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 .../devicetree/bindings/hwmon/pwm-fan.txt          | 28 ++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
index 610757c..3877810 100644
--- a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
+++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
@@ -3,10 +3,38 @@ Bindings for a fan connected to the PWM lines
 Required properties:
 - compatible	: "pwm-fan"
 - pwms		: the PWM that is used to control the PWM fan
+- cooling-pwm-values      : PWM duty cycle values relative to
+			    cooling-max-pwm-value correspondig to
+			    proper cooling states
+- default-pulse-width     : Property specifying default pulse width for FAN
+			    at system boot (zero to disable FAN on boot).
+			    Allowed range is 0 to 255
+
+Thorough description of the following bindings:
+		cooling-min-state = <0>;
+		cooling-max-state = <3>;
+		#cooling-cells = <2>;
+		thermal-zone {
+			cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				     trip = <&cpu_alert1>;
+				     cooling-device = <&fan0 0 1>;
+				};
+			};
+		};
+
+for PWM FAN used as cooling device can be found at:
+./Documentation/devicetree/bindings/thermal/thermal.txt
 
 Example:
 	pwm-fan {
 		compatible = "pwm-fan";
 		status = "okay";
 		pwms = <&pwm 0 10000 0>;
+		cooling-min-state = <0>;
+		cooling-max-state = <3>;
+		#cooling-cells = <2>;
+		cooling-pwm-values = <0 102 170 255>;
+		default-pulse-width = <0>;
 	};
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [lm-sensors] [PATCH 2/9] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling dev
@ 2014-12-18 10:13   ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-18 10:13 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki,
	Lukasz Majewski

Several new properties to allow PWM fan working as a cooling device have been
combined into this single commit.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 .../devicetree/bindings/hwmon/pwm-fan.txt          | 28 ++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
index 610757c..3877810 100644
--- a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
+++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
@@ -3,10 +3,38 @@ Bindings for a fan connected to the PWM lines
 Required properties:
 - compatible	: "pwm-fan"
 - pwms		: the PWM that is used to control the PWM fan
+- cooling-pwm-values      : PWM duty cycle values relative to
+			    cooling-max-pwm-value correspondig to
+			    proper cooling states
+- default-pulse-width     : Property specifying default pulse width for FAN
+			    at system boot (zero to disable FAN on boot).
+			    Allowed range is 0 to 255
+
+Thorough description of the following bindings:
+		cooling-min-state = <0>;
+		cooling-max-state = <3>;
+		#cooling-cells = <2>;
+		thermal-zone {
+			cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				     trip = <&cpu_alert1>;
+				     cooling-device = <&fan0 0 1>;
+				};
+			};
+		};
+
+for PWM FAN used as cooling device can be found at:
+./Documentation/devicetree/bindings/thermal/thermal.txt
 
 Example:
 	pwm-fan {
 		compatible = "pwm-fan";
 		status = "okay";
 		pwms = <&pwm 0 10000 0>;
+		cooling-min-state = <0>;
+		cooling-max-state = <3>;
+		#cooling-cells = <2>;
+		cooling-pwm-values = <0 102 170 255>;
+		default-pulse-width = <0>;
 	};
-- 
2.0.0.rc2


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH 3/9] ARM: dts: Add pwm-fan node to the Odroid-U3 board
  2014-12-18 10:13 ` Lukasz Majewski
  (?)
@ 2014-12-18 10:13   ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-18 10:13 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki

From: Kamil Debski <k.debski@samsung.com>

Add pwm-fan node to the Odroid-U3 board file to enable PWM control of the
cooling fan. In addition, add the "pwm" label to the pwm@139D0000 node
in the exynos4412.dtsi.

Signed-off-by: Kamil Debski <k.debski@samsung.com>
[Rebased on the newest mainline by l.majewski@samsung.com]
---
Changes since v1:
- added pwm label to the pwm@139D0000 node in exynos4.dtsi
- use the pwm label in the exynos4412-odroidu3.dts
- change order or properties in the pwn-fan node, to be sorted
  in alphabetical order

---
 arch/arm/boot/dts/exynos4.dtsi            |  2 +-
 arch/arm/boot/dts/exynos4412-odroidu3.dts | 13 +++++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/exynos4.dtsi b/arch/arm/boot/dts/exynos4.dtsi
index 1735bb3..f227a39 100644
--- a/arch/arm/boot/dts/exynos4.dtsi
+++ b/arch/arm/boot/dts/exynos4.dtsi
@@ -583,7 +583,7 @@
 		status = "disabled";
 	};
 
-	pwm@139D0000 {
+	pwm: pwm@139D0000 {
 		compatible = "samsung,exynos4210-pwm";
 		reg = <0x139D0000 0x1000>;
 		interrupts = <0 37 0>, <0 38 0>, <0 39 0>, <0 40 0>, <0 41 0>;
diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
index c8a64be..60bd1e4 100644
--- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
+++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
@@ -31,6 +31,19 @@
 			linux,default-trigger = "heartbeat";
 		};
 	};
+
+	pwm-fan {
+		compatible = "pwm-fan";
+		pwms = <&pwm 0 10000 0>;
+		status = "okay";
+	};
+};
+
+&pwm {
+	pinctrl-0 = <&pwm0_out>;
+	pinctrl-names = "default";
+	samsung,pwm-outputs = <0>;
+	status = "okay";
 };
 
 &usb3503 {
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH 3/9] ARM: dts: Add pwm-fan node to the Odroid-U3 board
@ 2014-12-18 10:13   ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-18 10:13 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki

From: Kamil Debski <k.debski@samsung.com>

Add pwm-fan node to the Odroid-U3 board file to enable PWM control of the
cooling fan. In addition, add the "pwm" label to the pwm@139D0000 node
in the exynos4412.dtsi.

Signed-off-by: Kamil Debski <k.debski@samsung.com>
[Rebased on the newest mainline by l.majewski@samsung.com]
---
Changes since v1:
- added pwm label to the pwm@139D0000 node in exynos4.dtsi
- use the pwm label in the exynos4412-odroidu3.dts
- change order or properties in the pwn-fan node, to be sorted
  in alphabetical order

---
 arch/arm/boot/dts/exynos4.dtsi            |  2 +-
 arch/arm/boot/dts/exynos4412-odroidu3.dts | 13 +++++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/exynos4.dtsi b/arch/arm/boot/dts/exynos4.dtsi
index 1735bb3..f227a39 100644
--- a/arch/arm/boot/dts/exynos4.dtsi
+++ b/arch/arm/boot/dts/exynos4.dtsi
@@ -583,7 +583,7 @@
 		status = "disabled";
 	};
 
-	pwm@139D0000 {
+	pwm: pwm@139D0000 {
 		compatible = "samsung,exynos4210-pwm";
 		reg = <0x139D0000 0x1000>;
 		interrupts = <0 37 0>, <0 38 0>, <0 39 0>, <0 40 0>, <0 41 0>;
diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
index c8a64be..60bd1e4 100644
--- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
+++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
@@ -31,6 +31,19 @@
 			linux,default-trigger = "heartbeat";
 		};
 	};
+
+	pwm-fan {
+		compatible = "pwm-fan";
+		pwms = <&pwm 0 10000 0>;
+		status = "okay";
+	};
+};
+
+&pwm {
+	pinctrl-0 = <&pwm0_out>;
+	pinctrl-names = "default";
+	samsung,pwm-outputs = <0>;
+	status = "okay";
 };
 
 &usb3503 {
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [lm-sensors] [PATCH 3/9] ARM: dts: Add pwm-fan node to the Odroid-U3 board
@ 2014-12-18 10:13   ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-18 10:13 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki

From: Kamil Debski <k.debski@samsung.com>

Add pwm-fan node to the Odroid-U3 board file to enable PWM control of the
cooling fan. In addition, add the "pwm" label to the pwm@139D0000 node
in the exynos4412.dtsi.

Signed-off-by: Kamil Debski <k.debski@samsung.com>
[Rebased on the newest mainline by l.majewski@samsung.com]
---
Changes since v1:
- added pwm label to the pwm@139D0000 node in exynos4.dtsi
- use the pwm label in the exynos4412-odroidu3.dts
- change order or properties in the pwn-fan node, to be sorted
  in alphabetical order

---
 arch/arm/boot/dts/exynos4.dtsi            |  2 +-
 arch/arm/boot/dts/exynos4412-odroidu3.dts | 13 +++++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/exynos4.dtsi b/arch/arm/boot/dts/exynos4.dtsi
index 1735bb3..f227a39 100644
--- a/arch/arm/boot/dts/exynos4.dtsi
+++ b/arch/arm/boot/dts/exynos4.dtsi
@@ -583,7 +583,7 @@
 		status = "disabled";
 	};
 
-	pwm@139D0000 {
+	pwm: pwm@139D0000 {
 		compatible = "samsung,exynos4210-pwm";
 		reg = <0x139D0000 0x1000>;
 		interrupts = <0 37 0>, <0 38 0>, <0 39 0>, <0 40 0>, <0 41 0>;
diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
index c8a64be..60bd1e4 100644
--- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
+++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
@@ -31,6 +31,19 @@
 			linux,default-trigger = "heartbeat";
 		};
 	};
+
+	pwm-fan {
+		compatible = "pwm-fan";
+		pwms = <&pwm 0 10000 0>;
+		status = "okay";
+	};
+};
+
+&pwm {
+	pinctrl-0 = <&pwm0_out>;
+	pinctrl-names = "default";
+	samsung,pwm-outputs = <0>;
+	status = "okay";
 };
 
 &usb3503 {
-- 
2.0.0.rc2


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH 4/9] hwmon: thermal: dts: Add properties to use pwm-fan device as a cooling device in Odroid U3
  2014-12-18 10:13 ` Lukasz Majewski
  (?)
@ 2014-12-18 10:13   ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-18 10:13 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki,
	Lukasz Majewski

With those bindings it is possible to use pwm-fan device available at
Odroid U3 as a cooling device.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 arch/arm/boot/dts/exynos4412-odroidu3.dts | 33 ++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
index 60bd1e4..cc50e96 100644
--- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
+++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
@@ -32,11 +32,42 @@
 		};
 	};
 
-	pwm-fan {
+	fan0: pwm-fan {
 		compatible = "pwm-fan";
 		pwms = <&pwm 0 10000 0>;
+		cooling-min-state = <0>;
+		cooling-max-state = <3>;
+		#cooling-cells = <2>;
+		cooling-pwm-values = <0 102 170 255>;
 		status = "okay";
 	};
+
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				     trip = <&cpu_alert1>;
+				     cooling-device = <&cpu0 7 7>;
+				};
+				map1 {
+				     trip = <&cpu_alert2>;
+				     cooling-device = <&cpu0 13 13>;
+				};
+				map2 {
+				     trip = <&cpu_alert0>;
+				     cooling-device = <&fan0 0 1>;
+				};
+				map3 {
+				     trip = <&cpu_alert1>;
+				     cooling-device = <&fan0 1 2>;
+				};
+				map4 {
+				     trip = <&cpu_alert2>;
+				     cooling-device = <&fan0 2 3>;
+				};
+			};
+		};
+	};
 };
 
 &pwm {
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH 4/9] hwmon: thermal: dts: Add properties to use pwm-fan device as a cooling device in Odroid U3
@ 2014-12-18 10:13   ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-18 10:13 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki,
	Lukasz Majewski

With those bindings it is possible to use pwm-fan device available at
Odroid U3 as a cooling device.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 arch/arm/boot/dts/exynos4412-odroidu3.dts | 33 ++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
index 60bd1e4..cc50e96 100644
--- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
+++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
@@ -32,11 +32,42 @@
 		};
 	};
 
-	pwm-fan {
+	fan0: pwm-fan {
 		compatible = "pwm-fan";
 		pwms = <&pwm 0 10000 0>;
+		cooling-min-state = <0>;
+		cooling-max-state = <3>;
+		#cooling-cells = <2>;
+		cooling-pwm-values = <0 102 170 255>;
 		status = "okay";
 	};
+
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				     trip = <&cpu_alert1>;
+				     cooling-device = <&cpu0 7 7>;
+				};
+				map1 {
+				     trip = <&cpu_alert2>;
+				     cooling-device = <&cpu0 13 13>;
+				};
+				map2 {
+				     trip = <&cpu_alert0>;
+				     cooling-device = <&fan0 0 1>;
+				};
+				map3 {
+				     trip = <&cpu_alert1>;
+				     cooling-device = <&fan0 1 2>;
+				};
+				map4 {
+				     trip = <&cpu_alert2>;
+				     cooling-device = <&fan0 2 3>;
+				};
+			};
+		};
+	};
 };
 
 &pwm {
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [lm-sensors] [PATCH 4/9] hwmon: thermal: dts: Add properties to use pwm-fan device as a cooling devi
@ 2014-12-18 10:13   ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-18 10:13 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki,
	Lukasz Majewski

With those bindings it is possible to use pwm-fan device available at
Odroid U3 as a cooling device.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 arch/arm/boot/dts/exynos4412-odroidu3.dts | 33 ++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
index 60bd1e4..cc50e96 100644
--- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
+++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
@@ -32,11 +32,42 @@
 		};
 	};
 
-	pwm-fan {
+	fan0: pwm-fan {
 		compatible = "pwm-fan";
 		pwms = <&pwm 0 10000 0>;
+		cooling-min-state = <0>;
+		cooling-max-state = <3>;
+		#cooling-cells = <2>;
+		cooling-pwm-values = <0 102 170 255>;
 		status = "okay";
 	};
+
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				     trip = <&cpu_alert1>;
+				     cooling-device = <&cpu0 7 7>;
+				};
+				map1 {
+				     trip = <&cpu_alert2>;
+				     cooling-device = <&cpu0 13 13>;
+				};
+				map2 {
+				     trip = <&cpu_alert0>;
+				     cooling-device = <&fan0 0 1>;
+				};
+				map3 {
+				     trip = <&cpu_alert1>;
+				     cooling-device = <&fan0 1 2>;
+				};
+				map4 {
+				     trip = <&cpu_alert2>;
+				     cooling-device = <&fan0 2 3>;
+				};
+			};
+		};
+	};
 };
 
 &pwm {
-- 
2.0.0.rc2


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH 5/9] hwmon: thermal: Extract __set_pwm() function to only modify PWM duty cycle
  2014-12-18 10:13 ` Lukasz Majewski
  (?)
@ 2014-12-18 10:13   ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-18 10:13 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki,
	Lukasz Majewski

It was necessary to decouple code handling writing to sysfs from the one
responsible for setting PWM of the fan.
Due to that, new __set_pwm() method was extracted, which is responsible for
only setting new PWM duty cycle.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 drivers/hwmon/pwm-fan.c | 35 ++++++++++++++++++++++-------------
 1 file changed, 22 insertions(+), 13 deletions(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index 1991d903..870e100 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -33,21 +33,15 @@ struct pwm_fan_ctx {
 	unsigned char pwm_value;
 };
 
-static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
-		       const char *buf, size_t count)
+static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
 {
-	struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
-	unsigned long pwm, duty;
-	ssize_t ret;
-
-	if (kstrtoul(buf, 10, &pwm) || pwm > MAX_PWM)
-		return -EINVAL;
-
-	mutex_lock(&ctx->lock);
+	unsigned long duty;
+	int ret;
 
 	if (ctx->pwm_value == pwm)
-		goto exit_set_pwm_no_change;
+		return 0;
 
+	mutex_lock(&ctx->lock);
 	if (pwm == 0) {
 		pwm_disable(ctx->pwm);
 		goto exit_set_pwm;
@@ -66,13 +60,28 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 
 exit_set_pwm:
 	ctx->pwm_value = pwm;
-exit_set_pwm_no_change:
-	ret = count;
 exit_set_pwm_err:
 	mutex_unlock(&ctx->lock);
 	return ret;
 }
 
+static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
+		       const char *buf, size_t count)
+{
+	struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
+	unsigned long pwm;
+	int ret;
+
+	if (kstrtoul(buf, 10, &pwm) || pwm > MAX_PWM)
+		return -EINVAL;
+
+	ret = __set_pwm(ctx, pwm);
+	if (ret)
+		return ret;
+
+	return count;
+}
+
 static ssize_t show_pwm(struct device *dev,
 			struct device_attribute *attr, char *buf)
 {
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH 5/9] hwmon: thermal: Extract __set_pwm() function to only modify PWM duty cycle
@ 2014-12-18 10:13   ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-18 10:13 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki,
	Lukasz Majewski

It was necessary to decouple code handling writing to sysfs from the one
responsible for setting PWM of the fan.
Due to that, new __set_pwm() method was extracted, which is responsible for
only setting new PWM duty cycle.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 drivers/hwmon/pwm-fan.c | 35 ++++++++++++++++++++++-------------
 1 file changed, 22 insertions(+), 13 deletions(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index 1991d903..870e100 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -33,21 +33,15 @@ struct pwm_fan_ctx {
 	unsigned char pwm_value;
 };
 
-static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
-		       const char *buf, size_t count)
+static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
 {
-	struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
-	unsigned long pwm, duty;
-	ssize_t ret;
-
-	if (kstrtoul(buf, 10, &pwm) || pwm > MAX_PWM)
-		return -EINVAL;
-
-	mutex_lock(&ctx->lock);
+	unsigned long duty;
+	int ret;
 
 	if (ctx->pwm_value == pwm)
-		goto exit_set_pwm_no_change;
+		return 0;
 
+	mutex_lock(&ctx->lock);
 	if (pwm == 0) {
 		pwm_disable(ctx->pwm);
 		goto exit_set_pwm;
@@ -66,13 +60,28 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 
 exit_set_pwm:
 	ctx->pwm_value = pwm;
-exit_set_pwm_no_change:
-	ret = count;
 exit_set_pwm_err:
 	mutex_unlock(&ctx->lock);
 	return ret;
 }
 
+static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
+		       const char *buf, size_t count)
+{
+	struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
+	unsigned long pwm;
+	int ret;
+
+	if (kstrtoul(buf, 10, &pwm) || pwm > MAX_PWM)
+		return -EINVAL;
+
+	ret = __set_pwm(ctx, pwm);
+	if (ret)
+		return ret;
+
+	return count;
+}
+
 static ssize_t show_pwm(struct device *dev,
 			struct device_attribute *attr, char *buf)
 {
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [lm-sensors] [PATCH 5/9] hwmon: thermal: Extract __set_pwm() function to only modify PWM duty cycle
@ 2014-12-18 10:13   ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-18 10:13 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki,
	Lukasz Majewski

It was necessary to decouple code handling writing to sysfs from the one
responsible for setting PWM of the fan.
Due to that, new __set_pwm() method was extracted, which is responsible for
only setting new PWM duty cycle.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 drivers/hwmon/pwm-fan.c | 35 ++++++++++++++++++++++-------------
 1 file changed, 22 insertions(+), 13 deletions(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index 1991d903..870e100 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -33,21 +33,15 @@ struct pwm_fan_ctx {
 	unsigned char pwm_value;
 };
 
-static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
-		       const char *buf, size_t count)
+static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
 {
-	struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
-	unsigned long pwm, duty;
-	ssize_t ret;
-
-	if (kstrtoul(buf, 10, &pwm) || pwm > MAX_PWM)
-		return -EINVAL;
-
-	mutex_lock(&ctx->lock);
+	unsigned long duty;
+	int ret;
 
 	if (ctx->pwm_value = pwm)
-		goto exit_set_pwm_no_change;
+		return 0;
 
+	mutex_lock(&ctx->lock);
 	if (pwm = 0) {
 		pwm_disable(ctx->pwm);
 		goto exit_set_pwm;
@@ -66,13 +60,28 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 
 exit_set_pwm:
 	ctx->pwm_value = pwm;
-exit_set_pwm_no_change:
-	ret = count;
 exit_set_pwm_err:
 	mutex_unlock(&ctx->lock);
 	return ret;
 }
 
+static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
+		       const char *buf, size_t count)
+{
+	struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
+	unsigned long pwm;
+	int ret;
+
+	if (kstrtoul(buf, 10, &pwm) || pwm > MAX_PWM)
+		return -EINVAL;
+
+	ret = __set_pwm(ctx, pwm);
+	if (ret)
+		return ret;
+
+	return count;
+}
+
 static ssize_t show_pwm(struct device *dev,
 			struct device_attribute *attr, char *buf)
 {
-- 
2.0.0.rc2


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH 6/9] hwmon: thermal: Read PWM FAN configuration from device tree
  2014-12-18 10:13 ` Lukasz Majewski
  (?)
@ 2014-12-18 10:13   ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-18 10:13 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki,
	Lukasz Majewski

Code for reading PWM FAN configuration data via device tree has been added.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 drivers/hwmon/pwm-fan.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 50 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index 870e100..5854bb3 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -30,7 +30,10 @@
 struct pwm_fan_ctx {
 	struct mutex lock;
 	struct pwm_device *pwm;
-	unsigned char pwm_value;
+	unsigned int pwm_value;
+	unsigned int pwm_fan_state;
+	unsigned int pwm_fan_max_state;
+	unsigned int *pwm_fan_cooling_states;
 };
 
 static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
@@ -100,6 +103,49 @@ static struct attribute *pwm_fan_attrs[] = {
 
 ATTRIBUTE_GROUPS(pwm_fan);
 
+int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
+{
+	struct device_node *np = dev->of_node;
+	struct property *pp;
+	int len, num, i;
+
+	pp = of_find_property(np, "cooling-pwm-values", &len);
+	if (!pp) {
+		dev_err(dev, "Property: 'cooling-pwm-values' not found\n");
+		return -EINVAL;
+	}
+
+	if (len == 0) {
+		dev_err(dev, "Length wrong value!\n");
+		return -EINVAL;
+	}
+
+	ctx->pwm_fan_cooling_states = devm_kzalloc(dev, len, GFP_KERNEL);
+	if (!ctx->pwm_fan_cooling_states) {
+		dev_err(dev, "Allocation failed for pwm dan cooling states\n");
+		return -ENOMEM;
+	}
+
+	num = len / sizeof(u32);
+	if (of_property_read_u32_array(np, pp->name,
+				       ctx->pwm_fan_cooling_states, num)) {
+		dev_err(dev, "Property: %s cannot be read!\n", pp->name);
+		return -EINVAL;
+	}
+
+	for (i = 0; i < num; i++) {
+		if (ctx->pwm_fan_cooling_states[i] > MAX_PWM) {
+			dev_err(dev, "PWM fan state[%d]:%d > %d\n", i,
+				ctx->pwm_fan_cooling_states[i], MAX_PWM);
+			return -EINVAL;
+		}
+	}
+
+	ctx->pwm_fan_max_state = num - 1;
+
+	return 0;
+}
+
 static int pwm_fan_probe(struct platform_device *pdev)
 {
 	struct device *hwmon;
@@ -120,6 +166,9 @@ static int pwm_fan_probe(struct platform_device *pdev)
 	}
 
 	platform_set_drvdata(pdev, ctx);
+	ret = pwm_fan_of_get_cooling_data(&pdev->dev, ctx);
+	if (ret)
+		return ret;
 
 	/* Set duty cycle to maximum allowed */
 	duty_cycle = ctx->pwm->period - 1;
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH 6/9] hwmon: thermal: Read PWM FAN configuration from device tree
@ 2014-12-18 10:13   ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-18 10:13 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki,
	Lukasz Majewski

Code for reading PWM FAN configuration data via device tree has been added.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 drivers/hwmon/pwm-fan.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 50 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index 870e100..5854bb3 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -30,7 +30,10 @@
 struct pwm_fan_ctx {
 	struct mutex lock;
 	struct pwm_device *pwm;
-	unsigned char pwm_value;
+	unsigned int pwm_value;
+	unsigned int pwm_fan_state;
+	unsigned int pwm_fan_max_state;
+	unsigned int *pwm_fan_cooling_states;
 };
 
 static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
@@ -100,6 +103,49 @@ static struct attribute *pwm_fan_attrs[] = {
 
 ATTRIBUTE_GROUPS(pwm_fan);
 
+int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
+{
+	struct device_node *np = dev->of_node;
+	struct property *pp;
+	int len, num, i;
+
+	pp = of_find_property(np, "cooling-pwm-values", &len);
+	if (!pp) {
+		dev_err(dev, "Property: 'cooling-pwm-values' not found\n");
+		return -EINVAL;
+	}
+
+	if (len == 0) {
+		dev_err(dev, "Length wrong value!\n");
+		return -EINVAL;
+	}
+
+	ctx->pwm_fan_cooling_states = devm_kzalloc(dev, len, GFP_KERNEL);
+	if (!ctx->pwm_fan_cooling_states) {
+		dev_err(dev, "Allocation failed for pwm dan cooling states\n");
+		return -ENOMEM;
+	}
+
+	num = len / sizeof(u32);
+	if (of_property_read_u32_array(np, pp->name,
+				       ctx->pwm_fan_cooling_states, num)) {
+		dev_err(dev, "Property: %s cannot be read!\n", pp->name);
+		return -EINVAL;
+	}
+
+	for (i = 0; i < num; i++) {
+		if (ctx->pwm_fan_cooling_states[i] > MAX_PWM) {
+			dev_err(dev, "PWM fan state[%d]:%d > %d\n", i,
+				ctx->pwm_fan_cooling_states[i], MAX_PWM);
+			return -EINVAL;
+		}
+	}
+
+	ctx->pwm_fan_max_state = num - 1;
+
+	return 0;
+}
+
 static int pwm_fan_probe(struct platform_device *pdev)
 {
 	struct device *hwmon;
@@ -120,6 +166,9 @@ static int pwm_fan_probe(struct platform_device *pdev)
 	}
 
 	platform_set_drvdata(pdev, ctx);
+	ret = pwm_fan_of_get_cooling_data(&pdev->dev, ctx);
+	if (ret)
+		return ret;
 
 	/* Set duty cycle to maximum allowed */
 	duty_cycle = ctx->pwm->period - 1;
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [lm-sensors] [PATCH 6/9] hwmon: thermal: Read PWM FAN configuration from device tree
@ 2014-12-18 10:13   ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-18 10:13 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki,
	Lukasz Majewski

Code for reading PWM FAN configuration data via device tree has been added.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 drivers/hwmon/pwm-fan.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 50 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index 870e100..5854bb3 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -30,7 +30,10 @@
 struct pwm_fan_ctx {
 	struct mutex lock;
 	struct pwm_device *pwm;
-	unsigned char pwm_value;
+	unsigned int pwm_value;
+	unsigned int pwm_fan_state;
+	unsigned int pwm_fan_max_state;
+	unsigned int *pwm_fan_cooling_states;
 };
 
 static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
@@ -100,6 +103,49 @@ static struct attribute *pwm_fan_attrs[] = {
 
 ATTRIBUTE_GROUPS(pwm_fan);
 
+int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
+{
+	struct device_node *np = dev->of_node;
+	struct property *pp;
+	int len, num, i;
+
+	pp = of_find_property(np, "cooling-pwm-values", &len);
+	if (!pp) {
+		dev_err(dev, "Property: 'cooling-pwm-values' not found\n");
+		return -EINVAL;
+	}
+
+	if (len = 0) {
+		dev_err(dev, "Length wrong value!\n");
+		return -EINVAL;
+	}
+
+	ctx->pwm_fan_cooling_states = devm_kzalloc(dev, len, GFP_KERNEL);
+	if (!ctx->pwm_fan_cooling_states) {
+		dev_err(dev, "Allocation failed for pwm dan cooling states\n");
+		return -ENOMEM;
+	}
+
+	num = len / sizeof(u32);
+	if (of_property_read_u32_array(np, pp->name,
+				       ctx->pwm_fan_cooling_states, num)) {
+		dev_err(dev, "Property: %s cannot be read!\n", pp->name);
+		return -EINVAL;
+	}
+
+	for (i = 0; i < num; i++) {
+		if (ctx->pwm_fan_cooling_states[i] > MAX_PWM) {
+			dev_err(dev, "PWM fan state[%d]:%d > %d\n", i,
+				ctx->pwm_fan_cooling_states[i], MAX_PWM);
+			return -EINVAL;
+		}
+	}
+
+	ctx->pwm_fan_max_state = num - 1;
+
+	return 0;
+}
+
 static int pwm_fan_probe(struct platform_device *pdev)
 {
 	struct device *hwmon;
@@ -120,6 +166,9 @@ static int pwm_fan_probe(struct platform_device *pdev)
 	}
 
 	platform_set_drvdata(pdev, ctx);
+	ret = pwm_fan_of_get_cooling_data(&pdev->dev, ctx);
+	if (ret)
+		return ret;
 
 	/* Set duty cycle to maximum allowed */
 	duty_cycle = ctx->pwm->period - 1;
-- 
2.0.0.rc2


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH 7/9] hwmon: thermal: Code for using PWM FAN as a cooling device
  2014-12-18 10:13 ` Lukasz Majewski
  (?)
@ 2014-12-18 10:13   ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-18 10:13 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki,
	Lukasz Majewski

The PWM FAN device can now be used as a thermal cooling device. Necessary
infrastructure has been added in this commit.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 drivers/hwmon/pwm-fan.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 78 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index 5854bb3..97b77e9 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -24,6 +24,7 @@
 #include <linux/platform_device.h>
 #include <linux/pwm.h>
 #include <linux/sysfs.h>
+#include <linux/thermal.h>
 
 #define MAX_PWM 255
 
@@ -68,6 +69,17 @@ exit_set_pwm_err:
 	return ret;
 }
 
+static void pwm_fan_update_state(struct pwm_fan_ctx *ctx, unsigned long pwm)
+{
+	int i;
+
+	for (i = 0; i < ctx->pwm_fan_max_state; ++i)
+		if (pwm < ctx->pwm_fan_cooling_states[i + 1])
+			break;
+
+	ctx->pwm_fan_state = i;
+}
+
 static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 		       const char *buf, size_t count)
 {
@@ -82,6 +94,7 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 	if (ret)
 		return ret;
 
+	pwm_fan_update_state(ctx, pwm);
 	return count;
 }
 
@@ -103,6 +116,59 @@ static struct attribute *pwm_fan_attrs[] = {
 
 ATTRIBUTE_GROUPS(pwm_fan);
 
+/* thermal cooling device callbacks */
+static int pwm_fan_get_max_state(struct thermal_cooling_device *cdev,
+				 unsigned long *state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+
+	*state = ctx->pwm_fan_max_state;
+
+	return 0;
+}
+
+static int pwm_fan_get_cur_state(struct thermal_cooling_device *cdev,
+				 unsigned long *state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+
+	if (!ctx)
+		return -EINVAL;
+
+	*state = ctx->pwm_fan_state;
+
+	return 0;
+}
+
+static int
+pwm_fan_set_cur_state(struct thermal_cooling_device *cdev, unsigned long state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+	int ret;
+
+	if (!ctx || (state > ctx->pwm_fan_max_state))
+		return -EINVAL;
+
+	if (state == ctx->pwm_fan_state)
+		return 0;
+
+	ret = __set_pwm(ctx, ctx->pwm_fan_cooling_states[state]);
+	if (ret) {
+		dev_err(&cdev->device, "Cannot set pwm!\n");
+		return ret;
+	}
+
+	ctx->pwm_fan_state = state;
+
+	return ret;
+}
+
+static const struct thermal_cooling_device_ops pwm_fan_cooling_ops = {
+	.get_max_state = pwm_fan_get_max_state,
+	.get_cur_state = pwm_fan_get_cur_state,
+	.set_cur_state = pwm_fan_set_cur_state,
+};
+
 int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
 {
 	struct device_node *np = dev->of_node;
@@ -148,8 +214,9 @@ int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
 
 static int pwm_fan_probe(struct platform_device *pdev)
 {
-	struct device *hwmon;
+	struct thermal_cooling_device *cdev;
 	struct pwm_fan_ctx *ctx;
+	struct device *hwmon;
 	int duty_cycle;
 	int ret;
 
@@ -194,6 +261,16 @@ static int pwm_fan_probe(struct platform_device *pdev)
 		pwm_disable(ctx->pwm);
 		return PTR_ERR(hwmon);
 	}
+
+	cdev = thermal_of_cooling_device_register(pdev->dev.of_node, "pwm-fan",
+						  ctx, &pwm_fan_cooling_ops);
+	if (IS_ERR(cdev)) {
+		dev_err(&pdev->dev,
+			"Failed to register pwm-fan as thermal cooling device");
+		pwm_disable(ctx->pwm);
+		return PTR_ERR(cdev);
+	}
+
 	return 0;
 }
 
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH 7/9] hwmon: thermal: Code for using PWM FAN as a cooling device
@ 2014-12-18 10:13   ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-18 10:13 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki,
	Lukasz Majewski

The PWM FAN device can now be used as a thermal cooling device. Necessary
infrastructure has been added in this commit.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 drivers/hwmon/pwm-fan.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 78 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index 5854bb3..97b77e9 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -24,6 +24,7 @@
 #include <linux/platform_device.h>
 #include <linux/pwm.h>
 #include <linux/sysfs.h>
+#include <linux/thermal.h>
 
 #define MAX_PWM 255
 
@@ -68,6 +69,17 @@ exit_set_pwm_err:
 	return ret;
 }
 
+static void pwm_fan_update_state(struct pwm_fan_ctx *ctx, unsigned long pwm)
+{
+	int i;
+
+	for (i = 0; i < ctx->pwm_fan_max_state; ++i)
+		if (pwm < ctx->pwm_fan_cooling_states[i + 1])
+			break;
+
+	ctx->pwm_fan_state = i;
+}
+
 static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 		       const char *buf, size_t count)
 {
@@ -82,6 +94,7 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 	if (ret)
 		return ret;
 
+	pwm_fan_update_state(ctx, pwm);
 	return count;
 }
 
@@ -103,6 +116,59 @@ static struct attribute *pwm_fan_attrs[] = {
 
 ATTRIBUTE_GROUPS(pwm_fan);
 
+/* thermal cooling device callbacks */
+static int pwm_fan_get_max_state(struct thermal_cooling_device *cdev,
+				 unsigned long *state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+
+	*state = ctx->pwm_fan_max_state;
+
+	return 0;
+}
+
+static int pwm_fan_get_cur_state(struct thermal_cooling_device *cdev,
+				 unsigned long *state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+
+	if (!ctx)
+		return -EINVAL;
+
+	*state = ctx->pwm_fan_state;
+
+	return 0;
+}
+
+static int
+pwm_fan_set_cur_state(struct thermal_cooling_device *cdev, unsigned long state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+	int ret;
+
+	if (!ctx || (state > ctx->pwm_fan_max_state))
+		return -EINVAL;
+
+	if (state == ctx->pwm_fan_state)
+		return 0;
+
+	ret = __set_pwm(ctx, ctx->pwm_fan_cooling_states[state]);
+	if (ret) {
+		dev_err(&cdev->device, "Cannot set pwm!\n");
+		return ret;
+	}
+
+	ctx->pwm_fan_state = state;
+
+	return ret;
+}
+
+static const struct thermal_cooling_device_ops pwm_fan_cooling_ops = {
+	.get_max_state = pwm_fan_get_max_state,
+	.get_cur_state = pwm_fan_get_cur_state,
+	.set_cur_state = pwm_fan_set_cur_state,
+};
+
 int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
 {
 	struct device_node *np = dev->of_node;
@@ -148,8 +214,9 @@ int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
 
 static int pwm_fan_probe(struct platform_device *pdev)
 {
-	struct device *hwmon;
+	struct thermal_cooling_device *cdev;
 	struct pwm_fan_ctx *ctx;
+	struct device *hwmon;
 	int duty_cycle;
 	int ret;
 
@@ -194,6 +261,16 @@ static int pwm_fan_probe(struct platform_device *pdev)
 		pwm_disable(ctx->pwm);
 		return PTR_ERR(hwmon);
 	}
+
+	cdev = thermal_of_cooling_device_register(pdev->dev.of_node, "pwm-fan",
+						  ctx, &pwm_fan_cooling_ops);
+	if (IS_ERR(cdev)) {
+		dev_err(&pdev->dev,
+			"Failed to register pwm-fan as thermal cooling device");
+		pwm_disable(ctx->pwm);
+		return PTR_ERR(cdev);
+	}
+
 	return 0;
 }
 
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [lm-sensors] [PATCH 7/9] hwmon: thermal: Code for using PWM FAN as a cooling device
@ 2014-12-18 10:13   ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-18 10:13 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki,
	Lukasz Majewski

The PWM FAN device can now be used as a thermal cooling device. Necessary
infrastructure has been added in this commit.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 drivers/hwmon/pwm-fan.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 78 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index 5854bb3..97b77e9 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -24,6 +24,7 @@
 #include <linux/platform_device.h>
 #include <linux/pwm.h>
 #include <linux/sysfs.h>
+#include <linux/thermal.h>
 
 #define MAX_PWM 255
 
@@ -68,6 +69,17 @@ exit_set_pwm_err:
 	return ret;
 }
 
+static void pwm_fan_update_state(struct pwm_fan_ctx *ctx, unsigned long pwm)
+{
+	int i;
+
+	for (i = 0; i < ctx->pwm_fan_max_state; ++i)
+		if (pwm < ctx->pwm_fan_cooling_states[i + 1])
+			break;
+
+	ctx->pwm_fan_state = i;
+}
+
 static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 		       const char *buf, size_t count)
 {
@@ -82,6 +94,7 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 	if (ret)
 		return ret;
 
+	pwm_fan_update_state(ctx, pwm);
 	return count;
 }
 
@@ -103,6 +116,59 @@ static struct attribute *pwm_fan_attrs[] = {
 
 ATTRIBUTE_GROUPS(pwm_fan);
 
+/* thermal cooling device callbacks */
+static int pwm_fan_get_max_state(struct thermal_cooling_device *cdev,
+				 unsigned long *state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+
+	*state = ctx->pwm_fan_max_state;
+
+	return 0;
+}
+
+static int pwm_fan_get_cur_state(struct thermal_cooling_device *cdev,
+				 unsigned long *state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+
+	if (!ctx)
+		return -EINVAL;
+
+	*state = ctx->pwm_fan_state;
+
+	return 0;
+}
+
+static int
+pwm_fan_set_cur_state(struct thermal_cooling_device *cdev, unsigned long state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+	int ret;
+
+	if (!ctx || (state > ctx->pwm_fan_max_state))
+		return -EINVAL;
+
+	if (state = ctx->pwm_fan_state)
+		return 0;
+
+	ret = __set_pwm(ctx, ctx->pwm_fan_cooling_states[state]);
+	if (ret) {
+		dev_err(&cdev->device, "Cannot set pwm!\n");
+		return ret;
+	}
+
+	ctx->pwm_fan_state = state;
+
+	return ret;
+}
+
+static const struct thermal_cooling_device_ops pwm_fan_cooling_ops = {
+	.get_max_state = pwm_fan_get_max_state,
+	.get_cur_state = pwm_fan_get_cur_state,
+	.set_cur_state = pwm_fan_set_cur_state,
+};
+
 int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
 {
 	struct device_node *np = dev->of_node;
@@ -148,8 +214,9 @@ int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
 
 static int pwm_fan_probe(struct platform_device *pdev)
 {
-	struct device *hwmon;
+	struct thermal_cooling_device *cdev;
 	struct pwm_fan_ctx *ctx;
+	struct device *hwmon;
 	int duty_cycle;
 	int ret;
 
@@ -194,6 +261,16 @@ static int pwm_fan_probe(struct platform_device *pdev)
 		pwm_disable(ctx->pwm);
 		return PTR_ERR(hwmon);
 	}
+
+	cdev = thermal_of_cooling_device_register(pdev->dev.of_node, "pwm-fan",
+						  ctx, &pwm_fan_cooling_ops);
+	if (IS_ERR(cdev)) {
+		dev_err(&pdev->dev,
+			"Failed to register pwm-fan as thermal cooling device");
+		pwm_disable(ctx->pwm);
+		return PTR_ERR(cdev);
+	}
+
 	return 0;
 }
 
-- 
2.0.0.rc2


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH 8/9] hwmon: thermal: Provide 'default-pulse-width' property to setup FAN on boot
  2014-12-18 10:13 ` Lukasz Majewski
  (?)
@ 2014-12-18 10:13   ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-18 10:13 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki,
	Lukasz Majewski

Up till now the PWM fan was enabled by default in the pwm-fan driver.
Now, by defining 'default-pulse-width' device tree property, it is possible
to configure the fan RPM on boot. By specifying value of 0, one can disable it.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 drivers/hwmon/pwm-fan.c | 34 ++++++++++++++++------------------
 1 file changed, 16 insertions(+), 18 deletions(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index 97b77e9..c1cf48b 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -34,6 +34,7 @@ struct pwm_fan_ctx {
 	unsigned int pwm_value;
 	unsigned int pwm_fan_state;
 	unsigned int pwm_fan_max_state;
+	unsigned int pwm_fan_default_width;
 	unsigned int *pwm_fan_cooling_states;
 };
 
@@ -172,8 +173,21 @@ static const struct thermal_cooling_device_ops pwm_fan_cooling_ops = {
 int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
 {
 	struct device_node *np = dev->of_node;
+	int len, num, i, ret;
 	struct property *pp;
-	int len, num, i;
+
+	ret = of_property_read_u32(np, "default-pulse-width",
+				   &ctx->pwm_fan_default_width);
+	if (ret) {
+		dev_err(dev, "Property: 'default-pulse-width' not found\n");
+		return -EINVAL;
+	}
+
+	if (ctx->pwm_fan_default_width > MAX_PWM) {
+		dev_err(dev, "'default-pulse-width %d larger than %d\n",
+			ctx->pwm_fan_default_width, MAX_PWM);
+		return -EINVAL;
+	}
 
 	pp = of_find_property(np, "cooling-pwm-values", &len);
 	if (!pp) {
@@ -217,7 +231,6 @@ static int pwm_fan_probe(struct platform_device *pdev)
 	struct thermal_cooling_device *cdev;
 	struct pwm_fan_ctx *ctx;
 	struct device *hwmon;
-	int duty_cycle;
 	int ret;
 
 	ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
@@ -237,22 +250,7 @@ static int pwm_fan_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
-	/* Set duty cycle to maximum allowed */
-	duty_cycle = ctx->pwm->period - 1;
-	ctx->pwm_value = MAX_PWM;
-
-	ret = pwm_config(ctx->pwm, duty_cycle, ctx->pwm->period);
-	if (ret) {
-		dev_err(&pdev->dev, "Failed to configure PWM\n");
-		return ret;
-	}
-
-	/* Enbale PWM output */
-	ret = pwm_enable(ctx->pwm);
-	if (ret) {
-		dev_err(&pdev->dev, "Failed to enable PWM\n");
-		return ret;
-	}
+	__set_pwm(ctx, ctx->pwm_fan_default_width);
 
 	hwmon = devm_hwmon_device_register_with_groups(&pdev->dev, "pwmfan",
 						       ctx, pwm_fan_groups);
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH 8/9] hwmon: thermal: Provide 'default-pulse-width' property to setup FAN on boot
@ 2014-12-18 10:13   ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-18 10:13 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki,
	Lukasz Majewski

Up till now the PWM fan was enabled by default in the pwm-fan driver.
Now, by defining 'default-pulse-width' device tree property, it is possible
to configure the fan RPM on boot. By specifying value of 0, one can disable it.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 drivers/hwmon/pwm-fan.c | 34 ++++++++++++++++------------------
 1 file changed, 16 insertions(+), 18 deletions(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index 97b77e9..c1cf48b 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -34,6 +34,7 @@ struct pwm_fan_ctx {
 	unsigned int pwm_value;
 	unsigned int pwm_fan_state;
 	unsigned int pwm_fan_max_state;
+	unsigned int pwm_fan_default_width;
 	unsigned int *pwm_fan_cooling_states;
 };
 
@@ -172,8 +173,21 @@ static const struct thermal_cooling_device_ops pwm_fan_cooling_ops = {
 int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
 {
 	struct device_node *np = dev->of_node;
+	int len, num, i, ret;
 	struct property *pp;
-	int len, num, i;
+
+	ret = of_property_read_u32(np, "default-pulse-width",
+				   &ctx->pwm_fan_default_width);
+	if (ret) {
+		dev_err(dev, "Property: 'default-pulse-width' not found\n");
+		return -EINVAL;
+	}
+
+	if (ctx->pwm_fan_default_width > MAX_PWM) {
+		dev_err(dev, "'default-pulse-width %d larger than %d\n",
+			ctx->pwm_fan_default_width, MAX_PWM);
+		return -EINVAL;
+	}
 
 	pp = of_find_property(np, "cooling-pwm-values", &len);
 	if (!pp) {
@@ -217,7 +231,6 @@ static int pwm_fan_probe(struct platform_device *pdev)
 	struct thermal_cooling_device *cdev;
 	struct pwm_fan_ctx *ctx;
 	struct device *hwmon;
-	int duty_cycle;
 	int ret;
 
 	ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
@@ -237,22 +250,7 @@ static int pwm_fan_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
-	/* Set duty cycle to maximum allowed */
-	duty_cycle = ctx->pwm->period - 1;
-	ctx->pwm_value = MAX_PWM;
-
-	ret = pwm_config(ctx->pwm, duty_cycle, ctx->pwm->period);
-	if (ret) {
-		dev_err(&pdev->dev, "Failed to configure PWM\n");
-		return ret;
-	}
-
-	/* Enbale PWM output */
-	ret = pwm_enable(ctx->pwm);
-	if (ret) {
-		dev_err(&pdev->dev, "Failed to enable PWM\n");
-		return ret;
-	}
+	__set_pwm(ctx, ctx->pwm_fan_default_width);
 
 	hwmon = devm_hwmon_device_register_with_groups(&pdev->dev, "pwmfan",
 						       ctx, pwm_fan_groups);
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [lm-sensors] [PATCH 8/9] hwmon: thermal: Provide 'default-pulse-width' property to setup FAN on boot
@ 2014-12-18 10:13   ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-18 10:13 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki,
	Lukasz Majewski

Up till now the PWM fan was enabled by default in the pwm-fan driver.
Now, by defining 'default-pulse-width' device tree property, it is possible
to configure the fan RPM on boot. By specifying value of 0, one can disable it.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 drivers/hwmon/pwm-fan.c | 34 ++++++++++++++++------------------
 1 file changed, 16 insertions(+), 18 deletions(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index 97b77e9..c1cf48b 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -34,6 +34,7 @@ struct pwm_fan_ctx {
 	unsigned int pwm_value;
 	unsigned int pwm_fan_state;
 	unsigned int pwm_fan_max_state;
+	unsigned int pwm_fan_default_width;
 	unsigned int *pwm_fan_cooling_states;
 };
 
@@ -172,8 +173,21 @@ static const struct thermal_cooling_device_ops pwm_fan_cooling_ops = {
 int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
 {
 	struct device_node *np = dev->of_node;
+	int len, num, i, ret;
 	struct property *pp;
-	int len, num, i;
+
+	ret = of_property_read_u32(np, "default-pulse-width",
+				   &ctx->pwm_fan_default_width);
+	if (ret) {
+		dev_err(dev, "Property: 'default-pulse-width' not found\n");
+		return -EINVAL;
+	}
+
+	if (ctx->pwm_fan_default_width > MAX_PWM) {
+		dev_err(dev, "'default-pulse-width %d larger than %d\n",
+			ctx->pwm_fan_default_width, MAX_PWM);
+		return -EINVAL;
+	}
 
 	pp = of_find_property(np, "cooling-pwm-values", &len);
 	if (!pp) {
@@ -217,7 +231,6 @@ static int pwm_fan_probe(struct platform_device *pdev)
 	struct thermal_cooling_device *cdev;
 	struct pwm_fan_ctx *ctx;
 	struct device *hwmon;
-	int duty_cycle;
 	int ret;
 
 	ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
@@ -237,22 +250,7 @@ static int pwm_fan_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
-	/* Set duty cycle to maximum allowed */
-	duty_cycle = ctx->pwm->period - 1;
-	ctx->pwm_value = MAX_PWM;
-
-	ret = pwm_config(ctx->pwm, duty_cycle, ctx->pwm->period);
-	if (ret) {
-		dev_err(&pdev->dev, "Failed to configure PWM\n");
-		return ret;
-	}
-
-	/* Enbale PWM output */
-	ret = pwm_enable(ctx->pwm);
-	if (ret) {
-		dev_err(&pdev->dev, "Failed to enable PWM\n");
-		return ret;
-	}
+	__set_pwm(ctx, ctx->pwm_fan_default_width);
 
 	hwmon = devm_hwmon_device_register_with_groups(&pdev->dev, "pwmfan",
 						       ctx, pwm_fan_groups);
-- 
2.0.0.rc2


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH 9/9] hwmon: thermal: dts: Disable FAN on boot on the Odroid U3
  2014-12-18 10:13 ` Lukasz Majewski
  (?)
@ 2014-12-18 10:13   ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-18 10:13 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki,
	Lukasz Majewski

By specifying default-pulse-width to zero, disable FAN on boot.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 arch/arm/boot/dts/exynos4412-odroidu3.dts | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
index cc50e96..fec063e 100644
--- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
+++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
@@ -39,6 +39,7 @@
 		cooling-max-state = <3>;
 		#cooling-cells = <2>;
 		cooling-pwm-values = <0 102 170 255>;
+		default-pulse-width = <0>;
 		status = "okay";
 	};
 
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH 9/9] hwmon: thermal: dts: Disable FAN on boot on the Odroid U3
@ 2014-12-18 10:13   ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-18 10:13 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki,
	Lukasz Majewski

By specifying default-pulse-width to zero, disable FAN on boot.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 arch/arm/boot/dts/exynos4412-odroidu3.dts | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
index cc50e96..fec063e 100644
--- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
+++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
@@ -39,6 +39,7 @@
 		cooling-max-state = <3>;
 		#cooling-cells = <2>;
 		cooling-pwm-values = <0 102 170 255>;
+		default-pulse-width = <0>;
 		status = "okay";
 	};
 
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [lm-sensors] [PATCH 9/9] hwmon: thermal: dts: Disable FAN on boot on the Odroid U3
@ 2014-12-18 10:13   ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-18 10:13 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki,
	Lukasz Majewski

By specifying default-pulse-width to zero, disable FAN on boot.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 arch/arm/boot/dts/exynos4412-odroidu3.dts | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
index cc50e96..fec063e 100644
--- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
+++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
@@ -39,6 +39,7 @@
 		cooling-max-state = <3>;
 		#cooling-cells = <2>;
 		cooling-pwm-values = <0 102 170 255>;
+		default-pulse-width = <0>;
 		status = "okay";
 	};
 
-- 
2.0.0.rc2


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* Re: [PATCH 2/9] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling device
  2014-12-18 10:13   ` [PATCH 2/9] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling device Lukasz Majewski
  (?)
@ 2014-12-18 10:42     ` Sjoerd Simons
  -1 siblings, 0 replies; 329+ messages in thread
From: Sjoerd Simons @ 2014-12-18 10:42 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki

[-- Attachment #1: Type: text/plain, Size: 2726 bytes --]

On Thu, 2014-12-18 at 11:13 +0100, Lukasz Majewski wrote:
> Several new properties to allow PWM fan working as a cooling device have been
> combined into this single commit.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
>  .../devicetree/bindings/hwmon/pwm-fan.txt          | 28 ++++++++++++++++++++++
>  1 file changed, 28 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> index 610757c..3877810 100644
> --- a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> +++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> @@ -3,10 +3,38 @@ Bindings for a fan connected to the PWM lines
>  Required properties:
>  - compatible	: "pwm-fan"
>  - pwms		: the PWM that is used to control the PWM fan
> +- cooling-pwm-values      : PWM duty cycle values relative to
> +			    cooling-max-pwm-value correspondig to
> +			    proper cooling states
> +- default-pulse-width     : Property specifying default pulse width for FAN
> +			    at system boot (zero to disable FAN on boot).
> +			    Allowed range is 0 to 255

The 0..255 range seems somewhat random. Would be nicer to either use the
approach of pwm-backlight (iotw, have the range go from the first to the
last entry of cooling-pwm-values) or simply have be the duty lenght in
NS as entries instead of the current indirection.

I assumed your cooling-pwm-values are a [0..255] range as well instead
of nanoseconds (would be good to make that more clear)?

Also having more consistent names would be nice.. To take pwm-backlight
as inspiration, cooling-levels and default-cooling-level would make it
more clear the second property picks a default setting from the first
one.

One thing i do wonder, is having an explicit default setting useful?
Should it not default to maximum cooling unless otherwise configured by
either the thermal framework or sysfs ?


> +Thorough description of the following bindings:
> +		cooling-min-state = <0>;
> +		cooling-max-state = <3>;
> +		#cooling-cells = <2>;
> +		thermal-zone {
> +			cpu_thermal: cpu-thermal {
> +			cooling-maps {
> +				map0 {
> +				     trip = <&cpu_alert1>;
> +				     cooling-device = <&fan0 0 1>;
> +				};
> +			};
> +		};
> +
> +for PWM FAN used as cooling device can be found at:
> +./Documentation/devicetree/bindings/thermal/thermal.txt
>  
>  Example:
>  	pwm-fan {
>  		compatible = "pwm-fan";
>  		status = "okay";
>  		pwms = <&pwm 0 10000 0>;
> +		cooling-min-state = <0>;
> +		cooling-max-state = <3>;
> +		#cooling-cells = <2>;
> +		cooling-pwm-values = <0 102 170 255>;
> +		default-pulse-width = <0>;
>  	};



[-- Attachment #2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 6170 bytes --]

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH 2/9] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling device
@ 2014-12-18 10:42     ` Sjoerd Simons
  0 siblings, 0 replies; 329+ messages in thread
From: Sjoerd Simons @ 2014-12-18 10:42 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki

[-- Attachment #1: Type: text/plain, Size: 2726 bytes --]

On Thu, 2014-12-18 at 11:13 +0100, Lukasz Majewski wrote:
> Several new properties to allow PWM fan working as a cooling device have been
> combined into this single commit.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
>  .../devicetree/bindings/hwmon/pwm-fan.txt          | 28 ++++++++++++++++++++++
>  1 file changed, 28 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> index 610757c..3877810 100644
> --- a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> +++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> @@ -3,10 +3,38 @@ Bindings for a fan connected to the PWM lines
>  Required properties:
>  - compatible	: "pwm-fan"
>  - pwms		: the PWM that is used to control the PWM fan
> +- cooling-pwm-values      : PWM duty cycle values relative to
> +			    cooling-max-pwm-value correspondig to
> +			    proper cooling states
> +- default-pulse-width     : Property specifying default pulse width for FAN
> +			    at system boot (zero to disable FAN on boot).
> +			    Allowed range is 0 to 255

The 0..255 range seems somewhat random. Would be nicer to either use the
approach of pwm-backlight (iotw, have the range go from the first to the
last entry of cooling-pwm-values) or simply have be the duty lenght in
NS as entries instead of the current indirection.

I assumed your cooling-pwm-values are a [0..255] range as well instead
of nanoseconds (would be good to make that more clear)?

Also having more consistent names would be nice.. To take pwm-backlight
as inspiration, cooling-levels and default-cooling-level would make it
more clear the second property picks a default setting from the first
one.

One thing i do wonder, is having an explicit default setting useful?
Should it not default to maximum cooling unless otherwise configured by
either the thermal framework or sysfs ?


> +Thorough description of the following bindings:
> +		cooling-min-state = <0>;
> +		cooling-max-state = <3>;
> +		#cooling-cells = <2>;
> +		thermal-zone {
> +			cpu_thermal: cpu-thermal {
> +			cooling-maps {
> +				map0 {
> +				     trip = <&cpu_alert1>;
> +				     cooling-device = <&fan0 0 1>;
> +				};
> +			};
> +		};
> +
> +for PWM FAN used as cooling device can be found at:
> +./Documentation/devicetree/bindings/thermal/thermal.txt
>  
>  Example:
>  	pwm-fan {
>  		compatible = "pwm-fan";
>  		status = "okay";
>  		pwms = <&pwm 0 10000 0>;
> +		cooling-min-state = <0>;
> +		cooling-max-state = <3>;
> +		#cooling-cells = <2>;
> +		cooling-pwm-values = <0 102 170 255>;
> +		default-pulse-width = <0>;
>  	};



[-- Attachment #2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 6170 bytes --]

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [lm-sensors] [PATCH 2/9] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling
@ 2014-12-18 10:42     ` Sjoerd Simons
  0 siblings, 0 replies; 329+ messages in thread
From: Sjoerd Simons @ 2014-12-18 10:42 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki


[-- Attachment #1.1: Type: text/plain, Size: 2726 bytes --]

On Thu, 2014-12-18 at 11:13 +0100, Lukasz Majewski wrote:
> Several new properties to allow PWM fan working as a cooling device have been
> combined into this single commit.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
>  .../devicetree/bindings/hwmon/pwm-fan.txt          | 28 ++++++++++++++++++++++
>  1 file changed, 28 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> index 610757c..3877810 100644
> --- a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> +++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> @@ -3,10 +3,38 @@ Bindings for a fan connected to the PWM lines
>  Required properties:
>  - compatible	: "pwm-fan"
>  - pwms		: the PWM that is used to control the PWM fan
> +- cooling-pwm-values      : PWM duty cycle values relative to
> +			    cooling-max-pwm-value correspondig to
> +			    proper cooling states
> +- default-pulse-width     : Property specifying default pulse width for FAN
> +			    at system boot (zero to disable FAN on boot).
> +			    Allowed range is 0 to 255

The 0..255 range seems somewhat random. Would be nicer to either use the
approach of pwm-backlight (iotw, have the range go from the first to the
last entry of cooling-pwm-values) or simply have be the duty lenght in
NS as entries instead of the current indirection.

I assumed your cooling-pwm-values are a [0..255] range as well instead
of nanoseconds (would be good to make that more clear)?

Also having more consistent names would be nice.. To take pwm-backlight
as inspiration, cooling-levels and default-cooling-level would make it
more clear the second property picks a default setting from the first
one.

One thing i do wonder, is having an explicit default setting useful?
Should it not default to maximum cooling unless otherwise configured by
either the thermal framework or sysfs ?


> +Thorough description of the following bindings:
> +		cooling-min-state = <0>;
> +		cooling-max-state = <3>;
> +		#cooling-cells = <2>;
> +		thermal-zone {
> +			cpu_thermal: cpu-thermal {
> +			cooling-maps {
> +				map0 {
> +				     trip = <&cpu_alert1>;
> +				     cooling-device = <&fan0 0 1>;
> +				};
> +			};
> +		};
> +
> +for PWM FAN used as cooling device can be found at:
> +./Documentation/devicetree/bindings/thermal/thermal.txt
>  
>  Example:
>  	pwm-fan {
>  		compatible = "pwm-fan";
>  		status = "okay";
>  		pwms = <&pwm 0 10000 0>;
> +		cooling-min-state = <0>;
> +		cooling-max-state = <3>;
> +		#cooling-cells = <2>;
> +		cooling-pwm-values = <0 102 170 255>;
> +		default-pulse-width = <0>;
>  	};



[-- Attachment #1.2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 6170 bytes --]

[-- Attachment #2: Type: text/plain, Size: 153 bytes --]

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH 2/9] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling device
  2014-12-18 10:13   ` [PATCH 2/9] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling device Lukasz Majewski
  (?)
@ 2014-12-18 14:27     ` Guenter Roeck
  -1 siblings, 0 replies; 329+ messages in thread
From: Guenter Roeck @ 2014-12-18 14:27 UTC (permalink / raw)
  To: Lukasz Majewski, Eduardo Valentin, Kamil Debski, Jean Delvare
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki

On 12/18/2014 02:13 AM, Lukasz Majewski wrote:
> Several new properties to allow PWM fan working as a cooling device have been
> combined into this single commit.
>
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
>   .../devicetree/bindings/hwmon/pwm-fan.txt          | 28 ++++++++++++++++++++++
>   1 file changed, 28 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> index 610757c..3877810 100644
> --- a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> +++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> @@ -3,10 +3,38 @@ Bindings for a fan connected to the PWM lines
>   Required properties:
>   - compatible	: "pwm-fan"
>   - pwms		: the PWM that is used to control the PWM fan
> +- cooling-pwm-values      : PWM duty cycle values relative to
> +			    cooling-max-pwm-value correspondig to
> +			    proper cooling states

I don't understand what you mean with "relative to". Please elaborate.
Do you mean "associated with" ?

Where is "cooling-max-pwm-value" defined, and how is this all expected
to relate to the maximum duty cycle value provided by the pwm device ?

> +- default-pulse-width     : Property specifying default pulse width for FAN
> +			    at system boot (zero to disable FAN on boot).
> +			    Allowed range is 0 to 255

You'll need dt maintainer approval for the new properties.

One thing I wonder about though is why you use "default-pulse-width"
and not "default-pwm". Seems to be arbitrary. I don't see "pulse-width"
used anywhere in the upstream kernel.

I am somewhat concerned that you define the new properties as mandatory.
That means existing configurations will fail, which does not seem to be
a good idea. It would be more appropriate to not configure the thermal device
if the new properties are not provided.

The newly introduced semantics also conflicts with the current semantics,
which sets the initial duty cycle initially to the maximum allowed duty cycle
as reported by the pwm device itself.

Guenter

> +
> +Thorough description of the following bindings:
> +		cooling-min-state = <0>;
> +		cooling-max-state = <3>;
> +		#cooling-cells = <2>;
> +		thermal-zone {
> +			cpu_thermal: cpu-thermal {
> +			cooling-maps {
> +				map0 {
> +				     trip = <&cpu_alert1>;
> +				     cooling-device = <&fan0 0 1>;
> +				};
> +			};
> +		};
> +
> +for PWM FAN used as cooling device can be found at:
> +./Documentation/devicetree/bindings/thermal/thermal.txt
>
>   Example:
>   	pwm-fan {
>   		compatible = "pwm-fan";
>   		status = "okay";
>   		pwms = <&pwm 0 10000 0>;
> +		cooling-min-state = <0>;
> +		cooling-max-state = <3>;
> +		#cooling-cells = <2>;
> +		cooling-pwm-values = <0 102 170 255>;
> +		default-pulse-width = <0>;
>   	};
>


^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH 2/9] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling device
@ 2014-12-18 14:27     ` Guenter Roeck
  0 siblings, 0 replies; 329+ messages in thread
From: Guenter Roeck @ 2014-12-18 14:27 UTC (permalink / raw)
  To: Lukasz Majewski, Eduardo Valentin, Kamil Debski, Jean Delvare
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki

On 12/18/2014 02:13 AM, Lukasz Majewski wrote:
> Several new properties to allow PWM fan working as a cooling device have been
> combined into this single commit.
>
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
>   .../devicetree/bindings/hwmon/pwm-fan.txt          | 28 ++++++++++++++++++++++
>   1 file changed, 28 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> index 610757c..3877810 100644
> --- a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> +++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> @@ -3,10 +3,38 @@ Bindings for a fan connected to the PWM lines
>   Required properties:
>   - compatible	: "pwm-fan"
>   - pwms		: the PWM that is used to control the PWM fan
> +- cooling-pwm-values      : PWM duty cycle values relative to
> +			    cooling-max-pwm-value correspondig to
> +			    proper cooling states

I don't understand what you mean with "relative to". Please elaborate.
Do you mean "associated with" ?

Where is "cooling-max-pwm-value" defined, and how is this all expected
to relate to the maximum duty cycle value provided by the pwm device ?

> +- default-pulse-width     : Property specifying default pulse width for FAN
> +			    at system boot (zero to disable FAN on boot).
> +			    Allowed range is 0 to 255

You'll need dt maintainer approval for the new properties.

One thing I wonder about though is why you use "default-pulse-width"
and not "default-pwm". Seems to be arbitrary. I don't see "pulse-width"
used anywhere in the upstream kernel.

I am somewhat concerned that you define the new properties as mandatory.
That means existing configurations will fail, which does not seem to be
a good idea. It would be more appropriate to not configure the thermal device
if the new properties are not provided.

The newly introduced semantics also conflicts with the current semantics,
which sets the initial duty cycle initially to the maximum allowed duty cycle
as reported by the pwm device itself.

Guenter

> +
> +Thorough description of the following bindings:
> +		cooling-min-state = <0>;
> +		cooling-max-state = <3>;
> +		#cooling-cells = <2>;
> +		thermal-zone {
> +			cpu_thermal: cpu-thermal {
> +			cooling-maps {
> +				map0 {
> +				     trip = <&cpu_alert1>;
> +				     cooling-device = <&fan0 0 1>;
> +				};
> +			};
> +		};
> +
> +for PWM FAN used as cooling device can be found at:
> +./Documentation/devicetree/bindings/thermal/thermal.txt
>
>   Example:
>   	pwm-fan {
>   		compatible = "pwm-fan";
>   		status = "okay";
>   		pwms = <&pwm 0 10000 0>;
> +		cooling-min-state = <0>;
> +		cooling-max-state = <3>;
> +		#cooling-cells = <2>;
> +		cooling-pwm-values = <0 102 170 255>;
> +		default-pulse-width = <0>;
>   	};
>


^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [lm-sensors] [PATCH 2/9] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling
@ 2014-12-18 14:27     ` Guenter Roeck
  0 siblings, 0 replies; 329+ messages in thread
From: Guenter Roeck @ 2014-12-18 14:27 UTC (permalink / raw)
  To: Lukasz Majewski, Eduardo Valentin, Kamil Debski, Jean Delvare
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki

On 12/18/2014 02:13 AM, Lukasz Majewski wrote:
> Several new properties to allow PWM fan working as a cooling device have been
> combined into this single commit.
>
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
>   .../devicetree/bindings/hwmon/pwm-fan.txt          | 28 ++++++++++++++++++++++
>   1 file changed, 28 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> index 610757c..3877810 100644
> --- a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> +++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> @@ -3,10 +3,38 @@ Bindings for a fan connected to the PWM lines
>   Required properties:
>   - compatible	: "pwm-fan"
>   - pwms		: the PWM that is used to control the PWM fan
> +- cooling-pwm-values      : PWM duty cycle values relative to
> +			    cooling-max-pwm-value correspondig to
> +			    proper cooling states

I don't understand what you mean with "relative to". Please elaborate.
Do you mean "associated with" ?

Where is "cooling-max-pwm-value" defined, and how is this all expected
to relate to the maximum duty cycle value provided by the pwm device ?

> +- default-pulse-width     : Property specifying default pulse width for FAN
> +			    at system boot (zero to disable FAN on boot).
> +			    Allowed range is 0 to 255

You'll need dt maintainer approval for the new properties.

One thing I wonder about though is why you use "default-pulse-width"
and not "default-pwm". Seems to be arbitrary. I don't see "pulse-width"
used anywhere in the upstream kernel.

I am somewhat concerned that you define the new properties as mandatory.
That means existing configurations will fail, which does not seem to be
a good idea. It would be more appropriate to not configure the thermal device
if the new properties are not provided.

The newly introduced semantics also conflicts with the current semantics,
which sets the initial duty cycle initially to the maximum allowed duty cycle
as reported by the pwm device itself.

Guenter

> +
> +Thorough description of the following bindings:
> +		cooling-min-state = <0>;
> +		cooling-max-state = <3>;
> +		#cooling-cells = <2>;
> +		thermal-zone {
> +			cpu_thermal: cpu-thermal {
> +			cooling-maps {
> +				map0 {
> +				     trip = <&cpu_alert1>;
> +				     cooling-device = <&fan0 0 1>;
> +				};
> +			};
> +		};
> +
> +for PWM FAN used as cooling device can be found at:
> +./Documentation/devicetree/bindings/thermal/thermal.txt
>
>   Example:
>   	pwm-fan {
>   		compatible = "pwm-fan";
>   		status = "okay";
>   		pwms = <&pwm 0 10000 0>;
> +		cooling-min-state = <0>;
> +		cooling-max-state = <3>;
> +		#cooling-cells = <2>;
> +		cooling-pwm-values = <0 102 170 255>;
> +		default-pulse-width = <0>;
>   	};
>


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH 2/9] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling device
  2014-12-18 10:42     ` [PATCH 2/9] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling device Sjoerd Simons
  (?)
@ 2014-12-19 15:32       ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-19 15:32 UTC (permalink / raw)
  To: Sjoerd Simons
  Cc: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki

Hi Sjoerd,

Thanks for your feedback and sorry for a late reply.

> On Thu, 2014-12-18 at 11:13 +0100, Lukasz Majewski wrote:
> > Several new properties to allow PWM fan working as a cooling device
> > have been combined into this single commit.
> > 
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > ---
> >  .../devicetree/bindings/hwmon/pwm-fan.txt          | 28
> > ++++++++++++++++++++++ 1 file changed, 28 insertions(+)
> > 
> > diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> > b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt index
> > 610757c..3877810 100644 ---
> > a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt +++
> > b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt @@ -3,10
> > +3,38 @@ Bindings for a fan connected to the PWM lines Required
> > properties:
> >  - compatible	: "pwm-fan"
> >  - pwms		: the PWM that is used to control the PWM fan
> > +- cooling-pwm-values      : PWM duty cycle values relative to
> > +			    cooling-max-pwm-value correspondig to
> > +			    proper cooling states
> > +- default-pulse-width     : Property specifying default pulse
> > width for FAN
> > +			    at system boot (zero to disable FAN on
> > boot).
> > +			    Allowed range is 0 to 255
> 
> The 0..255 range seems somewhat random. Would be nicer to either use
> the approach of pwm-backlight (iotw, have the range go from the first
> to the last entry of cooling-pwm-values) 

I'm OK to change the default-pulse-width to be similar to
"default-brightness-level" (as it is in
Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt)

> or simply have be the duty
> lenght in NS as entries instead of the current indirection.

I'd prefer to keep the indirection - as it is utilized in the current
pwm-fan.c driver.

> 
> I assumed your cooling-pwm-values are a [0..255] range as well instead
> of nanoseconds (would be good to make that more clear)?

Your assumption is correct. cooling-pwm-values are indeed in the
[0..255] range. I will add this information in v2.

> 
> Also having more consistent names would be nice.. To take
> pwm-backlight as inspiration, cooling-levels and
> default-cooling-level would make it more clear the second property
> picks a default setting from the first one.

I agree.

> 
> One thing i do wonder, is having an explicit default setting useful?
> Should it not default to maximum cooling unless otherwise configured
> by either the thermal framework or sysfs ?

Enabling pan to full RPM was the default behaviour in the current
pwm-fan.c file.

To be honest, there is no need to enable fan to full RPM speed in this
board for following reasons:
1. In Odroid the FAN is optional (stacked on top of a heat sink) - very
often it is just enough to only have the heat sink.

2. Odroid has thermal enabled by default and IMHO it would be more
feasible to allow thermal to control fan from the very beginning.

However, I can also understand if the policy for hwmon implies a rule
to enable by default all fans to full RPM speed.

> 
> 
> > +Thorough description of the following bindings:
> > +		cooling-min-state = <0>;
> > +		cooling-max-state = <3>;
> > +		#cooling-cells = <2>;
> > +		thermal-zone {
> > +			cpu_thermal: cpu-thermal {
> > +			cooling-maps {
> > +				map0 {
> > +				     trip = <&cpu_alert1>;
> > +				     cooling-device = <&fan0 0 1>;
> > +				};
> > +			};
> > +		};
> > +
> > +for PWM FAN used as cooling device can be found at:
> > +./Documentation/devicetree/bindings/thermal/thermal.txt
> >  
> >  Example:
> >  	pwm-fan {
> >  		compatible = "pwm-fan";
> >  		status = "okay";
> >  		pwms = <&pwm 0 10000 0>;
> > +		cooling-min-state = <0>;
> > +		cooling-max-state = <3>;
> > +		#cooling-cells = <2>;
> > +		cooling-pwm-values = <0 102 170 255>;
> > +		default-pulse-width = <0>;
> >  	};
> 
> 



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH 2/9] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling device
@ 2014-12-19 15:32       ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-19 15:32 UTC (permalink / raw)
  To: Sjoerd Simons
  Cc: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki

Hi Sjoerd,

Thanks for your feedback and sorry for a late reply.

> On Thu, 2014-12-18 at 11:13 +0100, Lukasz Majewski wrote:
> > Several new properties to allow PWM fan working as a cooling device
> > have been combined into this single commit.
> > 
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > ---
> >  .../devicetree/bindings/hwmon/pwm-fan.txt          | 28
> > ++++++++++++++++++++++ 1 file changed, 28 insertions(+)
> > 
> > diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> > b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt index
> > 610757c..3877810 100644 ---
> > a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt +++
> > b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt @@ -3,10
> > +3,38 @@ Bindings for a fan connected to the PWM lines Required
> > properties:
> >  - compatible	: "pwm-fan"
> >  - pwms		: the PWM that is used to control the PWM fan
> > +- cooling-pwm-values      : PWM duty cycle values relative to
> > +			    cooling-max-pwm-value correspondig to
> > +			    proper cooling states
> > +- default-pulse-width     : Property specifying default pulse
> > width for FAN
> > +			    at system boot (zero to disable FAN on
> > boot).
> > +			    Allowed range is 0 to 255
> 
> The 0..255 range seems somewhat random. Would be nicer to either use
> the approach of pwm-backlight (iotw, have the range go from the first
> to the last entry of cooling-pwm-values) 

I'm OK to change the default-pulse-width to be similar to
"default-brightness-level" (as it is in
Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt)

> or simply have be the duty
> lenght in NS as entries instead of the current indirection.

I'd prefer to keep the indirection - as it is utilized in the current
pwm-fan.c driver.

> 
> I assumed your cooling-pwm-values are a [0..255] range as well instead
> of nanoseconds (would be good to make that more clear)?

Your assumption is correct. cooling-pwm-values are indeed in the
[0..255] range. I will add this information in v2.

> 
> Also having more consistent names would be nice.. To take
> pwm-backlight as inspiration, cooling-levels and
> default-cooling-level would make it more clear the second property
> picks a default setting from the first one.

I agree.

> 
> One thing i do wonder, is having an explicit default setting useful?
> Should it not default to maximum cooling unless otherwise configured
> by either the thermal framework or sysfs ?

Enabling pan to full RPM was the default behaviour in the current
pwm-fan.c file.

To be honest, there is no need to enable fan to full RPM speed in this
board for following reasons:
1. In Odroid the FAN is optional (stacked on top of a heat sink) - very
often it is just enough to only have the heat sink.

2. Odroid has thermal enabled by default and IMHO it would be more
feasible to allow thermal to control fan from the very beginning.

However, I can also understand if the policy for hwmon implies a rule
to enable by default all fans to full RPM speed.

> 
> 
> > +Thorough description of the following bindings:
> > +		cooling-min-state = <0>;
> > +		cooling-max-state = <3>;
> > +		#cooling-cells = <2>;
> > +		thermal-zone {
> > +			cpu_thermal: cpu-thermal {
> > +			cooling-maps {
> > +				map0 {
> > +				     trip = <&cpu_alert1>;
> > +				     cooling-device = <&fan0 0 1>;
> > +				};
> > +			};
> > +		};
> > +
> > +for PWM FAN used as cooling device can be found at:
> > +./Documentation/devicetree/bindings/thermal/thermal.txt
> >  
> >  Example:
> >  	pwm-fan {
> >  		compatible = "pwm-fan";
> >  		status = "okay";
> >  		pwms = <&pwm 0 10000 0>;
> > +		cooling-min-state = <0>;
> > +		cooling-max-state = <3>;
> > +		#cooling-cells = <2>;
> > +		cooling-pwm-values = <0 102 170 255>;
> > +		default-pulse-width = <0>;
> >  	};
> 
> 



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [lm-sensors] [PATCH 2/9] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling
@ 2014-12-19 15:32       ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-19 15:32 UTC (permalink / raw)
  To: Sjoerd Simons
  Cc: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki

Hi Sjoerd,

Thanks for your feedback and sorry for a late reply.

> On Thu, 2014-12-18 at 11:13 +0100, Lukasz Majewski wrote:
> > Several new properties to allow PWM fan working as a cooling device
> > have been combined into this single commit.
> > 
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > ---
> >  .../devicetree/bindings/hwmon/pwm-fan.txt          | 28
> > ++++++++++++++++++++++ 1 file changed, 28 insertions(+)
> > 
> > diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> > b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt index
> > 610757c..3877810 100644 ---
> > a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt +++
> > b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt @@ -3,10
> > +3,38 @@ Bindings for a fan connected to the PWM lines Required
> > properties:
> >  - compatible	: "pwm-fan"
> >  - pwms		: the PWM that is used to control the PWM fan
> > +- cooling-pwm-values      : PWM duty cycle values relative to
> > +			    cooling-max-pwm-value correspondig to
> > +			    proper cooling states
> > +- default-pulse-width     : Property specifying default pulse
> > width for FAN
> > +			    at system boot (zero to disable FAN on
> > boot).
> > +			    Allowed range is 0 to 255
> 
> The 0..255 range seems somewhat random. Would be nicer to either use
> the approach of pwm-backlight (iotw, have the range go from the first
> to the last entry of cooling-pwm-values) 

I'm OK to change the default-pulse-width to be similar to
"default-brightness-level" (as it is in
Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt)

> or simply have be the duty
> lenght in NS as entries instead of the current indirection.

I'd prefer to keep the indirection - as it is utilized in the current
pwm-fan.c driver.

> 
> I assumed your cooling-pwm-values are a [0..255] range as well instead
> of nanoseconds (would be good to make that more clear)?

Your assumption is correct. cooling-pwm-values are indeed in the
[0..255] range. I will add this information in v2.

> 
> Also having more consistent names would be nice.. To take
> pwm-backlight as inspiration, cooling-levels and
> default-cooling-level would make it more clear the second property
> picks a default setting from the first one.

I agree.

> 
> One thing i do wonder, is having an explicit default setting useful?
> Should it not default to maximum cooling unless otherwise configured
> by either the thermal framework or sysfs ?

Enabling pan to full RPM was the default behaviour in the current
pwm-fan.c file.

To be honest, there is no need to enable fan to full RPM speed in this
board for following reasons:
1. In Odroid the FAN is optional (stacked on top of a heat sink) - very
often it is just enough to only have the heat sink.

2. Odroid has thermal enabled by default and IMHO it would be more
feasible to allow thermal to control fan from the very beginning.

However, I can also understand if the policy for hwmon implies a rule
to enable by default all fans to full RPM speed.

> 
> 
> > +Thorough description of the following bindings:
> > +		cooling-min-state = <0>;
> > +		cooling-max-state = <3>;
> > +		#cooling-cells = <2>;
> > +		thermal-zone {
> > +			cpu_thermal: cpu-thermal {
> > +			cooling-maps {
> > +				map0 {
> > +				     trip = <&cpu_alert1>;
> > +				     cooling-device = <&fan0 0 1>;
> > +				};
> > +			};
> > +		};
> > +
> > +for PWM FAN used as cooling device can be found at:
> > +./Documentation/devicetree/bindings/thermal/thermal.txt
> >  
> >  Example:
> >  	pwm-fan {
> >  		compatible = "pwm-fan";
> >  		status = "okay";
> >  		pwms = <&pwm 0 10000 0>;
> > +		cooling-min-state = <0>;
> > +		cooling-max-state = <3>;
> > +		#cooling-cells = <2>;
> > +		cooling-pwm-values = <0 102 170 255>;
> > +		default-pulse-width = <0>;
> >  	};
> 
> 



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH 2/9] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling device
  2014-12-19 15:32       ` [PATCH 2/9] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling device Lukasz Majewski
  (?)
@ 2014-12-19 16:02         ` Guenter Roeck
  -1 siblings, 0 replies; 329+ messages in thread
From: Guenter Roeck @ 2014-12-19 16:02 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Sjoerd Simons, Eduardo Valentin, Kamil Debski, Jean Delvare,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki

On Fri, Dec 19, 2014 at 04:32:24PM +0100, Lukasz Majewski wrote:
> Hi Sjoerd,
> 
> Thanks for your feedback and sorry for a late reply.
> 
> > On Thu, 2014-12-18 at 11:13 +0100, Lukasz Majewski wrote:
> > > Several new properties to allow PWM fan working as a cooling device
> > > have been combined into this single commit.
> > > 
> > > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > > ---
> > >  .../devicetree/bindings/hwmon/pwm-fan.txt          | 28
> > > ++++++++++++++++++++++ 1 file changed, 28 insertions(+)
> > > 
> > > diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> > > b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt index
> > > 610757c..3877810 100644 ---
> > > a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt +++
> > > b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt @@ -3,10
> > > +3,38 @@ Bindings for a fan connected to the PWM lines Required
> > > properties:
> > >  - compatible	: "pwm-fan"
> > >  - pwms		: the PWM that is used to control the PWM fan
> > > +- cooling-pwm-values      : PWM duty cycle values relative to
> > > +			    cooling-max-pwm-value correspondig to
> > > +			    proper cooling states
> > > +- default-pulse-width     : Property specifying default pulse
> > > width for FAN
> > > +			    at system boot (zero to disable FAN on
> > > boot).
> > > +			    Allowed range is 0 to 255
> > 
> > The 0..255 range seems somewhat random. Would be nicer to either use
> > the approach of pwm-backlight (iotw, have the range go from the first
> > to the last entry of cooling-pwm-values) 
> 
> I'm OK to change the default-pulse-width to be similar to
> "default-brightness-level" (as it is in
> Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt)
> 
> > or simply have be the duty
> > lenght in NS as entries instead of the current indirection.
> 
> I'd prefer to keep the indirection - as it is utilized in the current
> pwm-fan.c driver.
> 
FWIW, devicetree information is supposed to be implementation independent.
So this is a poor argument.

> 
> Enabling pan to full RPM was the default behaviour in the current
> pwm-fan.c file.
> 
> To be honest, there is no need to enable fan to full RPM speed in this
> board for following reasons:
> 1. In Odroid the FAN is optional (stacked on top of a heat sink) - very
> often it is just enough to only have the heat sink.
> 
> 2. Odroid has thermal enabled by default and IMHO it would be more
> feasible to allow thermal to control fan from the very beginning.
> 
> However, I can also understand if the policy for hwmon implies a rule
> to enable by default all fans to full RPM speed.
> 
Why and how does that all suggest that the current default behavior
should be changed ?

Guenter

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH 2/9] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling device
@ 2014-12-19 16:02         ` Guenter Roeck
  0 siblings, 0 replies; 329+ messages in thread
From: Guenter Roeck @ 2014-12-19 16:02 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Sjoerd Simons, Eduardo Valentin, Kamil Debski, Jean Delvare,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki

On Fri, Dec 19, 2014 at 04:32:24PM +0100, Lukasz Majewski wrote:
> Hi Sjoerd,
> 
> Thanks for your feedback and sorry for a late reply.
> 
> > On Thu, 2014-12-18 at 11:13 +0100, Lukasz Majewski wrote:
> > > Several new properties to allow PWM fan working as a cooling device
> > > have been combined into this single commit.
> > > 
> > > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > > ---
> > >  .../devicetree/bindings/hwmon/pwm-fan.txt          | 28
> > > ++++++++++++++++++++++ 1 file changed, 28 insertions(+)
> > > 
> > > diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> > > b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt index
> > > 610757c..3877810 100644 ---
> > > a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt +++
> > > b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt @@ -3,10
> > > +3,38 @@ Bindings for a fan connected to the PWM lines Required
> > > properties:
> > >  - compatible	: "pwm-fan"
> > >  - pwms		: the PWM that is used to control the PWM fan
> > > +- cooling-pwm-values      : PWM duty cycle values relative to
> > > +			    cooling-max-pwm-value correspondig to
> > > +			    proper cooling states
> > > +- default-pulse-width     : Property specifying default pulse
> > > width for FAN
> > > +			    at system boot (zero to disable FAN on
> > > boot).
> > > +			    Allowed range is 0 to 255
> > 
> > The 0..255 range seems somewhat random. Would be nicer to either use
> > the approach of pwm-backlight (iotw, have the range go from the first
> > to the last entry of cooling-pwm-values) 
> 
> I'm OK to change the default-pulse-width to be similar to
> "default-brightness-level" (as it is in
> Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt)
> 
> > or simply have be the duty
> > lenght in NS as entries instead of the current indirection.
> 
> I'd prefer to keep the indirection - as it is utilized in the current
> pwm-fan.c driver.
> 
FWIW, devicetree information is supposed to be implementation independent.
So this is a poor argument.

> 
> Enabling pan to full RPM was the default behaviour in the current
> pwm-fan.c file.
> 
> To be honest, there is no need to enable fan to full RPM speed in this
> board for following reasons:
> 1. In Odroid the FAN is optional (stacked on top of a heat sink) - very
> often it is just enough to only have the heat sink.
> 
> 2. Odroid has thermal enabled by default and IMHO it would be more
> feasible to allow thermal to control fan from the very beginning.
> 
> However, I can also understand if the policy for hwmon implies a rule
> to enable by default all fans to full RPM speed.
> 
Why and how does that all suggest that the current default behavior
should be changed ?

Guenter

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [lm-sensors] [PATCH 2/9] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling
@ 2014-12-19 16:02         ` Guenter Roeck
  0 siblings, 0 replies; 329+ messages in thread
From: Guenter Roeck @ 2014-12-19 16:02 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Sjoerd Simons, Eduardo Valentin, Kamil Debski, Jean Delvare,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki

On Fri, Dec 19, 2014 at 04:32:24PM +0100, Lukasz Majewski wrote:
> Hi Sjoerd,
> 
> Thanks for your feedback and sorry for a late reply.
> 
> > On Thu, 2014-12-18 at 11:13 +0100, Lukasz Majewski wrote:
> > > Several new properties to allow PWM fan working as a cooling device
> > > have been combined into this single commit.
> > > 
> > > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > > ---
> > >  .../devicetree/bindings/hwmon/pwm-fan.txt          | 28
> > > ++++++++++++++++++++++ 1 file changed, 28 insertions(+)
> > > 
> > > diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> > > b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt index
> > > 610757c..3877810 100644 ---
> > > a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt +++
> > > b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt @@ -3,10
> > > +3,38 @@ Bindings for a fan connected to the PWM lines Required
> > > properties:
> > >  - compatible	: "pwm-fan"
> > >  - pwms		: the PWM that is used to control the PWM fan
> > > +- cooling-pwm-values      : PWM duty cycle values relative to
> > > +			    cooling-max-pwm-value correspondig to
> > > +			    proper cooling states
> > > +- default-pulse-width     : Property specifying default pulse
> > > width for FAN
> > > +			    at system boot (zero to disable FAN on
> > > boot).
> > > +			    Allowed range is 0 to 255
> > 
> > The 0..255 range seems somewhat random. Would be nicer to either use
> > the approach of pwm-backlight (iotw, have the range go from the first
> > to the last entry of cooling-pwm-values) 
> 
> I'm OK to change the default-pulse-width to be similar to
> "default-brightness-level" (as it is in
> Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt)
> 
> > or simply have be the duty
> > lenght in NS as entries instead of the current indirection.
> 
> I'd prefer to keep the indirection - as it is utilized in the current
> pwm-fan.c driver.
> 
FWIW, devicetree information is supposed to be implementation independent.
So this is a poor argument.

> 
> Enabling pan to full RPM was the default behaviour in the current
> pwm-fan.c file.
> 
> To be honest, there is no need to enable fan to full RPM speed in this
> board for following reasons:
> 1. In Odroid the FAN is optional (stacked on top of a heat sink) - very
> often it is just enough to only have the heat sink.
> 
> 2. Odroid has thermal enabled by default and IMHO it would be more
> feasible to allow thermal to control fan from the very beginning.
> 
> However, I can also understand if the policy for hwmon implies a rule
> to enable by default all fans to full RPM speed.
> 
Why and how does that all suggest that the current default behavior
should be changed ?

Guenter

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH 2/9] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling device
  2014-12-19 16:02         ` [PATCH 2/9] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling device Guenter Roeck
  (?)
@ 2014-12-19 16:13           ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-19 16:13 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Sjoerd Simons, Eduardo Valentin, Kamil Debski, Jean Delvare,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki

Hi Guenter,

> On Fri, Dec 19, 2014 at 04:32:24PM +0100, Lukasz Majewski wrote:
> > Hi Sjoerd,
> > 
> > Thanks for your feedback and sorry for a late reply.
> > 
> > > On Thu, 2014-12-18 at 11:13 +0100, Lukasz Majewski wrote:
> > > > Several new properties to allow PWM fan working as a cooling
> > > > device have been combined into this single commit.
> > > > 
> > > > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > > > ---
> > > >  .../devicetree/bindings/hwmon/pwm-fan.txt          | 28
> > > > ++++++++++++++++++++++ 1 file changed, 28 insertions(+)
> > > > 
> > > > diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> > > > b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt index
> > > > 610757c..3877810 100644 ---
> > > > a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt +++
> > > > b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt @@ -3,10
> > > > +3,38 @@ Bindings for a fan connected to the PWM lines Required
> > > > properties:
> > > >  - compatible	: "pwm-fan"
> > > >  - pwms		: the PWM that is used to control the
> > > > PWM fan +- cooling-pwm-values      : PWM duty cycle values
> > > > relative to
> > > > +			    cooling-max-pwm-value correspondig
> > > > to
> > > > +			    proper cooling states
> > > > +- default-pulse-width     : Property specifying default pulse
> > > > width for FAN
> > > > +			    at system boot (zero to disable
> > > > FAN on boot).
> > > > +			    Allowed range is 0 to 255
> > > 
> > > The 0..255 range seems somewhat random. Would be nicer to either
> > > use the approach of pwm-backlight (iotw, have the range go from
> > > the first to the last entry of cooling-pwm-values) 
> > 
> > I'm OK to change the default-pulse-width to be similar to
> > "default-brightness-level" (as it is in
> > Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt)
> > 
> > > or simply have be the duty
> > > lenght in NS as entries instead of the current indirection.
> > 
> > I'd prefer to keep the indirection - as it is utilized in the
> > current pwm-fan.c driver.
> > 
> FWIW, devicetree information is supposed to be implementation
> independent. So this is a poor argument.

Many other pwm drivers use the indirection - e.g. mentioned
pwm-backlight.


> 
> > 
> > Enabling pan to full RPM was the default behaviour in the current
> > pwm-fan.c file.
> > 
> > To be honest, there is no need to enable fan to full RPM speed in
> > this board for following reasons:
> > 1. In Odroid the FAN is optional (stacked on top of a heat sink) -
> > very often it is just enough to only have the heat sink.
> > 
> > 2. Odroid has thermal enabled by default and IMHO it would be more
> > feasible to allow thermal to control fan from the very beginning.
> > 
> > However, I can also understand if the policy for hwmon implies a
> > rule to enable by default all fans to full RPM speed.
> > 
> Why and how does that all suggest that the current default behavior
> should be changed ?

I wanted to avoid the unpleasant sound for full speed fan when thermal
is not enabled by default.

But as I said, I fully understand the policy and I would be happy to
comply with it as thermal should reduce the fan speed anyway at boot
time.

> 
> Guenter



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH 2/9] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling device
@ 2014-12-19 16:13           ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-19 16:13 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Sjoerd Simons, Eduardo Valentin, Kamil Debski, Jean Delvare,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki

Hi Guenter,

> On Fri, Dec 19, 2014 at 04:32:24PM +0100, Lukasz Majewski wrote:
> > Hi Sjoerd,
> > 
> > Thanks for your feedback and sorry for a late reply.
> > 
> > > On Thu, 2014-12-18 at 11:13 +0100, Lukasz Majewski wrote:
> > > > Several new properties to allow PWM fan working as a cooling
> > > > device have been combined into this single commit.
> > > > 
> > > > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > > > ---
> > > >  .../devicetree/bindings/hwmon/pwm-fan.txt          | 28
> > > > ++++++++++++++++++++++ 1 file changed, 28 insertions(+)
> > > > 
> > > > diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> > > > b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt index
> > > > 610757c..3877810 100644 ---
> > > > a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt +++
> > > > b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt @@ -3,10
> > > > +3,38 @@ Bindings for a fan connected to the PWM lines Required
> > > > properties:
> > > >  - compatible	: "pwm-fan"
> > > >  - pwms		: the PWM that is used to control the
> > > > PWM fan +- cooling-pwm-values      : PWM duty cycle values
> > > > relative to
> > > > +			    cooling-max-pwm-value correspondig
> > > > to
> > > > +			    proper cooling states
> > > > +- default-pulse-width     : Property specifying default pulse
> > > > width for FAN
> > > > +			    at system boot (zero to disable
> > > > FAN on boot).
> > > > +			    Allowed range is 0 to 255
> > > 
> > > The 0..255 range seems somewhat random. Would be nicer to either
> > > use the approach of pwm-backlight (iotw, have the range go from
> > > the first to the last entry of cooling-pwm-values) 
> > 
> > I'm OK to change the default-pulse-width to be similar to
> > "default-brightness-level" (as it is in
> > Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt)
> > 
> > > or simply have be the duty
> > > lenght in NS as entries instead of the current indirection.
> > 
> > I'd prefer to keep the indirection - as it is utilized in the
> > current pwm-fan.c driver.
> > 
> FWIW, devicetree information is supposed to be implementation
> independent. So this is a poor argument.

Many other pwm drivers use the indirection - e.g. mentioned
pwm-backlight.


> 
> > 
> > Enabling pan to full RPM was the default behaviour in the current
> > pwm-fan.c file.
> > 
> > To be honest, there is no need to enable fan to full RPM speed in
> > this board for following reasons:
> > 1. In Odroid the FAN is optional (stacked on top of a heat sink) -
> > very often it is just enough to only have the heat sink.
> > 
> > 2. Odroid has thermal enabled by default and IMHO it would be more
> > feasible to allow thermal to control fan from the very beginning.
> > 
> > However, I can also understand if the policy for hwmon implies a
> > rule to enable by default all fans to full RPM speed.
> > 
> Why and how does that all suggest that the current default behavior
> should be changed ?

I wanted to avoid the unpleasant sound for full speed fan when thermal
is not enabled by default.

But as I said, I fully understand the policy and I would be happy to
comply with it as thermal should reduce the fan speed anyway at boot
time.

> 
> Guenter



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [lm-sensors] [PATCH 2/9] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling
@ 2014-12-19 16:13           ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-19 16:13 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Sjoerd Simons, Eduardo Valentin, Kamil Debski, Jean Delvare,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki

Hi Guenter,

> On Fri, Dec 19, 2014 at 04:32:24PM +0100, Lukasz Majewski wrote:
> > Hi Sjoerd,
> > 
> > Thanks for your feedback and sorry for a late reply.
> > 
> > > On Thu, 2014-12-18 at 11:13 +0100, Lukasz Majewski wrote:
> > > > Several new properties to allow PWM fan working as a cooling
> > > > device have been combined into this single commit.
> > > > 
> > > > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > > > ---
> > > >  .../devicetree/bindings/hwmon/pwm-fan.txt          | 28
> > > > ++++++++++++++++++++++ 1 file changed, 28 insertions(+)
> > > > 
> > > > diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> > > > b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt index
> > > > 610757c..3877810 100644 ---
> > > > a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt +++
> > > > b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt @@ -3,10
> > > > +3,38 @@ Bindings for a fan connected to the PWM lines Required
> > > > properties:
> > > >  - compatible	: "pwm-fan"
> > > >  - pwms		: the PWM that is used to control the
> > > > PWM fan +- cooling-pwm-values      : PWM duty cycle values
> > > > relative to
> > > > +			    cooling-max-pwm-value correspondig
> > > > to
> > > > +			    proper cooling states
> > > > +- default-pulse-width     : Property specifying default pulse
> > > > width for FAN
> > > > +			    at system boot (zero to disable
> > > > FAN on boot).
> > > > +			    Allowed range is 0 to 255
> > > 
> > > The 0..255 range seems somewhat random. Would be nicer to either
> > > use the approach of pwm-backlight (iotw, have the range go from
> > > the first to the last entry of cooling-pwm-values) 
> > 
> > I'm OK to change the default-pulse-width to be similar to
> > "default-brightness-level" (as it is in
> > Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt)
> > 
> > > or simply have be the duty
> > > lenght in NS as entries instead of the current indirection.
> > 
> > I'd prefer to keep the indirection - as it is utilized in the
> > current pwm-fan.c driver.
> > 
> FWIW, devicetree information is supposed to be implementation
> independent. So this is a poor argument.

Many other pwm drivers use the indirection - e.g. mentioned
pwm-backlight.


> 
> > 
> > Enabling pan to full RPM was the default behaviour in the current
> > pwm-fan.c file.
> > 
> > To be honest, there is no need to enable fan to full RPM speed in
> > this board for following reasons:
> > 1. In Odroid the FAN is optional (stacked on top of a heat sink) -
> > very often it is just enough to only have the heat sink.
> > 
> > 2. Odroid has thermal enabled by default and IMHO it would be more
> > feasible to allow thermal to control fan from the very beginning.
> > 
> > However, I can also understand if the policy for hwmon implies a
> > rule to enable by default all fans to full RPM speed.
> > 
> Why and how does that all suggest that the current default behavior
> should be changed ?

I wanted to avoid the unpleasant sound for full speed fan when thermal
is not enabled by default.

But as I said, I fully understand the policy and I would be happy to
comply with it as thermal should reduce the fan speed anyway at boot
time.

> 
> Guenter



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH 2/9] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling device
@ 2014-12-19 16:25       ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-19 16:25 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Eduardo Valentin, Kamil Debski, Jean Delvare, lm-sensors,
	Linux PM list, linux-samsung-soc, devicetree, Lukasz Majewski,
	Kukjin Kim, linux-kernel, Sylwester Nawrocki

Hi Guenter,

> On 12/18/2014 02:13 AM, Lukasz Majewski wrote:
> > Several new properties to allow PWM fan working as a cooling device
> > have been combined into this single commit.
> >
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > ---
> >   .../devicetree/bindings/hwmon/pwm-fan.txt          | 28
> > ++++++++++++++++++++++ 1 file changed, 28 insertions(+)
> >
> > diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> > b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt index
> > 610757c..3877810 100644 ---
> > a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt +++
> > b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt @@ -3,10
> > +3,38 @@ Bindings for a fan connected to the PWM lines Required
> > properties:
> >   - compatible	: "pwm-fan"
> >   - pwms		: the PWM that is used to control the PWM
> > fan +- cooling-pwm-values      : PWM duty cycle values relative to
> > +			    cooling-max-pwm-value correspondig to
> > +			    proper cooling states
> 
> I don't understand what you mean with "relative to". Please elaborate.
> Do you mean "associated with" ?

I meant that cooling-pwm-values is no greater than
cooling-max-pwm-value (which was present in some earlier version of
this patch and had value of 255).

This description is wrong and will be reworded.

> 
> Where is "cooling-max-pwm-value" defined, 

It was present in some early version of this patch.

> and how is this all expected
> to relate to the maximum duty cycle value provided by the pwm device ?
> 
> > +- default-pulse-width     : Property specifying default pulse
> > width for FAN
> > +			    at system boot (zero to disable FAN on
> > boot).
> > +			    Allowed range is 0 to 255
> 
> You'll need dt maintainer approval for the new properties.

I'm wondering how this patch series will get merged. It touches three
different subsystems (thermal, hwmon and device tree for Exynos). 

For me it would be best to use thermal tree (hence Odroid U3 fan is
supposed to work as a cooling device) with ACKs from other subsystems
maintainers.

> 
> One thing I wonder about though is why you use "default-pulse-width"
> and not "default-pwm". Seems to be arbitrary. I don't see
> "pulse-width" used anywhere in the upstream kernel.

Believe or not I've also considered the default-pwm name.

> 
> I am somewhat concerned that you define the new properties as
> mandatory. That means existing configurations will fail, which does
> not seem to be a good idea. It would be more appropriate to not
> configure the thermal device if the new properties are not provided.

Very good point. I will do that for v2.

> 
> The newly introduced semantics also conflicts with the current
> semantics, which sets the initial duty cycle initially to the maximum
> allowed duty cycle as reported by the pwm device itself.

Ok. I will stick to above policy and then the "default-pulse-width"
property can be removed.

> 
> Guenter
> 
> > +
> > +Thorough description of the following bindings:
> > +		cooling-min-state = <0>;
> > +		cooling-max-state = <3>;
> > +		#cooling-cells = <2>;
> > +		thermal-zone {
> > +			cpu_thermal: cpu-thermal {
> > +			cooling-maps {
> > +				map0 {
> > +				     trip = <&cpu_alert1>;
> > +				     cooling-device = <&fan0 0 1>;
> > +				};
> > +			};
> > +		};
> > +
> > +for PWM FAN used as cooling device can be found at:
> > +./Documentation/devicetree/bindings/thermal/thermal.txt
> >
> >   Example:
> >   	pwm-fan {
> >   		compatible = "pwm-fan";
> >   		status = "okay";
> >   		pwms = <&pwm 0 10000 0>;
> > +		cooling-min-state = <0>;
> > +		cooling-max-state = <3>;
> > +		#cooling-cells = <2>;
> > +		cooling-pwm-values = <0 102 170 255>;
> > +		default-pulse-width = <0>;
> >   	};
> >
> 



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH 2/9] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling device
@ 2014-12-19 16:25       ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-19 16:25 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Eduardo Valentin, Kamil Debski, Jean Delvare,
	lm-sensors-GZX6beZjE8VD60Wz+7aTrA, Linux PM list,
	linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Lukasz Majewski, Kukjin Kim,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Sylwester Nawrocki

Hi Guenter,

> On 12/18/2014 02:13 AM, Lukasz Majewski wrote:
> > Several new properties to allow PWM fan working as a cooling device
> > have been combined into this single commit.
> >
> > Signed-off-by: Lukasz Majewski <l.majewski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
> > ---
> >   .../devicetree/bindings/hwmon/pwm-fan.txt          | 28
> > ++++++++++++++++++++++ 1 file changed, 28 insertions(+)
> >
> > diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> > b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt index
> > 610757c..3877810 100644 ---
> > a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt +++
> > b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt @@ -3,10
> > +3,38 @@ Bindings for a fan connected to the PWM lines Required
> > properties:
> >   - compatible	: "pwm-fan"
> >   - pwms		: the PWM that is used to control the PWM
> > fan +- cooling-pwm-values      : PWM duty cycle values relative to
> > +			    cooling-max-pwm-value correspondig to
> > +			    proper cooling states
> 
> I don't understand what you mean with "relative to". Please elaborate.
> Do you mean "associated with" ?

I meant that cooling-pwm-values is no greater than
cooling-max-pwm-value (which was present in some earlier version of
this patch and had value of 255).

This description is wrong and will be reworded.

> 
> Where is "cooling-max-pwm-value" defined, 

It was present in some early version of this patch.

> and how is this all expected
> to relate to the maximum duty cycle value provided by the pwm device ?
> 
> > +- default-pulse-width     : Property specifying default pulse
> > width for FAN
> > +			    at system boot (zero to disable FAN on
> > boot).
> > +			    Allowed range is 0 to 255
> 
> You'll need dt maintainer approval for the new properties.

I'm wondering how this patch series will get merged. It touches three
different subsystems (thermal, hwmon and device tree for Exynos). 

For me it would be best to use thermal tree (hence Odroid U3 fan is
supposed to work as a cooling device) with ACKs from other subsystems
maintainers.

> 
> One thing I wonder about though is why you use "default-pulse-width"
> and not "default-pwm". Seems to be arbitrary. I don't see
> "pulse-width" used anywhere in the upstream kernel.

Believe or not I've also considered the default-pwm name.

> 
> I am somewhat concerned that you define the new properties as
> mandatory. That means existing configurations will fail, which does
> not seem to be a good idea. It would be more appropriate to not
> configure the thermal device if the new properties are not provided.

Very good point. I will do that for v2.

> 
> The newly introduced semantics also conflicts with the current
> semantics, which sets the initial duty cycle initially to the maximum
> allowed duty cycle as reported by the pwm device itself.

Ok. I will stick to above policy and then the "default-pulse-width"
property can be removed.

> 
> Guenter
> 
> > +
> > +Thorough description of the following bindings:
> > +		cooling-min-state = <0>;
> > +		cooling-max-state = <3>;
> > +		#cooling-cells = <2>;
> > +		thermal-zone {
> > +			cpu_thermal: cpu-thermal {
> > +			cooling-maps {
> > +				map0 {
> > +				     trip = <&cpu_alert1>;
> > +				     cooling-device = <&fan0 0 1>;
> > +				};
> > +			};
> > +		};
> > +
> > +for PWM FAN used as cooling device can be found at:
> > +./Documentation/devicetree/bindings/thermal/thermal.txt
> >
> >   Example:
> >   	pwm-fan {
> >   		compatible = "pwm-fan";
> >   		status = "okay";
> >   		pwms = <&pwm 0 10000 0>;
> > +		cooling-min-state = <0>;
> > +		cooling-max-state = <3>;
> > +		#cooling-cells = <2>;
> > +		cooling-pwm-values = <0 102 170 255>;
> > +		default-pulse-width = <0>;
> >   	};
> >
> 



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [lm-sensors] [PATCH 2/9] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling
@ 2014-12-19 16:25       ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-19 16:25 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Eduardo Valentin, Kamil Debski, Jean Delvare, lm-sensors,
	Linux PM list, linux-samsung-soc, devicetree, Lukasz Majewski,
	Kukjin Kim, linux-kernel, Sylwester Nawrocki

Hi Guenter,

> On 12/18/2014 02:13 AM, Lukasz Majewski wrote:
> > Several new properties to allow PWM fan working as a cooling device
> > have been combined into this single commit.
> >
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > ---
> >   .../devicetree/bindings/hwmon/pwm-fan.txt          | 28
> > ++++++++++++++++++++++ 1 file changed, 28 insertions(+)
> >
> > diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> > b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt index
> > 610757c..3877810 100644 ---
> > a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt +++
> > b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt @@ -3,10
> > +3,38 @@ Bindings for a fan connected to the PWM lines Required
> > properties:
> >   - compatible	: "pwm-fan"
> >   - pwms		: the PWM that is used to control the PWM
> > fan +- cooling-pwm-values      : PWM duty cycle values relative to
> > +			    cooling-max-pwm-value correspondig to
> > +			    proper cooling states
> 
> I don't understand what you mean with "relative to". Please elaborate.
> Do you mean "associated with" ?

I meant that cooling-pwm-values is no greater than
cooling-max-pwm-value (which was present in some earlier version of
this patch and had value of 255).

This description is wrong and will be reworded.

> 
> Where is "cooling-max-pwm-value" defined, 

It was present in some early version of this patch.

> and how is this all expected
> to relate to the maximum duty cycle value provided by the pwm device ?
> 
> > +- default-pulse-width     : Property specifying default pulse
> > width for FAN
> > +			    at system boot (zero to disable FAN on
> > boot).
> > +			    Allowed range is 0 to 255
> 
> You'll need dt maintainer approval for the new properties.

I'm wondering how this patch series will get merged. It touches three
different subsystems (thermal, hwmon and device tree for Exynos). 

For me it would be best to use thermal tree (hence Odroid U3 fan is
supposed to work as a cooling device) with ACKs from other subsystems
maintainers.

> 
> One thing I wonder about though is why you use "default-pulse-width"
> and not "default-pwm". Seems to be arbitrary. I don't see
> "pulse-width" used anywhere in the upstream kernel.

Believe or not I've also considered the default-pwm name.

> 
> I am somewhat concerned that you define the new properties as
> mandatory. That means existing configurations will fail, which does
> not seem to be a good idea. It would be more appropriate to not
> configure the thermal device if the new properties are not provided.

Very good point. I will do that for v2.

> 
> The newly introduced semantics also conflicts with the current
> semantics, which sets the initial duty cycle initially to the maximum
> allowed duty cycle as reported by the pwm device itself.

Ok. I will stick to above policy and then the "default-pulse-width"
property can be removed.

> 
> Guenter
> 
> > +
> > +Thorough description of the following bindings:
> > +		cooling-min-state = <0>;
> > +		cooling-max-state = <3>;
> > +		#cooling-cells = <2>;
> > +		thermal-zone {
> > +			cpu_thermal: cpu-thermal {
> > +			cooling-maps {
> > +				map0 {
> > +				     trip = <&cpu_alert1>;
> > +				     cooling-device = <&fan0 0 1>;
> > +				};
> > +			};
> > +		};
> > +
> > +for PWM FAN used as cooling device can be found at:
> > +./Documentation/devicetree/bindings/thermal/thermal.txt
> >
> >   Example:
> >   	pwm-fan {
> >   		compatible = "pwm-fan";
> >   		status = "okay";
> >   		pwms = <&pwm 0 10000 0>;
> > +		cooling-min-state = <0>;
> > +		cooling-max-state = <3>;
> > +		#cooling-cells = <2>;
> > +		cooling-pwm-values = <0 102 170 255>;
> > +		default-pulse-width = <0>;
> >   	};
> >
> 



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 329+ messages in thread

* [PATCH v2 0/8] hwmon: thermal: Odroid U3: Provide support for Odroid U3 fan
  2014-12-18 10:13 ` Lukasz Majewski
  (?)
@ 2014-12-22 16:27   ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-22 16:27 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

Presented patches add support for Odroid's U3 optional CPU FAN, which uses PWM
subsystem for low level control.

After successful probe it registers itself as a cooling device for thermal
subsystem. To preserve the ability to use this fan as a PWM device stubs for
thermal_of_cooling_device_register() and thermal_cdev_update() have been added.

Additionally, devices without support for DTS are still supported.

To provide correct functionality, new properties to device tree description for 
Exynos4412 and in particular Odroid U3 have been added.

Those patches were tested on Exynos4412 - Odroid U3 board.

Patches were applied on:
linux-soc-thermal/next branch
SHA1: d8c3cd75e77d8033b29470525781befc11b6bf7d

with following preceding patch series:
'thermal: exynos: Thermal code rework to use device tree'
http://www.spinics.net/lists/linux-samsung-soc/msg37719.html

Presented code utilize reworked Exynos thermal subsystem.

Kamil Debski (1):
  ARM: dts: Add pwm-fan node to the Odroid-U3 board

Lukasz Majewski (7):
  thermal: Provide stub for thermal_of_cooling_device_register()
    function
  thermal: Provide stub for thermal_cdev_update() function
  hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a
    cooling device
  hwmon: thermal: dts: Add properties to use pwm-fan device as a cooling
    device in Odroid U3
  hwmon: thermal: Extract __set_pwm() function to only modify PWM duty
    cycle
  hwmon: thermal: Read PWM FAN configuration from device tree
  hwmon: thermal: Code for using PWM FAN as a cooling device

 .../devicetree/bindings/hwmon/pwm-fan.txt          |  23 +++
 arch/arm/boot/dts/exynos4.dtsi                     |   2 +-
 arch/arm/boot/dts/exynos4412-odroidu3.dts          |  44 ++++++
 drivers/hwmon/pwm-fan.c                            | 166 +++++++++++++++++++--
 include/linux/thermal.h                            |  20 ++-
 5 files changed, 235 insertions(+), 20 deletions(-)

-- 
2.0.0.rc2


^ permalink raw reply	[flat|nested] 329+ messages in thread

* [PATCH v2 0/8] hwmon: thermal: Odroid U3: Provide support for Odroid U3 fan
@ 2014-12-22 16:27   ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-22 16:27 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

Presented patches add support for Odroid's U3 optional CPU FAN, which uses PWM
subsystem for low level control.

After successful probe it registers itself as a cooling device for thermal
subsystem. To preserve the ability to use this fan as a PWM device stubs for
thermal_of_cooling_device_register() and thermal_cdev_update() have been added.

Additionally, devices without support for DTS are still supported.

To provide correct functionality, new properties to device tree description for 
Exynos4412 and in particular Odroid U3 have been added.

Those patches were tested on Exynos4412 - Odroid U3 board.

Patches were applied on:
linux-soc-thermal/next branch
SHA1: d8c3cd75e77d8033b29470525781befc11b6bf7d

with following preceding patch series:
'thermal: exynos: Thermal code rework to use device tree'
http://www.spinics.net/lists/linux-samsung-soc/msg37719.html

Presented code utilize reworked Exynos thermal subsystem.

Kamil Debski (1):
  ARM: dts: Add pwm-fan node to the Odroid-U3 board

Lukasz Majewski (7):
  thermal: Provide stub for thermal_of_cooling_device_register()
    function
  thermal: Provide stub for thermal_cdev_update() function
  hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a
    cooling device
  hwmon: thermal: dts: Add properties to use pwm-fan device as a cooling
    device in Odroid U3
  hwmon: thermal: Extract __set_pwm() function to only modify PWM duty
    cycle
  hwmon: thermal: Read PWM FAN configuration from device tree
  hwmon: thermal: Code for using PWM FAN as a cooling device

 .../devicetree/bindings/hwmon/pwm-fan.txt          |  23 +++
 arch/arm/boot/dts/exynos4.dtsi                     |   2 +-
 arch/arm/boot/dts/exynos4412-odroidu3.dts          |  44 ++++++
 drivers/hwmon/pwm-fan.c                            | 166 +++++++++++++++++++--
 include/linux/thermal.h                            |  20 ++-
 5 files changed, 235 insertions(+), 20 deletions(-)

-- 
2.0.0.rc2


^ permalink raw reply	[flat|nested] 329+ messages in thread

* [lm-sensors] [PATCH v2 0/8] hwmon: thermal: Odroid U3: Provide support for Odroid U3 fan
@ 2014-12-22 16:27   ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-22 16:27 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

Presented patches add support for Odroid's U3 optional CPU FAN, which uses PWM
subsystem for low level control.

After successful probe it registers itself as a cooling device for thermal
subsystem. To preserve the ability to use this fan as a PWM device stubs for
thermal_of_cooling_device_register() and thermal_cdev_update() have been added.

Additionally, devices without support for DTS are still supported.

To provide correct functionality, new properties to device tree description for 
Exynos4412 and in particular Odroid U3 have been added.

Those patches were tested on Exynos4412 - Odroid U3 board.

Patches were applied on:
linux-soc-thermal/next branch
SHA1: d8c3cd75e77d8033b29470525781befc11b6bf7d

with following preceding patch series:
'thermal: exynos: Thermal code rework to use device tree'
http://www.spinics.net/lists/linux-samsung-soc/msg37719.html

Presented code utilize reworked Exynos thermal subsystem.

Kamil Debski (1):
  ARM: dts: Add pwm-fan node to the Odroid-U3 board

Lukasz Majewski (7):
  thermal: Provide stub for thermal_of_cooling_device_register()
    function
  thermal: Provide stub for thermal_cdev_update() function
  hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a
    cooling device
  hwmon: thermal: dts: Add properties to use pwm-fan device as a cooling
    device in Odroid U3
  hwmon: thermal: Extract __set_pwm() function to only modify PWM duty
    cycle
  hwmon: thermal: Read PWM FAN configuration from device tree
  hwmon: thermal: Code for using PWM FAN as a cooling device

 .../devicetree/bindings/hwmon/pwm-fan.txt          |  23 +++
 arch/arm/boot/dts/exynos4.dtsi                     |   2 +-
 arch/arm/boot/dts/exynos4412-odroidu3.dts          |  44 ++++++
 drivers/hwmon/pwm-fan.c                            | 166 +++++++++++++++++++--
 include/linux/thermal.h                            |  20 ++-
 5 files changed, 235 insertions(+), 20 deletions(-)

-- 
2.0.0.rc2


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 329+ messages in thread

* [PATCH v2 1/8] thermal: Provide stub for thermal_of_cooling_device_register() function
  2014-12-22 16:27   ` Lukasz Majewski
  (?)
@ 2014-12-22 16:27     ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-22 16:27 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

Odroid U3 fan can work without being registered as OF cooling device
(with CONFIG_THERMAL_OF disabled).
In this situation it can be controlled via PWM entry at
/sys/class/hwmon/hwmon0/pwm1.

Therefore, the thermal_of_cooling_device_register() function needs a stub
to allow clean compilation.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
---
 include/linux/thermal.h | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index 2de3d9e..871123c 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -328,6 +328,10 @@ thermal_zone_of_sensor_register(struct device *dev, int id, void *data,
 				const struct thermal_zone_of_device_ops *ops);
 void thermal_zone_of_sensor_unregister(struct device *dev,
 				       struct thermal_zone_device *tz);
+struct thermal_cooling_device *
+thermal_of_cooling_device_register(struct device_node *np,
+				   char *type, void *devdata,
+				   const struct thermal_cooling_device_ops *);
 #else
 static inline struct thermal_zone_device *
 thermal_zone_of_sensor_register(struct device *dev, int id, void *data,
@@ -342,6 +346,13 @@ void thermal_zone_of_sensor_unregister(struct device *dev,
 {
 }
 
+static inline struct thermal_cooling_device *
+thermal_of_cooling_device_register(struct device_node *np,
+				   char *type, void *devdata,
+				   const struct thermal_cooling_device_ops *ops)
+{
+	return NULL;
+}
 #endif
 struct thermal_zone_device *thermal_zone_device_register(const char *, int, int,
 		void *, struct thermal_zone_device_ops *,
@@ -357,9 +368,6 @@ void thermal_zone_device_update(struct thermal_zone_device *);
 
 struct thermal_cooling_device *thermal_cooling_device_register(char *, void *,
 		const struct thermal_cooling_device_ops *);
-struct thermal_cooling_device *
-thermal_of_cooling_device_register(struct device_node *np, char *, void *,
-				   const struct thermal_cooling_device_ops *);
 void thermal_cooling_device_unregister(struct thermal_cooling_device *);
 struct thermal_zone_device *thermal_zone_get_zone_by_name(const char *name);
 int thermal_zone_get_temp(struct thermal_zone_device *tz, unsigned long *temp);
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v2 1/8] thermal: Provide stub for thermal_of_cooling_device_register() function
@ 2014-12-22 16:27     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-22 16:27 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

Odroid U3 fan can work without being registered as OF cooling device
(with CONFIG_THERMAL_OF disabled).
In this situation it can be controlled via PWM entry at
/sys/class/hwmon/hwmon0/pwm1.

Therefore, the thermal_of_cooling_device_register() function needs a stub
to allow clean compilation.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
---
 include/linux/thermal.h | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index 2de3d9e..871123c 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -328,6 +328,10 @@ thermal_zone_of_sensor_register(struct device *dev, int id, void *data,
 				const struct thermal_zone_of_device_ops *ops);
 void thermal_zone_of_sensor_unregister(struct device *dev,
 				       struct thermal_zone_device *tz);
+struct thermal_cooling_device *
+thermal_of_cooling_device_register(struct device_node *np,
+				   char *type, void *devdata,
+				   const struct thermal_cooling_device_ops *);
 #else
 static inline struct thermal_zone_device *
 thermal_zone_of_sensor_register(struct device *dev, int id, void *data,
@@ -342,6 +346,13 @@ void thermal_zone_of_sensor_unregister(struct device *dev,
 {
 }
 
+static inline struct thermal_cooling_device *
+thermal_of_cooling_device_register(struct device_node *np,
+				   char *type, void *devdata,
+				   const struct thermal_cooling_device_ops *ops)
+{
+	return NULL;
+}
 #endif
 struct thermal_zone_device *thermal_zone_device_register(const char *, int, int,
 		void *, struct thermal_zone_device_ops *,
@@ -357,9 +368,6 @@ void thermal_zone_device_update(struct thermal_zone_device *);
 
 struct thermal_cooling_device *thermal_cooling_device_register(char *, void *,
 		const struct thermal_cooling_device_ops *);
-struct thermal_cooling_device *
-thermal_of_cooling_device_register(struct device_node *np, char *, void *,
-				   const struct thermal_cooling_device_ops *);
 void thermal_cooling_device_unregister(struct thermal_cooling_device *);
 struct thermal_zone_device *thermal_zone_get_zone_by_name(const char *name);
 int thermal_zone_get_temp(struct thermal_zone_device *tz, unsigned long *temp);
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [lm-sensors] [PATCH v2 1/8] thermal: Provide stub for thermal_of_cooling_device_register() function
@ 2014-12-22 16:27     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-22 16:27 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

Odroid U3 fan can work without being registered as OF cooling device
(with CONFIG_THERMAL_OF disabled).
In this situation it can be controlled via PWM entry at
/sys/class/hwmon/hwmon0/pwm1.

Therefore, the thermal_of_cooling_device_register() function needs a stub
to allow clean compilation.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
---
 include/linux/thermal.h | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index 2de3d9e..871123c 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -328,6 +328,10 @@ thermal_zone_of_sensor_register(struct device *dev, int id, void *data,
 				const struct thermal_zone_of_device_ops *ops);
 void thermal_zone_of_sensor_unregister(struct device *dev,
 				       struct thermal_zone_device *tz);
+struct thermal_cooling_device *
+thermal_of_cooling_device_register(struct device_node *np,
+				   char *type, void *devdata,
+				   const struct thermal_cooling_device_ops *);
 #else
 static inline struct thermal_zone_device *
 thermal_zone_of_sensor_register(struct device *dev, int id, void *data,
@@ -342,6 +346,13 @@ void thermal_zone_of_sensor_unregister(struct device *dev,
 {
 }
 
+static inline struct thermal_cooling_device *
+thermal_of_cooling_device_register(struct device_node *np,
+				   char *type, void *devdata,
+				   const struct thermal_cooling_device_ops *ops)
+{
+	return NULL;
+}
 #endif
 struct thermal_zone_device *thermal_zone_device_register(const char *, int, int,
 		void *, struct thermal_zone_device_ops *,
@@ -357,9 +368,6 @@ void thermal_zone_device_update(struct thermal_zone_device *);
 
 struct thermal_cooling_device *thermal_cooling_device_register(char *, void *,
 		const struct thermal_cooling_device_ops *);
-struct thermal_cooling_device *
-thermal_of_cooling_device_register(struct device_node *np, char *, void *,
-				   const struct thermal_cooling_device_ops *);
 void thermal_cooling_device_unregister(struct thermal_cooling_device *);
 struct thermal_zone_device *thermal_zone_get_zone_by_name(const char *name);
 int thermal_zone_get_temp(struct thermal_zone_device *tz, unsigned long *temp);
-- 
2.0.0.rc2


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v2 2/8] thermal: Provide stub for thermal_cdev_update() function
  2014-12-22 16:27   ` Lukasz Majewski
  (?)
@ 2014-12-22 16:27     ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-22 16:27 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

Odroid U3 fan can work without being registered as OF cooling device
(with CONFIG_THERMAL_OF disabled).
In this situation it can be controlled via PWM entry at
/sys/class/hwmon/hwmon0/pwm1.

Therefore, the thermal_cdev_update() function needs a stub
to allow clean compilation.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- New patch
---
 include/linux/thermal.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index 871123c..b3515b5 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -332,6 +332,7 @@ struct thermal_cooling_device *
 thermal_of_cooling_device_register(struct device_node *np,
 				   char *type, void *devdata,
 				   const struct thermal_cooling_device_ops *);
+void thermal_cdev_update(struct thermal_cooling_device *);
 #else
 static inline struct thermal_zone_device *
 thermal_zone_of_sensor_register(struct device *dev, int id, void *data,
@@ -353,6 +354,10 @@ thermal_of_cooling_device_register(struct device_node *np,
 {
 	return NULL;
 }
+
+static inline void thermal_cdev_update(struct thermal_cooling_device *cdev)
+{
+}
 #endif
 struct thermal_zone_device *thermal_zone_device_register(const char *, int, int,
 		void *, struct thermal_zone_device_ops *,
@@ -375,7 +380,6 @@ int thermal_zone_get_temp(struct thermal_zone_device *tz, unsigned long *temp);
 int get_tz_trend(struct thermal_zone_device *, int);
 struct thermal_instance *get_thermal_instance(struct thermal_zone_device *,
 		struct thermal_cooling_device *, int);
-void thermal_cdev_update(struct thermal_cooling_device *);
 void thermal_notify_framework(struct thermal_zone_device *, int);
 
 #ifdef CONFIG_NET
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v2 2/8] thermal: Provide stub for thermal_cdev_update() function
@ 2014-12-22 16:27     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-22 16:27 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

Odroid U3 fan can work without being registered as OF cooling device
(with CONFIG_THERMAL_OF disabled).
In this situation it can be controlled via PWM entry at
/sys/class/hwmon/hwmon0/pwm1.

Therefore, the thermal_cdev_update() function needs a stub
to allow clean compilation.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- New patch
---
 include/linux/thermal.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index 871123c..b3515b5 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -332,6 +332,7 @@ struct thermal_cooling_device *
 thermal_of_cooling_device_register(struct device_node *np,
 				   char *type, void *devdata,
 				   const struct thermal_cooling_device_ops *);
+void thermal_cdev_update(struct thermal_cooling_device *);
 #else
 static inline struct thermal_zone_device *
 thermal_zone_of_sensor_register(struct device *dev, int id, void *data,
@@ -353,6 +354,10 @@ thermal_of_cooling_device_register(struct device_node *np,
 {
 	return NULL;
 }
+
+static inline void thermal_cdev_update(struct thermal_cooling_device *cdev)
+{
+}
 #endif
 struct thermal_zone_device *thermal_zone_device_register(const char *, int, int,
 		void *, struct thermal_zone_device_ops *,
@@ -375,7 +380,6 @@ int thermal_zone_get_temp(struct thermal_zone_device *tz, unsigned long *temp);
 int get_tz_trend(struct thermal_zone_device *, int);
 struct thermal_instance *get_thermal_instance(struct thermal_zone_device *,
 		struct thermal_cooling_device *, int);
-void thermal_cdev_update(struct thermal_cooling_device *);
 void thermal_notify_framework(struct thermal_zone_device *, int);
 
 #ifdef CONFIG_NET
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [lm-sensors] [PATCH v2 2/8] thermal: Provide stub for thermal_cdev_update() function
@ 2014-12-22 16:27     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-22 16:27 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

Odroid U3 fan can work without being registered as OF cooling device
(with CONFIG_THERMAL_OF disabled).
In this situation it can be controlled via PWM entry at
/sys/class/hwmon/hwmon0/pwm1.

Therefore, the thermal_cdev_update() function needs a stub
to allow clean compilation.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- New patch
---
 include/linux/thermal.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index 871123c..b3515b5 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -332,6 +332,7 @@ struct thermal_cooling_device *
 thermal_of_cooling_device_register(struct device_node *np,
 				   char *type, void *devdata,
 				   const struct thermal_cooling_device_ops *);
+void thermal_cdev_update(struct thermal_cooling_device *);
 #else
 static inline struct thermal_zone_device *
 thermal_zone_of_sensor_register(struct device *dev, int id, void *data,
@@ -353,6 +354,10 @@ thermal_of_cooling_device_register(struct device_node *np,
 {
 	return NULL;
 }
+
+static inline void thermal_cdev_update(struct thermal_cooling_device *cdev)
+{
+}
 #endif
 struct thermal_zone_device *thermal_zone_device_register(const char *, int, int,
 		void *, struct thermal_zone_device_ops *,
@@ -375,7 +380,6 @@ int thermal_zone_get_temp(struct thermal_zone_device *tz, unsigned long *temp);
 int get_tz_trend(struct thermal_zone_device *, int);
 struct thermal_instance *get_thermal_instance(struct thermal_zone_device *,
 		struct thermal_cooling_device *, int);
-void thermal_cdev_update(struct thermal_cooling_device *);
 void thermal_notify_framework(struct thermal_zone_device *, int);
 
 #ifdef CONFIG_NET
-- 
2.0.0.rc2


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v2 3/8] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling device
  2014-12-22 16:27   ` Lukasz Majewski
  (?)
@ 2014-12-22 16:27     ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-22 16:27 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

Several new properties to allow PWM fan working as a cooling device have been
combined into this single commit.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Rename cooling-pwm-values to cooling-levels
- Remove default-pulse-width property and stick to default hwmon policy
---
 .../devicetree/bindings/hwmon/pwm-fan.txt          | 23 ++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
index 610757c..001446a 100644
--- a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
+++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
@@ -3,10 +3,33 @@ Bindings for a fan connected to the PWM lines
 Required properties:
 - compatible	: "pwm-fan"
 - pwms		: the PWM that is used to control the PWM fan
+- cooling-levels      : PWM duty cycle values in a range from 0 to 255
+			which correspond to thermal cooling states
+
+Thorough description of the following bindings:
+		cooling-min-state = <0>;
+		cooling-max-state = <3>;
+		#cooling-cells = <2>;
+		thermal-zone {
+			cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				     trip = <&cpu_alert1>;
+				     cooling-device = <&fan0 0 1>;
+				};
+			};
+		};
+
+for PWM FAN used as cooling device can be found at:
+./Documentation/devicetree/bindings/thermal/thermal.txt
 
 Example:
 	pwm-fan {
 		compatible = "pwm-fan";
 		status = "okay";
 		pwms = <&pwm 0 10000 0>;
+		cooling-min-state = <0>;
+		cooling-max-state = <3>;
+		#cooling-cells = <2>;
+		cooling-levels = <0 102 170 255>;
 	};
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v2 3/8] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling device
@ 2014-12-22 16:27     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-22 16:27 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

Several new properties to allow PWM fan working as a cooling device have been
combined into this single commit.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Rename cooling-pwm-values to cooling-levels
- Remove default-pulse-width property and stick to default hwmon policy
---
 .../devicetree/bindings/hwmon/pwm-fan.txt          | 23 ++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
index 610757c..001446a 100644
--- a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
+++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
@@ -3,10 +3,33 @@ Bindings for a fan connected to the PWM lines
 Required properties:
 - compatible	: "pwm-fan"
 - pwms		: the PWM that is used to control the PWM fan
+- cooling-levels      : PWM duty cycle values in a range from 0 to 255
+			which correspond to thermal cooling states
+
+Thorough description of the following bindings:
+		cooling-min-state = <0>;
+		cooling-max-state = <3>;
+		#cooling-cells = <2>;
+		thermal-zone {
+			cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				     trip = <&cpu_alert1>;
+				     cooling-device = <&fan0 0 1>;
+				};
+			};
+		};
+
+for PWM FAN used as cooling device can be found at:
+./Documentation/devicetree/bindings/thermal/thermal.txt
 
 Example:
 	pwm-fan {
 		compatible = "pwm-fan";
 		status = "okay";
 		pwms = <&pwm 0 10000 0>;
+		cooling-min-state = <0>;
+		cooling-max-state = <3>;
+		#cooling-cells = <2>;
+		cooling-levels = <0 102 170 255>;
 	};
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [lm-sensors] [PATCH v2 3/8] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling
@ 2014-12-22 16:27     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-22 16:27 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

Several new properties to allow PWM fan working as a cooling device have been
combined into this single commit.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Rename cooling-pwm-values to cooling-levels
- Remove default-pulse-width property and stick to default hwmon policy
---
 .../devicetree/bindings/hwmon/pwm-fan.txt          | 23 ++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
index 610757c..001446a 100644
--- a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
+++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
@@ -3,10 +3,33 @@ Bindings for a fan connected to the PWM lines
 Required properties:
 - compatible	: "pwm-fan"
 - pwms		: the PWM that is used to control the PWM fan
+- cooling-levels      : PWM duty cycle values in a range from 0 to 255
+			which correspond to thermal cooling states
+
+Thorough description of the following bindings:
+		cooling-min-state = <0>;
+		cooling-max-state = <3>;
+		#cooling-cells = <2>;
+		thermal-zone {
+			cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				     trip = <&cpu_alert1>;
+				     cooling-device = <&fan0 0 1>;
+				};
+			};
+		};
+
+for PWM FAN used as cooling device can be found at:
+./Documentation/devicetree/bindings/thermal/thermal.txt
 
 Example:
 	pwm-fan {
 		compatible = "pwm-fan";
 		status = "okay";
 		pwms = <&pwm 0 10000 0>;
+		cooling-min-state = <0>;
+		cooling-max-state = <3>;
+		#cooling-cells = <2>;
+		cooling-levels = <0 102 170 255>;
 	};
-- 
2.0.0.rc2


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v2 4/8] ARM: dts: Add pwm-fan node to the Odroid-U3 board
  2014-12-22 16:27   ` Lukasz Majewski
  (?)
@ 2014-12-22 16:27     ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-22 16:27 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki,
	Abhilash Kesavan, Abhilash Kesavan

From: Kamil Debski <k.debski@samsung.com>

Add pwm-fan node to the Odroid-U3 board file to enable PWM control of the
cooling fan. In addition, add the "pwm" label to the pwm@139D0000 node
in the exynos4412.dtsi.

Signed-off-by: Kamil Debski <k.debski@samsung.com>
[Rebased on the newest mainline by l.majewski@samsung.com]
---
Changes since v1:
- added pwm label to the pwm@139D0000 node in exynos4.dtsi
- use the pwm label in the exynos4412-odroidu3.dts
- change order or properties in the pwn-fan node, to be sorted
  in alphabetical order

---
 arch/arm/boot/dts/exynos4.dtsi            |  2 +-
 arch/arm/boot/dts/exynos4412-odroidu3.dts | 13 +++++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/exynos4.dtsi b/arch/arm/boot/dts/exynos4.dtsi
index 1735bb3..f227a39 100644
--- a/arch/arm/boot/dts/exynos4.dtsi
+++ b/arch/arm/boot/dts/exynos4.dtsi
@@ -583,7 +583,7 @@
 		status = "disabled";
 	};
 
-	pwm@139D0000 {
+	pwm: pwm@139D0000 {
 		compatible = "samsung,exynos4210-pwm";
 		reg = <0x139D0000 0x1000>;
 		interrupts = <0 37 0>, <0 38 0>, <0 39 0>, <0 40 0>, <0 41 0>;
diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
index c8a64be..60bd1e4 100644
--- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
+++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
@@ -31,6 +31,19 @@
 			linux,default-trigger = "heartbeat";
 		};
 	};
+
+	pwm-fan {
+		compatible = "pwm-fan";
+		pwms = <&pwm 0 10000 0>;
+		status = "okay";
+	};
+};
+
+&pwm {
+	pinctrl-0 = <&pwm0_out>;
+	pinctrl-names = "default";
+	samsung,pwm-outputs = <0>;
+	status = "okay";
 };
 
 &usb3503 {
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v2 4/8] ARM: dts: Add pwm-fan node to the Odroid-U3 board
@ 2014-12-22 16:27     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-22 16:27 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki,
	Abhilash Kesavan, Abhilash Kesavan

From: Kamil Debski <k.debski@samsung.com>

Add pwm-fan node to the Odroid-U3 board file to enable PWM control of the
cooling fan. In addition, add the "pwm" label to the pwm@139D0000 node
in the exynos4412.dtsi.

Signed-off-by: Kamil Debski <k.debski@samsung.com>
[Rebased on the newest mainline by l.majewski@samsung.com]
---
Changes since v1:
- added pwm label to the pwm@139D0000 node in exynos4.dtsi
- use the pwm label in the exynos4412-odroidu3.dts
- change order or properties in the pwn-fan node, to be sorted
  in alphabetical order

---
 arch/arm/boot/dts/exynos4.dtsi            |  2 +-
 arch/arm/boot/dts/exynos4412-odroidu3.dts | 13 +++++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/exynos4.dtsi b/arch/arm/boot/dts/exynos4.dtsi
index 1735bb3..f227a39 100644
--- a/arch/arm/boot/dts/exynos4.dtsi
+++ b/arch/arm/boot/dts/exynos4.dtsi
@@ -583,7 +583,7 @@
 		status = "disabled";
 	};
 
-	pwm@139D0000 {
+	pwm: pwm@139D0000 {
 		compatible = "samsung,exynos4210-pwm";
 		reg = <0x139D0000 0x1000>;
 		interrupts = <0 37 0>, <0 38 0>, <0 39 0>, <0 40 0>, <0 41 0>;
diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
index c8a64be..60bd1e4 100644
--- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
+++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
@@ -31,6 +31,19 @@
 			linux,default-trigger = "heartbeat";
 		};
 	};
+
+	pwm-fan {
+		compatible = "pwm-fan";
+		pwms = <&pwm 0 10000 0>;
+		status = "okay";
+	};
+};
+
+&pwm {
+	pinctrl-0 = <&pwm0_out>;
+	pinctrl-names = "default";
+	samsung,pwm-outputs = <0>;
+	status = "okay";
 };
 
 &usb3503 {
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [lm-sensors] [PATCH v2 4/8] ARM: dts: Add pwm-fan node to the Odroid-U3 board
@ 2014-12-22 16:27     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-22 16:27 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki,
	Abhilash Kesavan, Abhilash Kesavan

From: Kamil Debski <k.debski@samsung.com>

Add pwm-fan node to the Odroid-U3 board file to enable PWM control of the
cooling fan. In addition, add the "pwm" label to the pwm@139D0000 node
in the exynos4412.dtsi.

Signed-off-by: Kamil Debski <k.debski@samsung.com>
[Rebased on the newest mainline by l.majewski@samsung.com]
---
Changes since v1:
- added pwm label to the pwm@139D0000 node in exynos4.dtsi
- use the pwm label in the exynos4412-odroidu3.dts
- change order or properties in the pwn-fan node, to be sorted
  in alphabetical order

---
 arch/arm/boot/dts/exynos4.dtsi            |  2 +-
 arch/arm/boot/dts/exynos4412-odroidu3.dts | 13 +++++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/exynos4.dtsi b/arch/arm/boot/dts/exynos4.dtsi
index 1735bb3..f227a39 100644
--- a/arch/arm/boot/dts/exynos4.dtsi
+++ b/arch/arm/boot/dts/exynos4.dtsi
@@ -583,7 +583,7 @@
 		status = "disabled";
 	};
 
-	pwm@139D0000 {
+	pwm: pwm@139D0000 {
 		compatible = "samsung,exynos4210-pwm";
 		reg = <0x139D0000 0x1000>;
 		interrupts = <0 37 0>, <0 38 0>, <0 39 0>, <0 40 0>, <0 41 0>;
diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
index c8a64be..60bd1e4 100644
--- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
+++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
@@ -31,6 +31,19 @@
 			linux,default-trigger = "heartbeat";
 		};
 	};
+
+	pwm-fan {
+		compatible = "pwm-fan";
+		pwms = <&pwm 0 10000 0>;
+		status = "okay";
+	};
+};
+
+&pwm {
+	pinctrl-0 = <&pwm0_out>;
+	pinctrl-names = "default";
+	samsung,pwm-outputs = <0>;
+	status = "okay";
 };
 
 &usb3503 {
-- 
2.0.0.rc2


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v2 5/8] hwmon: thermal: dts: Add properties to use pwm-fan device as a cooling device in Odroid U3
  2014-12-22 16:27   ` Lukasz Majewski
  (?)
@ 2014-12-22 16:27     ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-22 16:27 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

With those bindings it is possible to use pwm-fan device available in
Odroid U3 as a cooling device.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Rename cooling-pwm-values property to cooling-levels
---
 arch/arm/boot/dts/exynos4412-odroidu3.dts | 33 ++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
index 60bd1e4..380035d 100644
--- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
+++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
@@ -32,11 +32,42 @@
 		};
 	};
 
-	pwm-fan {
+	fan0: pwm-fan {
 		compatible = "pwm-fan";
 		pwms = <&pwm 0 10000 0>;
+		cooling-min-state = <0>;
+		cooling-max-state = <3>;
+		#cooling-cells = <2>;
+		cooling-levels = <0 102 170 255>;
 		status = "okay";
 	};
+
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				     trip = <&cpu_alert1>;
+				     cooling-device = <&cpu0 7 7>;
+				};
+				map1 {
+				     trip = <&cpu_alert2>;
+				     cooling-device = <&cpu0 13 13>;
+				};
+				map2 {
+				     trip = <&cpu_alert0>;
+				     cooling-device = <&fan0 0 1>;
+				};
+				map3 {
+				     trip = <&cpu_alert1>;
+				     cooling-device = <&fan0 1 2>;
+				};
+				map4 {
+				     trip = <&cpu_alert2>;
+				     cooling-device = <&fan0 2 3>;
+				};
+			};
+		};
+	};
 };
 
 &pwm {
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v2 5/8] hwmon: thermal: dts: Add properties to use pwm-fan device as a cooling device in Odroid U3
@ 2014-12-22 16:27     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-22 16:27 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

With those bindings it is possible to use pwm-fan device available in
Odroid U3 as a cooling device.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Rename cooling-pwm-values property to cooling-levels
---
 arch/arm/boot/dts/exynos4412-odroidu3.dts | 33 ++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
index 60bd1e4..380035d 100644
--- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
+++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
@@ -32,11 +32,42 @@
 		};
 	};
 
-	pwm-fan {
+	fan0: pwm-fan {
 		compatible = "pwm-fan";
 		pwms = <&pwm 0 10000 0>;
+		cooling-min-state = <0>;
+		cooling-max-state = <3>;
+		#cooling-cells = <2>;
+		cooling-levels = <0 102 170 255>;
 		status = "okay";
 	};
+
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				     trip = <&cpu_alert1>;
+				     cooling-device = <&cpu0 7 7>;
+				};
+				map1 {
+				     trip = <&cpu_alert2>;
+				     cooling-device = <&cpu0 13 13>;
+				};
+				map2 {
+				     trip = <&cpu_alert0>;
+				     cooling-device = <&fan0 0 1>;
+				};
+				map3 {
+				     trip = <&cpu_alert1>;
+				     cooling-device = <&fan0 1 2>;
+				};
+				map4 {
+				     trip = <&cpu_alert2>;
+				     cooling-device = <&fan0 2 3>;
+				};
+			};
+		};
+	};
 };
 
 &pwm {
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [lm-sensors] [PATCH v2 5/8] hwmon: thermal: dts: Add properties to use pwm-fan device as a cooling d
@ 2014-12-22 16:27     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-22 16:27 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

With those bindings it is possible to use pwm-fan device available in
Odroid U3 as a cooling device.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Rename cooling-pwm-values property to cooling-levels
---
 arch/arm/boot/dts/exynos4412-odroidu3.dts | 33 ++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
index 60bd1e4..380035d 100644
--- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
+++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
@@ -32,11 +32,42 @@
 		};
 	};
 
-	pwm-fan {
+	fan0: pwm-fan {
 		compatible = "pwm-fan";
 		pwms = <&pwm 0 10000 0>;
+		cooling-min-state = <0>;
+		cooling-max-state = <3>;
+		#cooling-cells = <2>;
+		cooling-levels = <0 102 170 255>;
 		status = "okay";
 	};
+
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				     trip = <&cpu_alert1>;
+				     cooling-device = <&cpu0 7 7>;
+				};
+				map1 {
+				     trip = <&cpu_alert2>;
+				     cooling-device = <&cpu0 13 13>;
+				};
+				map2 {
+				     trip = <&cpu_alert0>;
+				     cooling-device = <&fan0 0 1>;
+				};
+				map3 {
+				     trip = <&cpu_alert1>;
+				     cooling-device = <&fan0 1 2>;
+				};
+				map4 {
+				     trip = <&cpu_alert2>;
+				     cooling-device = <&fan0 2 3>;
+				};
+			};
+		};
+	};
 };
 
 &pwm {
-- 
2.0.0.rc2


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v2 6/8] hwmon: thermal: Extract __set_pwm() function to only modify PWM duty cycle
  2014-12-22 16:27   ` Lukasz Majewski
  (?)
@ 2014-12-22 16:27     ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-22 16:27 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

It was necessary to decouple code handling writing to sysfs from the one
responsible for setting PWM of the fan.
Due to that, new __set_pwm() method was extracted, which is responsible for
only setting new PWM duty cycle.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
---
 drivers/hwmon/pwm-fan.c | 35 ++++++++++++++++++++++-------------
 1 file changed, 22 insertions(+), 13 deletions(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index 1991d903..870e100 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -33,21 +33,15 @@ struct pwm_fan_ctx {
 	unsigned char pwm_value;
 };
 
-static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
-		       const char *buf, size_t count)
+static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
 {
-	struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
-	unsigned long pwm, duty;
-	ssize_t ret;
-
-	if (kstrtoul(buf, 10, &pwm) || pwm > MAX_PWM)
-		return -EINVAL;
-
-	mutex_lock(&ctx->lock);
+	unsigned long duty;
+	int ret;
 
 	if (ctx->pwm_value == pwm)
-		goto exit_set_pwm_no_change;
+		return 0;
 
+	mutex_lock(&ctx->lock);
 	if (pwm == 0) {
 		pwm_disable(ctx->pwm);
 		goto exit_set_pwm;
@@ -66,13 +60,28 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 
 exit_set_pwm:
 	ctx->pwm_value = pwm;
-exit_set_pwm_no_change:
-	ret = count;
 exit_set_pwm_err:
 	mutex_unlock(&ctx->lock);
 	return ret;
 }
 
+static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
+		       const char *buf, size_t count)
+{
+	struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
+	unsigned long pwm;
+	int ret;
+
+	if (kstrtoul(buf, 10, &pwm) || pwm > MAX_PWM)
+		return -EINVAL;
+
+	ret = __set_pwm(ctx, pwm);
+	if (ret)
+		return ret;
+
+	return count;
+}
+
 static ssize_t show_pwm(struct device *dev,
 			struct device_attribute *attr, char *buf)
 {
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v2 6/8] hwmon: thermal: Extract __set_pwm() function to only modify PWM duty cycle
@ 2014-12-22 16:27     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-22 16:27 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

It was necessary to decouple code handling writing to sysfs from the one
responsible for setting PWM of the fan.
Due to that, new __set_pwm() method was extracted, which is responsible for
only setting new PWM duty cycle.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
---
 drivers/hwmon/pwm-fan.c | 35 ++++++++++++++++++++++-------------
 1 file changed, 22 insertions(+), 13 deletions(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index 1991d903..870e100 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -33,21 +33,15 @@ struct pwm_fan_ctx {
 	unsigned char pwm_value;
 };
 
-static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
-		       const char *buf, size_t count)
+static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
 {
-	struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
-	unsigned long pwm, duty;
-	ssize_t ret;
-
-	if (kstrtoul(buf, 10, &pwm) || pwm > MAX_PWM)
-		return -EINVAL;
-
-	mutex_lock(&ctx->lock);
+	unsigned long duty;
+	int ret;
 
 	if (ctx->pwm_value == pwm)
-		goto exit_set_pwm_no_change;
+		return 0;
 
+	mutex_lock(&ctx->lock);
 	if (pwm == 0) {
 		pwm_disable(ctx->pwm);
 		goto exit_set_pwm;
@@ -66,13 +60,28 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 
 exit_set_pwm:
 	ctx->pwm_value = pwm;
-exit_set_pwm_no_change:
-	ret = count;
 exit_set_pwm_err:
 	mutex_unlock(&ctx->lock);
 	return ret;
 }
 
+static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
+		       const char *buf, size_t count)
+{
+	struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
+	unsigned long pwm;
+	int ret;
+
+	if (kstrtoul(buf, 10, &pwm) || pwm > MAX_PWM)
+		return -EINVAL;
+
+	ret = __set_pwm(ctx, pwm);
+	if (ret)
+		return ret;
+
+	return count;
+}
+
 static ssize_t show_pwm(struct device *dev,
 			struct device_attribute *attr, char *buf)
 {
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [lm-sensors] [PATCH v2 6/8] hwmon: thermal: Extract __set_pwm() function to only modify PWM duty cyc
@ 2014-12-22 16:27     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-22 16:27 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

It was necessary to decouple code handling writing to sysfs from the one
responsible for setting PWM of the fan.
Due to that, new __set_pwm() method was extracted, which is responsible for
only setting new PWM duty cycle.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
---
 drivers/hwmon/pwm-fan.c | 35 ++++++++++++++++++++++-------------
 1 file changed, 22 insertions(+), 13 deletions(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index 1991d903..870e100 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -33,21 +33,15 @@ struct pwm_fan_ctx {
 	unsigned char pwm_value;
 };
 
-static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
-		       const char *buf, size_t count)
+static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
 {
-	struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
-	unsigned long pwm, duty;
-	ssize_t ret;
-
-	if (kstrtoul(buf, 10, &pwm) || pwm > MAX_PWM)
-		return -EINVAL;
-
-	mutex_lock(&ctx->lock);
+	unsigned long duty;
+	int ret;
 
 	if (ctx->pwm_value = pwm)
-		goto exit_set_pwm_no_change;
+		return 0;
 
+	mutex_lock(&ctx->lock);
 	if (pwm = 0) {
 		pwm_disable(ctx->pwm);
 		goto exit_set_pwm;
@@ -66,13 +60,28 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 
 exit_set_pwm:
 	ctx->pwm_value = pwm;
-exit_set_pwm_no_change:
-	ret = count;
 exit_set_pwm_err:
 	mutex_unlock(&ctx->lock);
 	return ret;
 }
 
+static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
+		       const char *buf, size_t count)
+{
+	struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
+	unsigned long pwm;
+	int ret;
+
+	if (kstrtoul(buf, 10, &pwm) || pwm > MAX_PWM)
+		return -EINVAL;
+
+	ret = __set_pwm(ctx, pwm);
+	if (ret)
+		return ret;
+
+	return count;
+}
+
 static ssize_t show_pwm(struct device *dev,
 			struct device_attribute *attr, char *buf)
 {
-- 
2.0.0.rc2


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v2 7/8] hwmon: thermal: Read PWM FAN configuration from device tree
  2014-12-22 16:27   ` Lukasz Majewski
  (?)
@ 2014-12-22 16:27     ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-22 16:27 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

Code for reading PWM FAN configuration data via device tree.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Rename pwm_fan_max_states to pwm_fan_cooling_levels
- Moving pwm_fan_of_get_cooling_data() call after setting end enabling PWM FAN
- pwm_fan_of_get_cooling_data() now can fail - preserving old behaviour
- Remove unnecessary dev_err() call
---
 drivers/hwmon/pwm-fan.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 47 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index 870e100..8e68308 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -30,7 +30,10 @@
 struct pwm_fan_ctx {
 	struct mutex lock;
 	struct pwm_device *pwm;
-	unsigned char pwm_value;
+	unsigned int pwm_value;
+	unsigned int pwm_fan_state;
+	unsigned int pwm_fan_max_state;
+	unsigned int *pwm_fan_cooling_levels;
 };
 
 static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
@@ -100,6 +103,47 @@ static struct attribute *pwm_fan_attrs[] = {
 
 ATTRIBUTE_GROUPS(pwm_fan);
 
+int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
+{
+	struct device_node *np = dev->of_node;
+	struct property *pp;
+	int len, num, i;
+
+	pp = of_find_property(np, "cooling-levels", &len);
+	if (!pp) {
+		dev_err(dev, "Property: 'cooling-levels' not found\n");
+		return -EINVAL;
+	}
+
+	if (len == 0) {
+		dev_err(dev, "Length wrong value!\n");
+		return -EINVAL;
+	}
+
+	ctx->pwm_fan_cooling_levels = devm_kzalloc(dev, len, GFP_KERNEL);
+	if (!ctx->pwm_fan_cooling_levels)
+		return -ENOMEM;
+
+	num = len / sizeof(u32);
+	if (of_property_read_u32_array(np, pp->name,
+				       ctx->pwm_fan_cooling_levels, num)) {
+		dev_err(dev, "Property: %s cannot be read!\n", pp->name);
+		return -EINVAL;
+	}
+
+	for (i = 0; i < num; i++) {
+		if (ctx->pwm_fan_cooling_levels[i] > MAX_PWM) {
+			dev_err(dev, "PWM fan state[%d]:%d > %d\n", i,
+				ctx->pwm_fan_cooling_levels[i], MAX_PWM);
+			return -EINVAL;
+		}
+	}
+
+	ctx->pwm_fan_max_state = num - 1;
+
+	return 0;
+}
+
 static int pwm_fan_probe(struct platform_device *pdev)
 {
 	struct device *hwmon;
@@ -145,6 +189,8 @@ static int pwm_fan_probe(struct platform_device *pdev)
 		pwm_disable(ctx->pwm);
 		return PTR_ERR(hwmon);
 	}
+
+	pwm_fan_of_get_cooling_data(&pdev->dev, ctx);
 	return 0;
 }
 
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v2 7/8] hwmon: thermal: Read PWM FAN configuration from device tree
@ 2014-12-22 16:27     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-22 16:27 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

Code for reading PWM FAN configuration data via device tree.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Rename pwm_fan_max_states to pwm_fan_cooling_levels
- Moving pwm_fan_of_get_cooling_data() call after setting end enabling PWM FAN
- pwm_fan_of_get_cooling_data() now can fail - preserving old behaviour
- Remove unnecessary dev_err() call
---
 drivers/hwmon/pwm-fan.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 47 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index 870e100..8e68308 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -30,7 +30,10 @@
 struct pwm_fan_ctx {
 	struct mutex lock;
 	struct pwm_device *pwm;
-	unsigned char pwm_value;
+	unsigned int pwm_value;
+	unsigned int pwm_fan_state;
+	unsigned int pwm_fan_max_state;
+	unsigned int *pwm_fan_cooling_levels;
 };
 
 static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
@@ -100,6 +103,47 @@ static struct attribute *pwm_fan_attrs[] = {
 
 ATTRIBUTE_GROUPS(pwm_fan);
 
+int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
+{
+	struct device_node *np = dev->of_node;
+	struct property *pp;
+	int len, num, i;
+
+	pp = of_find_property(np, "cooling-levels", &len);
+	if (!pp) {
+		dev_err(dev, "Property: 'cooling-levels' not found\n");
+		return -EINVAL;
+	}
+
+	if (len == 0) {
+		dev_err(dev, "Length wrong value!\n");
+		return -EINVAL;
+	}
+
+	ctx->pwm_fan_cooling_levels = devm_kzalloc(dev, len, GFP_KERNEL);
+	if (!ctx->pwm_fan_cooling_levels)
+		return -ENOMEM;
+
+	num = len / sizeof(u32);
+	if (of_property_read_u32_array(np, pp->name,
+				       ctx->pwm_fan_cooling_levels, num)) {
+		dev_err(dev, "Property: %s cannot be read!\n", pp->name);
+		return -EINVAL;
+	}
+
+	for (i = 0; i < num; i++) {
+		if (ctx->pwm_fan_cooling_levels[i] > MAX_PWM) {
+			dev_err(dev, "PWM fan state[%d]:%d > %d\n", i,
+				ctx->pwm_fan_cooling_levels[i], MAX_PWM);
+			return -EINVAL;
+		}
+	}
+
+	ctx->pwm_fan_max_state = num - 1;
+
+	return 0;
+}
+
 static int pwm_fan_probe(struct platform_device *pdev)
 {
 	struct device *hwmon;
@@ -145,6 +189,8 @@ static int pwm_fan_probe(struct platform_device *pdev)
 		pwm_disable(ctx->pwm);
 		return PTR_ERR(hwmon);
 	}
+
+	pwm_fan_of_get_cooling_data(&pdev->dev, ctx);
 	return 0;
 }
 
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [lm-sensors] [PATCH v2 7/8] hwmon: thermal: Read PWM FAN configuration from device tree
@ 2014-12-22 16:27     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-22 16:27 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

Code for reading PWM FAN configuration data via device tree.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Rename pwm_fan_max_states to pwm_fan_cooling_levels
- Moving pwm_fan_of_get_cooling_data() call after setting end enabling PWM FAN
- pwm_fan_of_get_cooling_data() now can fail - preserving old behaviour
- Remove unnecessary dev_err() call
---
 drivers/hwmon/pwm-fan.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 47 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index 870e100..8e68308 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -30,7 +30,10 @@
 struct pwm_fan_ctx {
 	struct mutex lock;
 	struct pwm_device *pwm;
-	unsigned char pwm_value;
+	unsigned int pwm_value;
+	unsigned int pwm_fan_state;
+	unsigned int pwm_fan_max_state;
+	unsigned int *pwm_fan_cooling_levels;
 };
 
 static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
@@ -100,6 +103,47 @@ static struct attribute *pwm_fan_attrs[] = {
 
 ATTRIBUTE_GROUPS(pwm_fan);
 
+int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
+{
+	struct device_node *np = dev->of_node;
+	struct property *pp;
+	int len, num, i;
+
+	pp = of_find_property(np, "cooling-levels", &len);
+	if (!pp) {
+		dev_err(dev, "Property: 'cooling-levels' not found\n");
+		return -EINVAL;
+	}
+
+	if (len = 0) {
+		dev_err(dev, "Length wrong value!\n");
+		return -EINVAL;
+	}
+
+	ctx->pwm_fan_cooling_levels = devm_kzalloc(dev, len, GFP_KERNEL);
+	if (!ctx->pwm_fan_cooling_levels)
+		return -ENOMEM;
+
+	num = len / sizeof(u32);
+	if (of_property_read_u32_array(np, pp->name,
+				       ctx->pwm_fan_cooling_levels, num)) {
+		dev_err(dev, "Property: %s cannot be read!\n", pp->name);
+		return -EINVAL;
+	}
+
+	for (i = 0; i < num; i++) {
+		if (ctx->pwm_fan_cooling_levels[i] > MAX_PWM) {
+			dev_err(dev, "PWM fan state[%d]:%d > %d\n", i,
+				ctx->pwm_fan_cooling_levels[i], MAX_PWM);
+			return -EINVAL;
+		}
+	}
+
+	ctx->pwm_fan_max_state = num - 1;
+
+	return 0;
+}
+
 static int pwm_fan_probe(struct platform_device *pdev)
 {
 	struct device *hwmon;
@@ -145,6 +189,8 @@ static int pwm_fan_probe(struct platform_device *pdev)
 		pwm_disable(ctx->pwm);
 		return PTR_ERR(hwmon);
 	}
+
+	pwm_fan_of_get_cooling_data(&pdev->dev, ctx);
 	return 0;
 }
 
-- 
2.0.0.rc2


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v2 8/8] hwmon: thermal: Code for using PWM FAN as a cooling device
  2014-12-22 16:27   ` Lukasz Majewski
  (?)
@ 2014-12-22 16:27     ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-22 16:27 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

The PWM FAN device can now be used as a thermal cooling device. Necessary
infrastructure has been added in this commit.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Replace pwm_fan_cooling_states with pwm_fan_cooling_levels
- Update ctx->pwm_fan_state when correct data from device tree is available
- Using therma_cdev_update() when thermal is ready for controlling the fan
---
 drivers/hwmon/pwm-fan.c | 85 +++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 83 insertions(+), 2 deletions(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index 8e68308..a47fc3c 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -24,6 +24,7 @@
 #include <linux/platform_device.h>
 #include <linux/pwm.h>
 #include <linux/sysfs.h>
+#include <linux/thermal.h>
 
 #define MAX_PWM 255
 
@@ -68,6 +69,17 @@ exit_set_pwm_err:
 	return ret;
 }
 
+static void pwm_fan_update_state(struct pwm_fan_ctx *ctx, unsigned long pwm)
+{
+	int i;
+
+	for (i = 0; i < ctx->pwm_fan_max_state; ++i)
+		if (pwm < ctx->pwm_fan_cooling_levels[i + 1])
+			break;
+
+	ctx->pwm_fan_state = i;
+}
+
 static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 		       const char *buf, size_t count)
 {
@@ -82,6 +94,7 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 	if (ret)
 		return ret;
 
+	pwm_fan_update_state(ctx, pwm);
 	return count;
 }
 
@@ -103,6 +116,59 @@ static struct attribute *pwm_fan_attrs[] = {
 
 ATTRIBUTE_GROUPS(pwm_fan);
 
+/* thermal cooling device callbacks */
+static int pwm_fan_get_max_state(struct thermal_cooling_device *cdev,
+				 unsigned long *state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+
+	*state = ctx->pwm_fan_max_state;
+
+	return 0;
+}
+
+static int pwm_fan_get_cur_state(struct thermal_cooling_device *cdev,
+				 unsigned long *state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+
+	if (!ctx)
+		return -EINVAL;
+
+	*state = ctx->pwm_fan_state;
+
+	return 0;
+}
+
+static int
+pwm_fan_set_cur_state(struct thermal_cooling_device *cdev, unsigned long state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+	int ret;
+
+	if (!ctx || (state > ctx->pwm_fan_max_state))
+		return -EINVAL;
+
+	if (state == ctx->pwm_fan_state)
+		return 0;
+
+	ret = __set_pwm(ctx, ctx->pwm_fan_cooling_levels[state]);
+	if (ret) {
+		dev_err(&cdev->device, "Cannot set pwm!\n");
+		return ret;
+	}
+
+	ctx->pwm_fan_state = state;
+
+	return ret;
+}
+
+static const struct thermal_cooling_device_ops pwm_fan_cooling_ops = {
+	.get_max_state = pwm_fan_get_max_state,
+	.get_cur_state = pwm_fan_get_cur_state,
+	.set_cur_state = pwm_fan_set_cur_state,
+};
+
 int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
 {
 	struct device_node *np = dev->of_node;
@@ -146,8 +212,9 @@ int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
 
 static int pwm_fan_probe(struct platform_device *pdev)
 {
-	struct device *hwmon;
+	struct thermal_cooling_device *cdev;
 	struct pwm_fan_ctx *ctx;
+	struct device *hwmon;
 	int duty_cycle;
 	int ret;
 
@@ -190,7 +257,21 @@ static int pwm_fan_probe(struct platform_device *pdev)
 		return PTR_ERR(hwmon);
 	}
 
-	pwm_fan_of_get_cooling_data(&pdev->dev, ctx);
+	ret = pwm_fan_of_get_cooling_data(&pdev->dev, ctx);
+	if (!ret) {
+		ctx->pwm_fan_state = ctx->pwm_fan_max_state;
+		cdev = thermal_of_cooling_device_register(pdev->dev.of_node,
+							  "pwm-fan", ctx,
+							  &pwm_fan_cooling_ops);
+		if (IS_ERR(cdev)) {
+			dev_err(&pdev->dev,
+				"Failed to register pwm-fan as cooling device");
+			pwm_disable(ctx->pwm);
+			return PTR_ERR(cdev);
+		}
+		thermal_cdev_update(cdev);
+	}
+
 	return 0;
 }
 
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v2 8/8] hwmon: thermal: Code for using PWM FAN as a cooling device
@ 2014-12-22 16:27     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-22 16:27 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

The PWM FAN device can now be used as a thermal cooling device. Necessary
infrastructure has been added in this commit.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Replace pwm_fan_cooling_states with pwm_fan_cooling_levels
- Update ctx->pwm_fan_state when correct data from device tree is available
- Using therma_cdev_update() when thermal is ready for controlling the fan
---
 drivers/hwmon/pwm-fan.c | 85 +++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 83 insertions(+), 2 deletions(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index 8e68308..a47fc3c 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -24,6 +24,7 @@
 #include <linux/platform_device.h>
 #include <linux/pwm.h>
 #include <linux/sysfs.h>
+#include <linux/thermal.h>
 
 #define MAX_PWM 255
 
@@ -68,6 +69,17 @@ exit_set_pwm_err:
 	return ret;
 }
 
+static void pwm_fan_update_state(struct pwm_fan_ctx *ctx, unsigned long pwm)
+{
+	int i;
+
+	for (i = 0; i < ctx->pwm_fan_max_state; ++i)
+		if (pwm < ctx->pwm_fan_cooling_levels[i + 1])
+			break;
+
+	ctx->pwm_fan_state = i;
+}
+
 static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 		       const char *buf, size_t count)
 {
@@ -82,6 +94,7 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 	if (ret)
 		return ret;
 
+	pwm_fan_update_state(ctx, pwm);
 	return count;
 }
 
@@ -103,6 +116,59 @@ static struct attribute *pwm_fan_attrs[] = {
 
 ATTRIBUTE_GROUPS(pwm_fan);
 
+/* thermal cooling device callbacks */
+static int pwm_fan_get_max_state(struct thermal_cooling_device *cdev,
+				 unsigned long *state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+
+	*state = ctx->pwm_fan_max_state;
+
+	return 0;
+}
+
+static int pwm_fan_get_cur_state(struct thermal_cooling_device *cdev,
+				 unsigned long *state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+
+	if (!ctx)
+		return -EINVAL;
+
+	*state = ctx->pwm_fan_state;
+
+	return 0;
+}
+
+static int
+pwm_fan_set_cur_state(struct thermal_cooling_device *cdev, unsigned long state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+	int ret;
+
+	if (!ctx || (state > ctx->pwm_fan_max_state))
+		return -EINVAL;
+
+	if (state == ctx->pwm_fan_state)
+		return 0;
+
+	ret = __set_pwm(ctx, ctx->pwm_fan_cooling_levels[state]);
+	if (ret) {
+		dev_err(&cdev->device, "Cannot set pwm!\n");
+		return ret;
+	}
+
+	ctx->pwm_fan_state = state;
+
+	return ret;
+}
+
+static const struct thermal_cooling_device_ops pwm_fan_cooling_ops = {
+	.get_max_state = pwm_fan_get_max_state,
+	.get_cur_state = pwm_fan_get_cur_state,
+	.set_cur_state = pwm_fan_set_cur_state,
+};
+
 int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
 {
 	struct device_node *np = dev->of_node;
@@ -146,8 +212,9 @@ int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
 
 static int pwm_fan_probe(struct platform_device *pdev)
 {
-	struct device *hwmon;
+	struct thermal_cooling_device *cdev;
 	struct pwm_fan_ctx *ctx;
+	struct device *hwmon;
 	int duty_cycle;
 	int ret;
 
@@ -190,7 +257,21 @@ static int pwm_fan_probe(struct platform_device *pdev)
 		return PTR_ERR(hwmon);
 	}
 
-	pwm_fan_of_get_cooling_data(&pdev->dev, ctx);
+	ret = pwm_fan_of_get_cooling_data(&pdev->dev, ctx);
+	if (!ret) {
+		ctx->pwm_fan_state = ctx->pwm_fan_max_state;
+		cdev = thermal_of_cooling_device_register(pdev->dev.of_node,
+							  "pwm-fan", ctx,
+							  &pwm_fan_cooling_ops);
+		if (IS_ERR(cdev)) {
+			dev_err(&pdev->dev,
+				"Failed to register pwm-fan as cooling device");
+			pwm_disable(ctx->pwm);
+			return PTR_ERR(cdev);
+		}
+		thermal_cdev_update(cdev);
+	}
+
 	return 0;
 }
 
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [lm-sensors] [PATCH v2 8/8] hwmon: thermal: Code for using PWM FAN as a cooling device
@ 2014-12-22 16:27     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2014-12-22 16:27 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

The PWM FAN device can now be used as a thermal cooling device. Necessary
infrastructure has been added in this commit.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Replace pwm_fan_cooling_states with pwm_fan_cooling_levels
- Update ctx->pwm_fan_state when correct data from device tree is available
- Using therma_cdev_update() when thermal is ready for controlling the fan
---
 drivers/hwmon/pwm-fan.c | 85 +++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 83 insertions(+), 2 deletions(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index 8e68308..a47fc3c 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -24,6 +24,7 @@
 #include <linux/platform_device.h>
 #include <linux/pwm.h>
 #include <linux/sysfs.h>
+#include <linux/thermal.h>
 
 #define MAX_PWM 255
 
@@ -68,6 +69,17 @@ exit_set_pwm_err:
 	return ret;
 }
 
+static void pwm_fan_update_state(struct pwm_fan_ctx *ctx, unsigned long pwm)
+{
+	int i;
+
+	for (i = 0; i < ctx->pwm_fan_max_state; ++i)
+		if (pwm < ctx->pwm_fan_cooling_levels[i + 1])
+			break;
+
+	ctx->pwm_fan_state = i;
+}
+
 static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 		       const char *buf, size_t count)
 {
@@ -82,6 +94,7 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 	if (ret)
 		return ret;
 
+	pwm_fan_update_state(ctx, pwm);
 	return count;
 }
 
@@ -103,6 +116,59 @@ static struct attribute *pwm_fan_attrs[] = {
 
 ATTRIBUTE_GROUPS(pwm_fan);
 
+/* thermal cooling device callbacks */
+static int pwm_fan_get_max_state(struct thermal_cooling_device *cdev,
+				 unsigned long *state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+
+	*state = ctx->pwm_fan_max_state;
+
+	return 0;
+}
+
+static int pwm_fan_get_cur_state(struct thermal_cooling_device *cdev,
+				 unsigned long *state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+
+	if (!ctx)
+		return -EINVAL;
+
+	*state = ctx->pwm_fan_state;
+
+	return 0;
+}
+
+static int
+pwm_fan_set_cur_state(struct thermal_cooling_device *cdev, unsigned long state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+	int ret;
+
+	if (!ctx || (state > ctx->pwm_fan_max_state))
+		return -EINVAL;
+
+	if (state = ctx->pwm_fan_state)
+		return 0;
+
+	ret = __set_pwm(ctx, ctx->pwm_fan_cooling_levels[state]);
+	if (ret) {
+		dev_err(&cdev->device, "Cannot set pwm!\n");
+		return ret;
+	}
+
+	ctx->pwm_fan_state = state;
+
+	return ret;
+}
+
+static const struct thermal_cooling_device_ops pwm_fan_cooling_ops = {
+	.get_max_state = pwm_fan_get_max_state,
+	.get_cur_state = pwm_fan_get_cur_state,
+	.set_cur_state = pwm_fan_set_cur_state,
+};
+
 int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
 {
 	struct device_node *np = dev->of_node;
@@ -146,8 +212,9 @@ int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
 
 static int pwm_fan_probe(struct platform_device *pdev)
 {
-	struct device *hwmon;
+	struct thermal_cooling_device *cdev;
 	struct pwm_fan_ctx *ctx;
+	struct device *hwmon;
 	int duty_cycle;
 	int ret;
 
@@ -190,7 +257,21 @@ static int pwm_fan_probe(struct platform_device *pdev)
 		return PTR_ERR(hwmon);
 	}
 
-	pwm_fan_of_get_cooling_data(&pdev->dev, ctx);
+	ret = pwm_fan_of_get_cooling_data(&pdev->dev, ctx);
+	if (!ret) {
+		ctx->pwm_fan_state = ctx->pwm_fan_max_state;
+		cdev = thermal_of_cooling_device_register(pdev->dev.of_node,
+							  "pwm-fan", ctx,
+							  &pwm_fan_cooling_ops);
+		if (IS_ERR(cdev)) {
+			dev_err(&pdev->dev,
+				"Failed to register pwm-fan as cooling device");
+			pwm_disable(ctx->pwm);
+			return PTR_ERR(cdev);
+		}
+		thermal_cdev_update(cdev);
+	}
+
 	return 0;
 }
 
-- 
2.0.0.rc2


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* Re: [PATCH v2 7/8] hwmon: thermal: Read PWM FAN configuration from device tree
  2014-12-22 16:27     ` Lukasz Majewski
  (?)
@ 2014-12-29 12:50       ` Guenter Roeck
  -1 siblings, 0 replies; 329+ messages in thread
From: Guenter Roeck @ 2014-12-29 12:50 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Eduardo Valentin, Kamil Debski, Jean Delvare, lm-sensors,
	Linux PM list, linux-samsung-soc, devicetree, Lukasz Majewski,
	Kukjin Kim, linux-kernel, Sylwester Nawrocki, Abhilash Kesavan,
	Abhilash Kesavan

On Mon, Dec 22, 2014 at 05:27:47PM +0100, Lukasz Majewski wrote:
> Code for reading PWM FAN configuration data via device tree.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---

The headline is quite misleading. Please provide the affected subsystem (hwmon)
and the affected driver (pwm-fan) in the hwmon-customary form
	hwmon: (pwm-fan) Description

The Description should explain what the patch is about.

> Changes for v2:
> - Rename pwm_fan_max_states to pwm_fan_cooling_levels
> - Moving pwm_fan_of_get_cooling_data() call after setting end enabling PWM FAN
> - pwm_fan_of_get_cooling_data() now can fail - preserving old behaviour
> - Remove unnecessary dev_err() call
> ---
>  drivers/hwmon/pwm-fan.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 47 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
> index 870e100..8e68308 100644
> --- a/drivers/hwmon/pwm-fan.c
> +++ b/drivers/hwmon/pwm-fan.c
> @@ -30,7 +30,10 @@
>  struct pwm_fan_ctx {
>  	struct mutex lock;
>  	struct pwm_device *pwm;
> -	unsigned char pwm_value;
> +	unsigned int pwm_value;
> +	unsigned int pwm_fan_state;
> +	unsigned int pwm_fan_max_state;
> +	unsigned int *pwm_fan_cooling_levels;
>  };
>  
>  static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
> @@ -100,6 +103,47 @@ static struct attribute *pwm_fan_attrs[] = {
>  
>  ATTRIBUTE_GROUPS(pwm_fan);
>  
> +int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
> +{
> +	struct device_node *np = dev->of_node;
> +	struct property *pp;
> +	int len, num, i;
> +
> +	pp = of_find_property(np, "cooling-levels", &len);
> +	if (!pp) {
> +		dev_err(dev, "Property: 'cooling-levels' not found\n");
> +		return -EINVAL;
> +	}
> +
> +	if (len == 0) {
> +		dev_err(dev, "Length wrong value!\n");

Semantics. "Wrong length" would be better.

> +		return -EINVAL;
> +	}
> +

of_property_count_elems_of_size() might be more appropriate here.

> +	ctx->pwm_fan_cooling_levels = devm_kzalloc(dev, len, GFP_KERNEL);
> +	if (!ctx->pwm_fan_cooling_levels)
> +		return -ENOMEM;
> +
> +	num = len / sizeof(u32);

What if 'num' is 0 ? Is that guaranteed to never happen ?

> +	if (of_property_read_u32_array(np, pp->name,
> +				       ctx->pwm_fan_cooling_levels, num)) {
> +		dev_err(dev, "Property: %s cannot be read!\n", pp->name);

The ':' after 'Property' in those error messages doesn't seem to make much sense
to me.

> +		return -EINVAL;

of_property_read_u32_array() returns an error code. Please use it.

> +	}
> +
> +	for (i = 0; i < num; i++) {
> +		if (ctx->pwm_fan_cooling_levels[i] > MAX_PWM) {
> +			dev_err(dev, "PWM fan state[%d]:%d > %d\n", i,
> +				ctx->pwm_fan_cooling_levels[i], MAX_PWM);
> +			return -EINVAL;
> +		}
> +	}
> +
> +	ctx->pwm_fan_max_state = num - 1;
> +
> +	return 0;
> +}
> +
>  static int pwm_fan_probe(struct platform_device *pdev)
>  {
>  	struct device *hwmon;
> @@ -145,6 +189,8 @@ static int pwm_fan_probe(struct platform_device *pdev)
>  		pwm_disable(ctx->pwm);
>  		return PTR_ERR(hwmon);
>  	}
> +
> +	pwm_fan_of_get_cooling_data(&pdev->dev, ctx);

Now this is odd. Adding a function to return an error code just to ignore it
doesn't make much sense. While it makes sense to ignore errors if there is no
cooling data in the devicetree, errors due to bad devicetree data should not be
ignored.

I am also a bit concerned that you make this call _after_ instantiating the
hwmon device; this may potentially result in a race condition. Please ensure
that this is not the case.

Thanks,
Guenter

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v2 7/8] hwmon: thermal: Read PWM FAN configuration from device tree
@ 2014-12-29 12:50       ` Guenter Roeck
  0 siblings, 0 replies; 329+ messages in thread
From: Guenter Roeck @ 2014-12-29 12:50 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Eduardo Valentin, Kamil Debski, Jean Delvare, lm-sensors,
	Linux PM list, linux-samsung-soc, devicetree, Lukasz Majewski,
	Kukjin Kim, linux-kernel, Sylwester Nawrocki, Abhilash Kesavan,
	Abhilash Kesavan

On Mon, Dec 22, 2014 at 05:27:47PM +0100, Lukasz Majewski wrote:
> Code for reading PWM FAN configuration data via device tree.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---

The headline is quite misleading. Please provide the affected subsystem (hwmon)
and the affected driver (pwm-fan) in the hwmon-customary form
	hwmon: (pwm-fan) Description

The Description should explain what the patch is about.

> Changes for v2:
> - Rename pwm_fan_max_states to pwm_fan_cooling_levels
> - Moving pwm_fan_of_get_cooling_data() call after setting end enabling PWM FAN
> - pwm_fan_of_get_cooling_data() now can fail - preserving old behaviour
> - Remove unnecessary dev_err() call
> ---
>  drivers/hwmon/pwm-fan.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 47 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
> index 870e100..8e68308 100644
> --- a/drivers/hwmon/pwm-fan.c
> +++ b/drivers/hwmon/pwm-fan.c
> @@ -30,7 +30,10 @@
>  struct pwm_fan_ctx {
>  	struct mutex lock;
>  	struct pwm_device *pwm;
> -	unsigned char pwm_value;
> +	unsigned int pwm_value;
> +	unsigned int pwm_fan_state;
> +	unsigned int pwm_fan_max_state;
> +	unsigned int *pwm_fan_cooling_levels;
>  };
>  
>  static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
> @@ -100,6 +103,47 @@ static struct attribute *pwm_fan_attrs[] = {
>  
>  ATTRIBUTE_GROUPS(pwm_fan);
>  
> +int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
> +{
> +	struct device_node *np = dev->of_node;
> +	struct property *pp;
> +	int len, num, i;
> +
> +	pp = of_find_property(np, "cooling-levels", &len);
> +	if (!pp) {
> +		dev_err(dev, "Property: 'cooling-levels' not found\n");
> +		return -EINVAL;
> +	}
> +
> +	if (len == 0) {
> +		dev_err(dev, "Length wrong value!\n");

Semantics. "Wrong length" would be better.

> +		return -EINVAL;
> +	}
> +

of_property_count_elems_of_size() might be more appropriate here.

> +	ctx->pwm_fan_cooling_levels = devm_kzalloc(dev, len, GFP_KERNEL);
> +	if (!ctx->pwm_fan_cooling_levels)
> +		return -ENOMEM;
> +
> +	num = len / sizeof(u32);

What if 'num' is 0 ? Is that guaranteed to never happen ?

> +	if (of_property_read_u32_array(np, pp->name,
> +				       ctx->pwm_fan_cooling_levels, num)) {
> +		dev_err(dev, "Property: %s cannot be read!\n", pp->name);

The ':' after 'Property' in those error messages doesn't seem to make much sense
to me.

> +		return -EINVAL;

of_property_read_u32_array() returns an error code. Please use it.

> +	}
> +
> +	for (i = 0; i < num; i++) {
> +		if (ctx->pwm_fan_cooling_levels[i] > MAX_PWM) {
> +			dev_err(dev, "PWM fan state[%d]:%d > %d\n", i,
> +				ctx->pwm_fan_cooling_levels[i], MAX_PWM);
> +			return -EINVAL;
> +		}
> +	}
> +
> +	ctx->pwm_fan_max_state = num - 1;
> +
> +	return 0;
> +}
> +
>  static int pwm_fan_probe(struct platform_device *pdev)
>  {
>  	struct device *hwmon;
> @@ -145,6 +189,8 @@ static int pwm_fan_probe(struct platform_device *pdev)
>  		pwm_disable(ctx->pwm);
>  		return PTR_ERR(hwmon);
>  	}
> +
> +	pwm_fan_of_get_cooling_data(&pdev->dev, ctx);

Now this is odd. Adding a function to return an error code just to ignore it
doesn't make much sense. While it makes sense to ignore errors if there is no
cooling data in the devicetree, errors due to bad devicetree data should not be
ignored.

I am also a bit concerned that you make this call _after_ instantiating the
hwmon device; this may potentially result in a race condition. Please ensure
that this is not the case.

Thanks,
Guenter

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [lm-sensors] [PATCH v2 7/8] hwmon: thermal: Read PWM FAN configuration from device tree
@ 2014-12-29 12:50       ` Guenter Roeck
  0 siblings, 0 replies; 329+ messages in thread
From: Guenter Roeck @ 2014-12-29 12:50 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Eduardo Valentin, Kamil Debski, Jean Delvare, lm-sensors,
	Linux PM list, linux-samsung-soc, devicetree, Lukasz Majewski,
	Kukjin Kim, linux-kernel, Sylwester Nawrocki, Abhilash Kesavan,
	Abhilash Kesavan

On Mon, Dec 22, 2014 at 05:27:47PM +0100, Lukasz Majewski wrote:
> Code for reading PWM FAN configuration data via device tree.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---

The headline is quite misleading. Please provide the affected subsystem (hwmon)
and the affected driver (pwm-fan) in the hwmon-customary form
	hwmon: (pwm-fan) Description

The Description should explain what the patch is about.

> Changes for v2:
> - Rename pwm_fan_max_states to pwm_fan_cooling_levels
> - Moving pwm_fan_of_get_cooling_data() call after setting end enabling PWM FAN
> - pwm_fan_of_get_cooling_data() now can fail - preserving old behaviour
> - Remove unnecessary dev_err() call
> ---
>  drivers/hwmon/pwm-fan.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 47 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
> index 870e100..8e68308 100644
> --- a/drivers/hwmon/pwm-fan.c
> +++ b/drivers/hwmon/pwm-fan.c
> @@ -30,7 +30,10 @@
>  struct pwm_fan_ctx {
>  	struct mutex lock;
>  	struct pwm_device *pwm;
> -	unsigned char pwm_value;
> +	unsigned int pwm_value;
> +	unsigned int pwm_fan_state;
> +	unsigned int pwm_fan_max_state;
> +	unsigned int *pwm_fan_cooling_levels;
>  };
>  
>  static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
> @@ -100,6 +103,47 @@ static struct attribute *pwm_fan_attrs[] = {
>  
>  ATTRIBUTE_GROUPS(pwm_fan);
>  
> +int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
> +{
> +	struct device_node *np = dev->of_node;
> +	struct property *pp;
> +	int len, num, i;
> +
> +	pp = of_find_property(np, "cooling-levels", &len);
> +	if (!pp) {
> +		dev_err(dev, "Property: 'cooling-levels' not found\n");
> +		return -EINVAL;
> +	}
> +
> +	if (len = 0) {
> +		dev_err(dev, "Length wrong value!\n");

Semantics. "Wrong length" would be better.

> +		return -EINVAL;
> +	}
> +

of_property_count_elems_of_size() might be more appropriate here.

> +	ctx->pwm_fan_cooling_levels = devm_kzalloc(dev, len, GFP_KERNEL);
> +	if (!ctx->pwm_fan_cooling_levels)
> +		return -ENOMEM;
> +
> +	num = len / sizeof(u32);

What if 'num' is 0 ? Is that guaranteed to never happen ?

> +	if (of_property_read_u32_array(np, pp->name,
> +				       ctx->pwm_fan_cooling_levels, num)) {
> +		dev_err(dev, "Property: %s cannot be read!\n", pp->name);

The ':' after 'Property' in those error messages doesn't seem to make much sense
to me.

> +		return -EINVAL;

of_property_read_u32_array() returns an error code. Please use it.

> +	}
> +
> +	for (i = 0; i < num; i++) {
> +		if (ctx->pwm_fan_cooling_levels[i] > MAX_PWM) {
> +			dev_err(dev, "PWM fan state[%d]:%d > %d\n", i,
> +				ctx->pwm_fan_cooling_levels[i], MAX_PWM);
> +			return -EINVAL;
> +		}
> +	}
> +
> +	ctx->pwm_fan_max_state = num - 1;
> +
> +	return 0;
> +}
> +
>  static int pwm_fan_probe(struct platform_device *pdev)
>  {
>  	struct device *hwmon;
> @@ -145,6 +189,8 @@ static int pwm_fan_probe(struct platform_device *pdev)
>  		pwm_disable(ctx->pwm);
>  		return PTR_ERR(hwmon);
>  	}
> +
> +	pwm_fan_of_get_cooling_data(&pdev->dev, ctx);

Now this is odd. Adding a function to return an error code just to ignore it
doesn't make much sense. While it makes sense to ignore errors if there is no
cooling data in the devicetree, errors due to bad devicetree data should not be
ignored.

I am also a bit concerned that you make this call _after_ instantiating the
hwmon device; this may potentially result in a race condition. Please ensure
that this is not the case.

Thanks,
Guenter

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v2 6/8] hwmon: thermal: Extract __set_pwm() function to only modify PWM duty cycle
  2014-12-22 16:27     ` [PATCH v2 6/8] hwmon: thermal: Extract __set_pwm() function to only modify PWM duty cycle Lukasz Majewski
  (?)
@ 2014-12-29 12:52       ` Guenter Roeck
  -1 siblings, 0 replies; 329+ messages in thread
From: Guenter Roeck @ 2014-12-29 12:52 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Eduardo Valentin, Kamil Debski, Jean Delvare, lm-sensors,
	Linux PM list, linux-samsung-soc, devicetree, Lukasz Majewski,
	Kukjin Kim, linux-kernel, Sylwester Nawrocki, Abhilash Kesavan,
	Abhilash Kesavan

On Mon, Dec 22, 2014 at 05:27:46PM +0100, Lukasz Majewski wrote:
> It was necessary to decouple code handling writing to sysfs from the one
> responsible for setting PWM of the fan.
> Due to that, new __set_pwm() method was extracted, which is responsible for
> only setting new PWM duty cycle.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---

Please provide the affected subsystem and the affected driver in the header.
While it may make sense to explain that the patch is to prepare the driver for
thermal use, this should be part of the descriptive text. The patch is,
however, not not a thermal subsystem related patch. The 'thermal:' in the
headline is thus misleading, and you should drop it.

Guenter

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v2 6/8] hwmon: thermal: Extract __set_pwm() function to only modify PWM duty cycle
@ 2014-12-29 12:52       ` Guenter Roeck
  0 siblings, 0 replies; 329+ messages in thread
From: Guenter Roeck @ 2014-12-29 12:52 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Eduardo Valentin, Kamil Debski, Jean Delvare, lm-sensors,
	Linux PM list, linux-samsung-soc, devicetree, Lukasz Majewski,
	Kukjin Kim, linux-kernel, Sylwester Nawrocki, Abhilash Kesavan,
	Abhilash Kesavan

On Mon, Dec 22, 2014 at 05:27:46PM +0100, Lukasz Majewski wrote:
> It was necessary to decouple code handling writing to sysfs from the one
> responsible for setting PWM of the fan.
> Due to that, new __set_pwm() method was extracted, which is responsible for
> only setting new PWM duty cycle.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---

Please provide the affected subsystem and the affected driver in the header.
While it may make sense to explain that the patch is to prepare the driver for
thermal use, this should be part of the descriptive text. The patch is,
however, not not a thermal subsystem related patch. The 'thermal:' in the
headline is thus misleading, and you should drop it.

Guenter

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [lm-sensors] [PATCH v2 6/8] hwmon: thermal: Extract __set_pwm() function to only modify PWM duty
@ 2014-12-29 12:52       ` Guenter Roeck
  0 siblings, 0 replies; 329+ messages in thread
From: Guenter Roeck @ 2014-12-29 12:52 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Eduardo Valentin, Kamil Debski, Jean Delvare, lm-sensors,
	Linux PM list, linux-samsung-soc, devicetree, Lukasz Majewski,
	Kukjin Kim, linux-kernel, Sylwester Nawrocki, Abhilash Kesavan,
	Abhilash Kesavan

On Mon, Dec 22, 2014 at 05:27:46PM +0100, Lukasz Majewski wrote:
> It was necessary to decouple code handling writing to sysfs from the one
> responsible for setting PWM of the fan.
> Due to that, new __set_pwm() method was extracted, which is responsible for
> only setting new PWM duty cycle.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---

Please provide the affected subsystem and the affected driver in the header.
While it may make sense to explain that the patch is to prepare the driver for
thermal use, this should be part of the descriptive text. The patch is,
however, not not a thermal subsystem related patch. The 'thermal:' in the
headline is thus misleading, and you should drop it.

Guenter

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v2 2/8] thermal: Provide stub for thermal_cdev_update() function
@ 2015-01-02 18:40       ` Eduardo Valentin
  0 siblings, 0 replies; 329+ messages in thread
From: Eduardo Valentin @ 2015-01-02 18:40 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, lm-sensors,
	Linux PM list, linux-samsung-soc, devicetree, Lukasz Majewski,
	Kukjin Kim, linux-kernel, Sylwester Nawrocki, Abhilash Kesavan,
	Abhilash Kesavan

[-- Attachment #1: Type: text/plain, Size: 2121 bytes --]

On Mon, Dec 22, 2014 at 05:27:42PM +0100, Lukasz Majewski wrote:
> Odroid U3 fan can work without being registered as OF cooling device
> (with CONFIG_THERMAL_OF disabled).
> In this situation it can be controlled via PWM entry at
> /sys/class/hwmon/hwmon0/pwm1.
> 
> Therefore, the thermal_cdev_update() function needs a stub
> to allow clean compilation.

I am not sure I understand what you are attempting to do here. What is
the relation that you see between CONFIG_OF_THERMAL and
thermal_cdev_update? 

> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
> Changes for v2:
> - New patch
> ---
>  include/linux/thermal.h | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> index 871123c..b3515b5 100644
> --- a/include/linux/thermal.h
> +++ b/include/linux/thermal.h
> @@ -332,6 +332,7 @@ struct thermal_cooling_device *
>  thermal_of_cooling_device_register(struct device_node *np,
>  				   char *type, void *devdata,
>  				   const struct thermal_cooling_device_ops *);
> +void thermal_cdev_update(struct thermal_cooling_device *);
>  #else
>  static inline struct thermal_zone_device *
>  thermal_zone_of_sensor_register(struct device *dev, int id, void *data,
> @@ -353,6 +354,10 @@ thermal_of_cooling_device_register(struct device_node *np,
>  {
>  	return NULL;
>  }
> +
> +static inline void thermal_cdev_update(struct thermal_cooling_device *cdev)
> +{
> +}
>  #endif
>  struct thermal_zone_device *thermal_zone_device_register(const char *, int, int,
>  		void *, struct thermal_zone_device_ops *,
> @@ -375,7 +380,6 @@ int thermal_zone_get_temp(struct thermal_zone_device *tz, unsigned long *temp);
>  int get_tz_trend(struct thermal_zone_device *, int);
>  struct thermal_instance *get_thermal_instance(struct thermal_zone_device *,
>  		struct thermal_cooling_device *, int);
> -void thermal_cdev_update(struct thermal_cooling_device *);
>  void thermal_notify_framework(struct thermal_zone_device *, int);
>  
>  #ifdef CONFIG_NET
> -- 
> 2.0.0.rc2
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v2 2/8] thermal: Provide stub for thermal_cdev_update() function
@ 2015-01-02 18:40       ` Eduardo Valentin
  0 siblings, 0 replies; 329+ messages in thread
From: Eduardo Valentin @ 2015-01-02 18:40 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck,
	lm-sensors-GZX6beZjE8VD60Wz+7aTrA, Linux PM list,
	linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Lukasz Majewski, Kukjin Kim,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Sylwester Nawrocki,
	Abhilash Kesavan, Abhilash Kesavan

[-- Attachment #1: Type: text/plain, Size: 2149 bytes --]

On Mon, Dec 22, 2014 at 05:27:42PM +0100, Lukasz Majewski wrote:
> Odroid U3 fan can work without being registered as OF cooling device
> (with CONFIG_THERMAL_OF disabled).
> In this situation it can be controlled via PWM entry at
> /sys/class/hwmon/hwmon0/pwm1.
> 
> Therefore, the thermal_cdev_update() function needs a stub
> to allow clean compilation.

I am not sure I understand what you are attempting to do here. What is
the relation that you see between CONFIG_OF_THERMAL and
thermal_cdev_update? 

> 
> Signed-off-by: Lukasz Majewski <l.majewski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
> ---
> Changes for v2:
> - New patch
> ---
>  include/linux/thermal.h | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> index 871123c..b3515b5 100644
> --- a/include/linux/thermal.h
> +++ b/include/linux/thermal.h
> @@ -332,6 +332,7 @@ struct thermal_cooling_device *
>  thermal_of_cooling_device_register(struct device_node *np,
>  				   char *type, void *devdata,
>  				   const struct thermal_cooling_device_ops *);
> +void thermal_cdev_update(struct thermal_cooling_device *);
>  #else
>  static inline struct thermal_zone_device *
>  thermal_zone_of_sensor_register(struct device *dev, int id, void *data,
> @@ -353,6 +354,10 @@ thermal_of_cooling_device_register(struct device_node *np,
>  {
>  	return NULL;
>  }
> +
> +static inline void thermal_cdev_update(struct thermal_cooling_device *cdev)
> +{
> +}
>  #endif
>  struct thermal_zone_device *thermal_zone_device_register(const char *, int, int,
>  		void *, struct thermal_zone_device_ops *,
> @@ -375,7 +380,6 @@ int thermal_zone_get_temp(struct thermal_zone_device *tz, unsigned long *temp);
>  int get_tz_trend(struct thermal_zone_device *, int);
>  struct thermal_instance *get_thermal_instance(struct thermal_zone_device *,
>  		struct thermal_cooling_device *, int);
> -void thermal_cdev_update(struct thermal_cooling_device *);
>  void thermal_notify_framework(struct thermal_zone_device *, int);
>  
>  #ifdef CONFIG_NET
> -- 
> 2.0.0.rc2
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [lm-sensors] [PATCH v2 2/8] thermal: Provide stub for thermal_cdev_update() function
@ 2015-01-02 18:40       ` Eduardo Valentin
  0 siblings, 0 replies; 329+ messages in thread
From: Eduardo Valentin @ 2015-01-02 18:40 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, lm-sensors,
	Linux PM list, linux-samsung-soc, devicetree, Lukasz Majewski,
	Kukjin Kim, linux-kernel, Sylwester Nawrocki, Abhilash Kesavan,
	Abhilash Kesavan


[-- Attachment #1.1: Type: text/plain, Size: 2121 bytes --]

On Mon, Dec 22, 2014 at 05:27:42PM +0100, Lukasz Majewski wrote:
> Odroid U3 fan can work without being registered as OF cooling device
> (with CONFIG_THERMAL_OF disabled).
> In this situation it can be controlled via PWM entry at
> /sys/class/hwmon/hwmon0/pwm1.
> 
> Therefore, the thermal_cdev_update() function needs a stub
> to allow clean compilation.

I am not sure I understand what you are attempting to do here. What is
the relation that you see between CONFIG_OF_THERMAL and
thermal_cdev_update? 

> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
> Changes for v2:
> - New patch
> ---
>  include/linux/thermal.h | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> index 871123c..b3515b5 100644
> --- a/include/linux/thermal.h
> +++ b/include/linux/thermal.h
> @@ -332,6 +332,7 @@ struct thermal_cooling_device *
>  thermal_of_cooling_device_register(struct device_node *np,
>  				   char *type, void *devdata,
>  				   const struct thermal_cooling_device_ops *);
> +void thermal_cdev_update(struct thermal_cooling_device *);
>  #else
>  static inline struct thermal_zone_device *
>  thermal_zone_of_sensor_register(struct device *dev, int id, void *data,
> @@ -353,6 +354,10 @@ thermal_of_cooling_device_register(struct device_node *np,
>  {
>  	return NULL;
>  }
> +
> +static inline void thermal_cdev_update(struct thermal_cooling_device *cdev)
> +{
> +}
>  #endif
>  struct thermal_zone_device *thermal_zone_device_register(const char *, int, int,
>  		void *, struct thermal_zone_device_ops *,
> @@ -375,7 +380,6 @@ int thermal_zone_get_temp(struct thermal_zone_device *tz, unsigned long *temp);
>  int get_tz_trend(struct thermal_zone_device *, int);
>  struct thermal_instance *get_thermal_instance(struct thermal_zone_device *,
>  		struct thermal_cooling_device *, int);
> -void thermal_cdev_update(struct thermal_cooling_device *);
>  void thermal_notify_framework(struct thermal_zone_device *, int);
>  
>  #ifdef CONFIG_NET
> -- 
> 2.0.0.rc2
> 

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

[-- Attachment #2: Type: text/plain, Size: 153 bytes --]

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v2 3/8] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling device
  2014-12-22 16:27     ` [PATCH v2 3/8] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling device Lukasz Majewski
  (?)
@ 2015-01-02 18:51       ` Eduardo Valentin
  -1 siblings, 0 replies; 329+ messages in thread
From: Eduardo Valentin @ 2015-01-02 18:51 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, lm-sensors,
	Linux PM list, linux-samsung-soc, devicetree, Lukasz Majewski,
	Kukjin Kim, linux-kernel, Sylwester Nawrocki, Abhilash Kesavan,
	Abhilash Kesavan

[-- Attachment #1: Type: text/plain, Size: 2000 bytes --]

On Mon, Dec 22, 2014 at 05:27:43PM +0100, Lukasz Majewski wrote:
> Several new properties to allow PWM fan working as a cooling device have been
> combined into this single commit.
> 

Patch prefix should look something like 'dt-bindings: ...', or better
'Documentation: devicetree: ...', or 'Documentation: bindings: ...'

> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
> Changes for v2:
> - Rename cooling-pwm-values to cooling-levels
> - Remove default-pulse-width property and stick to default hwmon policy
> ---
>  .../devicetree/bindings/hwmon/pwm-fan.txt          | 23 ++++++++++++++++++++++
>  1 file changed, 23 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> index 610757c..001446a 100644
> --- a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> +++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> @@ -3,10 +3,33 @@ Bindings for a fan connected to the PWM lines
>  Required properties:
>  - compatible	: "pwm-fan"
>  - pwms		: the PWM that is used to control the PWM fan
> +- cooling-levels      : PWM duty cycle values in a range from 0 to 255
> +			which correspond to thermal cooling states
> +
> +Thorough description of the following bindings:
> +		cooling-min-state = <0>;
> +		cooling-max-state = <3>;
> +		#cooling-cells = <2>;
> +		thermal-zone {
> +			cpu_thermal: cpu-thermal {
> +			cooling-maps {
> +				map0 {
> +				     trip = <&cpu_alert1>;
> +				     cooling-device = <&fan0 0 1>;
> +				};
> +			};
> +		};
> +
> +for PWM FAN used as cooling device can be found at:
> +./Documentation/devicetree/bindings/thermal/thermal.txt
>  
>  Example:
>  	pwm-fan {
>  		compatible = "pwm-fan";
>  		status = "okay";
>  		pwms = <&pwm 0 10000 0>;
> +		cooling-min-state = <0>;
> +		cooling-max-state = <3>;
> +		#cooling-cells = <2>;
> +		cooling-levels = <0 102 170 255>;
>  	};
> -- 
> 2.0.0.rc2
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v2 3/8] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling device
@ 2015-01-02 18:51       ` Eduardo Valentin
  0 siblings, 0 replies; 329+ messages in thread
From: Eduardo Valentin @ 2015-01-02 18:51 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, lm-sensors,
	Linux PM list, linux-samsung-soc, devicetree, Lukasz Majewski,
	Kukjin Kim, linux-kernel, Sylwester Nawrocki, Abhilash Kesavan,
	Abhilash Kesavan

[-- Attachment #1: Type: text/plain, Size: 2000 bytes --]

On Mon, Dec 22, 2014 at 05:27:43PM +0100, Lukasz Majewski wrote:
> Several new properties to allow PWM fan working as a cooling device have been
> combined into this single commit.
> 

Patch prefix should look something like 'dt-bindings: ...', or better
'Documentation: devicetree: ...', or 'Documentation: bindings: ...'

> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
> Changes for v2:
> - Rename cooling-pwm-values to cooling-levels
> - Remove default-pulse-width property and stick to default hwmon policy
> ---
>  .../devicetree/bindings/hwmon/pwm-fan.txt          | 23 ++++++++++++++++++++++
>  1 file changed, 23 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> index 610757c..001446a 100644
> --- a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> +++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> @@ -3,10 +3,33 @@ Bindings for a fan connected to the PWM lines
>  Required properties:
>  - compatible	: "pwm-fan"
>  - pwms		: the PWM that is used to control the PWM fan
> +- cooling-levels      : PWM duty cycle values in a range from 0 to 255
> +			which correspond to thermal cooling states
> +
> +Thorough description of the following bindings:
> +		cooling-min-state = <0>;
> +		cooling-max-state = <3>;
> +		#cooling-cells = <2>;
> +		thermal-zone {
> +			cpu_thermal: cpu-thermal {
> +			cooling-maps {
> +				map0 {
> +				     trip = <&cpu_alert1>;
> +				     cooling-device = <&fan0 0 1>;
> +				};
> +			};
> +		};
> +
> +for PWM FAN used as cooling device can be found at:
> +./Documentation/devicetree/bindings/thermal/thermal.txt
>  
>  Example:
>  	pwm-fan {
>  		compatible = "pwm-fan";
>  		status = "okay";
>  		pwms = <&pwm 0 10000 0>;
> +		cooling-min-state = <0>;
> +		cooling-max-state = <3>;
> +		#cooling-cells = <2>;
> +		cooling-levels = <0 102 170 255>;
>  	};
> -- 
> 2.0.0.rc2
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [lm-sensors] [PATCH v2 3/8] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cool
@ 2015-01-02 18:51       ` Eduardo Valentin
  0 siblings, 0 replies; 329+ messages in thread
From: Eduardo Valentin @ 2015-01-02 18:51 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, lm-sensors,
	Linux PM list, linux-samsung-soc, devicetree, Lukasz Majewski,
	Kukjin Kim, linux-kernel, Sylwester Nawrocki, Abhilash Kesavan,
	Abhilash Kesavan


[-- Attachment #1.1: Type: text/plain, Size: 2000 bytes --]

On Mon, Dec 22, 2014 at 05:27:43PM +0100, Lukasz Majewski wrote:
> Several new properties to allow PWM fan working as a cooling device have been
> combined into this single commit.
> 

Patch prefix should look something like 'dt-bindings: ...', or better
'Documentation: devicetree: ...', or 'Documentation: bindings: ...'

> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
> Changes for v2:
> - Rename cooling-pwm-values to cooling-levels
> - Remove default-pulse-width property and stick to default hwmon policy
> ---
>  .../devicetree/bindings/hwmon/pwm-fan.txt          | 23 ++++++++++++++++++++++
>  1 file changed, 23 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> index 610757c..001446a 100644
> --- a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> +++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> @@ -3,10 +3,33 @@ Bindings for a fan connected to the PWM lines
>  Required properties:
>  - compatible	: "pwm-fan"
>  - pwms		: the PWM that is used to control the PWM fan
> +- cooling-levels      : PWM duty cycle values in a range from 0 to 255
> +			which correspond to thermal cooling states
> +
> +Thorough description of the following bindings:
> +		cooling-min-state = <0>;
> +		cooling-max-state = <3>;
> +		#cooling-cells = <2>;
> +		thermal-zone {
> +			cpu_thermal: cpu-thermal {
> +			cooling-maps {
> +				map0 {
> +				     trip = <&cpu_alert1>;
> +				     cooling-device = <&fan0 0 1>;
> +				};
> +			};
> +		};
> +
> +for PWM FAN used as cooling device can be found at:
> +./Documentation/devicetree/bindings/thermal/thermal.txt
>  
>  Example:
>  	pwm-fan {
>  		compatible = "pwm-fan";
>  		status = "okay";
>  		pwms = <&pwm 0 10000 0>;
> +		cooling-min-state = <0>;
> +		cooling-max-state = <3>;
> +		#cooling-cells = <2>;
> +		cooling-levels = <0 102 170 255>;
>  	};
> -- 
> 2.0.0.rc2
> 

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

[-- Attachment #2: Type: text/plain, Size: 153 bytes --]

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v2 5/8] hwmon: thermal: dts: Add properties to use pwm-fan device as a cooling device in Odroid U3
  2014-12-22 16:27     ` [PATCH v2 5/8] hwmon: thermal: dts: Add properties to use pwm-fan device as a cooling device in Odroid U3 Lukasz Majewski
  (?)
@ 2015-01-02 18:52       ` Eduardo Valentin
  -1 siblings, 0 replies; 329+ messages in thread
From: Eduardo Valentin @ 2015-01-02 18:52 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, lm-sensors,
	Linux PM list, linux-samsung-soc, devicetree, Lukasz Majewski,
	Kukjin Kim, linux-kernel, Sylwester Nawrocki, Abhilash Kesavan,
	Abhilash Kesavan

[-- Attachment #1: Type: text/plain, Size: 1743 bytes --]

Patch subject should use a prefix like:
'arm: dts:....'

On Mon, Dec 22, 2014 at 05:27:45PM +0100, Lukasz Majewski wrote:
> With those bindings it is possible to use pwm-fan device available in
> Odroid U3 as a cooling device.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
> Changes for v2:
> - Rename cooling-pwm-values property to cooling-levels
> ---
>  arch/arm/boot/dts/exynos4412-odroidu3.dts | 33 ++++++++++++++++++++++++++++++-
>  1 file changed, 32 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
> index 60bd1e4..380035d 100644
> --- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
> +++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
> @@ -32,11 +32,42 @@
>  		};
>  	};
>  
> -	pwm-fan {
> +	fan0: pwm-fan {
>  		compatible = "pwm-fan";
>  		pwms = <&pwm 0 10000 0>;
> +		cooling-min-state = <0>;
> +		cooling-max-state = <3>;
> +		#cooling-cells = <2>;
> +		cooling-levels = <0 102 170 255>;
>  		status = "okay";
>  	};
> +
> +	thermal-zones {
> +		cpu_thermal: cpu-thermal {
> +			cooling-maps {
> +				map0 {
> +				     trip = <&cpu_alert1>;
> +				     cooling-device = <&cpu0 7 7>;
> +				};
> +				map1 {
> +				     trip = <&cpu_alert2>;
> +				     cooling-device = <&cpu0 13 13>;
> +				};
> +				map2 {
> +				     trip = <&cpu_alert0>;
> +				     cooling-device = <&fan0 0 1>;
> +				};
> +				map3 {
> +				     trip = <&cpu_alert1>;
> +				     cooling-device = <&fan0 1 2>;
> +				};
> +				map4 {
> +				     trip = <&cpu_alert2>;
> +				     cooling-device = <&fan0 2 3>;
> +				};
> +			};
> +		};
> +	};
>  };
>  
>  &pwm {
> -- 
> 2.0.0.rc2
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v2 5/8] hwmon: thermal: dts: Add properties to use pwm-fan device as a cooling device in Odroid U3
@ 2015-01-02 18:52       ` Eduardo Valentin
  0 siblings, 0 replies; 329+ messages in thread
From: Eduardo Valentin @ 2015-01-02 18:52 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, lm-sensors,
	Linux PM list, linux-samsung-soc, devicetree, Lukasz Majewski,
	Kukjin Kim, linux-kernel, Sylwester Nawrocki, Abhilash Kesavan,
	Abhilash Kesavan

[-- Attachment #1: Type: text/plain, Size: 1743 bytes --]

Patch subject should use a prefix like:
'arm: dts:....'

On Mon, Dec 22, 2014 at 05:27:45PM +0100, Lukasz Majewski wrote:
> With those bindings it is possible to use pwm-fan device available in
> Odroid U3 as a cooling device.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
> Changes for v2:
> - Rename cooling-pwm-values property to cooling-levels
> ---
>  arch/arm/boot/dts/exynos4412-odroidu3.dts | 33 ++++++++++++++++++++++++++++++-
>  1 file changed, 32 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
> index 60bd1e4..380035d 100644
> --- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
> +++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
> @@ -32,11 +32,42 @@
>  		};
>  	};
>  
> -	pwm-fan {
> +	fan0: pwm-fan {
>  		compatible = "pwm-fan";
>  		pwms = <&pwm 0 10000 0>;
> +		cooling-min-state = <0>;
> +		cooling-max-state = <3>;
> +		#cooling-cells = <2>;
> +		cooling-levels = <0 102 170 255>;
>  		status = "okay";
>  	};
> +
> +	thermal-zones {
> +		cpu_thermal: cpu-thermal {
> +			cooling-maps {
> +				map0 {
> +				     trip = <&cpu_alert1>;
> +				     cooling-device = <&cpu0 7 7>;
> +				};
> +				map1 {
> +				     trip = <&cpu_alert2>;
> +				     cooling-device = <&cpu0 13 13>;
> +				};
> +				map2 {
> +				     trip = <&cpu_alert0>;
> +				     cooling-device = <&fan0 0 1>;
> +				};
> +				map3 {
> +				     trip = <&cpu_alert1>;
> +				     cooling-device = <&fan0 1 2>;
> +				};
> +				map4 {
> +				     trip = <&cpu_alert2>;
> +				     cooling-device = <&fan0 2 3>;
> +				};
> +			};
> +		};
> +	};
>  };
>  
>  &pwm {
> -- 
> 2.0.0.rc2
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [lm-sensors] [PATCH v2 5/8] hwmon: thermal: dts: Add properties to use pwm-fan device as a cooli
@ 2015-01-02 18:52       ` Eduardo Valentin
  0 siblings, 0 replies; 329+ messages in thread
From: Eduardo Valentin @ 2015-01-02 18:52 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, lm-sensors,
	Linux PM list, linux-samsung-soc, devicetree, Lukasz Majewski,
	Kukjin Kim, linux-kernel, Sylwester Nawrocki, Abhilash Kesavan,
	Abhilash Kesavan


[-- Attachment #1.1: Type: text/plain, Size: 1743 bytes --]

Patch subject should use a prefix like:
'arm: dts:....'

On Mon, Dec 22, 2014 at 05:27:45PM +0100, Lukasz Majewski wrote:
> With those bindings it is possible to use pwm-fan device available in
> Odroid U3 as a cooling device.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
> Changes for v2:
> - Rename cooling-pwm-values property to cooling-levels
> ---
>  arch/arm/boot/dts/exynos4412-odroidu3.dts | 33 ++++++++++++++++++++++++++++++-
>  1 file changed, 32 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
> index 60bd1e4..380035d 100644
> --- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
> +++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
> @@ -32,11 +32,42 @@
>  		};
>  	};
>  
> -	pwm-fan {
> +	fan0: pwm-fan {
>  		compatible = "pwm-fan";
>  		pwms = <&pwm 0 10000 0>;
> +		cooling-min-state = <0>;
> +		cooling-max-state = <3>;
> +		#cooling-cells = <2>;
> +		cooling-levels = <0 102 170 255>;
>  		status = "okay";
>  	};
> +
> +	thermal-zones {
> +		cpu_thermal: cpu-thermal {
> +			cooling-maps {
> +				map0 {
> +				     trip = <&cpu_alert1>;
> +				     cooling-device = <&cpu0 7 7>;
> +				};
> +				map1 {
> +				     trip = <&cpu_alert2>;
> +				     cooling-device = <&cpu0 13 13>;
> +				};
> +				map2 {
> +				     trip = <&cpu_alert0>;
> +				     cooling-device = <&fan0 0 1>;
> +				};
> +				map3 {
> +				     trip = <&cpu_alert1>;
> +				     cooling-device = <&fan0 1 2>;
> +				};
> +				map4 {
> +				     trip = <&cpu_alert2>;
> +				     cooling-device = <&fan0 2 3>;
> +				};
> +			};
> +		};
> +	};
>  };
>  
>  &pwm {
> -- 
> 2.0.0.rc2
> 

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

[-- Attachment #2: Type: text/plain, Size: 153 bytes --]

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v2 1/8] thermal: Provide stub for thermal_of_cooling_device_register() function
  2014-12-22 16:27     ` Lukasz Majewski
  (?)
@ 2015-01-02 18:54       ` Eduardo Valentin
  -1 siblings, 0 replies; 329+ messages in thread
From: Eduardo Valentin @ 2015-01-02 18:54 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, lm-sensors,
	Linux PM list, linux-samsung-soc, devicetree, Lukasz Majewski,
	Kukjin Kim, linux-kernel, Sylwester Nawrocki, Abhilash Kesavan,
	Abhilash Kesavan

[-- Attachment #1: Type: text/plain, Size: 2539 bytes --]

On Mon, Dec 22, 2014 at 05:27:41PM +0100, Lukasz Majewski wrote:
> Odroid U3 fan can work without being registered as OF cooling device
> (with CONFIG_THERMAL_OF disabled).
> In this situation it can be controlled via PWM entry at
> /sys/class/hwmon/hwmon0/pwm1.
> 
> Therefore, the thermal_of_cooling_device_register() function needs a stub
> to allow clean compilation.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>

Acked-by: Eduardo Valentin <edubezval@gmail.com>

> ---
> Changes for v2:
> - None
> ---
>  include/linux/thermal.h | 14 +++++++++++---
>  1 file changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> index 2de3d9e..871123c 100644
> --- a/include/linux/thermal.h
> +++ b/include/linux/thermal.h
> @@ -328,6 +328,10 @@ thermal_zone_of_sensor_register(struct device *dev, int id, void *data,
>  				const struct thermal_zone_of_device_ops *ops);
>  void thermal_zone_of_sensor_unregister(struct device *dev,
>  				       struct thermal_zone_device *tz);
> +struct thermal_cooling_device *
> +thermal_of_cooling_device_register(struct device_node *np,
> +				   char *type, void *devdata,
> +				   const struct thermal_cooling_device_ops *);
>  #else
>  static inline struct thermal_zone_device *
>  thermal_zone_of_sensor_register(struct device *dev, int id, void *data,
> @@ -342,6 +346,13 @@ void thermal_zone_of_sensor_unregister(struct device *dev,
>  {
>  }
>  
> +static inline struct thermal_cooling_device *
> +thermal_of_cooling_device_register(struct device_node *np,
> +				   char *type, void *devdata,
> +				   const struct thermal_cooling_device_ops *ops)
> +{
> +	return NULL;
> +}
>  #endif
>  struct thermal_zone_device *thermal_zone_device_register(const char *, int, int,
>  		void *, struct thermal_zone_device_ops *,
> @@ -357,9 +368,6 @@ void thermal_zone_device_update(struct thermal_zone_device *);
>  
>  struct thermal_cooling_device *thermal_cooling_device_register(char *, void *,
>  		const struct thermal_cooling_device_ops *);
> -struct thermal_cooling_device *
> -thermal_of_cooling_device_register(struct device_node *np, char *, void *,
> -				   const struct thermal_cooling_device_ops *);
>  void thermal_cooling_device_unregister(struct thermal_cooling_device *);
>  struct thermal_zone_device *thermal_zone_get_zone_by_name(const char *name);
>  int thermal_zone_get_temp(struct thermal_zone_device *tz, unsigned long *temp);
> -- 
> 2.0.0.rc2
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v2 1/8] thermal: Provide stub for thermal_of_cooling_device_register() function
@ 2015-01-02 18:54       ` Eduardo Valentin
  0 siblings, 0 replies; 329+ messages in thread
From: Eduardo Valentin @ 2015-01-02 18:54 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, lm-sensors,
	Linux PM list, linux-samsung-soc, devicetree, Lukasz Majewski,
	Kukjin Kim, linux-kernel, Sylwester Nawrocki, Abhilash Kesavan,
	Abhilash Kesavan

[-- Attachment #1: Type: text/plain, Size: 2539 bytes --]

On Mon, Dec 22, 2014 at 05:27:41PM +0100, Lukasz Majewski wrote:
> Odroid U3 fan can work without being registered as OF cooling device
> (with CONFIG_THERMAL_OF disabled).
> In this situation it can be controlled via PWM entry at
> /sys/class/hwmon/hwmon0/pwm1.
> 
> Therefore, the thermal_of_cooling_device_register() function needs a stub
> to allow clean compilation.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>

Acked-by: Eduardo Valentin <edubezval@gmail.com>

> ---
> Changes for v2:
> - None
> ---
>  include/linux/thermal.h | 14 +++++++++++---
>  1 file changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> index 2de3d9e..871123c 100644
> --- a/include/linux/thermal.h
> +++ b/include/linux/thermal.h
> @@ -328,6 +328,10 @@ thermal_zone_of_sensor_register(struct device *dev, int id, void *data,
>  				const struct thermal_zone_of_device_ops *ops);
>  void thermal_zone_of_sensor_unregister(struct device *dev,
>  				       struct thermal_zone_device *tz);
> +struct thermal_cooling_device *
> +thermal_of_cooling_device_register(struct device_node *np,
> +				   char *type, void *devdata,
> +				   const struct thermal_cooling_device_ops *);
>  #else
>  static inline struct thermal_zone_device *
>  thermal_zone_of_sensor_register(struct device *dev, int id, void *data,
> @@ -342,6 +346,13 @@ void thermal_zone_of_sensor_unregister(struct device *dev,
>  {
>  }
>  
> +static inline struct thermal_cooling_device *
> +thermal_of_cooling_device_register(struct device_node *np,
> +				   char *type, void *devdata,
> +				   const struct thermal_cooling_device_ops *ops)
> +{
> +	return NULL;
> +}
>  #endif
>  struct thermal_zone_device *thermal_zone_device_register(const char *, int, int,
>  		void *, struct thermal_zone_device_ops *,
> @@ -357,9 +368,6 @@ void thermal_zone_device_update(struct thermal_zone_device *);
>  
>  struct thermal_cooling_device *thermal_cooling_device_register(char *, void *,
>  		const struct thermal_cooling_device_ops *);
> -struct thermal_cooling_device *
> -thermal_of_cooling_device_register(struct device_node *np, char *, void *,
> -				   const struct thermal_cooling_device_ops *);
>  void thermal_cooling_device_unregister(struct thermal_cooling_device *);
>  struct thermal_zone_device *thermal_zone_get_zone_by_name(const char *name);
>  int thermal_zone_get_temp(struct thermal_zone_device *tz, unsigned long *temp);
> -- 
> 2.0.0.rc2
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [lm-sensors] [PATCH v2 1/8] thermal: Provide stub for thermal_of_cooling_device_register() funct
@ 2015-01-02 18:54       ` Eduardo Valentin
  0 siblings, 0 replies; 329+ messages in thread
From: Eduardo Valentin @ 2015-01-02 18:54 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, lm-sensors,
	Linux PM list, linux-samsung-soc, devicetree, Lukasz Majewski,
	Kukjin Kim, linux-kernel, Sylwester Nawrocki, Abhilash Kesavan,
	Abhilash Kesavan


[-- Attachment #1.1: Type: text/plain, Size: 2539 bytes --]

On Mon, Dec 22, 2014 at 05:27:41PM +0100, Lukasz Majewski wrote:
> Odroid U3 fan can work without being registered as OF cooling device
> (with CONFIG_THERMAL_OF disabled).
> In this situation it can be controlled via PWM entry at
> /sys/class/hwmon/hwmon0/pwm1.
> 
> Therefore, the thermal_of_cooling_device_register() function needs a stub
> to allow clean compilation.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>

Acked-by: Eduardo Valentin <edubezval@gmail.com>

> ---
> Changes for v2:
> - None
> ---
>  include/linux/thermal.h | 14 +++++++++++---
>  1 file changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> index 2de3d9e..871123c 100644
> --- a/include/linux/thermal.h
> +++ b/include/linux/thermal.h
> @@ -328,6 +328,10 @@ thermal_zone_of_sensor_register(struct device *dev, int id, void *data,
>  				const struct thermal_zone_of_device_ops *ops);
>  void thermal_zone_of_sensor_unregister(struct device *dev,
>  				       struct thermal_zone_device *tz);
> +struct thermal_cooling_device *
> +thermal_of_cooling_device_register(struct device_node *np,
> +				   char *type, void *devdata,
> +				   const struct thermal_cooling_device_ops *);
>  #else
>  static inline struct thermal_zone_device *
>  thermal_zone_of_sensor_register(struct device *dev, int id, void *data,
> @@ -342,6 +346,13 @@ void thermal_zone_of_sensor_unregister(struct device *dev,
>  {
>  }
>  
> +static inline struct thermal_cooling_device *
> +thermal_of_cooling_device_register(struct device_node *np,
> +				   char *type, void *devdata,
> +				   const struct thermal_cooling_device_ops *ops)
> +{
> +	return NULL;
> +}
>  #endif
>  struct thermal_zone_device *thermal_zone_device_register(const char *, int, int,
>  		void *, struct thermal_zone_device_ops *,
> @@ -357,9 +368,6 @@ void thermal_zone_device_update(struct thermal_zone_device *);
>  
>  struct thermal_cooling_device *thermal_cooling_device_register(char *, void *,
>  		const struct thermal_cooling_device_ops *);
> -struct thermal_cooling_device *
> -thermal_of_cooling_device_register(struct device_node *np, char *, void *,
> -				   const struct thermal_cooling_device_ops *);
>  void thermal_cooling_device_unregister(struct thermal_cooling_device *);
>  struct thermal_zone_device *thermal_zone_get_zone_by_name(const char *name);
>  int thermal_zone_get_temp(struct thermal_zone_device *tz, unsigned long *temp);
> -- 
> 2.0.0.rc2
> 

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

[-- Attachment #2: Type: text/plain, Size: 153 bytes --]

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v2 1/8] thermal: Provide stub for thermal_of_cooling_device_register() function
  2015-01-02 18:54       ` [PATCH v2 1/8] thermal: Provide stub for thermal_of_cooling_device_register() function Eduardo Valentin
  (?)
@ 2015-01-02 19:03         ` Eduardo Valentin
  -1 siblings, 0 replies; 329+ messages in thread
From: Eduardo Valentin @ 2015-01-02 19:03 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, lm-sensors,
	Linux PM list, linux-samsung-soc, devicetree, Lukasz Majewski,
	Kukjin Kim, linux-kernel, Sylwester Nawrocki, Abhilash Kesavan,
	Abhilash Kesavan

[-- Attachment #1: Type: text/plain, Size: 3356 bytes --]

On Fri, Jan 02, 2015 at 02:54:28PM -0400, Eduardo Valentin wrote:
> On Mon, Dec 22, 2014 at 05:27:41PM +0100, Lukasz Majewski wrote:
> > Odroid U3 fan can work without being registered as OF cooling device
> > (with CONFIG_THERMAL_OF disabled).
> > In this situation it can be controlled via PWM entry at
> > /sys/class/hwmon/hwmon0/pwm1.
> > 
> > Therefore, the thermal_of_cooling_device_register() function needs a stub
> > to allow clean compilation.
> > 
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> 
> Acked-by: Eduardo Valentin <edubezval@gmail.com>

Sorry, too fast,

This is actually
Nacked-by: Eduardo Valentin <edubezval@gmail.com>

:-)

I get this error:
drivers/thermal/thermal_core.c:1210:1: error: redefinition of
‘thermal_of_cooling_device_register’
 thermal_of_cooling_device_register(struct device_node *np,
  ^
  In file included from drivers/thermal/thermal_core.c:34:0:
  include/linux/thermal.h:321:1: note: previous definition of
  ‘thermal_of_cooling_device_register’ was here
   thermal_of_cooling_device_register(struct device_node *np,
    ^


We provide the function in thermal core even if CONFIG_THERMAL_OF is not
set.
> 
> > ---
> > Changes for v2:
> > - None
> > ---
> >  include/linux/thermal.h | 14 +++++++++++---
> >  1 file changed, 11 insertions(+), 3 deletions(-)
> > 
> > diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> > index 2de3d9e..871123c 100644
> > --- a/include/linux/thermal.h
> > +++ b/include/linux/thermal.h
> > @@ -328,6 +328,10 @@ thermal_zone_of_sensor_register(struct device *dev, int id, void *data,
> >  				const struct thermal_zone_of_device_ops *ops);
> >  void thermal_zone_of_sensor_unregister(struct device *dev,
> >  				       struct thermal_zone_device *tz);
> > +struct thermal_cooling_device *
> > +thermal_of_cooling_device_register(struct device_node *np,
> > +				   char *type, void *devdata,
> > +				   const struct thermal_cooling_device_ops *);
> >  #else
> >  static inline struct thermal_zone_device *
> >  thermal_zone_of_sensor_register(struct device *dev, int id, void *data,
> > @@ -342,6 +346,13 @@ void thermal_zone_of_sensor_unregister(struct device *dev,
> >  {
> >  }
> >  
> > +static inline struct thermal_cooling_device *
> > +thermal_of_cooling_device_register(struct device_node *np,
> > +				   char *type, void *devdata,
> > +				   const struct thermal_cooling_device_ops *ops)
> > +{
> > +	return NULL;
> > +}
> >  #endif
> >  struct thermal_zone_device *thermal_zone_device_register(const char *, int, int,
> >  		void *, struct thermal_zone_device_ops *,
> > @@ -357,9 +368,6 @@ void thermal_zone_device_update(struct thermal_zone_device *);
> >  
> >  struct thermal_cooling_device *thermal_cooling_device_register(char *, void *,
> >  		const struct thermal_cooling_device_ops *);
> > -struct thermal_cooling_device *
> > -thermal_of_cooling_device_register(struct device_node *np, char *, void *,
> > -				   const struct thermal_cooling_device_ops *);
> >  void thermal_cooling_device_unregister(struct thermal_cooling_device *);
> >  struct thermal_zone_device *thermal_zone_get_zone_by_name(const char *name);
> >  int thermal_zone_get_temp(struct thermal_zone_device *tz, unsigned long *temp);
> > -- 
> > 2.0.0.rc2
> > 



[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v2 1/8] thermal: Provide stub for thermal_of_cooling_device_register() function
@ 2015-01-02 19:03         ` Eduardo Valentin
  0 siblings, 0 replies; 329+ messages in thread
From: Eduardo Valentin @ 2015-01-02 19:03 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, lm-sensors,
	Linux PM list, linux-samsung-soc, devicetree, Lukasz Majewski,
	Kukjin Kim, linux-kernel, Sylwester Nawrocki, Abhilash Kesavan,
	Abhilash Kesavan

[-- Attachment #1: Type: text/plain, Size: 3356 bytes --]

On Fri, Jan 02, 2015 at 02:54:28PM -0400, Eduardo Valentin wrote:
> On Mon, Dec 22, 2014 at 05:27:41PM +0100, Lukasz Majewski wrote:
> > Odroid U3 fan can work without being registered as OF cooling device
> > (with CONFIG_THERMAL_OF disabled).
> > In this situation it can be controlled via PWM entry at
> > /sys/class/hwmon/hwmon0/pwm1.
> > 
> > Therefore, the thermal_of_cooling_device_register() function needs a stub
> > to allow clean compilation.
> > 
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> 
> Acked-by: Eduardo Valentin <edubezval@gmail.com>

Sorry, too fast,

This is actually
Nacked-by: Eduardo Valentin <edubezval@gmail.com>

:-)

I get this error:
drivers/thermal/thermal_core.c:1210:1: error: redefinition of
‘thermal_of_cooling_device_register’
 thermal_of_cooling_device_register(struct device_node *np,
  ^
  In file included from drivers/thermal/thermal_core.c:34:0:
  include/linux/thermal.h:321:1: note: previous definition of
  ‘thermal_of_cooling_device_register’ was here
   thermal_of_cooling_device_register(struct device_node *np,
    ^


We provide the function in thermal core even if CONFIG_THERMAL_OF is not
set.
> 
> > ---
> > Changes for v2:
> > - None
> > ---
> >  include/linux/thermal.h | 14 +++++++++++---
> >  1 file changed, 11 insertions(+), 3 deletions(-)
> > 
> > diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> > index 2de3d9e..871123c 100644
> > --- a/include/linux/thermal.h
> > +++ b/include/linux/thermal.h
> > @@ -328,6 +328,10 @@ thermal_zone_of_sensor_register(struct device *dev, int id, void *data,
> >  				const struct thermal_zone_of_device_ops *ops);
> >  void thermal_zone_of_sensor_unregister(struct device *dev,
> >  				       struct thermal_zone_device *tz);
> > +struct thermal_cooling_device *
> > +thermal_of_cooling_device_register(struct device_node *np,
> > +				   char *type, void *devdata,
> > +				   const struct thermal_cooling_device_ops *);
> >  #else
> >  static inline struct thermal_zone_device *
> >  thermal_zone_of_sensor_register(struct device *dev, int id, void *data,
> > @@ -342,6 +346,13 @@ void thermal_zone_of_sensor_unregister(struct device *dev,
> >  {
> >  }
> >  
> > +static inline struct thermal_cooling_device *
> > +thermal_of_cooling_device_register(struct device_node *np,
> > +				   char *type, void *devdata,
> > +				   const struct thermal_cooling_device_ops *ops)
> > +{
> > +	return NULL;
> > +}
> >  #endif
> >  struct thermal_zone_device *thermal_zone_device_register(const char *, int, int,
> >  		void *, struct thermal_zone_device_ops *,
> > @@ -357,9 +368,6 @@ void thermal_zone_device_update(struct thermal_zone_device *);
> >  
> >  struct thermal_cooling_device *thermal_cooling_device_register(char *, void *,
> >  		const struct thermal_cooling_device_ops *);
> > -struct thermal_cooling_device *
> > -thermal_of_cooling_device_register(struct device_node *np, char *, void *,
> > -				   const struct thermal_cooling_device_ops *);
> >  void thermal_cooling_device_unregister(struct thermal_cooling_device *);
> >  struct thermal_zone_device *thermal_zone_get_zone_by_name(const char *name);
> >  int thermal_zone_get_temp(struct thermal_zone_device *tz, unsigned long *temp);
> > -- 
> > 2.0.0.rc2
> > 



[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [lm-sensors] [PATCH v2 1/8] thermal: Provide stub for thermal_of_cooling_device_register() funct
@ 2015-01-02 19:03         ` Eduardo Valentin
  0 siblings, 0 replies; 329+ messages in thread
From: Eduardo Valentin @ 2015-01-02 19:03 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, lm-sensors,
	Linux PM list, linux-samsung-soc, devicetree, Lukasz Majewski,
	Kukjin Kim, linux-kernel, Sylwester Nawrocki, Abhilash Kesavan,
	Abhilash Kesavan


[-- Attachment #1.1: Type: text/plain, Size: 3356 bytes --]

On Fri, Jan 02, 2015 at 02:54:28PM -0400, Eduardo Valentin wrote:
> On Mon, Dec 22, 2014 at 05:27:41PM +0100, Lukasz Majewski wrote:
> > Odroid U3 fan can work without being registered as OF cooling device
> > (with CONFIG_THERMAL_OF disabled).
> > In this situation it can be controlled via PWM entry at
> > /sys/class/hwmon/hwmon0/pwm1.
> > 
> > Therefore, the thermal_of_cooling_device_register() function needs a stub
> > to allow clean compilation.
> > 
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> 
> Acked-by: Eduardo Valentin <edubezval@gmail.com>

Sorry, too fast,

This is actually
Nacked-by: Eduardo Valentin <edubezval@gmail.com>

:-)

I get this error:
drivers/thermal/thermal_core.c:1210:1: error: redefinition of
‘thermal_of_cooling_device_register’
 thermal_of_cooling_device_register(struct device_node *np,
  ^
  In file included from drivers/thermal/thermal_core.c:34:0:
  include/linux/thermal.h:321:1: note: previous definition of
  ‘thermal_of_cooling_device_register’ was here
   thermal_of_cooling_device_register(struct device_node *np,
    ^


We provide the function in thermal core even if CONFIG_THERMAL_OF is not
set.
> 
> > ---
> > Changes for v2:
> > - None
> > ---
> >  include/linux/thermal.h | 14 +++++++++++---
> >  1 file changed, 11 insertions(+), 3 deletions(-)
> > 
> > diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> > index 2de3d9e..871123c 100644
> > --- a/include/linux/thermal.h
> > +++ b/include/linux/thermal.h
> > @@ -328,6 +328,10 @@ thermal_zone_of_sensor_register(struct device *dev, int id, void *data,
> >  				const struct thermal_zone_of_device_ops *ops);
> >  void thermal_zone_of_sensor_unregister(struct device *dev,
> >  				       struct thermal_zone_device *tz);
> > +struct thermal_cooling_device *
> > +thermal_of_cooling_device_register(struct device_node *np,
> > +				   char *type, void *devdata,
> > +				   const struct thermal_cooling_device_ops *);
> >  #else
> >  static inline struct thermal_zone_device *
> >  thermal_zone_of_sensor_register(struct device *dev, int id, void *data,
> > @@ -342,6 +346,13 @@ void thermal_zone_of_sensor_unregister(struct device *dev,
> >  {
> >  }
> >  
> > +static inline struct thermal_cooling_device *
> > +thermal_of_cooling_device_register(struct device_node *np,
> > +				   char *type, void *devdata,
> > +				   const struct thermal_cooling_device_ops *ops)
> > +{
> > +	return NULL;
> > +}
> >  #endif
> >  struct thermal_zone_device *thermal_zone_device_register(const char *, int, int,
> >  		void *, struct thermal_zone_device_ops *,
> > @@ -357,9 +368,6 @@ void thermal_zone_device_update(struct thermal_zone_device *);
> >  
> >  struct thermal_cooling_device *thermal_cooling_device_register(char *, void *,
> >  		const struct thermal_cooling_device_ops *);
> > -struct thermal_cooling_device *
> > -thermal_of_cooling_device_register(struct device_node *np, char *, void *,
> > -				   const struct thermal_cooling_device_ops *);
> >  void thermal_cooling_device_unregister(struct thermal_cooling_device *);
> >  struct thermal_zone_device *thermal_zone_get_zone_by_name(const char *name);
> >  int thermal_zone_get_temp(struct thermal_zone_device *tz, unsigned long *temp);
> > -- 
> > 2.0.0.rc2
> > 



[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

[-- Attachment #2: Type: text/plain, Size: 153 bytes --]

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH 2/9] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling device
  2014-12-19 16:13           ` [PATCH 2/9] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling device Lukasz Majewski
  (?)
@ 2015-01-05 10:50             ` Sjoerd Simons
  -1 siblings, 0 replies; 329+ messages in thread
From: Sjoerd Simons @ 2015-01-05 10:50 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Guenter Roeck, Eduardo Valentin, Kamil Debski, Jean Delvare,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki

[-- Attachment #1: Type: text/plain, Size: 4769 bytes --]

Hey Lukasz,

Blame the holiday season for my late reply ;)

On Fri, 2014-12-19 at 17:13 +0100, Lukasz Majewski wrote:
> Hi Guenter,
> 
> > On Fri, Dec 19, 2014 at 04:32:24PM +0100, Lukasz Majewski wrote:
> > > Hi Sjoerd,
> > > 
> > > Thanks for your feedback and sorry for a late reply.
> > > 
> > > > On Thu, 2014-12-18 at 11:13 +0100, Lukasz Majewski wrote:
> > > > > Several new properties to allow PWM fan working as a cooling
> > > > > device have been combined into this single commit.
> > > > > 
> > > > > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > > > > ---
> > > > >  .../devicetree/bindings/hwmon/pwm-fan.txt          | 28
> > > > > ++++++++++++++++++++++ 1 file changed, 28 insertions(+)
> > > > > 
> > > > > diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> > > > > b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt index
> > > > > 610757c..3877810 100644 ---
> > > > > a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt +++
> > > > > b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt @@ -3,10
> > > > > +3,38 @@ Bindings for a fan connected to the PWM lines Required
> > > > > properties:
> > > > >  - compatible	: "pwm-fan"
> > > > >  - pwms		: the PWM that is used to control the
> > > > > PWM fan +- cooling-pwm-values      : PWM duty cycle values
> > > > > relative to
> > > > > +			    cooling-max-pwm-value correspondig
> > > > > to
> > > > > +			    proper cooling states
> > > > > +- default-pulse-width     : Property specifying default pulse
> > > > > width for FAN
> > > > > +			    at system boot (zero to disable
> > > > > FAN on boot).
> > > > > +			    Allowed range is 0 to 255
> > > > 
> > > > The 0..255 range seems somewhat random. Would be nicer to either
> > > > use the approach of pwm-backlight (iotw, have the range go from
> > > > the first to the last entry of cooling-pwm-values) 
> > > 
> > > I'm OK to change the default-pulse-width to be similar to
> > > "default-brightness-level" (as it is in
> > > Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt)
> > > 
> > > > or simply have be the duty
> > > > lenght in NS as entries instead of the current indirection.
> > > 
> > > I'd prefer to keep the indirection - as it is utilized in the
> > > current pwm-fan.c driver.
> > > 
> > FWIW, devicetree information is supposed to be implementation
> > independent. So this is a poor argument.
> 
> Many other pwm drivers use the indirection - e.g. mentioned
> pwm-backlight.

I don't specifically mind the indirection, i was just thinking out loud
whether it added value (but if it's quite common, might indeed be good
to keep the pattern). What i do dislike is the number of levels is being
set to an arbitrary levels, as that will very rarely match the actual
number of distinct pwm levels you 

One thing though, when following the pattern of the pwm-backlight
driver; In pwm-backlight the highest index of brightness-levels is
always 100% duty cycle.. On e.g. XU3 the vendor kernel never drives the
fan at 100% duty (maximum of 91%). So it would be nice if the dt
bindigns could model that e.g. by having:

pwm-levels = <20>; // 21 distinct pwm levels
valid-pwm-level = <5 15 18>; /* 5 15 and 18 are usable levels - pwm will
                                default to highest level */


> > > Enabling pan to full RPM was the default behaviour in the current
> > > pwm-fan.c file.
> > > 
> > > To be honest, there is no need to enable fan to full RPM speed in
> > > this board for following reasons:
> > > 1. In Odroid the FAN is optional (stacked on top of a heat sink) -
> > > very often it is just enough to only have the heat sink.
> > > 
> > > 2. Odroid has thermal enabled by default and IMHO it would be more
> > > feasible to allow thermal to control fan from the very beginning.
> > > 
> > > However, I can also understand if the policy for hwmon implies a
> > > rule to enable by default all fans to full RPM speed.
> > > 
> > Why and how does that all suggest that the current default behavior
> > should be changed ?
> 
> I wanted to avoid the unpleasant sound for full speed fan when thermal
> is not enabled by default.
> 
> But as I said, I fully understand the policy and I would be happy to
> comply with it as thermal should reduce the fan speed anyway at boot
> time.

Yeah, what happens on my XU3 is that u-boot sets the pwm to 100% duty
and the thermal infrastructure turns it off as soon as it gets into
control, which works quite nicely (and keeps my sanity as that fan at
100% is *loud*)...  So if you want to avoid unpleasant sounds, just
build with thermal :p


-- 
Sjoerd Simons <sjoerd.simons@collabora.co.uk>
Collabora Ltd.

[-- Attachment #2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 6170 bytes --]

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH 2/9] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling device
@ 2015-01-05 10:50             ` Sjoerd Simons
  0 siblings, 0 replies; 329+ messages in thread
From: Sjoerd Simons @ 2015-01-05 10:50 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Guenter Roeck, Eduardo Valentin, Kamil Debski, Jean Delvare,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki

[-- Attachment #1: Type: text/plain, Size: 4769 bytes --]

Hey Lukasz,

Blame the holiday season for my late reply ;)

On Fri, 2014-12-19 at 17:13 +0100, Lukasz Majewski wrote:
> Hi Guenter,
> 
> > On Fri, Dec 19, 2014 at 04:32:24PM +0100, Lukasz Majewski wrote:
> > > Hi Sjoerd,
> > > 
> > > Thanks for your feedback and sorry for a late reply.
> > > 
> > > > On Thu, 2014-12-18 at 11:13 +0100, Lukasz Majewski wrote:
> > > > > Several new properties to allow PWM fan working as a cooling
> > > > > device have been combined into this single commit.
> > > > > 
> > > > > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > > > > ---
> > > > >  .../devicetree/bindings/hwmon/pwm-fan.txt          | 28
> > > > > ++++++++++++++++++++++ 1 file changed, 28 insertions(+)
> > > > > 
> > > > > diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> > > > > b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt index
> > > > > 610757c..3877810 100644 ---
> > > > > a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt +++
> > > > > b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt @@ -3,10
> > > > > +3,38 @@ Bindings for a fan connected to the PWM lines Required
> > > > > properties:
> > > > >  - compatible	: "pwm-fan"
> > > > >  - pwms		: the PWM that is used to control the
> > > > > PWM fan +- cooling-pwm-values      : PWM duty cycle values
> > > > > relative to
> > > > > +			    cooling-max-pwm-value correspondig
> > > > > to
> > > > > +			    proper cooling states
> > > > > +- default-pulse-width     : Property specifying default pulse
> > > > > width for FAN
> > > > > +			    at system boot (zero to disable
> > > > > FAN on boot).
> > > > > +			    Allowed range is 0 to 255
> > > > 
> > > > The 0..255 range seems somewhat random. Would be nicer to either
> > > > use the approach of pwm-backlight (iotw, have the range go from
> > > > the first to the last entry of cooling-pwm-values) 
> > > 
> > > I'm OK to change the default-pulse-width to be similar to
> > > "default-brightness-level" (as it is in
> > > Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt)
> > > 
> > > > or simply have be the duty
> > > > lenght in NS as entries instead of the current indirection.
> > > 
> > > I'd prefer to keep the indirection - as it is utilized in the
> > > current pwm-fan.c driver.
> > > 
> > FWIW, devicetree information is supposed to be implementation
> > independent. So this is a poor argument.
> 
> Many other pwm drivers use the indirection - e.g. mentioned
> pwm-backlight.

I don't specifically mind the indirection, i was just thinking out loud
whether it added value (but if it's quite common, might indeed be good
to keep the pattern). What i do dislike is the number of levels is being
set to an arbitrary levels, as that will very rarely match the actual
number of distinct pwm levels you 

One thing though, when following the pattern of the pwm-backlight
driver; In pwm-backlight the highest index of brightness-levels is
always 100% duty cycle.. On e.g. XU3 the vendor kernel never drives the
fan at 100% duty (maximum of 91%). So it would be nice if the dt
bindigns could model that e.g. by having:

pwm-levels = <20>; // 21 distinct pwm levels
valid-pwm-level = <5 15 18>; /* 5 15 and 18 are usable levels - pwm will
                                default to highest level */


> > > Enabling pan to full RPM was the default behaviour in the current
> > > pwm-fan.c file.
> > > 
> > > To be honest, there is no need to enable fan to full RPM speed in
> > > this board for following reasons:
> > > 1. In Odroid the FAN is optional (stacked on top of a heat sink) -
> > > very often it is just enough to only have the heat sink.
> > > 
> > > 2. Odroid has thermal enabled by default and IMHO it would be more
> > > feasible to allow thermal to control fan from the very beginning.
> > > 
> > > However, I can also understand if the policy for hwmon implies a
> > > rule to enable by default all fans to full RPM speed.
> > > 
> > Why and how does that all suggest that the current default behavior
> > should be changed ?
> 
> I wanted to avoid the unpleasant sound for full speed fan when thermal
> is not enabled by default.
> 
> But as I said, I fully understand the policy and I would be happy to
> comply with it as thermal should reduce the fan speed anyway at boot
> time.

Yeah, what happens on my XU3 is that u-boot sets the pwm to 100% duty
and the thermal infrastructure turns it off as soon as it gets into
control, which works quite nicely (and keeps my sanity as that fan at
100% is *loud*)...  So if you want to avoid unpleasant sounds, just
build with thermal :p


-- 
Sjoerd Simons <sjoerd.simons@collabora.co.uk>
Collabora Ltd.

[-- Attachment #2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 6170 bytes --]

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [lm-sensors] [PATCH 2/9] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling
@ 2015-01-05 10:50             ` Sjoerd Simons
  0 siblings, 0 replies; 329+ messages in thread
From: Sjoerd Simons @ 2015-01-05 10:50 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Guenter Roeck, Eduardo Valentin, Kamil Debski, Jean Delvare,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki


[-- Attachment #1.1: Type: text/plain, Size: 4769 bytes --]

Hey Lukasz,

Blame the holiday season for my late reply ;)

On Fri, 2014-12-19 at 17:13 +0100, Lukasz Majewski wrote:
> Hi Guenter,
> 
> > On Fri, Dec 19, 2014 at 04:32:24PM +0100, Lukasz Majewski wrote:
> > > Hi Sjoerd,
> > > 
> > > Thanks for your feedback and sorry for a late reply.
> > > 
> > > > On Thu, 2014-12-18 at 11:13 +0100, Lukasz Majewski wrote:
> > > > > Several new properties to allow PWM fan working as a cooling
> > > > > device have been combined into this single commit.
> > > > > 
> > > > > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > > > > ---
> > > > >  .../devicetree/bindings/hwmon/pwm-fan.txt          | 28
> > > > > ++++++++++++++++++++++ 1 file changed, 28 insertions(+)
> > > > > 
> > > > > diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> > > > > b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt index
> > > > > 610757c..3877810 100644 ---
> > > > > a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt +++
> > > > > b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt @@ -3,10
> > > > > +3,38 @@ Bindings for a fan connected to the PWM lines Required
> > > > > properties:
> > > > >  - compatible	: "pwm-fan"
> > > > >  - pwms		: the PWM that is used to control the
> > > > > PWM fan +- cooling-pwm-values      : PWM duty cycle values
> > > > > relative to
> > > > > +			    cooling-max-pwm-value correspondig
> > > > > to
> > > > > +			    proper cooling states
> > > > > +- default-pulse-width     : Property specifying default pulse
> > > > > width for FAN
> > > > > +			    at system boot (zero to disable
> > > > > FAN on boot).
> > > > > +			    Allowed range is 0 to 255
> > > > 
> > > > The 0..255 range seems somewhat random. Would be nicer to either
> > > > use the approach of pwm-backlight (iotw, have the range go from
> > > > the first to the last entry of cooling-pwm-values) 
> > > 
> > > I'm OK to change the default-pulse-width to be similar to
> > > "default-brightness-level" (as it is in
> > > Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt)
> > > 
> > > > or simply have be the duty
> > > > lenght in NS as entries instead of the current indirection.
> > > 
> > > I'd prefer to keep the indirection - as it is utilized in the
> > > current pwm-fan.c driver.
> > > 
> > FWIW, devicetree information is supposed to be implementation
> > independent. So this is a poor argument.
> 
> Many other pwm drivers use the indirection - e.g. mentioned
> pwm-backlight.

I don't specifically mind the indirection, i was just thinking out loud
whether it added value (but if it's quite common, might indeed be good
to keep the pattern). What i do dislike is the number of levels is being
set to an arbitrary levels, as that will very rarely match the actual
number of distinct pwm levels you 

One thing though, when following the pattern of the pwm-backlight
driver; In pwm-backlight the highest index of brightness-levels is
always 100% duty cycle.. On e.g. XU3 the vendor kernel never drives the
fan at 100% duty (maximum of 91%). So it would be nice if the dt
bindigns could model that e.g. by having:

pwm-levels = <20>; // 21 distinct pwm levels
valid-pwm-level = <5 15 18>; /* 5 15 and 18 are usable levels - pwm will
                                default to highest level */


> > > Enabling pan to full RPM was the default behaviour in the current
> > > pwm-fan.c file.
> > > 
> > > To be honest, there is no need to enable fan to full RPM speed in
> > > this board for following reasons:
> > > 1. In Odroid the FAN is optional (stacked on top of a heat sink) -
> > > very often it is just enough to only have the heat sink.
> > > 
> > > 2. Odroid has thermal enabled by default and IMHO it would be more
> > > feasible to allow thermal to control fan from the very beginning.
> > > 
> > > However, I can also understand if the policy for hwmon implies a
> > > rule to enable by default all fans to full RPM speed.
> > > 
> > Why and how does that all suggest that the current default behavior
> > should be changed ?
> 
> I wanted to avoid the unpleasant sound for full speed fan when thermal
> is not enabled by default.
> 
> But as I said, I fully understand the policy and I would be happy to
> comply with it as thermal should reduce the fan speed anyway at boot
> time.

Yeah, what happens on my XU3 is that u-boot sets the pwm to 100% duty
and the thermal infrastructure turns it off as soon as it gets into
control, which works quite nicely (and keeps my sanity as that fan at
100% is *loud*)...  So if you want to avoid unpleasant sounds, just
build with thermal :p


-- 
Sjoerd Simons <sjoerd.simons@collabora.co.uk>
Collabora Ltd.

[-- Attachment #1.2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 6170 bytes --]

[-- Attachment #2: Type: text/plain, Size: 153 bytes --]

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH 2/9] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling device
@ 2015-01-14 13:56               ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-01-14 13:56 UTC (permalink / raw)
  To: Sjoerd Simons
  Cc: Guenter Roeck, Eduardo Valentin, Kamil Debski, Jean Delvare,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki

Hi Sjoerd,

> Hey Lukasz,
> 
> Blame the holiday season for my late reply ;)
> 
> On Fri, 2014-12-19 at 17:13 +0100, Lukasz Majewski wrote:
> > Hi Guenter,
> > 
> > > On Fri, Dec 19, 2014 at 04:32:24PM +0100, Lukasz Majewski wrote:
> > > > Hi Sjoerd,
> > > > 
> > > > Thanks for your feedback and sorry for a late reply.
> > > > 
> > > > > On Thu, 2014-12-18 at 11:13 +0100, Lukasz Majewski wrote:
> > > > > > Several new properties to allow PWM fan working as a cooling
> > > > > > device have been combined into this single commit.
> > > > > > 
> > > > > > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > > > > > ---
> > > > > >  .../devicetree/bindings/hwmon/pwm-fan.txt          | 28
> > > > > > ++++++++++++++++++++++ 1 file changed, 28 insertions(+)
> > > > > > 
> > > > > > diff --git
> > > > > > a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> > > > > > b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt index
> > > > > > 610757c..3877810 100644 ---
> > > > > > a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt +++
> > > > > > b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt @@
> > > > > > -3,10 +3,38 @@ Bindings for a fan connected to the PWM
> > > > > > lines Required properties:
> > > > > >  - compatible	: "pwm-fan"
> > > > > >  - pwms		: the PWM that is used to control the
> > > > > > PWM fan +- cooling-pwm-values      : PWM duty cycle values
> > > > > > relative to
> > > > > > +			    cooling-max-pwm-value
> > > > > > correspondig to
> > > > > > +			    proper cooling states
> > > > > > +- default-pulse-width     : Property specifying default
> > > > > > pulse width for FAN
> > > > > > +			    at system boot (zero to disable
> > > > > > FAN on boot).
> > > > > > +			    Allowed range is 0 to 255
> > > > > 
> > > > > The 0..255 range seems somewhat random. Would be nicer to
> > > > > either use the approach of pwm-backlight (iotw, have the
> > > > > range go from the first to the last entry of
> > > > > cooling-pwm-values) 
> > > > 
> > > > I'm OK to change the default-pulse-width to be similar to
> > > > "default-brightness-level" (as it is in
> > > > Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt)
> > > > 
> > > > > or simply have be the duty
> > > > > lenght in NS as entries instead of the current indirection.
> > > > 
> > > > I'd prefer to keep the indirection - as it is utilized in the
> > > > current pwm-fan.c driver.
> > > > 
> > > FWIW, devicetree information is supposed to be implementation
> > > independent. So this is a poor argument.
> > 
> > Many other pwm drivers use the indirection - e.g. mentioned
> > pwm-backlight.
> 
> I don't specifically mind the indirection, i was just thinking out
> loud whether it added value (but if it's quite common, might indeed
> be good to keep the pattern). What i do dislike is the number of
> levels is being set to an arbitrary levels, as that will very rarely
> match the actual number of distinct pwm levels you 
> 
> One thing though, when following the pattern of the pwm-backlight
> driver; In pwm-backlight the highest index of brightness-levels is
> always 100% duty cycle.. On e.g. XU3 the vendor kernel never drives
> the fan at 100% duty (maximum of 91%). So it would be nice if the dt
> bindigns could model that e.g. by having:
> 
> pwm-levels = <20>; // 21 distinct pwm levels
> valid-pwm-level = <5 15 18>; /* 5 15 and 18 are usable levels - pwm
> will default to highest level */
> 

Could you review v2 of this patch series?

http://www.spinics.net/lists/devicetree/msg63159.html

> 
> > > > Enabling pan to full RPM was the default behaviour in the
> > > > current pwm-fan.c file.
> > > > 
> > > > To be honest, there is no need to enable fan to full RPM speed
> > > > in this board for following reasons:
> > > > 1. In Odroid the FAN is optional (stacked on top of a heat
> > > > sink) - very often it is just enough to only have the heat sink.
> > > > 
> > > > 2. Odroid has thermal enabled by default and IMHO it would be
> > > > more feasible to allow thermal to control fan from the very
> > > > beginning.
> > > > 
> > > > However, I can also understand if the policy for hwmon implies a
> > > > rule to enable by default all fans to full RPM speed.
> > > > 
> > > Why and how does that all suggest that the current default
> > > behavior should be changed ?
> > 
> > I wanted to avoid the unpleasant sound for full speed fan when
> > thermal is not enabled by default.
> > 
> > But as I said, I fully understand the policy and I would be happy to
> > comply with it as thermal should reduce the fan speed anyway at boot
> > time.
> 
> Yeah, what happens on my XU3 is that u-boot sets the pwm to 100% duty
> and the thermal infrastructure turns it off as soon as it gets into
> control, which works quite nicely (and keeps my sanity as that fan at
> 100% is *loud*)...  So if you want to avoid unpleasant sounds, just
> build with thermal :p
> 
> 



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH 2/9] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling device
@ 2015-01-14 13:56               ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-01-14 13:56 UTC (permalink / raw)
  To: Sjoerd Simons
  Cc: Guenter Roeck, Eduardo Valentin, Kamil Debski, Jean Delvare,
	lm-sensors-GZX6beZjE8VD60Wz+7aTrA, Linux PM list,
	linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Lukasz Majewski, Kukjin Kim,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Sylwester Nawrocki

Hi Sjoerd,

> Hey Lukasz,
> 
> Blame the holiday season for my late reply ;)
> 
> On Fri, 2014-12-19 at 17:13 +0100, Lukasz Majewski wrote:
> > Hi Guenter,
> > 
> > > On Fri, Dec 19, 2014 at 04:32:24PM +0100, Lukasz Majewski wrote:
> > > > Hi Sjoerd,
> > > > 
> > > > Thanks for your feedback and sorry for a late reply.
> > > > 
> > > > > On Thu, 2014-12-18 at 11:13 +0100, Lukasz Majewski wrote:
> > > > > > Several new properties to allow PWM fan working as a cooling
> > > > > > device have been combined into this single commit.
> > > > > > 
> > > > > > Signed-off-by: Lukasz Majewski <l.majewski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
> > > > > > ---
> > > > > >  .../devicetree/bindings/hwmon/pwm-fan.txt          | 28
> > > > > > ++++++++++++++++++++++ 1 file changed, 28 insertions(+)
> > > > > > 
> > > > > > diff --git
> > > > > > a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> > > > > > b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt index
> > > > > > 610757c..3877810 100644 ---
> > > > > > a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt +++
> > > > > > b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt @@
> > > > > > -3,10 +3,38 @@ Bindings for a fan connected to the PWM
> > > > > > lines Required properties:
> > > > > >  - compatible	: "pwm-fan"
> > > > > >  - pwms		: the PWM that is used to control the
> > > > > > PWM fan +- cooling-pwm-values      : PWM duty cycle values
> > > > > > relative to
> > > > > > +			    cooling-max-pwm-value
> > > > > > correspondig to
> > > > > > +			    proper cooling states
> > > > > > +- default-pulse-width     : Property specifying default
> > > > > > pulse width for FAN
> > > > > > +			    at system boot (zero to disable
> > > > > > FAN on boot).
> > > > > > +			    Allowed range is 0 to 255
> > > > > 
> > > > > The 0..255 range seems somewhat random. Would be nicer to
> > > > > either use the approach of pwm-backlight (iotw, have the
> > > > > range go from the first to the last entry of
> > > > > cooling-pwm-values) 
> > > > 
> > > > I'm OK to change the default-pulse-width to be similar to
> > > > "default-brightness-level" (as it is in
> > > > Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt)
> > > > 
> > > > > or simply have be the duty
> > > > > lenght in NS as entries instead of the current indirection.
> > > > 
> > > > I'd prefer to keep the indirection - as it is utilized in the
> > > > current pwm-fan.c driver.
> > > > 
> > > FWIW, devicetree information is supposed to be implementation
> > > independent. So this is a poor argument.
> > 
> > Many other pwm drivers use the indirection - e.g. mentioned
> > pwm-backlight.
> 
> I don't specifically mind the indirection, i was just thinking out
> loud whether it added value (but if it's quite common, might indeed
> be good to keep the pattern). What i do dislike is the number of
> levels is being set to an arbitrary levels, as that will very rarely
> match the actual number of distinct pwm levels you 
> 
> One thing though, when following the pattern of the pwm-backlight
> driver; In pwm-backlight the highest index of brightness-levels is
> always 100% duty cycle.. On e.g. XU3 the vendor kernel never drives
> the fan at 100% duty (maximum of 91%). So it would be nice if the dt
> bindigns could model that e.g. by having:
> 
> pwm-levels = <20>; // 21 distinct pwm levels
> valid-pwm-level = <5 15 18>; /* 5 15 and 18 are usable levels - pwm
> will default to highest level */
> 

Could you review v2 of this patch series?

http://www.spinics.net/lists/devicetree/msg63159.html

> 
> > > > Enabling pan to full RPM was the default behaviour in the
> > > > current pwm-fan.c file.
> > > > 
> > > > To be honest, there is no need to enable fan to full RPM speed
> > > > in this board for following reasons:
> > > > 1. In Odroid the FAN is optional (stacked on top of a heat
> > > > sink) - very often it is just enough to only have the heat sink.
> > > > 
> > > > 2. Odroid has thermal enabled by default and IMHO it would be
> > > > more feasible to allow thermal to control fan from the very
> > > > beginning.
> > > > 
> > > > However, I can also understand if the policy for hwmon implies a
> > > > rule to enable by default all fans to full RPM speed.
> > > > 
> > > Why and how does that all suggest that the current default
> > > behavior should be changed ?
> > 
> > I wanted to avoid the unpleasant sound for full speed fan when
> > thermal is not enabled by default.
> > 
> > But as I said, I fully understand the policy and I would be happy to
> > comply with it as thermal should reduce the fan speed anyway at boot
> > time.
> 
> Yeah, what happens on my XU3 is that u-boot sets the pwm to 100% duty
> and the thermal infrastructure turns it off as soon as it gets into
> control, which works quite nicely (and keeps my sanity as that fan at
> 100% is *loud*)...  So if you want to avoid unpleasant sounds, just
> build with thermal :p
> 
> 



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [lm-sensors] [PATCH 2/9] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling
@ 2015-01-14 13:56               ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-01-14 13:56 UTC (permalink / raw)
  To: Sjoerd Simons
  Cc: Guenter Roeck, Eduardo Valentin, Kamil Debski, Jean Delvare,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki

Hi Sjoerd,

> Hey Lukasz,
> 
> Blame the holiday season for my late reply ;)
> 
> On Fri, 2014-12-19 at 17:13 +0100, Lukasz Majewski wrote:
> > Hi Guenter,
> > 
> > > On Fri, Dec 19, 2014 at 04:32:24PM +0100, Lukasz Majewski wrote:
> > > > Hi Sjoerd,
> > > > 
> > > > Thanks for your feedback and sorry for a late reply.
> > > > 
> > > > > On Thu, 2014-12-18 at 11:13 +0100, Lukasz Majewski wrote:
> > > > > > Several new properties to allow PWM fan working as a cooling
> > > > > > device have been combined into this single commit.
> > > > > > 
> > > > > > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > > > > > ---
> > > > > >  .../devicetree/bindings/hwmon/pwm-fan.txt          | 28
> > > > > > ++++++++++++++++++++++ 1 file changed, 28 insertions(+)
> > > > > > 
> > > > > > diff --git
> > > > > > a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> > > > > > b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt index
> > > > > > 610757c..3877810 100644 ---
> > > > > > a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt +++
> > > > > > b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt @@
> > > > > > -3,10 +3,38 @@ Bindings for a fan connected to the PWM
> > > > > > lines Required properties:
> > > > > >  - compatible	: "pwm-fan"
> > > > > >  - pwms		: the PWM that is used to control the
> > > > > > PWM fan +- cooling-pwm-values      : PWM duty cycle values
> > > > > > relative to
> > > > > > +			    cooling-max-pwm-value
> > > > > > correspondig to
> > > > > > +			    proper cooling states
> > > > > > +- default-pulse-width     : Property specifying default
> > > > > > pulse width for FAN
> > > > > > +			    at system boot (zero to disable
> > > > > > FAN on boot).
> > > > > > +			    Allowed range is 0 to 255
> > > > > 
> > > > > The 0..255 range seems somewhat random. Would be nicer to
> > > > > either use the approach of pwm-backlight (iotw, have the
> > > > > range go from the first to the last entry of
> > > > > cooling-pwm-values) 
> > > > 
> > > > I'm OK to change the default-pulse-width to be similar to
> > > > "default-brightness-level" (as it is in
> > > > Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt)
> > > > 
> > > > > or simply have be the duty
> > > > > lenght in NS as entries instead of the current indirection.
> > > > 
> > > > I'd prefer to keep the indirection - as it is utilized in the
> > > > current pwm-fan.c driver.
> > > > 
> > > FWIW, devicetree information is supposed to be implementation
> > > independent. So this is a poor argument.
> > 
> > Many other pwm drivers use the indirection - e.g. mentioned
> > pwm-backlight.
> 
> I don't specifically mind the indirection, i was just thinking out
> loud whether it added value (but if it's quite common, might indeed
> be good to keep the pattern). What i do dislike is the number of
> levels is being set to an arbitrary levels, as that will very rarely
> match the actual number of distinct pwm levels you 
> 
> One thing though, when following the pattern of the pwm-backlight
> driver; In pwm-backlight the highest index of brightness-levels is
> always 100% duty cycle.. On e.g. XU3 the vendor kernel never drives
> the fan at 100% duty (maximum of 91%). So it would be nice if the dt
> bindigns could model that e.g. by having:
> 
> pwm-levels = <20>; // 21 distinct pwm levels
> valid-pwm-level = <5 15 18>; /* 5 15 and 18 are usable levels - pwm
> will default to highest level */
> 

Could you review v2 of this patch series?

http://www.spinics.net/lists/devicetree/msg63159.html

> 
> > > > Enabling pan to full RPM was the default behaviour in the
> > > > current pwm-fan.c file.
> > > > 
> > > > To be honest, there is no need to enable fan to full RPM speed
> > > > in this board for following reasons:
> > > > 1. In Odroid the FAN is optional (stacked on top of a heat
> > > > sink) - very often it is just enough to only have the heat sink.
> > > > 
> > > > 2. Odroid has thermal enabled by default and IMHO it would be
> > > > more feasible to allow thermal to control fan from the very
> > > > beginning.
> > > > 
> > > > However, I can also understand if the policy for hwmon implies a
> > > > rule to enable by default all fans to full RPM speed.
> > > > 
> > > Why and how does that all suggest that the current default
> > > behavior should be changed ?
> > 
> > I wanted to avoid the unpleasant sound for full speed fan when
> > thermal is not enabled by default.
> > 
> > But as I said, I fully understand the policy and I would be happy to
> > comply with it as thermal should reduce the fan speed anyway at boot
> > time.
> 
> Yeah, what happens on my XU3 is that u-boot sets the pwm to 100% duty
> and the thermal infrastructure turns it off as soon as it gets into
> control, which works quite nicely (and keeps my sanity as that fan at
> 100% is *loud*)...  So if you want to avoid unpleasant sounds, just
> build with thermal :p
> 
> 



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v2 1/8] thermal: Provide stub for thermal_of_cooling_device_register() function
  2015-01-02 19:03         ` [PATCH v2 1/8] thermal: Provide stub for thermal_of_cooling_device_register() function Eduardo Valentin
  (?)
@ 2015-01-14 15:01           ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-01-14 15:01 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, lm-sensors,
	Linux PM list, linux-samsung-soc, devicetree, Lukasz Majewski,
	Kukjin Kim, linux-kernel, Sylwester Nawrocki, Abhilash Kesavan,
	Abhilash Kesavan

Hi Eduardo,

> On Fri, Jan 02, 2015 at 02:54:28PM -0400, Eduardo Valentin wrote:
> > On Mon, Dec 22, 2014 at 05:27:41PM +0100, Lukasz Majewski wrote:
> > > Odroid U3 fan can work without being registered as OF cooling
> > > device (with CONFIG_THERMAL_OF disabled).
> > > In this situation it can be controlled via PWM entry at
> > > /sys/class/hwmon/hwmon0/pwm1.
> > > 
> > > Therefore, the thermal_of_cooling_device_register() function
> > > needs a stub to allow clean compilation.
> > > 
> > > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > 
> > Acked-by: Eduardo Valentin <edubezval@gmail.com>
> 
> Sorry, too fast,
> 
> This is actually
> Nacked-by: Eduardo Valentin <edubezval@gmail.com>
> 
> :-)
> 
> I get this error:
> drivers/thermal/thermal_core.c:1210:1: error: redefinition of
> ‘thermal_of_cooling_device_register’
>  thermal_of_cooling_device_register(struct device_node *np,
>   ^
>   In file included from drivers/thermal/thermal_core.c:34:0:
>   include/linux/thermal.h:321:1: note: previous definition of
>   ‘thermal_of_cooling_device_register’ was here
>    thermal_of_cooling_device_register(struct device_node *np,
>     ^
> 
> 
> We provide the function in thermal core even if CONFIG_THERMAL_OF is
> not set.

Unfortunately the PWM fan subsystem can work perfectly fine without
CONFIG_THERMAL.

I think that it would be enough to make something like this in
the ./include/linux/thermal.h:

#ifdef CONFIG_THERMAL
	static inline struct thermal_cooling_device *
		thermal_of_cooling_device_register(struct device_node
		*np, char *type, void *devdata,
				   const struct
		thermal_cooling_device_ops *ops) {
		return NULL;
	}
#else
	[ already present declaration of
	thermal_of_cooling_device_register() ]
#endif /* CONFIG_THERMAL */



> > 
> > > ---
> > > Changes for v2:
> > > - None
> > > ---
> > >  include/linux/thermal.h | 14 +++++++++++---
> > >  1 file changed, 11 insertions(+), 3 deletions(-)
> > > 
> > > diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> > > index 2de3d9e..871123c 100644
> > > --- a/include/linux/thermal.h
> > > +++ b/include/linux/thermal.h
> > > @@ -328,6 +328,10 @@ thermal_zone_of_sensor_register(struct
> > > device *dev, int id, void *data, const struct
> > > thermal_zone_of_device_ops *ops); void
> > > thermal_zone_of_sensor_unregister(struct device *dev, struct
> > > thermal_zone_device *tz); +struct thermal_cooling_device *
> > > +thermal_of_cooling_device_register(struct device_node *np,
> > > +				   char *type, void *devdata,
> > > +				   const struct
> > > thermal_cooling_device_ops *); #else
> > >  static inline struct thermal_zone_device *
> > >  thermal_zone_of_sensor_register(struct device *dev, int id, void
> > > *data, @@ -342,6 +346,13 @@ void
> > > thermal_zone_of_sensor_unregister(struct device *dev, {
> > >  }
> > >  
> > > +static inline struct thermal_cooling_device *
> > > +thermal_of_cooling_device_register(struct device_node *np,
> > > +				   char *type, void *devdata,
> > > +				   const struct
> > > thermal_cooling_device_ops *ops) +{
> > > +	return NULL;
> > > +}
> > >  #endif
> > >  struct thermal_zone_device *thermal_zone_device_register(const
> > > char *, int, int, void *, struct thermal_zone_device_ops *,
> > > @@ -357,9 +368,6 @@ void thermal_zone_device_update(struct
> > > thermal_zone_device *); 
> > >  struct thermal_cooling_device
> > > *thermal_cooling_device_register(char *, void *, const struct
> > > thermal_cooling_device_ops *); -struct thermal_cooling_device *
> > > -thermal_of_cooling_device_register(struct device_node *np, char
> > > *, void *,
> > > -				   const struct
> > > thermal_cooling_device_ops *); void
> > > thermal_cooling_device_unregister(struct thermal_cooling_device
> > > *); struct thermal_zone_device
> > > *thermal_zone_get_zone_by_name(const char *name); int
> > > thermal_zone_get_temp(struct thermal_zone_device *tz, unsigned
> > > long *temp); -- 2.0.0.rc2
> > > 
> 
> 



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v2 1/8] thermal: Provide stub for thermal_of_cooling_device_register() function
@ 2015-01-14 15:01           ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-01-14 15:01 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, lm-sensors,
	Linux PM list, linux-samsung-soc, devicetree, Lukasz Majewski,
	Kukjin Kim, linux-kernel, Sylwester Nawrocki, Abhilash Kesavan,
	Abhilash Kesavan

Hi Eduardo,

> On Fri, Jan 02, 2015 at 02:54:28PM -0400, Eduardo Valentin wrote:
> > On Mon, Dec 22, 2014 at 05:27:41PM +0100, Lukasz Majewski wrote:
> > > Odroid U3 fan can work without being registered as OF cooling
> > > device (with CONFIG_THERMAL_OF disabled).
> > > In this situation it can be controlled via PWM entry at
> > > /sys/class/hwmon/hwmon0/pwm1.
> > > 
> > > Therefore, the thermal_of_cooling_device_register() function
> > > needs a stub to allow clean compilation.
> > > 
> > > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > 
> > Acked-by: Eduardo Valentin <edubezval@gmail.com>
> 
> Sorry, too fast,
> 
> This is actually
> Nacked-by: Eduardo Valentin <edubezval@gmail.com>
> 
> :-)
> 
> I get this error:
> drivers/thermal/thermal_core.c:1210:1: error: redefinition of
> ‘thermal_of_cooling_device_register’
>  thermal_of_cooling_device_register(struct device_node *np,
>   ^
>   In file included from drivers/thermal/thermal_core.c:34:0:
>   include/linux/thermal.h:321:1: note: previous definition of
>   ‘thermal_of_cooling_device_register’ was here
>    thermal_of_cooling_device_register(struct device_node *np,
>     ^
> 
> 
> We provide the function in thermal core even if CONFIG_THERMAL_OF is
> not set.

Unfortunately the PWM fan subsystem can work perfectly fine without
CONFIG_THERMAL.

I think that it would be enough to make something like this in
the ./include/linux/thermal.h:

#ifdef CONFIG_THERMAL
	static inline struct thermal_cooling_device *
		thermal_of_cooling_device_register(struct device_node
		*np, char *type, void *devdata,
				   const struct
		thermal_cooling_device_ops *ops) {
		return NULL;
	}
#else
	[ already present declaration of
	thermal_of_cooling_device_register() ]
#endif /* CONFIG_THERMAL */



> > 
> > > ---
> > > Changes for v2:
> > > - None
> > > ---
> > >  include/linux/thermal.h | 14 +++++++++++---
> > >  1 file changed, 11 insertions(+), 3 deletions(-)
> > > 
> > > diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> > > index 2de3d9e..871123c 100644
> > > --- a/include/linux/thermal.h
> > > +++ b/include/linux/thermal.h
> > > @@ -328,6 +328,10 @@ thermal_zone_of_sensor_register(struct
> > > device *dev, int id, void *data, const struct
> > > thermal_zone_of_device_ops *ops); void
> > > thermal_zone_of_sensor_unregister(struct device *dev, struct
> > > thermal_zone_device *tz); +struct thermal_cooling_device *
> > > +thermal_of_cooling_device_register(struct device_node *np,
> > > +				   char *type, void *devdata,
> > > +				   const struct
> > > thermal_cooling_device_ops *); #else
> > >  static inline struct thermal_zone_device *
> > >  thermal_zone_of_sensor_register(struct device *dev, int id, void
> > > *data, @@ -342,6 +346,13 @@ void
> > > thermal_zone_of_sensor_unregister(struct device *dev, {
> > >  }
> > >  
> > > +static inline struct thermal_cooling_device *
> > > +thermal_of_cooling_device_register(struct device_node *np,
> > > +				   char *type, void *devdata,
> > > +				   const struct
> > > thermal_cooling_device_ops *ops) +{
> > > +	return NULL;
> > > +}
> > >  #endif
> > >  struct thermal_zone_device *thermal_zone_device_register(const
> > > char *, int, int, void *, struct thermal_zone_device_ops *,
> > > @@ -357,9 +368,6 @@ void thermal_zone_device_update(struct
> > > thermal_zone_device *); 
> > >  struct thermal_cooling_device
> > > *thermal_cooling_device_register(char *, void *, const struct
> > > thermal_cooling_device_ops *); -struct thermal_cooling_device *
> > > -thermal_of_cooling_device_register(struct device_node *np, char
> > > *, void *,
> > > -				   const struct
> > > thermal_cooling_device_ops *); void
> > > thermal_cooling_device_unregister(struct thermal_cooling_device
> > > *); struct thermal_zone_device
> > > *thermal_zone_get_zone_by_name(const char *name); int
> > > thermal_zone_get_temp(struct thermal_zone_device *tz, unsigned
> > > long *temp); -- 2.0.0.rc2
> > > 
> 
> 



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [lm-sensors] [PATCH v2 1/8] thermal: Provide stub for thermal_of_cooling_device_register() funct
@ 2015-01-14 15:01           ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-01-14 15:01 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, lm-sensors,
	Linux PM list, linux-samsung-soc, devicetree, Lukasz Majewski,
	Kukjin Kim, linux-kernel, Sylwester Nawrocki, Abhilash Kesavan,
	Abhilash Kesavan

SGkgRWR1YXJkbywKCj4gT24gRnJpLCBKYW4gMDIsIDIwMTUgYXQgMDI6NTQ6MjhQTSAtMDQwMCwg
RWR1YXJkbyBWYWxlbnRpbiB3cm90ZToKPiA+IE9uIE1vbiwgRGVjIDIyLCAyMDE0IGF0IDA1OjI3
OjQxUE0gKzAxMDAsIEx1a2FzeiBNYWpld3NraSB3cm90ZToKPiA+ID4gT2Ryb2lkIFUzIGZhbiBj
YW4gd29yayB3aXRob3V0IGJlaW5nIHJlZ2lzdGVyZWQgYXMgT0YgY29vbGluZwo+ID4gPiBkZXZp
Y2UgKHdpdGggQ09ORklHX1RIRVJNQUxfT0YgZGlzYWJsZWQpLgo+ID4gPiBJbiB0aGlzIHNpdHVh
dGlvbiBpdCBjYW4gYmUgY29udHJvbGxlZCB2aWEgUFdNIGVudHJ5IGF0Cj4gPiA+IC9zeXMvY2xh
c3MvaHdtb24vaHdtb24wL3B3bTEuCj4gPiA+IAo+ID4gPiBUaGVyZWZvcmUsIHRoZSB0aGVybWFs
X29mX2Nvb2xpbmdfZGV2aWNlX3JlZ2lzdGVyKCkgZnVuY3Rpb24KPiA+ID4gbmVlZHMgYSBzdHVi
IHRvIGFsbG93IGNsZWFuIGNvbXBpbGF0aW9uLgo+ID4gPiAKPiA+ID4gU2lnbmVkLW9mZi1ieTog
THVrYXN6IE1hamV3c2tpIDxsLm1hamV3c2tpQHNhbXN1bmcuY29tPgo+ID4gCj4gPiBBY2tlZC1i
eTogRWR1YXJkbyBWYWxlbnRpbiA8ZWR1YmV6dmFsQGdtYWlsLmNvbT4KPiAKPiBTb3JyeSwgdG9v
IGZhc3QsCj4gCj4gVGhpcyBpcyBhY3R1YWxseQo+IE5hY2tlZC1ieTogRWR1YXJkbyBWYWxlbnRp
biA8ZWR1YmV6dmFsQGdtYWlsLmNvbT4KPiAKPiA6LSkKPiAKPiBJIGdldCB0aGlzIGVycm9yOgo+
IGRyaXZlcnMvdGhlcm1hbC90aGVybWFsX2NvcmUuYzoxMjEwOjE6IGVycm9yOiByZWRlZmluaXRp
b24gb2YKPiDigJh0aGVybWFsX29mX2Nvb2xpbmdfZGV2aWNlX3JlZ2lzdGVy4oCZCj4gIHRoZXJt
YWxfb2ZfY29vbGluZ19kZXZpY2VfcmVnaXN0ZXIoc3RydWN0IGRldmljZV9ub2RlICpucCwKPiAg
IF4KPiAgIEluIGZpbGUgaW5jbHVkZWQgZnJvbSBkcml2ZXJzL3RoZXJtYWwvdGhlcm1hbF9jb3Jl
LmM6MzQ6MDoKPiAgIGluY2x1ZGUvbGludXgvdGhlcm1hbC5oOjMyMToxOiBub3RlOiBwcmV2aW91
cyBkZWZpbml0aW9uIG9mCj4gICDigJh0aGVybWFsX29mX2Nvb2xpbmdfZGV2aWNlX3JlZ2lzdGVy
4oCZIHdhcyBoZXJlCj4gICAgdGhlcm1hbF9vZl9jb29saW5nX2RldmljZV9yZWdpc3RlcihzdHJ1
Y3QgZGV2aWNlX25vZGUgKm5wLAo+ICAgICBeCj4gCj4gCj4gV2UgcHJvdmlkZSB0aGUgZnVuY3Rp
b24gaW4gdGhlcm1hbCBjb3JlIGV2ZW4gaWYgQ09ORklHX1RIRVJNQUxfT0YgaXMKPiBub3Qgc2V0
LgoKVW5mb3J0dW5hdGVseSB0aGUgUFdNIGZhbiBzdWJzeXN0ZW0gY2FuIHdvcmsgcGVyZmVjdGx5
IGZpbmUgd2l0aG91dApDT05GSUdfVEhFUk1BTC4KCkkgdGhpbmsgdGhhdCBpdCB3b3VsZCBiZSBl
bm91Z2ggdG8gbWFrZSBzb21ldGhpbmcgbGlrZSB0aGlzIGluCnRoZSAuL2luY2x1ZGUvbGludXgv
dGhlcm1hbC5oOgoKI2lmZGVmIENPTkZJR19USEVSTUFMCglzdGF0aWMgaW5saW5lIHN0cnVjdCB0
aGVybWFsX2Nvb2xpbmdfZGV2aWNlICoKCQl0aGVybWFsX29mX2Nvb2xpbmdfZGV2aWNlX3JlZ2lz
dGVyKHN0cnVjdCBkZXZpY2Vfbm9kZQoJCSpucCwgY2hhciAqdHlwZSwgdm9pZCAqZGV2ZGF0YSwK
CQkJCSAgIGNvbnN0IHN0cnVjdAoJCXRoZXJtYWxfY29vbGluZ19kZXZpY2Vfb3BzICpvcHMpIHsK
CQlyZXR1cm4gTlVMTDsKCX0KI2Vsc2UKCVsgYWxyZWFkeSBwcmVzZW50IGRlY2xhcmF0aW9uIG9m
Cgl0aGVybWFsX29mX2Nvb2xpbmdfZGV2aWNlX3JlZ2lzdGVyKCkgXQojZW5kaWYgLyogQ09ORklH
X1RIRVJNQUwgKi8KCgoKPiA+IAo+ID4gPiAtLS0KPiA+ID4gQ2hhbmdlcyBmb3IgdjI6Cj4gPiA+
IC0gTm9uZQo+ID4gPiAtLS0KPiA+ID4gIGluY2x1ZGUvbGludXgvdGhlcm1hbC5oIHwgMTQgKysr
KysrKysrKystLS0KPiA+ID4gIDEgZmlsZSBjaGFuZ2VkLCAxMSBpbnNlcnRpb25zKCspLCAzIGRl
bGV0aW9ucygtKQo+ID4gPiAKPiA+ID4gZGlmZiAtLWdpdCBhL2luY2x1ZGUvbGludXgvdGhlcm1h
bC5oIGIvaW5jbHVkZS9saW51eC90aGVybWFsLmgKPiA+ID4gaW5kZXggMmRlM2Q5ZS4uODcxMTIz
YyAxMDA2NDQKPiA+ID4gLS0tIGEvaW5jbHVkZS9saW51eC90aGVybWFsLmgKPiA+ID4gKysrIGIv
aW5jbHVkZS9saW51eC90aGVybWFsLmgKPiA+ID4gQEAgLTMyOCw2ICszMjgsMTAgQEAgdGhlcm1h
bF96b25lX29mX3NlbnNvcl9yZWdpc3RlcihzdHJ1Y3QKPiA+ID4gZGV2aWNlICpkZXYsIGludCBp
ZCwgdm9pZCAqZGF0YSwgY29uc3Qgc3RydWN0Cj4gPiA+IHRoZXJtYWxfem9uZV9vZl9kZXZpY2Vf
b3BzICpvcHMpOyB2b2lkCj4gPiA+IHRoZXJtYWxfem9uZV9vZl9zZW5zb3JfdW5yZWdpc3Rlcihz
dHJ1Y3QgZGV2aWNlICpkZXYsIHN0cnVjdAo+ID4gPiB0aGVybWFsX3pvbmVfZGV2aWNlICp0eik7
ICtzdHJ1Y3QgdGhlcm1hbF9jb29saW5nX2RldmljZSAqCj4gPiA+ICt0aGVybWFsX29mX2Nvb2xp
bmdfZGV2aWNlX3JlZ2lzdGVyKHN0cnVjdCBkZXZpY2Vfbm9kZSAqbnAsCj4gPiA+ICsJCQkJICAg
Y2hhciAqdHlwZSwgdm9pZCAqZGV2ZGF0YSwKPiA+ID4gKwkJCQkgICBjb25zdCBzdHJ1Y3QKPiA+
ID4gdGhlcm1hbF9jb29saW5nX2RldmljZV9vcHMgKik7ICNlbHNlCj4gPiA+ICBzdGF0aWMgaW5s
aW5lIHN0cnVjdCB0aGVybWFsX3pvbmVfZGV2aWNlICoKPiA+ID4gIHRoZXJtYWxfem9uZV9vZl9z
ZW5zb3JfcmVnaXN0ZXIoc3RydWN0IGRldmljZSAqZGV2LCBpbnQgaWQsIHZvaWQKPiA+ID4gKmRh
dGEsIEBAIC0zNDIsNiArMzQ2LDEzIEBAIHZvaWQKPiA+ID4gdGhlcm1hbF96b25lX29mX3NlbnNv
cl91bnJlZ2lzdGVyKHN0cnVjdCBkZXZpY2UgKmRldiwgewo+ID4gPiAgfQo+ID4gPiAgCj4gPiA+
ICtzdGF0aWMgaW5saW5lIHN0cnVjdCB0aGVybWFsX2Nvb2xpbmdfZGV2aWNlICoKPiA+ID4gK3Ro
ZXJtYWxfb2ZfY29vbGluZ19kZXZpY2VfcmVnaXN0ZXIoc3RydWN0IGRldmljZV9ub2RlICpucCwK
PiA+ID4gKwkJCQkgICBjaGFyICp0eXBlLCB2b2lkICpkZXZkYXRhLAo+ID4gPiArCQkJCSAgIGNv
bnN0IHN0cnVjdAo+ID4gPiB0aGVybWFsX2Nvb2xpbmdfZGV2aWNlX29wcyAqb3BzKSArewo+ID4g
PiArCXJldHVybiBOVUxMOwo+ID4gPiArfQo+ID4gPiAgI2VuZGlmCj4gPiA+ICBzdHJ1Y3QgdGhl
cm1hbF96b25lX2RldmljZSAqdGhlcm1hbF96b25lX2RldmljZV9yZWdpc3Rlcihjb25zdAo+ID4g
PiBjaGFyICosIGludCwgaW50LCB2b2lkICosIHN0cnVjdCB0aGVybWFsX3pvbmVfZGV2aWNlX29w
cyAqLAo+ID4gPiBAQCAtMzU3LDkgKzM2OCw2IEBAIHZvaWQgdGhlcm1hbF96b25lX2RldmljZV91
cGRhdGUoc3RydWN0Cj4gPiA+IHRoZXJtYWxfem9uZV9kZXZpY2UgKik7IAo+ID4gPiAgc3RydWN0
IHRoZXJtYWxfY29vbGluZ19kZXZpY2UKPiA+ID4gKnRoZXJtYWxfY29vbGluZ19kZXZpY2VfcmVn
aXN0ZXIoY2hhciAqLCB2b2lkICosIGNvbnN0IHN0cnVjdAo+ID4gPiB0aGVybWFsX2Nvb2xpbmdf
ZGV2aWNlX29wcyAqKTsgLXN0cnVjdCB0aGVybWFsX2Nvb2xpbmdfZGV2aWNlICoKPiA+ID4gLXRo
ZXJtYWxfb2ZfY29vbGluZ19kZXZpY2VfcmVnaXN0ZXIoc3RydWN0IGRldmljZV9ub2RlICpucCwg
Y2hhcgo+ID4gPiAqLCB2b2lkICosCj4gPiA+IC0JCQkJICAgY29uc3Qgc3RydWN0Cj4gPiA+IHRo
ZXJtYWxfY29vbGluZ19kZXZpY2Vfb3BzICopOyB2b2lkCj4gPiA+IHRoZXJtYWxfY29vbGluZ19k
ZXZpY2VfdW5yZWdpc3RlcihzdHJ1Y3QgdGhlcm1hbF9jb29saW5nX2RldmljZQo+ID4gPiAqKTsg
c3RydWN0IHRoZXJtYWxfem9uZV9kZXZpY2UKPiA+ID4gKnRoZXJtYWxfem9uZV9nZXRfem9uZV9i
eV9uYW1lKGNvbnN0IGNoYXIgKm5hbWUpOyBpbnQKPiA+ID4gdGhlcm1hbF96b25lX2dldF90ZW1w
KHN0cnVjdCB0aGVybWFsX3pvbmVfZGV2aWNlICp0eiwgdW5zaWduZWQKPiA+ID4gbG9uZyAqdGVt
cCk7IC0tIDIuMC4wLnJjMgo+ID4gPiAKPiAKPiAKCgoKLS0gCkJlc3QgcmVnYXJkcywKCkx1a2Fz
eiBNYWpld3NraQoKU2Ftc3VuZyBSJkQgSW5zdGl0dXRlIFBvbGFuZCAoU1JQT0wpIHwgTGludXgg
UGxhdGZvcm0gR3JvdXAKCl9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f
X19fX19fCmxtLXNlbnNvcnMgbWFpbGluZyBsaXN0CmxtLXNlbnNvcnNAbG0tc2Vuc29ycy5vcmcK
aHR0cDovL2xpc3RzLmxtLXNlbnNvcnMub3JnL21haWxtYW4vbGlzdGluZm8vbG0tc2Vuc29ycw=

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v2 2/8] thermal: Provide stub for thermal_cdev_update() function
  2015-01-02 18:40       ` Eduardo Valentin
  (?)
@ 2015-01-14 15:07         ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-01-14 15:07 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, lm-sensors,
	Linux PM list, linux-samsung-soc, devicetree, Lukasz Majewski,
	Kukjin Kim, linux-kernel, Sylwester Nawrocki, Abhilash Kesavan,
	Abhilash Kesavan

Hi Eduardo,

> On Mon, Dec 22, 2014 at 05:27:42PM +0100, Lukasz Majewski wrote:
> > Odroid U3 fan can work without being registered as OF cooling device
> > (with CONFIG_THERMAL_OF disabled).
> > In this situation it can be controlled via PWM entry at
> > /sys/class/hwmon/hwmon0/pwm1.
> > 
> > Therefore, the thermal_cdev_update() function needs a stub
> > to allow clean compilation.
> 
> I am not sure I understand what you are attempting to do here. What is
> the relation that you see between CONFIG_OF_THERMAL and
> thermal_cdev_update? 

It should be CONFIG_THERMAL, not CONFIG_OF_THERMAL.

The thermal_cdev_update() is necessary since pwm-fan code can be
run without THERMAL subsystem (and such configuration is perfectly
valid).

> 
> > 
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > ---
> > Changes for v2:
> > - New patch
> > ---
> >  include/linux/thermal.h | 6 +++++-
> >  1 file changed, 5 insertions(+), 1 deletion(-)
> > 
> > diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> > index 871123c..b3515b5 100644
> > --- a/include/linux/thermal.h
> > +++ b/include/linux/thermal.h
> > @@ -332,6 +332,7 @@ struct thermal_cooling_device *
> >  thermal_of_cooling_device_register(struct device_node *np,
> >  				   char *type, void *devdata,
> >  				   const struct
> > thermal_cooling_device_ops *); +void thermal_cdev_update(struct
> > thermal_cooling_device *); #else
> >  static inline struct thermal_zone_device *
> >  thermal_zone_of_sensor_register(struct device *dev, int id, void
> > *data, @@ -353,6 +354,10 @@
> > thermal_of_cooling_device_register(struct device_node *np, {
> >  	return NULL;
> >  }
> > +
> > +static inline void thermal_cdev_update(struct
> > thermal_cooling_device *cdev) +{
> > +}
> >  #endif
> >  struct thermal_zone_device *thermal_zone_device_register(const
> > char *, int, int, void *, struct thermal_zone_device_ops *,
> > @@ -375,7 +380,6 @@ int thermal_zone_get_temp(struct
> > thermal_zone_device *tz, unsigned long *temp); int
> > get_tz_trend(struct thermal_zone_device *, int); struct
> > thermal_instance *get_thermal_instance(struct thermal_zone_device
> > *, struct thermal_cooling_device *, int); -void
> > thermal_cdev_update(struct thermal_cooling_device *); void
> > thermal_notify_framework(struct thermal_zone_device *, int); 
> >  #ifdef CONFIG_NET
> > -- 
> > 2.0.0.rc2
> > 


-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v2 2/8] thermal: Provide stub for thermal_cdev_update() function
@ 2015-01-14 15:07         ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-01-14 15:07 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck,
	lm-sensors-GZX6beZjE8VD60Wz+7aTrA, Linux PM list,
	linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Lukasz Majewski, Kukjin Kim,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Sylwester Nawrocki,
	Abhilash Kesavan, Abhilash Kesavan

Hi Eduardo,

> On Mon, Dec 22, 2014 at 05:27:42PM +0100, Lukasz Majewski wrote:
> > Odroid U3 fan can work without being registered as OF cooling device
> > (with CONFIG_THERMAL_OF disabled).
> > In this situation it can be controlled via PWM entry at
> > /sys/class/hwmon/hwmon0/pwm1.
> > 
> > Therefore, the thermal_cdev_update() function needs a stub
> > to allow clean compilation.
> 
> I am not sure I understand what you are attempting to do here. What is
> the relation that you see between CONFIG_OF_THERMAL and
> thermal_cdev_update? 

It should be CONFIG_THERMAL, not CONFIG_OF_THERMAL.

The thermal_cdev_update() is necessary since pwm-fan code can be
run without THERMAL subsystem (and such configuration is perfectly
valid).

> 
> > 
> > Signed-off-by: Lukasz Majewski <l.majewski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
> > ---
> > Changes for v2:
> > - New patch
> > ---
> >  include/linux/thermal.h | 6 +++++-
> >  1 file changed, 5 insertions(+), 1 deletion(-)
> > 
> > diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> > index 871123c..b3515b5 100644
> > --- a/include/linux/thermal.h
> > +++ b/include/linux/thermal.h
> > @@ -332,6 +332,7 @@ struct thermal_cooling_device *
> >  thermal_of_cooling_device_register(struct device_node *np,
> >  				   char *type, void *devdata,
> >  				   const struct
> > thermal_cooling_device_ops *); +void thermal_cdev_update(struct
> > thermal_cooling_device *); #else
> >  static inline struct thermal_zone_device *
> >  thermal_zone_of_sensor_register(struct device *dev, int id, void
> > *data, @@ -353,6 +354,10 @@
> > thermal_of_cooling_device_register(struct device_node *np, {
> >  	return NULL;
> >  }
> > +
> > +static inline void thermal_cdev_update(struct
> > thermal_cooling_device *cdev) +{
> > +}
> >  #endif
> >  struct thermal_zone_device *thermal_zone_device_register(const
> > char *, int, int, void *, struct thermal_zone_device_ops *,
> > @@ -375,7 +380,6 @@ int thermal_zone_get_temp(struct
> > thermal_zone_device *tz, unsigned long *temp); int
> > get_tz_trend(struct thermal_zone_device *, int); struct
> > thermal_instance *get_thermal_instance(struct thermal_zone_device
> > *, struct thermal_cooling_device *, int); -void
> > thermal_cdev_update(struct thermal_cooling_device *); void
> > thermal_notify_framework(struct thermal_zone_device *, int); 
> >  #ifdef CONFIG_NET
> > -- 
> > 2.0.0.rc2
> > 


-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [lm-sensors] [PATCH v2 2/8] thermal: Provide stub for thermal_cdev_update() function
@ 2015-01-14 15:07         ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-01-14 15:07 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, lm-sensors,
	Linux PM list, linux-samsung-soc, devicetree, Lukasz Majewski,
	Kukjin Kim, linux-kernel, Sylwester Nawrocki, Abhilash Kesavan,
	Abhilash Kesavan

Hi Eduardo,

> On Mon, Dec 22, 2014 at 05:27:42PM +0100, Lukasz Majewski wrote:
> > Odroid U3 fan can work without being registered as OF cooling device
> > (with CONFIG_THERMAL_OF disabled).
> > In this situation it can be controlled via PWM entry at
> > /sys/class/hwmon/hwmon0/pwm1.
> > 
> > Therefore, the thermal_cdev_update() function needs a stub
> > to allow clean compilation.
> 
> I am not sure I understand what you are attempting to do here. What is
> the relation that you see between CONFIG_OF_THERMAL and
> thermal_cdev_update? 

It should be CONFIG_THERMAL, not CONFIG_OF_THERMAL.

The thermal_cdev_update() is necessary since pwm-fan code can be
run without THERMAL subsystem (and such configuration is perfectly
valid).

> 
> > 
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > ---
> > Changes for v2:
> > - New patch
> > ---
> >  include/linux/thermal.h | 6 +++++-
> >  1 file changed, 5 insertions(+), 1 deletion(-)
> > 
> > diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> > index 871123c..b3515b5 100644
> > --- a/include/linux/thermal.h
> > +++ b/include/linux/thermal.h
> > @@ -332,6 +332,7 @@ struct thermal_cooling_device *
> >  thermal_of_cooling_device_register(struct device_node *np,
> >  				   char *type, void *devdata,
> >  				   const struct
> > thermal_cooling_device_ops *); +void thermal_cdev_update(struct
> > thermal_cooling_device *); #else
> >  static inline struct thermal_zone_device *
> >  thermal_zone_of_sensor_register(struct device *dev, int id, void
> > *data, @@ -353,6 +354,10 @@
> > thermal_of_cooling_device_register(struct device_node *np, {
> >  	return NULL;
> >  }
> > +
> > +static inline void thermal_cdev_update(struct
> > thermal_cooling_device *cdev) +{
> > +}
> >  #endif
> >  struct thermal_zone_device *thermal_zone_device_register(const
> > char *, int, int, void *, struct thermal_zone_device_ops *,
> > @@ -375,7 +380,6 @@ int thermal_zone_get_temp(struct
> > thermal_zone_device *tz, unsigned long *temp); int
> > get_tz_trend(struct thermal_zone_device *, int); struct
> > thermal_instance *get_thermal_instance(struct thermal_zone_device
> > *, struct thermal_cooling_device *, int); -void
> > thermal_cdev_update(struct thermal_cooling_device *); void
> > thermal_notify_framework(struct thermal_zone_device *, int); 
> >  #ifdef CONFIG_NET
> > -- 
> > 2.0.0.rc2
> > 


-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v2 2/8] thermal: Provide stub for thermal_cdev_update() function
  2015-01-14 15:07         ` Lukasz Majewski
  (?)
@ 2015-01-14 18:28           ` Eduardo Valentin
  -1 siblings, 0 replies; 329+ messages in thread
From: Eduardo Valentin @ 2015-01-14 18:28 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, lm-sensors,
	Linux PM list, linux-samsung-soc, devicetree, Lukasz Majewski,
	Kukjin Kim, linux-kernel, Sylwester Nawrocki, Abhilash Kesavan,
	Abhilash Kesavan

[-- Attachment #1: Type: text/plain, Size: 2869 bytes --]

On Wed, Jan 14, 2015 at 04:07:53PM +0100, Lukasz Majewski wrote:
> Hi Eduardo,
> 
> > On Mon, Dec 22, 2014 at 05:27:42PM +0100, Lukasz Majewski wrote:
> > > Odroid U3 fan can work without being registered as OF cooling device
> > > (with CONFIG_THERMAL_OF disabled).
> > > In this situation it can be controlled via PWM entry at
> > > /sys/class/hwmon/hwmon0/pwm1.
> > > 
> > > Therefore, the thermal_cdev_update() function needs a stub
> > > to allow clean compilation.
> > 
> > I am not sure I understand what you are attempting to do here. What is
> > the relation that you see between CONFIG_OF_THERMAL and
> > thermal_cdev_update? 
> 
> It should be CONFIG_THERMAL, not CONFIG_OF_THERMAL.
> 
> The thermal_cdev_update() is necessary since pwm-fan code can be
> run without THERMAL subsystem (and such configuration is perfectly
> valid).

OK. Now I understand. Then, please resend this one using CONFIG_THERMAL.


Thanks,


Eduardo Valentin

> 
> > 
> > > 
> > > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > > ---
> > > Changes for v2:
> > > - New patch
> > > ---
> > >  include/linux/thermal.h | 6 +++++-
> > >  1 file changed, 5 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> > > index 871123c..b3515b5 100644
> > > --- a/include/linux/thermal.h
> > > +++ b/include/linux/thermal.h
> > > @@ -332,6 +332,7 @@ struct thermal_cooling_device *
> > >  thermal_of_cooling_device_register(struct device_node *np,
> > >  				   char *type, void *devdata,
> > >  				   const struct
> > > thermal_cooling_device_ops *); +void thermal_cdev_update(struct
> > > thermal_cooling_device *); #else
> > >  static inline struct thermal_zone_device *
> > >  thermal_zone_of_sensor_register(struct device *dev, int id, void
> > > *data, @@ -353,6 +354,10 @@
> > > thermal_of_cooling_device_register(struct device_node *np, {
> > >  	return NULL;
> > >  }
> > > +
> > > +static inline void thermal_cdev_update(struct
> > > thermal_cooling_device *cdev) +{
> > > +}
> > >  #endif
> > >  struct thermal_zone_device *thermal_zone_device_register(const
> > > char *, int, int, void *, struct thermal_zone_device_ops *,
> > > @@ -375,7 +380,6 @@ int thermal_zone_get_temp(struct
> > > thermal_zone_device *tz, unsigned long *temp); int
> > > get_tz_trend(struct thermal_zone_device *, int); struct
> > > thermal_instance *get_thermal_instance(struct thermal_zone_device
> > > *, struct thermal_cooling_device *, int); -void
> > > thermal_cdev_update(struct thermal_cooling_device *); void
> > > thermal_notify_framework(struct thermal_zone_device *, int); 
> > >  #ifdef CONFIG_NET
> > > -- 
> > > 2.0.0.rc2
> > > 
> 
> 
> -- 
> Best regards,
> 
> Lukasz Majewski
> 
> Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v2 2/8] thermal: Provide stub for thermal_cdev_update() function
@ 2015-01-14 18:28           ` Eduardo Valentin
  0 siblings, 0 replies; 329+ messages in thread
From: Eduardo Valentin @ 2015-01-14 18:28 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, lm-sensors,
	Linux PM list, linux-samsung-soc, devicetree, Lukasz Majewski,
	Kukjin Kim, linux-kernel, Sylwester Nawrocki, Abhilash Kesavan,
	Abhilash Kesavan

[-- Attachment #1: Type: text/plain, Size: 2869 bytes --]

On Wed, Jan 14, 2015 at 04:07:53PM +0100, Lukasz Majewski wrote:
> Hi Eduardo,
> 
> > On Mon, Dec 22, 2014 at 05:27:42PM +0100, Lukasz Majewski wrote:
> > > Odroid U3 fan can work without being registered as OF cooling device
> > > (with CONFIG_THERMAL_OF disabled).
> > > In this situation it can be controlled via PWM entry at
> > > /sys/class/hwmon/hwmon0/pwm1.
> > > 
> > > Therefore, the thermal_cdev_update() function needs a stub
> > > to allow clean compilation.
> > 
> > I am not sure I understand what you are attempting to do here. What is
> > the relation that you see between CONFIG_OF_THERMAL and
> > thermal_cdev_update? 
> 
> It should be CONFIG_THERMAL, not CONFIG_OF_THERMAL.
> 
> The thermal_cdev_update() is necessary since pwm-fan code can be
> run without THERMAL subsystem (and such configuration is perfectly
> valid).

OK. Now I understand. Then, please resend this one using CONFIG_THERMAL.


Thanks,


Eduardo Valentin

> 
> > 
> > > 
> > > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > > ---
> > > Changes for v2:
> > > - New patch
> > > ---
> > >  include/linux/thermal.h | 6 +++++-
> > >  1 file changed, 5 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> > > index 871123c..b3515b5 100644
> > > --- a/include/linux/thermal.h
> > > +++ b/include/linux/thermal.h
> > > @@ -332,6 +332,7 @@ struct thermal_cooling_device *
> > >  thermal_of_cooling_device_register(struct device_node *np,
> > >  				   char *type, void *devdata,
> > >  				   const struct
> > > thermal_cooling_device_ops *); +void thermal_cdev_update(struct
> > > thermal_cooling_device *); #else
> > >  static inline struct thermal_zone_device *
> > >  thermal_zone_of_sensor_register(struct device *dev, int id, void
> > > *data, @@ -353,6 +354,10 @@
> > > thermal_of_cooling_device_register(struct device_node *np, {
> > >  	return NULL;
> > >  }
> > > +
> > > +static inline void thermal_cdev_update(struct
> > > thermal_cooling_device *cdev) +{
> > > +}
> > >  #endif
> > >  struct thermal_zone_device *thermal_zone_device_register(const
> > > char *, int, int, void *, struct thermal_zone_device_ops *,
> > > @@ -375,7 +380,6 @@ int thermal_zone_get_temp(struct
> > > thermal_zone_device *tz, unsigned long *temp); int
> > > get_tz_trend(struct thermal_zone_device *, int); struct
> > > thermal_instance *get_thermal_instance(struct thermal_zone_device
> > > *, struct thermal_cooling_device *, int); -void
> > > thermal_cdev_update(struct thermal_cooling_device *); void
> > > thermal_notify_framework(struct thermal_zone_device *, int); 
> > >  #ifdef CONFIG_NET
> > > -- 
> > > 2.0.0.rc2
> > > 
> 
> 
> -- 
> Best regards,
> 
> Lukasz Majewski
> 
> Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [lm-sensors] [PATCH v2 2/8] thermal: Provide stub for thermal_cdev_update() function
@ 2015-01-14 18:28           ` Eduardo Valentin
  0 siblings, 0 replies; 329+ messages in thread
From: Eduardo Valentin @ 2015-01-14 18:28 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, lm-sensors,
	Linux PM list, linux-samsung-soc, devicetree, Lukasz Majewski,
	Kukjin Kim, linux-kernel, Sylwester Nawrocki, Abhilash Kesavan,
	Abhilash Kesavan


[-- Attachment #1.1: Type: text/plain, Size: 2869 bytes --]

On Wed, Jan 14, 2015 at 04:07:53PM +0100, Lukasz Majewski wrote:
> Hi Eduardo,
> 
> > On Mon, Dec 22, 2014 at 05:27:42PM +0100, Lukasz Majewski wrote:
> > > Odroid U3 fan can work without being registered as OF cooling device
> > > (with CONFIG_THERMAL_OF disabled).
> > > In this situation it can be controlled via PWM entry at
> > > /sys/class/hwmon/hwmon0/pwm1.
> > > 
> > > Therefore, the thermal_cdev_update() function needs a stub
> > > to allow clean compilation.
> > 
> > I am not sure I understand what you are attempting to do here. What is
> > the relation that you see between CONFIG_OF_THERMAL and
> > thermal_cdev_update? 
> 
> It should be CONFIG_THERMAL, not CONFIG_OF_THERMAL.
> 
> The thermal_cdev_update() is necessary since pwm-fan code can be
> run without THERMAL subsystem (and such configuration is perfectly
> valid).

OK. Now I understand. Then, please resend this one using CONFIG_THERMAL.


Thanks,


Eduardo Valentin

> 
> > 
> > > 
> > > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > > ---
> > > Changes for v2:
> > > - New patch
> > > ---
> > >  include/linux/thermal.h | 6 +++++-
> > >  1 file changed, 5 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> > > index 871123c..b3515b5 100644
> > > --- a/include/linux/thermal.h
> > > +++ b/include/linux/thermal.h
> > > @@ -332,6 +332,7 @@ struct thermal_cooling_device *
> > >  thermal_of_cooling_device_register(struct device_node *np,
> > >  				   char *type, void *devdata,
> > >  				   const struct
> > > thermal_cooling_device_ops *); +void thermal_cdev_update(struct
> > > thermal_cooling_device *); #else
> > >  static inline struct thermal_zone_device *
> > >  thermal_zone_of_sensor_register(struct device *dev, int id, void
> > > *data, @@ -353,6 +354,10 @@
> > > thermal_of_cooling_device_register(struct device_node *np, {
> > >  	return NULL;
> > >  }
> > > +
> > > +static inline void thermal_cdev_update(struct
> > > thermal_cooling_device *cdev) +{
> > > +}
> > >  #endif
> > >  struct thermal_zone_device *thermal_zone_device_register(const
> > > char *, int, int, void *, struct thermal_zone_device_ops *,
> > > @@ -375,7 +380,6 @@ int thermal_zone_get_temp(struct
> > > thermal_zone_device *tz, unsigned long *temp); int
> > > get_tz_trend(struct thermal_zone_device *, int); struct
> > > thermal_instance *get_thermal_instance(struct thermal_zone_device
> > > *, struct thermal_cooling_device *, int); -void
> > > thermal_cdev_update(struct thermal_cooling_device *); void
> > > thermal_notify_framework(struct thermal_zone_device *, int); 
> > >  #ifdef CONFIG_NET
> > > -- 
> > > 2.0.0.rc2
> > > 
> 
> 
> -- 
> Best regards,
> 
> Lukasz Majewski
> 
> Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

[-- Attachment #2: Type: text/plain, Size: 153 bytes --]

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v2 1/8] thermal: Provide stub for thermal_of_cooling_device_register() function
  2015-01-14 15:01           ` [PATCH v2 1/8] thermal: Provide stub for thermal_of_cooling_device_register() function Lukasz Majewski
  (?)
@ 2015-01-14 18:32             ` Eduardo Valentin
  -1 siblings, 0 replies; 329+ messages in thread
From: Eduardo Valentin @ 2015-01-14 18:32 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, lm-sensors,
	Linux PM list, linux-samsung-soc, devicetree, Lukasz Majewski,
	Kukjin Kim, linux-kernel, Sylwester Nawrocki, Abhilash Kesavan,
	Abhilash Kesavan

[-- Attachment #1: Type: text/plain, Size: 4709 bytes --]

On Wed, Jan 14, 2015 at 04:01:06PM +0100, Lukasz Majewski wrote:
> Hi Eduardo,
> 
> > On Fri, Jan 02, 2015 at 02:54:28PM -0400, Eduardo Valentin wrote:
> > > On Mon, Dec 22, 2014 at 05:27:41PM +0100, Lukasz Majewski wrote:
> > > > Odroid U3 fan can work without being registered as OF cooling
> > > > device (with CONFIG_THERMAL_OF disabled).
> > > > In this situation it can be controlled via PWM entry at
> > > > /sys/class/hwmon/hwmon0/pwm1.
> > > > 
> > > > Therefore, the thermal_of_cooling_device_register() function
> > > > needs a stub to allow clean compilation.
> > > > 
> > > > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > > 
> > > Acked-by: Eduardo Valentin <edubezval@gmail.com>
> > 
> > Sorry, too fast,
> > 
> > This is actually
> > Nacked-by: Eduardo Valentin <edubezval@gmail.com>
> > 
> > :-)
> > 
> > I get this error:
> > drivers/thermal/thermal_core.c:1210:1: error: redefinition of
> > ‘thermal_of_cooling_device_register’
> >  thermal_of_cooling_device_register(struct device_node *np,
> >   ^
> >   In file included from drivers/thermal/thermal_core.c:34:0:
> >   include/linux/thermal.h:321:1: note: previous definition of
> >   ‘thermal_of_cooling_device_register’ was here
> >    thermal_of_cooling_device_register(struct device_node *np,
> >     ^
> > 
> > 
> > We provide the function in thermal core even if CONFIG_THERMAL_OF is
> > not set.
> 
> Unfortunately the PWM fan subsystem can work perfectly fine without
> CONFIG_THERMAL.
> 

Now I understand what you are trying to do.

> I think that it would be enough to make something like this in
> the ./include/linux/thermal.h:
> 
> #ifdef CONFIG_THERMAL
Well, I think it should be the opposite here:

#ifndef CONFIG_THERMAL

that is, if no config thermal, then you provide the stub not the other
way around.

> 	static inline struct thermal_cooling_device *
> 		thermal_of_cooling_device_register(struct device_node
> 		*np, char *type, void *devdata,
> 				   const struct
> 		thermal_cooling_device_ops *ops) {
> 		return NULL;
> 	}
> #else
> 	[ already present declaration of
> 	thermal_of_cooling_device_register() ]
> #endif /* CONFIG_THERMAL */


> 
> 
> 
> > > 
> > > > ---
> > > > Changes for v2:
> > > > - None
> > > > ---
> > > >  include/linux/thermal.h | 14 +++++++++++---
> > > >  1 file changed, 11 insertions(+), 3 deletions(-)
> > > > 
> > > > diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> > > > index 2de3d9e..871123c 100644
> > > > --- a/include/linux/thermal.h
> > > > +++ b/include/linux/thermal.h
> > > > @@ -328,6 +328,10 @@ thermal_zone_of_sensor_register(struct
> > > > device *dev, int id, void *data, const struct
> > > > thermal_zone_of_device_ops *ops); void
> > > > thermal_zone_of_sensor_unregister(struct device *dev, struct
> > > > thermal_zone_device *tz); +struct thermal_cooling_device *
> > > > +thermal_of_cooling_device_register(struct device_node *np,
> > > > +				   char *type, void *devdata,
> > > > +				   const struct
> > > > thermal_cooling_device_ops *); #else
> > > >  static inline struct thermal_zone_device *
> > > >  thermal_zone_of_sensor_register(struct device *dev, int id, void
> > > > *data, @@ -342,6 +346,13 @@ void
> > > > thermal_zone_of_sensor_unregister(struct device *dev, {
> > > >  }
> > > >  
> > > > +static inline struct thermal_cooling_device *
> > > > +thermal_of_cooling_device_register(struct device_node *np,
> > > > +				   char *type, void *devdata,
> > > > +				   const struct
> > > > thermal_cooling_device_ops *ops) +{
> > > > +	return NULL;
> > > > +}
> > > >  #endif
> > > >  struct thermal_zone_device *thermal_zone_device_register(const
> > > > char *, int, int, void *, struct thermal_zone_device_ops *,
> > > > @@ -357,9 +368,6 @@ void thermal_zone_device_update(struct
> > > > thermal_zone_device *); 
> > > >  struct thermal_cooling_device
> > > > *thermal_cooling_device_register(char *, void *, const struct
> > > > thermal_cooling_device_ops *); -struct thermal_cooling_device *
> > > > -thermal_of_cooling_device_register(struct device_node *np, char
> > > > *, void *,
> > > > -				   const struct
> > > > thermal_cooling_device_ops *); void
> > > > thermal_cooling_device_unregister(struct thermal_cooling_device
> > > > *); struct thermal_zone_device
> > > > *thermal_zone_get_zone_by_name(const char *name); int
> > > > thermal_zone_get_temp(struct thermal_zone_device *tz, unsigned
> > > > long *temp); -- 2.0.0.rc2
> > > > 
> > 
> > 
> 
> 
> 
> -- 
> Best regards,
> 
> Lukasz Majewski
> 
> Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v2 1/8] thermal: Provide stub for thermal_of_cooling_device_register() function
@ 2015-01-14 18:32             ` Eduardo Valentin
  0 siblings, 0 replies; 329+ messages in thread
From: Eduardo Valentin @ 2015-01-14 18:32 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, lm-sensors,
	Linux PM list, linux-samsung-soc, devicetree, Lukasz Majewski,
	Kukjin Kim, linux-kernel, Sylwester Nawrocki, Abhilash Kesavan,
	Abhilash Kesavan

[-- Attachment #1: Type: text/plain, Size: 4709 bytes --]

On Wed, Jan 14, 2015 at 04:01:06PM +0100, Lukasz Majewski wrote:
> Hi Eduardo,
> 
> > On Fri, Jan 02, 2015 at 02:54:28PM -0400, Eduardo Valentin wrote:
> > > On Mon, Dec 22, 2014 at 05:27:41PM +0100, Lukasz Majewski wrote:
> > > > Odroid U3 fan can work without being registered as OF cooling
> > > > device (with CONFIG_THERMAL_OF disabled).
> > > > In this situation it can be controlled via PWM entry at
> > > > /sys/class/hwmon/hwmon0/pwm1.
> > > > 
> > > > Therefore, the thermal_of_cooling_device_register() function
> > > > needs a stub to allow clean compilation.
> > > > 
> > > > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > > 
> > > Acked-by: Eduardo Valentin <edubezval@gmail.com>
> > 
> > Sorry, too fast,
> > 
> > This is actually
> > Nacked-by: Eduardo Valentin <edubezval@gmail.com>
> > 
> > :-)
> > 
> > I get this error:
> > drivers/thermal/thermal_core.c:1210:1: error: redefinition of
> > ‘thermal_of_cooling_device_register’
> >  thermal_of_cooling_device_register(struct device_node *np,
> >   ^
> >   In file included from drivers/thermal/thermal_core.c:34:0:
> >   include/linux/thermal.h:321:1: note: previous definition of
> >   ‘thermal_of_cooling_device_register’ was here
> >    thermal_of_cooling_device_register(struct device_node *np,
> >     ^
> > 
> > 
> > We provide the function in thermal core even if CONFIG_THERMAL_OF is
> > not set.
> 
> Unfortunately the PWM fan subsystem can work perfectly fine without
> CONFIG_THERMAL.
> 

Now I understand what you are trying to do.

> I think that it would be enough to make something like this in
> the ./include/linux/thermal.h:
> 
> #ifdef CONFIG_THERMAL
Well, I think it should be the opposite here:

#ifndef CONFIG_THERMAL

that is, if no config thermal, then you provide the stub not the other
way around.

> 	static inline struct thermal_cooling_device *
> 		thermal_of_cooling_device_register(struct device_node
> 		*np, char *type, void *devdata,
> 				   const struct
> 		thermal_cooling_device_ops *ops) {
> 		return NULL;
> 	}
> #else
> 	[ already present declaration of
> 	thermal_of_cooling_device_register() ]
> #endif /* CONFIG_THERMAL */


> 
> 
> 
> > > 
> > > > ---
> > > > Changes for v2:
> > > > - None
> > > > ---
> > > >  include/linux/thermal.h | 14 +++++++++++---
> > > >  1 file changed, 11 insertions(+), 3 deletions(-)
> > > > 
> > > > diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> > > > index 2de3d9e..871123c 100644
> > > > --- a/include/linux/thermal.h
> > > > +++ b/include/linux/thermal.h
> > > > @@ -328,6 +328,10 @@ thermal_zone_of_sensor_register(struct
> > > > device *dev, int id, void *data, const struct
> > > > thermal_zone_of_device_ops *ops); void
> > > > thermal_zone_of_sensor_unregister(struct device *dev, struct
> > > > thermal_zone_device *tz); +struct thermal_cooling_device *
> > > > +thermal_of_cooling_device_register(struct device_node *np,
> > > > +				   char *type, void *devdata,
> > > > +				   const struct
> > > > thermal_cooling_device_ops *); #else
> > > >  static inline struct thermal_zone_device *
> > > >  thermal_zone_of_sensor_register(struct device *dev, int id, void
> > > > *data, @@ -342,6 +346,13 @@ void
> > > > thermal_zone_of_sensor_unregister(struct device *dev, {
> > > >  }
> > > >  
> > > > +static inline struct thermal_cooling_device *
> > > > +thermal_of_cooling_device_register(struct device_node *np,
> > > > +				   char *type, void *devdata,
> > > > +				   const struct
> > > > thermal_cooling_device_ops *ops) +{
> > > > +	return NULL;
> > > > +}
> > > >  #endif
> > > >  struct thermal_zone_device *thermal_zone_device_register(const
> > > > char *, int, int, void *, struct thermal_zone_device_ops *,
> > > > @@ -357,9 +368,6 @@ void thermal_zone_device_update(struct
> > > > thermal_zone_device *); 
> > > >  struct thermal_cooling_device
> > > > *thermal_cooling_device_register(char *, void *, const struct
> > > > thermal_cooling_device_ops *); -struct thermal_cooling_device *
> > > > -thermal_of_cooling_device_register(struct device_node *np, char
> > > > *, void *,
> > > > -				   const struct
> > > > thermal_cooling_device_ops *); void
> > > > thermal_cooling_device_unregister(struct thermal_cooling_device
> > > > *); struct thermal_zone_device
> > > > *thermal_zone_get_zone_by_name(const char *name); int
> > > > thermal_zone_get_temp(struct thermal_zone_device *tz, unsigned
> > > > long *temp); -- 2.0.0.rc2
> > > > 
> > 
> > 
> 
> 
> 
> -- 
> Best regards,
> 
> Lukasz Majewski
> 
> Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [lm-sensors] [PATCH v2 1/8] thermal: Provide stub for thermal_of_cooling_device_register() funct
@ 2015-01-14 18:32             ` Eduardo Valentin
  0 siblings, 0 replies; 329+ messages in thread
From: Eduardo Valentin @ 2015-01-14 18:32 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, lm-sensors,
	Linux PM list, linux-samsung-soc, devicetree, Lukasz Majewski,
	Kukjin Kim, linux-kernel, Sylwester Nawrocki, Abhilash Kesavan,
	Abhilash Kesavan


[-- Attachment #1.1: Type: text/plain, Size: 4709 bytes --]

On Wed, Jan 14, 2015 at 04:01:06PM +0100, Lukasz Majewski wrote:
> Hi Eduardo,
> 
> > On Fri, Jan 02, 2015 at 02:54:28PM -0400, Eduardo Valentin wrote:
> > > On Mon, Dec 22, 2014 at 05:27:41PM +0100, Lukasz Majewski wrote:
> > > > Odroid U3 fan can work without being registered as OF cooling
> > > > device (with CONFIG_THERMAL_OF disabled).
> > > > In this situation it can be controlled via PWM entry at
> > > > /sys/class/hwmon/hwmon0/pwm1.
> > > > 
> > > > Therefore, the thermal_of_cooling_device_register() function
> > > > needs a stub to allow clean compilation.
> > > > 
> > > > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > > 
> > > Acked-by: Eduardo Valentin <edubezval@gmail.com>
> > 
> > Sorry, too fast,
> > 
> > This is actually
> > Nacked-by: Eduardo Valentin <edubezval@gmail.com>
> > 
> > :-)
> > 
> > I get this error:
> > drivers/thermal/thermal_core.c:1210:1: error: redefinition of
> > ‘thermal_of_cooling_device_register’
> >  thermal_of_cooling_device_register(struct device_node *np,
> >   ^
> >   In file included from drivers/thermal/thermal_core.c:34:0:
> >   include/linux/thermal.h:321:1: note: previous definition of
> >   ‘thermal_of_cooling_device_register’ was here
> >    thermal_of_cooling_device_register(struct device_node *np,
> >     ^
> > 
> > 
> > We provide the function in thermal core even if CONFIG_THERMAL_OF is
> > not set.
> 
> Unfortunately the PWM fan subsystem can work perfectly fine without
> CONFIG_THERMAL.
> 

Now I understand what you are trying to do.

> I think that it would be enough to make something like this in
> the ./include/linux/thermal.h:
> 
> #ifdef CONFIG_THERMAL
Well, I think it should be the opposite here:

#ifndef CONFIG_THERMAL

that is, if no config thermal, then you provide the stub not the other
way around.

> 	static inline struct thermal_cooling_device *
> 		thermal_of_cooling_device_register(struct device_node
> 		*np, char *type, void *devdata,
> 				   const struct
> 		thermal_cooling_device_ops *ops) {
> 		return NULL;
> 	}
> #else
> 	[ already present declaration of
> 	thermal_of_cooling_device_register() ]
> #endif /* CONFIG_THERMAL */


> 
> 
> 
> > > 
> > > > ---
> > > > Changes for v2:
> > > > - None
> > > > ---
> > > >  include/linux/thermal.h | 14 +++++++++++---
> > > >  1 file changed, 11 insertions(+), 3 deletions(-)
> > > > 
> > > > diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> > > > index 2de3d9e..871123c 100644
> > > > --- a/include/linux/thermal.h
> > > > +++ b/include/linux/thermal.h
> > > > @@ -328,6 +328,10 @@ thermal_zone_of_sensor_register(struct
> > > > device *dev, int id, void *data, const struct
> > > > thermal_zone_of_device_ops *ops); void
> > > > thermal_zone_of_sensor_unregister(struct device *dev, struct
> > > > thermal_zone_device *tz); +struct thermal_cooling_device *
> > > > +thermal_of_cooling_device_register(struct device_node *np,
> > > > +				   char *type, void *devdata,
> > > > +				   const struct
> > > > thermal_cooling_device_ops *); #else
> > > >  static inline struct thermal_zone_device *
> > > >  thermal_zone_of_sensor_register(struct device *dev, int id, void
> > > > *data, @@ -342,6 +346,13 @@ void
> > > > thermal_zone_of_sensor_unregister(struct device *dev, {
> > > >  }
> > > >  
> > > > +static inline struct thermal_cooling_device *
> > > > +thermal_of_cooling_device_register(struct device_node *np,
> > > > +				   char *type, void *devdata,
> > > > +				   const struct
> > > > thermal_cooling_device_ops *ops) +{
> > > > +	return NULL;
> > > > +}
> > > >  #endif
> > > >  struct thermal_zone_device *thermal_zone_device_register(const
> > > > char *, int, int, void *, struct thermal_zone_device_ops *,
> > > > @@ -357,9 +368,6 @@ void thermal_zone_device_update(struct
> > > > thermal_zone_device *); 
> > > >  struct thermal_cooling_device
> > > > *thermal_cooling_device_register(char *, void *, const struct
> > > > thermal_cooling_device_ops *); -struct thermal_cooling_device *
> > > > -thermal_of_cooling_device_register(struct device_node *np, char
> > > > *, void *,
> > > > -				   const struct
> > > > thermal_cooling_device_ops *); void
> > > > thermal_cooling_device_unregister(struct thermal_cooling_device
> > > > *); struct thermal_zone_device
> > > > *thermal_zone_get_zone_by_name(const char *name); int
> > > > thermal_zone_get_temp(struct thermal_zone_device *tz, unsigned
> > > > long *temp); -- 2.0.0.rc2
> > > > 
> > 
> > 
> 
> 
> 
> -- 
> Best regards,
> 
> Lukasz Majewski
> 
> Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

[-- Attachment #2: Type: text/plain, Size: 153 bytes --]

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v2 1/8] thermal: Provide stub for thermal_of_cooling_device_register() function
  2015-01-14 18:32             ` [PATCH v2 1/8] thermal: Provide stub for thermal_of_cooling_device_register() function Eduardo Valentin
  (?)
@ 2015-01-15  8:43               ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-01-15  8:43 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, lm-sensors,
	Linux PM list, linux-samsung-soc, devicetree, Lukasz Majewski,
	Kukjin Kim, linux-kernel, Sylwester Nawrocki, Abhilash Kesavan,
	Abhilash Kesavan

Hi Eduardo,

> On Wed, Jan 14, 2015 at 04:01:06PM +0100, Lukasz Majewski wrote:
> > Hi Eduardo,
> > 
> > > On Fri, Jan 02, 2015 at 02:54:28PM -0400, Eduardo Valentin wrote:
> > > > On Mon, Dec 22, 2014 at 05:27:41PM +0100, Lukasz Majewski wrote:
> > > > > Odroid U3 fan can work without being registered as OF cooling
> > > > > device (with CONFIG_THERMAL_OF disabled).
> > > > > In this situation it can be controlled via PWM entry at
> > > > > /sys/class/hwmon/hwmon0/pwm1.
> > > > > 
> > > > > Therefore, the thermal_of_cooling_device_register() function
> > > > > needs a stub to allow clean compilation.
> > > > > 
> > > > > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > > > 
> > > > Acked-by: Eduardo Valentin <edubezval@gmail.com>
> > > 
> > > Sorry, too fast,
> > > 
> > > This is actually
> > > Nacked-by: Eduardo Valentin <edubezval@gmail.com>
> > > 
> > > :-)
> > > 
> > > I get this error:
> > > drivers/thermal/thermal_core.c:1210:1: error: redefinition of
> > > ‘thermal_of_cooling_device_register’
> > >  thermal_of_cooling_device_register(struct device_node *np,
> > >   ^
> > >   In file included from drivers/thermal/thermal_core.c:34:0:
> > >   include/linux/thermal.h:321:1: note: previous definition of
> > >   ‘thermal_of_cooling_device_register’ was here
> > >    thermal_of_cooling_device_register(struct device_node *np,
> > >     ^
> > > 
> > > 
> > > We provide the function in thermal core even if CONFIG_THERMAL_OF
> > > is not set.
> > 
> > Unfortunately the PWM fan subsystem can work perfectly fine without
> > CONFIG_THERMAL.
> > 
> 
> Now I understand what you are trying to do.
> 
> > I think that it would be enough to make something like this in
> > the ./include/linux/thermal.h:
> > 
> > #ifdef CONFIG_THERMAL
> Well, I think it should be the opposite here:
> 
> #ifndef CONFIG_THERMAL
> 
> that is, if no config thermal, then you provide the stub not the other
> way around.

This seems like a better solution :-).

Thanks.

> 
> > 	static inline struct thermal_cooling_device *
> > 		thermal_of_cooling_device_register(struct
> > device_node *np, char *type, void *devdata,
> > 				   const struct
> > 		thermal_cooling_device_ops *ops) {
> > 		return NULL;
> > 	}
> > #else
> > 	[ already present declaration of
> > 	thermal_of_cooling_device_register() ]
> > #endif /* CONFIG_THERMAL */
> 
> 
> > 
> > 
> > 
> > > > 
> > > > > ---
> > > > > Changes for v2:
> > > > > - None
> > > > > ---
> > > > >  include/linux/thermal.h | 14 +++++++++++---
> > > > >  1 file changed, 11 insertions(+), 3 deletions(-)
> > > > > 
> > > > > diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> > > > > index 2de3d9e..871123c 100644
> > > > > --- a/include/linux/thermal.h
> > > > > +++ b/include/linux/thermal.h
> > > > > @@ -328,6 +328,10 @@ thermal_zone_of_sensor_register(struct
> > > > > device *dev, int id, void *data, const struct
> > > > > thermal_zone_of_device_ops *ops); void
> > > > > thermal_zone_of_sensor_unregister(struct device *dev, struct
> > > > > thermal_zone_device *tz); +struct thermal_cooling_device *
> > > > > +thermal_of_cooling_device_register(struct device_node *np,
> > > > > +				   char *type, void *devdata,
> > > > > +				   const struct
> > > > > thermal_cooling_device_ops *); #else
> > > > >  static inline struct thermal_zone_device *
> > > > >  thermal_zone_of_sensor_register(struct device *dev, int id,
> > > > > void *data, @@ -342,6 +346,13 @@ void
> > > > > thermal_zone_of_sensor_unregister(struct device *dev, {
> > > > >  }
> > > > >  
> > > > > +static inline struct thermal_cooling_device *
> > > > > +thermal_of_cooling_device_register(struct device_node *np,
> > > > > +				   char *type, void *devdata,
> > > > > +				   const struct
> > > > > thermal_cooling_device_ops *ops) +{
> > > > > +	return NULL;
> > > > > +}
> > > > >  #endif
> > > > >  struct thermal_zone_device
> > > > > *thermal_zone_device_register(const char *, int, int, void *,
> > > > > struct thermal_zone_device_ops *, @@ -357,9 +368,6 @@ void
> > > > > thermal_zone_device_update(struct thermal_zone_device *); 
> > > > >  struct thermal_cooling_device
> > > > > *thermal_cooling_device_register(char *, void *, const struct
> > > > > thermal_cooling_device_ops *); -struct thermal_cooling_device
> > > > > * -thermal_of_cooling_device_register(struct device_node *np,
> > > > > char *, void *,
> > > > > -				   const struct
> > > > > thermal_cooling_device_ops *); void
> > > > > thermal_cooling_device_unregister(struct
> > > > > thermal_cooling_device *); struct thermal_zone_device
> > > > > *thermal_zone_get_zone_by_name(const char *name); int
> > > > > thermal_zone_get_temp(struct thermal_zone_device *tz, unsigned
> > > > > long *temp); -- 2.0.0.rc2
> > > > > 
> > > 
> > > 
> > 
> > 
> > 
> > -- 
> > Best regards,
> > 
> > Lukasz Majewski
> > 
> > Samsung R&D Institute Poland (SRPOL) | Linux Platform Group



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v2 1/8] thermal: Provide stub for thermal_of_cooling_device_register() function
@ 2015-01-15  8:43               ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-01-15  8:43 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, lm-sensors,
	Linux PM list, linux-samsung-soc, devicetree, Lukasz Majewski,
	Kukjin Kim, linux-kernel, Sylwester Nawrocki, Abhilash Kesavan,
	Abhilash Kesavan

Hi Eduardo,

> On Wed, Jan 14, 2015 at 04:01:06PM +0100, Lukasz Majewski wrote:
> > Hi Eduardo,
> > 
> > > On Fri, Jan 02, 2015 at 02:54:28PM -0400, Eduardo Valentin wrote:
> > > > On Mon, Dec 22, 2014 at 05:27:41PM +0100, Lukasz Majewski wrote:
> > > > > Odroid U3 fan can work without being registered as OF cooling
> > > > > device (with CONFIG_THERMAL_OF disabled).
> > > > > In this situation it can be controlled via PWM entry at
> > > > > /sys/class/hwmon/hwmon0/pwm1.
> > > > > 
> > > > > Therefore, the thermal_of_cooling_device_register() function
> > > > > needs a stub to allow clean compilation.
> > > > > 
> > > > > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > > > 
> > > > Acked-by: Eduardo Valentin <edubezval@gmail.com>
> > > 
> > > Sorry, too fast,
> > > 
> > > This is actually
> > > Nacked-by: Eduardo Valentin <edubezval@gmail.com>
> > > 
> > > :-)
> > > 
> > > I get this error:
> > > drivers/thermal/thermal_core.c:1210:1: error: redefinition of
> > > ‘thermal_of_cooling_device_register’
> > >  thermal_of_cooling_device_register(struct device_node *np,
> > >   ^
> > >   In file included from drivers/thermal/thermal_core.c:34:0:
> > >   include/linux/thermal.h:321:1: note: previous definition of
> > >   ‘thermal_of_cooling_device_register’ was here
> > >    thermal_of_cooling_device_register(struct device_node *np,
> > >     ^
> > > 
> > > 
> > > We provide the function in thermal core even if CONFIG_THERMAL_OF
> > > is not set.
> > 
> > Unfortunately the PWM fan subsystem can work perfectly fine without
> > CONFIG_THERMAL.
> > 
> 
> Now I understand what you are trying to do.
> 
> > I think that it would be enough to make something like this in
> > the ./include/linux/thermal.h:
> > 
> > #ifdef CONFIG_THERMAL
> Well, I think it should be the opposite here:
> 
> #ifndef CONFIG_THERMAL
> 
> that is, if no config thermal, then you provide the stub not the other
> way around.

This seems like a better solution :-).

Thanks.

> 
> > 	static inline struct thermal_cooling_device *
> > 		thermal_of_cooling_device_register(struct
> > device_node *np, char *type, void *devdata,
> > 				   const struct
> > 		thermal_cooling_device_ops *ops) {
> > 		return NULL;
> > 	}
> > #else
> > 	[ already present declaration of
> > 	thermal_of_cooling_device_register() ]
> > #endif /* CONFIG_THERMAL */
> 
> 
> > 
> > 
> > 
> > > > 
> > > > > ---
> > > > > Changes for v2:
> > > > > - None
> > > > > ---
> > > > >  include/linux/thermal.h | 14 +++++++++++---
> > > > >  1 file changed, 11 insertions(+), 3 deletions(-)
> > > > > 
> > > > > diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> > > > > index 2de3d9e..871123c 100644
> > > > > --- a/include/linux/thermal.h
> > > > > +++ b/include/linux/thermal.h
> > > > > @@ -328,6 +328,10 @@ thermal_zone_of_sensor_register(struct
> > > > > device *dev, int id, void *data, const struct
> > > > > thermal_zone_of_device_ops *ops); void
> > > > > thermal_zone_of_sensor_unregister(struct device *dev, struct
> > > > > thermal_zone_device *tz); +struct thermal_cooling_device *
> > > > > +thermal_of_cooling_device_register(struct device_node *np,
> > > > > +				   char *type, void *devdata,
> > > > > +				   const struct
> > > > > thermal_cooling_device_ops *); #else
> > > > >  static inline struct thermal_zone_device *
> > > > >  thermal_zone_of_sensor_register(struct device *dev, int id,
> > > > > void *data, @@ -342,6 +346,13 @@ void
> > > > > thermal_zone_of_sensor_unregister(struct device *dev, {
> > > > >  }
> > > > >  
> > > > > +static inline struct thermal_cooling_device *
> > > > > +thermal_of_cooling_device_register(struct device_node *np,
> > > > > +				   char *type, void *devdata,
> > > > > +				   const struct
> > > > > thermal_cooling_device_ops *ops) +{
> > > > > +	return NULL;
> > > > > +}
> > > > >  #endif
> > > > >  struct thermal_zone_device
> > > > > *thermal_zone_device_register(const char *, int, int, void *,
> > > > > struct thermal_zone_device_ops *, @@ -357,9 +368,6 @@ void
> > > > > thermal_zone_device_update(struct thermal_zone_device *); 
> > > > >  struct thermal_cooling_device
> > > > > *thermal_cooling_device_register(char *, void *, const struct
> > > > > thermal_cooling_device_ops *); -struct thermal_cooling_device
> > > > > * -thermal_of_cooling_device_register(struct device_node *np,
> > > > > char *, void *,
> > > > > -				   const struct
> > > > > thermal_cooling_device_ops *); void
> > > > > thermal_cooling_device_unregister(struct
> > > > > thermal_cooling_device *); struct thermal_zone_device
> > > > > *thermal_zone_get_zone_by_name(const char *name); int
> > > > > thermal_zone_get_temp(struct thermal_zone_device *tz, unsigned
> > > > > long *temp); -- 2.0.0.rc2
> > > > > 
> > > 
> > > 
> > 
> > 
> > 
> > -- 
> > Best regards,
> > 
> > Lukasz Majewski
> > 
> > Samsung R&D Institute Poland (SRPOL) | Linux Platform Group



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [lm-sensors] [PATCH v2 1/8] thermal: Provide stub for thermal_of_cooling_device_register() funct
@ 2015-01-15  8:43               ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-01-15  8:43 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, lm-sensors,
	Linux PM list, linux-samsung-soc, devicetree, Lukasz Majewski,
	Kukjin Kim, linux-kernel, Sylwester Nawrocki, Abhilash Kesavan,
	Abhilash Kesavan

SGkgRWR1YXJkbywKCj4gT24gV2VkLCBKYW4gMTQsIDIwMTUgYXQgMDQ6MDE6MDZQTSArMDEwMCwg
THVrYXN6IE1hamV3c2tpIHdyb3RlOgo+ID4gSGkgRWR1YXJkbywKPiA+IAo+ID4gPiBPbiBGcmks
IEphbiAwMiwgMjAxNSBhdCAwMjo1NDoyOFBNIC0wNDAwLCBFZHVhcmRvIFZhbGVudGluIHdyb3Rl
Ogo+ID4gPiA+IE9uIE1vbiwgRGVjIDIyLCAyMDE0IGF0IDA1OjI3OjQxUE0gKzAxMDAsIEx1a2Fz
eiBNYWpld3NraSB3cm90ZToKPiA+ID4gPiA+IE9kcm9pZCBVMyBmYW4gY2FuIHdvcmsgd2l0aG91
dCBiZWluZyByZWdpc3RlcmVkIGFzIE9GIGNvb2xpbmcKPiA+ID4gPiA+IGRldmljZSAod2l0aCBD
T05GSUdfVEhFUk1BTF9PRiBkaXNhYmxlZCkuCj4gPiA+ID4gPiBJbiB0aGlzIHNpdHVhdGlvbiBp
dCBjYW4gYmUgY29udHJvbGxlZCB2aWEgUFdNIGVudHJ5IGF0Cj4gPiA+ID4gPiAvc3lzL2NsYXNz
L2h3bW9uL2h3bW9uMC9wd20xLgo+ID4gPiA+ID4gCj4gPiA+ID4gPiBUaGVyZWZvcmUsIHRoZSB0
aGVybWFsX29mX2Nvb2xpbmdfZGV2aWNlX3JlZ2lzdGVyKCkgZnVuY3Rpb24KPiA+ID4gPiA+IG5l
ZWRzIGEgc3R1YiB0byBhbGxvdyBjbGVhbiBjb21waWxhdGlvbi4KPiA+ID4gPiA+IAo+ID4gPiA+
ID4gU2lnbmVkLW9mZi1ieTogTHVrYXN6IE1hamV3c2tpIDxsLm1hamV3c2tpQHNhbXN1bmcuY29t
Pgo+ID4gPiA+IAo+ID4gPiA+IEFja2VkLWJ5OiBFZHVhcmRvIFZhbGVudGluIDxlZHViZXp2YWxA
Z21haWwuY29tPgo+ID4gPiAKPiA+ID4gU29ycnksIHRvbyBmYXN0LAo+ID4gPiAKPiA+ID4gVGhp
cyBpcyBhY3R1YWxseQo+ID4gPiBOYWNrZWQtYnk6IEVkdWFyZG8gVmFsZW50aW4gPGVkdWJlenZh
bEBnbWFpbC5jb20+Cj4gPiA+IAo+ID4gPiA6LSkKPiA+ID4gCj4gPiA+IEkgZ2V0IHRoaXMgZXJy
b3I6Cj4gPiA+IGRyaXZlcnMvdGhlcm1hbC90aGVybWFsX2NvcmUuYzoxMjEwOjE6IGVycm9yOiBy
ZWRlZmluaXRpb24gb2YKPiA+ID4g4oCYdGhlcm1hbF9vZl9jb29saW5nX2RldmljZV9yZWdpc3Rl
cuKAmQo+ID4gPiAgdGhlcm1hbF9vZl9jb29saW5nX2RldmljZV9yZWdpc3RlcihzdHJ1Y3QgZGV2
aWNlX25vZGUgKm5wLAo+ID4gPiAgIF4KPiA+ID4gICBJbiBmaWxlIGluY2x1ZGVkIGZyb20gZHJp
dmVycy90aGVybWFsL3RoZXJtYWxfY29yZS5jOjM0OjA6Cj4gPiA+ICAgaW5jbHVkZS9saW51eC90
aGVybWFsLmg6MzIxOjE6IG5vdGU6IHByZXZpb3VzIGRlZmluaXRpb24gb2YKPiA+ID4gICDigJh0
aGVybWFsX29mX2Nvb2xpbmdfZGV2aWNlX3JlZ2lzdGVy4oCZIHdhcyBoZXJlCj4gPiA+ICAgIHRo
ZXJtYWxfb2ZfY29vbGluZ19kZXZpY2VfcmVnaXN0ZXIoc3RydWN0IGRldmljZV9ub2RlICpucCwK
PiA+ID4gICAgIF4KPiA+ID4gCj4gPiA+IAo+ID4gPiBXZSBwcm92aWRlIHRoZSBmdW5jdGlvbiBp
biB0aGVybWFsIGNvcmUgZXZlbiBpZiBDT05GSUdfVEhFUk1BTF9PRgo+ID4gPiBpcyBub3Qgc2V0
Lgo+ID4gCj4gPiBVbmZvcnR1bmF0ZWx5IHRoZSBQV00gZmFuIHN1YnN5c3RlbSBjYW4gd29yayBw
ZXJmZWN0bHkgZmluZSB3aXRob3V0Cj4gPiBDT05GSUdfVEhFUk1BTC4KPiA+IAo+IAo+IE5vdyBJ
IHVuZGVyc3RhbmQgd2hhdCB5b3UgYXJlIHRyeWluZyB0byBkby4KPiAKPiA+IEkgdGhpbmsgdGhh
dCBpdCB3b3VsZCBiZSBlbm91Z2ggdG8gbWFrZSBzb21ldGhpbmcgbGlrZSB0aGlzIGluCj4gPiB0
aGUgLi9pbmNsdWRlL2xpbnV4L3RoZXJtYWwuaDoKPiA+IAo+ID4gI2lmZGVmIENPTkZJR19USEVS
TUFMCj4gV2VsbCwgSSB0aGluayBpdCBzaG91bGQgYmUgdGhlIG9wcG9zaXRlIGhlcmU6Cj4gCj4g
I2lmbmRlZiBDT05GSUdfVEhFUk1BTAo+IAo+IHRoYXQgaXMsIGlmIG5vIGNvbmZpZyB0aGVybWFs
LCB0aGVuIHlvdSBwcm92aWRlIHRoZSBzdHViIG5vdCB0aGUgb3RoZXIKPiB3YXkgYXJvdW5kLgoK
VGhpcyBzZWVtcyBsaWtlIGEgYmV0dGVyIHNvbHV0aW9uIDotKS4KClRoYW5rcy4KCj4gCj4gPiAJ
c3RhdGljIGlubGluZSBzdHJ1Y3QgdGhlcm1hbF9jb29saW5nX2RldmljZSAqCj4gPiAJCXRoZXJt
YWxfb2ZfY29vbGluZ19kZXZpY2VfcmVnaXN0ZXIoc3RydWN0Cj4gPiBkZXZpY2Vfbm9kZSAqbnAs
IGNoYXIgKnR5cGUsIHZvaWQgKmRldmRhdGEsCj4gPiAJCQkJICAgY29uc3Qgc3RydWN0Cj4gPiAJ
CXRoZXJtYWxfY29vbGluZ19kZXZpY2Vfb3BzICpvcHMpIHsKPiA+IAkJcmV0dXJuIE5VTEw7Cj4g
PiAJfQo+ID4gI2Vsc2UKPiA+IAlbIGFscmVhZHkgcHJlc2VudCBkZWNsYXJhdGlvbiBvZgo+ID4g
CXRoZXJtYWxfb2ZfY29vbGluZ19kZXZpY2VfcmVnaXN0ZXIoKSBdCj4gPiAjZW5kaWYgLyogQ09O
RklHX1RIRVJNQUwgKi8KPiAKPiAKPiA+IAo+ID4gCj4gPiAKPiA+ID4gPiAKPiA+ID4gPiA+IC0t
LQo+ID4gPiA+ID4gQ2hhbmdlcyBmb3IgdjI6Cj4gPiA+ID4gPiAtIE5vbmUKPiA+ID4gPiA+IC0t
LQo+ID4gPiA+ID4gIGluY2x1ZGUvbGludXgvdGhlcm1hbC5oIHwgMTQgKysrKysrKysrKystLS0K
PiA+ID4gPiA+ICAxIGZpbGUgY2hhbmdlZCwgMTEgaW5zZXJ0aW9ucygrKSwgMyBkZWxldGlvbnMo
LSkKPiA+ID4gPiA+IAo+ID4gPiA+ID4gZGlmZiAtLWdpdCBhL2luY2x1ZGUvbGludXgvdGhlcm1h
bC5oIGIvaW5jbHVkZS9saW51eC90aGVybWFsLmgKPiA+ID4gPiA+IGluZGV4IDJkZTNkOWUuLjg3
MTEyM2MgMTAwNjQ0Cj4gPiA+ID4gPiAtLS0gYS9pbmNsdWRlL2xpbnV4L3RoZXJtYWwuaAo+ID4g
PiA+ID4gKysrIGIvaW5jbHVkZS9saW51eC90aGVybWFsLmgKPiA+ID4gPiA+IEBAIC0zMjgsNiAr
MzI4LDEwIEBAIHRoZXJtYWxfem9uZV9vZl9zZW5zb3JfcmVnaXN0ZXIoc3RydWN0Cj4gPiA+ID4g
PiBkZXZpY2UgKmRldiwgaW50IGlkLCB2b2lkICpkYXRhLCBjb25zdCBzdHJ1Y3QKPiA+ID4gPiA+
IHRoZXJtYWxfem9uZV9vZl9kZXZpY2Vfb3BzICpvcHMpOyB2b2lkCj4gPiA+ID4gPiB0aGVybWFs
X3pvbmVfb2Zfc2Vuc29yX3VucmVnaXN0ZXIoc3RydWN0IGRldmljZSAqZGV2LCBzdHJ1Y3QKPiA+
ID4gPiA+IHRoZXJtYWxfem9uZV9kZXZpY2UgKnR6KTsgK3N0cnVjdCB0aGVybWFsX2Nvb2xpbmdf
ZGV2aWNlICoKPiA+ID4gPiA+ICt0aGVybWFsX29mX2Nvb2xpbmdfZGV2aWNlX3JlZ2lzdGVyKHN0
cnVjdCBkZXZpY2Vfbm9kZSAqbnAsCj4gPiA+ID4gPiArCQkJCSAgIGNoYXIgKnR5cGUsIHZvaWQg
KmRldmRhdGEsCj4gPiA+ID4gPiArCQkJCSAgIGNvbnN0IHN0cnVjdAo+ID4gPiA+ID4gdGhlcm1h
bF9jb29saW5nX2RldmljZV9vcHMgKik7ICNlbHNlCj4gPiA+ID4gPiAgc3RhdGljIGlubGluZSBz
dHJ1Y3QgdGhlcm1hbF96b25lX2RldmljZSAqCj4gPiA+ID4gPiAgdGhlcm1hbF96b25lX29mX3Nl
bnNvcl9yZWdpc3RlcihzdHJ1Y3QgZGV2aWNlICpkZXYsIGludCBpZCwKPiA+ID4gPiA+IHZvaWQg
KmRhdGEsIEBAIC0zNDIsNiArMzQ2LDEzIEBAIHZvaWQKPiA+ID4gPiA+IHRoZXJtYWxfem9uZV9v
Zl9zZW5zb3JfdW5yZWdpc3RlcihzdHJ1Y3QgZGV2aWNlICpkZXYsIHsKPiA+ID4gPiA+ICB9Cj4g
PiA+ID4gPiAgCj4gPiA+ID4gPiArc3RhdGljIGlubGluZSBzdHJ1Y3QgdGhlcm1hbF9jb29saW5n
X2RldmljZSAqCj4gPiA+ID4gPiArdGhlcm1hbF9vZl9jb29saW5nX2RldmljZV9yZWdpc3Rlcihz
dHJ1Y3QgZGV2aWNlX25vZGUgKm5wLAo+ID4gPiA+ID4gKwkJCQkgICBjaGFyICp0eXBlLCB2b2lk
ICpkZXZkYXRhLAo+ID4gPiA+ID4gKwkJCQkgICBjb25zdCBzdHJ1Y3QKPiA+ID4gPiA+IHRoZXJt
YWxfY29vbGluZ19kZXZpY2Vfb3BzICpvcHMpICt7Cj4gPiA+ID4gPiArCXJldHVybiBOVUxMOwo+
ID4gPiA+ID4gK30KPiA+ID4gPiA+ICAjZW5kaWYKPiA+ID4gPiA+ICBzdHJ1Y3QgdGhlcm1hbF96
b25lX2RldmljZQo+ID4gPiA+ID4gKnRoZXJtYWxfem9uZV9kZXZpY2VfcmVnaXN0ZXIoY29uc3Qg
Y2hhciAqLCBpbnQsIGludCwgdm9pZCAqLAo+ID4gPiA+ID4gc3RydWN0IHRoZXJtYWxfem9uZV9k
ZXZpY2Vfb3BzICosIEBAIC0zNTcsOSArMzY4LDYgQEAgdm9pZAo+ID4gPiA+ID4gdGhlcm1hbF96
b25lX2RldmljZV91cGRhdGUoc3RydWN0IHRoZXJtYWxfem9uZV9kZXZpY2UgKik7IAo+ID4gPiA+
ID4gIHN0cnVjdCB0aGVybWFsX2Nvb2xpbmdfZGV2aWNlCj4gPiA+ID4gPiAqdGhlcm1hbF9jb29s
aW5nX2RldmljZV9yZWdpc3RlcihjaGFyICosIHZvaWQgKiwgY29uc3Qgc3RydWN0Cj4gPiA+ID4g
PiB0aGVybWFsX2Nvb2xpbmdfZGV2aWNlX29wcyAqKTsgLXN0cnVjdCB0aGVybWFsX2Nvb2xpbmdf
ZGV2aWNlCj4gPiA+ID4gPiAqIC10aGVybWFsX29mX2Nvb2xpbmdfZGV2aWNlX3JlZ2lzdGVyKHN0
cnVjdCBkZXZpY2Vfbm9kZSAqbnAsCj4gPiA+ID4gPiBjaGFyICosIHZvaWQgKiwKPiA+ID4gPiA+
IC0JCQkJICAgY29uc3Qgc3RydWN0Cj4gPiA+ID4gPiB0aGVybWFsX2Nvb2xpbmdfZGV2aWNlX29w
cyAqKTsgdm9pZAo+ID4gPiA+ID4gdGhlcm1hbF9jb29saW5nX2RldmljZV91bnJlZ2lzdGVyKHN0
cnVjdAo+ID4gPiA+ID4gdGhlcm1hbF9jb29saW5nX2RldmljZSAqKTsgc3RydWN0IHRoZXJtYWxf
em9uZV9kZXZpY2UKPiA+ID4gPiA+ICp0aGVybWFsX3pvbmVfZ2V0X3pvbmVfYnlfbmFtZShjb25z
dCBjaGFyICpuYW1lKTsgaW50Cj4gPiA+ID4gPiB0aGVybWFsX3pvbmVfZ2V0X3RlbXAoc3RydWN0
IHRoZXJtYWxfem9uZV9kZXZpY2UgKnR6LCB1bnNpZ25lZAo+ID4gPiA+ID4gbG9uZyAqdGVtcCk7
IC0tIDIuMC4wLnJjMgo+ID4gPiA+ID4gCj4gPiA+IAo+ID4gPiAKPiA+IAo+ID4gCj4gPiAKPiA+
IC0tIAo+ID4gQmVzdCByZWdhcmRzLAo+ID4gCj4gPiBMdWthc3ogTWFqZXdza2kKPiA+IAo+ID4g
U2Ftc3VuZyBSJkQgSW5zdGl0dXRlIFBvbGFuZCAoU1JQT0wpIHwgTGludXggUGxhdGZvcm0gR3Jv
dXAKCgoKLS0gCkJlc3QgcmVnYXJkcywKCkx1a2FzeiBNYWpld3NraQoKU2Ftc3VuZyBSJkQgSW5z
dGl0dXRlIFBvbGFuZCAoU1JQT0wpIHwgTGludXggUGxhdGZvcm0gR3JvdXAKCl9fX19fX19fX19f
X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fCmxtLXNlbnNvcnMgbWFpbGluZyBs
aXN0CmxtLXNlbnNvcnNAbG0tc2Vuc29ycy5vcmcKaHR0cDovL2xpc3RzLmxtLXNlbnNvcnMub3Jn
L21haWxtYW4vbGlzdGluZm8vbG0tc2Vuc29ycw=

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH 2/9] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling device
  2015-01-14 13:56               ` [PATCH 2/9] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling device Lukasz Majewski
  (?)
@ 2015-01-15  8:57                 ` Sjoerd Simons
  -1 siblings, 0 replies; 329+ messages in thread
From: Sjoerd Simons @ 2015-01-15  8:57 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Guenter Roeck, Eduardo Valentin, Kamil Debski, Jean Delvare,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki

[-- Attachment #1: Type: text/plain, Size: 509 bytes --]

On Wed, 2015-01-14 at 14:56 +0100, Lukasz Majewski wrote:
> Hi Sjoerd,

> Could you review v2 of this patch series?
> 
> http://www.spinics.net/lists/devicetree/msg63159.html

I skimmed it yesterday, I'll try to find some time to send you my review
comments later in the week/start of next. 

Do you happen to have a git branch with these patches in? That would
make it convenient for me to give your patches a spin on my XU3 

-- 
Sjoerd Simons <sjoerd.simons@collabora.co.uk>
Collabora Ltd.

[-- Attachment #2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 6170 bytes --]

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH 2/9] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling device
@ 2015-01-15  8:57                 ` Sjoerd Simons
  0 siblings, 0 replies; 329+ messages in thread
From: Sjoerd Simons @ 2015-01-15  8:57 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Guenter Roeck, Eduardo Valentin, Kamil Debski, Jean Delvare,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki

[-- Attachment #1: Type: text/plain, Size: 509 bytes --]

On Wed, 2015-01-14 at 14:56 +0100, Lukasz Majewski wrote:
> Hi Sjoerd,

> Could you review v2 of this patch series?
> 
> http://www.spinics.net/lists/devicetree/msg63159.html

I skimmed it yesterday, I'll try to find some time to send you my review
comments later in the week/start of next. 

Do you happen to have a git branch with these patches in? That would
make it convenient for me to give your patches a spin on my XU3 

-- 
Sjoerd Simons <sjoerd.simons@collabora.co.uk>
Collabora Ltd.

[-- Attachment #2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 6170 bytes --]

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [lm-sensors] [PATCH 2/9] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling
@ 2015-01-15  8:57                 ` Sjoerd Simons
  0 siblings, 0 replies; 329+ messages in thread
From: Sjoerd Simons @ 2015-01-15  8:57 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Guenter Roeck, Eduardo Valentin, Kamil Debski, Jean Delvare,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sylwester Nawrocki


[-- Attachment #1.1: Type: text/plain, Size: 509 bytes --]

On Wed, 2015-01-14 at 14:56 +0100, Lukasz Majewski wrote:
> Hi Sjoerd,

> Could you review v2 of this patch series?
> 
> http://www.spinics.net/lists/devicetree/msg63159.html

I skimmed it yesterday, I'll try to find some time to send you my review
comments later in the week/start of next. 

Do you happen to have a git branch with these patches in? That would
make it convenient for me to give your patches a spin on my XU3 

-- 
Sjoerd Simons <sjoerd.simons@collabora.co.uk>
Collabora Ltd.

[-- Attachment #1.2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 6170 bytes --]

[-- Attachment #2: Type: text/plain, Size: 153 bytes --]

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 329+ messages in thread

* [PATCH v3 0/8] hwmon: thermal: Odroid U3: Provide support for Odroid U3 fan
@ 2015-02-06 16:59   ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-06 16:59 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

Presented patches add support for Odroid's U3 optional CPU FAN, which uses PWM
subsystem for low level control.

After successful probe it registers itself as a cooling device for thermal
subsystem. To preserve the ability to use this fan as a PWM device stubs for
thermal_of_cooling_device_register() and thermal_cdev_update() have been added.

Additionally, devices without support for DTS are still supported.

To provide correct functionality, new properties to device tree description for 
Exynos4412 and in particular Odroid U3 have been added.

Those patches were tested on Exynos4412 - Odroid U3 board.

Patches were applied on:
linux-soc-thermal/next branch (Linux 3.19-rc5)
SHA1: 252454f5cbda2c6b40c5d36f58cac2938437b85d

Kamil Debski (1):
  ARM: dts: Add pwm-fan node to the Odroid-U3 board

Lukasz Majewski (7):
  thermal: Provide stub for thermal_of_cooling_device_register()
    function
  thermal: Provide stub for thermal_cdev_update() function
  Documentation: dts: Documentation entry to explain how to use PWM FAN
    as a cooling device
  ARM: dts: Add properties to use pwm-fan device as a cooling device in
    Odroid U3
  hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty
    cycle
  hwmon: pwm-fan: Read PWM FAN configuration from device tree
  hwmon: pwm-fan: Code for using PWM FAN as a cooling device

 .../devicetree/bindings/hwmon/pwm-fan.txt          |  20 +++
 arch/arm/boot/dts/exynos4.dtsi                     |   2 +-
 arch/arm/boot/dts/exynos4412-odroidu3.dts          |  44 ++++++
 drivers/hwmon/pwm-fan.c                            | 171 +++++++++++++++++++--
 include/linux/thermal.h                            |  22 ++-
 5 files changed, 239 insertions(+), 20 deletions(-)

-- 
2.0.0.rc2


^ permalink raw reply	[flat|nested] 329+ messages in thread

* [PATCH v3 0/8] hwmon: thermal: Odroid U3: Provide support for Odroid U3 fan
@ 2015-02-06 16:59   ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-06 16:59 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors-GZX6beZjE8VD60Wz+7aTrA, Linux PM list,
	linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Lukasz Majewski, Kukjin Kim,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

Presented patches add support for Odroid's U3 optional CPU FAN, which uses PWM
subsystem for low level control.

After successful probe it registers itself as a cooling device for thermal
subsystem. To preserve the ability to use this fan as a PWM device stubs for
thermal_of_cooling_device_register() and thermal_cdev_update() have been added.

Additionally, devices without support for DTS are still supported.

To provide correct functionality, new properties to device tree description for 
Exynos4412 and in particular Odroid U3 have been added.

Those patches were tested on Exynos4412 - Odroid U3 board.

Patches were applied on:
linux-soc-thermal/next branch (Linux 3.19-rc5)
SHA1: 252454f5cbda2c6b40c5d36f58cac2938437b85d

Kamil Debski (1):
  ARM: dts: Add pwm-fan node to the Odroid-U3 board

Lukasz Majewski (7):
  thermal: Provide stub for thermal_of_cooling_device_register()
    function
  thermal: Provide stub for thermal_cdev_update() function
  Documentation: dts: Documentation entry to explain how to use PWM FAN
    as a cooling device
  ARM: dts: Add properties to use pwm-fan device as a cooling device in
    Odroid U3
  hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty
    cycle
  hwmon: pwm-fan: Read PWM FAN configuration from device tree
  hwmon: pwm-fan: Code for using PWM FAN as a cooling device

 .../devicetree/bindings/hwmon/pwm-fan.txt          |  20 +++
 arch/arm/boot/dts/exynos4.dtsi                     |   2 +-
 arch/arm/boot/dts/exynos4412-odroidu3.dts          |  44 ++++++
 drivers/hwmon/pwm-fan.c                            | 171 +++++++++++++++++++--
 include/linux/thermal.h                            |  22 ++-
 5 files changed, 239 insertions(+), 20 deletions(-)

-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 329+ messages in thread

* [lm-sensors] [PATCH v3 0/8] hwmon: thermal: Odroid U3: Provide support for Odroid U3 fan
@ 2015-02-06 16:59   ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-06 16:59 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

Presented patches add support for Odroid's U3 optional CPU FAN, which uses PWM
subsystem for low level control.

After successful probe it registers itself as a cooling device for thermal
subsystem. To preserve the ability to use this fan as a PWM device stubs for
thermal_of_cooling_device_register() and thermal_cdev_update() have been added.

Additionally, devices without support for DTS are still supported.

To provide correct functionality, new properties to device tree description for 
Exynos4412 and in particular Odroid U3 have been added.

Those patches were tested on Exynos4412 - Odroid U3 board.

Patches were applied on:
linux-soc-thermal/next branch (Linux 3.19-rc5)
SHA1: 252454f5cbda2c6b40c5d36f58cac2938437b85d

Kamil Debski (1):
  ARM: dts: Add pwm-fan node to the Odroid-U3 board

Lukasz Majewski (7):
  thermal: Provide stub for thermal_of_cooling_device_register()
    function
  thermal: Provide stub for thermal_cdev_update() function
  Documentation: dts: Documentation entry to explain how to use PWM FAN
    as a cooling device
  ARM: dts: Add properties to use pwm-fan device as a cooling device in
    Odroid U3
  hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty
    cycle
  hwmon: pwm-fan: Read PWM FAN configuration from device tree
  hwmon: pwm-fan: Code for using PWM FAN as a cooling device

 .../devicetree/bindings/hwmon/pwm-fan.txt          |  20 +++
 arch/arm/boot/dts/exynos4.dtsi                     |   2 +-
 arch/arm/boot/dts/exynos4412-odroidu3.dts          |  44 ++++++
 drivers/hwmon/pwm-fan.c                            | 171 +++++++++++++++++++--
 include/linux/thermal.h                            |  22 ++-
 5 files changed, 239 insertions(+), 20 deletions(-)

-- 
2.0.0.rc2


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 329+ messages in thread

* [PATCH v3 1/8] thermal: Provide stub for thermal_of_cooling_device_register() function
  2015-02-06 16:59   ` Lukasz Majewski
  (?)
@ 2015-02-06 16:59     ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-06 16:59 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

Odroid U3 fan can work without being registered as OF cooling device
(with CONFIG_THERMAL_OF disabled).
In this situation it can be controlled via PWM entry at
/sys/class/hwmon/hwmon0/pwm1.

Therefore, the thermal_of_cooling_device_register() function needs a stub
to allow clean compilation.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- Provide stub declaration when CONFIG_THERMAL is not set
---
 include/linux/thermal.h | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index fc52e30..eacf2de 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -293,6 +293,20 @@ struct thermal_trip {
 };
 
 /* Function declarations */
+#ifdef CONFIG_THERMAL
+struct thermal_cooling_device *
+thermal_of_cooling_device_register(struct device_node *np,
+				   char *type, void *devdata,
+				   const struct thermal_cooling_device_ops *);
+#else
+static inline struct thermal_cooling_device *
+thermal_of_cooling_device_register(struct device_node *np,
+				   char *type, void *devdata,
+				   const struct thermal_cooling_device_ops *ops)
+{
+	return NULL;
+}
+#endif
 #ifdef CONFIG_THERMAL_OF
 struct thermal_zone_device *
 thermal_zone_of_sensor_register(struct device *dev, int id, void *data,
@@ -328,9 +342,6 @@ void thermal_zone_device_update(struct thermal_zone_device *);
 
 struct thermal_cooling_device *thermal_cooling_device_register(char *, void *,
 		const struct thermal_cooling_device_ops *);
-struct thermal_cooling_device *
-thermal_of_cooling_device_register(struct device_node *np, char *, void *,
-				   const struct thermal_cooling_device_ops *);
 void thermal_cooling_device_unregister(struct thermal_cooling_device *);
 struct thermal_zone_device *thermal_zone_get_zone_by_name(const char *name);
 int thermal_zone_get_temp(struct thermal_zone_device *tz, unsigned long *temp);
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v3 1/8] thermal: Provide stub for thermal_of_cooling_device_register() function
@ 2015-02-06 16:59     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-06 16:59 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

Odroid U3 fan can work without being registered as OF cooling device
(with CONFIG_THERMAL_OF disabled).
In this situation it can be controlled via PWM entry at
/sys/class/hwmon/hwmon0/pwm1.

Therefore, the thermal_of_cooling_device_register() function needs a stub
to allow clean compilation.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- Provide stub declaration when CONFIG_THERMAL is not set
---
 include/linux/thermal.h | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index fc52e30..eacf2de 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -293,6 +293,20 @@ struct thermal_trip {
 };
 
 /* Function declarations */
+#ifdef CONFIG_THERMAL
+struct thermal_cooling_device *
+thermal_of_cooling_device_register(struct device_node *np,
+				   char *type, void *devdata,
+				   const struct thermal_cooling_device_ops *);
+#else
+static inline struct thermal_cooling_device *
+thermal_of_cooling_device_register(struct device_node *np,
+				   char *type, void *devdata,
+				   const struct thermal_cooling_device_ops *ops)
+{
+	return NULL;
+}
+#endif
 #ifdef CONFIG_THERMAL_OF
 struct thermal_zone_device *
 thermal_zone_of_sensor_register(struct device *dev, int id, void *data,
@@ -328,9 +342,6 @@ void thermal_zone_device_update(struct thermal_zone_device *);
 
 struct thermal_cooling_device *thermal_cooling_device_register(char *, void *,
 		const struct thermal_cooling_device_ops *);
-struct thermal_cooling_device *
-thermal_of_cooling_device_register(struct device_node *np, char *, void *,
-				   const struct thermal_cooling_device_ops *);
 void thermal_cooling_device_unregister(struct thermal_cooling_device *);
 struct thermal_zone_device *thermal_zone_get_zone_by_name(const char *name);
 int thermal_zone_get_temp(struct thermal_zone_device *tz, unsigned long *temp);
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [lm-sensors] [PATCH v3 1/8] thermal: Provide stub for thermal_of_cooling_device_register() function
@ 2015-02-06 16:59     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-06 16:59 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

Odroid U3 fan can work without being registered as OF cooling device
(with CONFIG_THERMAL_OF disabled).
In this situation it can be controlled via PWM entry at
/sys/class/hwmon/hwmon0/pwm1.

Therefore, the thermal_of_cooling_device_register() function needs a stub
to allow clean compilation.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- Provide stub declaration when CONFIG_THERMAL is not set
---
 include/linux/thermal.h | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index fc52e30..eacf2de 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -293,6 +293,20 @@ struct thermal_trip {
 };
 
 /* Function declarations */
+#ifdef CONFIG_THERMAL
+struct thermal_cooling_device *
+thermal_of_cooling_device_register(struct device_node *np,
+				   char *type, void *devdata,
+				   const struct thermal_cooling_device_ops *);
+#else
+static inline struct thermal_cooling_device *
+thermal_of_cooling_device_register(struct device_node *np,
+				   char *type, void *devdata,
+				   const struct thermal_cooling_device_ops *ops)
+{
+	return NULL;
+}
+#endif
 #ifdef CONFIG_THERMAL_OF
 struct thermal_zone_device *
 thermal_zone_of_sensor_register(struct device *dev, int id, void *data,
@@ -328,9 +342,6 @@ void thermal_zone_device_update(struct thermal_zone_device *);
 
 struct thermal_cooling_device *thermal_cooling_device_register(char *, void *,
 		const struct thermal_cooling_device_ops *);
-struct thermal_cooling_device *
-thermal_of_cooling_device_register(struct device_node *np, char *, void *,
-				   const struct thermal_cooling_device_ops *);
 void thermal_cooling_device_unregister(struct thermal_cooling_device *);
 struct thermal_zone_device *thermal_zone_get_zone_by_name(const char *name);
 int thermal_zone_get_temp(struct thermal_zone_device *tz, unsigned long *temp);
-- 
2.0.0.rc2


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v3 2/8] thermal: Provide stub for thermal_cdev_update() function
  2015-02-06 16:59   ` Lukasz Majewski
  (?)
@ 2015-02-06 16:59     ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-06 16:59 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

Odroid U3 fan can work without being registered as OF cooling device
(with CONFIG_THERMAL{_OF|} disabled).
In this situation it can be controlled via PWM entry at
/sys/class/hwmon/hwmon0/pwm1.

Therefore, the thermal_cdev_update() function needs a stub
to allow clean compilation.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- New patch
Changes for v3:
- thermal_cdev_update() now depends on CONFIG_THERMAL flag
---
 include/linux/thermal.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index eacf2de..25382e6 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -298,6 +298,7 @@ struct thermal_cooling_device *
 thermal_of_cooling_device_register(struct device_node *np,
 				   char *type, void *devdata,
 				   const struct thermal_cooling_device_ops *);
+void thermal_cdev_update(struct thermal_cooling_device *);
 #else
 static inline struct thermal_cooling_device *
 thermal_of_cooling_device_register(struct device_node *np,
@@ -306,6 +307,9 @@ thermal_of_cooling_device_register(struct device_node *np,
 {
 	return NULL;
 }
+static inline void thermal_cdev_update(struct thermal_cooling_device *cdev)
+{
+}
 #endif
 #ifdef CONFIG_THERMAL_OF
 struct thermal_zone_device *
@@ -349,7 +353,6 @@ int thermal_zone_get_temp(struct thermal_zone_device *tz, unsigned long *temp);
 int get_tz_trend(struct thermal_zone_device *, int);
 struct thermal_instance *get_thermal_instance(struct thermal_zone_device *,
 		struct thermal_cooling_device *, int);
-void thermal_cdev_update(struct thermal_cooling_device *);
 void thermal_notify_framework(struct thermal_zone_device *, int);
 
 #ifdef CONFIG_NET
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v3 2/8] thermal: Provide stub for thermal_cdev_update() function
@ 2015-02-06 16:59     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-06 16:59 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

Odroid U3 fan can work without being registered as OF cooling device
(with CONFIG_THERMAL{_OF|} disabled).
In this situation it can be controlled via PWM entry at
/sys/class/hwmon/hwmon0/pwm1.

Therefore, the thermal_cdev_update() function needs a stub
to allow clean compilation.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- New patch
Changes for v3:
- thermal_cdev_update() now depends on CONFIG_THERMAL flag
---
 include/linux/thermal.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index eacf2de..25382e6 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -298,6 +298,7 @@ struct thermal_cooling_device *
 thermal_of_cooling_device_register(struct device_node *np,
 				   char *type, void *devdata,
 				   const struct thermal_cooling_device_ops *);
+void thermal_cdev_update(struct thermal_cooling_device *);
 #else
 static inline struct thermal_cooling_device *
 thermal_of_cooling_device_register(struct device_node *np,
@@ -306,6 +307,9 @@ thermal_of_cooling_device_register(struct device_node *np,
 {
 	return NULL;
 }
+static inline void thermal_cdev_update(struct thermal_cooling_device *cdev)
+{
+}
 #endif
 #ifdef CONFIG_THERMAL_OF
 struct thermal_zone_device *
@@ -349,7 +353,6 @@ int thermal_zone_get_temp(struct thermal_zone_device *tz, unsigned long *temp);
 int get_tz_trend(struct thermal_zone_device *, int);
 struct thermal_instance *get_thermal_instance(struct thermal_zone_device *,
 		struct thermal_cooling_device *, int);
-void thermal_cdev_update(struct thermal_cooling_device *);
 void thermal_notify_framework(struct thermal_zone_device *, int);
 
 #ifdef CONFIG_NET
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [lm-sensors] [PATCH v3 2/8] thermal: Provide stub for thermal_cdev_update() function
@ 2015-02-06 16:59     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-06 16:59 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

Odroid U3 fan can work without being registered as OF cooling device
(with CONFIG_THERMAL{_OF|} disabled).
In this situation it can be controlled via PWM entry at
/sys/class/hwmon/hwmon0/pwm1.

Therefore, the thermal_cdev_update() function needs a stub
to allow clean compilation.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- New patch
Changes for v3:
- thermal_cdev_update() now depends on CONFIG_THERMAL flag
---
 include/linux/thermal.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index eacf2de..25382e6 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -298,6 +298,7 @@ struct thermal_cooling_device *
 thermal_of_cooling_device_register(struct device_node *np,
 				   char *type, void *devdata,
 				   const struct thermal_cooling_device_ops *);
+void thermal_cdev_update(struct thermal_cooling_device *);
 #else
 static inline struct thermal_cooling_device *
 thermal_of_cooling_device_register(struct device_node *np,
@@ -306,6 +307,9 @@ thermal_of_cooling_device_register(struct device_node *np,
 {
 	return NULL;
 }
+static inline void thermal_cdev_update(struct thermal_cooling_device *cdev)
+{
+}
 #endif
 #ifdef CONFIG_THERMAL_OF
 struct thermal_zone_device *
@@ -349,7 +353,6 @@ int thermal_zone_get_temp(struct thermal_zone_device *tz, unsigned long *temp);
 int get_tz_trend(struct thermal_zone_device *, int);
 struct thermal_instance *get_thermal_instance(struct thermal_zone_device *,
 		struct thermal_cooling_device *, int);
-void thermal_cdev_update(struct thermal_cooling_device *);
 void thermal_notify_framework(struct thermal_zone_device *, int);
 
 #ifdef CONFIG_NET
-- 
2.0.0.rc2


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v3 3/8] Documentation: dts: Documentation entry to explain how to use PWM FAN as a cooling device
  2015-02-06 16:59   ` Lukasz Majewski
  (?)
@ 2015-02-06 16:59     ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-06 16:59 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

Explanation of several properties, which allow PWM fan working as a cooling
device, have been embraced in this commit.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Rename cooling-pwm-values to cooling-levels
- Remove default-pulse-width property and stick to default hwmon policy
Changes for v3:
- Changing commit title from "hwmon: dts: Doc:" to "Documentation: dts"
- Remove unnecessary properties
- Set maximal cooling level to 230 instead of 255
---
 Documentation/devicetree/bindings/hwmon/pwm-fan.txt | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
index 610757c..d53fe0c 100644
--- a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
+++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
@@ -3,10 +3,30 @@ Bindings for a fan connected to the PWM lines
 Required properties:
 - compatible	: "pwm-fan"
 - pwms		: the PWM that is used to control the PWM fan
+- cooling-levels      : PWM duty cycle values in a range from 0 to 255
+			which correspond to thermal cooling states
+
+Thorough description of the following bindings:
+		cooling-min-state = <0>;
+		cooling-max-state = <3>;
+		#cooling-cells = <2>;
+		thermal-zone {
+			cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				     trip = <&cpu_alert1>;
+				     cooling-device = <&fan0 0 1>;
+				};
+			};
+		};
+
+for PWM FAN used as cooling device can be found at:
+./Documentation/devicetree/bindings/thermal/thermal.txt
 
 Example:
 	pwm-fan {
 		compatible = "pwm-fan";
 		status = "okay";
 		pwms = <&pwm 0 10000 0>;
+		cooling-levels = <0 102 170 230>;
 	};
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v3 3/8] Documentation: dts: Documentation entry to explain how to use PWM FAN as a cooling device
@ 2015-02-06 16:59     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-06 16:59 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

Explanation of several properties, which allow PWM fan working as a cooling
device, have been embraced in this commit.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Rename cooling-pwm-values to cooling-levels
- Remove default-pulse-width property and stick to default hwmon policy
Changes for v3:
- Changing commit title from "hwmon: dts: Doc:" to "Documentation: dts"
- Remove unnecessary properties
- Set maximal cooling level to 230 instead of 255
---
 Documentation/devicetree/bindings/hwmon/pwm-fan.txt | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
index 610757c..d53fe0c 100644
--- a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
+++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
@@ -3,10 +3,30 @@ Bindings for a fan connected to the PWM lines
 Required properties:
 - compatible	: "pwm-fan"
 - pwms		: the PWM that is used to control the PWM fan
+- cooling-levels      : PWM duty cycle values in a range from 0 to 255
+			which correspond to thermal cooling states
+
+Thorough description of the following bindings:
+		cooling-min-state = <0>;
+		cooling-max-state = <3>;
+		#cooling-cells = <2>;
+		thermal-zone {
+			cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				     trip = <&cpu_alert1>;
+				     cooling-device = <&fan0 0 1>;
+				};
+			};
+		};
+
+for PWM FAN used as cooling device can be found at:
+./Documentation/devicetree/bindings/thermal/thermal.txt
 
 Example:
 	pwm-fan {
 		compatible = "pwm-fan";
 		status = "okay";
 		pwms = <&pwm 0 10000 0>;
+		cooling-levels = <0 102 170 230>;
 	};
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [lm-sensors] [PATCH v3 3/8] Documentation: dts: Documentation entry to explain how to use PWM FAN as
@ 2015-02-06 16:59     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-06 16:59 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

Explanation of several properties, which allow PWM fan working as a cooling
device, have been embraced in this commit.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Rename cooling-pwm-values to cooling-levels
- Remove default-pulse-width property and stick to default hwmon policy
Changes for v3:
- Changing commit title from "hwmon: dts: Doc:" to "Documentation: dts"
- Remove unnecessary properties
- Set maximal cooling level to 230 instead of 255
---
 Documentation/devicetree/bindings/hwmon/pwm-fan.txt | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
index 610757c..d53fe0c 100644
--- a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
+++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
@@ -3,10 +3,30 @@ Bindings for a fan connected to the PWM lines
 Required properties:
 - compatible	: "pwm-fan"
 - pwms		: the PWM that is used to control the PWM fan
+- cooling-levels      : PWM duty cycle values in a range from 0 to 255
+			which correspond to thermal cooling states
+
+Thorough description of the following bindings:
+		cooling-min-state = <0>;
+		cooling-max-state = <3>;
+		#cooling-cells = <2>;
+		thermal-zone {
+			cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				     trip = <&cpu_alert1>;
+				     cooling-device = <&fan0 0 1>;
+				};
+			};
+		};
+
+for PWM FAN used as cooling device can be found at:
+./Documentation/devicetree/bindings/thermal/thermal.txt
 
 Example:
 	pwm-fan {
 		compatible = "pwm-fan";
 		status = "okay";
 		pwms = <&pwm 0 10000 0>;
+		cooling-levels = <0 102 170 230>;
 	};
-- 
2.0.0.rc2


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v3 4/8] ARM: dts: Add pwm-fan node to the Odroid-U3 board
  2015-02-06 16:59   ` Lukasz Majewski
  (?)
@ 2015-02-06 16:59     ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-06 16:59 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

From: Kamil Debski <k.debski@samsung.com>

Add pwm-fan node to the Odroid-U3 board file to enable PWM control of the
cooling fan. In addition, add the "pwm" label to the pwm@139D0000 node
in the exynos4412.dtsi.

Signed-off-by: Kamil Debski <k.debski@samsung.com>
[Rebased on the newest mainline by l.majewski@samsung.com]
---
Changes since v1:
- added pwm label to the pwm@139D0000 node in exynos4.dtsi
- use the pwm label in the exynos4412-odroidu3.dts
- change order or properties in the pwn-fan node, to be sorted
  in alphabetical order

---
 arch/arm/boot/dts/exynos4.dtsi            |  2 +-
 arch/arm/boot/dts/exynos4412-odroidu3.dts | 13 +++++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/exynos4.dtsi b/arch/arm/boot/dts/exynos4.dtsi
index f18d746..75266e3 100644
--- a/arch/arm/boot/dts/exynos4.dtsi
+++ b/arch/arm/boot/dts/exynos4.dtsi
@@ -582,7 +582,7 @@
 		status = "disabled";
 	};
 
-	pwm@139D0000 {
+	pwm: pwm@139D0000 {
 		compatible = "samsung,exynos4210-pwm";
 		reg = <0x139D0000 0x1000>;
 		interrupts = <0 37 0>, <0 38 0>, <0 39 0>, <0 40 0>, <0 41 0>;
diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
index c8a64be..60bd1e4 100644
--- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
+++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
@@ -31,6 +31,19 @@
 			linux,default-trigger = "heartbeat";
 		};
 	};
+
+	pwm-fan {
+		compatible = "pwm-fan";
+		pwms = <&pwm 0 10000 0>;
+		status = "okay";
+	};
+};
+
+&pwm {
+	pinctrl-0 = <&pwm0_out>;
+	pinctrl-names = "default";
+	samsung,pwm-outputs = <0>;
+	status = "okay";
 };
 
 &usb3503 {
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v3 4/8] ARM: dts: Add pwm-fan node to the Odroid-U3 board
@ 2015-02-06 16:59     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-06 16:59 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

From: Kamil Debski <k.debski@samsung.com>

Add pwm-fan node to the Odroid-U3 board file to enable PWM control of the
cooling fan. In addition, add the "pwm" label to the pwm@139D0000 node
in the exynos4412.dtsi.

Signed-off-by: Kamil Debski <k.debski@samsung.com>
[Rebased on the newest mainline by l.majewski@samsung.com]
---
Changes since v1:
- added pwm label to the pwm@139D0000 node in exynos4.dtsi
- use the pwm label in the exynos4412-odroidu3.dts
- change order or properties in the pwn-fan node, to be sorted
  in alphabetical order

---
 arch/arm/boot/dts/exynos4.dtsi            |  2 +-
 arch/arm/boot/dts/exynos4412-odroidu3.dts | 13 +++++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/exynos4.dtsi b/arch/arm/boot/dts/exynos4.dtsi
index f18d746..75266e3 100644
--- a/arch/arm/boot/dts/exynos4.dtsi
+++ b/arch/arm/boot/dts/exynos4.dtsi
@@ -582,7 +582,7 @@
 		status = "disabled";
 	};
 
-	pwm@139D0000 {
+	pwm: pwm@139D0000 {
 		compatible = "samsung,exynos4210-pwm";
 		reg = <0x139D0000 0x1000>;
 		interrupts = <0 37 0>, <0 38 0>, <0 39 0>, <0 40 0>, <0 41 0>;
diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
index c8a64be..60bd1e4 100644
--- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
+++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
@@ -31,6 +31,19 @@
 			linux,default-trigger = "heartbeat";
 		};
 	};
+
+	pwm-fan {
+		compatible = "pwm-fan";
+		pwms = <&pwm 0 10000 0>;
+		status = "okay";
+	};
+};
+
+&pwm {
+	pinctrl-0 = <&pwm0_out>;
+	pinctrl-names = "default";
+	samsung,pwm-outputs = <0>;
+	status = "okay";
 };
 
 &usb3503 {
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [lm-sensors] [PATCH v3 4/8] ARM: dts: Add pwm-fan node to the Odroid-U3 board
@ 2015-02-06 16:59     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-06 16:59 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

From: Kamil Debski <k.debski@samsung.com>

Add pwm-fan node to the Odroid-U3 board file to enable PWM control of the
cooling fan. In addition, add the "pwm" label to the pwm@139D0000 node
in the exynos4412.dtsi.

Signed-off-by: Kamil Debski <k.debski@samsung.com>
[Rebased on the newest mainline by l.majewski@samsung.com]
---
Changes since v1:
- added pwm label to the pwm@139D0000 node in exynos4.dtsi
- use the pwm label in the exynos4412-odroidu3.dts
- change order or properties in the pwn-fan node, to be sorted
  in alphabetical order

---
 arch/arm/boot/dts/exynos4.dtsi            |  2 +-
 arch/arm/boot/dts/exynos4412-odroidu3.dts | 13 +++++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/exynos4.dtsi b/arch/arm/boot/dts/exynos4.dtsi
index f18d746..75266e3 100644
--- a/arch/arm/boot/dts/exynos4.dtsi
+++ b/arch/arm/boot/dts/exynos4.dtsi
@@ -582,7 +582,7 @@
 		status = "disabled";
 	};
 
-	pwm@139D0000 {
+	pwm: pwm@139D0000 {
 		compatible = "samsung,exynos4210-pwm";
 		reg = <0x139D0000 0x1000>;
 		interrupts = <0 37 0>, <0 38 0>, <0 39 0>, <0 40 0>, <0 41 0>;
diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
index c8a64be..60bd1e4 100644
--- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
+++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
@@ -31,6 +31,19 @@
 			linux,default-trigger = "heartbeat";
 		};
 	};
+
+	pwm-fan {
+		compatible = "pwm-fan";
+		pwms = <&pwm 0 10000 0>;
+		status = "okay";
+	};
+};
+
+&pwm {
+	pinctrl-0 = <&pwm0_out>;
+	pinctrl-names = "default";
+	samsung,pwm-outputs = <0>;
+	status = "okay";
 };
 
 &usb3503 {
-- 
2.0.0.rc2


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v3 5/8] ARM: dts: Add properties to use pwm-fan device as a cooling device in Odroid U3
  2015-02-06 16:59   ` Lukasz Majewski
  (?)
@ 2015-02-06 16:59     ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-06 16:59 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

With those bindings it is possible to use pwm-fan device available in
Odroid U3 as a cooling device.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Rename cooling-pwm-values property to cooling-levels
Changes for v3:
- Change patch's topic to "ARM dts"
- Reduce maximal cooling-level to 230 from 255
---
 arch/arm/boot/dts/exynos4412-odroidu3.dts | 33 ++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
index 60bd1e4..3e5df3e 100644
--- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
+++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
@@ -32,11 +32,42 @@
 		};
 	};
 
-	pwm-fan {
+	fan0: pwm-fan {
 		compatible = "pwm-fan";
 		pwms = <&pwm 0 10000 0>;
+		cooling-min-state = <0>;
+		cooling-max-state = <3>;
+		#cooling-cells = <2>;
+		cooling-levels = <0 102 170 230>;
 		status = "okay";
 	};
+
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				     trip = <&cpu_alert1>;
+				     cooling-device = <&cpu0 7 7>;
+				};
+				map1 {
+				     trip = <&cpu_alert2>;
+				     cooling-device = <&cpu0 13 13>;
+				};
+				map2 {
+				     trip = <&cpu_alert0>;
+				     cooling-device = <&fan0 0 1>;
+				};
+				map3 {
+				     trip = <&cpu_alert1>;
+				     cooling-device = <&fan0 1 2>;
+				};
+				map4 {
+				     trip = <&cpu_alert2>;
+				     cooling-device = <&fan0 2 3>;
+				};
+			};
+		};
+	};
 };
 
 &pwm {
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v3 5/8] ARM: dts: Add properties to use pwm-fan device as a cooling device in Odroid U3
@ 2015-02-06 16:59     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-06 16:59 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

With those bindings it is possible to use pwm-fan device available in
Odroid U3 as a cooling device.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Rename cooling-pwm-values property to cooling-levels
Changes for v3:
- Change patch's topic to "ARM dts"
- Reduce maximal cooling-level to 230 from 255
---
 arch/arm/boot/dts/exynos4412-odroidu3.dts | 33 ++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
index 60bd1e4..3e5df3e 100644
--- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
+++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
@@ -32,11 +32,42 @@
 		};
 	};
 
-	pwm-fan {
+	fan0: pwm-fan {
 		compatible = "pwm-fan";
 		pwms = <&pwm 0 10000 0>;
+		cooling-min-state = <0>;
+		cooling-max-state = <3>;
+		#cooling-cells = <2>;
+		cooling-levels = <0 102 170 230>;
 		status = "okay";
 	};
+
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				     trip = <&cpu_alert1>;
+				     cooling-device = <&cpu0 7 7>;
+				};
+				map1 {
+				     trip = <&cpu_alert2>;
+				     cooling-device = <&cpu0 13 13>;
+				};
+				map2 {
+				     trip = <&cpu_alert0>;
+				     cooling-device = <&fan0 0 1>;
+				};
+				map3 {
+				     trip = <&cpu_alert1>;
+				     cooling-device = <&fan0 1 2>;
+				};
+				map4 {
+				     trip = <&cpu_alert2>;
+				     cooling-device = <&fan0 2 3>;
+				};
+			};
+		};
+	};
 };
 
 &pwm {
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [lm-sensors] [PATCH v3 5/8] ARM: dts: Add properties to use pwm-fan device as a cooling device in Od
@ 2015-02-06 16:59     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-06 16:59 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

With those bindings it is possible to use pwm-fan device available in
Odroid U3 as a cooling device.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Rename cooling-pwm-values property to cooling-levels
Changes for v3:
- Change patch's topic to "ARM dts"
- Reduce maximal cooling-level to 230 from 255
---
 arch/arm/boot/dts/exynos4412-odroidu3.dts | 33 ++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
index 60bd1e4..3e5df3e 100644
--- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
+++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
@@ -32,11 +32,42 @@
 		};
 	};
 
-	pwm-fan {
+	fan0: pwm-fan {
 		compatible = "pwm-fan";
 		pwms = <&pwm 0 10000 0>;
+		cooling-min-state = <0>;
+		cooling-max-state = <3>;
+		#cooling-cells = <2>;
+		cooling-levels = <0 102 170 230>;
 		status = "okay";
 	};
+
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				     trip = <&cpu_alert1>;
+				     cooling-device = <&cpu0 7 7>;
+				};
+				map1 {
+				     trip = <&cpu_alert2>;
+				     cooling-device = <&cpu0 13 13>;
+				};
+				map2 {
+				     trip = <&cpu_alert0>;
+				     cooling-device = <&fan0 0 1>;
+				};
+				map3 {
+				     trip = <&cpu_alert1>;
+				     cooling-device = <&fan0 1 2>;
+				};
+				map4 {
+				     trip = <&cpu_alert2>;
+				     cooling-device = <&fan0 2 3>;
+				};
+			};
+		};
+	};
 };
 
 &pwm {
-- 
2.0.0.rc2


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v3 6/8] hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty cycle
  2015-02-06 16:59   ` Lukasz Majewski
  (?)
@ 2015-02-06 16:59     ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-06 16:59 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

It was necessary to decouple code handling writing to sysfs from the one
responsible for setting PWM of the fan.
Due to that, new __set_pwm() method was extracted, which is responsible for
only setting new PWM duty cycle.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- The commit headline has been reedited.
---
 drivers/hwmon/pwm-fan.c | 35 ++++++++++++++++++++++-------------
 1 file changed, 22 insertions(+), 13 deletions(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index 1991d903..870e100 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -33,21 +33,15 @@ struct pwm_fan_ctx {
 	unsigned char pwm_value;
 };
 
-static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
-		       const char *buf, size_t count)
+static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
 {
-	struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
-	unsigned long pwm, duty;
-	ssize_t ret;
-
-	if (kstrtoul(buf, 10, &pwm) || pwm > MAX_PWM)
-		return -EINVAL;
-
-	mutex_lock(&ctx->lock);
+	unsigned long duty;
+	int ret;
 
 	if (ctx->pwm_value == pwm)
-		goto exit_set_pwm_no_change;
+		return 0;
 
+	mutex_lock(&ctx->lock);
 	if (pwm == 0) {
 		pwm_disable(ctx->pwm);
 		goto exit_set_pwm;
@@ -66,13 +60,28 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 
 exit_set_pwm:
 	ctx->pwm_value = pwm;
-exit_set_pwm_no_change:
-	ret = count;
 exit_set_pwm_err:
 	mutex_unlock(&ctx->lock);
 	return ret;
 }
 
+static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
+		       const char *buf, size_t count)
+{
+	struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
+	unsigned long pwm;
+	int ret;
+
+	if (kstrtoul(buf, 10, &pwm) || pwm > MAX_PWM)
+		return -EINVAL;
+
+	ret = __set_pwm(ctx, pwm);
+	if (ret)
+		return ret;
+
+	return count;
+}
+
 static ssize_t show_pwm(struct device *dev,
 			struct device_attribute *attr, char *buf)
 {
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v3 6/8] hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty cycle
@ 2015-02-06 16:59     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-06 16:59 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

It was necessary to decouple code handling writing to sysfs from the one
responsible for setting PWM of the fan.
Due to that, new __set_pwm() method was extracted, which is responsible for
only setting new PWM duty cycle.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- The commit headline has been reedited.
---
 drivers/hwmon/pwm-fan.c | 35 ++++++++++++++++++++++-------------
 1 file changed, 22 insertions(+), 13 deletions(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index 1991d903..870e100 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -33,21 +33,15 @@ struct pwm_fan_ctx {
 	unsigned char pwm_value;
 };
 
-static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
-		       const char *buf, size_t count)
+static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
 {
-	struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
-	unsigned long pwm, duty;
-	ssize_t ret;
-
-	if (kstrtoul(buf, 10, &pwm) || pwm > MAX_PWM)
-		return -EINVAL;
-
-	mutex_lock(&ctx->lock);
+	unsigned long duty;
+	int ret;
 
 	if (ctx->pwm_value == pwm)
-		goto exit_set_pwm_no_change;
+		return 0;
 
+	mutex_lock(&ctx->lock);
 	if (pwm == 0) {
 		pwm_disable(ctx->pwm);
 		goto exit_set_pwm;
@@ -66,13 +60,28 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 
 exit_set_pwm:
 	ctx->pwm_value = pwm;
-exit_set_pwm_no_change:
-	ret = count;
 exit_set_pwm_err:
 	mutex_unlock(&ctx->lock);
 	return ret;
 }
 
+static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
+		       const char *buf, size_t count)
+{
+	struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
+	unsigned long pwm;
+	int ret;
+
+	if (kstrtoul(buf, 10, &pwm) || pwm > MAX_PWM)
+		return -EINVAL;
+
+	ret = __set_pwm(ctx, pwm);
+	if (ret)
+		return ret;
+
+	return count;
+}
+
 static ssize_t show_pwm(struct device *dev,
 			struct device_attribute *attr, char *buf)
 {
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [lm-sensors] [PATCH v3 6/8] hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty cyc
@ 2015-02-06 16:59     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-06 16:59 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

It was necessary to decouple code handling writing to sysfs from the one
responsible for setting PWM of the fan.
Due to that, new __set_pwm() method was extracted, which is responsible for
only setting new PWM duty cycle.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- The commit headline has been reedited.
---
 drivers/hwmon/pwm-fan.c | 35 ++++++++++++++++++++++-------------
 1 file changed, 22 insertions(+), 13 deletions(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index 1991d903..870e100 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -33,21 +33,15 @@ struct pwm_fan_ctx {
 	unsigned char pwm_value;
 };
 
-static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
-		       const char *buf, size_t count)
+static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
 {
-	struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
-	unsigned long pwm, duty;
-	ssize_t ret;
-
-	if (kstrtoul(buf, 10, &pwm) || pwm > MAX_PWM)
-		return -EINVAL;
-
-	mutex_lock(&ctx->lock);
+	unsigned long duty;
+	int ret;
 
 	if (ctx->pwm_value = pwm)
-		goto exit_set_pwm_no_change;
+		return 0;
 
+	mutex_lock(&ctx->lock);
 	if (pwm = 0) {
 		pwm_disable(ctx->pwm);
 		goto exit_set_pwm;
@@ -66,13 +60,28 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 
 exit_set_pwm:
 	ctx->pwm_value = pwm;
-exit_set_pwm_no_change:
-	ret = count;
 exit_set_pwm_err:
 	mutex_unlock(&ctx->lock);
 	return ret;
 }
 
+static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
+		       const char *buf, size_t count)
+{
+	struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
+	unsigned long pwm;
+	int ret;
+
+	if (kstrtoul(buf, 10, &pwm) || pwm > MAX_PWM)
+		return -EINVAL;
+
+	ret = __set_pwm(ctx, pwm);
+	if (ret)
+		return ret;
+
+	return count;
+}
+
 static ssize_t show_pwm(struct device *dev,
 			struct device_attribute *attr, char *buf)
 {
-- 
2.0.0.rc2


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v3 7/8] hwmon: pwm-fan: Read PWM FAN configuration from device tree
@ 2015-02-06 16:59     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-06 16:59 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

This patch provides code for reading PWM FAN configuration data via
device tree. The pwm-fan can work with full speed when configuration
is not provided. However, errors are propagated when wrong DT bindings
are found.
Additionally the struct pwm_fan_ctx has been extended.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Rename pwm_fan_max_states to pwm_fan_cooling_levels
- Moving pwm_fan_of_get_cooling_data() call after setting end enabling PWM FAN
- pwm_fan_of_get_cooling_data() now can fail - preserving old behaviour
- Remove unnecessary dev_err() call
Changes for v3:
- Patch's headline has been reedited
- pwm_fan_of_get_cooling_data() return code is now being checked.
- of_property_count_elems_of_size() is now used instead of_find_property()
- More verbose patch description added
---
 drivers/hwmon/pwm-fan.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 53 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index 870e100..f3f5843 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -30,7 +30,10 @@
 struct pwm_fan_ctx {
 	struct mutex lock;
 	struct pwm_device *pwm;
-	unsigned char pwm_value;
+	unsigned int pwm_value;
+	unsigned int pwm_fan_state;
+	unsigned int pwm_fan_max_state;
+	unsigned int *pwm_fan_cooling_levels;
 };
 
 static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
@@ -100,6 +103,50 @@ static struct attribute *pwm_fan_attrs[] = {
 
 ATTRIBUTE_GROUPS(pwm_fan);
 
+int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
+{
+	struct device_node *np = dev->of_node;
+	int num, i, ret;
+
+	ret = of_property_count_elems_of_size(np, "cooling-levels",
+					      sizeof(u32));
+
+	if (ret == -EINVAL) {
+		dev_err(dev, "Property 'cooling-levels' not found\n");
+		return 0;
+	}
+
+	if (ret <= 0) {
+		dev_err(dev, "Wrong data!\n");
+		return ret;
+	}
+
+	num = ret;
+	ctx->pwm_fan_cooling_levels = devm_kzalloc(dev, num * sizeof(u32),
+						   GFP_KERNEL);
+	if (!ctx->pwm_fan_cooling_levels)
+		return -ENOMEM;
+
+	ret = of_property_read_u32_array(np, "cooling-levels",
+					 ctx->pwm_fan_cooling_levels, num);
+	if (ret) {
+		dev_err(dev, "Property 'cooling-levels' cannot be read!\n");
+		return ret;
+	}
+
+	for (i = 0; i < num; i++) {
+		if (ctx->pwm_fan_cooling_levels[i] > MAX_PWM) {
+			dev_err(dev, "PWM fan state[%d]:%d > %d\n", i,
+				ctx->pwm_fan_cooling_levels[i], MAX_PWM);
+			return -EINVAL;
+		}
+	}
+
+	ctx->pwm_fan_max_state = num - 1;
+
+	return 0;
+}
+
 static int pwm_fan_probe(struct platform_device *pdev)
 {
 	struct device *hwmon;
@@ -145,6 +192,11 @@ static int pwm_fan_probe(struct platform_device *pdev)
 		pwm_disable(ctx->pwm);
 		return PTR_ERR(hwmon);
 	}
+
+	ret = pwm_fan_of_get_cooling_data(&pdev->dev, ctx);
+	if (ret)
+		return ret;
+
 	return 0;
 }
 
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v3 7/8] hwmon: pwm-fan: Read PWM FAN configuration from device tree
@ 2015-02-06 16:59     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-06 16:59 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors-GZX6beZjE8VD60Wz+7aTrA, Linux PM list,
	linux-samsung-soc-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Lukasz Majewski, Kukjin Kim,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

This patch provides code for reading PWM FAN configuration data via
device tree. The pwm-fan can work with full speed when configuration
is not provided. However, errors are propagated when wrong DT bindings
are found.
Additionally the struct pwm_fan_ctx has been extended.

Signed-off-by: Lukasz Majewski <l.majewski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
---
Changes for v2:
- Rename pwm_fan_max_states to pwm_fan_cooling_levels
- Moving pwm_fan_of_get_cooling_data() call after setting end enabling PWM FAN
- pwm_fan_of_get_cooling_data() now can fail - preserving old behaviour
- Remove unnecessary dev_err() call
Changes for v3:
- Patch's headline has been reedited
- pwm_fan_of_get_cooling_data() return code is now being checked.
- of_property_count_elems_of_size() is now used instead of_find_property()
- More verbose patch description added
---
 drivers/hwmon/pwm-fan.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 53 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index 870e100..f3f5843 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -30,7 +30,10 @@
 struct pwm_fan_ctx {
 	struct mutex lock;
 	struct pwm_device *pwm;
-	unsigned char pwm_value;
+	unsigned int pwm_value;
+	unsigned int pwm_fan_state;
+	unsigned int pwm_fan_max_state;
+	unsigned int *pwm_fan_cooling_levels;
 };
 
 static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
@@ -100,6 +103,50 @@ static struct attribute *pwm_fan_attrs[] = {
 
 ATTRIBUTE_GROUPS(pwm_fan);
 
+int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
+{
+	struct device_node *np = dev->of_node;
+	int num, i, ret;
+
+	ret = of_property_count_elems_of_size(np, "cooling-levels",
+					      sizeof(u32));
+
+	if (ret == -EINVAL) {
+		dev_err(dev, "Property 'cooling-levels' not found\n");
+		return 0;
+	}
+
+	if (ret <= 0) {
+		dev_err(dev, "Wrong data!\n");
+		return ret;
+	}
+
+	num = ret;
+	ctx->pwm_fan_cooling_levels = devm_kzalloc(dev, num * sizeof(u32),
+						   GFP_KERNEL);
+	if (!ctx->pwm_fan_cooling_levels)
+		return -ENOMEM;
+
+	ret = of_property_read_u32_array(np, "cooling-levels",
+					 ctx->pwm_fan_cooling_levels, num);
+	if (ret) {
+		dev_err(dev, "Property 'cooling-levels' cannot be read!\n");
+		return ret;
+	}
+
+	for (i = 0; i < num; i++) {
+		if (ctx->pwm_fan_cooling_levels[i] > MAX_PWM) {
+			dev_err(dev, "PWM fan state[%d]:%d > %d\n", i,
+				ctx->pwm_fan_cooling_levels[i], MAX_PWM);
+			return -EINVAL;
+		}
+	}
+
+	ctx->pwm_fan_max_state = num - 1;
+
+	return 0;
+}
+
 static int pwm_fan_probe(struct platform_device *pdev)
 {
 	struct device *hwmon;
@@ -145,6 +192,11 @@ static int pwm_fan_probe(struct platform_device *pdev)
 		pwm_disable(ctx->pwm);
 		return PTR_ERR(hwmon);
 	}
+
+	ret = pwm_fan_of_get_cooling_data(&pdev->dev, ctx);
+	if (ret)
+		return ret;
+
 	return 0;
 }
 
-- 
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [lm-sensors] [PATCH v3 7/8] hwmon: pwm-fan: Read PWM FAN configuration from device tree
@ 2015-02-06 16:59     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-06 16:59 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

This patch provides code for reading PWM FAN configuration data via
device tree. The pwm-fan can work with full speed when configuration
is not provided. However, errors are propagated when wrong DT bindings
are found.
Additionally the struct pwm_fan_ctx has been extended.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Rename pwm_fan_max_states to pwm_fan_cooling_levels
- Moving pwm_fan_of_get_cooling_data() call after setting end enabling PWM FAN
- pwm_fan_of_get_cooling_data() now can fail - preserving old behaviour
- Remove unnecessary dev_err() call
Changes for v3:
- Patch's headline has been reedited
- pwm_fan_of_get_cooling_data() return code is now being checked.
- of_property_count_elems_of_size() is now used instead of_find_property()
- More verbose patch description added
---
 drivers/hwmon/pwm-fan.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 53 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index 870e100..f3f5843 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -30,7 +30,10 @@
 struct pwm_fan_ctx {
 	struct mutex lock;
 	struct pwm_device *pwm;
-	unsigned char pwm_value;
+	unsigned int pwm_value;
+	unsigned int pwm_fan_state;
+	unsigned int pwm_fan_max_state;
+	unsigned int *pwm_fan_cooling_levels;
 };
 
 static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
@@ -100,6 +103,50 @@ static struct attribute *pwm_fan_attrs[] = {
 
 ATTRIBUTE_GROUPS(pwm_fan);
 
+int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
+{
+	struct device_node *np = dev->of_node;
+	int num, i, ret;
+
+	ret = of_property_count_elems_of_size(np, "cooling-levels",
+					      sizeof(u32));
+
+	if (ret = -EINVAL) {
+		dev_err(dev, "Property 'cooling-levels' not found\n");
+		return 0;
+	}
+
+	if (ret <= 0) {
+		dev_err(dev, "Wrong data!\n");
+		return ret;
+	}
+
+	num = ret;
+	ctx->pwm_fan_cooling_levels = devm_kzalloc(dev, num * sizeof(u32),
+						   GFP_KERNEL);
+	if (!ctx->pwm_fan_cooling_levels)
+		return -ENOMEM;
+
+	ret = of_property_read_u32_array(np, "cooling-levels",
+					 ctx->pwm_fan_cooling_levels, num);
+	if (ret) {
+		dev_err(dev, "Property 'cooling-levels' cannot be read!\n");
+		return ret;
+	}
+
+	for (i = 0; i < num; i++) {
+		if (ctx->pwm_fan_cooling_levels[i] > MAX_PWM) {
+			dev_err(dev, "PWM fan state[%d]:%d > %d\n", i,
+				ctx->pwm_fan_cooling_levels[i], MAX_PWM);
+			return -EINVAL;
+		}
+	}
+
+	ctx->pwm_fan_max_state = num - 1;
+
+	return 0;
+}
+
 static int pwm_fan_probe(struct platform_device *pdev)
 {
 	struct device *hwmon;
@@ -145,6 +192,11 @@ static int pwm_fan_probe(struct platform_device *pdev)
 		pwm_disable(ctx->pwm);
 		return PTR_ERR(hwmon);
 	}
+
+	ret = pwm_fan_of_get_cooling_data(&pdev->dev, ctx);
+	if (ret)
+		return ret;
+
 	return 0;
 }
 
-- 
2.0.0.rc2


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v3 8/8] hwmon: pwm-fan: Code for using PWM FAN as a cooling device
  2015-02-06 16:59   ` Lukasz Majewski
  (?)
@ 2015-02-06 16:59     ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-06 16:59 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

The PWM FAN device can now be used as a thermal cooling device. Necessary
infrastructure has been added in this commit.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Replace pwm_fan_cooling_states with pwm_fan_cooling_levels
- Update ctx->pwm_fan_state when correct data from device tree is available
- Using therma_cdev_update() when thermal is ready for controlling the fan
Changes for v3:
- Rename patch heading
- pwm_fan_of_get_cooling_data() now returns -EINVAL when no "cooling-levels"
  property defined
- register of cooling device only when proper cooling data is present
---
 drivers/hwmon/pwm-fan.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 83 insertions(+), 3 deletions(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index f3f5843..79fe24e 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -24,6 +24,7 @@
 #include <linux/platform_device.h>
 #include <linux/pwm.h>
 #include <linux/sysfs.h>
+#include <linux/thermal.h>
 
 #define MAX_PWM 255
 
@@ -68,6 +69,17 @@ exit_set_pwm_err:
 	return ret;
 }
 
+static void pwm_fan_update_state(struct pwm_fan_ctx *ctx, unsigned long pwm)
+{
+	int i;
+
+	for (i = 0; i < ctx->pwm_fan_max_state; ++i)
+		if (pwm < ctx->pwm_fan_cooling_levels[i + 1])
+			break;
+
+	ctx->pwm_fan_state = i;
+}
+
 static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 		       const char *buf, size_t count)
 {
@@ -82,6 +94,7 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 	if (ret)
 		return ret;
 
+	pwm_fan_update_state(ctx, pwm);
 	return count;
 }
 
@@ -103,6 +116,59 @@ static struct attribute *pwm_fan_attrs[] = {
 
 ATTRIBUTE_GROUPS(pwm_fan);
 
+/* thermal cooling device callbacks */
+static int pwm_fan_get_max_state(struct thermal_cooling_device *cdev,
+				 unsigned long *state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+
+	*state = ctx->pwm_fan_max_state;
+
+	return 0;
+}
+
+static int pwm_fan_get_cur_state(struct thermal_cooling_device *cdev,
+				 unsigned long *state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+
+	if (!ctx)
+		return -EINVAL;
+
+	*state = ctx->pwm_fan_state;
+
+	return 0;
+}
+
+static int
+pwm_fan_set_cur_state(struct thermal_cooling_device *cdev, unsigned long state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+	int ret;
+
+	if (!ctx || (state > ctx->pwm_fan_max_state))
+		return -EINVAL;
+
+	if (state == ctx->pwm_fan_state)
+		return 0;
+
+	ret = __set_pwm(ctx, ctx->pwm_fan_cooling_levels[state]);
+	if (ret) {
+		dev_err(&cdev->device, "Cannot set pwm!\n");
+		return ret;
+	}
+
+	ctx->pwm_fan_state = state;
+
+	return ret;
+}
+
+static const struct thermal_cooling_device_ops pwm_fan_cooling_ops = {
+	.get_max_state = pwm_fan_get_max_state,
+	.get_cur_state = pwm_fan_get_cur_state,
+	.set_cur_state = pwm_fan_set_cur_state,
+};
+
 int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
 {
 	struct device_node *np = dev->of_node;
@@ -113,7 +179,7 @@ int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
 
 	if (ret == -EINVAL) {
 		dev_err(dev, "Property 'cooling-levels' not found\n");
-		return 0;
+		return ret;
 	}
 
 	if (ret <= 0) {
@@ -149,8 +215,9 @@ int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
 
 static int pwm_fan_probe(struct platform_device *pdev)
 {
-	struct device *hwmon;
+	struct thermal_cooling_device *cdev;
 	struct pwm_fan_ctx *ctx;
+	struct device *hwmon;
 	int duty_cycle;
 	int ret;
 
@@ -194,8 +261,21 @@ static int pwm_fan_probe(struct platform_device *pdev)
 	}
 
 	ret = pwm_fan_of_get_cooling_data(&pdev->dev, ctx);
-	if (ret)
+	if (!ret) {
+		ctx->pwm_fan_state = ctx->pwm_fan_max_state;
+		cdev = thermal_of_cooling_device_register(pdev->dev.of_node,
+							  "pwm-fan", ctx,
+							  &pwm_fan_cooling_ops);
+		if (IS_ERR(cdev)) {
+			dev_err(&pdev->dev,
+				"Failed to register pwm-fan as cooling device");
+			pwm_disable(ctx->pwm);
+			return PTR_ERR(cdev);
+		}
+		thermal_cdev_update(cdev);
+	} else if (ret != -EINVAL) {
 		return ret;
+	}
 
 	return 0;
 }
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v3 8/8] hwmon: pwm-fan: Code for using PWM FAN as a cooling device
@ 2015-02-06 16:59     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-06 16:59 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

The PWM FAN device can now be used as a thermal cooling device. Necessary
infrastructure has been added in this commit.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Replace pwm_fan_cooling_states with pwm_fan_cooling_levels
- Update ctx->pwm_fan_state when correct data from device tree is available
- Using therma_cdev_update() when thermal is ready for controlling the fan
Changes for v3:
- Rename patch heading
- pwm_fan_of_get_cooling_data() now returns -EINVAL when no "cooling-levels"
  property defined
- register of cooling device only when proper cooling data is present
---
 drivers/hwmon/pwm-fan.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 83 insertions(+), 3 deletions(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index f3f5843..79fe24e 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -24,6 +24,7 @@
 #include <linux/platform_device.h>
 #include <linux/pwm.h>
 #include <linux/sysfs.h>
+#include <linux/thermal.h>
 
 #define MAX_PWM 255
 
@@ -68,6 +69,17 @@ exit_set_pwm_err:
 	return ret;
 }
 
+static void pwm_fan_update_state(struct pwm_fan_ctx *ctx, unsigned long pwm)
+{
+	int i;
+
+	for (i = 0; i < ctx->pwm_fan_max_state; ++i)
+		if (pwm < ctx->pwm_fan_cooling_levels[i + 1])
+			break;
+
+	ctx->pwm_fan_state = i;
+}
+
 static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 		       const char *buf, size_t count)
 {
@@ -82,6 +94,7 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 	if (ret)
 		return ret;
 
+	pwm_fan_update_state(ctx, pwm);
 	return count;
 }
 
@@ -103,6 +116,59 @@ static struct attribute *pwm_fan_attrs[] = {
 
 ATTRIBUTE_GROUPS(pwm_fan);
 
+/* thermal cooling device callbacks */
+static int pwm_fan_get_max_state(struct thermal_cooling_device *cdev,
+				 unsigned long *state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+
+	*state = ctx->pwm_fan_max_state;
+
+	return 0;
+}
+
+static int pwm_fan_get_cur_state(struct thermal_cooling_device *cdev,
+				 unsigned long *state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+
+	if (!ctx)
+		return -EINVAL;
+
+	*state = ctx->pwm_fan_state;
+
+	return 0;
+}
+
+static int
+pwm_fan_set_cur_state(struct thermal_cooling_device *cdev, unsigned long state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+	int ret;
+
+	if (!ctx || (state > ctx->pwm_fan_max_state))
+		return -EINVAL;
+
+	if (state == ctx->pwm_fan_state)
+		return 0;
+
+	ret = __set_pwm(ctx, ctx->pwm_fan_cooling_levels[state]);
+	if (ret) {
+		dev_err(&cdev->device, "Cannot set pwm!\n");
+		return ret;
+	}
+
+	ctx->pwm_fan_state = state;
+
+	return ret;
+}
+
+static const struct thermal_cooling_device_ops pwm_fan_cooling_ops = {
+	.get_max_state = pwm_fan_get_max_state,
+	.get_cur_state = pwm_fan_get_cur_state,
+	.set_cur_state = pwm_fan_set_cur_state,
+};
+
 int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
 {
 	struct device_node *np = dev->of_node;
@@ -113,7 +179,7 @@ int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
 
 	if (ret == -EINVAL) {
 		dev_err(dev, "Property 'cooling-levels' not found\n");
-		return 0;
+		return ret;
 	}
 
 	if (ret <= 0) {
@@ -149,8 +215,9 @@ int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
 
 static int pwm_fan_probe(struct platform_device *pdev)
 {
-	struct device *hwmon;
+	struct thermal_cooling_device *cdev;
 	struct pwm_fan_ctx *ctx;
+	struct device *hwmon;
 	int duty_cycle;
 	int ret;
 
@@ -194,8 +261,21 @@ static int pwm_fan_probe(struct platform_device *pdev)
 	}
 
 	ret = pwm_fan_of_get_cooling_data(&pdev->dev, ctx);
-	if (ret)
+	if (!ret) {
+		ctx->pwm_fan_state = ctx->pwm_fan_max_state;
+		cdev = thermal_of_cooling_device_register(pdev->dev.of_node,
+							  "pwm-fan", ctx,
+							  &pwm_fan_cooling_ops);
+		if (IS_ERR(cdev)) {
+			dev_err(&pdev->dev,
+				"Failed to register pwm-fan as cooling device");
+			pwm_disable(ctx->pwm);
+			return PTR_ERR(cdev);
+		}
+		thermal_cdev_update(cdev);
+	} else if (ret != -EINVAL) {
 		return ret;
+	}
 
 	return 0;
 }
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [lm-sensors] [PATCH v3 8/8] hwmon: pwm-fan: Code for using PWM FAN as a cooling device
@ 2015-02-06 16:59     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-06 16:59 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

The PWM FAN device can now be used as a thermal cooling device. Necessary
infrastructure has been added in this commit.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Replace pwm_fan_cooling_states with pwm_fan_cooling_levels
- Update ctx->pwm_fan_state when correct data from device tree is available
- Using therma_cdev_update() when thermal is ready for controlling the fan
Changes for v3:
- Rename patch heading
- pwm_fan_of_get_cooling_data() now returns -EINVAL when no "cooling-levels"
  property defined
- register of cooling device only when proper cooling data is present
---
 drivers/hwmon/pwm-fan.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 83 insertions(+), 3 deletions(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index f3f5843..79fe24e 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -24,6 +24,7 @@
 #include <linux/platform_device.h>
 #include <linux/pwm.h>
 #include <linux/sysfs.h>
+#include <linux/thermal.h>
 
 #define MAX_PWM 255
 
@@ -68,6 +69,17 @@ exit_set_pwm_err:
 	return ret;
 }
 
+static void pwm_fan_update_state(struct pwm_fan_ctx *ctx, unsigned long pwm)
+{
+	int i;
+
+	for (i = 0; i < ctx->pwm_fan_max_state; ++i)
+		if (pwm < ctx->pwm_fan_cooling_levels[i + 1])
+			break;
+
+	ctx->pwm_fan_state = i;
+}
+
 static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 		       const char *buf, size_t count)
 {
@@ -82,6 +94,7 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 	if (ret)
 		return ret;
 
+	pwm_fan_update_state(ctx, pwm);
 	return count;
 }
 
@@ -103,6 +116,59 @@ static struct attribute *pwm_fan_attrs[] = {
 
 ATTRIBUTE_GROUPS(pwm_fan);
 
+/* thermal cooling device callbacks */
+static int pwm_fan_get_max_state(struct thermal_cooling_device *cdev,
+				 unsigned long *state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+
+	*state = ctx->pwm_fan_max_state;
+
+	return 0;
+}
+
+static int pwm_fan_get_cur_state(struct thermal_cooling_device *cdev,
+				 unsigned long *state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+
+	if (!ctx)
+		return -EINVAL;
+
+	*state = ctx->pwm_fan_state;
+
+	return 0;
+}
+
+static int
+pwm_fan_set_cur_state(struct thermal_cooling_device *cdev, unsigned long state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+	int ret;
+
+	if (!ctx || (state > ctx->pwm_fan_max_state))
+		return -EINVAL;
+
+	if (state = ctx->pwm_fan_state)
+		return 0;
+
+	ret = __set_pwm(ctx, ctx->pwm_fan_cooling_levels[state]);
+	if (ret) {
+		dev_err(&cdev->device, "Cannot set pwm!\n");
+		return ret;
+	}
+
+	ctx->pwm_fan_state = state;
+
+	return ret;
+}
+
+static const struct thermal_cooling_device_ops pwm_fan_cooling_ops = {
+	.get_max_state = pwm_fan_get_max_state,
+	.get_cur_state = pwm_fan_get_cur_state,
+	.set_cur_state = pwm_fan_set_cur_state,
+};
+
 int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
 {
 	struct device_node *np = dev->of_node;
@@ -113,7 +179,7 @@ int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
 
 	if (ret = -EINVAL) {
 		dev_err(dev, "Property 'cooling-levels' not found\n");
-		return 0;
+		return ret;
 	}
 
 	if (ret <= 0) {
@@ -149,8 +215,9 @@ int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
 
 static int pwm_fan_probe(struct platform_device *pdev)
 {
-	struct device *hwmon;
+	struct thermal_cooling_device *cdev;
 	struct pwm_fan_ctx *ctx;
+	struct device *hwmon;
 	int duty_cycle;
 	int ret;
 
@@ -194,8 +261,21 @@ static int pwm_fan_probe(struct platform_device *pdev)
 	}
 
 	ret = pwm_fan_of_get_cooling_data(&pdev->dev, ctx);
-	if (ret)
+	if (!ret) {
+		ctx->pwm_fan_state = ctx->pwm_fan_max_state;
+		cdev = thermal_of_cooling_device_register(pdev->dev.of_node,
+							  "pwm-fan", ctx,
+							  &pwm_fan_cooling_ops);
+		if (IS_ERR(cdev)) {
+			dev_err(&pdev->dev,
+				"Failed to register pwm-fan as cooling device");
+			pwm_disable(ctx->pwm);
+			return PTR_ERR(cdev);
+		}
+		thermal_cdev_update(cdev);
+	} else if (ret != -EINVAL) {
 		return ret;
+	}
 
 	return 0;
 }
-- 
2.0.0.rc2


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* Re: [PATCH v3 6/8] hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty cycle
  2015-02-06 16:59     ` [PATCH v3 6/8] hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty cycle Lukasz Majewski
  (?)
@ 2015-02-06 18:27       ` Guenter Roeck
  -1 siblings, 0 replies; 329+ messages in thread
From: Guenter Roeck @ 2015-02-06 18:27 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Eduardo Valentin, Kamil Debski, Jean Delvare, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

On Fri, Feb 06, 2015 at 05:59:06PM +0100, Lukasz Majewski wrote:
> It was necessary to decouple code handling writing to sysfs from the one
> responsible for setting PWM of the fan.
> Due to that, new __set_pwm() method was extracted, which is responsible for
> only setting new PWM duty cycle.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
> Changes for v2:
> - None
> Changes for v3:
> - The commit headline has been reedited.
> ---
>  drivers/hwmon/pwm-fan.c | 35 ++++++++++++++++++++++-------------
>  1 file changed, 22 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
> index 1991d903..870e100 100644
> --- a/drivers/hwmon/pwm-fan.c
> +++ b/drivers/hwmon/pwm-fan.c
> @@ -33,21 +33,15 @@ struct pwm_fan_ctx {
>  	unsigned char pwm_value;
>  };
>  
> -static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
> -		       const char *buf, size_t count)
> +static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
>  {
> -	struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
> -	unsigned long pwm, duty;
> -	ssize_t ret;
> -
> -	if (kstrtoul(buf, 10, &pwm) || pwm > MAX_PWM)
> -		return -EINVAL;
> -
> -	mutex_lock(&ctx->lock);
> +	unsigned long duty;
> +	int ret;
>  
>  	if (ctx->pwm_value == pwm)
> -		goto exit_set_pwm_no_change;
> +		return 0;
>  
Why did you move this check outside the lock ? With this change there 
is no guarantee that pwm_value wasn't changed while waiting for the lock.

Guenter

> +	mutex_lock(&ctx->lock);
>  	if (pwm == 0) {
>  		pwm_disable(ctx->pwm);
>  		goto exit_set_pwm;
> @@ -66,13 +60,28 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
>  
>  exit_set_pwm:
>  	ctx->pwm_value = pwm;
> -exit_set_pwm_no_change:
> -	ret = count;
>  exit_set_pwm_err:
>  	mutex_unlock(&ctx->lock);
>  	return ret;
>  }
>  
> +static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
> +		       const char *buf, size_t count)
> +{
> +	struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
> +	unsigned long pwm;
> +	int ret;
> +
> +	if (kstrtoul(buf, 10, &pwm) || pwm > MAX_PWM)
> +		return -EINVAL;
> +
> +	ret = __set_pwm(ctx, pwm);
> +	if (ret)
> +		return ret;
> +
> +	return count;
> +}
> +
>  static ssize_t show_pwm(struct device *dev,
>  			struct device_attribute *attr, char *buf)
>  {
> -- 
> 2.0.0.rc2
> 

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v3 6/8] hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty cycle
@ 2015-02-06 18:27       ` Guenter Roeck
  0 siblings, 0 replies; 329+ messages in thread
From: Guenter Roeck @ 2015-02-06 18:27 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Eduardo Valentin, Kamil Debski, Jean Delvare, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

On Fri, Feb 06, 2015 at 05:59:06PM +0100, Lukasz Majewski wrote:
> It was necessary to decouple code handling writing to sysfs from the one
> responsible for setting PWM of the fan.
> Due to that, new __set_pwm() method was extracted, which is responsible for
> only setting new PWM duty cycle.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
> Changes for v2:
> - None
> Changes for v3:
> - The commit headline has been reedited.
> ---
>  drivers/hwmon/pwm-fan.c | 35 ++++++++++++++++++++++-------------
>  1 file changed, 22 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
> index 1991d903..870e100 100644
> --- a/drivers/hwmon/pwm-fan.c
> +++ b/drivers/hwmon/pwm-fan.c
> @@ -33,21 +33,15 @@ struct pwm_fan_ctx {
>  	unsigned char pwm_value;
>  };
>  
> -static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
> -		       const char *buf, size_t count)
> +static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
>  {
> -	struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
> -	unsigned long pwm, duty;
> -	ssize_t ret;
> -
> -	if (kstrtoul(buf, 10, &pwm) || pwm > MAX_PWM)
> -		return -EINVAL;
> -
> -	mutex_lock(&ctx->lock);
> +	unsigned long duty;
> +	int ret;
>  
>  	if (ctx->pwm_value == pwm)
> -		goto exit_set_pwm_no_change;
> +		return 0;
>  
Why did you move this check outside the lock ? With this change there 
is no guarantee that pwm_value wasn't changed while waiting for the lock.

Guenter

> +	mutex_lock(&ctx->lock);
>  	if (pwm == 0) {
>  		pwm_disable(ctx->pwm);
>  		goto exit_set_pwm;
> @@ -66,13 +60,28 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
>  
>  exit_set_pwm:
>  	ctx->pwm_value = pwm;
> -exit_set_pwm_no_change:
> -	ret = count;
>  exit_set_pwm_err:
>  	mutex_unlock(&ctx->lock);
>  	return ret;
>  }
>  
> +static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
> +		       const char *buf, size_t count)
> +{
> +	struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
> +	unsigned long pwm;
> +	int ret;
> +
> +	if (kstrtoul(buf, 10, &pwm) || pwm > MAX_PWM)
> +		return -EINVAL;
> +
> +	ret = __set_pwm(ctx, pwm);
> +	if (ret)
> +		return ret;
> +
> +	return count;
> +}
> +
>  static ssize_t show_pwm(struct device *dev,
>  			struct device_attribute *attr, char *buf)
>  {
> -- 
> 2.0.0.rc2
> 

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [lm-sensors] [PATCH v3 6/8] hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty
@ 2015-02-06 18:27       ` Guenter Roeck
  0 siblings, 0 replies; 329+ messages in thread
From: Guenter Roeck @ 2015-02-06 18:27 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Eduardo Valentin, Kamil Debski, Jean Delvare, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

On Fri, Feb 06, 2015 at 05:59:06PM +0100, Lukasz Majewski wrote:
> It was necessary to decouple code handling writing to sysfs from the one
> responsible for setting PWM of the fan.
> Due to that, new __set_pwm() method was extracted, which is responsible for
> only setting new PWM duty cycle.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
> Changes for v2:
> - None
> Changes for v3:
> - The commit headline has been reedited.
> ---
>  drivers/hwmon/pwm-fan.c | 35 ++++++++++++++++++++++-------------
>  1 file changed, 22 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
> index 1991d903..870e100 100644
> --- a/drivers/hwmon/pwm-fan.c
> +++ b/drivers/hwmon/pwm-fan.c
> @@ -33,21 +33,15 @@ struct pwm_fan_ctx {
>  	unsigned char pwm_value;
>  };
>  
> -static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
> -		       const char *buf, size_t count)
> +static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
>  {
> -	struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
> -	unsigned long pwm, duty;
> -	ssize_t ret;
> -
> -	if (kstrtoul(buf, 10, &pwm) || pwm > MAX_PWM)
> -		return -EINVAL;
> -
> -	mutex_lock(&ctx->lock);
> +	unsigned long duty;
> +	int ret;
>  
>  	if (ctx->pwm_value = pwm)
> -		goto exit_set_pwm_no_change;
> +		return 0;
>  
Why did you move this check outside the lock ? With this change there 
is no guarantee that pwm_value wasn't changed while waiting for the lock.

Guenter

> +	mutex_lock(&ctx->lock);
>  	if (pwm = 0) {
>  		pwm_disable(ctx->pwm);
>  		goto exit_set_pwm;
> @@ -66,13 +60,28 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
>  
>  exit_set_pwm:
>  	ctx->pwm_value = pwm;
> -exit_set_pwm_no_change:
> -	ret = count;
>  exit_set_pwm_err:
>  	mutex_unlock(&ctx->lock);
>  	return ret;
>  }
>  
> +static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
> +		       const char *buf, size_t count)
> +{
> +	struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
> +	unsigned long pwm;
> +	int ret;
> +
> +	if (kstrtoul(buf, 10, &pwm) || pwm > MAX_PWM)
> +		return -EINVAL;
> +
> +	ret = __set_pwm(ctx, pwm);
> +	if (ret)
> +		return ret;
> +
> +	return count;
> +}
> +
>  static ssize_t show_pwm(struct device *dev,
>  			struct device_attribute *attr, char *buf)
>  {
> -- 
> 2.0.0.rc2
> 

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v3 7/8] hwmon: pwm-fan: Read PWM FAN configuration from device tree
  2015-02-06 16:59     ` Lukasz Majewski
  (?)
@ 2015-02-06 18:36       ` Guenter Roeck
  -1 siblings, 0 replies; 329+ messages in thread
From: Guenter Roeck @ 2015-02-06 18:36 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Eduardo Valentin, Kamil Debski, Jean Delvare, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

On Fri, Feb 06, 2015 at 05:59:07PM +0100, Lukasz Majewski wrote:
> This patch provides code for reading PWM FAN configuration data via
> device tree. The pwm-fan can work with full speed when configuration
> is not provided. However, errors are propagated when wrong DT bindings
> are found.
> Additionally the struct pwm_fan_ctx has been extended.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
> Changes for v2:
> - Rename pwm_fan_max_states to pwm_fan_cooling_levels
> - Moving pwm_fan_of_get_cooling_data() call after setting end enabling PWM FAN
> - pwm_fan_of_get_cooling_data() now can fail - preserving old behaviour
> - Remove unnecessary dev_err() call
> Changes for v3:
> - Patch's headline has been reedited
> - pwm_fan_of_get_cooling_data() return code is now being checked.
> - of_property_count_elems_of_size() is now used instead of_find_property()
> - More verbose patch description added
> ---
>  drivers/hwmon/pwm-fan.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 53 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
> index 870e100..f3f5843 100644
> --- a/drivers/hwmon/pwm-fan.c
> +++ b/drivers/hwmon/pwm-fan.c
> @@ -30,7 +30,10 @@
>  struct pwm_fan_ctx {
>  	struct mutex lock;
>  	struct pwm_device *pwm;
> -	unsigned char pwm_value;
> +	unsigned int pwm_value;
> +	unsigned int pwm_fan_state;
> +	unsigned int pwm_fan_max_state;
> +	unsigned int *pwm_fan_cooling_levels;
>  };
>  
>  static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
> @@ -100,6 +103,50 @@ static struct attribute *pwm_fan_attrs[] = {
>  
>  ATTRIBUTE_GROUPS(pwm_fan);
>  
> +int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
> +{
> +	struct device_node *np = dev->of_node;
> +	int num, i, ret;
> +
> +	ret = of_property_count_elems_of_size(np, "cooling-levels",
> +					      sizeof(u32));
> +
> +	if (ret == -EINVAL) {
> +		dev_err(dev, "Property 'cooling-levels' not found\n");
> +		return 0;

Returning 0 is obviously not an error, otherwise you would not return 0 here.
So dev_err is wrong. Also, the message itself is wrong; the property may
well be there but have a wrong size.

> +	}
> +
> +	if (ret <= 0) {
> +		dev_err(dev, "Wrong data!\n");
> +		return ret;
> +	}

This will result in the driver failing to load if devicetree is not configured
(of_property_count_elems_of_size will return -ENOSYS). This is not acceptable.
Also, if the call returns 0 you don't return an error but display a "Wrong data!"
error message. Either it is an error or it is not, but not both.

Guenter

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v3 7/8] hwmon: pwm-fan: Read PWM FAN configuration from device tree
@ 2015-02-06 18:36       ` Guenter Roeck
  0 siblings, 0 replies; 329+ messages in thread
From: Guenter Roeck @ 2015-02-06 18:36 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Eduardo Valentin, Kamil Debski, Jean Delvare, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

On Fri, Feb 06, 2015 at 05:59:07PM +0100, Lukasz Majewski wrote:
> This patch provides code for reading PWM FAN configuration data via
> device tree. The pwm-fan can work with full speed when configuration
> is not provided. However, errors are propagated when wrong DT bindings
> are found.
> Additionally the struct pwm_fan_ctx has been extended.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
> Changes for v2:
> - Rename pwm_fan_max_states to pwm_fan_cooling_levels
> - Moving pwm_fan_of_get_cooling_data() call after setting end enabling PWM FAN
> - pwm_fan_of_get_cooling_data() now can fail - preserving old behaviour
> - Remove unnecessary dev_err() call
> Changes for v3:
> - Patch's headline has been reedited
> - pwm_fan_of_get_cooling_data() return code is now being checked.
> - of_property_count_elems_of_size() is now used instead of_find_property()
> - More verbose patch description added
> ---
>  drivers/hwmon/pwm-fan.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 53 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
> index 870e100..f3f5843 100644
> --- a/drivers/hwmon/pwm-fan.c
> +++ b/drivers/hwmon/pwm-fan.c
> @@ -30,7 +30,10 @@
>  struct pwm_fan_ctx {
>  	struct mutex lock;
>  	struct pwm_device *pwm;
> -	unsigned char pwm_value;
> +	unsigned int pwm_value;
> +	unsigned int pwm_fan_state;
> +	unsigned int pwm_fan_max_state;
> +	unsigned int *pwm_fan_cooling_levels;
>  };
>  
>  static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
> @@ -100,6 +103,50 @@ static struct attribute *pwm_fan_attrs[] = {
>  
>  ATTRIBUTE_GROUPS(pwm_fan);
>  
> +int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
> +{
> +	struct device_node *np = dev->of_node;
> +	int num, i, ret;
> +
> +	ret = of_property_count_elems_of_size(np, "cooling-levels",
> +					      sizeof(u32));
> +
> +	if (ret == -EINVAL) {
> +		dev_err(dev, "Property 'cooling-levels' not found\n");
> +		return 0;

Returning 0 is obviously not an error, otherwise you would not return 0 here.
So dev_err is wrong. Also, the message itself is wrong; the property may
well be there but have a wrong size.

> +	}
> +
> +	if (ret <= 0) {
> +		dev_err(dev, "Wrong data!\n");
> +		return ret;
> +	}

This will result in the driver failing to load if devicetree is not configured
(of_property_count_elems_of_size will return -ENOSYS). This is not acceptable.
Also, if the call returns 0 you don't return an error but display a "Wrong data!"
error message. Either it is an error or it is not, but not both.

Guenter

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [lm-sensors] [PATCH v3 7/8] hwmon: pwm-fan: Read PWM FAN configuration from device tree
@ 2015-02-06 18:36       ` Guenter Roeck
  0 siblings, 0 replies; 329+ messages in thread
From: Guenter Roeck @ 2015-02-06 18:36 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Eduardo Valentin, Kamil Debski, Jean Delvare, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

On Fri, Feb 06, 2015 at 05:59:07PM +0100, Lukasz Majewski wrote:
> This patch provides code for reading PWM FAN configuration data via
> device tree. The pwm-fan can work with full speed when configuration
> is not provided. However, errors are propagated when wrong DT bindings
> are found.
> Additionally the struct pwm_fan_ctx has been extended.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
> Changes for v2:
> - Rename pwm_fan_max_states to pwm_fan_cooling_levels
> - Moving pwm_fan_of_get_cooling_data() call after setting end enabling PWM FAN
> - pwm_fan_of_get_cooling_data() now can fail - preserving old behaviour
> - Remove unnecessary dev_err() call
> Changes for v3:
> - Patch's headline has been reedited
> - pwm_fan_of_get_cooling_data() return code is now being checked.
> - of_property_count_elems_of_size() is now used instead of_find_property()
> - More verbose patch description added
> ---
>  drivers/hwmon/pwm-fan.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 53 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
> index 870e100..f3f5843 100644
> --- a/drivers/hwmon/pwm-fan.c
> +++ b/drivers/hwmon/pwm-fan.c
> @@ -30,7 +30,10 @@
>  struct pwm_fan_ctx {
>  	struct mutex lock;
>  	struct pwm_device *pwm;
> -	unsigned char pwm_value;
> +	unsigned int pwm_value;
> +	unsigned int pwm_fan_state;
> +	unsigned int pwm_fan_max_state;
> +	unsigned int *pwm_fan_cooling_levels;
>  };
>  
>  static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
> @@ -100,6 +103,50 @@ static struct attribute *pwm_fan_attrs[] = {
>  
>  ATTRIBUTE_GROUPS(pwm_fan);
>  
> +int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
> +{
> +	struct device_node *np = dev->of_node;
> +	int num, i, ret;
> +
> +	ret = of_property_count_elems_of_size(np, "cooling-levels",
> +					      sizeof(u32));
> +
> +	if (ret = -EINVAL) {
> +		dev_err(dev, "Property 'cooling-levels' not found\n");
> +		return 0;

Returning 0 is obviously not an error, otherwise you would not return 0 here.
So dev_err is wrong. Also, the message itself is wrong; the property may
well be there but have a wrong size.

> +	}
> +
> +	if (ret <= 0) {
> +		dev_err(dev, "Wrong data!\n");
> +		return ret;
> +	}

This will result in the driver failing to load if devicetree is not configured
(of_property_count_elems_of_size will return -ENOSYS). This is not acceptable.
Also, if the call returns 0 you don't return an error but display a "Wrong data!"
error message. Either it is an error or it is not, but not both.

Guenter

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v3 6/8] hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty cycle
  2015-02-06 18:27       ` [PATCH v3 6/8] hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty cycle Guenter Roeck
  (?)
@ 2015-02-08 20:52         ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-08 20:52 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Lukasz Majewski, Eduardo Valentin, Kamil Debski, Jean Delvare,
	Kukjin Kim, lm-sensors, Linux PM list, linux-samsung-soc,
	devicetree, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

[-- Attachment #1: Type: text/plain, Size: 2835 bytes --]

On Fri, 6 Feb 2015 10:27:25 -0800
Guenter Roeck <linux@roeck-us.net> wrote:

> On Fri, Feb 06, 2015 at 05:59:06PM +0100, Lukasz Majewski wrote:
> > It was necessary to decouple code handling writing to sysfs from
> > the one responsible for setting PWM of the fan.
> > Due to that, new __set_pwm() method was extracted, which is
> > responsible for only setting new PWM duty cycle.
> > 
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > ---
> > Changes for v2:
> > - None
> > Changes for v3:
> > - The commit headline has been reedited.
> > ---
> >  drivers/hwmon/pwm-fan.c | 35 ++++++++++++++++++++++-------------
> >  1 file changed, 22 insertions(+), 13 deletions(-)
> > 
> > diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
> > index 1991d903..870e100 100644
> > --- a/drivers/hwmon/pwm-fan.c
> > +++ b/drivers/hwmon/pwm-fan.c
> > @@ -33,21 +33,15 @@ struct pwm_fan_ctx {
> >  	unsigned char pwm_value;
> >  };
> >  
> > -static ssize_t set_pwm(struct device *dev, struct device_attribute
> > *attr,
> > -		       const char *buf, size_t count)
> > +static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
> >  {
> > -	struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
> > -	unsigned long pwm, duty;
> > -	ssize_t ret;
> > -
> > -	if (kstrtoul(buf, 10, &pwm) || pwm > MAX_PWM)
> > -		return -EINVAL;
> > -
> > -	mutex_lock(&ctx->lock);
> > +	unsigned long duty;
> > +	int ret;
> >  
> >  	if (ctx->pwm_value == pwm)
> > -		goto exit_set_pwm_no_change;
> > +		return 0;
> >  
> Why did you move this check outside the lock ? With this change there 
> is no guarantee that pwm_value wasn't changed while waiting for the
> lock.

Grrr. You are obviously right here. I will fix this. Thanks for spotting

Best regards,
Lukasz Majewski

> 
> Guenter
> 
> > +	mutex_lock(&ctx->lock);
> >  	if (pwm == 0) {
> >  		pwm_disable(ctx->pwm);
> >  		goto exit_set_pwm;
> > @@ -66,13 +60,28 @@ static ssize_t set_pwm(struct device *dev,
> > struct device_attribute *attr, 
> >  exit_set_pwm:
> >  	ctx->pwm_value = pwm;
> > -exit_set_pwm_no_change:
> > -	ret = count;
> >  exit_set_pwm_err:
> >  	mutex_unlock(&ctx->lock);
> >  	return ret;
> >  }
> >  
> > +static ssize_t set_pwm(struct device *dev, struct device_attribute
> > *attr,
> > +		       const char *buf, size_t count)
> > +{
> > +	struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
> > +	unsigned long pwm;
> > +	int ret;
> > +
> > +	if (kstrtoul(buf, 10, &pwm) || pwm > MAX_PWM)
> > +		return -EINVAL;
> > +
> > +	ret = __set_pwm(ctx, pwm);
> > +	if (ret)
> > +		return ret;
> > +
> > +	return count;
> > +}
> > +
> >  static ssize_t show_pwm(struct device *dev,
> >  			struct device_attribute *attr, char *buf)
> >  {
> > -- 
> > 2.0.0.rc2
> > 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v3 6/8] hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty cycle
@ 2015-02-08 20:52         ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-08 20:52 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Lukasz Majewski, Eduardo Valentin, Kamil Debski, Jean Delvare,
	Kukjin Kim, lm-sensors, Linux PM list, linux-samsung-soc,
	devicetree, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

[-- Attachment #1: Type: text/plain, Size: 2835 bytes --]

On Fri, 6 Feb 2015 10:27:25 -0800
Guenter Roeck <linux@roeck-us.net> wrote:

> On Fri, Feb 06, 2015 at 05:59:06PM +0100, Lukasz Majewski wrote:
> > It was necessary to decouple code handling writing to sysfs from
> > the one responsible for setting PWM of the fan.
> > Due to that, new __set_pwm() method was extracted, which is
> > responsible for only setting new PWM duty cycle.
> > 
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > ---
> > Changes for v2:
> > - None
> > Changes for v3:
> > - The commit headline has been reedited.
> > ---
> >  drivers/hwmon/pwm-fan.c | 35 ++++++++++++++++++++++-------------
> >  1 file changed, 22 insertions(+), 13 deletions(-)
> > 
> > diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
> > index 1991d903..870e100 100644
> > --- a/drivers/hwmon/pwm-fan.c
> > +++ b/drivers/hwmon/pwm-fan.c
> > @@ -33,21 +33,15 @@ struct pwm_fan_ctx {
> >  	unsigned char pwm_value;
> >  };
> >  
> > -static ssize_t set_pwm(struct device *dev, struct device_attribute
> > *attr,
> > -		       const char *buf, size_t count)
> > +static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
> >  {
> > -	struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
> > -	unsigned long pwm, duty;
> > -	ssize_t ret;
> > -
> > -	if (kstrtoul(buf, 10, &pwm) || pwm > MAX_PWM)
> > -		return -EINVAL;
> > -
> > -	mutex_lock(&ctx->lock);
> > +	unsigned long duty;
> > +	int ret;
> >  
> >  	if (ctx->pwm_value == pwm)
> > -		goto exit_set_pwm_no_change;
> > +		return 0;
> >  
> Why did you move this check outside the lock ? With this change there 
> is no guarantee that pwm_value wasn't changed while waiting for the
> lock.

Grrr. You are obviously right here. I will fix this. Thanks for spotting

Best regards,
Lukasz Majewski

> 
> Guenter
> 
> > +	mutex_lock(&ctx->lock);
> >  	if (pwm == 0) {
> >  		pwm_disable(ctx->pwm);
> >  		goto exit_set_pwm;
> > @@ -66,13 +60,28 @@ static ssize_t set_pwm(struct device *dev,
> > struct device_attribute *attr, 
> >  exit_set_pwm:
> >  	ctx->pwm_value = pwm;
> > -exit_set_pwm_no_change:
> > -	ret = count;
> >  exit_set_pwm_err:
> >  	mutex_unlock(&ctx->lock);
> >  	return ret;
> >  }
> >  
> > +static ssize_t set_pwm(struct device *dev, struct device_attribute
> > *attr,
> > +		       const char *buf, size_t count)
> > +{
> > +	struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
> > +	unsigned long pwm;
> > +	int ret;
> > +
> > +	if (kstrtoul(buf, 10, &pwm) || pwm > MAX_PWM)
> > +		return -EINVAL;
> > +
> > +	ret = __set_pwm(ctx, pwm);
> > +	if (ret)
> > +		return ret;
> > +
> > +	return count;
> > +}
> > +
> >  static ssize_t show_pwm(struct device *dev,
> >  			struct device_attribute *attr, char *buf)
> >  {
> > -- 
> > 2.0.0.rc2
> > 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [lm-sensors] [PATCH v3 6/8] hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty
@ 2015-02-08 20:52         ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-08 20:52 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Lukasz Majewski, Eduardo Valentin, Kamil Debski, Jean Delvare,
	Kukjin Kim, lm-sensors, Linux PM list, linux-samsung-soc,
	devicetree, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan


[-- Attachment #1.1: Type: text/plain, Size: 2835 bytes --]

On Fri, 6 Feb 2015 10:27:25 -0800
Guenter Roeck <linux@roeck-us.net> wrote:

> On Fri, Feb 06, 2015 at 05:59:06PM +0100, Lukasz Majewski wrote:
> > It was necessary to decouple code handling writing to sysfs from
> > the one responsible for setting PWM of the fan.
> > Due to that, new __set_pwm() method was extracted, which is
> > responsible for only setting new PWM duty cycle.
> > 
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > ---
> > Changes for v2:
> > - None
> > Changes for v3:
> > - The commit headline has been reedited.
> > ---
> >  drivers/hwmon/pwm-fan.c | 35 ++++++++++++++++++++++-------------
> >  1 file changed, 22 insertions(+), 13 deletions(-)
> > 
> > diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
> > index 1991d903..870e100 100644
> > --- a/drivers/hwmon/pwm-fan.c
> > +++ b/drivers/hwmon/pwm-fan.c
> > @@ -33,21 +33,15 @@ struct pwm_fan_ctx {
> >  	unsigned char pwm_value;
> >  };
> >  
> > -static ssize_t set_pwm(struct device *dev, struct device_attribute
> > *attr,
> > -		       const char *buf, size_t count)
> > +static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
> >  {
> > -	struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
> > -	unsigned long pwm, duty;
> > -	ssize_t ret;
> > -
> > -	if (kstrtoul(buf, 10, &pwm) || pwm > MAX_PWM)
> > -		return -EINVAL;
> > -
> > -	mutex_lock(&ctx->lock);
> > +	unsigned long duty;
> > +	int ret;
> >  
> >  	if (ctx->pwm_value == pwm)
> > -		goto exit_set_pwm_no_change;
> > +		return 0;
> >  
> Why did you move this check outside the lock ? With this change there 
> is no guarantee that pwm_value wasn't changed while waiting for the
> lock.

Grrr. You are obviously right here. I will fix this. Thanks for spotting

Best regards,
Lukasz Majewski

> 
> Guenter
> 
> > +	mutex_lock(&ctx->lock);
> >  	if (pwm == 0) {
> >  		pwm_disable(ctx->pwm);
> >  		goto exit_set_pwm;
> > @@ -66,13 +60,28 @@ static ssize_t set_pwm(struct device *dev,
> > struct device_attribute *attr, 
> >  exit_set_pwm:
> >  	ctx->pwm_value = pwm;
> > -exit_set_pwm_no_change:
> > -	ret = count;
> >  exit_set_pwm_err:
> >  	mutex_unlock(&ctx->lock);
> >  	return ret;
> >  }
> >  
> > +static ssize_t set_pwm(struct device *dev, struct device_attribute
> > *attr,
> > +		       const char *buf, size_t count)
> > +{
> > +	struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
> > +	unsigned long pwm;
> > +	int ret;
> > +
> > +	if (kstrtoul(buf, 10, &pwm) || pwm > MAX_PWM)
> > +		return -EINVAL;
> > +
> > +	ret = __set_pwm(ctx, pwm);
> > +	if (ret)
> > +		return ret;
> > +
> > +	return count;
> > +}
> > +
> >  static ssize_t show_pwm(struct device *dev,
> >  			struct device_attribute *attr, char *buf)
> >  {
> > -- 
> > 2.0.0.rc2
> > 


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

[-- Attachment #2: Type: text/plain, Size: 153 bytes --]

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v3 7/8] hwmon: pwm-fan: Read PWM FAN configuration from device tree
  2015-02-06 18:36       ` Guenter Roeck
  (?)
@ 2015-02-08 21:36         ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-08 21:36 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Lukasz Majewski, Eduardo Valentin, Kamil Debski, Jean Delvare,
	Kukjin Kim, lm-sensors, Linux PM list, linux-samsung-soc,
	devicetree, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

[-- Attachment #1: Type: text/plain, Size: 3486 bytes --]

On Fri, 6 Feb 2015 10:36:57 -0800
Guenter Roeck <linux@roeck-us.net> wrote:

> On Fri, Feb 06, 2015 at 05:59:07PM +0100, Lukasz Majewski wrote:
> > This patch provides code for reading PWM FAN configuration data via
> > device tree. The pwm-fan can work with full speed when configuration
> > is not provided. However, errors are propagated when wrong DT
> > bindings are found.
> > Additionally the struct pwm_fan_ctx has been extended.
> > 
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > ---
> > Changes for v2:
> > - Rename pwm_fan_max_states to pwm_fan_cooling_levels
> > - Moving pwm_fan_of_get_cooling_data() call after setting end
> > enabling PWM FAN
> > - pwm_fan_of_get_cooling_data() now can fail - preserving old
> > behaviour
> > - Remove unnecessary dev_err() call
> > Changes for v3:
> > - Patch's headline has been reedited
> > - pwm_fan_of_get_cooling_data() return code is now being checked.
> > - of_property_count_elems_of_size() is now used instead
> > of_find_property()
> > - More verbose patch description added
> > ---
> >  drivers/hwmon/pwm-fan.c | 54
> > ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed,
> > 53 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
> > index 870e100..f3f5843 100644
> > --- a/drivers/hwmon/pwm-fan.c
> > +++ b/drivers/hwmon/pwm-fan.c
> > @@ -30,7 +30,10 @@
> >  struct pwm_fan_ctx {
> >  	struct mutex lock;
> >  	struct pwm_device *pwm;
> > -	unsigned char pwm_value;
> > +	unsigned int pwm_value;
> > +	unsigned int pwm_fan_state;
> > +	unsigned int pwm_fan_max_state;
> > +	unsigned int *pwm_fan_cooling_levels;
> >  };
> >  
> >  static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
> > @@ -100,6 +103,50 @@ static struct attribute *pwm_fan_attrs[] = {
> >  
> >  ATTRIBUTE_GROUPS(pwm_fan);
> >  
> > +int pwm_fan_of_get_cooling_data(struct device *dev, struct
> > pwm_fan_ctx *ctx) +{
> > +	struct device_node *np = dev->of_node;
> > +	int num, i, ret;
> > +
> > +	ret = of_property_count_elems_of_size(np, "cooling-levels",
> > +					      sizeof(u32));
> > +
> > +	if (ret == -EINVAL) {
> > +		dev_err(dev, "Property 'cooling-levels' not
> > found\n");
> > +		return 0;
> 
> Returning 0 is obviously not an error, otherwise you would not return
> 0 here. So dev_err is wrong.

pr_info would be more appropriate here.

> Also, the message itself is wrong; the
> property may well be there but have a wrong size.

As fair as I remember the -EINVAL is set only when the property is not
defined. Such situation is correct and our pwm-fan driver should work
with or without it.

> 
> > +	}
> > +
> > +	if (ret <= 0) {
> > +		dev_err(dev, "Wrong data!\n");
> > +		return ret;
> > +	}
> 
> This will result in the driver failing to load if devicetree is not
> configured (of_property_count_elems_of_size will return -ENOSYS).

As you pointed out in the comment to v2:

It is OK if the "cooling-levels" is not defined in DT. However, if it
has broken definition, then we should return error. This is what we do
here.

> This is not acceptable. Also, if the call returns 0 you don't return
> an error but display a "Wrong data!" error message. Either it is an
> error or it is not, but not both.

This is an error. "cooling-levels" with zero elements is regarded as a
broken property.

> 
> Guenter

Best regards,
Lukasz Majewski

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v3 7/8] hwmon: pwm-fan: Read PWM FAN configuration from device tree
@ 2015-02-08 21:36         ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-08 21:36 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Lukasz Majewski, Eduardo Valentin, Kamil Debski, Jean Delvare,
	Kukjin Kim, lm-sensors, Linux PM list, linux-samsung-soc,
	devicetree, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

[-- Attachment #1: Type: text/plain, Size: 3486 bytes --]

On Fri, 6 Feb 2015 10:36:57 -0800
Guenter Roeck <linux@roeck-us.net> wrote:

> On Fri, Feb 06, 2015 at 05:59:07PM +0100, Lukasz Majewski wrote:
> > This patch provides code for reading PWM FAN configuration data via
> > device tree. The pwm-fan can work with full speed when configuration
> > is not provided. However, errors are propagated when wrong DT
> > bindings are found.
> > Additionally the struct pwm_fan_ctx has been extended.
> > 
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > ---
> > Changes for v2:
> > - Rename pwm_fan_max_states to pwm_fan_cooling_levels
> > - Moving pwm_fan_of_get_cooling_data() call after setting end
> > enabling PWM FAN
> > - pwm_fan_of_get_cooling_data() now can fail - preserving old
> > behaviour
> > - Remove unnecessary dev_err() call
> > Changes for v3:
> > - Patch's headline has been reedited
> > - pwm_fan_of_get_cooling_data() return code is now being checked.
> > - of_property_count_elems_of_size() is now used instead
> > of_find_property()
> > - More verbose patch description added
> > ---
> >  drivers/hwmon/pwm-fan.c | 54
> > ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed,
> > 53 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
> > index 870e100..f3f5843 100644
> > --- a/drivers/hwmon/pwm-fan.c
> > +++ b/drivers/hwmon/pwm-fan.c
> > @@ -30,7 +30,10 @@
> >  struct pwm_fan_ctx {
> >  	struct mutex lock;
> >  	struct pwm_device *pwm;
> > -	unsigned char pwm_value;
> > +	unsigned int pwm_value;
> > +	unsigned int pwm_fan_state;
> > +	unsigned int pwm_fan_max_state;
> > +	unsigned int *pwm_fan_cooling_levels;
> >  };
> >  
> >  static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
> > @@ -100,6 +103,50 @@ static struct attribute *pwm_fan_attrs[] = {
> >  
> >  ATTRIBUTE_GROUPS(pwm_fan);
> >  
> > +int pwm_fan_of_get_cooling_data(struct device *dev, struct
> > pwm_fan_ctx *ctx) +{
> > +	struct device_node *np = dev->of_node;
> > +	int num, i, ret;
> > +
> > +	ret = of_property_count_elems_of_size(np, "cooling-levels",
> > +					      sizeof(u32));
> > +
> > +	if (ret == -EINVAL) {
> > +		dev_err(dev, "Property 'cooling-levels' not
> > found\n");
> > +		return 0;
> 
> Returning 0 is obviously not an error, otherwise you would not return
> 0 here. So dev_err is wrong.

pr_info would be more appropriate here.

> Also, the message itself is wrong; the
> property may well be there but have a wrong size.

As fair as I remember the -EINVAL is set only when the property is not
defined. Such situation is correct and our pwm-fan driver should work
with or without it.

> 
> > +	}
> > +
> > +	if (ret <= 0) {
> > +		dev_err(dev, "Wrong data!\n");
> > +		return ret;
> > +	}
> 
> This will result in the driver failing to load if devicetree is not
> configured (of_property_count_elems_of_size will return -ENOSYS).

As you pointed out in the comment to v2:

It is OK if the "cooling-levels" is not defined in DT. However, if it
has broken definition, then we should return error. This is what we do
here.

> This is not acceptable. Also, if the call returns 0 you don't return
> an error but display a "Wrong data!" error message. Either it is an
> error or it is not, but not both.

This is an error. "cooling-levels" with zero elements is regarded as a
broken property.

> 
> Guenter

Best regards,
Lukasz Majewski

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [lm-sensors] [PATCH v3 7/8] hwmon: pwm-fan: Read PWM FAN configuration from device tree
@ 2015-02-08 21:36         ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-08 21:36 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Lukasz Majewski, Eduardo Valentin, Kamil Debski, Jean Delvare,
	Kukjin Kim, lm-sensors, Linux PM list, linux-samsung-soc,
	devicetree, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan


[-- Attachment #1.1: Type: text/plain, Size: 3486 bytes --]

On Fri, 6 Feb 2015 10:36:57 -0800
Guenter Roeck <linux@roeck-us.net> wrote:

> On Fri, Feb 06, 2015 at 05:59:07PM +0100, Lukasz Majewski wrote:
> > This patch provides code for reading PWM FAN configuration data via
> > device tree. The pwm-fan can work with full speed when configuration
> > is not provided. However, errors are propagated when wrong DT
> > bindings are found.
> > Additionally the struct pwm_fan_ctx has been extended.
> > 
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > ---
> > Changes for v2:
> > - Rename pwm_fan_max_states to pwm_fan_cooling_levels
> > - Moving pwm_fan_of_get_cooling_data() call after setting end
> > enabling PWM FAN
> > - pwm_fan_of_get_cooling_data() now can fail - preserving old
> > behaviour
> > - Remove unnecessary dev_err() call
> > Changes for v3:
> > - Patch's headline has been reedited
> > - pwm_fan_of_get_cooling_data() return code is now being checked.
> > - of_property_count_elems_of_size() is now used instead
> > of_find_property()
> > - More verbose patch description added
> > ---
> >  drivers/hwmon/pwm-fan.c | 54
> > ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed,
> > 53 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
> > index 870e100..f3f5843 100644
> > --- a/drivers/hwmon/pwm-fan.c
> > +++ b/drivers/hwmon/pwm-fan.c
> > @@ -30,7 +30,10 @@
> >  struct pwm_fan_ctx {
> >  	struct mutex lock;
> >  	struct pwm_device *pwm;
> > -	unsigned char pwm_value;
> > +	unsigned int pwm_value;
> > +	unsigned int pwm_fan_state;
> > +	unsigned int pwm_fan_max_state;
> > +	unsigned int *pwm_fan_cooling_levels;
> >  };
> >  
> >  static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
> > @@ -100,6 +103,50 @@ static struct attribute *pwm_fan_attrs[] = {
> >  
> >  ATTRIBUTE_GROUPS(pwm_fan);
> >  
> > +int pwm_fan_of_get_cooling_data(struct device *dev, struct
> > pwm_fan_ctx *ctx) +{
> > +	struct device_node *np = dev->of_node;
> > +	int num, i, ret;
> > +
> > +	ret = of_property_count_elems_of_size(np, "cooling-levels",
> > +					      sizeof(u32));
> > +
> > +	if (ret == -EINVAL) {
> > +		dev_err(dev, "Property 'cooling-levels' not
> > found\n");
> > +		return 0;
> 
> Returning 0 is obviously not an error, otherwise you would not return
> 0 here. So dev_err is wrong.

pr_info would be more appropriate here.

> Also, the message itself is wrong; the
> property may well be there but have a wrong size.

As fair as I remember the -EINVAL is set only when the property is not
defined. Such situation is correct and our pwm-fan driver should work
with or without it.

> 
> > +	}
> > +
> > +	if (ret <= 0) {
> > +		dev_err(dev, "Wrong data!\n");
> > +		return ret;
> > +	}
> 
> This will result in the driver failing to load if devicetree is not
> configured (of_property_count_elems_of_size will return -ENOSYS).

As you pointed out in the comment to v2:

It is OK if the "cooling-levels" is not defined in DT. However, if it
has broken definition, then we should return error. This is what we do
here.

> This is not acceptable. Also, if the call returns 0 you don't return
> an error but display a "Wrong data!" error message. Either it is an
> error or it is not, but not both.

This is an error. "cooling-levels" with zero elements is regarded as a
broken property.

> 
> Guenter

Best regards,
Lukasz Majewski

[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

[-- Attachment #2: Type: text/plain, Size: 153 bytes --]

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v3 7/8] hwmon: pwm-fan: Read PWM FAN configuration from device tree
  2015-02-08 21:36         ` Lukasz Majewski
  (?)
@ 2015-02-09  4:40           ` Guenter Roeck
  -1 siblings, 0 replies; 329+ messages in thread
From: Guenter Roeck @ 2015-02-09  4:40 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Lukasz Majewski, Eduardo Valentin, Kamil Debski, Jean Delvare,
	Kukjin Kim, lm-sensors, Linux PM list, linux-samsung-soc,
	devicetree, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

On 02/08/2015 01:36 PM, Lukasz Majewski wrote:
> On Fri, 6 Feb 2015 10:36:57 -0800
> Guenter Roeck <linux@roeck-us.net> wrote:
>
>> On Fri, Feb 06, 2015 at 05:59:07PM +0100, Lukasz Majewski wrote:
>>> This patch provides code for reading PWM FAN configuration data via
>>> device tree. The pwm-fan can work with full speed when configuration
>>> is not provided. However, errors are propagated when wrong DT
>>> bindings are found.
>>> Additionally the struct pwm_fan_ctx has been extended.
>>>
>>> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
>>> ---
>>> Changes for v2:
>>> - Rename pwm_fan_max_states to pwm_fan_cooling_levels
>>> - Moving pwm_fan_of_get_cooling_data() call after setting end
>>> enabling PWM FAN
>>> - pwm_fan_of_get_cooling_data() now can fail - preserving old
>>> behaviour
>>> - Remove unnecessary dev_err() call
>>> Changes for v3:
>>> - Patch's headline has been reedited
>>> - pwm_fan_of_get_cooling_data() return code is now being checked.
>>> - of_property_count_elems_of_size() is now used instead
>>> of_find_property()
>>> - More verbose patch description added
>>> ---
>>>   drivers/hwmon/pwm-fan.c | 54
>>> ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed,
>>> 53 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
>>> index 870e100..f3f5843 100644
>>> --- a/drivers/hwmon/pwm-fan.c
>>> +++ b/drivers/hwmon/pwm-fan.c
>>> @@ -30,7 +30,10 @@
>>>   struct pwm_fan_ctx {
>>>   	struct mutex lock;
>>>   	struct pwm_device *pwm;
>>> -	unsigned char pwm_value;
>>> +	unsigned int pwm_value;
>>> +	unsigned int pwm_fan_state;
>>> +	unsigned int pwm_fan_max_state;
>>> +	unsigned int *pwm_fan_cooling_levels;
>>>   };
>>>
>>>   static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
>>> @@ -100,6 +103,50 @@ static struct attribute *pwm_fan_attrs[] = {
>>>
>>>   ATTRIBUTE_GROUPS(pwm_fan);
>>>
>>> +int pwm_fan_of_get_cooling_data(struct device *dev, struct
>>> pwm_fan_ctx *ctx) +{
>>> +	struct device_node *np = dev->of_node;
>>> +	int num, i, ret;
>>> +
>>> +	ret = of_property_count_elems_of_size(np, "cooling-levels",
>>> +					      sizeof(u32));
>>> +
>>> +	if (ret == -EINVAL) {
>>> +		dev_err(dev, "Property 'cooling-levels' not
>>> found\n");
>>> +		return 0;
>>
>> Returning 0 is obviously not an error, otherwise you would not return
>> 0 here. So dev_err is wrong.
>
> pr_info would be more appropriate here.
>
>> Also, the message itself is wrong; the
>> property may well be there but have a wrong size.
>
> As fair as I remember the -EINVAL is set only when the property is not
> defined. Such situation is correct and our pwm-fan driver should work
> with or without it.
>

of_property_count_elems_of_size returns -EINVAL if np is NULL or if
there is no peoperty or prop->length % elem_size != 0, and -ENODATA
if there is no value associated with the property.

If -EINVAL is not an error, please no message. Noisy drivers are
just that, noisy.

>>
>>> +	}
>>> +
>>> +	if (ret <= 0) {
>>> +		dev_err(dev, "Wrong data!\n");
>>> +		return ret;
>>> +	}
>>
>> This will result in the driver failing to load if devicetree is not
>> configured (of_property_count_elems_of_size will return -ENOSYS).
>
> As you pointed out in the comment to v2:
>
> It is OK if the "cooling-levels" is not defined in DT. However, if it
> has broken definition, then we should return error. This is what we do
> here.
>
You don't return an error, you return 0, at least in some circumstances.

>> This is not acceptable. Also, if the call returns 0 you don't return
>> an error but display a "Wrong data!" error message. Either it is an
>> error or it is not, but not both.
>
> This is an error. "cooling-levels" with zero elements is regarded as a
> broken property.
>
It returns -ENOSYS if DT is not configured, which is still unacceptable.
And, again, if ret == 0 is an error, you should return an error code,
not display an error message and return 0.

Guenter


^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v3 7/8] hwmon: pwm-fan: Read PWM FAN configuration from device tree
@ 2015-02-09  4:40           ` Guenter Roeck
  0 siblings, 0 replies; 329+ messages in thread
From: Guenter Roeck @ 2015-02-09  4:40 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Lukasz Majewski, Eduardo Valentin, Kamil Debski, Jean Delvare,
	Kukjin Kim, lm-sensors, Linux PM list, linux-samsung-soc,
	devicetree, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

On 02/08/2015 01:36 PM, Lukasz Majewski wrote:
> On Fri, 6 Feb 2015 10:36:57 -0800
> Guenter Roeck <linux@roeck-us.net> wrote:
>
>> On Fri, Feb 06, 2015 at 05:59:07PM +0100, Lukasz Majewski wrote:
>>> This patch provides code for reading PWM FAN configuration data via
>>> device tree. The pwm-fan can work with full speed when configuration
>>> is not provided. However, errors are propagated when wrong DT
>>> bindings are found.
>>> Additionally the struct pwm_fan_ctx has been extended.
>>>
>>> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
>>> ---
>>> Changes for v2:
>>> - Rename pwm_fan_max_states to pwm_fan_cooling_levels
>>> - Moving pwm_fan_of_get_cooling_data() call after setting end
>>> enabling PWM FAN
>>> - pwm_fan_of_get_cooling_data() now can fail - preserving old
>>> behaviour
>>> - Remove unnecessary dev_err() call
>>> Changes for v3:
>>> - Patch's headline has been reedited
>>> - pwm_fan_of_get_cooling_data() return code is now being checked.
>>> - of_property_count_elems_of_size() is now used instead
>>> of_find_property()
>>> - More verbose patch description added
>>> ---
>>>   drivers/hwmon/pwm-fan.c | 54
>>> ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed,
>>> 53 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
>>> index 870e100..f3f5843 100644
>>> --- a/drivers/hwmon/pwm-fan.c
>>> +++ b/drivers/hwmon/pwm-fan.c
>>> @@ -30,7 +30,10 @@
>>>   struct pwm_fan_ctx {
>>>   	struct mutex lock;
>>>   	struct pwm_device *pwm;
>>> -	unsigned char pwm_value;
>>> +	unsigned int pwm_value;
>>> +	unsigned int pwm_fan_state;
>>> +	unsigned int pwm_fan_max_state;
>>> +	unsigned int *pwm_fan_cooling_levels;
>>>   };
>>>
>>>   static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
>>> @@ -100,6 +103,50 @@ static struct attribute *pwm_fan_attrs[] = {
>>>
>>>   ATTRIBUTE_GROUPS(pwm_fan);
>>>
>>> +int pwm_fan_of_get_cooling_data(struct device *dev, struct
>>> pwm_fan_ctx *ctx) +{
>>> +	struct device_node *np = dev->of_node;
>>> +	int num, i, ret;
>>> +
>>> +	ret = of_property_count_elems_of_size(np, "cooling-levels",
>>> +					      sizeof(u32));
>>> +
>>> +	if (ret == -EINVAL) {
>>> +		dev_err(dev, "Property 'cooling-levels' not
>>> found\n");
>>> +		return 0;
>>
>> Returning 0 is obviously not an error, otherwise you would not return
>> 0 here. So dev_err is wrong.
>
> pr_info would be more appropriate here.
>
>> Also, the message itself is wrong; the
>> property may well be there but have a wrong size.
>
> As fair as I remember the -EINVAL is set only when the property is not
> defined. Such situation is correct and our pwm-fan driver should work
> with or without it.
>

of_property_count_elems_of_size returns -EINVAL if np is NULL or if
there is no peoperty or prop->length % elem_size != 0, and -ENODATA
if there is no value associated with the property.

If -EINVAL is not an error, please no message. Noisy drivers are
just that, noisy.

>>
>>> +	}
>>> +
>>> +	if (ret <= 0) {
>>> +		dev_err(dev, "Wrong data!\n");
>>> +		return ret;
>>> +	}
>>
>> This will result in the driver failing to load if devicetree is not
>> configured (of_property_count_elems_of_size will return -ENOSYS).
>
> As you pointed out in the comment to v2:
>
> It is OK if the "cooling-levels" is not defined in DT. However, if it
> has broken definition, then we should return error. This is what we do
> here.
>
You don't return an error, you return 0, at least in some circumstances.

>> This is not acceptable. Also, if the call returns 0 you don't return
>> an error but display a "Wrong data!" error message. Either it is an
>> error or it is not, but not both.
>
> This is an error. "cooling-levels" with zero elements is regarded as a
> broken property.
>
It returns -ENOSYS if DT is not configured, which is still unacceptable.
And, again, if ret == 0 is an error, you should return an error code,
not display an error message and return 0.

Guenter

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [lm-sensors] [PATCH v3 7/8] hwmon: pwm-fan: Read PWM FAN configuration from device tree
@ 2015-02-09  4:40           ` Guenter Roeck
  0 siblings, 0 replies; 329+ messages in thread
From: Guenter Roeck @ 2015-02-09  4:40 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Lukasz Majewski, Eduardo Valentin, Kamil Debski, Jean Delvare,
	Kukjin Kim, lm-sensors, Linux PM list, linux-samsung-soc,
	devicetree, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

On 02/08/2015 01:36 PM, Lukasz Majewski wrote:
> On Fri, 6 Feb 2015 10:36:57 -0800
> Guenter Roeck <linux@roeck-us.net> wrote:
>
>> On Fri, Feb 06, 2015 at 05:59:07PM +0100, Lukasz Majewski wrote:
>>> This patch provides code for reading PWM FAN configuration data via
>>> device tree. The pwm-fan can work with full speed when configuration
>>> is not provided. However, errors are propagated when wrong DT
>>> bindings are found.
>>> Additionally the struct pwm_fan_ctx has been extended.
>>>
>>> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
>>> ---
>>> Changes for v2:
>>> - Rename pwm_fan_max_states to pwm_fan_cooling_levels
>>> - Moving pwm_fan_of_get_cooling_data() call after setting end
>>> enabling PWM FAN
>>> - pwm_fan_of_get_cooling_data() now can fail - preserving old
>>> behaviour
>>> - Remove unnecessary dev_err() call
>>> Changes for v3:
>>> - Patch's headline has been reedited
>>> - pwm_fan_of_get_cooling_data() return code is now being checked.
>>> - of_property_count_elems_of_size() is now used instead
>>> of_find_property()
>>> - More verbose patch description added
>>> ---
>>>   drivers/hwmon/pwm-fan.c | 54
>>> ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed,
>>> 53 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
>>> index 870e100..f3f5843 100644
>>> --- a/drivers/hwmon/pwm-fan.c
>>> +++ b/drivers/hwmon/pwm-fan.c
>>> @@ -30,7 +30,10 @@
>>>   struct pwm_fan_ctx {
>>>   	struct mutex lock;
>>>   	struct pwm_device *pwm;
>>> -	unsigned char pwm_value;
>>> +	unsigned int pwm_value;
>>> +	unsigned int pwm_fan_state;
>>> +	unsigned int pwm_fan_max_state;
>>> +	unsigned int *pwm_fan_cooling_levels;
>>>   };
>>>
>>>   static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
>>> @@ -100,6 +103,50 @@ static struct attribute *pwm_fan_attrs[] = {
>>>
>>>   ATTRIBUTE_GROUPS(pwm_fan);
>>>
>>> +int pwm_fan_of_get_cooling_data(struct device *dev, struct
>>> pwm_fan_ctx *ctx) +{
>>> +	struct device_node *np = dev->of_node;
>>> +	int num, i, ret;
>>> +
>>> +	ret = of_property_count_elems_of_size(np, "cooling-levels",
>>> +					      sizeof(u32));
>>> +
>>> +	if (ret = -EINVAL) {
>>> +		dev_err(dev, "Property 'cooling-levels' not
>>> found\n");
>>> +		return 0;
>>
>> Returning 0 is obviously not an error, otherwise you would not return
>> 0 here. So dev_err is wrong.
>
> pr_info would be more appropriate here.
>
>> Also, the message itself is wrong; the
>> property may well be there but have a wrong size.
>
> As fair as I remember the -EINVAL is set only when the property is not
> defined. Such situation is correct and our pwm-fan driver should work
> with or without it.
>

of_property_count_elems_of_size returns -EINVAL if np is NULL or if
there is no peoperty or prop->length % elem_size != 0, and -ENODATA
if there is no value associated with the property.

If -EINVAL is not an error, please no message. Noisy drivers are
just that, noisy.

>>
>>> +	}
>>> +
>>> +	if (ret <= 0) {
>>> +		dev_err(dev, "Wrong data!\n");
>>> +		return ret;
>>> +	}
>>
>> This will result in the driver failing to load if devicetree is not
>> configured (of_property_count_elems_of_size will return -ENOSYS).
>
> As you pointed out in the comment to v2:
>
> It is OK if the "cooling-levels" is not defined in DT. However, if it
> has broken definition, then we should return error. This is what we do
> here.
>
You don't return an error, you return 0, at least in some circumstances.

>> This is not acceptable. Also, if the call returns 0 you don't return
>> an error but display a "Wrong data!" error message. Either it is an
>> error or it is not, but not both.
>
> This is an error. "cooling-levels" with zero elements is regarded as a
> broken property.
>
It returns -ENOSYS if DT is not configured, which is still unacceptable.
And, again, if ret = 0 is an error, you should return an error code,
not display an error message and return 0.

Guenter


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 329+ messages in thread

* [PATCH v4 0/8] hwmon: thermal: Odroid U3: Provide support for Odroid U3 fan
  2014-12-18 10:13 ` Lukasz Majewski
  (?)
@ 2015-02-18 10:07   ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-18 10:07 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

Presented patches add support for Odroid's U3 optional CPU FAN, which uses PWM
subsystem for low level control.

After successful probe it registers itself as a cooling device for thermal
subsystem. To preserve the ability to use this fan as a PWM device stubs for
thermal_of_cooling_device_register() and thermal_cdev_update() have been added.

Additionally, devices without support for DTS are still supported.

To provide correct functionality, new properties to device tree description for 
Exynos4412 and in particular Odroid U3 have been added.

Those patches were tested on Exynos4412 - Odroid U3 board.

Patches were applied on:
linux-soc-thermal/next branch (Linux 3.19-rc5)
SHA1: 252454f5cbda2c6b40c5d36f58cac2938437b85d

Kamil Debski (1):
  ARM: dts: Add pwm-fan node to the Odroid-U3 board

Lukasz Majewski (7):
  thermal: Provide stub for thermal_of_cooling_device_register()
    function
  thermal: Provide stub for thermal_cdev_update() function
  Documentation: dts: Documentation entry to explain how to use PWM FAN
    as a cooling device
  ARM: dts: Add properties to use pwm-fan device as a cooling device in
    Odroid U3
  hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty
    cycle
  hwmon: pwm-fan: Read PWM FAN configuration from device tree
  hwmon: pwm-fan: Code for using PWM FAN as a cooling device

 .../devicetree/bindings/hwmon/pwm-fan.txt          |  20 +++
 arch/arm/boot/dts/exynos4.dtsi                     |   2 +-
 arch/arm/boot/dts/exynos4412-odroidu3.dts          |  44 ++++++
 drivers/hwmon/pwm-fan.c                            | 167 +++++++++++++++++++--
 include/linux/thermal.h                            |  22 ++-
 5 files changed, 236 insertions(+), 19 deletions(-)

-- 
2.0.0.rc2


^ permalink raw reply	[flat|nested] 329+ messages in thread

* [PATCH v4 0/8] hwmon: thermal: Odroid U3: Provide support for Odroid U3 fan
@ 2015-02-18 10:07   ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-18 10:07 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

Presented patches add support for Odroid's U3 optional CPU FAN, which uses PWM
subsystem for low level control.

After successful probe it registers itself as a cooling device for thermal
subsystem. To preserve the ability to use this fan as a PWM device stubs for
thermal_of_cooling_device_register() and thermal_cdev_update() have been added.

Additionally, devices without support for DTS are still supported.

To provide correct functionality, new properties to device tree description for 
Exynos4412 and in particular Odroid U3 have been added.

Those patches were tested on Exynos4412 - Odroid U3 board.

Patches were applied on:
linux-soc-thermal/next branch (Linux 3.19-rc5)
SHA1: 252454f5cbda2c6b40c5d36f58cac2938437b85d

Kamil Debski (1):
  ARM: dts: Add pwm-fan node to the Odroid-U3 board

Lukasz Majewski (7):
  thermal: Provide stub for thermal_of_cooling_device_register()
    function
  thermal: Provide stub for thermal_cdev_update() function
  Documentation: dts: Documentation entry to explain how to use PWM FAN
    as a cooling device
  ARM: dts: Add properties to use pwm-fan device as a cooling device in
    Odroid U3
  hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty
    cycle
  hwmon: pwm-fan: Read PWM FAN configuration from device tree
  hwmon: pwm-fan: Code for using PWM FAN as a cooling device

 .../devicetree/bindings/hwmon/pwm-fan.txt          |  20 +++
 arch/arm/boot/dts/exynos4.dtsi                     |   2 +-
 arch/arm/boot/dts/exynos4412-odroidu3.dts          |  44 ++++++
 drivers/hwmon/pwm-fan.c                            | 167 +++++++++++++++++++--
 include/linux/thermal.h                            |  22 ++-
 5 files changed, 236 insertions(+), 19 deletions(-)

-- 
2.0.0.rc2


^ permalink raw reply	[flat|nested] 329+ messages in thread

* [lm-sensors] [PATCH v4 0/8] hwmon: thermal: Odroid U3: Provide support for Odroid U3 fan
@ 2015-02-18 10:07   ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-18 10:07 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

Presented patches add support for Odroid's U3 optional CPU FAN, which uses PWM
subsystem for low level control.

After successful probe it registers itself as a cooling device for thermal
subsystem. To preserve the ability to use this fan as a PWM device stubs for
thermal_of_cooling_device_register() and thermal_cdev_update() have been added.

Additionally, devices without support for DTS are still supported.

To provide correct functionality, new properties to device tree description for 
Exynos4412 and in particular Odroid U3 have been added.

Those patches were tested on Exynos4412 - Odroid U3 board.

Patches were applied on:
linux-soc-thermal/next branch (Linux 3.19-rc5)
SHA1: 252454f5cbda2c6b40c5d36f58cac2938437b85d

Kamil Debski (1):
  ARM: dts: Add pwm-fan node to the Odroid-U3 board

Lukasz Majewski (7):
  thermal: Provide stub for thermal_of_cooling_device_register()
    function
  thermal: Provide stub for thermal_cdev_update() function
  Documentation: dts: Documentation entry to explain how to use PWM FAN
    as a cooling device
  ARM: dts: Add properties to use pwm-fan device as a cooling device in
    Odroid U3
  hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty
    cycle
  hwmon: pwm-fan: Read PWM FAN configuration from device tree
  hwmon: pwm-fan: Code for using PWM FAN as a cooling device

 .../devicetree/bindings/hwmon/pwm-fan.txt          |  20 +++
 arch/arm/boot/dts/exynos4.dtsi                     |   2 +-
 arch/arm/boot/dts/exynos4412-odroidu3.dts          |  44 ++++++
 drivers/hwmon/pwm-fan.c                            | 167 +++++++++++++++++++--
 include/linux/thermal.h                            |  22 ++-
 5 files changed, 236 insertions(+), 19 deletions(-)

-- 
2.0.0.rc2


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 329+ messages in thread

* [PATCH v4 1/8] thermal: Provide stub for thermal_of_cooling_device_register() function
  2015-02-18 10:07   ` Lukasz Majewski
  (?)
@ 2015-02-18 10:07     ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-18 10:07 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

Odroid U3 fan can work without being registered as OF cooling device
(with CONFIG_THERMAL_OF disabled).
In this situation it can be controlled via PWM entry at
/sys/class/hwmon/hwmon0/pwm1.

Therefore, the thermal_of_cooling_device_register() function needs a stub
to allow clean compilation.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- Provide stub declaration when CONFIG_THERMAL is not set
Changes for v4:
- None
---
 include/linux/thermal.h | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index fc52e30..eacf2de 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -293,6 +293,20 @@ struct thermal_trip {
 };
 
 /* Function declarations */
+#ifdef CONFIG_THERMAL
+struct thermal_cooling_device *
+thermal_of_cooling_device_register(struct device_node *np,
+				   char *type, void *devdata,
+				   const struct thermal_cooling_device_ops *);
+#else
+static inline struct thermal_cooling_device *
+thermal_of_cooling_device_register(struct device_node *np,
+				   char *type, void *devdata,
+				   const struct thermal_cooling_device_ops *ops)
+{
+	return NULL;
+}
+#endif
 #ifdef CONFIG_THERMAL_OF
 struct thermal_zone_device *
 thermal_zone_of_sensor_register(struct device *dev, int id, void *data,
@@ -328,9 +342,6 @@ void thermal_zone_device_update(struct thermal_zone_device *);
 
 struct thermal_cooling_device *thermal_cooling_device_register(char *, void *,
 		const struct thermal_cooling_device_ops *);
-struct thermal_cooling_device *
-thermal_of_cooling_device_register(struct device_node *np, char *, void *,
-				   const struct thermal_cooling_device_ops *);
 void thermal_cooling_device_unregister(struct thermal_cooling_device *);
 struct thermal_zone_device *thermal_zone_get_zone_by_name(const char *name);
 int thermal_zone_get_temp(struct thermal_zone_device *tz, unsigned long *temp);
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v4 1/8] thermal: Provide stub for thermal_of_cooling_device_register() function
@ 2015-02-18 10:07     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-18 10:07 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

Odroid U3 fan can work without being registered as OF cooling device
(with CONFIG_THERMAL_OF disabled).
In this situation it can be controlled via PWM entry at
/sys/class/hwmon/hwmon0/pwm1.

Therefore, the thermal_of_cooling_device_register() function needs a stub
to allow clean compilation.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- Provide stub declaration when CONFIG_THERMAL is not set
Changes for v4:
- None
---
 include/linux/thermal.h | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index fc52e30..eacf2de 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -293,6 +293,20 @@ struct thermal_trip {
 };
 
 /* Function declarations */
+#ifdef CONFIG_THERMAL
+struct thermal_cooling_device *
+thermal_of_cooling_device_register(struct device_node *np,
+				   char *type, void *devdata,
+				   const struct thermal_cooling_device_ops *);
+#else
+static inline struct thermal_cooling_device *
+thermal_of_cooling_device_register(struct device_node *np,
+				   char *type, void *devdata,
+				   const struct thermal_cooling_device_ops *ops)
+{
+	return NULL;
+}
+#endif
 #ifdef CONFIG_THERMAL_OF
 struct thermal_zone_device *
 thermal_zone_of_sensor_register(struct device *dev, int id, void *data,
@@ -328,9 +342,6 @@ void thermal_zone_device_update(struct thermal_zone_device *);
 
 struct thermal_cooling_device *thermal_cooling_device_register(char *, void *,
 		const struct thermal_cooling_device_ops *);
-struct thermal_cooling_device *
-thermal_of_cooling_device_register(struct device_node *np, char *, void *,
-				   const struct thermal_cooling_device_ops *);
 void thermal_cooling_device_unregister(struct thermal_cooling_device *);
 struct thermal_zone_device *thermal_zone_get_zone_by_name(const char *name);
 int thermal_zone_get_temp(struct thermal_zone_device *tz, unsigned long *temp);
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [lm-sensors] [PATCH v4 1/8] thermal: Provide stub for thermal_of_cooling_device_register() function
@ 2015-02-18 10:07     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-18 10:07 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

Odroid U3 fan can work without being registered as OF cooling device
(with CONFIG_THERMAL_OF disabled).
In this situation it can be controlled via PWM entry at
/sys/class/hwmon/hwmon0/pwm1.

Therefore, the thermal_of_cooling_device_register() function needs a stub
to allow clean compilation.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- Provide stub declaration when CONFIG_THERMAL is not set
Changes for v4:
- None
---
 include/linux/thermal.h | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index fc52e30..eacf2de 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -293,6 +293,20 @@ struct thermal_trip {
 };
 
 /* Function declarations */
+#ifdef CONFIG_THERMAL
+struct thermal_cooling_device *
+thermal_of_cooling_device_register(struct device_node *np,
+				   char *type, void *devdata,
+				   const struct thermal_cooling_device_ops *);
+#else
+static inline struct thermal_cooling_device *
+thermal_of_cooling_device_register(struct device_node *np,
+				   char *type, void *devdata,
+				   const struct thermal_cooling_device_ops *ops)
+{
+	return NULL;
+}
+#endif
 #ifdef CONFIG_THERMAL_OF
 struct thermal_zone_device *
 thermal_zone_of_sensor_register(struct device *dev, int id, void *data,
@@ -328,9 +342,6 @@ void thermal_zone_device_update(struct thermal_zone_device *);
 
 struct thermal_cooling_device *thermal_cooling_device_register(char *, void *,
 		const struct thermal_cooling_device_ops *);
-struct thermal_cooling_device *
-thermal_of_cooling_device_register(struct device_node *np, char *, void *,
-				   const struct thermal_cooling_device_ops *);
 void thermal_cooling_device_unregister(struct thermal_cooling_device *);
 struct thermal_zone_device *thermal_zone_get_zone_by_name(const char *name);
 int thermal_zone_get_temp(struct thermal_zone_device *tz, unsigned long *temp);
-- 
2.0.0.rc2


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v4 2/8] thermal: Provide stub for thermal_cdev_update() function
  2015-02-18 10:07   ` Lukasz Majewski
  (?)
@ 2015-02-18 10:07     ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-18 10:07 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

Odroid U3 fan can work without being registered as OF cooling device
(with CONFIG_THERMAL{_OF|} disabled).
In this situation it can be controlled via PWM entry at
/sys/class/hwmon/hwmon0/pwm1.

Therefore, the thermal_cdev_update() function needs a stub
to allow clean compilation.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- New patch
Changes for v3:
- thermal_cdev_update() now depends on CONFIG_THERMAL flag
Changes for v4:
- None
---
 include/linux/thermal.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index eacf2de..25382e6 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -298,6 +298,7 @@ struct thermal_cooling_device *
 thermal_of_cooling_device_register(struct device_node *np,
 				   char *type, void *devdata,
 				   const struct thermal_cooling_device_ops *);
+void thermal_cdev_update(struct thermal_cooling_device *);
 #else
 static inline struct thermal_cooling_device *
 thermal_of_cooling_device_register(struct device_node *np,
@@ -306,6 +307,9 @@ thermal_of_cooling_device_register(struct device_node *np,
 {
 	return NULL;
 }
+static inline void thermal_cdev_update(struct thermal_cooling_device *cdev)
+{
+}
 #endif
 #ifdef CONFIG_THERMAL_OF
 struct thermal_zone_device *
@@ -349,7 +353,6 @@ int thermal_zone_get_temp(struct thermal_zone_device *tz, unsigned long *temp);
 int get_tz_trend(struct thermal_zone_device *, int);
 struct thermal_instance *get_thermal_instance(struct thermal_zone_device *,
 		struct thermal_cooling_device *, int);
-void thermal_cdev_update(struct thermal_cooling_device *);
 void thermal_notify_framework(struct thermal_zone_device *, int);
 
 #ifdef CONFIG_NET
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v4 2/8] thermal: Provide stub for thermal_cdev_update() function
@ 2015-02-18 10:07     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-18 10:07 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

Odroid U3 fan can work without being registered as OF cooling device
(with CONFIG_THERMAL{_OF|} disabled).
In this situation it can be controlled via PWM entry at
/sys/class/hwmon/hwmon0/pwm1.

Therefore, the thermal_cdev_update() function needs a stub
to allow clean compilation.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- New patch
Changes for v3:
- thermal_cdev_update() now depends on CONFIG_THERMAL flag
Changes for v4:
- None
---
 include/linux/thermal.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index eacf2de..25382e6 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -298,6 +298,7 @@ struct thermal_cooling_device *
 thermal_of_cooling_device_register(struct device_node *np,
 				   char *type, void *devdata,
 				   const struct thermal_cooling_device_ops *);
+void thermal_cdev_update(struct thermal_cooling_device *);
 #else
 static inline struct thermal_cooling_device *
 thermal_of_cooling_device_register(struct device_node *np,
@@ -306,6 +307,9 @@ thermal_of_cooling_device_register(struct device_node *np,
 {
 	return NULL;
 }
+static inline void thermal_cdev_update(struct thermal_cooling_device *cdev)
+{
+}
 #endif
 #ifdef CONFIG_THERMAL_OF
 struct thermal_zone_device *
@@ -349,7 +353,6 @@ int thermal_zone_get_temp(struct thermal_zone_device *tz, unsigned long *temp);
 int get_tz_trend(struct thermal_zone_device *, int);
 struct thermal_instance *get_thermal_instance(struct thermal_zone_device *,
 		struct thermal_cooling_device *, int);
-void thermal_cdev_update(struct thermal_cooling_device *);
 void thermal_notify_framework(struct thermal_zone_device *, int);
 
 #ifdef CONFIG_NET
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [lm-sensors] [PATCH v4 2/8] thermal: Provide stub for thermal_cdev_update() function
@ 2015-02-18 10:07     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-18 10:07 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

Odroid U3 fan can work without being registered as OF cooling device
(with CONFIG_THERMAL{_OF|} disabled).
In this situation it can be controlled via PWM entry at
/sys/class/hwmon/hwmon0/pwm1.

Therefore, the thermal_cdev_update() function needs a stub
to allow clean compilation.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- New patch
Changes for v3:
- thermal_cdev_update() now depends on CONFIG_THERMAL flag
Changes for v4:
- None
---
 include/linux/thermal.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index eacf2de..25382e6 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -298,6 +298,7 @@ struct thermal_cooling_device *
 thermal_of_cooling_device_register(struct device_node *np,
 				   char *type, void *devdata,
 				   const struct thermal_cooling_device_ops *);
+void thermal_cdev_update(struct thermal_cooling_device *);
 #else
 static inline struct thermal_cooling_device *
 thermal_of_cooling_device_register(struct device_node *np,
@@ -306,6 +307,9 @@ thermal_of_cooling_device_register(struct device_node *np,
 {
 	return NULL;
 }
+static inline void thermal_cdev_update(struct thermal_cooling_device *cdev)
+{
+}
 #endif
 #ifdef CONFIG_THERMAL_OF
 struct thermal_zone_device *
@@ -349,7 +353,6 @@ int thermal_zone_get_temp(struct thermal_zone_device *tz, unsigned long *temp);
 int get_tz_trend(struct thermal_zone_device *, int);
 struct thermal_instance *get_thermal_instance(struct thermal_zone_device *,
 		struct thermal_cooling_device *, int);
-void thermal_cdev_update(struct thermal_cooling_device *);
 void thermal_notify_framework(struct thermal_zone_device *, int);
 
 #ifdef CONFIG_NET
-- 
2.0.0.rc2


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v4 3/8] Documentation: dts: Documentation entry to explain how to use PWM FAN as a cooling device
  2015-02-18 10:07   ` Lukasz Majewski
  (?)
@ 2015-02-18 10:07     ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-18 10:07 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

Explanation of several properties, which allow PWM fan working as a cooling
device, have been embraced in this commit.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Rename cooling-pwm-values to cooling-levels
- Remove default-pulse-width property and stick to default hwmon policy
Changes for v3:
- Changing commit title from "hwmon: dts: Doc:" to "Documentation: dts"
- Remove unnecessary properties
- Set maximal cooling level to 230 instead of 255
Changes for v4:
- None
---
 Documentation/devicetree/bindings/hwmon/pwm-fan.txt | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
index 610757c..d53fe0c 100644
--- a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
+++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
@@ -3,10 +3,30 @@ Bindings for a fan connected to the PWM lines
 Required properties:
 - compatible	: "pwm-fan"
 - pwms		: the PWM that is used to control the PWM fan
+- cooling-levels      : PWM duty cycle values in a range from 0 to 255
+			which correspond to thermal cooling states
+
+Thorough description of the following bindings:
+		cooling-min-state = <0>;
+		cooling-max-state = <3>;
+		#cooling-cells = <2>;
+		thermal-zone {
+			cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				     trip = <&cpu_alert1>;
+				     cooling-device = <&fan0 0 1>;
+				};
+			};
+		};
+
+for PWM FAN used as cooling device can be found at:
+./Documentation/devicetree/bindings/thermal/thermal.txt
 
 Example:
 	pwm-fan {
 		compatible = "pwm-fan";
 		status = "okay";
 		pwms = <&pwm 0 10000 0>;
+		cooling-levels = <0 102 170 230>;
 	};
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v4 3/8] Documentation: dts: Documentation entry to explain how to use PWM FAN as a cooling device
@ 2015-02-18 10:07     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-18 10:07 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

Explanation of several properties, which allow PWM fan working as a cooling
device, have been embraced in this commit.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Rename cooling-pwm-values to cooling-levels
- Remove default-pulse-width property and stick to default hwmon policy
Changes for v3:
- Changing commit title from "hwmon: dts: Doc:" to "Documentation: dts"
- Remove unnecessary properties
- Set maximal cooling level to 230 instead of 255
Changes for v4:
- None
---
 Documentation/devicetree/bindings/hwmon/pwm-fan.txt | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
index 610757c..d53fe0c 100644
--- a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
+++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
@@ -3,10 +3,30 @@ Bindings for a fan connected to the PWM lines
 Required properties:
 - compatible	: "pwm-fan"
 - pwms		: the PWM that is used to control the PWM fan
+- cooling-levels      : PWM duty cycle values in a range from 0 to 255
+			which correspond to thermal cooling states
+
+Thorough description of the following bindings:
+		cooling-min-state = <0>;
+		cooling-max-state = <3>;
+		#cooling-cells = <2>;
+		thermal-zone {
+			cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				     trip = <&cpu_alert1>;
+				     cooling-device = <&fan0 0 1>;
+				};
+			};
+		};
+
+for PWM FAN used as cooling device can be found at:
+./Documentation/devicetree/bindings/thermal/thermal.txt
 
 Example:
 	pwm-fan {
 		compatible = "pwm-fan";
 		status = "okay";
 		pwms = <&pwm 0 10000 0>;
+		cooling-levels = <0 102 170 230>;
 	};
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [lm-sensors] [PATCH v4 3/8] Documentation: dts: Documentation entry to explain how to use PWM FAN as
@ 2015-02-18 10:07     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-18 10:07 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

Explanation of several properties, which allow PWM fan working as a cooling
device, have been embraced in this commit.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Rename cooling-pwm-values to cooling-levels
- Remove default-pulse-width property and stick to default hwmon policy
Changes for v3:
- Changing commit title from "hwmon: dts: Doc:" to "Documentation: dts"
- Remove unnecessary properties
- Set maximal cooling level to 230 instead of 255
Changes for v4:
- None
---
 Documentation/devicetree/bindings/hwmon/pwm-fan.txt | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
index 610757c..d53fe0c 100644
--- a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
+++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
@@ -3,10 +3,30 @@ Bindings for a fan connected to the PWM lines
 Required properties:
 - compatible	: "pwm-fan"
 - pwms		: the PWM that is used to control the PWM fan
+- cooling-levels      : PWM duty cycle values in a range from 0 to 255
+			which correspond to thermal cooling states
+
+Thorough description of the following bindings:
+		cooling-min-state = <0>;
+		cooling-max-state = <3>;
+		#cooling-cells = <2>;
+		thermal-zone {
+			cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				     trip = <&cpu_alert1>;
+				     cooling-device = <&fan0 0 1>;
+				};
+			};
+		};
+
+for PWM FAN used as cooling device can be found at:
+./Documentation/devicetree/bindings/thermal/thermal.txt
 
 Example:
 	pwm-fan {
 		compatible = "pwm-fan";
 		status = "okay";
 		pwms = <&pwm 0 10000 0>;
+		cooling-levels = <0 102 170 230>;
 	};
-- 
2.0.0.rc2


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v4 4/8] ARM: dts: Add pwm-fan node to the Odroid-U3 board
  2015-02-18 10:07   ` Lukasz Majewski
  (?)
@ 2015-02-18 10:07     ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-18 10:07 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

From: Kamil Debski <k.debski@samsung.com>

Add pwm-fan node to the Odroid-U3 board file to enable PWM control of the
cooling fan. In addition, add the "pwm" label to the pwm@139D0000 node
in the exynos4412.dtsi.

Signed-off-by: Kamil Debski <k.debski@samsung.com>
[Rebased on the newest mainline by l.majewski@samsung.com]
---
Changes since v1:
- added pwm label to the pwm@139D0000 node in exynos4.dtsi
- use the pwm label in the exynos4412-odroidu3.dts
- change order or properties in the pwn-fan node, to be sorted
  in alphabetical order

---
 arch/arm/boot/dts/exynos4.dtsi            |  2 +-
 arch/arm/boot/dts/exynos4412-odroidu3.dts | 13 +++++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/exynos4.dtsi b/arch/arm/boot/dts/exynos4.dtsi
index f18d746..75266e3 100644
--- a/arch/arm/boot/dts/exynos4.dtsi
+++ b/arch/arm/boot/dts/exynos4.dtsi
@@ -582,7 +582,7 @@
 		status = "disabled";
 	};
 
-	pwm@139D0000 {
+	pwm: pwm@139D0000 {
 		compatible = "samsung,exynos4210-pwm";
 		reg = <0x139D0000 0x1000>;
 		interrupts = <0 37 0>, <0 38 0>, <0 39 0>, <0 40 0>, <0 41 0>;
diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
index c8a64be..60bd1e4 100644
--- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
+++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
@@ -31,6 +31,19 @@
 			linux,default-trigger = "heartbeat";
 		};
 	};
+
+	pwm-fan {
+		compatible = "pwm-fan";
+		pwms = <&pwm 0 10000 0>;
+		status = "okay";
+	};
+};
+
+&pwm {
+	pinctrl-0 = <&pwm0_out>;
+	pinctrl-names = "default";
+	samsung,pwm-outputs = <0>;
+	status = "okay";
 };
 
 &usb3503 {
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v4 4/8] ARM: dts: Add pwm-fan node to the Odroid-U3 board
@ 2015-02-18 10:07     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-18 10:07 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

From: Kamil Debski <k.debski@samsung.com>

Add pwm-fan node to the Odroid-U3 board file to enable PWM control of the
cooling fan. In addition, add the "pwm" label to the pwm@139D0000 node
in the exynos4412.dtsi.

Signed-off-by: Kamil Debski <k.debski@samsung.com>
[Rebased on the newest mainline by l.majewski@samsung.com]
---
Changes since v1:
- added pwm label to the pwm@139D0000 node in exynos4.dtsi
- use the pwm label in the exynos4412-odroidu3.dts
- change order or properties in the pwn-fan node, to be sorted
  in alphabetical order

---
 arch/arm/boot/dts/exynos4.dtsi            |  2 +-
 arch/arm/boot/dts/exynos4412-odroidu3.dts | 13 +++++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/exynos4.dtsi b/arch/arm/boot/dts/exynos4.dtsi
index f18d746..75266e3 100644
--- a/arch/arm/boot/dts/exynos4.dtsi
+++ b/arch/arm/boot/dts/exynos4.dtsi
@@ -582,7 +582,7 @@
 		status = "disabled";
 	};
 
-	pwm@139D0000 {
+	pwm: pwm@139D0000 {
 		compatible = "samsung,exynos4210-pwm";
 		reg = <0x139D0000 0x1000>;
 		interrupts = <0 37 0>, <0 38 0>, <0 39 0>, <0 40 0>, <0 41 0>;
diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
index c8a64be..60bd1e4 100644
--- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
+++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
@@ -31,6 +31,19 @@
 			linux,default-trigger = "heartbeat";
 		};
 	};
+
+	pwm-fan {
+		compatible = "pwm-fan";
+		pwms = <&pwm 0 10000 0>;
+		status = "okay";
+	};
+};
+
+&pwm {
+	pinctrl-0 = <&pwm0_out>;
+	pinctrl-names = "default";
+	samsung,pwm-outputs = <0>;
+	status = "okay";
 };
 
 &usb3503 {
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [lm-sensors] [PATCH v4 4/8] ARM: dts: Add pwm-fan node to the Odroid-U3 board
@ 2015-02-18 10:07     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-18 10:07 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

From: Kamil Debski <k.debski@samsung.com>

Add pwm-fan node to the Odroid-U3 board file to enable PWM control of the
cooling fan. In addition, add the "pwm" label to the pwm@139D0000 node
in the exynos4412.dtsi.

Signed-off-by: Kamil Debski <k.debski@samsung.com>
[Rebased on the newest mainline by l.majewski@samsung.com]
---
Changes since v1:
- added pwm label to the pwm@139D0000 node in exynos4.dtsi
- use the pwm label in the exynos4412-odroidu3.dts
- change order or properties in the pwn-fan node, to be sorted
  in alphabetical order

---
 arch/arm/boot/dts/exynos4.dtsi            |  2 +-
 arch/arm/boot/dts/exynos4412-odroidu3.dts | 13 +++++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/exynos4.dtsi b/arch/arm/boot/dts/exynos4.dtsi
index f18d746..75266e3 100644
--- a/arch/arm/boot/dts/exynos4.dtsi
+++ b/arch/arm/boot/dts/exynos4.dtsi
@@ -582,7 +582,7 @@
 		status = "disabled";
 	};
 
-	pwm@139D0000 {
+	pwm: pwm@139D0000 {
 		compatible = "samsung,exynos4210-pwm";
 		reg = <0x139D0000 0x1000>;
 		interrupts = <0 37 0>, <0 38 0>, <0 39 0>, <0 40 0>, <0 41 0>;
diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
index c8a64be..60bd1e4 100644
--- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
+++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
@@ -31,6 +31,19 @@
 			linux,default-trigger = "heartbeat";
 		};
 	};
+
+	pwm-fan {
+		compatible = "pwm-fan";
+		pwms = <&pwm 0 10000 0>;
+		status = "okay";
+	};
+};
+
+&pwm {
+	pinctrl-0 = <&pwm0_out>;
+	pinctrl-names = "default";
+	samsung,pwm-outputs = <0>;
+	status = "okay";
 };
 
 &usb3503 {
-- 
2.0.0.rc2


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v4 5/8] ARM: dts: Add properties to use pwm-fan device as a cooling device in Odroid U3
  2015-02-18 10:07   ` Lukasz Majewski
  (?)
@ 2015-02-18 10:07     ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-18 10:07 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

With those bindings it is possible to use pwm-fan device available in
Odroid U3 as a cooling device.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Rename cooling-pwm-values property to cooling-levels
Changes for v3:
- Change patch's topic to "ARM dts"
- Reduce maximal cooling-level to 230 from 255
Changes for v4:
- None
---
 arch/arm/boot/dts/exynos4412-odroidu3.dts | 33 ++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
index 60bd1e4..3e5df3e 100644
--- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
+++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
@@ -32,11 +32,42 @@
 		};
 	};
 
-	pwm-fan {
+	fan0: pwm-fan {
 		compatible = "pwm-fan";
 		pwms = <&pwm 0 10000 0>;
+		cooling-min-state = <0>;
+		cooling-max-state = <3>;
+		#cooling-cells = <2>;
+		cooling-levels = <0 102 170 230>;
 		status = "okay";
 	};
+
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				     trip = <&cpu_alert1>;
+				     cooling-device = <&cpu0 7 7>;
+				};
+				map1 {
+				     trip = <&cpu_alert2>;
+				     cooling-device = <&cpu0 13 13>;
+				};
+				map2 {
+				     trip = <&cpu_alert0>;
+				     cooling-device = <&fan0 0 1>;
+				};
+				map3 {
+				     trip = <&cpu_alert1>;
+				     cooling-device = <&fan0 1 2>;
+				};
+				map4 {
+				     trip = <&cpu_alert2>;
+				     cooling-device = <&fan0 2 3>;
+				};
+			};
+		};
+	};
 };
 
 &pwm {
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v4 5/8] ARM: dts: Add properties to use pwm-fan device as a cooling device in Odroid U3
@ 2015-02-18 10:07     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-18 10:07 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

With those bindings it is possible to use pwm-fan device available in
Odroid U3 as a cooling device.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Rename cooling-pwm-values property to cooling-levels
Changes for v3:
- Change patch's topic to "ARM dts"
- Reduce maximal cooling-level to 230 from 255
Changes for v4:
- None
---
 arch/arm/boot/dts/exynos4412-odroidu3.dts | 33 ++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
index 60bd1e4..3e5df3e 100644
--- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
+++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
@@ -32,11 +32,42 @@
 		};
 	};
 
-	pwm-fan {
+	fan0: pwm-fan {
 		compatible = "pwm-fan";
 		pwms = <&pwm 0 10000 0>;
+		cooling-min-state = <0>;
+		cooling-max-state = <3>;
+		#cooling-cells = <2>;
+		cooling-levels = <0 102 170 230>;
 		status = "okay";
 	};
+
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				     trip = <&cpu_alert1>;
+				     cooling-device = <&cpu0 7 7>;
+				};
+				map1 {
+				     trip = <&cpu_alert2>;
+				     cooling-device = <&cpu0 13 13>;
+				};
+				map2 {
+				     trip = <&cpu_alert0>;
+				     cooling-device = <&fan0 0 1>;
+				};
+				map3 {
+				     trip = <&cpu_alert1>;
+				     cooling-device = <&fan0 1 2>;
+				};
+				map4 {
+				     trip = <&cpu_alert2>;
+				     cooling-device = <&fan0 2 3>;
+				};
+			};
+		};
+	};
 };
 
 &pwm {
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [lm-sensors] [PATCH v4 5/8] ARM: dts: Add properties to use pwm-fan device as a cooling device in Od
@ 2015-02-18 10:07     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-18 10:07 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

With those bindings it is possible to use pwm-fan device available in
Odroid U3 as a cooling device.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Rename cooling-pwm-values property to cooling-levels
Changes for v3:
- Change patch's topic to "ARM dts"
- Reduce maximal cooling-level to 230 from 255
Changes for v4:
- None
---
 arch/arm/boot/dts/exynos4412-odroidu3.dts | 33 ++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
index 60bd1e4..3e5df3e 100644
--- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
+++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
@@ -32,11 +32,42 @@
 		};
 	};
 
-	pwm-fan {
+	fan0: pwm-fan {
 		compatible = "pwm-fan";
 		pwms = <&pwm 0 10000 0>;
+		cooling-min-state = <0>;
+		cooling-max-state = <3>;
+		#cooling-cells = <2>;
+		cooling-levels = <0 102 170 230>;
 		status = "okay";
 	};
+
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				     trip = <&cpu_alert1>;
+				     cooling-device = <&cpu0 7 7>;
+				};
+				map1 {
+				     trip = <&cpu_alert2>;
+				     cooling-device = <&cpu0 13 13>;
+				};
+				map2 {
+				     trip = <&cpu_alert0>;
+				     cooling-device = <&fan0 0 1>;
+				};
+				map3 {
+				     trip = <&cpu_alert1>;
+				     cooling-device = <&fan0 1 2>;
+				};
+				map4 {
+				     trip = <&cpu_alert2>;
+				     cooling-device = <&fan0 2 3>;
+				};
+			};
+		};
+	};
 };
 
 &pwm {
-- 
2.0.0.rc2


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v4 6/8] hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty cycle
  2015-02-18 10:07   ` Lukasz Majewski
  (?)
@ 2015-02-18 10:07     ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-18 10:07 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

It was necessary to decouple code handling writing to sysfs from the one
responsible for setting PWM of the fan.
Due to that, new __set_pwm() method was extracted, which is responsible for
only setting new PWM duty cycle.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- The commit headline has been reedited.
Changes for v4:
- Protect "if (ctx->pwm_value == pwm)" with ctx lock
- Initialize ret with zero
---
 drivers/hwmon/pwm-fan.c | 33 +++++++++++++++++++++------------
 1 file changed, 21 insertions(+), 12 deletions(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index 1991d903..bd42d39 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -33,20 +33,14 @@ struct pwm_fan_ctx {
 	unsigned char pwm_value;
 };
 
-static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
-		       const char *buf, size_t count)
+static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
 {
-	struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
-	unsigned long pwm, duty;
-	ssize_t ret;
-
-	if (kstrtoul(buf, 10, &pwm) || pwm > MAX_PWM)
-		return -EINVAL;
+	unsigned long duty;
+	int ret = 0;
 
 	mutex_lock(&ctx->lock);
-
 	if (ctx->pwm_value == pwm)
-		goto exit_set_pwm_no_change;
+		goto exit_set_pwm_err;
 
 	if (pwm == 0) {
 		pwm_disable(ctx->pwm);
@@ -66,13 +60,28 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 
 exit_set_pwm:
 	ctx->pwm_value = pwm;
-exit_set_pwm_no_change:
-	ret = count;
 exit_set_pwm_err:
 	mutex_unlock(&ctx->lock);
 	return ret;
 }
 
+static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
+		       const char *buf, size_t count)
+{
+	struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
+	unsigned long pwm;
+	int ret;
+
+	if (kstrtoul(buf, 10, &pwm) || pwm > MAX_PWM)
+		return -EINVAL;
+
+	ret = __set_pwm(ctx, pwm);
+	if (ret)
+		return ret;
+
+	return count;
+}
+
 static ssize_t show_pwm(struct device *dev,
 			struct device_attribute *attr, char *buf)
 {
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v4 6/8] hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty cycle
@ 2015-02-18 10:07     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-18 10:07 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

It was necessary to decouple code handling writing to sysfs from the one
responsible for setting PWM of the fan.
Due to that, new __set_pwm() method was extracted, which is responsible for
only setting new PWM duty cycle.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- The commit headline has been reedited.
Changes for v4:
- Protect "if (ctx->pwm_value == pwm)" with ctx lock
- Initialize ret with zero
---
 drivers/hwmon/pwm-fan.c | 33 +++++++++++++++++++++------------
 1 file changed, 21 insertions(+), 12 deletions(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index 1991d903..bd42d39 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -33,20 +33,14 @@ struct pwm_fan_ctx {
 	unsigned char pwm_value;
 };
 
-static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
-		       const char *buf, size_t count)
+static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
 {
-	struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
-	unsigned long pwm, duty;
-	ssize_t ret;
-
-	if (kstrtoul(buf, 10, &pwm) || pwm > MAX_PWM)
-		return -EINVAL;
+	unsigned long duty;
+	int ret = 0;
 
 	mutex_lock(&ctx->lock);
-
 	if (ctx->pwm_value == pwm)
-		goto exit_set_pwm_no_change;
+		goto exit_set_pwm_err;
 
 	if (pwm == 0) {
 		pwm_disable(ctx->pwm);
@@ -66,13 +60,28 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 
 exit_set_pwm:
 	ctx->pwm_value = pwm;
-exit_set_pwm_no_change:
-	ret = count;
 exit_set_pwm_err:
 	mutex_unlock(&ctx->lock);
 	return ret;
 }
 
+static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
+		       const char *buf, size_t count)
+{
+	struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
+	unsigned long pwm;
+	int ret;
+
+	if (kstrtoul(buf, 10, &pwm) || pwm > MAX_PWM)
+		return -EINVAL;
+
+	ret = __set_pwm(ctx, pwm);
+	if (ret)
+		return ret;
+
+	return count;
+}
+
 static ssize_t show_pwm(struct device *dev,
 			struct device_attribute *attr, char *buf)
 {
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [lm-sensors] [PATCH v4 6/8] hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty cyc
@ 2015-02-18 10:07     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-18 10:07 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

It was necessary to decouple code handling writing to sysfs from the one
responsible for setting PWM of the fan.
Due to that, new __set_pwm() method was extracted, which is responsible for
only setting new PWM duty cycle.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- The commit headline has been reedited.
Changes for v4:
- Protect "if (ctx->pwm_value = pwm)" with ctx lock
- Initialize ret with zero
---
 drivers/hwmon/pwm-fan.c | 33 +++++++++++++++++++++------------
 1 file changed, 21 insertions(+), 12 deletions(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index 1991d903..bd42d39 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -33,20 +33,14 @@ struct pwm_fan_ctx {
 	unsigned char pwm_value;
 };
 
-static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
-		       const char *buf, size_t count)
+static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
 {
-	struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
-	unsigned long pwm, duty;
-	ssize_t ret;
-
-	if (kstrtoul(buf, 10, &pwm) || pwm > MAX_PWM)
-		return -EINVAL;
+	unsigned long duty;
+	int ret = 0;
 
 	mutex_lock(&ctx->lock);
-
 	if (ctx->pwm_value = pwm)
-		goto exit_set_pwm_no_change;
+		goto exit_set_pwm_err;
 
 	if (pwm = 0) {
 		pwm_disable(ctx->pwm);
@@ -66,13 +60,28 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 
 exit_set_pwm:
 	ctx->pwm_value = pwm;
-exit_set_pwm_no_change:
-	ret = count;
 exit_set_pwm_err:
 	mutex_unlock(&ctx->lock);
 	return ret;
 }
 
+static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
+		       const char *buf, size_t count)
+{
+	struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
+	unsigned long pwm;
+	int ret;
+
+	if (kstrtoul(buf, 10, &pwm) || pwm > MAX_PWM)
+		return -EINVAL;
+
+	ret = __set_pwm(ctx, pwm);
+	if (ret)
+		return ret;
+
+	return count;
+}
+
 static ssize_t show_pwm(struct device *dev,
 			struct device_attribute *attr, char *buf)
 {
-- 
2.0.0.rc2


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v4 7/8] hwmon: pwm-fan: Read PWM FAN configuration from device tree
  2015-02-18 10:07   ` Lukasz Majewski
  (?)
@ 2015-02-18 10:07     ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-18 10:07 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

This patch provides code for reading PWM FAN configuration data via
device tree. The pwm-fan can work with full speed when configuration
is not provided. However, errors are propagated when wrong DT bindings
are found.
Additionally the struct pwm_fan_ctx has been extended.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Rename pwm_fan_max_states to pwm_fan_cooling_levels
- Moving pwm_fan_of_get_cooling_data() call after setting end enabling PWM FAN
- pwm_fan_of_get_cooling_data() now can fail - preserving old behaviour
- Remove unnecessary dev_err() call
Changes for v3:
- Patch's headline has been reedited
- pwm_fan_of_get_cooling_data() return code is now being checked.
- of_property_count_elems_of_size() is now used instead of_find_property()
- More verbose patch description added
Changes for v4:
- dev_err() has been removed from pwm_fan_of_get_cooling_data()
- Returning -EINVAL when "cooling-levels" are defined in DT, but doesn't
  have the value
---
 drivers/hwmon/pwm-fan.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 51 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index bd42d39..82cd06a 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -30,7 +30,10 @@
 struct pwm_fan_ctx {
 	struct mutex lock;
 	struct pwm_device *pwm;
-	unsigned char pwm_value;
+	unsigned int pwm_value;
+	unsigned int pwm_fan_state;
+	unsigned int pwm_fan_max_state;
+	unsigned int *pwm_fan_cooling_levels;
 };
 
 static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
@@ -100,6 +103,48 @@ static struct attribute *pwm_fan_attrs[] = {
 
 ATTRIBUTE_GROUPS(pwm_fan);
 
+int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
+{
+	struct device_node *np = dev->of_node;
+	int num, i, ret;
+
+	ret = of_property_count_elems_of_size(np, "cooling-levels",
+					      sizeof(u32));
+
+	if (ret == -EINVAL)
+		return 0;
+
+	if (ret <= 0) {
+		dev_err(dev, "Wrong data!\n");
+		return ret ? ret : -EINVAL;
+	}
+
+	num = ret;
+	ctx->pwm_fan_cooling_levels = devm_kzalloc(dev, num * sizeof(u32),
+						   GFP_KERNEL);
+	if (!ctx->pwm_fan_cooling_levels)
+		return -ENOMEM;
+
+	ret = of_property_read_u32_array(np, "cooling-levels",
+					 ctx->pwm_fan_cooling_levels, num);
+	if (ret) {
+		dev_err(dev, "Property 'cooling-levels' cannot be read!\n");
+		return ret;
+	}
+
+	for (i = 0; i < num; i++) {
+		if (ctx->pwm_fan_cooling_levels[i] > MAX_PWM) {
+			dev_err(dev, "PWM fan state[%d]:%d > %d\n", i,
+				ctx->pwm_fan_cooling_levels[i], MAX_PWM);
+			return -EINVAL;
+		}
+	}
+
+	ctx->pwm_fan_max_state = num - 1;
+
+	return 0;
+}
+
 static int pwm_fan_probe(struct platform_device *pdev)
 {
 	struct device *hwmon;
@@ -145,6 +190,11 @@ static int pwm_fan_probe(struct platform_device *pdev)
 		pwm_disable(ctx->pwm);
 		return PTR_ERR(hwmon);
 	}
+
+	ret = pwm_fan_of_get_cooling_data(&pdev->dev, ctx);
+	if (ret)
+		return ret;
+
 	return 0;
 }
 
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v4 7/8] hwmon: pwm-fan: Read PWM FAN configuration from device tree
@ 2015-02-18 10:07     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-18 10:07 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

This patch provides code for reading PWM FAN configuration data via
device tree. The pwm-fan can work with full speed when configuration
is not provided. However, errors are propagated when wrong DT bindings
are found.
Additionally the struct pwm_fan_ctx has been extended.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Rename pwm_fan_max_states to pwm_fan_cooling_levels
- Moving pwm_fan_of_get_cooling_data() call after setting end enabling PWM FAN
- pwm_fan_of_get_cooling_data() now can fail - preserving old behaviour
- Remove unnecessary dev_err() call
Changes for v3:
- Patch's headline has been reedited
- pwm_fan_of_get_cooling_data() return code is now being checked.
- of_property_count_elems_of_size() is now used instead of_find_property()
- More verbose patch description added
Changes for v4:
- dev_err() has been removed from pwm_fan_of_get_cooling_data()
- Returning -EINVAL when "cooling-levels" are defined in DT, but doesn't
  have the value
---
 drivers/hwmon/pwm-fan.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 51 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index bd42d39..82cd06a 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -30,7 +30,10 @@
 struct pwm_fan_ctx {
 	struct mutex lock;
 	struct pwm_device *pwm;
-	unsigned char pwm_value;
+	unsigned int pwm_value;
+	unsigned int pwm_fan_state;
+	unsigned int pwm_fan_max_state;
+	unsigned int *pwm_fan_cooling_levels;
 };
 
 static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
@@ -100,6 +103,48 @@ static struct attribute *pwm_fan_attrs[] = {
 
 ATTRIBUTE_GROUPS(pwm_fan);
 
+int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
+{
+	struct device_node *np = dev->of_node;
+	int num, i, ret;
+
+	ret = of_property_count_elems_of_size(np, "cooling-levels",
+					      sizeof(u32));
+
+	if (ret == -EINVAL)
+		return 0;
+
+	if (ret <= 0) {
+		dev_err(dev, "Wrong data!\n");
+		return ret ? ret : -EINVAL;
+	}
+
+	num = ret;
+	ctx->pwm_fan_cooling_levels = devm_kzalloc(dev, num * sizeof(u32),
+						   GFP_KERNEL);
+	if (!ctx->pwm_fan_cooling_levels)
+		return -ENOMEM;
+
+	ret = of_property_read_u32_array(np, "cooling-levels",
+					 ctx->pwm_fan_cooling_levels, num);
+	if (ret) {
+		dev_err(dev, "Property 'cooling-levels' cannot be read!\n");
+		return ret;
+	}
+
+	for (i = 0; i < num; i++) {
+		if (ctx->pwm_fan_cooling_levels[i] > MAX_PWM) {
+			dev_err(dev, "PWM fan state[%d]:%d > %d\n", i,
+				ctx->pwm_fan_cooling_levels[i], MAX_PWM);
+			return -EINVAL;
+		}
+	}
+
+	ctx->pwm_fan_max_state = num - 1;
+
+	return 0;
+}
+
 static int pwm_fan_probe(struct platform_device *pdev)
 {
 	struct device *hwmon;
@@ -145,6 +190,11 @@ static int pwm_fan_probe(struct platform_device *pdev)
 		pwm_disable(ctx->pwm);
 		return PTR_ERR(hwmon);
 	}
+
+	ret = pwm_fan_of_get_cooling_data(&pdev->dev, ctx);
+	if (ret)
+		return ret;
+
 	return 0;
 }
 
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [lm-sensors] [PATCH v4 7/8] hwmon: pwm-fan: Read PWM FAN configuration from device tree
@ 2015-02-18 10:07     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-18 10:07 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

This patch provides code for reading PWM FAN configuration data via
device tree. The pwm-fan can work with full speed when configuration
is not provided. However, errors are propagated when wrong DT bindings
are found.
Additionally the struct pwm_fan_ctx has been extended.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Rename pwm_fan_max_states to pwm_fan_cooling_levels
- Moving pwm_fan_of_get_cooling_data() call after setting end enabling PWM FAN
- pwm_fan_of_get_cooling_data() now can fail - preserving old behaviour
- Remove unnecessary dev_err() call
Changes for v3:
- Patch's headline has been reedited
- pwm_fan_of_get_cooling_data() return code is now being checked.
- of_property_count_elems_of_size() is now used instead of_find_property()
- More verbose patch description added
Changes for v4:
- dev_err() has been removed from pwm_fan_of_get_cooling_data()
- Returning -EINVAL when "cooling-levels" are defined in DT, but doesn't
  have the value
---
 drivers/hwmon/pwm-fan.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 51 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index bd42d39..82cd06a 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -30,7 +30,10 @@
 struct pwm_fan_ctx {
 	struct mutex lock;
 	struct pwm_device *pwm;
-	unsigned char pwm_value;
+	unsigned int pwm_value;
+	unsigned int pwm_fan_state;
+	unsigned int pwm_fan_max_state;
+	unsigned int *pwm_fan_cooling_levels;
 };
 
 static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
@@ -100,6 +103,48 @@ static struct attribute *pwm_fan_attrs[] = {
 
 ATTRIBUTE_GROUPS(pwm_fan);
 
+int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
+{
+	struct device_node *np = dev->of_node;
+	int num, i, ret;
+
+	ret = of_property_count_elems_of_size(np, "cooling-levels",
+					      sizeof(u32));
+
+	if (ret = -EINVAL)
+		return 0;
+
+	if (ret <= 0) {
+		dev_err(dev, "Wrong data!\n");
+		return ret ? ret : -EINVAL;
+	}
+
+	num = ret;
+	ctx->pwm_fan_cooling_levels = devm_kzalloc(dev, num * sizeof(u32),
+						   GFP_KERNEL);
+	if (!ctx->pwm_fan_cooling_levels)
+		return -ENOMEM;
+
+	ret = of_property_read_u32_array(np, "cooling-levels",
+					 ctx->pwm_fan_cooling_levels, num);
+	if (ret) {
+		dev_err(dev, "Property 'cooling-levels' cannot be read!\n");
+		return ret;
+	}
+
+	for (i = 0; i < num; i++) {
+		if (ctx->pwm_fan_cooling_levels[i] > MAX_PWM) {
+			dev_err(dev, "PWM fan state[%d]:%d > %d\n", i,
+				ctx->pwm_fan_cooling_levels[i], MAX_PWM);
+			return -EINVAL;
+		}
+	}
+
+	ctx->pwm_fan_max_state = num - 1;
+
+	return 0;
+}
+
 static int pwm_fan_probe(struct platform_device *pdev)
 {
 	struct device *hwmon;
@@ -145,6 +190,11 @@ static int pwm_fan_probe(struct platform_device *pdev)
 		pwm_disable(ctx->pwm);
 		return PTR_ERR(hwmon);
 	}
+
+	ret = pwm_fan_of_get_cooling_data(&pdev->dev, ctx);
+	if (ret)
+		return ret;
+
 	return 0;
 }
 
-- 
2.0.0.rc2


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v4 8/8] hwmon: pwm-fan: Code for using PWM FAN as a cooling device
  2015-02-18 10:07   ` Lukasz Majewski
  (?)
@ 2015-02-18 10:07     ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-18 10:07 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

The PWM FAN device can now be used as a thermal cooling device. Necessary
infrastructure has been added in this commit.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Replace pwm_fan_cooling_states with pwm_fan_cooling_levels
- Update ctx->pwm_fan_state when correct data from device tree is available
- Using therma_cdev_update() when thermal is ready for controlling the fan
Changes for v3:
- Rename patch heading
- pwm_fan_of_get_cooling_data() now returns -EINVAL when no "cooling-levels"
  property defined
- register of cooling device only when proper cooling data is present
Changed for v4:
- None
---
 drivers/hwmon/pwm-fan.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 83 insertions(+), 3 deletions(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index 82cd06a..622bcd1 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -24,6 +24,7 @@
 #include <linux/platform_device.h>
 #include <linux/pwm.h>
 #include <linux/sysfs.h>
+#include <linux/thermal.h>
 
 #define MAX_PWM 255
 
@@ -68,6 +69,17 @@ exit_set_pwm_err:
 	return ret;
 }
 
+static void pwm_fan_update_state(struct pwm_fan_ctx *ctx, unsigned long pwm)
+{
+	int i;
+
+	for (i = 0; i < ctx->pwm_fan_max_state; ++i)
+		if (pwm < ctx->pwm_fan_cooling_levels[i + 1])
+			break;
+
+	ctx->pwm_fan_state = i;
+}
+
 static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 		       const char *buf, size_t count)
 {
@@ -82,6 +94,7 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 	if (ret)
 		return ret;
 
+	pwm_fan_update_state(ctx, pwm);
 	return count;
 }
 
@@ -103,6 +116,59 @@ static struct attribute *pwm_fan_attrs[] = {
 
 ATTRIBUTE_GROUPS(pwm_fan);
 
+/* thermal cooling device callbacks */
+static int pwm_fan_get_max_state(struct thermal_cooling_device *cdev,
+				 unsigned long *state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+
+	*state = ctx->pwm_fan_max_state;
+
+	return 0;
+}
+
+static int pwm_fan_get_cur_state(struct thermal_cooling_device *cdev,
+				 unsigned long *state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+
+	if (!ctx)
+		return -EINVAL;
+
+	*state = ctx->pwm_fan_state;
+
+	return 0;
+}
+
+static int
+pwm_fan_set_cur_state(struct thermal_cooling_device *cdev, unsigned long state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+	int ret;
+
+	if (!ctx || (state > ctx->pwm_fan_max_state))
+		return -EINVAL;
+
+	if (state == ctx->pwm_fan_state)
+		return 0;
+
+	ret = __set_pwm(ctx, ctx->pwm_fan_cooling_levels[state]);
+	if (ret) {
+		dev_err(&cdev->device, "Cannot set pwm!\n");
+		return ret;
+	}
+
+	ctx->pwm_fan_state = state;
+
+	return ret;
+}
+
+static const struct thermal_cooling_device_ops pwm_fan_cooling_ops = {
+	.get_max_state = pwm_fan_get_max_state,
+	.get_cur_state = pwm_fan_get_cur_state,
+	.set_cur_state = pwm_fan_set_cur_state,
+};
+
 int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
 {
 	struct device_node *np = dev->of_node;
@@ -112,7 +178,7 @@ int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
 					      sizeof(u32));
 
 	if (ret == -EINVAL)
-		return 0;
+		return ret;
 
 	if (ret <= 0) {
 		dev_err(dev, "Wrong data!\n");
@@ -147,8 +213,9 @@ int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
 
 static int pwm_fan_probe(struct platform_device *pdev)
 {
-	struct device *hwmon;
+	struct thermal_cooling_device *cdev;
 	struct pwm_fan_ctx *ctx;
+	struct device *hwmon;
 	int duty_cycle;
 	int ret;
 
@@ -192,8 +259,21 @@ static int pwm_fan_probe(struct platform_device *pdev)
 	}
 
 	ret = pwm_fan_of_get_cooling_data(&pdev->dev, ctx);
-	if (ret)
+	if (!ret) {
+		ctx->pwm_fan_state = ctx->pwm_fan_max_state;
+		cdev = thermal_of_cooling_device_register(pdev->dev.of_node,
+							  "pwm-fan", ctx,
+							  &pwm_fan_cooling_ops);
+		if (IS_ERR(cdev)) {
+			dev_err(&pdev->dev,
+				"Failed to register pwm-fan as cooling device");
+			pwm_disable(ctx->pwm);
+			return PTR_ERR(cdev);
+		}
+		thermal_cdev_update(cdev);
+	} else if (ret != -EINVAL) {
 		return ret;
+	}
 
 	return 0;
 }
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v4 8/8] hwmon: pwm-fan: Code for using PWM FAN as a cooling device
@ 2015-02-18 10:07     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-18 10:07 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

The PWM FAN device can now be used as a thermal cooling device. Necessary
infrastructure has been added in this commit.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Replace pwm_fan_cooling_states with pwm_fan_cooling_levels
- Update ctx->pwm_fan_state when correct data from device tree is available
- Using therma_cdev_update() when thermal is ready for controlling the fan
Changes for v3:
- Rename patch heading
- pwm_fan_of_get_cooling_data() now returns -EINVAL when no "cooling-levels"
  property defined
- register of cooling device only when proper cooling data is present
Changed for v4:
- None
---
 drivers/hwmon/pwm-fan.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 83 insertions(+), 3 deletions(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index 82cd06a..622bcd1 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -24,6 +24,7 @@
 #include <linux/platform_device.h>
 #include <linux/pwm.h>
 #include <linux/sysfs.h>
+#include <linux/thermal.h>
 
 #define MAX_PWM 255
 
@@ -68,6 +69,17 @@ exit_set_pwm_err:
 	return ret;
 }
 
+static void pwm_fan_update_state(struct pwm_fan_ctx *ctx, unsigned long pwm)
+{
+	int i;
+
+	for (i = 0; i < ctx->pwm_fan_max_state; ++i)
+		if (pwm < ctx->pwm_fan_cooling_levels[i + 1])
+			break;
+
+	ctx->pwm_fan_state = i;
+}
+
 static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 		       const char *buf, size_t count)
 {
@@ -82,6 +94,7 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 	if (ret)
 		return ret;
 
+	pwm_fan_update_state(ctx, pwm);
 	return count;
 }
 
@@ -103,6 +116,59 @@ static struct attribute *pwm_fan_attrs[] = {
 
 ATTRIBUTE_GROUPS(pwm_fan);
 
+/* thermal cooling device callbacks */
+static int pwm_fan_get_max_state(struct thermal_cooling_device *cdev,
+				 unsigned long *state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+
+	*state = ctx->pwm_fan_max_state;
+
+	return 0;
+}
+
+static int pwm_fan_get_cur_state(struct thermal_cooling_device *cdev,
+				 unsigned long *state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+
+	if (!ctx)
+		return -EINVAL;
+
+	*state = ctx->pwm_fan_state;
+
+	return 0;
+}
+
+static int
+pwm_fan_set_cur_state(struct thermal_cooling_device *cdev, unsigned long state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+	int ret;
+
+	if (!ctx || (state > ctx->pwm_fan_max_state))
+		return -EINVAL;
+
+	if (state == ctx->pwm_fan_state)
+		return 0;
+
+	ret = __set_pwm(ctx, ctx->pwm_fan_cooling_levels[state]);
+	if (ret) {
+		dev_err(&cdev->device, "Cannot set pwm!\n");
+		return ret;
+	}
+
+	ctx->pwm_fan_state = state;
+
+	return ret;
+}
+
+static const struct thermal_cooling_device_ops pwm_fan_cooling_ops = {
+	.get_max_state = pwm_fan_get_max_state,
+	.get_cur_state = pwm_fan_get_cur_state,
+	.set_cur_state = pwm_fan_set_cur_state,
+};
+
 int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
 {
 	struct device_node *np = dev->of_node;
@@ -112,7 +178,7 @@ int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
 					      sizeof(u32));
 
 	if (ret == -EINVAL)
-		return 0;
+		return ret;
 
 	if (ret <= 0) {
 		dev_err(dev, "Wrong data!\n");
@@ -147,8 +213,9 @@ int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
 
 static int pwm_fan_probe(struct platform_device *pdev)
 {
-	struct device *hwmon;
+	struct thermal_cooling_device *cdev;
 	struct pwm_fan_ctx *ctx;
+	struct device *hwmon;
 	int duty_cycle;
 	int ret;
 
@@ -192,8 +259,21 @@ static int pwm_fan_probe(struct platform_device *pdev)
 	}
 
 	ret = pwm_fan_of_get_cooling_data(&pdev->dev, ctx);
-	if (ret)
+	if (!ret) {
+		ctx->pwm_fan_state = ctx->pwm_fan_max_state;
+		cdev = thermal_of_cooling_device_register(pdev->dev.of_node,
+							  "pwm-fan", ctx,
+							  &pwm_fan_cooling_ops);
+		if (IS_ERR(cdev)) {
+			dev_err(&pdev->dev,
+				"Failed to register pwm-fan as cooling device");
+			pwm_disable(ctx->pwm);
+			return PTR_ERR(cdev);
+		}
+		thermal_cdev_update(cdev);
+	} else if (ret != -EINVAL) {
 		return ret;
+	}
 
 	return 0;
 }
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [lm-sensors] [PATCH v4 8/8] hwmon: pwm-fan: Code for using PWM FAN as a cooling device
@ 2015-02-18 10:07     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-18 10:07 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

The PWM FAN device can now be used as a thermal cooling device. Necessary
infrastructure has been added in this commit.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Replace pwm_fan_cooling_states with pwm_fan_cooling_levels
- Update ctx->pwm_fan_state when correct data from device tree is available
- Using therma_cdev_update() when thermal is ready for controlling the fan
Changes for v3:
- Rename patch heading
- pwm_fan_of_get_cooling_data() now returns -EINVAL when no "cooling-levels"
  property defined
- register of cooling device only when proper cooling data is present
Changed for v4:
- None
---
 drivers/hwmon/pwm-fan.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 83 insertions(+), 3 deletions(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index 82cd06a..622bcd1 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -24,6 +24,7 @@
 #include <linux/platform_device.h>
 #include <linux/pwm.h>
 #include <linux/sysfs.h>
+#include <linux/thermal.h>
 
 #define MAX_PWM 255
 
@@ -68,6 +69,17 @@ exit_set_pwm_err:
 	return ret;
 }
 
+static void pwm_fan_update_state(struct pwm_fan_ctx *ctx, unsigned long pwm)
+{
+	int i;
+
+	for (i = 0; i < ctx->pwm_fan_max_state; ++i)
+		if (pwm < ctx->pwm_fan_cooling_levels[i + 1])
+			break;
+
+	ctx->pwm_fan_state = i;
+}
+
 static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 		       const char *buf, size_t count)
 {
@@ -82,6 +94,7 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 	if (ret)
 		return ret;
 
+	pwm_fan_update_state(ctx, pwm);
 	return count;
 }
 
@@ -103,6 +116,59 @@ static struct attribute *pwm_fan_attrs[] = {
 
 ATTRIBUTE_GROUPS(pwm_fan);
 
+/* thermal cooling device callbacks */
+static int pwm_fan_get_max_state(struct thermal_cooling_device *cdev,
+				 unsigned long *state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+
+	*state = ctx->pwm_fan_max_state;
+
+	return 0;
+}
+
+static int pwm_fan_get_cur_state(struct thermal_cooling_device *cdev,
+				 unsigned long *state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+
+	if (!ctx)
+		return -EINVAL;
+
+	*state = ctx->pwm_fan_state;
+
+	return 0;
+}
+
+static int
+pwm_fan_set_cur_state(struct thermal_cooling_device *cdev, unsigned long state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+	int ret;
+
+	if (!ctx || (state > ctx->pwm_fan_max_state))
+		return -EINVAL;
+
+	if (state = ctx->pwm_fan_state)
+		return 0;
+
+	ret = __set_pwm(ctx, ctx->pwm_fan_cooling_levels[state]);
+	if (ret) {
+		dev_err(&cdev->device, "Cannot set pwm!\n");
+		return ret;
+	}
+
+	ctx->pwm_fan_state = state;
+
+	return ret;
+}
+
+static const struct thermal_cooling_device_ops pwm_fan_cooling_ops = {
+	.get_max_state = pwm_fan_get_max_state,
+	.get_cur_state = pwm_fan_get_cur_state,
+	.set_cur_state = pwm_fan_set_cur_state,
+};
+
 int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
 {
 	struct device_node *np = dev->of_node;
@@ -112,7 +178,7 @@ int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
 					      sizeof(u32));
 
 	if (ret = -EINVAL)
-		return 0;
+		return ret;
 
 	if (ret <= 0) {
 		dev_err(dev, "Wrong data!\n");
@@ -147,8 +213,9 @@ int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
 
 static int pwm_fan_probe(struct platform_device *pdev)
 {
-	struct device *hwmon;
+	struct thermal_cooling_device *cdev;
 	struct pwm_fan_ctx *ctx;
+	struct device *hwmon;
 	int duty_cycle;
 	int ret;
 
@@ -192,8 +259,21 @@ static int pwm_fan_probe(struct platform_device *pdev)
 	}
 
 	ret = pwm_fan_of_get_cooling_data(&pdev->dev, ctx);
-	if (ret)
+	if (!ret) {
+		ctx->pwm_fan_state = ctx->pwm_fan_max_state;
+		cdev = thermal_of_cooling_device_register(pdev->dev.of_node,
+							  "pwm-fan", ctx,
+							  &pwm_fan_cooling_ops);
+		if (IS_ERR(cdev)) {
+			dev_err(&pdev->dev,
+				"Failed to register pwm-fan as cooling device");
+			pwm_disable(ctx->pwm);
+			return PTR_ERR(cdev);
+		}
+		thermal_cdev_update(cdev);
+	} else if (ret != -EINVAL) {
 		return ret;
+	}
 
 	return 0;
 }
-- 
2.0.0.rc2


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* Re: [PATCH v4 4/8] ARM: dts: Add pwm-fan node to the Odroid-U3 board
  2015-02-18 10:07     ` Lukasz Majewski
  (?)
@ 2015-02-18 13:16       ` Andreas Färber
  -1 siblings, 0 replies; 329+ messages in thread
From: Andreas Färber @ 2015-02-18 13:16 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck,
	Kukjin Kim, lm-sensors, Linux PM list, linux-samsung-soc,
	devicetree, Lukasz Majewski, Kukjin Kim, linux-kernel,
	Sjoerd Simons, Abhilash Kesavan, Abhilash Kesavan

Am 18.02.2015 um 11:07 schrieb Lukasz Majewski:
> From: Kamil Debski <k.debski@samsung.com>
> 
> Add pwm-fan node to the Odroid-U3 board file to enable PWM control of the
> cooling fan. In addition, add the "pwm" label to the pwm@139D0000 node
> in the exynos4412.dtsi.
> 
> Signed-off-by: Kamil Debski <k.debski@samsung.com>
> [Rebased on the newest mainline by l.majewski@samsung.com]

You need to sign off patches you submit.

> ---
> Changes since v1:
> - added pwm label to the pwm@139D0000 node in exynos4.dtsi
> - use the pwm label in the exynos4412-odroidu3.dts
> - change order or properties in the pwn-fan node, to be sorted
>   in alphabetical order
> 
> ---
>  arch/arm/boot/dts/exynos4.dtsi            |  2 +-
>  arch/arm/boot/dts/exynos4412-odroidu3.dts | 13 +++++++++++++
>  2 files changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/boot/dts/exynos4.dtsi b/arch/arm/boot/dts/exynos4.dtsi
> index f18d746..75266e3 100644
> --- a/arch/arm/boot/dts/exynos4.dtsi
> +++ b/arch/arm/boot/dts/exynos4.dtsi
> @@ -582,7 +582,7 @@
>  		status = "disabled";
>  	};
>  
> -	pwm@139D0000 {
> +	pwm: pwm@139D0000 {
>  		compatible = "samsung,exynos4210-pwm";
>  		reg = <0x139D0000 0x1000>;
>  		interrupts = <0 37 0>, <0 38 0>, <0 39 0>, <0 40 0>, <0 41 0>;
> diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
> index c8a64be..60bd1e4 100644
> --- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
> +++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
> @@ -31,6 +31,19 @@
>  			linux,default-trigger = "heartbeat";
>  		};
>  	};
> +
> +	pwm-fan {
> +		compatible = "pwm-fan";
> +		pwms = <&pwm 0 10000 0>;
> +		status = "okay";

Status "okay" is only needed for pre-existing nodes that would have
status "disabled" otherwise, such as below. Just drop it here.

Regards,
Andreas

> +	};
> +};
> +
> +&pwm {
> +	pinctrl-0 = <&pwm0_out>;
> +	pinctrl-names = "default";
> +	samsung,pwm-outputs = <0>;
> +	status = "okay";
>  };
>  
>  &usb3503 {
> 


-- 
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Jennifer Guild, Dilip Upmanyu,
Graham Norton; HRB 21284 (AG Nürnberg)

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v4 4/8] ARM: dts: Add pwm-fan node to the Odroid-U3 board
@ 2015-02-18 13:16       ` Andreas Färber
  0 siblings, 0 replies; 329+ messages in thread
From: Andreas Färber @ 2015-02-18 13:16 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck,
	Kukjin Kim, lm-sensors, Linux PM list, linux-samsung-soc,
	devicetree, Lukasz Majewski, Kukjin Kim, linux-kernel,
	Sjoerd Simons, Abhilash Kesavan, Abhilash Kesavan

Am 18.02.2015 um 11:07 schrieb Lukasz Majewski:
> From: Kamil Debski <k.debski@samsung.com>
> 
> Add pwm-fan node to the Odroid-U3 board file to enable PWM control of the
> cooling fan. In addition, add the "pwm" label to the pwm@139D0000 node
> in the exynos4412.dtsi.
> 
> Signed-off-by: Kamil Debski <k.debski@samsung.com>
> [Rebased on the newest mainline by l.majewski@samsung.com]

You need to sign off patches you submit.

> ---
> Changes since v1:
> - added pwm label to the pwm@139D0000 node in exynos4.dtsi
> - use the pwm label in the exynos4412-odroidu3.dts
> - change order or properties in the pwn-fan node, to be sorted
>   in alphabetical order
> 
> ---
>  arch/arm/boot/dts/exynos4.dtsi            |  2 +-
>  arch/arm/boot/dts/exynos4412-odroidu3.dts | 13 +++++++++++++
>  2 files changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/boot/dts/exynos4.dtsi b/arch/arm/boot/dts/exynos4.dtsi
> index f18d746..75266e3 100644
> --- a/arch/arm/boot/dts/exynos4.dtsi
> +++ b/arch/arm/boot/dts/exynos4.dtsi
> @@ -582,7 +582,7 @@
>  		status = "disabled";
>  	};
>  
> -	pwm@139D0000 {
> +	pwm: pwm@139D0000 {
>  		compatible = "samsung,exynos4210-pwm";
>  		reg = <0x139D0000 0x1000>;
>  		interrupts = <0 37 0>, <0 38 0>, <0 39 0>, <0 40 0>, <0 41 0>;
> diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
> index c8a64be..60bd1e4 100644
> --- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
> +++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
> @@ -31,6 +31,19 @@
>  			linux,default-trigger = "heartbeat";
>  		};
>  	};
> +
> +	pwm-fan {
> +		compatible = "pwm-fan";
> +		pwms = <&pwm 0 10000 0>;
> +		status = "okay";

Status "okay" is only needed for pre-existing nodes that would have
status "disabled" otherwise, such as below. Just drop it here.

Regards,
Andreas

> +	};
> +};
> +
> +&pwm {
> +	pinctrl-0 = <&pwm0_out>;
> +	pinctrl-names = "default";
> +	samsung,pwm-outputs = <0>;
> +	status = "okay";
>  };
>  
>  &usb3503 {
> 


-- 
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Jennifer Guild, Dilip Upmanyu,
Graham Norton; HRB 21284 (AG Nürnberg)

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [lm-sensors] [PATCH v4 4/8] ARM: dts: Add pwm-fan node to the Odroid-U3 board
@ 2015-02-18 13:16       ` Andreas Färber
  0 siblings, 0 replies; 329+ messages in thread
From: Andreas Färber @ 2015-02-18 13:16 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck,
	Kukjin Kim, lm-sensors, Linux PM list, linux-samsung-soc,
	devicetree, Lukasz Majewski, Kukjin Kim, linux-kernel,
	Sjoerd Simons, Abhilash Kesavan, Abhilash Kesavan

Am 18.02.2015 um 11:07 schrieb Lukasz Majewski:
> From: Kamil Debski <k.debski@samsung.com>
> 
> Add pwm-fan node to the Odroid-U3 board file to enable PWM control of the
> cooling fan. In addition, add the "pwm" label to the pwm@139D0000 node
> in the exynos4412.dtsi.
> 
> Signed-off-by: Kamil Debski <k.debski@samsung.com>
> [Rebased on the newest mainline by l.majewski@samsung.com]

You need to sign off patches you submit.

> ---
> Changes since v1:
> - added pwm label to the pwm@139D0000 node in exynos4.dtsi
> - use the pwm label in the exynos4412-odroidu3.dts
> - change order or properties in the pwn-fan node, to be sorted
>   in alphabetical order
> 
> ---
>  arch/arm/boot/dts/exynos4.dtsi            |  2 +-
>  arch/arm/boot/dts/exynos4412-odroidu3.dts | 13 +++++++++++++
>  2 files changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/boot/dts/exynos4.dtsi b/arch/arm/boot/dts/exynos4.dtsi
> index f18d746..75266e3 100644
> --- a/arch/arm/boot/dts/exynos4.dtsi
> +++ b/arch/arm/boot/dts/exynos4.dtsi
> @@ -582,7 +582,7 @@
>  		status = "disabled";
>  	};
>  
> -	pwm@139D0000 {
> +	pwm: pwm@139D0000 {
>  		compatible = "samsung,exynos4210-pwm";
>  		reg = <0x139D0000 0x1000>;
>  		interrupts = <0 37 0>, <0 38 0>, <0 39 0>, <0 40 0>, <0 41 0>;
> diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
> index c8a64be..60bd1e4 100644
> --- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
> +++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
> @@ -31,6 +31,19 @@
>  			linux,default-trigger = "heartbeat";
>  		};
>  	};
> +
> +	pwm-fan {
> +		compatible = "pwm-fan";
> +		pwms = <&pwm 0 10000 0>;
> +		status = "okay";

Status "okay" is only needed for pre-existing nodes that would have
status "disabled" otherwise, such as below. Just drop it here.

Regards,
Andreas

> +	};
> +};
> +
> +&pwm {
> +	pinctrl-0 = <&pwm0_out>;
> +	pinctrl-names = "default";
> +	samsung,pwm-outputs = <0>;
> +	status = "okay";
>  };
>  
>  &usb3503 {
> 


-- 
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Jennifer Guild, Dilip Upmanyu,
Graham Norton; HRB 21284 (AG Nürnberg)

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v4 7/8] hwmon: pwm-fan: Read PWM FAN configuration from device tree
  2015-02-18 10:07     ` Lukasz Majewski
  (?)
@ 2015-02-21  0:26       ` Guenter Roeck
  -1 siblings, 0 replies; 329+ messages in thread
From: Guenter Roeck @ 2015-02-21  0:26 UTC (permalink / raw)
  To: Lukasz Majewski, Eduardo Valentin, Kamil Debski, Jean Delvare,
	Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

On 02/18/2015 02:07 AM, Lukasz Majewski wrote:
> This patch provides code for reading PWM FAN configuration data via
> device tree. The pwm-fan can work with full speed when configuration
> is not provided. However, errors are propagated when wrong DT bindings
> are found.
> Additionally the struct pwm_fan_ctx has been extended.
>
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
> Changes for v2:
> - Rename pwm_fan_max_states to pwm_fan_cooling_levels
> - Moving pwm_fan_of_get_cooling_data() call after setting end enabling PWM FAN
> - pwm_fan_of_get_cooling_data() now can fail - preserving old behaviour
> - Remove unnecessary dev_err() call
> Changes for v3:
> - Patch's headline has been reedited
> - pwm_fan_of_get_cooling_data() return code is now being checked.
> - of_property_count_elems_of_size() is now used instead of_find_property()
> - More verbose patch description added
> Changes for v4:
> - dev_err() has been removed from pwm_fan_of_get_cooling_data()
> - Returning -EINVAL when "cooling-levels" are defined in DT, but doesn't
>    have the value
> ---
>   drivers/hwmon/pwm-fan.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++-
>   1 file changed, 51 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
> index bd42d39..82cd06a 100644
> --- a/drivers/hwmon/pwm-fan.c
> +++ b/drivers/hwmon/pwm-fan.c
> @@ -30,7 +30,10 @@
>   struct pwm_fan_ctx {
>   	struct mutex lock;
>   	struct pwm_device *pwm;
> -	unsigned char pwm_value;
> +	unsigned int pwm_value;
> +	unsigned int pwm_fan_state;
> +	unsigned int pwm_fan_max_state;
> +	unsigned int *pwm_fan_cooling_levels;
>   };
>
>   static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
> @@ -100,6 +103,48 @@ static struct attribute *pwm_fan_attrs[] = {
>
>   ATTRIBUTE_GROUPS(pwm_fan);
>
> +int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
> +{
> +	struct device_node *np = dev->of_node;
> +	int num, i, ret;
> +
> +	ret = of_property_count_elems_of_size(np, "cooling-levels",
> +					      sizeof(u32));
> +
> +	if (ret == -EINVAL)
> +		return 0;

The function returns -EINVAL if there is no such property,
but also if prop->length % elem_size != 0. The latter _would_
be an error.

Overall I don't entirely understand why you do not call
of_find_property first. If that returns NULL, you would know for sure
that the property does not exist, and you would not have to second
guess the returned error from of_property_count_elems_of_size.

On a side note, there is of_property_count_u32_elems() to count
properties of size u32.

> +
> +	if (ret <= 0) {
> +		dev_err(dev, "Wrong data!\n");
> +		return ret ? ret : -EINVAL;
> +	}

If devicetree is not configured, of_property_count_elems_of_size
returns -ENOSYS, which is returned, causing the driver to fail loading.

> +
> +	num = ret;
> +	ctx->pwm_fan_cooling_levels = devm_kzalloc(dev, num * sizeof(u32),
> +						   GFP_KERNEL);
> +	if (!ctx->pwm_fan_cooling_levels)
> +		return -ENOMEM;
> +
> +	ret = of_property_read_u32_array(np, "cooling-levels",
> +					 ctx->pwm_fan_cooling_levels, num);
> +	if (ret) {
> +		dev_err(dev, "Property 'cooling-levels' cannot be read!\n");
> +		return ret;
> +	}
> +
> +	for (i = 0; i < num; i++) {
> +		if (ctx->pwm_fan_cooling_levels[i] > MAX_PWM) {
> +			dev_err(dev, "PWM fan state[%d]:%d > %d\n", i,
> +				ctx->pwm_fan_cooling_levels[i], MAX_PWM);
> +			return -EINVAL;
> +		}
> +	}
> +
> +	ctx->pwm_fan_max_state = num - 1;
> +
> +	return 0;
> +}
> +
>   static int pwm_fan_probe(struct platform_device *pdev)
>   {
>   	struct device *hwmon;
> @@ -145,6 +190,11 @@ static int pwm_fan_probe(struct platform_device *pdev)
>   		pwm_disable(ctx->pwm);
>   		return PTR_ERR(hwmon);
>   	}
> +
> +	ret = pwm_fan_of_get_cooling_data(&pdev->dev, ctx);
> +	if (ret)
> +		return ret;
> +
>   	return 0;
>   }
>
>


^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v4 7/8] hwmon: pwm-fan: Read PWM FAN configuration from device tree
@ 2015-02-21  0:26       ` Guenter Roeck
  0 siblings, 0 replies; 329+ messages in thread
From: Guenter Roeck @ 2015-02-21  0:26 UTC (permalink / raw)
  To: Lukasz Majewski, Eduardo Valentin, Kamil Debski, Jean Delvare,
	Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

On 02/18/2015 02:07 AM, Lukasz Majewski wrote:
> This patch provides code for reading PWM FAN configuration data via
> device tree. The pwm-fan can work with full speed when configuration
> is not provided. However, errors are propagated when wrong DT bindings
> are found.
> Additionally the struct pwm_fan_ctx has been extended.
>
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
> Changes for v2:
> - Rename pwm_fan_max_states to pwm_fan_cooling_levels
> - Moving pwm_fan_of_get_cooling_data() call after setting end enabling PWM FAN
> - pwm_fan_of_get_cooling_data() now can fail - preserving old behaviour
> - Remove unnecessary dev_err() call
> Changes for v3:
> - Patch's headline has been reedited
> - pwm_fan_of_get_cooling_data() return code is now being checked.
> - of_property_count_elems_of_size() is now used instead of_find_property()
> - More verbose patch description added
> Changes for v4:
> - dev_err() has been removed from pwm_fan_of_get_cooling_data()
> - Returning -EINVAL when "cooling-levels" are defined in DT, but doesn't
>    have the value
> ---
>   drivers/hwmon/pwm-fan.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++-
>   1 file changed, 51 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
> index bd42d39..82cd06a 100644
> --- a/drivers/hwmon/pwm-fan.c
> +++ b/drivers/hwmon/pwm-fan.c
> @@ -30,7 +30,10 @@
>   struct pwm_fan_ctx {
>   	struct mutex lock;
>   	struct pwm_device *pwm;
> -	unsigned char pwm_value;
> +	unsigned int pwm_value;
> +	unsigned int pwm_fan_state;
> +	unsigned int pwm_fan_max_state;
> +	unsigned int *pwm_fan_cooling_levels;
>   };
>
>   static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
> @@ -100,6 +103,48 @@ static struct attribute *pwm_fan_attrs[] = {
>
>   ATTRIBUTE_GROUPS(pwm_fan);
>
> +int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
> +{
> +	struct device_node *np = dev->of_node;
> +	int num, i, ret;
> +
> +	ret = of_property_count_elems_of_size(np, "cooling-levels",
> +					      sizeof(u32));
> +
> +	if (ret == -EINVAL)
> +		return 0;

The function returns -EINVAL if there is no such property,
but also if prop->length % elem_size != 0. The latter _would_
be an error.

Overall I don't entirely understand why you do not call
of_find_property first. If that returns NULL, you would know for sure
that the property does not exist, and you would not have to second
guess the returned error from of_property_count_elems_of_size.

On a side note, there is of_property_count_u32_elems() to count
properties of size u32.

> +
> +	if (ret <= 0) {
> +		dev_err(dev, "Wrong data!\n");
> +		return ret ? ret : -EINVAL;
> +	}

If devicetree is not configured, of_property_count_elems_of_size
returns -ENOSYS, which is returned, causing the driver to fail loading.

> +
> +	num = ret;
> +	ctx->pwm_fan_cooling_levels = devm_kzalloc(dev, num * sizeof(u32),
> +						   GFP_KERNEL);
> +	if (!ctx->pwm_fan_cooling_levels)
> +		return -ENOMEM;
> +
> +	ret = of_property_read_u32_array(np, "cooling-levels",
> +					 ctx->pwm_fan_cooling_levels, num);
> +	if (ret) {
> +		dev_err(dev, "Property 'cooling-levels' cannot be read!\n");
> +		return ret;
> +	}
> +
> +	for (i = 0; i < num; i++) {
> +		if (ctx->pwm_fan_cooling_levels[i] > MAX_PWM) {
> +			dev_err(dev, "PWM fan state[%d]:%d > %d\n", i,
> +				ctx->pwm_fan_cooling_levels[i], MAX_PWM);
> +			return -EINVAL;
> +		}
> +	}
> +
> +	ctx->pwm_fan_max_state = num - 1;
> +
> +	return 0;
> +}
> +
>   static int pwm_fan_probe(struct platform_device *pdev)
>   {
>   	struct device *hwmon;
> @@ -145,6 +190,11 @@ static int pwm_fan_probe(struct platform_device *pdev)
>   		pwm_disable(ctx->pwm);
>   		return PTR_ERR(hwmon);
>   	}
> +
> +	ret = pwm_fan_of_get_cooling_data(&pdev->dev, ctx);
> +	if (ret)
> +		return ret;
> +
>   	return 0;
>   }
>
>

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [lm-sensors] [PATCH v4 7/8] hwmon: pwm-fan: Read PWM FAN configuration from device tree
@ 2015-02-21  0:26       ` Guenter Roeck
  0 siblings, 0 replies; 329+ messages in thread
From: Guenter Roeck @ 2015-02-21  0:26 UTC (permalink / raw)
  To: Lukasz Majewski, Eduardo Valentin, Kamil Debski, Jean Delvare,
	Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

On 02/18/2015 02:07 AM, Lukasz Majewski wrote:
> This patch provides code for reading PWM FAN configuration data via
> device tree. The pwm-fan can work with full speed when configuration
> is not provided. However, errors are propagated when wrong DT bindings
> are found.
> Additionally the struct pwm_fan_ctx has been extended.
>
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
> Changes for v2:
> - Rename pwm_fan_max_states to pwm_fan_cooling_levels
> - Moving pwm_fan_of_get_cooling_data() call after setting end enabling PWM FAN
> - pwm_fan_of_get_cooling_data() now can fail - preserving old behaviour
> - Remove unnecessary dev_err() call
> Changes for v3:
> - Patch's headline has been reedited
> - pwm_fan_of_get_cooling_data() return code is now being checked.
> - of_property_count_elems_of_size() is now used instead of_find_property()
> - More verbose patch description added
> Changes for v4:
> - dev_err() has been removed from pwm_fan_of_get_cooling_data()
> - Returning -EINVAL when "cooling-levels" are defined in DT, but doesn't
>    have the value
> ---
>   drivers/hwmon/pwm-fan.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++-
>   1 file changed, 51 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
> index bd42d39..82cd06a 100644
> --- a/drivers/hwmon/pwm-fan.c
> +++ b/drivers/hwmon/pwm-fan.c
> @@ -30,7 +30,10 @@
>   struct pwm_fan_ctx {
>   	struct mutex lock;
>   	struct pwm_device *pwm;
> -	unsigned char pwm_value;
> +	unsigned int pwm_value;
> +	unsigned int pwm_fan_state;
> +	unsigned int pwm_fan_max_state;
> +	unsigned int *pwm_fan_cooling_levels;
>   };
>
>   static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
> @@ -100,6 +103,48 @@ static struct attribute *pwm_fan_attrs[] = {
>
>   ATTRIBUTE_GROUPS(pwm_fan);
>
> +int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
> +{
> +	struct device_node *np = dev->of_node;
> +	int num, i, ret;
> +
> +	ret = of_property_count_elems_of_size(np, "cooling-levels",
> +					      sizeof(u32));
> +
> +	if (ret = -EINVAL)
> +		return 0;

The function returns -EINVAL if there is no such property,
but also if prop->length % elem_size != 0. The latter _would_
be an error.

Overall I don't entirely understand why you do not call
of_find_property first. If that returns NULL, you would know for sure
that the property does not exist, and you would not have to second
guess the returned error from of_property_count_elems_of_size.

On a side note, there is of_property_count_u32_elems() to count
properties of size u32.

> +
> +	if (ret <= 0) {
> +		dev_err(dev, "Wrong data!\n");
> +		return ret ? ret : -EINVAL;
> +	}

If devicetree is not configured, of_property_count_elems_of_size
returns -ENOSYS, which is returned, causing the driver to fail loading.

> +
> +	num = ret;
> +	ctx->pwm_fan_cooling_levels = devm_kzalloc(dev, num * sizeof(u32),
> +						   GFP_KERNEL);
> +	if (!ctx->pwm_fan_cooling_levels)
> +		return -ENOMEM;
> +
> +	ret = of_property_read_u32_array(np, "cooling-levels",
> +					 ctx->pwm_fan_cooling_levels, num);
> +	if (ret) {
> +		dev_err(dev, "Property 'cooling-levels' cannot be read!\n");
> +		return ret;
> +	}
> +
> +	for (i = 0; i < num; i++) {
> +		if (ctx->pwm_fan_cooling_levels[i] > MAX_PWM) {
> +			dev_err(dev, "PWM fan state[%d]:%d > %d\n", i,
> +				ctx->pwm_fan_cooling_levels[i], MAX_PWM);
> +			return -EINVAL;
> +		}
> +	}
> +
> +	ctx->pwm_fan_max_state = num - 1;
> +
> +	return 0;
> +}
> +
>   static int pwm_fan_probe(struct platform_device *pdev)
>   {
>   	struct device *hwmon;
> @@ -145,6 +190,11 @@ static int pwm_fan_probe(struct platform_device *pdev)
>   		pwm_disable(ctx->pwm);
>   		return PTR_ERR(hwmon);
>   	}
> +
> +	ret = pwm_fan_of_get_cooling_data(&pdev->dev, ctx);
> +	if (ret)
> +		return ret;
> +
>   	return 0;
>   }
>
>


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v4 7/8] hwmon: pwm-fan: Read PWM FAN configuration from device tree
  2015-02-21  0:26       ` Guenter Roeck
  (?)
@ 2015-02-23 16:13         ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-23 16:13 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Eduardo Valentin, Kamil Debski, Jean Delvare, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

Hi Guenter,

> On 02/18/2015 02:07 AM, Lukasz Majewski wrote:
> > This patch provides code for reading PWM FAN configuration data via
> > device tree. The pwm-fan can work with full speed when configuration
> > is not provided. However, errors are propagated when wrong DT
> > bindings are found.
> > Additionally the struct pwm_fan_ctx has been extended.
> >
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > ---
> > Changes for v2:
> > - Rename pwm_fan_max_states to pwm_fan_cooling_levels
> > - Moving pwm_fan_of_get_cooling_data() call after setting end
> > enabling PWM FAN
> > - pwm_fan_of_get_cooling_data() now can fail - preserving old
> > behaviour
> > - Remove unnecessary dev_err() call
> > Changes for v3:
> > - Patch's headline has been reedited
> > - pwm_fan_of_get_cooling_data() return code is now being checked.
> > - of_property_count_elems_of_size() is now used instead
> > of_find_property()
> > - More verbose patch description added
> > Changes for v4:
> > - dev_err() has been removed from pwm_fan_of_get_cooling_data()
> > - Returning -EINVAL when "cooling-levels" are defined in DT, but
> > doesn't have the value
> > ---
> >   drivers/hwmon/pwm-fan.c | 52
> > ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed,
> > 51 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
> > index bd42d39..82cd06a 100644
> > --- a/drivers/hwmon/pwm-fan.c
> > +++ b/drivers/hwmon/pwm-fan.c
> > @@ -30,7 +30,10 @@
> >   struct pwm_fan_ctx {
> >   	struct mutex lock;
> >   	struct pwm_device *pwm;
> > -	unsigned char pwm_value;
> > +	unsigned int pwm_value;
> > +	unsigned int pwm_fan_state;
> > +	unsigned int pwm_fan_max_state;
> > +	unsigned int *pwm_fan_cooling_levels;
> >   };
> >
> >   static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
> > @@ -100,6 +103,48 @@ static struct attribute *pwm_fan_attrs[] = {
> >
> >   ATTRIBUTE_GROUPS(pwm_fan);
> >
> > +int pwm_fan_of_get_cooling_data(struct device *dev, struct
> > pwm_fan_ctx *ctx) +{
> > +	struct device_node *np = dev->of_node;
> > +	int num, i, ret;
> > +
> > +	ret = of_property_count_elems_of_size(np, "cooling-levels",
> > +					      sizeof(u32));
> > +
> > +	if (ret == -EINVAL)
> > +		return 0;
> 
> The function returns -EINVAL if there is no such property,
> but also if prop->length % elem_size != 0. The latter _would_
> be an error.
> 
> Overall I don't entirely understand why you do not call
> of_find_property first. If that returns NULL, you would know for sure
> that the property does not exist, and you would not have to second
> guess the returned error from of_property_count_elems_of_size.

For sake of readability I will at v5 first check of_find_property() and
if it is correct, then I will call of_property_count_u32_elems().

> 
> On a side note, there is of_property_count_u32_elems() to count
> properties of size u32.
> 
> > +
> > +	if (ret <= 0) {
> > +		dev_err(dev, "Wrong data!\n");
> > +		return ret ? ret : -EINVAL;
> > +	}
> 
> If devicetree is not configured, of_property_count_elems_of_size
> returns -ENOSYS, which is returned, causing the driver to fail
> loading.

Has of_property_count_elems_of_size() returns -ENOSYS?

Maybe something has changed, but in my linux-vanila (3.19-rc4)
at ./drivers/of/base.c it returns -EINVAL, -ENODATA or number of
elements.

Have I missed something?

> 
> > +
> > +	num = ret;
> > +	ctx->pwm_fan_cooling_levels = devm_kzalloc(dev, num *
> > sizeof(u32),
> > +						   GFP_KERNEL);
> > +	if (!ctx->pwm_fan_cooling_levels)
> > +		return -ENOMEM;
> > +
> > +	ret = of_property_read_u32_array(np, "cooling-levels",
> > +
> > ctx->pwm_fan_cooling_levels, num);
> > +	if (ret) {
> > +		dev_err(dev, "Property 'cooling-levels' cannot be
> > read!\n");
> > +		return ret;
> > +	}
> > +
> > +	for (i = 0; i < num; i++) {
> > +		if (ctx->pwm_fan_cooling_levels[i] > MAX_PWM) {
> > +			dev_err(dev, "PWM fan state[%d]:%d >
> > %d\n", i,
> > +				ctx->pwm_fan_cooling_levels[i],
> > MAX_PWM);
> > +			return -EINVAL;
> > +		}
> > +	}
> > +
> > +	ctx->pwm_fan_max_state = num - 1;
> > +
> > +	return 0;
> > +}
> > +
> >   static int pwm_fan_probe(struct platform_device *pdev)
> >   {
> >   	struct device *hwmon;
> > @@ -145,6 +190,11 @@ static int pwm_fan_probe(struct
> > platform_device *pdev) pwm_disable(ctx->pwm);
> >   		return PTR_ERR(hwmon);
> >   	}
> > +
> > +	ret = pwm_fan_of_get_cooling_data(&pdev->dev, ctx);
> > +	if (ret)
> > +		return ret;

I think that here is the confusing part. Please compare this patch with
the following one.

Here we configure ctx struct via DT. If of_property_count_u32_elems()
returns -EINVAL, then we consider that "cooling-levels" wasn't defined
in DT and return with 0. Other error codes are considered as errors
and probe return error code.

> > +
> >   	return 0;
> >   }
> >
> >
> 



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v4 7/8] hwmon: pwm-fan: Read PWM FAN configuration from device tree
@ 2015-02-23 16:13         ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-23 16:13 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Eduardo Valentin, Kamil Debski, Jean Delvare, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

Hi Guenter,

> On 02/18/2015 02:07 AM, Lukasz Majewski wrote:
> > This patch provides code for reading PWM FAN configuration data via
> > device tree. The pwm-fan can work with full speed when configuration
> > is not provided. However, errors are propagated when wrong DT
> > bindings are found.
> > Additionally the struct pwm_fan_ctx has been extended.
> >
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > ---
> > Changes for v2:
> > - Rename pwm_fan_max_states to pwm_fan_cooling_levels
> > - Moving pwm_fan_of_get_cooling_data() call after setting end
> > enabling PWM FAN
> > - pwm_fan_of_get_cooling_data() now can fail - preserving old
> > behaviour
> > - Remove unnecessary dev_err() call
> > Changes for v3:
> > - Patch's headline has been reedited
> > - pwm_fan_of_get_cooling_data() return code is now being checked.
> > - of_property_count_elems_of_size() is now used instead
> > of_find_property()
> > - More verbose patch description added
> > Changes for v4:
> > - dev_err() has been removed from pwm_fan_of_get_cooling_data()
> > - Returning -EINVAL when "cooling-levels" are defined in DT, but
> > doesn't have the value
> > ---
> >   drivers/hwmon/pwm-fan.c | 52
> > ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed,
> > 51 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
> > index bd42d39..82cd06a 100644
> > --- a/drivers/hwmon/pwm-fan.c
> > +++ b/drivers/hwmon/pwm-fan.c
> > @@ -30,7 +30,10 @@
> >   struct pwm_fan_ctx {
> >   	struct mutex lock;
> >   	struct pwm_device *pwm;
> > -	unsigned char pwm_value;
> > +	unsigned int pwm_value;
> > +	unsigned int pwm_fan_state;
> > +	unsigned int pwm_fan_max_state;
> > +	unsigned int *pwm_fan_cooling_levels;
> >   };
> >
> >   static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
> > @@ -100,6 +103,48 @@ static struct attribute *pwm_fan_attrs[] = {
> >
> >   ATTRIBUTE_GROUPS(pwm_fan);
> >
> > +int pwm_fan_of_get_cooling_data(struct device *dev, struct
> > pwm_fan_ctx *ctx) +{
> > +	struct device_node *np = dev->of_node;
> > +	int num, i, ret;
> > +
> > +	ret = of_property_count_elems_of_size(np, "cooling-levels",
> > +					      sizeof(u32));
> > +
> > +	if (ret == -EINVAL)
> > +		return 0;
> 
> The function returns -EINVAL if there is no such property,
> but also if prop->length % elem_size != 0. The latter _would_
> be an error.
> 
> Overall I don't entirely understand why you do not call
> of_find_property first. If that returns NULL, you would know for sure
> that the property does not exist, and you would not have to second
> guess the returned error from of_property_count_elems_of_size.

For sake of readability I will at v5 first check of_find_property() and
if it is correct, then I will call of_property_count_u32_elems().

> 
> On a side note, there is of_property_count_u32_elems() to count
> properties of size u32.
> 
> > +
> > +	if (ret <= 0) {
> > +		dev_err(dev, "Wrong data!\n");
> > +		return ret ? ret : -EINVAL;
> > +	}
> 
> If devicetree is not configured, of_property_count_elems_of_size
> returns -ENOSYS, which is returned, causing the driver to fail
> loading.

Has of_property_count_elems_of_size() returns -ENOSYS?

Maybe something has changed, but in my linux-vanila (3.19-rc4)
at ./drivers/of/base.c it returns -EINVAL, -ENODATA or number of
elements.

Have I missed something?

> 
> > +
> > +	num = ret;
> > +	ctx->pwm_fan_cooling_levels = devm_kzalloc(dev, num *
> > sizeof(u32),
> > +						   GFP_KERNEL);
> > +	if (!ctx->pwm_fan_cooling_levels)
> > +		return -ENOMEM;
> > +
> > +	ret = of_property_read_u32_array(np, "cooling-levels",
> > +
> > ctx->pwm_fan_cooling_levels, num);
> > +	if (ret) {
> > +		dev_err(dev, "Property 'cooling-levels' cannot be
> > read!\n");
> > +		return ret;
> > +	}
> > +
> > +	for (i = 0; i < num; i++) {
> > +		if (ctx->pwm_fan_cooling_levels[i] > MAX_PWM) {
> > +			dev_err(dev, "PWM fan state[%d]:%d >
> > %d\n", i,
> > +				ctx->pwm_fan_cooling_levels[i],
> > MAX_PWM);
> > +			return -EINVAL;
> > +		}
> > +	}
> > +
> > +	ctx->pwm_fan_max_state = num - 1;
> > +
> > +	return 0;
> > +}
> > +
> >   static int pwm_fan_probe(struct platform_device *pdev)
> >   {
> >   	struct device *hwmon;
> > @@ -145,6 +190,11 @@ static int pwm_fan_probe(struct
> > platform_device *pdev) pwm_disable(ctx->pwm);
> >   		return PTR_ERR(hwmon);
> >   	}
> > +
> > +	ret = pwm_fan_of_get_cooling_data(&pdev->dev, ctx);
> > +	if (ret)
> > +		return ret;

I think that here is the confusing part. Please compare this patch with
the following one.

Here we configure ctx struct via DT. If of_property_count_u32_elems()
returns -EINVAL, then we consider that "cooling-levels" wasn't defined
in DT and return with 0. Other error codes are considered as errors
and probe return error code.

> > +
> >   	return 0;
> >   }
> >
> >
> 



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [lm-sensors] [PATCH v4 7/8] hwmon: pwm-fan: Read PWM FAN configuration from device tree
@ 2015-02-23 16:13         ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-23 16:13 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Eduardo Valentin, Kamil Debski, Jean Delvare, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

Hi Guenter,

> On 02/18/2015 02:07 AM, Lukasz Majewski wrote:
> > This patch provides code for reading PWM FAN configuration data via
> > device tree. The pwm-fan can work with full speed when configuration
> > is not provided. However, errors are propagated when wrong DT
> > bindings are found.
> > Additionally the struct pwm_fan_ctx has been extended.
> >
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > ---
> > Changes for v2:
> > - Rename pwm_fan_max_states to pwm_fan_cooling_levels
> > - Moving pwm_fan_of_get_cooling_data() call after setting end
> > enabling PWM FAN
> > - pwm_fan_of_get_cooling_data() now can fail - preserving old
> > behaviour
> > - Remove unnecessary dev_err() call
> > Changes for v3:
> > - Patch's headline has been reedited
> > - pwm_fan_of_get_cooling_data() return code is now being checked.
> > - of_property_count_elems_of_size() is now used instead
> > of_find_property()
> > - More verbose patch description added
> > Changes for v4:
> > - dev_err() has been removed from pwm_fan_of_get_cooling_data()
> > - Returning -EINVAL when "cooling-levels" are defined in DT, but
> > doesn't have the value
> > ---
> >   drivers/hwmon/pwm-fan.c | 52
> > ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed,
> > 51 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
> > index bd42d39..82cd06a 100644
> > --- a/drivers/hwmon/pwm-fan.c
> > +++ b/drivers/hwmon/pwm-fan.c
> > @@ -30,7 +30,10 @@
> >   struct pwm_fan_ctx {
> >   	struct mutex lock;
> >   	struct pwm_device *pwm;
> > -	unsigned char pwm_value;
> > +	unsigned int pwm_value;
> > +	unsigned int pwm_fan_state;
> > +	unsigned int pwm_fan_max_state;
> > +	unsigned int *pwm_fan_cooling_levels;
> >   };
> >
> >   static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
> > @@ -100,6 +103,48 @@ static struct attribute *pwm_fan_attrs[] = {
> >
> >   ATTRIBUTE_GROUPS(pwm_fan);
> >
> > +int pwm_fan_of_get_cooling_data(struct device *dev, struct
> > pwm_fan_ctx *ctx) +{
> > +	struct device_node *np = dev->of_node;
> > +	int num, i, ret;
> > +
> > +	ret = of_property_count_elems_of_size(np, "cooling-levels",
> > +					      sizeof(u32));
> > +
> > +	if (ret = -EINVAL)
> > +		return 0;
> 
> The function returns -EINVAL if there is no such property,
> but also if prop->length % elem_size != 0. The latter _would_
> be an error.
> 
> Overall I don't entirely understand why you do not call
> of_find_property first. If that returns NULL, you would know for sure
> that the property does not exist, and you would not have to second
> guess the returned error from of_property_count_elems_of_size.

For sake of readability I will at v5 first check of_find_property() and
if it is correct, then I will call of_property_count_u32_elems().

> 
> On a side note, there is of_property_count_u32_elems() to count
> properties of size u32.
> 
> > +
> > +	if (ret <= 0) {
> > +		dev_err(dev, "Wrong data!\n");
> > +		return ret ? ret : -EINVAL;
> > +	}
> 
> If devicetree is not configured, of_property_count_elems_of_size
> returns -ENOSYS, which is returned, causing the driver to fail
> loading.

Has of_property_count_elems_of_size() returns -ENOSYS?

Maybe something has changed, but in my linux-vanila (3.19-rc4)
at ./drivers/of/base.c it returns -EINVAL, -ENODATA or number of
elements.

Have I missed something?

> 
> > +
> > +	num = ret;
> > +	ctx->pwm_fan_cooling_levels = devm_kzalloc(dev, num *
> > sizeof(u32),
> > +						   GFP_KERNEL);
> > +	if (!ctx->pwm_fan_cooling_levels)
> > +		return -ENOMEM;
> > +
> > +	ret = of_property_read_u32_array(np, "cooling-levels",
> > +
> > ctx->pwm_fan_cooling_levels, num);
> > +	if (ret) {
> > +		dev_err(dev, "Property 'cooling-levels' cannot be
> > read!\n");
> > +		return ret;
> > +	}
> > +
> > +	for (i = 0; i < num; i++) {
> > +		if (ctx->pwm_fan_cooling_levels[i] > MAX_PWM) {
> > +			dev_err(dev, "PWM fan state[%d]:%d >
> > %d\n", i,
> > +				ctx->pwm_fan_cooling_levels[i],
> > MAX_PWM);
> > +			return -EINVAL;
> > +		}
> > +	}
> > +
> > +	ctx->pwm_fan_max_state = num - 1;
> > +
> > +	return 0;
> > +}
> > +
> >   static int pwm_fan_probe(struct platform_device *pdev)
> >   {
> >   	struct device *hwmon;
> > @@ -145,6 +190,11 @@ static int pwm_fan_probe(struct
> > platform_device *pdev) pwm_disable(ctx->pwm);
> >   		return PTR_ERR(hwmon);
> >   	}
> > +
> > +	ret = pwm_fan_of_get_cooling_data(&pdev->dev, ctx);
> > +	if (ret)
> > +		return ret;

I think that here is the confusing part. Please compare this patch with
the following one.

Here we configure ctx struct via DT. If of_property_count_u32_elems()
returns -EINVAL, then we consider that "cooling-levels" wasn't defined
in DT and return with 0. Other error codes are considered as errors
and probe return error code.

> > +
> >   	return 0;
> >   }
> >
> >
> 



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v4 7/8] hwmon: pwm-fan: Read PWM FAN configuration from device tree
  2015-02-23 16:13         ` Lukasz Majewski
  (?)
@ 2015-02-23 16:23           ` Guenter Roeck
  -1 siblings, 0 replies; 329+ messages in thread
From: Guenter Roeck @ 2015-02-23 16:23 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Eduardo Valentin, Kamil Debski, Jean Delvare, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

On Mon, Feb 23, 2015 at 05:13:36PM +0100, Lukasz Majewski wrote:
> Hi Guenter,
> 
[ ... ]

> > 
> > If devicetree is not configured, of_property_count_elems_of_size
> > returns -ENOSYS, which is returned, causing the driver to fail
> > loading.
> 
> Has of_property_count_elems_of_size() returns -ENOSYS?
> 
> Maybe something has changed, but in my linux-vanila (3.19-rc4)
> at ./drivers/of/base.c it returns -EINVAL, -ENODATA or number of
> elements.
> 
> Have I missed something?
> 
Hi Lukasz,

Yes, you have. Check include/linux/of.h, line 484, in latest mainline.

Guenter

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v4 7/8] hwmon: pwm-fan: Read PWM FAN configuration from device tree
@ 2015-02-23 16:23           ` Guenter Roeck
  0 siblings, 0 replies; 329+ messages in thread
From: Guenter Roeck @ 2015-02-23 16:23 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Eduardo Valentin, Kamil Debski, Jean Delvare, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

On Mon, Feb 23, 2015 at 05:13:36PM +0100, Lukasz Majewski wrote:
> Hi Guenter,
> 
[ ... ]

> > 
> > If devicetree is not configured, of_property_count_elems_of_size
> > returns -ENOSYS, which is returned, causing the driver to fail
> > loading.
> 
> Has of_property_count_elems_of_size() returns -ENOSYS?
> 
> Maybe something has changed, but in my linux-vanila (3.19-rc4)
> at ./drivers/of/base.c it returns -EINVAL, -ENODATA or number of
> elements.
> 
> Have I missed something?
> 
Hi Lukasz,

Yes, you have. Check include/linux/of.h, line 484, in latest mainline.

Guenter

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [lm-sensors] [PATCH v4 7/8] hwmon: pwm-fan: Read PWM FAN configuration from device tree
@ 2015-02-23 16:23           ` Guenter Roeck
  0 siblings, 0 replies; 329+ messages in thread
From: Guenter Roeck @ 2015-02-23 16:23 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Eduardo Valentin, Kamil Debski, Jean Delvare, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

On Mon, Feb 23, 2015 at 05:13:36PM +0100, Lukasz Majewski wrote:
> Hi Guenter,
> 
[ ... ]

> > 
> > If devicetree is not configured, of_property_count_elems_of_size
> > returns -ENOSYS, which is returned, causing the driver to fail
> > loading.
> 
> Has of_property_count_elems_of_size() returns -ENOSYS?
> 
> Maybe something has changed, but in my linux-vanila (3.19-rc4)
> at ./drivers/of/base.c it returns -EINVAL, -ENODATA or number of
> elements.
> 
> Have I missed something?
> 
Hi Lukasz,

Yes, you have. Check include/linux/of.h, line 484, in latest mainline.

Guenter

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v4 7/8] hwmon: pwm-fan: Read PWM FAN configuration from device tree
  2015-02-23 16:23           ` Guenter Roeck
  (?)
@ 2015-02-23 16:51             ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-23 16:51 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Eduardo Valentin, Kamil Debski, Jean Delvare, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

Hi Guenter,

> On Mon, Feb 23, 2015 at 05:13:36PM +0100, Lukasz Majewski wrote:
> > Hi Guenter,
> > 
> [ ... ]
> 
> > > 
> > > If devicetree is not configured, of_property_count_elems_of_size
> > > returns -ENOSYS, which is returned, causing the driver to fail
> > > loading.
> > 
> > Has of_property_count_elems_of_size() returns -ENOSYS?
> > 
> > Maybe something has changed, but in my linux-vanila (3.19-rc4)
> > at ./drivers/of/base.c it returns -EINVAL, -ENODATA or number of
> > elements.
> > 
> > Have I missed something?
> > 
> Hi Lukasz,
> 
> Yes, you have. Check include/linux/of.h, line 484, in latest mainline.

Ok. Now I got it.

The above situation shouldn't happen if I put of_find_property() check
on the very beginning of this function (it returns NULL when DT support
is not compiled).

The function would look as follows:

int 
pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx
*ctx) 
{       
        struct device_node *np = dev->of_node;
	int num, i, ret;

	if (!of_find_property(np, "cooling-levels", NULL))
		return 0;

	ret = of_property_count_u32_elems(np, "cooling-levels");
	if (ret <= 0) {
		dev_err(dev, "Wrong data!\n");
		return ret;
	}

	num = ret;
	ctx->pwm_fan_cooling_levels = devm_kzalloc(dev, num *
					sizeof(u32), GFP_KERNEL); 
	if (!ctx->pwm_fan_cooling_levels) 
		return -ENOMEM;

	ret = of_property_read_u32_array(np, "cooling-levels",
					 ctx->pwm_fan_cooling_levels,
					 num); 
	if (ret) {
		dev_err(dev, "Property 'cooling-levels' cannot be
			read!\n"); 
		return ret;
	}

	for (i = 0; i < num; i++) {
		if (ctx->pwm_fan_cooling_levels[i] > MAX_PWM) {
			dev_err(dev, "PWM fan state[%d]:%d > %d\n", i,
				ctx->pwm_fan_cooling_levels[i],
				MAX_PWM); 
			return -EINVAL;
		}
	}

	ctx->pwm_fan_max_state = num - 1;

	return 0;
}

> 
> Guenter



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v4 7/8] hwmon: pwm-fan: Read PWM FAN configuration from device tree
@ 2015-02-23 16:51             ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-23 16:51 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Eduardo Valentin, Kamil Debski, Jean Delvare, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

Hi Guenter,

> On Mon, Feb 23, 2015 at 05:13:36PM +0100, Lukasz Majewski wrote:
> > Hi Guenter,
> > 
> [ ... ]
> 
> > > 
> > > If devicetree is not configured, of_property_count_elems_of_size
> > > returns -ENOSYS, which is returned, causing the driver to fail
> > > loading.
> > 
> > Has of_property_count_elems_of_size() returns -ENOSYS?
> > 
> > Maybe something has changed, but in my linux-vanila (3.19-rc4)
> > at ./drivers/of/base.c it returns -EINVAL, -ENODATA or number of
> > elements.
> > 
> > Have I missed something?
> > 
> Hi Lukasz,
> 
> Yes, you have. Check include/linux/of.h, line 484, in latest mainline.

Ok. Now I got it.

The above situation shouldn't happen if I put of_find_property() check
on the very beginning of this function (it returns NULL when DT support
is not compiled).

The function would look as follows:

int 
pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx
*ctx) 
{       
        struct device_node *np = dev->of_node;
	int num, i, ret;

	if (!of_find_property(np, "cooling-levels", NULL))
		return 0;

	ret = of_property_count_u32_elems(np, "cooling-levels");
	if (ret <= 0) {
		dev_err(dev, "Wrong data!\n");
		return ret;
	}

	num = ret;
	ctx->pwm_fan_cooling_levels = devm_kzalloc(dev, num *
					sizeof(u32), GFP_KERNEL); 
	if (!ctx->pwm_fan_cooling_levels) 
		return -ENOMEM;

	ret = of_property_read_u32_array(np, "cooling-levels",
					 ctx->pwm_fan_cooling_levels,
					 num); 
	if (ret) {
		dev_err(dev, "Property 'cooling-levels' cannot be
			read!\n"); 
		return ret;
	}

	for (i = 0; i < num; i++) {
		if (ctx->pwm_fan_cooling_levels[i] > MAX_PWM) {
			dev_err(dev, "PWM fan state[%d]:%d > %d\n", i,
				ctx->pwm_fan_cooling_levels[i],
				MAX_PWM); 
			return -EINVAL;
		}
	}

	ctx->pwm_fan_max_state = num - 1;

	return 0;
}

> 
> Guenter



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [lm-sensors] [PATCH v4 7/8] hwmon: pwm-fan: Read PWM FAN configuration from device tree
@ 2015-02-23 16:51             ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-23 16:51 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Eduardo Valentin, Kamil Debski, Jean Delvare, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

Hi Guenter,

> On Mon, Feb 23, 2015 at 05:13:36PM +0100, Lukasz Majewski wrote:
> > Hi Guenter,
> > 
> [ ... ]
> 
> > > 
> > > If devicetree is not configured, of_property_count_elems_of_size
> > > returns -ENOSYS, which is returned, causing the driver to fail
> > > loading.
> > 
> > Has of_property_count_elems_of_size() returns -ENOSYS?
> > 
> > Maybe something has changed, but in my linux-vanila (3.19-rc4)
> > at ./drivers/of/base.c it returns -EINVAL, -ENODATA or number of
> > elements.
> > 
> > Have I missed something?
> > 
> Hi Lukasz,
> 
> Yes, you have. Check include/linux/of.h, line 484, in latest mainline.

Ok. Now I got it.

The above situation shouldn't happen if I put of_find_property() check
on the very beginning of this function (it returns NULL when DT support
is not compiled).

The function would look as follows:

int 
pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx
*ctx) 
{       
        struct device_node *np = dev->of_node;
	int num, i, ret;

	if (!of_find_property(np, "cooling-levels", NULL))
		return 0;

	ret = of_property_count_u32_elems(np, "cooling-levels");
	if (ret <= 0) {
		dev_err(dev, "Wrong data!\n");
		return ret;
	}

	num = ret;
	ctx->pwm_fan_cooling_levels = devm_kzalloc(dev, num *
					sizeof(u32), GFP_KERNEL); 
	if (!ctx->pwm_fan_cooling_levels) 
		return -ENOMEM;

	ret = of_property_read_u32_array(np, "cooling-levels",
					 ctx->pwm_fan_cooling_levels,
					 num); 
	if (ret) {
		dev_err(dev, "Property 'cooling-levels' cannot be
			read!\n"); 
		return ret;
	}

	for (i = 0; i < num; i++) {
		if (ctx->pwm_fan_cooling_levels[i] > MAX_PWM) {
			dev_err(dev, "PWM fan state[%d]:%d > %d\n", i,
				ctx->pwm_fan_cooling_levels[i],
				MAX_PWM); 
			return -EINVAL;
		}
	}

	ctx->pwm_fan_max_state = num - 1;

	return 0;
}

> 
> Guenter



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v4 7/8] hwmon: pwm-fan: Read PWM FAN configuration from device tree
  2015-02-23 16:51             ` Lukasz Majewski
  (?)
@ 2015-02-23 16:59               ` Guenter Roeck
  -1 siblings, 0 replies; 329+ messages in thread
From: Guenter Roeck @ 2015-02-23 16:59 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Eduardo Valentin, Kamil Debski, Jean Delvare, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

On Mon, Feb 23, 2015 at 05:51:22PM +0100, Lukasz Majewski wrote:
> Hi Guenter,
> 
> > On Mon, Feb 23, 2015 at 05:13:36PM +0100, Lukasz Majewski wrote:
> > > Hi Guenter,
> > > 
> > [ ... ]
> > 
> > > > 
> > > > If devicetree is not configured, of_property_count_elems_of_size
> > > > returns -ENOSYS, which is returned, causing the driver to fail
> > > > loading.
> > > 
> > > Has of_property_count_elems_of_size() returns -ENOSYS?
> > > 
> > > Maybe something has changed, but in my linux-vanila (3.19-rc4)
> > > at ./drivers/of/base.c it returns -EINVAL, -ENODATA or number of
> > > elements.
> > > 
> > > Have I missed something?
> > > 
> > Hi Lukasz,
> > 
> > Yes, you have. Check include/linux/of.h, line 484, in latest mainline.
> 
> Ok. Now I got it.
> 
> The above situation shouldn't happen if I put of_find_property() check
> on the very beginning of this function (it returns NULL when DT support
> is not compiled).
> 

Correct.

> The function would look as follows:
> 
> int 
> pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx
> *ctx) 
> {       
>         struct device_node *np = dev->of_node;
> 	int num, i, ret;
> 
> 	if (!of_find_property(np, "cooling-levels", NULL))
> 		return 0;
> 
> 	ret = of_property_count_u32_elems(np, "cooling-levels");
> 	if (ret <= 0) {
> 		dev_err(dev, "Wrong data!\n");
> 		return ret;

This should probably be something like 

		return ret ? : -EINVAL;

or ret == 0 is not an error, and you should not display an error message
in that case.

Thanks,
Guenter

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v4 7/8] hwmon: pwm-fan: Read PWM FAN configuration from device tree
@ 2015-02-23 16:59               ` Guenter Roeck
  0 siblings, 0 replies; 329+ messages in thread
From: Guenter Roeck @ 2015-02-23 16:59 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Eduardo Valentin, Kamil Debski, Jean Delvare, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

On Mon, Feb 23, 2015 at 05:51:22PM +0100, Lukasz Majewski wrote:
> Hi Guenter,
> 
> > On Mon, Feb 23, 2015 at 05:13:36PM +0100, Lukasz Majewski wrote:
> > > Hi Guenter,
> > > 
> > [ ... ]
> > 
> > > > 
> > > > If devicetree is not configured, of_property_count_elems_of_size
> > > > returns -ENOSYS, which is returned, causing the driver to fail
> > > > loading.
> > > 
> > > Has of_property_count_elems_of_size() returns -ENOSYS?
> > > 
> > > Maybe something has changed, but in my linux-vanila (3.19-rc4)
> > > at ./drivers/of/base.c it returns -EINVAL, -ENODATA or number of
> > > elements.
> > > 
> > > Have I missed something?
> > > 
> > Hi Lukasz,
> > 
> > Yes, you have. Check include/linux/of.h, line 484, in latest mainline.
> 
> Ok. Now I got it.
> 
> The above situation shouldn't happen if I put of_find_property() check
> on the very beginning of this function (it returns NULL when DT support
> is not compiled).
> 

Correct.

> The function would look as follows:
> 
> int 
> pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx
> *ctx) 
> {       
>         struct device_node *np = dev->of_node;
> 	int num, i, ret;
> 
> 	if (!of_find_property(np, "cooling-levels", NULL))
> 		return 0;
> 
> 	ret = of_property_count_u32_elems(np, "cooling-levels");
> 	if (ret <= 0) {
> 		dev_err(dev, "Wrong data!\n");
> 		return ret;

This should probably be something like 

		return ret ? : -EINVAL;

or ret == 0 is not an error, and you should not display an error message
in that case.

Thanks,
Guenter

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [lm-sensors] [PATCH v4 7/8] hwmon: pwm-fan: Read PWM FAN configuration from device tree
@ 2015-02-23 16:59               ` Guenter Roeck
  0 siblings, 0 replies; 329+ messages in thread
From: Guenter Roeck @ 2015-02-23 16:59 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Eduardo Valentin, Kamil Debski, Jean Delvare, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

On Mon, Feb 23, 2015 at 05:51:22PM +0100, Lukasz Majewski wrote:
> Hi Guenter,
> 
> > On Mon, Feb 23, 2015 at 05:13:36PM +0100, Lukasz Majewski wrote:
> > > Hi Guenter,
> > > 
> > [ ... ]
> > 
> > > > 
> > > > If devicetree is not configured, of_property_count_elems_of_size
> > > > returns -ENOSYS, which is returned, causing the driver to fail
> > > > loading.
> > > 
> > > Has of_property_count_elems_of_size() returns -ENOSYS?
> > > 
> > > Maybe something has changed, but in my linux-vanila (3.19-rc4)
> > > at ./drivers/of/base.c it returns -EINVAL, -ENODATA or number of
> > > elements.
> > > 
> > > Have I missed something?
> > > 
> > Hi Lukasz,
> > 
> > Yes, you have. Check include/linux/of.h, line 484, in latest mainline.
> 
> Ok. Now I got it.
> 
> The above situation shouldn't happen if I put of_find_property() check
> on the very beginning of this function (it returns NULL when DT support
> is not compiled).
> 

Correct.

> The function would look as follows:
> 
> int 
> pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx
> *ctx) 
> {       
>         struct device_node *np = dev->of_node;
> 	int num, i, ret;
> 
> 	if (!of_find_property(np, "cooling-levels", NULL))
> 		return 0;
> 
> 	ret = of_property_count_u32_elems(np, "cooling-levels");
> 	if (ret <= 0) {
> 		dev_err(dev, "Wrong data!\n");
> 		return ret;

This should probably be something like 

		return ret ? : -EINVAL;

or ret = 0 is not an error, and you should not display an error message
in that case.

Thanks,
Guenter

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v4 2/8] thermal: Provide stub for thermal_cdev_update() function
  2015-02-18 10:07     ` Lukasz Majewski
  (?)
@ 2015-02-24 19:21       ` Eduardo Valentin
  -1 siblings, 0 replies; 329+ messages in thread
From: Eduardo Valentin @ 2015-02-24 19:21 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

[-- Attachment #1: Type: text/plain, Size: 2266 bytes --]

On Wed, Feb 18, 2015 at 11:07:30AM +0100, Lukasz Majewski wrote:
> Odroid U3 fan can work without being registered as OF cooling device
> (with CONFIG_THERMAL{_OF|} disabled).
> In this situation it can be controlled via PWM entry at
> /sys/class/hwmon/hwmon0/pwm1.
> 
> Therefore, the thermal_cdev_update() function needs a stub
> to allow clean compilation.

I've just applied a patch on this same matter from Nishanth Menon [1].
Can you please check if his patch is enough for you?

[1] -
https://git.kernel.org/cgit/linux/kernel/git/evalenti/linux-soc-thermal.git/commit/?h=fixes&id=12ca7188468ee29c4e717f73db4bf43c90954fc7

> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
> Changes for v2:
> - New patch
> Changes for v3:
> - thermal_cdev_update() now depends on CONFIG_THERMAL flag
> Changes for v4:
> - None
> ---
>  include/linux/thermal.h | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> index eacf2de..25382e6 100644
> --- a/include/linux/thermal.h
> +++ b/include/linux/thermal.h
> @@ -298,6 +298,7 @@ struct thermal_cooling_device *
>  thermal_of_cooling_device_register(struct device_node *np,
>  				   char *type, void *devdata,
>  				   const struct thermal_cooling_device_ops *);
> +void thermal_cdev_update(struct thermal_cooling_device *);
>  #else
>  static inline struct thermal_cooling_device *
>  thermal_of_cooling_device_register(struct device_node *np,
> @@ -306,6 +307,9 @@ thermal_of_cooling_device_register(struct device_node *np,
>  {
>  	return NULL;
>  }
> +static inline void thermal_cdev_update(struct thermal_cooling_device *cdev)
> +{
> +}
>  #endif
>  #ifdef CONFIG_THERMAL_OF
>  struct thermal_zone_device *
> @@ -349,7 +353,6 @@ int thermal_zone_get_temp(struct thermal_zone_device *tz, unsigned long *temp);
>  int get_tz_trend(struct thermal_zone_device *, int);
>  struct thermal_instance *get_thermal_instance(struct thermal_zone_device *,
>  		struct thermal_cooling_device *, int);
> -void thermal_cdev_update(struct thermal_cooling_device *);
>  void thermal_notify_framework(struct thermal_zone_device *, int);
>  
>  #ifdef CONFIG_NET
> -- 
> 2.0.0.rc2
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v4 2/8] thermal: Provide stub for thermal_cdev_update() function
@ 2015-02-24 19:21       ` Eduardo Valentin
  0 siblings, 0 replies; 329+ messages in thread
From: Eduardo Valentin @ 2015-02-24 19:21 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

[-- Attachment #1: Type: text/plain, Size: 2266 bytes --]

On Wed, Feb 18, 2015 at 11:07:30AM +0100, Lukasz Majewski wrote:
> Odroid U3 fan can work without being registered as OF cooling device
> (with CONFIG_THERMAL{_OF|} disabled).
> In this situation it can be controlled via PWM entry at
> /sys/class/hwmon/hwmon0/pwm1.
> 
> Therefore, the thermal_cdev_update() function needs a stub
> to allow clean compilation.

I've just applied a patch on this same matter from Nishanth Menon [1].
Can you please check if his patch is enough for you?

[1] -
https://git.kernel.org/cgit/linux/kernel/git/evalenti/linux-soc-thermal.git/commit/?h=fixes&id=12ca7188468ee29c4e717f73db4bf43c90954fc7

> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
> Changes for v2:
> - New patch
> Changes for v3:
> - thermal_cdev_update() now depends on CONFIG_THERMAL flag
> Changes for v4:
> - None
> ---
>  include/linux/thermal.h | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> index eacf2de..25382e6 100644
> --- a/include/linux/thermal.h
> +++ b/include/linux/thermal.h
> @@ -298,6 +298,7 @@ struct thermal_cooling_device *
>  thermal_of_cooling_device_register(struct device_node *np,
>  				   char *type, void *devdata,
>  				   const struct thermal_cooling_device_ops *);
> +void thermal_cdev_update(struct thermal_cooling_device *);
>  #else
>  static inline struct thermal_cooling_device *
>  thermal_of_cooling_device_register(struct device_node *np,
> @@ -306,6 +307,9 @@ thermal_of_cooling_device_register(struct device_node *np,
>  {
>  	return NULL;
>  }
> +static inline void thermal_cdev_update(struct thermal_cooling_device *cdev)
> +{
> +}
>  #endif
>  #ifdef CONFIG_THERMAL_OF
>  struct thermal_zone_device *
> @@ -349,7 +353,6 @@ int thermal_zone_get_temp(struct thermal_zone_device *tz, unsigned long *temp);
>  int get_tz_trend(struct thermal_zone_device *, int);
>  struct thermal_instance *get_thermal_instance(struct thermal_zone_device *,
>  		struct thermal_cooling_device *, int);
> -void thermal_cdev_update(struct thermal_cooling_device *);
>  void thermal_notify_framework(struct thermal_zone_device *, int);
>  
>  #ifdef CONFIG_NET
> -- 
> 2.0.0.rc2
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [lm-sensors] [PATCH v4 2/8] thermal: Provide stub for thermal_cdev_update() function
@ 2015-02-24 19:21       ` Eduardo Valentin
  0 siblings, 0 replies; 329+ messages in thread
From: Eduardo Valentin @ 2015-02-24 19:21 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan


[-- Attachment #1.1: Type: text/plain, Size: 2266 bytes --]

On Wed, Feb 18, 2015 at 11:07:30AM +0100, Lukasz Majewski wrote:
> Odroid U3 fan can work without being registered as OF cooling device
> (with CONFIG_THERMAL{_OF|} disabled).
> In this situation it can be controlled via PWM entry at
> /sys/class/hwmon/hwmon0/pwm1.
> 
> Therefore, the thermal_cdev_update() function needs a stub
> to allow clean compilation.

I've just applied a patch on this same matter from Nishanth Menon [1].
Can you please check if his patch is enough for you?

[1] -
https://git.kernel.org/cgit/linux/kernel/git/evalenti/linux-soc-thermal.git/commit/?h=fixes&id=12ca7188468ee29c4e717f73db4bf43c90954fc7

> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
> Changes for v2:
> - New patch
> Changes for v3:
> - thermal_cdev_update() now depends on CONFIG_THERMAL flag
> Changes for v4:
> - None
> ---
>  include/linux/thermal.h | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> index eacf2de..25382e6 100644
> --- a/include/linux/thermal.h
> +++ b/include/linux/thermal.h
> @@ -298,6 +298,7 @@ struct thermal_cooling_device *
>  thermal_of_cooling_device_register(struct device_node *np,
>  				   char *type, void *devdata,
>  				   const struct thermal_cooling_device_ops *);
> +void thermal_cdev_update(struct thermal_cooling_device *);
>  #else
>  static inline struct thermal_cooling_device *
>  thermal_of_cooling_device_register(struct device_node *np,
> @@ -306,6 +307,9 @@ thermal_of_cooling_device_register(struct device_node *np,
>  {
>  	return NULL;
>  }
> +static inline void thermal_cdev_update(struct thermal_cooling_device *cdev)
> +{
> +}
>  #endif
>  #ifdef CONFIG_THERMAL_OF
>  struct thermal_zone_device *
> @@ -349,7 +353,6 @@ int thermal_zone_get_temp(struct thermal_zone_device *tz, unsigned long *temp);
>  int get_tz_trend(struct thermal_zone_device *, int);
>  struct thermal_instance *get_thermal_instance(struct thermal_zone_device *,
>  		struct thermal_cooling_device *, int);
> -void thermal_cdev_update(struct thermal_cooling_device *);
>  void thermal_notify_framework(struct thermal_zone_device *, int);
>  
>  #ifdef CONFIG_NET
> -- 
> 2.0.0.rc2
> 

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

[-- Attachment #2: Type: text/plain, Size: 153 bytes --]

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v4 1/8] thermal: Provide stub for thermal_of_cooling_device_register() function
  2015-02-18 10:07     ` Lukasz Majewski
  (?)
@ 2015-02-24 19:21       ` Eduardo Valentin
  -1 siblings, 0 replies; 329+ messages in thread
From: Eduardo Valentin @ 2015-02-24 19:21 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

[-- Attachment #1: Type: text/plain, Size: 2513 bytes --]

On Wed, Feb 18, 2015 at 11:07:29AM +0100, Lukasz Majewski wrote:
> Odroid U3 fan can work without being registered as OF cooling device
> (with CONFIG_THERMAL_OF disabled).
> In this situation it can be controlled via PWM entry at
> /sys/class/hwmon/hwmon0/pwm1.
> 
> Therefore, the thermal_of_cooling_device_register() function needs a stub
> to allow clean compilation.


I've just applied a patch on this same matter from Nishanth Menon [1].
Can you please check if his patch is enough for you?

[1] -
https://git.kernel.org/cgit/linux/kernel/git/evalenti/linux-soc-thermal.git/commit/?h=fixes&id=12ca7188468ee29c4e717f73db4bf43c90954fc7


> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
> Changes for v2:
> - None
> Changes for v3:
> - Provide stub declaration when CONFIG_THERMAL is not set
> Changes for v4:
> - None
> ---
>  include/linux/thermal.h | 17 ++++++++++++++---
>  1 file changed, 14 insertions(+), 3 deletions(-)
> 
> diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> index fc52e30..eacf2de 100644
> --- a/include/linux/thermal.h
> +++ b/include/linux/thermal.h
> @@ -293,6 +293,20 @@ struct thermal_trip {
>  };
>  
>  /* Function declarations */
> +#ifdef CONFIG_THERMAL
> +struct thermal_cooling_device *
> +thermal_of_cooling_device_register(struct device_node *np,
> +				   char *type, void *devdata,
> +				   const struct thermal_cooling_device_ops *);
> +#else
> +static inline struct thermal_cooling_device *
> +thermal_of_cooling_device_register(struct device_node *np,
> +				   char *type, void *devdata,
> +				   const struct thermal_cooling_device_ops *ops)
> +{
> +	return NULL;
> +}
> +#endif
>  #ifdef CONFIG_THERMAL_OF
>  struct thermal_zone_device *
>  thermal_zone_of_sensor_register(struct device *dev, int id, void *data,
> @@ -328,9 +342,6 @@ void thermal_zone_device_update(struct thermal_zone_device *);
>  
>  struct thermal_cooling_device *thermal_cooling_device_register(char *, void *,
>  		const struct thermal_cooling_device_ops *);
> -struct thermal_cooling_device *
> -thermal_of_cooling_device_register(struct device_node *np, char *, void *,
> -				   const struct thermal_cooling_device_ops *);
>  void thermal_cooling_device_unregister(struct thermal_cooling_device *);
>  struct thermal_zone_device *thermal_zone_get_zone_by_name(const char *name);
>  int thermal_zone_get_temp(struct thermal_zone_device *tz, unsigned long *temp);
> -- 
> 2.0.0.rc2
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v4 1/8] thermal: Provide stub for thermal_of_cooling_device_register() function
@ 2015-02-24 19:21       ` Eduardo Valentin
  0 siblings, 0 replies; 329+ messages in thread
From: Eduardo Valentin @ 2015-02-24 19:21 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

[-- Attachment #1: Type: text/plain, Size: 2513 bytes --]

On Wed, Feb 18, 2015 at 11:07:29AM +0100, Lukasz Majewski wrote:
> Odroid U3 fan can work without being registered as OF cooling device
> (with CONFIG_THERMAL_OF disabled).
> In this situation it can be controlled via PWM entry at
> /sys/class/hwmon/hwmon0/pwm1.
> 
> Therefore, the thermal_of_cooling_device_register() function needs a stub
> to allow clean compilation.


I've just applied a patch on this same matter from Nishanth Menon [1].
Can you please check if his patch is enough for you?

[1] -
https://git.kernel.org/cgit/linux/kernel/git/evalenti/linux-soc-thermal.git/commit/?h=fixes&id=12ca7188468ee29c4e717f73db4bf43c90954fc7


> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
> Changes for v2:
> - None
> Changes for v3:
> - Provide stub declaration when CONFIG_THERMAL is not set
> Changes for v4:
> - None
> ---
>  include/linux/thermal.h | 17 ++++++++++++++---
>  1 file changed, 14 insertions(+), 3 deletions(-)
> 
> diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> index fc52e30..eacf2de 100644
> --- a/include/linux/thermal.h
> +++ b/include/linux/thermal.h
> @@ -293,6 +293,20 @@ struct thermal_trip {
>  };
>  
>  /* Function declarations */
> +#ifdef CONFIG_THERMAL
> +struct thermal_cooling_device *
> +thermal_of_cooling_device_register(struct device_node *np,
> +				   char *type, void *devdata,
> +				   const struct thermal_cooling_device_ops *);
> +#else
> +static inline struct thermal_cooling_device *
> +thermal_of_cooling_device_register(struct device_node *np,
> +				   char *type, void *devdata,
> +				   const struct thermal_cooling_device_ops *ops)
> +{
> +	return NULL;
> +}
> +#endif
>  #ifdef CONFIG_THERMAL_OF
>  struct thermal_zone_device *
>  thermal_zone_of_sensor_register(struct device *dev, int id, void *data,
> @@ -328,9 +342,6 @@ void thermal_zone_device_update(struct thermal_zone_device *);
>  
>  struct thermal_cooling_device *thermal_cooling_device_register(char *, void *,
>  		const struct thermal_cooling_device_ops *);
> -struct thermal_cooling_device *
> -thermal_of_cooling_device_register(struct device_node *np, char *, void *,
> -				   const struct thermal_cooling_device_ops *);
>  void thermal_cooling_device_unregister(struct thermal_cooling_device *);
>  struct thermal_zone_device *thermal_zone_get_zone_by_name(const char *name);
>  int thermal_zone_get_temp(struct thermal_zone_device *tz, unsigned long *temp);
> -- 
> 2.0.0.rc2
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [lm-sensors] [PATCH v4 1/8] thermal: Provide stub for thermal_of_cooling_device_register() funct
@ 2015-02-24 19:21       ` Eduardo Valentin
  0 siblings, 0 replies; 329+ messages in thread
From: Eduardo Valentin @ 2015-02-24 19:21 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan


[-- Attachment #1.1: Type: text/plain, Size: 2513 bytes --]

On Wed, Feb 18, 2015 at 11:07:29AM +0100, Lukasz Majewski wrote:
> Odroid U3 fan can work without being registered as OF cooling device
> (with CONFIG_THERMAL_OF disabled).
> In this situation it can be controlled via PWM entry at
> /sys/class/hwmon/hwmon0/pwm1.
> 
> Therefore, the thermal_of_cooling_device_register() function needs a stub
> to allow clean compilation.


I've just applied a patch on this same matter from Nishanth Menon [1].
Can you please check if his patch is enough for you?

[1] -
https://git.kernel.org/cgit/linux/kernel/git/evalenti/linux-soc-thermal.git/commit/?h=fixes&id=12ca7188468ee29c4e717f73db4bf43c90954fc7


> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
> Changes for v2:
> - None
> Changes for v3:
> - Provide stub declaration when CONFIG_THERMAL is not set
> Changes for v4:
> - None
> ---
>  include/linux/thermal.h | 17 ++++++++++++++---
>  1 file changed, 14 insertions(+), 3 deletions(-)
> 
> diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> index fc52e30..eacf2de 100644
> --- a/include/linux/thermal.h
> +++ b/include/linux/thermal.h
> @@ -293,6 +293,20 @@ struct thermal_trip {
>  };
>  
>  /* Function declarations */
> +#ifdef CONFIG_THERMAL
> +struct thermal_cooling_device *
> +thermal_of_cooling_device_register(struct device_node *np,
> +				   char *type, void *devdata,
> +				   const struct thermal_cooling_device_ops *);
> +#else
> +static inline struct thermal_cooling_device *
> +thermal_of_cooling_device_register(struct device_node *np,
> +				   char *type, void *devdata,
> +				   const struct thermal_cooling_device_ops *ops)
> +{
> +	return NULL;
> +}
> +#endif
>  #ifdef CONFIG_THERMAL_OF
>  struct thermal_zone_device *
>  thermal_zone_of_sensor_register(struct device *dev, int id, void *data,
> @@ -328,9 +342,6 @@ void thermal_zone_device_update(struct thermal_zone_device *);
>  
>  struct thermal_cooling_device *thermal_cooling_device_register(char *, void *,
>  		const struct thermal_cooling_device_ops *);
> -struct thermal_cooling_device *
> -thermal_of_cooling_device_register(struct device_node *np, char *, void *,
> -				   const struct thermal_cooling_device_ops *);
>  void thermal_cooling_device_unregister(struct thermal_cooling_device *);
>  struct thermal_zone_device *thermal_zone_get_zone_by_name(const char *name);
>  int thermal_zone_get_temp(struct thermal_zone_device *tz, unsigned long *temp);
> -- 
> 2.0.0.rc2
> 

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

[-- Attachment #2: Type: text/plain, Size: 153 bytes --]

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v4 3/8] Documentation: dts: Documentation entry to explain how to use PWM FAN as a cooling device
  2015-02-18 10:07     ` [PATCH v4 3/8] Documentation: dts: Documentation entry to explain how to use PWM FAN as a cooling device Lukasz Majewski
  (?)
@ 2015-02-24 19:25       ` Eduardo Valentin
  -1 siblings, 0 replies; 329+ messages in thread
From: Eduardo Valentin @ 2015-02-24 19:25 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

[-- Attachment #1: Type: text/plain, Size: 2137 bytes --]

On Wed, Feb 18, 2015 at 11:07:31AM +0100, Lukasz Majewski wrote:
> Explanation of several properties, which allow PWM fan working as a cooling
> device, have been embraced in this commit.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
> Changes for v2:
> - Rename cooling-pwm-values to cooling-levels
> - Remove default-pulse-width property and stick to default hwmon policy
> Changes for v3:
> - Changing commit title from "hwmon: dts: Doc:" to "Documentation: dts"
> - Remove unnecessary properties
> - Set maximal cooling level to 230 instead of 255
> Changes for v4:
> - None
> ---
>  Documentation/devicetree/bindings/hwmon/pwm-fan.txt | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> index 610757c..d53fe0c 100644
> --- a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> +++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> @@ -3,10 +3,30 @@ Bindings for a fan connected to the PWM lines
>  Required properties:
>  - compatible	: "pwm-fan"
>  - pwms		: the PWM that is used to control the PWM fan
> +- cooling-levels      : PWM duty cycle values in a range from 0 to 255
> +			which correspond to thermal cooling states
> +
> +Thorough description of the following bindings:
> +		cooling-min-state = <0>;
> +		cooling-max-state = <3>;
> +		#cooling-cells = <2>;
> +		thermal-zone {
> +			cpu_thermal: cpu-thermal {
> +			cooling-maps {
> +				map0 {
> +				     trip = <&cpu_alert1>;
> +				     cooling-device = <&fan0 0 1>;
> +				};
> +			};
> +		};

I am fine if you leave the reference to thermal.txt biding description,
but I would prefer if you move the above lines to a proper example section.

> +
> +for PWM FAN used as cooling device can be found at:
> +./Documentation/devicetree/bindings/thermal/thermal.txt
>  
>  Example:
>  	pwm-fan {
>  		compatible = "pwm-fan";
>  		status = "okay";
>  		pwms = <&pwm 0 10000 0>;
> +		cooling-levels = <0 102 170 230>;
>  	};
> -- 
> 2.0.0.rc2
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v4 3/8] Documentation: dts: Documentation entry to explain how to use PWM FAN as a cooling device
@ 2015-02-24 19:25       ` Eduardo Valentin
  0 siblings, 0 replies; 329+ messages in thread
From: Eduardo Valentin @ 2015-02-24 19:25 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

[-- Attachment #1: Type: text/plain, Size: 2137 bytes --]

On Wed, Feb 18, 2015 at 11:07:31AM +0100, Lukasz Majewski wrote:
> Explanation of several properties, which allow PWM fan working as a cooling
> device, have been embraced in this commit.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
> Changes for v2:
> - Rename cooling-pwm-values to cooling-levels
> - Remove default-pulse-width property and stick to default hwmon policy
> Changes for v3:
> - Changing commit title from "hwmon: dts: Doc:" to "Documentation: dts"
> - Remove unnecessary properties
> - Set maximal cooling level to 230 instead of 255
> Changes for v4:
> - None
> ---
>  Documentation/devicetree/bindings/hwmon/pwm-fan.txt | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> index 610757c..d53fe0c 100644
> --- a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> +++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> @@ -3,10 +3,30 @@ Bindings for a fan connected to the PWM lines
>  Required properties:
>  - compatible	: "pwm-fan"
>  - pwms		: the PWM that is used to control the PWM fan
> +- cooling-levels      : PWM duty cycle values in a range from 0 to 255
> +			which correspond to thermal cooling states
> +
> +Thorough description of the following bindings:
> +		cooling-min-state = <0>;
> +		cooling-max-state = <3>;
> +		#cooling-cells = <2>;
> +		thermal-zone {
> +			cpu_thermal: cpu-thermal {
> +			cooling-maps {
> +				map0 {
> +				     trip = <&cpu_alert1>;
> +				     cooling-device = <&fan0 0 1>;
> +				};
> +			};
> +		};

I am fine if you leave the reference to thermal.txt biding description,
but I would prefer if you move the above lines to a proper example section.

> +
> +for PWM FAN used as cooling device can be found at:
> +./Documentation/devicetree/bindings/thermal/thermal.txt
>  
>  Example:
>  	pwm-fan {
>  		compatible = "pwm-fan";
>  		status = "okay";
>  		pwms = <&pwm 0 10000 0>;
> +		cooling-levels = <0 102 170 230>;
>  	};
> -- 
> 2.0.0.rc2
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [lm-sensors] [PATCH v4 3/8] Documentation: dts: Documentation entry to explain how to use PWM FA
@ 2015-02-24 19:25       ` Eduardo Valentin
  0 siblings, 0 replies; 329+ messages in thread
From: Eduardo Valentin @ 2015-02-24 19:25 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan


[-- Attachment #1.1: Type: text/plain, Size: 2137 bytes --]

On Wed, Feb 18, 2015 at 11:07:31AM +0100, Lukasz Majewski wrote:
> Explanation of several properties, which allow PWM fan working as a cooling
> device, have been embraced in this commit.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
> Changes for v2:
> - Rename cooling-pwm-values to cooling-levels
> - Remove default-pulse-width property and stick to default hwmon policy
> Changes for v3:
> - Changing commit title from "hwmon: dts: Doc:" to "Documentation: dts"
> - Remove unnecessary properties
> - Set maximal cooling level to 230 instead of 255
> Changes for v4:
> - None
> ---
>  Documentation/devicetree/bindings/hwmon/pwm-fan.txt | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> index 610757c..d53fe0c 100644
> --- a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> +++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> @@ -3,10 +3,30 @@ Bindings for a fan connected to the PWM lines
>  Required properties:
>  - compatible	: "pwm-fan"
>  - pwms		: the PWM that is used to control the PWM fan
> +- cooling-levels      : PWM duty cycle values in a range from 0 to 255
> +			which correspond to thermal cooling states
> +
> +Thorough description of the following bindings:
> +		cooling-min-state = <0>;
> +		cooling-max-state = <3>;
> +		#cooling-cells = <2>;
> +		thermal-zone {
> +			cpu_thermal: cpu-thermal {
> +			cooling-maps {
> +				map0 {
> +				     trip = <&cpu_alert1>;
> +				     cooling-device = <&fan0 0 1>;
> +				};
> +			};
> +		};

I am fine if you leave the reference to thermal.txt biding description,
but I would prefer if you move the above lines to a proper example section.

> +
> +for PWM FAN used as cooling device can be found at:
> +./Documentation/devicetree/bindings/thermal/thermal.txt
>  
>  Example:
>  	pwm-fan {
>  		compatible = "pwm-fan";
>  		status = "okay";
>  		pwms = <&pwm 0 10000 0>;
> +		cooling-levels = <0 102 170 230>;
>  	};
> -- 
> 2.0.0.rc2
> 

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

[-- Attachment #2: Type: text/plain, Size: 153 bytes --]

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v4 5/8] ARM: dts: Add properties to use pwm-fan device as a cooling device in Odroid U3
  2015-02-18 10:07     ` [PATCH v4 5/8] ARM: dts: Add properties to use pwm-fan device as a cooling device in Odroid U3 Lukasz Majewski
  (?)
@ 2015-02-24 19:37       ` Eduardo Valentin
  -1 siblings, 0 replies; 329+ messages in thread
From: Eduardo Valentin @ 2015-02-24 19:37 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

[-- Attachment #1: Type: text/plain, Size: 1941 bytes --]

On Wed, Feb 18, 2015 at 11:07:33AM +0100, Lukasz Majewski wrote:
> With those bindings it is possible to use pwm-fan device available in
> Odroid U3 as a cooling device.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
> Changes for v2:
> - Rename cooling-pwm-values property to cooling-levels
> Changes for v3:
> - Change patch's topic to "ARM dts"
> - Reduce maximal cooling-level to 230 from 255
> Changes for v4:
> - None
> ---
>  arch/arm/boot/dts/exynos4412-odroidu3.dts | 33 ++++++++++++++++++++++++++++++-
>  1 file changed, 32 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
> index 60bd1e4..3e5df3e 100644
> --- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
> +++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
> @@ -32,11 +32,42 @@
>  		};
>  	};
>  
> -	pwm-fan {
> +	fan0: pwm-fan {
>  		compatible = "pwm-fan";
>  		pwms = <&pwm 0 10000 0>;
> +		cooling-min-state = <0>;
> +		cooling-max-state = <3>;
> +		#cooling-cells = <2>;
> +		cooling-levels = <0 102 170 230>;
>  		status = "okay";
>  	};
> +
> +	thermal-zones {
> +		cpu_thermal: cpu-thermal {


This thermal zone misses the mandatory properties as per 
 Documentation/devicetree/bindings/thermal/thermal.txt

> +			cooling-maps {
> +				map0 {
> +				     trip = <&cpu_alert1>;
> +				     cooling-device = <&cpu0 7 7>;
> +				};
> +				map1 {
> +				     trip = <&cpu_alert2>;
> +				     cooling-device = <&cpu0 13 13>;
> +				};
> +				map2 {
> +				     trip = <&cpu_alert0>;
> +				     cooling-device = <&fan0 0 1>;
> +				};
> +				map3 {
> +				     trip = <&cpu_alert1>;
> +				     cooling-device = <&fan0 1 2>;
> +				};
> +				map4 {
> +				     trip = <&cpu_alert2>;
> +				     cooling-device = <&fan0 2 3>;
> +				};
> +			};
> +		};
> +	};
>  };
>  
>  &pwm {
> -- 
> 2.0.0.rc2
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v4 5/8] ARM: dts: Add properties to use pwm-fan device as a cooling device in Odroid U3
@ 2015-02-24 19:37       ` Eduardo Valentin
  0 siblings, 0 replies; 329+ messages in thread
From: Eduardo Valentin @ 2015-02-24 19:37 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

[-- Attachment #1: Type: text/plain, Size: 1941 bytes --]

On Wed, Feb 18, 2015 at 11:07:33AM +0100, Lukasz Majewski wrote:
> With those bindings it is possible to use pwm-fan device available in
> Odroid U3 as a cooling device.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
> Changes for v2:
> - Rename cooling-pwm-values property to cooling-levels
> Changes for v3:
> - Change patch's topic to "ARM dts"
> - Reduce maximal cooling-level to 230 from 255
> Changes for v4:
> - None
> ---
>  arch/arm/boot/dts/exynos4412-odroidu3.dts | 33 ++++++++++++++++++++++++++++++-
>  1 file changed, 32 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
> index 60bd1e4..3e5df3e 100644
> --- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
> +++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
> @@ -32,11 +32,42 @@
>  		};
>  	};
>  
> -	pwm-fan {
> +	fan0: pwm-fan {
>  		compatible = "pwm-fan";
>  		pwms = <&pwm 0 10000 0>;
> +		cooling-min-state = <0>;
> +		cooling-max-state = <3>;
> +		#cooling-cells = <2>;
> +		cooling-levels = <0 102 170 230>;
>  		status = "okay";
>  	};
> +
> +	thermal-zones {
> +		cpu_thermal: cpu-thermal {


This thermal zone misses the mandatory properties as per 
 Documentation/devicetree/bindings/thermal/thermal.txt

> +			cooling-maps {
> +				map0 {
> +				     trip = <&cpu_alert1>;
> +				     cooling-device = <&cpu0 7 7>;
> +				};
> +				map1 {
> +				     trip = <&cpu_alert2>;
> +				     cooling-device = <&cpu0 13 13>;
> +				};
> +				map2 {
> +				     trip = <&cpu_alert0>;
> +				     cooling-device = <&fan0 0 1>;
> +				};
> +				map3 {
> +				     trip = <&cpu_alert1>;
> +				     cooling-device = <&fan0 1 2>;
> +				};
> +				map4 {
> +				     trip = <&cpu_alert2>;
> +				     cooling-device = <&fan0 2 3>;
> +				};
> +			};
> +		};
> +	};
>  };
>  
>  &pwm {
> -- 
> 2.0.0.rc2
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [lm-sensors] [PATCH v4 5/8] ARM: dts: Add properties to use pwm-fan device as a cooling device i
@ 2015-02-24 19:37       ` Eduardo Valentin
  0 siblings, 0 replies; 329+ messages in thread
From: Eduardo Valentin @ 2015-02-24 19:37 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan


[-- Attachment #1.1: Type: text/plain, Size: 1941 bytes --]

On Wed, Feb 18, 2015 at 11:07:33AM +0100, Lukasz Majewski wrote:
> With those bindings it is possible to use pwm-fan device available in
> Odroid U3 as a cooling device.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
> Changes for v2:
> - Rename cooling-pwm-values property to cooling-levels
> Changes for v3:
> - Change patch's topic to "ARM dts"
> - Reduce maximal cooling-level to 230 from 255
> Changes for v4:
> - None
> ---
>  arch/arm/boot/dts/exynos4412-odroidu3.dts | 33 ++++++++++++++++++++++++++++++-
>  1 file changed, 32 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
> index 60bd1e4..3e5df3e 100644
> --- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
> +++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
> @@ -32,11 +32,42 @@
>  		};
>  	};
>  
> -	pwm-fan {
> +	fan0: pwm-fan {
>  		compatible = "pwm-fan";
>  		pwms = <&pwm 0 10000 0>;
> +		cooling-min-state = <0>;
> +		cooling-max-state = <3>;
> +		#cooling-cells = <2>;
> +		cooling-levels = <0 102 170 230>;
>  		status = "okay";
>  	};
> +
> +	thermal-zones {
> +		cpu_thermal: cpu-thermal {


This thermal zone misses the mandatory properties as per 
 Documentation/devicetree/bindings/thermal/thermal.txt

> +			cooling-maps {
> +				map0 {
> +				     trip = <&cpu_alert1>;
> +				     cooling-device = <&cpu0 7 7>;
> +				};
> +				map1 {
> +				     trip = <&cpu_alert2>;
> +				     cooling-device = <&cpu0 13 13>;
> +				};
> +				map2 {
> +				     trip = <&cpu_alert0>;
> +				     cooling-device = <&fan0 0 1>;
> +				};
> +				map3 {
> +				     trip = <&cpu_alert1>;
> +				     cooling-device = <&fan0 1 2>;
> +				};
> +				map4 {
> +				     trip = <&cpu_alert2>;
> +				     cooling-device = <&fan0 2 3>;
> +				};
> +			};
> +		};
> +	};
>  };
>  
>  &pwm {
> -- 
> 2.0.0.rc2
> 

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

[-- Attachment #2: Type: text/plain, Size: 153 bytes --]

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v4 1/8] thermal: Provide stub for thermal_of_cooling_device_register() function
  2015-02-24 19:21       ` [PATCH v4 1/8] thermal: Provide stub for thermal_of_cooling_device_register() function Eduardo Valentin
  (?)
@ 2015-02-25 12:26         ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-25 12:26 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

Hi Eduardo,

> On Wed, Feb 18, 2015 at 11:07:29AM +0100, Lukasz Majewski wrote:
> > Odroid U3 fan can work without being registered as OF cooling device
> > (with CONFIG_THERMAL_OF disabled).
> > In this situation it can be controlled via PWM entry at
> > /sys/class/hwmon/hwmon0/pwm1.
> > 
> > Therefore, the thermal_of_cooling_device_register() function needs
> > a stub to allow clean compilation.
> 
> 
> I've just applied a patch on this same matter from Nishanth Menon [1].
> Can you please check if his patch is enough for you?
> 
> [1] -
> https://git.kernel.org/cgit/linux/kernel/git/evalenti/linux-soc-thermal.git/commit/?h=fixes&id=12ca7188468ee29c4e717f73db4bf43c90954fc7
> 

I will prepare new PWM-FAN patch set with above changes in mind.


> 
> > 
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > ---
> > Changes for v2:
> > - None
> > Changes for v3:
> > - Provide stub declaration when CONFIG_THERMAL is not set
> > Changes for v4:
> > - None
> > ---
> >  include/linux/thermal.h | 17 ++++++++++++++---
> >  1 file changed, 14 insertions(+), 3 deletions(-)
> > 
> > diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> > index fc52e30..eacf2de 100644
> > --- a/include/linux/thermal.h
> > +++ b/include/linux/thermal.h
> > @@ -293,6 +293,20 @@ struct thermal_trip {
> >  };
> >  
> >  /* Function declarations */
> > +#ifdef CONFIG_THERMAL
> > +struct thermal_cooling_device *
> > +thermal_of_cooling_device_register(struct device_node *np,
> > +				   char *type, void *devdata,
> > +				   const struct
> > thermal_cooling_device_ops *); +#else
> > +static inline struct thermal_cooling_device *
> > +thermal_of_cooling_device_register(struct device_node *np,
> > +				   char *type, void *devdata,
> > +				   const struct
> > thermal_cooling_device_ops *ops) +{
> > +	return NULL;
> > +}
> > +#endif
> >  #ifdef CONFIG_THERMAL_OF
> >  struct thermal_zone_device *
> >  thermal_zone_of_sensor_register(struct device *dev, int id, void
> > *data, @@ -328,9 +342,6 @@ void thermal_zone_device_update(struct
> > thermal_zone_device *); 
> >  struct thermal_cooling_device
> > *thermal_cooling_device_register(char *, void *, const struct
> > thermal_cooling_device_ops *); -struct thermal_cooling_device *
> > -thermal_of_cooling_device_register(struct device_node *np, char *,
> > void *,
> > -				   const struct
> > thermal_cooling_device_ops *); void
> > thermal_cooling_device_unregister(struct thermal_cooling_device *);
> > struct thermal_zone_device *thermal_zone_get_zone_by_name(const
> > char *name); int thermal_zone_get_temp(struct thermal_zone_device
> > *tz, unsigned long *temp); -- 2.0.0.rc2
> > 



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v4 1/8] thermal: Provide stub for thermal_of_cooling_device_register() function
@ 2015-02-25 12:26         ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-25 12:26 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

Hi Eduardo,

> On Wed, Feb 18, 2015 at 11:07:29AM +0100, Lukasz Majewski wrote:
> > Odroid U3 fan can work without being registered as OF cooling device
> > (with CONFIG_THERMAL_OF disabled).
> > In this situation it can be controlled via PWM entry at
> > /sys/class/hwmon/hwmon0/pwm1.
> > 
> > Therefore, the thermal_of_cooling_device_register() function needs
> > a stub to allow clean compilation.
> 
> 
> I've just applied a patch on this same matter from Nishanth Menon [1].
> Can you please check if his patch is enough for you?
> 
> [1] -
> https://git.kernel.org/cgit/linux/kernel/git/evalenti/linux-soc-thermal.git/commit/?h=fixes&id=12ca7188468ee29c4e717f73db4bf43c90954fc7
> 

I will prepare new PWM-FAN patch set with above changes in mind.


> 
> > 
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > ---
> > Changes for v2:
> > - None
> > Changes for v3:
> > - Provide stub declaration when CONFIG_THERMAL is not set
> > Changes for v4:
> > - None
> > ---
> >  include/linux/thermal.h | 17 ++++++++++++++---
> >  1 file changed, 14 insertions(+), 3 deletions(-)
> > 
> > diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> > index fc52e30..eacf2de 100644
> > --- a/include/linux/thermal.h
> > +++ b/include/linux/thermal.h
> > @@ -293,6 +293,20 @@ struct thermal_trip {
> >  };
> >  
> >  /* Function declarations */
> > +#ifdef CONFIG_THERMAL
> > +struct thermal_cooling_device *
> > +thermal_of_cooling_device_register(struct device_node *np,
> > +				   char *type, void *devdata,
> > +				   const struct
> > thermal_cooling_device_ops *); +#else
> > +static inline struct thermal_cooling_device *
> > +thermal_of_cooling_device_register(struct device_node *np,
> > +				   char *type, void *devdata,
> > +				   const struct
> > thermal_cooling_device_ops *ops) +{
> > +	return NULL;
> > +}
> > +#endif
> >  #ifdef CONFIG_THERMAL_OF
> >  struct thermal_zone_device *
> >  thermal_zone_of_sensor_register(struct device *dev, int id, void
> > *data, @@ -328,9 +342,6 @@ void thermal_zone_device_update(struct
> > thermal_zone_device *); 
> >  struct thermal_cooling_device
> > *thermal_cooling_device_register(char *, void *, const struct
> > thermal_cooling_device_ops *); -struct thermal_cooling_device *
> > -thermal_of_cooling_device_register(struct device_node *np, char *,
> > void *,
> > -				   const struct
> > thermal_cooling_device_ops *); void
> > thermal_cooling_device_unregister(struct thermal_cooling_device *);
> > struct thermal_zone_device *thermal_zone_get_zone_by_name(const
> > char *name); int thermal_zone_get_temp(struct thermal_zone_device
> > *tz, unsigned long *temp); -- 2.0.0.rc2
> > 



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [lm-sensors] [PATCH v4 1/8] thermal: Provide stub for thermal_of_cooling_device_register() funct
@ 2015-02-25 12:26         ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-25 12:26 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

Hi Eduardo,

> On Wed, Feb 18, 2015 at 11:07:29AM +0100, Lukasz Majewski wrote:
> > Odroid U3 fan can work without being registered as OF cooling device
> > (with CONFIG_THERMAL_OF disabled).
> > In this situation it can be controlled via PWM entry at
> > /sys/class/hwmon/hwmon0/pwm1.
> > 
> > Therefore, the thermal_of_cooling_device_register() function needs
> > a stub to allow clean compilation.
> 
> 
> I've just applied a patch on this same matter from Nishanth Menon [1].
> Can you please check if his patch is enough for you?
> 
> [1] -
> https://git.kernel.org/cgit/linux/kernel/git/evalenti/linux-soc-thermal.git/commit/?h=fixes&id\x12ca7188468ee29c4e717f73db4bf43c90954fc7
> 

I will prepare new PWM-FAN patch set with above changes in mind.


> 
> > 
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > ---
> > Changes for v2:
> > - None
> > Changes for v3:
> > - Provide stub declaration when CONFIG_THERMAL is not set
> > Changes for v4:
> > - None
> > ---
> >  include/linux/thermal.h | 17 ++++++++++++++---
> >  1 file changed, 14 insertions(+), 3 deletions(-)
> > 
> > diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> > index fc52e30..eacf2de 100644
> > --- a/include/linux/thermal.h
> > +++ b/include/linux/thermal.h
> > @@ -293,6 +293,20 @@ struct thermal_trip {
> >  };
> >  
> >  /* Function declarations */
> > +#ifdef CONFIG_THERMAL
> > +struct thermal_cooling_device *
> > +thermal_of_cooling_device_register(struct device_node *np,
> > +				   char *type, void *devdata,
> > +				   const struct
> > thermal_cooling_device_ops *); +#else
> > +static inline struct thermal_cooling_device *
> > +thermal_of_cooling_device_register(struct device_node *np,
> > +				   char *type, void *devdata,
> > +				   const struct
> > thermal_cooling_device_ops *ops) +{
> > +	return NULL;
> > +}
> > +#endif
> >  #ifdef CONFIG_THERMAL_OF
> >  struct thermal_zone_device *
> >  thermal_zone_of_sensor_register(struct device *dev, int id, void
> > *data, @@ -328,9 +342,6 @@ void thermal_zone_device_update(struct
> > thermal_zone_device *); 
> >  struct thermal_cooling_device
> > *thermal_cooling_device_register(char *, void *, const struct
> > thermal_cooling_device_ops *); -struct thermal_cooling_device *
> > -thermal_of_cooling_device_register(struct device_node *np, char *,
> > void *,
> > -				   const struct
> > thermal_cooling_device_ops *); void
> > thermal_cooling_device_unregister(struct thermal_cooling_device *);
> > struct thermal_zone_device *thermal_zone_get_zone_by_name(const
> > char *name); int thermal_zone_get_temp(struct thermal_zone_device
> > *tz, unsigned long *temp); -- 2.0.0.rc2
> > 



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v4 5/8] ARM: dts: Add properties to use pwm-fan device as a cooling device in Odroid U3
  2015-02-24 19:37       ` [PATCH v4 5/8] ARM: dts: Add properties to use pwm-fan device as a cooling device in Odroid U3 Eduardo Valentin
  (?)
@ 2015-02-25 13:28         ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-25 13:28 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

Hi Eduardo,

> On Wed, Feb 18, 2015 at 11:07:33AM +0100, Lukasz Majewski wrote:
> > With those bindings it is possible to use pwm-fan device available
> > in Odroid U3 as a cooling device.
> > 
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > ---
> > Changes for v2:
> > - Rename cooling-pwm-values property to cooling-levels
> > Changes for v3:
> > - Change patch's topic to "ARM dts"
> > - Reduce maximal cooling-level to 230 from 255
> > Changes for v4:
> > - None
> > ---
> >  arch/arm/boot/dts/exynos4412-odroidu3.dts | 33
> > ++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1
> > deletion(-)
> > 
> > diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts
> > b/arch/arm/boot/dts/exynos4412-odroidu3.dts index 60bd1e4..3e5df3e
> > 100644 --- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
> > +++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
> > @@ -32,11 +32,42 @@
> >  		};
> >  	};
> >  
> > -	pwm-fan {
> > +	fan0: pwm-fan {
> >  		compatible = "pwm-fan";
> >  		pwms = <&pwm 0 10000 0>;
> > +		cooling-min-state = <0>;
> > +		cooling-max-state = <3>;
> > +		#cooling-cells = <2>;
> > +		cooling-levels = <0 102 170 230>;
> >  		status = "okay";
> >  	};
> > +
> > +	thermal-zones {
> > +		cpu_thermal: cpu-thermal {
> 
> 
> This thermal zone misses the mandatory properties as per 
>  Documentation/devicetree/bindings/thermal/thermal.txt

Following mandatory properties:
		thermal-sensors = <&tmu 0>;
		polling-delay-passive = <0>;
		polling-delay = <0>;
		trips {

		}

are defined in exynos4-cpu-thermal.dtsi included by this file.

In this patch only device dependent changes are stated.

> 
> > +			cooling-maps {
> > +				map0 {
> > +				     trip = <&cpu_alert1>;
> > +				     cooling-device = <&cpu0 7 7>;
> > +				};
> > +				map1 {
> > +				     trip = <&cpu_alert2>;
> > +				     cooling-device = <&cpu0 13
> > 13>;
> > +				};
> > +				map2 {
> > +				     trip = <&cpu_alert0>;
> > +				     cooling-device = <&fan0 0 1>;
> > +				};
> > +				map3 {
> > +				     trip = <&cpu_alert1>;
> > +				     cooling-device = <&fan0 1 2>;
> > +				};
> > +				map4 {
> > +				     trip = <&cpu_alert2>;
> > +				     cooling-device = <&fan0 2 3>;
> > +				};
> > +			};
> > +		};
> > +	};
> >  };
> >  
> >  &pwm {
> > -- 
> > 2.0.0.rc2
> > 



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v4 5/8] ARM: dts: Add properties to use pwm-fan device as a cooling device in Odroid U3
@ 2015-02-25 13:28         ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-25 13:28 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

Hi Eduardo,

> On Wed, Feb 18, 2015 at 11:07:33AM +0100, Lukasz Majewski wrote:
> > With those bindings it is possible to use pwm-fan device available
> > in Odroid U3 as a cooling device.
> > 
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > ---
> > Changes for v2:
> > - Rename cooling-pwm-values property to cooling-levels
> > Changes for v3:
> > - Change patch's topic to "ARM dts"
> > - Reduce maximal cooling-level to 230 from 255
> > Changes for v4:
> > - None
> > ---
> >  arch/arm/boot/dts/exynos4412-odroidu3.dts | 33
> > ++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1
> > deletion(-)
> > 
> > diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts
> > b/arch/arm/boot/dts/exynos4412-odroidu3.dts index 60bd1e4..3e5df3e
> > 100644 --- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
> > +++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
> > @@ -32,11 +32,42 @@
> >  		};
> >  	};
> >  
> > -	pwm-fan {
> > +	fan0: pwm-fan {
> >  		compatible = "pwm-fan";
> >  		pwms = <&pwm 0 10000 0>;
> > +		cooling-min-state = <0>;
> > +		cooling-max-state = <3>;
> > +		#cooling-cells = <2>;
> > +		cooling-levels = <0 102 170 230>;
> >  		status = "okay";
> >  	};
> > +
> > +	thermal-zones {
> > +		cpu_thermal: cpu-thermal {
> 
> 
> This thermal zone misses the mandatory properties as per 
>  Documentation/devicetree/bindings/thermal/thermal.txt

Following mandatory properties:
		thermal-sensors = <&tmu 0>;
		polling-delay-passive = <0>;
		polling-delay = <0>;
		trips {

		}

are defined in exynos4-cpu-thermal.dtsi included by this file.

In this patch only device dependent changes are stated.

> 
> > +			cooling-maps {
> > +				map0 {
> > +				     trip = <&cpu_alert1>;
> > +				     cooling-device = <&cpu0 7 7>;
> > +				};
> > +				map1 {
> > +				     trip = <&cpu_alert2>;
> > +				     cooling-device = <&cpu0 13
> > 13>;
> > +				};
> > +				map2 {
> > +				     trip = <&cpu_alert0>;
> > +				     cooling-device = <&fan0 0 1>;
> > +				};
> > +				map3 {
> > +				     trip = <&cpu_alert1>;
> > +				     cooling-device = <&fan0 1 2>;
> > +				};
> > +				map4 {
> > +				     trip = <&cpu_alert2>;
> > +				     cooling-device = <&fan0 2 3>;
> > +				};
> > +			};
> > +		};
> > +	};
> >  };
> >  
> >  &pwm {
> > -- 
> > 2.0.0.rc2
> > 



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [lm-sensors] [PATCH v4 5/8] ARM: dts: Add properties to use pwm-fan device as a cooling device i
@ 2015-02-25 13:28         ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-25 13:28 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

Hi Eduardo,

> On Wed, Feb 18, 2015 at 11:07:33AM +0100, Lukasz Majewski wrote:
> > With those bindings it is possible to use pwm-fan device available
> > in Odroid U3 as a cooling device.
> > 
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > ---
> > Changes for v2:
> > - Rename cooling-pwm-values property to cooling-levels
> > Changes for v3:
> > - Change patch's topic to "ARM dts"
> > - Reduce maximal cooling-level to 230 from 255
> > Changes for v4:
> > - None
> > ---
> >  arch/arm/boot/dts/exynos4412-odroidu3.dts | 33
> > ++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1
> > deletion(-)
> > 
> > diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts
> > b/arch/arm/boot/dts/exynos4412-odroidu3.dts index 60bd1e4..3e5df3e
> > 100644 --- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
> > +++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
> > @@ -32,11 +32,42 @@
> >  		};
> >  	};
> >  
> > -	pwm-fan {
> > +	fan0: pwm-fan {
> >  		compatible = "pwm-fan";
> >  		pwms = <&pwm 0 10000 0>;
> > +		cooling-min-state = <0>;
> > +		cooling-max-state = <3>;
> > +		#cooling-cells = <2>;
> > +		cooling-levels = <0 102 170 230>;
> >  		status = "okay";
> >  	};
> > +
> > +	thermal-zones {
> > +		cpu_thermal: cpu-thermal {
> 
> 
> This thermal zone misses the mandatory properties as per 
>  Documentation/devicetree/bindings/thermal/thermal.txt

Following mandatory properties:
		thermal-sensors = <&tmu 0>;
		polling-delay-passive = <0>;
		polling-delay = <0>;
		trips {

		}

are defined in exynos4-cpu-thermal.dtsi included by this file.

In this patch only device dependent changes are stated.

> 
> > +			cooling-maps {
> > +				map0 {
> > +				     trip = <&cpu_alert1>;
> > +				     cooling-device = <&cpu0 7 7>;
> > +				};
> > +				map1 {
> > +				     trip = <&cpu_alert2>;
> > +				     cooling-device = <&cpu0 13
> > 13>;
> > +				};
> > +				map2 {
> > +				     trip = <&cpu_alert0>;
> > +				     cooling-device = <&fan0 0 1>;
> > +				};
> > +				map3 {
> > +				     trip = <&cpu_alert1>;
> > +				     cooling-device = <&fan0 1 2>;
> > +				};
> > +				map4 {
> > +				     trip = <&cpu_alert2>;
> > +				     cooling-device = <&fan0 2 3>;
> > +				};
> > +			};
> > +		};
> > +	};
> >  };
> >  
> >  &pwm {
> > -- 
> > 2.0.0.rc2
> > 



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 329+ messages in thread

* [PATCH v5 0/6] hwmon: thermal: Odroid U3: Provide support for Odroid U3 fan
  2014-12-18 10:13 ` Lukasz Majewski
  (?)
@ 2015-02-25 15:34   ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-25 15:34 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

Presented patches add support for Odroid's U3 optional CPU FAN, which uses PWM
subsystem for low level control.

After successful probe it registers itself as a cooling device for thermal
subsystem.

This driver also supports devices without DTS specified.

To provide correct functionality, new properties to device tree description for
Exynos4412 and in particular Odroid U3 have been added.

Those patches were tested at Exynos4412 - Odroid U3 board.

Patches were applied on:
linux-soc-thermal/fixes branch (Linux v4.0-rc1)
SHA1: b71d399c7f2fe06b60b96155ec0b9ae167334e4a

Kamil Debski (1):
  ARM: dts: Add pwm-fan node to the Odroid-U3 board

Lukasz Majewski (5):
  Documentation: dts: Documentation entry to explain how to use PWM FAN
    as a cooling device
  ARM: dts: Add properties to use pwm-fan device as a cooling device in
    Odroid U3
  hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty
    cycle
  hwmon: pwm-fan: Read PWM FAN configuration from device tree
  hwmon: pwm-fan: Code for using PWM FAN as a cooling device

 .../devicetree/bindings/hwmon/pwm-fan.txt          |  25 +++-
 arch/arm/boot/dts/exynos4.dtsi                     |   2 +-
 arch/arm/boot/dts/exynos4412-odroidu3.dts          |  43 ++++++
 drivers/hwmon/pwm-fan.c                            | 166 +++++++++++++++++++--
 4 files changed, 220 insertions(+), 16 deletions(-)

-- 
2.0.0.rc2


^ permalink raw reply	[flat|nested] 329+ messages in thread

* [PATCH v5 0/6] hwmon: thermal: Odroid U3: Provide support for Odroid U3 fan
@ 2015-02-25 15:34   ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-25 15:34 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

Presented patches add support for Odroid's U3 optional CPU FAN, which uses PWM
subsystem for low level control.

After successful probe it registers itself as a cooling device for thermal
subsystem.

This driver also supports devices without DTS specified.

To provide correct functionality, new properties to device tree description for
Exynos4412 and in particular Odroid U3 have been added.

Those patches were tested at Exynos4412 - Odroid U3 board.

Patches were applied on:
linux-soc-thermal/fixes branch (Linux v4.0-rc1)
SHA1: b71d399c7f2fe06b60b96155ec0b9ae167334e4a

Kamil Debski (1):
  ARM: dts: Add pwm-fan node to the Odroid-U3 board

Lukasz Majewski (5):
  Documentation: dts: Documentation entry to explain how to use PWM FAN
    as a cooling device
  ARM: dts: Add properties to use pwm-fan device as a cooling device in
    Odroid U3
  hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty
    cycle
  hwmon: pwm-fan: Read PWM FAN configuration from device tree
  hwmon: pwm-fan: Code for using PWM FAN as a cooling device

 .../devicetree/bindings/hwmon/pwm-fan.txt          |  25 +++-
 arch/arm/boot/dts/exynos4.dtsi                     |   2 +-
 arch/arm/boot/dts/exynos4412-odroidu3.dts          |  43 ++++++
 drivers/hwmon/pwm-fan.c                            | 166 +++++++++++++++++++--
 4 files changed, 220 insertions(+), 16 deletions(-)

-- 
2.0.0.rc2


^ permalink raw reply	[flat|nested] 329+ messages in thread

* [lm-sensors] [PATCH v5 0/6] hwmon: thermal: Odroid U3: Provide support for Odroid U3 fan
@ 2015-02-25 15:34   ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-25 15:34 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

Presented patches add support for Odroid's U3 optional CPU FAN, which uses PWM
subsystem for low level control.

After successful probe it registers itself as a cooling device for thermal
subsystem.

This driver also supports devices without DTS specified.

To provide correct functionality, new properties to device tree description for
Exynos4412 and in particular Odroid U3 have been added.

Those patches were tested at Exynos4412 - Odroid U3 board.

Patches were applied on:
linux-soc-thermal/fixes branch (Linux v4.0-rc1)
SHA1: b71d399c7f2fe06b60b96155ec0b9ae167334e4a

Kamil Debski (1):
  ARM: dts: Add pwm-fan node to the Odroid-U3 board

Lukasz Majewski (5):
  Documentation: dts: Documentation entry to explain how to use PWM FAN
    as a cooling device
  ARM: dts: Add properties to use pwm-fan device as a cooling device in
    Odroid U3
  hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty
    cycle
  hwmon: pwm-fan: Read PWM FAN configuration from device tree
  hwmon: pwm-fan: Code for using PWM FAN as a cooling device

 .../devicetree/bindings/hwmon/pwm-fan.txt          |  25 +++-
 arch/arm/boot/dts/exynos4.dtsi                     |   2 +-
 arch/arm/boot/dts/exynos4412-odroidu3.dts          |  43 ++++++
 drivers/hwmon/pwm-fan.c                            | 166 +++++++++++++++++++--
 4 files changed, 220 insertions(+), 16 deletions(-)

-- 
2.0.0.rc2


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 329+ messages in thread

* [PATCH v5 1/6] Documentation: dts: Documentation entry to explain how to use PWM FAN as a cooling device
  2015-02-25 15:34   ` Lukasz Majewski
  (?)
@ 2015-02-25 15:34     ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-25 15:34 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

Explanation of several properties, which allow PWM fan working as a cooling
device, have been embraced in this commit.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Rename cooling-pwm-values to cooling-levels
- Remove default-pulse-width property and stick to default hwmon policy
Changes for v3:
- Changing commit title from "hwmon: dts: Doc:" to "Documentation: dts"
- Remove unnecessary properties
- Set maximal cooling level to 230 instead of 255
Changes for v4:
- None
Changes for v5:
- Move thermal-zones description to example section
- Extending example section

---
 .../devicetree/bindings/hwmon/pwm-fan.txt          | 25 +++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
index 610757c..645251b 100644
--- a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
+++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
@@ -3,10 +3,33 @@ Bindings for a fan connected to the PWM lines
 Required properties:
 - compatible	: "pwm-fan"
 - pwms		: the PWM that is used to control the PWM fan
+- cooling-levels      : PWM duty cycle values in a range from 0 to 255
+			which correspond to thermal cooling states
 
 Example:
-	pwm-fan {
+	fan0: pwm-fan {
 		compatible = "pwm-fan";
 		status = "okay";
 		pwms = <&pwm 0 10000 0>;
+		cooling-levels = <0 102 170 230>;
+	};
+
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+		cooling-min-state = <0>;
+		cooling-max-state = <3>;
+		#cooling-cells = <2>;
+		trips {
+			cpu_alert1: cpu-alert1 {
+				temperature = <100000>; /* millicelsius */
+				hysteresis = <2000>; /* millicelsius */
+				type = "passive";
+			};
+		};
+		cooling-maps {
+			map0 {
+			     trip = <&cpu_alert1>;
+			     cooling-device = <&fan0 0 1>;
+			};
+		};
 	};
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v5 1/6] Documentation: dts: Documentation entry to explain how to use PWM FAN as a cooling device
@ 2015-02-25 15:34     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-25 15:34 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

Explanation of several properties, which allow PWM fan working as a cooling
device, have been embraced in this commit.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Rename cooling-pwm-values to cooling-levels
- Remove default-pulse-width property and stick to default hwmon policy
Changes for v3:
- Changing commit title from "hwmon: dts: Doc:" to "Documentation: dts"
- Remove unnecessary properties
- Set maximal cooling level to 230 instead of 255
Changes for v4:
- None
Changes for v5:
- Move thermal-zones description to example section
- Extending example section

---
 .../devicetree/bindings/hwmon/pwm-fan.txt          | 25 +++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
index 610757c..645251b 100644
--- a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
+++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
@@ -3,10 +3,33 @@ Bindings for a fan connected to the PWM lines
 Required properties:
 - compatible	: "pwm-fan"
 - pwms		: the PWM that is used to control the PWM fan
+- cooling-levels      : PWM duty cycle values in a range from 0 to 255
+			which correspond to thermal cooling states
 
 Example:
-	pwm-fan {
+	fan0: pwm-fan {
 		compatible = "pwm-fan";
 		status = "okay";
 		pwms = <&pwm 0 10000 0>;
+		cooling-levels = <0 102 170 230>;
+	};
+
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+		cooling-min-state = <0>;
+		cooling-max-state = <3>;
+		#cooling-cells = <2>;
+		trips {
+			cpu_alert1: cpu-alert1 {
+				temperature = <100000>; /* millicelsius */
+				hysteresis = <2000>; /* millicelsius */
+				type = "passive";
+			};
+		};
+		cooling-maps {
+			map0 {
+			     trip = <&cpu_alert1>;
+			     cooling-device = <&fan0 0 1>;
+			};
+		};
 	};
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [lm-sensors] [PATCH v5 1/6] Documentation: dts: Documentation entry to explain how to use PWM FAN as
@ 2015-02-25 15:34     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-25 15:34 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

Explanation of several properties, which allow PWM fan working as a cooling
device, have been embraced in this commit.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Rename cooling-pwm-values to cooling-levels
- Remove default-pulse-width property and stick to default hwmon policy
Changes for v3:
- Changing commit title from "hwmon: dts: Doc:" to "Documentation: dts"
- Remove unnecessary properties
- Set maximal cooling level to 230 instead of 255
Changes for v4:
- None
Changes for v5:
- Move thermal-zones description to example section
- Extending example section

---
 .../devicetree/bindings/hwmon/pwm-fan.txt          | 25 +++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
index 610757c..645251b 100644
--- a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
+++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
@@ -3,10 +3,33 @@ Bindings for a fan connected to the PWM lines
 Required properties:
 - compatible	: "pwm-fan"
 - pwms		: the PWM that is used to control the PWM fan
+- cooling-levels      : PWM duty cycle values in a range from 0 to 255
+			which correspond to thermal cooling states
 
 Example:
-	pwm-fan {
+	fan0: pwm-fan {
 		compatible = "pwm-fan";
 		status = "okay";
 		pwms = <&pwm 0 10000 0>;
+		cooling-levels = <0 102 170 230>;
+	};
+
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+		cooling-min-state = <0>;
+		cooling-max-state = <3>;
+		#cooling-cells = <2>;
+		trips {
+			cpu_alert1: cpu-alert1 {
+				temperature = <100000>; /* millicelsius */
+				hysteresis = <2000>; /* millicelsius */
+				type = "passive";
+			};
+		};
+		cooling-maps {
+			map0 {
+			     trip = <&cpu_alert1>;
+			     cooling-device = <&fan0 0 1>;
+			};
+		};
 	};
-- 
2.0.0.rc2


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v5 2/6] ARM: dts: Add pwm-fan node to the Odroid-U3 board
  2015-02-25 15:34   ` Lukasz Majewski
  (?)
@ 2015-02-25 15:34     ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-25 15:34 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

From: Kamil Debski <k.debski@samsung.com>

Add pwm-fan node to the Odroid-U3 board file to enable PWM control of the
cooling fan. In addition, add the "pwm" label to the pwm@139D0000 node
in the exynos4412.dtsi.

Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes since v1:
- added pwm label to the pwm@139D0000 node in exynos4.dtsi
- use the pwm label in the exynos4412-odroidu3.dts
- change order or properties in the pwn-fan node, to be sorted
  in alphabetical order
Changes for v5:
- Adding Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
- status = "okay"; dropped from the patch

---
 arch/arm/boot/dts/exynos4.dtsi            |  2 +-
 arch/arm/boot/dts/exynos4412-odroidu3.dts | 12 ++++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/exynos4.dtsi b/arch/arm/boot/dts/exynos4.dtsi
index 690f56c..a93f5ca5 100644
--- a/arch/arm/boot/dts/exynos4.dtsi
+++ b/arch/arm/boot/dts/exynos4.dtsi
@@ -599,7 +599,7 @@
 		status = "disabled";
 	};
 
-	pwm@139D0000 {
+	pwm: pwm@139D0000 {
 		compatible = "samsung,exynos4210-pwm";
 		reg = <0x139D0000 0x1000>;
 		interrupts = <0 37 0>, <0 38 0>, <0 39 0>, <0 40 0>, <0 41 0>;
diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
index 44684e5..4c04837 100644
--- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
+++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
@@ -31,6 +31,18 @@
 			linux,default-trigger = "heartbeat";
 		};
 	};
+
+	pwm-fan {
+		compatible = "pwm-fan";
+		pwms = <&pwm 0 10000 0>;
+	};
+};
+
+&pwm {
+	pinctrl-0 = <&pwm0_out>;
+	pinctrl-names = "default";
+	samsung,pwm-outputs = <0>;
+	status = "okay";
 };
 
 &usb3503 {
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v5 2/6] ARM: dts: Add pwm-fan node to the Odroid-U3 board
@ 2015-02-25 15:34     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-25 15:34 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

From: Kamil Debski <k.debski@samsung.com>

Add pwm-fan node to the Odroid-U3 board file to enable PWM control of the
cooling fan. In addition, add the "pwm" label to the pwm@139D0000 node
in the exynos4412.dtsi.

Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes since v1:
- added pwm label to the pwm@139D0000 node in exynos4.dtsi
- use the pwm label in the exynos4412-odroidu3.dts
- change order or properties in the pwn-fan node, to be sorted
  in alphabetical order
Changes for v5:
- Adding Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
- status = "okay"; dropped from the patch

---
 arch/arm/boot/dts/exynos4.dtsi            |  2 +-
 arch/arm/boot/dts/exynos4412-odroidu3.dts | 12 ++++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/exynos4.dtsi b/arch/arm/boot/dts/exynos4.dtsi
index 690f56c..a93f5ca5 100644
--- a/arch/arm/boot/dts/exynos4.dtsi
+++ b/arch/arm/boot/dts/exynos4.dtsi
@@ -599,7 +599,7 @@
 		status = "disabled";
 	};
 
-	pwm@139D0000 {
+	pwm: pwm@139D0000 {
 		compatible = "samsung,exynos4210-pwm";
 		reg = <0x139D0000 0x1000>;
 		interrupts = <0 37 0>, <0 38 0>, <0 39 0>, <0 40 0>, <0 41 0>;
diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
index 44684e5..4c04837 100644
--- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
+++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
@@ -31,6 +31,18 @@
 			linux,default-trigger = "heartbeat";
 		};
 	};
+
+	pwm-fan {
+		compatible = "pwm-fan";
+		pwms = <&pwm 0 10000 0>;
+	};
+};
+
+&pwm {
+	pinctrl-0 = <&pwm0_out>;
+	pinctrl-names = "default";
+	samsung,pwm-outputs = <0>;
+	status = "okay";
 };
 
 &usb3503 {
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [lm-sensors] [PATCH v5 2/6] ARM: dts: Add pwm-fan node to the Odroid-U3 board
@ 2015-02-25 15:34     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-25 15:34 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

From: Kamil Debski <k.debski@samsung.com>

Add pwm-fan node to the Odroid-U3 board file to enable PWM control of the
cooling fan. In addition, add the "pwm" label to the pwm@139D0000 node
in the exynos4412.dtsi.

Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes since v1:
- added pwm label to the pwm@139D0000 node in exynos4.dtsi
- use the pwm label in the exynos4412-odroidu3.dts
- change order or properties in the pwn-fan node, to be sorted
  in alphabetical order
Changes for v5:
- Adding Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
- status = "okay"; dropped from the patch

---
 arch/arm/boot/dts/exynos4.dtsi            |  2 +-
 arch/arm/boot/dts/exynos4412-odroidu3.dts | 12 ++++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/exynos4.dtsi b/arch/arm/boot/dts/exynos4.dtsi
index 690f56c..a93f5ca5 100644
--- a/arch/arm/boot/dts/exynos4.dtsi
+++ b/arch/arm/boot/dts/exynos4.dtsi
@@ -599,7 +599,7 @@
 		status = "disabled";
 	};
 
-	pwm@139D0000 {
+	pwm: pwm@139D0000 {
 		compatible = "samsung,exynos4210-pwm";
 		reg = <0x139D0000 0x1000>;
 		interrupts = <0 37 0>, <0 38 0>, <0 39 0>, <0 40 0>, <0 41 0>;
diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
index 44684e5..4c04837 100644
--- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
+++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
@@ -31,6 +31,18 @@
 			linux,default-trigger = "heartbeat";
 		};
 	};
+
+	pwm-fan {
+		compatible = "pwm-fan";
+		pwms = <&pwm 0 10000 0>;
+	};
+};
+
+&pwm {
+	pinctrl-0 = <&pwm0_out>;
+	pinctrl-names = "default";
+	samsung,pwm-outputs = <0>;
+	status = "okay";
 };
 
 &usb3503 {
-- 
2.0.0.rc2


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v5 3/6] ARM: dts: Add properties to use pwm-fan device as a cooling device in Odroid U3
  2015-02-25 15:34   ` Lukasz Majewski
  (?)
@ 2015-02-25 15:34     ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-25 15:34 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

With those bindings it is possible to use pwm-fan device available in
Odroid U3 as a cooling device.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Rename cooling-pwm-values property to cooling-levels
Changes for v3:
- Change patch's topic to "ARM dts"
- Reduce maximal cooling-level to 230 from 255
Changes for v4:
- None
Changes for v5:
- None
---
 arch/arm/boot/dts/exynos4412-odroidu3.dts | 33 ++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
index 4c04837..abcfa3c 100644
--- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
+++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
@@ -32,9 +32,40 @@
 		};
 	};
 
-	pwm-fan {
+	fan0: pwm-fan {
 		compatible = "pwm-fan";
 		pwms = <&pwm 0 10000 0>;
+		cooling-min-state = <0>;
+		cooling-max-state = <3>;
+		#cooling-cells = <2>;
+		cooling-levels = <0 102 170 230>;
+	};
+
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				     trip = <&cpu_alert1>;
+				     cooling-device = <&cpu0 7 7>;
+				};
+				map1 {
+				     trip = <&cpu_alert2>;
+				     cooling-device = <&cpu0 13 13>;
+				};
+				map2 {
+				     trip = <&cpu_alert0>;
+				     cooling-device = <&fan0 0 1>;
+				};
+				map3 {
+				     trip = <&cpu_alert1>;
+				     cooling-device = <&fan0 1 2>;
+				};
+				map4 {
+				     trip = <&cpu_alert2>;
+				     cooling-device = <&fan0 2 3>;
+				};
+			};
+		};
 	};
 };
 
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v5 3/6] ARM: dts: Add properties to use pwm-fan device as a cooling device in Odroid U3
@ 2015-02-25 15:34     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-25 15:34 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

With those bindings it is possible to use pwm-fan device available in
Odroid U3 as a cooling device.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Rename cooling-pwm-values property to cooling-levels
Changes for v3:
- Change patch's topic to "ARM dts"
- Reduce maximal cooling-level to 230 from 255
Changes for v4:
- None
Changes for v5:
- None
---
 arch/arm/boot/dts/exynos4412-odroidu3.dts | 33 ++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
index 4c04837..abcfa3c 100644
--- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
+++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
@@ -32,9 +32,40 @@
 		};
 	};
 
-	pwm-fan {
+	fan0: pwm-fan {
 		compatible = "pwm-fan";
 		pwms = <&pwm 0 10000 0>;
+		cooling-min-state = <0>;
+		cooling-max-state = <3>;
+		#cooling-cells = <2>;
+		cooling-levels = <0 102 170 230>;
+	};
+
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				     trip = <&cpu_alert1>;
+				     cooling-device = <&cpu0 7 7>;
+				};
+				map1 {
+				     trip = <&cpu_alert2>;
+				     cooling-device = <&cpu0 13 13>;
+				};
+				map2 {
+				     trip = <&cpu_alert0>;
+				     cooling-device = <&fan0 0 1>;
+				};
+				map3 {
+				     trip = <&cpu_alert1>;
+				     cooling-device = <&fan0 1 2>;
+				};
+				map4 {
+				     trip = <&cpu_alert2>;
+				     cooling-device = <&fan0 2 3>;
+				};
+			};
+		};
 	};
 };
 
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [lm-sensors] [PATCH v5 3/6] ARM: dts: Add properties to use pwm-fan device as a cooling device in Od
@ 2015-02-25 15:34     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-25 15:34 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

With those bindings it is possible to use pwm-fan device available in
Odroid U3 as a cooling device.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Rename cooling-pwm-values property to cooling-levels
Changes for v3:
- Change patch's topic to "ARM dts"
- Reduce maximal cooling-level to 230 from 255
Changes for v4:
- None
Changes for v5:
- None
---
 arch/arm/boot/dts/exynos4412-odroidu3.dts | 33 ++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
index 4c04837..abcfa3c 100644
--- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
+++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
@@ -32,9 +32,40 @@
 		};
 	};
 
-	pwm-fan {
+	fan0: pwm-fan {
 		compatible = "pwm-fan";
 		pwms = <&pwm 0 10000 0>;
+		cooling-min-state = <0>;
+		cooling-max-state = <3>;
+		#cooling-cells = <2>;
+		cooling-levels = <0 102 170 230>;
+	};
+
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				     trip = <&cpu_alert1>;
+				     cooling-device = <&cpu0 7 7>;
+				};
+				map1 {
+				     trip = <&cpu_alert2>;
+				     cooling-device = <&cpu0 13 13>;
+				};
+				map2 {
+				     trip = <&cpu_alert0>;
+				     cooling-device = <&fan0 0 1>;
+				};
+				map3 {
+				     trip = <&cpu_alert1>;
+				     cooling-device = <&fan0 1 2>;
+				};
+				map4 {
+				     trip = <&cpu_alert2>;
+				     cooling-device = <&fan0 2 3>;
+				};
+			};
+		};
 	};
 };
 
-- 
2.0.0.rc2


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v5 4/6] hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty cycle
  2015-02-25 15:34   ` Lukasz Majewski
  (?)
@ 2015-02-25 15:34     ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-25 15:34 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

It was necessary to decouple code handling writing to sysfs from the one
responsible for setting PWM of the fan.
Due to that, new __set_pwm() method was extracted, which is responsible for
only setting new PWM duty cycle.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- The commit headline has been reedited.
Changes for v4:
- Protect "if (ctx->pwm_value == pwm)" with ctx lock
- Initialize ret with zero
Changes for v5:
- None
---
 drivers/hwmon/pwm-fan.c | 33 +++++++++++++++++++++------------
 1 file changed, 21 insertions(+), 12 deletions(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index 1991d903..bd42d39 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -33,20 +33,14 @@ struct pwm_fan_ctx {
 	unsigned char pwm_value;
 };
 
-static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
-		       const char *buf, size_t count)
+static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
 {
-	struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
-	unsigned long pwm, duty;
-	ssize_t ret;
-
-	if (kstrtoul(buf, 10, &pwm) || pwm > MAX_PWM)
-		return -EINVAL;
+	unsigned long duty;
+	int ret = 0;
 
 	mutex_lock(&ctx->lock);
-
 	if (ctx->pwm_value == pwm)
-		goto exit_set_pwm_no_change;
+		goto exit_set_pwm_err;
 
 	if (pwm == 0) {
 		pwm_disable(ctx->pwm);
@@ -66,13 +60,28 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 
 exit_set_pwm:
 	ctx->pwm_value = pwm;
-exit_set_pwm_no_change:
-	ret = count;
 exit_set_pwm_err:
 	mutex_unlock(&ctx->lock);
 	return ret;
 }
 
+static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
+		       const char *buf, size_t count)
+{
+	struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
+	unsigned long pwm;
+	int ret;
+
+	if (kstrtoul(buf, 10, &pwm) || pwm > MAX_PWM)
+		return -EINVAL;
+
+	ret = __set_pwm(ctx, pwm);
+	if (ret)
+		return ret;
+
+	return count;
+}
+
 static ssize_t show_pwm(struct device *dev,
 			struct device_attribute *attr, char *buf)
 {
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v5 4/6] hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty cycle
@ 2015-02-25 15:34     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-25 15:34 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

It was necessary to decouple code handling writing to sysfs from the one
responsible for setting PWM of the fan.
Due to that, new __set_pwm() method was extracted, which is responsible for
only setting new PWM duty cycle.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- The commit headline has been reedited.
Changes for v4:
- Protect "if (ctx->pwm_value == pwm)" with ctx lock
- Initialize ret with zero
Changes for v5:
- None
---
 drivers/hwmon/pwm-fan.c | 33 +++++++++++++++++++++------------
 1 file changed, 21 insertions(+), 12 deletions(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index 1991d903..bd42d39 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -33,20 +33,14 @@ struct pwm_fan_ctx {
 	unsigned char pwm_value;
 };
 
-static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
-		       const char *buf, size_t count)
+static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
 {
-	struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
-	unsigned long pwm, duty;
-	ssize_t ret;
-
-	if (kstrtoul(buf, 10, &pwm) || pwm > MAX_PWM)
-		return -EINVAL;
+	unsigned long duty;
+	int ret = 0;
 
 	mutex_lock(&ctx->lock);
-
 	if (ctx->pwm_value == pwm)
-		goto exit_set_pwm_no_change;
+		goto exit_set_pwm_err;
 
 	if (pwm == 0) {
 		pwm_disable(ctx->pwm);
@@ -66,13 +60,28 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 
 exit_set_pwm:
 	ctx->pwm_value = pwm;
-exit_set_pwm_no_change:
-	ret = count;
 exit_set_pwm_err:
 	mutex_unlock(&ctx->lock);
 	return ret;
 }
 
+static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
+		       const char *buf, size_t count)
+{
+	struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
+	unsigned long pwm;
+	int ret;
+
+	if (kstrtoul(buf, 10, &pwm) || pwm > MAX_PWM)
+		return -EINVAL;
+
+	ret = __set_pwm(ctx, pwm);
+	if (ret)
+		return ret;
+
+	return count;
+}
+
 static ssize_t show_pwm(struct device *dev,
 			struct device_attribute *attr, char *buf)
 {
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [lm-sensors] [PATCH v5 4/6] hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty cyc
@ 2015-02-25 15:34     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-25 15:34 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

It was necessary to decouple code handling writing to sysfs from the one
responsible for setting PWM of the fan.
Due to that, new __set_pwm() method was extracted, which is responsible for
only setting new PWM duty cycle.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- The commit headline has been reedited.
Changes for v4:
- Protect "if (ctx->pwm_value = pwm)" with ctx lock
- Initialize ret with zero
Changes for v5:
- None
---
 drivers/hwmon/pwm-fan.c | 33 +++++++++++++++++++++------------
 1 file changed, 21 insertions(+), 12 deletions(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index 1991d903..bd42d39 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -33,20 +33,14 @@ struct pwm_fan_ctx {
 	unsigned char pwm_value;
 };
 
-static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
-		       const char *buf, size_t count)
+static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
 {
-	struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
-	unsigned long pwm, duty;
-	ssize_t ret;
-
-	if (kstrtoul(buf, 10, &pwm) || pwm > MAX_PWM)
-		return -EINVAL;
+	unsigned long duty;
+	int ret = 0;
 
 	mutex_lock(&ctx->lock);
-
 	if (ctx->pwm_value = pwm)
-		goto exit_set_pwm_no_change;
+		goto exit_set_pwm_err;
 
 	if (pwm = 0) {
 		pwm_disable(ctx->pwm);
@@ -66,13 +60,28 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 
 exit_set_pwm:
 	ctx->pwm_value = pwm;
-exit_set_pwm_no_change:
-	ret = count;
 exit_set_pwm_err:
 	mutex_unlock(&ctx->lock);
 	return ret;
 }
 
+static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
+		       const char *buf, size_t count)
+{
+	struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
+	unsigned long pwm;
+	int ret;
+
+	if (kstrtoul(buf, 10, &pwm) || pwm > MAX_PWM)
+		return -EINVAL;
+
+	ret = __set_pwm(ctx, pwm);
+	if (ret)
+		return ret;
+
+	return count;
+}
+
 static ssize_t show_pwm(struct device *dev,
 			struct device_attribute *attr, char *buf)
 {
-- 
2.0.0.rc2


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v5 5/6] hwmon: pwm-fan: Read PWM FAN configuration from device tree
  2015-02-25 15:34   ` Lukasz Majewski
  (?)
@ 2015-02-25 15:34     ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-25 15:34 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

This patch provides code for reading PWM FAN configuration data via
device tree. The pwm-fan can work with full speed when configuration
is not provided. However, errors are propagated when wrong DT bindings
are found.
Additionally the struct pwm_fan_ctx has been extended.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Rename pwm_fan_max_states to pwm_fan_cooling_levels
- Moving pwm_fan_of_get_cooling_data() call after setting end enabling PWM FAN
- pwm_fan_of_get_cooling_data() now can fail - preserving old behaviour
- Remove unnecessary dev_err() call
Changes for v3:
- Patch's headline has been reedited
- pwm_fan_of_get_cooling_data() return code is now being checked.
- of_property_count_elems_of_size() is now used instead of_find_property()
- More verbose patch description added
Changes for v4:
- dev_err() has been removed from pwm_fan_of_get_cooling_data()
- Returning -EINVAL when "cooling-levels" are defined in DT, but doesn't
  have the value
Changes for v5:
- Use of of_find_property() to assess if "cooling-levels" was defined in
  device tree
- Replace of_property_count_elems_of_size() with of_property_count_u32_elems()
- Remove ambiguity with returning error code from of_property_count_u32_elems()
- Return -EINVAL when "cooling-levels" has zero elements
---
 drivers/hwmon/pwm-fan.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 49 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index bd42d39..e6ed353 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -30,7 +30,10 @@
 struct pwm_fan_ctx {
 	struct mutex lock;
 	struct pwm_device *pwm;
-	unsigned char pwm_value;
+	unsigned int pwm_value;
+	unsigned int pwm_fan_state;
+	unsigned int pwm_fan_max_state;
+	unsigned int *pwm_fan_cooling_levels;
 };
 
 static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
@@ -100,6 +103,46 @@ static struct attribute *pwm_fan_attrs[] = {
 
 ATTRIBUTE_GROUPS(pwm_fan);
 
+int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
+{
+	struct device_node *np = dev->of_node;
+	int num, i, ret;
+
+	if (!of_find_property(np, "cooling-levels", NULL))
+		return 0;
+
+	ret = of_property_count_u32_elems(np, "cooling-levels");
+	if (ret <= 0) {
+		dev_err(dev, "Wrong data!\n");
+		return ret ? : -EINVAL;
+	}
+
+	num = ret;
+	ctx->pwm_fan_cooling_levels = devm_kzalloc(dev, num * sizeof(u32),
+						   GFP_KERNEL);
+	if (!ctx->pwm_fan_cooling_levels)
+		return -ENOMEM;
+
+	ret = of_property_read_u32_array(np, "cooling-levels",
+					 ctx->pwm_fan_cooling_levels, num);
+	if (ret) {
+		dev_err(dev, "Property 'cooling-levels' cannot be read!\n");
+		return ret;
+	}
+
+	for (i = 0; i < num; i++) {
+		if (ctx->pwm_fan_cooling_levels[i] > MAX_PWM) {
+			dev_err(dev, "PWM fan state[%d]:%d > %d\n", i,
+				ctx->pwm_fan_cooling_levels[i], MAX_PWM);
+			return -EINVAL;
+		}
+	}
+
+	ctx->pwm_fan_max_state = num - 1;
+
+	return 0;
+}
+
 static int pwm_fan_probe(struct platform_device *pdev)
 {
 	struct device *hwmon;
@@ -145,6 +188,11 @@ static int pwm_fan_probe(struct platform_device *pdev)
 		pwm_disable(ctx->pwm);
 		return PTR_ERR(hwmon);
 	}
+
+	ret = pwm_fan_of_get_cooling_data(&pdev->dev, ctx);
+	if (ret)
+		return ret;
+
 	return 0;
 }
 
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v5 5/6] hwmon: pwm-fan: Read PWM FAN configuration from device tree
@ 2015-02-25 15:34     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-25 15:34 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

This patch provides code for reading PWM FAN configuration data via
device tree. The pwm-fan can work with full speed when configuration
is not provided. However, errors are propagated when wrong DT bindings
are found.
Additionally the struct pwm_fan_ctx has been extended.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Rename pwm_fan_max_states to pwm_fan_cooling_levels
- Moving pwm_fan_of_get_cooling_data() call after setting end enabling PWM FAN
- pwm_fan_of_get_cooling_data() now can fail - preserving old behaviour
- Remove unnecessary dev_err() call
Changes for v3:
- Patch's headline has been reedited
- pwm_fan_of_get_cooling_data() return code is now being checked.
- of_property_count_elems_of_size() is now used instead of_find_property()
- More verbose patch description added
Changes for v4:
- dev_err() has been removed from pwm_fan_of_get_cooling_data()
- Returning -EINVAL when "cooling-levels" are defined in DT, but doesn't
  have the value
Changes for v5:
- Use of of_find_property() to assess if "cooling-levels" was defined in
  device tree
- Replace of_property_count_elems_of_size() with of_property_count_u32_elems()
- Remove ambiguity with returning error code from of_property_count_u32_elems()
- Return -EINVAL when "cooling-levels" has zero elements
---
 drivers/hwmon/pwm-fan.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 49 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index bd42d39..e6ed353 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -30,7 +30,10 @@
 struct pwm_fan_ctx {
 	struct mutex lock;
 	struct pwm_device *pwm;
-	unsigned char pwm_value;
+	unsigned int pwm_value;
+	unsigned int pwm_fan_state;
+	unsigned int pwm_fan_max_state;
+	unsigned int *pwm_fan_cooling_levels;
 };
 
 static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
@@ -100,6 +103,46 @@ static struct attribute *pwm_fan_attrs[] = {
 
 ATTRIBUTE_GROUPS(pwm_fan);
 
+int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
+{
+	struct device_node *np = dev->of_node;
+	int num, i, ret;
+
+	if (!of_find_property(np, "cooling-levels", NULL))
+		return 0;
+
+	ret = of_property_count_u32_elems(np, "cooling-levels");
+	if (ret <= 0) {
+		dev_err(dev, "Wrong data!\n");
+		return ret ? : -EINVAL;
+	}
+
+	num = ret;
+	ctx->pwm_fan_cooling_levels = devm_kzalloc(dev, num * sizeof(u32),
+						   GFP_KERNEL);
+	if (!ctx->pwm_fan_cooling_levels)
+		return -ENOMEM;
+
+	ret = of_property_read_u32_array(np, "cooling-levels",
+					 ctx->pwm_fan_cooling_levels, num);
+	if (ret) {
+		dev_err(dev, "Property 'cooling-levels' cannot be read!\n");
+		return ret;
+	}
+
+	for (i = 0; i < num; i++) {
+		if (ctx->pwm_fan_cooling_levels[i] > MAX_PWM) {
+			dev_err(dev, "PWM fan state[%d]:%d > %d\n", i,
+				ctx->pwm_fan_cooling_levels[i], MAX_PWM);
+			return -EINVAL;
+		}
+	}
+
+	ctx->pwm_fan_max_state = num - 1;
+
+	return 0;
+}
+
 static int pwm_fan_probe(struct platform_device *pdev)
 {
 	struct device *hwmon;
@@ -145,6 +188,11 @@ static int pwm_fan_probe(struct platform_device *pdev)
 		pwm_disable(ctx->pwm);
 		return PTR_ERR(hwmon);
 	}
+
+	ret = pwm_fan_of_get_cooling_data(&pdev->dev, ctx);
+	if (ret)
+		return ret;
+
 	return 0;
 }
 
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [lm-sensors] [PATCH v5 5/6] hwmon: pwm-fan: Read PWM FAN configuration from device tree
@ 2015-02-25 15:34     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-25 15:34 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

This patch provides code for reading PWM FAN configuration data via
device tree. The pwm-fan can work with full speed when configuration
is not provided. However, errors are propagated when wrong DT bindings
are found.
Additionally the struct pwm_fan_ctx has been extended.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Rename pwm_fan_max_states to pwm_fan_cooling_levels
- Moving pwm_fan_of_get_cooling_data() call after setting end enabling PWM FAN
- pwm_fan_of_get_cooling_data() now can fail - preserving old behaviour
- Remove unnecessary dev_err() call
Changes for v3:
- Patch's headline has been reedited
- pwm_fan_of_get_cooling_data() return code is now being checked.
- of_property_count_elems_of_size() is now used instead of_find_property()
- More verbose patch description added
Changes for v4:
- dev_err() has been removed from pwm_fan_of_get_cooling_data()
- Returning -EINVAL when "cooling-levels" are defined in DT, but doesn't
  have the value
Changes for v5:
- Use of of_find_property() to assess if "cooling-levels" was defined in
  device tree
- Replace of_property_count_elems_of_size() with of_property_count_u32_elems()
- Remove ambiguity with returning error code from of_property_count_u32_elems()
- Return -EINVAL when "cooling-levels" has zero elements
---
 drivers/hwmon/pwm-fan.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 49 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index bd42d39..e6ed353 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -30,7 +30,10 @@
 struct pwm_fan_ctx {
 	struct mutex lock;
 	struct pwm_device *pwm;
-	unsigned char pwm_value;
+	unsigned int pwm_value;
+	unsigned int pwm_fan_state;
+	unsigned int pwm_fan_max_state;
+	unsigned int *pwm_fan_cooling_levels;
 };
 
 static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
@@ -100,6 +103,46 @@ static struct attribute *pwm_fan_attrs[] = {
 
 ATTRIBUTE_GROUPS(pwm_fan);
 
+int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
+{
+	struct device_node *np = dev->of_node;
+	int num, i, ret;
+
+	if (!of_find_property(np, "cooling-levels", NULL))
+		return 0;
+
+	ret = of_property_count_u32_elems(np, "cooling-levels");
+	if (ret <= 0) {
+		dev_err(dev, "Wrong data!\n");
+		return ret ? : -EINVAL;
+	}
+
+	num = ret;
+	ctx->pwm_fan_cooling_levels = devm_kzalloc(dev, num * sizeof(u32),
+						   GFP_KERNEL);
+	if (!ctx->pwm_fan_cooling_levels)
+		return -ENOMEM;
+
+	ret = of_property_read_u32_array(np, "cooling-levels",
+					 ctx->pwm_fan_cooling_levels, num);
+	if (ret) {
+		dev_err(dev, "Property 'cooling-levels' cannot be read!\n");
+		return ret;
+	}
+
+	for (i = 0; i < num; i++) {
+		if (ctx->pwm_fan_cooling_levels[i] > MAX_PWM) {
+			dev_err(dev, "PWM fan state[%d]:%d > %d\n", i,
+				ctx->pwm_fan_cooling_levels[i], MAX_PWM);
+			return -EINVAL;
+		}
+	}
+
+	ctx->pwm_fan_max_state = num - 1;
+
+	return 0;
+}
+
 static int pwm_fan_probe(struct platform_device *pdev)
 {
 	struct device *hwmon;
@@ -145,6 +188,11 @@ static int pwm_fan_probe(struct platform_device *pdev)
 		pwm_disable(ctx->pwm);
 		return PTR_ERR(hwmon);
 	}
+
+	ret = pwm_fan_of_get_cooling_data(&pdev->dev, ctx);
+	if (ret)
+		return ret;
+
 	return 0;
 }
 
-- 
2.0.0.rc2


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v5 6/6] hwmon: pwm-fan: Code for using PWM FAN as a cooling device
  2015-02-25 15:34   ` Lukasz Majewski
  (?)
@ 2015-02-25 15:34     ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-25 15:34 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

The PWM FAN device can now be used as a thermal cooling device. Necessary
infrastructure has been added in this commit.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Replace pwm_fan_cooling_states with pwm_fan_cooling_levels
- Update ctx->pwm_fan_state when correct data from device tree is available
- Using therma_cdev_update() when thermal is ready for controlling the fan
Changes for v3:
- Rename patch heading
- pwm_fan_of_get_cooling_data() now returns -EINVAL when no "cooling-levels"
  property defined
- register of cooling device only when proper cooling data is present
Changes for v4:
- None
Changes for v5:
- Check for IS_ENABLED(CONFIG_THERMAL) has been added to prevent from
  executing thermal_* specific functions
---
 drivers/hwmon/pwm-fan.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 82 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index e6ed353..2c1a8f0 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -24,6 +24,7 @@
 #include <linux/platform_device.h>
 #include <linux/pwm.h>
 #include <linux/sysfs.h>
+#include <linux/thermal.h>
 
 #define MAX_PWM 255
 
@@ -68,6 +69,17 @@ exit_set_pwm_err:
 	return ret;
 }
 
+static void pwm_fan_update_state(struct pwm_fan_ctx *ctx, unsigned long pwm)
+{
+	int i;
+
+	for (i = 0; i < ctx->pwm_fan_max_state; ++i)
+		if (pwm < ctx->pwm_fan_cooling_levels[i + 1])
+			break;
+
+	ctx->pwm_fan_state = i;
+}
+
 static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 		       const char *buf, size_t count)
 {
@@ -82,6 +94,7 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 	if (ret)
 		return ret;
 
+	pwm_fan_update_state(ctx, pwm);
 	return count;
 }
 
@@ -103,6 +116,59 @@ static struct attribute *pwm_fan_attrs[] = {
 
 ATTRIBUTE_GROUPS(pwm_fan);
 
+/* thermal cooling device callbacks */
+static int pwm_fan_get_max_state(struct thermal_cooling_device *cdev,
+				 unsigned long *state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+
+	*state = ctx->pwm_fan_max_state;
+
+	return 0;
+}
+
+static int pwm_fan_get_cur_state(struct thermal_cooling_device *cdev,
+				 unsigned long *state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+
+	if (!ctx)
+		return -EINVAL;
+
+	*state = ctx->pwm_fan_state;
+
+	return 0;
+}
+
+static int
+pwm_fan_set_cur_state(struct thermal_cooling_device *cdev, unsigned long state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+	int ret;
+
+	if (!ctx || (state > ctx->pwm_fan_max_state))
+		return -EINVAL;
+
+	if (state == ctx->pwm_fan_state)
+		return 0;
+
+	ret = __set_pwm(ctx, ctx->pwm_fan_cooling_levels[state]);
+	if (ret) {
+		dev_err(&cdev->device, "Cannot set pwm!\n");
+		return ret;
+	}
+
+	ctx->pwm_fan_state = state;
+
+	return ret;
+}
+
+static const struct thermal_cooling_device_ops pwm_fan_cooling_ops = {
+	.get_max_state = pwm_fan_get_max_state,
+	.get_cur_state = pwm_fan_get_cur_state,
+	.set_cur_state = pwm_fan_set_cur_state,
+};
+
 int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
 {
 	struct device_node *np = dev->of_node;
@@ -145,8 +211,9 @@ int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
 
 static int pwm_fan_probe(struct platform_device *pdev)
 {
-	struct device *hwmon;
+	struct thermal_cooling_device *cdev;
 	struct pwm_fan_ctx *ctx;
+	struct device *hwmon;
 	int duty_cycle;
 	int ret;
 
@@ -193,6 +260,20 @@ static int pwm_fan_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
+	ctx->pwm_fan_state = ctx->pwm_fan_max_state;
+	if (IS_ENABLED(CONFIG_THERMAL)) {
+		cdev = thermal_of_cooling_device_register(pdev->dev.of_node,
+							  "pwm-fan", ctx,
+							  &pwm_fan_cooling_ops);
+		if (IS_ERR(cdev)) {
+			dev_err(&pdev->dev,
+				"Failed to register pwm-fan as cooling device");
+			pwm_disable(ctx->pwm);
+			return PTR_ERR(cdev);
+		}
+		thermal_cdev_update(cdev);
+	}
+
 	return 0;
 }
 
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v5 6/6] hwmon: pwm-fan: Code for using PWM FAN as a cooling device
@ 2015-02-25 15:34     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-25 15:34 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

The PWM FAN device can now be used as a thermal cooling device. Necessary
infrastructure has been added in this commit.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Replace pwm_fan_cooling_states with pwm_fan_cooling_levels
- Update ctx->pwm_fan_state when correct data from device tree is available
- Using therma_cdev_update() when thermal is ready for controlling the fan
Changes for v3:
- Rename patch heading
- pwm_fan_of_get_cooling_data() now returns -EINVAL when no "cooling-levels"
  property defined
- register of cooling device only when proper cooling data is present
Changes for v4:
- None
Changes for v5:
- Check for IS_ENABLED(CONFIG_THERMAL) has been added to prevent from
  executing thermal_* specific functions
---
 drivers/hwmon/pwm-fan.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 82 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index e6ed353..2c1a8f0 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -24,6 +24,7 @@
 #include <linux/platform_device.h>
 #include <linux/pwm.h>
 #include <linux/sysfs.h>
+#include <linux/thermal.h>
 
 #define MAX_PWM 255
 
@@ -68,6 +69,17 @@ exit_set_pwm_err:
 	return ret;
 }
 
+static void pwm_fan_update_state(struct pwm_fan_ctx *ctx, unsigned long pwm)
+{
+	int i;
+
+	for (i = 0; i < ctx->pwm_fan_max_state; ++i)
+		if (pwm < ctx->pwm_fan_cooling_levels[i + 1])
+			break;
+
+	ctx->pwm_fan_state = i;
+}
+
 static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 		       const char *buf, size_t count)
 {
@@ -82,6 +94,7 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 	if (ret)
 		return ret;
 
+	pwm_fan_update_state(ctx, pwm);
 	return count;
 }
 
@@ -103,6 +116,59 @@ static struct attribute *pwm_fan_attrs[] = {
 
 ATTRIBUTE_GROUPS(pwm_fan);
 
+/* thermal cooling device callbacks */
+static int pwm_fan_get_max_state(struct thermal_cooling_device *cdev,
+				 unsigned long *state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+
+	*state = ctx->pwm_fan_max_state;
+
+	return 0;
+}
+
+static int pwm_fan_get_cur_state(struct thermal_cooling_device *cdev,
+				 unsigned long *state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+
+	if (!ctx)
+		return -EINVAL;
+
+	*state = ctx->pwm_fan_state;
+
+	return 0;
+}
+
+static int
+pwm_fan_set_cur_state(struct thermal_cooling_device *cdev, unsigned long state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+	int ret;
+
+	if (!ctx || (state > ctx->pwm_fan_max_state))
+		return -EINVAL;
+
+	if (state == ctx->pwm_fan_state)
+		return 0;
+
+	ret = __set_pwm(ctx, ctx->pwm_fan_cooling_levels[state]);
+	if (ret) {
+		dev_err(&cdev->device, "Cannot set pwm!\n");
+		return ret;
+	}
+
+	ctx->pwm_fan_state = state;
+
+	return ret;
+}
+
+static const struct thermal_cooling_device_ops pwm_fan_cooling_ops = {
+	.get_max_state = pwm_fan_get_max_state,
+	.get_cur_state = pwm_fan_get_cur_state,
+	.set_cur_state = pwm_fan_set_cur_state,
+};
+
 int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
 {
 	struct device_node *np = dev->of_node;
@@ -145,8 +211,9 @@ int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
 
 static int pwm_fan_probe(struct platform_device *pdev)
 {
-	struct device *hwmon;
+	struct thermal_cooling_device *cdev;
 	struct pwm_fan_ctx *ctx;
+	struct device *hwmon;
 	int duty_cycle;
 	int ret;
 
@@ -193,6 +260,20 @@ static int pwm_fan_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
+	ctx->pwm_fan_state = ctx->pwm_fan_max_state;
+	if (IS_ENABLED(CONFIG_THERMAL)) {
+		cdev = thermal_of_cooling_device_register(pdev->dev.of_node,
+							  "pwm-fan", ctx,
+							  &pwm_fan_cooling_ops);
+		if (IS_ERR(cdev)) {
+			dev_err(&pdev->dev,
+				"Failed to register pwm-fan as cooling device");
+			pwm_disable(ctx->pwm);
+			return PTR_ERR(cdev);
+		}
+		thermal_cdev_update(cdev);
+	}
+
 	return 0;
 }
 
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [lm-sensors] [PATCH v5 6/6] hwmon: pwm-fan: Code for using PWM FAN as a cooling device
@ 2015-02-25 15:34     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-25 15:34 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

The PWM FAN device can now be used as a thermal cooling device. Necessary
infrastructure has been added in this commit.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Replace pwm_fan_cooling_states with pwm_fan_cooling_levels
- Update ctx->pwm_fan_state when correct data from device tree is available
- Using therma_cdev_update() when thermal is ready for controlling the fan
Changes for v3:
- Rename patch heading
- pwm_fan_of_get_cooling_data() now returns -EINVAL when no "cooling-levels"
  property defined
- register of cooling device only when proper cooling data is present
Changes for v4:
- None
Changes for v5:
- Check for IS_ENABLED(CONFIG_THERMAL) has been added to prevent from
  executing thermal_* specific functions
---
 drivers/hwmon/pwm-fan.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 82 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index e6ed353..2c1a8f0 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -24,6 +24,7 @@
 #include <linux/platform_device.h>
 #include <linux/pwm.h>
 #include <linux/sysfs.h>
+#include <linux/thermal.h>
 
 #define MAX_PWM 255
 
@@ -68,6 +69,17 @@ exit_set_pwm_err:
 	return ret;
 }
 
+static void pwm_fan_update_state(struct pwm_fan_ctx *ctx, unsigned long pwm)
+{
+	int i;
+
+	for (i = 0; i < ctx->pwm_fan_max_state; ++i)
+		if (pwm < ctx->pwm_fan_cooling_levels[i + 1])
+			break;
+
+	ctx->pwm_fan_state = i;
+}
+
 static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 		       const char *buf, size_t count)
 {
@@ -82,6 +94,7 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 	if (ret)
 		return ret;
 
+	pwm_fan_update_state(ctx, pwm);
 	return count;
 }
 
@@ -103,6 +116,59 @@ static struct attribute *pwm_fan_attrs[] = {
 
 ATTRIBUTE_GROUPS(pwm_fan);
 
+/* thermal cooling device callbacks */
+static int pwm_fan_get_max_state(struct thermal_cooling_device *cdev,
+				 unsigned long *state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+
+	*state = ctx->pwm_fan_max_state;
+
+	return 0;
+}
+
+static int pwm_fan_get_cur_state(struct thermal_cooling_device *cdev,
+				 unsigned long *state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+
+	if (!ctx)
+		return -EINVAL;
+
+	*state = ctx->pwm_fan_state;
+
+	return 0;
+}
+
+static int
+pwm_fan_set_cur_state(struct thermal_cooling_device *cdev, unsigned long state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+	int ret;
+
+	if (!ctx || (state > ctx->pwm_fan_max_state))
+		return -EINVAL;
+
+	if (state = ctx->pwm_fan_state)
+		return 0;
+
+	ret = __set_pwm(ctx, ctx->pwm_fan_cooling_levels[state]);
+	if (ret) {
+		dev_err(&cdev->device, "Cannot set pwm!\n");
+		return ret;
+	}
+
+	ctx->pwm_fan_state = state;
+
+	return ret;
+}
+
+static const struct thermal_cooling_device_ops pwm_fan_cooling_ops = {
+	.get_max_state = pwm_fan_get_max_state,
+	.get_cur_state = pwm_fan_get_cur_state,
+	.set_cur_state = pwm_fan_set_cur_state,
+};
+
 int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
 {
 	struct device_node *np = dev->of_node;
@@ -145,8 +211,9 @@ int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
 
 static int pwm_fan_probe(struct platform_device *pdev)
 {
-	struct device *hwmon;
+	struct thermal_cooling_device *cdev;
 	struct pwm_fan_ctx *ctx;
+	struct device *hwmon;
 	int duty_cycle;
 	int ret;
 
@@ -193,6 +260,20 @@ static int pwm_fan_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
+	ctx->pwm_fan_state = ctx->pwm_fan_max_state;
+	if (IS_ENABLED(CONFIG_THERMAL)) {
+		cdev = thermal_of_cooling_device_register(pdev->dev.of_node,
+							  "pwm-fan", ctx,
+							  &pwm_fan_cooling_ops);
+		if (IS_ERR(cdev)) {
+			dev_err(&pdev->dev,
+				"Failed to register pwm-fan as cooling device");
+			pwm_disable(ctx->pwm);
+			return PTR_ERR(cdev);
+		}
+		thermal_cdev_update(cdev);
+	}
+
 	return 0;
 }
 
-- 
2.0.0.rc2


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* Re: [PATCH v5 0/6] hwmon: thermal: Odroid U3: Provide support for Odroid U3 fan
  2015-02-25 15:34   ` Lukasz Majewski
  (?)
@ 2015-02-25 17:18     ` Guenter Roeck
  -1 siblings, 0 replies; 329+ messages in thread
From: Guenter Roeck @ 2015-02-25 17:18 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Eduardo Valentin, Kamil Debski, Jean Delvare, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

On Wed, Feb 25, 2015 at 04:34:16PM +0100, Lukasz Majewski wrote:
> Presented patches add support for Odroid's U3 optional CPU FAN, which uses PWM
> subsystem for low level control.
> 
> After successful probe it registers itself as a cooling device for thermal
> subsystem.
> 
> This driver also supports devices without DTS specified.
> 
> To provide correct functionality, new properties to device tree description for
> Exynos4412 and in particular Odroid U3 have been added.
> 
> Those patches were tested at Exynos4412 - Odroid U3 board.
> 
> Patches were applied on:
> linux-soc-thermal/fixes branch (Linux v4.0-rc1)
> SHA1: b71d399c7f2fe06b60b96155ec0b9ae167334e4a
> 
> Kamil Debski (1):
>   ARM: dts: Add pwm-fan node to the Odroid-U3 board
> 
> Lukasz Majewski (5):
>   Documentation: dts: Documentation entry to explain how to use PWM FAN
>     as a cooling device
>   ARM: dts: Add properties to use pwm-fan device as a cooling device in
>     Odroid U3
>   hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty
>     cycle
>   hwmon: pwm-fan: Read PWM FAN configuration from device tree
>   hwmon: pwm-fan: Code for using PWM FAN as a cooling device
> 
>  .../devicetree/bindings/hwmon/pwm-fan.txt          |  25 +++-
>  arch/arm/boot/dts/exynos4.dtsi                     |   2 +-
>  arch/arm/boot/dts/exynos4412-odroidu3.dts          |  43 ++++++
>  drivers/hwmon/pwm-fan.c                            | 166 +++++++++++++++++++--
>  4 files changed, 220 insertions(+), 16 deletions(-)
> 
For the series:

Acked-by: Guenter Roeck <linux@roeck-us.net>

Should I take it through hwmon ? Might make sense given the majority
of the changes is in hwmon code.

Thanks,
Guenter

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v5 0/6] hwmon: thermal: Odroid U3: Provide support for Odroid U3 fan
@ 2015-02-25 17:18     ` Guenter Roeck
  0 siblings, 0 replies; 329+ messages in thread
From: Guenter Roeck @ 2015-02-25 17:18 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Eduardo Valentin, Kamil Debski, Jean Delvare, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

On Wed, Feb 25, 2015 at 04:34:16PM +0100, Lukasz Majewski wrote:
> Presented patches add support for Odroid's U3 optional CPU FAN, which uses PWM
> subsystem for low level control.
> 
> After successful probe it registers itself as a cooling device for thermal
> subsystem.
> 
> This driver also supports devices without DTS specified.
> 
> To provide correct functionality, new properties to device tree description for
> Exynos4412 and in particular Odroid U3 have been added.
> 
> Those patches were tested at Exynos4412 - Odroid U3 board.
> 
> Patches were applied on:
> linux-soc-thermal/fixes branch (Linux v4.0-rc1)
> SHA1: b71d399c7f2fe06b60b96155ec0b9ae167334e4a
> 
> Kamil Debski (1):
>   ARM: dts: Add pwm-fan node to the Odroid-U3 board
> 
> Lukasz Majewski (5):
>   Documentation: dts: Documentation entry to explain how to use PWM FAN
>     as a cooling device
>   ARM: dts: Add properties to use pwm-fan device as a cooling device in
>     Odroid U3
>   hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty
>     cycle
>   hwmon: pwm-fan: Read PWM FAN configuration from device tree
>   hwmon: pwm-fan: Code for using PWM FAN as a cooling device
> 
>  .../devicetree/bindings/hwmon/pwm-fan.txt          |  25 +++-
>  arch/arm/boot/dts/exynos4.dtsi                     |   2 +-
>  arch/arm/boot/dts/exynos4412-odroidu3.dts          |  43 ++++++
>  drivers/hwmon/pwm-fan.c                            | 166 +++++++++++++++++++--
>  4 files changed, 220 insertions(+), 16 deletions(-)
> 
For the series:

Acked-by: Guenter Roeck <linux@roeck-us.net>

Should I take it through hwmon ? Might make sense given the majority
of the changes is in hwmon code.

Thanks,
Guenter

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [lm-sensors] [PATCH v5 0/6] hwmon: thermal: Odroid U3: Provide support for Odroid U3 fan
@ 2015-02-25 17:18     ` Guenter Roeck
  0 siblings, 0 replies; 329+ messages in thread
From: Guenter Roeck @ 2015-02-25 17:18 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Eduardo Valentin, Kamil Debski, Jean Delvare, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

On Wed, Feb 25, 2015 at 04:34:16PM +0100, Lukasz Majewski wrote:
> Presented patches add support for Odroid's U3 optional CPU FAN, which uses PWM
> subsystem for low level control.
> 
> After successful probe it registers itself as a cooling device for thermal
> subsystem.
> 
> This driver also supports devices without DTS specified.
> 
> To provide correct functionality, new properties to device tree description for
> Exynos4412 and in particular Odroid U3 have been added.
> 
> Those patches were tested at Exynos4412 - Odroid U3 board.
> 
> Patches were applied on:
> linux-soc-thermal/fixes branch (Linux v4.0-rc1)
> SHA1: b71d399c7f2fe06b60b96155ec0b9ae167334e4a
> 
> Kamil Debski (1):
>   ARM: dts: Add pwm-fan node to the Odroid-U3 board
> 
> Lukasz Majewski (5):
>   Documentation: dts: Documentation entry to explain how to use PWM FAN
>     as a cooling device
>   ARM: dts: Add properties to use pwm-fan device as a cooling device in
>     Odroid U3
>   hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty
>     cycle
>   hwmon: pwm-fan: Read PWM FAN configuration from device tree
>   hwmon: pwm-fan: Code for using PWM FAN as a cooling device
> 
>  .../devicetree/bindings/hwmon/pwm-fan.txt          |  25 +++-
>  arch/arm/boot/dts/exynos4.dtsi                     |   2 +-
>  arch/arm/boot/dts/exynos4412-odroidu3.dts          |  43 ++++++
>  drivers/hwmon/pwm-fan.c                            | 166 +++++++++++++++++++--
>  4 files changed, 220 insertions(+), 16 deletions(-)
> 
For the series:

Acked-by: Guenter Roeck <linux@roeck-us.net>

Should I take it through hwmon ? Might make sense given the majority
of the changes is in hwmon code.

Thanks,
Guenter

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v5 6/6] hwmon: pwm-fan: Code for using PWM FAN as a cooling device
  2015-02-25 15:34     ` Lukasz Majewski
  (?)
@ 2015-02-25 18:24       ` Eduardo Valentin
  -1 siblings, 0 replies; 329+ messages in thread
From: Eduardo Valentin @ 2015-02-25 18:24 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

[-- Attachment #1: Type: text/plain, Size: 5088 bytes --]

Hey Lukasz,

On Wed, Feb 25, 2015 at 04:34:22PM +0100, Lukasz Majewski wrote:
> The PWM FAN device can now be used as a thermal cooling device. Necessary
> infrastructure has been added in this commit.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
> Changes for v2:
> - Replace pwm_fan_cooling_states with pwm_fan_cooling_levels
> - Update ctx->pwm_fan_state when correct data from device tree is available
> - Using therma_cdev_update() when thermal is ready for controlling the fan
> Changes for v3:
> - Rename patch heading
> - pwm_fan_of_get_cooling_data() now returns -EINVAL when no "cooling-levels"
>   property defined
> - register of cooling device only when proper cooling data is present
> Changes for v4:
> - None
> Changes for v5:
> - Check for IS_ENABLED(CONFIG_THERMAL) has been added to prevent from
>   executing thermal_* specific functions
> ---
>  drivers/hwmon/pwm-fan.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 82 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
> index e6ed353..2c1a8f0 100644
> --- a/drivers/hwmon/pwm-fan.c
> +++ b/drivers/hwmon/pwm-fan.c
> @@ -24,6 +24,7 @@
>  #include <linux/platform_device.h>
>  #include <linux/pwm.h>
>  #include <linux/sysfs.h>
> +#include <linux/thermal.h>
>  
>  #define MAX_PWM 255
>  
> @@ -68,6 +69,17 @@ exit_set_pwm_err:
>  	return ret;
>  }
>  
> +static void pwm_fan_update_state(struct pwm_fan_ctx *ctx, unsigned long pwm)
> +{
> +	int i;
> +
> +	for (i = 0; i < ctx->pwm_fan_max_state; ++i)
> +		if (pwm < ctx->pwm_fan_cooling_levels[i + 1])
> +			break;
> +
> +	ctx->pwm_fan_state = i;
> +}
> +
>  static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
>  		       const char *buf, size_t count)
>  {
> @@ -82,6 +94,7 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
>  	if (ret)
>  		return ret;
>  
> +	pwm_fan_update_state(ctx, pwm);
>  	return count;
>  }
>  
> @@ -103,6 +116,59 @@ static struct attribute *pwm_fan_attrs[] = {
>  
>  ATTRIBUTE_GROUPS(pwm_fan);
>  
> +/* thermal cooling device callbacks */
> +static int pwm_fan_get_max_state(struct thermal_cooling_device *cdev,
> +				 unsigned long *state)
> +{
> +	struct pwm_fan_ctx *ctx = cdev->devdata;
> +

Why this call back is the only one you didn't add a check for ctx ==
NULL?

> +	*state = ctx->pwm_fan_max_state;
> +
> +	return 0;
> +}
> +
> +static int pwm_fan_get_cur_state(struct thermal_cooling_device *cdev,
> +				 unsigned long *state)
> +{
> +	struct pwm_fan_ctx *ctx = cdev->devdata;
> +
> +	if (!ctx)
> +		return -EINVAL;
> +
> +	*state = ctx->pwm_fan_state;
> +
> +	return 0;
> +}
> +
> +static int
> +pwm_fan_set_cur_state(struct thermal_cooling_device *cdev, unsigned long state)
> +{
> +	struct pwm_fan_ctx *ctx = cdev->devdata;
> +	int ret;
> +
> +	if (!ctx || (state > ctx->pwm_fan_max_state))
> +		return -EINVAL;
> +
> +	if (state == ctx->pwm_fan_state)
> +		return 0;
> +
> +	ret = __set_pwm(ctx, ctx->pwm_fan_cooling_levels[state]);
> +	if (ret) {
> +		dev_err(&cdev->device, "Cannot set pwm!\n");
> +		return ret;
> +	}
> +
> +	ctx->pwm_fan_state = state;
> +
> +	return ret;
> +}
> +
> +static const struct thermal_cooling_device_ops pwm_fan_cooling_ops = {
> +	.get_max_state = pwm_fan_get_max_state,
> +	.get_cur_state = pwm_fan_get_cur_state,
> +	.set_cur_state = pwm_fan_set_cur_state,
> +};
> +
>  int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
>  {
>  	struct device_node *np = dev->of_node;
> @@ -145,8 +211,9 @@ int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
>  
>  static int pwm_fan_probe(struct platform_device *pdev)
>  {
> -	struct device *hwmon;
> +	struct thermal_cooling_device *cdev;
>  	struct pwm_fan_ctx *ctx;
> +	struct device *hwmon;
>  	int duty_cycle;
>  	int ret;
>  
> @@ -193,6 +260,20 @@ static int pwm_fan_probe(struct platform_device *pdev)
>  	if (ret)
>  		return ret;
>  
> +	ctx->pwm_fan_state = ctx->pwm_fan_max_state;
> +	if (IS_ENABLED(CONFIG_THERMAL)) {
> +		cdev = thermal_of_cooling_device_register(pdev->dev.of_node,
> +							  "pwm-fan", ctx,
> +							  &pwm_fan_cooling_ops);


I know this is a PITA, but thermal subsystem still does not use devm
based helpers. That means, you need to be old school and unregister the
device yourself.

Please add the cdev to ctx structure:
+		ctx->cdev = cdev;

and add a call for:
	thermal_cooling_device_unregister(ctx->cdev);

in static int pwm_fan_remove(struct platform_device *pdev)


despite the above two minor issues, you may add my
Acked-by: Eduardo Valentin <edubezval@gmail.com>

> +		if (IS_ERR(cdev)) {
> +			dev_err(&pdev->dev,
> +				"Failed to register pwm-fan as cooling device");
> +			pwm_disable(ctx->pwm);
> +			return PTR_ERR(cdev);
> +		}
> +		thermal_cdev_update(cdev);
> +	}
> +
>  	return 0;
>  }
>  
> -- 
> 2.0.0.rc2
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v5 6/6] hwmon: pwm-fan: Code for using PWM FAN as a cooling device
@ 2015-02-25 18:24       ` Eduardo Valentin
  0 siblings, 0 replies; 329+ messages in thread
From: Eduardo Valentin @ 2015-02-25 18:24 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

[-- Attachment #1: Type: text/plain, Size: 5088 bytes --]

Hey Lukasz,

On Wed, Feb 25, 2015 at 04:34:22PM +0100, Lukasz Majewski wrote:
> The PWM FAN device can now be used as a thermal cooling device. Necessary
> infrastructure has been added in this commit.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
> Changes for v2:
> - Replace pwm_fan_cooling_states with pwm_fan_cooling_levels
> - Update ctx->pwm_fan_state when correct data from device tree is available
> - Using therma_cdev_update() when thermal is ready for controlling the fan
> Changes for v3:
> - Rename patch heading
> - pwm_fan_of_get_cooling_data() now returns -EINVAL when no "cooling-levels"
>   property defined
> - register of cooling device only when proper cooling data is present
> Changes for v4:
> - None
> Changes for v5:
> - Check for IS_ENABLED(CONFIG_THERMAL) has been added to prevent from
>   executing thermal_* specific functions
> ---
>  drivers/hwmon/pwm-fan.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 82 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
> index e6ed353..2c1a8f0 100644
> --- a/drivers/hwmon/pwm-fan.c
> +++ b/drivers/hwmon/pwm-fan.c
> @@ -24,6 +24,7 @@
>  #include <linux/platform_device.h>
>  #include <linux/pwm.h>
>  #include <linux/sysfs.h>
> +#include <linux/thermal.h>
>  
>  #define MAX_PWM 255
>  
> @@ -68,6 +69,17 @@ exit_set_pwm_err:
>  	return ret;
>  }
>  
> +static void pwm_fan_update_state(struct pwm_fan_ctx *ctx, unsigned long pwm)
> +{
> +	int i;
> +
> +	for (i = 0; i < ctx->pwm_fan_max_state; ++i)
> +		if (pwm < ctx->pwm_fan_cooling_levels[i + 1])
> +			break;
> +
> +	ctx->pwm_fan_state = i;
> +}
> +
>  static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
>  		       const char *buf, size_t count)
>  {
> @@ -82,6 +94,7 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
>  	if (ret)
>  		return ret;
>  
> +	pwm_fan_update_state(ctx, pwm);
>  	return count;
>  }
>  
> @@ -103,6 +116,59 @@ static struct attribute *pwm_fan_attrs[] = {
>  
>  ATTRIBUTE_GROUPS(pwm_fan);
>  
> +/* thermal cooling device callbacks */
> +static int pwm_fan_get_max_state(struct thermal_cooling_device *cdev,
> +				 unsigned long *state)
> +{
> +	struct pwm_fan_ctx *ctx = cdev->devdata;
> +

Why this call back is the only one you didn't add a check for ctx ==
NULL?

> +	*state = ctx->pwm_fan_max_state;
> +
> +	return 0;
> +}
> +
> +static int pwm_fan_get_cur_state(struct thermal_cooling_device *cdev,
> +				 unsigned long *state)
> +{
> +	struct pwm_fan_ctx *ctx = cdev->devdata;
> +
> +	if (!ctx)
> +		return -EINVAL;
> +
> +	*state = ctx->pwm_fan_state;
> +
> +	return 0;
> +}
> +
> +static int
> +pwm_fan_set_cur_state(struct thermal_cooling_device *cdev, unsigned long state)
> +{
> +	struct pwm_fan_ctx *ctx = cdev->devdata;
> +	int ret;
> +
> +	if (!ctx || (state > ctx->pwm_fan_max_state))
> +		return -EINVAL;
> +
> +	if (state == ctx->pwm_fan_state)
> +		return 0;
> +
> +	ret = __set_pwm(ctx, ctx->pwm_fan_cooling_levels[state]);
> +	if (ret) {
> +		dev_err(&cdev->device, "Cannot set pwm!\n");
> +		return ret;
> +	}
> +
> +	ctx->pwm_fan_state = state;
> +
> +	return ret;
> +}
> +
> +static const struct thermal_cooling_device_ops pwm_fan_cooling_ops = {
> +	.get_max_state = pwm_fan_get_max_state,
> +	.get_cur_state = pwm_fan_get_cur_state,
> +	.set_cur_state = pwm_fan_set_cur_state,
> +};
> +
>  int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
>  {
>  	struct device_node *np = dev->of_node;
> @@ -145,8 +211,9 @@ int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
>  
>  static int pwm_fan_probe(struct platform_device *pdev)
>  {
> -	struct device *hwmon;
> +	struct thermal_cooling_device *cdev;
>  	struct pwm_fan_ctx *ctx;
> +	struct device *hwmon;
>  	int duty_cycle;
>  	int ret;
>  
> @@ -193,6 +260,20 @@ static int pwm_fan_probe(struct platform_device *pdev)
>  	if (ret)
>  		return ret;
>  
> +	ctx->pwm_fan_state = ctx->pwm_fan_max_state;
> +	if (IS_ENABLED(CONFIG_THERMAL)) {
> +		cdev = thermal_of_cooling_device_register(pdev->dev.of_node,
> +							  "pwm-fan", ctx,
> +							  &pwm_fan_cooling_ops);


I know this is a PITA, but thermal subsystem still does not use devm
based helpers. That means, you need to be old school and unregister the
device yourself.

Please add the cdev to ctx structure:
+		ctx->cdev = cdev;

and add a call for:
	thermal_cooling_device_unregister(ctx->cdev);

in static int pwm_fan_remove(struct platform_device *pdev)


despite the above two minor issues, you may add my
Acked-by: Eduardo Valentin <edubezval@gmail.com>

> +		if (IS_ERR(cdev)) {
> +			dev_err(&pdev->dev,
> +				"Failed to register pwm-fan as cooling device");
> +			pwm_disable(ctx->pwm);
> +			return PTR_ERR(cdev);
> +		}
> +		thermal_cdev_update(cdev);
> +	}
> +
>  	return 0;
>  }
>  
> -- 
> 2.0.0.rc2
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [lm-sensors] [PATCH v5 6/6] hwmon: pwm-fan: Code for using PWM FAN as a cooling device
@ 2015-02-25 18:24       ` Eduardo Valentin
  0 siblings, 0 replies; 329+ messages in thread
From: Eduardo Valentin @ 2015-02-25 18:24 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan


[-- Attachment #1.1: Type: text/plain, Size: 5088 bytes --]

Hey Lukasz,

On Wed, Feb 25, 2015 at 04:34:22PM +0100, Lukasz Majewski wrote:
> The PWM FAN device can now be used as a thermal cooling device. Necessary
> infrastructure has been added in this commit.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
> Changes for v2:
> - Replace pwm_fan_cooling_states with pwm_fan_cooling_levels
> - Update ctx->pwm_fan_state when correct data from device tree is available
> - Using therma_cdev_update() when thermal is ready for controlling the fan
> Changes for v3:
> - Rename patch heading
> - pwm_fan_of_get_cooling_data() now returns -EINVAL when no "cooling-levels"
>   property defined
> - register of cooling device only when proper cooling data is present
> Changes for v4:
> - None
> Changes for v5:
> - Check for IS_ENABLED(CONFIG_THERMAL) has been added to prevent from
>   executing thermal_* specific functions
> ---
>  drivers/hwmon/pwm-fan.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 82 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
> index e6ed353..2c1a8f0 100644
> --- a/drivers/hwmon/pwm-fan.c
> +++ b/drivers/hwmon/pwm-fan.c
> @@ -24,6 +24,7 @@
>  #include <linux/platform_device.h>
>  #include <linux/pwm.h>
>  #include <linux/sysfs.h>
> +#include <linux/thermal.h>
>  
>  #define MAX_PWM 255
>  
> @@ -68,6 +69,17 @@ exit_set_pwm_err:
>  	return ret;
>  }
>  
> +static void pwm_fan_update_state(struct pwm_fan_ctx *ctx, unsigned long pwm)
> +{
> +	int i;
> +
> +	for (i = 0; i < ctx->pwm_fan_max_state; ++i)
> +		if (pwm < ctx->pwm_fan_cooling_levels[i + 1])
> +			break;
> +
> +	ctx->pwm_fan_state = i;
> +}
> +
>  static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
>  		       const char *buf, size_t count)
>  {
> @@ -82,6 +94,7 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
>  	if (ret)
>  		return ret;
>  
> +	pwm_fan_update_state(ctx, pwm);
>  	return count;
>  }
>  
> @@ -103,6 +116,59 @@ static struct attribute *pwm_fan_attrs[] = {
>  
>  ATTRIBUTE_GROUPS(pwm_fan);
>  
> +/* thermal cooling device callbacks */
> +static int pwm_fan_get_max_state(struct thermal_cooling_device *cdev,
> +				 unsigned long *state)
> +{
> +	struct pwm_fan_ctx *ctx = cdev->devdata;
> +

Why this call back is the only one you didn't add a check for ctx ==
NULL?

> +	*state = ctx->pwm_fan_max_state;
> +
> +	return 0;
> +}
> +
> +static int pwm_fan_get_cur_state(struct thermal_cooling_device *cdev,
> +				 unsigned long *state)
> +{
> +	struct pwm_fan_ctx *ctx = cdev->devdata;
> +
> +	if (!ctx)
> +		return -EINVAL;
> +
> +	*state = ctx->pwm_fan_state;
> +
> +	return 0;
> +}
> +
> +static int
> +pwm_fan_set_cur_state(struct thermal_cooling_device *cdev, unsigned long state)
> +{
> +	struct pwm_fan_ctx *ctx = cdev->devdata;
> +	int ret;
> +
> +	if (!ctx || (state > ctx->pwm_fan_max_state))
> +		return -EINVAL;
> +
> +	if (state == ctx->pwm_fan_state)
> +		return 0;
> +
> +	ret = __set_pwm(ctx, ctx->pwm_fan_cooling_levels[state]);
> +	if (ret) {
> +		dev_err(&cdev->device, "Cannot set pwm!\n");
> +		return ret;
> +	}
> +
> +	ctx->pwm_fan_state = state;
> +
> +	return ret;
> +}
> +
> +static const struct thermal_cooling_device_ops pwm_fan_cooling_ops = {
> +	.get_max_state = pwm_fan_get_max_state,
> +	.get_cur_state = pwm_fan_get_cur_state,
> +	.set_cur_state = pwm_fan_set_cur_state,
> +};
> +
>  int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
>  {
>  	struct device_node *np = dev->of_node;
> @@ -145,8 +211,9 @@ int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
>  
>  static int pwm_fan_probe(struct platform_device *pdev)
>  {
> -	struct device *hwmon;
> +	struct thermal_cooling_device *cdev;
>  	struct pwm_fan_ctx *ctx;
> +	struct device *hwmon;
>  	int duty_cycle;
>  	int ret;
>  
> @@ -193,6 +260,20 @@ static int pwm_fan_probe(struct platform_device *pdev)
>  	if (ret)
>  		return ret;
>  
> +	ctx->pwm_fan_state = ctx->pwm_fan_max_state;
> +	if (IS_ENABLED(CONFIG_THERMAL)) {
> +		cdev = thermal_of_cooling_device_register(pdev->dev.of_node,
> +							  "pwm-fan", ctx,
> +							  &pwm_fan_cooling_ops);


I know this is a PITA, but thermal subsystem still does not use devm
based helpers. That means, you need to be old school and unregister the
device yourself.

Please add the cdev to ctx structure:
+		ctx->cdev = cdev;

and add a call for:
	thermal_cooling_device_unregister(ctx->cdev);

in static int pwm_fan_remove(struct platform_device *pdev)


despite the above two minor issues, you may add my
Acked-by: Eduardo Valentin <edubezval@gmail.com>

> +		if (IS_ERR(cdev)) {
> +			dev_err(&pdev->dev,
> +				"Failed to register pwm-fan as cooling device");
> +			pwm_disable(ctx->pwm);
> +			return PTR_ERR(cdev);
> +		}
> +		thermal_cdev_update(cdev);
> +	}
> +
>  	return 0;
>  }
>  
> -- 
> 2.0.0.rc2
> 

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

[-- Attachment #2: Type: text/plain, Size: 153 bytes --]

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v5 0/6] hwmon: thermal: Odroid U3: Provide support for Odroid U3 fan
  2015-02-25 17:18     ` Guenter Roeck
  (?)
@ 2015-02-25 18:29       ` Eduardo Valentin
  -1 siblings, 0 replies; 329+ messages in thread
From: Eduardo Valentin @ 2015-02-25 18:29 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Lukasz Majewski, Kamil Debski, Jean Delvare, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

[-- Attachment #1: Type: text/plain, Size: 2270 bytes --]

Guenter,

On Wed, Feb 25, 2015 at 09:18:20AM -0800, Guenter Roeck wrote:
> On Wed, Feb 25, 2015 at 04:34:16PM +0100, Lukasz Majewski wrote:
> > Presented patches add support for Odroid's U3 optional CPU FAN, which uses PWM
> > subsystem for low level control.
> > 
> > After successful probe it registers itself as a cooling device for thermal
> > subsystem.
> > 
> > This driver also supports devices without DTS specified.
> > 
> > To provide correct functionality, new properties to device tree description for
> > Exynos4412 and in particular Odroid U3 have been added.
> > 
> > Those patches were tested at Exynos4412 - Odroid U3 board.
> > 
> > Patches were applied on:
> > linux-soc-thermal/fixes branch (Linux v4.0-rc1)
> > SHA1: b71d399c7f2fe06b60b96155ec0b9ae167334e4a
> > 
> > Kamil Debski (1):
> >   ARM: dts: Add pwm-fan node to the Odroid-U3 board
> > 
> > Lukasz Majewski (5):
> >   Documentation: dts: Documentation entry to explain how to use PWM FAN
> >     as a cooling device
> >   ARM: dts: Add properties to use pwm-fan device as a cooling device in
> >     Odroid U3
> >   hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty
> >     cycle
> >   hwmon: pwm-fan: Read PWM FAN configuration from device tree
> >   hwmon: pwm-fan: Code for using PWM FAN as a cooling device
> > 
> >  .../devicetree/bindings/hwmon/pwm-fan.txt          |  25 +++-
> >  arch/arm/boot/dts/exynos4.dtsi                     |   2 +-
> >  arch/arm/boot/dts/exynos4412-odroidu3.dts          |  43 ++++++
> >  drivers/hwmon/pwm-fan.c                            | 166 +++++++++++++++++++--
> >  4 files changed, 220 insertions(+), 16 deletions(-)
> > 
> For the series:
> 
> Acked-by: Guenter Roeck <linux@roeck-us.net>
> 
> Should I take it through hwmon ? Might make sense given the majority
> of the changes is in hwmon code.

I believe the series should go via your tree, yes. I had only minor
comments in the code added for the cooling device code, as it lacks the
unregistration call in the .remove callback. 

Also, the DTS changes may generate conflicts with platform code. Lukasz
may probably ask  Kukjin Kim to add them via the samsung tree.

BR,

Eduardo Valentin

> 
> Thanks,
> Guenter

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v5 0/6] hwmon: thermal: Odroid U3: Provide support for Odroid U3 fan
@ 2015-02-25 18:29       ` Eduardo Valentin
  0 siblings, 0 replies; 329+ messages in thread
From: Eduardo Valentin @ 2015-02-25 18:29 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Lukasz Majewski, Kamil Debski, Jean Delvare, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

[-- Attachment #1: Type: text/plain, Size: 2270 bytes --]

Guenter,

On Wed, Feb 25, 2015 at 09:18:20AM -0800, Guenter Roeck wrote:
> On Wed, Feb 25, 2015 at 04:34:16PM +0100, Lukasz Majewski wrote:
> > Presented patches add support for Odroid's U3 optional CPU FAN, which uses PWM
> > subsystem for low level control.
> > 
> > After successful probe it registers itself as a cooling device for thermal
> > subsystem.
> > 
> > This driver also supports devices without DTS specified.
> > 
> > To provide correct functionality, new properties to device tree description for
> > Exynos4412 and in particular Odroid U3 have been added.
> > 
> > Those patches were tested at Exynos4412 - Odroid U3 board.
> > 
> > Patches were applied on:
> > linux-soc-thermal/fixes branch (Linux v4.0-rc1)
> > SHA1: b71d399c7f2fe06b60b96155ec0b9ae167334e4a
> > 
> > Kamil Debski (1):
> >   ARM: dts: Add pwm-fan node to the Odroid-U3 board
> > 
> > Lukasz Majewski (5):
> >   Documentation: dts: Documentation entry to explain how to use PWM FAN
> >     as a cooling device
> >   ARM: dts: Add properties to use pwm-fan device as a cooling device in
> >     Odroid U3
> >   hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty
> >     cycle
> >   hwmon: pwm-fan: Read PWM FAN configuration from device tree
> >   hwmon: pwm-fan: Code for using PWM FAN as a cooling device
> > 
> >  .../devicetree/bindings/hwmon/pwm-fan.txt          |  25 +++-
> >  arch/arm/boot/dts/exynos4.dtsi                     |   2 +-
> >  arch/arm/boot/dts/exynos4412-odroidu3.dts          |  43 ++++++
> >  drivers/hwmon/pwm-fan.c                            | 166 +++++++++++++++++++--
> >  4 files changed, 220 insertions(+), 16 deletions(-)
> > 
> For the series:
> 
> Acked-by: Guenter Roeck <linux@roeck-us.net>
> 
> Should I take it through hwmon ? Might make sense given the majority
> of the changes is in hwmon code.

I believe the series should go via your tree, yes. I had only minor
comments in the code added for the cooling device code, as it lacks the
unregistration call in the .remove callback. 

Also, the DTS changes may generate conflicts with platform code. Lukasz
may probably ask  Kukjin Kim to add them via the samsung tree.

BR,

Eduardo Valentin

> 
> Thanks,
> Guenter

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [lm-sensors] [PATCH v5 0/6] hwmon: thermal: Odroid U3: Provide support for Odroid U3 fan
@ 2015-02-25 18:29       ` Eduardo Valentin
  0 siblings, 0 replies; 329+ messages in thread
From: Eduardo Valentin @ 2015-02-25 18:29 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Lukasz Majewski, Kamil Debski, Jean Delvare, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan


[-- Attachment #1.1: Type: text/plain, Size: 2270 bytes --]

Guenter,

On Wed, Feb 25, 2015 at 09:18:20AM -0800, Guenter Roeck wrote:
> On Wed, Feb 25, 2015 at 04:34:16PM +0100, Lukasz Majewski wrote:
> > Presented patches add support for Odroid's U3 optional CPU FAN, which uses PWM
> > subsystem for low level control.
> > 
> > After successful probe it registers itself as a cooling device for thermal
> > subsystem.
> > 
> > This driver also supports devices without DTS specified.
> > 
> > To provide correct functionality, new properties to device tree description for
> > Exynos4412 and in particular Odroid U3 have been added.
> > 
> > Those patches were tested at Exynos4412 - Odroid U3 board.
> > 
> > Patches were applied on:
> > linux-soc-thermal/fixes branch (Linux v4.0-rc1)
> > SHA1: b71d399c7f2fe06b60b96155ec0b9ae167334e4a
> > 
> > Kamil Debski (1):
> >   ARM: dts: Add pwm-fan node to the Odroid-U3 board
> > 
> > Lukasz Majewski (5):
> >   Documentation: dts: Documentation entry to explain how to use PWM FAN
> >     as a cooling device
> >   ARM: dts: Add properties to use pwm-fan device as a cooling device in
> >     Odroid U3
> >   hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty
> >     cycle
> >   hwmon: pwm-fan: Read PWM FAN configuration from device tree
> >   hwmon: pwm-fan: Code for using PWM FAN as a cooling device
> > 
> >  .../devicetree/bindings/hwmon/pwm-fan.txt          |  25 +++-
> >  arch/arm/boot/dts/exynos4.dtsi                     |   2 +-
> >  arch/arm/boot/dts/exynos4412-odroidu3.dts          |  43 ++++++
> >  drivers/hwmon/pwm-fan.c                            | 166 +++++++++++++++++++--
> >  4 files changed, 220 insertions(+), 16 deletions(-)
> > 
> For the series:
> 
> Acked-by: Guenter Roeck <linux@roeck-us.net>
> 
> Should I take it through hwmon ? Might make sense given the majority
> of the changes is in hwmon code.

I believe the series should go via your tree, yes. I had only minor
comments in the code added for the cooling device code, as it lacks the
unregistration call in the .remove callback. 

Also, the DTS changes may generate conflicts with platform code. Lukasz
may probably ask  Kukjin Kim to add them via the samsung tree.

BR,

Eduardo Valentin

> 
> Thanks,
> Guenter

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

[-- Attachment #2: Type: text/plain, Size: 153 bytes --]

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v4 5/8] ARM: dts: Add properties to use pwm-fan device as a cooling device in Odroid U3
  2015-02-25 13:28         ` [PATCH v4 5/8] ARM: dts: Add properties to use pwm-fan device as a cooling device in Odroid U3 Lukasz Majewski
  (?)
@ 2015-02-25 18:30           ` Eduardo Valentin
  -1 siblings, 0 replies; 329+ messages in thread
From: Eduardo Valentin @ 2015-02-25 18:30 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

[-- Attachment #1: Type: text/plain, Size: 2778 bytes --]

On Wed, Feb 25, 2015 at 02:28:15PM +0100, Lukasz Majewski wrote:
> Hi Eduardo,
> 
> > On Wed, Feb 18, 2015 at 11:07:33AM +0100, Lukasz Majewski wrote:
> > > With those bindings it is possible to use pwm-fan device available
> > > in Odroid U3 as a cooling device.
> > > 
> > > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > > ---
> > > Changes for v2:
> > > - Rename cooling-pwm-values property to cooling-levels
> > > Changes for v3:
> > > - Change patch's topic to "ARM dts"
> > > - Reduce maximal cooling-level to 230 from 255
> > > Changes for v4:
> > > - None
> > > ---
> > >  arch/arm/boot/dts/exynos4412-odroidu3.dts | 33
> > > ++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1
> > > deletion(-)
> > > 
> > > diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts
> > > b/arch/arm/boot/dts/exynos4412-odroidu3.dts index 60bd1e4..3e5df3e
> > > 100644 --- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
> > > +++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
> > > @@ -32,11 +32,42 @@
> > >  		};
> > >  	};
> > >  
> > > -	pwm-fan {
> > > +	fan0: pwm-fan {
> > >  		compatible = "pwm-fan";
> > >  		pwms = <&pwm 0 10000 0>;
> > > +		cooling-min-state = <0>;
> > > +		cooling-max-state = <3>;
> > > +		#cooling-cells = <2>;
> > > +		cooling-levels = <0 102 170 230>;
> > >  		status = "okay";
> > >  	};
> > > +
> > > +	thermal-zones {
> > > +		cpu_thermal: cpu-thermal {
> > 
> > 
> > This thermal zone misses the mandatory properties as per 
> >  Documentation/devicetree/bindings/thermal/thermal.txt
> 
> Following mandatory properties:
> 		thermal-sensors = <&tmu 0>;
> 		polling-delay-passive = <0>;
> 		polling-delay = <0>;
> 		trips {
> 
> 		}
> 
> are defined in exynos4-cpu-thermal.dtsi included by this file.
> 
> In this patch only device dependent changes are stated.

OK. I missed that.



> 
> > 
> > > +			cooling-maps {
> > > +				map0 {
> > > +				     trip = <&cpu_alert1>;
> > > +				     cooling-device = <&cpu0 7 7>;
> > > +				};
> > > +				map1 {
> > > +				     trip = <&cpu_alert2>;
> > > +				     cooling-device = <&cpu0 13
> > > 13>;
> > > +				};
> > > +				map2 {
> > > +				     trip = <&cpu_alert0>;
> > > +				     cooling-device = <&fan0 0 1>;
> > > +				};
> > > +				map3 {
> > > +				     trip = <&cpu_alert1>;
> > > +				     cooling-device = <&fan0 1 2>;
> > > +				};
> > > +				map4 {
> > > +				     trip = <&cpu_alert2>;
> > > +				     cooling-device = <&fan0 2 3>;
> > > +				};
> > > +			};
> > > +		};
> > > +	};
> > >  };
> > >  
> > >  &pwm {
> > > -- 
> > > 2.0.0.rc2
> > > 
> 
> 
> 
> -- 
> Best regards,
> 
> Lukasz Majewski
> 
> Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v4 5/8] ARM: dts: Add properties to use pwm-fan device as a cooling device in Odroid U3
@ 2015-02-25 18:30           ` Eduardo Valentin
  0 siblings, 0 replies; 329+ messages in thread
From: Eduardo Valentin @ 2015-02-25 18:30 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

[-- Attachment #1: Type: text/plain, Size: 2778 bytes --]

On Wed, Feb 25, 2015 at 02:28:15PM +0100, Lukasz Majewski wrote:
> Hi Eduardo,
> 
> > On Wed, Feb 18, 2015 at 11:07:33AM +0100, Lukasz Majewski wrote:
> > > With those bindings it is possible to use pwm-fan device available
> > > in Odroid U3 as a cooling device.
> > > 
> > > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > > ---
> > > Changes for v2:
> > > - Rename cooling-pwm-values property to cooling-levels
> > > Changes for v3:
> > > - Change patch's topic to "ARM dts"
> > > - Reduce maximal cooling-level to 230 from 255
> > > Changes for v4:
> > > - None
> > > ---
> > >  arch/arm/boot/dts/exynos4412-odroidu3.dts | 33
> > > ++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1
> > > deletion(-)
> > > 
> > > diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts
> > > b/arch/arm/boot/dts/exynos4412-odroidu3.dts index 60bd1e4..3e5df3e
> > > 100644 --- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
> > > +++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
> > > @@ -32,11 +32,42 @@
> > >  		};
> > >  	};
> > >  
> > > -	pwm-fan {
> > > +	fan0: pwm-fan {
> > >  		compatible = "pwm-fan";
> > >  		pwms = <&pwm 0 10000 0>;
> > > +		cooling-min-state = <0>;
> > > +		cooling-max-state = <3>;
> > > +		#cooling-cells = <2>;
> > > +		cooling-levels = <0 102 170 230>;
> > >  		status = "okay";
> > >  	};
> > > +
> > > +	thermal-zones {
> > > +		cpu_thermal: cpu-thermal {
> > 
> > 
> > This thermal zone misses the mandatory properties as per 
> >  Documentation/devicetree/bindings/thermal/thermal.txt
> 
> Following mandatory properties:
> 		thermal-sensors = <&tmu 0>;
> 		polling-delay-passive = <0>;
> 		polling-delay = <0>;
> 		trips {
> 
> 		}
> 
> are defined in exynos4-cpu-thermal.dtsi included by this file.
> 
> In this patch only device dependent changes are stated.

OK. I missed that.



> 
> > 
> > > +			cooling-maps {
> > > +				map0 {
> > > +				     trip = <&cpu_alert1>;
> > > +				     cooling-device = <&cpu0 7 7>;
> > > +				};
> > > +				map1 {
> > > +				     trip = <&cpu_alert2>;
> > > +				     cooling-device = <&cpu0 13
> > > 13>;
> > > +				};
> > > +				map2 {
> > > +				     trip = <&cpu_alert0>;
> > > +				     cooling-device = <&fan0 0 1>;
> > > +				};
> > > +				map3 {
> > > +				     trip = <&cpu_alert1>;
> > > +				     cooling-device = <&fan0 1 2>;
> > > +				};
> > > +				map4 {
> > > +				     trip = <&cpu_alert2>;
> > > +				     cooling-device = <&fan0 2 3>;
> > > +				};
> > > +			};
> > > +		};
> > > +	};
> > >  };
> > >  
> > >  &pwm {
> > > -- 
> > > 2.0.0.rc2
> > > 
> 
> 
> 
> -- 
> Best regards,
> 
> Lukasz Majewski
> 
> Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [lm-sensors] [PATCH v4 5/8] ARM: dts: Add properties to use pwm-fan device as a cooling device i
@ 2015-02-25 18:30           ` Eduardo Valentin
  0 siblings, 0 replies; 329+ messages in thread
From: Eduardo Valentin @ 2015-02-25 18:30 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan


[-- Attachment #1.1: Type: text/plain, Size: 2778 bytes --]

On Wed, Feb 25, 2015 at 02:28:15PM +0100, Lukasz Majewski wrote:
> Hi Eduardo,
> 
> > On Wed, Feb 18, 2015 at 11:07:33AM +0100, Lukasz Majewski wrote:
> > > With those bindings it is possible to use pwm-fan device available
> > > in Odroid U3 as a cooling device.
> > > 
> > > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > > ---
> > > Changes for v2:
> > > - Rename cooling-pwm-values property to cooling-levels
> > > Changes for v3:
> > > - Change patch's topic to "ARM dts"
> > > - Reduce maximal cooling-level to 230 from 255
> > > Changes for v4:
> > > - None
> > > ---
> > >  arch/arm/boot/dts/exynos4412-odroidu3.dts | 33
> > > ++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1
> > > deletion(-)
> > > 
> > > diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts
> > > b/arch/arm/boot/dts/exynos4412-odroidu3.dts index 60bd1e4..3e5df3e
> > > 100644 --- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
> > > +++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
> > > @@ -32,11 +32,42 @@
> > >  		};
> > >  	};
> > >  
> > > -	pwm-fan {
> > > +	fan0: pwm-fan {
> > >  		compatible = "pwm-fan";
> > >  		pwms = <&pwm 0 10000 0>;
> > > +		cooling-min-state = <0>;
> > > +		cooling-max-state = <3>;
> > > +		#cooling-cells = <2>;
> > > +		cooling-levels = <0 102 170 230>;
> > >  		status = "okay";
> > >  	};
> > > +
> > > +	thermal-zones {
> > > +		cpu_thermal: cpu-thermal {
> > 
> > 
> > This thermal zone misses the mandatory properties as per 
> >  Documentation/devicetree/bindings/thermal/thermal.txt
> 
> Following mandatory properties:
> 		thermal-sensors = <&tmu 0>;
> 		polling-delay-passive = <0>;
> 		polling-delay = <0>;
> 		trips {
> 
> 		}
> 
> are defined in exynos4-cpu-thermal.dtsi included by this file.
> 
> In this patch only device dependent changes are stated.

OK. I missed that.



> 
> > 
> > > +			cooling-maps {
> > > +				map0 {
> > > +				     trip = <&cpu_alert1>;
> > > +				     cooling-device = <&cpu0 7 7>;
> > > +				};
> > > +				map1 {
> > > +				     trip = <&cpu_alert2>;
> > > +				     cooling-device = <&cpu0 13
> > > 13>;
> > > +				};
> > > +				map2 {
> > > +				     trip = <&cpu_alert0>;
> > > +				     cooling-device = <&fan0 0 1>;
> > > +				};
> > > +				map3 {
> > > +				     trip = <&cpu_alert1>;
> > > +				     cooling-device = <&fan0 1 2>;
> > > +				};
> > > +				map4 {
> > > +				     trip = <&cpu_alert2>;
> > > +				     cooling-device = <&fan0 2 3>;
> > > +				};
> > > +			};
> > > +		};
> > > +	};
> > >  };
> > >  
> > >  &pwm {
> > > -- 
> > > 2.0.0.rc2
> > > 
> 
> 
> 
> -- 
> Best regards,
> 
> Lukasz Majewski
> 
> Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

[-- Attachment #2: Type: text/plain, Size: 153 bytes --]

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v5 0/6] hwmon: thermal: Odroid U3: Provide support for Odroid U3 fan
  2015-02-25 18:29       ` Eduardo Valentin
  (?)
@ 2015-02-25 18:42         ` Guenter Roeck
  -1 siblings, 0 replies; 329+ messages in thread
From: Guenter Roeck @ 2015-02-25 18:42 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Lukasz Majewski, Kamil Debski, Jean Delvare, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

On Wed, Feb 25, 2015 at 02:29:18PM -0400, Eduardo Valentin wrote:
> Guenter,
> 
> On Wed, Feb 25, 2015 at 09:18:20AM -0800, Guenter Roeck wrote:
> > On Wed, Feb 25, 2015 at 04:34:16PM +0100, Lukasz Majewski wrote:
> > > Presented patches add support for Odroid's U3 optional CPU FAN, which uses PWM
> > > subsystem for low level control.
> > > 
> > > After successful probe it registers itself as a cooling device for thermal
> > > subsystem.
> > > 
> > > This driver also supports devices without DTS specified.
> > > 
> > > To provide correct functionality, new properties to device tree description for
> > > Exynos4412 and in particular Odroid U3 have been added.
> > > 
> > > Those patches were tested at Exynos4412 - Odroid U3 board.
> > > 
> > > Patches were applied on:
> > > linux-soc-thermal/fixes branch (Linux v4.0-rc1)
> > > SHA1: b71d399c7f2fe06b60b96155ec0b9ae167334e4a
> > > 
> > > Kamil Debski (1):
> > >   ARM: dts: Add pwm-fan node to the Odroid-U3 board
> > > 
> > > Lukasz Majewski (5):
> > >   Documentation: dts: Documentation entry to explain how to use PWM FAN
> > >     as a cooling device
> > >   ARM: dts: Add properties to use pwm-fan device as a cooling device in
> > >     Odroid U3
> > >   hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty
> > >     cycle
> > >   hwmon: pwm-fan: Read PWM FAN configuration from device tree
> > >   hwmon: pwm-fan: Code for using PWM FAN as a cooling device
> > > 
> > >  .../devicetree/bindings/hwmon/pwm-fan.txt          |  25 +++-
> > >  arch/arm/boot/dts/exynos4.dtsi                     |   2 +-
> > >  arch/arm/boot/dts/exynos4412-odroidu3.dts          |  43 ++++++
> > >  drivers/hwmon/pwm-fan.c                            | 166 +++++++++++++++++++--
> > >  4 files changed, 220 insertions(+), 16 deletions(-)
> > > 
> > For the series:
> > 
> > Acked-by: Guenter Roeck <linux@roeck-us.net>
> > 
> > Should I take it through hwmon ? Might make sense given the majority
> > of the changes is in hwmon code.
> 
> I believe the series should go via your tree, yes. I had only minor
> comments in the code added for the cooling device code, as it lacks the
> unregistration call in the .remove callback. 
> 
> Also, the DTS changes may generate conflicts with platform code. Lukasz
> may probably ask  Kukjin Kim to add them via the samsung tree.
> 
Ok, I'll wait for the updated patch and then add the hwmon parts to hwmon-next.

Thanks,
Guenter

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v5 0/6] hwmon: thermal: Odroid U3: Provide support for Odroid U3 fan
@ 2015-02-25 18:42         ` Guenter Roeck
  0 siblings, 0 replies; 329+ messages in thread
From: Guenter Roeck @ 2015-02-25 18:42 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Lukasz Majewski, Kamil Debski, Jean Delvare, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

On Wed, Feb 25, 2015 at 02:29:18PM -0400, Eduardo Valentin wrote:
> Guenter,
> 
> On Wed, Feb 25, 2015 at 09:18:20AM -0800, Guenter Roeck wrote:
> > On Wed, Feb 25, 2015 at 04:34:16PM +0100, Lukasz Majewski wrote:
> > > Presented patches add support for Odroid's U3 optional CPU FAN, which uses PWM
> > > subsystem for low level control.
> > > 
> > > After successful probe it registers itself as a cooling device for thermal
> > > subsystem.
> > > 
> > > This driver also supports devices without DTS specified.
> > > 
> > > To provide correct functionality, new properties to device tree description for
> > > Exynos4412 and in particular Odroid U3 have been added.
> > > 
> > > Those patches were tested at Exynos4412 - Odroid U3 board.
> > > 
> > > Patches were applied on:
> > > linux-soc-thermal/fixes branch (Linux v4.0-rc1)
> > > SHA1: b71d399c7f2fe06b60b96155ec0b9ae167334e4a
> > > 
> > > Kamil Debski (1):
> > >   ARM: dts: Add pwm-fan node to the Odroid-U3 board
> > > 
> > > Lukasz Majewski (5):
> > >   Documentation: dts: Documentation entry to explain how to use PWM FAN
> > >     as a cooling device
> > >   ARM: dts: Add properties to use pwm-fan device as a cooling device in
> > >     Odroid U3
> > >   hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty
> > >     cycle
> > >   hwmon: pwm-fan: Read PWM FAN configuration from device tree
> > >   hwmon: pwm-fan: Code for using PWM FAN as a cooling device
> > > 
> > >  .../devicetree/bindings/hwmon/pwm-fan.txt          |  25 +++-
> > >  arch/arm/boot/dts/exynos4.dtsi                     |   2 +-
> > >  arch/arm/boot/dts/exynos4412-odroidu3.dts          |  43 ++++++
> > >  drivers/hwmon/pwm-fan.c                            | 166 +++++++++++++++++++--
> > >  4 files changed, 220 insertions(+), 16 deletions(-)
> > > 
> > For the series:
> > 
> > Acked-by: Guenter Roeck <linux@roeck-us.net>
> > 
> > Should I take it through hwmon ? Might make sense given the majority
> > of the changes is in hwmon code.
> 
> I believe the series should go via your tree, yes. I had only minor
> comments in the code added for the cooling device code, as it lacks the
> unregistration call in the .remove callback. 
> 
> Also, the DTS changes may generate conflicts with platform code. Lukasz
> may probably ask  Kukjin Kim to add them via the samsung tree.
> 
Ok, I'll wait for the updated patch and then add the hwmon parts to hwmon-next.

Thanks,
Guenter

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [lm-sensors] [PATCH v5 0/6] hwmon: thermal: Odroid U3: Provide support for Odroid U3 fan
@ 2015-02-25 18:42         ` Guenter Roeck
  0 siblings, 0 replies; 329+ messages in thread
From: Guenter Roeck @ 2015-02-25 18:42 UTC (permalink / raw)
  To: Eduardo Valentin
  Cc: Lukasz Majewski, Kamil Debski, Jean Delvare, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

On Wed, Feb 25, 2015 at 02:29:18PM -0400, Eduardo Valentin wrote:
> Guenter,
> 
> On Wed, Feb 25, 2015 at 09:18:20AM -0800, Guenter Roeck wrote:
> > On Wed, Feb 25, 2015 at 04:34:16PM +0100, Lukasz Majewski wrote:
> > > Presented patches add support for Odroid's U3 optional CPU FAN, which uses PWM
> > > subsystem for low level control.
> > > 
> > > After successful probe it registers itself as a cooling device for thermal
> > > subsystem.
> > > 
> > > This driver also supports devices without DTS specified.
> > > 
> > > To provide correct functionality, new properties to device tree description for
> > > Exynos4412 and in particular Odroid U3 have been added.
> > > 
> > > Those patches were tested at Exynos4412 - Odroid U3 board.
> > > 
> > > Patches were applied on:
> > > linux-soc-thermal/fixes branch (Linux v4.0-rc1)
> > > SHA1: b71d399c7f2fe06b60b96155ec0b9ae167334e4a
> > > 
> > > Kamil Debski (1):
> > >   ARM: dts: Add pwm-fan node to the Odroid-U3 board
> > > 
> > > Lukasz Majewski (5):
> > >   Documentation: dts: Documentation entry to explain how to use PWM FAN
> > >     as a cooling device
> > >   ARM: dts: Add properties to use pwm-fan device as a cooling device in
> > >     Odroid U3
> > >   hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty
> > >     cycle
> > >   hwmon: pwm-fan: Read PWM FAN configuration from device tree
> > >   hwmon: pwm-fan: Code for using PWM FAN as a cooling device
> > > 
> > >  .../devicetree/bindings/hwmon/pwm-fan.txt          |  25 +++-
> > >  arch/arm/boot/dts/exynos4.dtsi                     |   2 +-
> > >  arch/arm/boot/dts/exynos4412-odroidu3.dts          |  43 ++++++
> > >  drivers/hwmon/pwm-fan.c                            | 166 +++++++++++++++++++--
> > >  4 files changed, 220 insertions(+), 16 deletions(-)
> > > 
> > For the series:
> > 
> > Acked-by: Guenter Roeck <linux@roeck-us.net>
> > 
> > Should I take it through hwmon ? Might make sense given the majority
> > of the changes is in hwmon code.
> 
> I believe the series should go via your tree, yes. I had only minor
> comments in the code added for the cooling device code, as it lacks the
> unregistration call in the .remove callback. 
> 
> Also, the DTS changes may generate conflicts with platform code. Lukasz
> may probably ask  Kukjin Kim to add them via the samsung tree.
> 
Ok, I'll wait for the updated patch and then add the hwmon parts to hwmon-next.

Thanks,
Guenter

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v5 3/6] ARM: dts: Add properties to use pwm-fan device as a cooling device in Odroid U3
  2015-02-25 15:34     ` [PATCH v5 3/6] ARM: dts: Add properties to use pwm-fan device as a cooling device in Odroid U3 Lukasz Majewski
  (?)
@ 2015-02-25 18:49       ` Eduardo Valentin
  -1 siblings, 0 replies; 329+ messages in thread
From: Eduardo Valentin @ 2015-02-25 18:49 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

[-- Attachment #1: Type: text/plain, Size: 1868 bytes --]

On Wed, Feb 25, 2015 at 04:34:19PM +0100, Lukasz Majewski wrote:
> With those bindings it is possible to use pwm-fan device available in
> Odroid U3 as a cooling device.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>

Acked-by: Eduardo Valentin <edubezval@gmail.com>

> ---
> Changes for v2:
> - Rename cooling-pwm-values property to cooling-levels
> Changes for v3:
> - Change patch's topic to "ARM dts"
> - Reduce maximal cooling-level to 230 from 255
> Changes for v4:
> - None
> Changes for v5:
> - None
> ---
>  arch/arm/boot/dts/exynos4412-odroidu3.dts | 33 ++++++++++++++++++++++++++++++-
>  1 file changed, 32 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
> index 4c04837..abcfa3c 100644
> --- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
> +++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
> @@ -32,9 +32,40 @@
>  		};
>  	};
>  
> -	pwm-fan {
> +	fan0: pwm-fan {
>  		compatible = "pwm-fan";
>  		pwms = <&pwm 0 10000 0>;
> +		cooling-min-state = <0>;
> +		cooling-max-state = <3>;
> +		#cooling-cells = <2>;
> +		cooling-levels = <0 102 170 230>;
> +	};
> +
> +	thermal-zones {
> +		cpu_thermal: cpu-thermal {
> +			cooling-maps {
> +				map0 {
> +				     trip = <&cpu_alert1>;
> +				     cooling-device = <&cpu0 7 7>;
> +				};
> +				map1 {
> +				     trip = <&cpu_alert2>;
> +				     cooling-device = <&cpu0 13 13>;
> +				};
> +				map2 {
> +				     trip = <&cpu_alert0>;
> +				     cooling-device = <&fan0 0 1>;
> +				};
> +				map3 {
> +				     trip = <&cpu_alert1>;
> +				     cooling-device = <&fan0 1 2>;
> +				};
> +				map4 {
> +				     trip = <&cpu_alert2>;
> +				     cooling-device = <&fan0 2 3>;
> +				};
> +			};
> +		};
>  	};
>  };
>  
> -- 
> 2.0.0.rc2
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v5 3/6] ARM: dts: Add properties to use pwm-fan device as a cooling device in Odroid U3
@ 2015-02-25 18:49       ` Eduardo Valentin
  0 siblings, 0 replies; 329+ messages in thread
From: Eduardo Valentin @ 2015-02-25 18:49 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

[-- Attachment #1: Type: text/plain, Size: 1868 bytes --]

On Wed, Feb 25, 2015 at 04:34:19PM +0100, Lukasz Majewski wrote:
> With those bindings it is possible to use pwm-fan device available in
> Odroid U3 as a cooling device.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>

Acked-by: Eduardo Valentin <edubezval@gmail.com>

> ---
> Changes for v2:
> - Rename cooling-pwm-values property to cooling-levels
> Changes for v3:
> - Change patch's topic to "ARM dts"
> - Reduce maximal cooling-level to 230 from 255
> Changes for v4:
> - None
> Changes for v5:
> - None
> ---
>  arch/arm/boot/dts/exynos4412-odroidu3.dts | 33 ++++++++++++++++++++++++++++++-
>  1 file changed, 32 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
> index 4c04837..abcfa3c 100644
> --- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
> +++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
> @@ -32,9 +32,40 @@
>  		};
>  	};
>  
> -	pwm-fan {
> +	fan0: pwm-fan {
>  		compatible = "pwm-fan";
>  		pwms = <&pwm 0 10000 0>;
> +		cooling-min-state = <0>;
> +		cooling-max-state = <3>;
> +		#cooling-cells = <2>;
> +		cooling-levels = <0 102 170 230>;
> +	};
> +
> +	thermal-zones {
> +		cpu_thermal: cpu-thermal {
> +			cooling-maps {
> +				map0 {
> +				     trip = <&cpu_alert1>;
> +				     cooling-device = <&cpu0 7 7>;
> +				};
> +				map1 {
> +				     trip = <&cpu_alert2>;
> +				     cooling-device = <&cpu0 13 13>;
> +				};
> +				map2 {
> +				     trip = <&cpu_alert0>;
> +				     cooling-device = <&fan0 0 1>;
> +				};
> +				map3 {
> +				     trip = <&cpu_alert1>;
> +				     cooling-device = <&fan0 1 2>;
> +				};
> +				map4 {
> +				     trip = <&cpu_alert2>;
> +				     cooling-device = <&fan0 2 3>;
> +				};
> +			};
> +		};
>  	};
>  };
>  
> -- 
> 2.0.0.rc2
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [lm-sensors] [PATCH v5 3/6] ARM: dts: Add properties to use pwm-fan device as a cooling device i
@ 2015-02-25 18:49       ` Eduardo Valentin
  0 siblings, 0 replies; 329+ messages in thread
From: Eduardo Valentin @ 2015-02-25 18:49 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan


[-- Attachment #1.1: Type: text/plain, Size: 1868 bytes --]

On Wed, Feb 25, 2015 at 04:34:19PM +0100, Lukasz Majewski wrote:
> With those bindings it is possible to use pwm-fan device available in
> Odroid U3 as a cooling device.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>

Acked-by: Eduardo Valentin <edubezval@gmail.com>

> ---
> Changes for v2:
> - Rename cooling-pwm-values property to cooling-levels
> Changes for v3:
> - Change patch's topic to "ARM dts"
> - Reduce maximal cooling-level to 230 from 255
> Changes for v4:
> - None
> Changes for v5:
> - None
> ---
>  arch/arm/boot/dts/exynos4412-odroidu3.dts | 33 ++++++++++++++++++++++++++++++-
>  1 file changed, 32 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
> index 4c04837..abcfa3c 100644
> --- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
> +++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
> @@ -32,9 +32,40 @@
>  		};
>  	};
>  
> -	pwm-fan {
> +	fan0: pwm-fan {
>  		compatible = "pwm-fan";
>  		pwms = <&pwm 0 10000 0>;
> +		cooling-min-state = <0>;
> +		cooling-max-state = <3>;
> +		#cooling-cells = <2>;
> +		cooling-levels = <0 102 170 230>;
> +	};
> +
> +	thermal-zones {
> +		cpu_thermal: cpu-thermal {
> +			cooling-maps {
> +				map0 {
> +				     trip = <&cpu_alert1>;
> +				     cooling-device = <&cpu0 7 7>;
> +				};
> +				map1 {
> +				     trip = <&cpu_alert2>;
> +				     cooling-device = <&cpu0 13 13>;
> +				};
> +				map2 {
> +				     trip = <&cpu_alert0>;
> +				     cooling-device = <&fan0 0 1>;
> +				};
> +				map3 {
> +				     trip = <&cpu_alert1>;
> +				     cooling-device = <&fan0 1 2>;
> +				};
> +				map4 {
> +				     trip = <&cpu_alert2>;
> +				     cooling-device = <&fan0 2 3>;
> +				};
> +			};
> +		};
>  	};
>  };
>  
> -- 
> 2.0.0.rc2
> 

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

[-- Attachment #2: Type: text/plain, Size: 153 bytes --]

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v5 1/6] Documentation: dts: Documentation entry to explain how to use PWM FAN as a cooling device
  2015-02-25 15:34     ` [PATCH v5 1/6] Documentation: dts: Documentation entry to explain how to use PWM FAN as a cooling device Lukasz Majewski
  (?)
@ 2015-02-25 19:11       ` Eduardo Valentin
  -1 siblings, 0 replies; 329+ messages in thread
From: Eduardo Valentin @ 2015-02-25 19:11 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

[-- Attachment #1: Type: text/plain, Size: 2349 bytes --]

On Wed, Feb 25, 2015 at 04:34:17PM +0100, Lukasz Majewski wrote:
> Explanation of several properties, which allow PWM fan working as a cooling
> device, have been embraced in this commit.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
> Changes for v2:
> - Rename cooling-pwm-values to cooling-levels
> - Remove default-pulse-width property and stick to default hwmon policy
> Changes for v3:
> - Changing commit title from "hwmon: dts: Doc:" to "Documentation: dts"
> - Remove unnecessary properties
> - Set maximal cooling level to 230 instead of 255
> Changes for v4:
> - None
> Changes for v5:
> - Move thermal-zones description to example section
> - Extending example section
> 
> ---
>  .../devicetree/bindings/hwmon/pwm-fan.txt          | 25 +++++++++++++++++++++-
>  1 file changed, 24 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> index 610757c..645251b 100644
> --- a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> +++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> @@ -3,10 +3,33 @@ Bindings for a fan connected to the PWM lines
>  Required properties:
>  - compatible	: "pwm-fan"
>  - pwms		: the PWM that is used to control the PWM fan
> +- cooling-levels      : PWM duty cycle values in a range from 0 to 255
> +			which correspond to thermal cooling states
>  
>  Example:
> -	pwm-fan {
> +	fan0: pwm-fan {
>  		compatible = "pwm-fan";
>  		status = "okay";
>  		pwms = <&pwm 0 10000 0>;
> +		cooling-levels = <0 102 170 230>;
> +	};
> +
> +	thermal-zones {
> +		cpu_thermal: cpu-thermal {
> +		cooling-min-state = <0>;
> +		cooling-max-state = <3>;
> +		#cooling-cells = <2>;
> +		trips {
> +			cpu_alert1: cpu-alert1 {
> +				temperature = <100000>; /* millicelsius */
> +				hysteresis = <2000>; /* millicelsius */
> +				type = "passive";
> +			};
> +		};
> +		cooling-maps {
> +			map0 {
> +			     trip = <&cpu_alert1>;
> +			     cooling-device = <&fan0 0 1>;
> +			};
> +		};

The above example has two issues:
(1) it is wrong, as the cooling device properties are in the thermal
zone node.
(2) has a misalignment / tabulation

Can you please fix that in your next version too?

>  	};
> -- 
> 2.0.0.rc2
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v5 1/6] Documentation: dts: Documentation entry to explain how to use PWM FAN as a cooling device
@ 2015-02-25 19:11       ` Eduardo Valentin
  0 siblings, 0 replies; 329+ messages in thread
From: Eduardo Valentin @ 2015-02-25 19:11 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

[-- Attachment #1: Type: text/plain, Size: 2349 bytes --]

On Wed, Feb 25, 2015 at 04:34:17PM +0100, Lukasz Majewski wrote:
> Explanation of several properties, which allow PWM fan working as a cooling
> device, have been embraced in this commit.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
> Changes for v2:
> - Rename cooling-pwm-values to cooling-levels
> - Remove default-pulse-width property and stick to default hwmon policy
> Changes for v3:
> - Changing commit title from "hwmon: dts: Doc:" to "Documentation: dts"
> - Remove unnecessary properties
> - Set maximal cooling level to 230 instead of 255
> Changes for v4:
> - None
> Changes for v5:
> - Move thermal-zones description to example section
> - Extending example section
> 
> ---
>  .../devicetree/bindings/hwmon/pwm-fan.txt          | 25 +++++++++++++++++++++-
>  1 file changed, 24 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> index 610757c..645251b 100644
> --- a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> +++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> @@ -3,10 +3,33 @@ Bindings for a fan connected to the PWM lines
>  Required properties:
>  - compatible	: "pwm-fan"
>  - pwms		: the PWM that is used to control the PWM fan
> +- cooling-levels      : PWM duty cycle values in a range from 0 to 255
> +			which correspond to thermal cooling states
>  
>  Example:
> -	pwm-fan {
> +	fan0: pwm-fan {
>  		compatible = "pwm-fan";
>  		status = "okay";
>  		pwms = <&pwm 0 10000 0>;
> +		cooling-levels = <0 102 170 230>;
> +	};
> +
> +	thermal-zones {
> +		cpu_thermal: cpu-thermal {
> +		cooling-min-state = <0>;
> +		cooling-max-state = <3>;
> +		#cooling-cells = <2>;
> +		trips {
> +			cpu_alert1: cpu-alert1 {
> +				temperature = <100000>; /* millicelsius */
> +				hysteresis = <2000>; /* millicelsius */
> +				type = "passive";
> +			};
> +		};
> +		cooling-maps {
> +			map0 {
> +			     trip = <&cpu_alert1>;
> +			     cooling-device = <&fan0 0 1>;
> +			};
> +		};

The above example has two issues:
(1) it is wrong, as the cooling device properties are in the thermal
zone node.
(2) has a misalignment / tabulation

Can you please fix that in your next version too?

>  	};
> -- 
> 2.0.0.rc2
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [lm-sensors] [PATCH v5 1/6] Documentation: dts: Documentation entry to explain how to use PWM FA
@ 2015-02-25 19:11       ` Eduardo Valentin
  0 siblings, 0 replies; 329+ messages in thread
From: Eduardo Valentin @ 2015-02-25 19:11 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan


[-- Attachment #1.1: Type: text/plain, Size: 2349 bytes --]

On Wed, Feb 25, 2015 at 04:34:17PM +0100, Lukasz Majewski wrote:
> Explanation of several properties, which allow PWM fan working as a cooling
> device, have been embraced in this commit.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
> Changes for v2:
> - Rename cooling-pwm-values to cooling-levels
> - Remove default-pulse-width property and stick to default hwmon policy
> Changes for v3:
> - Changing commit title from "hwmon: dts: Doc:" to "Documentation: dts"
> - Remove unnecessary properties
> - Set maximal cooling level to 230 instead of 255
> Changes for v4:
> - None
> Changes for v5:
> - Move thermal-zones description to example section
> - Extending example section
> 
> ---
>  .../devicetree/bindings/hwmon/pwm-fan.txt          | 25 +++++++++++++++++++++-
>  1 file changed, 24 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> index 610757c..645251b 100644
> --- a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> +++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> @@ -3,10 +3,33 @@ Bindings for a fan connected to the PWM lines
>  Required properties:
>  - compatible	: "pwm-fan"
>  - pwms		: the PWM that is used to control the PWM fan
> +- cooling-levels      : PWM duty cycle values in a range from 0 to 255
> +			which correspond to thermal cooling states
>  
>  Example:
> -	pwm-fan {
> +	fan0: pwm-fan {
>  		compatible = "pwm-fan";
>  		status = "okay";
>  		pwms = <&pwm 0 10000 0>;
> +		cooling-levels = <0 102 170 230>;
> +	};
> +
> +	thermal-zones {
> +		cpu_thermal: cpu-thermal {
> +		cooling-min-state = <0>;
> +		cooling-max-state = <3>;
> +		#cooling-cells = <2>;
> +		trips {
> +			cpu_alert1: cpu-alert1 {
> +				temperature = <100000>; /* millicelsius */
> +				hysteresis = <2000>; /* millicelsius */
> +				type = "passive";
> +			};
> +		};
> +		cooling-maps {
> +			map0 {
> +			     trip = <&cpu_alert1>;
> +			     cooling-device = <&fan0 0 1>;
> +			};
> +		};

The above example has two issues:
(1) it is wrong, as the cooling device properties are in the thermal
zone node.
(2) has a misalignment / tabulation

Can you please fix that in your next version too?

>  	};
> -- 
> 2.0.0.rc2
> 

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

[-- Attachment #2: Type: text/plain, Size: 153 bytes --]

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v5 1/6] Documentation: dts: Documentation entry to explain how to use PWM FAN as a cooling device
  2015-02-25 19:11       ` [PATCH v5 1/6] Documentation: dts: Documentation entry to explain how to use PWM FAN as a cooling device Eduardo Valentin
  (?)
@ 2015-02-25 19:13         ` Eduardo Valentin
  -1 siblings, 0 replies; 329+ messages in thread
From: Eduardo Valentin @ 2015-02-25 19:13 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

[-- Attachment #1: Type: text/plain, Size: 2671 bytes --]

On Wed, Feb 25, 2015 at 03:11:24PM -0400, Eduardo Valentin wrote:
> On Wed, Feb 25, 2015 at 04:34:17PM +0100, Lukasz Majewski wrote:
> > Explanation of several properties, which allow PWM fan working as a cooling
> > device, have been embraced in this commit.
> > 
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > ---
> > Changes for v2:
> > - Rename cooling-pwm-values to cooling-levels
> > - Remove default-pulse-width property and stick to default hwmon policy
> > Changes for v3:
> > - Changing commit title from "hwmon: dts: Doc:" to "Documentation: dts"
> > - Remove unnecessary properties
> > - Set maximal cooling level to 230 instead of 255
> > Changes for v4:
> > - None
> > Changes for v5:
> > - Move thermal-zones description to example section
> > - Extending example section
> > 
> > ---
> >  .../devicetree/bindings/hwmon/pwm-fan.txt          | 25 +++++++++++++++++++++-
> >  1 file changed, 24 insertions(+), 1 deletion(-)
> > 
> > diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> > index 610757c..645251b 100644
> > --- a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> > +++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> > @@ -3,10 +3,33 @@ Bindings for a fan connected to the PWM lines
> >  Required properties:
> >  - compatible	: "pwm-fan"
> >  - pwms		: the PWM that is used to control the PWM fan
> > +- cooling-levels      : PWM duty cycle values in a range from 0 to 255
> > +			which correspond to thermal cooling states
> >  
> >  Example:
> > -	pwm-fan {
> > +	fan0: pwm-fan {
> >  		compatible = "pwm-fan";
> >  		status = "okay";
> >  		pwms = <&pwm 0 10000 0>;
> > +		cooling-levels = <0 102 170 230>;
> > +	};
> > +
> > +	thermal-zones {
> > +		cpu_thermal: cpu-thermal {
> > +		cooling-min-state = <0>;
> > +		cooling-max-state = <3>;
> > +		#cooling-cells = <2>;
> > +		trips {
> > +			cpu_alert1: cpu-alert1 {
> > +				temperature = <100000>; /* millicelsius */
> > +				hysteresis = <2000>; /* millicelsius */
> > +				type = "passive";
> > +			};
> > +		};
> > +		cooling-maps {
> > +			map0 {
> > +			     trip = <&cpu_alert1>;
> > +			     cooling-device = <&fan0 0 1>;
> > +			};
> > +		};
> 
> The above example has two issues:
> (1) it is wrong, as the cooling device properties are in the thermal
> zone node.
> (2) has a misalignment / tabulation
> 
> Can you please fix that in your next version too?


Apart from the above two issues you may add my 
Acked-by: Eduardo Valentin <edubezval@gmail.com>

> 
> >  	};
> > -- 
> > 2.0.0.rc2
> > 



[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v5 1/6] Documentation: dts: Documentation entry to explain how to use PWM FAN as a cooling device
@ 2015-02-25 19:13         ` Eduardo Valentin
  0 siblings, 0 replies; 329+ messages in thread
From: Eduardo Valentin @ 2015-02-25 19:13 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

[-- Attachment #1: Type: text/plain, Size: 2671 bytes --]

On Wed, Feb 25, 2015 at 03:11:24PM -0400, Eduardo Valentin wrote:
> On Wed, Feb 25, 2015 at 04:34:17PM +0100, Lukasz Majewski wrote:
> > Explanation of several properties, which allow PWM fan working as a cooling
> > device, have been embraced in this commit.
> > 
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > ---
> > Changes for v2:
> > - Rename cooling-pwm-values to cooling-levels
> > - Remove default-pulse-width property and stick to default hwmon policy
> > Changes for v3:
> > - Changing commit title from "hwmon: dts: Doc:" to "Documentation: dts"
> > - Remove unnecessary properties
> > - Set maximal cooling level to 230 instead of 255
> > Changes for v4:
> > - None
> > Changes for v5:
> > - Move thermal-zones description to example section
> > - Extending example section
> > 
> > ---
> >  .../devicetree/bindings/hwmon/pwm-fan.txt          | 25 +++++++++++++++++++++-
> >  1 file changed, 24 insertions(+), 1 deletion(-)
> > 
> > diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> > index 610757c..645251b 100644
> > --- a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> > +++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> > @@ -3,10 +3,33 @@ Bindings for a fan connected to the PWM lines
> >  Required properties:
> >  - compatible	: "pwm-fan"
> >  - pwms		: the PWM that is used to control the PWM fan
> > +- cooling-levels      : PWM duty cycle values in a range from 0 to 255
> > +			which correspond to thermal cooling states
> >  
> >  Example:
> > -	pwm-fan {
> > +	fan0: pwm-fan {
> >  		compatible = "pwm-fan";
> >  		status = "okay";
> >  		pwms = <&pwm 0 10000 0>;
> > +		cooling-levels = <0 102 170 230>;
> > +	};
> > +
> > +	thermal-zones {
> > +		cpu_thermal: cpu-thermal {
> > +		cooling-min-state = <0>;
> > +		cooling-max-state = <3>;
> > +		#cooling-cells = <2>;
> > +		trips {
> > +			cpu_alert1: cpu-alert1 {
> > +				temperature = <100000>; /* millicelsius */
> > +				hysteresis = <2000>; /* millicelsius */
> > +				type = "passive";
> > +			};
> > +		};
> > +		cooling-maps {
> > +			map0 {
> > +			     trip = <&cpu_alert1>;
> > +			     cooling-device = <&fan0 0 1>;
> > +			};
> > +		};
> 
> The above example has two issues:
> (1) it is wrong, as the cooling device properties are in the thermal
> zone node.
> (2) has a misalignment / tabulation
> 
> Can you please fix that in your next version too?


Apart from the above two issues you may add my 
Acked-by: Eduardo Valentin <edubezval@gmail.com>

> 
> >  	};
> > -- 
> > 2.0.0.rc2
> > 



[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [lm-sensors] [PATCH v5 1/6] Documentation: dts: Documentation entry to explain how to use PWM FA
@ 2015-02-25 19:13         ` Eduardo Valentin
  0 siblings, 0 replies; 329+ messages in thread
From: Eduardo Valentin @ 2015-02-25 19:13 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan


[-- Attachment #1.1: Type: text/plain, Size: 2671 bytes --]

On Wed, Feb 25, 2015 at 03:11:24PM -0400, Eduardo Valentin wrote:
> On Wed, Feb 25, 2015 at 04:34:17PM +0100, Lukasz Majewski wrote:
> > Explanation of several properties, which allow PWM fan working as a cooling
> > device, have been embraced in this commit.
> > 
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > ---
> > Changes for v2:
> > - Rename cooling-pwm-values to cooling-levels
> > - Remove default-pulse-width property and stick to default hwmon policy
> > Changes for v3:
> > - Changing commit title from "hwmon: dts: Doc:" to "Documentation: dts"
> > - Remove unnecessary properties
> > - Set maximal cooling level to 230 instead of 255
> > Changes for v4:
> > - None
> > Changes for v5:
> > - Move thermal-zones description to example section
> > - Extending example section
> > 
> > ---
> >  .../devicetree/bindings/hwmon/pwm-fan.txt          | 25 +++++++++++++++++++++-
> >  1 file changed, 24 insertions(+), 1 deletion(-)
> > 
> > diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> > index 610757c..645251b 100644
> > --- a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> > +++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
> > @@ -3,10 +3,33 @@ Bindings for a fan connected to the PWM lines
> >  Required properties:
> >  - compatible	: "pwm-fan"
> >  - pwms		: the PWM that is used to control the PWM fan
> > +- cooling-levels      : PWM duty cycle values in a range from 0 to 255
> > +			which correspond to thermal cooling states
> >  
> >  Example:
> > -	pwm-fan {
> > +	fan0: pwm-fan {
> >  		compatible = "pwm-fan";
> >  		status = "okay";
> >  		pwms = <&pwm 0 10000 0>;
> > +		cooling-levels = <0 102 170 230>;
> > +	};
> > +
> > +	thermal-zones {
> > +		cpu_thermal: cpu-thermal {
> > +		cooling-min-state = <0>;
> > +		cooling-max-state = <3>;
> > +		#cooling-cells = <2>;
> > +		trips {
> > +			cpu_alert1: cpu-alert1 {
> > +				temperature = <100000>; /* millicelsius */
> > +				hysteresis = <2000>; /* millicelsius */
> > +				type = "passive";
> > +			};
> > +		};
> > +		cooling-maps {
> > +			map0 {
> > +			     trip = <&cpu_alert1>;
> > +			     cooling-device = <&fan0 0 1>;
> > +			};
> > +		};
> 
> The above example has two issues:
> (1) it is wrong, as the cooling device properties are in the thermal
> zone node.
> (2) has a misalignment / tabulation
> 
> Can you please fix that in your next version too?


Apart from the above two issues you may add my 
Acked-by: Eduardo Valentin <edubezval@gmail.com>

> 
> >  	};
> > -- 
> > 2.0.0.rc2
> > 



[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

[-- Attachment #2: Type: text/plain, Size: 153 bytes --]

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 329+ messages in thread

* [PATCH v6 0/6] hwmon: thermal: Odroid U3: Provide support for Odroid U3 fan
  2014-12-18 10:13 ` Lukasz Majewski
  (?)
@ 2015-02-26 13:59   ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-26 13:59 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

Presented patches add support for Odroid's U3 optional CPU FAN, which uses PWM
subsystem for low level control.

After successful probe it registers itself as a cooling device for thermal
subsystem.

This driver also supports devices without DTS specified.

To provide correct functionality, new properties to device tree description for
Exynos4412 and in particular Odroid U3 have been added.

Those patches were tested at Exynos4412 - Odroid U3 board.

Patches were applied on:
linux-soc-thermal/fixes branch (Linux v4.0-rc1)
SHA1: b71d399c7f2fe06b60b96155ec0b9ae167334e4a


Kamil Debski (1):
  ARM: dts: Add pwm-fan node to the Odroid-U3 board

Lukasz Majewski (5):
  Documentation: dts: Documentation entry to explain how to use PWM FAN
    as a cooling device
  ARM: dts: Add properties to use pwm-fan device as a cooling device in
    Odroid U3
  hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty
    cycle
  hwmon: pwm-fan: Read PWM FAN configuration from device tree
  hwmon: pwm-fan: Code for using PWM FAN as a cooling device

 .../devicetree/bindings/hwmon/pwm-fan.txt          |  29 +++-
 arch/arm/boot/dts/exynos4.dtsi                     |   2 +-
 arch/arm/boot/dts/exynos4412-odroidu3.dts          |  43 ++++++
 drivers/hwmon/pwm-fan.c                            | 172 +++++++++++++++++++--
 4 files changed, 229 insertions(+), 17 deletions(-)

-- 
2.0.0.rc2


^ permalink raw reply	[flat|nested] 329+ messages in thread

* [PATCH v6 0/6] hwmon: thermal: Odroid U3: Provide support for Odroid U3 fan
@ 2015-02-26 13:59   ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-26 13:59 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

Presented patches add support for Odroid's U3 optional CPU FAN, which uses PWM
subsystem for low level control.

After successful probe it registers itself as a cooling device for thermal
subsystem.

This driver also supports devices without DTS specified.

To provide correct functionality, new properties to device tree description for
Exynos4412 and in particular Odroid U3 have been added.

Those patches were tested at Exynos4412 - Odroid U3 board.

Patches were applied on:
linux-soc-thermal/fixes branch (Linux v4.0-rc1)
SHA1: b71d399c7f2fe06b60b96155ec0b9ae167334e4a


Kamil Debski (1):
  ARM: dts: Add pwm-fan node to the Odroid-U3 board

Lukasz Majewski (5):
  Documentation: dts: Documentation entry to explain how to use PWM FAN
    as a cooling device
  ARM: dts: Add properties to use pwm-fan device as a cooling device in
    Odroid U3
  hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty
    cycle
  hwmon: pwm-fan: Read PWM FAN configuration from device tree
  hwmon: pwm-fan: Code for using PWM FAN as a cooling device

 .../devicetree/bindings/hwmon/pwm-fan.txt          |  29 +++-
 arch/arm/boot/dts/exynos4.dtsi                     |   2 +-
 arch/arm/boot/dts/exynos4412-odroidu3.dts          |  43 ++++++
 drivers/hwmon/pwm-fan.c                            | 172 +++++++++++++++++++--
 4 files changed, 229 insertions(+), 17 deletions(-)

-- 
2.0.0.rc2

^ permalink raw reply	[flat|nested] 329+ messages in thread

* [lm-sensors] [PATCH v6 0/6] hwmon: thermal: Odroid U3: Provide support for Odroid U3 fan
@ 2015-02-26 13:59   ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-26 13:59 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

Presented patches add support for Odroid's U3 optional CPU FAN, which uses PWM
subsystem for low level control.

After successful probe it registers itself as a cooling device for thermal
subsystem.

This driver also supports devices without DTS specified.

To provide correct functionality, new properties to device tree description for
Exynos4412 and in particular Odroid U3 have been added.

Those patches were tested at Exynos4412 - Odroid U3 board.

Patches were applied on:
linux-soc-thermal/fixes branch (Linux v4.0-rc1)
SHA1: b71d399c7f2fe06b60b96155ec0b9ae167334e4a


Kamil Debski (1):
  ARM: dts: Add pwm-fan node to the Odroid-U3 board

Lukasz Majewski (5):
  Documentation: dts: Documentation entry to explain how to use PWM FAN
    as a cooling device
  ARM: dts: Add properties to use pwm-fan device as a cooling device in
    Odroid U3
  hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty
    cycle
  hwmon: pwm-fan: Read PWM FAN configuration from device tree
  hwmon: pwm-fan: Code for using PWM FAN as a cooling device

 .../devicetree/bindings/hwmon/pwm-fan.txt          |  29 +++-
 arch/arm/boot/dts/exynos4.dtsi                     |   2 +-
 arch/arm/boot/dts/exynos4412-odroidu3.dts          |  43 ++++++
 drivers/hwmon/pwm-fan.c                            | 172 +++++++++++++++++++--
 4 files changed, 229 insertions(+), 17 deletions(-)

-- 
2.0.0.rc2


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 329+ messages in thread

* [PATCH v6 1/6] Documentation: dts: Documentation entry to explain how to use PWM FAN as a cooling device
  2015-02-26 13:59   ` Lukasz Majewski
  (?)
@ 2015-02-26 13:59     ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-26 13:59 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

Explanation of several properties, which allow PWM fan working as a cooling
device, have been embraced in this commit.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
Acked-by: Eduardo Valentin <edubezval@gmail.com>
---
Changes for v2:
- Rename cooling-pwm-values to cooling-levels
- Remove default-pulse-width property and stick to default hwmon policy
Changes for v3:
- Changing commit title from "hwmon: dts: Doc:" to "Documentation: dts"
- Remove unnecessary properties
- Set maximal cooling level to 230 instead of 255
Changes for v4:
- None
Changes for v5:
- Move thermal-zones description to example section
- Extending example section
Changes for v6:
- cooling-{min|max}-state properties added to pwm-fan binding
- Mandatory properties for thermal-zones added
- Indentation fixed
---
 .../devicetree/bindings/hwmon/pwm-fan.txt          | 29 ++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
index 610757c..c6d5332 100644
--- a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
+++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
@@ -3,10 +3,35 @@ Bindings for a fan connected to the PWM lines
 Required properties:
 - compatible	: "pwm-fan"
 - pwms		: the PWM that is used to control the PWM fan
+- cooling-levels      : PWM duty cycle values in a range from 0 to 255
+			which correspond to thermal cooling states
 
 Example:
-	pwm-fan {
+	fan0: pwm-fan {
 		compatible = "pwm-fan";
-		status = "okay";
+		cooling-min-state = <0>;
+		cooling-max-state = <3>;
+		#cooling-cells = <2>;
 		pwms = <&pwm 0 10000 0>;
+		cooling-levels = <0 102 170 230>;
 	};
+
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			     thermal-sensors = <&tmu 0>;
+			     polling-delay-passive = <0>;
+			     polling-delay = <0>;
+			     trips {
+					cpu_alert1: cpu-alert1 {
+						    temperature = <100000>; /* millicelsius */
+						    hysteresis = <2000>; /* millicelsius */
+						    type = "passive";
+					};
+			     };
+			     cooling-maps {
+					map0 {
+						    trip = <&cpu_alert1>;
+						    cooling-device = <&fan0 0 1>;
+					};
+			     };
+		};
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v6 1/6] Documentation: dts: Documentation entry to explain how to use PWM FAN as a cooling device
@ 2015-02-26 13:59     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-26 13:59 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

Explanation of several properties, which allow PWM fan working as a cooling
device, have been embraced in this commit.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
Acked-by: Eduardo Valentin <edubezval@gmail.com>
---
Changes for v2:
- Rename cooling-pwm-values to cooling-levels
- Remove default-pulse-width property and stick to default hwmon policy
Changes for v3:
- Changing commit title from "hwmon: dts: Doc:" to "Documentation: dts"
- Remove unnecessary properties
- Set maximal cooling level to 230 instead of 255
Changes for v4:
- None
Changes for v5:
- Move thermal-zones description to example section
- Extending example section
Changes for v6:
- cooling-{min|max}-state properties added to pwm-fan binding
- Mandatory properties for thermal-zones added
- Indentation fixed
---
 .../devicetree/bindings/hwmon/pwm-fan.txt          | 29 ++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
index 610757c..c6d5332 100644
--- a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
+++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
@@ -3,10 +3,35 @@ Bindings for a fan connected to the PWM lines
 Required properties:
 - compatible	: "pwm-fan"
 - pwms		: the PWM that is used to control the PWM fan
+- cooling-levels      : PWM duty cycle values in a range from 0 to 255
+			which correspond to thermal cooling states
 
 Example:
-	pwm-fan {
+	fan0: pwm-fan {
 		compatible = "pwm-fan";
-		status = "okay";
+		cooling-min-state = <0>;
+		cooling-max-state = <3>;
+		#cooling-cells = <2>;
 		pwms = <&pwm 0 10000 0>;
+		cooling-levels = <0 102 170 230>;
 	};
+
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			     thermal-sensors = <&tmu 0>;
+			     polling-delay-passive = <0>;
+			     polling-delay = <0>;
+			     trips {
+					cpu_alert1: cpu-alert1 {
+						    temperature = <100000>; /* millicelsius */
+						    hysteresis = <2000>; /* millicelsius */
+						    type = "passive";
+					};
+			     };
+			     cooling-maps {
+					map0 {
+						    trip = <&cpu_alert1>;
+						    cooling-device = <&fan0 0 1>;
+					};
+			     };
+		};
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [lm-sensors] [PATCH v6 1/6] Documentation: dts: Documentation entry to explain how to use PWM FAN as
@ 2015-02-26 13:59     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-26 13:59 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

Explanation of several properties, which allow PWM fan working as a cooling
device, have been embraced in this commit.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
Acked-by: Eduardo Valentin <edubezval@gmail.com>
---
Changes for v2:
- Rename cooling-pwm-values to cooling-levels
- Remove default-pulse-width property and stick to default hwmon policy
Changes for v3:
- Changing commit title from "hwmon: dts: Doc:" to "Documentation: dts"
- Remove unnecessary properties
- Set maximal cooling level to 230 instead of 255
Changes for v4:
- None
Changes for v5:
- Move thermal-zones description to example section
- Extending example section
Changes for v6:
- cooling-{min|max}-state properties added to pwm-fan binding
- Mandatory properties for thermal-zones added
- Indentation fixed
---
 .../devicetree/bindings/hwmon/pwm-fan.txt          | 29 ++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
index 610757c..c6d5332 100644
--- a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
+++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
@@ -3,10 +3,35 @@ Bindings for a fan connected to the PWM lines
 Required properties:
 - compatible	: "pwm-fan"
 - pwms		: the PWM that is used to control the PWM fan
+- cooling-levels      : PWM duty cycle values in a range from 0 to 255
+			which correspond to thermal cooling states
 
 Example:
-	pwm-fan {
+	fan0: pwm-fan {
 		compatible = "pwm-fan";
-		status = "okay";
+		cooling-min-state = <0>;
+		cooling-max-state = <3>;
+		#cooling-cells = <2>;
 		pwms = <&pwm 0 10000 0>;
+		cooling-levels = <0 102 170 230>;
 	};
+
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			     thermal-sensors = <&tmu 0>;
+			     polling-delay-passive = <0>;
+			     polling-delay = <0>;
+			     trips {
+					cpu_alert1: cpu-alert1 {
+						    temperature = <100000>; /* millicelsius */
+						    hysteresis = <2000>; /* millicelsius */
+						    type = "passive";
+					};
+			     };
+			     cooling-maps {
+					map0 {
+						    trip = <&cpu_alert1>;
+						    cooling-device = <&fan0 0 1>;
+					};
+			     };
+		};
-- 
2.0.0.rc2


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v6 2/6] ARM: dts: Add pwm-fan node to the Odroid-U3 board
  2015-02-26 13:59   ` Lukasz Majewski
  (?)
@ 2015-02-26 13:59     ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-26 13:59 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

From: Kamil Debski <k.debski@samsung.com>

Add pwm-fan node to the Odroid-U3 board file to enable PWM control of the
cooling fan. In addition, add the "pwm" label to the pwm@139D0000 node
in the exynos4412.dtsi.

Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes since v1:
- added pwm label to the pwm@139D0000 node in exynos4.dtsi
- use the pwm label in the exynos4412-odroidu3.dts
- change order or properties in the pwn-fan node, to be sorted
  in alphabetical order
Changes for v5:
- Adding Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
- status = "okay"; dropped from the patch
Changes for v6:
- None

---
 arch/arm/boot/dts/exynos4.dtsi            |  2 +-
 arch/arm/boot/dts/exynos4412-odroidu3.dts | 12 ++++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/exynos4.dtsi b/arch/arm/boot/dts/exynos4.dtsi
index 690f56c..a93f5ca5 100644
--- a/arch/arm/boot/dts/exynos4.dtsi
+++ b/arch/arm/boot/dts/exynos4.dtsi
@@ -599,7 +599,7 @@
 		status = "disabled";
 	};
 
-	pwm@139D0000 {
+	pwm: pwm@139D0000 {
 		compatible = "samsung,exynos4210-pwm";
 		reg = <0x139D0000 0x1000>;
 		interrupts = <0 37 0>, <0 38 0>, <0 39 0>, <0 40 0>, <0 41 0>;
diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
index 44684e5..4c04837 100644
--- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
+++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
@@ -31,6 +31,18 @@
 			linux,default-trigger = "heartbeat";
 		};
 	};
+
+	pwm-fan {
+		compatible = "pwm-fan";
+		pwms = <&pwm 0 10000 0>;
+	};
+};
+
+&pwm {
+	pinctrl-0 = <&pwm0_out>;
+	pinctrl-names = "default";
+	samsung,pwm-outputs = <0>;
+	status = "okay";
 };
 
 &usb3503 {
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v6 2/6] ARM: dts: Add pwm-fan node to the Odroid-U3 board
@ 2015-02-26 13:59     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-26 13:59 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

From: Kamil Debski <k.debski@samsung.com>

Add pwm-fan node to the Odroid-U3 board file to enable PWM control of the
cooling fan. In addition, add the "pwm" label to the pwm@139D0000 node
in the exynos4412.dtsi.

Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes since v1:
- added pwm label to the pwm@139D0000 node in exynos4.dtsi
- use the pwm label in the exynos4412-odroidu3.dts
- change order or properties in the pwn-fan node, to be sorted
  in alphabetical order
Changes for v5:
- Adding Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
- status = "okay"; dropped from the patch
Changes for v6:
- None

---
 arch/arm/boot/dts/exynos4.dtsi            |  2 +-
 arch/arm/boot/dts/exynos4412-odroidu3.dts | 12 ++++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/exynos4.dtsi b/arch/arm/boot/dts/exynos4.dtsi
index 690f56c..a93f5ca5 100644
--- a/arch/arm/boot/dts/exynos4.dtsi
+++ b/arch/arm/boot/dts/exynos4.dtsi
@@ -599,7 +599,7 @@
 		status = "disabled";
 	};
 
-	pwm@139D0000 {
+	pwm: pwm@139D0000 {
 		compatible = "samsung,exynos4210-pwm";
 		reg = <0x139D0000 0x1000>;
 		interrupts = <0 37 0>, <0 38 0>, <0 39 0>, <0 40 0>, <0 41 0>;
diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
index 44684e5..4c04837 100644
--- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
+++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
@@ -31,6 +31,18 @@
 			linux,default-trigger = "heartbeat";
 		};
 	};
+
+	pwm-fan {
+		compatible = "pwm-fan";
+		pwms = <&pwm 0 10000 0>;
+	};
+};
+
+&pwm {
+	pinctrl-0 = <&pwm0_out>;
+	pinctrl-names = "default";
+	samsung,pwm-outputs = <0>;
+	status = "okay";
 };
 
 &usb3503 {
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [lm-sensors] [PATCH v6 2/6] ARM: dts: Add pwm-fan node to the Odroid-U3 board
@ 2015-02-26 13:59     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-26 13:59 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

From: Kamil Debski <k.debski@samsung.com>

Add pwm-fan node to the Odroid-U3 board file to enable PWM control of the
cooling fan. In addition, add the "pwm" label to the pwm@139D0000 node
in the exynos4412.dtsi.

Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes since v1:
- added pwm label to the pwm@139D0000 node in exynos4.dtsi
- use the pwm label in the exynos4412-odroidu3.dts
- change order or properties in the pwn-fan node, to be sorted
  in alphabetical order
Changes for v5:
- Adding Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
- status = "okay"; dropped from the patch
Changes for v6:
- None

---
 arch/arm/boot/dts/exynos4.dtsi            |  2 +-
 arch/arm/boot/dts/exynos4412-odroidu3.dts | 12 ++++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/exynos4.dtsi b/arch/arm/boot/dts/exynos4.dtsi
index 690f56c..a93f5ca5 100644
--- a/arch/arm/boot/dts/exynos4.dtsi
+++ b/arch/arm/boot/dts/exynos4.dtsi
@@ -599,7 +599,7 @@
 		status = "disabled";
 	};
 
-	pwm@139D0000 {
+	pwm: pwm@139D0000 {
 		compatible = "samsung,exynos4210-pwm";
 		reg = <0x139D0000 0x1000>;
 		interrupts = <0 37 0>, <0 38 0>, <0 39 0>, <0 40 0>, <0 41 0>;
diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
index 44684e5..4c04837 100644
--- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
+++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
@@ -31,6 +31,18 @@
 			linux,default-trigger = "heartbeat";
 		};
 	};
+
+	pwm-fan {
+		compatible = "pwm-fan";
+		pwms = <&pwm 0 10000 0>;
+	};
+};
+
+&pwm {
+	pinctrl-0 = <&pwm0_out>;
+	pinctrl-names = "default";
+	samsung,pwm-outputs = <0>;
+	status = "okay";
 };
 
 &usb3503 {
-- 
2.0.0.rc2


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v6 3/6] ARM: dts: Add properties to use pwm-fan device as a cooling device in Odroid U3
  2015-02-26 13:59   ` Lukasz Majewski
  (?)
@ 2015-02-26 13:59     ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-26 13:59 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

With those bindings it is possible to use pwm-fan device available in
Odroid U3 as a cooling device.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
Acked-by: Eduardo Valentin <edubezval@gmail.com>
---
Changes for v2:
- Rename cooling-pwm-values property to cooling-levels
Changes for v3:
- Change patch's topic to "ARM dts"
- Reduce maximal cooling-level to 230 from 255
Changes for v4:
- None
Changes for v5:
- None
Changes for v6:
- None
---
 arch/arm/boot/dts/exynos4412-odroidu3.dts | 33 ++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
index 4c04837..abcfa3c 100644
--- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
+++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
@@ -32,9 +32,40 @@
 		};
 	};
 
-	pwm-fan {
+	fan0: pwm-fan {
 		compatible = "pwm-fan";
 		pwms = <&pwm 0 10000 0>;
+		cooling-min-state = <0>;
+		cooling-max-state = <3>;
+		#cooling-cells = <2>;
+		cooling-levels = <0 102 170 230>;
+	};
+
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				     trip = <&cpu_alert1>;
+				     cooling-device = <&cpu0 7 7>;
+				};
+				map1 {
+				     trip = <&cpu_alert2>;
+				     cooling-device = <&cpu0 13 13>;
+				};
+				map2 {
+				     trip = <&cpu_alert0>;
+				     cooling-device = <&fan0 0 1>;
+				};
+				map3 {
+				     trip = <&cpu_alert1>;
+				     cooling-device = <&fan0 1 2>;
+				};
+				map4 {
+				     trip = <&cpu_alert2>;
+				     cooling-device = <&fan0 2 3>;
+				};
+			};
+		};
 	};
 };
 
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v6 3/6] ARM: dts: Add properties to use pwm-fan device as a cooling device in Odroid U3
@ 2015-02-26 13:59     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-26 13:59 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

With those bindings it is possible to use pwm-fan device available in
Odroid U3 as a cooling device.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
Acked-by: Eduardo Valentin <edubezval@gmail.com>
---
Changes for v2:
- Rename cooling-pwm-values property to cooling-levels
Changes for v3:
- Change patch's topic to "ARM dts"
- Reduce maximal cooling-level to 230 from 255
Changes for v4:
- None
Changes for v5:
- None
Changes for v6:
- None
---
 arch/arm/boot/dts/exynos4412-odroidu3.dts | 33 ++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
index 4c04837..abcfa3c 100644
--- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
+++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
@@ -32,9 +32,40 @@
 		};
 	};
 
-	pwm-fan {
+	fan0: pwm-fan {
 		compatible = "pwm-fan";
 		pwms = <&pwm 0 10000 0>;
+		cooling-min-state = <0>;
+		cooling-max-state = <3>;
+		#cooling-cells = <2>;
+		cooling-levels = <0 102 170 230>;
+	};
+
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				     trip = <&cpu_alert1>;
+				     cooling-device = <&cpu0 7 7>;
+				};
+				map1 {
+				     trip = <&cpu_alert2>;
+				     cooling-device = <&cpu0 13 13>;
+				};
+				map2 {
+				     trip = <&cpu_alert0>;
+				     cooling-device = <&fan0 0 1>;
+				};
+				map3 {
+				     trip = <&cpu_alert1>;
+				     cooling-device = <&fan0 1 2>;
+				};
+				map4 {
+				     trip = <&cpu_alert2>;
+				     cooling-device = <&fan0 2 3>;
+				};
+			};
+		};
 	};
 };
 
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [lm-sensors] [PATCH v6 3/6] ARM: dts: Add properties to use pwm-fan device as a cooling device in Od
@ 2015-02-26 13:59     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-26 13:59 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

With those bindings it is possible to use pwm-fan device available in
Odroid U3 as a cooling device.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
Acked-by: Eduardo Valentin <edubezval@gmail.com>
---
Changes for v2:
- Rename cooling-pwm-values property to cooling-levels
Changes for v3:
- Change patch's topic to "ARM dts"
- Reduce maximal cooling-level to 230 from 255
Changes for v4:
- None
Changes for v5:
- None
Changes for v6:
- None
---
 arch/arm/boot/dts/exynos4412-odroidu3.dts | 33 ++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
index 4c04837..abcfa3c 100644
--- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
+++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
@@ -32,9 +32,40 @@
 		};
 	};
 
-	pwm-fan {
+	fan0: pwm-fan {
 		compatible = "pwm-fan";
 		pwms = <&pwm 0 10000 0>;
+		cooling-min-state = <0>;
+		cooling-max-state = <3>;
+		#cooling-cells = <2>;
+		cooling-levels = <0 102 170 230>;
+	};
+
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				     trip = <&cpu_alert1>;
+				     cooling-device = <&cpu0 7 7>;
+				};
+				map1 {
+				     trip = <&cpu_alert2>;
+				     cooling-device = <&cpu0 13 13>;
+				};
+				map2 {
+				     trip = <&cpu_alert0>;
+				     cooling-device = <&fan0 0 1>;
+				};
+				map3 {
+				     trip = <&cpu_alert1>;
+				     cooling-device = <&fan0 1 2>;
+				};
+				map4 {
+				     trip = <&cpu_alert2>;
+				     cooling-device = <&fan0 2 3>;
+				};
+			};
+		};
 	};
 };
 
-- 
2.0.0.rc2


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v6 4/6] hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty cycle
  2015-02-26 13:59   ` Lukasz Majewski
  (?)
@ 2015-02-26 13:59     ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-26 13:59 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

It was necessary to decouple code handling writing to sysfs from the one
responsible for setting PWM of the fan.
Due to that, new __set_pwm() method was extracted, which is responsible for
only setting new PWM duty cycle.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- The commit headline has been reedited.
Changes for v4:
- Protect "if (ctx->pwm_value == pwm)" with ctx lock
- Initialize ret with zero
Changes for v5:
- None
Changes for v6:
- None
---
 drivers/hwmon/pwm-fan.c | 33 +++++++++++++++++++++------------
 1 file changed, 21 insertions(+), 12 deletions(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index 1991d903..bd42d39 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -33,20 +33,14 @@ struct pwm_fan_ctx {
 	unsigned char pwm_value;
 };
 
-static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
-		       const char *buf, size_t count)
+static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
 {
-	struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
-	unsigned long pwm, duty;
-	ssize_t ret;
-
-	if (kstrtoul(buf, 10, &pwm) || pwm > MAX_PWM)
-		return -EINVAL;
+	unsigned long duty;
+	int ret = 0;
 
 	mutex_lock(&ctx->lock);
-
 	if (ctx->pwm_value == pwm)
-		goto exit_set_pwm_no_change;
+		goto exit_set_pwm_err;
 
 	if (pwm == 0) {
 		pwm_disable(ctx->pwm);
@@ -66,13 +60,28 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 
 exit_set_pwm:
 	ctx->pwm_value = pwm;
-exit_set_pwm_no_change:
-	ret = count;
 exit_set_pwm_err:
 	mutex_unlock(&ctx->lock);
 	return ret;
 }
 
+static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
+		       const char *buf, size_t count)
+{
+	struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
+	unsigned long pwm;
+	int ret;
+
+	if (kstrtoul(buf, 10, &pwm) || pwm > MAX_PWM)
+		return -EINVAL;
+
+	ret = __set_pwm(ctx, pwm);
+	if (ret)
+		return ret;
+
+	return count;
+}
+
 static ssize_t show_pwm(struct device *dev,
 			struct device_attribute *attr, char *buf)
 {
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v6 4/6] hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty cycle
@ 2015-02-26 13:59     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-26 13:59 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

It was necessary to decouple code handling writing to sysfs from the one
responsible for setting PWM of the fan.
Due to that, new __set_pwm() method was extracted, which is responsible for
only setting new PWM duty cycle.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- The commit headline has been reedited.
Changes for v4:
- Protect "if (ctx->pwm_value == pwm)" with ctx lock
- Initialize ret with zero
Changes for v5:
- None
Changes for v6:
- None
---
 drivers/hwmon/pwm-fan.c | 33 +++++++++++++++++++++------------
 1 file changed, 21 insertions(+), 12 deletions(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index 1991d903..bd42d39 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -33,20 +33,14 @@ struct pwm_fan_ctx {
 	unsigned char pwm_value;
 };
 
-static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
-		       const char *buf, size_t count)
+static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
 {
-	struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
-	unsigned long pwm, duty;
-	ssize_t ret;
-
-	if (kstrtoul(buf, 10, &pwm) || pwm > MAX_PWM)
-		return -EINVAL;
+	unsigned long duty;
+	int ret = 0;
 
 	mutex_lock(&ctx->lock);
-
 	if (ctx->pwm_value == pwm)
-		goto exit_set_pwm_no_change;
+		goto exit_set_pwm_err;
 
 	if (pwm == 0) {
 		pwm_disable(ctx->pwm);
@@ -66,13 +60,28 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 
 exit_set_pwm:
 	ctx->pwm_value = pwm;
-exit_set_pwm_no_change:
-	ret = count;
 exit_set_pwm_err:
 	mutex_unlock(&ctx->lock);
 	return ret;
 }
 
+static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
+		       const char *buf, size_t count)
+{
+	struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
+	unsigned long pwm;
+	int ret;
+
+	if (kstrtoul(buf, 10, &pwm) || pwm > MAX_PWM)
+		return -EINVAL;
+
+	ret = __set_pwm(ctx, pwm);
+	if (ret)
+		return ret;
+
+	return count;
+}
+
 static ssize_t show_pwm(struct device *dev,
 			struct device_attribute *attr, char *buf)
 {
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [lm-sensors] [PATCH v6 4/6] hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty cyc
@ 2015-02-26 13:59     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-26 13:59 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

It was necessary to decouple code handling writing to sysfs from the one
responsible for setting PWM of the fan.
Due to that, new __set_pwm() method was extracted, which is responsible for
only setting new PWM duty cycle.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- The commit headline has been reedited.
Changes for v4:
- Protect "if (ctx->pwm_value = pwm)" with ctx lock
- Initialize ret with zero
Changes for v5:
- None
Changes for v6:
- None
---
 drivers/hwmon/pwm-fan.c | 33 +++++++++++++++++++++------------
 1 file changed, 21 insertions(+), 12 deletions(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index 1991d903..bd42d39 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -33,20 +33,14 @@ struct pwm_fan_ctx {
 	unsigned char pwm_value;
 };
 
-static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
-		       const char *buf, size_t count)
+static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
 {
-	struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
-	unsigned long pwm, duty;
-	ssize_t ret;
-
-	if (kstrtoul(buf, 10, &pwm) || pwm > MAX_PWM)
-		return -EINVAL;
+	unsigned long duty;
+	int ret = 0;
 
 	mutex_lock(&ctx->lock);
-
 	if (ctx->pwm_value = pwm)
-		goto exit_set_pwm_no_change;
+		goto exit_set_pwm_err;
 
 	if (pwm = 0) {
 		pwm_disable(ctx->pwm);
@@ -66,13 +60,28 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 
 exit_set_pwm:
 	ctx->pwm_value = pwm;
-exit_set_pwm_no_change:
-	ret = count;
 exit_set_pwm_err:
 	mutex_unlock(&ctx->lock);
 	return ret;
 }
 
+static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
+		       const char *buf, size_t count)
+{
+	struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
+	unsigned long pwm;
+	int ret;
+
+	if (kstrtoul(buf, 10, &pwm) || pwm > MAX_PWM)
+		return -EINVAL;
+
+	ret = __set_pwm(ctx, pwm);
+	if (ret)
+		return ret;
+
+	return count;
+}
+
 static ssize_t show_pwm(struct device *dev,
 			struct device_attribute *attr, char *buf)
 {
-- 
2.0.0.rc2


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v6 5/6] hwmon: pwm-fan: Read PWM FAN configuration from device tree
  2015-02-26 13:59   ` Lukasz Majewski
  (?)
@ 2015-02-26 13:59     ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-26 13:59 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

This patch provides code for reading PWM FAN configuration data via
device tree. The pwm-fan can work with full speed when configuration
is not provided. However, errors are propagated when wrong DT bindings
are found.
Additionally the struct pwm_fan_ctx has been extended.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Rename pwm_fan_max_states to pwm_fan_cooling_levels
- Moving pwm_fan_of_get_cooling_data() call after setting end enabling PWM FAN
- pwm_fan_of_get_cooling_data() now can fail - preserving old behaviour
- Remove unnecessary dev_err() call
Changes for v3:
- Patch's headline has been reedited
- pwm_fan_of_get_cooling_data() return code is now being checked.
- of_property_count_elems_of_size() is now used instead of_find_property()
- More verbose patch description added
Changes for v4:
- dev_err() has been removed from pwm_fan_of_get_cooling_data()
- Returning -EINVAL when "cooling-levels" are defined in DT, but doesn't
  have the value
Changes for v5:
- Use of of_find_property() to assess if "cooling-levels" was defined in
  device tree
- Replace of_property_count_elems_of_size() with of_property_count_u32_elems()
- Remove ambiguity with returning error code from of_property_count_u32_elems()
- Return -EINVAL when "cooling-levels" has zero elements
Changes for v6:
- None
---
 drivers/hwmon/pwm-fan.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 49 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index bd42d39..e6ed353 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -30,7 +30,10 @@
 struct pwm_fan_ctx {
 	struct mutex lock;
 	struct pwm_device *pwm;
-	unsigned char pwm_value;
+	unsigned int pwm_value;
+	unsigned int pwm_fan_state;
+	unsigned int pwm_fan_max_state;
+	unsigned int *pwm_fan_cooling_levels;
 };
 
 static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
@@ -100,6 +103,46 @@ static struct attribute *pwm_fan_attrs[] = {
 
 ATTRIBUTE_GROUPS(pwm_fan);
 
+int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
+{
+	struct device_node *np = dev->of_node;
+	int num, i, ret;
+
+	if (!of_find_property(np, "cooling-levels", NULL))
+		return 0;
+
+	ret = of_property_count_u32_elems(np, "cooling-levels");
+	if (ret <= 0) {
+		dev_err(dev, "Wrong data!\n");
+		return ret ? : -EINVAL;
+	}
+
+	num = ret;
+	ctx->pwm_fan_cooling_levels = devm_kzalloc(dev, num * sizeof(u32),
+						   GFP_KERNEL);
+	if (!ctx->pwm_fan_cooling_levels)
+		return -ENOMEM;
+
+	ret = of_property_read_u32_array(np, "cooling-levels",
+					 ctx->pwm_fan_cooling_levels, num);
+	if (ret) {
+		dev_err(dev, "Property 'cooling-levels' cannot be read!\n");
+		return ret;
+	}
+
+	for (i = 0; i < num; i++) {
+		if (ctx->pwm_fan_cooling_levels[i] > MAX_PWM) {
+			dev_err(dev, "PWM fan state[%d]:%d > %d\n", i,
+				ctx->pwm_fan_cooling_levels[i], MAX_PWM);
+			return -EINVAL;
+		}
+	}
+
+	ctx->pwm_fan_max_state = num - 1;
+
+	return 0;
+}
+
 static int pwm_fan_probe(struct platform_device *pdev)
 {
 	struct device *hwmon;
@@ -145,6 +188,11 @@ static int pwm_fan_probe(struct platform_device *pdev)
 		pwm_disable(ctx->pwm);
 		return PTR_ERR(hwmon);
 	}
+
+	ret = pwm_fan_of_get_cooling_data(&pdev->dev, ctx);
+	if (ret)
+		return ret;
+
 	return 0;
 }
 
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v6 5/6] hwmon: pwm-fan: Read PWM FAN configuration from device tree
@ 2015-02-26 13:59     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-26 13:59 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

This patch provides code for reading PWM FAN configuration data via
device tree. The pwm-fan can work with full speed when configuration
is not provided. However, errors are propagated when wrong DT bindings
are found.
Additionally the struct pwm_fan_ctx has been extended.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Rename pwm_fan_max_states to pwm_fan_cooling_levels
- Moving pwm_fan_of_get_cooling_data() call after setting end enabling PWM FAN
- pwm_fan_of_get_cooling_data() now can fail - preserving old behaviour
- Remove unnecessary dev_err() call
Changes for v3:
- Patch's headline has been reedited
- pwm_fan_of_get_cooling_data() return code is now being checked.
- of_property_count_elems_of_size() is now used instead of_find_property()
- More verbose patch description added
Changes for v4:
- dev_err() has been removed from pwm_fan_of_get_cooling_data()
- Returning -EINVAL when "cooling-levels" are defined in DT, but doesn't
  have the value
Changes for v5:
- Use of of_find_property() to assess if "cooling-levels" was defined in
  device tree
- Replace of_property_count_elems_of_size() with of_property_count_u32_elems()
- Remove ambiguity with returning error code from of_property_count_u32_elems()
- Return -EINVAL when "cooling-levels" has zero elements
Changes for v6:
- None
---
 drivers/hwmon/pwm-fan.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 49 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index bd42d39..e6ed353 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -30,7 +30,10 @@
 struct pwm_fan_ctx {
 	struct mutex lock;
 	struct pwm_device *pwm;
-	unsigned char pwm_value;
+	unsigned int pwm_value;
+	unsigned int pwm_fan_state;
+	unsigned int pwm_fan_max_state;
+	unsigned int *pwm_fan_cooling_levels;
 };
 
 static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
@@ -100,6 +103,46 @@ static struct attribute *pwm_fan_attrs[] = {
 
 ATTRIBUTE_GROUPS(pwm_fan);
 
+int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
+{
+	struct device_node *np = dev->of_node;
+	int num, i, ret;
+
+	if (!of_find_property(np, "cooling-levels", NULL))
+		return 0;
+
+	ret = of_property_count_u32_elems(np, "cooling-levels");
+	if (ret <= 0) {
+		dev_err(dev, "Wrong data!\n");
+		return ret ? : -EINVAL;
+	}
+
+	num = ret;
+	ctx->pwm_fan_cooling_levels = devm_kzalloc(dev, num * sizeof(u32),
+						   GFP_KERNEL);
+	if (!ctx->pwm_fan_cooling_levels)
+		return -ENOMEM;
+
+	ret = of_property_read_u32_array(np, "cooling-levels",
+					 ctx->pwm_fan_cooling_levels, num);
+	if (ret) {
+		dev_err(dev, "Property 'cooling-levels' cannot be read!\n");
+		return ret;
+	}
+
+	for (i = 0; i < num; i++) {
+		if (ctx->pwm_fan_cooling_levels[i] > MAX_PWM) {
+			dev_err(dev, "PWM fan state[%d]:%d > %d\n", i,
+				ctx->pwm_fan_cooling_levels[i], MAX_PWM);
+			return -EINVAL;
+		}
+	}
+
+	ctx->pwm_fan_max_state = num - 1;
+
+	return 0;
+}
+
 static int pwm_fan_probe(struct platform_device *pdev)
 {
 	struct device *hwmon;
@@ -145,6 +188,11 @@ static int pwm_fan_probe(struct platform_device *pdev)
 		pwm_disable(ctx->pwm);
 		return PTR_ERR(hwmon);
 	}
+
+	ret = pwm_fan_of_get_cooling_data(&pdev->dev, ctx);
+	if (ret)
+		return ret;
+
 	return 0;
 }
 
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [lm-sensors] [PATCH v6 5/6] hwmon: pwm-fan: Read PWM FAN configuration from device tree
@ 2015-02-26 13:59     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-26 13:59 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

This patch provides code for reading PWM FAN configuration data via
device tree. The pwm-fan can work with full speed when configuration
is not provided. However, errors are propagated when wrong DT bindings
are found.
Additionally the struct pwm_fan_ctx has been extended.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Rename pwm_fan_max_states to pwm_fan_cooling_levels
- Moving pwm_fan_of_get_cooling_data() call after setting end enabling PWM FAN
- pwm_fan_of_get_cooling_data() now can fail - preserving old behaviour
- Remove unnecessary dev_err() call
Changes for v3:
- Patch's headline has been reedited
- pwm_fan_of_get_cooling_data() return code is now being checked.
- of_property_count_elems_of_size() is now used instead of_find_property()
- More verbose patch description added
Changes for v4:
- dev_err() has been removed from pwm_fan_of_get_cooling_data()
- Returning -EINVAL when "cooling-levels" are defined in DT, but doesn't
  have the value
Changes for v5:
- Use of of_find_property() to assess if "cooling-levels" was defined in
  device tree
- Replace of_property_count_elems_of_size() with of_property_count_u32_elems()
- Remove ambiguity with returning error code from of_property_count_u32_elems()
- Return -EINVAL when "cooling-levels" has zero elements
Changes for v6:
- None
---
 drivers/hwmon/pwm-fan.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 49 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index bd42d39..e6ed353 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -30,7 +30,10 @@
 struct pwm_fan_ctx {
 	struct mutex lock;
 	struct pwm_device *pwm;
-	unsigned char pwm_value;
+	unsigned int pwm_value;
+	unsigned int pwm_fan_state;
+	unsigned int pwm_fan_max_state;
+	unsigned int *pwm_fan_cooling_levels;
 };
 
 static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
@@ -100,6 +103,46 @@ static struct attribute *pwm_fan_attrs[] = {
 
 ATTRIBUTE_GROUPS(pwm_fan);
 
+int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
+{
+	struct device_node *np = dev->of_node;
+	int num, i, ret;
+
+	if (!of_find_property(np, "cooling-levels", NULL))
+		return 0;
+
+	ret = of_property_count_u32_elems(np, "cooling-levels");
+	if (ret <= 0) {
+		dev_err(dev, "Wrong data!\n");
+		return ret ? : -EINVAL;
+	}
+
+	num = ret;
+	ctx->pwm_fan_cooling_levels = devm_kzalloc(dev, num * sizeof(u32),
+						   GFP_KERNEL);
+	if (!ctx->pwm_fan_cooling_levels)
+		return -ENOMEM;
+
+	ret = of_property_read_u32_array(np, "cooling-levels",
+					 ctx->pwm_fan_cooling_levels, num);
+	if (ret) {
+		dev_err(dev, "Property 'cooling-levels' cannot be read!\n");
+		return ret;
+	}
+
+	for (i = 0; i < num; i++) {
+		if (ctx->pwm_fan_cooling_levels[i] > MAX_PWM) {
+			dev_err(dev, "PWM fan state[%d]:%d > %d\n", i,
+				ctx->pwm_fan_cooling_levels[i], MAX_PWM);
+			return -EINVAL;
+		}
+	}
+
+	ctx->pwm_fan_max_state = num - 1;
+
+	return 0;
+}
+
 static int pwm_fan_probe(struct platform_device *pdev)
 {
 	struct device *hwmon;
@@ -145,6 +188,11 @@ static int pwm_fan_probe(struct platform_device *pdev)
 		pwm_disable(ctx->pwm);
 		return PTR_ERR(hwmon);
 	}
+
+	ret = pwm_fan_of_get_cooling_data(&pdev->dev, ctx);
+	if (ret)
+		return ret;
+
 	return 0;
 }
 
-- 
2.0.0.rc2


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v6 6/6] hwmon: pwm-fan: Code for using PWM FAN as a cooling device
  2015-02-26 13:59   ` Lukasz Majewski
  (?)
@ 2015-02-26 13:59     ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-26 13:59 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

The PWM FAN device can now be used as a thermal cooling device. Necessary
infrastructure has been added in this commit.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
Acked-by: Eduardo Valentin <edubezval@gmail.com>
---
Changes for v2:
- Replace pwm_fan_cooling_states with pwm_fan_cooling_levels
- Update ctx->pwm_fan_state when correct data from device tree is available
- Using therma_cdev_update() when thermal is ready for controlling the fan
Changes for v3:
- Rename patch heading
- pwm_fan_of_get_cooling_data() now returns -EINVAL when no "cooling-levels"
  property defined
- register of cooling device only when proper cooling data is present
Changes for v4:
- None
Changes for v5:
- Check for IS_ENABLED(CONFIG_THERMAL) has been added to prevent from
  executing thermal_* specific functions
Changes for v6:
- Adding missing ctx == NULL check in pwm_fan_get_max_state()
- Call to thermal_cooling_device_unregister(ctx->cdev); at pwm_fan_remove()
- struct thermal_cooling_device *cdev; added to struct pwm_fan_ctx
---
 drivers/hwmon/pwm-fan.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 88 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index e6ed353..7c83dc4 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -24,6 +24,7 @@
 #include <linux/platform_device.h>
 #include <linux/pwm.h>
 #include <linux/sysfs.h>
+#include <linux/thermal.h>
 
 #define MAX_PWM 255
 
@@ -34,6 +35,7 @@ struct pwm_fan_ctx {
 	unsigned int pwm_fan_state;
 	unsigned int pwm_fan_max_state;
 	unsigned int *pwm_fan_cooling_levels;
+	struct thermal_cooling_device *cdev;
 };
 
 static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
@@ -68,6 +70,17 @@ exit_set_pwm_err:
 	return ret;
 }
 
+static void pwm_fan_update_state(struct pwm_fan_ctx *ctx, unsigned long pwm)
+{
+	int i;
+
+	for (i = 0; i < ctx->pwm_fan_max_state; ++i)
+		if (pwm < ctx->pwm_fan_cooling_levels[i + 1])
+			break;
+
+	ctx->pwm_fan_state = i;
+}
+
 static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 		       const char *buf, size_t count)
 {
@@ -82,6 +95,7 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 	if (ret)
 		return ret;
 
+	pwm_fan_update_state(ctx, pwm);
 	return count;
 }
 
@@ -103,6 +117,62 @@ static struct attribute *pwm_fan_attrs[] = {
 
 ATTRIBUTE_GROUPS(pwm_fan);
 
+/* thermal cooling device callbacks */
+static int pwm_fan_get_max_state(struct thermal_cooling_device *cdev,
+				 unsigned long *state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+
+	if (!ctx)
+		return -EINVAL;
+
+	*state = ctx->pwm_fan_max_state;
+
+	return 0;
+}
+
+static int pwm_fan_get_cur_state(struct thermal_cooling_device *cdev,
+				 unsigned long *state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+
+	if (!ctx)
+		return -EINVAL;
+
+	*state = ctx->pwm_fan_state;
+
+	return 0;
+}
+
+static int
+pwm_fan_set_cur_state(struct thermal_cooling_device *cdev, unsigned long state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+	int ret;
+
+	if (!ctx || (state > ctx->pwm_fan_max_state))
+		return -EINVAL;
+
+	if (state == ctx->pwm_fan_state)
+		return 0;
+
+	ret = __set_pwm(ctx, ctx->pwm_fan_cooling_levels[state]);
+	if (ret) {
+		dev_err(&cdev->device, "Cannot set pwm!\n");
+		return ret;
+	}
+
+	ctx->pwm_fan_state = state;
+
+	return ret;
+}
+
+static const struct thermal_cooling_device_ops pwm_fan_cooling_ops = {
+	.get_max_state = pwm_fan_get_max_state,
+	.get_cur_state = pwm_fan_get_cur_state,
+	.set_cur_state = pwm_fan_set_cur_state,
+};
+
 int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
 {
 	struct device_node *np = dev->of_node;
@@ -145,8 +215,9 @@ int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
 
 static int pwm_fan_probe(struct platform_device *pdev)
 {
-	struct device *hwmon;
+	struct thermal_cooling_device *cdev;
 	struct pwm_fan_ctx *ctx;
+	struct device *hwmon;
 	int duty_cycle;
 	int ret;
 
@@ -193,6 +264,21 @@ static int pwm_fan_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
+	ctx->pwm_fan_state = ctx->pwm_fan_max_state;
+	if (IS_ENABLED(CONFIG_THERMAL)) {
+		cdev = thermal_of_cooling_device_register(pdev->dev.of_node,
+							  "pwm-fan", ctx,
+							  &pwm_fan_cooling_ops);
+		if (IS_ERR(cdev)) {
+			dev_err(&pdev->dev,
+				"Failed to register pwm-fan as cooling device");
+			pwm_disable(ctx->pwm);
+			return PTR_ERR(cdev);
+		}
+		ctx->cdev = cdev;
+		thermal_cdev_update(cdev);
+	}
+
 	return 0;
 }
 
@@ -200,6 +286,7 @@ static int pwm_fan_remove(struct platform_device *pdev)
 {
 	struct pwm_fan_ctx *ctx = platform_get_drvdata(pdev);
 
+	thermal_cooling_device_unregister(ctx->cdev);
 	if (ctx->pwm_value)
 		pwm_disable(ctx->pwm);
 	return 0;
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH v6 6/6] hwmon: pwm-fan: Code for using PWM FAN as a cooling device
@ 2015-02-26 13:59     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-26 13:59 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

The PWM FAN device can now be used as a thermal cooling device. Necessary
infrastructure has been added in this commit.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
Acked-by: Eduardo Valentin <edubezval@gmail.com>
---
Changes for v2:
- Replace pwm_fan_cooling_states with pwm_fan_cooling_levels
- Update ctx->pwm_fan_state when correct data from device tree is available
- Using therma_cdev_update() when thermal is ready for controlling the fan
Changes for v3:
- Rename patch heading
- pwm_fan_of_get_cooling_data() now returns -EINVAL when no "cooling-levels"
  property defined
- register of cooling device only when proper cooling data is present
Changes for v4:
- None
Changes for v5:
- Check for IS_ENABLED(CONFIG_THERMAL) has been added to prevent from
  executing thermal_* specific functions
Changes for v6:
- Adding missing ctx == NULL check in pwm_fan_get_max_state()
- Call to thermal_cooling_device_unregister(ctx->cdev); at pwm_fan_remove()
- struct thermal_cooling_device *cdev; added to struct pwm_fan_ctx
---
 drivers/hwmon/pwm-fan.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 88 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index e6ed353..7c83dc4 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -24,6 +24,7 @@
 #include <linux/platform_device.h>
 #include <linux/pwm.h>
 #include <linux/sysfs.h>
+#include <linux/thermal.h>
 
 #define MAX_PWM 255
 
@@ -34,6 +35,7 @@ struct pwm_fan_ctx {
 	unsigned int pwm_fan_state;
 	unsigned int pwm_fan_max_state;
 	unsigned int *pwm_fan_cooling_levels;
+	struct thermal_cooling_device *cdev;
 };
 
 static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
@@ -68,6 +70,17 @@ exit_set_pwm_err:
 	return ret;
 }
 
+static void pwm_fan_update_state(struct pwm_fan_ctx *ctx, unsigned long pwm)
+{
+	int i;
+
+	for (i = 0; i < ctx->pwm_fan_max_state; ++i)
+		if (pwm < ctx->pwm_fan_cooling_levels[i + 1])
+			break;
+
+	ctx->pwm_fan_state = i;
+}
+
 static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 		       const char *buf, size_t count)
 {
@@ -82,6 +95,7 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 	if (ret)
 		return ret;
 
+	pwm_fan_update_state(ctx, pwm);
 	return count;
 }
 
@@ -103,6 +117,62 @@ static struct attribute *pwm_fan_attrs[] = {
 
 ATTRIBUTE_GROUPS(pwm_fan);
 
+/* thermal cooling device callbacks */
+static int pwm_fan_get_max_state(struct thermal_cooling_device *cdev,
+				 unsigned long *state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+
+	if (!ctx)
+		return -EINVAL;
+
+	*state = ctx->pwm_fan_max_state;
+
+	return 0;
+}
+
+static int pwm_fan_get_cur_state(struct thermal_cooling_device *cdev,
+				 unsigned long *state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+
+	if (!ctx)
+		return -EINVAL;
+
+	*state = ctx->pwm_fan_state;
+
+	return 0;
+}
+
+static int
+pwm_fan_set_cur_state(struct thermal_cooling_device *cdev, unsigned long state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+	int ret;
+
+	if (!ctx || (state > ctx->pwm_fan_max_state))
+		return -EINVAL;
+
+	if (state == ctx->pwm_fan_state)
+		return 0;
+
+	ret = __set_pwm(ctx, ctx->pwm_fan_cooling_levels[state]);
+	if (ret) {
+		dev_err(&cdev->device, "Cannot set pwm!\n");
+		return ret;
+	}
+
+	ctx->pwm_fan_state = state;
+
+	return ret;
+}
+
+static const struct thermal_cooling_device_ops pwm_fan_cooling_ops = {
+	.get_max_state = pwm_fan_get_max_state,
+	.get_cur_state = pwm_fan_get_cur_state,
+	.set_cur_state = pwm_fan_set_cur_state,
+};
+
 int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
 {
 	struct device_node *np = dev->of_node;
@@ -145,8 +215,9 @@ int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
 
 static int pwm_fan_probe(struct platform_device *pdev)
 {
-	struct device *hwmon;
+	struct thermal_cooling_device *cdev;
 	struct pwm_fan_ctx *ctx;
+	struct device *hwmon;
 	int duty_cycle;
 	int ret;
 
@@ -193,6 +264,21 @@ static int pwm_fan_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
+	ctx->pwm_fan_state = ctx->pwm_fan_max_state;
+	if (IS_ENABLED(CONFIG_THERMAL)) {
+		cdev = thermal_of_cooling_device_register(pdev->dev.of_node,
+							  "pwm-fan", ctx,
+							  &pwm_fan_cooling_ops);
+		if (IS_ERR(cdev)) {
+			dev_err(&pdev->dev,
+				"Failed to register pwm-fan as cooling device");
+			pwm_disable(ctx->pwm);
+			return PTR_ERR(cdev);
+		}
+		ctx->cdev = cdev;
+		thermal_cdev_update(cdev);
+	}
+
 	return 0;
 }
 
@@ -200,6 +286,7 @@ static int pwm_fan_remove(struct platform_device *pdev)
 {
 	struct pwm_fan_ctx *ctx = platform_get_drvdata(pdev);
 
+	thermal_cooling_device_unregister(ctx->cdev);
 	if (ctx->pwm_value)
 		pwm_disable(ctx->pwm);
 	return 0;
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [lm-sensors] [PATCH v6 6/6] hwmon: pwm-fan: Code for using PWM FAN as a cooling device
@ 2015-02-26 13:59     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-26 13:59 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

The PWM FAN device can now be used as a thermal cooling device. Necessary
infrastructure has been added in this commit.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
Acked-by: Eduardo Valentin <edubezval@gmail.com>
---
Changes for v2:
- Replace pwm_fan_cooling_states with pwm_fan_cooling_levels
- Update ctx->pwm_fan_state when correct data from device tree is available
- Using therma_cdev_update() when thermal is ready for controlling the fan
Changes for v3:
- Rename patch heading
- pwm_fan_of_get_cooling_data() now returns -EINVAL when no "cooling-levels"
  property defined
- register of cooling device only when proper cooling data is present
Changes for v4:
- None
Changes for v5:
- Check for IS_ENABLED(CONFIG_THERMAL) has been added to prevent from
  executing thermal_* specific functions
Changes for v6:
- Adding missing ctx = NULL check in pwm_fan_get_max_state()
- Call to thermal_cooling_device_unregister(ctx->cdev); at pwm_fan_remove()
- struct thermal_cooling_device *cdev; added to struct pwm_fan_ctx
---
 drivers/hwmon/pwm-fan.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 88 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index e6ed353..7c83dc4 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -24,6 +24,7 @@
 #include <linux/platform_device.h>
 #include <linux/pwm.h>
 #include <linux/sysfs.h>
+#include <linux/thermal.h>
 
 #define MAX_PWM 255
 
@@ -34,6 +35,7 @@ struct pwm_fan_ctx {
 	unsigned int pwm_fan_state;
 	unsigned int pwm_fan_max_state;
 	unsigned int *pwm_fan_cooling_levels;
+	struct thermal_cooling_device *cdev;
 };
 
 static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
@@ -68,6 +70,17 @@ exit_set_pwm_err:
 	return ret;
 }
 
+static void pwm_fan_update_state(struct pwm_fan_ctx *ctx, unsigned long pwm)
+{
+	int i;
+
+	for (i = 0; i < ctx->pwm_fan_max_state; ++i)
+		if (pwm < ctx->pwm_fan_cooling_levels[i + 1])
+			break;
+
+	ctx->pwm_fan_state = i;
+}
+
 static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 		       const char *buf, size_t count)
 {
@@ -82,6 +95,7 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 	if (ret)
 		return ret;
 
+	pwm_fan_update_state(ctx, pwm);
 	return count;
 }
 
@@ -103,6 +117,62 @@ static struct attribute *pwm_fan_attrs[] = {
 
 ATTRIBUTE_GROUPS(pwm_fan);
 
+/* thermal cooling device callbacks */
+static int pwm_fan_get_max_state(struct thermal_cooling_device *cdev,
+				 unsigned long *state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+
+	if (!ctx)
+		return -EINVAL;
+
+	*state = ctx->pwm_fan_max_state;
+
+	return 0;
+}
+
+static int pwm_fan_get_cur_state(struct thermal_cooling_device *cdev,
+				 unsigned long *state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+
+	if (!ctx)
+		return -EINVAL;
+
+	*state = ctx->pwm_fan_state;
+
+	return 0;
+}
+
+static int
+pwm_fan_set_cur_state(struct thermal_cooling_device *cdev, unsigned long state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+	int ret;
+
+	if (!ctx || (state > ctx->pwm_fan_max_state))
+		return -EINVAL;
+
+	if (state = ctx->pwm_fan_state)
+		return 0;
+
+	ret = __set_pwm(ctx, ctx->pwm_fan_cooling_levels[state]);
+	if (ret) {
+		dev_err(&cdev->device, "Cannot set pwm!\n");
+		return ret;
+	}
+
+	ctx->pwm_fan_state = state;
+
+	return ret;
+}
+
+static const struct thermal_cooling_device_ops pwm_fan_cooling_ops = {
+	.get_max_state = pwm_fan_get_max_state,
+	.get_cur_state = pwm_fan_get_cur_state,
+	.set_cur_state = pwm_fan_set_cur_state,
+};
+
 int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
 {
 	struct device_node *np = dev->of_node;
@@ -145,8 +215,9 @@ int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
 
 static int pwm_fan_probe(struct platform_device *pdev)
 {
-	struct device *hwmon;
+	struct thermal_cooling_device *cdev;
 	struct pwm_fan_ctx *ctx;
+	struct device *hwmon;
 	int duty_cycle;
 	int ret;
 
@@ -193,6 +264,21 @@ static int pwm_fan_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
+	ctx->pwm_fan_state = ctx->pwm_fan_max_state;
+	if (IS_ENABLED(CONFIG_THERMAL)) {
+		cdev = thermal_of_cooling_device_register(pdev->dev.of_node,
+							  "pwm-fan", ctx,
+							  &pwm_fan_cooling_ops);
+		if (IS_ERR(cdev)) {
+			dev_err(&pdev->dev,
+				"Failed to register pwm-fan as cooling device");
+			pwm_disable(ctx->pwm);
+			return PTR_ERR(cdev);
+		}
+		ctx->cdev = cdev;
+		thermal_cdev_update(cdev);
+	}
+
 	return 0;
 }
 
@@ -200,6 +286,7 @@ static int pwm_fan_remove(struct platform_device *pdev)
 {
 	struct pwm_fan_ctx *ctx = platform_get_drvdata(pdev);
 
+	thermal_cooling_device_unregister(ctx->cdev);
 	if (ctx->pwm_value)
 		pwm_disable(ctx->pwm);
 	return 0;
-- 
2.0.0.rc2


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* Re: [PATCH v6 6/6] hwmon: pwm-fan: Code for using PWM FAN as a cooling device
  2015-02-26 13:59     ` Lukasz Majewski
  (?)
@ 2015-02-26 14:12       ` Guenter Roeck
  -1 siblings, 0 replies; 329+ messages in thread
From: Guenter Roeck @ 2015-02-26 14:12 UTC (permalink / raw)
  To: Lukasz Majewski, Eduardo Valentin, Kamil Debski, Jean Delvare,
	Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

On 02/26/2015 05:59 AM, Lukasz Majewski wrote:
> The PWM FAN device can now be used as a thermal cooling device. Necessary
> infrastructure has been added in this commit.
>
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> Acked-by: Eduardo Valentin <edubezval@gmail.com>
> ---
> Changes for v2:
> - Replace pwm_fan_cooling_states with pwm_fan_cooling_levels
> - Update ctx->pwm_fan_state when correct data from device tree is available
> - Using therma_cdev_update() when thermal is ready for controlling the fan
> Changes for v3:
> - Rename patch heading
> - pwm_fan_of_get_cooling_data() now returns -EINVAL when no "cooling-levels"
>    property defined
> - register of cooling device only when proper cooling data is present
> Changes for v4:
> - None
> Changes for v5:
> - Check for IS_ENABLED(CONFIG_THERMAL) has been added to prevent from
>    executing thermal_* specific functions
> Changes for v6:
> - Adding missing ctx == NULL check in pwm_fan_get_max_state()
> - Call to thermal_cooling_device_unregister(ctx->cdev); at pwm_fan_remove()
> - struct thermal_cooling_device *cdev; added to struct pwm_fan_ctx
> ---
>   drivers/hwmon/pwm-fan.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++++-
>   1 file changed, 88 insertions(+), 1 deletion(-)
[ ... ]
>
> @@ -200,6 +286,7 @@ static int pwm_fan_remove(struct platform_device *pdev)
>   {
>   	struct pwm_fan_ctx *ctx = platform_get_drvdata(pdev);
>
> +	thermal_cooling_device_unregister(ctx->cdev);

Unfortunately there is still no prototype for this if CONFIG_THERMAL
is not configured.

Two options: Yet another revision, or wait a week until the prototypes
are (hopefully) available and submit a patch without the conditionals.

Guenter


^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v6 6/6] hwmon: pwm-fan: Code for using PWM FAN as a cooling device
@ 2015-02-26 14:12       ` Guenter Roeck
  0 siblings, 0 replies; 329+ messages in thread
From: Guenter Roeck @ 2015-02-26 14:12 UTC (permalink / raw)
  To: Lukasz Majewski, Eduardo Valentin, Kamil Debski, Jean Delvare,
	Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

On 02/26/2015 05:59 AM, Lukasz Majewski wrote:
> The PWM FAN device can now be used as a thermal cooling device. Necessary
> infrastructure has been added in this commit.
>
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> Acked-by: Eduardo Valentin <edubezval@gmail.com>
> ---
> Changes for v2:
> - Replace pwm_fan_cooling_states with pwm_fan_cooling_levels
> - Update ctx->pwm_fan_state when correct data from device tree is available
> - Using therma_cdev_update() when thermal is ready for controlling the fan
> Changes for v3:
> - Rename patch heading
> - pwm_fan_of_get_cooling_data() now returns -EINVAL when no "cooling-levels"
>    property defined
> - register of cooling device only when proper cooling data is present
> Changes for v4:
> - None
> Changes for v5:
> - Check for IS_ENABLED(CONFIG_THERMAL) has been added to prevent from
>    executing thermal_* specific functions
> Changes for v6:
> - Adding missing ctx == NULL check in pwm_fan_get_max_state()
> - Call to thermal_cooling_device_unregister(ctx->cdev); at pwm_fan_remove()
> - struct thermal_cooling_device *cdev; added to struct pwm_fan_ctx
> ---
>   drivers/hwmon/pwm-fan.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++++-
>   1 file changed, 88 insertions(+), 1 deletion(-)
[ ... ]
>
> @@ -200,6 +286,7 @@ static int pwm_fan_remove(struct platform_device *pdev)
>   {
>   	struct pwm_fan_ctx *ctx = platform_get_drvdata(pdev);
>
> +	thermal_cooling_device_unregister(ctx->cdev);

Unfortunately there is still no prototype for this if CONFIG_THERMAL
is not configured.

Two options: Yet another revision, or wait a week until the prototypes
are (hopefully) available and submit a patch without the conditionals.

Guenter

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [lm-sensors] [PATCH v6 6/6] hwmon: pwm-fan: Code for using PWM FAN as a cooling device
@ 2015-02-26 14:12       ` Guenter Roeck
  0 siblings, 0 replies; 329+ messages in thread
From: Guenter Roeck @ 2015-02-26 14:12 UTC (permalink / raw)
  To: Lukasz Majewski, Eduardo Valentin, Kamil Debski, Jean Delvare,
	Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

On 02/26/2015 05:59 AM, Lukasz Majewski wrote:
> The PWM FAN device can now be used as a thermal cooling device. Necessary
> infrastructure has been added in this commit.
>
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> Acked-by: Eduardo Valentin <edubezval@gmail.com>
> ---
> Changes for v2:
> - Replace pwm_fan_cooling_states with pwm_fan_cooling_levels
> - Update ctx->pwm_fan_state when correct data from device tree is available
> - Using therma_cdev_update() when thermal is ready for controlling the fan
> Changes for v3:
> - Rename patch heading
> - pwm_fan_of_get_cooling_data() now returns -EINVAL when no "cooling-levels"
>    property defined
> - register of cooling device only when proper cooling data is present
> Changes for v4:
> - None
> Changes for v5:
> - Check for IS_ENABLED(CONFIG_THERMAL) has been added to prevent from
>    executing thermal_* specific functions
> Changes for v6:
> - Adding missing ctx = NULL check in pwm_fan_get_max_state()
> - Call to thermal_cooling_device_unregister(ctx->cdev); at pwm_fan_remove()
> - struct thermal_cooling_device *cdev; added to struct pwm_fan_ctx
> ---
>   drivers/hwmon/pwm-fan.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++++-
>   1 file changed, 88 insertions(+), 1 deletion(-)
[ ... ]
>
> @@ -200,6 +286,7 @@ static int pwm_fan_remove(struct platform_device *pdev)
>   {
>   	struct pwm_fan_ctx *ctx = platform_get_drvdata(pdev);
>
> +	thermal_cooling_device_unregister(ctx->cdev);

Unfortunately there is still no prototype for this if CONFIG_THERMAL
is not configured.

Two options: Yet another revision, or wait a week until the prototypes
are (hopefully) available and submit a patch without the conditionals.

Guenter


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v6 6/6] hwmon: pwm-fan: Code for using PWM FAN as a cooling device
  2015-02-26 14:12       ` Guenter Roeck
  (?)
@ 2015-02-26 14:40         ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-26 14:40 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Eduardo Valentin, Kamil Debski, Jean Delvare, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

Hi Guenter,

> On 02/26/2015 05:59 AM, Lukasz Majewski wrote:
> > The PWM FAN device can now be used as a thermal cooling device.
> > Necessary infrastructure has been added in this commit.
> >
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > Acked-by: Eduardo Valentin <edubezval@gmail.com>
> > ---
> > Changes for v2:
> > - Replace pwm_fan_cooling_states with pwm_fan_cooling_levels
> > - Update ctx->pwm_fan_state when correct data from device tree is
> > available
> > - Using therma_cdev_update() when thermal is ready for controlling
> > the fan Changes for v3:
> > - Rename patch heading
> > - pwm_fan_of_get_cooling_data() now returns -EINVAL when no
> > "cooling-levels" property defined
> > - register of cooling device only when proper cooling data is
> > present Changes for v4:
> > - None
> > Changes for v5:
> > - Check for IS_ENABLED(CONFIG_THERMAL) has been added to prevent
> > from executing thermal_* specific functions
> > Changes for v6:
> > - Adding missing ctx == NULL check in pwm_fan_get_max_state()
> > - Call to thermal_cooling_device_unregister(ctx->cdev); at
> > pwm_fan_remove()
> > - struct thermal_cooling_device *cdev; added to struct pwm_fan_ctx
> > ---
> >   drivers/hwmon/pwm-fan.c | 89
> > ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed,
> > 88 insertions(+), 1 deletion(-)
> [ ... ]
> >
> > @@ -200,6 +286,7 @@ static int pwm_fan_remove(struct
> > platform_device *pdev) {
> >   	struct pwm_fan_ctx *ctx = platform_get_drvdata(pdev);
> >
> > +	thermal_cooling_device_unregister(ctx->cdev);
> 
> Unfortunately there is still no prototype for this if CONFIG_THERMAL
> is not configured.

Yes... since Nishanth Menon's changes are now only in
linux-soc-thermal/fixes

> 
> Two options: Yet another revision, or wait a week until the prototypes
> are (hopefully) available and submit a patch without the conditionals.

No problem, I will wait a bit and resend this patch set.

> 
> Guenter
> 

-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH v6 6/6] hwmon: pwm-fan: Code for using PWM FAN as a cooling device
@ 2015-02-26 14:40         ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-26 14:40 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Eduardo Valentin, Kamil Debski, Jean Delvare, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

Hi Guenter,

> On 02/26/2015 05:59 AM, Lukasz Majewski wrote:
> > The PWM FAN device can now be used as a thermal cooling device.
> > Necessary infrastructure has been added in this commit.
> >
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > Acked-by: Eduardo Valentin <edubezval@gmail.com>
> > ---
> > Changes for v2:
> > - Replace pwm_fan_cooling_states with pwm_fan_cooling_levels
> > - Update ctx->pwm_fan_state when correct data from device tree is
> > available
> > - Using therma_cdev_update() when thermal is ready for controlling
> > the fan Changes for v3:
> > - Rename patch heading
> > - pwm_fan_of_get_cooling_data() now returns -EINVAL when no
> > "cooling-levels" property defined
> > - register of cooling device only when proper cooling data is
> > present Changes for v4:
> > - None
> > Changes for v5:
> > - Check for IS_ENABLED(CONFIG_THERMAL) has been added to prevent
> > from executing thermal_* specific functions
> > Changes for v6:
> > - Adding missing ctx == NULL check in pwm_fan_get_max_state()
> > - Call to thermal_cooling_device_unregister(ctx->cdev); at
> > pwm_fan_remove()
> > - struct thermal_cooling_device *cdev; added to struct pwm_fan_ctx
> > ---
> >   drivers/hwmon/pwm-fan.c | 89
> > ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed,
> > 88 insertions(+), 1 deletion(-)
> [ ... ]
> >
> > @@ -200,6 +286,7 @@ static int pwm_fan_remove(struct
> > platform_device *pdev) {
> >   	struct pwm_fan_ctx *ctx = platform_get_drvdata(pdev);
> >
> > +	thermal_cooling_device_unregister(ctx->cdev);
> 
> Unfortunately there is still no prototype for this if CONFIG_THERMAL
> is not configured.

Yes... since Nishanth Menon's changes are now only in
linux-soc-thermal/fixes

> 
> Two options: Yet another revision, or wait a week until the prototypes
> are (hopefully) available and submit a patch without the conditionals.

No problem, I will wait a bit and resend this patch set.

> 
> Guenter
> 

-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [lm-sensors] [PATCH v6 6/6] hwmon: pwm-fan: Code for using PWM FAN as a cooling device
@ 2015-02-26 14:40         ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-02-26 14:40 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Eduardo Valentin, Kamil Debski, Jean Delvare, Kukjin Kim,
	lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan

Hi Guenter,

> On 02/26/2015 05:59 AM, Lukasz Majewski wrote:
> > The PWM FAN device can now be used as a thermal cooling device.
> > Necessary infrastructure has been added in this commit.
> >
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > Acked-by: Eduardo Valentin <edubezval@gmail.com>
> > ---
> > Changes for v2:
> > - Replace pwm_fan_cooling_states with pwm_fan_cooling_levels
> > - Update ctx->pwm_fan_state when correct data from device tree is
> > available
> > - Using therma_cdev_update() when thermal is ready for controlling
> > the fan Changes for v3:
> > - Rename patch heading
> > - pwm_fan_of_get_cooling_data() now returns -EINVAL when no
> > "cooling-levels" property defined
> > - register of cooling device only when proper cooling data is
> > present Changes for v4:
> > - None
> > Changes for v5:
> > - Check for IS_ENABLED(CONFIG_THERMAL) has been added to prevent
> > from executing thermal_* specific functions
> > Changes for v6:
> > - Adding missing ctx = NULL check in pwm_fan_get_max_state()
> > - Call to thermal_cooling_device_unregister(ctx->cdev); at
> > pwm_fan_remove()
> > - struct thermal_cooling_device *cdev; added to struct pwm_fan_ctx
> > ---
> >   drivers/hwmon/pwm-fan.c | 89
> > ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed,
> > 88 insertions(+), 1 deletion(-)
> [ ... ]
> >
> > @@ -200,6 +286,7 @@ static int pwm_fan_remove(struct
> > platform_device *pdev) {
> >   	struct pwm_fan_ctx *ctx = platform_get_drvdata(pdev);
> >
> > +	thermal_cooling_device_unregister(ctx->cdev);
> 
> Unfortunately there is still no prototype for this if CONFIG_THERMAL
> is not configured.

Yes... since Nishanth Menon's changes are now only in
linux-soc-thermal/fixes

> 
> Two options: Yet another revision, or wait a week until the prototypes
> are (hopefully) available and submit a patch without the conditionals.

No problem, I will wait a bit and resend this patch set.

> 
> Guenter
> 

-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 329+ messages in thread

* [PATCH RESEND RESEND v6 0/6] hwmon: thermal: Odroid U3: Provide support for Odroid U3 fan
  2014-12-18 10:13 ` Lukasz Majewski
  (?)
@ 2015-03-04 12:03   ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-03-04 12:03 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

Presented patches add support for Odroid's U3 optional CPU FAN, which uses PWM
subsystem for low level control.

After successful probe it registers itself as a cooling device for thermal
subsystem.

This driver also supports devices without DTS specified.

To provide correct functionality, new properties to device tree description for
Exynos4412 and in particular Odroid U3 have been added.

Those patches were tested at Exynos4412 - Odroid U3 board.

Patches were applied on:
linux-soc-thermal/fixes branch (Linux v4.0-rc2)
SHA1: ad83a2d87bff355750a17dd00aec563eb9f9d388


Kamil Debski (1):
  ARM: dts: Add pwm-fan node to the Odroid-U3 board

Lukasz Majewski (5):
  Documentation: dts: Documentation entry to explain how to use PWM FAN
    as a cooling device
  ARM: dts: Add properties to use pwm-fan device as a cooling device in
    Odroid U3
  hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty
    cycle
  hwmon: pwm-fan: Read PWM FAN configuration from device tree
  hwmon: pwm-fan: Code for using PWM FAN as a cooling device

 .../devicetree/bindings/hwmon/pwm-fan.txt          |  29 +++-
 arch/arm/boot/dts/exynos4.dtsi                     |   2 +-
 arch/arm/boot/dts/exynos4412-odroidu3.dts          |  43 ++++++
 drivers/hwmon/pwm-fan.c                            | 172 +++++++++++++++++++--
 4 files changed, 229 insertions(+), 17 deletions(-)

-- 
2.0.0.rc2


^ permalink raw reply	[flat|nested] 329+ messages in thread

* [PATCH RESEND RESEND v6 0/6] hwmon: thermal: Odroid U3: Provide support for Odroid U3 fan
@ 2015-03-04 12:03   ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-03-04 12:03 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

Presented patches add support for Odroid's U3 optional CPU FAN, which uses PWM
subsystem for low level control.

After successful probe it registers itself as a cooling device for thermal
subsystem.

This driver also supports devices without DTS specified.

To provide correct functionality, new properties to device tree description for
Exynos4412 and in particular Odroid U3 have been added.

Those patches were tested at Exynos4412 - Odroid U3 board.

Patches were applied on:
linux-soc-thermal/fixes branch (Linux v4.0-rc2)
SHA1: ad83a2d87bff355750a17dd00aec563eb9f9d388


Kamil Debski (1):
  ARM: dts: Add pwm-fan node to the Odroid-U3 board

Lukasz Majewski (5):
  Documentation: dts: Documentation entry to explain how to use PWM FAN
    as a cooling device
  ARM: dts: Add properties to use pwm-fan device as a cooling device in
    Odroid U3
  hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty
    cycle
  hwmon: pwm-fan: Read PWM FAN configuration from device tree
  hwmon: pwm-fan: Code for using PWM FAN as a cooling device

 .../devicetree/bindings/hwmon/pwm-fan.txt          |  29 +++-
 arch/arm/boot/dts/exynos4.dtsi                     |   2 +-
 arch/arm/boot/dts/exynos4412-odroidu3.dts          |  43 ++++++
 drivers/hwmon/pwm-fan.c                            | 172 +++++++++++++++++++--
 4 files changed, 229 insertions(+), 17 deletions(-)

-- 
2.0.0.rc2

^ permalink raw reply	[flat|nested] 329+ messages in thread

* [lm-sensors] [PATCH RESEND RESEND v6 0/6] hwmon: thermal: Odroid U3: Provide support for Odroid U3 f
@ 2015-03-04 12:03   ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-03-04 12:03 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

Presented patches add support for Odroid's U3 optional CPU FAN, which uses PWM
subsystem for low level control.

After successful probe it registers itself as a cooling device for thermal
subsystem.

This driver also supports devices without DTS specified.

To provide correct functionality, new properties to device tree description for
Exynos4412 and in particular Odroid U3 have been added.

Those patches were tested at Exynos4412 - Odroid U3 board.

Patches were applied on:
linux-soc-thermal/fixes branch (Linux v4.0-rc2)
SHA1: ad83a2d87bff355750a17dd00aec563eb9f9d388


Kamil Debski (1):
  ARM: dts: Add pwm-fan node to the Odroid-U3 board

Lukasz Majewski (5):
  Documentation: dts: Documentation entry to explain how to use PWM FAN
    as a cooling device
  ARM: dts: Add properties to use pwm-fan device as a cooling device in
    Odroid U3
  hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty
    cycle
  hwmon: pwm-fan: Read PWM FAN configuration from device tree
  hwmon: pwm-fan: Code for using PWM FAN as a cooling device

 .../devicetree/bindings/hwmon/pwm-fan.txt          |  29 +++-
 arch/arm/boot/dts/exynos4.dtsi                     |   2 +-
 arch/arm/boot/dts/exynos4412-odroidu3.dts          |  43 ++++++
 drivers/hwmon/pwm-fan.c                            | 172 +++++++++++++++++++--
 4 files changed, 229 insertions(+), 17 deletions(-)

-- 
2.0.0.rc2


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 329+ messages in thread

* [PATCH RESEND v6 1/6] Documentation: dts: Documentation entry to explain how to use PWM FAN as a cooling device
  2015-03-04 12:03   ` [PATCH RESEND RESEND v6 0/6] hwmon: thermal: Odroid U3: Provide support for Odroid U3 fan Lukasz Majewski
  (?)
@ 2015-03-04 12:03     ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-03-04 12:03 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

Explanation of several properties, which allow PWM fan working as a cooling
device, have been embraced in this commit.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
Acked-by: Eduardo Valentin <edubezval@gmail.com>
---
Changes for v2:
- Rename cooling-pwm-values to cooling-levels
- Remove default-pulse-width property and stick to default hwmon policy
Changes for v3:
- Changing commit title from "hwmon: dts: Doc:" to "Documentation: dts"
- Remove unnecessary properties
- Set maximal cooling level to 230 instead of 255
Changes for v4:
- None
Changes for v5:
- Move thermal-zones description to example section
- Extending example section
Changes for v6:
- cooling-{min|max}-state properties added to pwm-fan binding
- Mandatory properties for thermal-zones added
- Indentation fixed
---
 .../devicetree/bindings/hwmon/pwm-fan.txt          | 29 ++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
index 610757c..c6d5332 100644
--- a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
+++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
@@ -3,10 +3,35 @@ Bindings for a fan connected to the PWM lines
 Required properties:
 - compatible	: "pwm-fan"
 - pwms		: the PWM that is used to control the PWM fan
+- cooling-levels      : PWM duty cycle values in a range from 0 to 255
+			which correspond to thermal cooling states
 
 Example:
-	pwm-fan {
+	fan0: pwm-fan {
 		compatible = "pwm-fan";
-		status = "okay";
+		cooling-min-state = <0>;
+		cooling-max-state = <3>;
+		#cooling-cells = <2>;
 		pwms = <&pwm 0 10000 0>;
+		cooling-levels = <0 102 170 230>;
 	};
+
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			     thermal-sensors = <&tmu 0>;
+			     polling-delay-passive = <0>;
+			     polling-delay = <0>;
+			     trips {
+					cpu_alert1: cpu-alert1 {
+						    temperature = <100000>; /* millicelsius */
+						    hysteresis = <2000>; /* millicelsius */
+						    type = "passive";
+					};
+			     };
+			     cooling-maps {
+					map0 {
+						    trip = <&cpu_alert1>;
+						    cooling-device = <&fan0 0 1>;
+					};
+			     };
+		};
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH RESEND v6 1/6] Documentation: dts: Documentation entry to explain how to use PWM FAN as a cooling device
@ 2015-03-04 12:03     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-03-04 12:03 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

Explanation of several properties, which allow PWM fan working as a cooling
device, have been embraced in this commit.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
Acked-by: Eduardo Valentin <edubezval@gmail.com>
---
Changes for v2:
- Rename cooling-pwm-values to cooling-levels
- Remove default-pulse-width property and stick to default hwmon policy
Changes for v3:
- Changing commit title from "hwmon: dts: Doc:" to "Documentation: dts"
- Remove unnecessary properties
- Set maximal cooling level to 230 instead of 255
Changes for v4:
- None
Changes for v5:
- Move thermal-zones description to example section
- Extending example section
Changes for v6:
- cooling-{min|max}-state properties added to pwm-fan binding
- Mandatory properties for thermal-zones added
- Indentation fixed
---
 .../devicetree/bindings/hwmon/pwm-fan.txt          | 29 ++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
index 610757c..c6d5332 100644
--- a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
+++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
@@ -3,10 +3,35 @@ Bindings for a fan connected to the PWM lines
 Required properties:
 - compatible	: "pwm-fan"
 - pwms		: the PWM that is used to control the PWM fan
+- cooling-levels      : PWM duty cycle values in a range from 0 to 255
+			which correspond to thermal cooling states
 
 Example:
-	pwm-fan {
+	fan0: pwm-fan {
 		compatible = "pwm-fan";
-		status = "okay";
+		cooling-min-state = <0>;
+		cooling-max-state = <3>;
+		#cooling-cells = <2>;
 		pwms = <&pwm 0 10000 0>;
+		cooling-levels = <0 102 170 230>;
 	};
+
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			     thermal-sensors = <&tmu 0>;
+			     polling-delay-passive = <0>;
+			     polling-delay = <0>;
+			     trips {
+					cpu_alert1: cpu-alert1 {
+						    temperature = <100000>; /* millicelsius */
+						    hysteresis = <2000>; /* millicelsius */
+						    type = "passive";
+					};
+			     };
+			     cooling-maps {
+					map0 {
+						    trip = <&cpu_alert1>;
+						    cooling-device = <&fan0 0 1>;
+					};
+			     };
+		};
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [lm-sensors] [PATCH RESEND v6 1/6] Documentation: dts: Documentation entry to explain how to use PWM
@ 2015-03-04 12:03     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-03-04 12:03 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

Explanation of several properties, which allow PWM fan working as a cooling
device, have been embraced in this commit.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
Acked-by: Eduardo Valentin <edubezval@gmail.com>
---
Changes for v2:
- Rename cooling-pwm-values to cooling-levels
- Remove default-pulse-width property and stick to default hwmon policy
Changes for v3:
- Changing commit title from "hwmon: dts: Doc:" to "Documentation: dts"
- Remove unnecessary properties
- Set maximal cooling level to 230 instead of 255
Changes for v4:
- None
Changes for v5:
- Move thermal-zones description to example section
- Extending example section
Changes for v6:
- cooling-{min|max}-state properties added to pwm-fan binding
- Mandatory properties for thermal-zones added
- Indentation fixed
---
 .../devicetree/bindings/hwmon/pwm-fan.txt          | 29 ++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
index 610757c..c6d5332 100644
--- a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
+++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
@@ -3,10 +3,35 @@ Bindings for a fan connected to the PWM lines
 Required properties:
 - compatible	: "pwm-fan"
 - pwms		: the PWM that is used to control the PWM fan
+- cooling-levels      : PWM duty cycle values in a range from 0 to 255
+			which correspond to thermal cooling states
 
 Example:
-	pwm-fan {
+	fan0: pwm-fan {
 		compatible = "pwm-fan";
-		status = "okay";
+		cooling-min-state = <0>;
+		cooling-max-state = <3>;
+		#cooling-cells = <2>;
 		pwms = <&pwm 0 10000 0>;
+		cooling-levels = <0 102 170 230>;
 	};
+
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			     thermal-sensors = <&tmu 0>;
+			     polling-delay-passive = <0>;
+			     polling-delay = <0>;
+			     trips {
+					cpu_alert1: cpu-alert1 {
+						    temperature = <100000>; /* millicelsius */
+						    hysteresis = <2000>; /* millicelsius */
+						    type = "passive";
+					};
+			     };
+			     cooling-maps {
+					map0 {
+						    trip = <&cpu_alert1>;
+						    cooling-device = <&fan0 0 1>;
+					};
+			     };
+		};
-- 
2.0.0.rc2


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH RESEND v6 2/6] ARM: dts: Add pwm-fan node to the Odroid-U3 board
  2015-03-04 12:03   ` [PATCH RESEND RESEND v6 0/6] hwmon: thermal: Odroid U3: Provide support for Odroid U3 fan Lukasz Majewski
  (?)
@ 2015-03-04 12:03     ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-03-04 12:03 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

From: Kamil Debski <k.debski@samsung.com>

Add pwm-fan node to the Odroid-U3 board file to enable PWM control of the
cooling fan. In addition, add the "pwm" label to the pwm@139D0000 node
in the exynos4412.dtsi.

Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes since v1:
- added pwm label to the pwm@139D0000 node in exynos4.dtsi
- use the pwm label in the exynos4412-odroidu3.dts
- change order or properties in the pwn-fan node, to be sorted
  in alphabetical order
Changes for v5:
- Adding Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
- status = "okay"; dropped from the patch
Changes for v6:
- None

---
 arch/arm/boot/dts/exynos4.dtsi            |  2 +-
 arch/arm/boot/dts/exynos4412-odroidu3.dts | 12 ++++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/exynos4.dtsi b/arch/arm/boot/dts/exynos4.dtsi
index 690f56c..a93f5ca5 100644
--- a/arch/arm/boot/dts/exynos4.dtsi
+++ b/arch/arm/boot/dts/exynos4.dtsi
@@ -599,7 +599,7 @@
 		status = "disabled";
 	};
 
-	pwm@139D0000 {
+	pwm: pwm@139D0000 {
 		compatible = "samsung,exynos4210-pwm";
 		reg = <0x139D0000 0x1000>;
 		interrupts = <0 37 0>, <0 38 0>, <0 39 0>, <0 40 0>, <0 41 0>;
diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
index 44684e5..4c04837 100644
--- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
+++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
@@ -31,6 +31,18 @@
 			linux,default-trigger = "heartbeat";
 		};
 	};
+
+	pwm-fan {
+		compatible = "pwm-fan";
+		pwms = <&pwm 0 10000 0>;
+	};
+};
+
+&pwm {
+	pinctrl-0 = <&pwm0_out>;
+	pinctrl-names = "default";
+	samsung,pwm-outputs = <0>;
+	status = "okay";
 };
 
 &usb3503 {
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH RESEND v6 2/6] ARM: dts: Add pwm-fan node to the Odroid-U3 board
@ 2015-03-04 12:03     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-03-04 12:03 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

From: Kamil Debski <k.debski@samsung.com>

Add pwm-fan node to the Odroid-U3 board file to enable PWM control of the
cooling fan. In addition, add the "pwm" label to the pwm@139D0000 node
in the exynos4412.dtsi.

Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes since v1:
- added pwm label to the pwm@139D0000 node in exynos4.dtsi
- use the pwm label in the exynos4412-odroidu3.dts
- change order or properties in the pwn-fan node, to be sorted
  in alphabetical order
Changes for v5:
- Adding Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
- status = "okay"; dropped from the patch
Changes for v6:
- None

---
 arch/arm/boot/dts/exynos4.dtsi            |  2 +-
 arch/arm/boot/dts/exynos4412-odroidu3.dts | 12 ++++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/exynos4.dtsi b/arch/arm/boot/dts/exynos4.dtsi
index 690f56c..a93f5ca5 100644
--- a/arch/arm/boot/dts/exynos4.dtsi
+++ b/arch/arm/boot/dts/exynos4.dtsi
@@ -599,7 +599,7 @@
 		status = "disabled";
 	};
 
-	pwm@139D0000 {
+	pwm: pwm@139D0000 {
 		compatible = "samsung,exynos4210-pwm";
 		reg = <0x139D0000 0x1000>;
 		interrupts = <0 37 0>, <0 38 0>, <0 39 0>, <0 40 0>, <0 41 0>;
diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
index 44684e5..4c04837 100644
--- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
+++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
@@ -31,6 +31,18 @@
 			linux,default-trigger = "heartbeat";
 		};
 	};
+
+	pwm-fan {
+		compatible = "pwm-fan";
+		pwms = <&pwm 0 10000 0>;
+	};
+};
+
+&pwm {
+	pinctrl-0 = <&pwm0_out>;
+	pinctrl-names = "default";
+	samsung,pwm-outputs = <0>;
+	status = "okay";
 };
 
 &usb3503 {
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [lm-sensors] [PATCH RESEND v6 2/6] ARM: dts: Add pwm-fan node to the Odroid-U3 board
@ 2015-03-04 12:03     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-03-04 12:03 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

From: Kamil Debski <k.debski@samsung.com>

Add pwm-fan node to the Odroid-U3 board file to enable PWM control of the
cooling fan. In addition, add the "pwm" label to the pwm@139D0000 node
in the exynos4412.dtsi.

Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes since v1:
- added pwm label to the pwm@139D0000 node in exynos4.dtsi
- use the pwm label in the exynos4412-odroidu3.dts
- change order or properties in the pwn-fan node, to be sorted
  in alphabetical order
Changes for v5:
- Adding Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
- status = "okay"; dropped from the patch
Changes for v6:
- None

---
 arch/arm/boot/dts/exynos4.dtsi            |  2 +-
 arch/arm/boot/dts/exynos4412-odroidu3.dts | 12 ++++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/exynos4.dtsi b/arch/arm/boot/dts/exynos4.dtsi
index 690f56c..a93f5ca5 100644
--- a/arch/arm/boot/dts/exynos4.dtsi
+++ b/arch/arm/boot/dts/exynos4.dtsi
@@ -599,7 +599,7 @@
 		status = "disabled";
 	};
 
-	pwm@139D0000 {
+	pwm: pwm@139D0000 {
 		compatible = "samsung,exynos4210-pwm";
 		reg = <0x139D0000 0x1000>;
 		interrupts = <0 37 0>, <0 38 0>, <0 39 0>, <0 40 0>, <0 41 0>;
diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
index 44684e5..4c04837 100644
--- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
+++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
@@ -31,6 +31,18 @@
 			linux,default-trigger = "heartbeat";
 		};
 	};
+
+	pwm-fan {
+		compatible = "pwm-fan";
+		pwms = <&pwm 0 10000 0>;
+	};
+};
+
+&pwm {
+	pinctrl-0 = <&pwm0_out>;
+	pinctrl-names = "default";
+	samsung,pwm-outputs = <0>;
+	status = "okay";
 };
 
 &usb3503 {
-- 
2.0.0.rc2


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH RESEND v6 3/6] ARM: dts: Add properties to use pwm-fan device as a cooling device in Odroid U3
  2015-03-04 12:03   ` [PATCH RESEND RESEND v6 0/6] hwmon: thermal: Odroid U3: Provide support for Odroid U3 fan Lukasz Majewski
  (?)
@ 2015-03-04 12:03     ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-03-04 12:03 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

With those bindings it is possible to use pwm-fan device available in
Odroid U3 as a cooling device.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
Acked-by: Eduardo Valentin <edubezval@gmail.com>
---
Changes for v2:
- Rename cooling-pwm-values property to cooling-levels
Changes for v3:
- Change patch's topic to "ARM dts"
- Reduce maximal cooling-level to 230 from 255
Changes for v4:
- None
Changes for v5:
- None
Changes for v6:
- None
---
 arch/arm/boot/dts/exynos4412-odroidu3.dts | 33 ++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
index 4c04837..abcfa3c 100644
--- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
+++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
@@ -32,9 +32,40 @@
 		};
 	};
 
-	pwm-fan {
+	fan0: pwm-fan {
 		compatible = "pwm-fan";
 		pwms = <&pwm 0 10000 0>;
+		cooling-min-state = <0>;
+		cooling-max-state = <3>;
+		#cooling-cells = <2>;
+		cooling-levels = <0 102 170 230>;
+	};
+
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				     trip = <&cpu_alert1>;
+				     cooling-device = <&cpu0 7 7>;
+				};
+				map1 {
+				     trip = <&cpu_alert2>;
+				     cooling-device = <&cpu0 13 13>;
+				};
+				map2 {
+				     trip = <&cpu_alert0>;
+				     cooling-device = <&fan0 0 1>;
+				};
+				map3 {
+				     trip = <&cpu_alert1>;
+				     cooling-device = <&fan0 1 2>;
+				};
+				map4 {
+				     trip = <&cpu_alert2>;
+				     cooling-device = <&fan0 2 3>;
+				};
+			};
+		};
 	};
 };
 
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH RESEND v6 3/6] ARM: dts: Add properties to use pwm-fan device as a cooling device in Odroid U3
@ 2015-03-04 12:03     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-03-04 12:03 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

With those bindings it is possible to use pwm-fan device available in
Odroid U3 as a cooling device.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
Acked-by: Eduardo Valentin <edubezval@gmail.com>
---
Changes for v2:
- Rename cooling-pwm-values property to cooling-levels
Changes for v3:
- Change patch's topic to "ARM dts"
- Reduce maximal cooling-level to 230 from 255
Changes for v4:
- None
Changes for v5:
- None
Changes for v6:
- None
---
 arch/arm/boot/dts/exynos4412-odroidu3.dts | 33 ++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
index 4c04837..abcfa3c 100644
--- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
+++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
@@ -32,9 +32,40 @@
 		};
 	};
 
-	pwm-fan {
+	fan0: pwm-fan {
 		compatible = "pwm-fan";
 		pwms = <&pwm 0 10000 0>;
+		cooling-min-state = <0>;
+		cooling-max-state = <3>;
+		#cooling-cells = <2>;
+		cooling-levels = <0 102 170 230>;
+	};
+
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				     trip = <&cpu_alert1>;
+				     cooling-device = <&cpu0 7 7>;
+				};
+				map1 {
+				     trip = <&cpu_alert2>;
+				     cooling-device = <&cpu0 13 13>;
+				};
+				map2 {
+				     trip = <&cpu_alert0>;
+				     cooling-device = <&fan0 0 1>;
+				};
+				map3 {
+				     trip = <&cpu_alert1>;
+				     cooling-device = <&fan0 1 2>;
+				};
+				map4 {
+				     trip = <&cpu_alert2>;
+				     cooling-device = <&fan0 2 3>;
+				};
+			};
+		};
 	};
 };
 
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [lm-sensors] [PATCH RESEND v6 3/6] ARM: dts: Add properties to use pwm-fan device as a cooling devic
@ 2015-03-04 12:03     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-03-04 12:03 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

With those bindings it is possible to use pwm-fan device available in
Odroid U3 as a cooling device.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
Acked-by: Eduardo Valentin <edubezval@gmail.com>
---
Changes for v2:
- Rename cooling-pwm-values property to cooling-levels
Changes for v3:
- Change patch's topic to "ARM dts"
- Reduce maximal cooling-level to 230 from 255
Changes for v4:
- None
Changes for v5:
- None
Changes for v6:
- None
---
 arch/arm/boot/dts/exynos4412-odroidu3.dts | 33 ++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
index 4c04837..abcfa3c 100644
--- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
+++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
@@ -32,9 +32,40 @@
 		};
 	};
 
-	pwm-fan {
+	fan0: pwm-fan {
 		compatible = "pwm-fan";
 		pwms = <&pwm 0 10000 0>;
+		cooling-min-state = <0>;
+		cooling-max-state = <3>;
+		#cooling-cells = <2>;
+		cooling-levels = <0 102 170 230>;
+	};
+
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				     trip = <&cpu_alert1>;
+				     cooling-device = <&cpu0 7 7>;
+				};
+				map1 {
+				     trip = <&cpu_alert2>;
+				     cooling-device = <&cpu0 13 13>;
+				};
+				map2 {
+				     trip = <&cpu_alert0>;
+				     cooling-device = <&fan0 0 1>;
+				};
+				map3 {
+				     trip = <&cpu_alert1>;
+				     cooling-device = <&fan0 1 2>;
+				};
+				map4 {
+				     trip = <&cpu_alert2>;
+				     cooling-device = <&fan0 2 3>;
+				};
+			};
+		};
 	};
 };
 
-- 
2.0.0.rc2


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH RESEND v6 4/6] hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty cycle
  2015-03-04 12:03   ` [PATCH RESEND RESEND v6 0/6] hwmon: thermal: Odroid U3: Provide support for Odroid U3 fan Lukasz Majewski
  (?)
@ 2015-03-04 12:03     ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-03-04 12:03 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

It was necessary to decouple code handling writing to sysfs from the one
responsible for setting PWM of the fan.
Due to that, new __set_pwm() method was extracted, which is responsible for
only setting new PWM duty cycle.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- The commit headline has been reedited.
Changes for v4:
- Protect "if (ctx->pwm_value == pwm)" with ctx lock
- Initialize ret with zero
Changes for v5:
- None
Changes for v6:
- None
---
 drivers/hwmon/pwm-fan.c | 33 +++++++++++++++++++++------------
 1 file changed, 21 insertions(+), 12 deletions(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index 1991d903..bd42d39 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -33,20 +33,14 @@ struct pwm_fan_ctx {
 	unsigned char pwm_value;
 };
 
-static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
-		       const char *buf, size_t count)
+static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
 {
-	struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
-	unsigned long pwm, duty;
-	ssize_t ret;
-
-	if (kstrtoul(buf, 10, &pwm) || pwm > MAX_PWM)
-		return -EINVAL;
+	unsigned long duty;
+	int ret = 0;
 
 	mutex_lock(&ctx->lock);
-
 	if (ctx->pwm_value == pwm)
-		goto exit_set_pwm_no_change;
+		goto exit_set_pwm_err;
 
 	if (pwm == 0) {
 		pwm_disable(ctx->pwm);
@@ -66,13 +60,28 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 
 exit_set_pwm:
 	ctx->pwm_value = pwm;
-exit_set_pwm_no_change:
-	ret = count;
 exit_set_pwm_err:
 	mutex_unlock(&ctx->lock);
 	return ret;
 }
 
+static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
+		       const char *buf, size_t count)
+{
+	struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
+	unsigned long pwm;
+	int ret;
+
+	if (kstrtoul(buf, 10, &pwm) || pwm > MAX_PWM)
+		return -EINVAL;
+
+	ret = __set_pwm(ctx, pwm);
+	if (ret)
+		return ret;
+
+	return count;
+}
+
 static ssize_t show_pwm(struct device *dev,
 			struct device_attribute *attr, char *buf)
 {
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH RESEND v6 4/6] hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty cycle
@ 2015-03-04 12:03     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-03-04 12:03 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

It was necessary to decouple code handling writing to sysfs from the one
responsible for setting PWM of the fan.
Due to that, new __set_pwm() method was extracted, which is responsible for
only setting new PWM duty cycle.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- The commit headline has been reedited.
Changes for v4:
- Protect "if (ctx->pwm_value == pwm)" with ctx lock
- Initialize ret with zero
Changes for v5:
- None
Changes for v6:
- None
---
 drivers/hwmon/pwm-fan.c | 33 +++++++++++++++++++++------------
 1 file changed, 21 insertions(+), 12 deletions(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index 1991d903..bd42d39 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -33,20 +33,14 @@ struct pwm_fan_ctx {
 	unsigned char pwm_value;
 };
 
-static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
-		       const char *buf, size_t count)
+static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
 {
-	struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
-	unsigned long pwm, duty;
-	ssize_t ret;
-
-	if (kstrtoul(buf, 10, &pwm) || pwm > MAX_PWM)
-		return -EINVAL;
+	unsigned long duty;
+	int ret = 0;
 
 	mutex_lock(&ctx->lock);
-
 	if (ctx->pwm_value == pwm)
-		goto exit_set_pwm_no_change;
+		goto exit_set_pwm_err;
 
 	if (pwm == 0) {
 		pwm_disable(ctx->pwm);
@@ -66,13 +60,28 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 
 exit_set_pwm:
 	ctx->pwm_value = pwm;
-exit_set_pwm_no_change:
-	ret = count;
 exit_set_pwm_err:
 	mutex_unlock(&ctx->lock);
 	return ret;
 }
 
+static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
+		       const char *buf, size_t count)
+{
+	struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
+	unsigned long pwm;
+	int ret;
+
+	if (kstrtoul(buf, 10, &pwm) || pwm > MAX_PWM)
+		return -EINVAL;
+
+	ret = __set_pwm(ctx, pwm);
+	if (ret)
+		return ret;
+
+	return count;
+}
+
 static ssize_t show_pwm(struct device *dev,
 			struct device_attribute *attr, char *buf)
 {
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [lm-sensors] [PATCH RESEND v6 4/6] hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM d
@ 2015-03-04 12:03     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-03-04 12:03 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

It was necessary to decouple code handling writing to sysfs from the one
responsible for setting PWM of the fan.
Due to that, new __set_pwm() method was extracted, which is responsible for
only setting new PWM duty cycle.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- None
Changes for v3:
- The commit headline has been reedited.
Changes for v4:
- Protect "if (ctx->pwm_value = pwm)" with ctx lock
- Initialize ret with zero
Changes for v5:
- None
Changes for v6:
- None
---
 drivers/hwmon/pwm-fan.c | 33 +++++++++++++++++++++------------
 1 file changed, 21 insertions(+), 12 deletions(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index 1991d903..bd42d39 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -33,20 +33,14 @@ struct pwm_fan_ctx {
 	unsigned char pwm_value;
 };
 
-static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
-		       const char *buf, size_t count)
+static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
 {
-	struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
-	unsigned long pwm, duty;
-	ssize_t ret;
-
-	if (kstrtoul(buf, 10, &pwm) || pwm > MAX_PWM)
-		return -EINVAL;
+	unsigned long duty;
+	int ret = 0;
 
 	mutex_lock(&ctx->lock);
-
 	if (ctx->pwm_value = pwm)
-		goto exit_set_pwm_no_change;
+		goto exit_set_pwm_err;
 
 	if (pwm = 0) {
 		pwm_disable(ctx->pwm);
@@ -66,13 +60,28 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 
 exit_set_pwm:
 	ctx->pwm_value = pwm;
-exit_set_pwm_no_change:
-	ret = count;
 exit_set_pwm_err:
 	mutex_unlock(&ctx->lock);
 	return ret;
 }
 
+static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
+		       const char *buf, size_t count)
+{
+	struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
+	unsigned long pwm;
+	int ret;
+
+	if (kstrtoul(buf, 10, &pwm) || pwm > MAX_PWM)
+		return -EINVAL;
+
+	ret = __set_pwm(ctx, pwm);
+	if (ret)
+		return ret;
+
+	return count;
+}
+
 static ssize_t show_pwm(struct device *dev,
 			struct device_attribute *attr, char *buf)
 {
-- 
2.0.0.rc2


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH RESEND v6 5/6] hwmon: pwm-fan: Read PWM FAN configuration from device tree
  2015-03-04 12:03   ` [PATCH RESEND RESEND v6 0/6] hwmon: thermal: Odroid U3: Provide support for Odroid U3 fan Lukasz Majewski
  (?)
@ 2015-03-04 12:03     ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-03-04 12:03 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

This patch provides code for reading PWM FAN configuration data via
device tree. The pwm-fan can work with full speed when configuration
is not provided. However, errors are propagated when wrong DT bindings
are found.
Additionally the struct pwm_fan_ctx has been extended.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Rename pwm_fan_max_states to pwm_fan_cooling_levels
- Moving pwm_fan_of_get_cooling_data() call after setting end enabling PWM FAN
- pwm_fan_of_get_cooling_data() now can fail - preserving old behaviour
- Remove unnecessary dev_err() call
Changes for v3:
- Patch's headline has been reedited
- pwm_fan_of_get_cooling_data() return code is now being checked.
- of_property_count_elems_of_size() is now used instead of_find_property()
- More verbose patch description added
Changes for v4:
- dev_err() has been removed from pwm_fan_of_get_cooling_data()
- Returning -EINVAL when "cooling-levels" are defined in DT, but doesn't
  have the value
Changes for v5:
- Use of of_find_property() to assess if "cooling-levels" was defined in
  device tree
- Replace of_property_count_elems_of_size() with of_property_count_u32_elems()
- Remove ambiguity with returning error code from of_property_count_u32_elems()
- Return -EINVAL when "cooling-levels" has zero elements
Changes for v6:
- None
---
 drivers/hwmon/pwm-fan.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 49 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index bd42d39..e6ed353 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -30,7 +30,10 @@
 struct pwm_fan_ctx {
 	struct mutex lock;
 	struct pwm_device *pwm;
-	unsigned char pwm_value;
+	unsigned int pwm_value;
+	unsigned int pwm_fan_state;
+	unsigned int pwm_fan_max_state;
+	unsigned int *pwm_fan_cooling_levels;
 };
 
 static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
@@ -100,6 +103,46 @@ static struct attribute *pwm_fan_attrs[] = {
 
 ATTRIBUTE_GROUPS(pwm_fan);
 
+int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
+{
+	struct device_node *np = dev->of_node;
+	int num, i, ret;
+
+	if (!of_find_property(np, "cooling-levels", NULL))
+		return 0;
+
+	ret = of_property_count_u32_elems(np, "cooling-levels");
+	if (ret <= 0) {
+		dev_err(dev, "Wrong data!\n");
+		return ret ? : -EINVAL;
+	}
+
+	num = ret;
+	ctx->pwm_fan_cooling_levels = devm_kzalloc(dev, num * sizeof(u32),
+						   GFP_KERNEL);
+	if (!ctx->pwm_fan_cooling_levels)
+		return -ENOMEM;
+
+	ret = of_property_read_u32_array(np, "cooling-levels",
+					 ctx->pwm_fan_cooling_levels, num);
+	if (ret) {
+		dev_err(dev, "Property 'cooling-levels' cannot be read!\n");
+		return ret;
+	}
+
+	for (i = 0; i < num; i++) {
+		if (ctx->pwm_fan_cooling_levels[i] > MAX_PWM) {
+			dev_err(dev, "PWM fan state[%d]:%d > %d\n", i,
+				ctx->pwm_fan_cooling_levels[i], MAX_PWM);
+			return -EINVAL;
+		}
+	}
+
+	ctx->pwm_fan_max_state = num - 1;
+
+	return 0;
+}
+
 static int pwm_fan_probe(struct platform_device *pdev)
 {
 	struct device *hwmon;
@@ -145,6 +188,11 @@ static int pwm_fan_probe(struct platform_device *pdev)
 		pwm_disable(ctx->pwm);
 		return PTR_ERR(hwmon);
 	}
+
+	ret = pwm_fan_of_get_cooling_data(&pdev->dev, ctx);
+	if (ret)
+		return ret;
+
 	return 0;
 }
 
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH RESEND v6 5/6] hwmon: pwm-fan: Read PWM FAN configuration from device tree
@ 2015-03-04 12:03     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-03-04 12:03 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

This patch provides code for reading PWM FAN configuration data via
device tree. The pwm-fan can work with full speed when configuration
is not provided. However, errors are propagated when wrong DT bindings
are found.
Additionally the struct pwm_fan_ctx has been extended.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Rename pwm_fan_max_states to pwm_fan_cooling_levels
- Moving pwm_fan_of_get_cooling_data() call after setting end enabling PWM FAN
- pwm_fan_of_get_cooling_data() now can fail - preserving old behaviour
- Remove unnecessary dev_err() call
Changes for v3:
- Patch's headline has been reedited
- pwm_fan_of_get_cooling_data() return code is now being checked.
- of_property_count_elems_of_size() is now used instead of_find_property()
- More verbose patch description added
Changes for v4:
- dev_err() has been removed from pwm_fan_of_get_cooling_data()
- Returning -EINVAL when "cooling-levels" are defined in DT, but doesn't
  have the value
Changes for v5:
- Use of of_find_property() to assess if "cooling-levels" was defined in
  device tree
- Replace of_property_count_elems_of_size() with of_property_count_u32_elems()
- Remove ambiguity with returning error code from of_property_count_u32_elems()
- Return -EINVAL when "cooling-levels" has zero elements
Changes for v6:
- None
---
 drivers/hwmon/pwm-fan.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 49 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index bd42d39..e6ed353 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -30,7 +30,10 @@
 struct pwm_fan_ctx {
 	struct mutex lock;
 	struct pwm_device *pwm;
-	unsigned char pwm_value;
+	unsigned int pwm_value;
+	unsigned int pwm_fan_state;
+	unsigned int pwm_fan_max_state;
+	unsigned int *pwm_fan_cooling_levels;
 };
 
 static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
@@ -100,6 +103,46 @@ static struct attribute *pwm_fan_attrs[] = {
 
 ATTRIBUTE_GROUPS(pwm_fan);
 
+int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
+{
+	struct device_node *np = dev->of_node;
+	int num, i, ret;
+
+	if (!of_find_property(np, "cooling-levels", NULL))
+		return 0;
+
+	ret = of_property_count_u32_elems(np, "cooling-levels");
+	if (ret <= 0) {
+		dev_err(dev, "Wrong data!\n");
+		return ret ? : -EINVAL;
+	}
+
+	num = ret;
+	ctx->pwm_fan_cooling_levels = devm_kzalloc(dev, num * sizeof(u32),
+						   GFP_KERNEL);
+	if (!ctx->pwm_fan_cooling_levels)
+		return -ENOMEM;
+
+	ret = of_property_read_u32_array(np, "cooling-levels",
+					 ctx->pwm_fan_cooling_levels, num);
+	if (ret) {
+		dev_err(dev, "Property 'cooling-levels' cannot be read!\n");
+		return ret;
+	}
+
+	for (i = 0; i < num; i++) {
+		if (ctx->pwm_fan_cooling_levels[i] > MAX_PWM) {
+			dev_err(dev, "PWM fan state[%d]:%d > %d\n", i,
+				ctx->pwm_fan_cooling_levels[i], MAX_PWM);
+			return -EINVAL;
+		}
+	}
+
+	ctx->pwm_fan_max_state = num - 1;
+
+	return 0;
+}
+
 static int pwm_fan_probe(struct platform_device *pdev)
 {
 	struct device *hwmon;
@@ -145,6 +188,11 @@ static int pwm_fan_probe(struct platform_device *pdev)
 		pwm_disable(ctx->pwm);
 		return PTR_ERR(hwmon);
 	}
+
+	ret = pwm_fan_of_get_cooling_data(&pdev->dev, ctx);
+	if (ret)
+		return ret;
+
 	return 0;
 }
 
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [lm-sensors] [PATCH RESEND v6 5/6] hwmon: pwm-fan: Read PWM FAN configuration from device tree
@ 2015-03-04 12:03     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-03-04 12:03 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

This patch provides code for reading PWM FAN configuration data via
device tree. The pwm-fan can work with full speed when configuration
is not provided. However, errors are propagated when wrong DT bindings
are found.
Additionally the struct pwm_fan_ctx has been extended.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
Changes for v2:
- Rename pwm_fan_max_states to pwm_fan_cooling_levels
- Moving pwm_fan_of_get_cooling_data() call after setting end enabling PWM FAN
- pwm_fan_of_get_cooling_data() now can fail - preserving old behaviour
- Remove unnecessary dev_err() call
Changes for v3:
- Patch's headline has been reedited
- pwm_fan_of_get_cooling_data() return code is now being checked.
- of_property_count_elems_of_size() is now used instead of_find_property()
- More verbose patch description added
Changes for v4:
- dev_err() has been removed from pwm_fan_of_get_cooling_data()
- Returning -EINVAL when "cooling-levels" are defined in DT, but doesn't
  have the value
Changes for v5:
- Use of of_find_property() to assess if "cooling-levels" was defined in
  device tree
- Replace of_property_count_elems_of_size() with of_property_count_u32_elems()
- Remove ambiguity with returning error code from of_property_count_u32_elems()
- Return -EINVAL when "cooling-levels" has zero elements
Changes for v6:
- None
---
 drivers/hwmon/pwm-fan.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 49 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index bd42d39..e6ed353 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -30,7 +30,10 @@
 struct pwm_fan_ctx {
 	struct mutex lock;
 	struct pwm_device *pwm;
-	unsigned char pwm_value;
+	unsigned int pwm_value;
+	unsigned int pwm_fan_state;
+	unsigned int pwm_fan_max_state;
+	unsigned int *pwm_fan_cooling_levels;
 };
 
 static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
@@ -100,6 +103,46 @@ static struct attribute *pwm_fan_attrs[] = {
 
 ATTRIBUTE_GROUPS(pwm_fan);
 
+int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
+{
+	struct device_node *np = dev->of_node;
+	int num, i, ret;
+
+	if (!of_find_property(np, "cooling-levels", NULL))
+		return 0;
+
+	ret = of_property_count_u32_elems(np, "cooling-levels");
+	if (ret <= 0) {
+		dev_err(dev, "Wrong data!\n");
+		return ret ? : -EINVAL;
+	}
+
+	num = ret;
+	ctx->pwm_fan_cooling_levels = devm_kzalloc(dev, num * sizeof(u32),
+						   GFP_KERNEL);
+	if (!ctx->pwm_fan_cooling_levels)
+		return -ENOMEM;
+
+	ret = of_property_read_u32_array(np, "cooling-levels",
+					 ctx->pwm_fan_cooling_levels, num);
+	if (ret) {
+		dev_err(dev, "Property 'cooling-levels' cannot be read!\n");
+		return ret;
+	}
+
+	for (i = 0; i < num; i++) {
+		if (ctx->pwm_fan_cooling_levels[i] > MAX_PWM) {
+			dev_err(dev, "PWM fan state[%d]:%d > %d\n", i,
+				ctx->pwm_fan_cooling_levels[i], MAX_PWM);
+			return -EINVAL;
+		}
+	}
+
+	ctx->pwm_fan_max_state = num - 1;
+
+	return 0;
+}
+
 static int pwm_fan_probe(struct platform_device *pdev)
 {
 	struct device *hwmon;
@@ -145,6 +188,11 @@ static int pwm_fan_probe(struct platform_device *pdev)
 		pwm_disable(ctx->pwm);
 		return PTR_ERR(hwmon);
 	}
+
+	ret = pwm_fan_of_get_cooling_data(&pdev->dev, ctx);
+	if (ret)
+		return ret;
+
 	return 0;
 }
 
-- 
2.0.0.rc2


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH RESEND v6 6/6] hwmon: pwm-fan: Code for using PWM FAN as a cooling device
  2015-03-04 12:03   ` [PATCH RESEND RESEND v6 0/6] hwmon: thermal: Odroid U3: Provide support for Odroid U3 fan Lukasz Majewski
  (?)
@ 2015-03-04 12:03     ` Lukasz Majewski
  -1 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-03-04 12:03 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

The PWM FAN device can now be used as a thermal cooling device. Necessary
infrastructure has been added in this commit.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
Acked-by: Eduardo Valentin <edubezval@gmail.com>
---
Changes for v2:
- Replace pwm_fan_cooling_states with pwm_fan_cooling_levels
- Update ctx->pwm_fan_state when correct data from device tree is available
- Using therma_cdev_update() when thermal is ready for controlling the fan
Changes for v3:
- Rename patch heading
- pwm_fan_of_get_cooling_data() now returns -EINVAL when no "cooling-levels"
  property defined
- register of cooling device only when proper cooling data is present
Changes for v4:
- None
Changes for v5:
- Check for IS_ENABLED(CONFIG_THERMAL) has been added to prevent from
  executing thermal_* specific functions
Changes for v6:
- Adding missing ctx == NULL check in pwm_fan_get_max_state()
- Call to thermal_cooling_device_unregister(ctx->cdev); at pwm_fan_remove()
- struct thermal_cooling_device *cdev; added to struct pwm_fan_ctx
---
 drivers/hwmon/pwm-fan.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 88 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index e6ed353..7c83dc4 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -24,6 +24,7 @@
 #include <linux/platform_device.h>
 #include <linux/pwm.h>
 #include <linux/sysfs.h>
+#include <linux/thermal.h>
 
 #define MAX_PWM 255
 
@@ -34,6 +35,7 @@ struct pwm_fan_ctx {
 	unsigned int pwm_fan_state;
 	unsigned int pwm_fan_max_state;
 	unsigned int *pwm_fan_cooling_levels;
+	struct thermal_cooling_device *cdev;
 };
 
 static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
@@ -68,6 +70,17 @@ exit_set_pwm_err:
 	return ret;
 }
 
+static void pwm_fan_update_state(struct pwm_fan_ctx *ctx, unsigned long pwm)
+{
+	int i;
+
+	for (i = 0; i < ctx->pwm_fan_max_state; ++i)
+		if (pwm < ctx->pwm_fan_cooling_levels[i + 1])
+			break;
+
+	ctx->pwm_fan_state = i;
+}
+
 static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 		       const char *buf, size_t count)
 {
@@ -82,6 +95,7 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 	if (ret)
 		return ret;
 
+	pwm_fan_update_state(ctx, pwm);
 	return count;
 }
 
@@ -103,6 +117,62 @@ static struct attribute *pwm_fan_attrs[] = {
 
 ATTRIBUTE_GROUPS(pwm_fan);
 
+/* thermal cooling device callbacks */
+static int pwm_fan_get_max_state(struct thermal_cooling_device *cdev,
+				 unsigned long *state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+
+	if (!ctx)
+		return -EINVAL;
+
+	*state = ctx->pwm_fan_max_state;
+
+	return 0;
+}
+
+static int pwm_fan_get_cur_state(struct thermal_cooling_device *cdev,
+				 unsigned long *state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+
+	if (!ctx)
+		return -EINVAL;
+
+	*state = ctx->pwm_fan_state;
+
+	return 0;
+}
+
+static int
+pwm_fan_set_cur_state(struct thermal_cooling_device *cdev, unsigned long state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+	int ret;
+
+	if (!ctx || (state > ctx->pwm_fan_max_state))
+		return -EINVAL;
+
+	if (state == ctx->pwm_fan_state)
+		return 0;
+
+	ret = __set_pwm(ctx, ctx->pwm_fan_cooling_levels[state]);
+	if (ret) {
+		dev_err(&cdev->device, "Cannot set pwm!\n");
+		return ret;
+	}
+
+	ctx->pwm_fan_state = state;
+
+	return ret;
+}
+
+static const struct thermal_cooling_device_ops pwm_fan_cooling_ops = {
+	.get_max_state = pwm_fan_get_max_state,
+	.get_cur_state = pwm_fan_get_cur_state,
+	.set_cur_state = pwm_fan_set_cur_state,
+};
+
 int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
 {
 	struct device_node *np = dev->of_node;
@@ -145,8 +215,9 @@ int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
 
 static int pwm_fan_probe(struct platform_device *pdev)
 {
-	struct device *hwmon;
+	struct thermal_cooling_device *cdev;
 	struct pwm_fan_ctx *ctx;
+	struct device *hwmon;
 	int duty_cycle;
 	int ret;
 
@@ -193,6 +264,21 @@ static int pwm_fan_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
+	ctx->pwm_fan_state = ctx->pwm_fan_max_state;
+	if (IS_ENABLED(CONFIG_THERMAL)) {
+		cdev = thermal_of_cooling_device_register(pdev->dev.of_node,
+							  "pwm-fan", ctx,
+							  &pwm_fan_cooling_ops);
+		if (IS_ERR(cdev)) {
+			dev_err(&pdev->dev,
+				"Failed to register pwm-fan as cooling device");
+			pwm_disable(ctx->pwm);
+			return PTR_ERR(cdev);
+		}
+		ctx->cdev = cdev;
+		thermal_cdev_update(cdev);
+	}
+
 	return 0;
 }
 
@@ -200,6 +286,7 @@ static int pwm_fan_remove(struct platform_device *pdev)
 {
 	struct pwm_fan_ctx *ctx = platform_get_drvdata(pdev);
 
+	thermal_cooling_device_unregister(ctx->cdev);
 	if (ctx->pwm_value)
 		pwm_disable(ctx->pwm);
 	return 0;
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH RESEND v6 6/6] hwmon: pwm-fan: Code for using PWM FAN as a cooling device
@ 2015-03-04 12:03     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-03-04 12:03 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

The PWM FAN device can now be used as a thermal cooling device. Necessary
infrastructure has been added in this commit.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
Acked-by: Eduardo Valentin <edubezval@gmail.com>
---
Changes for v2:
- Replace pwm_fan_cooling_states with pwm_fan_cooling_levels
- Update ctx->pwm_fan_state when correct data from device tree is available
- Using therma_cdev_update() when thermal is ready for controlling the fan
Changes for v3:
- Rename patch heading
- pwm_fan_of_get_cooling_data() now returns -EINVAL when no "cooling-levels"
  property defined
- register of cooling device only when proper cooling data is present
Changes for v4:
- None
Changes for v5:
- Check for IS_ENABLED(CONFIG_THERMAL) has been added to prevent from
  executing thermal_* specific functions
Changes for v6:
- Adding missing ctx == NULL check in pwm_fan_get_max_state()
- Call to thermal_cooling_device_unregister(ctx->cdev); at pwm_fan_remove()
- struct thermal_cooling_device *cdev; added to struct pwm_fan_ctx
---
 drivers/hwmon/pwm-fan.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 88 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index e6ed353..7c83dc4 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -24,6 +24,7 @@
 #include <linux/platform_device.h>
 #include <linux/pwm.h>
 #include <linux/sysfs.h>
+#include <linux/thermal.h>
 
 #define MAX_PWM 255
 
@@ -34,6 +35,7 @@ struct pwm_fan_ctx {
 	unsigned int pwm_fan_state;
 	unsigned int pwm_fan_max_state;
 	unsigned int *pwm_fan_cooling_levels;
+	struct thermal_cooling_device *cdev;
 };
 
 static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
@@ -68,6 +70,17 @@ exit_set_pwm_err:
 	return ret;
 }
 
+static void pwm_fan_update_state(struct pwm_fan_ctx *ctx, unsigned long pwm)
+{
+	int i;
+
+	for (i = 0; i < ctx->pwm_fan_max_state; ++i)
+		if (pwm < ctx->pwm_fan_cooling_levels[i + 1])
+			break;
+
+	ctx->pwm_fan_state = i;
+}
+
 static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 		       const char *buf, size_t count)
 {
@@ -82,6 +95,7 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 	if (ret)
 		return ret;
 
+	pwm_fan_update_state(ctx, pwm);
 	return count;
 }
 
@@ -103,6 +117,62 @@ static struct attribute *pwm_fan_attrs[] = {
 
 ATTRIBUTE_GROUPS(pwm_fan);
 
+/* thermal cooling device callbacks */
+static int pwm_fan_get_max_state(struct thermal_cooling_device *cdev,
+				 unsigned long *state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+
+	if (!ctx)
+		return -EINVAL;
+
+	*state = ctx->pwm_fan_max_state;
+
+	return 0;
+}
+
+static int pwm_fan_get_cur_state(struct thermal_cooling_device *cdev,
+				 unsigned long *state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+
+	if (!ctx)
+		return -EINVAL;
+
+	*state = ctx->pwm_fan_state;
+
+	return 0;
+}
+
+static int
+pwm_fan_set_cur_state(struct thermal_cooling_device *cdev, unsigned long state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+	int ret;
+
+	if (!ctx || (state > ctx->pwm_fan_max_state))
+		return -EINVAL;
+
+	if (state == ctx->pwm_fan_state)
+		return 0;
+
+	ret = __set_pwm(ctx, ctx->pwm_fan_cooling_levels[state]);
+	if (ret) {
+		dev_err(&cdev->device, "Cannot set pwm!\n");
+		return ret;
+	}
+
+	ctx->pwm_fan_state = state;
+
+	return ret;
+}
+
+static const struct thermal_cooling_device_ops pwm_fan_cooling_ops = {
+	.get_max_state = pwm_fan_get_max_state,
+	.get_cur_state = pwm_fan_get_cur_state,
+	.set_cur_state = pwm_fan_set_cur_state,
+};
+
 int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
 {
 	struct device_node *np = dev->of_node;
@@ -145,8 +215,9 @@ int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
 
 static int pwm_fan_probe(struct platform_device *pdev)
 {
-	struct device *hwmon;
+	struct thermal_cooling_device *cdev;
 	struct pwm_fan_ctx *ctx;
+	struct device *hwmon;
 	int duty_cycle;
 	int ret;
 
@@ -193,6 +264,21 @@ static int pwm_fan_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
+	ctx->pwm_fan_state = ctx->pwm_fan_max_state;
+	if (IS_ENABLED(CONFIG_THERMAL)) {
+		cdev = thermal_of_cooling_device_register(pdev->dev.of_node,
+							  "pwm-fan", ctx,
+							  &pwm_fan_cooling_ops);
+		if (IS_ERR(cdev)) {
+			dev_err(&pdev->dev,
+				"Failed to register pwm-fan as cooling device");
+			pwm_disable(ctx->pwm);
+			return PTR_ERR(cdev);
+		}
+		ctx->cdev = cdev;
+		thermal_cdev_update(cdev);
+	}
+
 	return 0;
 }
 
@@ -200,6 +286,7 @@ static int pwm_fan_remove(struct platform_device *pdev)
 {
 	struct pwm_fan_ctx *ctx = platform_get_drvdata(pdev);
 
+	thermal_cooling_device_unregister(ctx->cdev);
 	if (ctx->pwm_value)
 		pwm_disable(ctx->pwm);
 	return 0;
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [lm-sensors] [PATCH RESEND v6 6/6] hwmon: pwm-fan: Code for using PWM FAN as a cooling device
@ 2015-03-04 12:03     ` Lukasz Majewski
  0 siblings, 0 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-03-04 12:03 UTC (permalink / raw)
  To: Eduardo Valentin, Kamil Debski, Jean Delvare, Guenter Roeck, Kukjin Kim
  Cc: lm-sensors, Linux PM list, linux-samsung-soc, devicetree,
	Lukasz Majewski, Kukjin Kim, linux-kernel, Sjoerd Simons,
	Abhilash Kesavan, Abhilash Kesavan, Lukasz Majewski

The PWM FAN device can now be used as a thermal cooling device. Necessary
infrastructure has been added in this commit.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
Acked-by: Eduardo Valentin <edubezval@gmail.com>
---
Changes for v2:
- Replace pwm_fan_cooling_states with pwm_fan_cooling_levels
- Update ctx->pwm_fan_state when correct data from device tree is available
- Using therma_cdev_update() when thermal is ready for controlling the fan
Changes for v3:
- Rename patch heading
- pwm_fan_of_get_cooling_data() now returns -EINVAL when no "cooling-levels"
  property defined
- register of cooling device only when proper cooling data is present
Changes for v4:
- None
Changes for v5:
- Check for IS_ENABLED(CONFIG_THERMAL) has been added to prevent from
  executing thermal_* specific functions
Changes for v6:
- Adding missing ctx = NULL check in pwm_fan_get_max_state()
- Call to thermal_cooling_device_unregister(ctx->cdev); at pwm_fan_remove()
- struct thermal_cooling_device *cdev; added to struct pwm_fan_ctx
---
 drivers/hwmon/pwm-fan.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 88 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index e6ed353..7c83dc4 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -24,6 +24,7 @@
 #include <linux/platform_device.h>
 #include <linux/pwm.h>
 #include <linux/sysfs.h>
+#include <linux/thermal.h>
 
 #define MAX_PWM 255
 
@@ -34,6 +35,7 @@ struct pwm_fan_ctx {
 	unsigned int pwm_fan_state;
 	unsigned int pwm_fan_max_state;
 	unsigned int *pwm_fan_cooling_levels;
+	struct thermal_cooling_device *cdev;
 };
 
 static int  __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
@@ -68,6 +70,17 @@ exit_set_pwm_err:
 	return ret;
 }
 
+static void pwm_fan_update_state(struct pwm_fan_ctx *ctx, unsigned long pwm)
+{
+	int i;
+
+	for (i = 0; i < ctx->pwm_fan_max_state; ++i)
+		if (pwm < ctx->pwm_fan_cooling_levels[i + 1])
+			break;
+
+	ctx->pwm_fan_state = i;
+}
+
 static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 		       const char *buf, size_t count)
 {
@@ -82,6 +95,7 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
 	if (ret)
 		return ret;
 
+	pwm_fan_update_state(ctx, pwm);
 	return count;
 }
 
@@ -103,6 +117,62 @@ static struct attribute *pwm_fan_attrs[] = {
 
 ATTRIBUTE_GROUPS(pwm_fan);
 
+/* thermal cooling device callbacks */
+static int pwm_fan_get_max_state(struct thermal_cooling_device *cdev,
+				 unsigned long *state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+
+	if (!ctx)
+		return -EINVAL;
+
+	*state = ctx->pwm_fan_max_state;
+
+	return 0;
+}
+
+static int pwm_fan_get_cur_state(struct thermal_cooling_device *cdev,
+				 unsigned long *state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+
+	if (!ctx)
+		return -EINVAL;
+
+	*state = ctx->pwm_fan_state;
+
+	return 0;
+}
+
+static int
+pwm_fan_set_cur_state(struct thermal_cooling_device *cdev, unsigned long state)
+{
+	struct pwm_fan_ctx *ctx = cdev->devdata;
+	int ret;
+
+	if (!ctx || (state > ctx->pwm_fan_max_state))
+		return -EINVAL;
+
+	if (state = ctx->pwm_fan_state)
+		return 0;
+
+	ret = __set_pwm(ctx, ctx->pwm_fan_cooling_levels[state]);
+	if (ret) {
+		dev_err(&cdev->device, "Cannot set pwm!\n");
+		return ret;
+	}
+
+	ctx->pwm_fan_state = state;
+
+	return ret;
+}
+
+static const struct thermal_cooling_device_ops pwm_fan_cooling_ops = {
+	.get_max_state = pwm_fan_get_max_state,
+	.get_cur_state = pwm_fan_get_cur_state,
+	.set_cur_state = pwm_fan_set_cur_state,
+};
+
 int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
 {
 	struct device_node *np = dev->of_node;
@@ -145,8 +215,9 @@ int pwm_fan_of_get_cooling_data(struct device *dev, struct pwm_fan_ctx *ctx)
 
 static int pwm_fan_probe(struct platform_device *pdev)
 {
-	struct device *hwmon;
+	struct thermal_cooling_device *cdev;
 	struct pwm_fan_ctx *ctx;
+	struct device *hwmon;
 	int duty_cycle;
 	int ret;
 
@@ -193,6 +264,21 @@ static int pwm_fan_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
+	ctx->pwm_fan_state = ctx->pwm_fan_max_state;
+	if (IS_ENABLED(CONFIG_THERMAL)) {
+		cdev = thermal_of_cooling_device_register(pdev->dev.of_node,
+							  "pwm-fan", ctx,
+							  &pwm_fan_cooling_ops);
+		if (IS_ERR(cdev)) {
+			dev_err(&pdev->dev,
+				"Failed to register pwm-fan as cooling device");
+			pwm_disable(ctx->pwm);
+			return PTR_ERR(cdev);
+		}
+		ctx->cdev = cdev;
+		thermal_cdev_update(cdev);
+	}
+
 	return 0;
 }
 
@@ -200,6 +286,7 @@ static int pwm_fan_remove(struct platform_device *pdev)
 {
 	struct pwm_fan_ctx *ctx = platform_get_drvdata(pdev);
 
+	thermal_cooling_device_unregister(ctx->cdev);
 	if (ctx->pwm_value)
 		pwm_disable(ctx->pwm);
 	return 0;
-- 
2.0.0.rc2


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH RESEND v6 0/3] dts: thermal: Odroid U3: Provide support for Odroid U3 fan
  2015-03-04 12:03   ` [PATCH RESEND RESEND v6 0/6] hwmon: thermal: Odroid U3: Provide support for Odroid U3 fan Lukasz Majewski
                     ` (7 preceding siblings ...)
  (?)
@ 2015-08-11 13:07   ` Lukasz Majewski
  2015-08-11 13:07     ` [PATCH RESEND v6 1/3] Documentation: dts: Documentation entry to explain how to use PWM FAN as a cooling device Lukasz Majewski
  2015-09-16 11:00     ` [PATCH RESEND v6 0/3] dts: thermal: Odroid U3: Provide support for Odroid U3 fan Thomas Pietrowski
  -1 siblings, 2 replies; 329+ messages in thread
From: Lukasz Majewski @ 2015-08-11 13:07 UTC (permalink / raw)
  To: Eduardo Valentin, Krzysztof Kozlowski, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, devicetree, Lukasz Majewski,
	Lukasz Majewski

Presented patches add support for Odroid's U3 optional CPU FAN, which uses PWM
subsystem for low level control.

This patch is a resend of previously send series:
https://lkml.org/lkml/2015/3/4/726

The "hwmon" part of this series has been already added to upstream.
Unfortunately, the DTS files for Odroid U3 device have NOT been added to 
mainline repository.

Those patches were tested at Exynos4412 - Odroid U3 board.

Patches were applied on:
kernel_samsung -> git://git.kernel.org/pub/scm/linux/kernel/git/kgene/linux-samsung.git

kernel_samsung/for-next (Linux v4.2-rc1)
SHA1: 366c21fdd7b1e71a47a6fa969f2e9a014c981aff

Kamil Debski (1):
  ARM: dts: Add pwm-fan node to the Odroid-U3 board

Lukasz Majewski (2):
  Documentation: dts: Documentation entry to explain how to use PWM FAN
    as a cooling device
  ARM: dts: Add properties to use pwm-fan device as a cooling device in
    Odroid U3

 .../devicetree/bindings/hwmon/pwm-fan.txt          | 29 ++++++++++++++-
 arch/arm/boot/dts/exynos4412-odroidu3.dts          | 43 ++++++++++++++++++++++
 2 files changed, 70 insertions(+), 2 deletions(-)

-- 
2.0.0.rc2


^ permalink raw reply	[flat|nested] 329+ messages in thread

* [PATCH RESEND v6 1/3] Documentation: dts: Documentation entry to explain how to use PWM FAN as a cooling device
  2015-08-11 13:07   ` [PATCH RESEND v6 0/3] dts: thermal: Odroid U3: Provide support for Odroid U3 fan Lukasz Majewski
@ 2015-08-11 13:07     ` Lukasz Majewski
  2015-08-13  0:17       ` Krzysztof Kozlowski
  2015-09-16 11:00     ` [PATCH RESEND v6 0/3] dts: thermal: Odroid U3: Provide support for Odroid U3 fan Thomas Pietrowski
  1 sibling, 1 reply; 329+ messages in thread
From: Lukasz Majewski @ 2015-08-11 13:07 UTC (permalink / raw)
  To: Eduardo Valentin, Krzysztof Kozlowski, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, devicetree, Lukasz Majewski,
	Lukasz Majewski

Explanation of several properties, which allow PWM fan working as a cooling
device, have been embraced in this commit.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
Acked-by: Eduardo Valentin <edubezval@gmail.com>
---
 .../devicetree/bindings/hwmon/pwm-fan.txt          | 29 ++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
index 610757c..c6d5332 100644
--- a/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
+++ b/Documentation/devicetree/bindings/hwmon/pwm-fan.txt
@@ -3,10 +3,35 @@ Bindings for a fan connected to the PWM lines
 Required properties:
 - compatible	: "pwm-fan"
 - pwms		: the PWM that is used to control the PWM fan
+- cooling-levels      : PWM duty cycle values in a range from 0 to 255
+			which correspond to thermal cooling states
 
 Example:
-	pwm-fan {
+	fan0: pwm-fan {
 		compatible = "pwm-fan";
-		status = "okay";
+		cooling-min-state = <0>;
+		cooling-max-state = <3>;
+		#cooling-cells = <2>;
 		pwms = <&pwm 0 10000 0>;
+		cooling-levels = <0 102 170 230>;
 	};
+
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			     thermal-sensors = <&tmu 0>;
+			     polling-delay-passive = <0>;
+			     polling-delay = <0>;
+			     trips {
+					cpu_alert1: cpu-alert1 {
+						    temperature = <100000>; /* millicelsius */
+						    hysteresis = <2000>; /* millicelsius */
+						    type = "passive";
+					};
+			     };
+			     cooling-maps {
+					map0 {
+						    trip = <&cpu_alert1>;
+						    cooling-device = <&fan0 0 1>;
+					};
+			     };
+		};
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH RESEND v6 2/3] ARM: dts: Add pwm-fan node to the Odroid-U3 board
  2015-03-04 12:03   ` [PATCH RESEND RESEND v6 0/6] hwmon: thermal: Odroid U3: Provide support for Odroid U3 fan Lukasz Majewski
                     ` (8 preceding siblings ...)
  (?)
@ 2015-08-11 13:14   ` Lukasz Majewski
  2015-08-13  0:35     ` Krzysztof Kozlowski
  -1 siblings, 1 reply; 329+ messages in thread
From: Lukasz Majewski @ 2015-08-11 13:14 UTC (permalink / raw)
  To: Eduardo Valentin, Krzysztof Kozlowski, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, devicetree, Lukasz Majewski

From: Kamil Debski <k.debski@samsung.com>

Add pwm-fan node to the Odroid-U3 board file to enable PWM control of the
cooling fan. In addition, add the "pwm" label to the pwm@139D0000 node
in the exynos4412.dtsi.

Signed-off-by: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
---
 arch/arm/boot/dts/exynos4412-odroidu3.dts | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
index 44684e5..4c04837 100644
--- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
+++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
@@ -31,6 +31,18 @@
 			linux,default-trigger = "heartbeat";
 		};
 	};
+
+	pwm-fan {
+		compatible = "pwm-fan";
+		pwms = <&pwm 0 10000 0>;
+	};
+};
+
+&pwm {
+	pinctrl-0 = <&pwm0_out>;
+	pinctrl-names = "default";
+	samsung,pwm-outputs = <0>;
+	status = "okay";
 };
 
 &usb3503 {
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 329+ messages in thread

* [PATCH RESEND v6 3/3] ARM: dts: Add properties to use pwm-fan device as a cooling device in Odroid U3
  2015-03-04 12:03   ` [PATCH RESEND RESEND v6 0/6] hwmon: thermal: Odroid U3: Provide support for Odroid U3 fan Lukasz Majewski
                     ` (9 preceding siblings ...)
  (?)
@ 2015-08-11 13:15   ` Lukasz Majewski
  2015-08-13  0:35     ` Krzysztof Kozlowski
  -1 siblings, 1 reply; 329+ messages in thread
From: Lukasz Majewski @ 2015-08-11 13:15 UTC (permalink / raw)
  To: Eduardo Valentin, Krzysztof Kozlowski, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, devicetree, Lukasz Majewski,
	Lukasz Majewski

With those bindings it is possible to use pwm-fan device available in
Odroid U3 as a cooling device.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
Acked-by: Eduardo Valentin <edubezval@gmail.com>
---
 arch/arm/boot/dts/exynos4412-odroidu3.dts | 33 ++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/exynos4412-odroidu3.dts b/arch/arm/boot/dts/exynos4412-odroidu3.dts
index 4c04837..abcfa3c 100644
--- a/arch/arm/boot/dts/exynos4412-odroidu3.dts
+++ b/arch/arm/boot/dts/exynos4412-odroidu3.dts
@@ -32,9 +32,40 @@
 		};
 	};
 
-	pwm-fan {
+	fan0: pwm-fan {
 		compatible = "pwm-fan";
 		pwms = <&pwm 0 10000 0>;
+		cooling-min-state = <0>;
+		cooling-max-state = <3>;
+		#cooling-cells = <2>;
+		cooling-levels = <0 102 170 230>;
+	};
+
+	thermal-zones {
+		cpu_thermal: cpu-thermal {
+			cooling-maps {
+				map0 {
+				     trip = <&cpu_alert1>;
+				     cooling-device = <&cpu0 7 7>;
+				};
+				map1 {
+				     trip = <&cpu_alert2>;
+				     cooling-device = <&cpu0 13 13>;
+				};
+				map2 {
+				     trip = <&cpu_alert0>;
+				     cooling-device = <&fan0 0 1>;
+				};
+				map3 {
+				     trip = <&cpu_alert1>;
+				     cooling-device = <&fan0 1 2>;
+				};
+				map4 {
+				     trip = <&cpu_alert2>;
+				     cooling-device = <&fan0 2 3>;
+				};
+			};
+		};
 	};
 };
 
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 329+ messages in thread

* Re: [PATCH RESEND v6 1/3] Documentation: dts: Documentation entry to explain how to use PWM FAN as a cooling device
  2015-08-11 13:07     ` [PATCH RESEND v6 1/3] Documentation: dts: Documentation entry to explain how to use PWM FAN as a cooling device Lukasz Majewski
@ 2015-08-13  0:17       ` Krzysztof Kozlowski
  2015-08-14  9:36         ` Kukjin Kim
  0 siblings, 1 reply; 329+ messages in thread
From: Krzysztof Kozlowski @ 2015-08-13  0:17 UTC (permalink / raw)
  To: Lukasz Majewski, Eduardo Valentin, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, devicetree, Lukasz Majewski

On 11.08.2015 22:07, Lukasz Majewski wrote:
> Explanation of several properties, which allow PWM fan working as a cooling
> device, have been embraced in this commit.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> Acked-by: Eduardo Valentin <edubezval@gmail.com>
> ---
>  .../devicetree/bindings/hwmon/pwm-fan.txt          | 29 ++++++++++++++++++++--
>  1 file changed, 27 insertions(+), 2 deletions(-)
> 

Acked-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>

I'll take care of it and send it to Kukjin for v4.4.

Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH RESEND v6 3/3] ARM: dts: Add properties to use pwm-fan device as a cooling device in Odroid U3
  2015-08-11 13:15   ` [PATCH RESEND v6 3/3] ARM: dts: Add properties to use pwm-fan device as a cooling device in Odroid U3 Lukasz Majewski
@ 2015-08-13  0:35     ` Krzysztof Kozlowski
  0 siblings, 0 replies; 329+ messages in thread
From: Krzysztof Kozlowski @ 2015-08-13  0:35 UTC (permalink / raw)
  To: Lukasz Majewski, Eduardo Valentin, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, devicetree, Lukasz Majewski

On 11.08.2015 22:15, Lukasz Majewski wrote:
> With those bindings it is possible to use pwm-fan device available in
> Odroid U3 as a cooling device.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> Acked-by: Eduardo Valentin <edubezval@gmail.com>
> ---
>  arch/arm/boot/dts/exynos4412-odroidu3.dts | 33 ++++++++++++++++++++++++++++++-
>  1 file changed, 32 insertions(+), 1 deletion(-)

Looks sensible.

Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>

Best regards,
Krzysztof



^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH RESEND v6 2/3] ARM: dts: Add pwm-fan node to the Odroid-U3 board
  2015-08-11 13:14   ` [PATCH RESEND v6 2/3] ARM: dts: Add pwm-fan node to the Odroid-U3 board Lukasz Majewski
@ 2015-08-13  0:35     ` Krzysztof Kozlowski
  0 siblings, 0 replies; 329+ messages in thread
From: Krzysztof Kozlowski @ 2015-08-13  0:35 UTC (permalink / raw)
  To: Lukasz Majewski, Eduardo Valentin, Kukjin Kim, Kukjin Kim
  Cc: Linux PM list, linux-samsung-soc, devicetree, Lukasz Majewski

On 11.08.2015 22:14, Lukasz Majewski wrote:
> From: Kamil Debski <k.debski@samsung.com>
> 
> Add pwm-fan node to the Odroid-U3 board file to enable PWM control of the
> cooling fan. In addition, add the "pwm" label to the pwm@139D0000 node
> in the exynos4412.dtsi.
> 
> Signed-off-by: Kamil Debski <k.debski@samsung.com>
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> ---
>  arch/arm/boot/dts/exynos4412-odroidu3.dts | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 

Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>

Best regards,
Krzysztof


^ permalink raw reply	[flat|nested] 329+ messages in thread

* RE: [PATCH RESEND v6 1/3] Documentation: dts: Documentation entry to explain how to use PWM FAN as a cooling device
  2015-08-13  0:17       ` Krzysztof Kozlowski
@ 2015-08-14  9:36         ` Kukjin Kim
  2015-08-16  9:35           ` Krzysztof Kozlowski
  0 siblings, 1 reply; 329+ messages in thread
From: Kukjin Kim @ 2015-08-14  9:36 UTC (permalink / raw)
  To: 'Krzysztof Kozlowski', 'Lukasz Majewski',
	'Eduardo Valentin', 'Kukjin Kim'
  Cc: 'Linux PM list',
	linux-samsung-soc, devicetree, 'Lukasz Majewski'

Krzysztof Kozlowski wrote:
> On 11.08.2015 22:07, Lukasz Majewski wrote:
> > Explanation of several properties, which allow PWM fan working as a cooling
> > device, have been embraced in this commit.
> >
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > Acked-by: Eduardo Valentin <edubezval@gmail.com>
> > ---
> >  .../devicetree/bindings/hwmon/pwm-fan.txt          | 29 ++++++++++++++++++++--
> >  1 file changed, 27 insertions(+), 2 deletions(-)
> >
> 
> Acked-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
> 
> I'll take care of it and send it to Kukjin for v4.4.
> 
Hi, Krzysztof

If you're ok, I'll take this series into samsung tree directly for v4.3.

Thanks,
Kukjin

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH RESEND v6 1/3] Documentation: dts: Documentation entry to explain how to use PWM FAN as a cooling device
  2015-08-14  9:36         ` Kukjin Kim
@ 2015-08-16  9:35           ` Krzysztof Kozlowski
  0 siblings, 0 replies; 329+ messages in thread
From: Krzysztof Kozlowski @ 2015-08-16  9:35 UTC (permalink / raw)
  To: Kukjin Kim, 'Lukasz Majewski', 'Eduardo Valentin'
  Cc: 'Linux PM list',
	linux-samsung-soc, devicetree, 'Lukasz Majewski'

W dniu 14.08.2015 o 18:36, Kukjin Kim pisze:
> Krzysztof Kozlowski wrote:
>> On 11.08.2015 22:07, Lukasz Majewski wrote:
>>> Explanation of several properties, which allow PWM fan working as a cooling
>>> device, have been embraced in this commit.
>>>
>>> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
>>> Acked-by: Eduardo Valentin <edubezval@gmail.com>
>>> ---
>>>  .../devicetree/bindings/hwmon/pwm-fan.txt          | 29 ++++++++++++++++++++--
>>>  1 file changed, 27 insertions(+), 2 deletions(-)
>>>
>>
>> Acked-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
>>
>> I'll take care of it and send it to Kukjin for v4.4.
>>
> Hi, Krzysztof
> 
> If you're ok, I'll take this series into samsung tree directly for v4.3.

Sure, please go ahead.

Best regards,
Krzysztof


^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH RESEND v6 0/3] dts: thermal: Odroid U3: Provide support for Odroid U3 fan
  2015-08-11 13:07   ` [PATCH RESEND v6 0/3] dts: thermal: Odroid U3: Provide support for Odroid U3 fan Lukasz Majewski
  2015-08-11 13:07     ` [PATCH RESEND v6 1/3] Documentation: dts: Documentation entry to explain how to use PWM FAN as a cooling device Lukasz Majewski
@ 2015-09-16 11:00     ` Thomas Pietrowski
  2015-09-16 11:57       ` Krzysztof Kozlowski
  1 sibling, 1 reply; 329+ messages in thread
From: Thomas Pietrowski @ 2015-09-16 11:00 UTC (permalink / raw)
  To: Lukasz Majewski
  Cc: Eduardo Valentin, Krzysztof Kozlowski, Kukjin Kim, Kukjin Kim,
	Linux PM list, linux-samsung-soc, devicetree, Lukasz Majewski

Will this patchset be released with 4.3.x?

2015-08-11 15:07 GMT+02:00 Lukasz Majewski <l.majewski@samsung.com>:
> Presented patches add support for Odroid's U3 optional CPU FAN, which uses PWM
> subsystem for low level control.
>
> This patch is a resend of previously send series:
> https://lkml.org/lkml/2015/3/4/726
>
> The "hwmon" part of this series has been already added to upstream.
> Unfortunately, the DTS files for Odroid U3 device have NOT been added to
> mainline repository.
>
> Those patches were tested at Exynos4412 - Odroid U3 board.
>
> Patches were applied on:
> kernel_samsung -> git://git.kernel.org/pub/scm/linux/kernel/git/kgene/linux-samsung.git
>
> kernel_samsung/for-next (Linux v4.2-rc1)
> SHA1: 366c21fdd7b1e71a47a6fa969f2e9a014c981aff
>
> Kamil Debski (1):
>   ARM: dts: Add pwm-fan node to the Odroid-U3 board
>
> Lukasz Majewski (2):
>   Documentation: dts: Documentation entry to explain how to use PWM FAN
>     as a cooling device
>   ARM: dts: Add properties to use pwm-fan device as a cooling device in
>     Odroid U3
>
>  .../devicetree/bindings/hwmon/pwm-fan.txt          | 29 ++++++++++++++-
>  arch/arm/boot/dts/exynos4412-odroidu3.dts          | 43 ++++++++++++++++++++++
>  2 files changed, 70 insertions(+), 2 deletions(-)
>
> --
> 2.0.0.rc2
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 329+ messages in thread

* Re: [PATCH RESEND v6 0/3] dts: thermal: Odroid U3: Provide support for Odroid U3 fan
  2015-09-16 11:00     ` [PATCH RESEND v6 0/3] dts: thermal: Odroid U3: Provide support for Odroid U3 fan Thomas Pietrowski
@ 2015-09-16 11:57       ` Krzysztof Kozlowski
  0 siblings, 0 replies; 329+ messages in thread
From: Krzysztof Kozlowski @ 2015-09-16 11:57 UTC (permalink / raw)
  To: Thomas Pietrowski
  Cc: Lukasz Majewski, Eduardo Valentin, Krzysztof Kozlowski,
	Kukjin Kim, Kukjin Kim, Linux PM list, linux-samsung-soc,
	devicetree, Lukasz Majewski

2015-09-16 20:00 GMT+09:00 Thomas Pietrowski <thopiekar@gmail.com>:
> Will this patchset be released with 4.3.x?

No, although Kukjin applied it but it did not reach arm-soc for v4.3.

Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 329+ messages in thread

end of thread, other threads:[~2015-09-16 11:57 UTC | newest]

Thread overview: 329+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-18 10:13 [PATCH 0/9] hwmon: thermal: Odroid U3: Provide support for Odroid U3 fan Lukasz Majewski
2014-12-18 10:13 ` [lm-sensors] " Lukasz Majewski
2014-12-18 10:13 ` Lukasz Majewski
2014-12-18 10:13 ` [PATCH 1/9] thermal: Provide stub for thermal_of_cooling_device_register() function Lukasz Majewski
2014-12-18 10:13   ` [lm-sensors] " Lukasz Majewski
2014-12-18 10:13   ` Lukasz Majewski
2014-12-18 10:13 ` [PATCH 2/9] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling device Lukasz Majewski
2014-12-18 10:13   ` [lm-sensors] [PATCH 2/9] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling dev Lukasz Majewski
2014-12-18 10:13   ` [PATCH 2/9] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling device Lukasz Majewski
2014-12-18 10:42   ` Sjoerd Simons
2014-12-18 10:42     ` [lm-sensors] [PATCH 2/9] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling Sjoerd Simons
2014-12-18 10:42     ` [PATCH 2/9] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling device Sjoerd Simons
2014-12-19 15:32     ` Lukasz Majewski
2014-12-19 15:32       ` [lm-sensors] [PATCH 2/9] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling Lukasz Majewski
2014-12-19 15:32       ` [PATCH 2/9] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling device Lukasz Majewski
2014-12-19 16:02       ` Guenter Roeck
2014-12-19 16:02         ` [lm-sensors] [PATCH 2/9] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling Guenter Roeck
2014-12-19 16:02         ` [PATCH 2/9] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling device Guenter Roeck
2014-12-19 16:13         ` Lukasz Majewski
2014-12-19 16:13           ` [lm-sensors] [PATCH 2/9] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling Lukasz Majewski
2014-12-19 16:13           ` [PATCH 2/9] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling device Lukasz Majewski
2015-01-05 10:50           ` Sjoerd Simons
2015-01-05 10:50             ` [lm-sensors] [PATCH 2/9] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling Sjoerd Simons
2015-01-05 10:50             ` [PATCH 2/9] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling device Sjoerd Simons
2015-01-14 13:56             ` Lukasz Majewski
2015-01-14 13:56               ` [lm-sensors] [PATCH 2/9] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling Lukasz Majewski
2015-01-14 13:56               ` [PATCH 2/9] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling device Lukasz Majewski
2015-01-15  8:57               ` Sjoerd Simons
2015-01-15  8:57                 ` [lm-sensors] [PATCH 2/9] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling Sjoerd Simons
2015-01-15  8:57                 ` [PATCH 2/9] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling device Sjoerd Simons
2014-12-18 14:27   ` Guenter Roeck
2014-12-18 14:27     ` [lm-sensors] [PATCH 2/9] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling Guenter Roeck
2014-12-18 14:27     ` [PATCH 2/9] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling device Guenter Roeck
2014-12-19 16:25     ` Lukasz Majewski
2014-12-19 16:25       ` [lm-sensors] [PATCH 2/9] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling Lukasz Majewski
2014-12-19 16:25       ` [PATCH 2/9] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling device Lukasz Majewski
2014-12-18 10:13 ` [PATCH 3/9] ARM: dts: Add pwm-fan node to the Odroid-U3 board Lukasz Majewski
2014-12-18 10:13   ` [lm-sensors] " Lukasz Majewski
2014-12-18 10:13   ` Lukasz Majewski
2014-12-18 10:13 ` [PATCH 4/9] hwmon: thermal: dts: Add properties to use pwm-fan device as a cooling device in Odroid U3 Lukasz Majewski
2014-12-18 10:13   ` [lm-sensors] [PATCH 4/9] hwmon: thermal: dts: Add properties to use pwm-fan device as a cooling devi Lukasz Majewski
2014-12-18 10:13   ` [PATCH 4/9] hwmon: thermal: dts: Add properties to use pwm-fan device as a cooling device in Odroid U3 Lukasz Majewski
2014-12-18 10:13 ` [PATCH 5/9] hwmon: thermal: Extract __set_pwm() function to only modify PWM duty cycle Lukasz Majewski
2014-12-18 10:13   ` [lm-sensors] " Lukasz Majewski
2014-12-18 10:13   ` Lukasz Majewski
2014-12-18 10:13 ` [PATCH 6/9] hwmon: thermal: Read PWM FAN configuration from device tree Lukasz Majewski
2014-12-18 10:13   ` [lm-sensors] " Lukasz Majewski
2014-12-18 10:13   ` Lukasz Majewski
2014-12-18 10:13 ` [PATCH 7/9] hwmon: thermal: Code for using PWM FAN as a cooling device Lukasz Majewski
2014-12-18 10:13   ` [lm-sensors] " Lukasz Majewski
2014-12-18 10:13   ` Lukasz Majewski
2014-12-18 10:13 ` [PATCH 8/9] hwmon: thermal: Provide 'default-pulse-width' property to setup FAN on boot Lukasz Majewski
2014-12-18 10:13   ` [lm-sensors] " Lukasz Majewski
2014-12-18 10:13   ` Lukasz Majewski
2014-12-18 10:13 ` [PATCH 9/9] hwmon: thermal: dts: Disable FAN on boot on the Odroid U3 Lukasz Majewski
2014-12-18 10:13   ` [lm-sensors] " Lukasz Majewski
2014-12-18 10:13   ` Lukasz Majewski
2014-12-22 16:27 ` [PATCH v2 0/8] hwmon: thermal: Odroid U3: Provide support for Odroid U3 fan Lukasz Majewski
2014-12-22 16:27   ` [lm-sensors] " Lukasz Majewski
2014-12-22 16:27   ` Lukasz Majewski
2014-12-22 16:27   ` [PATCH v2 1/8] thermal: Provide stub for thermal_of_cooling_device_register() function Lukasz Majewski
2014-12-22 16:27     ` [lm-sensors] " Lukasz Majewski
2014-12-22 16:27     ` Lukasz Majewski
2015-01-02 18:54     ` Eduardo Valentin
2015-01-02 18:54       ` [lm-sensors] [PATCH v2 1/8] thermal: Provide stub for thermal_of_cooling_device_register() funct Eduardo Valentin
2015-01-02 18:54       ` [PATCH v2 1/8] thermal: Provide stub for thermal_of_cooling_device_register() function Eduardo Valentin
2015-01-02 19:03       ` Eduardo Valentin
2015-01-02 19:03         ` [lm-sensors] [PATCH v2 1/8] thermal: Provide stub for thermal_of_cooling_device_register() funct Eduardo Valentin
2015-01-02 19:03         ` [PATCH v2 1/8] thermal: Provide stub for thermal_of_cooling_device_register() function Eduardo Valentin
2015-01-14 15:01         ` Lukasz Majewski
2015-01-14 15:01           ` [lm-sensors] [PATCH v2 1/8] thermal: Provide stub for thermal_of_cooling_device_register() funct Lukasz Majewski
2015-01-14 15:01           ` [PATCH v2 1/8] thermal: Provide stub for thermal_of_cooling_device_register() function Lukasz Majewski
2015-01-14 18:32           ` Eduardo Valentin
2015-01-14 18:32             ` [lm-sensors] [PATCH v2 1/8] thermal: Provide stub for thermal_of_cooling_device_register() funct Eduardo Valentin
2015-01-14 18:32             ` [PATCH v2 1/8] thermal: Provide stub for thermal_of_cooling_device_register() function Eduardo Valentin
2015-01-15  8:43             ` Lukasz Majewski
2015-01-15  8:43               ` [lm-sensors] [PATCH v2 1/8] thermal: Provide stub for thermal_of_cooling_device_register() funct Lukasz Majewski
2015-01-15  8:43               ` [PATCH v2 1/8] thermal: Provide stub for thermal_of_cooling_device_register() function Lukasz Majewski
2014-12-22 16:27   ` [PATCH v2 2/8] thermal: Provide stub for thermal_cdev_update() function Lukasz Majewski
2014-12-22 16:27     ` [lm-sensors] " Lukasz Majewski
2014-12-22 16:27     ` Lukasz Majewski
2015-01-02 18:40     ` Eduardo Valentin
2015-01-02 18:40       ` [lm-sensors] " Eduardo Valentin
2015-01-02 18:40       ` Eduardo Valentin
2015-01-14 15:07       ` Lukasz Majewski
2015-01-14 15:07         ` [lm-sensors] " Lukasz Majewski
2015-01-14 15:07         ` Lukasz Majewski
2015-01-14 18:28         ` Eduardo Valentin
2015-01-14 18:28           ` [lm-sensors] " Eduardo Valentin
2015-01-14 18:28           ` Eduardo Valentin
2014-12-22 16:27   ` [PATCH v2 3/8] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling device Lukasz Majewski
2014-12-22 16:27     ` [lm-sensors] [PATCH v2 3/8] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling Lukasz Majewski
2014-12-22 16:27     ` [PATCH v2 3/8] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling device Lukasz Majewski
2015-01-02 18:51     ` Eduardo Valentin
2015-01-02 18:51       ` [lm-sensors] [PATCH v2 3/8] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cool Eduardo Valentin
2015-01-02 18:51       ` [PATCH v2 3/8] hwmon: dts: Doc: Add DTS doc to explain how to use PWM FAN as a cooling device Eduardo Valentin
2014-12-22 16:27   ` [PATCH v2 4/8] ARM: dts: Add pwm-fan node to the Odroid-U3 board Lukasz Majewski
2014-12-22 16:27     ` [lm-sensors] " Lukasz Majewski
2014-12-22 16:27     ` Lukasz Majewski
2014-12-22 16:27   ` [PATCH v2 5/8] hwmon: thermal: dts: Add properties to use pwm-fan device as a cooling device in Odroid U3 Lukasz Majewski
2014-12-22 16:27     ` [lm-sensors] [PATCH v2 5/8] hwmon: thermal: dts: Add properties to use pwm-fan device as a cooling d Lukasz Majewski
2014-12-22 16:27     ` [PATCH v2 5/8] hwmon: thermal: dts: Add properties to use pwm-fan device as a cooling device in Odroid U3 Lukasz Majewski
2015-01-02 18:52     ` Eduardo Valentin
2015-01-02 18:52       ` [lm-sensors] [PATCH v2 5/8] hwmon: thermal: dts: Add properties to use pwm-fan device as a cooli Eduardo Valentin
2015-01-02 18:52       ` [PATCH v2 5/8] hwmon: thermal: dts: Add properties to use pwm-fan device as a cooling device in Odroid U3 Eduardo Valentin
2014-12-22 16:27   ` [PATCH v2 6/8] hwmon: thermal: Extract __set_pwm() function to only modify PWM duty cycle Lukasz Majewski
2014-12-22 16:27     ` [lm-sensors] [PATCH v2 6/8] hwmon: thermal: Extract __set_pwm() function to only modify PWM duty cyc Lukasz Majewski
2014-12-22 16:27     ` [PATCH v2 6/8] hwmon: thermal: Extract __set_pwm() function to only modify PWM duty cycle Lukasz Majewski
2014-12-29 12:52     ` Guenter Roeck
2014-12-29 12:52       ` [lm-sensors] [PATCH v2 6/8] hwmon: thermal: Extract __set_pwm() function to only modify PWM duty Guenter Roeck
2014-12-29 12:52       ` [PATCH v2 6/8] hwmon: thermal: Extract __set_pwm() function to only modify PWM duty cycle Guenter Roeck
2014-12-22 16:27   ` [PATCH v2 7/8] hwmon: thermal: Read PWM FAN configuration from device tree Lukasz Majewski
2014-12-22 16:27     ` [lm-sensors] " Lukasz Majewski
2014-12-22 16:27     ` Lukasz Majewski
2014-12-29 12:50     ` Guenter Roeck
2014-12-29 12:50       ` [lm-sensors] " Guenter Roeck
2014-12-29 12:50       ` Guenter Roeck
2014-12-22 16:27   ` [PATCH v2 8/8] hwmon: thermal: Code for using PWM FAN as a cooling device Lukasz Majewski
2014-12-22 16:27     ` [lm-sensors] " Lukasz Majewski
2014-12-22 16:27     ` Lukasz Majewski
2015-02-06 16:59 ` [PATCH v3 0/8] hwmon: thermal: Odroid U3: Provide support for Odroid U3 fan Lukasz Majewski
2015-02-06 16:59   ` [lm-sensors] " Lukasz Majewski
2015-02-06 16:59   ` Lukasz Majewski
2015-02-06 16:59   ` [PATCH v3 1/8] thermal: Provide stub for thermal_of_cooling_device_register() function Lukasz Majewski
2015-02-06 16:59     ` [lm-sensors] " Lukasz Majewski
2015-02-06 16:59     ` Lukasz Majewski
2015-02-06 16:59   ` [PATCH v3 2/8] thermal: Provide stub for thermal_cdev_update() function Lukasz Majewski
2015-02-06 16:59     ` [lm-sensors] " Lukasz Majewski
2015-02-06 16:59     ` Lukasz Majewski
2015-02-06 16:59   ` [PATCH v3 3/8] Documentation: dts: Documentation entry to explain how to use PWM FAN as a cooling device Lukasz Majewski
2015-02-06 16:59     ` [lm-sensors] [PATCH v3 3/8] Documentation: dts: Documentation entry to explain how to use PWM FAN as Lukasz Majewski
2015-02-06 16:59     ` [PATCH v3 3/8] Documentation: dts: Documentation entry to explain how to use PWM FAN as a cooling device Lukasz Majewski
2015-02-06 16:59   ` [PATCH v3 4/8] ARM: dts: Add pwm-fan node to the Odroid-U3 board Lukasz Majewski
2015-02-06 16:59     ` [lm-sensors] " Lukasz Majewski
2015-02-06 16:59     ` Lukasz Majewski
2015-02-06 16:59   ` [PATCH v3 5/8] ARM: dts: Add properties to use pwm-fan device as a cooling device in Odroid U3 Lukasz Majewski
2015-02-06 16:59     ` [lm-sensors] [PATCH v3 5/8] ARM: dts: Add properties to use pwm-fan device as a cooling device in Od Lukasz Majewski
2015-02-06 16:59     ` [PATCH v3 5/8] ARM: dts: Add properties to use pwm-fan device as a cooling device in Odroid U3 Lukasz Majewski
2015-02-06 16:59   ` [PATCH v3 6/8] hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty cycle Lukasz Majewski
2015-02-06 16:59     ` [lm-sensors] [PATCH v3 6/8] hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty cyc Lukasz Majewski
2015-02-06 16:59     ` [PATCH v3 6/8] hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty cycle Lukasz Majewski
2015-02-06 18:27     ` Guenter Roeck
2015-02-06 18:27       ` [lm-sensors] [PATCH v3 6/8] hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty Guenter Roeck
2015-02-06 18:27       ` [PATCH v3 6/8] hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty cycle Guenter Roeck
2015-02-08 20:52       ` Lukasz Majewski
2015-02-08 20:52         ` [lm-sensors] [PATCH v3 6/8] hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty Lukasz Majewski
2015-02-08 20:52         ` [PATCH v3 6/8] hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty cycle Lukasz Majewski
2015-02-06 16:59   ` [PATCH v3 7/8] hwmon: pwm-fan: Read PWM FAN configuration from device tree Lukasz Majewski
2015-02-06 16:59     ` [lm-sensors] " Lukasz Majewski
2015-02-06 16:59     ` Lukasz Majewski
2015-02-06 18:36     ` Guenter Roeck
2015-02-06 18:36       ` [lm-sensors] " Guenter Roeck
2015-02-06 18:36       ` Guenter Roeck
2015-02-08 21:36       ` Lukasz Majewski
2015-02-08 21:36         ` [lm-sensors] " Lukasz Majewski
2015-02-08 21:36         ` Lukasz Majewski
2015-02-09  4:40         ` Guenter Roeck
2015-02-09  4:40           ` [lm-sensors] " Guenter Roeck
2015-02-09  4:40           ` Guenter Roeck
2015-02-06 16:59   ` [PATCH v3 8/8] hwmon: pwm-fan: Code for using PWM FAN as a cooling device Lukasz Majewski
2015-02-06 16:59     ` [lm-sensors] " Lukasz Majewski
2015-02-06 16:59     ` Lukasz Majewski
2015-02-18 10:07 ` [PATCH v4 0/8] hwmon: thermal: Odroid U3: Provide support for Odroid U3 fan Lukasz Majewski
2015-02-18 10:07   ` [lm-sensors] " Lukasz Majewski
2015-02-18 10:07   ` Lukasz Majewski
2015-02-18 10:07   ` [PATCH v4 1/8] thermal: Provide stub for thermal_of_cooling_device_register() function Lukasz Majewski
2015-02-18 10:07     ` [lm-sensors] " Lukasz Majewski
2015-02-18 10:07     ` Lukasz Majewski
2015-02-24 19:21     ` Eduardo Valentin
2015-02-24 19:21       ` [lm-sensors] [PATCH v4 1/8] thermal: Provide stub for thermal_of_cooling_device_register() funct Eduardo Valentin
2015-02-24 19:21       ` [PATCH v4 1/8] thermal: Provide stub for thermal_of_cooling_device_register() function Eduardo Valentin
2015-02-25 12:26       ` Lukasz Majewski
2015-02-25 12:26         ` [lm-sensors] [PATCH v4 1/8] thermal: Provide stub for thermal_of_cooling_device_register() funct Lukasz Majewski
2015-02-25 12:26         ` [PATCH v4 1/8] thermal: Provide stub for thermal_of_cooling_device_register() function Lukasz Majewski
2015-02-18 10:07   ` [PATCH v4 2/8] thermal: Provide stub for thermal_cdev_update() function Lukasz Majewski
2015-02-18 10:07     ` [lm-sensors] " Lukasz Majewski
2015-02-18 10:07     ` Lukasz Majewski
2015-02-24 19:21     ` Eduardo Valentin
2015-02-24 19:21       ` [lm-sensors] " Eduardo Valentin
2015-02-24 19:21       ` Eduardo Valentin
2015-02-18 10:07   ` [PATCH v4 3/8] Documentation: dts: Documentation entry to explain how to use PWM FAN as a cooling device Lukasz Majewski
2015-02-18 10:07     ` [lm-sensors] [PATCH v4 3/8] Documentation: dts: Documentation entry to explain how to use PWM FAN as Lukasz Majewski
2015-02-18 10:07     ` [PATCH v4 3/8] Documentation: dts: Documentation entry to explain how to use PWM FAN as a cooling device Lukasz Majewski
2015-02-24 19:25     ` Eduardo Valentin
2015-02-24 19:25       ` [lm-sensors] [PATCH v4 3/8] Documentation: dts: Documentation entry to explain how to use PWM FA Eduardo Valentin
2015-02-24 19:25       ` [PATCH v4 3/8] Documentation: dts: Documentation entry to explain how to use PWM FAN as a cooling device Eduardo Valentin
2015-02-18 10:07   ` [PATCH v4 4/8] ARM: dts: Add pwm-fan node to the Odroid-U3 board Lukasz Majewski
2015-02-18 10:07     ` [lm-sensors] " Lukasz Majewski
2015-02-18 10:07     ` Lukasz Majewski
2015-02-18 13:16     ` Andreas Färber
2015-02-18 13:16       ` [lm-sensors] " Andreas Färber
2015-02-18 13:16       ` Andreas Färber
2015-02-18 10:07   ` [PATCH v4 5/8] ARM: dts: Add properties to use pwm-fan device as a cooling device in Odroid U3 Lukasz Majewski
2015-02-18 10:07     ` [lm-sensors] [PATCH v4 5/8] ARM: dts: Add properties to use pwm-fan device as a cooling device in Od Lukasz Majewski
2015-02-18 10:07     ` [PATCH v4 5/8] ARM: dts: Add properties to use pwm-fan device as a cooling device in Odroid U3 Lukasz Majewski
2015-02-24 19:37     ` Eduardo Valentin
2015-02-24 19:37       ` [lm-sensors] [PATCH v4 5/8] ARM: dts: Add properties to use pwm-fan device as a cooling device i Eduardo Valentin
2015-02-24 19:37       ` [PATCH v4 5/8] ARM: dts: Add properties to use pwm-fan device as a cooling device in Odroid U3 Eduardo Valentin
2015-02-25 13:28       ` Lukasz Majewski
2015-02-25 13:28         ` [lm-sensors] [PATCH v4 5/8] ARM: dts: Add properties to use pwm-fan device as a cooling device i Lukasz Majewski
2015-02-25 13:28         ` [PATCH v4 5/8] ARM: dts: Add properties to use pwm-fan device as a cooling device in Odroid U3 Lukasz Majewski
2015-02-25 18:30         ` Eduardo Valentin
2015-02-25 18:30           ` [lm-sensors] [PATCH v4 5/8] ARM: dts: Add properties to use pwm-fan device as a cooling device i Eduardo Valentin
2015-02-25 18:30           ` [PATCH v4 5/8] ARM: dts: Add properties to use pwm-fan device as a cooling device in Odroid U3 Eduardo Valentin
2015-02-18 10:07   ` [PATCH v4 6/8] hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty cycle Lukasz Majewski
2015-02-18 10:07     ` [lm-sensors] [PATCH v4 6/8] hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty cyc Lukasz Majewski
2015-02-18 10:07     ` [PATCH v4 6/8] hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty cycle Lukasz Majewski
2015-02-18 10:07   ` [PATCH v4 7/8] hwmon: pwm-fan: Read PWM FAN configuration from device tree Lukasz Majewski
2015-02-18 10:07     ` [lm-sensors] " Lukasz Majewski
2015-02-18 10:07     ` Lukasz Majewski
2015-02-21  0:26     ` Guenter Roeck
2015-02-21  0:26       ` [lm-sensors] " Guenter Roeck
2015-02-21  0:26       ` Guenter Roeck
2015-02-23 16:13       ` Lukasz Majewski
2015-02-23 16:13         ` [lm-sensors] " Lukasz Majewski
2015-02-23 16:13         ` Lukasz Majewski
2015-02-23 16:23         ` Guenter Roeck
2015-02-23 16:23           ` [lm-sensors] " Guenter Roeck
2015-02-23 16:23           ` Guenter Roeck
2015-02-23 16:51           ` Lukasz Majewski
2015-02-23 16:51             ` [lm-sensors] " Lukasz Majewski
2015-02-23 16:51             ` Lukasz Majewski
2015-02-23 16:59             ` Guenter Roeck
2015-02-23 16:59               ` [lm-sensors] " Guenter Roeck
2015-02-23 16:59               ` Guenter Roeck
2015-02-18 10:07   ` [PATCH v4 8/8] hwmon: pwm-fan: Code for using PWM FAN as a cooling device Lukasz Majewski
2015-02-18 10:07     ` [lm-sensors] " Lukasz Majewski
2015-02-18 10:07     ` Lukasz Majewski
2015-02-25 15:34 ` [PATCH v5 0/6] hwmon: thermal: Odroid U3: Provide support for Odroid U3 fan Lukasz Majewski
2015-02-25 15:34   ` [lm-sensors] " Lukasz Majewski
2015-02-25 15:34   ` Lukasz Majewski
2015-02-25 15:34   ` [PATCH v5 1/6] Documentation: dts: Documentation entry to explain how to use PWM FAN as a cooling device Lukasz Majewski
2015-02-25 15:34     ` [lm-sensors] [PATCH v5 1/6] Documentation: dts: Documentation entry to explain how to use PWM FAN as Lukasz Majewski
2015-02-25 15:34     ` [PATCH v5 1/6] Documentation: dts: Documentation entry to explain how to use PWM FAN as a cooling device Lukasz Majewski
2015-02-25 19:11     ` Eduardo Valentin
2015-02-25 19:11       ` [lm-sensors] [PATCH v5 1/6] Documentation: dts: Documentation entry to explain how to use PWM FA Eduardo Valentin
2015-02-25 19:11       ` [PATCH v5 1/6] Documentation: dts: Documentation entry to explain how to use PWM FAN as a cooling device Eduardo Valentin
2015-02-25 19:13       ` Eduardo Valentin
2015-02-25 19:13         ` [lm-sensors] [PATCH v5 1/6] Documentation: dts: Documentation entry to explain how to use PWM FA Eduardo Valentin
2015-02-25 19:13         ` [PATCH v5 1/6] Documentation: dts: Documentation entry to explain how to use PWM FAN as a cooling device Eduardo Valentin
2015-02-25 15:34   ` [PATCH v5 2/6] ARM: dts: Add pwm-fan node to the Odroid-U3 board Lukasz Majewski
2015-02-25 15:34     ` [lm-sensors] " Lukasz Majewski
2015-02-25 15:34     ` Lukasz Majewski
2015-02-25 15:34   ` [PATCH v5 3/6] ARM: dts: Add properties to use pwm-fan device as a cooling device in Odroid U3 Lukasz Majewski
2015-02-25 15:34     ` [lm-sensors] [PATCH v5 3/6] ARM: dts: Add properties to use pwm-fan device as a cooling device in Od Lukasz Majewski
2015-02-25 15:34     ` [PATCH v5 3/6] ARM: dts: Add properties to use pwm-fan device as a cooling device in Odroid U3 Lukasz Majewski
2015-02-25 18:49     ` Eduardo Valentin
2015-02-25 18:49       ` [lm-sensors] [PATCH v5 3/6] ARM: dts: Add properties to use pwm-fan device as a cooling device i Eduardo Valentin
2015-02-25 18:49       ` [PATCH v5 3/6] ARM: dts: Add properties to use pwm-fan device as a cooling device in Odroid U3 Eduardo Valentin
2015-02-25 15:34   ` [PATCH v5 4/6] hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty cycle Lukasz Majewski
2015-02-25 15:34     ` [lm-sensors] [PATCH v5 4/6] hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty cyc Lukasz Majewski
2015-02-25 15:34     ` [PATCH v5 4/6] hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty cycle Lukasz Majewski
2015-02-25 15:34   ` [PATCH v5 5/6] hwmon: pwm-fan: Read PWM FAN configuration from device tree Lukasz Majewski
2015-02-25 15:34     ` [lm-sensors] " Lukasz Majewski
2015-02-25 15:34     ` Lukasz Majewski
2015-02-25 15:34   ` [PATCH v5 6/6] hwmon: pwm-fan: Code for using PWM FAN as a cooling device Lukasz Majewski
2015-02-25 15:34     ` [lm-sensors] " Lukasz Majewski
2015-02-25 15:34     ` Lukasz Majewski
2015-02-25 18:24     ` Eduardo Valentin
2015-02-25 18:24       ` [lm-sensors] " Eduardo Valentin
2015-02-25 18:24       ` Eduardo Valentin
2015-02-25 17:18   ` [PATCH v5 0/6] hwmon: thermal: Odroid U3: Provide support for Odroid U3 fan Guenter Roeck
2015-02-25 17:18     ` [lm-sensors] " Guenter Roeck
2015-02-25 17:18     ` Guenter Roeck
2015-02-25 18:29     ` Eduardo Valentin
2015-02-25 18:29       ` [lm-sensors] " Eduardo Valentin
2015-02-25 18:29       ` Eduardo Valentin
2015-02-25 18:42       ` Guenter Roeck
2015-02-25 18:42         ` [lm-sensors] " Guenter Roeck
2015-02-25 18:42         ` Guenter Roeck
2015-02-26 13:59 ` [PATCH v6 " Lukasz Majewski
2015-02-26 13:59   ` [lm-sensors] " Lukasz Majewski
2015-02-26 13:59   ` Lukasz Majewski
2015-02-26 13:59   ` [PATCH v6 1/6] Documentation: dts: Documentation entry to explain how to use PWM FAN as a cooling device Lukasz Majewski
2015-02-26 13:59     ` [lm-sensors] [PATCH v6 1/6] Documentation: dts: Documentation entry to explain how to use PWM FAN as Lukasz Majewski
2015-02-26 13:59     ` [PATCH v6 1/6] Documentation: dts: Documentation entry to explain how to use PWM FAN as a cooling device Lukasz Majewski
2015-02-26 13:59   ` [PATCH v6 2/6] ARM: dts: Add pwm-fan node to the Odroid-U3 board Lukasz Majewski
2015-02-26 13:59     ` [lm-sensors] " Lukasz Majewski
2015-02-26 13:59     ` Lukasz Majewski
2015-02-26 13:59   ` [PATCH v6 3/6] ARM: dts: Add properties to use pwm-fan device as a cooling device in Odroid U3 Lukasz Majewski
2015-02-26 13:59     ` [lm-sensors] [PATCH v6 3/6] ARM: dts: Add properties to use pwm-fan device as a cooling device in Od Lukasz Majewski
2015-02-26 13:59     ` [PATCH v6 3/6] ARM: dts: Add properties to use pwm-fan device as a cooling device in Odroid U3 Lukasz Majewski
2015-02-26 13:59   ` [PATCH v6 4/6] hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty cycle Lukasz Majewski
2015-02-26 13:59     ` [lm-sensors] [PATCH v6 4/6] hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty cyc Lukasz Majewski
2015-02-26 13:59     ` [PATCH v6 4/6] hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty cycle Lukasz Majewski
2015-02-26 13:59   ` [PATCH v6 5/6] hwmon: pwm-fan: Read PWM FAN configuration from device tree Lukasz Majewski
2015-02-26 13:59     ` [lm-sensors] " Lukasz Majewski
2015-02-26 13:59     ` Lukasz Majewski
2015-02-26 13:59   ` [PATCH v6 6/6] hwmon: pwm-fan: Code for using PWM FAN as a cooling device Lukasz Majewski
2015-02-26 13:59     ` [lm-sensors] " Lukasz Majewski
2015-02-26 13:59     ` Lukasz Majewski
2015-02-26 14:12     ` Guenter Roeck
2015-02-26 14:12       ` [lm-sensors] " Guenter Roeck
2015-02-26 14:12       ` Guenter Roeck
2015-02-26 14:40       ` Lukasz Majewski
2015-02-26 14:40         ` [lm-sensors] " Lukasz Majewski
2015-02-26 14:40         ` Lukasz Majewski
2015-03-04 12:03 ` [PATCH RESEND RESEND v6 0/6] hwmon: thermal: Odroid U3: Provide support for Odroid U3 fan Lukasz Majewski
2015-03-04 12:03   ` [lm-sensors] [PATCH RESEND RESEND v6 0/6] hwmon: thermal: Odroid U3: Provide support for Odroid U3 f Lukasz Majewski
2015-03-04 12:03   ` [PATCH RESEND RESEND v6 0/6] hwmon: thermal: Odroid U3: Provide support for Odroid U3 fan Lukasz Majewski
2015-03-04 12:03   ` [PATCH RESEND v6 1/6] Documentation: dts: Documentation entry to explain how to use PWM FAN as a cooling device Lukasz Majewski
2015-03-04 12:03     ` [lm-sensors] [PATCH RESEND v6 1/6] Documentation: dts: Documentation entry to explain how to use PWM Lukasz Majewski
2015-03-04 12:03     ` [PATCH RESEND v6 1/6] Documentation: dts: Documentation entry to explain how to use PWM FAN as a cooling device Lukasz Majewski
2015-03-04 12:03   ` [PATCH RESEND v6 2/6] ARM: dts: Add pwm-fan node to the Odroid-U3 board Lukasz Majewski
2015-03-04 12:03     ` [lm-sensors] " Lukasz Majewski
2015-03-04 12:03     ` Lukasz Majewski
2015-03-04 12:03   ` [PATCH RESEND v6 3/6] ARM: dts: Add properties to use pwm-fan device as a cooling device in Odroid U3 Lukasz Majewski
2015-03-04 12:03     ` [lm-sensors] [PATCH RESEND v6 3/6] ARM: dts: Add properties to use pwm-fan device as a cooling devic Lukasz Majewski
2015-03-04 12:03     ` [PATCH RESEND v6 3/6] ARM: dts: Add properties to use pwm-fan device as a cooling device in Odroid U3 Lukasz Majewski
2015-03-04 12:03   ` [PATCH RESEND v6 4/6] hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty cycle Lukasz Majewski
2015-03-04 12:03     ` [lm-sensors] [PATCH RESEND v6 4/6] hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM d Lukasz Majewski
2015-03-04 12:03     ` [PATCH RESEND v6 4/6] hwmon: pwm-fan: Extract __set_pwm() function to only modify PWM duty cycle Lukasz Majewski
2015-03-04 12:03   ` [PATCH RESEND v6 5/6] hwmon: pwm-fan: Read PWM FAN configuration from device tree Lukasz Majewski
2015-03-04 12:03     ` [lm-sensors] " Lukasz Majewski
2015-03-04 12:03     ` Lukasz Majewski
2015-03-04 12:03   ` [PATCH RESEND v6 6/6] hwmon: pwm-fan: Code for using PWM FAN as a cooling device Lukasz Majewski
2015-03-04 12:03     ` [lm-sensors] " Lukasz Majewski
2015-03-04 12:03     ` Lukasz Majewski
2015-08-11 13:07   ` [PATCH RESEND v6 0/3] dts: thermal: Odroid U3: Provide support for Odroid U3 fan Lukasz Majewski
2015-08-11 13:07     ` [PATCH RESEND v6 1/3] Documentation: dts: Documentation entry to explain how to use PWM FAN as a cooling device Lukasz Majewski
2015-08-13  0:17       ` Krzysztof Kozlowski
2015-08-14  9:36         ` Kukjin Kim
2015-08-16  9:35           ` Krzysztof Kozlowski
2015-09-16 11:00     ` [PATCH RESEND v6 0/3] dts: thermal: Odroid U3: Provide support for Odroid U3 fan Thomas Pietrowski
2015-09-16 11:57       ` Krzysztof Kozlowski
2015-08-11 13:14   ` [PATCH RESEND v6 2/3] ARM: dts: Add pwm-fan node to the Odroid-U3 board Lukasz Majewski
2015-08-13  0:35     ` Krzysztof Kozlowski
2015-08-11 13:15   ` [PATCH RESEND v6 3/3] ARM: dts: Add properties to use pwm-fan device as a cooling device in Odroid U3 Lukasz Majewski
2015-08-13  0:35     ` Krzysztof Kozlowski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.