diff options
Diffstat (limited to 'board/xilinx/zynqmp')
-rw-r--r-- | board/xilinx/zynqmp/Makefile | 10 | ||||
-rw-r--r-- | board/xilinx/zynqmp/cmds.c | 113 | ||||
-rw-r--r-- | board/xilinx/zynqmp/zynqmp.c | 16 |
3 files changed, 101 insertions, 38 deletions
diff --git a/board/xilinx/zynqmp/Makefile b/board/xilinx/zynqmp/Makefile index 05ccd25dce..960b81fc58 100644 --- a/board/xilinx/zynqmp/Makefile +++ b/board/xilinx/zynqmp/Makefile @@ -5,10 +5,18 @@ obj-y := zynqmp.o -hw-platform-y :=$(shell echo $(CONFIG_DEFAULT_DEVICE_TREE)) +ifneq ($(CONFIG_XILINX_PS_INIT_FILE),"") +PS_INIT_FILE := $(shell cd $(srctree); readlink -f $(CONFIG_XILINX_PS_INIT_FILE)) +init-objs := ps_init_gpl.o +spl/board/xilinx/zynqmp/ps_init_gpl.o board/xilinx/zynqmp/ps_init_gpl.o: $(PS_INIT_FILE) + $(CC) $(c_flags) -I $(srctree)/$(src) -c -o $@ $^ +endif +ifeq ($(init-objs),) +hw-platform-y :=$(shell echo $(CONFIG_DEFAULT_DEVICE_TREE)) init-objs := $(if $(wildcard $(srctree)/$(src)/$(hw-platform-y)/psu_init_gpl.c),\ $(hw-platform-y)/psu_init_gpl.o) +endif ifeq ($(init-objs),) ifneq ($(wildcard $(srctree)/$(src)/psu_init_gpl.c),) diff --git a/board/xilinx/zynqmp/cmds.c b/board/xilinx/zynqmp/cmds.c index d914653238..f8c8674f87 100644 --- a/board/xilinx/zynqmp/cmds.c +++ b/board/xilinx/zynqmp/cmds.c @@ -9,24 +9,37 @@ #include <asm/arch/sys_proto.h> #include <asm/io.h> -static int zynqmp_verify_secure(u8 *key_ptr, u8 *src_ptr, u32 len) +static int do_zynqmp_verify_secure(cmd_tbl_t *cmdtp, int flag, int argc, + char * const argv[]) { + u64 src_addr, addr; + u32 len, src_lo, src_hi; + u8 *key_ptr = NULL; int ret; - u32 src_lo, src_hi; u32 key_lo = 0; u32 key_hi = 0; u32 ret_payload[PAYLOAD_ARG_CNT]; - u64 addr; - if ((ulong)src_ptr != ALIGN((ulong)src_ptr, - CONFIG_SYS_CACHELINE_SIZE)) { - printf("Failed: source address not aligned:%p\n", src_ptr); + if (argc < 4) + return CMD_RET_USAGE; + + src_addr = simple_strtoull(argv[2], NULL, 16); + len = simple_strtoul(argv[3], NULL, 16); + + if (argc == 5) + key_ptr = (uint8_t *)(uintptr_t)simple_strtoull(argv[4], + NULL, 16); + + if ((ulong)src_addr != ALIGN((ulong)src_addr, + CONFIG_SYS_CACHELINE_SIZE)) { + printf("Failed: source address not aligned:%lx\n", + (ulong)src_addr); return -EINVAL; } - src_lo = lower_32_bits((ulong)src_ptr); - src_hi = upper_32_bits((ulong)src_ptr); - flush_dcache_range((ulong)src_ptr, (ulong)(src_ptr + len)); + src_lo = lower_32_bits((ulong)src_addr); + src_hi = upper_32_bits((ulong)src_addr); + flush_dcache_range((ulong)src_addr, (ulong)(src_addr + len)); if (key_ptr) { key_lo = lower_32_bits((ulong)key_ptr); @@ -48,6 +61,53 @@ static int zynqmp_verify_secure(u8 *key_ptr, u8 *src_ptr, u32 len) return ret; } +static int do_zynqmp_mmio_read(cmd_tbl_t *cmdtp, int flag, int argc, + char * const argv[]) +{ + u32 read_val, addr; + int ret; + + if (argc != cmdtp->maxargs) + return CMD_RET_USAGE; + + addr = simple_strtoul(argv[2], NULL, 16); + + ret = zynqmp_mmio_read(addr, &read_val); + if (!ret) + printf("mmio read value at 0x%x = 0x%x\n", + addr, read_val); + else + printf("Failed: mmio read\n"); + + return ret; +} + +static int do_zynqmp_mmio_write(cmd_tbl_t *cmdtp, int flag, int argc, + char * const argv[]) +{ + u32 addr, mask, val; + int ret; + + if (argc != cmdtp->maxargs) + return CMD_RET_USAGE; + + addr = simple_strtoul(argv[2], NULL, 16); + mask = simple_strtoul(argv[3], NULL, 16); + val = simple_strtoul(argv[4], NULL, 16); + + ret = zynqmp_mmio_write(addr, mask, val); + if (ret != 0) + printf("Failed: mmio write\n"); + + return ret; +} + +static cmd_tbl_t cmd_zynqmp_sub[] = { + U_BOOT_CMD_MKENT(secure, 5, 0, do_zynqmp_verify_secure, "", ""), + U_BOOT_CMD_MKENT(mmio_read, 3, 0, do_zynqmp_mmio_read, "", ""), + U_BOOT_CMD_MKENT(mmio_write, 5, 0, do_zynqmp_mmio_write, "", ""), +}; + /** * do_zynqmp - Handle the "zynqmp" command-line command * @cmdtp: Command data struct pointer @@ -62,30 +122,18 @@ static int zynqmp_verify_secure(u8 *key_ptr, u8 *src_ptr, u32 len) static int do_zynqmp(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) { - u64 src_addr; - u32 len; - u8 *key_ptr = NULL; - u8 *src_ptr; - int ret; + cmd_tbl_t *c; - if (argc > 5 || argc < 4 || strncmp(argv[1], "secure", 6)) + if (argc < 2) return CMD_RET_USAGE; - src_addr = simple_strtoull(argv[2], NULL, 16); - - len = simple_strtoul(argv[3], NULL, 16); - - if (argc > 4) - key_ptr = (uint8_t *)(uintptr_t)simple_strtoull(argv[4], - NULL, 16); - - src_ptr = (uint8_t *)(uintptr_t)src_addr; + c = find_cmd_tbl(argv[1], &cmd_zynqmp_sub[0], + ARRAY_SIZE(cmd_zynqmp_sub)); - ret = zynqmp_verify_secure(key_ptr, src_ptr, len); - if (ret) - return CMD_RET_FAILURE; - - return CMD_RET_SUCCESS; + if (c) + return c->cmd(c, flag, argc, argv); + else + return CMD_RET_USAGE; } /***************************************************/ @@ -94,11 +142,14 @@ static char zynqmp_help_text[] = "secure src len [key_addr] - verifies secure images of $len bytes\n" " long at address $src. Optional key_addr\n" " can be specified if user key needs to\n" - " be used for decryption\n"; + " be used for decryption\n" + "zynqmp mmio_read address - read from address\n" + "zynqmp mmio_write address mask value - write value after masking to\n" + " address\n"; #endif U_BOOT_CMD( zynqmp, 5, 1, do_zynqmp, - "Verify and load secure images", + "ZynqMP sub-system", zynqmp_help_text ) diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c index 81c10fcf8a..89fac6bb67 100644 --- a/board/xilinx/zynqmp/zynqmp.c +++ b/board/xilinx/zynqmp/zynqmp.c @@ -312,12 +312,16 @@ int board_init(void) #endif #if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_WDT) - if (uclass_get_device(UCLASS_WDT, 0, &watchdog_dev)) { - puts("Watchdog: Not found!\n"); - } else { - wdt_start(watchdog_dev, 0, 0); - puts("Watchdog: Started\n"); + if (uclass_get_device_by_seq(UCLASS_WDT, 0, &watchdog_dev)) { + debug("Watchdog: Not found by seq!\n"); + if (uclass_get_device(UCLASS_WDT, 0, &watchdog_dev)) { + puts("Watchdog: Not found!\n"); + return 0; + } } + + wdt_start(watchdog_dev, 0, 0); + puts("Watchdog: Started\n"); #endif return 0; @@ -419,7 +423,7 @@ int dram_init_banksize(void) int dram_init(void) { - if (fdtdec_setup_memory_size() != 0) + if (fdtdec_setup_mem_size_base() != 0) return -EINVAL; return 0; |