Skip to contentSkip to conversation

drivers: Add hwmon occ driver framework

PATCH New [email protected] 1 participant 1 message Nov 7, 2016

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

PATCH v5 2/5 drivers: Add hwmon occ driver framework

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

create i2c layer for accessing OCC over i2c bus create p8 and p9 specific layers for different OCC versions

---
 .../devicetree/bindings/i2c/i2c-ibm-occ.txt        | 13 ++++
 drivers/hwmon/Kconfig                              |  2 +
 drivers/hwmon/Makefile                             |  1 +
 drivers/hwmon/occ/Kconfig                          | 15 +++++
 drivers/hwmon/occ/Makefile                         |  1 +
 drivers/hwmon/occ/occ.c                            | 45 +++++++++++++
 drivers/hwmon/occ/occ.h                            | 28 ++++++++
 drivers/hwmon/occ/occ_i2c.c                        | 77 ++++++++++++++++++++++
 drivers/hwmon/occ/p8.c                             | 39 +++++++++++
 drivers/hwmon/occ/p8.h                             | 27 ++++++++
 drivers/hwmon/occ/p9.c                             | 39 +++++++++++
 drivers/hwmon/occ/p9.h                             | 27 ++++++++
 12 files changed, 314 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/i2c/i2c-ibm-occ.txt
 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_i2c.c
 create mode 100644 drivers/hwmon/occ/p8.c
 create mode 100644 drivers/hwmon/occ/p8.h
 create mode 100644 drivers/hwmon/occ/p9.c
 create mode 100644 drivers/hwmon/occ/p9.h
Documentation/devicetree/bindings/i2c/i2c-ibm-occ.txt new file +13 -0
new file mode 100644
index 0000000..7d73dd6
@@ -0,0 +1,13 @@
+HWMON i2c driver for IBM POWER CPU OCC (On Chip Controller)
+
+Required properties:
+ - compatible: must be "ibm,occ-i2c"
+ - reg: physical address
+
+Example:
+i2c3: i2c-bus@100 {
+	occ@50 {
+		compatible = "ibm,occ-i2c";
+		reg = <0x50>;
+	};
+};
drivers/hwmon/Kconfig +2 -0
index 367496c..f4b0180 100644
@@ -1226,6 +1226,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
index d7ccb02..ab1c121 100644
@@ -165,6 +165,7 @@ obj-$(CONFIG_SENSORS_WM831X)	+= wm831x-hwmon.o
 obj-$(CONFIG_SENSORS_WM8350)	+= wm8350-hwmon.o
 
 obj-$(CONFIG_PMBUS)		+= pmbus/
+obj-$(CONFIG_OCC)		+= occ/
 
 ccflags-$(CONFIG_HWMON_DEBUG_CHIP) := -DDEBUG
 
drivers/hwmon/occ/Kconfig new file +15 -0
new file mode 100644
index 0000000..628fd6e
@@ -0,0 +1,15 @@
+#
+# On Chip Controller configuration
+#
+
+config OCC
+	tristate "On Chip Controller driver"
+	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
new file mode 100644
index 0000000..87c191a
@@ -0,0 +1 @@
+obj-$(CONFIG_OCC) += occ.o occ_i2c.o p8.o p9.o
drivers/hwmon/occ/occ.c new file +45 -0

45 lines not on this page · raw message

drivers/hwmon/occ/occ.h new file +28 -0
new file mode 100644
index 0000000..736d3b9
@@ -0,0 +1,28 @@
+/*
+ * occ.h - hwmon OCC driver
+ *
+ * This file contains data structures and function prototypes for common access
+ * between different bus protocols and host systems.
+ *
+ * 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_H__
+#define __OCC_H__
+
+struct device;
+
+int occ_start(struct device *dev);
+int occ_stop(struct device *dev);
+
+#endif /* __OCC_H__ */
drivers/hwmon/occ/occ_i2c.c new file +77 -0

77 lines not on this page · raw message

drivers/hwmon/occ/p8.c new file +39 -0
new file mode 100644
index 0000000..6d854bc
@@ -0,0 +1,39 @@
+/*
+ * p8.c - OCC hwmon driver
+ *
+ * This file contains the Power8-specific methods and data structures for
+ * the OCC hwmon 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/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 <linux/platform_device.h>
+
+#include "occ.h"
+
+int p8_occ_start(struct device *dev)
+{
+	return occ_start(dev);
+}
+
+int p8_occ_stop(struct device *dev)
+{
+	return occ_stop(dev);
+}
drivers/hwmon/occ/p8.h new file +27 -0
new file mode 100644
index 0000000..e6941e4
@@ -0,0 +1,27 @@
+/*
+ * 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 __P8_H__
+#define __P8_H__
+
+struct device;
+
+int p8_occ_start(struct device *dev);
+int p8_occ_stop(struct device *dev);
+
+#endif /* __P8_H__ */
drivers/hwmon/occ/p9.c new file +39 -0
new file mode 100644
index 0000000..065d9bb
@@ -0,0 +1,39 @@
+/*
+ * p9.c - OCC hwmon driver
+ *
+ * This file contains the Power9-specific methods and data structures for
+ * the OCC hwmon 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/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 "occ.h"
+
+int p9_occ_start(struct device *dev)
+{
+	return occ_start(dev);
+}
+
+int p9_occ_stop(struct device *dev)
+{
+	return occ_stop(dev);
+}
drivers/hwmon/occ/p9.h new file +27 -0
new file mode 100644
index 0000000..62fe95a
@@ -0,0 +1,27 @@
+/*
+ * 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 __P9_H__
+#define __P9_H__
+
+struct device;
+
+int p9_occ_start(struct device *dev);
+int p9_occ_stop(struct device *dev);
+
+#endif /* __P9_H__ */
Signature · 1 line
1.9.1