Skip to content

Commit 2c722eb

Browse files
author
Josh Tsai
committed
Modified the condition to do the error recovery and port reconnect
System cannot ac auto power on when battery in cut-off mode. We need to check the battery can provide the power before doing the error recovery. Also need to modify the condition to re-connect the type-c port. Signed-off-by: Josh Tsai <josh_tsai@compal.com>
1 parent 85fdf34 commit 2c722eb

1 file changed

Lines changed: 12 additions & 20 deletions

File tree

board/hx30/cypress5525.c

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -412,13 +412,16 @@ void cypd_set_power_active(enum power_state power)
412412
cypd_enque_evt(CYPD_EVT_S_CHANGE, 0);
413413
}
414414

415+
static bool reconnect_flag;
416+
415417
void cypd_set_error_recovery(void)
416418
{
417419
int i;
418420

419421
for (i = 0; i < PD_CHIP_COUNT; i++) {
420422
if (charger_current_battery_params()->flags & BATT_FLAG_RESPONSIVE &&
421-
charger_current_battery_params()->state_of_charge > 0)
423+
charger_current_battery_params()->state_of_charge > 0 &&
424+
board_batt_is_present() == BP_YES) {
422425
/* CYPD firmware will issue error recovery when we change the system
423426
* power state to S0, if battery can't provide the power, it will cause
424427
* power loss.
@@ -427,19 +430,12 @@ void cypd_set_error_recovery(void)
427430
* change the system power state
428431
*/
429432
cypd_write_reg8_wait_ack(i, CYP5525_SYS_PWR_STATE, 0xC1);
430-
else
433+
reconnect_flag = false;
434+
} else
431435
cypd_write_reg8_wait_ack(i, CYP5525_SYS_PWR_STATE, 0xC0);
432436
}
433437
}
434438

435-
static bool reconnect_flag;
436-
437-
static void reconnect_port_deferred(void)
438-
{
439-
cypd_aconly_reconnect();
440-
}
441-
DECLARE_DEFERRED(reconnect_port_deferred);
442-
443439
void update_system_power_state(int controller)
444440
{
445441

@@ -459,9 +455,9 @@ void update_system_power_state(int controller)
459455
cypd_set_error_recovery();
460456
cypd_set_power_state(CYP5525_POWERSTATE_S0, controller);
461457
if (reconnect_flag) {
462-
reconnect_flag = false;
463458
CPRINTS("CYPD reconnect");
464459
cypd_aconly_reconnect();
460+
reconnect_flag = false;
465461
}
466462
break;
467463
}
@@ -1402,15 +1398,11 @@ int cypd_reconnect_port_enable(int controller)
14021398

14031399
void cypd_aconly_reconnect(void)
14041400
{
1405-
int batt_status, events;
1406-
1407-
battery_status(&batt_status);
1401+
int events;
14081402

1409-
if (extpower_is_present() && board_batt_is_present() != BP_YES) {
1410-
events = task_wait_event_mask(TASK_EVENT_TIMER, 100*MSEC);
1411-
if (events & TASK_EVENT_TIMER)
1412-
cypd_enque_evt(CYPD_EVT_PORT_DISABLE, 0);
1413-
}
1403+
events = task_wait_event_mask(TASK_EVENT_TIMER, 100*MSEC);
1404+
if (events & TASK_EVENT_TIMER)
1405+
cypd_enque_evt(CYPD_EVT_PORT_DISABLE, 0);
14141406
}
14151407

14161408
void cypd_usci_ppm_reset(void)
@@ -1473,7 +1465,7 @@ void cypd_set_typec_profile(int controller, int port)
14731465
CPRINTS("CYP5525_TYPE_C_STATUS_REG failed");
14741466
pd_port_states[port_idx].c_state = (typec_status_reg >> 2) & 0x7;
14751467

1476-
/* if port no device connect set type c profile to 1.5A */
1468+
/* if port no device connect set type c current to 1.5A */
14771469
if (pd_port_states[port_idx].c_state == CYPD_STATUS_NOTHING) {
14781470
cypd_write_reg8(controller, CYP5525_PD_CONTROL_REG(port), CYPD_PD_CMD_SET_TYPEC_1_5A);
14791471
return;

0 commit comments

Comments
 (0)