1
1
// SPDX-License-Identifier: GPL-2.0+
2
2
/*
3
- * Hardware monitoring driver for Intersil ISL68137
3
+ * Hardware monitoring driver for Renesas Digital Multiphase Voltage Regulators
4
4
*
5
5
* Copyright (c) 2017 Google Inc
6
+ * Copyright (c) 2020 Renesas Electronics America
6
7
*
7
8
*/
8
9
14
15
#include <linux/module.h>
15
16
#include <linux/string.h>
16
17
#include <linux/sysfs.h>
18
+
17
19
#include "pmbus.h"
18
20
19
21
#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
+ };
20
31
21
32
static ssize_t isl68137_avs_enable_show_page (struct i2c_client * client ,
22
33
int page ,
@@ -99,13 +110,31 @@ static const struct attribute_group enable_group = {
99
110
.attrs = enable_attrs ,
100
111
};
101
112
102
- static const struct attribute_group * attribute_groups [] = {
113
+ static const struct attribute_group * isl68137_attribute_groups [] = {
103
114
& enable_group ,
104
115
NULL ,
105
116
};
106
117
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 ,
109
138
.format [PSC_VOLTAGE_IN ] = direct ,
110
139
.format [PSC_VOLTAGE_OUT ] = direct ,
111
140
.format [PSC_CURRENT_IN ] = direct ,
@@ -114,7 +143,7 @@ static struct pmbus_driver_info isl68137_info = {
114
143
.format [PSC_TEMPERATURE ] = direct ,
115
144
.m [PSC_VOLTAGE_IN ] = 1 ,
116
145
.b [PSC_VOLTAGE_IN ] = 0 ,
117
- .R [PSC_VOLTAGE_IN ] = 3 ,
146
+ .R [PSC_VOLTAGE_IN ] = 2 ,
118
147
.m [PSC_VOLTAGE_OUT ] = 1 ,
119
148
.b [PSC_VOLTAGE_OUT ] = 0 ,
120
149
.R [PSC_VOLTAGE_OUT ] = 3 ,
@@ -134,24 +163,76 @@ static struct pmbus_driver_info isl68137_info = {
134
163
| PMBUS_HAVE_STATUS_INPUT | PMBUS_HAVE_TEMP | PMBUS_HAVE_TEMP2
135
164
| PMBUS_HAVE_TEMP3 | PMBUS_HAVE_STATUS_TEMP
136
165
| 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 ,
141
176
};
142
177
143
178
static int isl68137_probe (struct i2c_client * client ,
144
179
const struct i2c_device_id * id )
145
180
{
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 );
147
224
}
148
225
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 },
151
232
{}
152
233
};
153
234
154
- MODULE_DEVICE_TABLE (i2c , isl68137_id );
235
+ MODULE_DEVICE_TABLE (i2c , raa_dmpvr_id );
155
236
156
237
/* This is the driver that will be inserted */
157
238
static struct i2c_driver isl68137_driver = {
@@ -160,11 +241,11 @@ static struct i2c_driver isl68137_driver = {
160
241
},
161
242
.probe = isl68137_probe ,
162
243
.remove = pmbus_do_remove ,
163
- .id_table = isl68137_id ,
244
+ .id_table = raa_dmpvr_id ,
164
245
};
165
246
166
247
module_i2c_driver (isl68137_driver );
167
248
168
249
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 " );
170
251
MODULE_LICENSE ("GPL" );
0 commit comments