| From 6b627b0ff2a29aa6f9172d906899e691ba99e733 Mon Sep 17 00:00:00 2001 |
| From: Shao-Chieh <jieh.sc.chao@fii-na.corp-partner.google.com> |
| Date: Mon, 4 Aug 2025 09:42:11 +0800 |
| Subject: [PATCH] Add PWM Rate-of-Change configuration |
| |
| --- |
| drivers/hwmon/max31790.c | 22 +++++++++++++++++++++- |
| 1 file changed, 21 insertions(+), 1 deletion(-) |
| |
| diff --git a/drivers/hwmon/max31790.c b/drivers/hwmon/max31790.c |
| index 0cd44c1e9..890d1f614 100644 |
| --- a/drivers/hwmon/max31790.c |
| +++ b/drivers/hwmon/max31790.c |
| @@ -483,7 +483,9 @@ static const struct hwmon_chip_info max31790_chip_info = { |
| static int max31790_init_client(struct i2c_client *client, |
| struct max31790_data *data) |
| { |
| - int i, rv; |
| + int i, rv, err; |
| + struct device *dev = &client->dev; |
| + u32 val; |
| |
| for (i = 0; i < NR_CHANNEL; i++) { |
| rv = i2c_smbus_read_byte_data(client, |
| @@ -492,6 +494,17 @@ static int max31790_init_client(struct i2c_client *client, |
| return rv; |
| data->fan_config[i] = rv; |
| |
| + if (device_property_read_u32(dev, "pwm-rate-of-change", &val) == 0) { |
| + rv = i2c_smbus_read_byte_data(client, MAX31790_REG_FAN_DYNAMICS(i)); |
| + if (rv < 0) |
| + return rv; |
| + rv &= ~0x1C; |
| + rv |= (val & 0x7) << 2; |
| + err = i2c_smbus_write_byte_data(client, MAX31790_REG_FAN_DYNAMICS(i), rv); |
| + if (err < 0) |
| + return err; |
| + } |
| + |
| rv = i2c_smbus_read_byte_data(client, |
| MAX31790_REG_FAN_DYNAMICS(i)); |
| if (rv < 0) |
| @@ -542,11 +555,18 @@ static const struct i2c_device_id max31790_id[] = { |
| }; |
| MODULE_DEVICE_TABLE(i2c, max31790_id); |
| |
| +static const struct of_device_id max31790_of_match[] = { |
| + { .compatible = "maxim,max31790" }, |
| + { } |
| +}; |
| +MODULE_DEVICE_TABLE(of, max31790_of_match); |
| + |
| static struct i2c_driver max31790_driver = { |
| .class = I2C_CLASS_HWMON, |
| .probe = max31790_probe, |
| .driver = { |
| .name = "max31790", |
| + .of_match_table = max31790_of_match, |
| }, |
| .id_table = max31790_id, |
| }; |
| -- |
| 2.34.1 |
| |