Skip to content

Commit cdfea15

Browse files
authored
Merge pull request #812 from FrameworkComputer/azalea.fix_low_power_pd
do not set rp on error recover
2 parents dead73e + d448ad1 commit cdfea15

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

zephyr/program/lotus/src/cypress_pd_common.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -498,11 +498,14 @@ static void cypd_pdo_init(int controller, int port, uint8_t profile)
498498
CPRINTS("CLEAR CCG_MEMORY failed");
499499
}
500500

501-
static int cypd_select_rp(int controller, int port, uint8_t profile)
501+
static int cypd_select_rp(int port, uint8_t profile)
502502
{
503503
int rv;
504+
CPRINTF("P:%d SET TYPEC RP=%d", port, profile);
504505

505-
rv = cypd_write_reg8_wait_ack(controller, CCG_PD_CONTROL_REG(port), profile);
506+
rv = cypd_write_reg8_wait_ack(PORT_TO_CONTROLLER(port),
507+
CCG_PD_CONTROL_REG(PORT_TO_CONTROLLER_PORT(port)),
508+
profile);
506509
if (rv != EC_SUCCESS)
507510
CPRINTS("SET TYPEC RP failed");
508511

@@ -520,6 +523,7 @@ static int cypd_select_pdo(int controller, int port, uint8_t profile)
520523
return rv;
521524
}
522525

526+
523527
static int pd_3a_flag;
524528
static int pd_3a_set;
525529
static int pd_3a_controller;
@@ -580,7 +584,7 @@ void cypd_release_port(int controller, int port)
580584

581585
/* if port disconnect should set RP and PDO to default */
582586

583-
cypd_select_rp(controller, port, CCG_PD_CMD_SET_TYPEC_1_5A);
587+
cypd_select_rp(port_idx, CCG_PD_CMD_SET_TYPEC_1_5A);
584588
cypd_select_pdo(controller, port, CCG_PD_CMD_SET_TYPEC_3A);
585589

586590
if (cypd_port_3a_status(controller, port)) {
@@ -657,12 +661,13 @@ static void cypd_set_prepare_pdo(int controller, int port)
657661
static int cypd_modify_profile(int controller, int port, int profile)
658662
{
659663
int rv;
664+
int port_idx = (controller << 1) + port;
660665

661666
if (verbose_msg_logging)
662667
CPRINTS("PD Select PDO %s ", profile & 0x02 ? "3A" : "1.5A");
663668

664669
if (profile == CCG_PD_CMD_SET_TYPEC_3A) {
665-
rv = cypd_select_rp(controller, port, profile);
670+
rv = cypd_select_rp(port_idx, profile);
666671
if (rv != EC_SUCCESS)
667672
return rv;
668673
}
@@ -1471,7 +1476,7 @@ static void cypd_handle_state(int controller)
14711476

14721477
/* Update PDO format after init complete */
14731478
if (controller)
1474-
hook_call_deferred(&pdo_init_deferred_data, 1 * MSEC);
1479+
hook_call_deferred(&pdo_init_deferred_data, 25 * MSEC);
14751480

14761481
CPRINTS("CYPD %d Ready!", controller);
14771482
pd_chip_config[controller].state = CCG_STATE_READY;
@@ -1673,6 +1678,7 @@ void cypd_port_int(int controller, int port)
16731678
switch (data2[0]) {
16741679
case CCG_RESPONSE_PORT_DISCONNECT:
16751680
record_ucsi_connector_change_event(controller, port);
1681+
cypd_release_port(controller, port);
16761682
CPRINTS("PORT_DISCONNECT");
16771683
__fallthrough;
16781684
case CCG_RESPONSE_HARD_RESET_RX:
@@ -1683,7 +1689,6 @@ void cypd_port_int(int controller, int port)
16831689
CPRINTS("TYPE_C_ERROR_RECOVERY");
16841690

16851691
cypd_update_port_state(controller, port);
1686-
cypd_release_port(controller, port);
16871692
/* make sure the type-c state is cleared */
16881693
clear_port_state(controller, port);
16891694
#ifdef CONFIG_BOARD_LOTUS

0 commit comments

Comments
 (0)