v1.1.2:add audio and efuse patch

This commit is contained in:
刘可亮
2025-03-14 16:31:58 +08:00
parent fe0b990053
commit 049676e8a8
27 changed files with 380 additions and 119 deletions

View File

@@ -4,14 +4,20 @@
menu "SID Parameter"
depends on AIC_USING_SID
config EFUSE_WRITE_SUPPORT
bool "support efuse write"
default n
config EFUSE_MAX_WORD
int "set efuse max word"
default 64
default 16 if AIC_CHIP_D12X
default 64 if AIC_CHIP_D21X || AIC_CHIP_D13X || AIC_CHIP_G73X
config EFUSE_TIMING_VALUE
hex "set timing value"
default 0x0402FFD8 if AIC_CHIP_D21X
default 0x0402FFD8 if AIC_CHIP_D13X || AIC_CHIP_G73X
default 0x04021FF1 if AIC_CHIP_D12X
default 0x04021FF1 if AIC_CHIP_AIC1606SE
endmenu

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022-2024, ArtInChip Technology Co., Ltd
* Copyright (c) 2022-2025, ArtInChip Technology Co., Ltd
*
* SPDX-License-Identifier: Apache-2.0
*
@@ -26,13 +26,28 @@ static int drv_efuse_init(void)
return RT_TRUE;
}
void drv_efuse_write_enable(void)
{
hal_efuse_write_enable();
}
void drv_efuse_write_disable(void)
{
hal_efuse_write_disable();
}
int drv_efuse_read(u32 addr, void *data, u32 size)
{
u32 wid, wval, rest, cnt;
u8 *pd, *pw;
int ret;
if (hal_efuse_clk_enable()) {
return RT_FALSE;
}
if (hal_efuse_wait_ready()) {
hal_efuse_clk_disable();
LOG_E("eFuse is not ready.\n");
return RT_FALSE;
}
@@ -60,6 +75,8 @@ int drv_efuse_read(u32 addr, void *data, u32 size)
rest -= cnt;
}
hal_efuse_clk_disable();
return (int)(size - rest);
}
@@ -125,6 +142,7 @@ int drv_efuse_read_reserved_2(void *data)
return 0;
}
#ifdef EFUSE_WRITE_SUPPORT
int drv_efuse_program(u32 addr, const void *data, u32 size)
{
u32 wid, wval, rest, cnt;
@@ -132,7 +150,12 @@ int drv_efuse_program(u32 addr, const void *data, u32 size)
u8 *pw;
int ret;
if (hal_efuse_clk_enable()) {
return RT_FALSE;
}
if (hal_efuse_wait_ready()) {
hal_efuse_clk_disable();
LOG_E("eFuse is not ready.\n");
return RT_FALSE;
}
@@ -162,17 +185,40 @@ int drv_efuse_program(u32 addr, const void *data, u32 size)
rest -= cnt;
}
hal_efuse_clk_disable();
return (int)(size - rest);
}
#endif
int drv_sjtag_auth(u32 *key, u32 kwlen)
{
return hal_sjtag_auth(key, kwlen);
int ret;
if (hal_efuse_clk_enable()) {
return RT_FALSE;
}
ret = hal_sjtag_auth(key, kwlen);
hal_efuse_clk_disable();
return ret;
}
int drv_szone_auth(u32 *key, u32 kwlen)
{
return hal_szone_auth(key, kwlen);
int ret;
if (hal_efuse_clk_enable()) {
return RT_FALSE;
}
ret = hal_szone_auth(key, kwlen);
hal_efuse_clk_disable();
return ret;
}
INIT_DEVICE_EXPORT(drv_efuse_init);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022-2024, ArtInChip Technology Co., Ltd
* Copyright (c) 2022-2025, ArtInChip Technology Co., Ltd
*
* SPDX-License-Identifier: Apache-2.0
*
@@ -16,9 +16,11 @@ static void cmd_efuse_help(void)
printf(" efuse help : Get this help.\n");
printf(" efuse dump offset len : Dump data from eFuse offset.\n");
printf(" efuse read addr offset len : Read eFuse data to RAM addr.\n");
#ifdef EFUSE_WRITE_SUPPORT
printf(" efuse write addr offset len : Write data to eFuse from RAM addr.\n");
printf(" efuse writehex offset data : Write data to eFuse from input hex string.\n");
printf(" efuse writestr offset data : Write data to eFuse from input string.\n");
#endif
printf(" efuse authenticate sjtag key : Authenticate secure jtag from hex string key.\n");
printf(" efuse authenticate szone key : Authenticate secure zone from hex string key.\n");
}
@@ -80,6 +82,7 @@ static void cmd_efuse_dump(int argc, char **argv)
printf("\n");
}
#ifdef EFUSE_WRITE_SUPPORT
static void cmd_efuse_write(int argc, char **argv)
{
ulong addr, offset, len;
@@ -155,6 +158,7 @@ static void cmd_efuse_writestr(int argc, char **argv)
printf("Program efuse done.\n");
}
#endif
static void cmd_efuse_authenticate(int argc, char **argv)
{
@@ -203,18 +207,26 @@ static void cmd_efuse_do(int argc, char **argv)
cmd_efuse_dump(argc - 1, &argv[1]);
return;
}
#ifdef EFUSE_WRITE_SUPPORT
if (!strcmp(argv[1], "write")) {
drv_efuse_write_enable();
cmd_efuse_write(argc - 1, &argv[1]);
drv_efuse_write_disable();
return;
}
if (!strcmp(argv[1], "writehex")) {
drv_efuse_write_enable();
cmd_efuse_writehex(argc - 1, &argv[1]);
drv_efuse_write_disable();
return;
}
if (!strcmp(argv[1], "writestr")) {
drv_efuse_write_enable();
cmd_efuse_writestr(argc - 1, &argv[1]);
drv_efuse_write_disable();
return;
}
#endif
if (!strcmp(argv[1], "authenticate")) {
cmd_efuse_authenticate(argc - 1, &argv[1]);
return;