Skip to content

Commit d57f728

Browse files
chris2511Lee Jones
authored andcommitted
mfd: tps65218.c: Add input voltage options
These options apply to all regulators in this chip. ti,strict-supply-voltage-supervision: Set STRICT flag in CONFIG1 ti,under-voltage-limit-microvolt: Select 2.75, 2.95, 3.25 or 3.35 V UVLO in CONFIG1 ti,under-voltage-hyst-microvolt: Select 200mV or 400mV UVLOHYS in CONFIG2 Signed-off-by: Christian Hohnstaedt <Christian.Hohnstaedt@wago.com> Tested-by: Keerthy <j-keerthy@ti.com> Reviewed-by: Keerthy <j-keerthy@ti.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
1 parent b2b6587 commit d57f728

2 files changed

Lines changed: 93 additions & 0 deletions

File tree

‎drivers/mfd/tps65218.c‎

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,83 @@ static const struct of_device_id of_tps65218_match_table[] = {
211211
};
212212
MODULE_DEVICE_TABLE(of, of_tps65218_match_table);
213213

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+
214291
static int tps65218_probe(struct i2c_client *client,
215292
const struct i2c_device_id *ids)
216293
{
@@ -249,6 +326,18 @@ static int tps65218_probe(struct i2c_client *client,
249326

250327
tps->rev = chipid & TPS65218_CHIPID_REV_MASK;
251328

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+
252341
ret = mfd_add_devices(tps->dev, PLATFORM_DEVID_AUTO, tps65218_cells,
253342
ARRAY_SIZE(tps65218_cells), NULL, 0,
254343
regmap_irq_get_domain(tps->irq_data));

‎include/linux/mfd/tps65218.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@
137137
#define TPS65218_CONFIG1_PGDLY_MASK 0x18
138138
#define TPS65218_CONFIG1_STRICT BIT(2)
139139
#define TPS65218_CONFIG1_UVLO_MASK 0x3
140+
#define TPS65218_CONFIG1_UVLO_2750000 0x0
141+
#define TPS65218_CONFIG1_UVLO_2950000 0x1
142+
#define TPS65218_CONFIG1_UVLO_3250000 0x2
143+
#define TPS65218_CONFIG1_UVLO_3350000 0x3
140144

141145
#define TPS65218_CONFIG2_DC12_RST BIT(7)
142146
#define TPS65218_CONFIG2_UVLOHYS BIT(6)

0 commit comments

Comments
 (0)