Skip to contentSkip to conversation

powerpc/powernv: hwmon driver for power, fan rpm, voltage and temperature

PATCH Applied Neelesh Gupta 2 participants 2 messages Jul 8, 2014 1 message not in the archive

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v5 1/1 powerpc/powernv: hwmon driver for power, fan rpm, voltage and temperature

This patch adds basic kernel support for reading power values, fan speed rpm, voltage and temperature data on powernv platforms which will be exported to user space through sysfs interface.

Test results:
-------------
[root@tul163p1 ~]# sensors
ibmpowernv-isa-0000

Adapter: ISA adapter
fan1:        5465 RPM  (min =    0 RPM)
fan2:        5152 RPM  (min =    0 RPM)
fan3:        5521 RPM  (min =    0 RPM)
fan4:        4891 RPM  (min =    0 RPM)
fan5:           0 RPM  (min =    0 RPM)
fan6:           0 RPM  (min =    0 RPM)
fan7:        7480 RPM  (min =    0 RPM)
fan8:        7944 RPM  (min =    0 RPM)
temp1:        +39.0°C  (high =  +0.0°C)
power1:      190.00 W  

[root@tul163p1 ~]# ls /sys/devices/platform/
alarmtimer ibmpowernv.0 power rtc-generic serial8250 uevent [root@tul163p1 ~]# ls /sys/devices/platform/ibmpowernv.0/hwmon/hwmon0/
device fan2_min fan4_min fan6_min fan8_min power

fan1_fault  fan3_fault	fan5_fault  fan7_fault	in1_fault  power1_input
fan1_input  fan3_input	fan5_input  fan7_input	in2_fault  subsystem
fan1_min    fan3_min	fan5_min    fan7_min	in3_fault  temp1_input
fan2_fault  fan4_fault	fan6_fault  fan8_fault	in4_fault  temp1_max
fan2_input  fan4_input	fan6_input  fan8_input	name	   uevent
[root@tul163p1 ~]# ls /sys/class/hwmon/hwmon0/
device	    fan2_min	fan4_min    fan6_min	fan8_min   power
fan1_fault  fan3_fault	fan5_fault  fan7_fault	in1_fault  power1_input
fan1_input  fan3_input	fan5_input  fan7_input	in2_fault  subsystem
fan1_min    fan3_min	fan5_min    fan7_min	in3_fault  temp1_input
fan2_fault  fan4_fault	fan6_fault  fan8_fault	in4_fault  temp1_max
fan2_input  fan4_input	fan6_input  fan8_input	name	   uevent

[root@tul163p1 ~]#

---

Changes in v5
=============
- Addressed couple minor comments in v4.

Changes in v4
=============
- Replaced pr_err() with dev_err() for logging print messages.
- Using kstrtou32() function for converting string to u32 instead of sscanf().

Changes in v3
=============
- Fixed an endianness bug leading the driver to break on LE.
- Fixed a bug that when one of the 'attribute_group' not populated, following groups attributes were dropped.
- Rewrite the get_sensor_index_attr() function to handle all the error scenarios like 'sscanf' etc.
- Fixed all the errors/warnings related to coding style/whitespace.
- Added 'Documentation' files.
- Addressed remaining review comments on V2.

Changes in v2
=============
- Generic use of devm_* functions in hwmon like using devm_kzalloc() for dynamic memory request, avoiding the need to explicit free of memory. Adding 'struct attribute_group' as member of platform data structure to be populated and then passed to devm_hwmon_device_register_with_groups().

Note: Having an array of pointers of 'attribute_group' and each group corresponds to 'enum sensors' type. Not completely sure, if it's ideal or could have just one group populated with attributes of sensor types?

- 'ibmpowernv' is not hot-pluggable device so moving 'platform_driver' callback function (probe) as part of __init code.
- Fixed issues related to coding style.
- Other general comments in v1.

 .../devicetree/bindings/hwmon/ibmpowernv.txt       |   23 +
 Documentation/hwmon/ibmpowernv                     |   41 ++
 drivers/hwmon/Kconfig                              |   11 +
 drivers/hwmon/Makefile                             |    1 
 drivers/hwmon/ibmpowernv.c                         |  364 ++++++++++++++++++++
 5 files changed, 440 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/hwmon/ibmpowernv.txt
 create mode 100644 Documentation/hwmon/ibmpowernv
 create mode 100644 drivers/hwmon/ibmpowernv.c
Documentation/devicetree/bindings/hwmon/ibmpowernv.txt new file +23 -0
new file mode 100644
index 0000000..f93242b
@@ -0,0 +1,23 @@
+IBM POWERNV platform sensors
+----------------------------
+
+Required node properties:
+- compatible: must be one of
+		"ibm,opal-sensor-cooling-fan"
+		"ibm,opal-sensor-amb-temp"
+		"ibm,opal-sensor-power-supply"
+		"ibm,opal-sensor-power"
+- sensor-id: an opaque id provided by the firmware to the kernel, identifies a
+	     given sensor and its attribute data
+
+Example sensors node:
+
+cooling-fan#8-data {
+	sensor-id = <0x7052107>;
+	compatible = "ibm,opal-sensor-cooling-fan";
+};
+
+amb-temp#1-thrs {
+	sensor-id = <0x5096000>;
+	compatible = "ibm,opal-sensor-amb-temp";
+};
Documentation/hwmon/ibmpowernv new file +41 -0

41 lines not on this page · raw message

drivers/hwmon/Kconfig +11 -0
index 02d3d85..29c3fcb 100644
@@ -554,6 +554,17 @@ config SENSORS_IBMPEX
 	  This driver can also be built as a module.  If so, the module
 	  will be called ibmpex.
 
+config SENSORS_IBMPOWERNV
+	tristate "IBM POWERNV platform sensors"
+	depends on PPC_POWERNV
+	default y
+	help
+	  If you say yes here you get support for the temperature/fan/power
+	  sensors on your PowerNV platform.
+
+	  This driver can also be built as a module. If so, the module
+	  will be called ibmpowernv.
+
 config SENSORS_IIO_HWMON
 	tristate "Hwmon driver that uses channels specified via iio maps"
 	depends on IIO
drivers/hwmon/Makefile +1 -0
index 3dc0f02..fc4ed26 100644
@@ -71,6 +71,7 @@ obj-$(CONFIG_SENSORS_ULTRA45)	+= ultra45_env.o
 obj-$(CONFIG_SENSORS_I5K_AMB)	+= i5k_amb.o
 obj-$(CONFIG_SENSORS_IBMAEM)	+= ibmaem.o
 obj-$(CONFIG_SENSORS_IBMPEX)	+= ibmpex.o
+obj-$(CONFIG_SENSORS_IBMPOWERNV)+= ibmpowernv.o
 obj-$(CONFIG_SENSORS_IIO_HWMON) += iio_hwmon.o
 obj-$(CONFIG_SENSORS_INA209)	+= ina209.o
 obj-$(CONFIG_SENSORS_INA2XX)	+= ina2xx.o
drivers/hwmon/ibmpowernv.c new file +364 -0

364 lines not on this page · raw message

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20140708090315.3866.15604.stgit-bi+AKbBUZKY6gyzm1THtWbp2dZbC/[email protected]

#2 lore raw
Quoted 36 lines · Neelesh Gupta

This patch adds basic kernel support for reading power values, fan speed rpm, voltage and temperature data on powernv platforms which will be exported to user space through sysfs interface.

Test results:
-------------
[root@tul163p1 ~]# sensors
ibmpowernv-isa-0000

Adapter: ISA adapter
fan1:        5465 RPM  (min =    0 RPM)
fan2:        5152 RPM  (min =    0 RPM)
fan3:        5521 RPM  (min =    0 RPM)
fan4:        4891 RPM  (min =    0 RPM)
fan5:           0 RPM  (min =    0 RPM)
fan6:           0 RPM  (min =    0 RPM)
fan7:        7480 RPM  (min =    0 RPM)
fan8:        7944 RPM  (min =    0 RPM)
temp1:        +39.0°C  (high =  +0.0°C)
power1:      190.00 W

[root@tul163p1 ~]# ls /sys/devices/platform/
alarmtimer ibmpowernv.0 power rtc-generic serial8250 uevent [root@tul163p1 ~]# ls /sys/devices/platform/ibmpowernv.0/hwmon/hwmon0/
device fan2_min fan4_min fan6_min fan8_min power

fan1_fault  fan3_fault	fan5_fault  fan7_fault	in1_fault  power1_input
fan1_input  fan3_input	fan5_input  fan7_input	in2_fault  subsystem
fan1_min    fan3_min	fan5_min    fan7_min	in3_fault  temp1_input
fan2_fault  fan4_fault	fan6_fault  fan8_fault	in4_fault  temp1_max
fan2_input  fan4_input	fan6_input  fan8_input	name	   uevent
[root@tul163p1 ~]# ls /sys/class/hwmon/hwmon0/
device	    fan2_min	fan4_min    fan6_min	fan8_min   power
fan1_fault  fan3_fault	fan5_fault  fan7_fault	in1_fault  power1_input
fan1_input  fan3_input	fan5_input  fan7_input	in2_fault  subsystem
fan1_min    fan3_min	fan5_min    fan7_min	in3_fault  temp1_input
fan2_fault  fan4_fault	fan6_fault  fan8_fault	in4_fault  temp1_max
fan2_input  fan4_input	fan6_input  fan8_input	name	   uevent
Quoted 3 lines

[root@tul163p1 ~]#

Applied to -next, with a minor cleanup.

Thanks for your patience,

Guenter

Documentation/hwmon/ibmpowernv line 1

Quoted 7 lines
Documentation/hwmon/ibmpowernv new file +1 -0
new file mode 100644
index 0000000..644245a
@@ -0,0 +1,41 @@
+Kernel Driver IBMPOWENV

s/IBMPOWENV/IBMPOWERNV/

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html