* [PATCH 0/2] hwmon: (pmbus/ibm-cffps) Add version detection capability @ 2019-10-09 19:11 Eddie James 2019-10-09 19:11 ` [PATCH 1/2] dt-bindings: hwmon: Document ibm,cffps compatible string Eddie James 2019-10-09 19:11 ` [PATCH 2/2] hwmon: (pmbus/ibm-cffps) Add version detection capability Eddie James 0 siblings, 2 replies; 6+ messages in thread From: Eddie James @ 2019-10-09 19:11 UTC (permalink / raw) To: linux-hwmon Cc: linux-kernel, devicetree, jdelvare, linux, mark.rutland, robh+dt, Eddie James The IBM common form factor power supply driver may need to detect which PSU version is connected, since some systems can use a variety of power supplies. This series adds a new compatible string with no version number, and some code to parse the CCIN of the PSU to determine which version is applicable. Eddie James (2): dt-bindings: hwmon: Document ibm,cffps compatible string hwmon: (pmbus/ibm-cffps) Add version detection capability .../devicetree/bindings/hwmon/ibm,cffps1.txt | 3 ++ drivers/hwmon/pmbus/ibm-cffps.c | 37 +++++++++++++++++++--- 2 files changed, 36 insertions(+), 4 deletions(-) -- 1.8.3.1 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] dt-bindings: hwmon: Document ibm,cffps compatible string 2019-10-09 19:11 [PATCH 0/2] hwmon: (pmbus/ibm-cffps) Add version detection capability Eddie James @ 2019-10-09 19:11 ` Eddie James 2019-10-15 22:32 ` Rob Herring 2019-10-17 13:35 ` Guenter Roeck 2019-10-09 19:11 ` [PATCH 2/2] hwmon: (pmbus/ibm-cffps) Add version detection capability Eddie James 1 sibling, 2 replies; 6+ messages in thread From: Eddie James @ 2019-10-09 19:11 UTC (permalink / raw) To: linux-hwmon Cc: linux-kernel, devicetree, jdelvare, linux, mark.rutland, robh+dt, Eddie James Document this string that indicates that any version of the power supply may be connected. In this case, the driver must detect the version automatically. Signed-off-by: Eddie James <eajames@linux.ibm.com> --- Documentation/devicetree/bindings/hwmon/ibm,cffps1.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Documentation/devicetree/bindings/hwmon/ibm,cffps1.txt b/Documentation/devicetree/bindings/hwmon/ibm,cffps1.txt index 1036f65..d9a2719 100644 --- a/Documentation/devicetree/bindings/hwmon/ibm,cffps1.txt +++ b/Documentation/devicetree/bindings/hwmon/ibm,cffps1.txt @@ -5,6 +5,9 @@ Required properties: - compatible : Must be one of the following: "ibm,cffps1" "ibm,cffps2" + or "ibm,cffps" if the system + must support any version of the + power supply - reg = < I2C bus address >; : Address of the power supply on the I2C bus. -- 1.8.3.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] dt-bindings: hwmon: Document ibm,cffps compatible string 2019-10-09 19:11 ` [PATCH 1/2] dt-bindings: hwmon: Document ibm,cffps compatible string Eddie James @ 2019-10-15 22:32 ` Rob Herring 2019-10-17 13:35 ` Guenter Roeck 1 sibling, 0 replies; 6+ messages in thread From: Rob Herring @ 2019-10-15 22:32 UTC (permalink / raw) To: Eddie James Cc: linux-hwmon, linux-kernel, devicetree, jdelvare, linux, mark.rutland, robh+dt, Eddie James On Wed, 9 Oct 2019 14:11:01 -0500, Eddie James wrote: > Document this string that indicates that any version of the power supply > may be connected. In this case, the driver must detect the version > automatically. > > Signed-off-by: Eddie James <eajames@linux.ibm.com> > --- > Documentation/devicetree/bindings/hwmon/ibm,cffps1.txt | 3 +++ > 1 file changed, 3 insertions(+) > Acked-by: Rob Herring <robh@kernel.org> ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] dt-bindings: hwmon: Document ibm,cffps compatible string 2019-10-09 19:11 ` [PATCH 1/2] dt-bindings: hwmon: Document ibm,cffps compatible string Eddie James 2019-10-15 22:32 ` Rob Herring @ 2019-10-17 13:35 ` Guenter Roeck 1 sibling, 0 replies; 6+ messages in thread From: Guenter Roeck @ 2019-10-17 13:35 UTC (permalink / raw) To: Eddie James Cc: linux-hwmon, linux-kernel, devicetree, jdelvare, mark.rutland, robh+dt On Wed, Oct 09, 2019 at 02:11:01PM -0500, Eddie James wrote: > Document this string that indicates that any version of the power supply > may be connected. In this case, the driver must detect the version > automatically. > > Signed-off-by: Eddie James <eajames@linux.ibm.com> > Acked-by: Rob Herring <robh@kernel.org> Applied. Thanks, Guenter > --- > Documentation/devicetree/bindings/hwmon/ibm,cffps1.txt | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/Documentation/devicetree/bindings/hwmon/ibm,cffps1.txt b/Documentation/devicetree/bindings/hwmon/ibm,cffps1.txt > index 1036f65..d9a2719 100644 > --- a/Documentation/devicetree/bindings/hwmon/ibm,cffps1.txt > +++ b/Documentation/devicetree/bindings/hwmon/ibm,cffps1.txt > @@ -5,6 +5,9 @@ Required properties: > - compatible : Must be one of the following: > "ibm,cffps1" > "ibm,cffps2" > + or "ibm,cffps" if the system > + must support any version of the > + power supply > - reg = < I2C bus address >; : Address of the power supply on the > I2C bus. > ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/2] hwmon: (pmbus/ibm-cffps) Add version detection capability 2019-10-09 19:11 [PATCH 0/2] hwmon: (pmbus/ibm-cffps) Add version detection capability Eddie James 2019-10-09 19:11 ` [PATCH 1/2] dt-bindings: hwmon: Document ibm,cffps compatible string Eddie James @ 2019-10-09 19:11 ` Eddie James 2019-10-17 13:36 ` Guenter Roeck 1 sibling, 1 reply; 6+ messages in thread From: Eddie James @ 2019-10-09 19:11 UTC (permalink / raw) To: linux-hwmon Cc: linux-kernel, devicetree, jdelvare, linux, mark.rutland, robh+dt, Eddie James Some systems may plug in either version 1 or version 2 of the IBM common form factor power supply. Add a version-less compatibility string that tells the driver to try and detect which version of the power supply is connected. Signed-off-by: Eddie James <eajames@linux.ibm.com> --- drivers/hwmon/pmbus/ibm-cffps.c | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/drivers/hwmon/pmbus/ibm-cffps.c b/drivers/hwmon/pmbus/ibm-cffps.c index d44745e..d61547e 100644 --- a/drivers/hwmon/pmbus/ibm-cffps.c +++ b/drivers/hwmon/pmbus/ibm-cffps.c @@ -3,6 +3,7 @@ * Copyright 2017 IBM Corp. */ +#include <linux/bitfield.h> #include <linux/bitops.h> #include <linux/debugfs.h> #include <linux/device.h> @@ -29,6 +30,10 @@ #define CFFPS_INPUT_HISTORY_CMD 0xD6 #define CFFPS_INPUT_HISTORY_SIZE 100 +#define CFFPS_CCIN_VERSION GENMASK(15, 8) +#define CFFPS_CCIN_VERSION_1 0x2b +#define CFFPS_CCIN_VERSION_2 0x2e + /* STATUS_MFR_SPECIFIC bits */ #define CFFPS_MFR_FAN_FAULT BIT(0) #define CFFPS_MFR_THERMAL_FAULT BIT(1) @@ -54,7 +59,7 @@ enum { CFFPS_DEBUGFS_NUM_ENTRIES }; -enum versions { cffps1, cffps2 }; +enum versions { cffps1, cffps2, cffps_unknown }; struct ibm_cffps_input_history { struct mutex update_lock; @@ -395,7 +400,7 @@ static int ibm_cffps_probe(struct i2c_client *client, const struct i2c_device_id *id) { int i, rc; - enum versions vs; + enum versions vs = cffps_unknown; struct dentry *debugfs; struct dentry *ibm_cffps_dir; struct ibm_cffps *psu; @@ -405,8 +410,27 @@ static int ibm_cffps_probe(struct i2c_client *client, vs = (enum versions)md; else if (id) vs = (enum versions)id->driver_data; - else - vs = cffps1; + + if (vs == cffps_unknown) { + u16 ccin_version = CFFPS_CCIN_VERSION_1; + int ccin = i2c_smbus_read_word_swapped(client, CFFPS_CCIN_CMD); + + if (ccin > 0) + ccin_version = FIELD_GET(CFFPS_CCIN_VERSION, ccin); + + switch (ccin_version) { + default: + case CFFPS_CCIN_VERSION_1: + vs = cffps1; + break; + case CFFPS_CCIN_VERSION_2: + vs = cffps2; + break; + } + + /* Set the client name to include the version number. */ + snprintf(client->name, I2C_NAME_SIZE, "cffps%d", vs + 1); + } client->dev.platform_data = &ibm_cffps_pdata; rc = pmbus_do_probe(client, id, &ibm_cffps_info[vs]); @@ -465,6 +489,7 @@ static int ibm_cffps_probe(struct i2c_client *client, static const struct i2c_device_id ibm_cffps_id[] = { { "ibm_cffps1", cffps1 }, { "ibm_cffps2", cffps2 }, + { "ibm_cffps", cffps_unknown }, {} }; MODULE_DEVICE_TABLE(i2c, ibm_cffps_id); @@ -478,6 +503,10 @@ static int ibm_cffps_probe(struct i2c_client *client, .compatible = "ibm,cffps2", .data = (void *)cffps2 }, + { + .compatible = "ibm,cffps", + .data = (void *)cffps_unknown + }, {} }; MODULE_DEVICE_TABLE(of, ibm_cffps_of_match); -- 1.8.3.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] hwmon: (pmbus/ibm-cffps) Add version detection capability 2019-10-09 19:11 ` [PATCH 2/2] hwmon: (pmbus/ibm-cffps) Add version detection capability Eddie James @ 2019-10-17 13:36 ` Guenter Roeck 0 siblings, 0 replies; 6+ messages in thread From: Guenter Roeck @ 2019-10-17 13:36 UTC (permalink / raw) To: Eddie James Cc: linux-hwmon, linux-kernel, devicetree, jdelvare, mark.rutland, robh+dt On Wed, Oct 09, 2019 at 02:11:02PM -0500, Eddie James wrote: > Some systems may plug in either version 1 or version 2 of the IBM common > form factor power supply. Add a version-less compatibility string that > tells the driver to try and detect which version of the power supply is > connected. > > Signed-off-by: Eddie James <eajames@linux.ibm.com> Applied. Thanks, Guenter > --- > drivers/hwmon/pmbus/ibm-cffps.c | 37 +++++++++++++++++++++++++++++++++---- > 1 file changed, 33 insertions(+), 4 deletions(-) > > diff --git a/drivers/hwmon/pmbus/ibm-cffps.c b/drivers/hwmon/pmbus/ibm-cffps.c > index d44745e..d61547e 100644 > --- a/drivers/hwmon/pmbus/ibm-cffps.c > +++ b/drivers/hwmon/pmbus/ibm-cffps.c > @@ -3,6 +3,7 @@ > * Copyright 2017 IBM Corp. > */ > > +#include <linux/bitfield.h> > #include <linux/bitops.h> > #include <linux/debugfs.h> > #include <linux/device.h> > @@ -29,6 +30,10 @@ > #define CFFPS_INPUT_HISTORY_CMD 0xD6 > #define CFFPS_INPUT_HISTORY_SIZE 100 > > +#define CFFPS_CCIN_VERSION GENMASK(15, 8) > +#define CFFPS_CCIN_VERSION_1 0x2b > +#define CFFPS_CCIN_VERSION_2 0x2e > + > /* STATUS_MFR_SPECIFIC bits */ > #define CFFPS_MFR_FAN_FAULT BIT(0) > #define CFFPS_MFR_THERMAL_FAULT BIT(1) > @@ -54,7 +59,7 @@ enum { > CFFPS_DEBUGFS_NUM_ENTRIES > }; > > -enum versions { cffps1, cffps2 }; > +enum versions { cffps1, cffps2, cffps_unknown }; > > struct ibm_cffps_input_history { > struct mutex update_lock; > @@ -395,7 +400,7 @@ static int ibm_cffps_probe(struct i2c_client *client, > const struct i2c_device_id *id) > { > int i, rc; > - enum versions vs; > + enum versions vs = cffps_unknown; > struct dentry *debugfs; > struct dentry *ibm_cffps_dir; > struct ibm_cffps *psu; > @@ -405,8 +410,27 @@ static int ibm_cffps_probe(struct i2c_client *client, > vs = (enum versions)md; > else if (id) > vs = (enum versions)id->driver_data; > - else > - vs = cffps1; > + > + if (vs == cffps_unknown) { > + u16 ccin_version = CFFPS_CCIN_VERSION_1; > + int ccin = i2c_smbus_read_word_swapped(client, CFFPS_CCIN_CMD); > + > + if (ccin > 0) > + ccin_version = FIELD_GET(CFFPS_CCIN_VERSION, ccin); > + > + switch (ccin_version) { > + default: > + case CFFPS_CCIN_VERSION_1: > + vs = cffps1; > + break; > + case CFFPS_CCIN_VERSION_2: > + vs = cffps2; > + break; > + } > + > + /* Set the client name to include the version number. */ > + snprintf(client->name, I2C_NAME_SIZE, "cffps%d", vs + 1); > + } > > client->dev.platform_data = &ibm_cffps_pdata; > rc = pmbus_do_probe(client, id, &ibm_cffps_info[vs]); > @@ -465,6 +489,7 @@ static int ibm_cffps_probe(struct i2c_client *client, > static const struct i2c_device_id ibm_cffps_id[] = { > { "ibm_cffps1", cffps1 }, > { "ibm_cffps2", cffps2 }, > + { "ibm_cffps", cffps_unknown }, > {} > }; > MODULE_DEVICE_TABLE(i2c, ibm_cffps_id); > @@ -478,6 +503,10 @@ static int ibm_cffps_probe(struct i2c_client *client, > .compatible = "ibm,cffps2", > .data = (void *)cffps2 > }, > + { > + .compatible = "ibm,cffps", > + .data = (void *)cffps_unknown > + }, > {} > }; > MODULE_DEVICE_TABLE(of, ibm_cffps_of_match); ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-10-17 13:36 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2019-10-09 19:11 [PATCH 0/2] hwmon: (pmbus/ibm-cffps) Add version detection capability Eddie James 2019-10-09 19:11 ` [PATCH 1/2] dt-bindings: hwmon: Document ibm,cffps compatible string Eddie James 2019-10-15 22:32 ` Rob Herring 2019-10-17 13:35 ` Guenter Roeck 2019-10-09 19:11 ` [PATCH 2/2] hwmon: (pmbus/ibm-cffps) Add version detection capability Eddie James 2019-10-17 13:36 ` Guenter Roeck
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).