Skip to content

Commit 74adc73

Browse files
committed
Lotus: enable bypass mode
The upstream code uses a configuration to enable the bypass mode. It cause the current firmware does not enable the bypass mode when connect 180w adapter. Signed-off-by: Josh-Tsai <josh_tsai@compal.com>
1 parent d154431 commit 74adc73

File tree

4 files changed

+30
-2
lines changed

4 files changed

+30
-2
lines changed

common/charge_state.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,20 @@ __overridable int board_should_charger_bypass(void)
434434
return false;
435435
}
436436

437+
#ifdef CONFIG_CHARGER_BYPASS_REVERSE_TURBO
438+
int board_want_charger_change_mode(void)
439+
{
440+
static int pre_batt = BP_YES;
441+
int curr_batt = battery_is_present();
442+
443+
if (pre_batt != curr_batt) {
444+
pre_batt = curr_batt;
445+
return true;
446+
} else
447+
return false;
448+
}
449+
#endif
450+
437451
int charge_request(bool use_curr, bool is_full)
438452
{
439453
int r1 = EC_SUCCESS, r2 = EC_SUCCESS, r3 = EC_SUCCESS, r4 = EC_SUCCESS;
@@ -478,7 +492,11 @@ int charge_request(bool use_curr, bool is_full)
478492
*/
479493
should_bypass = board_should_charger_bypass();
480494
if ((should_bypass && !(curr.chg.status & CHARGER_BYPASS_MODE)) ||
481-
(!should_bypass && (curr.chg.status & CHARGER_BYPASS_MODE)))
495+
(!should_bypass && (curr.chg.status & CHARGER_BYPASS_MODE))
496+
#ifdef CONFIG_CHARGER_BYPASS_REVERSE_TURBO
497+
|| board_want_charger_change_mode()
498+
#endif
499+
)
482500
charger_enable_bypass_mode(0, should_bypass);
483501

484502
/*

include/charge_state.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,15 @@ __test_only bool charging_progress_displayed(void);
420420
*/
421421
int board_should_charger_bypass(void);
422422

423+
#ifdef CONFIG_CHARGER_BYPASS_REVERSE_TURBO
424+
/**
425+
* Callback for boards to call the charger_enable_bypass_mode without mode change.
426+
*
427+
* @return True for requesting change.
428+
*/
429+
int board_want_charger_change_mode(void);
430+
#endif
431+
423432
/* Config Charger */
424433
#include "charge_state.h"
425434

zephyr/Kconfig.charger

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ config PLATFORM_EC_CHARGER_MAINTAIN_VBAT
579579
work around quirks of certain charger chips, such as the BD9995X.
580580

581581
config PLATFORM_EC_CHARGER_BYPASS_MODE
582-
bool
582+
bool "enable charger bypass mode"
583583
help
584584
Select this option if the charger will be used in a bypass mode in
585585
order to pass the input current from AC directly to the system

zephyr/program/lotus/lotus/project.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=5
2121
CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=5
2222
CONFIG_PLATFORM_EC_CHARGER_DEFAULT_CURRENT_LIMIT=500
2323
CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON=55000
24+
CONFIG_PLATFORM_EC_CHARGER_BYPASS_MODE=y
2425
CONFIG_PLATFORM_EC_CHARGER_BYPASS_REVERSE_TURBO=y
2526
CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC_CUSTOM=y
2627
CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_NOT_PRESENT=y

0 commit comments

Comments
 (0)