diff options
| author | Jerome Brunet <jbrunet@baylibre.com> | 2024-12-02 11:28:01 +0100 |
|---|---|---|
| committer | Guenter Roeck <linux@roeck-us.net> | 2024-12-14 08:00:44 -0800 |
| commit | 83bed3c159f44bf2e205875feb8d932bbcf1b656 (patch) | |
| tree | 12fb9fbc711d6d8d068efbc4c9361375c09623dd /drivers/hwmon | |
| parent | hwmon: (pmbus/core) improve handling of write protected regulators (diff) | |
| download | linux-83bed3c159f44bf2e205875feb8d932bbcf1b656.tar.gz linux-83bed3c159f44bf2e205875feb8d932bbcf1b656.zip | |
hwmon: (pmbus/core) add wp module param
Add a module parameter to force the write protection mode of pmbus chips.
4 protections modes are provided to start with:
* 0: Remove the write protection
* 1: Disable all writes except to the WRITE_PROTECT, OPERATION,
PAGE, ON_OFF_CONFIG and VOUT_COMMAND commands
* 2: Disable all writes except to the WRITE_PROTECT, OPERATION and
PAGE commands
* 3: Disable all writes except to the WRITE_PROTECT command
Of course, if the parameter is not provided, the default write protection
status of the pmbus chips is left untouched.
Suggested-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon')
| -rw-r--r-- | drivers/hwmon/pmbus/pmbus_core.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c index 5976dd819b3c..a7000314e5ad 100644 --- a/drivers/hwmon/pmbus/pmbus_core.c +++ b/drivers/hwmon/pmbus/pmbus_core.c @@ -31,6 +31,9 @@ #define PMBUS_ATTR_ALLOC_SIZE 32 #define PMBUS_NAME_SIZE 24 +static int wp = -1; +module_param(wp, int, 0444); + struct pmbus_sensor { struct pmbus_sensor *next; char name[PMBUS_NAME_SIZE]; /* sysfs sensor name */ @@ -2669,6 +2672,32 @@ static void pmbus_init_wp(struct i2c_client *client, struct pmbus_data *data) { int ret; + switch (wp) { + case 0: + _pmbus_write_byte_data(client, -1, + PMBUS_WRITE_PROTECT, 0); + break; + + case 1: + _pmbus_write_byte_data(client, -1, + PMBUS_WRITE_PROTECT, PB_WP_VOUT); + break; + + case 2: + _pmbus_write_byte_data(client, -1, + PMBUS_WRITE_PROTECT, PB_WP_OP); + break; + + case 3: + _pmbus_write_byte_data(client, -1, + PMBUS_WRITE_PROTECT, PB_WP_ALL); + break; + + default: + /* Ignore the other values */ + break; + } + ret = _pmbus_read_byte_data(client, -1, PMBUS_WRITE_PROTECT); if (ret < 0) return; |
