Skip to contentSkip to conversation

wip: hwmon: occ: Add sketch of the hwmon implementation for the P9 OCC

RFC PATCH NAK [email protected] 2 participants 2 messages Nov 29, 2016 – Dec 13, 2016 Hardware monitoring

lore
Share & tools
lore
#0 lore raw

RFC PATCH v6 9/9 wip: hwmon: occ: Add sketch of the hwmon implementation for the P9 OCC

From: "Edward A. James" <[email protected]>

---
 drivers/hwmon/occ/Kconfig      |  9 ++++
 drivers/hwmon/occ/Makefile     |  1 +
 drivers/hwmon/occ/occ_p9_fsi.c | 93 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 103 insertions(+)
 create mode 100644 drivers/hwmon/occ/occ_p9_fsi.c
drivers/hwmon/occ/Kconfig +9 -0
index e690001..7e95876 100644
@@ -26,4 +26,13 @@ config SENSORS_PPC_OCC_P8_I2C
 	 This driver can also be built as a module. If so, the module will be
 	 called occ-p8-i2c.
 
+config SENSORS_PPC_OCC_P9_FSI
+	tristate "POWER9 OCC hwmon support"
+	help
+	  Provide a hwmon sysfs interface for the POWER9 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 occ-p9-fsi.
+
 endif
drivers/hwmon/occ/Makefile +1 -0
index 05a84e9..77e47e1 100644
@@ -1,2 +1,3 @@
 obj-$(CONFIG_SENSORS_PPC_OCC) += occ.o occ_sysfs.o
 obj-$(CONFIG_SENSORS_PPC_OCC_P8_I2C) += occ_scom_i2c.o occ_p8.o occ_p8_i2c.o
+obj-$(CONFIG_SENSORS_PPC_OCC_P9_FSI) += occ_p9.o occ_p9_fsi.o
drivers/hwmon/occ/occ_p9_fsi.c new file +93 -0

93 lines not on this page · raw message

Signature · 1 line
1.9.1
#1 lore raw
Quoted 2 lines · On Tue, 2016-11-29 at 17:04 -0600, [email protected] wrote:
Quoted 1 line

From: "Edward A. James" <[email protected]>

We shouldn't include this patch until it is actually useful. I purposefully crippled it so I could get it to compile, mainly as a demonstration of how the architecture would work for the P9 case.

Andrew

Quoted 133 lines

---
 drivers/hwmon/occ/Kconfig      |  9 ++++ drivers/hwmon/occ/Makefile     |  1 + drivers/hwmon/occ/occ_p9_fsi.c | 93 ++++++++++++++++++++++++++++++++++++++++++

 3 files changed, 103 insertions(+)

 create mode 100644 drivers/hwmon/occ/occ_p9_fsi.c

drivers/hwmon/occ/Kconfig +0 -0
index e690001..7e95876 100644
@@ -26,4 +26,13 @@ config SENSORS_PPC_OCC_P8_I2C
Quoted 2 lines

   This driver can also be built as a module. If so, the module will be called occ-p8-i2c.


+config SENSORS_PPC_OCC_P9_FSI

drivers/hwmon/occ/Kconfig config SENSORS_PPC_OCC_P8_I2C · line 33

Quoted 4 lines
drivers/hwmon/occ/Kconfig +4 -0
+	tristate "POWER9 OCC hwmon support"
+	help
+	  Provide a hwmon sysfs interface for the POWER9 On-Chip Controller,
+	  exposing temperature, frequency and power measurements.

+

drivers/hwmon/occ/Kconfig config SENSORS_PPC_OCC_P8_I2C · line 36

Quoted 2 lines
drivers/hwmon/occ/Kconfig +2 -0
+	  This driver can also be built as a module. If so, the module will be
+	  called occ-p9-fsi.

+
 endif

drivers/hwmon/occ/Makefile +0 -0
index 05a84e9..77e47e1 100644
@@ -1,2 +1,3 @@

 obj-$(CONFIG_SENSORS_PPC_OCC) += occ.o occ_sysfs.o obj-$(CONFIG_SENSORS_PPC_OCC_P8_I2C) += occ_scom_i2c.o occ_p8.o occ_p8_i2c.o

drivers/hwmon/occ/Makefile +1 -0
+obj-$(CONFIG_SENSORS_PPC_OCC_P9_FSI) += occ_p9.o occ_p9_fsi.o
drivers/hwmon/occ/occ_p9_fsi.c new file +29 -0
new file mode 100644
index 0000000..2f651d1
@@ -0,0 +1,93 @@
+/*
+ * occ_p9_fsi.c - hwmon OCC driver
+ *
+ * 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/err.h>
+#include <linux/of.h>
+#include <linux/kernel.h>
+#include <linux/device.h>
+
+#include "scom.h"
+#include "occ_p9.h"
+#include "occ_sysfs.h"
+
Quoted 1 line

+#define OCC_I2C_NAME "occ-p9-fsi"

drivers/hwmon/occ/occ_p9_fsi.c new file +2 -0
+
+static char *caps_sensor_names[] = {
Quoted 6 lines
drivers/hwmon/occ/occ_p9_fsi.c new file +6 -0
+	"curr_powercap",
+	"curr_powerreading",
+	"norm_powercap",
+	"max_powercap",
+	"min_powercap",
+	"user_powerlimit"
drivers/hwmon/occ/occ_p9_fsi.c new file +4 -0
+};
+
+int p9_fsi_getscom(void *bus, u32 address, u8 *data, size_t offset)
+{
Quoted 1 line
drivers/hwmon/occ/occ_p9_fsi.c new file +1 -0
+	return -SCOM_READ_ERROR;
drivers/hwmon/occ/occ_p9_fsi.c new file +4 -0
+}
+
+int p9_fsi_putscom(void *bus, u32 address, u32 data0, u32 data1)
+{
Quoted 1 line
drivers/hwmon/occ/occ_p9_fsi.c new file +1 -0
+	return -SCOM_WRITE_ERROR;
drivers/hwmon/occ/occ_p9_fsi.c new file +3 -0
+}
+
+static struct occ_bus_ops p9_bus_ops = {
Quoted 2 lines
drivers/hwmon/occ/occ_p9_fsi.c new file +2 -0
+	.getscom = p9_fsi_getscom,
+	.putscom = p9_fsi_putscom,
drivers/hwmon/occ/occ_p9_fsi.c new file +3 -0
+};
+
+static struct occ_sysfs_config p9_sysfs_config = {
Quoted 2 lines
drivers/hwmon/occ/occ_p9_fsi.c new file +2 -0
+	.num_caps_fields = ARRAY_SIZE(caps_sensor_names),
+	.caps_names = caps_sensor_names,
drivers/hwmon/occ/occ_p9_fsi.c new file +4 -0
+};
+
+int occ_p9_probe(struct device *dev, void *client)
+{

drivers/hwmon/occ/occ_p9_fsi.c line 64

Quoted 2 lines
drivers/hwmon/occ/occ_p9_fsi.c new file +2 -0
+	struct occ *occ;
+	struct occ_sysfs *hwmon;

+

drivers/hwmon/occ/occ_p9_fsi.c line 68

Quoted 3 lines
drivers/hwmon/occ/occ_p9_fsi.c new file +3 -0
+	occ = occ_p9_start(dev, client, p9_bus_ops);
+	if (IS_ERR(occ))
+		return PTR_ERR(occ);

+

drivers/hwmon/occ/occ_p9_fsi.c line 72

Quoted 3 lines
drivers/hwmon/occ/occ_p9_fsi.c new file +3 -0
+	hwmon = occ_sysfs_start(dev, occ, &p9_sysfs_config);
+	if (IS_ERR(hwmon))
+		return PTR_ERR(hwmon);

+

Quoted 1 line
drivers/hwmon/occ/occ_p9_fsi.c new file +1 -0
+	return 0;
drivers/hwmon/occ/occ_p9_fsi.c new file +4 -0
+}
+
+int occ_p9_remove(void)
+{

drivers/hwmon/occ/occ_p9_fsi.c line 79

Quoted 1 line
drivers/hwmon/occ/occ_p9_fsi.c new file +1 -0
+	struct occ *occ = NULL;

+

Quoted 1 line
drivers/hwmon/occ/occ_p9_fsi.c new file +1 -0
+	return occ_p9_stop(occ);
drivers/hwmon/occ/occ_p9_fsi.c new file +4 -0
+}
+
+/* used by device table */
+static const struct of_device_id occ_of_match[] = {
Quoted 2 lines
drivers/hwmon/occ/occ_p9_fsi.c new file +2 -0
+	{ .compatible = "ibm,occ-p9-fsi" },
+	{}
drivers/hwmon/occ/occ_p9_fsi.c new file +3 -0
+};
+MODULE_DEVICE_TABLE(of, occ_of_match);
+
Quoted 1 line

+MODULE_AUTHOR("Eddie James <[email protected]>");

drivers/hwmon/occ/occ_p9_fsi.c new file +2 -0
+MODULE_DESCRIPTION("BMC P9 OCC hwmon driver");
+MODULE_LICENSE("GPL");