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

power: supply: bq256xx: Apply TS_IGNORE from devicetree

TS_IGNORE is default off in bq256xx chip. For some HW which doesn't have
the NTC, we need to set TS_IGNORE to 1 to make the charge work. The new
"ti,no-thermistor" is introduced to toggle it.

Signed-off-by: Hermes Zhang <chenhuiz@axis.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>

authored by

Hermes Zhang and committed by
Sebastian Reichel
131c0c76 da8a240f

+28
+28
drivers/power/supply/bq256xx_charger.c
··· 41 41 #define BQ256XX_IINDPM_MAX_uA 3200000 42 42 #define BQ256XX_IINDPM_DEF_uA 2400000 43 43 44 + #define BQ256XX_TS_IGNORE BIT(6) 45 + #define BQ256XX_TS_IGNORE_SHIFT 6 46 + 44 47 #define BQ256XX_VINDPM_MASK GENMASK(3, 0) 45 48 #define BQ256XX_VINDPM_STEP_uV 100000 46 49 #define BQ256XX_VINDPM_OFFSET_uV 3900000 ··· 159 156 * @vindpm: input voltage limit 160 157 * @ichg_max: maximum fast charge current 161 158 * @vbatreg_max: maximum charge voltage 159 + * @ts_ignore: TS_IGNORE flag 162 160 */ 163 161 struct bq256xx_init_data { 164 162 u32 ichg; ··· 170 166 u32 vindpm; 171 167 u32 ichg_max; 172 168 u32 vbatreg_max; 169 + bool ts_ignore; 173 170 }; 174 171 175 172 /** ··· 268 263 * @bq256xx_set_iprechg: pointer to instance specific set_iprechg function 269 264 * @bq256xx_set_vindpm: pointer to instance specific set_vindpm function 270 265 * @bq256xx_set_charge_type: pointer to instance specific set_charge_type function 266 + * @bq256xx_set_ts_ignore: pointer to instance specific set_ts_ignore function 271 267 * 272 268 * @bq256xx_def_ichg: default ichg value in microamps 273 269 * @bq256xx_def_iindpm: default iindpm value in microamps ··· 301 295 int (*bq256xx_set_iprechg)(struct bq256xx_device *bq, int iprechg); 302 296 int (*bq256xx_set_vindpm)(struct bq256xx_device *bq, int vindpm); 303 297 int (*bq256xx_set_charge_type)(struct bq256xx_device *bq, int type); 298 + int (*bq256xx_set_ts_ignore)(struct bq256xx_device *bq, bool ts_ignore); 304 299 305 300 int bq256xx_def_ichg; 306 301 int bq256xx_def_iindpm; ··· 701 694 return regmap_update_bits(bq->regmap, BQ256XX_BATTERY_VOLTAGE_LIMIT, 702 695 BQ256XX_VBATREG_MASK, vbatreg_reg_code << 703 696 BQ256XX_VBATREG_BIT_SHIFT); 697 + } 698 + 699 + static int bq256xx_set_ts_ignore(struct bq256xx_device *bq, bool ts_ignore) 700 + { 701 + return regmap_update_bits(bq->regmap, BQ256XX_INPUT_CURRENT_LIMIT, 702 + BQ256XX_TS_IGNORE, (ts_ignore ? 1 : 0) << BQ256XX_TS_IGNORE_SHIFT); 704 703 } 705 704 706 705 static int bq256xx_get_prechrg_curr(struct bq256xx_device *bq) ··· 1325 1312 .bq256xx_get_iterm = bq256xx_get_term_curr, 1326 1313 .bq256xx_get_iprechg = bq256xx_get_prechrg_curr, 1327 1314 .bq256xx_get_vindpm = bq256xx_get_input_volt_lim, 1315 + .bq256xx_set_ts_ignore = NULL, 1328 1316 1329 1317 .bq256xx_set_ichg = bq256xx_set_ichg_curr, 1330 1318 .bq256xx_set_iindpm = bq256xx_set_input_curr_lim, ··· 1365 1351 .bq256xx_set_iprechg = bq256xx_set_prechrg_curr, 1366 1352 .bq256xx_set_vindpm = bq256xx_set_input_volt_lim, 1367 1353 .bq256xx_set_charge_type = bq256xx_set_charge_type, 1354 + .bq256xx_set_ts_ignore = NULL, 1368 1355 1369 1356 .bq256xx_def_ichg = BQ2560X_ICHG_DEF_uA, 1370 1357 .bq256xx_def_iindpm = BQ256XX_IINDPM_DEF_uA, ··· 1397 1382 .bq256xx_set_iprechg = bq256xx_set_prechrg_curr, 1398 1383 .bq256xx_set_vindpm = bq256xx_set_input_volt_lim, 1399 1384 .bq256xx_set_charge_type = bq256xx_set_charge_type, 1385 + .bq256xx_set_ts_ignore = NULL, 1400 1386 1401 1387 .bq256xx_def_ichg = BQ2560X_ICHG_DEF_uA, 1402 1388 .bq256xx_def_iindpm = BQ256XX_IINDPM_DEF_uA, ··· 1429 1413 .bq256xx_set_iprechg = bq256xx_set_prechrg_curr, 1430 1414 .bq256xx_set_vindpm = bq256xx_set_input_volt_lim, 1431 1415 .bq256xx_set_charge_type = bq256xx_set_charge_type, 1416 + .bq256xx_set_ts_ignore = NULL, 1432 1417 1433 1418 .bq256xx_def_ichg = BQ2560X_ICHG_DEF_uA, 1434 1419 .bq256xx_def_iindpm = BQ256XX_IINDPM_DEF_uA, ··· 1461 1444 .bq256xx_set_iprechg = bq256xx_set_prechrg_curr, 1462 1445 .bq256xx_set_vindpm = bq256xx_set_input_volt_lim, 1463 1446 .bq256xx_set_charge_type = bq256xx_set_charge_type, 1447 + .bq256xx_set_ts_ignore = bq256xx_set_ts_ignore, 1464 1448 1465 1449 .bq256xx_def_ichg = BQ25611D_ICHG_DEF_uA, 1466 1450 .bq256xx_def_iindpm = BQ256XX_IINDPM_DEF_uA, ··· 1493 1475 .bq256xx_set_iprechg = bq25618_619_set_prechrg_curr, 1494 1476 .bq256xx_set_vindpm = bq256xx_set_input_volt_lim, 1495 1477 .bq256xx_set_charge_type = bq256xx_set_charge_type, 1478 + .bq256xx_set_ts_ignore = bq256xx_set_ts_ignore, 1496 1479 1497 1480 .bq256xx_def_ichg = BQ25618_ICHG_DEF_uA, 1498 1481 .bq256xx_def_iindpm = BQ256XX_IINDPM_DEF_uA, ··· 1525 1506 .bq256xx_set_iprechg = bq25618_619_set_prechrg_curr, 1526 1507 .bq256xx_set_vindpm = bq256xx_set_input_volt_lim, 1527 1508 .bq256xx_set_charge_type = bq256xx_set_charge_type, 1509 + .bq256xx_set_ts_ignore = bq256xx_set_ts_ignore, 1528 1510 1529 1511 .bq256xx_def_ichg = BQ25618_ICHG_DEF_uA, 1530 1512 .bq256xx_def_iindpm = BQ256XX_IINDPM_DEF_uA, ··· 1642 1622 if (ret) 1643 1623 return ret; 1644 1624 1625 + if (bq->chip_info->bq256xx_set_ts_ignore) { 1626 + ret = bq->chip_info->bq256xx_set_ts_ignore(bq, bq->init_data.ts_ignore); 1627 + if (ret) 1628 + return ret; 1629 + } 1630 + 1645 1631 power_supply_put_battery_info(bq->charger, bat_info); 1646 1632 1647 1633 return 0; ··· 1681 1655 &bq->init_data.iindpm); 1682 1656 if (ret) 1683 1657 bq->init_data.iindpm = bq->chip_info->bq256xx_def_iindpm; 1658 + 1659 + bq->init_data.ts_ignore = device_property_read_bool(bq->dev, "ti,no-thermistor"); 1684 1660 1685 1661 return 0; 1686 1662 }