diff --git a/arch/arm/cpu/armv8/zynqmp/Kconfig b/arch/arm/cpu/armv8/zynqmp/Kconfig index 1eedb39..a3baae4 100644 --- a/arch/arm/cpu/armv8/zynqmp/Kconfig +++ b/arch/arm/cpu/armv8/zynqmp/Kconfig @@ -41,6 +41,13 @@ config SYS_CONFIG_NAME Based on this option include/configs/.h header will be used for board configuration. +config BOOT_INIT_FILE + string "boot.bin init register filename" + default "" + help + Add register writes to boot.bin format (max 256 pairs). + Expect a table of register-value pairs, e.g. "0x12345678 0x4321" + config ZYNQMP_USB bool "Configure ZynqMP USB" diff --git a/arch/arm/mach-zynq/Kconfig b/arch/arm/mach-zynq/Kconfig index a1175ee..44e16af 100644 --- a/arch/arm/mach-zynq/Kconfig +++ b/arch/arm/mach-zynq/Kconfig @@ -44,4 +44,11 @@ config SYS_CONFIG_NAME config SYS_MALLOC_F_LEN default 0x600 +config BOOT_INIT_FILE + string "boot.bin init register filename" + default "" + help + Add register writes to boot.bin format (max 256 pairs). + Expect a table of register-value pairs, e.g. "0x12345678 0x4321" + endif diff --git a/scripts/Makefile.spl b/scripts/Makefile.spl index e0b0117..03a2f06 100644 --- a/scripts/Makefile.spl +++ b/scripts/Makefile.spl @@ -146,10 +146,10 @@ boot.bin: $(obj)/u-boot-spl.bin FORCE $(call if_changed,mkimage) else ifdef CONFIG_ARCH_ZYNQ -MKIMAGEFLAGS_boot.bin = -T zynqimage +MKIMAGEFLAGS_boot.bin = -T zynqimage -R $(srctree)/$(CONFIG_BOOT_INIT_FILE) endif ifdef CONFIG_ARCH_ZYNQMP -MKIMAGEFLAGS_boot.bin = -T zynqmpimage +MKIMAGEFLAGS_boot.bin = -T zynqmpimage -R $(srctree)/$(CONFIG_BOOT_INIT_FILE) endif spl/boot.bin: $(obj)/u-boot-spl.bin FORCE diff --git a/tools/zynqimage.c b/tools/zynqimage.c index c43bd5d..43876e7 100644 --- a/tools/zynqimage.c +++ b/tools/zynqimage.c @@ -222,6 +222,30 @@ static int zynqimage_check_image_types(uint8_t type) return EXIT_FAILURE; } +static void zynqimage_parse_initparams(struct zynq_header *zynqhdr, + const char *filename) +{ + /* Expect a table of register-value pairs, e.g. "0x12345678 0x4321" */ + FILE *fp = fopen(filename, "r"); + struct zynq_reginit reginit; + unsigned int reg_count = 0; + int r; + + if (!fp) { + fprintf(stderr, "Cannot open initparams file: %s\n", filename); + exit(1); + } + do { + r = fscanf(fp, "%x %x", ®init.address, ®init.data); + if (r == 2) { + zynqhdr->register_init[reg_count] = reginit; + ++reg_count; + } + r = fscanf(fp, "%*[^\n]\n"); /* Skip to next line */ + } while ((r != EOF) && (reg_count < HEADER_REGINITS)); + fclose(fp); +} + static void zynqimage_set_header(void *ptr, struct stat *sbuf, int ifd, struct image_tool_params *params) { @@ -237,6 +261,10 @@ static void zynqimage_set_header(void *ptr, struct stat *sbuf, int ifd, if (params->eflag) zynqhdr->image_load = cpu_to_le32((uint32_t)params->ep); + /* User can pass in text file with init list */ + if (strlen(params->imagename2)) + zynqimage_parse_initparams(zynqhdr, params->imagename2); + zynqhdr->checksum = zynqimage_checksum(zynqhdr); } diff --git a/tools/zynqmpimage.c b/tools/zynqmpimage.c index 3f28eb4..d08144c 100644 --- a/tools/zynqmpimage.c +++ b/tools/zynqmpimage.c @@ -234,6 +234,30 @@ static int zynqmpimage_check_image_types(uint8_t type) return EXIT_FAILURE; } +static void zynqmpimage_parse_initparams(struct zynqmp_header *zynqhdr, + const char *filename) +{ + /* Expect a table of register-value pairs, e.g. "0x12345678 0x4321" */ + FILE *fp = fopen(filename, "r"); + struct zynqmp_reginit reginit; + unsigned int reg_count = 0; + int r; + + if (!fp) { + fprintf(stderr, "Cannot open initparams file: %s\n", filename); + exit(1); + } + do { + r = fscanf(fp, "%x %x", ®init.address, ®init.data); + if (r == 2) { + zynqhdr->register_init[reg_count] = reginit; + ++reg_count; + } + r = fscanf(fp, "%*[^\n]\n"); /* Skip to next line */ + } while ((r != EOF) && (reg_count < HEADER_REGINITS)); + fclose(fp); +} + static void zynqmpimage_set_header(void *ptr, struct stat *sbuf, int ifd, struct image_tool_params *params) { @@ -250,6 +274,10 @@ static void zynqmpimage_set_header(void *ptr, struct stat *sbuf, int ifd, if (params->eflag) zynqhdr->image_load = cpu_to_le32((uint32_t)params->ep); + /* User can pass in text file with init list */ + if (strlen(params->imagename2)) + zynqmpimage_parse_initparams(zynqhdr, params->imagename2); + zynqhdr->checksum = zynqmpimage_checksum(zynqhdr); }