Source
204
204
.mask_base = TPS65218_REG_INT_MASK1,
205
205
.status_base = TPS65218_REG_INT1,
206
206
};
207
207
208
208
static const struct of_device_id of_tps65218_match_table[] = {
209
209
{ .compatible = "ti,tps65218", },
210
210
{}
211
211
};
212
212
MODULE_DEVICE_TABLE(of, of_tps65218_match_table);
213
213
214
+
static int tps65218_voltage_set_strict(struct tps65218 *tps)
215
+
{
216
+
u32 strict;
217
+
218
+
if (of_property_read_u32(tps->dev->of_node,
219
+
"ti,strict-supply-voltage-supervision",
220
+
&strict))
221
+
return 0;
222
+
223
+
if (strict != 0 && strict != 1) {
224
+
dev_err(tps->dev,
225
+
"Invalid ti,strict-supply-voltage-supervision value\n");
226
+
return -EINVAL;
227
+
}
228
+
229
+
tps65218_update_bits(tps, TPS65218_REG_CONFIG1,
230
+
TPS65218_CONFIG1_STRICT,
231
+
strict ? TPS65218_CONFIG1_STRICT : 0,
232
+
TPS65218_PROTECT_L1);
233
+
return 0;
234
+
}
235
+
236
+
static int tps65218_voltage_set_uv_hyst(struct tps65218 *tps)
237
+
{
238
+
u32 hyst;
239
+
240
+
if (of_property_read_u32(tps->dev->of_node,
241
+
"ti,under-voltage-hyst-microvolt", &hyst))
242
+
return 0;
243
+
244
+
if (hyst != 400000 && hyst != 200000) {
245
+
dev_err(tps->dev,
246
+
"Invalid ti,under-voltage-hyst-microvolt value\n");
247
+
return -EINVAL;
248
+
}
249
+
250
+
tps65218_update_bits(tps, TPS65218_REG_CONFIG2,
251
+
TPS65218_CONFIG2_UVLOHYS,
252
+
hyst == 400000 ? TPS65218_CONFIG2_UVLOHYS : 0,
253
+
TPS65218_PROTECT_L1);
254
+
return 0;
255
+
}
256
+
257
+
static int tps65218_voltage_set_uvlo(struct tps65218 *tps)
258
+
{
259
+
u32 uvlo;
260
+
int uvloval;
261
+
262
+
if (of_property_read_u32(tps->dev->of_node,
263
+
"ti,under-voltage-limit-microvolt", &uvlo))
264
+
return 0;
265
+
266
+
switch (uvlo) {
267
+
case 2750000:
268
+
uvloval = TPS65218_CONFIG1_UVLO_2750000;
269
+
break;
270
+
case 2950000:
271
+
uvloval = TPS65218_CONFIG1_UVLO_2950000;
272
+
break;
273
+
case 3250000:
274
+
uvloval = TPS65218_CONFIG1_UVLO_3250000;
275
+
break;
276
+
case 3350000:
277
+
uvloval = TPS65218_CONFIG1_UVLO_3350000;
278
+
break;
279
+
default:
280
+
dev_err(tps->dev,
281
+
"Invalid ti,under-voltage-limit-microvolt value\n");
282
+
return -EINVAL;
283
+
}
284
+
285
+
tps65218_update_bits(tps, TPS65218_REG_CONFIG1,
286
+
TPS65218_CONFIG1_UVLO_MASK, uvloval,
287
+
TPS65218_PROTECT_L1);
288
+
return 0;
289
+
}
290
+
214
291
static int tps65218_probe(struct i2c_client *client,
215
292
const struct i2c_device_id *ids)
216
293
{
217
294
struct tps65218 *tps;
218
295
int ret;
219
296
unsigned int chipid;
220
297
221
298
tps = devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL);
222
299
if (!tps)
223
300
return -ENOMEM;
242
319
return ret;
243
320
244
321
ret = regmap_read(tps->regmap, TPS65218_REG_CHIPID, &chipid);
245
322
if (ret) {
246
323
dev_err(tps->dev, "Failed to read chipid: %d\n", ret);
247
324
return ret;
248
325
}
249
326
250
327
tps->rev = chipid & TPS65218_CHIPID_REV_MASK;
251
328
329
+
ret = tps65218_voltage_set_strict(tps);
330
+
if (ret)
331
+
return ret;
332
+
333
+
ret = tps65218_voltage_set_uvlo(tps);
334
+
if (ret)
335
+
return ret;
336
+
337
+
ret = tps65218_voltage_set_uv_hyst(tps);
338
+
if (ret)
339
+
return ret;
340
+
252
341
ret = mfd_add_devices(tps->dev, PLATFORM_DEVID_AUTO, tps65218_cells,
253
342
ARRAY_SIZE(tps65218_cells), NULL, 0,
254
343
regmap_irq_get_domain(tps->irq_data));
255
344
256
345
return ret;
257
346
}
258
347
259
348
static const struct i2c_device_id tps65218_id_table[] = {
260
349
{ "tps65218", TPS65218 },
261
350
{ },