@@ -399,6 +399,9 @@ DECLARE_HOOK(HOOK_INIT, vci_init, HOOK_PRIO_FIRST);
399399static void board_power_off_deferred (void )
400400{
401401 int i ;
402+ /* Turn off BGATE and NGATE for power saving */
403+ charger_psys_enable (0 );
404+ charge_gate_onoff (0 );
402405
403406 /* Disable interrupts */
404407 interrupt_disable ();
@@ -535,7 +538,7 @@ void charge_gate_onoff(uint8_t enable)
535538}
536539
537540
538- void charge_psys_onoff (uint8_t enable )
541+ void charger_psys_enable (uint8_t enable )
539542{
540543 int control1 = 0x0000 ;
541544 int control4 = 0x0000 ;
@@ -576,44 +579,6 @@ void charge_psys_onoff(uint8_t enable)
576579 }
577580}
578581
579-
580- /*
581- * Charger Low Power Mode Process
582- * modern standby should not turn off Bfet and Nfet
583- * DC only at S5 need enable
584- * AC+DC at S5 & Fully charge need enable
585- * AC+DC at Modern standby & Fully charge need enable
586- * AC only need disable
587- */
588- void charger_low_power_update (void )
589- {
590- static int ac_state ;
591- static int dc_state ;
592- int batt_status ;
593-
594- ac_state = extpower_is_present ();
595- dc_state = battery_is_present ();
596- battery_status (& batt_status );
597-
598- if (dc_state && !ac_state &&
599- chipset_in_state (CHIPSET_STATE_ANY_OFF )) {
600- charge_gate_onoff (0 );
601- charge_psys_onoff (0 );
602- } else if (ac_state && dc_state &&
603- batt_status & STATUS_FULLY_CHARGED ) {
604- if (chipset_in_state (CHIPSET_STATE_ANY_OFF )) {
605- charge_gate_onoff (0 );
606- charge_psys_onoff (0 );
607- } else if (chipset_in_state (CHIPSET_STATE_STANDBY ))
608- charge_psys_onoff (0 );
609- } else if (ac_state && !dc_state ) {
610- charge_gate_onoff (1 );
611- charge_psys_onoff (1 );
612- }
613- }
614- DECLARE_HOOK (HOOK_AC_CHANGE , charger_low_power_update , HOOK_PRIO_DEFAULT );
615- DECLARE_HOOK (HOOK_BATTERY_SOC_CHANGE , charger_low_power_update , HOOK_PRIO_DEFAULT );
616-
617582/* Initialize board. */
618583static void board_init (void )
619584{
@@ -647,8 +612,7 @@ static void board_chipset_startup(void)
647612 if (version > 6 )
648613 gpio_set_level (GPIO_EN_INVPWR , 1 );
649614
650- charge_gate_onoff (1 );
651- charge_psys_onoff (1 );
615+ charger_psys_enable (1 );
652616}
653617DECLARE_HOOK (HOOK_CHIPSET_STARTUP ,
654618 board_chipset_startup ,
@@ -667,11 +631,7 @@ static void board_chipset_shutdown(void)
667631 lpc_set_host_event_mask (LPC_HOST_EVENT_SCI , 0 );
668632#endif
669633
670- /* avoid AC mode enable charger LPM when charging*/
671- if (!extpower_is_present () || (batt_status & STATUS_FULLY_CHARGED )) {
672- charge_gate_onoff (0 );
673- charge_psys_onoff (0 );
674- }
634+ charger_psys_enable (0 );
675635}
676636DECLARE_HOOK (HOOK_CHIPSET_SHUTDOWN ,
677637 board_chipset_shutdown ,
@@ -684,7 +644,7 @@ static void board_chipset_resume(void)
684644 /*gpio_set_level(GPIO_ENABLE_BACKLIGHT, 1);*/
685645 gpio_set_level (GPIO_EC_MUTE_L , 1 );
686646 gpio_set_level (GPIO_CAM_EN , 1 );
687- charge_psys_onoff (1 );
647+ charger_psys_enable (1 );
688648}
689649DECLARE_HOOK (HOOK_CHIPSET_RESUME , board_chipset_resume ,
690650 MOTION_SENSE_HOOK_PRIO - 1 );
@@ -698,7 +658,7 @@ static void board_chipset_suspend(void)
698658 gpio_set_level (GPIO_EC_MUTE_L , 0 );
699659 gpio_set_level (GPIO_CAM_EN , 0 );
700660 }
701- charge_psys_onoff (0 );
661+ charger_psys_enable (0 );
702662}
703663DECLARE_HOOK (HOOK_CHIPSET_SUSPEND ,
704664 board_chipset_suspend ,
@@ -885,6 +845,9 @@ static void charger_chips_init(void)
885845
886846 val = ISL9241_CONTROL1_PROCHOT_REF_6800 | ISL9241_CONTROL1_SWITCH_FREQ ;
887847
848+ /* make sure battery FET is enabled on EC on */
849+ val &= ~ISL9241_CONTROL1_BGATE ;
850+
888851 if (i2c_write16 (I2C_PORT_CHARGER , ISL9241_ADDR_FLAGS ,
889852 ISL9241_REG_CONTROL1 , val ))
890853 goto init_fail ;
0 commit comments