Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Christian Hohnstaedt and committed by
Lee Jones
d57f7287 b2b65875

+93
+89
drivers/mfd/tps65218.c
··· 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 { ··· 325 248 } 326 249 327 250 tps->rev = chipid & TPS65218_CHIPID_REV_MASK; 251 + 252 + ret = tps65218_voltage_set_strict(tps); 253 + if (ret) 254 + return ret; 255 + 256 + ret = tps65218_voltage_set_uvlo(tps); 257 + if (ret) 258 + return ret; 259 + 260 + ret = tps65218_voltage_set_uv_hyst(tps); 261 + if (ret) 262 + return ret; 328 263 329 264 ret = mfd_add_devices(tps->dev, PLATFORM_DEVID_AUTO, tps65218_cells, 330 265 ARRAY_SIZE(tps65218_cells), NULL, 0,
+4
include/linux/mfd/tps65218.h
··· 137 137 #define TPS65218_CONFIG1_PGDLY_MASK 0x18 138 138 #define TPS65218_CONFIG1_STRICT BIT(2) 139 139 #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 140 144 141 145 #define TPS65218_CONFIG2_DC12_RST BIT(7) 142 146 #define TPS65218_CONFIG2_UVLOHYS BIT(6)