diff options
author | Andrew Jeffery <andrew@aj.id.au> | 2020-09-10 11:41:06 +0930 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2020-09-23 09:42:41 -0700 |
commit | 2cd8529cfb28eb9bc392a8a36c66dd318aafd49d (patch) | |
tree | 91ee8b2d5d0a5eba455dcbdf174f76058840925b /drivers/hwmon | |
parent | a919ba06979a7858dab65492eb580121ccbd524f (diff) | |
download | linux-stable-2cd8529cfb28eb9bc392a8a36c66dd318aafd49d.tar.gz linux-stable-2cd8529cfb28eb9bc392a8a36c66dd318aafd49d.tar.bz2 linux-stable-2cd8529cfb28eb9bc392a8a36c66dd318aafd49d.zip |
hwmon: (pmbus) Expose PEC debugfs attribute
Enable runtime debug control of whether the PEC byte is exchanged with
the PMBus device.
Some manufacturers have asked for the PEC to be disabled as part of
debugging driver communication issues with devices.
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Link: https://lore.kernel.org/r/20200910021106.2958382-1-andrew@aj.id.au
[groeck: Replace %1llu with %llu]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r-- | drivers/hwmon/pmbus/pmbus_core.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c index 1f43bf0f23b2..138f83538c8b 100644 --- a/drivers/hwmon/pmbus/pmbus_core.c +++ b/drivers/hwmon/pmbus/pmbus_core.c @@ -2351,6 +2351,42 @@ static int pmbus_debugfs_get_status(void *data, u64 *val) DEFINE_DEBUGFS_ATTRIBUTE(pmbus_debugfs_ops_status, pmbus_debugfs_get_status, NULL, "0x%04llx\n"); +static int pmbus_debugfs_get_pec(void *data, u64 *val) +{ + struct i2c_client *client = data; + + *val = !!(client->flags & I2C_CLIENT_PEC); + + return 0; +} + +static int pmbus_debugfs_set_pec(void *data, u64 val) +{ + int rc; + struct i2c_client *client = data; + + if (!val) { + client->flags &= ~I2C_CLIENT_PEC; + return 0; + } + + if (val != 1) + return -EINVAL; + + rc = i2c_smbus_read_byte_data(client, PMBUS_CAPABILITY); + if (rc < 0) + return rc; + + if (!(rc & PB_CAPABILITY_ERROR_CHECK)) + return -EOPNOTSUPP; + + client->flags |= I2C_CLIENT_PEC; + + return 0; +} +DEFINE_DEBUGFS_ATTRIBUTE(pmbus_debugfs_ops_pec, pmbus_debugfs_get_pec, + pmbus_debugfs_set_pec, "%llu\n"); + static int pmbus_init_debugfs(struct i2c_client *client, struct pmbus_data *data) { @@ -2379,6 +2415,9 @@ static int pmbus_init_debugfs(struct i2c_client *client, if (!entries) return -ENOMEM; + debugfs_create_file("pec", 0664, data->debugfs, client, + &pmbus_debugfs_ops_pec); + for (i = 0; i < data->info->pages; ++i) { /* Check accessibility of status register if it's not page 0 */ if (!i || pmbus_check_status_register(client, i)) { |