]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
Merge branch 'master' of http://git.denx.de/u-boot-sunxi
authorTom Rini <trini@ti.com>
Mon, 16 Feb 2015 19:55:50 +0000 (14:55 -0500)
committerTom Rini <trini@ti.com>
Tue, 17 Feb 2015 11:27:44 +0000 (06:27 -0500)
24 files changed:
arch/arm/cpu/armv7/exynos/spl_boot.c
arch/arm/cpu/armv7/omap-common/lowlevel_init.S
arch/arm/cpu/armv7/omap3/lowlevel_init.S
arch/arm/cpu/armv7/start.S
arch/arm/cpu/armv7/sunxi/Makefile
arch/arm/cpu/armv7/sunxi/board.c
arch/arm/cpu/armv7/sunxi/config.mk
arch/arm/cpu/armv7/sunxi/dram_helpers.c [new file with mode: 0644]
arch/arm/cpu/armv7/sunxi/fel_utils.S [new file with mode: 0644]
arch/arm/cpu/armv7/sunxi/u-boot-spl-fel.lds [deleted file]
arch/arm/include/asm/arch-sunxi/dram.h
arch/arm/include/asm/arch-sunxi/sys_proto.h
arch/arm/include/asm/spl.h
arch/arm/include/asm/system.h
board/nokia/rx51/lowlevel_init.S
board/sunxi/Kconfig
board/sunxi/MAINTAINERS
common/spl/spl.c
configs/Ampe_A76_defconfig [new file with mode: 0644]
drivers/usb/musb-new/sunxi.c
drivers/video/sunxi_display.c
include/configs/sunxi-common.h
scripts/Makefile.spl
tools/mksunxiboot.c

index bc237c969fc9eba89e50fe36eb4164bf283c9a07..c7f943eb6a93bc55519744d16647f870f64d5f89 100644 (file)
@@ -309,4 +309,3 @@ void board_init_r(gd_t *id, ulong dest_addr)
        while (1)
                ;
 }
-void save_boot_params(u32 r0, u32 r1, u32 r2, u32 r3) {}
index 86c0e4217478f9d06b00723d7280c6629e465059..e19c7aececddeb30c785c2162b6e0c5579854d82 100644 (file)
@@ -19,7 +19,7 @@
 ENTRY(save_boot_params)
        ldr     r1, =OMAP_SRAM_SCRATCH_BOOT_PARAMS
        str     r0, [r1]
-       bx      lr
+       b       save_boot_params_ret
 ENDPROC(save_boot_params)
 
 ENTRY(set_pl310_ctrl_reg)
index 78577b1d1c75bc0632be5725fea1be4b2d0f8cad..80cb2639f60cc9ca8f3cb5eb338671e252dcb03e 100644 (file)
@@ -23,7 +23,7 @@ ENTRY(save_boot_params)
        ldr     r5, [r0, #0x4]
        and     r5, r5, #0xff
        str     r5, [r4]
-       bx      lr
+       b       save_boot_params_ret
 ENDPROC(save_boot_params)
 #endif
 
index 70048c10aee6736117e078931b75c4b6ba7756a5..9b49ece2d650e199a1ed3415ed2ae47794f20fab 100644 (file)
  *************************************************************************/
 
        .globl  reset
+       .globl  save_boot_params_ret
 
 reset:
-       bl      save_boot_params
+       /* Allow the board to save important registers */
+       b       save_boot_params
+save_boot_params_ret:
        /*
         * disable interrupts (FIQ and IRQ), also set the cpu to SVC32 mode,
         * except if in HYP mode already
@@ -96,7 +99,7 @@ ENDPROC(c_runtime_cpu_setup)
  *
  *************************************************************************/
 ENTRY(save_boot_params)
-       bx      lr                      @ back to my caller
+       b       save_boot_params_ret            @ back to my caller
 ENDPROC(save_boot_params)
        .weak   save_boot_params
 
index 48db7442f4f0b771a6f1865a611aa9cb45975d3d..4bb12ad8bdb06a85ace3de8a3aae769f781bdda0 100644 (file)
@@ -11,6 +11,7 @@ obj-y += timer.o
 obj-y  += board.o
 obj-y  += clock.o
 obj-y  += cpu_info.o
+obj-y  += dram_helpers.o
 obj-y  += pinmux.o
 obj-y  += usbc.o
 obj-$(CONFIG_MACH_SUN6I)       += prcm.o
@@ -38,7 +39,5 @@ obj-$(CONFIG_MACH_SUN5I)      += dram_sun4i.o
 obj-$(CONFIG_MACH_SUN6I)       += dram_sun6i.o
 obj-$(CONFIG_MACH_SUN7I)       += dram_sun4i.o
 obj-$(CONFIG_MACH_SUN8I)       += dram_sun8i.o
-ifdef CONFIG_SPL_FEL
-obj-y  += start.o
-endif
+obj-y  += fel_utils.o
 endif
index 6e28bcd040686a3cc2c36b72cb5f7ff1234da796..c02c0150960c2be2ee2324c680d86d258f09b4f2 100644 (file)
 
 #include <linux/compiler.h>
 
+struct fel_stash {
+       uint32_t sp;
+       uint32_t lr;
+       uint32_t cpsr;
+       uint32_t sctlr;
+       uint32_t vbar;
+       uint32_t cr;
+};
+
+struct fel_stash fel_stash __attribute__((section(".data")));
+
 static int gpio_init(void)
 {
 #if CONFIG_CONS_INDEX == 1 && defined(CONFIG_UART0_PORT_F)
@@ -65,6 +76,12 @@ static int gpio_init(void)
        return 0;
 }
 
+void spl_board_load_image(void)
+{
+       debug("Returning to FEL sp=%x, lr=%x\n", fel_stash.sp, fel_stash.lr);
+       return_to_fel(fel_stash.sp, fel_stash.lr);
+}
+
 void s_init(void)
 {
 #if defined CONFIG_MACH_SUN6I || defined CONFIG_MACH_SUN8I
@@ -95,7 +112,34 @@ void s_init(void)
  */
 u32 spl_boot_device(void)
 {
-       return BOOT_DEVICE_MMC1;
+#ifdef CONFIG_SPL_FEL
+       /*
+        * This is the legacy compile time configuration for a special FEL
+        * enabled build. It has many restrictions and can only boot over USB.
+        */
+       return BOOT_DEVICE_BOARD;
+#else
+       /*
+        * When booting from the SD card, the "eGON.BT0" signature is expected
+        * to be found in memory at the address 0x0004 (see the "mksunxiboot"
+        * tool, which generates this header).
+        *
+        * When booting in the FEL mode over USB, this signature is patched in
+        * memory and replaced with something else by the 'fel' tool. This other
+        * signature is selected in such a way, that it can't be present in a
+        * valid bootable SD card image (because the BROM would refuse to
+        * execute the SPL in this case).
+        *
+        * This branch is just making a decision at runtime whether to load
+        * the main u-boot binary from the SD card (if the "eGON.BT0" signature
+        * is found) or return to the FEL code in the BROM to wait and receive
+        * the main u-boot binary over USB.
+        */
+       if (readl(4) == 0x4E4F4765 && readl(8) == 0x3054422E) /* eGON.BT0 */
+               return BOOT_DEVICE_MMC1;
+       else
+               return BOOT_DEVICE_BOARD;
+#endif
 }
 
 /* No confirmation data available in SPL yet. Hardcode bootmode */
index 00f5ffc68301d8e0e9bb56bffaa1f87745b1b167..76ffec9df6aa87f5625daabfc67aa9ba7d848726 100644 (file)
@@ -1,8 +1,6 @@
 # Build a combined spl + u-boot image
 ifdef CONFIG_SPL
 ifndef CONFIG_SPL_BUILD
-ifndef CONFIG_SPL_FEL
 ALL-y += u-boot-sunxi-with-spl.bin
 endif
 endif
-endif
diff --git a/arch/arm/cpu/armv7/sunxi/dram_helpers.c b/arch/arm/cpu/armv7/sunxi/dram_helpers.c
new file mode 100644 (file)
index 0000000..9a94e1b
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * DRAM init helper functions
+ *
+ * (C) Copyright 2015 Hans de Goede <hdegoede@redhat.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <asm/arch/dram.h>
+
+/*
+ * Wait up to 1s for value to be set in given part of reg.
+ */
+void mctl_await_completion(u32 *reg, u32 mask, u32 val)
+{
+       unsigned long tmo = timer_get_us() + 1000000;
+
+       while ((readl(reg) & mask) != val) {
+               if (timer_get_us() > tmo)
+                       panic("Timeout initialising DRAM\n");
+       }
+}
+
+/*
+ * Test if memory at offset offset matches memory at begin of DRAM
+ */
+bool mctl_mem_matches(u32 offset)
+{
+       /* Try to write different values to RAM at two addresses */
+       writel(0, CONFIG_SYS_SDRAM_BASE);
+       writel(0xaa55aa55, CONFIG_SYS_SDRAM_BASE + offset);
+       /* Check if the same value is actually observed when reading back */
+       return readl(CONFIG_SYS_SDRAM_BASE) ==
+              readl(CONFIG_SYS_SDRAM_BASE + offset);
+}
diff --git a/arch/arm/cpu/armv7/sunxi/fel_utils.S b/arch/arm/cpu/armv7/sunxi/fel_utils.S
new file mode 100644 (file)
index 0000000..bf00335
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Utility functions for FEL mode.
+ *
+ * Copyright (c) 2015 Google, Inc
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <asm-offsets.h>
+#include <config.h>
+#include <asm/system.h>
+#include <linux/linkage.h>
+
+ENTRY(save_boot_params)
+       ldr     r0, =fel_stash
+       str     sp, [r0, #0]
+       str     lr, [r0, #4]
+       mrs     lr, cpsr                @ Read CPSR
+       str     lr, [r0, #8]
+       mrc     p15, 0, lr, c1, c0, 0   @ Read CP15 SCTLR Register
+       str     lr, [r0, #12]
+       mrc     p15, 0, lr, c12, c0, 0  @ Read VBAR
+       str     lr, [r0, #16]
+       mrc     p15, 0, lr, c1, c0, 0   @ Read CP15 Control Register
+       str     lr, [r0, #20]
+       b       save_boot_params_ret
+ENDPROC(save_boot_params)
+
+ENTRY(return_to_fel)
+       mov     sp, r0
+       mov     lr, r1
+       ldr     r0, =fel_stash
+       ldr     r1, [r0, #20]
+       mcr     p15, 0, r1, c1, c0, 0   @ Write CP15 Control Register
+       ldr     r1, [r0, #16]
+       mcr     p15, 0, r1, c12, c0, 0  @ Write VBAR
+       ldr     r1, [r0, #12]
+       mcr     p15, 0, r1, c1, c0, 0   @ Write CP15 SCTLR Register
+       ldr     r1, [r0, #8]
+       msr     cpsr, r1                @ Write CPSR
+       bx      lr
+ENDPROC(return_to_fel)
diff --git a/arch/arm/cpu/armv7/sunxi/u-boot-spl-fel.lds b/arch/arm/cpu/armv7/sunxi/u-boot-spl-fel.lds
deleted file mode 100644 (file)
index 928b7c1..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * (C) Copyright 2013
- * Henrik Nordstrom <henrik@henriknordstrom.net>
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
-OUTPUT_ARCH(arm)
-ENTRY(s_init)
-SECTIONS
-{
-       . = 0x00002000;
-
-       . = ALIGN(4);
-       .text :
-       {
-               *(.text.s_init)
-               *(.text*)
-       }
-
-       . = ALIGN(4);
-       .rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
-
-       . = ALIGN(4);
-       .data : {
-               *(.data*)
-       }
-
-       . = ALIGN(4);
-       .u_boot_list : {
-               KEEP(*(SORT(.u_boot_list*)));
-       }
-
-       . = ALIGN(4);
-       . = .;
-
-       . = ALIGN(4);
-       .rel.dyn : {
-               __rel_dyn_start = .;
-               *(.rel*)
-               __rel_dyn_end = .;
-       }
-
-       .dynsym : {
-               __dynsym_start = .;
-               *(.dynsym)
-       }
-
-       . = ALIGN(4);
-       .note.gnu.build-id :
-       {
-               *(.note.gnu.build-id)
-       }
-       _end = .;
-
-       . = ALIGN(4096);
-       .mmutable : {
-               *(.mmutable)
-       }
-
-       .bss_start __rel_dyn_start (OVERLAY) : {
-               KEEP(*(.__bss_start));
-               __bss_base = .;
-       }
-
-       .bss __bss_base (OVERLAY) : {
-               *(.bss*)
-               . = ALIGN(4);
-               __bss_limit = .;
-       }
-
-       .bss_end __bss_limit (OVERLAY) : {
-               KEEP(*(.__bss_end));
-       }
-
-       /DISCARD/ : { *(.dynstr*) }
-       /DISCARD/ : { *(.dynamic*) }
-       /DISCARD/ : { *(.plt*) }
-       /DISCARD/ : { *(.interp*) }
-       /DISCARD/ : { *(.gnu*) }
-       /DISCARD/ : { *(.note*) }
-}
index 7ff43e6d3a90fa46c35785a92fce4b1818c8168f..aedd1941d5527a4084e1c20d89f2f6b09eb2ceac 100644 (file)
 #endif
 
 unsigned long sunxi_dram_init(void);
-
-/*
- * Wait up to 1s for value to be set in given part of reg.
- */
-static inline void mctl_await_completion(u32 *reg, u32 mask, u32 val)
-{
-       unsigned long tmo = timer_get_us() + 1000000;
-
-       while ((readl(reg) & mask) != val) {
-               if (timer_get_us() > tmo)
-                       panic("Timeout initialising DRAM\n");
-       }
-}
-
-/*
- * Test if memory at offset offset matches memory at begin of DRAM
- */
-static inline bool mctl_mem_matches(u32 offset)
-{
-       /* Try to write different values to RAM at two addresses */
-       writel(0, CONFIG_SYS_SDRAM_BASE);
-       writel(0xaa55aa55, CONFIG_SYS_SDRAM_BASE + offset);
-       /* Check if the same value is actually observed when reading back */
-       return readl(CONFIG_SYS_SDRAM_BASE) ==
-              readl(CONFIG_SYS_SDRAM_BASE + offset);
-}
+void mctl_await_completion(u32 *reg, u32 mask, u32 val);
+bool mctl_mem_matches(u32 offset);
 
 #endif /* _SUNXI_DRAM_H */
index c3e636e1d9b6ae9ce1ff331a9660ad538ecc3028..60a5bd8c850d31ef0e04343e773ee86de081339f 100644 (file)
 
 void sdelay(unsigned long);
 
+/* return_to_fel() - Return to BROM from SPL
+ *
+ * This returns back into the BROM after U-Boot SPL has performed its initial
+ * init. It uses the provided lr and sp to do so.
+ *
+ * @lr:                BROM link register value (return address)
+ * @sp:                BROM stack pointer
+ */
+void return_to_fel(uint32_t lr, uint32_t sp);
+
 #endif
index 8acd7cd1bd5ab539ccef5201607fcfe64aab08a7..17b6f544da79e024a6fb25e9c1405bac420663f4 100644 (file)
@@ -26,10 +26,14 @@ enum {
        BOOT_DEVICE_SPI,
        BOOT_DEVICE_SATA,
        BOOT_DEVICE_I2C,
+       BOOT_DEVICE_BOARD,
        BOOT_DEVICE_NONE
 };
 #endif
 
+/* Board-specific load method */
+void spl_board_load_image(void);
+
 /* Linker symbols. */
 extern char __bss_start[], __bss_end[];
 
index 89f22946895301b09a183ead75503ae4dff0f1b2..7820486df00e50405c31d079c497ecdb6a562ed0 100644 (file)
@@ -142,6 +142,21 @@ void flush_l3_cache(void);
 
 #ifndef __ASSEMBLY__
 
+/**
+ * save_boot_params() - Save boot parameters before starting reset sequence
+ *
+ * If you provide this function it will be called immediately U-Boot starts,
+ * both for SPL and U-Boot proper.
+ *
+ * All registers are unchanged from U-Boot entry. No registers need be
+ * preserved.
+ *
+ * This is not a normal C function. There is no stack. Return by branching to
+ * save_boot_params_ret.
+ *
+ * void save_boot_params(u32 r0, u32 r1, u32 r2, u32 r3);
+ */
+
 #define isb() __asm__ __volatile__ ("" : : : "memory")
 
 #define nop() __asm__ __volatile__("mov\tr0,r0\t@ nop\n\t");
index e25290966c5d85668f4d147a748d6f6b14bb84df..9d4ea1b3f90e68d2670b914bd2f4e82180970f9a 100644 (file)
@@ -37,7 +37,8 @@ ih_magic:             /* IH_MAGIC in big endian from include/image.h */
 
 .global save_boot_params
 save_boot_params:
-
+       /* Get return address */
+       ldr     lr, =save_boot_params_ret
 
 /* Copy valid attached kernel to address KERNEL_ADDRESS */
 
index 4a2158988fc9bce0d1991d51e72586e7c2af5615..3eab81fd12b17fc530595258cbecd2b91d926816 100644 (file)
@@ -149,6 +149,16 @@ config SPL_FEL
        bool "SPL/FEL mode support"
        depends on SPL
        default n
+       help
+         This enables support for Fast Early Loader (FEL) mode. This
+         allows U-Boot to be loaded to the board over USB by the on-chip
+         boot rom. U-Boot should be sent in two parts: SPL first, with
+         'fel write 0x2000 u-boot-spl.bin; fel exe 0x2000' then U-Boot with
+         'fel write 0x4a000000 u-boot.bin; fel exe 0x4a000000'. This option
+         shrinks the amount of SRAM available to SPL, so only enable it if
+         you need FEL. Note that enabling this option only allows FEL to be
+         used; it is still possible to boot U-Boot from boot media. U-Boot
+         SPL detects when it is being loaded using FEL.
 
 config UART0_PORT_F
        bool "UART0 on MicroSD breakout board"
index faa413cb0660678d50162e97f60a1ac36be789de..9a287d3c309aeee81a91f625c59e53e4304b6814 100644 (file)
@@ -46,6 +46,11 @@ S:   Maintained
 F:     board/sunxi/dram_a20_olinuxino_l2.c
 F:     configs/A20-OLinuXino-Lime2_defconfig
 
+AMPE A76 BOARD
+M:     Paul Kocialkowski <contact@paulk.fr>
+S:     Maintained
+F:     configs/Ampe_A76_defconfig
+
 COLOMBUS BOARD
 M:     Maxime Ripard <maxime.ripard@free-electrons.com>
 S:     Maintained
@@ -57,9 +62,7 @@ M:    Hans de Goede <hdegoede@redhat.com>
 S:     Maintained
 F:     include/configs/sun7i.h
 F:     configs/Cubieboard2_defconfig
-F:     configs/Cubieboard2_FEL_defconfig
 F:     configs/Cubietruck_defconfig
-F:     configs/Cubietruck_FEL_defconfig
 
 GEMEI-G9 TABLET
 M:     Priit Laes <plaes@plaes.org>
index daaeb507c467b14cf0f80ecaab46e48064e58672..ded0f304786d275ad3818072ab7019e49a26ba6a 100644 (file)
@@ -228,6 +228,11 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
        case BOOT_DEVICE_SATA:
                spl_sata_load_image();
                break;
+#endif
+#ifdef CONFIG_SPL_BOARD_LOAD_IMAGE
+       case BOOT_DEVICE_BOARD:
+               spl_board_load_image();
+               break;
 #endif
        default:
 #if defined(CONFIG_SPL_SERIAL_SUPPORT) && defined(CONFIG_SPL_LIBCOMMON_SUPPORT)
diff --git a/configs/Ampe_A76_defconfig b/configs/Ampe_A76_defconfig
new file mode 100644 (file)
index 0000000..2054fc3
--- /dev/null
@@ -0,0 +1,15 @@
+CONFIG_SPL=y
+CONFIG_SYS_EXTRA_OPTIONS="CONS_INDEX=2,AXP209_POWER"
+CONFIG_FDTFILE="sun5i-a13-ampe-a76.dtb"
+CONFIG_USB_MUSB_SUNXI=y
+CONFIG_USB0_VBUS_PIN="PG12"
+CONFIG_VIDEO_LCD_MODE="x:800,y:480,depth:18,pclk_khz:33000,le:45,ri:82,up:22,lo:22,hs:1,vs:1,sync:3,vmode:0"
+CONFIG_VIDEO_LCD_POWER="AXP0-0"
+CONFIG_VIDEO_LCD_BL_EN="AXP0-1"
+CONFIG_VIDEO_LCD_BL_PWM="PB2"
++S:CONFIG_ARM=y
++S:CONFIG_ARCH_SUNXI=y
++S:CONFIG_MACH_SUN5I=y
++S:CONFIG_DRAM_CLK=432
++S:CONFIG_DRAM_ZQ=123
++S:CONFIG_DRAM_EMR1=4
index 778916df00b76a56d2bb257a45f53e4b1eedfe5d..4646a3d9fe673b95bff45cbfaca6e9818893c68d 100644 (file)
@@ -145,16 +145,6 @@ static void USBC_ForceIdToHigh(__iomem void *base)
        musb_writel(base, USBC_REG_o_ISCR, reg_val);
 }
 
-static void USBC_ForceVbusValidDisable(__iomem void *base)
-{
-       u32 reg_val;
-
-       reg_val = musb_readl(base, USBC_REG_o_ISCR);
-       reg_val &= ~(0x03 << USBC_BP_ISCR_FORCE_VBUS_VALID);
-       reg_val = USBC_WakeUp_ClearChangeDetect(reg_val);
-       musb_writel(base, USBC_REG_o_ISCR, reg_val);
-}
-
 static void USBC_ForceVbusValidToHigh(__iomem void *base)
 {
        u32 reg_val;
@@ -248,12 +238,11 @@ static int sunxi_musb_init(struct musb *musb)
        if (is_host_enabled(musb)) {
                /* Host mode */
                USBC_ForceIdToLow(musb->mregs);
-               USBC_ForceVbusValidToHigh(musb->mregs);
        } else {
                /* Peripheral mode */
                USBC_ForceIdToHigh(musb->mregs);
-               USBC_ForceVbusValidDisable(musb->mregs);
        }
+       USBC_ForceVbusValidToHigh(musb->mregs);
 
        return 0;
 }
index f5f24fc020bd793d2e1de7914f99d032e55a5743..dbda97e746b97b5dc2a729198738c449e59163c7 100644 (file)
@@ -46,6 +46,7 @@ struct sunxi_display {
        GraphicDevice graphic_device;
        enum sunxi_monitor monitor;
        unsigned int depth;
+       unsigned int fb_size;
 } sunxi_display;
 
 #ifdef CONFIG_VIDEO_HDMI
@@ -1060,6 +1061,11 @@ static const char *sunxi_get_mon_desc(enum sunxi_monitor monitor)
        return NULL; /* never reached */
 }
 
+ulong board_get_usable_ram_top(ulong total_size)
+{
+       return gd->ram_top - CONFIG_SUNXI_MAX_FB_SIZE;
+}
+
 void *video_hw_init(void)
 {
        static GraphicDevice *graphic_device = &sunxi_display.graphic_device;
@@ -1075,10 +1081,6 @@ void *video_hw_init(void)
 
        memset(&sunxi_display, 0, sizeof(struct sunxi_display));
 
-       printf("Reserved %dkB of RAM for Framebuffer.\n",
-              CONFIG_SUNXI_FB_SIZE >> 10);
-       gd->fb_base = gd->ram_top;
-
        video_get_ctfb_res_modes(RES_MODE_1024x768, 24, &mode,
                                 &sunxi_display.depth, &options);
 #ifdef CONFIG_VIDEO_HDMI
@@ -1169,6 +1171,17 @@ void *video_hw_init(void)
                       mode->yres, sunxi_get_mon_desc(sunxi_display.monitor));
        }
 
+       sunxi_display.fb_size =
+               (mode->xres * mode->yres * 4 + 0xfff) & ~0xfff;
+       if (sunxi_display.fb_size > CONFIG_SUNXI_MAX_FB_SIZE) {
+               printf("Error need %dkB for fb, but only %dkB is reserved\n",
+                      sunxi_display.fb_size >> 10,
+                      CONFIG_SUNXI_MAX_FB_SIZE >> 10);
+               return NULL;
+       }
+
+       gd->fb_base = gd->bd->bi_dram[0].start +
+                     gd->bd->bi_dram[0].size - sunxi_display.fb_size;
        sunxi_engines_init();
        sunxi_mode_set(mode, gd->fb_base - CONFIG_SYS_SDRAM_BASE);
 
@@ -1194,6 +1207,7 @@ int sunxi_simplefb_setup(void *blob)
 {
        static GraphicDevice *graphic_device = &sunxi_display.graphic_device;
        int offset, ret;
+       u64 start, size;
        const char *pipeline = NULL;
 
 #ifdef CONFIG_MACH_SUN4I
@@ -1237,6 +1251,20 @@ int sunxi_simplefb_setup(void *blob)
                return 0; /* Keep older kernels working */
        }
 
+       /*
+        * Do not report the framebuffer as free RAM to the OS, note we cannot
+        * use fdt_add_mem_rsv() here, because then it is still seen as RAM,
+        * and e.g. Linux refuses to iomap RAM on ARM, see:
+        * linux/arch/arm/mm/ioremap.c around line 301.
+        */
+       start = gd->bd->bi_dram[0].start;
+       size = gd->bd->bi_dram[0].size - sunxi_display.fb_size;
+       ret = fdt_fixup_memory_banks(blob, &start, &size, 1);
+       if (ret) {
+               eprintf("Cannot setup simplefb: Error reserving memory\n");
+               return ret;
+       }
+
        ret = fdt_setup_simplefb_node(blob, offset, gd->fb_base,
                        graphic_device->winSizeX, graphic_device->winSizeY,
                        graphic_device->winSizeX * graphic_device->gdfBytesPP,
index 09889eeb4433c2f923074aacac49a54ea171d092..5e8885277f0306311cbd5a7b6eb9d3a860278c91 100644 (file)
  */
 #define CONFIG_SUNXI           /* sunxi family */
 #ifdef CONFIG_SPL_BUILD
-#ifndef CONFIG_SPL_FEL
 #define CONFIG_SYS_THUMB_BUILD /* Thumbs mode to save space in SPL */
 #endif
-#endif
 
 #include <asm/arch/cpu.h>      /* get chip and board defs */
 
 #define CONFIG_SPL_SERIAL_SUPPORT
 #define CONFIG_SPL_LIBGENERIC_SUPPORT
 
+#define CONFIG_SPL_BOARD_LOAD_IMAGE
+
 #ifdef CONFIG_SPL_FEL
 
-#define CONFIG_SPL_LDSCRIPT "arch/arm/cpu/armv7/sunxi/u-boot-spl-fel.lds"
-#define CONFIG_SPL_START_S_PATH "arch/arm/cpu/armv7/sunxi"
 #define CONFIG_SPL_TEXT_BASE           0x2000
 #define CONFIG_SPL_MAX_SIZE            0x4000          /* 16 KiB */
 
 
 #ifdef CONFIG_VIDEO
 /*
- * The amount of RAM that is reserved for the FB. This will not show up as
- * RAM to the kernel, but will be reclaimed by a KMS driver in future.
+ * The amount of RAM to keep free at the top of RAM when relocating u-boot,
+ * to use as framebuffer. This must be a multiple of 4096.
  */
-#define CONFIG_SUNXI_FB_SIZE (9 << 20)
+#define CONFIG_SUNXI_MAX_FB_SIZE (9 << 20)
 
 /* Do we want to initialize a simple FB? */
 #define CONFIG_VIDEO_DT_SIMPLEFB
 /* stop x86 thinking in cfbconsole from trying to init a pc keyboard */
 #define CONFIG_VGA_AS_SINGLE_DEVICE
 
-#define CONFIG_SYS_MEM_TOP_HIDE ((CONFIG_SUNXI_FB_SIZE + 0xFFF) & ~0xFFF)
-
 /* To be able to hook simplefb into dt */
 #ifdef CONFIG_VIDEO_DT_SIMPLEFB
 #define CONFIG_OF_BOARD_SETUP
index e4b98811867da5d6ce753cbe578d187caaaf60b5..cc189adc0c604bdb2440dc3b5f9b1bc8e1a8d543 100644 (file)
@@ -154,10 +154,8 @@ ALL-y      += $(obj)/$(BOARD)-spl.bin
 endif
 
 ifdef CONFIG_SUNXI
-ifndef CONFIG_SPL_FEL
 ALL-y  += $(obj)/sunxi-spl.bin
 endif
-endif
 
 ifeq ($(CONFIG_SYS_SOC),"at91")
 ALL-y  += boot.bin
index 1f0fbae8e17dd4432912d95be4883d2dca273772..0035f6ea265d926837ed576418dc81fbed3970c9 100644 (file)
@@ -43,19 +43,19 @@ int gen_check_sum(struct boot_file_head *head_p)
        uint32_t i;
        uint32_t sum;
 
-       length = head_p->length;
+       length = le32_to_cpu(head_p->length);
        if ((length & 0x3) != 0)        /* must 4-byte-aligned */
                return -1;
        buf = (uint32_t *)head_p;
-       head_p->check_sum = STAMP_VALUE;        /* fill stamp */
+       head_p->check_sum = cpu_to_le32(STAMP_VALUE);   /* fill stamp */
        loop = length >> 2;
 
        /* calculate the sum */
        for (i = 0, sum = 0; i < loop; i++)
-               sum += buf[i];
+               sum += le32_to_cpu(buf[i]);
 
        /* write back check sum */
-       head_p->check_sum = sum;
+       head_p->check_sum = cpu_to_le32(sum);
 
        return 0;
 }
@@ -125,10 +125,12 @@ int main(int argc, char *argv[])
        memcpy(img.header.magic, BOOT0_MAGIC, 8);       /* no '0' termination */
        img.header.length =
                ALIGN(file_size + sizeof(struct boot_file_head), BLOCK_SIZE);
+       img.header.b_instruction = cpu_to_le32(img.header.b_instruction);
+       img.header.length = cpu_to_le32(img.header.length);
        gen_check_sum(&img.header);
 
-       count = write(fd_out, &img, img.header.length);
-       if (count != img.header.length) {
+       count = write(fd_out, &img, le32_to_cpu(img.header.length));
+       if (count != le32_to_cpu(img.header.length)) {
                perror("Writing output");
                return EXIT_FAILURE;
        }