mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-06 06:37:59 +00:00
hwmon: (pmbus/ibm-cffps) Add new manufacturer debugfs entries
Add support for a number of manufacturer-specific registers in the debugfs entries, as well as support to read and write the PMBUS_ON_OFF_CONFIG register through debugfs. Signed-off-by: Eddie James <eajames@linux.ibm.com> Link: https://lore.kernel.org/r/1576788607-13567-2-git-send-email-eajames@linux.ibm.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:
parent
cce209581a
commit
abe508b66d
1 changed files with 70 additions and 4 deletions
|
@ -20,7 +20,9 @@
|
||||||
|
|
||||||
#define CFFPS_FRU_CMD 0x9A
|
#define CFFPS_FRU_CMD 0x9A
|
||||||
#define CFFPS_PN_CMD 0x9B
|
#define CFFPS_PN_CMD 0x9B
|
||||||
|
#define CFFPS_HEADER_CMD 0x9C
|
||||||
#define CFFPS_SN_CMD 0x9E
|
#define CFFPS_SN_CMD 0x9E
|
||||||
|
#define CFFPS_MAX_POWER_OUT_CMD 0xA7
|
||||||
#define CFFPS_CCIN_CMD 0xBD
|
#define CFFPS_CCIN_CMD 0xBD
|
||||||
#define CFFPS_FW_CMD 0xFA
|
#define CFFPS_FW_CMD 0xFA
|
||||||
#define CFFPS1_FW_NUM_BYTES 4
|
#define CFFPS1_FW_NUM_BYTES 4
|
||||||
|
@ -57,9 +59,12 @@ enum {
|
||||||
CFFPS_DEBUGFS_INPUT_HISTORY = 0,
|
CFFPS_DEBUGFS_INPUT_HISTORY = 0,
|
||||||
CFFPS_DEBUGFS_FRU,
|
CFFPS_DEBUGFS_FRU,
|
||||||
CFFPS_DEBUGFS_PN,
|
CFFPS_DEBUGFS_PN,
|
||||||
|
CFFPS_DEBUGFS_HEADER,
|
||||||
CFFPS_DEBUGFS_SN,
|
CFFPS_DEBUGFS_SN,
|
||||||
|
CFFPS_DEBUGFS_MAX_POWER_OUT,
|
||||||
CFFPS_DEBUGFS_CCIN,
|
CFFPS_DEBUGFS_CCIN,
|
||||||
CFFPS_DEBUGFS_FW,
|
CFFPS_DEBUGFS_FW,
|
||||||
|
CFFPS_DEBUGFS_ON_OFF_CONFIG,
|
||||||
CFFPS_DEBUGFS_NUM_ENTRIES
|
CFFPS_DEBUGFS_NUM_ENTRIES
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -136,15 +141,15 @@ static ssize_t ibm_cffps_read_input_history(struct ibm_cffps *psu,
|
||||||
psu->input_history.byte_count);
|
psu->input_history.byte_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t ibm_cffps_debugfs_op(struct file *file, char __user *buf,
|
static ssize_t ibm_cffps_debugfs_read(struct file *file, char __user *buf,
|
||||||
size_t count, loff_t *ppos)
|
size_t count, loff_t *ppos)
|
||||||
{
|
{
|
||||||
u8 cmd;
|
u8 cmd;
|
||||||
int i, rc;
|
int i, rc;
|
||||||
int *idxp = file->private_data;
|
int *idxp = file->private_data;
|
||||||
int idx = *idxp;
|
int idx = *idxp;
|
||||||
struct ibm_cffps *psu = to_psu(idxp, idx);
|
struct ibm_cffps *psu = to_psu(idxp, idx);
|
||||||
char data[I2C_SMBUS_BLOCK_MAX] = { 0 };
|
char data[I2C_SMBUS_BLOCK_MAX + 2] = { 0 };
|
||||||
|
|
||||||
pmbus_set_page(psu->client, 0);
|
pmbus_set_page(psu->client, 0);
|
||||||
|
|
||||||
|
@ -157,9 +162,20 @@ static ssize_t ibm_cffps_debugfs_op(struct file *file, char __user *buf,
|
||||||
case CFFPS_DEBUGFS_PN:
|
case CFFPS_DEBUGFS_PN:
|
||||||
cmd = CFFPS_PN_CMD;
|
cmd = CFFPS_PN_CMD;
|
||||||
break;
|
break;
|
||||||
|
case CFFPS_DEBUGFS_HEADER:
|
||||||
|
cmd = CFFPS_HEADER_CMD;
|
||||||
|
break;
|
||||||
case CFFPS_DEBUGFS_SN:
|
case CFFPS_DEBUGFS_SN:
|
||||||
cmd = CFFPS_SN_CMD;
|
cmd = CFFPS_SN_CMD;
|
||||||
break;
|
break;
|
||||||
|
case CFFPS_DEBUGFS_MAX_POWER_OUT:
|
||||||
|
rc = i2c_smbus_read_word_swapped(psu->client,
|
||||||
|
CFFPS_MAX_POWER_OUT_CMD);
|
||||||
|
if (rc < 0)
|
||||||
|
return rc;
|
||||||
|
|
||||||
|
rc = snprintf(data, I2C_SMBUS_BLOCK_MAX, "%d", rc);
|
||||||
|
goto done;
|
||||||
case CFFPS_DEBUGFS_CCIN:
|
case CFFPS_DEBUGFS_CCIN:
|
||||||
rc = i2c_smbus_read_word_swapped(psu->client, CFFPS_CCIN_CMD);
|
rc = i2c_smbus_read_word_swapped(psu->client, CFFPS_CCIN_CMD);
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
|
@ -199,6 +215,14 @@ static ssize_t ibm_cffps_debugfs_op(struct file *file, char __user *buf,
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
}
|
}
|
||||||
goto done;
|
goto done;
|
||||||
|
case CFFPS_DEBUGFS_ON_OFF_CONFIG:
|
||||||
|
rc = i2c_smbus_read_byte_data(psu->client,
|
||||||
|
PMBUS_ON_OFF_CONFIG);
|
||||||
|
if (rc < 0)
|
||||||
|
return rc;
|
||||||
|
|
||||||
|
rc = snprintf(data, 3, "%02x", rc);
|
||||||
|
goto done;
|
||||||
default:
|
default:
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
@ -214,9 +238,42 @@ done:
|
||||||
return simple_read_from_buffer(buf, count, ppos, data, rc);
|
return simple_read_from_buffer(buf, count, ppos, data, rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static ssize_t ibm_cffps_debugfs_write(struct file *file,
|
||||||
|
const char __user *buf, size_t count,
|
||||||
|
loff_t *ppos)
|
||||||
|
{
|
||||||
|
u8 data;
|
||||||
|
ssize_t rc;
|
||||||
|
int *idxp = file->private_data;
|
||||||
|
int idx = *idxp;
|
||||||
|
struct ibm_cffps *psu = to_psu(idxp, idx);
|
||||||
|
|
||||||
|
switch (idx) {
|
||||||
|
case CFFPS_DEBUGFS_ON_OFF_CONFIG:
|
||||||
|
pmbus_set_page(psu->client, 0);
|
||||||
|
|
||||||
|
rc = simple_write_to_buffer(&data, 1, ppos, buf, count);
|
||||||
|
if (rc < 0)
|
||||||
|
return rc;
|
||||||
|
|
||||||
|
rc = i2c_smbus_write_byte_data(psu->client,
|
||||||
|
PMBUS_ON_OFF_CONFIG, data);
|
||||||
|
if (rc)
|
||||||
|
return rc;
|
||||||
|
|
||||||
|
rc = 1;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
static const struct file_operations ibm_cffps_fops = {
|
static const struct file_operations ibm_cffps_fops = {
|
||||||
.llseek = noop_llseek,
|
.llseek = noop_llseek,
|
||||||
.read = ibm_cffps_debugfs_op,
|
.read = ibm_cffps_debugfs_read,
|
||||||
|
.write = ibm_cffps_debugfs_write,
|
||||||
.open = simple_open,
|
.open = simple_open,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -486,15 +543,24 @@ static int ibm_cffps_probe(struct i2c_client *client,
|
||||||
debugfs_create_file("part_number", 0444, ibm_cffps_dir,
|
debugfs_create_file("part_number", 0444, ibm_cffps_dir,
|
||||||
&psu->debugfs_entries[CFFPS_DEBUGFS_PN],
|
&psu->debugfs_entries[CFFPS_DEBUGFS_PN],
|
||||||
&ibm_cffps_fops);
|
&ibm_cffps_fops);
|
||||||
|
debugfs_create_file("header", 0444, ibm_cffps_dir,
|
||||||
|
&psu->debugfs_entries[CFFPS_DEBUGFS_HEADER],
|
||||||
|
&ibm_cffps_fops);
|
||||||
debugfs_create_file("serial_number", 0444, ibm_cffps_dir,
|
debugfs_create_file("serial_number", 0444, ibm_cffps_dir,
|
||||||
&psu->debugfs_entries[CFFPS_DEBUGFS_SN],
|
&psu->debugfs_entries[CFFPS_DEBUGFS_SN],
|
||||||
&ibm_cffps_fops);
|
&ibm_cffps_fops);
|
||||||
|
debugfs_create_file("max_power_out", 0444, ibm_cffps_dir,
|
||||||
|
&psu->debugfs_entries[CFFPS_DEBUGFS_MAX_POWER_OUT],
|
||||||
|
&ibm_cffps_fops);
|
||||||
debugfs_create_file("ccin", 0444, ibm_cffps_dir,
|
debugfs_create_file("ccin", 0444, ibm_cffps_dir,
|
||||||
&psu->debugfs_entries[CFFPS_DEBUGFS_CCIN],
|
&psu->debugfs_entries[CFFPS_DEBUGFS_CCIN],
|
||||||
&ibm_cffps_fops);
|
&ibm_cffps_fops);
|
||||||
debugfs_create_file("fw_version", 0444, ibm_cffps_dir,
|
debugfs_create_file("fw_version", 0444, ibm_cffps_dir,
|
||||||
&psu->debugfs_entries[CFFPS_DEBUGFS_FW],
|
&psu->debugfs_entries[CFFPS_DEBUGFS_FW],
|
||||||
&ibm_cffps_fops);
|
&ibm_cffps_fops);
|
||||||
|
debugfs_create_file("on_off_config", 0644, ibm_cffps_dir,
|
||||||
|
&psu->debugfs_entries[CFFPS_DEBUGFS_ON_OFF_CONFIG],
|
||||||
|
&ibm_cffps_fops);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue