Skip to content

Commit a02abe0

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 7d7c5ee commit a02abe0

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
@@ -1284,6 +1284,7 @@ static void ot_lc_ctrl_handle_otp_ack(void *opaque, bool ack)
12841284
s->regs[R_STATUS] |= R_STATUS_OTP_ERROR_MASK;
12851285
}
12861286
LC_FSM_CHANGE_STATE(s, ST_POST_TRANS);
1287+
s->lc_state = LC_STATE_POST_TRANSITION;
12871288
break;
12881289
default:
12891290
g_assert_not_reached();
@@ -1302,6 +1303,7 @@ static void ot_lc_ctrl_program_otp(OtLcCtrlState *s, unsigned lc_tcount,
13021303
__func__);
13031304
s->regs[R_STATUS] |= R_STATUS_OTP_ERROR_MASK;
13041305
LC_FSM_CHANGE_STATE(s, ST_POST_TRANS);
1306+
s->lc_state = LC_STATE_POST_TRANSITION;
13051307
return;
13061308
}
13071309

@@ -1315,6 +1317,7 @@ static void ot_lc_ctrl_program_otp(OtLcCtrlState *s, unsigned lc_tcount,
13151317
trace_ot_lc_ctrl_error(s->ot_id, "OTP program request rejected");
13161318
s->regs[R_STATUS] |= R_STATUS_STATE_ERROR_MASK;
13171319
LC_FSM_CHANGE_STATE(s, ST_POST_TRANS);
1320+
s->lc_state = LC_STATE_POST_TRANSITION;
13181321
return;
13191322
}
13201323
}
@@ -1362,12 +1365,14 @@ static void ot_lc_ctrl_start_transition(OtLcCtrlState *s)
13621365
"Invalid volatile unlock token");
13631366
s->regs[R_STATUS] |= R_STATUS_TOKEN_ERROR_MASK;
13641367
LC_FSM_CHANGE_STATE(s, ST_POST_TRANS);
1368+
s->lc_state = LC_STATE_POST_TRANSITION;
13651369
}
13661370
} else {
13671371
trace_ot_lc_ctrl_error(s->ot_id,
13681372
"Invalid state(s) for volatile unlock");
13691373
s->regs[R_STATUS] |= R_STATUS_TRANSITION_ERROR_MASK;
13701374
LC_FSM_CHANGE_STATE(s, ST_POST_TRANS);
1375+
s->lc_state = LC_STATE_POST_TRANSITION;
13711376
}
13721377
return;
13731378
}
@@ -1407,6 +1412,7 @@ static void ot_lc_ctrl_start_transition(OtLcCtrlState *s)
14071412
trace_ot_lc_ctrl_error(s->ot_id, "Max transition count reached");
14081413
s->regs[R_STATUS] |= R_STATUS_TRANSITION_COUNT_ERROR_MASK;
14091414
LC_FSM_CHANGE_STATE(s, ST_POST_TRANS);
1415+
s->lc_state = LC_STATE_POST_TRANSITION;
14101416
return;
14111417
}
14121418

@@ -1454,10 +1460,12 @@ static void ot_lc_ctrl_resume_transition(OtLcCtrlState *s)
14541460
trace_ot_lc_ctrl_error(s->ot_id, "Invalid transition");
14551461
s->regs[R_STATUS] |= R_STATUS_TRANSITION_ERROR_MASK;
14561462
LC_FSM_CHANGE_STATE(s, ST_POST_TRANS);
1463+
s->lc_state = LC_STATE_POST_TRANSITION;
14571464
} else if (!ot_lc_ctrl_match_token(s, token)) {
14581465
trace_ot_lc_ctrl_error(s->ot_id, "Invalid OTP token");
14591466
s->regs[R_STATUS] |= R_STATUS_TOKEN_ERROR_MASK;
14601467
LC_FSM_CHANGE_STATE(s, ST_POST_TRANS);
1468+
s->lc_state = LC_STATE_POST_TRANSITION;
14611469
} else {
14621470
trace_ot_lc_ctrl_info(s->ot_id, "Valid token");
14631471

0 commit comments

Comments
 (0)