Commit 3641339eff7d45342a5d3443ed7c057c5c62ae29

Authored by Jeffy Chen
Committed by Simon Glass
1 parent 6ae5860942

rockchip: Add support for rk's second level loader

The Rockchip boot ROM could load & run an initial spl loader,
and continue to load a second level boot-loader(which stored
right after the initial loader) when it returns.
Modify idblock generation code to support it.

Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
Acked-by: Simon Glass <sjg@chromium.org>

Showing 4 changed files with 14 additions and 17 deletions Side-by-side Diff

... ... @@ -25,7 +25,7 @@
25 25 *
26 26 * @signature: Signature (must be RKSD_SIGNATURE)
27 27 * @disable_rc4: 0 to use rc4 for boot image, 1 to use plain binary
28   - * @code1_offset: Offset in blocks of the SPL code from this header
  28 + * @init_offset: Offset in blocks of the SPL code from this header
29 29 * block. E.g. 4 means 2KB after the start of this header.
30 30 * Other fields are not used by U-Boot
31 31 */
... ... @@ -33,11 +33,10 @@
33 33 uint32_t signature;
34 34 uint8_t reserved[4];
35 35 uint32_t disable_rc4;
36   - uint16_t code1_offset;
37   - uint16_t code2_offset;
38   - uint8_t reserved1[490];
39   - uint16_t usflashdatasize;
40   - uint16_t ucflashbootsize;
  36 + uint16_t init_offset;
  37 + uint8_t reserved1[492];
  38 + uint16_t init_size;
  39 + uint16_t init_boot_size;
41 40 uint8_t reserved2[2];
42 41 };
43 42  
44 43  
45 44  
... ... @@ -53,18 +52,15 @@
53 52 if (file_size > CONFIG_ROCKCHIP_MAX_SPL_SIZE)
54 53 return -ENOSPC;
55 54  
56   - memset(buf, '\0', RK_CODE1_OFFSET * RK_BLK_SIZE);
  55 + memset(buf, '\0', RK_INIT_OFFSET * RK_BLK_SIZE);
57 56 hdr = (struct header0_info *)buf;
58 57 hdr->signature = RK_SIGNATURE;
59 58 hdr->disable_rc4 = 1;
60   - hdr->code1_offset = RK_CODE1_OFFSET;
61   - hdr->code2_offset = 8;
  59 + hdr->init_offset = RK_INIT_OFFSET;
62 60  
63   - hdr->usflashdatasize = (file_size + RK_BLK_SIZE - 1) / RK_BLK_SIZE;
64   - hdr->usflashdatasize = (hdr->usflashdatasize + 3) & ~3;
65   - hdr->ucflashbootsize = hdr->usflashdatasize;
66   -
67   - debug("size=%x, %x\n", params->file_size, hdr->usflashdatasize);
  61 + hdr->init_size = (file_size + RK_BLK_SIZE - 1) / RK_BLK_SIZE;
  62 + hdr->init_size = (hdr->init_size + 3) & ~3;
  63 + hdr->init_boot_size = hdr->init_size + RK_MAX_BOOT_SIZE / RK_BLK_SIZE;
68 64  
69 65 rc4_encode(buf, RK_BLK_SIZE, rc4_key);
70 66  
... ... @@ -10,7 +10,8 @@
10 10  
11 11 enum {
12 12 RK_BLK_SIZE = 512,
13   - RK_CODE1_OFFSET = 4,
  13 + RK_INIT_OFFSET = 4,
  14 + RK_MAX_BOOT_SIZE = 512 << 10,
14 15 };
15 16  
16 17 /**
... ... @@ -14,7 +14,7 @@
14 14 #include "rkcommon.h"
15 15  
16 16 enum {
17   - RKSD_SPL_HDR_START = RK_CODE1_OFFSET * RK_BLK_SIZE,
  17 + RKSD_SPL_HDR_START = RK_INIT_OFFSET * RK_BLK_SIZE,
18 18 RKSD_SPL_START = RKSD_SPL_HDR_START + 4,
19 19 RKSD_HEADER_LEN = RKSD_SPL_START,
20 20 };
... ... @@ -14,7 +14,7 @@
14 14 #include "rkcommon.h"
15 15  
16 16 enum {
17   - RKSPI_SPL_HDR_START = RK_CODE1_OFFSET * RK_BLK_SIZE,
  17 + RKSPI_SPL_HDR_START = RK_INIT_OFFSET * RK_BLK_SIZE,
18 18 RKSPI_SPL_START = RKSPI_SPL_HDR_START + 4,
19 19 RKSPI_HEADER_LEN = RKSPI_SPL_START,
20 20 RKSPI_SECT_LEN = RK_BLK_SIZE * 4,