Commit 9d24274509cdd463992dc1fb1a2820d6a4b6d21d
1 parent
22ff7f4d19
Exists in
master
and in
49 other branches
microblaze: Add SPL support
Add support for U-BOOT SPL. NOR and RAM mode are supported. There are 3 images in NOR flash. u-boot.img, dtb and kernel. Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Showing 9 changed files with 219 additions and 2 deletions Side-by-side Diff
arch/microblaze/cpu/Makefile
arch/microblaze/cpu/spl.c
1 | +/* | |
2 | + * (C) Copyright 2013 - 2014 Xilinx, Inc | |
3 | + * | |
4 | + * Michal Simek <michal.simek@xilinx.com> | |
5 | + * | |
6 | + * SPDX-License-Identifier: GPL-2.0+ | |
7 | + */ | |
8 | + | |
9 | +#include <common.h> | |
10 | +#include <image.h> | |
11 | +#include <spl.h> | |
12 | +#include <version.h> | |
13 | +#include <asm/io.h> | |
14 | +#include <asm/u-boot.h> | |
15 | + | |
16 | +DECLARE_GLOBAL_DATA_PTR; | |
17 | + | |
18 | +bool boot_linux; | |
19 | + | |
20 | +u32 spl_boot_device(void) | |
21 | +{ | |
22 | + return BOOT_DEVICE_NOR; | |
23 | +} | |
24 | + | |
25 | +/* Board initialization after bss clearance */ | |
26 | +void spl_board_init(void) | |
27 | +{ | |
28 | + gd = (gd_t *)CONFIG_SPL_STACK_ADDR; | |
29 | + | |
30 | + /* enable console uart printing */ | |
31 | + preloader_console_init(); | |
32 | +} | |
33 | + | |
34 | +#ifdef CONFIG_SPL_OS_BOOT | |
35 | +void __noreturn jump_to_image_linux(void *arg) | |
36 | +{ | |
37 | + debug("Entering kernel arg pointer: 0x%p\n", arg); | |
38 | + typedef void (*image_entry_arg_t)(char *, ulong, ulong) | |
39 | + __attribute__ ((noreturn)); | |
40 | + image_entry_arg_t image_entry = | |
41 | + (image_entry_arg_t)spl_image.entry_point; | |
42 | + | |
43 | + image_entry(NULL, 0, (ulong)arg); | |
44 | +} | |
45 | +#endif /* CONFIG_SPL_OS_BOOT */ | |
46 | + | |
47 | +int spl_start_uboot(void) | |
48 | +{ | |
49 | +#ifdef CONFIG_SPL_OS_BOOT | |
50 | + if (boot_linux) | |
51 | + return 0; | |
52 | +#endif | |
53 | + | |
54 | + return 1; | |
55 | +} |
arch/microblaze/cpu/start.S
... | ... | @@ -22,6 +22,11 @@ |
22 | 22 | */ |
23 | 23 | |
24 | 24 | mts rmsr, r0 /* disable cache */ |
25 | + | |
26 | +#if defined(CONFIG_SPL_BUILD) | |
27 | + addi r1, r0, CONFIG_SPL_STACK_ADDR | |
28 | + addi r1, r1, -4 /* Decrement SP to top of memory */ | |
29 | +#else | |
25 | 30 | addi r1, r0, CONFIG_SYS_INIT_SP_OFFSET |
26 | 31 | addi r1, r1, -4 /* Decrement SP to top of memory */ |
27 | 32 | |
... | ... | @@ -115,6 +120,7 @@ |
115 | 120 | sh r7, r0, r8 |
116 | 121 | rsubi r8, r10, 0x26 |
117 | 122 | sh r6, r0, r8 |
123 | +#endif /* BUILD_SPL */ | |
118 | 124 | |
119 | 125 | /* Flush cache before enable cache */ |
120 | 126 | addik r5, r0, 0 |
121 | 127 | |
122 | 128 | |
... | ... | @@ -139,9 +145,14 @@ |
139 | 145 | cmp r6, r5, r4 /* check if we have reach the end */ |
140 | 146 | bnei r6, 2b |
141 | 147 | 3: /* jumping to board_init */ |
148 | +#ifndef CONFIG_SPL_BUILD | |
142 | 149 | brai board_init_f |
150 | +#else | |
151 | + brai board_init_r | |
152 | +#endif | |
143 | 153 | 1: bri 1b |
144 | 154 | |
155 | +#ifndef CONFIG_SPL_BUILD | |
145 | 156 | /* |
146 | 157 | * Read 16bit little endian |
147 | 158 | */ |
... | ... | @@ -174,4 +185,5 @@ |
174 | 185 | rtsd r15, 8 |
175 | 186 | or r0, r0, r0 |
176 | 187 | .end out16 |
188 | +#endif |
arch/microblaze/cpu/timer.c
... | ... | @@ -34,6 +34,7 @@ |
34 | 34 | } |
35 | 35 | } |
36 | 36 | |
37 | +#ifndef CONFIG_SPL_BUILD | |
37 | 38 | static void timer_isr(void *arg) |
38 | 39 | { |
39 | 40 | timestamp++; |
40 | 41 | |
... | ... | @@ -62,10 +63,15 @@ |
62 | 63 | if (ret) |
63 | 64 | tmr = NULL; |
64 | 65 | } |
65 | - | |
66 | 66 | /* No problem if timer is not found/initialized */ |
67 | 67 | return 0; |
68 | 68 | } |
69 | +#else | |
70 | +int timer_init(void) | |
71 | +{ | |
72 | + return 0; | |
73 | +} | |
74 | +#endif | |
69 | 75 | |
70 | 76 | /* |
71 | 77 | * This function is derived from PowerPC code (read timebase as long long). |
arch/microblaze/cpu/u-boot-spl.lds
1 | +/* | |
2 | + * (C) Copyright 2013 - 2014 Xilinx, Inc | |
3 | + * | |
4 | + * Michal Simek <michal.simek@xilinx.com> | |
5 | + * | |
6 | + * SPDX-License-Identifier: GPL-2.0+ | |
7 | + */ | |
8 | + | |
9 | +#include <asm-offsets.h> | |
10 | + | |
11 | +OUTPUT_ARCH(microblaze) | |
12 | +ENTRY(_start) | |
13 | + | |
14 | +SECTIONS | |
15 | +{ | |
16 | + .text ALIGN(0x4): | |
17 | + { | |
18 | + __text_start = .; | |
19 | + arch/microblaze/cpu/start.o (.text) | |
20 | + *(.text) | |
21 | + *(.text.*) | |
22 | + __text_end = .; | |
23 | + } | |
24 | + | |
25 | + .rodata ALIGN(0x4): | |
26 | + { | |
27 | + __rodata_start = .; | |
28 | + *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) | |
29 | + __rodata_end = .; | |
30 | + } | |
31 | + | |
32 | + .data ALIGN(0x4): | |
33 | + { | |
34 | + __data_start = .; | |
35 | + *(.data) | |
36 | + *(.data.*) | |
37 | + __data_end = .; | |
38 | + } | |
39 | + | |
40 | + .bss ALIGN(0x4): | |
41 | + { | |
42 | + __bss_start = .; | |
43 | + *(.sbss) | |
44 | + *(.scommon) | |
45 | + *(.bss) | |
46 | + *(.bss.*) | |
47 | + *(COMMON) | |
48 | + . = ALIGN(4); | |
49 | + __bss_end = .; | |
50 | + } | |
51 | + __end = . ; | |
52 | +} | |
53 | + | |
54 | +#if defined(CONFIG_SPL_MAX_FOOTPRINT) | |
55 | +ASSERT(__end - _start < (CONFIG_SPL_MAX_FOOTPRINT), \ | |
56 | + "SPL image plus BSS too big"); | |
57 | +#endif |
arch/microblaze/include/asm/spl.h
1 | +/* | |
2 | + * (C) Copyright 2013 - 2014 Xilinx, Inc | |
3 | + * | |
4 | + * Michal Simek <michal.simek@xilinx.com> | |
5 | + * | |
6 | + * SPDX-License-Identifier: GPL-2.0+ | |
7 | + */ | |
8 | + | |
9 | +#ifndef _ASM_MICROBLAZE_SPL_H_ | |
10 | +#define _ASM_MICROBLAZE_SPL_H_ | |
11 | + | |
12 | +#define BOOT_DEVICE_RAM 1 | |
13 | +#define BOOT_DEVICE_NOR 2 | |
14 | +#define BOOT_DEVICE_SPI 3 | |
15 | + | |
16 | +#endif |
arch/microblaze/include/asm/u-boot.h
... | ... | @@ -25,6 +25,7 @@ |
25 | 25 | unsigned long bi_sramstart; /* start of SRAM memory */ |
26 | 26 | unsigned long bi_sramsize; /* size of SRAM memory */ |
27 | 27 | unsigned int bi_baudrate; /* Console Baudrate */ |
28 | + ulong bi_boot_params; /* where this board expects params */ | |
28 | 29 | } bd_t; |
29 | 30 | |
30 | 31 | /* For image.h:image_check_target_arch() */ |
arch/microblaze/lib/board.c
... | ... | @@ -50,10 +50,14 @@ |
50 | 50 | fdtdec_check_fdt, |
51 | 51 | #endif |
52 | 52 | serial_init, |
53 | +#ifndef CONFIG_SPL_BUILD | |
53 | 54 | console_init_f, |
55 | +#endif | |
54 | 56 | display_banner, |
57 | +#ifndef CONFIG_SPL_BUILD | |
55 | 58 | interrupts_init, |
56 | 59 | timer_init, |
60 | +#endif | |
57 | 61 | NULL, |
58 | 62 | }; |
59 | 63 | |
... | ... | @@ -66,7 +70,7 @@ |
66 | 70 | gd = (gd_t *)(CONFIG_SYS_SDRAM_BASE + CONFIG_SYS_GBL_DATA_OFFSET); |
67 | 71 | bd = (bd_t *)(CONFIG_SYS_SDRAM_BASE + CONFIG_SYS_GBL_DATA_OFFSET |
68 | 72 | - GENERATED_BD_INFO_SIZE); |
69 | -#if defined(CONFIG_CMD_FLASH) | |
73 | +#if defined(CONFIG_CMD_FLASH) && !defined(CONFIG_SPL_BUILD) | |
70 | 74 | ulong flash_size = 0; |
71 | 75 | #endif |
72 | 76 | asm ("nop"); /* FIXME gd is not initialize - wait */ |
73 | 77 | |
... | ... | @@ -88,9 +92,12 @@ |
88 | 92 | /* FDT is at end of image */ |
89 | 93 | gd->fdt_blob = (void *)__end; |
90 | 94 | #endif |
95 | + | |
96 | +#ifndef CONFIG_SPL_BUILD | |
91 | 97 | /* Allow the early environment to override the fdt address */ |
92 | 98 | gd->fdt_blob = (void *)getenv_ulong("fdtcontroladdr", 16, |
93 | 99 | (uintptr_t)gd->fdt_blob); |
100 | +#endif | |
94 | 101 | |
95 | 102 | /* |
96 | 103 | * The Malloc area is immediately below the monitor copy in DRAM |
... | ... | @@ -110,6 +117,7 @@ |
110 | 117 | hang(); |
111 | 118 | } |
112 | 119 | |
120 | +#ifndef CONFIG_SPL_BUILD | |
113 | 121 | #ifdef CONFIG_OF_CONTROL |
114 | 122 | /* For now, put this check after the console is ready */ |
115 | 123 | if (fdtdec_prepare_fdt()) |
... | ... | @@ -190,5 +198,6 @@ |
190 | 198 | WATCHDOG_RESET(); |
191 | 199 | main_loop(); |
192 | 200 | } |
201 | +#endif /* CONFIG_SPL_BUILD */ | |
193 | 202 | } |
include/configs/microblaze-generic.h
... | ... | @@ -447,5 +447,65 @@ |
447 | 447 | # undef CONFIG_PHYLIB |
448 | 448 | #endif |
449 | 449 | |
450 | +/* SPL part */ | |
451 | +#define CONFIG_SPL | |
452 | +#define CONFIG_CMD_SPL | |
453 | +#define CONFIG_SPL_FRAMEWORK | |
454 | +#define CONFIG_SPL_LIBCOMMON_SUPPORT | |
455 | +#define CONFIG_SPL_LIBGENERIC_SUPPORT | |
456 | +#define CONFIG_SPL_SERIAL_SUPPORT | |
457 | +#define CONFIG_SPL_BOARD_INIT | |
458 | + | |
459 | +#define CONFIG_SPL_LDSCRIPT "arch/microblaze/cpu/u-boot-spl.lds" | |
460 | + | |
461 | +#define CONFIG_SPL_RAM_DEVICE | |
462 | +#define CONFIG_SPL_NOR_SUPPORT | |
463 | + | |
464 | +/* for booting directly linux */ | |
465 | +#define CONFIG_SPL_OS_BOOT | |
466 | + | |
467 | +#define CONFIG_SYS_OS_BASE (CONFIG_SYS_FLASH_BASE + \ | |
468 | + 0x60000) | |
469 | +#define CONFIG_SYS_FDT_BASE (CONFIG_SYS_FLASH_BASE + \ | |
470 | + 0x40000) | |
471 | +#define CONFIG_SYS_SPL_ARGS_ADDR (CONFIG_SYS_TEXT_BASE + \ | |
472 | + 0x1000000) | |
473 | + | |
474 | +/* SP location before relocation, must use scratch RAM */ | |
475 | +/* BRAM start */ | |
476 | +#define CONFIG_SYS_INIT_RAM_ADDR 0x0 | |
477 | +/* BRAM size - will be generated */ | |
478 | +#define CONFIG_SYS_INIT_RAM_SIZE 0x10000 | |
479 | +/* Stack pointer prior relocation, must situated at on-chip RAM */ | |
480 | +#define CONFIG_SYS_SPL_MALLOC_END (CONFIG_SYS_INIT_RAM_ADDR + \ | |
481 | + CONFIG_SYS_INIT_RAM_SIZE - \ | |
482 | + GENERATED_GBL_DATA_SIZE) | |
483 | + | |
484 | +#define CONFIG_SYS_SPL_MALLOC_SIZE 0x100 | |
485 | + | |
486 | +/* | |
487 | + * The main reason to do it in this way is that MALLOC_START | |
488 | + * can't be defined - common/spl/spl.c | |
489 | + */ | |
490 | +#if (CONFIG_SYS_SPL_MALLOC_SIZE != 0) | |
491 | +# define CONFIG_SYS_SPL_MALLOC_START (CONFIG_SYS_SPL_MALLOC_END - \ | |
492 | + CONFIG_SYS_SPL_MALLOC_SIZE) | |
493 | +# define CONFIG_SPL_STACK_ADDR CONFIG_SYS_SPL_MALLOC_START | |
494 | +#else | |
495 | +# define CONFIG_SPL_STACK_ADDR CONFIG_SYS_SPL_MALLOC_END | |
496 | +#endif | |
497 | + | |
498 | +/* Just for sure that there is a space for stack */ | |
499 | +#define CONFIG_SPL_STACK_SIZE 0x100 | |
500 | + | |
501 | +#define CONFIG_SYS_UBOOT_BASE CONFIG_SYS_FLASH_BASE | |
502 | +#define CONFIG_SYS_UBOOT_START CONFIG_SYS_TEXT_BASE | |
503 | + | |
504 | +#define CONFIG_SPL_MAX_FOOTPRINT (CONFIG_SYS_INIT_RAM_SIZE - \ | |
505 | + CONFIG_SYS_INIT_RAM_ADDR - \ | |
506 | + GENERATED_GBL_DATA_SIZE - \ | |
507 | + CONFIG_SYS_SPL_MALLOC_SIZE - \ | |
508 | + CONFIG_SPL_STACK_SIZE) | |
509 | + | |
450 | 510 | #endif /* __CONFIG_H */ |