@@ -95,7 +95,7 @@ static void cypd_update_port_state(int controller, int port);
9595static void cypd_pdo_reset_deferred (void );
9696static void cypd_set_prepare_pdo (int controller , int port );
9797
98- int cypd_write_reg_block (int controller , int reg , void * data , int len )
98+ int cypd_write_reg_block (int controller , int reg , const void * data , int len )
9999{
100100 int rv ;
101101 uint16_t i2c_port = pd_chip_config [controller ].i2c_port ;
@@ -1262,43 +1262,33 @@ static void port_to_safe_mode(int port)
12621262 CPRINTS ("P%d: Safe" , port );
12631263
12641264}
1265-
1266- enum power_state pd_prev_power_state = POWER_G3 ;
1265+ bool apu_not_initialized ;
12671266void update_system_power_state (int controller )
12681267{
12691268 enum power_state ps = power_get_state ();
1270-
12711269 switch (ps ) {
12721270 case POWER_G3 :
12731271 case POWER_S5G3 :
1274- pd_prev_power_state = POWER_G3 ;
12751272 cypd_set_power_state (CCG_POWERSTATE_G3 , controller );
1273+ apu_not_initialized = true;
12761274 break ;
12771275 case POWER_S5 :
12781276 case POWER_S3S5 :
12791277 case POWER_S4S5 :
1280- pd_prev_power_state = POWER_S5 ;
12811278 cypd_set_power_state (CCG_POWERSTATE_S5 , controller );
1279+ apu_not_initialized = true;
12821280 break ;
12831281 case POWER_S3 :
12841282 case POWER_S4S3 :
12851283 case POWER_S5S3 :
12861284 case POWER_S0S3 :
12871285 case POWER_S0ixS3 : /* S0ix -> S3 */
12881286 cypd_set_power_state (CCG_POWERSTATE_S3 , controller );
1289- if (pd_prev_power_state < POWER_S3 ) {
1290- perform_error_recovery (controller );
1291- pd_prev_power_state = ps ;
1292- }
12931287 break ;
12941288 case POWER_S0 :
12951289 case POWER_S3S0 :
12961290 case POWER_S0ixS0 : /* S0ix -> S0 */
12971291 cypd_set_power_state (CCG_POWERSTATE_S0 , controller );
1298- if (pd_prev_power_state < POWER_S3 ) {
1299- perform_error_recovery (controller );
1300- pd_prev_power_state = ps ;
1301- }
13021292 break ;
13031293 case POWER_S0ix :
13041294 case POWER_S3S0ix : /* S3 -> S0ix */
@@ -1317,6 +1307,16 @@ void cypd_set_power_active(void)
13171307 task_set_event (TASK_ID_CYPD , CCG_EVT_S_CHANGE );
13181308}
13191309
1310+ void cypd_port_reset (void )
1311+ {
1312+ if (apu_not_initialized ) {
1313+ task_set_event (TASK_ID_CYPD , CCG_EVT_PLT_RESET );
1314+ apu_not_initialized = false;
1315+ }
1316+ }
1317+
1318+
1319+
13201320#define CYPD_SETUP_CMDS_LEN 2
13211321static int cypd_setup (int controller )
13221322{
@@ -1421,6 +1421,7 @@ static void cypd_handle_state(int controller)
14211421 cypd_update_power_status (controller );
14221422
14231423 update_system_power_state (controller );
1424+
14241425 cypd_setup (controller );
14251426
14261427 /* After initial complete, update the type-c port state */
@@ -1853,6 +1854,10 @@ void cypd_interrupt_handler_task(void *p)
18531854 if (evt & CCG_EVT_UPDATE_PWRSTAT )
18541855 cypd_update_power_status (2 );
18551856
1857+ if (evt & CCG_EVT_PLT_RESET ) {
1858+ perform_error_recovery (2 );
1859+ }
1860+
18561861
18571862 if (evt & (CCG_EVT_INT_CTRL_0 | CCG_EVT_INT_CTRL_1 |
18581863 CCG_EVT_STATE_CTRL_0 | CCG_EVT_STATE_CTRL_1 )) {
0 commit comments