|
19 | 19 | #include "printf.h" |
20 | 20 | #include "riscv_hw_if.h" |
21 | 21 | #include "soc_ifc.h" |
| 22 | +#include "lc_ctrl.h" |
22 | 23 | #include "caliptra_ss_lc_ctrl_address_map.h" |
23 | 24 | #include <string.h> |
24 | 25 | #include <stdint.h> |
@@ -65,84 +66,6 @@ void lcc_initilization(){ |
65 | 66 |
|
66 | 67 | } |
67 | 68 |
|
68 | | -void sw_transition_req(uint32_t next_lc_state, |
69 | | - uint32_t token_127_96, |
70 | | - uint32_t token_95_64, |
71 | | - uint32_t token_63_32, |
72 | | - uint32_t token_31_0, |
73 | | - uint32_t conditional) { |
74 | | - uint32_t reg_value; |
75 | | - uint32_t status_val; |
76 | | - uint32_t loop_ctrl; |
77 | | - int trigger_alert = 0; |
78 | | - |
79 | | - VPRINTF(LOW, "Starting sw_transition_req...\n"); |
80 | | - |
81 | | - // Step 1: Set Claim Transition Register |
82 | | - loop_ctrl = 0; |
83 | | - while (loop_ctrl != CLAIM_TRANS_VAL) { |
84 | | - lsu_write_32(LC_CTRL_CLAIM_TRANSITION_IF_OFFSET, CLAIM_TRANS_VAL); |
85 | | - reg_value = lsu_read_32(LC_CTRL_CLAIM_TRANSITION_IF_OFFSET); |
86 | | - loop_ctrl = reg_value & CLAIM_TRANS_VAL; |
87 | | - VPRINTF(LOW, "Claim Mutex Register [0x%08x]: Read 0x%08x, expected 0x%08x\n", |
88 | | - LC_CTRL_CLAIM_TRANSITION_IF_OFFSET, reg_value, CLAIM_TRANS_VAL); |
89 | | - } |
90 | | - VPRINTF(LOW, "LC_CTRL: Mutex successfully acquired.\n"); |
91 | | - |
92 | | - // Step 3: Set Target Lifecycle State |
93 | | - VPRINTF(LOW, "Setting next lifecycle state [0x%08x]: 0x%08x\n", LC_CTRL_TRANSITION_TARGET_OFFSET, next_lc_state); |
94 | | - lsu_write_32(LC_CTRL_TRANSITION_TARGET_OFFSET, next_lc_state); |
95 | | - |
96 | | - // Step 4: Write Transition Tokens |
97 | | - if (conditional == 1) { |
98 | | - VPRINTF(LOW, "Writing tokens: 0x%08x\n", token_127_96); |
99 | | - lsu_write_32(LC_CTRL_TRANSITION_TOKEN_0_OFFSET, token_127_96); |
100 | | - VPRINTF(LOW, "Writing tokens: 0x%08x\n", token_95_64); |
101 | | - lsu_write_32(LC_CTRL_TRANSITION_TOKEN_0_OFFSET, token_95_64); |
102 | | - VPRINTF(LOW, "Writing tokens: 0x%08x\n", token_63_32); |
103 | | - lsu_write_32(LC_CTRL_TRANSITION_TOKEN_0_OFFSET, token_63_32); |
104 | | - VPRINTF(LOW, "Writing tokens: 0x%08x\n", token_31_0); |
105 | | - lsu_write_32(LC_CTRL_TRANSITION_TOKEN_0_OFFSET, token_31_0); |
106 | | - } |
107 | | - |
108 | | - // Step 6: Trigger the Transition Command |
109 | | - VPRINTF(LOW, "Triggering transition command [0x%08x]: 0x1\n", LC_CTRL_TRANSITION_CMD_OFFSET); |
110 | | - lsu_write_32(LC_CTRL_TRANSITION_CMD_OFFSET, 0x1); |
111 | | - |
112 | | - // Step 7: Poll Status Register |
113 | | - VPRINTF(LOW, "Polling status register [0x%08x]...\n", LC_CTRL_STATUS_OFFSET); |
114 | | - while (1) { |
115 | | - status_val = lsu_read_32(LC_CTRL_STATUS_OFFSET); |
116 | | - uint32_t TRANSITION_SUCCESSFUL = ((status_val & 0x8) >> 3); |
117 | | - uint32_t TOKEN_ERROR = ((status_val & 0x40) >> 6); |
118 | | - uint32_t OTP_ERROR = ((status_val & 0x100) >> 8); |
119 | | - uint32_t RMA_ERROR = ((status_val & 0x80) >> 7); |
120 | | - |
121 | | - VPRINTF(LOW, "Status Register: 0x%08x | Transition Successful: %d | Token Error: %d | OTP Error: %d\n", |
122 | | - status_val, TRANSITION_SUCCESSFUL, TOKEN_ERROR, OTP_ERROR); |
123 | | - |
124 | | - if (TRANSITION_SUCCESSFUL) { |
125 | | - VPRINTF(LOW, "Transition successful.\n"); |
126 | | - break; |
127 | | - } |
128 | | - if (TOKEN_ERROR) { |
129 | | - VPRINTF(LOW, "Token error detected.\n"); |
130 | | - break; |
131 | | - } |
132 | | - if (OTP_ERROR) { |
133 | | - VPRINTF(LOW, "OTP error detected.\n"); |
134 | | - break; |
135 | | - } |
136 | | - if (RMA_ERROR) { |
137 | | - VPRINTF(LOW, "FLASH RMA error detected.\n"); |
138 | | - break; |
139 | | - } |
140 | | - } |
141 | | - lsu_write_32(LC_CTRL_CLAIM_TRANSITION_IF_OFFSET, 0x0); |
142 | | - |
143 | | - VPRINTF(LOW, "sw_transition_req completed.\n"); |
144 | | -} |
145 | | - |
146 | 69 | void RAW_to_TESTUNLOCK0(){ |
147 | 70 | uint32_t reg_value; |
148 | 71 | uint32_t status_val; |
|
0 commit comments