xilinx: versal: Add new versal loadpdi command
Versal loadpdi command is used for loading secure & non-secure pdi images. Signed-off-by: T Karthik Reddy <t.karthik.reddy@xilinx.com> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
This commit is contained in:
committed by
Michal Simek
parent
1b208d59ba
commit
526a67eb35
@@ -1962,6 +1962,7 @@ source "board/vscom/baltos/Kconfig"
|
|||||||
source "board/xilinx/Kconfig"
|
source "board/xilinx/Kconfig"
|
||||||
source "board/xilinx/zynq/Kconfig"
|
source "board/xilinx/zynq/Kconfig"
|
||||||
source "board/xilinx/zynqmp/Kconfig"
|
source "board/xilinx/zynqmp/Kconfig"
|
||||||
|
source "board/xilinx/versal/Kconfig"
|
||||||
source "board/phytium/durian/Kconfig"
|
source "board/phytium/durian/Kconfig"
|
||||||
source "board/xen/xenguest_arm64/Kconfig"
|
source "board/xen/xenguest_arm64/Kconfig"
|
||||||
|
|
||||||
|
|||||||
14
board/xilinx/versal/Kconfig
Normal file
14
board/xilinx/versal/Kconfig
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
# Copyright (c) 2020, Xilinx, Inc.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: GPL-2.0
|
||||||
|
|
||||||
|
if ARCH_VERSAL
|
||||||
|
|
||||||
|
config CMD_VERSAL
|
||||||
|
bool "Enable Versal specific commands"
|
||||||
|
default y
|
||||||
|
depends on ZYNQMP_FIRMWARE
|
||||||
|
help
|
||||||
|
Enable Versal specific commands.
|
||||||
|
|
||||||
|
endif
|
||||||
@@ -5,4 +5,5 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
obj-y := board.o
|
obj-y := board.o
|
||||||
|
obj-$(CONFIG_CMD_VERSAL) += cmds.o
|
||||||
obj-y += ../common/board.o
|
obj-y += ../common/board.o
|
||||||
|
|||||||
105
board/xilinx/versal/cmds.c
Normal file
105
board/xilinx/versal/cmds.c
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
// SPDX-License-Identifier: GPL-2.0
|
||||||
|
/*
|
||||||
|
* (C) Copyright 2020 Xilinx, Inc.
|
||||||
|
* Michal Simek <michal.simek@xilinx.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <cpu_func.h>
|
||||||
|
#include <command.h>
|
||||||
|
#include <common.h>
|
||||||
|
#include <log.h>
|
||||||
|
#include <memalign.h>
|
||||||
|
#include <versalpl.h>
|
||||||
|
#include <zynqmp_firmware.h>
|
||||||
|
|
||||||
|
static int do_versal_load_pdi(struct cmd_tbl *cmdtp, int flag, int argc,
|
||||||
|
char * const argv[])
|
||||||
|
{
|
||||||
|
u32 buf_lo, buf_hi;
|
||||||
|
u32 ret_payload[5];
|
||||||
|
ulong addr, *pdi_buf;
|
||||||
|
size_t len;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (argc != cmdtp->maxargs) {
|
||||||
|
debug("pdi_load: incorrect parameters passed\n");
|
||||||
|
return CMD_RET_USAGE;
|
||||||
|
}
|
||||||
|
|
||||||
|
addr = simple_strtol(argv[2], NULL, 16);
|
||||||
|
if (!addr) {
|
||||||
|
debug("pdi_load: zero pdi_data address\n");
|
||||||
|
return CMD_RET_USAGE;
|
||||||
|
}
|
||||||
|
|
||||||
|
len = simple_strtoul(argv[3], NULL, 16);
|
||||||
|
if (!len) {
|
||||||
|
debug("pdi_load: zero size\n");
|
||||||
|
return CMD_RET_USAGE;
|
||||||
|
}
|
||||||
|
|
||||||
|
pdi_buf = (ulong *)ALIGN((ulong)addr, ARCH_DMA_MINALIGN);
|
||||||
|
if ((ulong)addr != (ulong)pdi_buf) {
|
||||||
|
memcpy((void *)pdi_buf, (void *)addr, len);
|
||||||
|
debug("Pdi addr:0x%lx aligned to 0x%lx\n",
|
||||||
|
addr, (ulong)pdi_buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
flush_dcache_range((ulong)pdi_buf, (ulong)pdi_buf + len);
|
||||||
|
|
||||||
|
buf_lo = lower_32_bits((ulong)pdi_buf);
|
||||||
|
buf_hi = upper_32_bits((ulong)pdi_buf);
|
||||||
|
|
||||||
|
ret = xilinx_pm_request(VERSAL_PM_LOAD_PDI, VERSAL_PM_PDI_TYPE, buf_lo,
|
||||||
|
buf_hi, 0, ret_payload);
|
||||||
|
if (ret)
|
||||||
|
printf("PDI load failed with err: 0x%08x\n", ret);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct cmd_tbl cmd_versal_sub[] = {
|
||||||
|
U_BOOT_CMD_MKENT(loadpdi, 4, 1, do_versal_load_pdi, "", ""),
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* do_versal - Handle the "versal" command-line command
|
||||||
|
* @cmdtp: Command data struct pointer
|
||||||
|
* @flag: Command flag
|
||||||
|
* @argc: Command-line argument count
|
||||||
|
* @argv: Array of command-line arguments
|
||||||
|
*
|
||||||
|
* Processes the versal specific commands
|
||||||
|
*
|
||||||
|
* Return: return 0 on success, Error value if command fails.
|
||||||
|
* CMD_RET_USAGE incase of incorrect/missing parameters.
|
||||||
|
*/
|
||||||
|
static int do_versal(struct cmd_tbl *cmdtp, int flag, int argc,
|
||||||
|
char *const argv[])
|
||||||
|
{
|
||||||
|
struct cmd_tbl *c;
|
||||||
|
int ret = CMD_RET_USAGE;
|
||||||
|
|
||||||
|
if (argc < 2)
|
||||||
|
return CMD_RET_USAGE;
|
||||||
|
|
||||||
|
c = find_cmd_tbl(argv[1], &cmd_versal_sub[0],
|
||||||
|
ARRAY_SIZE(cmd_versal_sub));
|
||||||
|
if (c)
|
||||||
|
ret = c->cmd(c, flag, argc, argv);
|
||||||
|
|
||||||
|
return cmd_process_error(c, ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_SYS_LONGHELP
|
||||||
|
static char versal_help_text[] =
|
||||||
|
"loadpdi addr len - Load pdi image\n"
|
||||||
|
"load pdi image at ddr address 'addr' with pdi image size 'len'\n"
|
||||||
|
;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
U_BOOT_CMD(versal, 4, 1, do_versal,
|
||||||
|
"versal sub-system",
|
||||||
|
versal_help_text
|
||||||
|
)
|
||||||
|
|
||||||
Reference in New Issue
Block a user