16
16
#include "pmbus.h"
17
17
18
18
enum chips {
19
- tps53647 , tps53667 , tps53676 , tps53679 , tps53681 , tps53688
19
+ tps53647 , tps53667 , tps53676 , tps53679 , tps53681 , tps53685 , tps53688
20
20
};
21
21
22
22
#define TPS53647_PAGE_NUM 1
@@ -31,7 +31,8 @@ enum chips {
31
31
#define TPS53679_PROT_VR13_5MV 0x07 /* VR13.0 mode, 5-mV DAC */
32
32
#define TPS53679_PAGE_NUM 2
33
33
34
- #define TPS53681_DEVICE_ID 0x81
34
+ #define TPS53681_DEVICE_ID "\x81"
35
+ #define TPS53685_DEVICE_ID "TIShP"
35
36
36
37
#define TPS53681_PMBUS_REVISION 0x33
37
38
@@ -86,10 +87,12 @@ static int tps53679_identify_phases(struct i2c_client *client,
86
87
}
87
88
88
89
static int tps53679_identify_chip (struct i2c_client * client ,
89
- u8 revision , u16 id )
90
+ u8 revision , char * id )
90
91
{
91
92
u8 buf [I2C_SMBUS_BLOCK_MAX ];
92
93
int ret ;
94
+ int buf_len ;
95
+ int id_len ;
93
96
94
97
ret = pmbus_read_byte_data (client , 0 , PMBUS_REVISION );
95
98
if (ret < 0 )
@@ -102,8 +105,14 @@ static int tps53679_identify_chip(struct i2c_client *client,
102
105
ret = i2c_smbus_read_block_data (client , PMBUS_IC_DEVICE_ID , buf );
103
106
if (ret < 0 )
104
107
return ret ;
105
- if (ret != 1 || buf [0 ] != id ) {
106
- dev_err (& client -> dev , "Unexpected device ID 0x%x\n" , buf [0 ]);
108
+
109
+ /* Adjust length if null terminator if present */
110
+ buf_len = (buf [ret - 1 ] != '\x00' ? ret : ret - 1 );
111
+
112
+ id_len = strlen (id );
113
+
114
+ if (buf_len != id_len || strncmp (id , buf , id_len )) {
115
+ dev_err (& client -> dev , "Unexpected device ID: %*ph\n" , ret , buf );
107
116
return - ENODEV ;
108
117
}
109
118
return 0 ;
@@ -117,7 +126,7 @@ static int tps53679_identify_chip(struct i2c_client *client,
117
126
*/
118
127
static int tps53679_identify_multiphase (struct i2c_client * client ,
119
128
struct pmbus_driver_info * info ,
120
- int pmbus_rev , int device_id )
129
+ int pmbus_rev , char * device_id )
121
130
{
122
131
int ret ;
123
132
@@ -138,6 +147,16 @@ static int tps53679_identify(struct i2c_client *client,
138
147
return tps53679_identify_mode (client , info );
139
148
}
140
149
150
+ static int tps53685_identify (struct i2c_client * client ,
151
+ struct pmbus_driver_info * info )
152
+ {
153
+ info -> func [1 ] |= PMBUS_HAVE_VIN | PMBUS_HAVE_IIN | PMBUS_HAVE_PIN |
154
+ PMBUS_HAVE_STATUS_INPUT ;
155
+ info -> format [PSC_VOLTAGE_OUT ] = linear ;
156
+ return tps53679_identify_chip (client , TPS53681_PMBUS_REVISION ,
157
+ TPS53685_DEVICE_ID );
158
+ }
159
+
141
160
static int tps53681_identify (struct i2c_client * client ,
142
161
struct pmbus_driver_info * info )
143
162
{
@@ -263,6 +282,10 @@ static int tps53679_probe(struct i2c_client *client)
263
282
info -> identify = tps53681_identify ;
264
283
info -> read_word_data = tps53681_read_word_data ;
265
284
break ;
285
+ case tps53685 :
286
+ info -> pages = TPS53679_PAGE_NUM ;
287
+ info -> identify = tps53685_identify ;
288
+ break ;
266
289
default :
267
290
return - ENODEV ;
268
291
}
@@ -277,6 +300,7 @@ static const struct i2c_device_id tps53679_id[] = {
277
300
{"tps53676" , tps53676 },
278
301
{"tps53679" , tps53679 },
279
302
{"tps53681" , tps53681 },
303
+ {"tps53685" , tps53685 },
280
304
{"tps53688" , tps53688 },
281
305
{}
282
306
};
@@ -289,6 +313,7 @@ static const struct of_device_id __maybe_unused tps53679_of_match[] = {
289
313
{.compatible = "ti,tps53676" , .data = (void * )tps53676 },
290
314
{.compatible = "ti,tps53679" , .data = (void * )tps53679 },
291
315
{.compatible = "ti,tps53681" , .data = (void * )tps53681 },
316
+ {.compatible = "ti,tps53685" , .data = (void * )tps53685 },
292
317
{.compatible = "ti,tps53688" , .data = (void * )tps53688 },
293
318
{}
294
319
};
0 commit comments