Skip to content

Commit 78f8929

Browse files
committed
[fix] reconnect PD port if connect Sink device when ac only
Solution: after power state change reconnect PD port by cmd 2C. test:boot up Unit when ac only, at s0 can catch DP/HDMI device ClickUp:https://app.clickup.com/t/2j3vpzd Signed-off-by: Leo_Tsai <LeoCX_Tsai@compal.com>
1 parent b790da9 commit 78f8929

3 files changed

Lines changed: 69 additions & 0 deletions

File tree

board/hx30/cypress5525.c

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,6 +1311,72 @@ void cypd_interrupt_handler_task(void *p)
13111311
}
13121312
}
13131313

1314+
1315+
1316+
int cypd_reconnect_port(int controller, int port)
1317+
{
1318+
int rv;
1319+
uint8_t pd_status_reg[4];
1320+
int port_idx = (controller << 1) + port;
1321+
int port_pd_state, port_power_role, data;
1322+
1323+
rv = cypd_read_reg_block(controller, CYP5525_PD_STATUS_REG(port), pd_status_reg, 4);
1324+
if (rv != EC_SUCCESS)
1325+
CPRINTS("CYP5525_PD_STATUS_REG failed");
1326+
1327+
port_pd_state = pd_status_reg[1] & BIT(2);
1328+
port_power_role = pd_status_reg[1] & BIT(0);
1329+
1330+
if (port_power_role == PD_ROLE_SINK && port_pd_state)
1331+
return EC_SUCCESS;
1332+
1333+
rv = cypd_read_reg8(controller, CYP5525_PDPORT_ENABLE_REG, &data);
1334+
if (rv != EC_SUCCESS)
1335+
return rv;
1336+
1337+
CPRINTS("Port data0: %d", data);
1338+
1339+
data &= ~BIT(port);
1340+
1341+
CPRINTS("Port data1: %d", data);
1342+
1343+
rv = cypd_write_reg8(controller, CYP5525_PDPORT_ENABLE_REG, data);
1344+
if (rv != EC_SUCCESS)
1345+
return rv;
1346+
1347+
cyp5225_wait_for_ack(controller, 1 * SECOND);
1348+
1349+
data |= BIT(port);
1350+
1351+
CPRINTS("Port data2: %d", data);
1352+
1353+
rv = cypd_write_reg8(controller, CYP5525_PDPORT_ENABLE_REG, data);
1354+
if (rv != EC_SUCCESS)
1355+
return rv;
1356+
1357+
cyp5225_wait_for_ack(controller, 200 * MSEC);
1358+
1359+
CPRINTS("PD Re connect controller: %d, Port: %d", controller, port_idx);
1360+
return rv;
1361+
}
1362+
1363+
void cypd_aconly_reconnect(void)
1364+
{
1365+
int batt_status;
1366+
1367+
battery_status(&batt_status);
1368+
1369+
if (extpower_is_present() && battery_is_present() != BP_YES) {
1370+
cypd_reconnect_port(0, 0);
1371+
msleep(20);
1372+
cypd_reconnect_port(0, 1);
1373+
cypd_reconnect_port(1, 0);
1374+
msleep(20);
1375+
cypd_reconnect_port(1, 1);
1376+
}
1377+
}
1378+
1379+
13141380
int cypd_get_pps_power_budget(void)
13151381
{
13161382
/* TODO:

board/hx30/cypress5525.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,4 +457,6 @@ int cypd_get_active_charging_port(void);
457457
void set_pd_fw_update(bool update);
458458

459459
void cypd_charger_init_complete(void);
460+
461+
void cypd_aconly_reconnect(void);
460462
#endif /* __CROS_EC_CYPRESS5525_H */

board/hx30/power_sequence.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,7 @@ enum power_state power_handle_state(enum power_state state)
563563
me_gpio_change(GPIO_FLAG_NONE);
564564

565565
cypd_set_power_active(POWER_S0);
566+
cypd_aconly_reconnect();
566567
CPRINTS("PH S3S0->S0");
567568
return POWER_S0;
568569

0 commit comments

Comments
 (0)