drivers: hwmon: Add On-Chip Controller driver
Subsystems (3)
v9 cover drivers: hwmon: Add On-Chip Controller driver
From: "Edward A. James" <[email protected]>
This patchset adds a hwmon driver to support the OCC (On-Chip Controller) on the IBM POWER8 and POWER9 processors, from a BMC (Baseboard Management Controller). The OCC is an embedded processor that provides real time power and thermal monitoring.
The driver provides an interface on a BMC to poll OCC sensor data, set user power caps, and perform some basic OCC error handling. It interfaces with userspace through hwmon.
The driver is currently functional only for the OCC on POWER8 chips. Communicating with the POWER9 OCC requries FSI support.
since v8:
* drop P9 sensors patch. This patch was mainly included to demonstrate
why we abstracted out the sensor-specific code into the occ_p8 functions. However, since we haven't submitted the transfer protocol to the OCC for P9 yet, we shouldn't submit this unused P9 code yet.
* fix string access in hwmon read_string() function. Thanks Guenter.
* change parameter to const char ** in read_string() function to match
upcoming hwmon code.
Edward A. James (5):
hwmon: Add core On-Chip Controller support for POWER CPUs
hwmon: occ: Add sysfs interface
hwmon: occ: Add I2C transport implementation for SCOM operations
hwmon: occ: Add callbacks for parsing P8 OCC datastructures
hwmon: occ: Add hwmon implementation for the P8 OCC
Documentation/devicetree/bindings/hwmon/occ.txt | 13 + Documentation/hwmon/occ | 113 ++++++ MAINTAINERS | 7 + drivers/hwmon/Kconfig | 2 + drivers/hwmon/Makefile | 1 + drivers/hwmon/occ/Kconfig | 28 ++ drivers/hwmon/occ/Makefile | 3 + drivers/hwmon/occ/occ.c | 440 ++++++++++++++++++++++++ drivers/hwmon/occ/occ.h | 77 +++++ drivers/hwmon/occ/occ_p8.c | 256 ++++++++++++++ drivers/hwmon/occ/occ_p8.h | 25 ++ drivers/hwmon/occ/occ_p8_i2c.c | 99 ++++++ drivers/hwmon/occ/occ_scom_i2c.c | 69 ++++ drivers/hwmon/occ/occ_scom_i2c.h | 21 ++ drivers/hwmon/occ/occ_sysfs.c | 253 ++++++++++++++ drivers/hwmon/occ/occ_sysfs.h | 25 ++ drivers/hwmon/occ/scom.h | 42 +++ 17 files changed, 1474 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/occ.txt create mode 100644 Documentation/hwmon/occ create mode 100644 drivers/hwmon/occ/Kconfig create mode 100644 drivers/hwmon/occ/Makefile create mode 100644 drivers/hwmon/occ/occ.c create mode 100644 drivers/hwmon/occ/occ.h create mode 100644 drivers/hwmon/occ/occ_p8.c create mode 100644 drivers/hwmon/occ/occ_p8.h create mode 100644 drivers/hwmon/occ/occ_p8_i2c.c create mode 100644 drivers/hwmon/occ/occ_scom_i2c.c create mode 100644 drivers/hwmon/occ/occ_scom_i2c.h create mode 100644 drivers/hwmon/occ/occ_sysfs.c create mode 100644 drivers/hwmon/occ/occ_sysfs.h create mode 100644 drivers/hwmon/occ/scom.h
Signature · 1 line
1.8.3.1
PATCH v9 1/5 hwmon: Add core On-Chip Controller support for POWER CPUs
From: "Edward A. James" <[email protected]>
Add core support for polling the OCC for it's sensor data and parsing that data into sensor-specific information.
--- Documentation/hwmon/occ | 42 +++++ MAINTAINERS | 7 + drivers/hwmon/Kconfig | 2 + drivers/hwmon/Makefile | 1 + drivers/hwmon/occ/Kconfig | 13 ++ drivers/hwmon/occ/Makefile | 1 + drivers/hwmon/occ/occ.c | 440 +++++++++++++++++++++++++++++++++++++++++++++ drivers/hwmon/occ/occ.h | 77 ++++++++ drivers/hwmon/occ/scom.h | 42 +++++ 9 files changed, 625 insertions(+) create mode 100644 Documentation/hwmon/occ create mode 100644 drivers/hwmon/occ/Kconfig create mode 100644 drivers/hwmon/occ/Makefile create mode 100644 drivers/hwmon/occ/occ.c create mode 100644 drivers/hwmon/occ/occ.h create mode 100644 drivers/hwmon/occ/scom.h
Documentation/hwmon/occ new file +42 -0
@@ -0,0 +1,42 @@ +================= +Kernel driver occ +================= + +Supported chips: + * POWER8 + * POWER9 + +Please note that the driver does not run on these processors. Instead, the +driver runs on a connected service processor, such as an AST2400. (see the +BMC - Host Communications section). + +Author: Eddie James <[email protected]> + +Description +----------- + +This driver implements support for the OCC (On-Chip Controller) on the IBM +POWER8 and POWER9 processors, from a BMC (Baseboard Management Controller). The +OCC is an embedded processor that provides real time power and thermal +monitoring. + +This driver provides an interface on a BMC to poll OCC sensor data, set user +power caps, and perform some basic OCC error handling. + +Currently, all versions of the OCC support four types of sensor data: power, +temperature, frequency, and "caps," which indicate limits and thresholds used +internally on the OCC. + +BMC - Host Communications +------------------------- + +For the POWER8 application, the BMC can communicate with the P8 over I2C bus. +However, to access the OCC register space, any data transfer must use a SCOM +operation. SCOM is a procedure to initiate a data transfer, typically of 8 +bytes. SCOMs consist of writing a 32-bit command register and then +reading/writing two 32-bit data registers. This driver implements these +SCOM operations over I2C bus in order to communicate with the OCC. + +For the POWER9 application, the BMC can communicate with the P9 over FSI bus +and SBE engine. Once again, SCOM operations are required. This driver will +implement SCOM ops over FSI/SBE. This will require the FSI driver.
MAINTAINERS +7 -0
@@ -9266,6 +9266,13 @@ T: git git://linuxtv.org/media_tree.git S: Maintained F: drivers/media/i2c/ov7670.c +ON-CHIP CONTROLLER HWMON POWER8/POWER9 DRIVER +M: Eddie James <[email protected]> +L: [email protected] +S: Maintained +F: Documentation/hwmon/occ +F: drivers/hwmon/occ/ + ONENAND FLASH DRIVER M: Kyungmin Park <[email protected]> L: [email protected]
drivers/hwmon/Kconfig +2 -0
@@ -1240,6 +1240,8 @@ config SENSORS_NSA320 This driver can also be built as a module. If so, the module will be called nsa320-hwmon. +source drivers/hwmon/occ/Kconfig + config SENSORS_PCF8591 tristate "Philips PCF8591 ADC/DAC" depends on I2C
drivers/hwmon/Makefile +1 -0
@@ -170,6 +170,7 @@ obj-$(CONFIG_SENSORS_WM831X) += wm831x-hwmon.o obj-$(CONFIG_SENSORS_WM8350) += wm8350-hwmon.o obj-$(CONFIG_SENSORS_XGENE) += xgene-hwmon.o +obj-$(CONFIG_SENSORS_IBM_OCC) += occ/ obj-$(CONFIG_PMBUS) += pmbus/ ccflags-$(CONFIG_HWMON_DEBUG_CHIP) := -DDEBUG
drivers/hwmon/occ/Kconfig new file +13 -0
@@ -0,0 +1,13 @@ +# +# On Chip Controller configuration +# + +menuconfig SENSORS_IBM_OCC + bool "IBM On-Chip Controller" + help + If you say yes here you get support to monitor IBM Power CPU + sensors via the On-Chip Controller (OCC), from a service + processor. + + Generally this is used by management controllers such as a BMC + on an OpenPower system.
drivers/hwmon/occ/Makefile new file +1 -0
@@ -0,0 +1 @@ +obj-$(CONFIG_SENSORS_IBM_OCC) += occ.o
drivers/hwmon/occ/occ.c new file +440 -0
440 lines not on this page · raw message
drivers/hwmon/occ/occ.h new file +77 -0
77 lines not on this page · raw message
drivers/hwmon/occ/scom.h new file +42 -0
42 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v9 2/5 hwmon: occ: Add sysfs interface
In reply to Eddie JamesFrom: "Edward A. James" <eajames-r/[email protected]>
Add a generic mechanism to expose the sensors provided by the OCC in sysfs.
--- Documentation/hwmon/occ | 62 +++++++++++ drivers/hwmon/occ/Makefile | 2 +- drivers/hwmon/occ/occ_sysfs.c | 253 ++++++++++++++++++++++++++++++++++++++++++ drivers/hwmon/occ/occ_sysfs.h | 25 +++++ 4 files changed, 341 insertions(+), 1 deletion(-) create mode 100644 drivers/hwmon/occ/occ_sysfs.c create mode 100644 drivers/hwmon/occ/occ_sysfs.h
Documentation/hwmon/occ +62 -0
@@ -27,6 +27,68 @@ Currently, all versions of the OCC support four types of sensor data: power, temperature, frequency, and "caps," which indicate limits and thresholds used internally on the OCC. +sysfs Entries +------------- + +The OCC driver uses the hwmon sysfs framework to provide data to userspace. + +The driver exports a number of sysfs files for each type of sensor. The +sensor-specific files vary depending on the processor type, though many of the +attributes are common for both the POWER8 and POWER9. + +The hwmon interface cannot define every type of sensor that may be used. +Therefore, the frequency sensor on the OCC uses the "input" type sensor defined +by the hwmon interface, rather than defining a new type of custom sensor. + +Below are detailed the names and meaning of each sensor file for both types of +processors. All sensors are read-only unless otherwise specified. <x> indicates +the hwmon index. sensor id indicates the unique internal OCC identifer. Please +see the POWER OCC specification for details on all these sensor values. + +frequency: + all processors: + in<x>_input - frequency value + in<x>_label - sensor id +temperature: + POWER8: + temp<x>_input - temperature value + temp<x>_label - sensor id + POWER9 (in addition to above): + temp<x>_type - FRU type + +power: + POWER8: + power<x>_input - power value + power<x>_label - sensor id + power<x>_average - accumulator + power<x>_average_interval - update tag (number of samples in + accumulator) + POWER9: + power<x>_input - power value + power<x>_label - sensor id + power<x>_average_min - accumulator[0] + power<x>_average_max - accumulator[1] (64 bits total) + power<x>_average_interval - update tag + power<x>_reset_history - (function_id | (apss_channel << 8) + +caps: + POWER8: + power<x>_cap - current powercap + power<x>_cap_max - max powercap + power<x>_cap_min - min powercap + power<x>_max - normal powercap + power<x>_alarm - user powercap, r/w + POWER9: + power<x>_cap_alarm - user powercap source + +The driver also provides two sysfs entries through hwmon to better +control the driver and monitor the master OCC. Though there may be multiple +OCCs present on the system, these two files are only present for the "master" +OCC. + name - read the name of the driver + update_interval - read or write the minimum interval for polling the + OCC. + BMC - Host Communications -------------------------
drivers/hwmon/occ/Makefile +1 -1
@@ -1 +1 @@ -obj-$(CONFIG_SENSORS_IBM_OCC) += occ.o +obj-$(CONFIG_SENSORS_IBM_OCC) += occ.o occ_sysfs.o
drivers/hwmon/occ/occ_sysfs.c new file +253 -0
253 lines not on this page · raw message
drivers/hwmon/occ/occ_sysfs.h new file +25 -0
@@ -0,0 +1,25 @@ +/* +* occ_sysfs.h - OCC sysfs interface +* +* This file contains the data structures and function prototypes for the OCC +* hwmon sysfs entries. +* +* Copyright 2017 IBM Corp. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +*/ + +#ifndef __OCC_SYSFS_H__ +#define __OCC_SYSFS_H__ + +struct occ ; +struct device ; +struct occ_sysfs ; + +struct occ_sysfs *occ_sysfs_start (struct device *dev,struct occ *occ, +const u32 *sensor_hwmon_configs, +const char *name); +#endif /* __OCC_SYSFS_H__ */
Signature · 6 lines
1.8.3.1 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Guenter Roeck
maintainerRe: [PATCH linux v9 2/5] hwmon: occ: Add sysfs interface
Quoted 180 lines · Eddie James
From: "Edward A. James" <[email protected]>
Add a generic mechanism to expose the sensors provided by the OCC in sysfs.
Signed-off-by Edward A. James <[email protected]>Signed-off-by Andrew Jeffery <[email protected]>--- Documentation/hwmon/occ | 62 +++++++++++ drivers/hwmon/occ/Makefile | 2 +- drivers/hwmon/occ/occ_sysfs.c | 253 ++++++++++++++++++++++++++++++++++++++++++ drivers/hwmon/occ/occ_sysfs.h | 25 +++++ 4 files changed, 341 insertions(+), 1 deletion(-) create mode 100644 drivers/hwmon/occ/occ_sysfs.c create mode 100644 drivers/hwmon/occ/occ_sysfs.hDocumentation/hwmon/occ +62
-0@@ -27,6 +27,68 @@ Currently, all versions of the OCC support four types of sensor data: power, temperature, frequency, and "caps," which indicate limits and thresholds used internally on the OCC. +sysfs Entries +------------- + +The OCC driver uses the hwmon sysfs framework to provide data to userspace. + +The driver exports a number of sysfs files for each type of sensor. The +sensor-specific files vary depending on the processor type, though many of the +attributes are common for both the POWER8 and POWER9. + +The hwmon interface cannot define every type of sensor that may be used. +Therefore, the frequency sensor on the OCC uses the "input" type sensor defined +by the hwmon interface, rather than defining a new type of custom sensor. + +Below are detailed the names and meaning of each sensor file for both types of +processors. All sensors are read-only unless otherwise specified. <x> indicates +the hwmon index. sensor id indicates the unique internal OCC identifer. Please +see the POWER OCC specification for details on all these sensor values. + +frequency: + all processors: + in<x>_input - frequency value + in<x>_label - sensor id +temperature: + POWER8: + temp<x>_input - temperature value + temp<x>_label - sensor id + POWER9 (in addition to above): + temp<x>_type - FRU type + +power: + POWER8: + power<x>_input - power value + power<x>_label - sensor id + power<x>_average - accumulator + power<x>_average_interval - update tag (number of samples in + accumulator) + POWER9: + power<x>_input - power value + power<x>_label - sensor id + power<x>_average_min - accumulator[0] + power<x>_average_max - accumulator[1] (64 bits total) + power<x>_average_interval - update tag + power<x>_reset_history - (function_id | (apss_channel << 8) + +caps: + POWER8: + power<x>_cap - current powercap + power<x>_cap_max - max powercap + power<x>_cap_min - min powercap + power<x>_max - normal powercap + power<x>_alarm - user powercap, r/w + POWER9: + power<x>_cap_alarm - user powercap source + +The driver also provides two sysfs entries through hwmon to better +control the driver and monitor the master OCC. Though there may be multiple +OCCs present on the system, these two files are only present for the "master" +OCC. + name - read the name of the driver + update_interval - read or write the minimum interval for polling the + OCC. + BMC - Host Communications -------------------------drivers/hwmon/occ/Makefile +1
-1@@ -1 +1 @@ -obj-$(CONFIG_SENSORS_IBM_OCC) += occ.o +obj-$(CONFIG_SENSORS_IBM_OCC) += occ.o occ_sysfs.odrivers/hwmon/occ/occ_sysfs.c new file +78
-0@@ -0,0 +1,253 @@ +/* +* occ_sysfs.c - OCC sysfs interface +* +* This file contains the methods and data structures for implementing the OCC +* hwmon sysfs entries. +* +* Copyright 2017 IBM Corp. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +*/ + +#include <linux/delay.h> +#include <linux/device.h> +#include <linux/err.h> +#include <linux/hwmon.h> +#include <linux/hwmon-sysfs.h> +#include <linux/init.h> +#include <linux/jiffies.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/mutex.h> +#include <linux/slab.h> +#include "occ.h" +#include "occ_sysfs.h" + +#define OCC_HWMON_NAME_LENGTH 32 + +struct occ_sysfs { +struct device *dev; +struct occ *occ; + +char label_buffer[OCC_HWMON_NAME_LENGTH +1 ]; +char hwmon_name[OCC_HWMON_NAME_LENGTH +1 ]; +const u32 *sensor_hwmon_configs; +struct hwmon_channel_info **occ_sensors; +struct hwmon_chip_info occ_info; +u16 user_powercap; +}; + +static int occ_hwmon_read (struct device *dev,enum hwmon_sensor_types type, +u32 attr,int channel,long *val) +{ +int rc; +struct occ_sysfs *driver =dev_get_drvdata (dev); +struct occ *occ = driver->occ; + +switch (type) { +case hwmon_in: + rc =occ_get_sensor_field (occ,FREQ , channel, attr, val); +break ; +case hwmon_temp: + rc =occ_get_sensor_field (occ,TEMP , channel, attr, val); +break ; +case hwmon_power: + rc =occ_get_sensor_field (occ,POWER , channel, attr, val); +break ; +default : + rc = -EOPNOTSUPP ; + } + +return rc; +} + +static int occ_hwmon_read_string (struct device *dev, +enum hwmon_sensor_types type,u32 attr, +int channel,const char **str) +{ +int rc; +unsigned long val =0 ; +struct occ_sysfs *driver =dev_get_drvdata (dev); + +if (!((type == hwmon_in && attr == hwmon_in_label) || + (type == hwmon_temp && attr == hwmon_temp_label) || + (type == hwmon_power && attr == hwmon_power_label))) +return -EOPNOTSUPP ;
drivers/hwmon/occ/occ_sysfs.c line 88
Quoted 10 lines
drivers/hwmon/occ/occ_sysfs.c new file +10
-0+ +/* will fetch the "label", the sensor_id */ + rc =occ_hwmon_read (dev, type, attr, channel, &val); +if (rc <0 ) +return rc; + +/* just use one label buffer for all sensors. works with current hwmon +* implementation. only alternative is to store a buffer for each +* sensor, which gets expensive quickly. +*/
Sorry for the late reply.
No, this doesn't work and is racy. Reading all labels from multiple threads in parallel will result in random data.
The label is supposed to be constant for each sensor. If it isn't, it is not a label. Either create it as constant and use the generated string, or drop the attribute.
Guenter
Re: [PATCH linux v9 2/5] hwmon: occ: Add sysfs interface
Quoted 211 lines · Guenter Roeck
Quoted 204 lines · Eddie James
From: "Edward A. James" <[email protected]>
Add a generic mechanism to expose the sensors provided by the OCC in sysfs.
Signed-off-by Edward A. James <[email protected]>Signed-off-by Andrew Jeffery <[email protected]>--- Documentation/hwmon/occ | 62 +++++++++++ drivers/hwmon/occ/Makefile | 2 +- drivers/hwmon/occ/occ_sysfs.c | 253 ++++++++++++++++++++++++++++++++++++++++++ drivers/hwmon/occ/occ_sysfs.h | 25 +++++ 4 files changed, 341 insertions(+), 1 deletion(-) create mode 100644 drivers/hwmon/occ/occ_sysfs.c create mode 100644 drivers/hwmon/occ/occ_sysfs.hDocumentation/hwmon/occ +0
-0@@ -27,6 +27,68 @@ Currently, all versions of the OCC support four types of sensor data: power, temperature, frequency, and "caps," which indicate limits andthresholds used
internally on the OCC.Documentation/hwmon/occ +4
-0+sysfs Entries +------------- + +The OCC driver uses the hwmon sysfs framework to provide data touserspace.
Documentation/hwmon/occ +3
-0+ +The driver exports a number of sysfs files for each type of sensor. The +sensor-specific files vary depending on the processor type, thoughmany of the
Documentation/hwmon/occ +3
-0+attributes are common for both the POWER8 and POWER9. + +The hwmon interface cannot define every type of sensor that may beused.
+Therefore, the frequency sensor on the OCC uses the "input" type sensor defined
+by the hwmon interface, rather than defining a new type of custom sensor.Documentation/hwmon/occ +2
-0+ +Below are detailed the names and meaning of each sensor file forboth types of
+processors. All sensors are read-only unless otherwise specified. <x> indicates
+the hwmon index. sensor id indicates the unique internal OCC identifer. PleaseDocumentation/hwmon/occ +40
-0+see the POWER OCC specification for details on all these sensor values. + +frequency: + all processors: + in<x>_input - frequency value + in<x>_label - sensor id +temperature: + POWER8: + temp<x>_input - temperature value + temp<x>_label - sensor id + POWER9 (in addition to above): + temp<x>_type - FRU type + +power: + POWER8: + power<x>_input - power value + power<x>_label - sensor id + power<x>_average - accumulator + power<x>_average_interval - update tag (number of samples in + accumulator) + POWER9: + power<x>_input - power value + power<x>_label - sensor id + power<x>_average_min - accumulator[0] + power<x>_average_max - accumulator[1] (64 bits total) + power<x>_average_interval - update tag + power<x>_reset_history - (function_id | (apss_channel << 8) + +caps: + POWER8: + power<x>_cap - current powercap + power<x>_cap_max - max powercap + power<x>_cap_min - min powercap + power<x>_max - normal powercap + power<x>_alarm - user powercap, r/w + POWER9: + power<x>_cap_alarm - user powercap source + +The driver also provides two sysfs entries through hwmon to better +control the driver and monitor the master OCC. Though there may bemultiple
+OCCs present on the system, these two files are only present for the "master"Documentation/hwmon/occ +3
-0+OCC. + name - read the name of the driver + update_interval - read or write the minimum interval for pollingthe
Documentation/hwmon/occ +2
-0+ OCC. + BMC - Host Communications -------------------------drivers/hwmon/occ/Makefile +1
-1@@ -1 +1 @@ -obj-$(CONFIG_SENSORS_IBM_OCC) += occ.o +obj-$(CONFIG_SENSORS_IBM_OCC) += occ.o occ_sysfs.odrivers/hwmon/occ/occ_sysfs.c new file +4
-0@@ -0,0 +1,253 @@ +/* +* occ_sysfs.c - OCC sysfs interface +* +* This file contains the methods and data structures for implementing the OCC
+ * hwmon sysfs entries.
+ *
+ * Copyright 2017 IBM Corp.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */drivers/hwmon/occ/occ_sysfs.c new file +30
-0+ +#include <linux/delay.h> +#include <linux/device.h> +#include <linux/err.h> +#include <linux/hwmon.h> +#include <linux/hwmon-sysfs.h> +#include <linux/init.h> +#include <linux/jiffies.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/mutex.h> +#include <linux/slab.h> +#include "occ.h" +#include "occ_sysfs.h" + +#define OCC_HWMON_NAME_LENGTH 32 + +struct occ_sysfs { +struct device *dev; +struct occ *occ; + +char label_buffer[OCC_HWMON_NAME_LENGTH +1 ]; +char hwmon_name[OCC_HWMON_NAME_LENGTH +1 ]; +const u32 *sensor_hwmon_configs; +struct hwmon_channel_info **occ_sensors; +struct hwmon_chip_info occ_info; +u16 user_powercap; +}; + +static int occ_hwmon_read(struct device *dev, enum
hwmon_sensor_typestype,drivers/hwmon/occ/occ_sysfs.c new file +42
-0+ u32 attr, int channel, long *val) +{ + int rc; +struct occ_sysfs *driver =dev_get_drvdata (dev); +struct occ *occ = driver->occ; + +switch (type) { +case hwmon_in: + rc =occ_get_sensor_field (occ,FREQ , channel, attr, val); +break ; +case hwmon_temp: + rc =occ_get_sensor_field (occ,TEMP , channel, attr, val); +break ; +case hwmon_power: + rc =occ_get_sensor_field (occ,POWER , channel, attr, val); +break ; +default : + rc = -EOPNOTSUPP ; + } + +return rc; +} + +static int occ_hwmon_read_string (struct device *dev, +enum hwmon_sensor_types type,u32 attr, +int channel,const char **str) +{ +int rc; +unsigned long val =0 ; +struct occ_sysfs *driver =dev_get_drvdata (dev); + +if (!((type == hwmon_in && attr == hwmon_in_label) || + (type == hwmon_temp && attr == hwmon_temp_label) || + (type == hwmon_power && attr == hwmon_power_label))) +return -EOPNOTSUPP ; + +/* will fetch the "label", the sensor_id */ + rc =occ_hwmon_read (dev, type, attr, channel, &val); +if (rc <0 ) +return rc; + +/* just use one label buffer for all sensors. works with current hwmon
drivers/hwmon/occ/occ_sysfs.c line 88
Quoted 3 lines
drivers/hwmon/occ/occ_sysfs.c new file +3
-0+* implementation. only alternative is to store a buffer for each +* sensor, which gets expensive quickly. +*/ Sorry for the late reply.
Quoted 8 lines
No, this doesn't work and is racy. Reading all labels from multiple threads in parallel will result in random data.
The label is supposed to be constant for each sensor. If it isn't, it is not a label. Either create it as constant and use the generated string, or drop the attribute.
Guenter
Thanks for catching that. The driver is undergoing some significant restructuring as a result of changes in design to the low-level driver for the P9 side of things (actually doing the communication with the OCC). Depending on how extensive the changes are (haven't had time to finalize), this patchset could be abandoned and I'll start again.
Thanks for the feedback so far.
Eddie
PATCH v9 3/5 hwmon: occ: Add I2C transport implementation for SCOM operations
In reply to Eddie JamesFrom: "Edward A. James" <[email protected]>
Add functions to send SCOM operations over I2C bus. The BMC can communicate with the Power8 host processor over I2C, but needs to use SCOM operations in order to access the OCC register space.
--- drivers/hwmon/occ/Makefile | 2 +- drivers/hwmon/occ/occ_scom_i2c.c | 69 ++++++++++++++++++++++++++++++++++++++++ drivers/hwmon/occ/occ_scom_i2c.h | 21 ++++++++++++ 3 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 drivers/hwmon/occ/occ_scom_i2c.c create mode 100644 drivers/hwmon/occ/occ_scom_i2c.h
drivers/hwmon/occ/Makefile +1 -1
@@ -1 +1 @@ -obj-$(CONFIG_SENSORS_IBM_OCC) += occ.o occ_sysfs.o +obj-$(CONFIG_SENSORS_IBM_OCC) += occ.o occ_sysfs.o occ_scom_i2c.o
drivers/hwmon/occ/occ_scom_i2c.c new file +69 -0
69 lines not on this page · raw message
drivers/hwmon/occ/occ_scom_i2c.h new file +21 -0
@@ -0,0 +1,21 @@ +/* +* occ_scom_i2c.h - hwmon OCC driver +* +* This file contains function protoypes for peforming SCOM operations over I2C +* bus to access the OCC. +* +* Copyright 2017 IBM Corp. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +*/ + +#ifndef __OCC_SCOM_I2C_H__ +#define __OCC_SCOM_I2C_H__ + +int occ_i2c_getscom (void *bus,u32 address,u64 *data); +int occ_i2c_putscom (void *bus,u32 address,u32 data0,u32 data1); + +#endif /* __OCC_SCOM_I2C_H__ */
Signature · 1 line
1.8.3.1
PATCH v9 4/5 hwmon: occ: Add callbacks for parsing P8 OCC datastructures
In reply to Eddie JamesFrom: "Edward A. James" <eajames-r/[email protected]>
Add functions to parse the data structures that are specific to the OCC on the POWER8 processor. These are the sensor data structures, including temperature, frequency, power, and "caps."
--- Documentation/hwmon/occ | 9 ++ drivers/hwmon/occ/Makefile | 2 +- drivers/hwmon/occ/occ_p8.c | 256 +++++++++++++++++++++++++++++++++++++++++++++ drivers/hwmon/occ/occ_p8.h | 25 +++++ 4 files changed, 291 insertions(+), 1 deletion(-) create mode 100644 drivers/hwmon/occ/occ_p8.c create mode 100644 drivers/hwmon/occ/occ_p8.h
Documentation/hwmon/occ +9 -0
@@ -27,6 +27,15 @@ Currently, all versions of the OCC support four types of sensor data: power, temperature, frequency, and "caps," which indicate limits and thresholds used internally on the OCC. +The format for the POWER8 OCC sensor data can be found in the P8 OCC +specification: +github.com/open-power/docs/blob/master/occ/OCC_OpenPwr_FW_Interfaces.pdf +This document provides the details of the OCC sensors: power, frequency, +temperature, and caps. These sensor formats are specific to the POWER8 OCC. A +number of data structures, such as command format, response headers, and the +like, are also defined in this specification, and are common to both POWER8 and +POWER9 OCCs. + sysfs Entries -------------
drivers/hwmon/occ/Makefile +1 -1
@@ -1 +1 @@ -obj-$(CONFIG_SENSORS_IBM_OCC) += occ.o occ_sysfs.o occ_scom_i2c.o +obj-$(CONFIG_SENSORS_IBM_OCC) += occ.o occ_sysfs.o occ_scom_i2c.o occ_p8.o
drivers/hwmon/occ/occ_p8.c new file +256 -0
256 lines not on this page · raw message
drivers/hwmon/occ/occ_p8.h new file +25 -0
@@ -0,0 +1,25 @@ +/* +* occ_p8.h - OCC hwmon driver +* +* This file contains Power8-specific function prototypes +* +* Copyright 2017 IBM Corp. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +*/ + +#ifndef __OCC_P8_H__ +#define __OCC_P8_H__ + +struct device ; +struct occ ; +struct occ_bus_ops ; + +const u32 *p8_get_sensor_hwmon_configs (void ); +struct occ *p8_occ_init (struct device *dev,void *bus, +const struct occ_bus_ops *bus_ops); + +#endif /* __OCC_P8_H__ */
Signature · 6 lines
1.8.3.1 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v9 5/5 hwmon: occ: Add hwmon implementation for the P8 OCC
In reply to Eddie JamesFrom: "Edward A. James" <[email protected]>
Add code to tie the hwmon sysfs code and the POWER8 OCC code together, as well as probe the entire driver from the I2C bus. I2C is the communication method between the BMC and the P8 OCC.
--- Documentation/devicetree/bindings/hwmon/occ.txt | 13 ++++ drivers/hwmon/occ/Kconfig | 15 ++++ drivers/hwmon/occ/Makefile | 4 +- drivers/hwmon/occ/occ_p8_i2c.c | 99 +++++++++++++++++++++++++ 4 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/hwmon/occ.txt create mode 100644 drivers/hwmon/occ/occ_p8_i2c.c
Documentation/devicetree/bindings/hwmon/occ.txt new file +13 -0
@@ -0,0 +1,13 @@ +HWMON I2C driver for IBM POWER CPU OCC (On Chip Controller) + +Required properties: + - compatible: must be "ibm,p8-occ-i2c" + - reg: physical address + +Example: +i2c3: i2c-bus@100 { + occ@50 { + compatible = "ibm,p8-occ-i2c"; + reg = <0x50>; + }; +};
drivers/hwmon/occ/Kconfig +15 -0
@@ -11,3 +11,18 @@ menuconfig SENSORS_IBM_OCC Generally this is used by management controllers such as a BMC on an OpenPower system. + +if SENSORS_IBM_OCC + +config SENSORS_IBM_OCC_P8_I2C + tristate "POWER8 OCC hwmon support" + depends on I2C + help + Provide a hwmon sysfs interface for the POWER8 On-Chip Controller, + exposing temperature, frequency and power measurements. This + interface runs on the service processor, not the POWER CPU. + + This driver can also be built as a module. If so, the module will be + called hwmon_occ_p8. + +endif
drivers/hwmon/occ/Makefile +3 -1
@@ -1 +1,3 @@ -obj-$(CONFIG_SENSORS_IBM_OCC) += occ.o occ_sysfs.o occ_scom_i2c.o occ_p8.o +obj-$(CONFIG_SENSORS_IBM_OCC_P8_I2C) += hwmon_occ_p8.o + +hwmon_occ_p8-objs := occ.o occ_sysfs.o occ_scom_i2c.o occ_p8.o occ_p8_i2c.o
drivers/hwmon/occ/occ_p8_i2c.c new file +99 -0
99 lines not on this page · raw message
Signature · 1 line
1.8.3.1