Skip to content

Commit bbb60d2

Browse files
committed
[ot] hw/opentitan: ot_lc_ctrl: Set LC_STATE to POST_TRANSITION after a transition
From <https://opentitan.org/book/hw/ip/lc_ctrl/doc/programmers_guide.html>: "Note that all life cycle state transition increments the LC_TRANSITION_CNT and moves the life cycle state into the temporary POST_TRANSITION state - even if the transition was unsuccessful" This is checked by manufacturing tests (on the host side). Signed-off-by: Luís Marques <[email protected]>
1 parent f943275 commit bbb60d2

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

hw/opentitan/ot_lc_ctrl.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,6 +1285,7 @@ static void ot_lc_ctrl_handle_otp_ack(void *opaque, bool ack)
12851285
s->regs[R_STATUS] |= R_STATUS_OTP_ERROR_MASK;
12861286
}
12871287
LC_FSM_CHANGE_STATE(s, ST_POST_TRANS);
1288+
s->lc_state = LC_STATE_POST_TRANSITION;
12881289
break;
12891290
default:
12901291
g_assert_not_reached();
@@ -1304,6 +1305,7 @@ static void ot_lc_ctrl_program_otp(OtLcCtrlState *s, unsigned lc_tcount,
13041305
__func__);
13051306
s->regs[R_STATUS] |= R_STATUS_OTP_ERROR_MASK;
13061307
LC_FSM_CHANGE_STATE(s, ST_POST_TRANS);
1308+
s->lc_state = LC_STATE_POST_TRANSITION;
13071309
return;
13081310
}
13091311

@@ -1317,6 +1319,7 @@ static void ot_lc_ctrl_program_otp(OtLcCtrlState *s, unsigned lc_tcount,
13171319
trace_ot_lc_ctrl_error(s->ot_id, "OTP program request rejected");
13181320
s->regs[R_STATUS] |= R_STATUS_STATE_ERROR_MASK;
13191321
LC_FSM_CHANGE_STATE(s, ST_POST_TRANS);
1322+
s->lc_state = LC_STATE_POST_TRANSITION;
13201323
return;
13211324
}
13221325
}
@@ -1364,12 +1367,14 @@ static void ot_lc_ctrl_start_transition(OtLcCtrlState *s)
13641367
"Invalid volatile unlock token");
13651368
s->regs[R_STATUS] |= R_STATUS_TOKEN_ERROR_MASK;
13661369
LC_FSM_CHANGE_STATE(s, ST_POST_TRANS);
1370+
s->lc_state = LC_STATE_POST_TRANSITION;
13671371
}
13681372
} else {
13691373
trace_ot_lc_ctrl_error(s->ot_id,
13701374
"Invalid state(s) for volatile unlock");
13711375
s->regs[R_STATUS] |= R_STATUS_TRANSITION_ERROR_MASK;
13721376
LC_FSM_CHANGE_STATE(s, ST_POST_TRANS);
1377+
s->lc_state = LC_STATE_POST_TRANSITION;
13731378
}
13741379
return;
13751380
}
@@ -1409,6 +1414,7 @@ static void ot_lc_ctrl_start_transition(OtLcCtrlState *s)
14091414
trace_ot_lc_ctrl_error(s->ot_id, "Max transition count reached");
14101415
s->regs[R_STATUS] |= R_STATUS_TRANSITION_COUNT_ERROR_MASK;
14111416
LC_FSM_CHANGE_STATE(s, ST_POST_TRANS);
1417+
s->lc_state = LC_STATE_POST_TRANSITION;
14121418
return;
14131419
}
14141420

@@ -1456,10 +1462,12 @@ static void ot_lc_ctrl_resume_transition(OtLcCtrlState *s)
14561462
trace_ot_lc_ctrl_error(s->ot_id, "Invalid transition");
14571463
s->regs[R_STATUS] |= R_STATUS_TRANSITION_ERROR_MASK;
14581464
LC_FSM_CHANGE_STATE(s, ST_POST_TRANS);
1465+
s->lc_state = LC_STATE_POST_TRANSITION;
14591466
} else if (!ot_lc_ctrl_match_token(s, token)) {
14601467
trace_ot_lc_ctrl_error(s->ot_id, "Invalid OTP token");
14611468
s->regs[R_STATUS] |= R_STATUS_TOKEN_ERROR_MASK;
14621469
LC_FSM_CHANGE_STATE(s, ST_POST_TRANS);
1470+
s->lc_state = LC_STATE_POST_TRANSITION;
14631471
} else {
14641472
trace_ot_lc_ctrl_info(s->ot_id, "Valid token");
14651473

0 commit comments

Comments
 (0)