Commit 435199f38020c294659a44607ca0e1b6f0ed1542

Authored by Heiko Schocher
Committed by Albert ARIBAUD
1 parent 18e8ff18fa

arm, davinci: add support for new spl framework

Signed-off-by: Heiko Schocher <hs@denx.de>
Cc: Albert ARIBAUD <albert.u.boot@aribaud.net>
Cc: Sandeep Paulraj <s-paulraj@ti.com>
Cc: Scott Wood <scottwood@freescale.com>
Signed-off-by: Sandeep Paulraj <s-paulraj@ti.com>

Showing 7 changed files with 158 additions and 3 deletions Side-by-side Diff

... ... @@ -416,9 +416,13 @@
416 416 $(obj)u-boot.dis: $(obj)u-boot
417 417 $(OBJDUMP) -d $< > $@
418 418  
419   -$(obj)u-boot.ubl: $(obj)u-boot-nand.bin
  419 +$(obj)u-boot.ubl: $(obj)spl/u-boot-spl.bin $(obj)u-boot.bin
  420 + $(OBJCOPY) ${OBJCFLAGS} --pad-to=$(PAD_TO) -O binary $(obj)spl/u-boot-spl $(obj)spl/u-boot-spl-pad.bin
  421 + cat $(obj)spl/u-boot-spl-pad.bin $(obj)u-boot.bin > $(obj)u-boot-ubl.bin
420 422 $(obj)tools/mkimage -n $(UBL_CONFIG) -T ublimage \
421   - -e $(CONFIG_SYS_TEXT_BASE) -d $< $@
  423 + -e $(CONFIG_SYS_TEXT_BASE) -d $(obj)u-boot-ubl.bin $(obj)u-boot.ubl
  424 + rm $(obj)u-boot-ubl.bin
  425 + rm $(obj)spl/u-boot-spl-pad.bin
422 426  
423 427 ifeq ($(CONFIG_SANDBOX),y)
424 428 GEN_UBOOT = \
arch/arm/cpu/arm926ejs/davinci/Makefile
... ... @@ -35,6 +35,11 @@
35 35 COBJS-$(CONFIG_SOC_DM646X) += dm646x.o
36 36 COBJS-$(CONFIG_DRIVER_TI_EMAC) += lxt972.o dp83848.o et1011c.o ksz8873.o
37 37  
  38 +ifdef CONFIG_SPL_BUILD
  39 +COBJS-y += spl.o
  40 +COBJS-y += dm365_lowlevel.o
  41 +endif
  42 +
38 43 SOBJS = reset.o
39 44  
40 45 ifndef CONFIG_SKIP_LOWLEVEL_INIT
arch/arm/cpu/arm926ejs/davinci/spl.c
  1 +/*
  2 + * Copyright (C) 2011
  3 + * Heiko Schocher, DENX Software Engineering, hs@denx.de.
  4 + *
  5 + * See file CREDITS for list of people who contributed to this
  6 + * project.
  7 + *
  8 + * This program is free software; you can redistribute it and/or
  9 + * modify it under the terms of the GNU General Public License as
  10 + * published by the Free Software Foundation; either version 2 of
  11 + * the License, or (at your option) any later version.
  12 + *
  13 + * This program is distributed in the hope that it will be useful,
  14 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16 + * GNU General Public License for more details.
  17 + *
  18 + * You should have received a copy of the GNU General Public License
  19 + * along with this program; if not, write to the Free Software
  20 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21 + * MA 02111-1307 USA
  22 + */
  23 +#include <common.h>
  24 +#include <asm/u-boot.h>
  25 +#include <asm/utils.h>
  26 +#include <nand.h>
  27 +#include <asm/arch/dm365_lowlevel.h>
  28 +#include <ns16550.h>
  29 +
  30 +void puts(const char *str)
  31 +{
  32 + while (*str)
  33 + putc(*str++);
  34 +}
  35 +
  36 +void putc(char c)
  37 +{
  38 + if (c == '\n')
  39 + NS16550_putc((NS16550_t)(CONFIG_SYS_NS16550_COM1), '\r');
  40 +
  41 + NS16550_putc((NS16550_t)(CONFIG_SYS_NS16550_COM1), c);
  42 +}
  43 +
  44 +inline void hang(void)
  45 +{
  46 + puts("### ERROR ### Please RESET the board ###\n");
  47 + for (;;)
  48 + ;
  49 +}
  50 +
  51 +void board_init_f(ulong dummy)
  52 +{
  53 + dm36x_lowlevel_init(0);
  54 + relocate_code(CONFIG_SPL_STACK, NULL, CONFIG_SPL_TEXT_BASE);
  55 +}
  56 +
  57 +void board_init_r(gd_t *id, ulong dummy)
  58 +{
  59 +
  60 + nand_init();
  61 + puts("Nand boot...\n");
  62 + nand_boot();
  63 +}
arch/arm/cpu/arm926ejs/start.S
... ... @@ -126,7 +126,15 @@
126 126  
127 127 .globl _TEXT_BASE
128 128 _TEXT_BASE:
  129 +#ifdef CONFIG_NAND_SPL /* deprecated, use instead CONFIG_SPL_BUILD */
129 130 .word CONFIG_SYS_TEXT_BASE
  131 +#else
  132 +#ifdef CONFIG_SPL_BUILD
  133 + .word CONFIG_SPL_TEXT_BASE
  134 +#else
  135 + .word CONFIG_SYS_TEXT_BASE
  136 +#endif
  137 +#endif
130 138  
131 139 /*
132 140 * These are defined in the board-specific linker script.
133 141  
... ... @@ -192,7 +200,15 @@
192 200  
193 201 /* Set stackpointer in internal RAM to call board_init_f */
194 202 call_board_init_f:
  203 +#ifdef CONFIG_NAND_SPL /* deprecated, use instead CONFIG_SPL_BUILD */
195 204 ldr sp, =(CONFIG_SYS_INIT_SP_ADDR)
  205 +#else
  206 +#ifdef CONFIG_SPL_BUILD
  207 + ldr sp, =(CONFIG_SPL_STACK)
  208 +#else
  209 + ldr sp, =(CONFIG_SYS_INIT_SP_ADDR)
  210 +#endif
  211 +#endif
196 212 bic sp, sp, #7 /* 8-byte alignment for ABI compliance */
197 213 ldr r0,=0x00000000
198 214 bl board_init_f
... ... @@ -217,6 +233,7 @@
217 233 mov sp, r4
218 234  
219 235 adr r0, _start
  236 + sub r9, r6, r0 /* r9 <- relocation offset */
220 237 cmp r0, r6
221 238 beq clear_bss /* skip relocation */
222 239 mov r1, r6 /* r1 <- scratch for copy loop */
223 240  
... ... @@ -271,12 +288,17 @@
271 288 #endif
272 289  
273 290 clear_bss:
274   -#ifndef CONFIG_SPL_BUILD
  291 +#ifdef CONFIG_SPL_BUILD
  292 + /* No relocation for SPL */
  293 + ldr r0, =__bss_start
  294 + ldr r1, =__bss_end__
  295 +#else
275 296 ldr r0, _bss_start_ofs
276 297 ldr r1, _bss_end_ofs
277 298 mov r4, r6 /* reloc addr */
278 299 add r0, r0, r4
279 300 add r1, r1, r4
  301 +#endif
280 302 mov r2, #0x00000000 /* clear */
281 303  
282 304 clbss_l:str r2, [r0] /* clear loop... */
... ... @@ -284,6 +306,7 @@
284 306 cmp r0, r1
285 307 bne clbss_l
286 308  
  309 +#ifndef CONFIG_SPL_BUILD
287 310 bl coloured_LED_init
288 311 bl red_led_on
289 312 #endif
... ... @@ -64,4 +64,5 @@
64 64 CONFIG_SPL_NAND_SUPPORT (drivers/mtd/nand/libnand.o)
65 65 CONFIG_SPL_DMA_SUPPORT (drivers/dma/libdma.o)
66 66 CONFIG_SPL_POST_MEM_SUPPORT (post/drivers/memory.o)
  67 +CONFIG_SPL_NAND_LOAD (drivers/mtd/nand/nand_spl_load.o)
drivers/mtd/nand/Makefile
... ... @@ -30,6 +30,9 @@
30 30 ifdef CONFIG_SPL_NAND_SIMPLE
31 31 COBJS-y += nand_spl_simple.o
32 32 endif
  33 +ifdef CONFIG_SPL_NAND_LOAD
  34 +COBJS-y += nand_spl_load.o
  35 +endif
33 36 else
34 37 COBJS-y += nand.o
35 38 COBJS-y += nand_bbt.o
drivers/mtd/nand/nand_spl_load.c
  1 +/*
  2 + * Copyright (C) 2011
  3 + * Heiko Schocher, DENX Software Engineering, hs@denx.de.
  4 + *
  5 + * This program is free software; you can redistribute it and/or
  6 + * modify it under the terms of the GNU General Public License as
  7 + * published by the Free Software Foundation; either version 2 of
  8 + * the License, or (at your option) any later version.
  9 + *
  10 + * This program is distributed in the hope that it will be useful,
  11 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13 + * GNU General Public License for more details.
  14 + *
  15 + * You should have received a copy of the GNU General Public License
  16 + * along with this program; if not, write to the Free Software
  17 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  18 + * MA 02111-1307 USA
  19 + */
  20 +
  21 +#include <common.h>
  22 +#include <nand.h>
  23 +
  24 +/*
  25 + * The main entry for NAND booting. It's necessary that SDRAM is already
  26 + * configured and available since this code loads the main U-Boot image
  27 + * from NAND into SDRAM and starts it from there.
  28 + */
  29 +void nand_boot(void)
  30 +{
  31 + int ret;
  32 + __attribute__((noreturn)) void (*uboot)(void);
  33 +
  34 + /*
  35 + * Load U-Boot image from NAND into RAM
  36 + */
  37 + ret = nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS,
  38 + CONFIG_SYS_NAND_U_BOOT_SIZE,
  39 + (void *)CONFIG_SYS_NAND_U_BOOT_DST);
  40 +
  41 +#ifdef CONFIG_NAND_ENV_DST
  42 + ret = nand_spl_load_image(CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE,
  43 + (void *)CONFIG_NAND_ENV_DST);
  44 +
  45 +#ifdef CONFIG_ENV_OFFSET_REDUND
  46 + ret = nand_spl_load_image(CONFIG_ENV_OFFSET_REDUND, CONFIG_ENV_SIZE,
  47 + (void *)CONFIG_NAND_ENV_DST + CONFIG_ENV_SIZE);
  48 +#endif
  49 +#endif
  50 +
  51 + /*
  52 + * Jump to U-Boot image
  53 + */
  54 + uboot = (void *)CONFIG_SYS_NAND_U_BOOT_START;
  55 + (*uboot)();
  56 +}