drivers: hwmon: occ: Fix sensors and add P8
cover drivers: hwmon: occ: Fix sensors and add P8
From: "Edward A. James" <[email protected]>
This series refactors the OCC hwmon driver to use versioned sensors. This allows both the P8 and P9 code paths to use common hwmon attributes and functions. Only the OCC access code is different.
The series also adds non-hwmon sysfs attributes to represent the status of the OCC. These are not real sensors and therefor do not belong as hwmon attributes.
The patchset also adds the P8 OCC access code over I2C bus.
Edward A. James (2):
drivers: hwmon: occ: Add new sensor versions and non-hwmon attributes
drivers: hwmon: occ: Add P8 OCC access
drivers/hwmon/Makefile | 2 +- drivers/hwmon/occ/Kconfig | 19 +- drivers/hwmon/occ/Makefile | 12 +- drivers/hwmon/occ/common.c | 992 ++++++++++++++++++++++++++++++++++++++++++++- drivers/hwmon/occ/common.h | 5 + drivers/hwmon/occ/p8_i2c.c | 282 +++++++++++++ drivers/hwmon/occ/p9.c | 350 ---------------- drivers/hwmon/occ/p9.h | 17 - drivers/hwmon/occ/p9_sbe.c | 18 +- 9 files changed, 1320 insertions(+), 377 deletions(-) create mode 100644 drivers/hwmon/occ/p8_i2c.c delete mode 100644 drivers/hwmon/occ/p9.c delete mode 100644 drivers/hwmon/occ/p9.h
Signature · 1 line
1.8.3.1
PATCH 1/2 drivers: hwmon: occ: Add new sensor versions and non-hwmon attributes
From: "Edward A. James" <[email protected]>
Switch to versioned sensors which can be used for both p8 and p9. This adds more common code and removes the need for the processor-specific functions (other than the OCC access code).
Also add non-hwmon attributes for OCC status.
--- drivers/hwmon/occ/Makefile | 2 +- drivers/hwmon/occ/common.c | 992 ++++++++++++++++++++++++++++++++++++++++++++- drivers/hwmon/occ/common.h | 5 + drivers/hwmon/occ/p9.c | 350 ---------------- drivers/hwmon/occ/p9.h | 17 - drivers/hwmon/occ/p9_sbe.c | 18 +- 6 files changed, 1009 insertions(+), 375 deletions(-) delete mode 100644 drivers/hwmon/occ/p9.c delete mode 100644 drivers/hwmon/occ/p9.h
drivers/hwmon/occ/Makefile +1 -1
@@ -1 +1 @@ -obj-y += p9.o p9_sbe.o common.o +obj-y += p9_sbe.o common.o
drivers/hwmon/occ/common.c +991 -1
1,022 lines not on this page · raw message
drivers/hwmon/occ/common.h +5 -0
@@ -63,6 +63,7 @@ struct occ_poll_response {struct occ_sensor {u8 num_sensors; +u8 version;void *data; };
@@ -71,6 +72,7 @@ struct occ_sensors {struct occ_sensor freq;struct occ_sensor power;struct occ_sensor caps; +struct occ_sensor extended; };struct occ_attribute {
@@ -92,6 +94,7 @@ struct occ {struct occ_attribute *attrs;struct attribute_group group;const struct attribute_group *groups[2 ]; +struct sensor_device_attribute *status_attrs;u8 poll_cmd_data;int (*send_cmd)(struct occ *occ,u8 *cmd);
@@ -120,5 +123,7 @@ struct occ {int occ_poll (struct occ *occ);int occ_set_user_power_cap (struct occ *occ,u16 user_power_cap);int occ_update_response (struct occ *occ); +int occ_setup_sensor_attrs (struct occ *occ); +int occ_create_status_attrs (struct occ *occ);#endif /* __OCC_COMMON_H__ */
drivers/hwmon/occ/p9.c deleted +0 -350
350 lines not on this page · raw message
drivers/hwmon/occ/p9.h deleted +0 -17
@@ -1,17 +0,0 @@ -/* -* 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_P9_H__ -#define __OCC_P9_H__ - -struct occ ; - -int p9_occ_setup_sensor_attrs (struct occ *occ); - -#endif /* __OCC_P9_H__ */
drivers/hwmon/occ/p9_sbe.c +12 -6
@@ -15,9 +15,8 @@#include <linux/occ.h> #include <linux/sched.h> #include <linux/workqueue.h> -#include "p9.h" -#define P9_SBE_OCC_SETUP_DELAY 2500 +#define P9_SBE_OCC_SETUP_DELAY 5000#define OCC_TIMEOUT_MS 5000#define OCC_CMD_IN_PRG_MS 100
@@ -66,7 +65,8 @@ static int p9_sbe_occ_send_cmd(struct occ *occ, u8 *cmd)switch (resp->return_status) {case RESP_RETURN_CMD_IN_PRG : -if (time_after (jiffies, start +msecs_to_jiffies (OCC_TIMEOUT_MS ))) +if (time_after (jiffies, + start +msecs_to_jiffies (OCC_TIMEOUT_MS ))) rc = -EALREADY ;else {set_current_state (TASK_INTERRUPTIBLE );
@@ -123,7 +123,7 @@ static void p9_sbe_occ_setup(struct work_struct *work)occ_parse_poll_response (occ); - rc =p9_occ_setup_sensor_attrs (occ); + rc =occ_setup_sensor_attrs (occ);if (rc) {dev_err (occ->bus_dev,"failed to setup p9 attrs: %d\n" , rc);return ;
@@ -137,6 +137,10 @@ static void p9_sbe_occ_setup(struct work_struct *work) PTR_ERR(occ->hwmon));return ; } + + rc =occ_create_status_attrs (occ); +if (rc) +dev_err (occ->bus_dev,"failed to setup p9 status attrs: %d\n" , rc); }static int p9_sbe_occ_probe (struct platform_device *pdev)
@@ -157,7 +161,8 @@ static int p9_sbe_occ_probe(struct platform_device *pdev) occ->send_cmd = p9_sbe_occ_send_cmd;mutex_init (&occ->lock);INIT_DELAYED_WORK (&p9_sbe_occ->setup, p9_sbe_occ_setup); -platform_set_drvdata (pdev, p9_sbe_occ); + +platform_set_drvdata (pdev, occ);schedule_delayed_work (&p9_sbe_occ->setup,msecs_to_jiffies (P9_SBE_OCC_SETUP_DELAY ));
@@ -167,7 +172,8 @@ static int p9_sbe_occ_probe(struct platform_device *pdev)static int p9_sbe_occ_remove (struct platform_device *pdev) { -struct p9_sbe_occ *p9_sbe_occ =platform_get_drvdata (pdev); +struct occ *occ =platform_get_drvdata (pdev); +struct p9_sbe_occ *p9_sbe_occ =to_p9_sbe_occ (occ);cancel_delayed_work_sync (&p9_sbe_occ->setup);
Signature · 1 line
1.8.3.1
PATCH 2/2 drivers: hwmon: occ: Add P8 OCC access
In reply to Eddie JamesFrom: "Edward A. James" <[email protected]>
Access the P8 OCC over I2C bus.
--- drivers/hwmon/Makefile | 2 +- drivers/hwmon/occ/Kconfig | 19 ++- drivers/hwmon/occ/Makefile | 12 +- drivers/hwmon/occ/p8_i2c.c | 282 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 312 insertions(+), 3 deletions(-) create mode 100644 drivers/hwmon/occ/p8_i2c.c
drivers/hwmon/Makefile +1 -1
@@ -47,7 +47,6 @@ obj-$(CONFIG_SENSORS_APPLESMC) += applesmc.o obj-$(CONFIG_SENSORS_ARM_SCPI) += scpi-hwmon.o obj-$(CONFIG_SENSORS_ASC7621) += asc7621.o obj-$(CONFIG_SENSORS_ASPEED) += aspeed-pwm-tacho.o -obj-$(CONFIG_SENSORS_OCC_P9_SBE) += occ/ obj-$(CONFIG_SENSORS_ATXP1) += atxp1.o obj-$(CONFIG_SENSORS_CORETEMP) += coretemp.o obj-$(CONFIG_SENSORS_DA9052_ADC)+= da9052-hwmon.o
@@ -172,6 +171,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_OCC) += occ/ obj-$(CONFIG_PMBUS) += pmbus/ ccflags-$(CONFIG_HWMON_DEBUG_CHIP) := -DDEBUG
drivers/hwmon/occ/Kconfig +18 -1
@@ -2,9 +2,26 @@ # On-Chip Controller configuration # +config SENSORS_OCC + tristate "POWER On-Chip Controller" + help + If you say yes here you get support for monitoring the IBM POWER + processor sensors via the On-Chip Controller (OCC). + + This driver can also be built as a module. If so, the module will be + called occ-hwmon. + +config SENSORS_OCC_P8_I2C + bool "POWER8 OCC via I2C" + depends on I2C && SENSORS_OCC + help + If you say yes here you get support for monitoring the POWER8 + processor sensors via the OCC, from a service processor, over I2C + bus. + config SENSORS_OCC_P9_SBE bool "POWER9 OCC via SBE" - depends on OCCFIFO + depends on OCCFIFO && SENSORS_OCC help If you say yes here you get support for monitoring the POWER9 processor sensors via the OCC, from a service processor, over SBE
drivers/hwmon/occ/Makefile +11 -1
@@ -1 +1,11 @@ -obj-y += p9_sbe.o common.o +occ-hwmon-objs := common.o + +ifeq ($(CONFIG_SENSORS_OCC_P9_SBE), y) +occ-hwmon-objs += p9_sbe.o +endif + +ifeq ($(CONFIG_SENSORS_OCC_P8_I2C), y) +occ-hwmon-objs += p8_i2c.o +endif + +obj-$(CONFIG_SENSORS_OCC) += occ-hwmon.o
drivers/hwmon/occ/p8_i2c.c new file +282 -0
282 lines not on this page · raw message
Signature · 1 line
1.8.3.1