Message ID | 1501105213-13881-1-git-send-email-eajames@linux.vnet.ibm.com |
---|---|
State | Superseded, archived |
Headers | show |
On Thu, Jul 27, 2017 at 7:10 AM, Eddie James <eajames@linux.vnet.ibm.com> wrote: > From: "Edward A. James" <eajames@us.ibm.com> > > Add the driver to monitor power supply with hwmon. > > Signed-off-by: Edward A. James <eajames@us.ibm.com> Very neat! Great work. I assume there are no public datasheets for this one? Mention that in your commit message if so. Can you please post this to the upstream list? I want to get their opinion on the fault clearing. I don't have a suggestion for an alternative, unless we make this part of the pmbus core so that all devices have a clear_fault sysfs knob. Cheers, Joel > --- > drivers/hwmon/pmbus/Kconfig | 10 ++++++ > drivers/hwmon/pmbus/Makefile | 1 + > drivers/hwmon/pmbus/p17531.c | 81 ++++++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 92 insertions(+) > create mode 100644 drivers/hwmon/pmbus/p17531.c > > diff --git a/drivers/hwmon/pmbus/Kconfig b/drivers/hwmon/pmbus/Kconfig > index 68d717a..808ef2f 100644 > --- a/drivers/hwmon/pmbus/Kconfig > +++ b/drivers/hwmon/pmbus/Kconfig > @@ -125,6 +125,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 75bb7ca..f43628f 100644 > --- a/drivers/hwmon/pmbus/Makefile > +++ b/drivers/hwmon/pmbus/Makefile > @@ -13,6 +13,7 @@ obj-$(CONFIG_SENSORS_MAX16064) += max16064.o > obj-$(CONFIG_SENSORS_MAX20751) += max20751.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..ae6a19f > --- /dev/null > +++ b/drivers/hwmon/pmbus/p17531.c > @@ -0,0 +1,81 @@ > +/* > + * 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" > + > +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, > +}; > + > +static ssize_t p17531_clear_fault(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_fault, 0200, NULL, p17531_clear_fault); > + > +static int p17531_probe(struct i2c_client *client, > + const struct i2c_device_id *id) > +{ > + int rc; > + > + rc = pmbus_do_probe(client, id, &p17531_info); > + if (rc < 0) > + return rc; > + > + rc = device_create_file(&client->dev, &dev_attr_clear_fault); > + > + return rc; > +} > + > +static int p17531_remove(struct i2c_client *client) > +{ > + device_remove_file(&client->dev, &dev_attr_clear_fault); > + > + 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 struct i2c_driver p17531_driver = { > + .driver = { > + .name = "p17531", > + }, > + .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 >
diff --git a/drivers/hwmon/pmbus/Kconfig b/drivers/hwmon/pmbus/Kconfig index 68d717a..808ef2f 100644 --- a/drivers/hwmon/pmbus/Kconfig +++ b/drivers/hwmon/pmbus/Kconfig @@ -125,6 +125,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 75bb7ca..f43628f 100644 --- a/drivers/hwmon/pmbus/Makefile +++ b/drivers/hwmon/pmbus/Makefile @@ -13,6 +13,7 @@ obj-$(CONFIG_SENSORS_MAX16064) += max16064.o obj-$(CONFIG_SENSORS_MAX20751) += max20751.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..ae6a19f --- /dev/null +++ b/drivers/hwmon/pmbus/p17531.c @@ -0,0 +1,81 @@ +/* + * 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" + +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, +}; + +static ssize_t p17531_clear_fault(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_fault, 0200, NULL, p17531_clear_fault); + +static int p17531_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + int rc; + + rc = pmbus_do_probe(client, id, &p17531_info); + if (rc < 0) + return rc; + + rc = device_create_file(&client->dev, &dev_attr_clear_fault); + + return rc; +} + +static int p17531_remove(struct i2c_client *client) +{ + device_remove_file(&client->dev, &dev_attr_clear_fault); + + 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 struct i2c_driver p17531_driver = { + .driver = { + .name = "p17531", + }, + .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");