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

Configure Feed

Select the types of activity you want to include in your feed.

power: supply: bq25890: Reduce reported CONSTANT_CHARGE_CURRENT_MAX for low temperatures

Take into account possible current reduction due to low-temperature when
reading POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX. As described in
the datasheet in cool (0-20° Celcius) conditions the current limit is
decreased to 20% or 50% of ICHG field value depended on JEITA_ISET field.

Also add NTC_FAULT field value to the debug message in
bq25890_get_chip_state().

Changed by Hans de Goede:
- Fix reading F_CHG_FAULT instead of F_NTC_FIELD for state->ntc_fault
- Only read JEITA_ISET field if necessary
- Tweak commit message a bit

Signed-off-by: Yauhen Kharuzhy <jekhor@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Co-developed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>

authored by

Yauhen Kharuzhy and committed by
Sebastian Reichel
c562a43a 766873c1

+26 -3
+26 -3
drivers/power/supply/bq25890_charger.c
··· 94 94 u8 vsys_status; 95 95 u8 boost_fault; 96 96 u8 bat_fault; 97 + u8 ntc_fault; 97 98 }; 98 99 99 100 struct bq25890_device { ··· 408 407 CHRG_FAULT_TIMER_EXPIRED, 409 408 }; 410 409 410 + enum bq25890_ntc_fault { 411 + NTC_FAULT_NORMAL = 0, 412 + NTC_FAULT_WARM = 2, 413 + NTC_FAULT_COOL = 3, 414 + NTC_FAULT_COLD = 5, 415 + NTC_FAULT_HOT = 6, 416 + }; 417 + 411 418 static bool bq25890_is_adc_property(enum power_supply_property psp) 412 419 { 413 420 switch (psp) { ··· 508 499 509 500 case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX: 510 501 val->intval = bq25890_find_val(bq->init_data.ichg, TBL_ICHG); 502 + 503 + /* When temperature is too low, charge current is decreased */ 504 + if (bq->state.ntc_fault == NTC_FAULT_COOL) { 505 + ret = bq25890_field_read(bq, F_JEITA_ISET); 506 + if (ret < 0) 507 + return ret; 508 + 509 + if (ret) 510 + val->intval /= 5; 511 + else 512 + val->intval /= 2; 513 + } 511 514 break; 512 515 513 516 case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE: ··· 604 583 {F_VSYS_STAT, &state->vsys_status}, 605 584 {F_BOOST_FAULT, &state->boost_fault}, 606 585 {F_BAT_FAULT, &state->bat_fault}, 607 - {F_CHG_FAULT, &state->chrg_fault} 586 + {F_CHG_FAULT, &state->chrg_fault}, 587 + {F_NTC_FAULT, &state->ntc_fault} 608 588 }; 609 589 610 590 for (i = 0; i < ARRAY_SIZE(state_fields); i++) { ··· 616 594 *state_fields[i].data = ret; 617 595 } 618 596 619 - dev_dbg(bq->dev, "S:CHG/PG/VSYS=%d/%d/%d, F:CHG/BOOST/BAT=%d/%d/%d\n", 597 + dev_dbg(bq->dev, "S:CHG/PG/VSYS=%d/%d/%d, F:CHG/BOOST/BAT/NTC=%d/%d/%d/%d\n", 620 598 state->chrg_status, state->online, state->vsys_status, 621 - state->chrg_fault, state->boost_fault, state->bat_fault); 599 + state->chrg_fault, state->boost_fault, state->bat_fault, 600 + state->ntc_fault); 622 601 623 602 return 0; 624 603 }