openbmc.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] hwmon: (pmbus/ibm-cffps) Add mfg_id debugfs entry
@ 2021-10-04 14:43 Brandon Wyman
  2021-10-04 14:43 ` [PATCH 2/2] hwmon: (pmbus/ibm-cffps) Use MFR_ID to choose version Brandon Wyman
  2021-10-08 14:10 ` [PATCH 1/2] hwmon: (pmbus/ibm-cffps) Add mfg_id debugfs entry Guenter Roeck
  0 siblings, 2 replies; 4+ messages in thread
From: Brandon Wyman @ 2021-10-04 14:43 UTC (permalink / raw)
  To: Joel Stanley, openbmc, Guenter Roeck, Jean Delvare, linux-hwmon,
	linux-kernel, Eddie James
  Cc: Brandon Wyman

Add support for the manufacturer ID to the debugfs entries.

Signed-off-by: Brandon Wyman <bjwyman@gmail.com>
---
 drivers/hwmon/pmbus/ibm-cffps.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/pmbus/ibm-cffps.c b/drivers/hwmon/pmbus/ibm-cffps.c
index df712ce4b164..2ee47cbbb665 100644
--- a/drivers/hwmon/pmbus/ibm-cffps.c
+++ b/drivers/hwmon/pmbus/ibm-cffps.c
@@ -18,6 +18,7 @@
 
 #include "pmbus.h"
 
+#define CFFPS_MFG_ID_CMD                        0x99
 #define CFFPS_FRU_CMD				0x9A
 #define CFFPS_PN_CMD				0x9B
 #define CFFPS_HEADER_CMD			0x9C
@@ -34,7 +35,7 @@
 #define CFFPS_INPUT_HISTORY_SIZE		100
 
 #define CFFPS_CCIN_REVISION			GENMASK(7, 0)
-#define  CFFPS_CCIN_REVISION_LEGACY		 0xde
+#define CFFPS_CCIN_REVISION_LEGACY		 0xde
 #define CFFPS_CCIN_VERSION			GENMASK(15, 8)
 #define CFFPS_CCIN_VERSION_1			 0x2b
 #define CFFPS_CCIN_VERSION_2			 0x2e
@@ -57,6 +58,7 @@
 
 enum {
 	CFFPS_DEBUGFS_INPUT_HISTORY = 0,
+	CFFPS_DEBUGFS_MFG_ID,
 	CFFPS_DEBUGFS_FRU,
 	CFFPS_DEBUGFS_PN,
 	CFFPS_DEBUGFS_HEADER,
@@ -158,6 +160,9 @@ static ssize_t ibm_cffps_debugfs_read(struct file *file, char __user *buf,
 	switch (idx) {
 	case CFFPS_DEBUGFS_INPUT_HISTORY:
 		return ibm_cffps_read_input_history(psu, buf, count, ppos);
+	case CFFPS_DEBUGFS_MFG_ID:
+		cmd = CFFPS_MFG_ID_CMD;
+		break;
 	case CFFPS_DEBUGFS_FRU:
 		cmd = CFFPS_FRU_CMD;
 		break;
@@ -558,6 +563,9 @@ static int ibm_cffps_probe(struct i2c_client *client)
 	debugfs_create_file("input_history", 0444, ibm_cffps_dir,
 			    &psu->debugfs_entries[CFFPS_DEBUGFS_INPUT_HISTORY],
 			    &ibm_cffps_fops);
+	debugfs_create_file("mfg_id", 0444, ibm_cffps_dir,
+			    &psu->debugfs_entries[CFFPS_DEBUGFS_MFG_ID],
+			    &ibm_cffps_fops);
 	debugfs_create_file("fru", 0444, ibm_cffps_dir,
 			    &psu->debugfs_entries[CFFPS_DEBUGFS_FRU],
 			    &ibm_cffps_fops);
-- 
2.25.1


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

* [PATCH 2/2] hwmon: (pmbus/ibm-cffps) Use MFR_ID to choose version
  2021-10-04 14:43 [PATCH 1/2] hwmon: (pmbus/ibm-cffps) Add mfg_id debugfs entry Brandon Wyman
@ 2021-10-04 14:43 ` Brandon Wyman
  2021-10-08 14:12   ` Guenter Roeck
  2021-10-08 14:10 ` [PATCH 1/2] hwmon: (pmbus/ibm-cffps) Add mfg_id debugfs entry Guenter Roeck
  1 sibling, 1 reply; 4+ messages in thread
From: Brandon Wyman @ 2021-10-04 14:43 UTC (permalink / raw)
  To: Joel Stanley, openbmc, Guenter Roeck, Jean Delvare, linux-hwmon,
	linux-kernel, Eddie James
  Cc: Brandon Wyman

There are multiple power supplies that will indicate
CFFPS_CCIN_VERSION_1, use the manufacturer ID to determine if it should
be treated as version cffps1 or version cffps2.

Signed-off-by: Brandon Wyman <bjwyman@gmail.com>
---
 drivers/hwmon/pmbus/ibm-cffps.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/pmbus/ibm-cffps.c b/drivers/hwmon/pmbus/ibm-cffps.c
index 2ee47cbbb665..292c87331f2b 100644
--- a/drivers/hwmon/pmbus/ibm-cffps.c
+++ b/drivers/hwmon/pmbus/ibm-cffps.c
@@ -502,16 +502,29 @@ static int ibm_cffps_probe(struct i2c_client *client)
 		u16 ccin_revision = 0;
 		u16 ccin_version = CFFPS_CCIN_VERSION_1;
 		int ccin = i2c_smbus_read_word_swapped(client, CFFPS_CCIN_CMD);
+		char mfg_id[I2C_SMBUS_BLOCK_MAX + 2] = { 0 };
 
 		if (ccin > 0) {
 			ccin_revision = FIELD_GET(CFFPS_CCIN_REVISION, ccin);
 			ccin_version = FIELD_GET(CFFPS_CCIN_VERSION, ccin);
 		}
 
+		rc = i2c_smbus_read_block_data(client, PMBUS_MFR_ID,
+				mfg_id);
+		if (rc < 0) {
+			dev_err(&client->dev,
+					"Failed to read Manufacturer ID\n");
+			return rc;
+		}
+
 		switch (ccin_version) {
 		default:
 		case CFFPS_CCIN_VERSION_1:
-			vs = cffps1;
+			if ((strncmp(mfg_id, "ACBE", 4) == 0) ||
+					(strncmp(mfg_id, "ARTE", 4) == 0))
+				vs = cffps1;
+			else
+				vs = cffps2;
 			break;
 		case CFFPS_CCIN_VERSION_2:
 			vs = cffps2;
-- 
2.25.1


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

* Re: [PATCH 1/2] hwmon: (pmbus/ibm-cffps) Add mfg_id debugfs entry
  2021-10-04 14:43 [PATCH 1/2] hwmon: (pmbus/ibm-cffps) Add mfg_id debugfs entry Brandon Wyman
  2021-10-04 14:43 ` [PATCH 2/2] hwmon: (pmbus/ibm-cffps) Use MFR_ID to choose version Brandon Wyman
@ 2021-10-08 14:10 ` Guenter Roeck
  1 sibling, 0 replies; 4+ messages in thread
From: Guenter Roeck @ 2021-10-08 14:10 UTC (permalink / raw)
  To: Brandon Wyman
  Cc: linux-hwmon, Jean Delvare, openbmc, Eddie James, linux-kernel

On Mon, Oct 04, 2021 at 02:43:38PM +0000, Brandon Wyman wrote:
> Add support for the manufacturer ID to the debugfs entries.
> 
> Signed-off-by: Brandon Wyman <bjwyman@gmail.com>

Applied.

Thanks,
Guenter

> ---
>  drivers/hwmon/pmbus/ibm-cffps.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/hwmon/pmbus/ibm-cffps.c b/drivers/hwmon/pmbus/ibm-cffps.c
> index df712ce4b164..2ee47cbbb665 100644
> --- a/drivers/hwmon/pmbus/ibm-cffps.c
> +++ b/drivers/hwmon/pmbus/ibm-cffps.c
> @@ -18,6 +18,7 @@
>  
>  #include "pmbus.h"
>  
> +#define CFFPS_MFG_ID_CMD                        0x99
>  #define CFFPS_FRU_CMD				0x9A
>  #define CFFPS_PN_CMD				0x9B
>  #define CFFPS_HEADER_CMD			0x9C
> @@ -34,7 +35,7 @@
>  #define CFFPS_INPUT_HISTORY_SIZE		100
>  
>  #define CFFPS_CCIN_REVISION			GENMASK(7, 0)
> -#define  CFFPS_CCIN_REVISION_LEGACY		 0xde
> +#define CFFPS_CCIN_REVISION_LEGACY		 0xde
>  #define CFFPS_CCIN_VERSION			GENMASK(15, 8)
>  #define CFFPS_CCIN_VERSION_1			 0x2b
>  #define CFFPS_CCIN_VERSION_2			 0x2e
> @@ -57,6 +58,7 @@
>  
>  enum {
>  	CFFPS_DEBUGFS_INPUT_HISTORY = 0,
> +	CFFPS_DEBUGFS_MFG_ID,
>  	CFFPS_DEBUGFS_FRU,
>  	CFFPS_DEBUGFS_PN,
>  	CFFPS_DEBUGFS_HEADER,
> @@ -158,6 +160,9 @@ static ssize_t ibm_cffps_debugfs_read(struct file *file, char __user *buf,
>  	switch (idx) {
>  	case CFFPS_DEBUGFS_INPUT_HISTORY:
>  		return ibm_cffps_read_input_history(psu, buf, count, ppos);
> +	case CFFPS_DEBUGFS_MFG_ID:
> +		cmd = CFFPS_MFG_ID_CMD;
> +		break;
>  	case CFFPS_DEBUGFS_FRU:
>  		cmd = CFFPS_FRU_CMD;
>  		break;
> @@ -558,6 +563,9 @@ static int ibm_cffps_probe(struct i2c_client *client)
>  	debugfs_create_file("input_history", 0444, ibm_cffps_dir,
>  			    &psu->debugfs_entries[CFFPS_DEBUGFS_INPUT_HISTORY],
>  			    &ibm_cffps_fops);
> +	debugfs_create_file("mfg_id", 0444, ibm_cffps_dir,
> +			    &psu->debugfs_entries[CFFPS_DEBUGFS_MFG_ID],
> +			    &ibm_cffps_fops);
>  	debugfs_create_file("fru", 0444, ibm_cffps_dir,
>  			    &psu->debugfs_entries[CFFPS_DEBUGFS_FRU],
>  			    &ibm_cffps_fops);

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

* Re: [PATCH 2/2] hwmon: (pmbus/ibm-cffps) Use MFR_ID to choose version
  2021-10-04 14:43 ` [PATCH 2/2] hwmon: (pmbus/ibm-cffps) Use MFR_ID to choose version Brandon Wyman
@ 2021-10-08 14:12   ` Guenter Roeck
  0 siblings, 0 replies; 4+ messages in thread
From: Guenter Roeck @ 2021-10-08 14:12 UTC (permalink / raw)
  To: Brandon Wyman
  Cc: linux-hwmon, Jean Delvare, openbmc, Eddie James, linux-kernel

On Mon, Oct 04, 2021 at 02:43:39PM +0000, Brandon Wyman wrote:
> There are multiple power supplies that will indicate
> CFFPS_CCIN_VERSION_1, use the manufacturer ID to determine if it should
> be treated as version cffps1 or version cffps2.
> 
> Signed-off-by: Brandon Wyman <bjwyman@gmail.com>

Applied, after fixing continnuation line alignments.

Guenter

> ---
>  drivers/hwmon/pmbus/ibm-cffps.c | 15 ++++++++++++++-
>  1 file changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/hwmon/pmbus/ibm-cffps.c b/drivers/hwmon/pmbus/ibm-cffps.c
> index 2ee47cbbb665..292c87331f2b 100644
> --- a/drivers/hwmon/pmbus/ibm-cffps.c
> +++ b/drivers/hwmon/pmbus/ibm-cffps.c
> @@ -502,16 +502,29 @@ static int ibm_cffps_probe(struct i2c_client *client)
>  		u16 ccin_revision = 0;
>  		u16 ccin_version = CFFPS_CCIN_VERSION_1;
>  		int ccin = i2c_smbus_read_word_swapped(client, CFFPS_CCIN_CMD);
> +		char mfg_id[I2C_SMBUS_BLOCK_MAX + 2] = { 0 };
>  
>  		if (ccin > 0) {
>  			ccin_revision = FIELD_GET(CFFPS_CCIN_REVISION, ccin);
>  			ccin_version = FIELD_GET(CFFPS_CCIN_VERSION, ccin);
>  		}
>  
> +		rc = i2c_smbus_read_block_data(client, PMBUS_MFR_ID,
> +				mfg_id);
> +		if (rc < 0) {
> +			dev_err(&client->dev,
> +					"Failed to read Manufacturer ID\n");
> +			return rc;
> +		}
> +
>  		switch (ccin_version) {
>  		default:
>  		case CFFPS_CCIN_VERSION_1:
> -			vs = cffps1;
> +			if ((strncmp(mfg_id, "ACBE", 4) == 0) ||
> +					(strncmp(mfg_id, "ARTE", 4) == 0))
> +				vs = cffps1;
> +			else
> +				vs = cffps2;
>  			break;
>  		case CFFPS_CCIN_VERSION_2:
>  			vs = cffps2;

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

end of thread, other threads:[~2021-10-08 14:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-04 14:43 [PATCH 1/2] hwmon: (pmbus/ibm-cffps) Add mfg_id debugfs entry Brandon Wyman
2021-10-04 14:43 ` [PATCH 2/2] hwmon: (pmbus/ibm-cffps) Use MFR_ID to choose version Brandon Wyman
2021-10-08 14:12   ` Guenter Roeck
2021-10-08 14:10 ` [PATCH 1/2] hwmon: (pmbus/ibm-cffps) Add mfg_id debugfs entry 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).