File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed
Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -771,6 +771,8 @@ int poweron_reason_powerbtn(void);
771771
772772void spi_mux_control (int enable );
773773
774+ enum battery_present board_batt_is_present (void );
775+
774776#ifdef CONFIG_LOW_POWER_IDLE
775777void board_prepare_for_deep_sleep (void );
776778void board_resume_from_deep_sleep (void );
Original file line number Diff line number Diff line change @@ -1487,9 +1487,20 @@ int board_set_active_charge_port(int charge_port)
14871487 int mask ;
14881488 int i ;
14891489 int disable_lockout ;
1490+ int force_reduce ;
1491+ int current ;
1492+
1493+ /* if battery is present, set the current limit 500 mA*/
14901494
14911495 if (prev_charge_port != -1 && prev_charge_port != charge_port ) {
14921496 update_soc_power_limit (false, true);
1497+
1498+ /* force to reduce the input current limit when battery is connected */
1499+ if (board_batt_is_present () == BP_YES ) {
1500+ force_reduce = 1 ;
1501+ charge_set_input_current_limit (0 , pd_port_states [charge_port ].voltage );
1502+ }
1503+
14931504 gpio_set_level (GPIO_TYPEC0_VBUS_ON_EC , 0 );
14941505 gpio_set_level (GPIO_TYPEC1_VBUS_ON_EC , 0 );
14951506 gpio_set_level (GPIO_TYPEC2_VBUS_ON_EC , 0 );
@@ -1511,6 +1522,13 @@ int board_set_active_charge_port(int charge_port)
15111522 gpio_set_level (GPIO_TYPEC2_VBUS_ON_EC , 1 );
15121523 gpio_set_level (GPIO_TYPEC3_VBUS_ON_EC , 1 );
15131524 }
1525+
1526+ /* Switch port complete. set the current limit to charge_ma*0.95 */
1527+ if (force_reduce ) {
1528+ current = pd_port_states [charge_port ].current * 95 / 100 ;
1529+ charge_set_input_current_limit (current , pd_port_states [charge_port ].voltage );
1530+ }
1531+
15141532 for (i = 0 ; i < PD_CHIP_COUNT ; i ++ )
15151533 cypd_write_reg8 (i , CYP5225_USER_DISABLE_LOCKOUT , disable_lockout );
15161534
You can’t perform that action at this time.
0 commit comments