drivers: hwmon: Add On-Chip Controller driver
v2 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.
Edward A. James (6):
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
hwmon: occ: Add callbacks for parsing P9 OCC datastructures
Documentation/devicetree/bindings/hwmon/occ.txt | 13 + Documentation/hwmon/occ | 114 +++++ drivers/hwmon/Kconfig | 2 + drivers/hwmon/Makefile | 1 + drivers/hwmon/occ/Kconfig | 29 ++ drivers/hwmon/occ/Makefile | 2 + drivers/hwmon/occ/occ.c | 533 ++++++++++++++++++++++++ drivers/hwmon/occ/occ.h | 83 ++++ drivers/hwmon/occ/occ_p8.c | 254 +++++++++++ drivers/hwmon/occ/occ_p8.h | 31 ++ drivers/hwmon/occ/occ_p9.c | 314 ++++++++++++++ drivers/hwmon/occ/occ_p9.h | 31 ++ drivers/hwmon/occ/occ_scom_i2c.c | 73 ++++ drivers/hwmon/occ/occ_scom_i2c.h | 26 ++ drivers/hwmon/occ/occ_sysfs.c | 274 ++++++++++++ drivers/hwmon/occ/occ_sysfs.h | 44 ++ drivers/hwmon/occ/p8_occ_i2c.c | 123 ++++++ drivers/hwmon/occ/scom.h | 47 +++ 18 files changed, 1994 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_p9.c create mode 100644 drivers/hwmon/occ/occ_p9.h 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/p8_occ_i2c.c create mode 100644 drivers/hwmon/occ/scom.h
Signature · 1 line
1.9.1
PATCH v2 1/6 hwmon: Add core On-Chip Controller support for POWER CPUs
From: "Edward A. James" <eajames-r/[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 | 40 ++++ drivers/hwmon/Kconfig | 2 + drivers/hwmon/Makefile | 1 + drivers/hwmon/occ/Kconfig | 15 ++ drivers/hwmon/occ/Makefile | 1 + drivers/hwmon/occ/occ.c | 533 +++++++++++++++++++++++++++++++++++++++++++++ drivers/hwmon/occ/occ.h | 83 +++++++ drivers/hwmon/occ/scom.h | 47 ++++ 8 files changed, 722 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 +40 -0
@@ -0,0 +1,40 @@ +Kernel driver occ +================= + +Supported chips: + * ASPEED AST2400 + * ASPEED AST2500 + +Please note that the chip must be connected to a POWER8 or POWER9 processor +(see the BMC - Host Communications section). + +Author: Eddie James <eajames-r/[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.
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
@@ -169,6 +169,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_PPC_OCC) += occ/ obj-$(CONFIG_PMBUS) += pmbus/ ccflags-$(CONFIG_HWMON_DEBUG_CHIP) := -DDEBUG
drivers/hwmon/occ/Kconfig new file +15 -0
@@ -0,0 +1,15 @@ +# +# On Chip Controller configuration +# + +menuconfig SENSORS_PPC_OCC + bool "PPC On-Chip Controller" + help + If you say yes here you get support to monitor Power CPU + sensors via the On-Chip Controller (OCC). + + Generally this is used by management controllers such as a BMC + on an OpenPower system. + + This driver can also be built as a module. If so, the module + will be called occ.
drivers/hwmon/occ/Makefile new file +1 -0
@@ -0,0 +1 @@ +obj-$(CONFIG_SENSORS_PPC_OCC) += occ.o
drivers/hwmon/occ/occ.c new file +533 -0
533 lines not on this page · raw message
drivers/hwmon/occ/occ.h new file +83 -0
83 lines not on this page · raw message
drivers/hwmon/occ/scom.h new file +47 -0
47 lines not on this page · raw message
Signature · 6 lines
1.9.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 v2 2/6 hwmon: occ: Add sysfs interface
In reply to [email protected]From: "Edward A. James" <[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 | 274 ++++++++++++++++++++++++++++++++++++++++++ drivers/hwmon/occ/occ_sysfs.h | 44 +++++++ 4 files changed, 381 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
@@ -25,6 +25,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_PPC_OCC) += occ.o +obj-$(CONFIG_SENSORS_PPC_OCC) += occ.o occ_sysfs.o
drivers/hwmon/occ/occ_sysfs.c new file +274 -0
274 lines not on this page · raw message
drivers/hwmon/occ/occ_sysfs.h new file +44 -0
44 lines not on this page · raw message
Signature · 1 line
1.9.1
kbuild test robot
build bot[PATCH] hwmon: occ: fix err_cast.cocci warnings
drivers/hwmon/occ/occ_sysfs.c:265:9-16: WARNING: ERR_CAST can be used with hwmon -> dev
drivers/hwmon/occ/occ_sysfs.c:265:9-16: WARNING: ERR_CAST can be used with hwmon -> dev
Use ERR_CAST inlined function instead of ERR_PTR(PTR_ERR(...))
Generated by: scripts/coccinelle/api/err_cast.cocci
---
occ_sysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/occ/occ_sysfs.c +1 -1
@@ -262,7 +262,7 @@ struct occ_sysfs *occ_sysfs_start(structif (IS_ERR (hwmon->dev)) {dev_err (dev,"cannot register hwmon device %s: %ld\n" , hwmon->hwmon_name,PTR_ERR (hwmon->dev)); -return ERR_PTR (PTR_ERR (hwmon->dev)); +return ERR_CAST (hwmon->dev); }return hwmon;
kbuild test robot
build botRe: [PATCH linux v2 2/6] hwmon: occ: Add sysfs interface
In reply to [email protected]coccinelle warnings: (new ones prefixed by >>)
Hi Edward,
[auto build test WARNING on hwmon/hwmon-next]
[also build test WARNING on v4.10-rc3 next-20170111]
[cannot apply to linux/master]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/eajames-ibm-gmail-com/hwmon-Add-core-On-Chip-Controller-support-for-POWER-CPUs/20170112-150440 base: https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git hwmon-next
coccinelle warnings: (new ones prefixed by >>)
>> drivers/hwmon/occ/occ_sysfs.c:265:9-16: WARNING: ERR_CAST can be used with hwmon -> dev
Please review and possibly fold the followup patch.
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Guenter Roeck
maintainerRe: [PATCH linux v2 2/6] hwmon: occ: Add sysfs interface
In reply to [email protected]Quoted 123 lines · On 01/11/2017 10:10 AM, [email protected] wrote:
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 | 274 ++++++++++++++++++++++++++++++++++++++++++ drivers/hwmon/occ/occ_sysfs.h | 44 +++++++ 4 files changed, 381 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@@ -25,6 +25,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_PPC_OCC) += occ.o +obj-$(CONFIG_SENSORS_PPC_OCC) += occ.o occ_sysfs.odrivers/hwmon/occ/occ_sysfs.c new file +21
-0@@ -0,0 +1,274 @@ +/* +* occ_sysfs.c - OCC sysfs interface +* +* This file contains the methods and data structures for implementing the OCC +* hwmon sysfs entries. +* +* Copyright 2016 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. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#include <linux/module.h> +#include <linux/init.h>
drivers/hwmon/occ/occ_sysfs.c line 31
Quoted 10 lines
drivers/hwmon/occ/occ_sysfs.c new file +10
-0+#include <linux/slab.h> +#include <linux/jiffies.h> +#include <linux/hwmon.h> +#include <linux/hwmon-sysfs.h> +#include <linux/err.h> +#include <linux/mutex.h> +#include <linux/delay.h> +#include <linux/kernel.h> +#include <linux/device.h> +
Again, for all patches: alphabetic order, please.
Quoted 159 lines
drivers/hwmon/occ/occ_sysfs.c new file +159
-0+#include "occ.h" +#include "occ_sysfs.h" + +#define RESP_RETURN_CMD_INVAL 0x13 + +static int occ_hwmon_read (struct device *dev,enum hwmon_sensor_types type, +u32 attr,int channel,long *val) +{ +int rc =0 ; +struct occ_sysfs *driver =dev_get_drvdata (dev); +struct occ *occ = driver->occ; + +switch (type) { +case hwmon_in: + rc =occ_get_sensor_value (occ,FREQ , channel, attr, val); +break ; +case hwmon_temp: + rc =occ_get_sensor_value (occ,TEMP , channel, attr, val); +break ; +case hwmon_power: + rc =occ_get_sensor_value (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,char **str) +{ +int rc; +unsigned long val =0 ; + +if (!((type == hwmon_in && attr == hwmon_in_label) || + (type == hwmon_temp && attr == hwmon_temp_label) || + (type == hwmon_power && attr == hwmon_power_label))) +return -EOPNOTSUPP ; + + rc =occ_hwmon_read (dev, type, attr, channel, &val); +if (rc <0 ) +return rc; + + rc =snprintf (*str,PAGE_SIZE -1 ,"%ld" , val); +if (rc >0 ) + rc =0 ; + +return rc; +} + +static int occ_hwmon_write (struct device *dev,enum hwmon_sensor_types type, +u32 attr,int channel,long val) +{ +int rc =0 ; +struct occ_sysfs *driver =dev_get_drvdata (dev); + +if (type == hwmon_chip && attr == hwmon_chip_update_interval) { +occ_set_update_interval (driver->occ, val); +return 0 ; + }else if (type == hwmon_power && attr == hwmon_power_alarm) { + rc =occ_set_user_powercap (driver->occ, val); +if (rc) { +if (rc ==RESP_RETURN_CMD_INVAL ) { +dev_err (dev, +"set invalid powercap value: %ld\n" , + val); +return -EINVAL ; + } + +dev_err (dev,"set user powercap failed: 0x:%x\n" , rc); +return rc; + } + + driver->user_powercap = val; + +return rc; + } + +return -EOPNOTSUPP ; +} + +static umode_t occ_is_visible (const void *data,enum hwmon_sensor_types type, +u32 attr,int channel) +{ +const struct occ_sysfs *driver = data; + +switch (type) { +case hwmon_chip: +if (attr == hwmon_chip_update_interval) +return S_IRUGO |S_IWUSR ; +break ; +case hwmon_in: +if (BIT (attr) & driver->sensor_hwmon_configs[0 ]) +return S_IRUGO ; +break ; +case hwmon_temp: +if (BIT (attr) & driver->sensor_hwmon_configs[1 ]) +return S_IRUGO ; +break ; +case hwmon_power: +/* user power limit */ +if (attr == hwmon_power_alarm) +return S_IRUGO |S_IWUSR ; +else if ((BIT (attr) & driver->sensor_hwmon_configs[2 ]) || + (BIT (attr) & driver->sensor_hwmon_configs[3 ])) +return S_IRUGO ; +break ; +default : +return 0 ; + } + +return 0 ; +} + +static const struct hwmon_ops occ_hwmon_ops = { + .is_visible = occ_is_visible, + .read = occ_hwmon_read, + .read_string = occ_hwmon_read_string, + .write = occ_hwmon_write, +}; + +static const u32 occ_chip_config[] = { +HWMON_C_UPDATE_INTERVAL , +0 +}; + +static const struct hwmon_channel_info occ_chip = { + .type = hwmon_chip, + .config = occ_chip_config +}; + +static const enum hwmon_sensor_types occ_sensor_types[MAX_OCC_SENSOR_TYPE ] = { + hwmon_in, + hwmon_temp, + hwmon_power, + hwmon_power +}; + +struct occ_sysfs *occ_sysfs_start (struct device *dev,struct occ *occ, +const u32 *sensor_hwmon_configs, +const char *name) +{ +bool master_occ = false; +int rc, i, j, sensor_num, index =0 , id; +char *brk; +struct occ_blocks *resp =NULL ; +u32 *sensor_config; +struct occ_sysfs *hwmon =devm_kzalloc (dev,sizeof (struct occ_sysfs ), +GFP_KERNEL ); +if (!hwmon) +return ERR_PTR (-ENOMEM ); + +/* need space for null-termination and occ chip */ + hwmon->occ_sensors = +devm_kzalloc (dev,sizeof (struct hwmon_channel_info *) * + (MAX_OCC_SENSOR_TYPE +2 ),GFP_KERNEL ); +if (!hwmon->occ_sensors)
drivers/hwmon/occ/occ_sysfs.c line 200
Quoted 10 lines
drivers/hwmon/occ/occ_sysfs.c new file +10
-0+return ERR_PTR (-ENOMEM ); + + hwmon->occ = occ; + hwmon->sensor_hwmon_configs = (u32 *)sensor_hwmon_configs; + hwmon->occ_info.ops = &occ_hwmon_ops; + hwmon->occ_info.info = + (const struct hwmon_channel_info **)hwmon->occ_sensors; + +dev_set_drvdata (dev, hwmon); +
Overwritten in the calling code. It is actually not needed here because dev_get_drvdata() in the access functions gets the value from the hwmon device, and that is set with the 3rd parameter of devm_hwmon_device_register_with_info().
Quoted 125 lines
drivers/hwmon/occ/occ_sysfs.c new file +74
-0+occ_get_response_blocks (occ, &resp); + +for (i =0 ; i <MAX_OCC_SENSOR_TYPE ; ++i) + resp->sensor_block_id[i] =-1 ; + +/* read sensor data from occ */ + rc =occ_update_device (occ); +if (rc) { +dev_err (dev,"cannot get occ sensor data: %d\n" , rc); +return ERR_PTR (rc); + } +if (!resp->blocks) +return ERR_PTR (-ENOMEM ); + + master_occ = resp->sensor_block_id[CAPS ] >=0 ; + +for (i =0 ; i <MAX_OCC_SENSOR_TYPE ; i++) { + id = resp->sensor_block_id[i]; +if (id <0 ) +continue ; + + sensor_num = resp->blocks[id].header.sensor_num; +/* need null-termination */ + sensor_config =devm_kzalloc (dev, +sizeof (u32) * (sensor_num +1 ), +GFP_KERNEL ); +if (!sensor_config) +return ERR_PTR (-ENOMEM ); + +for (j =0 ; j < sensor_num; j++) + sensor_config[j] = sensor_hwmon_configs[i]; + + hwmon->occ_sensors[index] = +devm_kzalloc (dev,sizeof (struct hwmon_channel_info ), +GFP_KERNEL ); +if (!hwmon->occ_sensors[index]) +return ERR_PTR (-ENOMEM ); + + hwmon->occ_sensors[index]->type = occ_sensor_types[i]; + hwmon->occ_sensors[index]->config = sensor_config; + index++; + } + +/* only need one of these for any number of occs */ +if (master_occ) + hwmon->occ_sensors[index] = + (struct hwmon_channel_info *)&occ_chip; + +/* search for bad chars */ +strncpy (hwmon->hwmon_name, name,OCC_HWMON_NAME_LENGTH ); + brk =strpbrk (hwmon->hwmon_name,"-* \t\n" ); +while (brk) { + *brk ='_' ; + brk =strpbrk (brk,"-* \t\n" ); + } + + hwmon->dev =devm_hwmon_device_register_with_info (dev, + hwmon->hwmon_name, + hwmon, + &hwmon->occ_info, +NULL ); +if (IS_ERR (hwmon->dev)) { +dev_err (dev,"cannot register hwmon device %s: %ld\n" , + hwmon->hwmon_name,PTR_ERR (hwmon->dev)); +return ERR_PTR (PTR_ERR (hwmon->dev)); + } + +return hwmon; +} +EXPORT_SYMBOL (occ_sysfs_start); + +MODULE_AUTHOR ("Eddie James <[email protected]>" ); +MODULE_DESCRIPTION ("OCC sysfs driver" ); +MODULE_LICENSE ("GPL" );drivers/hwmon/occ/occ_sysfs.h new file +44
-0@@ -0,0 +1,44 @@ +/* +* occ_sysfs.h - OCC sysfs interface +* +* This file contains the data structures and function prototypes for the OCC +* hwmon sysfs entries. +* +* Copyright 2016 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. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#ifndef __OCC_SYSFS_H__ +#define __OCC_SYSFS_H__ + +#include <linux/hwmon.h> + +struct occ ; +struct device ; + +#define OCC_HWMON_NAME_LENGTH 32 + +struct occ_sysfs { +struct device *dev; +struct occ *occ; + +char hwmon_name[OCC_HWMON_NAME_LENGTH +1 ]; +u32 *sensor_hwmon_configs; +struct hwmon_channel_info **occ_sensors; +struct hwmon_chip_info occ_info; +u16 user_powercap; +}; + +struct occ_sysfs *occ_sysfs_start (struct device *dev,struct occ *occ, +const u32 *sensor_hwmon_configs, +const char *name); +#endif /* __OCC_SYSFS_H__ */
PATCH v2 3/6 hwmon: occ: Add I2C transport implementation for SCOM operations
In reply to [email protected]From: "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/occ_scom_i2c.c | 73 ++++++++++++++++++++++++++++++++++++++++ drivers/hwmon/occ/occ_scom_i2c.h | 26 ++++++++++++++ 2 files changed, 99 insertions(+) create mode 100644 drivers/hwmon/occ/occ_scom_i2c.c create mode 100644 drivers/hwmon/occ/occ_scom_i2c.h
drivers/hwmon/occ/occ_scom_i2c.c new file +73 -0
@@ -0,0 +1,73 @@ +/* +* occ_scom_i2c.c - hwmon OCC driver +* +* This file contains the functions for performing SCOM operations over I2C bus +* to access the OCC. +* +* Copyright 2016 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. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#include <linux/i2c.h> +#include <linux/kernel.h> +#include <linux/module.h> + +#include "scom.h" +#include "occ_scom_i2c.h" + +int occ_i2c_getscom (void *bus,u32 address,u64 *data) +{ +ssize_t rc; +u64 buf; +struct i2c_client *client = bus; + + rc =i2c_master_send (client, (const char *)&address,sizeof (u32)); +if (rc <0 ) +return rc; +else if (rc !=sizeof (u32)) +return -EIO ; + + rc =i2c_master_recv (client, (char *)&buf,sizeof (u64)); +if (rc <0 ) +return rc; +else if (rc !=sizeof (u64)) +return -EIO ; + + *data =be64_to_cpu (buf); + +return 0 ; +} +EXPORT_SYMBOL (occ_i2c_getscom); + +int occ_i2c_putscom (void *bus,u32 address,u32 data0,u32 data1) +{ +u32 buf[3 ]; +ssize_t rc; +struct i2c_client *client = bus; + + buf[0 ] = address; + buf[1 ] = data1; + buf[2 ] = data0; + + rc =i2c_master_send (client, (const char *)buf,sizeof (u32) *3 ); +if (rc <0 ) +return rc; +else if (rc !=sizeof (u32) *3 ) +return -EIO ; + +return 0 ; +} +EXPORT_SYMBOL (occ_i2c_putscom); + +MODULE_AUTHOR ("Eddie James <[email protected]>" ); +MODULE_DESCRIPTION ("I2C OCC SCOM transport" ); +MODULE_LICENSE ("GPL" );
drivers/hwmon/occ/occ_scom_i2c.h new file +26 -0
@@ -0,0 +1,26 @@ +/* +* occ_scom_i2c.h - hwmon OCC driver +* +* This file contains function protoypes for peforming SCOM operations over I2C +* bus to access the OCC. +* +* Copyright 2016 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. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#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.9.1
PATCH v2 4/6 hwmon: occ: Add callbacks for parsing P8 OCC datastructures
In reply to [email protected]From: "Edward A. James" <[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/occ_p8.c | 254 +++++++++++++++++++++++++++++++++++++++++++++ drivers/hwmon/occ/occ_p8.h | 31 ++++++ 3 files changed, 294 insertions(+) create mode 100644 drivers/hwmon/occ/occ_p8.c create mode 100644 drivers/hwmon/occ/occ_p8.h
Documentation/hwmon/occ +9 -0
@@ -25,6 +25,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/occ_p8.c new file +254 -0
254 lines not on this page · raw message
drivers/hwmon/occ/occ_p8.h new file +31 -0
@@ -0,0 +1,31 @@ +/* +* occ_p8.h - OCC hwmon driver +* +* This file contains Power8-specific function prototypes +* +* Copyright 2016 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. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#ifndef __OCC_P8_H__ +#define __OCC_P8_H__ + +#include "scom.h" + +struct device ; + +const u32 *p8_get_sensor_hwmon_configs (void ); +struct occ *p8_occ_start (struct device *dev,void *bus, +struct occ_bus_ops *bus_ops); +int p8_occ_stop (struct occ *occ); + +#endif /* __OCC_P8_H__ */
Signature · 1 line
1.9.1
PATCH v2 5/6 hwmon: occ: Add hwmon implementation for the P8 OCC
In reply to [email protected]From: "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 | 14 +++ drivers/hwmon/occ/Makefile | 1 + drivers/hwmon/occ/p8_occ_i2c.c | 123 ++++++++++++++++++++++++ 4 files changed, 151 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/occ.txt create mode 100644 drivers/hwmon/occ/p8_occ_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 +14 -0
@@ -13,3 +13,17 @@ menuconfig SENSORS_PPC_OCC This driver can also be built as a module. If so, the module will be called occ. + +if SENSORS_PPC_OCC + +config SENSORS_PPC_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 driver can also be built as a module. If so, the module will be + called p8-occ-i2c. + +endif
drivers/hwmon/occ/Makefile +1 -0
@@ -1 +1,2 @@ obj-$(CONFIG_SENSORS_PPC_OCC) += occ.o occ_sysfs.o +obj-$(CONFIG_SENSORS_PPC_OCC_P8_I2C) += occ_scom_i2c.o occ_p8.o p8_occ_i2c.o
drivers/hwmon/occ/p8_occ_i2c.c new file +123 -0
123 lines not on this page · raw message
Signature · 1 line
1.9.1
Guenter Roeck
maintainerRe: [PATCH linux v2 5/6] hwmon: occ: Add hwmon implementation for the P8 OCC
Quoted 88 lines · On 01/11/2017 10:10 AM, [email protected] wrote:
From: "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.
Signed-off-by Edward A. James <[email protected]>Signed-off-by Andrew Jeffery <[email protected]>--- Documentation/devicetree/bindings/hwmon/occ.txt | 13 +++ drivers/hwmon/occ/Kconfig | 14 +++ drivers/hwmon/occ/Makefile | 1 + drivers/hwmon/occ/p8_occ_i2c.c | 123 ++++++++++++++++++++++++ 4 files changed, 151 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/occ.txt create mode 100644 drivers/hwmon/occ/p8_occ_i2c.cDocumentation/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 +14
-0@@ -13,3 +13,17 @@ menuconfig SENSORS_PPC_OCC This driver can also be built as a module. If so, the module will be called occ. + +if SENSORS_PPC_OCC + +config SENSORS_PPC_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 driver can also be built as a module. If so, the module will be + called p8-occ-i2c. + +endifdrivers/hwmon/occ/Makefile +1
-0@@ -1 +1,2 @@ obj-$(CONFIG_SENSORS_PPC_OCC) += occ.o occ_sysfs.o +obj-$(CONFIG_SENSORS_PPC_OCC_P8_I2C) += occ_scom_i2c.o occ_p8.o p8_occ_i2c.odrivers/hwmon/occ/p8_occ_i2c.c new file +17
-0@@ -0,0 +1,123 @@ +/* +* p8_occ_i2c.c - hwmon OCC driver +* +* This file contains the i2c layer for accessing the P8 OCC over i2c bus. +* +* Copyright 2016 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. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/
drivers/hwmon/occ/p8_occ_i2c.c line 27
Quoted 10 lines
drivers/hwmon/occ/p8_occ_i2c.c new file +10
-0+ +#include <linux/err.h> +#include <linux/module.h> +#include <linux/init.h> +#include <linux/slab.h> +#include <linux/i2c.h> +#include <linux/err.h> +#include <linux/of.h> +#include <linux/kernel.h> +#include <linux/device.h>
For all patches: alphabetic order, please.
Quoted 36 lines
drivers/hwmon/occ/p8_occ_i2c.c new file +36
-0+ +#include "scom.h" +#include "occ_scom_i2c.h" +#include "occ_p8.h" +#include "occ_sysfs.h" + +#define P8_OCC_I2C_NAME "p8-occ-i2c" + +int p8_i2c_getscom (void *bus,u32 address,u64 *data) +{ +/* P8 i2c slave requires address to be shifted by 1 */ + address = address <<1 ; + +return occ_i2c_getscom (bus, address, data); +} + +int p8_i2c_putscom (void *bus,u32 address,u32 data0,u32 data1) +{ +/* P8 i2c slave requires address to be shifted by 1 */ + address = address <<1 ; + +return occ_i2c_putscom (bus, address, data0, data1); +} + +static struct occ_bus_ops p8_bus_ops = { + .getscom = p8_i2c_getscom, + .putscom = p8_i2c_putscom, +}; + +static int p8_occ_probe (struct i2c_client *client, +const struct i2c_device_id *id) +{ +struct occ *occ; +struct occ_sysfs *hwmon; +const u32 *sensor_hwmon_configs =p8_get_sensor_hwmon_configs (); +
drivers/hwmon/occ/p8_occ_i2c.c line 73
Quoted 10 lines
drivers/hwmon/occ/p8_occ_i2c.c new file +10
-0+ occ =p8_occ_start (&client->dev, client, &p8_bus_ops); +if (IS_ERR (occ)) +return PTR_ERR (occ); + + hwmon =occ_sysfs_start (&client->dev, occ, sensor_hwmon_configs, +P8_OCC_I2C_NAME ); +if (IS_ERR (hwmon)) +return PTR_ERR (hwmon); + +i2c_set_clientdata (client, occ);
This maps to
dev_set_drvdata(&client->dev, occ);
and code in occ_sysfs_start() does the same, writing a reference to the hwmon device.
Quoted 51 lines
drivers/hwmon/occ/p8_occ_i2c.c new file +50
-0+ +return 0 ; +} + +static int p8_occ_remove (struct i2c_client *client) +{ +struct occ *occ =i2c_get_clientdata (client); + +return p8_occ_stop (occ); +} + +/* used by old-style board info. */ +static const struct i2c_device_id occ_ids[] = { + {P8_OCC_I2C_NAME ,0 }, + {} +}; +MODULE_DEVICE_TABLE (i2c, occ_ids); + +/* used by device table */ +static const struct of_device_id occ_of_match[] = { + { .compatible ="ibm,p8-occ-i2c" }, + {} +}; +MODULE_DEVICE_TABLE (of, occ_of_match); + +/* +* i2c-core uses i2c-detect() to detect device in below address list. +* If exists, address will be assigned to client. +* It is also possible to read address from device table. +*/ +static const unsigned short normal_i2c[] = {0x50 ,0x51 ,I2C_CLIENT_END }; + +static struct i2c_driver p8_occ_driver = { + .class =I2C_CLASS_HWMON , + .driver = { + .name =P8_OCC_I2C_NAME , + .pm =NULL , + .of_match_table = occ_of_match, + }, + .probe = p8_occ_probe, + .remove = p8_occ_remove, + .id_table = occ_ids, + .address_list = normal_i2c, +}; + +module_i2c_driver (p8_occ_driver); + +MODULE_AUTHOR ("Eddie James <[email protected]>" ); +MODULE_DESCRIPTION ("BMC P8 OCC hwmon driver" ); +MODULE_LICENSE ("GPL" );
Guenter Roeck
maintainerRe: [PATCH linux v2 5/6] hwmon: occ: Add hwmon implementation for the P8 OCC
In reply to [email protected]Quoted 135 lines · On 01/11/2017 10:10 AM, [email protected]…
From: "Edward A. James" <eajames-r/[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.
Signed-off-by Edward A. James <eajames-r/[email protected]>Signed-off-by Andrew Jeffery <[email protected]>--- Documentation/devicetree/bindings/hwmon/occ.txt | 13 +++ drivers/hwmon/occ/Kconfig | 14 +++ drivers/hwmon/occ/Makefile | 1 + drivers/hwmon/occ/p8_occ_i2c.c | 123 ++++++++++++++++++++++++ 4 files changed, 151 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/occ.txt create mode 100644 drivers/hwmon/occ/p8_occ_i2c.cDocumentation/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 +14
-0@@ -13,3 +13,17 @@ menuconfig SENSORS_PPC_OCC This driver can also be built as a module. If so, the module will be called occ. + +if SENSORS_PPC_OCC + +config SENSORS_PPC_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 driver can also be built as a module. If so, the module will be + called p8-occ-i2c. + +endifdrivers/hwmon/occ/Makefile +1
-0@@ -1 +1,2 @@ obj-$(CONFIG_SENSORS_PPC_OCC) += occ.o occ_sysfs.o +obj-$(CONFIG_SENSORS_PPC_OCC_P8_I2C) += occ_scom_i2c.o occ_p8.o p8_occ_i2c.odrivers/hwmon/occ/p8_occ_i2c.c new file +64
-0@@ -0,0 +1,123 @@ +/* +* p8_occ_i2c.c - hwmon OCC driver +* +* This file contains the i2c layer for accessing the P8 OCC over i2c bus. +* +* Copyright 2016 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. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#include <linux/err.h> +#include <linux/module.h> +#include <linux/init.h> +#include <linux/slab.h> +#include <linux/i2c.h> +#include <linux/err.h> +#include <linux/of.h> +#include <linux/kernel.h> +#include <linux/device.h> + +#include "scom.h" +#include "occ_scom_i2c.h" +#include "occ_p8.h" +#include "occ_sysfs.h" + +#define P8_OCC_I2C_NAME "p8-occ-i2c" + +int p8_i2c_getscom (void *bus,u32 address,u64 *data) +{ +/* P8 i2c slave requires address to be shifted by 1 */ + address = address <<1 ; + +return occ_i2c_getscom (bus, address, data); +} + +int p8_i2c_putscom (void *bus,u32 address,u32 data0,u32 data1) +{ +/* P8 i2c slave requires address to be shifted by 1 */ + address = address <<1 ; + +return occ_i2c_putscom (bus, address, data0, data1); +} + +static struct occ_bus_ops p8_bus_ops = { + .getscom = p8_i2c_getscom, + .putscom = p8_i2c_putscom, +}; + +static int p8_occ_probe (struct i2c_client *client, +const struct i2c_device_id *id) +{ +struct occ *occ; +struct occ_sysfs *hwmon; +const u32 *sensor_hwmon_configs =p8_get_sensor_hwmon_configs (); + + occ =p8_occ_start (&client->dev, client, &p8_bus_ops);
drivers/hwmon/occ/p8_occ_i2c.c line 74
Quoted 10 lines
drivers/hwmon/occ/p8_occ_i2c.c new file +10
-0+if (IS_ERR (occ)) +return PTR_ERR (occ); + + hwmon =occ_sysfs_start (&client->dev, occ, sensor_hwmon_configs, +P8_OCC_I2C_NAME ); +if (IS_ERR (hwmon)) +return PTR_ERR (hwmon); + +i2c_set_clientdata (client, occ); +
You might do the set_clientdata() call before the registration, and use return PTR_ERR_OR_ZERO(hwmon). You'll need to drop the call to dev_set_drvdata() in occ_sysfs_start() for that to work.
drivers/hwmon/occ/p8_occ_i2c.c line 82
Quoted 8 lines
drivers/hwmon/occ/p8_occ_i2c.c new file +8
-0+return 0 ; +} + +static int p8_occ_remove (struct i2c_client *client) +{ +struct occ *occ =i2c_get_clientdata (client); + +return p8_occ_stop (occ);
That stops occ first, then removes the hwmon driver registration. It also leaves a hole:
if occ_sysfs_start() failed, occ_stop() won't be called.
But wait ... all occ_stop does is to call devm_kfree(), which is wrong, because it should never be necessary to call it, but even more so since the data structure is still in use after the call to p8_occ_stop(). Just drop that function.
Quoted 13 lines
drivers/hwmon/occ/p8_occ_i2c.c new file +13
-0+} + +/* used by old-style board info. */ +static const struct i2c_device_id occ_ids[] = { + {P8_OCC_I2C_NAME ,0 }, + {} +}; +MODULE_DEVICE_TABLE (i2c, occ_ids); + +/* used by device table */ +static const struct of_device_id occ_of_match[] = { + { .compatible ="ibm,p8-occ-i2c" }, + {}
drivers/hwmon/occ/p8_occ_i2c.c line 105
Quoted 10 lines
drivers/hwmon/occ/p8_occ_i2c.c new file +10
-0+}; +MODULE_DEVICE_TABLE (of, occ_of_match); + +/* +* i2c-core uses i2c-detect() to detect device in below address list. +* If exists, address will be assigned to client. +* It is also possible to read address from device table. +*/ +static const unsigned short normal_i2c[] = {0x50 ,0x51 ,I2C_CLIENT_END }; +
... but only if there is a detect function, and trying to detect any chip on the common eeprom addresses is not a good idea anyway (it would be really easy to spoof). Please drop.
Quoted 9 lines
drivers/hwmon/occ/p8_occ_i2c.c new file +8
-0+static struct i2c_driver p8_occ_driver = { + .class =I2C_CLASS_HWMON , + .driver = { + .name =P8_OCC_I2C_NAME , + .pm =NULL , + .of_match_table = occ_of_match, + }, + .probe = p8_occ_probe,
drivers/hwmon/occ/p8_occ_i2c.c line 123
Quoted 10 lines
drivers/hwmon/occ/p8_occ_i2c.c new file +10
-0+ .remove = p8_occ_remove, + .id_table = occ_ids, + .address_list = normal_i2c, +}; + +module_i2c_driver (p8_occ_driver); + +MODULE_AUTHOR ("Eddie James <eajames-r/[email protected]>" ); +MODULE_DESCRIPTION ("BMC P8 OCC hwmon driver" ); +MODULE_LICENSE ("GPL" );
--
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 v2 6/6 hwmon: occ: Add callbacks for parsing P9 OCC datastructures
In reply to [email protected]From: "Edward A. James" <[email protected]>
Add functions to parse the data structures that are specific to the OCC on the POWER9 processor. These are the sensor data structures, including temperature, frequency, power, and "caps."
--- Documentation/hwmon/occ | 3 + drivers/hwmon/occ/occ_p9.c | 314 +++++++++++++++++++++++++++++++++++++++++++++ drivers/hwmon/occ/occ_p9.h | 31 +++++ 3 files changed, 348 insertions(+) create mode 100644 drivers/hwmon/occ/occ_p9.c create mode 100644 drivers/hwmon/occ/occ_p9.h
Documentation/hwmon/occ +3 -0
@@ -34,6 +34,9 @@ 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. +There is currently no public P9 OCC specification, and the data structures +defined in the POWER9 OCC driver are subject to change. + sysfs Entries -------------
drivers/hwmon/occ/occ_p9.c new file +314 -0
314 lines not on this page · raw message
drivers/hwmon/occ/occ_p9.h new file +31 -0
@@ -0,0 +1,31 @@ +/* +* occ_p9.h - OCC hwmon driver +* +* This file contains Power9-specific function prototypes +* +* Copyright 2016 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. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#ifndef __OCC_P9_H__ +#define __OCC_P9_H__ + +#include "scom.h" + +struct device ; + +const u32 *p9_get_sensor_hwmon_configs (void ); +struct occ *p9_occ_start (struct device *dev,void *bus, +struct occ_bus_ops *bus_ops); +int p9_occ_stop (struct occ *occ); + +#endif /* __OCC_P9_H__ */
Signature · 1 line
1.9.1
Quoted 5 lines
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.
Please don't cc the I2C list for I2C client drivers unless you have a specific question about the I2C framework. Same as you usually don't add the PCI list for every PCI (client) card.
Guenter Roeck
maintainerQuoted 7 lines · On 01/11/2017 10:10 AM, [email protected] wrote:
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.
Quoted 7 lines
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.
Overall looks pretty good. There is the 0day hiccup (was that solved ?) and a few comments I made separately. It might make sense to add someone from IBM as maintainer.
Thanks,
Guenter
Quoted 44 lines
Edward A. James (6):
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
hwmon: occ: Add callbacks for parsing P9 OCC datastructuresDocumentation/devicetree/bindings/hwmon/occ.txt | 13 + Documentation/hwmon/occ | 114 +++++ drivers/hwmon/Kconfig | 2 + drivers/hwmon/Makefile | 1 + drivers/hwmon/occ/Kconfig | 29 ++ drivers/hwmon/occ/Makefile | 2 + drivers/hwmon/occ/occ.c | 533 ++++++++++++++++++++++++ drivers/hwmon/occ/occ.h | 83 ++++ drivers/hwmon/occ/occ_p8.c | 254 +++++++++++ drivers/hwmon/occ/occ_p8.h | 31 ++ drivers/hwmon/occ/occ_p9.c | 314 ++++++++++++++ drivers/hwmon/occ/occ_p9.h | 31 ++ drivers/hwmon/occ/occ_scom_i2c.c | 73 ++++ drivers/hwmon/occ/occ_scom_i2c.h | 26 ++ drivers/hwmon/occ/occ_sysfs.c | 274 ++++++++++++ drivers/hwmon/occ/occ_sysfs.h | 44 ++ drivers/hwmon/occ/p8_occ_i2c.c | 123 ++++++ drivers/hwmon/occ/scom.h | 47 +++ 18 files changed, 1994 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_p9.c create mode 100644 drivers/hwmon/occ/occ_p9.h 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/p8_occ_i2c.c create mode 100644 drivers/hwmon/occ/scom.h