62 lines
1.2 KiB
C
62 lines
1.2 KiB
C
/* SPDX-License-Identifier: (GPL-2.0+ OR MIT) */
|
|
/*
|
|
* common/cmd_rpmb.c
|
|
*
|
|
* Copyright (C) 2020 Amlogic, Inc. All rights reserved.
|
|
*
|
|
*/
|
|
|
|
#include <config.h>
|
|
#include <common.h>
|
|
#include <asm/arch/io.h>
|
|
#include <command.h>
|
|
#include <malloc.h>
|
|
#include <asm/arch/secure_apb.h>
|
|
|
|
static int do_rpmb_state(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
|
|
{
|
|
int nReturn = __LINE__;
|
|
|
|
#define AML_RPMB_STATE (((readl(AO_SEC_GP_CFG7))>>22) & 0x01)
|
|
|
|
char *pARG = getenv("bootconfig");
|
|
char env_cmd[128] = {0};
|
|
|
|
if (!pARG) {
|
|
pARG = getenv("bootargs");
|
|
sprintf(env_cmd,
|
|
"setenv bootargs ${bootargs} androidboot.rpmb_state=%d",
|
|
AML_RPMB_STATE);
|
|
} else {
|
|
sprintf(env_cmd,
|
|
"setenv bootconfig ${bootconfig} androidboot.rpmb_state=%d",
|
|
AML_RPMB_STATE);
|
|
}
|
|
|
|
if (pARG)
|
|
{
|
|
char *pFind = strstr(pARG,"androidboot.rpmb_state");
|
|
if (!pFind)
|
|
{
|
|
run_command(env_cmd,0);
|
|
}
|
|
else
|
|
pFind[23] = AML_RPMB_STATE ? '1':'0';
|
|
|
|
setenv("rpmb_state",AML_RPMB_STATE?"1":"0");
|
|
|
|
nReturn = 0;
|
|
}
|
|
else
|
|
printf("aml log : internal sys error!\n");
|
|
|
|
return nReturn;
|
|
}
|
|
|
|
U_BOOT_CMD(rpmb_state, CONFIG_SYS_MAXARGS, 0, do_rpmb_state,
|
|
"RPMB sub-system",
|
|
"RPMB state\n");
|
|
|
|
|
|
/****************************************************/
|