Skip to content

Commit

Permalink
power: apply safety margin on USB-PD only
Browse files Browse the repository at this point in the history
Signed-off-by: Michał Kopeć <[email protected]>
  • Loading branch information
mkopec committed Oct 18, 2024
1 parent 582481d commit 4312637
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/board/system76/common/charger/bq24780s.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ int16_t battery_charger_enable(void) {
res = smbus_write(
CHARGER_ADDRESS,
REG_INPUT_CURRENT,
INPUT_CURRENT(battery_charger_input_current * 9 / 10)
INPUT_CURRENT(battery_charger_input_current)
);
if (res < 0)
return res;
Expand Down
2 changes: 1 addition & 1 deletion src/board/system76/common/charger/oz26786.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ int16_t battery_charger_enable(void) {
res = smbus_write(
CHARGER_ADDRESS,
REG_ADAPTER_CURRENT,
INPUT_CURRENT((uint32_t)battery_charger_input_current * 93 / 100)
INPUT_CURRENT((uint32_t)battery_charger_input_current)
);
if (res < 0)
return res;
Expand Down
2 changes: 0 additions & 2 deletions src/board/system76/common/power.c
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,6 @@ void power_peci_limit(bool ac) {
supply_watts = (uint32_t)battery_charger_input_current *
(uint32_t)battery_charger_input_voltage / 1000;
DEBUG("%llu W supply detected\n", supply_watts);
// 7% safety margin
supply_watts = supply_watts * 93 / 100;
}

if (!ac || !supply_watts || options_get(OPT_ALLOW_BAT_BOOST)) {
Expand Down
2 changes: 2 additions & 0 deletions src/board/system76/common/usbpd/tps65987.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,13 @@ void usbpd_event(void) {
} else if (sink_ctrl_1) {
while ((res = usbpd_current_limit(PORT_A_ADDRESS)) < 0 && retry--) {};
next_input_current = res < CHARGER_INPUT_CURRENT ? res : CHARGER_INPUT_CURRENT;
next_input_current = (uint32_t)next_input_current * 93 / 100;
next_input_voltage = BATTERY_CHARGER_VOLTAGE_PD;
#ifdef USBPD_DUAL_PORT
} else if (sink_ctrl_2) {
while ((res = usbpd_current_limit(PORT_B_ADDRESS)) < 0 && retry--) {};
next_input_current = res < CHARGER_INPUT_CURRENT ? res : CHARGER_INPUT_CURRENT;
next_input_current = (uint32_t)next_input_current * 93 / 100;
next_input_voltage = BATTERY_CHARGER_VOLTAGE_PD;
#endif
}
Expand Down

0 comments on commit 4312637

Please sign in to comment.