All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH linux dev-4.10 v2 0/5] drivers/hwmon/pmbus: Add IBM P17531 driver
@ 2017-07-31 20:12 Eddie James
  2017-07-31 20:12 ` [PATCH linux dev-4.10 v2 1/5] " Eddie James
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Eddie James @ 2017-07-31 20:12 UTC (permalink / raw)
  To: openbmc; +Cc: joel, mspinler, bjwyman, Edward A. James

From: "Edward A. James" <eajames@us.ibm.com>

This series adds a hwmon pmbus driver for the IBM P17531 power supply. The core
monitoring functionality is provided by pmbus. The driver also exports some
sysfs entries for raw status register access.

The driver should be probed automatically, so I added it to the witherspoon
device-tree.

Edward A. James (5):
  drivers/hwmon/pmbus: Add IBM P17531 driver
  drivers/hwmon/pmbus: p17531: Add non-hwmon attributes
  ARM: dts: aspeed: witherspoon: Add P17531 power supply to I2C bus
  Documentation: hwmon: Add P17531 documentation
  Documentation: ABI: Add P17531 sysfs documentation

 Documentation/ABI/testing/sysfs-driver-p17531    |  49 +++++
 Documentation/hwmon/p17531                       |  53 +++++
 arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts |  10 +
 drivers/hwmon/pmbus/Kconfig                      |  10 +
 drivers/hwmon/pmbus/Makefile                     |   1 +
 drivers/hwmon/pmbus/p17531.c                     | 245 +++++++++++++++++++++++
 6 files changed, 368 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-driver-p17531
 create mode 100644 Documentation/hwmon/p17531
 create mode 100644 drivers/hwmon/pmbus/p17531.c

-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH linux dev-4.10 v2 1/5] drivers/hwmon/pmbus: Add IBM P17531 driver
  2017-07-31 20:12 [PATCH linux dev-4.10 v2 0/5] drivers/hwmon/pmbus: Add IBM P17531 driver Eddie James
@ 2017-07-31 20:12 ` Eddie James
  2017-08-01 22:11   ` Brandon Wyman
  2017-07-31 20:12 ` [PATCH linux dev-4.10 v2 2/5] drivers/hwmon/pmbus: p17531: Add non-hwmon attributes Eddie James
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 7+ messages in thread
From: Eddie James @ 2017-07-31 20:12 UTC (permalink / raw)
  To: openbmc; +Cc: joel, mspinler, bjwyman, Edward A. James

From: "Edward A. James" <eajames@us.ibm.com>

Add the driver to monitor power supplies with hwmon over pmbus.

Signed-off-by: Edward A. James <eajames@us.ibm.com>
---
 drivers/hwmon/pmbus/Kconfig  |  10 +++
 drivers/hwmon/pmbus/Makefile |   1 +
 drivers/hwmon/pmbus/p17531.c | 165 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 176 insertions(+)
 create mode 100644 drivers/hwmon/pmbus/p17531.c

diff --git a/drivers/hwmon/pmbus/Kconfig b/drivers/hwmon/pmbus/Kconfig
index 04f6baa..033aeda 100644
--- a/drivers/hwmon/pmbus/Kconfig
+++ b/drivers/hwmon/pmbus/Kconfig
@@ -135,6 +135,16 @@ config SENSORS_MAX8688
 	  This driver can also be built as a module. If so, the module will
 	  be called max8688.
 
+config SENSORS_P17531
+	tristate "IBM P17531"
+	default n
+	help
+	  If you say yes here you get hardware monitoring support for IBM
+	  P17531 power supply.
+
+	  This driver can also be built as a module. If so, the module will
+	  be called p17531.
+
 config SENSORS_TPS40422
 	tristate "TI TPS40422"
 	default n
diff --git a/drivers/hwmon/pmbus/Makefile b/drivers/hwmon/pmbus/Makefile
index 663801c..b0625ec 100644
--- a/drivers/hwmon/pmbus/Makefile
+++ b/drivers/hwmon/pmbus/Makefile
@@ -14,6 +14,7 @@ obj-$(CONFIG_SENSORS_MAX20751)	+= max20751.o
 obj-$(CONFIG_SENSORS_MAX31785)	+= max31785.o
 obj-$(CONFIG_SENSORS_MAX34440)	+= max34440.o
 obj-$(CONFIG_SENSORS_MAX8688)	+= max8688.o
+obj-$(CONFIG_SENSORS_P17531)	+= p17531.o
 obj-$(CONFIG_SENSORS_TPS40422)	+= tps40422.o
 obj-$(CONFIG_SENSORS_UCD9000)	+= ucd9000.o
 obj-$(CONFIG_SENSORS_UCD9200)	+= ucd9200.o
diff --git a/drivers/hwmon/pmbus/p17531.c b/drivers/hwmon/pmbus/p17531.c
new file mode 100644
index 0000000..2190f8c
--- /dev/null
+++ b/drivers/hwmon/pmbus/p17531.c
@@ -0,0 +1,165 @@
+/*
+ * 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/device.h>
+#include <linux/i2c.h>
+#include <linux/jiffies.h>
+#include <linux/module.h>
+
+#include "pmbus.h"
+
+#define P17531_MFR_FAN_FAULT			BIT(0)
+#define P17531_MFR_THERMAL_FAULT		BIT(1)
+#define P17531_MFR_OV_FAULT			BIT(2)
+#define P17531_MFR_UV_FAULT			BIT(3)
+#define P17531_MFR_PS_KILL			BIT(4)
+#define P17531_MFR_OC_FAULT			BIT(5)
+#define P17531_MFR_VAUX_FAULT			BIT(6)
+#define P17531_MFR_CURRENT_SHARE_WARNING	BIT(7)
+
+static int p17531_read_word_data(struct i2c_client *client, int page, int reg);
+
+static int p17531_read_byte_data(struct i2c_client *client, int page, int reg)
+{
+	int rc, mfr;
+
+	switch (reg) {
+	case PMBUS_STATUS_BYTE:
+	case PMBUS_STATUS_WORD:
+		rc = p17531_read_word_data(client, page, PMBUS_STATUS_WORD);
+		break;
+	case PMBUS_STATUS_VOUT:
+	case PMBUS_STATUS_IOUT:
+	case PMBUS_STATUS_TEMPERATURE:
+	case PMBUS_STATUS_FAN_12:
+		rc = pmbus_read_byte_data(client, page, reg);
+		if (rc < 0)
+			return rc;
+
+		mfr = pmbus_read_byte_data(client, page,
+					   PMBUS_STATUS_MFR_SPECIFIC);
+		if (mfr < 0)
+			return rc;
+
+		if (reg == PMBUS_STATUS_FAN_12) {
+			if (mfr & P17531_MFR_FAN_FAULT)
+				rc |= PB_FAN_FAN1_FAULT;
+		} else if (reg == PMBUS_STATUS_TEMPERATURE) {
+			if (mfr & P17531_MFR_THERMAL_FAULT)
+				rc |= PB_TEMP_OT_FAULT;
+		} else if (reg == PMBUS_STATUS_VOUT) {
+			if (mfr &
+			    (P17531_MFR_OV_FAULT | P17531_MFR_VAUX_FAULT))
+				rc |= PB_VOLTAGE_OV_FAULT;
+			if (mfr & P17531_MFR_UV_FAULT)
+				rc |= PB_VOLTAGE_UV_FAULT;
+		} else if (reg == PMBUS_STATUS_IOUT) {
+			if (mfr & P17531_MFR_OC_FAULT)
+				rc |= PB_IOUT_OC_FAULT;
+			if (mfr & P17531_MFR_CURRENT_SHARE_WARNING)
+				rc |= PB_CURRENT_SHARE_FAULT;
+		}
+		break;
+	default:
+		if (reg >= PMBUS_VIRT_BASE)
+			return -ENXIO;
+
+		rc = pmbus_read_byte_data(client, page, reg);
+		break;
+	}
+
+	return rc;
+}
+
+static int p17531_read_word_data(struct i2c_client *client, int page, int reg)
+{
+	int rc, mfr;
+
+	switch (reg) {
+	case PMBUS_STATUS_BYTE:
+	case PMBUS_STATUS_WORD:
+		rc = pmbus_read_word_data(client, page, PMBUS_STATUS_WORD);
+		if (rc < 0)
+			return rc;
+
+		mfr = pmbus_read_byte_data(client, page,
+					   PMBUS_STATUS_MFR_SPECIFIC);
+		if (mfr < 0)
+			return rc;
+
+		if (mfr & P17531_MFR_PS_KILL)
+			rc |= PB_STATUS_OFF;
+
+		if (mfr)
+			rc |= PB_STATUS_WORD_MFR;
+		break;
+	default:
+		if (reg >= PMBUS_VIRT_BASE)
+			return -ENXIO;
+
+		rc = pmbus_read_word_data(client, page, reg);
+		if (rc < 0)
+			rc = p17531_read_byte_data(client, page, reg);
+		break;
+	}
+
+	return rc;
+}
+
+static struct pmbus_driver_info p17531_info = {
+	.pages = 1,
+	.func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT | PMBUS_HAVE_IOUT |
+		PMBUS_HAVE_PIN | PMBUS_HAVE_FAN12 | PMBUS_HAVE_TEMP |
+		PMBUS_HAVE_TEMP2 | PMBUS_HAVE_TEMP3 | PMBUS_HAVE_STATUS_VOUT |
+		PMBUS_HAVE_STATUS_IOUT | PMBUS_HAVE_STATUS_INPUT |
+		PMBUS_HAVE_STATUS_TEMP | PMBUS_HAVE_STATUS_FAN12,
+	.read_byte_data = p17531_read_byte_data,
+	.read_word_data = p17531_read_word_data,
+};
+
+static int p17531_probe(struct i2c_client *client,
+			const struct i2c_device_id *id)
+{
+	return pmbus_do_probe(client, id, &p17531_info);
+}
+
+static int p17531_remove(struct i2c_client *client)
+{
+	return pmbus_do_remove(client);
+}
+
+enum chips { p17531 };
+
+static const struct i2c_device_id p17531_id[] = {
+	{ "p17531", p17531 },
+	{ }
+};
+MODULE_DEVICE_TABLE(i2c, p17531_id);
+
+static const struct of_device_id p17531_of_match[] = {
+	{ .compatible = "ibm,p17531" },
+	{}
+};
+MODULE_DEVICE_TABLE(of, p8_i2c_occ_of_match);
+
+static struct i2c_driver p17531_driver = {
+	.driver = {
+		.name = "p17531",
+		.of_match_table = p17531_of_match,
+	},
+	.probe = p17531_probe,
+	.remove = p17531_remove,
+	.id_table = p17531_id,
+};
+
+module_i2c_driver(p17531_driver);
+
+MODULE_AUTHOR("Eddie James");
+MODULE_DESCRIPTION("PMBus driver for IBM P17531");
+MODULE_LICENSE("GPL");
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH linux dev-4.10 v2 2/5] drivers/hwmon/pmbus: p17531: Add non-hwmon attributes
  2017-07-31 20:12 [PATCH linux dev-4.10 v2 0/5] drivers/hwmon/pmbus: Add IBM P17531 driver Eddie James
  2017-07-31 20:12 ` [PATCH linux dev-4.10 v2 1/5] " Eddie James
@ 2017-07-31 20:12 ` Eddie James
  2017-07-31 20:12 ` [PATCH linux dev-4.10 v2 3/5] ARM: dts: aspeed: witherspoon: Add P17531 power supply to I2C bus Eddie James
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Eddie James @ 2017-07-31 20:12 UTC (permalink / raw)
  To: openbmc; +Cc: joel, mspinler, bjwyman, Edward A. James

From: "Edward A. James" <eajames@us.ibm.com>

Add sysfs entries to dump out PS registers and clear faults.

Signed-off-by: Edward A. James <eajames@us.ibm.com>
---
 drivers/hwmon/pmbus/p17531.c | 80 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 80 insertions(+)

diff --git a/drivers/hwmon/pmbus/p17531.c b/drivers/hwmon/pmbus/p17531.c
index 2190f8c..4b2d7e1 100644
--- a/drivers/hwmon/pmbus/p17531.c
+++ b/drivers/hwmon/pmbus/p17531.c
@@ -9,8 +9,10 @@
 
 #include <linux/device.h>
 #include <linux/i2c.h>
+#include <linux/hwmon-sysfs.h>
 #include <linux/jiffies.h>
 #include <linux/module.h>
+#include <linux/sysfs.h>
 
 #include "pmbus.h"
 
@@ -123,14 +125,92 @@ static int p17531_read_word_data(struct i2c_client *client, int page, int reg)
 	.read_word_data = p17531_read_word_data,
 };
 
+static ssize_t p17531_clear_faults(struct device *dev,
+				   struct device_attribute *dev_attr,
+				   const char *buf, size_t count)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+
+	pmbus_clear_faults(client);
+
+	return count;
+}
+static DEVICE_ATTR(clear_faults, 0200, NULL, p17531_clear_faults);
+
+static ssize_t p17531_show_status_word(struct device *dev,
+				       struct device_attribute *dev_attr,
+				       char *buf)
+{
+	int rc;
+	struct i2c_client *client = to_i2c_client(dev);
+
+	rc = pmbus_read_word_data(client, 0, PMBUS_STATUS_WORD);
+	if (rc < 0)
+		return rc;
+
+	return snprintf(buf, PAGE_SIZE - 1, "%04x\n", rc);
+}
+static DEVICE_ATTR(status_word, 0444, p17531_show_status_word, NULL);
+
+static ssize_t p17531_show_status_byte(struct device *dev,
+				       struct device_attribute *dev_attr,
+				       char *buf)
+{
+	int rc;
+	struct i2c_client *client = to_i2c_client(dev);
+	struct sensor_device_attribute *sattr = to_sensor_dev_attr(dev_attr);
+
+	rc = pmbus_read_byte_data(client, 0, PMBUS_STATUS_VOUT + sattr->index);
+	if (rc < 0)
+		return rc;
+
+	return snprintf(buf, PAGE_SIZE - 1, "%02x\n", rc);
+}
+
+static SENSOR_DEVICE_ATTR(status_vout, 0444, p17531_show_status_byte, NULL, 0);
+static SENSOR_DEVICE_ATTR(status_iout, 0444, p17531_show_status_byte, NULL, 1);
+static SENSOR_DEVICE_ATTR(status_input, 0444, p17531_show_status_byte, NULL,
+			  2);
+static SENSOR_DEVICE_ATTR(status_temp, 0444, p17531_show_status_byte, NULL, 3);
+static SENSOR_DEVICE_ATTR(status_cml, 0444, p17531_show_status_byte, NULL, 4);
+static SENSOR_DEVICE_ATTR(status_other, 0444, p17531_show_status_byte, NULL,
+			  5);
+static SENSOR_DEVICE_ATTR(status_mfr, 0444, p17531_show_status_byte, NULL, 6);
+static SENSOR_DEVICE_ATTR(status_fan, 0444, p17531_show_status_byte, NULL, 7);
+
+static struct attribute *p17531_attributes[] = {
+	&dev_attr_clear_faults.attr,
+	&dev_attr_status_word.attr,
+	&sensor_dev_attr_status_vout.dev_attr.attr,
+	&sensor_dev_attr_status_iout.dev_attr.attr,
+	&sensor_dev_attr_status_input.dev_attr.attr,
+	&sensor_dev_attr_status_temp.dev_attr.attr,
+	&sensor_dev_attr_status_cml.dev_attr.attr,
+	&sensor_dev_attr_status_other.dev_attr.attr,
+	&sensor_dev_attr_status_mfr.dev_attr.attr,
+	&sensor_dev_attr_status_fan.dev_attr.attr,
+	NULL
+};
+
+static const struct attribute_group p17531_attribute_group = {
+	.attrs = p17531_attributes,
+};
+
 static int p17531_probe(struct i2c_client *client,
 			const struct i2c_device_id *id)
 {
+	int rc = sysfs_create_group(&client->dev.kobj,
+				    &p17531_attribute_group);
+	if (rc)
+		return rc;
+
 	return pmbus_do_probe(client, id, &p17531_info);
 }
 
 static int p17531_remove(struct i2c_client *client)
 {
+	sysfs_remove_group(&client->dev.kobj, &p17531_attribute_group);
+
 	return pmbus_do_remove(client);
 }
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH linux dev-4.10 v2 3/5] ARM: dts: aspeed: witherspoon: Add P17531 power supply to I2C bus
  2017-07-31 20:12 [PATCH linux dev-4.10 v2 0/5] drivers/hwmon/pmbus: Add IBM P17531 driver Eddie James
  2017-07-31 20:12 ` [PATCH linux dev-4.10 v2 1/5] " Eddie James
  2017-07-31 20:12 ` [PATCH linux dev-4.10 v2 2/5] drivers/hwmon/pmbus: p17531: Add non-hwmon attributes Eddie James
@ 2017-07-31 20:12 ` Eddie James
  2017-07-31 20:12 ` [PATCH linux dev-4.10 v2 4/5] Documentation: hwmon: Add P17531 documentation Eddie James
  2017-07-31 20:12 ` [PATCH linux dev-4.10 v2 5/5] Documentation: ABI: Add P17531 sysfs documentation Eddie James
  4 siblings, 0 replies; 7+ messages in thread
From: Eddie James @ 2017-07-31 20:12 UTC (permalink / raw)
  To: openbmc; +Cc: joel, mspinler, bjwyman, Edward A. James

From: "Edward A. James" <eajames@us.ibm.com>

Signed-off-by: Edward A. James <eajames@us.ibm.com>
---
 arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts b/arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts
index 5afc03a..bb9f4a3 100644
--- a/arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts
+++ b/arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts
@@ -321,6 +321,16 @@
 			type = <PCA955X_TYPE_LED>;
 		};
 	};
+
+	p17531@68 {
+		compatible = "ibm,p17531";
+		reg = <0x68>;
+	};
+
+	p17531@69 {
+		compatible = "ibm,p17531";
+		reg = <0x69>;
+	};
 };
 
 &i2c4 {
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH linux dev-4.10 v2 4/5] Documentation: hwmon: Add P17531 documentation
  2017-07-31 20:12 [PATCH linux dev-4.10 v2 0/5] drivers/hwmon/pmbus: Add IBM P17531 driver Eddie James
                   ` (2 preceding siblings ...)
  2017-07-31 20:12 ` [PATCH linux dev-4.10 v2 3/5] ARM: dts: aspeed: witherspoon: Add P17531 power supply to I2C bus Eddie James
@ 2017-07-31 20:12 ` Eddie James
  2017-07-31 20:12 ` [PATCH linux dev-4.10 v2 5/5] Documentation: ABI: Add P17531 sysfs documentation Eddie James
  4 siblings, 0 replies; 7+ messages in thread
From: Eddie James @ 2017-07-31 20:12 UTC (permalink / raw)
  To: openbmc; +Cc: joel, mspinler, bjwyman, Edward A. James

From: "Edward A. James" <eajames@us.ibm.com>

Signed-off-by: Edward A. James <eajames@us.ibm.com>
---
 Documentation/hwmon/p17531 | 53 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)
 create mode 100644 Documentation/hwmon/p17531

diff --git a/Documentation/hwmon/p17531 b/Documentation/hwmon/p17531
new file mode 100644
index 0000000..e1fcbfc
--- /dev/null
+++ b/Documentation/hwmon/p17531
@@ -0,0 +1,53 @@
+Kernel driver p17531
+====================
+
+Supported chips:
+  * IBM P17531
+
+Author: Eddie James <eajames@us.ibm.com>
+
+Description
+-----------
+
+This driver supports the IBM P17531 power supply. This driver is a client to
+the core PMBus driver.
+
+Usage Notes
+-----------
+
+This driver should auto-detect devices. In the event that it does not, you will
+have to instantiate the devices explicitly. Please see
+Documentation/i2c/instantiating-devices for details.
+
+Sysfs entries
+-------------
+
+The following attributes are supported:
+
+curr1_alarm		Output current over-current fault.
+curr1_input		Measured output current in mA.
+curr1_label		"iout1"
+
+fan1_alarm		Fan 1 warning.
+fan1_fault		Fan 1 fault.
+fan1_input		Fan 1 speed in RPM.
+fan2_alarm		Fan 2 warning.
+fan2_fault		Fan 2 fault.
+fan2_input		Fan 2 speed in RPM.
+
+in1_alarm		Input voltage under-voltage fault.
+in1_input		Measured input voltage in mV.
+in1_label		"vin"
+in2_alarm		Output voltage over-voltage fault.
+in2_input		Measured output voltage in mV.
+in2_label		"vout1"
+
+power1_input		Measured input power in uW.
+power1_label		"pin"
+
+temp1_alarm		PSU inlet ambient temperature over-temperature fault.
+temp1_input		Measured PSU inlet ambient temp in millidegrees C.
+temp2_alarm		Secondary rectifier temp over-temperature fault.
+temp2_input		Measured secondary rectifier temp in millidegrees C.
+temp3_alarm		ORing FET temperature over-temperature fault.
+temp3_input		Measured ORing FET temperature in millidegrees C.
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH linux dev-4.10 v2 5/5] Documentation: ABI: Add P17531 sysfs documentation
  2017-07-31 20:12 [PATCH linux dev-4.10 v2 0/5] drivers/hwmon/pmbus: Add IBM P17531 driver Eddie James
                   ` (3 preceding siblings ...)
  2017-07-31 20:12 ` [PATCH linux dev-4.10 v2 4/5] Documentation: hwmon: Add P17531 documentation Eddie James
@ 2017-07-31 20:12 ` Eddie James
  4 siblings, 0 replies; 7+ messages in thread
From: Eddie James @ 2017-07-31 20:12 UTC (permalink / raw)
  To: openbmc; +Cc: joel, mspinler, bjwyman, Edward A. James

From: "Edward A. James" <eajames@us.ibm.com>

Signed-off-by: Edward A. James <eajames@us.ibm.com>
---
 Documentation/ABI/testing/sysfs-driver-p17531 | 49 +++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-driver-p17531

diff --git a/Documentation/ABI/testing/sysfs-driver-p17531 b/Documentation/ABI/testing/sysfs-driver-p17531
new file mode 100644
index 0000000..1645685
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-driver-p17531
@@ -0,0 +1,49 @@
+What:		/sys/bus/i2c/devices/<dev>/clear_faults
+KernelVersion:	4.13
+Contact:	eajames@us.ibm.com
+Description:	Clears pmbus faults for this power supply.
+
+What:		/sys/bus/i2c/devices/<dev>/status_word
+KernelVersion:	4.13
+Contact:	eajames@us.ibm.com
+Description:	Displays the STATUS_WORD register.
+
+What:		/sys/bus/i2c/devices/<dev>/status_vout
+KernelVersion:	4.13
+Contact:	eajames@us.ibm.com
+Description:	Displays the STATUS_VOUT register.
+
+What:		/sys/bus/i2c/devices/<dev>/status_iout
+KernelVersion:	4.13
+Contact:	eajames@us.ibm.com
+Description:	Displays the STATUS_IOUT register.
+
+What:		/sys/bus/i2c/devices/<dev>/status_input
+KernelVersion:	4.13
+Contact:	eajames@us.ibm.com
+Description:	Displays the STATUS_INPUT register.
+
+What:		/sys/bus/i2c/devices/<dev>/status_temp
+KernelVersion:	4.13
+Contact:	eajames@us.ibm.com
+Description:	Displays the STATUS_TEMPERATURE register.
+
+What:		/sys/bus/i2c/devices/<dev>/status_cml
+KernelVersion:	4.13
+Contact:	eajames@us.ibm.com
+Description:	Displays the STATUS_CML register.
+
+What:		/sys/bus/i2c/devices/<dev>/status_other
+KernelVersion:	4.13
+Contact:	eajames@us.ibm.com
+Description:	Displays the STATUS_OTHER register.
+
+What:		/sys/bus/i2c/devices/<dev>/status_mfr
+KernelVersion:	4.13
+Contact:	eajames@us.ibm.com
+Description:	Displays the STATUS_MFR_SPECIFIC register.
+
+What:		/sys/bus/i2c/devices/<dev>/status_fan
+KernelVersion:	4.13
+Contact:	eajames@us.ibm.com
+Description:	Displays the STATUS_FAN register.
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH linux dev-4.10 v2 1/5] drivers/hwmon/pmbus: Add IBM P17531 driver
  2017-07-31 20:12 ` [PATCH linux dev-4.10 v2 1/5] " Eddie James
@ 2017-08-01 22:11   ` Brandon Wyman
  0 siblings, 0 replies; 7+ messages in thread
From: Brandon Wyman @ 2017-08-01 22:11 UTC (permalink / raw)
  To: Eddie James; +Cc: OpenBMC Maillist, Joel Stanley, Matt Spinler, Edward A. James

On Mon, Jul 31, 2017 at 3:12 PM, Eddie James <eajames@linux.vnet.ibm.com> wrote:
> From: "Edward A. James" <eajames@us.ibm.com>
>
> Add the driver to monitor power supplies with hwmon over pmbus.
>
> Signed-off-by: Edward A. James <eajames@us.ibm.com>
> ---
>  drivers/hwmon/pmbus/Kconfig  |  10 +++
>  drivers/hwmon/pmbus/Makefile |   1 +
>  drivers/hwmon/pmbus/p17531.c | 165 +++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 176 insertions(+)
>  create mode 100644 drivers/hwmon/pmbus/p17531.c

This p17531/P17531 name for the device driver, files, and constants is
a bit cryptic. Without going into too much detail on why that is a bad
choice (refers to a document revision, not actual device), could a
better name be chosen for this device driver?

>
> diff --git a/drivers/hwmon/pmbus/Kconfig b/drivers/hwmon/pmbus/Kconfig
> index 04f6baa..033aeda 100644
> --- a/drivers/hwmon/pmbus/Kconfig
> +++ b/drivers/hwmon/pmbus/Kconfig
> @@ -135,6 +135,16 @@ config SENSORS_MAX8688
>           This driver can also be built as a module. If so, the module will
>           be called max8688.
>
> +config SENSORS_P17531
> +       tristate "IBM P17531"
> +       default n
> +       help
> +         If you say yes here you get hardware monitoring support for IBM
> +         P17531 power supply.
> +
> +         This driver can also be built as a module. If so, the module will
> +         be called p17531.
> +
>  config SENSORS_TPS40422
>         tristate "TI TPS40422"
>         default n
> diff --git a/drivers/hwmon/pmbus/Makefile b/drivers/hwmon/pmbus/Makefile
> index 663801c..b0625ec 100644
> --- a/drivers/hwmon/pmbus/Makefile
> +++ b/drivers/hwmon/pmbus/Makefile
> @@ -14,6 +14,7 @@ obj-$(CONFIG_SENSORS_MAX20751)        += max20751.o
>  obj-$(CONFIG_SENSORS_MAX31785) += max31785.o
>  obj-$(CONFIG_SENSORS_MAX34440) += max34440.o
>  obj-$(CONFIG_SENSORS_MAX8688)  += max8688.o
> +obj-$(CONFIG_SENSORS_P17531)   += p17531.o
>  obj-$(CONFIG_SENSORS_TPS40422) += tps40422.o
>  obj-$(CONFIG_SENSORS_UCD9000)  += ucd9000.o
>  obj-$(CONFIG_SENSORS_UCD9200)  += ucd9200.o
> diff --git a/drivers/hwmon/pmbus/p17531.c b/drivers/hwmon/pmbus/p17531.c
> new file mode 100644
> index 0000000..2190f8c
> --- /dev/null
> +++ b/drivers/hwmon/pmbus/p17531.c
> @@ -0,0 +1,165 @@
> +/*
> + * 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/device.h>
> +#include <linux/i2c.h>
> +#include <linux/jiffies.h>
> +#include <linux/module.h>
> +
> +#include "pmbus.h"
> +
> +#define P17531_MFR_FAN_FAULT                   BIT(0)
> +#define P17531_MFR_THERMAL_FAULT               BIT(1)
> +#define P17531_MFR_OV_FAULT                    BIT(2)
> +#define P17531_MFR_UV_FAULT                    BIT(3)
> +#define P17531_MFR_PS_KILL                     BIT(4)
> +#define P17531_MFR_OC_FAULT                    BIT(5)
> +#define P17531_MFR_VAUX_FAULT                  BIT(6)
> +#define P17531_MFR_CURRENT_SHARE_WARNING       BIT(7)
> +
> +static int p17531_read_word_data(struct i2c_client *client, int page, int reg);
> +
> +static int p17531_read_byte_data(struct i2c_client *client, int page, int reg)
> +{
> +       int rc, mfr;
> +
> +       switch (reg) {
> +       case PMBUS_STATUS_BYTE:
> +       case PMBUS_STATUS_WORD:
> +               rc = p17531_read_word_data(client, page, PMBUS_STATUS_WORD);
> +               break;
> +       case PMBUS_STATUS_VOUT:
> +       case PMBUS_STATUS_IOUT:
> +       case PMBUS_STATUS_TEMPERATURE:
> +       case PMBUS_STATUS_FAN_12:
> +               rc = pmbus_read_byte_data(client, page, reg);
> +               if (rc < 0)
> +                       return rc;
> +
> +               mfr = pmbus_read_byte_data(client, page,
> +                                          PMBUS_STATUS_MFR_SPECIFIC);
> +               if (mfr < 0)
> +                       return rc;
> +
> +               if (reg == PMBUS_STATUS_FAN_12) {
> +                       if (mfr & P17531_MFR_FAN_FAULT)
> +                               rc |= PB_FAN_FAN1_FAULT;
> +               } else if (reg == PMBUS_STATUS_TEMPERATURE) {
> +                       if (mfr & P17531_MFR_THERMAL_FAULT)
> +                               rc |= PB_TEMP_OT_FAULT;
> +               } else if (reg == PMBUS_STATUS_VOUT) {
> +                       if (mfr &
> +                           (P17531_MFR_OV_FAULT | P17531_MFR_VAUX_FAULT))
> +                               rc |= PB_VOLTAGE_OV_FAULT;
> +                       if (mfr & P17531_MFR_UV_FAULT)
> +                               rc |= PB_VOLTAGE_UV_FAULT;
> +               } else if (reg == PMBUS_STATUS_IOUT) {
> +                       if (mfr & P17531_MFR_OC_FAULT)
> +                               rc |= PB_IOUT_OC_FAULT;
> +                       if (mfr & P17531_MFR_CURRENT_SHARE_WARNING)
> +                               rc |= PB_CURRENT_SHARE_FAULT;
> +               }
> +               break;
> +       default:
> +               if (reg >= PMBUS_VIRT_BASE)
> +                       return -ENXIO;
> +
> +               rc = pmbus_read_byte_data(client, page, reg);
> +               break;
> +       }
> +
> +       return rc;
> +}
> +
> +static int p17531_read_word_data(struct i2c_client *client, int page, int reg)
> +{
> +       int rc, mfr;
> +
> +       switch (reg) {
> +       case PMBUS_STATUS_BYTE:
> +       case PMBUS_STATUS_WORD:
> +               rc = pmbus_read_word_data(client, page, PMBUS_STATUS_WORD);
> +               if (rc < 0)
> +                       return rc;
> +
> +               mfr = pmbus_read_byte_data(client, page,
> +                                          PMBUS_STATUS_MFR_SPECIFIC);
> +               if (mfr < 0)
> +                       return rc;
> +
> +               if (mfr & P17531_MFR_PS_KILL)
> +                       rc |= PB_STATUS_OFF;
> +
> +               if (mfr)
> +                       rc |= PB_STATUS_WORD_MFR;
> +               break;
> +       default:
> +               if (reg >= PMBUS_VIRT_BASE)
> +                       return -ENXIO;
> +
> +               rc = pmbus_read_word_data(client, page, reg);
> +               if (rc < 0)
> +                       rc = p17531_read_byte_data(client, page, reg);
> +               break;
> +       }
> +
> +       return rc;
> +}
> +
> +static struct pmbus_driver_info p17531_info = {
> +       .pages = 1,
> +       .func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT | PMBUS_HAVE_IOUT |
> +               PMBUS_HAVE_PIN | PMBUS_HAVE_FAN12 | PMBUS_HAVE_TEMP |
> +               PMBUS_HAVE_TEMP2 | PMBUS_HAVE_TEMP3 | PMBUS_HAVE_STATUS_VOUT |
> +               PMBUS_HAVE_STATUS_IOUT | PMBUS_HAVE_STATUS_INPUT |
> +               PMBUS_HAVE_STATUS_TEMP | PMBUS_HAVE_STATUS_FAN12,
> +       .read_byte_data = p17531_read_byte_data,
> +       .read_word_data = p17531_read_word_data,
> +};
> +
> +static int p17531_probe(struct i2c_client *client,
> +                       const struct i2c_device_id *id)
> +{
> +       return pmbus_do_probe(client, id, &p17531_info);
> +}
> +
> +static int p17531_remove(struct i2c_client *client)
> +{
> +       return pmbus_do_remove(client);
> +}
> +
> +enum chips { p17531 };
> +
> +static const struct i2c_device_id p17531_id[] = {
> +       { "p17531", p17531 },
> +       { }
> +};
> +MODULE_DEVICE_TABLE(i2c, p17531_id);
> +
> +static const struct of_device_id p17531_of_match[] = {
> +       { .compatible = "ibm,p17531" },
> +       {}
> +};
> +MODULE_DEVICE_TABLE(of, p8_i2c_occ_of_match);
> +
> +static struct i2c_driver p17531_driver = {
> +       .driver = {
> +               .name = "p17531",
> +               .of_match_table = p17531_of_match,
> +       },
> +       .probe = p17531_probe,
> +       .remove = p17531_remove,
> +       .id_table = p17531_id,
> +};
> +
> +module_i2c_driver(p17531_driver);
> +
> +MODULE_AUTHOR("Eddie James");
> +MODULE_DESCRIPTION("PMBus driver for IBM P17531");
> +MODULE_LICENSE("GPL");
> --
> 1.8.3.1
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-08-01 22:11 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-31 20:12 [PATCH linux dev-4.10 v2 0/5] drivers/hwmon/pmbus: Add IBM P17531 driver Eddie James
2017-07-31 20:12 ` [PATCH linux dev-4.10 v2 1/5] " Eddie James
2017-08-01 22:11   ` Brandon Wyman
2017-07-31 20:12 ` [PATCH linux dev-4.10 v2 2/5] drivers/hwmon/pmbus: p17531: Add non-hwmon attributes Eddie James
2017-07-31 20:12 ` [PATCH linux dev-4.10 v2 3/5] ARM: dts: aspeed: witherspoon: Add P17531 power supply to I2C bus Eddie James
2017-07-31 20:12 ` [PATCH linux dev-4.10 v2 4/5] Documentation: hwmon: Add P17531 documentation Eddie James
2017-07-31 20:12 ` [PATCH linux dev-4.10 v2 5/5] Documentation: ABI: Add P17531 sysfs documentation Eddie James

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.