9 #include "sw/device/lib/base/multibits.h"
11 #include "lc_ctrl_regs.h"
15 if (lc == NULL || state == NULL) {
19 uint32_t reg = mmio_region_read32(lc->
base_addr, LC_CTRL_LC_STATE_REG_OFFSET);
21 case LC_CTRL_LC_STATE_STATE_VALUE_RAW:
24 case LC_CTRL_LC_STATE_STATE_VALUE_TEST_UNLOCKED0:
27 case LC_CTRL_LC_STATE_STATE_VALUE_TEST_LOCKED0:
30 case LC_CTRL_LC_STATE_STATE_VALUE_TEST_UNLOCKED1:
33 case LC_CTRL_LC_STATE_STATE_VALUE_TEST_LOCKED1:
36 case LC_CTRL_LC_STATE_STATE_VALUE_TEST_UNLOCKED2:
39 case LC_CTRL_LC_STATE_STATE_VALUE_TEST_LOCKED2:
42 case LC_CTRL_LC_STATE_STATE_VALUE_TEST_UNLOCKED3:
45 case LC_CTRL_LC_STATE_STATE_VALUE_TEST_LOCKED3:
48 case LC_CTRL_LC_STATE_STATE_VALUE_TEST_UNLOCKED4:
51 case LC_CTRL_LC_STATE_STATE_VALUE_TEST_LOCKED4:
54 case LC_CTRL_LC_STATE_STATE_VALUE_TEST_UNLOCKED5:
57 case LC_CTRL_LC_STATE_STATE_VALUE_TEST_LOCKED5:
60 case LC_CTRL_LC_STATE_STATE_VALUE_TEST_UNLOCKED6:
63 case LC_CTRL_LC_STATE_STATE_VALUE_TEST_LOCKED6:
66 case LC_CTRL_LC_STATE_STATE_VALUE_TEST_UNLOCKED7:
69 case LC_CTRL_LC_STATE_STATE_VALUE_DEV:
72 case LC_CTRL_LC_STATE_STATE_VALUE_PROD:
75 case LC_CTRL_LC_STATE_STATE_VALUE_PROD_END:
78 case LC_CTRL_LC_STATE_STATE_VALUE_RMA:
81 case LC_CTRL_LC_STATE_STATE_VALUE_SCRAP:
85 case LC_CTRL_LC_STATE_STATE_VALUE_POST_TRANSITION:
88 case LC_CTRL_LC_STATE_STATE_VALUE_ESCALATE:
91 case LC_CTRL_LC_STATE_STATE_VALUE_INVALID:
103 if (lc == NULL || count == NULL) {
108 mmio_region_read32(lc->
base_addr, LC_CTRL_LC_TRANSITION_CNT_REG_OFFSET);
111 if (value == LC_CTRL_LC_TRANSITION_CNT_CNT_MASK) {
121 if (lc == NULL ||
status == NULL) {
125 uint32_t reg = mmio_region_read32(lc->
base_addr, LC_CTRL_STATUS_REG_OFFSET);
195 if (lc == NULL || state == NULL) {
200 mmio_region_read32(lc->
base_addr, LC_CTRL_LC_ID_STATE_REG_OFFSET);
202 case LC_CTRL_LC_ID_STATE_STATE_VALUE_BLANK:
205 case LC_CTRL_LC_ID_STATE_STATE_VALUE_PERSONALIZED:
208 case LC_CTRL_LC_ID_STATE_STATE_VALUE_INVALID:
220 if (lc == NULL || hw_rev == NULL) {
225 mmio_region_read32(lc->
base_addr, LC_CTRL_HW_REVISION0_REG_OFFSET);
227 reg, LC_CTRL_HW_REVISION0_SILICON_CREATOR_ID_FIELD);
229 reg, LC_CTRL_HW_REVISION0_PRODUCT_ID_FIELD);
231 reg, LC_CTRL_HW_REVISION1_REVISION_ID_FIELD);
237 if (lc == NULL || device_id == NULL) {
243 ARRAYSIZE(device_id->data) *
sizeof(uint32_t));
254 LC_CTRL_CLAIM_TRANSITION_IF_REGWEN_REG_OFFSET) == 0) {
258 mmio_region_write32(lc->
base_addr, LC_CTRL_CLAIM_TRANSITION_IF_REG_OFFSET,
261 mmio_region_read32(lc->
base_addr, LC_CTRL_CLAIM_TRANSITION_IF_REG_OFFSET);
264 if (reg != kMultiBitBool8True) {
277 mmio_region_read32(lc->
base_addr, LC_CTRL_CLAIM_TRANSITION_IF_REG_OFFSET);
278 if (reg != kMultiBitBool8True) {
283 mmio_region_write32(lc->
base_addr, LC_CTRL_CLAIM_TRANSITION_IF_REG_OFFSET,
284 kMultiBitBool8False);
299 target = LC_CTRL_TRANSITION_TARGET_STATE_VALUE_RAW;
302 target = LC_CTRL_TRANSITION_TARGET_STATE_VALUE_TEST_UNLOCKED0;
305 target = LC_CTRL_TRANSITION_TARGET_STATE_VALUE_TEST_LOCKED0;
308 target = LC_CTRL_TRANSITION_TARGET_STATE_VALUE_TEST_UNLOCKED1;
311 target = LC_CTRL_TRANSITION_TARGET_STATE_VALUE_TEST_LOCKED1;
314 target = LC_CTRL_TRANSITION_TARGET_STATE_VALUE_TEST_UNLOCKED2;
317 target = LC_CTRL_TRANSITION_TARGET_STATE_VALUE_TEST_LOCKED2;
320 target = LC_CTRL_TRANSITION_TARGET_STATE_VALUE_TEST_UNLOCKED3;
323 target = LC_CTRL_TRANSITION_TARGET_STATE_VALUE_TEST_LOCKED3;
326 target = LC_CTRL_TRANSITION_TARGET_STATE_VALUE_TEST_UNLOCKED4;
329 target = LC_CTRL_TRANSITION_TARGET_STATE_VALUE_TEST_LOCKED4;
332 target = LC_CTRL_TRANSITION_TARGET_STATE_VALUE_TEST_UNLOCKED5;
335 target = LC_CTRL_TRANSITION_TARGET_STATE_VALUE_TEST_LOCKED5;
338 target = LC_CTRL_TRANSITION_TARGET_STATE_VALUE_TEST_UNLOCKED6;
341 target = LC_CTRL_TRANSITION_TARGET_STATE_VALUE_TEST_LOCKED6;
344 target = LC_CTRL_TRANSITION_TARGET_STATE_VALUE_TEST_UNLOCKED7;
347 target = LC_CTRL_TRANSITION_TARGET_STATE_VALUE_DEV;
350 target = LC_CTRL_TRANSITION_TARGET_STATE_VALUE_PROD;
353 target = LC_CTRL_TRANSITION_TARGET_STATE_VALUE_PROD_END;
356 target = LC_CTRL_TRANSITION_TARGET_STATE_VALUE_RMA;
359 target = LC_CTRL_TRANSITION_TARGET_STATE_VALUE_SCRAP;
368 LC_CTRL_TRANSITION_REGWEN_REG_OFFSET)) {
373 mmio_region_write32(lc->
base_addr, LC_CTRL_TRANSITION_TARGET_REG_OFFSET,
377 uint32_t ctrl_reg = 0;
380 ctrl_reg, LC_CTRL_TRANSITION_CTRL_EXT_CLOCK_EN_BIT,
true);
384 ctrl_reg, LC_CTRL_TRANSITION_CTRL_EXT_CLOCK_EN_BIT,
false);
386 mmio_region_write32(lc->
base_addr, LC_CTRL_TRANSITION_CTRL_REG_OFFSET,
391 for (
int i = 0; i <
sizeof(token->data); i +=
sizeof(uint32_t)) {
393 memcpy(&word, &token->data[i],
sizeof(uint32_t));
395 LC_CTRL_TRANSITION_TOKEN_0_REG_OFFSET + i, word);
409 LC_CTRL_TRANSITION_REGWEN_REG_OFFSET)) {
413 mmio_region_write32(lc->
base_addr, LC_CTRL_TRANSITION_CMD_REG_OFFSET, 1);
425 mmio_region_read32(lc->
base_addr, LC_CTRL_TRANSITION_REGWEN_REG_OFFSET);
430 mmio_region_write32(lc->
base_addr, LC_CTRL_OTP_VENDOR_TEST_CTRL_REG_OFFSET,
437 uint32_t *settings) {
438 if (lc == NULL || settings == NULL) {
443 mmio_region_read32(lc->
base_addr, LC_CTRL_TRANSITION_REGWEN_REG_OFFSET);
448 *settings = mmio_region_read32(lc->
base_addr,
449 LC_CTRL_OTP_VENDOR_TEST_CTRL_REG_OFFSET);
461 LC_CTRL_CLAIM_TRANSITION_IF_REGWEN_REG_OFFSET, 0);