diff options
Diffstat (limited to 'drivers/hwmon/pmbus/ibm-cffps.c')
-rw-r--r-- | drivers/hwmon/pmbus/ibm-cffps.c | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/drivers/hwmon/pmbus/ibm-cffps.c b/drivers/hwmon/pmbus/ibm-cffps.c index df712ce4b164..e3294a1a54bb 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; @@ -171,8 +176,14 @@ static ssize_t ibm_cffps_debugfs_read(struct file *file, char __user *buf, cmd = CFFPS_SN_CMD; break; case CFFPS_DEBUGFS_MAX_POWER_OUT: - rc = i2c_smbus_read_word_swapped(psu->client, - CFFPS_MAX_POWER_OUT_CMD); + if (psu->version == cffps1) { + rc = i2c_smbus_read_word_swapped(psu->client, + CFFPS_MAX_POWER_OUT_CMD); + } else { + rc = i2c_smbus_read_word_data(psu->client, + CFFPS_MAX_POWER_OUT_CMD); + } + if (rc < 0) return rc; @@ -497,16 +508,27 @@ 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; @@ -558,6 +580,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); |