blob: c4dc05182824c713fd23f99dc3dd02a7f4206547 [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001/*
2 ***********************************************************
3 */
4
5#include <common.h>
6#include <asm/io.h>
7#include <sdio.h>
8
9#include "efuse.h"
10
11
12
13void efuse_init(void)
14{
15 //start read efuse all 256bit
16 while((REG32(SYS_EFUSE_BASE + 0x4) & 1) == 1);// bit0=1 ctl is busy
17 REG32(SYS_EFUSE_BASE + 0x4) = 1;
18 while((REG32(SYS_EFUSE_BASE + 0x14) & 2) == 0);//bit1=0 read not over
19}
20
21int get_ddr_flag(void)
22{
23 efuse_struct *psEfuseInfo = NULL;
24 int ddr_flag = 0;
25
26
27 psEfuseInfo = (efuse_struct*)EFUSE_RAM_BASE;
28
29 /* get chip flag */
30 if(((psEfuseInfo->secure_flag >> 8) == ZX297520V3ECO_GW_WINBD_256M_DDR)
31 ||((psEfuseInfo->secure_flag >> 8) == ZX297520V3ECO_ZW_WINBD_256M_DDR)
32 ||((psEfuseInfo->secure_flag >> 8) == ZX297520V3ECO_GW_UNILC_256M_DDR)
33 ||((psEfuseInfo->secure_flag >> 8) == ZX297520V3ECO_ZW_UNILC_256M_DDR)
34 ||((psEfuseInfo->secure_flag >> 8) == ZX297520V3ECO_GW_APM_256M_DDR)
35 ||((psEfuseInfo->secure_flag >> 8) == ZX297520V3ECO_ZW_APM_256M_DDR))
36 {
37 ddr_flag = CHIP_DDR_32M;
38 }
39 else if(((psEfuseInfo->secure_flag >> 8) == ZX297520V3ECO_GW_UNILC_512M_DDR)
40 ||((psEfuseInfo->secure_flag >> 8) == ZX297520V3ECO_GW_APM_512M_DDR)
41 ||((psEfuseInfo->secure_flag >> 8) == ZX297520V3ECO_GW_ESMT_512M_DDR)
42 ||((psEfuseInfo->secure_flag >> 8) == ZX297520V3ECO_ZW_UNILC_512M_DDR)
43 ||((psEfuseInfo->secure_flag >> 8) == ZX297520V3ECO_AZW_UNILC_512M_DDR)
44 ||((psEfuseInfo->secure_flag >> 8) == ZX297520V3ECO_ZW_APM_512M_DDR)
45 ||((psEfuseInfo->secure_flag >> 8) == ZX297520V3ECO_ZW_ESMT_512M_DDR))
46 {
47 ddr_flag = CHIP_DDR_64M;
48 }
lh758261d2023-07-13 05:52:04 -070049 else if(((psEfuseInfo->secure_flag >> 8) == ZX297520V3ECOSC_GW_NYC_2G_DDR)
50 ||((psEfuseInfo->secure_flag >> 8) == ZX297520V3ECOGG_GW_NYC_2G_DDR))
lh9ed821d2023-04-07 01:36:19 -070051 {
52 ddr_flag = CHIP_DDR_256M;
53 }
54 else
55 {
56 ddr_flag = CHIP_DDR_128M;
57 }
58
59 return ddr_flag;
60}
61
62int get_secure_verify_status(void)
63{
64 u32 uiLen;
65 efuse_struct *psEfuseInfo = NULL;
66
67 if((REG32(EFUSE_BYPASS) & 1) == 1) //Secure Verify. 1->Disable, 0->Enable.
68 {
69 return SECURE_VERIFY_DISABLE;
70 }
71
72 /*
73 * 0. Èç¹ûsecure flag²»µÈÓÚ0xFF£¬Í˳ö°²È«boot¡£
74 */
75 psEfuseInfo = (efuse_struct*)EFUSE_RAM_BASE;
76 if((psEfuseInfo->secure_flag & 0xFF) != 0xFF)
77 {
78 return SECURE_VERIFY_DISABLE;
79 }
80
81 /*
82 * 1.´ÓefuseÖжÁ³öpuk_hash[127:0], ÅжÏÈç¹ûÈ«²¿Îª0Í˳ö°²È«boot¡£
83 */
84 for(uiLen = 0; uiLen < 4; uiLen++)
85 {
86 if(psEfuseInfo->puk_hash[uiLen] != 0)
87 {
88 break;
89 }
90 if(uiLen == 3)
91 {
92 return SECURE_VERIFY_DISABLE;
93 }
94 }
95 printf("SecureVerify->enable.\n");
96
97 return SECURE_VERIFY_ENABLE;
98}
99
100
101