[Feature][ZXW-311] add lynq nv config support & merge changes for sihai
Only Configure :No
Affected branch: master
Affected module: uboot/ap
Is it affected on both ZXIC and MTK:only ZXIC
Self-test: Yes
Doc Update: No
Change-Id: Ie02a4c5daad09441e82b92c9746d5aff0a603692
diff --git a/boot/common/src/uboot/drivers/peripheral/Makefile b/boot/common/src/uboot/drivers/peripheral/Makefile
index 103b373..2f058a9 100755
--- a/boot/common/src/uboot/drivers/peripheral/Makefile
+++ b/boot/common/src/uboot/drivers/peripheral/Makefile
@@ -42,6 +42,8 @@
COBJS-$(CONFIG_ZX297520V3E_MDL_AB) += peripheral.o
COBJS-$(CONFIG_ZX297520V3E_VEHICLE_DC) += peripheral.o
COBJS-$(CONFIG_ZX297520V3E_VEHICLE_DC_REF) += peripheral.o
+COBJS-$(CONFIG_ZX297520V3E_VEHICLE_DC_REF) += lynq_uboot_nv_cfg.o
+COBJS-$(CONFIG_ZX297520V3E_VEHICLE_DC_REF) += oem_nv_cfg.o
COBJS := $(sort $(COBJS-y))
SRCS := $(COBJS:.o=.c)
diff --git a/boot/common/src/uboot/drivers/peripheral/lynq_uboot_nv_cfg.c b/boot/common/src/uboot/drivers/peripheral/lynq_uboot_nv_cfg.c
new file mode 100755
index 0000000..36fe651
--- /dev/null
+++ b/boot/common/src/uboot/drivers/peripheral/lynq_uboot_nv_cfg.c
@@ -0,0 +1,194 @@
+#include <dma_cfg.h>
+
+#ifdef LYNQ_NV_CFG_SUPPORT
+
+#include "../rsa/drv_rsa.h"
+#include "../hash/drv_hash.h"
+#include "lynq_uboot_nv_cfg.h"
+
+#define LYNQ_ERROR(t) do{BOOT_PRINTF(UBOOT_NOTICE, t);}while(0)
+
+#define DEBUG_LYNQ_NV_CFG 1
+
+#ifdef DEBUG_LYNQ_NV_CFG
+void lynq_hex_display(u32 * buff, int len)
+{
+ int i, pos;
+ char * txt_buffer = malloc(4096);
+ memset(txt_buffer, 0, 4096);
+ pos = 0;
+ BOOT_PRINTF(UBOOT_NOTICE, "display data begin:\n");
+ for(i=0;i<len;i++)
+ {
+ pos += sprintf(txt_buffer+pos, "%08x", buff[i]);
+ //BOOT_PRINTF(UBOOT_NOTICE, "%08x ", buff[i]);
+ if (i % 8 == 7 )
+ {
+ BOOT_PRINTF(UBOOT_NOTICE, "%s\n", txt_buffer);
+ memset(txt_buffer, 0, 4096);
+ pos = 0;
+ }
+ }
+ BOOT_PRINTF(UBOOT_NOTICE, "%s\n", txt_buffer);
+ free(txt_buffer);
+}
+#define LYNQ_DEBUG(t) do{BOOT_PRINTF(UBOOT_NOTICE, t);}while(0)
+#else
+#define lynq_hex_display(...) do{}while(0)
+#define LYNQ_DEBUG(t) do{}while(0)
+#endif
+
+int check_lynq_nv_cfg(void)
+{
+ struct lynq_nv_cfg * tmp_cfg;
+ int content_len, pos, len, x;
+ T_Rsa_Paramter sRSAInput;
+ u32 uiRet = -1;
+ u32 uiHashResArr[4] = {0};
+ u32 uiHashResLen = 0;
+ u32 uiRsaResArr[RSA_U32_LEN] = {0};
+ u32 puiArrPubKey[RSA_U32_LEN*2] = {0};
+ u32 *puiRsaResAddr = NULL;
+ char * tmp_buffer = malloc(MMC_LYNQ_NV_CFG_SIZE*3);
+ memset(tmp_buffer, 0 , MMC_LYNQ_NV_CFG_SIZE*3);
+ tmp_cfg = (struct lynq_nv_cfg *)tmp_buffer;
+ if (sizeof (lynq_nv_cfg_bitmap) <= 0 || sizeof (lynq_nv_cfg_bitmap) != sizeof (oem_nv_cfg_bitmap))
+ {
+ LYNQ_ERROR("got bad bitmap\n");
+ goto fail_exit;
+ }
+ if (sizeof (lynq_nv_cfg_publickey) != LYNQ_NV_CFG_PUBLICKEY_LEN)
+ {
+ LYNQ_ERROR("got bad public key\n");
+ goto fail_exit;
+ }
+ if (sizeof (lynq_nv_cfg_sign) != LYNQ_NV_CFG_SIGN_LEN )
+ {
+ LYNQ_ERROR("got bad sign\n");
+ goto fail_exit;
+ }
+ if (sizeof(lynq_nv_cfg_value) == sizeof(struct lynq_nv_cfg))
+ {
+ pos = 0;
+ len = sizeof(lynq_nv_cfg_value);
+ memcpy(tmp_cfg, lynq_nv_cfg_value, len);
+ pos += len;
+ content_len = ((char*)&tmp_cfg->tail - (char*)&tmp_cfg->head) - sizeof(struct lynq_nv_cfg_header);
+
+ if (tmp_cfg->head.magic_flag == 0xaa55 && tmp_cfg->tail.magic_flag == 0x55aa
+ && tmp_cfg->head.content_len == content_len && tmp_cfg->tail.content_len == content_len
+ && tmp_cfg->head.valid_flag == 1 && tmp_cfg->tail.valid_flag == 1)
+ {
+ len = sizeof (lynq_nv_cfg_version);
+ memcpy(tmp_buffer+pos, lynq_nv_cfg_version, len);
+ pos += len;
+
+ len = sizeof (lynq_nv_cfg_bitmap);
+ memcpy(tmp_buffer+pos, lynq_nv_cfg_bitmap, len);
+ pos += len;
+
+ len = sizeof (oem_nv_cfg_bitmap);
+ memcpy(tmp_buffer+pos, oem_nv_cfg_bitmap, len);
+ pos += len;
+
+ for(x=0; x < sizeof(lynq_nv_cfg_bitmap); x++)
+ {
+ tmp_cfg->content[x] &= lynq_nv_cfg_bitmap[x];
+ }
+
+ memcpy(puiArrPubKey, lynq_nv_cfg_publickey, RSA_BYTE_LEN);
+ memcpy((puiArrPubKey+(RSA_U32_LEN*2 -1)), lynq_nv_cfg_publickey + RSA_BYTE_LEN, sizeof(u32));
+ sRSAInput.udCalMode = RSA_MOD_EXPO_WITH_INIT;
+ sRSAInput.udNbitLen = RAS_BIT_LEN;
+ sRSAInput.udEbitLen = RAS_BIT_LEN;
+ sRSAInput.pudInputM = (u32*)lynq_nv_cfg_sign;
+ sRSAInput.pudInputE = (u32*)puiArrPubKey + RSA_U32_LEN;
+ sRSAInput.pudInputN = ((u32*)puiArrPubKey);
+ sRSAInput.pudOutputP = uiRsaResArr;
+
+ lynq_hex_display(sRSAInput.pudInputE, RSA_U32_LEN);
+ lynq_hex_display(sRSAInput.pudInputN, RSA_U32_LEN);
+ lynq_hex_display(sRSAInput.pudInputM, RSA_U32_LEN);
+
+ uiRet = Rsa_Calculate(sRSAInput);
+ if(uiRet != 0)
+ {
+ LYNQ_ERROR("calc rsa fail\n");
+ goto fail_exit;
+ }
+
+ lynq_hex_display(uiRsaResArr, RSA_U32_LEN);
+
+ uiRet = Hash_Calculate(HASH_MODE_MD5,
+ HASH_SMALL_ENDIAN,
+ (u32*)tmp_buffer,
+ pos,
+ NULL,
+ 0,
+ uiHashResArr,
+ &uiHashResLen);
+ if(uiRet != 0)
+ {
+ LYNQ_ERROR("calc hash fail\n");
+ goto fail_exit;
+ }
+ lynq_hex_display(uiHashResArr, uiHashResLen);
+
+ puiRsaResAddr = sRSAInput.pudOutputP + (RSA_U32_LEN - uiHashResLen);
+
+ if (memcmp(puiRsaResAddr, uiHashResArr, uiHashResLen*sizeof (u32)) != 0)
+ {
+ LYNQ_ERROR("not valid sign\n");
+ goto fail_exit;
+ }
+ }
+ else
+ {
+ LYNQ_ERROR("not valid head\n");
+ goto fail_exit;
+ }
+ }
+ else
+ {
+ LYNQ_ERROR("not valid cfg\n");
+ goto fail_exit;
+ }
+
+ free(tmp_buffer);
+// for (x=0;x<10;x++)
+// udelay (600000);
+// LYNQ_ERROR("cy: lynq_setup_nv_cfg\n");
+ return 0;
+fail_exit:
+ free(tmp_buffer);
+ return -1;
+}
+
+extern char* get_oem_nv_cfg(void);
+void lynq_setup_nv_cfg(void)
+{
+ char * oem_cfg_buff;
+ memset((void*)MMC_LYNQ_NV_CFG_ADDR, 0, MMC_LYNQ_NV_CFG_SIZE);
+ if (sizeof(lynq_nv_cfg_value) <= MMC_LYNQ_NV_CFG_SIZE && check_lynq_nv_cfg() == 0)
+ {
+ oem_cfg_buff = get_oem_nv_cfg();
+ if (oem_cfg_buff != NULL)
+ {
+ memcpy((void*)MMC_LYNQ_NV_CFG_ADDR, oem_cfg_buff, sizeof(lynq_nv_cfg_value));
+ free(oem_cfg_buff);
+ LYNQ_DEBUG("using oem nv cfg\n");
+ }
+ else
+ {
+ memcpy((void*)MMC_LYNQ_NV_CFG_ADDR, lynq_nv_cfg_value, sizeof(lynq_nv_cfg_value));
+ LYNQ_DEBUG("using lynq nv cfg\n");
+ }
+ }
+ else
+ {
+ LYNQ_ERROR("lynq_setup_nv_cfg no valid nv config\n");
+ }
+}
+
+#endif
+
diff --git a/boot/common/src/uboot/drivers/peripheral/lynq_uboot_nv_cfg.h b/boot/common/src/uboot/drivers/peripheral/lynq_uboot_nv_cfg.h
new file mode 100755
index 0000000..d2f0da9
--- /dev/null
+++ b/boot/common/src/uboot/drivers/peripheral/lynq_uboot_nv_cfg.h
@@ -0,0 +1,60 @@
+#ifndef __LYNQ_UBOOT_NV_CFG__H__
+#define __LYNQ_UBOOT_NV_CFG__H__
+
+#define RAS_BIT_LEN 1024
+#define RSA_BYTE_LEN (RAS_BIT_LEN / 8)
+#define RSA_U32_LEN (RSA_BYTE_LEN / sizeof(u32))
+#define LYNQ_NV_CFG_SIGN_LEN RSA_BYTE_LEN
+#define LYNQ_NV_CFG_PUBLICKEY_LEN (RSA_BYTE_LEN + sizeof(u32))
+
+#pragma pack(1)
+
+struct lynq_nv_cfg_header
+{
+ unsigned short magic_flag;
+ unsigned short valid_flag:1;
+ unsigned short content_len:15;
+};
+struct lynq_nv_cfg
+{
+ struct lynq_nv_cfg_header head;
+ unsigned char content[4];
+ struct lynq_nv_cfg_header tail;
+ unsigned int lynq_reserved[1];
+};
+#pragma pack()
+
+static const char lynq_nv_cfg_version[] = "T106_CN_20240617";
+static const char lynq_nv_cfg_value[] = {
+ '\x55', '\xaa', '\x09', '\x00', '\xc0', '\x00', '\x00', '\x00', '\xaa', '\x55', '\x09', '\x00', '\x01', '\x00', '\x3c', '\x00'
+};
+
+static const char lynq_nv_cfg_bitmap[] = {
+ '\xC0', '\x80', '\x80', '\x80'
+};
+static const char oem_nv_cfg_bitmap[] = {
+ '\x40', '\x80', '\x80', '\x80'
+};
+static const char lynq_nv_cfg_publickey[] = {
+ '\x92', '\x95', '\xf0', '\xc7', '\x36', '\x68', '\xad', '\xd0', '\x0f', '\xdb', '\x5c', '\xfd', '\x58', '\xf0', '\xc0', '\xa0',
+ '\x0b', '\x89', '\x6b', '\xa0', '\x05', '\x93', '\xa9', '\xb3', '\x54', '\x0f', '\x68', '\x24', '\x3e', '\x2d', '\xfd', '\x02',
+ '\x05', '\xf7', '\xe7', '\x48', '\xad', '\x39', '\x13', '\x6f', '\x71', '\xef', '\x6e', '\xcf', '\xc6', '\xcf', '\x5f', '\xc9',
+ '\x24', '\xa2', '\xd8', '\x2d', '\x17', '\xd6', '\x2b', '\x96', '\x7b', '\x48', '\x98', '\x12', '\xd5', '\x28', '\x4c', '\x72',
+ '\xcd', '\x34', '\xd5', '\xdb', '\x89', '\x87', '\x34', '\xe2', '\xab', '\x29', '\xe4', '\x56', '\x40', '\xe5', '\x92', '\x76',
+ '\xa5', '\xee', '\xb4', '\xbc', '\x37', '\x93', '\xb7', '\xe4', '\x30', '\x4d', '\x92', '\x7b', '\x2c', '\x11', '\x94', '\xd9',
+ '\x8b', '\xe8', '\x0d', '\x96', '\xed', '\x64', '\xd1', '\x0a', '\x7d', '\x4a', '\xd8', '\x1b', '\xf5', '\x0f', '\x4c', '\xfb',
+ '\x07', '\xde', '\xfa', '\xf9', '\xae', '\x42', '\x68', '\x6d', '\xe9', '\xe4', '\x58', '\x80', '\xdb', '\x0b', '\x84', '\xab',
+ '\x01', '\x00', '\x01', '\x00'
+};
+static const char lynq_nv_cfg_sign[] = {
+ '\xef', '\x87', '\xd6', '\x86', '\xea', '\xe6', '\x7f', '\xbd', '\x01', '\x57', '\xe4', '\x94', '\xfa', '\x86', '\xcd', '\xdb',
+ '\x75', '\xe2', '\xc0', '\x94', '\xe0', '\x3f', '\x30', '\x90', '\x9d', '\x24', '\x6e', '\x29', '\x8f', '\x90', '\x52', '\x86',
+ '\x19', '\xfc', '\x83', '\x7f', '\x1d', '\x9f', '\x32', '\x4b', '\xb9', '\x01', '\x5d', '\xb3', '\xf3', '\xcd', '\x30', '\xc5',
+ '\xf6', '\x2f', '\xc5', '\x68', '\x7e', '\x87', '\xae', '\xf2', '\x70', '\x54', '\xff', '\xe6', '\x60', '\xcb', '\xfe', '\xec',
+ '\x68', '\xaa', '\x01', '\x49', '\xd2', '\x93', '\x7b', '\x6e', '\x31', '\x0f', '\x91', '\xad', '\xdf', '\x81', '\x62', '\x04',
+ '\x36', '\x21', '\x22', '\xb6', '\x79', '\xfd', '\x61', '\xcf', '\x3a', '\xb9', '\x40', '\xba', '\x7c', '\xdf', '\x6e', '\xba',
+ '\x1e', '\xc2', '\x27', '\xb9', '\x49', '\x35', '\xd6', '\x5d', '\xc9', '\xe5', '\xed', '\x27', '\xa4', '\x70', '\x59', '\x41',
+ '\x4c', '\x84', '\x72', '\x7a', '\x06', '\xc7', '\x16', '\xcb', '\x56', '\x6a', '\x39', '\xeb', '\x0f', '\xa9', '\x59', '\xcc'
+};
+
+#endif
diff --git a/boot/common/src/uboot/drivers/peripheral/oem_nv_cfg.c b/boot/common/src/uboot/drivers/peripheral/oem_nv_cfg.c
new file mode 100755
index 0000000..0893035
--- /dev/null
+++ b/boot/common/src/uboot/drivers/peripheral/oem_nv_cfg.c
@@ -0,0 +1,141 @@
+#include <dma_cfg.h>
+
+
+#ifdef LYNQ_NV_CFG_SUPPORT
+#include "../rsa/drv_rsa.h"
+#include "../hash/drv_hash.h"
+#include "lynq_uboot_nv_cfg.h"
+#include "oem_nv_cfg.h"
+
+#define LYNQ_ERROR(t) do{BOOT_PRINTF(UBOOT_NOTICE, t);}while(0)
+
+#define DEBUG_LYNQ_NV_CFG 1
+
+#ifdef DEBUG_LYNQ_NV_CFG
+#define LYNQ_DEBUG(t) do{BOOT_PRINTF(UBOOT_NOTICE, t);}while(0)
+extern void lynq_hex_display(u32 * buff, int len);
+#else
+#define lynq_hex_display(...) do{}while(0)
+#define LYNQ_DEBUG(t) do{}while(0)
+#endif
+
+char* get_oem_nv_cfg(void)
+{
+ struct lynq_nv_cfg * oem_cfg, *lynq_cfg;
+ int content_len, pos, len, x;
+ T_Rsa_Paramter sRSAInput;
+ u32 uiRet = -1;
+ u32 uiHashResArr[4] = {0};
+ u32 uiHashResLen = 0;
+ u32 uiRsaResArr[RSA_U32_LEN] = {0};
+ u32 puiArrPubKey[RSA_U32_LEN*2] = {0};
+ u32 *puiRsaResAddr = NULL;
+ char * tmp_buffer = malloc(MMC_LYNQ_NV_CFG_SIZE*3);
+ memset(tmp_buffer, 0 , MMC_LYNQ_NV_CFG_SIZE*3);
+ oem_cfg = (struct lynq_nv_cfg *)tmp_buffer;
+ lynq_cfg = (struct lynq_nv_cfg *)lynq_nv_cfg_value;
+ if (sizeof (oem_nv_cfg_publickey) != LYNQ_NV_CFG_PUBLICKEY_LEN)
+ {
+ LYNQ_ERROR("got bad oem public key\n");
+ goto fail_exit;
+ }
+ if (sizeof (oem_nv_cfg_sign) != LYNQ_NV_CFG_SIGN_LEN )
+ {
+ LYNQ_ERROR("got bad oem sign\n");
+ goto fail_exit;
+ }
+ if (sizeof(oem_nv_cfg_value) == sizeof(struct lynq_nv_cfg))
+ {
+ pos = 0;
+ len = sizeof(oem_nv_cfg_value);
+ memcpy(oem_cfg, oem_nv_cfg_value, len);
+ pos += len;
+ content_len = ((char*)&oem_cfg->tail - (char*)&oem_cfg->head) - sizeof (struct lynq_nv_cfg_header);
+ if (oem_cfg->head.magic_flag == 0xaa55 && oem_cfg->tail.magic_flag == 0x55aa
+ && oem_cfg->head.content_len == content_len && oem_cfg->tail.content_len == content_len
+ && oem_cfg->head.valid_flag == 1 && oem_cfg->tail.valid_flag == 1)
+ {
+ len = sizeof (oem_nv_cfg_version);
+ memcpy(tmp_buffer+pos, oem_nv_cfg_version, len);
+ pos += len;
+
+ len = sizeof (lynq_nv_cfg_bitmap);
+ memcpy(tmp_buffer+pos, lynq_nv_cfg_bitmap, len);
+ pos += len;
+
+ len = sizeof (oem_nv_cfg_bitmap);
+ memcpy(tmp_buffer+pos, oem_nv_cfg_bitmap, len);
+ pos += len;
+
+ for(x=0; x < sizeof(lynq_nv_cfg_bitmap); x++)
+ {
+ oem_cfg->content[x] &= oem_nv_cfg_bitmap[x];
+ oem_cfg->content[x] |= (lynq_cfg->content[x] & (~lynq_nv_cfg_bitmap[x]));
+ }
+
+ memcpy(puiArrPubKey, oem_nv_cfg_publickey, RSA_BYTE_LEN);
+ memcpy((puiArrPubKey+(RSA_U32_LEN*2 -1)), oem_nv_cfg_publickey + RSA_BYTE_LEN, sizeof(u32));
+ sRSAInput.udCalMode = RSA_MOD_EXPO_WITH_INIT;
+ sRSAInput.udNbitLen = RAS_BIT_LEN;
+ sRSAInput.udEbitLen = RAS_BIT_LEN;
+ sRSAInput.pudInputM = (u32*)oem_nv_cfg_sign;
+ sRSAInput.pudInputE = (u32*)puiArrPubKey + RSA_U32_LEN;
+ sRSAInput.pudInputN = ((u32*)puiArrPubKey);
+ sRSAInput.pudOutputP = uiRsaResArr;
+
+ lynq_hex_display(sRSAInput.pudInputE, RSA_U32_LEN);
+ lynq_hex_display(sRSAInput.pudInputN, RSA_U32_LEN);
+ lynq_hex_display(sRSAInput.pudInputM, RSA_U32_LEN);
+
+ uiRet = Rsa_Calculate(sRSAInput);
+ if(uiRet != 0)
+ {
+ LYNQ_ERROR("oem calc rsa fail\n");
+ goto fail_exit;
+ }
+
+ lynq_hex_display(uiRsaResArr, RSA_U32_LEN);
+
+ uiRet = Hash_Calculate(HASH_MODE_MD5,
+ HASH_SMALL_ENDIAN,
+ (u32*)tmp_buffer,
+ pos,
+ NULL,
+ 0,
+ uiHashResArr,
+ &uiHashResLen);
+ if(uiRet != 0)
+ {
+ LYNQ_ERROR("oem calc hash fail\n");
+ goto fail_exit;
+ }
+ lynq_hex_display(uiHashResArr, uiHashResLen);
+
+ puiRsaResAddr = sRSAInput.pudOutputP + (RSA_U32_LEN - uiHashResLen);
+
+ if (memcmp(puiRsaResAddr, uiHashResArr, uiHashResLen*sizeof (u32)) != 0)
+ {
+ LYNQ_ERROR("not valid oem sign\n");
+ goto fail_exit;
+ }
+ }
+ else
+ {
+ LYNQ_ERROR("not valid oem head\n");
+ goto fail_exit;
+ }
+ }
+ else
+ {
+ LYNQ_ERROR("not valid oem cfg\n");
+ goto fail_exit;
+ }
+
+ return tmp_buffer;
+fail_exit:
+ free(tmp_buffer);
+ return NULL;
+}
+
+#endif
+
diff --git a/boot/common/src/uboot/drivers/peripheral/oem_nv_cfg.h b/boot/common/src/uboot/drivers/peripheral/oem_nv_cfg.h
new file mode 100755
index 0000000..82d0a91
--- /dev/null
+++ b/boot/common/src/uboot/drivers/peripheral/oem_nv_cfg.h
@@ -0,0 +1,32 @@
+#ifndef __OEM_NV_CFG__H__
+#define __OEM_NV_CFG__H__
+
+static const char oem_nv_cfg_version[] = "oem_20240617";
+static const char oem_nv_cfg_value[] = {
+ '\x55', '\xaa', '\x19', '\x00', '\x31', '\x32', '\x33', '\x34', '\x35', '\x36', '\x37', '\x38', '\x39', '\x30', '\x31', '\x32',
+ '\xaa', '\x55', '\x19', '\x00', '\x10', '\x00', '\x00', '\x00'
+};
+
+static const char oem_nv_cfg_publickey[] = {
+ '\x85', '\xb2', '\x39', '\x98', '\x5d', '\x46', '\xb4', '\xc0', '\x7d', '\x30', '\x47', '\x7e', '\xa8', '\x1a', '\x8c', '\xdf',
+ '\x2c', '\x02', '\xdf', '\xb0', '\xeb', '\x95', '\x2b', '\xf0', '\xde', '\x04', '\xe8', '\xcd', '\x4c', '\x94', '\x49', '\x2d',
+ '\xe8', '\xa0', '\xcc', '\x91', '\x6e', '\xb3', '\xba', '\x53', '\x31', '\x21', '\x88', '\xbf', '\xd8', '\x7f', '\xab', '\x24',
+ '\xd4', '\x07', '\x76', '\xb6', '\x23', '\x6c', '\x43', '\x9e', '\x15', '\x4c', '\xc2', '\x67', '\x49', '\x47', '\x02', '\x8b',
+ '\x19', '\x52', '\x29', '\xd2', '\xd7', '\xdb', '\x7e', '\x48', '\xa3', '\x53', '\x03', '\xb9', '\xd6', '\x10', '\xb8', '\x52',
+ '\x18', '\x92', '\xf0', '\x4d', '\x96', '\x62', '\xc0', '\x65', '\x17', '\x51', '\xc0', '\x4c', '\xa1', '\x5c', '\x92', '\xeb',
+ '\x83', '\xc5', '\x61', '\xbe', '\x85', '\x1f', '\x21', '\x16', '\xf1', '\xbc', '\x17', '\xa0', '\xfe', '\x15', '\x03', '\xcf',
+ '\x82', '\x2b', '\xd6', '\x7e', '\x82', '\xdb', '\xfc', '\xd5', '\xe3', '\xc5', '\x9d', '\x73', '\x5d', '\xb1', '\x51', '\xbf',
+ '\x01', '\x00', '\x01', '\x00'
+};
+static const char oem_nv_cfg_sign[] = {
+ '\xc8', '\x48', '\x27', '\x16','\x8e', '\x43', '\x5d', '\xb2', '\x00', '\xac', '\x49', '\x8f','\x0c', '\xef', '\xf0', '\xdb',
+ '\x7d', '\x5c', '\xa9', '\x30','\xe3', '\x7e', '\xbe', '\xbd', '\xe9', '\xa4', '\x20', '\x9f','\x49', '\x65', '\xed', '\x3e',
+ '\x63', '\xfa', '\xeb', '\xbf','\xb9', '\xa6', '\x7f', '\x7e', '\x6e', '\x65', '\xfb', '\x84','\xf5', '\x6b', '\xc8', '\xe0',
+ '\x62', '\x3a', '\x55', '\xc9','\xa9', '\xc1', '\x64', '\x3a', '\xdf', '\x2e', '\xc6', '\xf2','\x5d', '\xcc', '\xa5', '\x28',
+ '\xfd', '\xaa', '\x33', '\x55','\x41', '\x8d', '\x26', '\xc8', '\x8a', '\xba', '\x73', '\x57','\x5c', '\xd5', '\x54', '\xbd',
+ '\x22', '\x7f', '\xcd', '\x04','\x28', '\x1d', '\x94', '\xdf', '\x40', '\x17', '\x89', '\x53','\xf2', '\xef', '\x6c', '\x22',
+ '\x19', '\x49', '\xd8', '\xbd','\xb4', '\xf7', '\x8f', '\x08', '\xd2', '\x08', '\x76', '\xa2','\xc8', '\xc3', '\x96', '\xc4',
+ '\x6d', '\x60', '\x10', '\x3f','\xb6', '\x87', '\x63', '\xec', '\x82', '\x81', '\x19', '\x63','\xac', '\x42', '\xf4', '\xc6'
+};
+
+#endif
diff --git a/boot/common/src/uboot/drivers/peripheral/peripheral.c b/boot/common/src/uboot/drivers/peripheral/peripheral.c
index fe410a9..3898062 100755
--- a/boot/common/src/uboot/drivers/peripheral/peripheral.c
+++ b/boot/common/src/uboot/drivers/peripheral/peripheral.c
@@ -28,6 +28,11 @@
#include <drvs_gpio.h>
#include "common.h"
#include <dma_cfg.h>
+#include "../rsa/drv_rsa.h"
+
+#ifdef LYNQ_NV_CFG_SUPPORT
+extern void lynq_setup_nv_cfg(void);
+#endif
//#include <gpio.h>
@@ -67,9 +72,16 @@
int ret = 0;
ret = power_init();
+ BOOT_PRINTF(UBOOT_NOTICE, "cy: peripheral_init 2\n");
+
+#ifndef LYNQ_NV_CFG_SUPPORT
/*mmc config*/
- REG32(MMC_FLAG_ADDR) &=~0x3;//clear bit0~1
+ REG32(MMC_FLAG_ADDR) &=~0x3;//clear bit0~1
REG32(MMC_FLAG_ADDR) |=((MMC0_USED_EN<<0)|(MMC1_USED_EN<<1));
+#else
+ lynq_setup_nv_cfg();
+#endif
+
/*led*/
/*lcd*/