summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorMike Looijmans <mike.looijmans@topic.nl>2016-09-20 11:37:24 +0200
committerMichal Simek <michal.simek@xilinx.com>2016-11-15 15:27:37 +0100
commit3b6460809c2a28360029c1c48247648fac4455c9 (patch)
tree02d76f167ac1ed749c116b919657544c8c4caa27 /tools
parent29e0cfb4f77f7aa369136302cee14a91e22dca71 (diff)
downloadu-boot-3b6460809c2a28360029c1c48247648fac4455c9.tar.gz
u-boot-3b6460809c2a28360029c1c48247648fac4455c9.tar.bz2
u-boot-3b6460809c2a28360029c1c48247648fac4455c9.zip
tools: mkimage: Add support for initialization table for Zynq and ZynqMP
The Zynq/ZynqMP boot.bin file contains a region for register initialization data. Filling in proper values in this table can reduce boot time (e.g. about 50ms faster on QSPI boot) and also reduce the size of the SPL binary. The table is a simple text file with register+data on each line. Other lines are simply skipped. The file can be passed to mkimage using the "-R" parameter. It is recommended to add reg init file to board folder. For example: CONFIG_BOOT_INIT_FILE="board/xilinx/zynqmp/xilinx_zynqmp_zcu102/reg.int Signed-off-by: Mike Looijmans <mike.looijmans@topic.nl> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/zynqimage.c28
-rw-r--r--tools/zynqmpimage.c28
2 files changed, 56 insertions, 0 deletions
diff --git a/tools/zynqimage.c b/tools/zynqimage.c
index c43bd5d488..43876e7a30 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", &reginit.address, &reginit.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 3f28eb401d..d08144c2bd 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", &reginit.address, &reginit.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);
}