Skip to content

Commit f621d61

Browse files
gfpeltiergroeck
authored andcommitted
hwmon: (pmbus) add support for 2nd Gen Renesas digital multiphase
Extend the isl68137 driver to provide support for 2nd generation Renesas digital multiphase voltage regulators. Signed-off-by: Grant Peltier <[email protected]> Link: https://lore.kernel.org/r/62c000adf0108aeb65d3f275f28eb26b690384aa.1584720563.git.grantpeltier93@gmail.com [groeck: Adjusted for new PMBus API function parameters] Signed-off-by: Guenter Roeck <[email protected]>
1 parent b1fbe67 commit f621d61

File tree

2 files changed

+99
-18
lines changed

2 files changed

+99
-18
lines changed

drivers/hwmon/pmbus/Kconfig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ config SENSORS_IRPS5401
9292
be called irps5401.
9393

9494
config SENSORS_ISL68137
95-
tristate "Intersil ISL68137"
95+
tristate "Renesas Digital Multiphase Voltage Regulators"
9696
help
97-
If you say yes here you get hardware monitoring support for Intersil
98-
ISL68137.
97+
If you say yes here you get hardware monitoring support for Renesas
98+
digital multiphase voltage regulators.
9999

100100
This driver can also be built as a module. If so, the module will
101101
be called isl68137.

drivers/hwmon/pmbus/isl68137.c

Lines changed: 96 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
// SPDX-License-Identifier: GPL-2.0+
22
/*
3-
* Hardware monitoring driver for Intersil ISL68137
3+
* Hardware monitoring driver for Renesas Digital Multiphase Voltage Regulators
44
*
55
* Copyright (c) 2017 Google Inc
6+
* Copyright (c) 2020 Renesas Electronics America
67
*
78
*/
89

@@ -14,9 +15,19 @@
1415
#include <linux/module.h>
1516
#include <linux/string.h>
1617
#include <linux/sysfs.h>
18+
1719
#include "pmbus.h"
1820

1921
#define ISL68137_VOUT_AVS 0x30
22+
#define RAA_DMPVR2_READ_VMON 0xc8
23+
24+
enum versions {
25+
isl68137,
26+
raa_dmpvr2_1rail,
27+
raa_dmpvr2_2rail,
28+
raa_dmpvr2_3rail,
29+
raa_dmpvr2_hv,
30+
};
2031

2132
static ssize_t isl68137_avs_enable_show_page(struct i2c_client *client,
2233
int page,
@@ -99,13 +110,31 @@ static const struct attribute_group enable_group = {
99110
.attrs = enable_attrs,
100111
};
101112

102-
static const struct attribute_group *attribute_groups[] = {
113+
static const struct attribute_group *isl68137_attribute_groups[] = {
103114
&enable_group,
104115
NULL,
105116
};
106117

107-
static struct pmbus_driver_info isl68137_info = {
108-
.pages = 2,
118+
static int raa_dmpvr2_read_word_data(struct i2c_client *client, int page,
119+
int phase, int reg)
120+
{
121+
int ret;
122+
123+
switch (reg) {
124+
case PMBUS_VIRT_READ_VMON:
125+
ret = pmbus_read_word_data(client, page, phase,
126+
RAA_DMPVR2_READ_VMON);
127+
break;
128+
default:
129+
ret = -ENODATA;
130+
break;
131+
}
132+
133+
return ret;
134+
}
135+
136+
static struct pmbus_driver_info raa_dmpvr_info = {
137+
.pages = 3,
109138
.format[PSC_VOLTAGE_IN] = direct,
110139
.format[PSC_VOLTAGE_OUT] = direct,
111140
.format[PSC_CURRENT_IN] = direct,
@@ -114,7 +143,7 @@ static struct pmbus_driver_info isl68137_info = {
114143
.format[PSC_TEMPERATURE] = direct,
115144
.m[PSC_VOLTAGE_IN] = 1,
116145
.b[PSC_VOLTAGE_IN] = 0,
117-
.R[PSC_VOLTAGE_IN] = 3,
146+
.R[PSC_VOLTAGE_IN] = 2,
118147
.m[PSC_VOLTAGE_OUT] = 1,
119148
.b[PSC_VOLTAGE_OUT] = 0,
120149
.R[PSC_VOLTAGE_OUT] = 3,
@@ -134,24 +163,76 @@ static struct pmbus_driver_info isl68137_info = {
134163
| PMBUS_HAVE_STATUS_INPUT | PMBUS_HAVE_TEMP | PMBUS_HAVE_TEMP2
135164
| PMBUS_HAVE_TEMP3 | PMBUS_HAVE_STATUS_TEMP
136165
| PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
137-
| PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT | PMBUS_HAVE_POUT,
138-
.func[1] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
139-
| PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT | PMBUS_HAVE_POUT,
140-
.groups = attribute_groups,
166+
| PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT | PMBUS_HAVE_POUT
167+
| PMBUS_HAVE_VMON,
168+
.func[1] = PMBUS_HAVE_IIN | PMBUS_HAVE_PIN | PMBUS_HAVE_STATUS_INPUT
169+
| PMBUS_HAVE_TEMP | PMBUS_HAVE_TEMP3 | PMBUS_HAVE_STATUS_TEMP
170+
| PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT | PMBUS_HAVE_IOUT
171+
| PMBUS_HAVE_STATUS_IOUT | PMBUS_HAVE_POUT,
172+
.func[2] = PMBUS_HAVE_IIN | PMBUS_HAVE_PIN | PMBUS_HAVE_STATUS_INPUT
173+
| PMBUS_HAVE_TEMP | PMBUS_HAVE_TEMP3 | PMBUS_HAVE_STATUS_TEMP
174+
| PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT | PMBUS_HAVE_IOUT
175+
| PMBUS_HAVE_STATUS_IOUT | PMBUS_HAVE_POUT,
141176
};
142177

143178
static int isl68137_probe(struct i2c_client *client,
144179
const struct i2c_device_id *id)
145180
{
146-
return pmbus_do_probe(client, id, &isl68137_info);
181+
struct pmbus_driver_info *info;
182+
183+
info = devm_kzalloc(&client->dev, sizeof(*info), GFP_KERNEL);
184+
if (!info)
185+
return -ENOMEM;
186+
memcpy(info, &raa_dmpvr_info, sizeof(*info));
187+
188+
switch (id->driver_data) {
189+
case isl68137:
190+
info->pages = 2;
191+
info->R[PSC_VOLTAGE_IN] = 3;
192+
info->func[0] &= ~PMBUS_HAVE_VMON;
193+
info->func[1] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
194+
| PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT
195+
| PMBUS_HAVE_POUT;
196+
info->groups = isl68137_attribute_groups;
197+
break;
198+
case raa_dmpvr2_1rail:
199+
info->pages = 1;
200+
info->read_word_data = raa_dmpvr2_read_word_data;
201+
break;
202+
case raa_dmpvr2_2rail:
203+
info->pages = 2;
204+
info->read_word_data = raa_dmpvr2_read_word_data;
205+
break;
206+
case raa_dmpvr2_3rail:
207+
info->read_word_data = raa_dmpvr2_read_word_data;
208+
break;
209+
case raa_dmpvr2_hv:
210+
info->pages = 1;
211+
info->R[PSC_VOLTAGE_IN] = 1;
212+
info->m[PSC_VOLTAGE_OUT] = 2;
213+
info->R[PSC_VOLTAGE_OUT] = 2;
214+
info->m[PSC_CURRENT_IN] = 2;
215+
info->m[PSC_POWER] = 2;
216+
info->R[PSC_POWER] = -1;
217+
info->read_word_data = raa_dmpvr2_read_word_data;
218+
break;
219+
default:
220+
return -ENODEV;
221+
}
222+
223+
return pmbus_do_probe(client, id, info);
147224
}
148225

149-
static const struct i2c_device_id isl68137_id[] = {
150-
{"isl68137", 0},
226+
static const struct i2c_device_id raa_dmpvr_id[] = {
227+
{"isl68137", isl68137},
228+
{"raa_dmpvr2_1rail", raa_dmpvr2_1rail},
229+
{"raa_dmpvr2_2rail", raa_dmpvr2_2rail},
230+
{"raa_dmpvr2_3rail", raa_dmpvr2_3rail},
231+
{"raa_dmpvr2_hv", raa_dmpvr2_hv},
151232
{}
152233
};
153234

154-
MODULE_DEVICE_TABLE(i2c, isl68137_id);
235+
MODULE_DEVICE_TABLE(i2c, raa_dmpvr_id);
155236

156237
/* This is the driver that will be inserted */
157238
static struct i2c_driver isl68137_driver = {
@@ -160,11 +241,11 @@ static struct i2c_driver isl68137_driver = {
160241
},
161242
.probe = isl68137_probe,
162243
.remove = pmbus_do_remove,
163-
.id_table = isl68137_id,
244+
.id_table = raa_dmpvr_id,
164245
};
165246

166247
module_i2c_driver(isl68137_driver);
167248

168249
MODULE_AUTHOR("Maxim Sloyko <[email protected]>");
169-
MODULE_DESCRIPTION("PMBus driver for Intersil ISL68137");
250+
MODULE_DESCRIPTION("PMBus driver for Renesas digital multiphase voltage regulators");
170251
MODULE_LICENSE("GPL");

0 commit comments

Comments
 (0)