drivers/hwmon/pmbus: Add IBM power supply hwmon driver
v3 cover drivers/hwmon/pmbus: Add IBM power supply hwmon driver
From: "Edward A. James" <[email protected]>
This series adds a hwmon pmbus driver for the IBM 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 power supply hwmon driver drivers/hwmon/pmbus: ibmps: Add non-hwmon attributes
Documentation: hwmon: Add IBM power supply documentation
Documentation: ABI: Add IBM power supply sysfs documentation
ARM: dts: aspeed: witherspoon: Add IBM power supply to I2C bus
Documentation/ABI/testing/sysfs-driver-ibmps | 49 +++++ Documentation/hwmon/ibmps | 53 +++++ arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts | 10 + drivers/hwmon/pmbus/Kconfig | 10 + drivers/hwmon/pmbus/Makefile | 1 + drivers/hwmon/pmbus/ibmps.c | 242 +++++++++++++++++++++++ 6 files changed, 365 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-driver-ibmps create mode 100644 Documentation/hwmon/ibmps create mode 100644 drivers/hwmon/pmbus/ibmps.c
Signature · 1 line
1.8.3.1
PATCH v3 1/5 drivers/hwmon/pmbus: Add IBM power supply hwmon driver
From: "Edward A. James" <[email protected]>
Add the driver to monitor power supplies with hwmon over pmbus.
--- drivers/hwmon/pmbus/Kconfig | 10 +++ drivers/hwmon/pmbus/Makefile | 1 + drivers/hwmon/pmbus/ibmps.c | 164 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 175 insertions(+) create mode 100644 drivers/hwmon/pmbus/ibmps.c
drivers/hwmon/pmbus/Kconfig +10 -0
@@ -37,6 +37,16 @@ config SENSORS_ADM1275 This driver can also be built as a module. If so, the module will be called adm1275. +config SENSORS_IBMPS + tristate "IBM Power Supply" + default n + help + If you say yes here you get hardware monitoring support for IBM + power supply. + + This driver can also be built as a module. If so, the module will + be called ibmps. + config SENSORS_IR35221 tristate "Infineon IR35221" default n
drivers/hwmon/pmbus/Makefile +1 -0
@@ -5,6 +5,7 @@ obj-$(CONFIG_PMBUS) += pmbus_core.o obj-$(CONFIG_SENSORS_PMBUS) += pmbus.o obj-$(CONFIG_SENSORS_ADM1275) += adm1275.o +obj-$(CONFIG_SENSORS_IBMPS) += ibmps.o obj-$(CONFIG_SENSORS_IR35221) += ir35221.o obj-$(CONFIG_SENSORS_LM25066) += lm25066.o obj-$(CONFIG_SENSORS_LTC2978) += ltc2978.o
drivers/hwmon/pmbus/ibmps.c new file +164 -0
164 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Quoted 57 lines · Eddie James
Quoted 1 line
From: "Edward A. James" <[email protected]>
Add the driver to monitor power supplies with hwmon over pmbus.
Quoted 1 line
Signed-off-by Edward A. James <[email protected]>---
drivers/hwmon/pmbus/Kconfig | 10 +++drivers/hwmon/pmbus/Makefile| 1 +
drivers/hwmon/pmbus/ibmps.c | 164 +++++++++++++++++++++++++++++++++++++++++++3 files changed, 175 insertions(+)create mode 100644
drivers/hwmon/pmbus/ibmps.cdrivers/hwmon/pmbus/Kconfig +0
-0@@ -37,6 +37,16 @@ config SENSORS_ADM1275Quoted 2 lines
This driver can also be built as a module. If so, the module will be called adm1275.
+configSENSORS_IBMPSdrivers/hwmon/pmbus/Kconfig config SENSORS_ADM1275 · line 45
Quoted 5 lines
drivers/hwmon/pmbus/Kconfig +5
-0+ tristate "IBM Power Supply" + default n + help + If you say yes here you get hardware monitoring support for IBM + power supply.+
drivers/hwmon/pmbus/Kconfig config SENSORS_ADM1275 · line 48
Quoted 2 lines
drivers/hwmon/pmbus/Kconfig +2
-0+ This driver can also be built as a module. If so, the module will + be called ibmps.+
configSENSORS_IR35221Quoted 2 lines
tristate "Infineon IR35221"
default ndrivers/hwmon/pmbus/Makefile +0
-0@@ -5,6 +5,7 @@Quoted 7 lines
obj-$(CONFIG_PMBUS) += pmbus_core.o
obj-$(CONFIG_SENSORS_PMBUS) += pmbus.o
obj-$(CONFIG_SENSORS_ADM1275) += adm1275.o
+obj-$(CONFIG_SENSORS_IBMPS) += ibmps.o
obj-$(CONFIG_SENSORS_IR35221) += ir35221.o
obj-$(CONFIG_SENSORS_LM25066) += lm25066.o
obj-$(CONFIG_SENSORS_LTC2978) += ltc2978.odrivers/hwmon/pmbus/ibmps.c new file +6
-0@@ -0,0 +1,164 @@ +/* +* 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
drivers/hwmon/pmbus/ibmps.c line 16
Quoted 10 lines
drivers/hwmon/pmbus/ibmps.c new file +10
-0+* (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" +
I think a comment is needed here to point out these bits are for STATUS_MFR_SPECIFIC.
drivers/hwmon/pmbus/ibmps.c line 27
Quoted 11 lines
drivers/hwmon/pmbus/ibmps.c new file +1
-0+#define IBMPS_MFR_FAN_FAULT BIT(0)Quoted 7 lines
drivers/hwmon/pmbus/ibmps.c new file +7
-0+#define IBMPS_MFR_THERMAL_FAULT BIT(1) +#define IBMPS_MFR_OV_FAULT BIT(2) +#define IBMPS_MFR_UV_FAULT BIT(3) +#define IBMPS_MFR_PS_KILL BIT(4) +#define IBMPS_MFR_OC_FAULT BIT(5) +#define IBMPS_MFR_VAUX_FAULT BIT(6) +#define IBMPS_MFR_CURRENT_SHARE_WARNING BIT(7)drivers/hwmon/pmbus/ibmps.c new file +3
-0+ +static int ibmps_read_word_data (struct i2c_client *client,int page,int reg); +
This makes me curious.
drivers/hwmon/pmbus/ibmps.c line 35
Quoted 8 lines
drivers/hwmon/pmbus/ibmps.c new file +2
-0+static int ibmps_read_byte_data (struct i2c_client *client,int page,int reg) +{Review
Quoted 1 line
(quoted diff) +1
-0+ int rc, mfr;+
Quoted 3 lines
drivers/hwmon/pmbus/ibmps.c new file +3
-0+switch (reg) { +case PMBUS_STATUS_BYTE : +case PMBUS_STATUS_WORD :drivers/hwmon/pmbus/ibmps.c new file +1
-0+ rc =ibmps_read_word_data (client, page,PMBUS_STATUS_WORD );
Feels wrong to return "junk" in the result for a PMBUS_STATUS_BYTE query.
Quoted 29 lines
drivers/hwmon/pmbus/ibmps.c new file +1
-0+break ;drivers/hwmon/pmbus/ibmps.c line 43
Quoted 7 lines
drivers/hwmon/pmbus/ibmps.c new file +7
-0+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;+
drivers/hwmon/pmbus/ibmps.c line 48
Quoted 4 lines
drivers/hwmon/pmbus/ibmps.c new file +4
-0+ mfr =pmbus_read_byte_data (client, page, + PMBUS_STATUS_MFR_SPECIFIC); +if (mfr <0 ) +return rc;+
Quoted 15 lines
drivers/hwmon/pmbus/ibmps.c new file +15
-0+if (reg ==PMBUS_STATUS_FAN_12 ) { +if (mfr &IBMPS_MFR_FAN_FAULT ) + rc |=PB_FAN_FAN1_FAULT ; + }else if (reg ==PMBUS_STATUS_TEMPERATURE ) { +if (mfr &IBMPS_MFR_THERMAL_FAULT ) + rc |=PB_TEMP_OT_FAULT ; + }else if (reg ==PMBUS_STATUS_VOUT ) { +if (mfr & (IBMPS_MFR_OV_FAULT |IBMPS_MFR_VAUX_FAULT )) + rc |=PB_VOLTAGE_OV_FAULT ; +if (mfr &IBMPS_MFR_UV_FAULT ) + rc |=PB_VOLTAGE_UV_FAULT ; + }else if (reg ==PMBUS_STATUS_IOUT ) { +if (mfr &IBMPS_MFR_OC_FAULT ) + rc |=PB_IOUT_OC_FAULT ; +if (mfr &IBMPS_MFR_CURRENT_SHARE_WARNING )
drivers/hwmon/pmbus/ibmps.c line 66
Quoted 3 lines
drivers/hwmon/pmbus/ibmps.c new file +2
-0+ rc |=PB_CURRENT_SHARE_FAULT ; + }
I wonder why it was done this way and not simply via the spec'ed bits? Maybe some don't fit, but it seems there's a pretty direct mapping for the most part.
Do the spec'ed status bits ever get set? As in, is there ever some ambiguity about how the bits got set?
drivers/hwmon/pmbus/ibmps.c
Quoted 6 lines
Quoted 4 lines
drivers/hwmon/pmbus/ibmps.c new file +4
-0+break ; +default : +if (reg >=PMBUS_VIRT_BASE ) +return -ENXIO ;drivers/hwmon/pmbus/ibmps.c new file +2
-0+ + rc =pmbus_read_byte_data (client, page, reg);
The alternative here is -ENODATA; not sure which is better though.
Quoted 26 lines
drivers/hwmon/pmbus/ibmps.c new file +1
-0+break ;Review
Quoted 1 line
(quoted diff) +1
-0+ }+
Quoted 1 line
(quoted diff) +1
-0+ return rc;drivers/hwmon/pmbus/ibmps.c new file +4
-0+} + +static int ibmps_read_word_data (struct i2c_client *client,int page,int reg) +{Review
Quoted 1 line
(quoted diff) +1
-0+ int rc, mfr;+
drivers/hwmon/pmbus/ibmps.c line 88
Quoted 6 lines
drivers/hwmon/pmbus/ibmps.c new file +6
-0+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;+
drivers/hwmon/pmbus/ibmps.c line 48
Quoted 4 lines
drivers/hwmon/pmbus/ibmps.c new file +4
-0+ mfr =pmbus_read_byte_data (client, page, + PMBUS_STATUS_MFR_SPECIFIC); +if (mfr <0 ) +return rc;+
drivers/hwmon/pmbus/ibmps.c line 96
Quoted 2 lines
drivers/hwmon/pmbus/ibmps.c new file +2
-0+if (mfr &IBMPS_MFR_PS_KILL ) + rc |=PB_STATUS_OFF ;+
Quoted 1 line
drivers/hwmon/pmbus/ibmps.c new file +1
-0+if (mfr)
drivers/hwmon/pmbus/ibmps.c line 99
Quoted 1 line
drivers/hwmon/pmbus/ibmps.c new file +1
-0+ rc |=PB_STATUS_WORD_MFR ;
This isn't set automatically by the device?
drivers/hwmon/pmbus/ibmps.c line 107
Quoted 8 lines
drivers/hwmon/pmbus/ibmps.c new file +1
-0+break ;drivers/hwmon/pmbus/ibmps.c line 70
Quoted 3 lines
drivers/hwmon/pmbus/ibmps.c new file +3
-0+default : +if (reg >=PMBUS_VIRT_BASE ) +return -ENXIO ;+
Quoted 2 lines
drivers/hwmon/pmbus/ibmps.c new file +2
-0+ rc =pmbus_read_word_data (client, page, reg); +if (rc <0 )drivers/hwmon/pmbus/ibmps.c new file +1
-0+ rc =ibmps_read_byte_data (client, page, reg);
Is this really the way we should go about accesses?
Quoted 19 lines
drivers/hwmon/pmbus/ibmps.c new file +1
-0+break ;Review
Quoted 1 line
(quoted diff) +1
-0+ }+
Quoted 1 line
(quoted diff) +1
-0+ return rc;drivers/hwmon/pmbus/ibmps.c new file +3
-0+} + +static struct pmbus_driver_info ibmps_info = {Quoted 8 lines
drivers/hwmon/pmbus/ibmps.c new file +8
-0+ .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 = ibmps_read_byte_data, + .read_word_data = ibmps_read_word_data,drivers/hwmon/pmbus/ibmps.c new file +3
-0+}; + +static int ibmps_probe(struct i2c_client *client,Quoted 1 line
drivers/hwmon/pmbus/ibmps.c new file +1
-0+ const struct i2c_device_id *id)
drivers/hwmon/pmbus/ibmps.c
Quoted 2 lines
drivers/hwmon/pmbus/ibmps.c new file +2
-0+{ +return pmbus_do_probe (client, id, &ibmps_info);
Is there anything we need to check before probe, e.g. MFR_ID/MFR_MODEL/MFR_REVISION? Are there options that might need to be configured (and exposed via devicetree bindings)?
I note we support fans: Is FAN_CONFIG_1_2 configured as needed? Or do we need to enable the fan, configure PWM vs RPM and the tach pulses value? If it is pre-configured, is this register always going to be pre-configured? Or do we need a property like my proposed 'use-stored- presence' for the MAX31785?
Have you had a look at my proposed bindings for the max31785? I think it would be worth your input, as we have another case of fans here, and it will help us shape a better picture of whether my generic properties
and node structure are appropriate.
drivers/hwmon/pmbus/ibmps.c line 136
Quoted 8 lines
drivers/hwmon/pmbus/ibmps.c new file +4
-0+} + +static int ibmps_remove (struct i2c_client *client) +{Quoted 1 line
drivers/hwmon/pmbus/ibmps.c new file +1
-0+return pmbus_do_remove (client);drivers/hwmon/pmbus/ibmps.c new file +3
-0+} + +enum chips { witherspoon };
This doesn't look necessary.
drivers/hwmon/pmbus/ibmps.c
Quoted 12 lines
drivers/hwmon/pmbus/ibmps.c new file +2
-0+ +static const struct i2c_device_id ibmps_id[] = {Quoted 2 lines
drivers/hwmon/pmbus/ibmps.c new file +2
-0+ { "witherspoon", witherspoon }, + { }drivers/hwmon/pmbus/ibmps.c new file +4
-0+}; +MODULE_DEVICE_TABLE (i2c, ibmps_id); + +static const struct of_device_id ibmps_of_match[] = {Quoted 2 lines
drivers/hwmon/pmbus/ibmps.c new file +2
-0+ { .compatible = "ibm,ibmps" }, + {}drivers/hwmon/pmbus/ibmps.c new file +2
-0+}; +MODULE_DEVICE_TABLE (of, p8_i2c_occ_of_match);
p8_i2c_occ_of_match isn't right. Do we need both device tables? "witherspoon" as a device ID also seems unusual. What's going on there?
Quoted 9 lines
drivers/hwmon/pmbus/ibmps.c new file +2
-0+ +static struct i2c_driver ibmps_driver = {Quoted 7 lines
drivers/hwmon/pmbus/ibmps.c new file +7
-0+ .driver = { + .name = "ibmps", + .of_match_table = ibmps_of_match, + }, + .probe = ibmps_probe, + .remove = ibmps_remove, + .id_table = ibmps_id,
drivers/hwmon/pmbus/ibmps.c line 163
Quoted 6 lines
drivers/hwmon/pmbus/ibmps.c new file +6
-0+}; + +module_i2c_driver (ibmps_driver); + +MODULE_AUTHOR ("Eddie James" ); +MODULE_DESCRIPTION ("PMBus driver for IBM power supply" );
So do we anticipate only ever having one power supply design? The name feels a bit generic. In the device id table above you suggest it's called 'witherspoon'. Is the design specific to Witherspoon? If so this fact should be included in the driver name and description.
If there are other power supplies that are similar, then when we add support we can rename the driver, and add any necessary module aliases, and have a common device id table listing all of the supported devices.
Cheers,
Andrew
Quoted 1 line
+MODULE_LICENSE("GPL");
Quoted 85 lines · Andrew Jeffery
Quoted 56 lines · Eddie James
Quoted 1 line
From: "Edward A. James" <[email protected]>
Add the driver to monitor power supplies with hwmon over pmbus.
Quoted 1 line
Signed-off-by Edward A. James <[email protected]>--- drivers/hwmon/pmbus/Kconfig | 10 +++ drivers/hwmon/pmbus/Makefile | 1 + drivers/hwmon/pmbus/ibmps.c | 164 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 175 insertions(+)create mode 100644
drivers/hwmon/pmbus/ibmps.cdrivers/hwmon/pmbus/Kconfig +0
-0@@ -37,6 +37,16 @@ config SENSORS_ADM1275Quoted 2 lines
This driver can also be built as a module. If so, the module will be called adm1275.
+config
SENSORS_IBMPSdrivers/hwmon/pmbus/Kconfig config SENSORS_ADM1275 · line 45
Quoted 5 lines
drivers/hwmon/pmbus/Kconfig +5
-0+ tristate "IBM Power Supply" + default n + help + If you say yes here you get hardware monitoring support for IBM + power supply.+
drivers/hwmon/pmbus/Kconfig config SENSORS_ADM1275 · line 48
Quoted 2 lines
drivers/hwmon/pmbus/Kconfig +2
-0+ This driver can also be built as a module. If so, the module will + be called ibmps.+
configSENSORS_IR35221Quoted 2 lines
tristate "Infineon IR35221"
default ndrivers/hwmon/pmbus/Makefile +0
-0@@ -5,6 +5,7 @@Quoted 7 lines
obj-$(CONFIG_PMBUS) += pmbus_core.o
obj-$(CONFIG_SENSORS_PMBUS) += pmbus.o
obj-$(CONFIG_SENSORS_ADM1275) += adm1275.o
+obj-$(CONFIG_SENSORS_IBMPS) += ibmps.o
obj-$(CONFIG_SENSORS_IR35221) += ir35221.o
obj-$(CONFIG_SENSORS_LM25066) += lm25066.o
obj-$(CONFIG_SENSORS_LTC2978) += ltc2978.odrivers/hwmon/pmbus/ibmps.c new file +6
-0@@ -0,0 +1,164 @@ +/* +* 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 drivers/hwmon/pmbus/ibmps.c line 16
Quoted 10 lines
drivers/hwmon/pmbus/ibmps.c new file +10
-0+* (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" +I think a comment is needed here to point out these bits are for
STATUS_MFR_SPECIFIC.drivers/hwmon/pmbus/ibmps.c line 27
Quoted 11 lines
drivers/hwmon/pmbus/ibmps.c new file +1
-0+#define IBMPS_MFR_FAN_FAULT BIT(0)Quoted 7 lines
drivers/hwmon/pmbus/ibmps.c new file +7
-0+#define IBMPS_MFR_THERMAL_FAULT BIT(1) +#define IBMPS_MFR_OV_FAULT BIT(2) +#define IBMPS_MFR_UV_FAULT BIT(3) +#define IBMPS_MFR_PS_KILL BIT(4) +#define IBMPS_MFR_OC_FAULT BIT(5) +#define IBMPS_MFR_VAUX_FAULT BIT(6) +#define IBMPS_MFR_CURRENT_SHARE_WARNING BIT(7)drivers/hwmon/pmbus/ibmps.c new file +3
-0+ +static int ibmps_read_word_data (struct i2c_client *client,int page,int reg); +This makes me curious.
Quoted 2 lines
drivers/hwmon/pmbus/ibmps.c new file +2
-0+static int ibmps_read_byte_data (struct i2c_client *client,int page,int reg) +{
Quoted 8 lines
drivers/hwmon/pmbus/ibmps.c line 35
Quoted 6 lines
Review
Quoted 1 line
(quoted diff) +1
-0+ int rc, mfr;+
Quoted 3 lines
drivers/hwmon/pmbus/ibmps.c new file +3
-0+switch (reg) { +case PMBUS_STATUS_BYTE : +case PMBUS_STATUS_WORD :drivers/hwmon/pmbus/ibmps.c new file +1
-0+ rc =ibmps_read_word_data (client, page,PMBUS_STATUS_WORD );Feels wrong to return "junk" in the result for a
PMBUS_STATUS_BYTEquery.
Good point, I'll mask the byte one.
Quoted 36 lines
Quoted 30 lines
drivers/hwmon/pmbus/ibmps.c new file +1
-0+break ;drivers/hwmon/pmbus/ibmps.c line 43
Quoted 7 lines
drivers/hwmon/pmbus/ibmps.c new file +7
-0+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;+
drivers/hwmon/pmbus/ibmps.c line 48
Quoted 4 lines
drivers/hwmon/pmbus/ibmps.c new file +4
-0+ mfr =pmbus_read_byte_data (client, page, +PMBUS_STATUS_MFR_SPECIFIC ); +if (mfr <0 ) +return rc;+
Quoted 15 lines
drivers/hwmon/pmbus/ibmps.c new file +15
-0+if (reg ==PMBUS_STATUS_FAN_12 ) { +if (mfr &IBMPS_MFR_FAN_FAULT ) + rc |=PB_FAN_FAN1_FAULT ; + }else if (reg ==PMBUS_STATUS_TEMPERATURE ) { +if (mfr &IBMPS_MFR_THERMAL_FAULT ) + rc |=PB_TEMP_OT_FAULT ; + }else if (reg ==PMBUS_STATUS_VOUT ) { +if (mfr & (IBMPS_MFR_OV_FAULT |IBMPS_MFR_VAUX_FAULT )) + rc |=PB_VOLTAGE_OV_FAULT ; +if (mfr &IBMPS_MFR_UV_FAULT ) + rc |=PB_VOLTAGE_UV_FAULT ; + }else if (reg ==PMBUS_STATUS_IOUT ) { +if (mfr &IBMPS_MFR_OC_FAULT ) + rc |=PB_IOUT_OC_FAULT ; +if (mfr &IBMPS_MFR_CURRENT_SHARE_WARNING )drivers/hwmon/pmbus/ibmps.c
Quoted 2 lines
drivers/hwmon/pmbus/ibmps.c new file +2
-0+ rc |=PB_CURRENT_SHARE_FAULT ; + }I wonder why it was done this way and not simply via the spec'ed bits? Maybe some don't fit, but it seems there's a pretty direct mapping for the most part.
Quoted 2 lines
Do the spec'ed status bits ever get set? As in, is there ever some ambiguity about how the bits got set?
Yes I believe some are set by the "normal" status bits, but I'm not sure the coverage is complete, so we definitely need to add the MFR register bits as well.
Quoted 31 lines
drivers/hwmon/pmbus/ibmps.c
Quoted 7 lines
Quoted 5 lines
drivers/hwmon/pmbus/ibmps.c new file +4
-0+break ; +default : +if (reg >=PMBUS_VIRT_BASE ) +return -ENXIO ;drivers/hwmon/pmbus/ibmps.c new file +2
-0+ + rc =pmbus_read_byte_data (client, page, reg);The alternative here is
-ENODATA; not sure which is better though.Quoted 22 lines
drivers/hwmon/pmbus/ibmps.c new file +1
-0+break ;Review
Quoted 1 line
(quoted diff) +1
-0+ }+
Quoted 1 line
(quoted diff) +1
-0+ return rc;drivers/hwmon/pmbus/ibmps.c new file +4
-0+} + +static int ibmps_read_word_data (struct i2c_client *client,int page,int reg) +{Review
Quoted 1 line
(quoted diff) +1
-0+ int rc, mfr;+
drivers/hwmon/pmbus/ibmps.c line 88
Quoted 6 lines
drivers/hwmon/pmbus/ibmps.c new file +6
-0+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;+
drivers/hwmon/pmbus/ibmps.c line 48
Quoted 4 lines
drivers/hwmon/pmbus/ibmps.c new file +4
-0+ mfr =pmbus_read_byte_data (client, page, +PMBUS_STATUS_MFR_SPECIFIC ); +if (mfr <0 ) +return rc;+
Quoted 6 lines
drivers/hwmon/pmbus/ibmps.c line 99
Quoted 5 lines
drivers/hwmon/pmbus/ibmps.c line 96
Quoted 2 lines
drivers/hwmon/pmbus/ibmps.c new file +2
-0+if (mfr &IBMPS_MFR_PS_KILL ) + rc |=PB_STATUS_OFF ;+
Quoted 1 line
drivers/hwmon/pmbus/ibmps.c new file +1
-0+if (mfr)drivers/hwmon/pmbus/ibmps.c new file +1
-0+ rc |=PB_STATUS_WORD_MFR ;This isn't set automatically by the device?
I'll have to check on that.
Quoted 10 lines
drivers/hwmon/pmbus/ibmps.c line 107
Quoted 9 lines
drivers/hwmon/pmbus/ibmps.c new file +1
-0+break ;drivers/hwmon/pmbus/ibmps.c line 70
Quoted 3 lines
drivers/hwmon/pmbus/ibmps.c new file +3
-0+default : +if (reg >=PMBUS_VIRT_BASE ) +return -ENXIO ;+
Quoted 2 lines
drivers/hwmon/pmbus/ibmps.c new file +2
-0+ rc =pmbus_read_word_data (client, page, reg); +if (rc <0 )drivers/hwmon/pmbus/ibmps.c new file +1
-0+ rc =ibmps_read_byte_data (client, page, reg);Is this really the way we should go about accesses?
The power supply seems to mix up byte and word accesses. For example, the actual data regs are words, but the status_* are bytes (except status_word, obviously). This was basically the only way I could get everything working.
Quoted 19 lines
Quoted 19 lines
drivers/hwmon/pmbus/ibmps.c new file +1
-0+break ;Review
Quoted 1 line
(quoted diff) +1
-0+ }+
Quoted 1 line
(quoted diff) +1
-0+ return rc;drivers/hwmon/pmbus/ibmps.c new file +3
-0+} + +static struct pmbus_driver_info ibmps_info = {Quoted 8 lines
drivers/hwmon/pmbus/ibmps.c new file +8
-0+ .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 = ibmps_read_byte_data, + .read_word_data = ibmps_read_word_data,drivers/hwmon/pmbus/ibmps.c new file +3
-0+}; + +static int ibmps_probe(struct i2c_client *client,
Quoted 6 lines
drivers/hwmon/pmbus/ibmps.c
Quoted 3 lines
Quoted 1 line
drivers/hwmon/pmbus/ibmps.c new file +1
-0+ const struct i2c_device_id *id)drivers/hwmon/pmbus/ibmps.c new file +2
-0+{ +return pmbus_do_probe (client, id, &ibmps_info);Is there anything we need to check before probe, e.g. MFR_ID/MFR_MODEL/MFR_REVISION? Are there options that might need to be configured (and exposed via devicetree bindings)?
Nothing in the spec that I see.
Quoted 6 lines
I note we support fans: Is
FAN_CONFIG_1_2configured as needed? Or do we need to enable the fan, configure PWM vs RPM and the tach pulses value? If it is pre-configured, is this register always going to be pre-configured? Or do we need a property like my proposed 'use-stored- presence' for the MAX31785?
I believe they are all configured internally. FAN_CONFIG_1_2 is listed in the spec but doesn't state that anything needs to be setup.
Quoted 5 lines
Have you had a look at my proposed bindings for the max31785? I think it would be worth your input, as we have another case of fans here, and it will help us shape a better picture of whether my generic properties
and node structure are appropriate.
Sure, I'll take a look.
Quoted 10 lines
drivers/hwmon/pmbus/ibmps.c line 136
Quoted 9 lines
drivers/hwmon/pmbus/ibmps.c new file +4
-0+} + +static int ibmps_remove (struct i2c_client *client) +{Quoted 1 line
drivers/hwmon/pmbus/ibmps.c new file +1
-0+return pmbus_do_remove (client);drivers/hwmon/pmbus/ibmps.c new file +3
-0+} + +enum chips { witherspoon };This doesn't look necessary.
Agreed, it's somewhat of a pmbus convention, but maybe since there's just one I'll remove it.
Quoted 9 lines
Quoted 9 lines
drivers/hwmon/pmbus/ibmps.c new file +2
-0+ +static const struct i2c_device_id ibmps_id[] = {Quoted 2 lines
drivers/hwmon/pmbus/ibmps.c new file +2
-0+ { "witherspoon", witherspoon }, + { }drivers/hwmon/pmbus/ibmps.c new file +4
-0+}; +MODULE_DEVICE_TABLE (i2c, ibmps_id); + +static const struct of_device_id ibmps_of_match[] = {
Quoted 6 lines
drivers/hwmon/pmbus/ibmps.c
Quoted 4 lines
Quoted 2 lines
drivers/hwmon/pmbus/ibmps.c new file +2
-0+ { .compatible = "ibm,ibmps" }, + {}drivers/hwmon/pmbus/ibmps.c new file +2
-0+}; +MODULE_DEVICE_TABLE (of, p8_i2c_occ_of_match);
p8_i2c_occ_of_matchisn't right. Do we need both device tables? "witherspoon" as a device ID also seems unusual. What's going on there?
Uhh, not sure how that got in there... How does this compile?? I'll fix it. The power supply doesn't have any device id or anything, so I just went with witherspoon...
Quoted 12 lines
Quoted 12 lines
drivers/hwmon/pmbus/ibmps.c new file +2
-0+ +static struct i2c_driver ibmps_driver = {Quoted 7 lines
drivers/hwmon/pmbus/ibmps.c new file +7
-0+ .driver = { + .name = "ibmps", + .of_match_table = ibmps_of_match, + }, + .probe = ibmps_probe, + .remove = ibmps_remove, + .id_table = ibmps_id,drivers/hwmon/pmbus/ibmps.c new file +2
-0+}; +
Quoted 8 lines
drivers/hwmon/pmbus/ibmps.c line 163
Quoted 4 lines
drivers/hwmon/pmbus/ibmps.c new file +4
-0+module_i2c_driver (ibmps_driver); + +MODULE_AUTHOR ("Eddie James" ); +MODULE_DESCRIPTION ("PMBus driver for IBM power supply" );So do we anticipate only ever having one power supply design? The name feels a bit generic. In the device id table above you suggest it's called 'witherspoon'. Is the design specific to Witherspoon? If so this fact should be included in the driver name and description.
I was told it is specific to witherspoon. I just hate to make it so specific when I'm pretty sure there will be future similar power supplies (in fact there was another compatible one that's buggy, present on some older witherspoons). But that will work.
Quoted 10 lines
If there are other power supplies that are similar, then when we add support we can rename the driver, and add any necessary module aliases, and have a common device id table listing all of the supported devices.
Cheers,
Andrew
Quoted 1 line
+MODULE_LICENSE("GPL");
Quoted 151 lines · Eddie James
Quoted 98 lines · Andrew Jeffery
Quoted 63 lines · Eddie James
Quoted 1 line
From: "Edward A. James" <[email protected]>
Add the driver to monitor power supplies with hwmon over pmbus.
Quoted 1 line
Signed-off-by Edward A. James <[email protected]>---
drivers/hwmon/pmbus/Kconfig | 10 +++drivers/hwmon/pmbus/Makefile| 1 +
drivers/hwmon/pmbus/ibmps.c | 164 +++++++++++++++++++++++++++++++++++++++++++3 files changed, 175 insertions(+)create mode 100644
drivers/hwmon/pmbus/ibmps.cdrivers/hwmon/pmbus/Kconfig +0
-0@@ -37,6 +37,16 @@ config SENSORS_ADM1275Quoted 2 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
This driver can also be built as a module. If so, the module will
be called adm1275.
+configSENSORS_IBMPSdrivers/hwmon/pmbus/Kconfig config SENSORS_ADM1275 · line 45
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/hwmon/pmbus/Kconfig +4
-0+ tristate "IBM Power Supply" + default n + help + If you say yes here you get hardware monitoring support for IBMdrivers/hwmon/pmbus/Kconfig +1
-0+ power supply.+
drivers/hwmon/pmbus/Kconfig config SENSORS_ADM1275 · line 48
Quoted 2 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
drivers/hwmon/pmbus/Kconfig +1
-0+ This driver can also be built as a module. If so, the module willdrivers/hwmon/pmbus/Kconfig +1
-0+ be called ibmps.+
configSENSORS_IR35221Quoted 2 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
tristate "Infineon IR35221"
default n
drivers/hwmon/pmbus/Makefile +0
-0@@ -5,6 +5,7 @@Quoted 7 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
obj-$(CONFIG_PMBUS) += pmbus_core.o
obj-$(CONFIG_SENSORS_PMBUS) += pmbus.o
obj-$(CONFIG_SENSORS_ADM1275) += adm1275.o
+obj-$(CONFIG_SENSORS_IBMPS) += ibmps.o
obj-$(CONFIG_SENSORS_IR35221) += ir35221.o
obj-$(CONFIG_SENSORS_LM25066) += lm25066.oobj-$(CONFIG_SENSORS_LTC2978) += ltc2978.o
drivers/hwmon/pmbus/ibmps.c new file +6
-0@@ -0,0 +1,164 @@ +/* +* 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 drivers/hwmon/pmbus/ibmps.c line 16
Quoted 10 lines
drivers/hwmon/pmbus/ibmps.c new file +10
-0+* (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" +I think a comment is needed here to point out these bits are for
STATUS_MFR_SPECIFIC.drivers/hwmon/pmbus/ibmps.c line 27
Quoted 12 lines
Quoted 8 lines
Quoted 7 lines
Quoted 7 lines
+#define
IBMPS_MFR_FAN_FAULTBIT(0)Quoted 6 lines
drivers/hwmon/pmbus/ibmps.c line 23
Quoted 6 lines
drivers/hwmon/pmbus/ibmps.c new file +6
-0+#define IBMPS_MFR_THERMAL_FAULT BIT(1) +#define IBMPS_MFR_OV_FAULT BIT(2) +#define IBMPS_MFR_UV_FAULT BIT(3) +#define IBMPS_MFR_PS_KILL BIT(4) +#define IBMPS_MFR_OC_FAULT BIT(5) +#define IBMPS_MFR_VAUX_FAULT BIT(6)+#define
IBMPS_MFR_CURRENT_SHARE_WARNINGBIT(7)drivers/hwmon/pmbus/ibmps.c new file +3
-0+ +static int ibmps_read_word_data (struct i2c_client *client,int page,int reg); +This makes me curious.
Quoted 5 lines
drivers/hwmon/pmbus/ibmps.c new file +2
-0+static int ibmps_read_byte_data (struct i2c_client *client,int page,int reg) +{Review
Quoted 1 line
(quoted diff) +1
-0+ int rc, mfr;+
Quoted 8 lines
drivers/hwmon/pmbus/ibmps.c line 35
Quoted 5 lines
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
(quoted diff) +2
-0+ switch (reg) { + case PMBUS_STATUS_BYTE:(quoted diff) +1
-0+ case PMBUS_STATUS_WORD:drivers/hwmon/pmbus/ibmps.c new file +1
-0+ rc =ibmps_read_word_data (client, page,PMBUS_STATUS_WORD );Feels wrong to return "junk" in the result for a
PMBUS_STATUS_BYTEquery.Good point, I'll mask the byte one.
Quoted 40 lines
Quoted 34 lines
Review
Quoted 9 lines
Quoted 8 lines
Quoted 8 lines
(quoted diff) +1
-0+ break;Quoted 6 lines
Quoted 6 lines
drivers/hwmon/pmbus/ibmps.c new file +6
-0+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 )(quoted diff) +1
-0+ return rc;+
Review
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/hwmon/pmbus/ibmps.c new file +3
-0+ mfr =pmbus_read_byte_data (client, page, + PMBUS_STATUS_MFR_SPECIFIC); +if (mfr <0 )(quoted diff) +1
-0+ return rc;+
Quoted 17 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
drivers/hwmon/pmbus/ibmps.c new file +14
-0+if (reg ==PMBUS_STATUS_FAN_12 ) { +if (mfr &IBMPS_MFR_FAN_FAULT ) + rc |=PB_FAN_FAN1_FAULT ; + }else if (reg ==PMBUS_STATUS_TEMPERATURE ) { +if (mfr &IBMPS_MFR_THERMAL_FAULT ) + rc |=PB_TEMP_OT_FAULT ; + }else if (reg ==PMBUS_STATUS_VOUT ) { +if (mfr & (IBMPS_MFR_OV_FAULT |IBMPS_MFR_VAUX_FAULT )) + rc |=PB_VOLTAGE_OV_FAULT ; +if (mfr &IBMPS_MFR_UV_FAULT ) + rc |=PB_VOLTAGE_UV_FAULT ; + }else if (reg ==PMBUS_STATUS_IOUT ) { +if (mfr &IBMPS_MFR_OC_FAULT ) + rc |=PB_IOUT_OC_FAULT ;drivers/hwmon/pmbus/ibmps.c new file +1
-0+if (mfr &IBMPS_MFR_CURRENT_SHARE_WARNING )Quoted 2 lines
Quoted 2 lines
drivers/hwmon/pmbus/ibmps.c new file +1
-0+ rc |=PB_CURRENT_SHARE_FAULT ;drivers/hwmon/pmbus/ibmps.c
Quoted 1 line
drivers/hwmon/pmbus/ibmps.c new file +1
-0+ }I wonder why it was done this way and not simply via the spec'ed bits? Maybe some don't fit, but it seems there's a pretty direct mapping for the most part.
Quoted 6 lines
Quoted 2 lines
Do the spec'ed status bits ever get set? As in, is there ever some ambiguity about how the bits got set?
Yes I believe some are set by the "normal" status bits, but I'm not sure the coverage is complete, so we definitely need to add the MFR register bits as well.
Okay, I'll have a look at the datasheet.
Quoted 65 lines
Quoted 43 lines
drivers/hwmon/pmbus/ibmps.c
Quoted 9 lines
Quoted 6 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/hwmon/pmbus/ibmps.c new file +3
-0+break ; +default : +if (reg >=PMBUS_VIRT_BASE )(quoted diff) +1
-0+ return -ENXIO;drivers/hwmon/pmbus/ibmps.c new file +2
-0+ + rc =pmbus_read_byte_data (client, page, reg);The alternative here is
-ENODATA; not sure which is better though.Quoted 31 lines
Review
Quoted 2 lines
Quoted 1 line
Quoted 1 line
(quoted diff) +1
-0+ break;(quoted diff) +1
-0+ }+
Quoted 1 line
(quoted diff) +1
-0+ return rc;drivers/hwmon/pmbus/ibmps.c new file +4
-0+} + +static int ibmps_read_word_data (struct i2c_client *client,int page,int reg) +{Review
Quoted 1 line
(quoted diff) +1
-0+ int rc, mfr;+
Review
Quoted 6 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/hwmon/pmbus/ibmps.c new file +5
-0+switch (reg) { +case PMBUS_STATUS_BYTE : +case PMBUS_STATUS_WORD : + rc =pmbus_read_word_data (client, page,PMBUS_STATUS_WORD ); +if (rc <0 )(quoted diff) +1
-0+ return rc;+
Review
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/hwmon/pmbus/ibmps.c new file +3
-0+ mfr =pmbus_read_byte_data (client, page, + PMBUS_STATUS_MFR_SPECIFIC); +if (mfr <0 )(quoted diff) +1
-0+ return rc;+
drivers/hwmon/pmbus/ibmps.c line 96
Quoted 2 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
drivers/hwmon/pmbus/ibmps.c new file +1
-0+if (mfr &IBMPS_MFR_PS_KILL )drivers/hwmon/pmbus/ibmps.c new file +1
-0+ rc |=PB_STATUS_OFF ;+
Quoted 5 lines
drivers/hwmon/pmbus/ibmps.c line 99
Quoted 3 lines
Quoted 1 line
drivers/hwmon/pmbus/ibmps.c new file +1
-0+if (mfr)drivers/hwmon/pmbus/ibmps.c new file +1
-0+ rc |=PB_STATUS_WORD_MFR ;This isn't set automatically by the device?
I'll have to check on that.
Quoted 7 lines
Quoted 7 lines
Review
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
(quoted diff) +1
-0+ break;Quoted 2 lines
Quoted 2 lines
(quoted diff) +2
-0+ default: + if (reg >= PMBUS_VIRT_BASE)(quoted diff) +1
-0+ return -ENXIO;+
Quoted 6 lines
drivers/hwmon/pmbus/ibmps.c line 107
Quoted 4 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
drivers/hwmon/pmbus/ibmps.c new file +1
-0+ rc =pmbus_read_word_data (client, page, reg);(quoted diff) +1
-0+ if (rc < 0)drivers/hwmon/pmbus/ibmps.c new file +1
-0+ rc =ibmps_read_byte_data (client, page, reg);Is this really the way we should go about accesses?
Quoted 4 lines
The power supply seems to mix up byte and word accesses. For example, the actual data regs are words, but the status_* are bytes (except
status_word, obviously). This was basically the only way I could get everything working.
I don't understand - even if you read a word register with a byte- accessor everything should still work (aside from not reading the amount you're *meant* to).
So this still seems odd to me. Can you rephrase or expand on what you've said?
Quoted 32 lines
Quoted 23 lines
Quoted 23 lines
Review
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines
(quoted diff) +1
-0+ break;(quoted diff) +1
-0+ }+
Quoted 1 line
(quoted diff) +1
-0+ return rc;drivers/hwmon/pmbus/ibmps.c new file +3
-0+} + +static struct pmbus_driver_info ibmps_info = {Quoted 8 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/hwmon/pmbus/ibmps.c new file +7
-0+ .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 = ibmps_read_byte_data,drivers/hwmon/pmbus/ibmps.c new file +1
-0+ .read_word_data = ibmps_read_word_data,drivers/hwmon/pmbus/ibmps.c new file +3
-0+}; + +static int ibmps_probe(struct i2c_client *client,Quoted 8 lines
drivers/hwmon/pmbus/ibmps.c
Quoted 4 lines
Quoted 1 line
drivers/hwmon/pmbus/ibmps.c new file +1
-0+ const struct i2c_device_id *id)drivers/hwmon/pmbus/ibmps.c new file +2
-0+{ +return pmbus_do_probe (client, id, &ibmps_info);Is there anything we need to check before probe, e.g. MFR_ID/MFR_MODEL/MFR_REVISION? Are there options that might need to be configured (and exposed via devicetree bindings)?
Quoted 1 line
Nothing in the spec that I see.
Okay.
Quoted 12 lines
Quoted 7 lines
I note we support fans: Is
FAN_CONFIG_1_2configured as needed? Or do we need to enable the fan, configure PWM vs RPM and the tach pulses value? If it is pre-configured, is this register always going to be pre-configured? Or do we need a property like my proposed 'use-stored- presence' for the MAX31785?I believe they are all configured internally.
FAN_CONFIG_1_2is listed in the spec but doesn't state that anything needs to be setup.Quoted 1 line
Quoted 7 lines
Quoted 4 lines
Have you had a look at my proposed bindings for the max31785? I think it would be worth your input, as we have another case of fans here, and it will help us shape a better picture of whether my generic properties and node structure are appropriate.
Sure, I'll take a look.
Thanks.
Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
drivers/hwmon/pmbus/ibmps.c new file +4
-0+} + +static int ibmps_remove (struct i2c_client *client) +{Quoted 7 lines
drivers/hwmon/pmbus/ibmps.c line 136
Quoted 5 lines
Quoted 1 line
drivers/hwmon/pmbus/ibmps.c new file +1
-0+return pmbus_do_remove (client);drivers/hwmon/pmbus/ibmps.c new file +3
-0+} + +enum chips { witherspoon };This doesn't look necessary.
Quoted 2 lines
Agreed, it's somewhat of a pmbus convention, but maybe since there's just one I'll remove it.
Right, at least IMO it's better to add it when we come to needing it.
Quoted 20 lines
Quoted 11 lines
Quoted 11 lines
drivers/hwmon/pmbus/ibmps.c new file +2
-0+ +static const struct i2c_device_id ibmps_id[] = {Quoted 2 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
drivers/hwmon/pmbus/ibmps.c new file +1
-0+ { "witherspoon", witherspoon },drivers/hwmon/pmbus/ibmps.c new file +1
-0+ { }drivers/hwmon/pmbus/ibmps.c new file +4
-0+}; +MODULE_DEVICE_TABLE (i2c, ibmps_id); + +static const struct of_device_id ibmps_of_match[] = {Quoted 8 lines
drivers/hwmon/pmbus/ibmps.c
Quoted 5 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
drivers/hwmon/pmbus/ibmps.c new file +1
-0+ { .compatible = "ibm,ibmps" },drivers/hwmon/pmbus/ibmps.c new file +1
-0+ {}drivers/hwmon/pmbus/ibmps.c new file +2
-0+}; +MODULE_DEVICE_TABLE (of, p8_i2c_occ_of_match);
p8_i2c_occ_of_matchisn't right. Do we need both device tables? "witherspoon" as a device ID also seems unusual. What's going on there?
Quoted 3 lines
Uhh, not sure how that got in there... How does this compile?? I'll fix it. The power supply doesn't have any device id or anything, so I just went with witherspoon...
My issue is "withersoon" identifies a class of machine, not a power supply, even if the powersupply is specific to Witherspoon.
Quoted 24 lines
Quoted 15 lines
Quoted 15 lines
drivers/hwmon/pmbus/ibmps.c new file +2
-0+ +static struct i2c_driver ibmps_driver = {Quoted 7 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/hwmon/pmbus/ibmps.c new file +6
-0+ .driver = { + .name = "ibmps", + .of_match_table = ibmps_of_match, + }, + .probe = ibmps_probe, + .remove = ibmps_remove,drivers/hwmon/pmbus/ibmps.c new file +1
-0+ .id_table = ibmps_id,drivers/hwmon/pmbus/ibmps.c new file +3
-0+}; + +module_i2c_driver (ibmps_driver);Quoted 8 lines
drivers/hwmon/pmbus/ibmps.c line 163
Quoted 3 lines
drivers/hwmon/pmbus/ibmps.c new file +3
-0+ +MODULE_AUTHOR ("Eddie James" ); +MODULE_DESCRIPTION ("PMBus driver for IBM power supply" );So do we anticipate only ever having one power supply design? The name feels a bit generic. In the device id table above you suggest it's called 'witherspoon'. Is the design specific to Witherspoon? If so this fact should be included in the driver name and description.
Quoted 4 lines
I was told it is specific to witherspoon. I just hate to make it so specific when I'm pretty sure there will be future similar power supplies (in fact there was another compatible one that's buggy, present on some older witherspoons). But that will work.
Right, but if we can't really claim support power supplies that don't yet exist. I think we should scope ourselves to what we currently have.
Cheers,
Andrew
Quoted 13 lines
Quoted 11 lines
If there are other power supplies that are similar, then when we add support we can rename the driver, and add any necessary module aliases, and have a common device id table listing all of the supported devices.
Cheers,
Andrew
Quoted 1 line
+MODULE_LICENSE("GPL");
Quoted 19 lines · Andrew Jeffery
Quoted 19 lines
Quoted 18 lines
Quoted 12 lines
(quoted diff) +2
-0+ +static const struct i2c_device_id ibmps_id[] = {Quoted 2 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
+ { "witherspoon", witherspoon },
+ { }
drivers/hwmon/pmbus/ibmps.c new file +4
-0+}; +MODULE_DEVICE_TABLE (i2c, ibmps_id); + +static const struct of_device_id ibmps_of_match[] = {Quoted 2 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
+ { .compatible = "ibm,ibmps" },
+ {}
Review
Quoted 2 lines
(quoted diff) +2
-0+}; +MODULE_DEVICE_TABLE(of, p8_i2c_occ_of_match);
p8_i2c_occ_of_matchisn't right. Do we need both device tables? "witherspoon" as a device ID also seems unusual. What's going on there?
Quoted 7 lines
Quoted 4 lines
Uhh, not sure how that got in there... How does this compile?? I'll fix it. The power supply doesn't have any device id or anything, so I just went with witherspoon...My issue is "withersoon" identifies a class of machine, not a power supply, even if the powersupply is specific to Witherspoon.
Further to this, I've just got hold of the datasheet. My reading of it says the part number is "01KL054". Maybe the driver should include that in its name and compatible.
Andrew
Quoted 25 lines · Andrew Jeffery
Quoted 24 lines · Andrew Jeffery
Quoted 23 lines
Quoted 11 lines
Quoted 11 lines
(quoted diff) +2
-0+ +static const struct i2c_device_id ibmps_id[] = {Quoted 2 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
+ { "witherspoon", witherspoon },
+ { }
drivers/hwmon/pmbus/ibmps.c new file +4
-0+}; +MODULE_DEVICE_TABLE (i2c, ibmps_id); + +static const struct of_device_id ibmps_of_match[] = {Quoted 8 lines
Review
Quoted 5 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
+ { .compatible = "ibm,ibmps" },
+ {}
(quoted diff) +2
-0+}; +MODULE_DEVICE_TABLE(of, p8_i2c_occ_of_match);
p8_i2c_occ_of_matchisn't right. Do we need both device tables? "witherspoon" as a device ID also seems unusual. What's going on there?Uhh, not sure how that got in there... How does this compile?? I'll fix it. The power supply doesn't have any device id or anything, so I just went with witherspoon...
Quoted 6 lines
Quoted 2 lines
My issue is "withersoon" identifies a class of machine, not a power supply, even if the powersupply is specific to Witherspoon.
Further to this, I've just got hold of the datasheet. My reading of it says the part number is "01KL054". Maybe the driver should include that in its name and compatible.
I don't know that this part number value always remains the same, for the part used in a particular system. There was a similar 2000W PMBus power supply that had one part number, and it stuck. However, a previous 1720W power supply had at least four different part numbers before it finally stuck on the final one.
That being said, there quite probably are some differences between various part numbers, but most of what this device driver is doing would still be compatible. I can see have 01KL054 in the compatible list, but trying to shoe-horn it into the device driver name doesn't feel like it makes sense to me.
Quoted 2 lines
Andrew
Quoted 41 lines · Brandon Wyman
Quoted 28 lines · Andrew Jeffery
Quoted 26 lines · Andrew Jeffery
Quoted 25 lines
Quoted 14 lines
Quoted 14 lines
(quoted diff) +2
-0+ +static const struct i2c_device_id ibmps_id[] = {Quoted 3 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
+ { "witherspoon", witherspoon },
+ { }
drivers/hwmon/pmbus/ibmps.c new file +4
-0+}; +MODULE_DEVICE_TABLE (i2c, ibmps_id); + +static const struct of_device_id ibmps_of_match[] = {Quoted 2 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
+ { .compatible = "ibm,ibmps" },
Quoted 7 lines
Review
Quoted 4 lines
Quoted 1 line
+ {}
(quoted diff) +2
-0+}; +MODULE_DEVICE_TABLE(of, p8_i2c_occ_of_match);
p8_i2c_occ_of_matchisn't right. Do we need both device tables? "witherspoon" as a device ID also seems unusual. What's going on there?Uhh, not sure how that got in there... How does this compile?? I'll fix it. The power supply doesn't have any device id or anything, so I just went with witherspoon...
Quoted 6 lines
Quoted 2 lines
My issue is "withersoon" identifies a class of machine, not a power supply, even if the powersupply is specific to Witherspoon.
Further to this, I've just got hold of the datasheet. My reading of it says the part number is "01KL054". Maybe the driver should include that in its name and compatible.
I don't know that this part number value always remains the same, for the part used in a particular system. There was a similar 2000W PMBus power supply that had one part number, and it stuck. However, a previous 1720W power supply had at least four different part numbers before it finally stuck on the final one.
Quoted 5 lines
That being said, there quite probably are some differences between various part numbers, but most of what this device driver is doing would still be compatible. I can see have 01KL054 in the compatible list, but trying to shoe-horn it into the device driver name doesn't feel like it makes sense to me.
Right; without the context you've provided above I wouldn't consider it shoe-horning. However, since having a diversity of part numbers is a thing, I agree with your assessment. It should be part of a compatible, but maybe we do need something generic for the driver name.
Andrew
Quoted 3 lines
Quoted 3 lines
Andrew
PATCH v3 2/5 drivers/hwmon/pmbus: ibmps: Add non-hwmon attributes
In reply to Eddie JamesFrom: "Edward A. James" <[email protected]>
Add sysfs entries to dump out PS registers and clear faults.
--- drivers/hwmon/pmbus/ibmps.c | 78 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+)
drivers/hwmon/pmbus/ibmps.c +78 -0
@@ -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"
@@ -122,14 +124,90 @@ static int ibmps_read_word_data(struct i2c_client *client, int page, int reg) .read_word_data = ibmps_read_word_data, }; +static ssize_t ibmps_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, ibmps_clear_faults); + +static ssize_t ibmps_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, ibmps_show_status_word, NULL); + +static ssize_t ibmps_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, ibmps_show_status_byte, NULL, 0); +static SENSOR_DEVICE_ATTR(status_iout, 0444, ibmps_show_status_byte, NULL, 1); +static SENSOR_DEVICE_ATTR(status_input, 0444, ibmps_show_status_byte, NULL, 2); +static SENSOR_DEVICE_ATTR(status_temp, 0444, ibmps_show_status_byte, NULL, 3); +static SENSOR_DEVICE_ATTR(status_cml, 0444, ibmps_show_status_byte, NULL, 4); +static SENSOR_DEVICE_ATTR(status_other, 0444, ibmps_show_status_byte, NULL, 5); +static SENSOR_DEVICE_ATTR(status_mfr, 0444, ibmps_show_status_byte, NULL, 6); +static SENSOR_DEVICE_ATTR(status_fan, 0444, ibmps_show_status_byte, NULL, 7); + +static struct attribute *ibmps_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 ibmps_attribute_group = { + .attrs = ibmps_attributes, +}; +static int ibmps_probe (struct i2c_client *client,const struct i2c_device_id *id) { +int rc =sysfs_create_group (&client->dev.kobj, + &ibmps_attribute_group); +if (rc) +return rc; +return pmbus_do_probe (client, id, &ibmps_info); }static int ibmps_remove (struct i2c_client *client) { +sysfs_remove_group (&client->dev.kobj, &ibmps_attribute_group); +return pmbus_do_remove (client); }
Signature · 1 line
1.8.3.1
Re: [PATCH linux dev-4.10 v3 2/5] drivers/hwmon/pmbus: ibmps: Add non-hwmon attributes
Quoted 3 lines · Eddie James
Quoted 1 line
From: "Edward A. James" <[email protected]>
Add sysfs entries to dump out PS registers
Why are we working against what the pmbus subsystem already gives us? Why not augment support in pmbus core to give us the information we need in a manner acceptable to upstream?
Flipping to the other end of the spectrum: The device only has one page. We can just use i2cget -f -y ... without risk of corruption.
Quoted 1 line
and clear faults.
Can you describe the motivation for this? I feel like it would be worth having this as a separate patch, and to the core rather than in an arbitrary driver.
Cheers,
Andrew
Quoted 112 lines
Quoted 2 lines
Signed-off-by Edward A. James <[email protected]>---
drivers/hwmon/pmbus/ibmps.c | 78 +++++++++++++++++++++++++++++++++++++++++++++1 file changed, 78 insertions(+)drivers/hwmon/pmbus/ibmps.c +0
-0@@ -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"drivers/hwmon/pmbus/ibmps.c +0
-0@@ -122,14 +124,90 @@ static int ibmps_read_word_data(struct i2c_client *client, int page, int reg) > .read_word_data = ibmps_read_word_data, };
+staticssize_tibmps_clear_faults(struct device *dev,drivers/hwmon/pmbus/ibmps.c static int ibmps_read_word_data(struct i2c_client *client, int page, int reg) · line 129
Quoted 2 lines
drivers/hwmon/pmbus/ibmps.c +2
-0+ struct device_attribute *dev_attr, + const char *buf, size_t count)+{
Review
Quoted 1 line
(quoted diff) +1
-0+ struct i2c_client *client = to_i2c_client(dev);+
drivers/hwmon/pmbus/ibmps.c static int ibmps_read_word_data(struct i2c_client *client, int page, int reg) · line 133
Quoted 1 line
drivers/hwmon/pmbus/ibmps.c +1
-0+pmbus_clear_faults (client);+
Quoted 1 line
drivers/hwmon/pmbus/ibmps.c +1
-0+return count;drivers/hwmon/pmbus/ibmps.c +4
-0+} +static DEVICE_ATTR(clear_faults, 0200, NULL, ibmps_clear_faults); + +static ssize_t ibmps_show_status_word(struct device *dev,Review
Quoted 2 lines
(quoted diff) +2
-0+ struct device_attribute *dev_attr, + char *buf)+{
Review
Quoted 2 lines
(quoted diff) +2
-0+ int rc; + struct i2c_client *client = to_i2c_client(dev);+
drivers/hwmon/pmbus/ibmps.c static int ibmps_read_word_data(struct i2c_client *client, int page, int reg) · line 148
Quoted 3 lines
drivers/hwmon/pmbus/ibmps.c +3
-0+ rc =pmbus_read_word_data (client,0 ,PMBUS_STATUS_WORD ); +if (rc <0 ) +return rc;+
Quoted 1 line
drivers/hwmon/pmbus/ibmps.c +1
-0+return snprintf (buf,PAGE_SIZE -1 ,"%04x\n" , rc);drivers/hwmon/pmbus/ibmps.c +4
-0+} +static DEVICE_ATTR(status_word, 0444, ibmps_show_status_word, NULL); + +static ssize_t ibmps_show_status_byte(struct device *dev,Review
Quoted 2 lines
(quoted diff) +2
-0+ struct device_attribute *dev_attr, + char *buf)+{
drivers/hwmon/pmbus/ibmps.c static int ibmps_read_word_data(struct i2c_client *client, int page, int reg) · line 160
Quoted 3 lines
drivers/hwmon/pmbus/ibmps.c +3
-0+int rc; +struct i2c_client *client =to_i2c_client (dev); +struct sensor_device_attribute *sattr =to_sensor_dev_attr (dev_attr);+
drivers/hwmon/pmbus/ibmps.c static int ibmps_read_word_data(struct i2c_client *client, int page, int reg) · line 164
Quoted 3 lines
drivers/hwmon/pmbus/ibmps.c +3
-0+ rc =pmbus_read_byte_data (client,0 ,PMBUS_STATUS_VOUT + sattr->index); +if (rc <0 ) +return rc;+
Quoted 1 line
drivers/hwmon/pmbus/ibmps.c +1
-0+return snprintf (buf,PAGE_SIZE -1 ,"%02x\n" , rc);drivers/hwmon/pmbus/ibmps.c +12
-0+} + +static SENSOR_DEVICE_ATTR(status_vout, 0444, ibmps_show_status_byte, NULL, 0); +static SENSOR_DEVICE_ATTR(status_iout, 0444, ibmps_show_status_byte, NULL, 1); +static SENSOR_DEVICE_ATTR(status_input, 0444, ibmps_show_status_byte, NULL, 2); +static SENSOR_DEVICE_ATTR(status_temp, 0444, ibmps_show_status_byte, NULL, 3); +static SENSOR_DEVICE_ATTR(status_cml, 0444, ibmps_show_status_byte, NULL, 4); +static SENSOR_DEVICE_ATTR(status_other, 0444, ibmps_show_status_byte, NULL, 5); +static SENSOR_DEVICE_ATTR(status_mfr, 0444, ibmps_show_status_byte, NULL, 6); +static SENSOR_DEVICE_ATTR(status_fan, 0444, ibmps_show_status_byte, NULL, 7); + +static struct attribute *ibmps_attributes[] = {Quoted 11 lines
drivers/hwmon/pmbus/ibmps.c +11
-0+ &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 drivers/hwmon/pmbus/ibmps.c +3
-0+}; + +static const struct attribute_group ibmps_attribute_group = {Quoted 1 line
drivers/hwmon/pmbus/ibmps.c +1
-0+ .attrs = ibmps_attributes,drivers/hwmon/pmbus/ibmps.c +2
-0+}; +static int ibmps_probe(struct
i2c_client*client,Quoted 1 line
const struct
i2c_device_id*id){
drivers/hwmon/pmbus/ibmps.c static int ibmps_read_word_data(struct i2c_client *client, int page, int reg) · line 202
Quoted 4 lines
drivers/hwmon/pmbus/ibmps.c +4
-0+int rc =sysfs_create_group (&client->dev.kobj, + &ibmps_attribute_group); +if (rc) +return rc;+
Quoted 1 line
return
pmbus_do_probe(client, id, &ibmps_info);}
static intibmps_remove(struct i2c_client *client){drivers/hwmon/pmbus/ibmps.c static int ibmps_read_word_data(struct i2c_client *client, int page, int reg) · line 209
Quoted 1 line
drivers/hwmon/pmbus/ibmps.c +1
-0+sysfs_remove_group (&client->dev.kobj, &ibmps_attribute_group);+
Quoted 1 line
return
pmbus_do_remove(client);}
Re: [PATCH linux dev-4.10 v3 2/5] drivers/hwmon/pmbus: ibmps: Add non-hwmon attributes
Quoted 6 lines · Andrew Jeffery
Quoted 2 lines · Eddie James
Quoted 1 line
From: "Edward A. James" <[email protected]>
Add sysfs entries to dump out PS registers
Why are we working against what the pmbus subsystem already gives us? Why not augment support in pmbus core to give us the information we need in a manner acceptable to upstream?
Yea, that would be great. I feel like we're a little short on time for that, as we need this functionality basically now. But we can give it a shot.
Quoted 3 lines
Flipping to the other end of the spectrum: The device only has one page. We can just use
i2cget -f -y ...without risk of corruption.
Yea, I just get a lot of requests to have it all in the device driver. I guess we need to just push back and ask people to use i2c tools. But we will have to solve this for the UCD driver.
Quoted 5 lines
Quoted 2 lines
and clear faults.
Can you describe the motivation for this? I feel like it would be worth having this as a separate patch, and to the core rather than in an arbitrary driver.
Users need to be able to clear faults, that was just on my list of requirements :) They could probably use i2cset though.
Quoted 116 lines
Cheers,
Andrew
Quoted 111 lines
Quoted 1 line
Signed-off-by Edward A. James <[email protected]>--- drivers/hwmon/pmbus/ibmps.c | 78 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+)drivers/hwmon/pmbus/ibmps.c +12
-0@@ -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" @@ -122,14 +124,90 @@ static int ibmps_read_word_data(struct i2c_client *client, int page, int reg) > .read_word_data = ibmps_read_word_data, }; +static ssize_t ibmps_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, ibmps_clear_faults); + +static ssize_t ibmps_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)Review
Quoted 1 line
(quoted diff) +1
-0+ return rc;+
Quoted 1 line
drivers/hwmon/pmbus/ibmps.c +1
-0+return snprintf (buf,PAGE_SIZE -1 ,"%04x\n" , rc);drivers/hwmon/pmbus/ibmps.c +4
-0+} +static DEVICE_ATTR(status_word, 0444, ibmps_show_status_word, NULL); + +static ssize_t ibmps_show_status_byte(struct device *dev,Review
Quoted 2 lines
(quoted diff) +2
-0+ struct device_attribute *dev_attr, + char *buf)+{
drivers/hwmon/pmbus/ibmps.c static int ibmps_read_word_data(struct i2c_client *client, int page, int reg) · line 160
Quoted 3 lines
drivers/hwmon/pmbus/ibmps.c +3
-0+int rc; +struct i2c_client *client =to_i2c_client (dev); +struct sensor_device_attribute *sattr =to_sensor_dev_attr (dev_attr);+
drivers/hwmon/pmbus/ibmps.c static int ibmps_read_word_data(struct i2c_client *client, int page, int reg) · line 164
Quoted 3 lines
drivers/hwmon/pmbus/ibmps.c +3
-0+ rc =pmbus_read_byte_data (client,0 ,PMBUS_STATUS_VOUT + sattr->index); +if (rc <0 ) +return rc;+
Quoted 1 line
drivers/hwmon/pmbus/ibmps.c +1
-0+return snprintf (buf,PAGE_SIZE -1 ,"%02x\n" , rc);drivers/hwmon/pmbus/ibmps.c +12
-0+} + +static SENSOR_DEVICE_ATTR(status_vout, 0444, ibmps_show_status_byte, NULL, 0); +static SENSOR_DEVICE_ATTR(status_iout, 0444, ibmps_show_status_byte, NULL, 1); +static SENSOR_DEVICE_ATTR(status_input, 0444, ibmps_show_status_byte, NULL, 2); +static SENSOR_DEVICE_ATTR(status_temp, 0444, ibmps_show_status_byte, NULL, 3); +static SENSOR_DEVICE_ATTR(status_cml, 0444, ibmps_show_status_byte, NULL, 4); +static SENSOR_DEVICE_ATTR(status_other, 0444, ibmps_show_status_byte, NULL, 5); +static SENSOR_DEVICE_ATTR(status_mfr, 0444, ibmps_show_status_byte, NULL, 6); +static SENSOR_DEVICE_ATTR(status_fan, 0444, ibmps_show_status_byte, NULL, 7); + +static struct attribute *ibmps_attributes[] = {Quoted 11 lines
drivers/hwmon/pmbus/ibmps.c +11
-0+ &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 drivers/hwmon/pmbus/ibmps.c +3
-0+}; + +static const struct attribute_group ibmps_attribute_group = {Quoted 1 line
drivers/hwmon/pmbus/ibmps.c +1
-0+ .attrs = ibmps_attributes,drivers/hwmon/pmbus/ibmps.c +2
-0+}; + static int ibmps_probe(struct i2c_client *client,Quoted 1 line
const struct
i2c_device_id*id){
drivers/hwmon/pmbus/ibmps.c static int ibmps_read_word_data(struct i2c_client *client, int page, int reg) · line 202
Quoted 4 lines
drivers/hwmon/pmbus/ibmps.c +4
-0+int rc =sysfs_create_group (&client->dev.kobj, + &ibmps_attribute_group); +if (rc) +return rc;+
Quoted 1 line
return pmbus_do_probe(client, id, &ibmps_info);}
static int
ibmps_remove(struct i2c_client *client){drivers/hwmon/pmbus/ibmps.c static int ibmps_read_word_data(struct i2c_client *client, int page, int reg) · line 209
Quoted 1 line
drivers/hwmon/pmbus/ibmps.c +1
-0+sysfs_remove_group (&client->dev.kobj, &ibmps_attribute_group);+
Quoted 1 line
return pmbus_do_remove(client);}
Re: [PATCH linux dev-4.10 v3 2/5] drivers/hwmon/pmbus: ibmps: Add non-hwmon attributes
Quoted 10 lines · Eddie James
Quoted 6 lines · Andrew Jeffery
Quoted 2 lines · Eddie James
Quoted 1 line
From: "Edward A. James" <[email protected]>
Add sysfs entries to dump out PS registers
Why are we working against what the pmbus subsystem already gives us? Why not augment support in pmbus core to give us the information we need in a manner acceptable to upstream?
Quoted 7 lines
Yea, that would be great. I feel like we're a little short on time for that, as we need this functionality basically now. But we can give it a shot.
Quoted 3 lines
Flipping to the other end of the spectrum: The device only has one page. We can just use
i2cget -f -y ...without risk of corruption.Yea, I just get a lot of requests to have it all in the device driver. I guess we need to just push back and ask people to use i2c tools. But we will have to solve this for the UCD driver.
In general, IBM likes to capture a lot of registers on failures so we can actually figure out what went wrong after the fact, as we have customers who get mad when we can't give them root cause. It's a bummer that is so hard to do here. And if we had to use the i2cdev stuff for that, then why even use a device driver for any of this...
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
and clear faults.
Can you describe the motivation for this? I feel like it would be worth having this as a separate patch, and to the core rather than in an arbitrary driver.
Users need to be able to clear faults, that was just on my list of requirements :) They could probably use i2cset though.
Yea, userspace needs this. I'm kinda surprised there wasn't already a way to expose it.
Quoted 124 lines
Quoted 123 lines
Cheers,
Andrew
Quoted 117 lines
Quoted 1 line
Signed-off-by Edward A. James <[email protected]>--- drivers/hwmon/pmbus/ibmps.c | 78 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+)drivers/hwmon/pmbus/ibmps.c +2
-0@@ -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" @@ -122,14 +124,90 @@ static int ibmps_read_word_data(structi2c_client *client,int page,int reg) > .read_word_data = ibmps_read_word_data,};
+staticssize_tibmps_clear_faults(struct device *dev,drivers/hwmon/pmbus/ibmps.c static int ibmps_read_word_data(struct i2c_client *client, int page, int reg) · line 129
Quoted 2 lines
drivers/hwmon/pmbus/ibmps.c +2
-0+struct device_attribute *dev_attr, + const char *buf, size_t count)+{
Quoted 1 line
+ struct
i2c_client*client =to_i2c_client(dev);+
Quoted 1 line
+
pmbus_clear_faults(client);+
Quoted 1 line
+ return count;
drivers/hwmon/pmbus/ibmps.c +4
-0+} +static DEVICE_ATTR(clear_faults, 0200, NULL, ibmps_clear_faults); + +static ssize_t ibmps_show_status_word(struct device *dev,Review
Quoted 2 lines
(quoted diff) +2
-0+ struct device_attribute *dev_attr, + char *buf)+{
Review
Quoted 2 lines
(quoted diff) +2
-0+ int rc; + struct i2c_client *client = to_i2c_client(dev);+
drivers/hwmon/pmbus/ibmps.c static int ibmps_read_word_data(struct i2c_client *client, int page, int reg) · line 148
Quoted 3 lines
drivers/hwmon/pmbus/ibmps.c +3
-0+ rc =pmbus_read_word_data (client,0 ,PMBUS_STATUS_WORD ); +if (rc <0 ) +return rc;+
Quoted 1 line
+ return
snprintf(buf, PAGE_SIZE - 1, "%04x\n", rc);drivers/hwmon/pmbus/ibmps.c +4
-0+} +static DEVICE_ATTR(status_word, 0444, ibmps_show_status_word, NULL); + +static ssize_t ibmps_show_status_byte(struct device *dev,Review
Quoted 2 lines
(quoted diff) +2
-0+ struct device_attribute *dev_attr, + char *buf)+{
Quoted 4 lines
drivers/hwmon/pmbus/ibmps.c +3
-0+int rc; +struct i2c_client *client =to_i2c_client (dev); + struct sensor_device_attribute *sattr =
to_sensor_dev_attr(dev_attr);+
Review
Quoted 4 lines
+ rc = pmbus_read_byte_data(client, 0,
PMBUS_STATUS_VOUT+sattr->index);(quoted diff) +2
-0+ if (rc < 0) + return rc;+
Quoted 1 line
+ return
snprintf(buf, PAGE_SIZE - 1, "%02x\n", rc);drivers/hwmon/pmbus/ibmps.c +3
-0+} + +static SENSOR_DEVICE_ATTR(status_vout, 0444,
ibmps_show_status_byte, NULL, 0);
+staticSENSOR_DEVICE_ATTR(status_iout, 0444, ibmps_show_status_byte, NULL, 1);
+staticSENSOR_DEVICE_ATTR(status_input, 0444, ibmps_show_status_byte, NULL, 2);
+staticSENSOR_DEVICE_ATTR(status_temp, 0444, ibmps_show_status_byte, NULL, 3);
+staticSENSOR_DEVICE_ATTR(status_cml, 0444, ibmps_show_status_byte, NULL, 4);
+staticSENSOR_DEVICE_ATTR(status_other, 0444, ibmps_show_status_byte, NULL, 5);
+staticSENSOR_DEVICE_ATTR(status_mfr, 0444, ibmps_show_status_byte, NULL, 6);
+staticSENSOR_DEVICE_ATTR(status_fan, 0444, ibmps_show_status_byte, NULL, 7);drivers/hwmon/pmbus/ibmps.c +2
-0+ +static struct attribute *ibmps_attributes[] = {Quoted 11 lines
drivers/hwmon/pmbus/ibmps.c +11
-0+ &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 drivers/hwmon/pmbus/ibmps.c +3
-0+}; + +static const struct attribute_group ibmps_attribute_group = {Quoted 1 line
+ .attrs =
ibmps_attributes,drivers/hwmon/pmbus/ibmps.c +2
-0+}; + static int ibmps_probe(struct i2c_client *client,Quoted 1 line
const struct
i2c_device_id*id){
drivers/hwmon/pmbus/ibmps.c static int ibmps_read_word_data(struct i2c_client *client, int page, int reg) · line 202
Quoted 4 lines
drivers/hwmon/pmbus/ibmps.c +4
-0+int rc =sysfs_create_group (&client->dev.kobj, + &ibmps_attribute_group); +if (rc) +return rc;+
Quoted 1 line
return pmbus_do_probe(client, id, &ibmps_info);}
static intibmps_remove(struct i2c_client *client)
{Quoted 1 line
+
sysfs_remove_group(&client->dev.kobj, &ibmps_attribute_group);+
Quoted 1 line
return pmbus_do_remove(client);}
Re: [PATCH linux dev-4.10 v3 2/5] drivers/hwmon/pmbus: ibmps: Add non-hwmon attributes
Quoted 22 lines · Matt Spinler
Quoted 20 lines · Eddie James
Quoted 8 lines · Andrew Jeffery
Quoted 3 lines · Eddie James
Quoted 1 line
From: "Edward A. James" <[email protected]>
Add sysfs entries to dump out PS registers
Why are we working against what the pmbus subsystem already gives us? Why not augment support in pmbus core to give us the information we need in a manner acceptable to upstream?
Yea, that would be great. I feel like we're a little short on time for that, as we need this functionality basically now. But we can give it a shot.
Quoted 3 lines
Flipping to the other end of the spectrum: The device only has one page. We can just use
i2cget -f -y ...without risk of corruption.
Quoted 7 lines
Quoted 3 lines
Yea, I just get a lot of requests to have it all in the device driver. I guess we need to just push back and ask people to use i2c tools. But we will have to solve this for the UCD driver.
In general, IBM likes to capture a lot of registers on failures so we can actually figure out what went wrong after the fact, as we have customers who get mad when we can't give them root cause.
I appreciate that.
Quoted 3 lines
It's a bummer
that is so hard to do here. And if we had to use the i2cdev stuff for that, then why even use a device driver for any of this...
Well, because:
1. There are existing ABIs for exposing a lot (but not all) of these properties, and hwmon/pmbus devices should have drivers that conform to these ABIs
2. Using the existing ABIs allows existing applications (e.g. sensors) to display interesting information without knowledge of the hardware (PMBus spec is pretty loose in terms of what you can do, what you support, and how you go about it)
The problem I have with the proposal is it emulates what we can equivalently scrape with i2cget -f by documenting a new kernel ABI that has no additional semantics. This isn't going to fly with upstream, and isn't terribly useful for us given the single page this device supports.
The spanner in the works is the UCD driver where we will want to do the same thing, but where the device has multiple pages. The i2cget -f approach falls down there, and does seem it might require something like what's proposed here if time is a factor. Given that there's the question of consistency in the approach (i.e. providing the sysfs interface for the UCD device but requiring the use of i2cget -f here seems broken).
I'm a bit torn really.
Has anyone looked at how much effort it would really be to split out the bits?
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
Quoted 5 lines
and clear faults.
Can you describe the motivation for this? I feel like it would be worth having this as a separate patch, and to the core rather than in an arbitrary driver.
Quoted 5 lines
Quoted 2 lines
Users need to be able to clear faults, that was just on my list of requirements :) They could probably use i2cset though.
Yea, userspace needs this. I'm kinda surprised there wasn't already a way to expose it.
Right; it seems the kernel's pmbus subsystem has mainly been concerned with monitoring and not controlling the associated device. Clearing faults would be a departure from that, as are my core changes to support the MAX31785. I think there's a good chance that something like what's proposed is acceptable, just no-one had implemented it.
Andrew
Quoted 147 lines
Quoted 145 lines
Quoted 145 lines
Cheers,
Andrew
Quoted 138 lines
Quoted 1 line
Signed-off-by Edward A. James <[email protected]>---
drivers/hwmon/pmbus/ibmps.c| 78
+++++++++++++++++++++++++++++++++++++++++++++1 file changed, 78 insertions(+)drivers/hwmon/pmbus/ibmps.c +2
-0@@ -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"@@ -122,14 +124,90 @@ static int
ibmps_read_word_data(struct i2c_client *client, int page, int reg)Quoted 1 line
.read_word_data =
ibmps_read_word_data,};
+staticssize_tibmps_clear_faults(struct device *dev,Quoted 2 lines
+ struct
device_attribute*dev_attr, + const char *buf,size_tcount)+{
Quoted 1 line
+ struct
i2c_client*client =to_i2c_client(dev);+
Quoted 1 line
+ pmbus_clear_faults(client);
+
Quoted 1 line
+ return count;
drivers/hwmon/pmbus/ibmps.c +4
-0+} +static DEVICE_ATTR(clear_faults, 0200, NULL, ibmps_clear_faults); + +static ssize_t ibmps_show_status_word(struct device *dev,Quoted 2 lines
+ struct
device_attribute*dev_attr, + char *buf)+{
Quoted 2 lines
+ int rc;
+ structi2c_client*client =to_i2c_client(dev);+
Quoted 3 lines
+ rc =
pmbus_read_word_data(client, 0, PMBUS_STATUS_WORD); + if (rc < 0)
+ return rc;+
Quoted 1 line
+ return
snprintf(buf, PAGE_SIZE - 1, "%04x\n", rc);drivers/hwmon/pmbus/ibmps.c +4
-0+} +static DEVICE_ATTR(status_word, 0444, ibmps_show_status_word, NULL); + +static ssize_t ibmps_show_status_byte(struct device *dev,Quoted 2 lines
+ struct
device_attribute*dev_attr, + char *buf)+{
Quoted 4 lines
+ int rc;
+ structi2c_client*client =to_i2c_client(dev); + structsensor_device_attribute*sattr =to_sensor_dev_attr(dev_attr);+
Quoted 4 lines
+ rc =
pmbus_read_byte_data(client, 0, PMBUS_STATUS_VOUT + sattr->index);
+ if (rc < 0)
+ return rc;+
Quoted 1 line
+ return
snprintf(buf, PAGE_SIZE - 1, "%02x\n", rc);drivers/hwmon/pmbus/ibmps.c +3
-0+} + +static SENSOR_DEVICE_ATTR(status_vout, 0444,
ibmps_show_status_byte, NULL, 0);
+staticSENSOR_DEVICE_ATTR(status_iout, 0444, ibmps_show_status_byte, NULL, 1);
+staticSENSOR_DEVICE_ATTR(status_input, 0444, ibmps_show_status_byte, NULL, 2);
+staticSENSOR_DEVICE_ATTR(status_temp, 0444, ibmps_show_status_byte, NULL, 3);
+staticSENSOR_DEVICE_ATTR(status_cml, 0444, ibmps_show_status_byte, NULL, 4);
+staticSENSOR_DEVICE_ATTR(status_other, 0444, ibmps_show_status_byte, NULL, 5);
+staticSENSOR_DEVICE_ATTR(status_mfr, 0444, ibmps_show_status_byte, NULL, 6);
+staticSENSOR_DEVICE_ATTR(status_fan, 0444, ibmps_show_status_byte, NULL, 7);drivers/hwmon/pmbus/ibmps.c +2
-0+ +static struct attribute *ibmps_attributes[] = {Quoted 11 lines
+ &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,
+ NULLdrivers/hwmon/pmbus/ibmps.c +3
-0+}; + +static const struct attribute_group ibmps_attribute_group = {Quoted 1 line
+ .attrs =
ibmps_attributes,drivers/hwmon/pmbus/ibmps.c +2
-0+}; +static int ibmps_probe(struct
i2c_client*client,Quoted 1 line
const struct
i2c_device_id*id){
Quoted 4 lines
+ int rc =
sysfs_create_group(&client->dev.kobj, + &ibmps_attribute_group); + if (rc)
+ return rc;+
Quoted 1 line
return
pmbus_do_probe(client, id, &ibmps_info);}
static intibmps_remove(struct i2c_client *client){Quoted 1 line
+
sysfs_remove_group(&client->dev.kobj, &ibmps_attribute_group);+
Quoted 1 line
return
pmbus_do_remove(client);}
PATCH v3 3/5 Documentation: hwmon: Add IBM power supply documentation
In reply to Eddie JamesFrom: "Edward A. James" <[email protected]>
--- Documentation/hwmon/ibmps | 53 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 Documentation/hwmon/ibmps
Documentation/hwmon/ibmps new file +53 -0
@@ -0,0 +1,53 @@ +Kernel driver ibmps +==================== + +Supported chips: + * IBM Witherspoon power supply + +Author: Eddie James <[email protected]> + +Description +----------- + +This driver supports the IBM 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.
Signature · 1 line
1.8.3.1
Re: [PATCH linux dev-4.10 v3 3/5] Documentation: hwmon: Add IBM power supply documentation
Quoted 42 lines · Eddie James
From: "Edward A. James" <[email protected]>
Signed-off-by Edward A. James <[email protected]>--- Documentation/hwmon/ibmps | 53 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 Documentation/hwmon/ibmpsDocumentation/hwmon/ibmps new file +28
-0@@ -0,0 +1,53 @@ +Kernel driver ibmps +==================== + +Supported chips: + * IBM Witherspoon power supply + +Author: Eddie James <[email protected]> + +Description +----------- + +This driver supports the IBM 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.
Documentation/hwmon/ibmps line 38
Quoted 10 lines
Documentation/hwmon/ibmps new file +10
-0+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.
Is this the normal/regular file to put this under-voltage fault in? I noticed that the UCD9200 device driver appears to be the only one looking for that right now, and it has it updating in1_lcrit_alarm:
ucd9200:in1_lcrit_alarm Voltage critical low alarm. FromVIN_UV_FAULT status.
Quoted 18 lines
Documentation/hwmon/ibmps new file +15
-1+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
Re: [PATCH linux dev-4.10 v3 3/5] Documentation: hwmon: Add IBM power supply documentation
Quoted 50 lines · Brandon Wyman
Quoted 49 lines · Eddie James
From: "Edward A. James" <[email protected]>
Signed-off-by Edward A. James <[email protected]>--- Documentation/hwmon/ibmps | 53 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+)create mode 100644
Documentation/hwmon/ibmpsDocumentation/hwmon/ibmps new file +35
-0@@ -0,0 +1,53 @@ +Kernel driver ibmps +==================== + +Supported chips: + * IBM Witherspoon power supply + +Author: Eddie James <[email protected]> + +Description +----------- + +This driver supports the IBM 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.
Quoted 8 lines
Documentation/hwmon/ibmps line 38
Quoted 3 lines
Documentation/hwmon/ibmps new file +3
-0+fan2_input Fan 2 speed in RPM. + +in1_alarm Input voltage under-voltage fault.Is this the normal/regular file to put this under-voltage fault in? I noticed that the UCD9200 device driver appears to be the only one looking for that right now, and it has it updating
in1_lcrit_alarm:
ucd9200:in1_lcrit_alarm Voltage critical low alarm. FromVIN_UV_FAULTstatus.
Since this is "vin" this will provide the status of VIN_UV_FAULT. Similarly, VOUT_OV_FAULT will be provided by the in2_alarm ("vout"). The power supply doesn't provide limit ranges for it's values, so in order to get lcrit_alarm or similar I'd have to "trick" pmbus into thinking limits are being provided by the PS. This seems more simple.
Thanks,
Eddie
Quoted 19 lines
Quoted 19 lines
Documentation/hwmon/ibmps new file +15
-1+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
Re: [PATCH linux dev-4.10 v3 3/5] Documentation: hwmon: Add IBM power supply documentation
Quoted 62 lines · Eddie James
Quoted 51 lines · Brandon Wyman
Quoted 50 lines · Eddie James
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
From: "Edward A. James" <[email protected]>
Signed-off-by Edward A. James <[email protected]>---
Documentation/hwmon/ibmps| 53 +++++++++++++++++++++++++++++++++++++++++++++++1 file changed, 53 insertions(+)create mode 100644
Documentation/hwmon/ibmpsDocumentation/hwmon/ibmps new file +6
-0@@ -0,0 +1,53 @@ +Kernel driver ibmps +==================== + +Supported chips: + * IBM Witherspoon power supply +Quoted 1 line
Quoted 1 line
Quoted 1 line
+Author: Eddie James <[email protected]>
Documentation/hwmon/ibmps new file +29
-0+ +Description +----------- + +This driver supports the IBM 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.Quoted 8 lines
Documentation/hwmon/ibmps
Quoted 2 lines
Documentation/hwmon/ibmps new file +2
-0+ +in1_alarm Input voltage under-voltage fault.Is this the normal/regular file to put this under-voltage fault in? I noticed that the UCD9200 device driver appears to be the only one looking for that right now, and it has it updating
in1_lcrit_alarm:
ucd9200:in1_lcrit_alarm Voltage critical low alarm. FromVIN_UV_FAULTstatus.
Quoted 5 lines
Since this is "vin" this will provide the status of
VIN_UV_FAULT. Similarly,VOUT_OV_FAULTwill be provided by thein2_alarm("vout"). The power supply doesn't provide limit ranges for it's values, so in order to getlcrit_alarmor similar I'd have to "trick" pmbus into thinking limits are being provided by the PS. This seems more simple.
I'm not across the context, but tricking pmbus is straight forward:
Implement the {read,write}_{byte,word}_data callbacks, and provide an implementation of the register whose value you want to to fake out.
However, from Documentation/hwmon/sysfs-interface:
Each channel or limit may have an associated alarm file, containing a boolean value. 1 means than an alarm condition exists, 0 means no alarm.
Usually a given chip will either use channel-related alarms, or limit-related alarms, not both. The driver should just reflect the hardware.
Sounds like what Eddie's describing maybe fits the channel-related case? Again, I haven't read though the whole series so take that with a grain of salt.
Andrew
Quoted 25 lines
Thanks,
EddieQuoted 19 lines
Quoted 19 lines
Documentation/hwmon/ibmps new file +15
-1+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
PATCH v3 4/5 Documentation: ABI: Add IBM power supply sysfs documentation
In reply to Eddie JamesFrom: "Edward A. James" <[email protected]>
--- Documentation/ABI/testing/sysfs-driver-ibmps | 49 ++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-driver-ibmps
Documentation/ABI/testing/sysfs-driver-ibmps new file +49 -0
@@ -0,0 +1,49 @@ +What: /sys/bus/i2c/devices/<dev>/clear_faults +KernelVersion: 4.13 +Contact: [email protected] +Description: Clears pmbus faults for this power supply. + +What: /sys/bus/i2c/devices/<dev>/status_word +KernelVersion: 4.13 +Contact: [email protected] +Description: Displays the STATUS_WORD register. + +What: /sys/bus/i2c/devices/<dev>/status_vout +KernelVersion: 4.13 +Contact: [email protected] +Description: Displays the STATUS_VOUT register. + +What: /sys/bus/i2c/devices/<dev>/status_iout +KernelVersion: 4.13 +Contact: [email protected] +Description: Displays the STATUS_IOUT register. + +What: /sys/bus/i2c/devices/<dev>/status_input +KernelVersion: 4.13 +Contact: [email protected] +Description: Displays the STATUS_INPUT register. + +What: /sys/bus/i2c/devices/<dev>/status_temp +KernelVersion: 4.13 +Contact: [email protected] +Description: Displays the STATUS_TEMPERATURE register. + +What: /sys/bus/i2c/devices/<dev>/status_cml +KernelVersion: 4.13 +Contact: [email protected] +Description: Displays the STATUS_CML register. + +What: /sys/bus/i2c/devices/<dev>/status_other +KernelVersion: 4.13 +Contact: [email protected] +Description: Displays the STATUS_OTHER register. + +What: /sys/bus/i2c/devices/<dev>/status_mfr +KernelVersion: 4.13 +Contact: [email protected] +Description: Displays the STATUS_MFR_SPECIFIC register. + +What: /sys/bus/i2c/devices/<dev>/status_fan +KernelVersion: 4.13 +Contact: [email protected] +Description: Displays the STATUS_FAN register.
Signature · 1 line
1.8.3.1
Re: [PATCH linux dev-4.10 v3 4/5] Documentation: ABI: Add IBM power supply sysfs documentation
Quoted 14 lines · Eddie James
From: "Edward A. James" <[email protected]>
Signed-off-by Edward A. James <[email protected]>--- Documentation/ABI/testing/sysfs-driver-ibmps | 49 ++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+)create mode 100644
Documentation/ABI/testing/sysfs-driver-ibmpsDocumentation/ABI/testing/sysfs-driver-ibmps new file +0
-0
Documentation/ABI/testing/sysfs-driver-ibmps line 9
Quoted 9 lines
Documentation/ABI/testing/sysfs-driver-ibmps new file +9
-0@@ -0,0 +1,49 @@ +What: /sys/bus/i2c/devices/<dev>/clear_faults +KernelVersion: 4.13 +Contact: [email protected] +Description: Clears pmbus faults for this power supply. + +What: /sys/bus/i2c/devices/<dev>/status_word +KernelVersion: 4.13 +Contact: [email protected] +Description: Displays the STATUS_WORD register.
Hey Chris, I think you did some research and found that upstream wouldn't allow capturing full registers like this? Was that the case? Or does it not matter as long as it isn't in hwmon?
Quoted 40 lines
Documentation/ABI/testing/sysfs-driver-ibmps new file +40
-0+ +What: /sys/bus/i2c/devices/<dev>/status_vout +KernelVersion: 4.13 +Contact: [email protected] +Description: Displays the STATUS_VOUT register. + +What: /sys/bus/i2c/devices/<dev>/status_iout +KernelVersion: 4.13 +Contact: [email protected] +Description: Displays the STATUS_IOUT register. + +What: /sys/bus/i2c/devices/<dev>/status_input +KernelVersion: 4.13 +Contact: [email protected] +Description: Displays the STATUS_INPUT register. + +What: /sys/bus/i2c/devices/<dev>/status_temp +KernelVersion: 4.13 +Contact: [email protected] +Description: Displays the STATUS_TEMPERATURE register. + +What: /sys/bus/i2c/devices/<dev>/status_cml +KernelVersion: 4.13 +Contact: [email protected] +Description: Displays the STATUS_CML register. + +What: /sys/bus/i2c/devices/<dev>/status_other +KernelVersion: 4.13 +Contact: [email protected] +Description: Displays the STATUS_OTHER register. + +What: /sys/bus/i2c/devices/<dev>/status_mfr +KernelVersion: 4.13 +Contact: [email protected] +Description: Displays the STATUS_MFR_SPECIFIC register. + +What: /sys/bus/i2c/devices/<dev>/status_fan +KernelVersion: 4.13 +Contact: [email protected] +Description: Displays the STATUS_FAN register.
Re: [PATCH linux dev-4.10 v3 4/5] Documentation: ABI: Add IBM power supply sysfs documentation
Quoted 21 lines · Matt Spinler
Quoted 19 lines · Eddie James
Quoted 3 lines
Quoted 3 lines
From: "Edward A. James" <[email protected]>
Signed-off-by Edward A. James <[email protected]>---
Documentation/ABI/testing/sysfs-driver-ibmps| 49 ++++++++++++++++++++++++++++1 file changed, 49 insertions(+)create mode 100644
Documentation/ABI/testing/sysfs-driver-ibmpsDocumentation/ABI/testing/sysfs-driver-ibmps new file +0
-0@@ -0,0 +1,49 @@Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+What: /sys/bus/i2c/devices/<dev>/clear_faults +KernelVersion: 4.13+Contact: [email protected]
Quoted 1 line
Quoted 1 line
+Description: Clears pmbus faults for this power supply.
+
Quoted 8 lines
Documentation/ABI/testing/sysfs-driver-ibmps
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines
(quoted diff) +2
-0+What: /sys/bus/i2c/devices/<dev>/status_word +KernelVersion: 4.13Documentation/ABI/testing/sysfs-driver-ibmps new file +2
-0+Contact: [email protected] +Description: Displays the STATUS_WORD register.Hey Chris, I think you did some research and found that upstream wouldn't allow capturing full registers like this? Was that the case? Or does it not matter as long as it isn't in hwmon?
This is a PMBus device, so it should be implemented in terms of the PMBus subsystem. I expect this approach will be shot down by the hwmon/pmbus maintainer.
Given the STATUS_BYTE/STATUS_WORD registers are the root of a fault tree, another approach is to ignore the tree and focus on the leaves, which is the PMBus subsystem's approach:
https://github.com/openbmc/linux/blob/dev-4.10/drivers/hwmon/pmbus/pmbus_core.c#L1245
This continues down to line 1700.
Now, for several of the bits STATUS_WORD is the leaf node. Using STATUS_WORD as a reference, as STATUS_BYTE is STATUS_WORD's lower byte, STATUS_WORD is a leaf for the following bits:
* Bit 0: None of the above
* Bit 6: Unit is off
* Bit 7: Unit was busy
* Bit 8: Unknown fault or warning
* Bit 11: Power Good negated
Currently none of these bits are exposed by pmbus core, so that would need to be rectified, but in-line with the approach used above. I recommend getting in touch with Guenter on his preferred approach.
Quoted 35 lines
Quoted 35 lines
+
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+What: /sys/bus/i2c/devices/<dev>/status_vout +KernelVersion: 4.13+Contact: [email protected]
Quoted 1 line
Quoted 1 line
+Description: Displays the
STATUS_VOUTregister.+
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+What: /sys/bus/i2c/devices/<dev>/status_iout +KernelVersion: 4.13+Contact: [email protected]
Quoted 1 line
Quoted 1 line
+Description: Displays the
STATUS_IOUTregister.+
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+What: /sys/bus/i2c/devices/<dev>/status_input +KernelVersion: 4.13+Contact: [email protected]
Quoted 1 line
Quoted 1 line
+Description: Displays the
STATUS_INPUTregister.+
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+What: /sys/bus/i2c/devices/<dev>/status_temp +KernelVersion: 4.13+Contact: [email protected]
Quoted 1 line
Quoted 1 line
+Description: Displays the
STATUS_TEMPERATUREregister.+
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+What: /sys/bus/i2c/devices/<dev>/status_cml +KernelVersion: 4.13+Contact: [email protected]
Quoted 1 line
Quoted 1 line
+Description: Displays the
STATUS_CMLregister.+
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+What: /sys/bus/i2c/devices/<dev>/status_other +KernelVersion: 4.13+Contact: [email protected]
Quoted 1 line
Quoted 1 line
+Description: Displays the
STATUS_OTHERregister.+
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+What: /sys/bus/i2c/devices/<dev>/status_mfr +KernelVersion: 4.13+Contact: [email protected]
Quoted 6 lines
Documentation/ABI/testing/sysfs-driver-ibmps
Quoted 6 lines
Quoted 1 line
Quoted 1 line
+Description: Displays the
STATUS_MFR_SPECIFICregister.+
Quoted 2 lines
Quoted 2 lines
Documentation/ABI/testing/sysfs-driver-ibmps new file +2
-0+What: /sys/bus/i2c/devices/<dev>/status_fan +KernelVersion: 4.13Documentation/ABI/testing/sysfs-driver-ibmps new file +2
-0+Contact: [email protected] +Description: Displays the STATUS_FAN register.
See my comment above. This will get a prickly response if sent upstream.
Andrew
Quoted 2 lines
PATCH v3 5/5 ARM: dts: aspeed: witherspoon: Add IBM power supply to I2C bus
In reply to Eddie JamesFrom: "Edward A. James" <[email protected]>
--- arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts | 10 ++++++++++ 1 file changed, 10 insertions(+)
arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts +10 -0
@@ -321,6 +321,16 @@ type = <PCA955X_TYPE_LED>; }; }; + + power-supply@68 { + compatible = "ibm,ibmps"; + reg = <0x68>; + }; + + power-supply@69 { + compatible = "ibm,ibmps"; + reg = <0x69>; + }; }; &i2c4 {
Signature · 1 line
1.8.3.1
Quoted 8 lines · Eddie James
From: "Edward A. James" <[email protected]>
This series adds a hwmon pmbus driver for the IBM 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.
Forgot to mention; only change since v2 was to rename the driver to ibmps.
Quoted 19 lines
Edward A. James (5):
drivers/hwmon/pmbus: Add IBM power supply hwmon driverdrivers/hwmon/pmbus: ibmps: Add non-hwmon attributes
Documentation: hwmon: Add IBM power supply documentation
Documentation: ABI: Add IBM power supply sysfs documentation
ARM: dts: aspeed: witherspoon: Add IBM power supply to I2C busDocumentation/ABI/testing/sysfs-driver-ibmps | 49 +++++ Documentation/hwmon/ibmps | 53 +++++ arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts | 10 + drivers/hwmon/pmbus/Kconfig | 10 + drivers/hwmon/pmbus/Makefile | 1 + drivers/hwmon/pmbus/ibmps.c | 242 +++++++++++++++++++++++ 6 files changed, 365 insertions(+)create mode 100644
Documentation/ABI/testing/sysfs-driver-ibmpscreate mode 100644Documentation/hwmon/ibmps
create mode 100644drivers/hwmon/pmbus/ibmps.c