Skip to content

Commit 94e1ede

Browse files
committed
[fix] ec should disable C_CTRL before enable
everytime EC change port, need to disable ports and then enable. Signed-off-by: elmo_lan <hplan1112@gmail.com>
1 parent 5f42826 commit 94e1ede

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

board/hx30/cypress5525.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1766,8 +1766,10 @@ int board_set_active_charge_port(int charge_port)
17661766
{
17671767
CPRINTS("start change port = %d, prev_charge_port = %d", charge_port, prev_charge_port);
17681768

1769-
if (board_batt_is_present() != BP_YES)
1769+
if (board_batt_is_present() != BP_YES) {
1770+
CPRINTS("No batt, no change");
17701771
return EC_ERROR_NOT_POWERED;
1772+
}
17711773

17721774
/* port need change, stop all power and ready to switch. */
17731775
if (prev_charge_port != -1 && prev_charge_port != charge_port) {
@@ -1785,16 +1787,16 @@ int board_set_active_charge_port(int charge_port)
17851787
int pd_controller = (charge_port & 0x02) >> 1;
17861788
int pd_port = charge_port & 0x01;
17871789

1788-
CPRINTS("choose p %d, ctrler = %d, p = %d", charge_port, pd_controller, pd_port);
1789-
cypd_write_reg8(pd_controller, CYP5525_CUST_C_CTRL_CONTROL_REG,
1790-
pd_port ? CYP5525_P0_OFF_P1_CY : CYP5525_P0_CY_P1_OFF);
17911790
CPRINTS("force off ctrler = %d", (~pd_controller) & 0x01);
17921791
cypd_write_reg8((~pd_controller) & 0x01, CYP5525_CUST_C_CTRL_CONTROL_REG,
17931792
CYP5525_P0P1_TURN_OFF_C_CTRL);
1793+
CPRINTS("choose p %d, ctrler = %d, p = %d", charge_port, pd_controller, pd_port);
1794+
cypd_write_reg8(pd_controller, CYP5525_CUST_C_CTRL_CONTROL_REG,
1795+
pd_port ? CYP5525_P0_OFF_P1_CY : CYP5525_P0_CY_P1_OFF);
17941796
} else {
17951797
CPRINTS("else = %d, set all ports auto", charge_port);
1796-
cypd_write_reg8(0, CYP5525_CUST_C_CTRL_CONTROL_REG, CYP5525_P0P1_CONTROL_BY_CY);
1797-
cypd_write_reg8(1, CYP5525_CUST_C_CTRL_CONTROL_REG, CYP5525_P0P1_CONTROL_BY_CY);
1798+
cypd_write_reg8(0, CYP5525_CUST_C_CTRL_CONTROL_REG, CYP5525_P0P1_TURN_OFF_C_CTRL);
1799+
cypd_write_reg8(1, CYP5525_CUST_C_CTRL_CONTROL_REG, CYP5525_P0P1_TURN_OFF_C_CTRL);
17981800
}
17991801

18001802
hook_call_deferred(&update_power_limit_deferred_data, 100 * MSEC);

0 commit comments

Comments
 (0)