Skip to content

Commit

Permalink
Merge pull request #799 from FrameworkComputer/fwk.PD_wait_ack
Browse files Browse the repository at this point in the history
fwk: modify PD wait ack time
  • Loading branch information
kiram9 authored Sep 11, 2023
2 parents 9ae94a4 + dcf47f1 commit d5fe080
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions zephyr/program/lotus/src/cypress_pd_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,17 +192,16 @@ int cypd_clear_int(int controller, int mask)
return rv;
}

int cypd_wait_for_ack(int controller, int timeout_us)
int cypd_wait_for_ack(int controller, int timeout_ms)
{
int timeout;
const struct gpio_dt_spec *intr = gpio_get_dt_spec(pd_chip_config[controller].gpio);

timeout_us = timeout_us / 10;
/* wait for interrupt ack to be asserted */
for (timeout = 0; timeout < timeout_us; timeout++) {
for (timeout = 0; timeout < timeout_ms; timeout++) {
if (gpio_pin_get_dt(intr) == 0)
break;
usleep(10);
usleep(MSEC);
}
/* make sure response is ok */
if (gpio_pin_get_dt(intr) != 0) {
Expand All @@ -224,7 +223,7 @@ static int cypd_write_reg8_wait_ack(int controller, int reg, int data)
if (rv != EC_SUCCESS)
CPRINTS("Write Reg8 0x%x fail!", reg);

if (cypd_wait_for_ack(controller, 100*MSEC) != EC_SUCCESS) {
if (cypd_wait_for_ack(controller, 100) != EC_SUCCESS) {
CPRINTS("%s timeout on interrupt", __func__);
return EC_ERROR_INVAL;
}
Expand Down Expand Up @@ -1318,7 +1317,7 @@ static int cypd_setup(int controller)
return EC_ERROR_INVAL;
}
/* wait for interrupt ack to be asserted */
if (cypd_wait_for_ack(controller, 5000) != EC_SUCCESS) {
if (cypd_wait_for_ack(controller, 5) != EC_SUCCESS) {
CPRINTS("%s timeout on interrupt", __func__);
return EC_ERROR_INVAL;
}
Expand Down Expand Up @@ -1766,6 +1765,7 @@ int board_set_active_charge_port(int charge_port)
return EC_SUCCESS;
}


if (prev_charge_port != -1 &&
prev_charge_port != charge_port) {
/* Turn off the previous charge port before turning on the next port */
Expand Down Expand Up @@ -1959,7 +1959,7 @@ static int cmd_cypd_control(int argc, const char **argv)
} else if (!strncmp(argv[1], "reset", 5)) {
cypd_write_reg8(i, CCG_PDPORT_ENABLE_REG, 0);
/*can take up to 650ms to discharge port for disable*/
cypd_wait_for_ack(i, 65000);
cypd_wait_for_ack(i, 65);
cypd_clear_int(i, CCG_DEV_INTR +
CCG_PORT0_INTR +
CCG_PORT1_INTR +
Expand Down
2 changes: 1 addition & 1 deletion zephyr/program/lotus/src/ucsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ int ucsi_startup(int controller)
if (rv != EC_SUCCESS)
CPRINTS("UCSI start command fail!");

if (cypd_wait_for_ack(controller, 100000) != EC_SUCCESS) {
if (cypd_wait_for_ack(controller, 100) != EC_SUCCESS) {
CPRINTS("%s timeout on interrupt", __func__);
return EC_ERROR_INVAL;
}
Expand Down

0 comments on commit d5fe080

Please sign in to comment.