Merge branch 'master' of git://git.denx.de/u-boot-fdt
authorTom Rini <trini@ti.com>
Wed, 18 Feb 2015 13:46:50 +0000 (08:46 -0500)
committerTom Rini <trini@ti.com>
Wed, 18 Feb 2015 13:46:50 +0000 (08:46 -0500)
98 files changed:
.travis.yml
Makefile
arch/arm/cpu/armv7/am33xx/clock_am43xx.c
arch/arm/cpu/armv7/exynos/spl_boot.c
arch/arm/cpu/armv7/keystone/ddr3.c
arch/arm/cpu/armv7/omap-common/emif-common.c
arch/arm/cpu/armv7/omap-common/lowlevel_init.S
arch/arm/cpu/armv7/omap3/lowlevel_init.S
arch/arm/cpu/armv7/omap5/sdram.c
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-am33xx/cpu.h
arch/arm/include/asm/arch-keystone/ddr3.h
arch/arm/include/asm/arch-lpc32xx/config.h
arch/arm/include/asm/arch-sunxi/dram.h
arch/arm/include/asm/arch-sunxi/sys_proto.h
arch/arm/include/asm/emif.h
arch/arm/include/asm/spl.h
arch/arm/include/asm/system.h
arch/arm/lib/Makefile
arch/arm/lib/stack.c [new file with mode: 0644]
arch/avr32/config.mk
arch/avr32/cpu/Makefile
arch/avr32/cpu/at32ap700x/mmu.c
arch/avr32/cpu/cpu.c
arch/avr32/cpu/exception.c
arch/avr32/cpu/mmc.c [new file with mode: 0644]
arch/avr32/cpu/u-boot.lds
arch/avr32/include/asm/arch-at32ap700x/mmu.h
arch/avr32/include/asm/config.h
arch/avr32/include/asm/dma-mapping.h
arch/avr32/include/asm/global_data.h
arch/avr32/include/asm/u-boot.h
arch/avr32/lib/Makefile
arch/avr32/lib/board.c
arch/avr32/lib/dram_init.c [new file with mode: 0644]
arch/avr32/lib/interrupts.c
arch/powerpc/lib/Makefile
arch/powerpc/lib/stack.c [new file with mode: 0644]
board/atmel/atngw100/atngw100.c
board/atmel/atngw100mkii/atngw100mkii.c
board/atmel/atstk1000/atstk1000.c
board/earthlcd/favr-32-ezkit/favr-32-ezkit.c
board/in-circuit/grasshopper/grasshopper.c
board/keymile/common/common.h
board/keymile/common/ivm.c
board/keymile/km82xx/km82xx.c
board/keymile/km83xx/km83xx.c
board/keymile/km_arm/km_arm.c
board/keymile/kmp204x/kmp204x.c
board/mimc/mimc200/mimc200.c
board/miromico/hammerhead/hammerhead.c
board/nokia/rx51/lowlevel_init.S
board/sunxi/Kconfig
board/sunxi/MAINTAINERS
board/ti/beagle_x15/board.c
board/ti/ks2_evm/board.c
board/ti/ks2_evm/ddr3_k2e.c
board/ti/ks2_evm/ddr3_k2hk.c
board/ti/ks2_evm/ddr3_k2l.c
common/board_f.c
common/board_r.c
common/cmd_bdinfo.c
common/image-fit.c
common/image-sig.c
common/spl/spl.c
common/spl/spl_nor.c
configs/Ampe_A76_defconfig [new file with mode: 0644]
drivers/mtd/nand/omap_gpmc.c
drivers/net/keystone_net.c
drivers/pci/pci_auto.c
drivers/usb/musb-new/sunxi.c
drivers/video/sunxi_display.c
include/asm-generic/u-boot.h
include/common.h
include/config_distro_bootcmd.h
include/configs/atngw100.h
include/configs/atngw100mkii.h
include/configs/atstk1002.h
include/configs/atstk1006.h
include/configs/favr-32-ezkit.h
include/configs/grasshopper.h
include/configs/hammerhead.h
include/configs/km82xx.h
include/configs/mimc200.h
include/configs/sunxi-common.h
scripts/Makefile.spl
tools/Makefile
tools/env/fw_env.config
tools/imagetool.c
tools/imagetool.h
tools/imagetool.lds [deleted file]
tools/mksunxiboot.c

index 90f0fd7615eaa134ced178c88e9caf2905dee0ef..923c9ddc3efdba52d3a2e989ac7b8c85528e17de 100644 (file)
@@ -106,9 +106,6 @@ matrix:
     - env:
         - TEST_CMD="tools/buildman/buildman mpc512x"
           INSTALL_TOOLCHAIN="ppc"
-    - env:
-        - TEST_CMD="tools/buildman/buildman mpc824x"
-          INSTALL_TOOLCHAIN="ppc"
     - env:
         - TEST_CMD="tools/buildman/buildman mpc8260"
           INSTALL_TOOLCHAIN="ppc"
index 6da42157b5d6da8d9d0378d8f7a3ac4e1982eed4..bd4ababe001a89bd00c5bd90238f100ac75ffec9 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
 VERSION = 2015
 PATCHLEVEL = 04
 SUBLEVEL =
-EXTRAVERSION = -rc1
+EXTRAVERSION = -rc2
 NAME =
 
 # *DOCUMENTATION*
@@ -281,6 +281,11 @@ os_x_before        = $(shell if [ $(DARWIN_MAJOR_VERSION) -le $(1) -a \
 HOSTCC       = $(call os_x_before, 10, 5, "cc", "gcc")
 HOSTCFLAGS  += $(call os_x_before, 10, 4, "-traditional-cpp")
 HOSTLDFLAGS += $(call os_x_before, 10, 5, "-multiply_defined suppress")
+
+# since Lion (10.7) ASLR is on by default, but we use linker generated lists
+# in some host tools which is a problem then ... so disable ASLR for these
+# tools
+HOSTLDFLAGS += $(call os_x_before, 10, 7, "", "-Xlinker -no_pie")
 endif
 
 # Decide whether to build built-in, modular, or both.
index 31188c85bccb7fcd69644c185494752993551ea8..529a11951401764696bfb3d5006573c95509f329 100644 (file)
@@ -118,4 +118,7 @@ void enable_basic_clocks(void)
 
        /* Select the Master osc clk as Timer2 clock source */
        writel(0x1, &cmdpll->clktimer2clk);
+
+       /* For OPP100 the mac clock should be /5. */
+       writel(0x4, &cmdpll->clkselmacclk);
 }
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 923906afb5bec2ab2ff10d149e891cc387918738..dfb27b5ba20f5b0709be3ba398f228892c0aff33 100644 (file)
@@ -263,17 +263,14 @@ static void ddr3_map_ecc_cic2_irq(u32 base)
 }
 #endif
 
-void ddr3_init_ecc(u32 base)
+void ddr3_init_ecc(u32 base, u32 ddr3_size)
 {
-       u32 ddr3_size;
-
        if (!ddr3_ecc_support_rmw(base)) {
                ddr3_disable_ecc(base);
                return;
        }
 
        ddr3_ecc_init_range(base);
-       ddr3_size = ddr3_get_size();
        ddr3_reset_data(CONFIG_SYS_SDRAM_BASE, ddr3_size);
 
        /* mapping DDR3 ECC system interrupt from CIC2 to GIC */
index e601ba1886fb82a9b552b099dc1b14a09dfedd3b..c01a98f71958e67df5674f4330d463ffa1512a32 100644 (file)
@@ -252,6 +252,8 @@ static void ddr3_init(u32 base, const struct emif_regs *regs)
 {
        struct emif_reg_struct *emif = (struct emif_reg_struct *)base;
 
+       writel(regs->ref_ctrl, &emif->emif_sdram_ref_ctrl);
+       writel(regs->sdram_config_init, &emif->emif_sdram_config);
        /*
         * Set SDRAM_CONFIG and PHY control registers to locked frequency
         * and RL =7. As the default values of the Mode Registers are not
@@ -265,7 +267,6 @@ static void ddr3_init(u32 base, const struct emif_regs *regs)
        writel(regs->sdram_tim2, &emif->emif_sdram_tim_2);
        writel(regs->sdram_tim3, &emif->emif_sdram_tim_3);
 
-       writel(regs->ref_ctrl, &emif->emif_sdram_ref_ctrl);
        writel(regs->read_idle_ctrl, &emif->emif_read_idlectrl);
 
        /*
@@ -274,6 +275,7 @@ static void ddr3_init(u32 base, const struct emif_regs *regs)
         */
        if (is_dra7xx()) {
                do_ext_phy_settings(base, regs);
+               writel(regs->ref_ctrl_final, &emif->emif_sdram_ref_ctrl);
                writel(regs->sdram_config2, &emif->emif_lpddr2_nvm_config);
                writel(regs->sdram_config_init, &emif->emif_sdram_config);
        } else {
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 7d8cec08c2f189283e0a7e170763db98e3a5818b..5f8daa1ee1e7a749f9de90c47857a9f29a39a8d8 100644 (file)
@@ -141,7 +141,8 @@ const struct emif_regs emif_1_regs_ddr3_532_mhz_1cs_dra_es1 = {
        .sdram_config_init              = 0x61851ab2,
        .sdram_config                   = 0x61851ab2,
        .sdram_config2                  = 0x08000000,
-       .ref_ctrl                       = 0x00001035,
+       .ref_ctrl                       = 0x000040F1,
+       .ref_ctrl_final                 = 0x00001035,
        .sdram_tim1                     = 0xCCCF36B3,
        .sdram_tim2                     = 0x308F7FDA,
        .sdram_tim3                     = 0x027F88A8,
@@ -151,10 +152,10 @@ const struct emif_regs emif_1_regs_ddr3_532_mhz_1cs_dra_es1 = {
        .emif_ddr_phy_ctlr_1_init       = 0x0E24400A,
        .emif_ddr_phy_ctlr_1            = 0x0E24400A,
        .emif_ddr_ext_phy_ctrl_1        = 0x10040100,
-       .emif_ddr_ext_phy_ctrl_2        = 0x00BB00BB,
-       .emif_ddr_ext_phy_ctrl_3        = 0x00BB00BB,
-       .emif_ddr_ext_phy_ctrl_4        = 0x00BB00BB,
-       .emif_ddr_ext_phy_ctrl_5        = 0x00BB00BB,
+       .emif_ddr_ext_phy_ctrl_2        = 0x00910091,
+       .emif_ddr_ext_phy_ctrl_3        = 0x00950095,
+       .emif_ddr_ext_phy_ctrl_4        = 0x009B009B,
+       .emif_ddr_ext_phy_ctrl_5        = 0x009E009E,
        .emif_rd_wr_lvl_rmp_win         = 0x00000000,
        .emif_rd_wr_lvl_rmp_ctl         = 0x00000000,
        .emif_rd_wr_lvl_ctl             = 0x00000000,
@@ -165,7 +166,8 @@ const struct emif_regs emif_2_regs_ddr3_532_mhz_1cs_dra_es1 = {
        .sdram_config_init              = 0x61851B32,
        .sdram_config                   = 0x61851B32,
        .sdram_config2                  = 0x08000000,
-       .ref_ctrl                       = 0x00001035,
+       .ref_ctrl                       = 0x000040F1,
+       .ref_ctrl_final                 = 0x00001035,
        .sdram_tim1                     = 0xCCCF36B3,
        .sdram_tim2                     = 0x308F7FDA,
        .sdram_tim3                     = 0x027F88A8,
@@ -175,10 +177,10 @@ const struct emif_regs emif_2_regs_ddr3_532_mhz_1cs_dra_es1 = {
        .emif_ddr_phy_ctlr_1_init       = 0x0E24400A,
        .emif_ddr_phy_ctlr_1            = 0x0E24400A,
        .emif_ddr_ext_phy_ctrl_1        = 0x10040100,
-       .emif_ddr_ext_phy_ctrl_2        = 0x00BB00BB,
-       .emif_ddr_ext_phy_ctrl_3        = 0x00BB00BB,
-       .emif_ddr_ext_phy_ctrl_4        = 0x00BB00BB,
-       .emif_ddr_ext_phy_ctrl_5        = 0x00BB00BB,
+       .emif_ddr_ext_phy_ctrl_2        = 0x00910091,
+       .emif_ddr_ext_phy_ctrl_3        = 0x00950095,
+       .emif_ddr_ext_phy_ctrl_4        = 0x009B009B,
+       .emif_ddr_ext_phy_ctrl_5        = 0x009E009E,
        .emif_rd_wr_lvl_rmp_win         = 0x00000000,
        .emif_rd_wr_lvl_rmp_ctl         = 0x00000000,
        .emif_rd_wr_lvl_ctl             = 0x00000000,
@@ -186,18 +188,19 @@ const struct emif_regs emif_2_regs_ddr3_532_mhz_1cs_dra_es1 = {
 };
 
 const struct emif_regs emif_1_regs_ddr3_666_mhz_1cs_dra_es1 = {
-       .sdram_config_init              = 0x61851AB2,
-       .sdram_config                   = 0x61851AB2,
+       .sdram_config_init              = 0x61862B32,
+       .sdram_config                   = 0x61862B32,
        .sdram_config2                  = 0x08000000,
-       .ref_ctrl                       = 0x00001035,
-       .sdram_tim1                     = 0xCCCF36B3,
-       .sdram_tim2                     = 0x308F7FDA,
-       .sdram_tim3                     = 0x027F88A8,
+       .ref_ctrl                       = 0x0000493E,
+       .ref_ctrl_final                 = 0x0000144A,
+       .sdram_tim1                     = 0xD113781C,
+       .sdram_tim2                     = 0x308F7FE3,
+       .sdram_tim3                     = 0x009F86A8,
        .read_idle_ctrl                 = 0x00050000,
        .zq_config                      = 0x0007190B,
        .temp_alert_config              = 0x00000000,
-       .emif_ddr_phy_ctlr_1_init       = 0x0024400A,
-       .emif_ddr_phy_ctlr_1            = 0x0024400A,
+       .emif_ddr_phy_ctlr_1_init       = 0x0E24400D,
+       .emif_ddr_phy_ctlr_1            = 0x0E24400D,
        .emif_ddr_ext_phy_ctrl_1        = 0x10040100,
        .emif_ddr_ext_phy_ctrl_2        = 0x00A400A4,
        .emif_ddr_ext_phy_ctrl_3        = 0x00A900A9,
@@ -420,22 +423,22 @@ const u32 ddr3_ext_phy_ctrl_const_base_es2[] = {
 
 const u32
 dra_ddr3_ext_phy_ctrl_const_base_es1_emif1[] = {
-       0x00BB00BB,
-       0x00440044,
-       0x00440044,
-       0x00440044,
-       0x00440044,
-       0x00440044,
+       0x00980098,
+       0x00340034,
+       0x00350035,
+       0x00340034,
+       0x00310031,
+       0x00340034,
        0x007F007F,
        0x007F007F,
        0x007F007F,
        0x007F007F,
        0x007F007F,
-       0x00600060,
-       0x00600060,
-       0x00600060,
-       0x00600060,
-       0x00600060,
+       0x00480048,
+       0x004A004A,
+       0x00520052,
+       0x00550055,
+       0x00500050,
        0x00000000,
        0x00600020,
        0x40010080,
@@ -449,22 +452,22 @@ dra_ddr3_ext_phy_ctrl_const_base_es1_emif1[] = {
 
 const u32
 dra_ddr3_ext_phy_ctrl_const_base_es1_emif2[] = {
-       0x00BB00BB,
-       0x00440044,
-       0x00440044,
-       0x00440044,
-       0x00440044,
-       0x00440044,
+       0x00980098,
+       0x00330033,
+       0x00330033,
+       0x002F002F,
+       0x00320032,
+       0x00310031,
        0x007F007F,
        0x007F007F,
        0x007F007F,
        0x007F007F,
        0x007F007F,
-       0x00600060,
-       0x00600060,
-       0x00600060,
-       0x00600060,
-       0x00600060,
+       0x00520052,
+       0x00520052,
+       0x00470047,
+       0x00490049,
+       0x00500050,
        0x00000000,
        0x00600020,
        0x40010080,
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 b94b56cba73d3d8ef5f569eb9c126f40d2033fdc..523d22eb87dd394e12053dfedbbe0226ca5e144c 100644 (file)
@@ -400,6 +400,8 @@ struct prm_device_inst {
 struct cm_dpll {
        unsigned int resv1;
        unsigned int clktimer2clk;      /* offset 0x04 */
+       unsigned int resv2[11];
+       unsigned int clkselmacclk;      /* offset 0x34 */ 
 };
 #endif /* CONFIG_AM43XX */
 
index b044d6f18ff2473f44060aab7816f3329e46a097..a22c237c8026e98905406638abcec836c8a42906 100644 (file)
@@ -48,10 +48,9 @@ struct ddr3_emif_config {
        unsigned int sdrfc;
 };
 
-void ddr3_init(void);
-int ddr3_get_size(void);
+u32 ddr3_init(void);
 void ddr3_reset_ddrphy(void);
-void ddr3_init_ecc(u32 base);
+void ddr3_init_ecc(u32 base, u32 ddr3_size);
 void ddr3_disable_ecc(u32 base);
 void ddr3_check_ecc_int(u32 base);
 int ddr3_ecc_support_rmw(u32 base);
index 8f6426bc1b0184d4c362487ca499268aa7e783f1..564441cbfa3b603299fd6fdf29b155711488f7e2 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Common definitions for LPC32XX board configurations
  *
- * Copyright (C) 2011 Vladimir Zapolskiy <vz@mleia.com>
+ * Copyright (C) 2011-2015 Vladimir Zapolskiy <vz@mleia.com>
  *
  * SPDX-License-Identifier:    GPL-2.0+
  */
@@ -9,6 +9,8 @@
 #ifndef _LPC32XX_CONFIG_H
 #define _LPC32XX_CONFIG_H
 
+#define CONFIG_SYS_GENERIC_BOARD
+
 /* Basic CPU architecture */
 #define CONFIG_ARCH_CPU_INIT
 
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 342f045f41419471adea238aed0fcb309e7185d2..7a545ea01a7c3f661867696f9c88c80fd3386dae 100644 (file)
@@ -1149,6 +1149,7 @@ struct emif_regs {
        u32 sdram_config;
        u32 sdram_config2;
        u32 ref_ctrl;
+       u32 ref_ctrl_final;
        u32 sdram_tim1;
        u32 sdram_tim2;
        u32 sdram_tim3;
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 d74e4b8415f152061d50614185617749478a5e41..da8ed72a11e52e350ec3031a37c4755760cb589a 100644 (file)
@@ -35,6 +35,7 @@ endif
 obj-$(CONFIG_SEMIHOSTING) += semihosting.o
 
 obj-y  += sections.o
+obj-y  += stack.o
 ifdef CONFIG_ARM64
 obj-y  += gic_64.o
 obj-y  += interrupts_64.o
diff --git a/arch/arm/lib/stack.c b/arch/arm/lib/stack.c
new file mode 100644 (file)
index 0000000..cf10a53
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2015 Andreas Bießmann <andreas.devel@googlemail.com>
+ *
+ * Copyright (c) 2011 The Chromium OS Authors.
+ * (C) Copyright 2002-2006
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * (C) Copyright 2002
+ * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
+ * Marius Groeger <mgroeger@sysgo.de>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+#include <common.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+int arch_reserve_stacks(void)
+{
+#ifdef CONFIG_SPL_BUILD
+       gd->start_addr_sp -= 128;       /* leave 32 words for abort-stack */
+       gd->irq_sp = gd->start_addr_sp;
+#else
+       /* setup stack pointer for exceptions */
+       gd->irq_sp = gd->start_addr_sp;
+
+# if !defined(CONFIG_ARM64)
+#  ifdef CONFIG_USE_IRQ
+       gd->start_addr_sp -= (CONFIG_STACKSIZE_IRQ + CONFIG_STACKSIZE_FIQ);
+       debug("Reserving %zu Bytes for IRQ stack at: %08lx\n",
+             CONFIG_STACKSIZE_IRQ + CONFIG_STACKSIZE_FIQ, gd->start_addr_sp);
+
+       /* 8-byte alignment for ARM ABI compliance */
+       gd->start_addr_sp &= ~0x07;
+#  endif
+       /* leave 3 words for abort-stack, plus 1 for alignment */
+       gd->start_addr_sp -= 16;
+# endif
+#endif
+
+       return 0;
+}
index 469185e8b44bcef8cc23e77e5a620f8feae8cbfb..8252f598c3bdd9de371293d021e64f95c7485914 100644 (file)
@@ -9,6 +9,9 @@ ifeq ($(CROSS_COMPILE),)
 CROSS_COMPILE := avr32-linux-
 endif
 
+# avr32 has generic board support
+__HAVE_ARCH_GENERIC_BOARD := y
+
 CONFIG_STANDALONE_LOAD_ADDR ?= 0x00000000
 
 PLATFORM_RELFLAGS      += -ffixed-r5 -fPIC -mno-init-got -mrelax
index 00cede3fd981be7be855df45f0a84ef727c4edc1..e111db3e75727274d7df5869a6d52e7e04634482 100644 (file)
@@ -16,5 +16,6 @@ obj-y                 += cache.o
 obj-y                  += interrupts.o
 obj-$(CONFIG_PORTMUX_PIO) += portmux-pio.o
 obj-$(CONFIG_PORTMUX_GPIO) += portmux-gpio.o
+obj-y += mmc.o
 
 obj-$(if $(filter at32ap700x,$(SOC)),y) += at32ap700x/
index 0e28b21eefd4c8436801e63ff792db221857dc49..f5e62f27ebd2dbaacf3b8c799eff1ca49feb6f7f 100644 (file)
@@ -7,7 +7,7 @@ void mmu_init_r(unsigned long dest_addr)
        uintptr_t       vmr_table_addr;
 
        /* Round monitor address down to the nearest page boundary */
-       dest_addr &= PAGE_ADDR_MASK;
+       dest_addr &= MMU_PAGE_ADDR_MASK;
 
        /* Initialize TLB entry 0 to cover the monitor, and lock it */
        sysreg_write(TLBEHI, dest_addr | SYSREG_BIT(TLBEHI_V));
@@ -36,7 +36,7 @@ int mmu_handle_tlb_miss(void)
        unsigned int fault_pgno;
        int first, last;
 
-       fault_pgno = sysreg_read(TLBEAR) >> PAGE_SHIFT;
+       fault_pgno = sysreg_read(TLBEAR) >> MMU_PAGE_SHIFT;
        vmr_table = (const struct mmu_vm_range *)sysreg_read(PTBR);
 
        /* Do a binary search through the VM ranges */
@@ -60,8 +60,8 @@ int mmu_handle_tlb_miss(void)
                        /* Got it; let's slam it into the TLB */
                        uint32_t tlbelo;
 
-                       tlbelo = vmr->phys & ~PAGE_ADDR_MASK;
-                       tlbelo |= fault_pgno << PAGE_SHIFT;
+                       tlbelo = vmr->phys & ~MMU_PAGE_ADDR_MASK;
+                       tlbelo |= fault_pgno << MMU_PAGE_SHIFT;
                        sysreg_write(TLBELO, tlbelo);
                        __builtin_tlbw();
 
index cef630ed45836b37d2b8ef548533349ae88f6c5a..cd226a6f71b384f757441098dc0708241e867453 100644 (file)
@@ -27,7 +27,7 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-int cpu_init(void)
+int arch_cpu_init(void)
 {
        extern void _evba(void);
 
index 5d1bc689f85d4f9977d490a23d30dfd7168966f8..d6991f6668d3326bfaf205719f9f421bbfff7f25 100644 (file)
@@ -96,11 +96,11 @@ void do_unknown_exception(unsigned int ecr, struct pt_regs *regs)
        printf("CPU Mode: %s\n", cpu_modes[mode]);
 
        /* Avoid exception loops */
-       if (regs->sp < (gd->arch.stack_end - CONFIG_STACKSIZE)
-                       || regs->sp >= gd->arch.stack_end)
+       if (regs->sp < (gd->start_addr_sp - CONFIG_STACKSIZE) ||
+           regs->sp >= gd->start_addr_sp)
                printf("\nStack pointer seems bogus, won't do stack dump\n");
        else
-               dump_mem("\nStack: ", regs->sp, gd->arch.stack_end);
+               dump_mem("\nStack: ", regs->sp, gd->start_addr_sp);
 
        panic("Unhandled exception\n");
 }
diff --git a/arch/avr32/cpu/mmc.c b/arch/avr32/cpu/mmc.c
new file mode 100644 (file)
index 0000000..b7213e4
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * Copyright (C) 2004-2006 Atmel Corporation
+ * Copyright (C) 2015 Andreas Bießmann <andreas.devel@googlmail.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+#include <common.h>
+#include <atmel_mci.h>
+#include <asm/arch/hardware.h>
+
+/* provide cpu_mmc_init, to overwrite provide board_mmc_init */
+int cpu_mmc_init(bd_t *bd)
+{
+       /* This calls the atmel_mci_init in gen_atmel_mci.c */
+       return atmel_mci_init((void *)ATMEL_BASE_MMCI);
+}
index cb29a22b1ea9c3190881772a19d77fe804796ec9..b0180e3534591d512c2a31bf4f3c1b93d9db4d94 100644 (file)
@@ -48,9 +48,11 @@ SECTIONS
        _edata = .;
 
        .bss (NOLOAD) : {
+               __bss_start = .;
                *(.bss)
                *(.bss.*)
        }
        . = ALIGN(8);
        __bss_end = .;
+       __init_end = .;
 }
index fcd9a0560929df51e768b5a733d176ed03418cf3..4736312f5dbc9cfedd937d4476c91f27367a3744 100644 (file)
@@ -13,9 +13,9 @@
 
 #include <asm/sysreg.h>
 
-#define PAGE_SHIFT     20
-#define PAGE_SIZE      (1UL << PAGE_SHIFT)
-#define PAGE_ADDR_MASK (~(PAGE_SIZE - 1))
+#define MMU_PAGE_SHIFT 20
+#define MMU_PAGE_SIZE  (1UL << MMU_PAGE_SHIFT)
+#define MMU_PAGE_ADDR_MASK     (~(MMU_PAGE_SIZE - 1))
 
 #define MMU_VMR_CACHE_NONE                                             \
        (SYSREG_BF(AP, 3) | SYSREG_BF(SZ, 3) | SYSREG_BIT(TLBELO_D))
index 63056a4dfa1b3799c1413dc15aaba2cae1b1c1af..529fe227a6b634b4bd33ab8c9db47d9f5bdb796f 100644 (file)
@@ -8,5 +8,6 @@
 #define _ASM_CONFIG_H_
 
 #define CONFIG_NEEDS_MANUAL_RELOC
+#define CONFIG_SYS_GENERIC_GLOBAL_DATA
 
 #endif
index dbdd2fee3806c32e7c8a48597d0b603882cd7564..1cde8275f4f905ee8a2c3eeadc3045a01850ae9a 100644 (file)
@@ -14,7 +14,12 @@ enum dma_data_direction {
        DMA_TO_DEVICE           = 1,
        DMA_FROM_DEVICE         = 2,
 };
-extern void *dma_alloc_coherent(size_t len, unsigned long *handle);
+
+static inline void *dma_alloc_coherent(size_t len, unsigned long *handle)
+{
+       *handle = (unsigned long)memalign(ARCH_DMA_MINALIGN, len);
+       return (void *)*handle;
+}
 
 static inline unsigned long dma_map_single(volatile void *vaddr, size_t len,
                                           enum dma_data_direction dir)
index d82fb7cc6d807c63637b452e83f15352713423e1..60abd007821cf76e0a96f45b08acde1762d68816 100644 (file)
@@ -8,7 +8,6 @@
 
 /* Architecture-specific global data */
 struct arch_global_data {
-       unsigned long stack_end;        /* highest stack address */
        unsigned long cpu_hz;           /* cpu core clock frequency */
 };
 
index 6aef8087490a2d9ab031062ea193eeb270082d61..8b047ec7c8b090b37c114d3cef8a21c86cf05cb8 100644 (file)
@@ -6,6 +6,11 @@
 #ifndef __ASM_U_BOOT_H__
 #define __ASM_U_BOOT_H__ 1
 
+#ifdef CONFIG_SYS_GENERIC_BOARD
+/* Use the generic board which requires a unified bd_info */
+#include <asm-generic/u-boot.h>
+#else
+
 typedef struct bd_info {
        unsigned char           bi_phy_id[4];
        unsigned long           bi_board_number;
@@ -22,7 +27,12 @@ typedef struct bd_info {
 #define bi_memstart bi_dram[0].start
 #define bi_memsize bi_dram[0].size
 
+#endif
+
 /* For image.h:image_check_target_arch() */
 #define IH_ARCH_DEFAULT IH_ARCH_AVR32
 
+int arch_cpu_init(void);
+int dram_init(void);
+
 #endif /* __ASM_U_BOOT_H__ */
index bb45cbe1538460591c80b6ff9268e9dbc50f3af1..675091363087d3410fe7837b50c789f9abcd5d51 100644 (file)
@@ -8,6 +8,9 @@
 #
 
 obj-y  += memset.o
+ifndef CONFIG_SYS_GENERIC_BOARD
 obj-y  += board.o
+endif
 obj-$(CONFIG_CMD_BOOTM) += bootm.o
 obj-y  += interrupts.o
+obj-y  += dram_init.o
index bf0997f98dc3802626418d190bb3cec2e165992c..99aa96e23fab0498e7e4bc636ac0ea464e4b9d18 100644 (file)
@@ -9,7 +9,6 @@
 #include <stdio_dev.h>
 #include <version.h>
 #include <net.h>
-#include <atmel_mci.h>
 
 #ifdef CONFIG_BITBANGMII
 #include <miiphy.h>
@@ -30,6 +29,12 @@ DECLARE_GLOBAL_DATA_PTR;
 
 unsigned long monitor_flash_len;
 
+__weak void dram_init_banksize(void)
+{
+       gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
+       gd->bd->bi_dram[0].size =  gd->ram_size;
+}
+
 /* Weak aliases for optional board functions */
 static int __do_nothing(void)
 {
@@ -38,57 +43,6 @@ static int __do_nothing(void)
 int board_postclk_init(void) __attribute__((weak, alias("__do_nothing")));
 int board_early_init_r(void) __attribute__((weak, alias("__do_nothing")));
 
-/* provide cpu_mmc_init, to overwrite provide board_mmc_init */
-int cpu_mmc_init(bd_t *bd)
-{
-       /* This calls the atmel_mci_init in gen_atmel_mci.c */
-       return atmel_mci_init((void *)ATMEL_BASE_MMCI);
-}
-
-#ifdef CONFIG_SYS_DMA_ALLOC_LEN
-#include <asm/arch/cacheflush.h>
-#include <asm/io.h>
-
-static unsigned long dma_alloc_start;
-static unsigned long dma_alloc_end;
-static unsigned long dma_alloc_brk;
-
-static void dma_alloc_init(void)
-{
-       unsigned long monitor_addr;
-
-       monitor_addr = CONFIG_SYS_MONITOR_BASE + gd->reloc_off;
-       dma_alloc_end = monitor_addr - CONFIG_SYS_MALLOC_LEN;
-       dma_alloc_start = dma_alloc_end - CONFIG_SYS_DMA_ALLOC_LEN;
-       dma_alloc_brk = dma_alloc_start;
-
-       printf("DMA: Using memory from 0x%08lx to 0x%08lx\n",
-              dma_alloc_start, dma_alloc_end);
-
-       invalidate_dcache_range((unsigned long)cached(dma_alloc_start),
-                               dma_alloc_end);
-}
-
-void *dma_alloc_coherent(size_t len, unsigned long *handle)
-{
-       unsigned long paddr = dma_alloc_brk;
-
-       if (dma_alloc_brk + len > dma_alloc_end)
-               return NULL;
-
-       dma_alloc_brk = ((paddr + len + CONFIG_SYS_DCACHE_LINESZ - 1)
-                        & ~(CONFIG_SYS_DCACHE_LINESZ - 1));
-
-       *handle = paddr;
-       return uncached(paddr);
-}
-#else
-static inline void dma_alloc_init(void)
-{
-
-}
-#endif
-
 static int init_baudrate(void)
 {
        gd->baudrate = getenv_ulong("baudrate", 10, CONFIG_BAUDRATE);
@@ -134,7 +88,6 @@ void board_init_f(ulong board_type)
        unsigned long monitor_len;
        unsigned long monitor_addr;
        unsigned long addr;
-       long sdram_size;
 
        /* Initialize the global data pointer */
        memset(&gd_data, 0, sizeof(gd_data));
@@ -142,17 +95,17 @@ void board_init_f(ulong board_type)
 
        /* Perform initialization sequence */
        board_early_init_f();
-       cpu_init();
+       arch_cpu_init();
        board_postclk_init();
        env_init();
        init_baudrate();
        serial_init();
        console_init_f();
        display_banner();
-       sdram_size = initdram(board_type);
+       dram_init();
 
        /* If we have no SDRAM, we can't go on */
-       if (sdram_size <= 0)
+       if (gd->ram_size <= 0)
                panic("No working SDRAM available\n");
 
        /*
@@ -166,7 +119,7 @@ void board_init_f(ulong board_type)
         *  - global data struct
         *  - stack
         */
-       addr = CONFIG_SYS_SDRAM_BASE + sdram_size;
+       addr = CONFIG_SYS_SDRAM_BASE + gd->ram_size;
        monitor_len = (char *)(&__bss_end) - _text;
 
        /*
@@ -180,12 +133,6 @@ void board_init_f(ulong board_type)
        /* Reserve memory for malloc() */
        addr -= CONFIG_SYS_MALLOC_LEN;
 
-#ifdef CONFIG_SYS_DMA_ALLOC_LEN
-       /* Reserve DMA memory (must be cache aligned) */
-       addr &= ~(CONFIG_SYS_DCACHE_LINESZ - 1);
-       addr -= CONFIG_SYS_DMA_ALLOC_LEN;
-#endif
-
 #ifdef CONFIG_LCD
 #ifdef CONFIG_FB_ADDR
        printf("LCD: Frame buffer allocated at preset 0x%08x\n",
@@ -210,16 +157,11 @@ void board_init_f(ulong board_type)
 
        /* And finally, a new, bigger stack. */
        new_sp = (unsigned long *)addr;
-       gd->arch.stack_end = addr;
+       gd->start_addr_sp = addr;
        *(--new_sp) = 0;
        *(--new_sp) = 0;
 
-       /*
-        * Initialize the board information struct with the
-        * information we have.
-        */
-       bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
-       bd->bi_dram[0].size = sdram_size;
+       dram_init_banksize();
 
        memcpy(new_gd, gd, sizeof(gd_t));
 
@@ -264,7 +206,6 @@ void board_init_r(gd_t *new_gd, ulong dest_addr)
        /* The malloc area is right below the monitor image in RAM */
        mem_malloc_init(CONFIG_SYS_MONITOR_BASE + gd->reloc_off -
                        CONFIG_SYS_MALLOC_LEN, CONFIG_SYS_MALLOC_LEN);
-       dma_alloc_init();
 
        enable_interrupts();
 
diff --git a/arch/avr32/lib/dram_init.c b/arch/avr32/lib/dram_init.c
new file mode 100644 (file)
index 0000000..5078e77
--- /dev/null
@@ -0,0 +1,17 @@
+/*
+ * Copyright (C) 2015 Andreas Bießmann <andreas.devel@googlemail.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+#include <common.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+int dram_init(void)
+{
+       /* check for the maximum amount of memory possible on AP7000 devices */
+       gd->ram_size = get_ram_size(
+               (void *)CONFIG_SYS_SDRAM_BASE,
+               (256<<20));
+       return 0;
+}
index bacb2d186ad61b75c4eae207778099d6d1a98667..5f3a49e15212edf55cc34ba955c31d78ed455f2b 100644 (file)
@@ -7,6 +7,11 @@
 
 #include <asm/sysreg.h>
 
+int interrupt_init(void)
+{
+       return 0;
+}
+
 void enable_interrupts(void)
 {
        asm volatile("csrf      %0" : : "n"(SYSREG_GM_OFFSET));
index 0f6298269a7764181286b789947ddc7827c85b56..05b22bb5f702a6e2bb39b1a5a3944571b229dad8 100644 (file)
@@ -40,6 +40,7 @@ obj-y += extable.o
 obj-y  += interrupts.o
 obj-$(CONFIG_CMD_KGDB) += kgdb.o
 obj-$(CONFIG_CMD_IDE) += ide.o
+obj-y  += stack.o
 obj-y  += time.o
 
 # Don't include the MPC5xxx special memcpy into the
diff --git a/arch/powerpc/lib/stack.c b/arch/powerpc/lib/stack.c
new file mode 100644 (file)
index 0000000..1985f03
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2015 Andreas Bießmann <andreas.devel@googlemail.com>
+ *
+ * Copyright (c) 2011 The Chromium OS Authors.
+ * (C) Copyright 2002-2006
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * (C) Copyright 2002
+ * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
+ * Marius Groeger <mgroeger@sysgo.de>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+#include <common.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+int arch_reserve_stacks(void)
+{
+       ulong *s;
+
+       /* setup stack pointer for exceptions */
+       gd->irq_sp = gd->start_addr_sp;
+
+       /* Clear initial stack frame */
+       s = (ulong *)gd->start_addr_sp;
+       *s = 0; /* Terminate back chain */
+       *++s = 0; /* NULL return address */
+
+       return 0;
+}
index 03d767a4a88dac63a2646187501d0030b9d4901f..dacd4278314c5b3ed0c0c10a44f0c951da621e3c 100644 (file)
@@ -18,14 +18,14 @@ DECLARE_GLOBAL_DATA_PTR;
 
 struct mmu_vm_range mmu_vmr_table[CONFIG_SYS_NR_VM_REGIONS] = {
        {
-               .virt_pgno      = CONFIG_SYS_FLASH_BASE >> PAGE_SHIFT,
-               .nr_pages       = CONFIG_SYS_FLASH_SIZE >> PAGE_SHIFT,
-               .phys           = (CONFIG_SYS_FLASH_BASE >> PAGE_SHIFT)
+               .virt_pgno      = CONFIG_SYS_FLASH_BASE >> MMU_PAGE_SHIFT,
+               .nr_pages       = CONFIG_SYS_FLASH_SIZE >> MMU_PAGE_SHIFT,
+               .phys           = (CONFIG_SYS_FLASH_BASE >> MMU_PAGE_SHIFT)
                                        | MMU_VMR_CACHE_NONE,
        }, {
-               .virt_pgno      = CONFIG_SYS_SDRAM_BASE >> PAGE_SHIFT,
-               .nr_pages       = EBI_SDRAM_SIZE >> PAGE_SHIFT,
-               .phys           = (CONFIG_SYS_SDRAM_BASE >> PAGE_SHIFT)
+               .virt_pgno      = CONFIG_SYS_SDRAM_BASE >> MMU_PAGE_SHIFT,
+               .nr_pages       = EBI_SDRAM_SIZE >> MMU_PAGE_SHIFT,
+               .phys           = (CONFIG_SYS_SDRAM_BASE >> MMU_PAGE_SHIFT)
                                        | MMU_VMR_CACHE_WRBACK,
        },
 };
@@ -52,6 +52,8 @@ int board_early_init_f(void)
        hmatrix_slave_write(EBI, SFR, HMATRIX_BIT(EBI_SDRAM_ENABLE));
 
        portmux_enable_ebi(16, 23, 0, PORTMUX_DRIVE_HIGH);
+       sdram_init(uncached(EBI_SDRAM_BASE), &sdram_config);
+
        portmux_enable_usart1(PORTMUX_DRIVE_MIN);
 
 #if defined(CONFIG_MACB)
@@ -68,24 +70,6 @@ int board_early_init_f(void)
        return 0;
 }
 
-phys_size_t initdram(int board_type)
-{
-       unsigned long expected_size;
-       unsigned long actual_size;
-       void *sdram_base;
-
-       sdram_base = uncached(EBI_SDRAM_BASE);
-
-       expected_size = sdram_init(sdram_base, &sdram_config);
-       actual_size = get_ram_size(sdram_base, expected_size);
-
-       if (expected_size != actual_size)
-               printf("Warning: Only %lu of %lu MiB SDRAM is working\n",
-                               actual_size >> 20, expected_size >> 20);
-
-       return actual_size;
-}
-
 int board_early_init_r(void)
 {
        gd->bd->bi_phy_id[0] = 0x01;
index 72d19e430ef8c8818028b71417593641fee647a9..8e215d5fcf2f062dfe8dd4b020b5a3b6bfd7a8eb 100644 (file)
@@ -23,21 +23,21 @@ DECLARE_GLOBAL_DATA_PTR;
 struct mmu_vm_range mmu_vmr_table[CONFIG_SYS_NR_VM_REGIONS] = {
        {
                /* Atmel AT49BV640D 8 MiB x16 NOR flash on NCS0 */
-               .virt_pgno      = CONFIG_SYS_FLASH_BASE >> PAGE_SHIFT,
-               .nr_pages       = CONFIG_SYS_FLASH_SIZE >> PAGE_SHIFT,
-               .phys           = (CONFIG_SYS_FLASH_BASE >> PAGE_SHIFT)
+               .virt_pgno      = CONFIG_SYS_FLASH_BASE >> MMU_PAGE_SHIFT,
+               .nr_pages       = CONFIG_SYS_FLASH_SIZE >> MMU_PAGE_SHIFT,
+               .phys           = (CONFIG_SYS_FLASH_BASE >> MMU_PAGE_SHIFT)
                                        | MMU_VMR_CACHE_NONE,
        }, {
                /* Micron MT29F2G16AAD 256 MiB x16 NAND flash on NCS3 */
-               .virt_pgno      = EBI_SRAM_CS3_BASE >> PAGE_SHIFT,
-               .nr_pages       = EBI_SRAM_CS3_SIZE >> PAGE_SHIFT,
-               .phys           = (EBI_SRAM_CS3_BASE >> PAGE_SHIFT)
+               .virt_pgno      = EBI_SRAM_CS3_BASE >> MMU_PAGE_SHIFT,
+               .nr_pages       = EBI_SRAM_CS3_SIZE >> MMU_PAGE_SHIFT,
+               .phys           = (EBI_SRAM_CS3_BASE >> MMU_PAGE_SHIFT)
                                        | MMU_VMR_CACHE_NONE,
        }, {
                /* 2x16-bit ISSI IS42S16320B 64 MiB SDRAM (128 MiB total) */
-               .virt_pgno      = CONFIG_SYS_SDRAM_BASE >> PAGE_SHIFT,
-               .nr_pages       = EBI_SDRAM_SIZE >> PAGE_SHIFT,
-               .phys           = (CONFIG_SYS_SDRAM_BASE >> PAGE_SHIFT)
+               .virt_pgno      = CONFIG_SYS_SDRAM_BASE >> MMU_PAGE_SHIFT,
+               .nr_pages       = EBI_SDRAM_SIZE >> MMU_PAGE_SHIFT,
+               .phys           = (CONFIG_SYS_SDRAM_BASE >> MMU_PAGE_SHIFT)
                                        | MMU_VMR_CACHE_WRBACK,
        },
 };
@@ -69,6 +69,9 @@ int board_early_init_f(void)
        portmux_select_gpio(PORTMUX_PORT_E, 1 << 23,
                        PORTMUX_DIR_OUTPUT | PORTMUX_INIT_HIGH
                        | PORTMUX_DRIVE_MIN);
+
+       sdram_init(uncached(EBI_SDRAM_BASE), &sdram_config);
+
        portmux_enable_usart1(PORTMUX_DRIVE_MIN);
 
 #if defined(CONFIG_MACB)
@@ -85,24 +88,6 @@ int board_early_init_f(void)
        return 0;
 }
 
-phys_size_t initdram(int board_type)
-{
-       unsigned long expected_size;
-       unsigned long actual_size;
-       void *sdram_base;
-
-       sdram_base = uncached(EBI_SDRAM_BASE);
-
-       expected_size = sdram_init(sdram_base, &sdram_config);
-       actual_size = get_ram_size(sdram_base, expected_size);
-
-       if (expected_size != actual_size)
-               printf("Warning: Only %lu of %lu MiB SDRAM is working\n",
-                               actual_size >> 20, expected_size >> 20);
-
-       return actual_size;
-}
-
 int board_early_init_r(void)
 {
        gd->bd->bi_phy_id[0] = 0x01;
index 4b6b90f683dcca568c9778462fd42f3d7e8079eb..fd4363beceb1222384c5887c3bff3e3b7947cd34 100644 (file)
@@ -17,14 +17,14 @@ DECLARE_GLOBAL_DATA_PTR;
 
 struct mmu_vm_range mmu_vmr_table[CONFIG_SYS_NR_VM_REGIONS] = {
        {
-               .virt_pgno      = CONFIG_SYS_FLASH_BASE >> PAGE_SHIFT,
-               .nr_pages       = CONFIG_SYS_FLASH_SIZE >> PAGE_SHIFT,
-               .phys           = (CONFIG_SYS_FLASH_BASE >> PAGE_SHIFT)
+               .virt_pgno      = CONFIG_SYS_FLASH_BASE >> MMU_PAGE_SHIFT,
+               .nr_pages       = CONFIG_SYS_FLASH_SIZE >> MMU_PAGE_SHIFT,
+               .phys           = (CONFIG_SYS_FLASH_BASE >> MMU_PAGE_SHIFT)
                                        | MMU_VMR_CACHE_NONE,
        }, {
-               .virt_pgno      = CONFIG_SYS_SDRAM_BASE >> PAGE_SHIFT,
-               .nr_pages       = EBI_SDRAM_SIZE >> PAGE_SHIFT,
-               .phys           = (CONFIG_SYS_SDRAM_BASE >> PAGE_SHIFT)
+               .virt_pgno      = CONFIG_SYS_SDRAM_BASE >> MMU_PAGE_SHIFT,
+               .nr_pages       = EBI_SDRAM_SIZE >> MMU_PAGE_SHIFT,
+               .phys           = (CONFIG_SYS_SDRAM_BASE >> MMU_PAGE_SHIFT)
                                        | MMU_VMR_CACHE_WRBACK,
        },
 };
@@ -78,7 +78,10 @@ int board_early_init_f(void)
        hmatrix_slave_write(EBI, SFR, HMATRIX_BIT(EBI_SDRAM_ENABLE));
 
        portmux_enable_ebi(sdram_config.data_bits, 23, 0, PORTMUX_DRIVE_HIGH);
+       sdram_init(uncached(EBI_SDRAM_BASE), &sdram_config);
+
        portmux_enable_usart1(PORTMUX_DRIVE_MIN);
+
 #if defined(CONFIG_MACB)
        portmux_enable_macb0(PORTMUX_MACB_MII, PORTMUX_DRIVE_LOW);
        portmux_enable_macb1(PORTMUX_MACB_MII, PORTMUX_DRIVE_LOW);
@@ -90,24 +93,6 @@ int board_early_init_f(void)
        return 0;
 }
 
-phys_size_t initdram(int board_type)
-{
-       unsigned long expected_size;
-       unsigned long actual_size;
-       void *sdram_base;
-
-       sdram_base = uncached(EBI_SDRAM_BASE);
-
-       expected_size = sdram_init(sdram_base, &sdram_config);
-       actual_size = get_ram_size(sdram_base, expected_size);
-
-       if (expected_size != actual_size)
-               printf("Warning: Only %lu of %lu MiB SDRAM is working\n",
-                               actual_size >> 20, expected_size >> 20);
-
-       return actual_size;
-}
-
 int board_early_init_r(void)
 {
        gd->bd->bi_phy_id[0] = 0x10;
index a74547bf65106f4e73764e7da5000110439bb79f..f9ac330c33edee7aa790893524f66d3dbd212133 100644 (file)
@@ -17,14 +17,14 @@ DECLARE_GLOBAL_DATA_PTR;
 
 struct mmu_vm_range mmu_vmr_table[CONFIG_SYS_NR_VM_REGIONS] = {
        {
-               .virt_pgno      = CONFIG_SYS_FLASH_BASE >> PAGE_SHIFT,
-               .nr_pages       = CONFIG_SYS_FLASH_SIZE >> PAGE_SHIFT,
-               .phys           = (CONFIG_SYS_FLASH_BASE >> PAGE_SHIFT)
+               .virt_pgno      = CONFIG_SYS_FLASH_BASE >> MMU_PAGE_SHIFT,
+               .nr_pages       = CONFIG_SYS_FLASH_SIZE >> MMU_PAGE_SHIFT,
+               .phys           = (CONFIG_SYS_FLASH_BASE >> MMU_PAGE_SHIFT)
                                        | MMU_VMR_CACHE_NONE,
        }, {
-               .virt_pgno      = CONFIG_SYS_SDRAM_BASE >> PAGE_SHIFT,
-               .nr_pages       = EBI_SDRAM_SIZE >> PAGE_SHIFT,
-               .phys           = (CONFIG_SYS_SDRAM_BASE >> PAGE_SHIFT)
+               .virt_pgno      = CONFIG_SYS_SDRAM_BASE >> MMU_PAGE_SHIFT,
+               .nr_pages       = EBI_SDRAM_SIZE >> MMU_PAGE_SHIFT,
+               .phys           = (CONFIG_SYS_SDRAM_BASE >> MMU_PAGE_SHIFT)
                                        | MMU_VMR_CACHE_WRBACK,
        },
 };
@@ -52,6 +52,9 @@ int board_early_init_f(void)
        hmatrix_slave_write(EBI, SFR, HMATRIX_BIT(EBI_SDRAM_ENABLE));
 
        portmux_enable_ebi(32, 23, 0, PORTMUX_DRIVE_HIGH);
+
+       sdram_init(uncached(EBI_SDRAM_BASE), &sdram_config);
+
        portmux_enable_usart3(PORTMUX_DRIVE_MIN);
 #if defined(CONFIG_MACB)
        portmux_enable_macb0(PORTMUX_MACB_MII, PORTMUX_DRIVE_HIGH);
@@ -63,24 +66,6 @@ int board_early_init_f(void)
        return 0;
 }
 
-phys_size_t initdram(int board_type)
-{
-       unsigned long expected_size;
-       unsigned long actual_size;
-       void *sdram_base;
-
-       sdram_base = uncached(EBI_SDRAM_BASE);
-
-       expected_size = sdram_init(sdram_base, &sdram_config);
-       actual_size = get_ram_size(sdram_base, expected_size);
-
-       if (expected_size != actual_size)
-               printf("Warning: Only %lu of %lu MiB SDRAM is working\n",
-                               actual_size >> 20, expected_size >> 20);
-
-       return actual_size;
-}
-
 int board_early_init_r(void)
 {
        gd->bd->bi_phy_id[0] = 0x01;
index 340b7131883d46b88f30e55588b59c69c7f094e1..91b41162de95ea7ed9e6abb47c1c150181c972e6 100644 (file)
@@ -18,14 +18,14 @@ DECLARE_GLOBAL_DATA_PTR;
 
 struct mmu_vm_range mmu_vmr_table[CONFIG_SYS_NR_VM_REGIONS] = {
        {
-               .virt_pgno      = CONFIG_SYS_FLASH_BASE >> PAGE_SHIFT,
-               .nr_pages       = CONFIG_SYS_FLASH_SIZE >> PAGE_SHIFT,
-               .phys           = (CONFIG_SYS_FLASH_BASE >> PAGE_SHIFT)
+               .virt_pgno      = CONFIG_SYS_FLASH_BASE >> MMU_PAGE_SHIFT,
+               .nr_pages       = CONFIG_SYS_FLASH_SIZE >> MMU_PAGE_SHIFT,
+               .phys           = (CONFIG_SYS_FLASH_BASE >> MMU_PAGE_SHIFT)
                                | MMU_VMR_CACHE_NONE,
        }, {
-               .virt_pgno      = CONFIG_SYS_SDRAM_BASE >> PAGE_SHIFT,
-               .nr_pages       = EBI_SDRAM_SIZE >> PAGE_SHIFT,
-               .phys           = (CONFIG_SYS_SDRAM_BASE >> PAGE_SHIFT)
+               .virt_pgno      = CONFIG_SYS_SDRAM_BASE >> MMU_PAGE_SHIFT,
+               .nr_pages       = EBI_SDRAM_SIZE >> MMU_PAGE_SHIFT,
+               .phys           = (CONFIG_SYS_SDRAM_BASE >> MMU_PAGE_SHIFT)
                                | MMU_VMR_CACHE_WRBACK,
        },
 };
@@ -53,6 +53,8 @@ int board_early_init_f(void)
        hmatrix_slave_write(EBI, SFR, HMATRIX_BIT(EBI_SDRAM_ENABLE));
 
        portmux_enable_ebi(SDRAM_DATA_32BIT, 23, 0, PORTMUX_DRIVE_HIGH);
+       sdram_init(uncached(EBI_SDRAM_BASE), &sdram_config);
+
        portmux_enable_usart0(PORTMUX_DRIVE_MIN);
        portmux_enable_usart1(PORTMUX_DRIVE_MIN);
 #if defined(CONFIG_MACB)
@@ -69,24 +71,6 @@ int board_early_init_f(void)
        return 0;
 }
 
-phys_size_t initdram(int board_type)
-{
-       unsigned long expected_size;
-       unsigned long actual_size;
-       void *sdram_base;
-
-       sdram_base = uncached(EBI_SDRAM_BASE);
-
-       expected_size = sdram_init(sdram_base, &sdram_config);
-       actual_size = get_ram_size(sdram_base, expected_size);
-
-       if (expected_size != actual_size)
-               printf("Warning: Only %lu of %lu MiB SDRAM is working\n",
-                               actual_size >> 20, expected_size >> 20);
-
-       return actual_size;
-}
-
 int board_early_init_r(void)
 {
        gd->bd->bi_phy_id[0] = 0x00;
index e075f4687bac7f01ce51dc2f31dd20ac55afdc28..dcfefc46b3448ee3a4bb9b8ae09a1b659f2beaca 100644 (file)
@@ -126,7 +126,8 @@ struct bfticu_iomap {
 #endif
 
 int ethernet_present(void);
-int ivm_read_eeprom(void);
+int ivm_read_eeprom(unsigned char *buf, int len);
+int ivm_analyze_eeprom(unsigned char *buf, int len);
 
 int trigger_fpga_config(void);
 int wait_for_fpga_config(void);
index b6b19ccb8ea1379b2e0fbed5b86df26e40aa1a1e..42db54221bb34dc30966304cba6bdb822842fc47 100644 (file)
@@ -10,6 +10,8 @@
 #include <i2c.h>
 #include "common.h"
 
+#define MAC_STR_SZ     20
+
 static int ivm_calc_crc(unsigned char *buf, int len)
 {
        const unsigned short crc_tab[16] = {
@@ -185,45 +187,37 @@ static int ivm_check_crc(unsigned char *buf, int block)
        return 0;
 }
 
-static int calculate_mac_offset(unsigned char *valbuf, unsigned char *buf,
+/* take care of the possible MAC address offset and the IVM content offset */
+static int process_mac(unsigned char *valbuf, unsigned char *buf,
                                int offset)
 {
+       unsigned char mac[6];
        unsigned long val = (buf[4] << 16) + (buf[5] << 8) + buf[6];
 
-       if (offset == 0)
-               return 0;
+       /* use an intermediate buffer, to not change IVM content
+        * MAC address is at offset 1
+        */
+       memcpy(mac, buf+1, 6);
 
-       val += offset;
-       buf[4] = (val >> 16) & 0xff;
-       buf[5] = (val >> 8) & 0xff;
-       buf[6] = val & 0xff;
-       sprintf((char *)valbuf, "%pM", buf + 1);
+       if (offset) {
+               val += offset;
+               mac[3] = (val >> 16) & 0xff;
+               mac[4] = (val >> 8) & 0xff;
+               mac[5] = val & 0xff;
+       }
+
+       sprintf((char *)valbuf, "%pM", mac);
        return 0;
 }
 
 static int ivm_analyze_block2(unsigned char *buf, int len)
 {
-       unsigned char   valbuf[CONFIG_SYS_IVM_EEPROM_PAGE_LEN];
+       unsigned char   valbuf[MAC_STR_SZ];
        unsigned long   count;
 
        /* IVM_MAC Adress begins at offset 1 */
        sprintf((char *)valbuf, "%pM", buf + 1);
        ivm_set_value("IVM_MacAddress", (char *)valbuf);
-       /* if an offset is defined, add it */
-       calculate_mac_offset(buf, valbuf, CONFIG_PIGGY_MAC_ADRESS_OFFSET);
-#ifdef MACH_TYPE_KM_KIRKWOOD
-       setenv((char *)"ethaddr", (char *)valbuf);
-#else
-       if (getenv("ethaddr") == NULL)
-               setenv((char *)"ethaddr", (char *)valbuf);
-#endif
-#ifdef CONFIG_KMVECT1
-/* KMVECT1 has two ethernet interfaces */
-       if (getenv("eth1addr") == NULL) {
-               calculate_mac_offset(buf, valbuf, 1);
-               setenv((char *)"eth1addr", (char *)valbuf);
-       }
-#endif
        /* IVM_MacCount */
        count = (buf[10] << 24) +
                   (buf[11] << 16) +
@@ -236,7 +230,7 @@ static int ivm_analyze_block2(unsigned char *buf, int len)
        return 0;
 }
 
-static int ivm_analyze_eeprom(unsigned char *buf, int len)
+int ivm_analyze_eeprom(unsigned char *buf, int len)
 {
        unsigned short  val;
        unsigned char   valbuf[CONFIG_SYS_IVM_EEPROM_PAGE_LEN];
@@ -296,21 +290,44 @@ static int ivm_analyze_eeprom(unsigned char *buf, int len)
        return 0;
 }
 
-int ivm_read_eeprom(void)
+static int ivm_populate_env(unsigned char *buf, int len)
+{
+       unsigned char   *page2;
+       unsigned char   valbuf[MAC_STR_SZ];
+
+       /* do we have the page 2 filled ? if not return */
+       if (ivm_check_crc(buf, 2))
+               return 0;
+       page2 = &buf[CONFIG_SYS_IVM_EEPROM_PAGE_LEN*2];
+
+       /* if an offset is defined, add it */
+       process_mac(valbuf, page2, CONFIG_PIGGY_MAC_ADRESS_OFFSET);
+       if (getenv("ethaddr") == NULL)
+               setenv((char *)"ethaddr", (char *)valbuf);
+#ifdef CONFIG_KMVECT1
+/* KMVECT1 has two ethernet interfaces */
+       if (getenv("eth1addr") == NULL) {
+               process_mac(valbuf, page2, 1);
+               setenv((char *)"eth1addr", (char *)valbuf);
+       }
+#endif
+
+       return 0;
+}
+
+int ivm_read_eeprom(unsigned char *buf, int len)
 {
-       uchar i2c_buffer[CONFIG_SYS_IVM_EEPROM_MAX_LEN];
        int ret;
 
        i2c_set_bus_num(CONFIG_KM_IVM_BUS);
        /* add deblocking here */
        i2c_make_abort();
 
-       ret = i2c_read(CONFIG_SYS_IVM_EEPROM_ADR, 0, 1, i2c_buffer,
-               CONFIG_SYS_IVM_EEPROM_MAX_LEN);
+       ret = i2c_read(CONFIG_SYS_IVM_EEPROM_ADR, 0, 1, buf, len);
        if (ret != 0) {
                printf("Error reading EEprom\n");
                return -2;
        }
 
-       return ivm_analyze_eeprom(i2c_buffer, CONFIG_SYS_IVM_EEPROM_MAX_LEN);
+       return ivm_populate_env(buf, len);
 }
index bf84676b9bd900accc072148bbb70e4a0259f4a0..c599b409362603c2463e12c75427fec8c5b801dd 100644 (file)
@@ -18,6 +18,8 @@
 #include <i2c.h>
 #include "../common/common.h"
 
+static uchar ivm_content[CONFIG_SYS_IVM_EEPROM_MAX_LEN];
+
 /*
  * I/O Port configuration table
  *
@@ -393,9 +395,15 @@ int board_early_init_r(void)
        return 0;
 }
 
+int misc_init_r(void)
+{
+       ivm_read_eeprom(ivm_content, CONFIG_SYS_IVM_EEPROM_MAX_LEN);
+       return 0;
+}
+
 int hush_init_var(void)
 {
-       ivm_read_eeprom();
+       ivm_analyze_eeprom(ivm_content, CONFIG_SYS_IVM_EEPROM_MAX_LEN);
        return 0;
 }
 
index 1da0dcb9d8a03354db82fc72385b7ba52407cc7a..89e9e1e57c384abf9205898ba438ad2e01d38ea9 100644 (file)
@@ -28,6 +28,8 @@
 
 #include "../common/common.h"
 
+static uchar ivm_content[CONFIG_SYS_IVM_EEPROM_MAX_LEN];
+
 const qe_iop_conf_t qe_iop_conf_tab[] = {
        /* port pin dir open_drain assign */
 #if defined(CONFIG_MPC8360)
@@ -190,6 +192,7 @@ int board_early_init_r(void)
 
 int misc_init_r(void)
 {
+       ivm_read_eeprom(ivm_content, CONFIG_SYS_IVM_EEPROM_MAX_LEN);
        return 0;
 }
 
@@ -370,7 +373,7 @@ int ft_board_setup(void *blob, bd_t *bd)
 #if defined(CONFIG_HUSH_INIT_VAR)
 int hush_init_var(void)
 {
-       ivm_read_eeprom();
+       ivm_analyze_eeprom(ivm_content, CONFIG_SYS_IVM_EEPROM_MAX_LEN);
        return 0;
 }
 #endif
index 1c7c108cb5acd7536e0081a7d2a7f40a7eb23a74..2938861f368fc454e657485fe73372da89de2641 100644 (file)
@@ -102,6 +102,8 @@ static const u32 kwmpp_config[] = {
        0
 };
 
+static uchar ivm_content[CONFIG_SYS_IVM_EEPROM_MAX_LEN];
+
 #if defined(CONFIG_KM_MGCOGE3UN)
 /*
  * Wait for startup OK from mgcoge3ne
@@ -210,6 +212,8 @@ int misc_init_r(void)
        }
 #endif
 
+       ivm_read_eeprom(ivm_content, CONFIG_SYS_IVM_EEPROM_MAX_LEN);
+
        initialize_unit_leds();
        set_km_env();
        set_bootcount_addr();
@@ -419,7 +423,7 @@ void reset_phy(void)
 #if defined(CONFIG_HUSH_INIT_VAR)
 int hush_init_var(void)
 {
-       ivm_read_eeprom();
+       ivm_analyze_eeprom(ivm_content, CONFIG_SYS_IVM_EEPROM_MAX_LEN);
        return 0;
 }
 #endif
index a74f75bad41dc09af5d9caf680f6f1bf08bb2a3e..eebb47fc21f1cfbcf6aff58e72154c9cc9f5388c 100644 (file)
@@ -26,6 +26,8 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+static uchar ivm_content[CONFIG_SYS_IVM_EEPROM_MAX_LEN];
+
 int checkboard(void)
 {
        printf("Board: Keymile %s\n", CONFIG_KM_BOARD_NAME);
@@ -195,13 +197,14 @@ int misc_init_r(void)
                }
        }
 
+       ivm_read_eeprom(ivm_content, CONFIG_SYS_IVM_EEPROM_MAX_LEN);
        return 0;
 }
 
 #if defined(CONFIG_HUSH_INIT_VAR)
 int hush_init_var(void)
 {
-       ivm_read_eeprom();
+       ivm_analyze_eeprom(ivm_content, CONFIG_SYS_IVM_EEPROM_MAX_LEN);
        return 0;
 }
 #endif
index 2ad53ec2ab6d8d6f9b172bd9ab8b6d426bd9e8cb..f07829550821c43923adc9b04ea2a3caa334e1f0 100644 (file)
 
 struct mmu_vm_range mmu_vmr_table[CONFIG_SYS_NR_VM_REGIONS] = {
        {
-               .virt_pgno      = CONFIG_SYS_FLASH_BASE >> PAGE_SHIFT,
-               .nr_pages       = CONFIG_SYS_FLASH_SIZE >> PAGE_SHIFT,
-               .phys           = (CONFIG_SYS_FLASH_BASE >> PAGE_SHIFT)
+               .virt_pgno      = CONFIG_SYS_FLASH_BASE >> MMU_PAGE_SHIFT,
+               .nr_pages       = CONFIG_SYS_FLASH_SIZE >> MMU_PAGE_SHIFT,
+               .phys           = (CONFIG_SYS_FLASH_BASE >> MMU_PAGE_SHIFT)
                                        | MMU_VMR_CACHE_NONE,
        }, {
-               .virt_pgno      = EBI_SRAM_CS2_BASE >> PAGE_SHIFT,
-               .nr_pages       = EBI_SRAM_CS2_SIZE >> PAGE_SHIFT,
-               .phys           = (EBI_SRAM_CS2_BASE >> PAGE_SHIFT)
+               .virt_pgno      = EBI_SRAM_CS2_BASE >> MMU_PAGE_SHIFT,
+               .nr_pages       = EBI_SRAM_CS2_SIZE >> MMU_PAGE_SHIFT,
+               .phys           = (EBI_SRAM_CS2_BASE >> MMU_PAGE_SHIFT)
                                        | MMU_VMR_CACHE_NONE,
        }, {
-               .virt_pgno      = CONFIG_SYS_SDRAM_BASE >> PAGE_SHIFT,
-               .nr_pages       = EBI_SDRAM_SIZE >> PAGE_SHIFT,
-               .phys           = (CONFIG_SYS_SDRAM_BASE >> PAGE_SHIFT)
+               .virt_pgno      = CONFIG_SYS_SDRAM_BASE >> MMU_PAGE_SHIFT,
+               .nr_pages       = EBI_SDRAM_SIZE >> MMU_PAGE_SHIFT,
+               .phys           = (CONFIG_SYS_SDRAM_BASE >> MMU_PAGE_SHIFT)
                                        | MMU_VMR_CACHE_WRBACK,
        },
 };
@@ -91,6 +91,8 @@ int board_early_init_f(void)
 
        /* Enable 26 address bits and NCS2 */
        portmux_enable_ebi(16, 26, PORTMUX_EBI_CS(2), PORTMUX_DRIVE_HIGH);
+       sdram_init(uncached(EBI_SDRAM_BASE), &sdram_config);
+
        portmux_enable_usart1(PORTMUX_DRIVE_MIN);
 
        /* de-assert "force sys reset" pin */
@@ -151,24 +153,6 @@ int board_early_init_f(void)
        return 0;
 }
 
-phys_size_t initdram(int board_type)
-{
-       unsigned long expected_size;
-       unsigned long actual_size;
-       void *sdram_base;
-
-       sdram_base = uncached(EBI_SDRAM_BASE);
-
-       expected_size = sdram_init(sdram_base, &sdram_config);
-       actual_size = get_ram_size(sdram_base, expected_size);
-
-       if (expected_size != actual_size)
-               printf("Warning: Only %lu of %lu MiB SDRAM is working\n",
-                               actual_size >> 20, expected_size >> 20);
-
-       return actual_size;
-}
-
 int board_early_init_r(void)
 {
        gd->bd->bi_phy_id[0] = 0x01;
index d82fee7b90fd4eb4d15290e9239eb20413ca7c23..a0c7d3b3232c66cabeb934e135f25b9a0e9d8253 100644 (file)
@@ -21,14 +21,14 @@ DECLARE_GLOBAL_DATA_PTR;
 
 struct mmu_vm_range mmu_vmr_table[CONFIG_SYS_NR_VM_REGIONS] = {
        {
-               .virt_pgno      = CONFIG_SYS_FLASH_BASE >> PAGE_SHIFT,
-               .nr_pages       = CONFIG_SYS_FLASH_SIZE >> PAGE_SHIFT,
-               .phys           = (CONFIG_SYS_FLASH_BASE >> PAGE_SHIFT)
+               .virt_pgno      = CONFIG_SYS_FLASH_BASE >> MMU_PAGE_SHIFT,
+               .nr_pages       = CONFIG_SYS_FLASH_SIZE >> MMU_PAGE_SHIFT,
+               .phys           = (CONFIG_SYS_FLASH_BASE >> MMU_PAGE_SHIFT)
                                        | MMU_VMR_CACHE_NONE,
        }, {
-               .virt_pgno      = CONFIG_SYS_SDRAM_BASE >> PAGE_SHIFT,
-               .nr_pages       = EBI_SDRAM_SIZE >> PAGE_SHIFT,
-               .phys           = (CONFIG_SYS_SDRAM_BASE >> PAGE_SHIFT)
+               .virt_pgno      = CONFIG_SYS_SDRAM_BASE >> MMU_PAGE_SHIFT,
+               .nr_pages       = EBI_SDRAM_SIZE >> MMU_PAGE_SHIFT,
+               .phys           = (CONFIG_SYS_SDRAM_BASE >> MMU_PAGE_SHIFT)
                                        | MMU_VMR_CACHE_WRBACK,
        },
 };
@@ -63,6 +63,8 @@ int board_early_init_f(void)
        hmatrix_slave_write(EBI, SFR, HMATRIX_BIT(EBI_SDRAM_ENABLE));
 
        portmux_enable_ebi(32, 23, 0, PORTMUX_DRIVE_HIGH);
+       sdram_init(uncached(EBI_SDRAM_BASE), &sdram_config);
+
        portmux_enable_usart1(PORTMUX_DRIVE_MIN);
 
 #if defined(CONFIG_MACB)
@@ -74,24 +76,6 @@ int board_early_init_f(void)
        return 0;
 }
 
-phys_size_t initdram(int board_type)
-{
-       unsigned long expected_size;
-       unsigned long actual_size;
-       void *sdram_base;
-
-       sdram_base = uncached(EBI_SDRAM_BASE);
-
-       expected_size = sdram_init(sdram_base, &sdram_config);
-       actual_size = get_ram_size(sdram_base, expected_size);
-
-       if (expected_size != actual_size)
-               printf("Warning: Only %lu of %lu MiB SDRAM is working\n",
-                      actual_size >> 20, expected_size >> 20);
-
-       return actual_size;
-}
-
 int board_early_init_r(void)
 {
        gd->bd->bi_phy_id[0] = 0x01;
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 db96e347e7ab10b7ea7dc1f5e1205050d5008f95..3a7e04d542dde214d04b808bf47cf15b01019b89 100644 (file)
@@ -47,7 +47,8 @@ static const struct emif_regs beagle_x15_emif1_ddr3_532mhz_emif_regs = {
        .sdram_config_init      = 0x61851b32,
        .sdram_config           = 0x61851b32,
        .sdram_config2          = 0x00000000,
-       .ref_ctrl               = 0x00001035,
+       .ref_ctrl               = 0x000040F1,
+       .ref_ctrl_final         = 0x00001035,
        .sdram_tim1             = 0xceef266b,
        .sdram_tim2             = 0x328f7fda,
        .sdram_tim3             = 0x027f88a8,
@@ -103,7 +104,8 @@ static const struct emif_regs beagle_x15_emif2_ddr3_532mhz_emif_regs = {
        .sdram_config_init      = 0x61851b32,
        .sdram_config           = 0x61851b32,
        .sdram_config2          = 0x00000000,
-       .ref_ctrl               = 0x00001035,
+       .ref_ctrl               = 0x000040F1,
+       .ref_ctrl_final         = 0x00001035,
        .sdram_tim1             = 0xceef266b,
        .sdram_tim2             = 0x328f7fda,
        .sdram_tim3             = 0x027f88a8,
index 04ec675103630c35af3dd7eaaeaee9f7800b6ab0..8892a2843df4db3fad47235f55353f92ab84e981 100644 (file)
@@ -35,12 +35,14 @@ static struct aemif_config aemif_configs[] = {
 
 int dram_init(void)
 {
-       ddr3_init();
+       u32 ddr3_size;
+
+       ddr3_size = ddr3_init();
 
        gd->ram_size = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE,
                                    CONFIG_MAX_RAM_BANK_SIZE);
        aemif_init(ARRAY_SIZE(aemif_configs), aemif_configs);
-       ddr3_init_ecc(KS2_DDR3A_EMIF_CTRL_BASE);
+       ddr3_init_ecc(KS2_DDR3A_EMIF_CTRL_BASE, ddr3_size);
        return 0;
 }
 
index 40fd96607dbfc22c7d7339ca04bd330917e9a666..35ffb4205673f3f63295e4acaeb3a29f00fc6d0d 100644 (file)
 #include "ddr3_cfg.h"
 #include <asm/arch/ddr3.h>
 
-static int ddr3_size;
 static struct pll_init_data ddr3_400 = DDR3_PLL_400;
 
-void ddr3_init(void)
+u32 ddr3_init(void)
 {
+       u32 ddr3_size;
        char dimm_name[32];
 
        if (~(readl(KS2_PLL_CNTRL_BASE + KS2_RSTCTRL_RSTYPE) & 0x1))
@@ -43,13 +43,11 @@ void ddr3_init(void)
                printf("DRAM: 4 GiB\n");
                ddr3_init_ddrphy(KS2_DDR3A_DDRPHYC, &ddr3phy_1600_4g);
                ddr3_init_ddremif(KS2_DDR3A_EMIF_CTRL_BASE, &ddr3_1600_4g);
+       } else {
+               printf("Unknown SO-DIMM. Cannot configure DDR3\n");
+               while (1)
+                       ;
        }
-}
 
-/**
- * ddr3_get_size - return ddr3 size in GiB
- */
-int ddr3_get_size(void)
-{
        return ddr3_size;
 }
index a1c3d05f8e50e2f7d4f2a62097f8e46379f0aaaa..b36eb27bfaa74b5f15793c7996874aa658520bb2 100644 (file)
 #include <asm/arch/ddr3.h>
 #include <asm/arch/hardware.h>
 
-static int ddr3_size;
-
 struct pll_init_data ddr3a_333 = DDR3_PLL_333(A);
 struct pll_init_data ddr3a_400 = DDR3_PLL_400(A);
 
-void ddr3_init(void)
+u32 ddr3_init(void)
 {
        char dimm_name[32];
+       u32 ddr3_size;
 
        ddr3_get_dimm_params(dimm_name);
 
@@ -93,12 +92,6 @@ void ddr3_init(void)
        /* Apply the workaround for PG 1.0 and 1.1 Silicons */
        if (cpu_revision() <= 1)
                ddr3_err_reset_workaround();
-}
 
-/**
- * ddr3_get_size - return ddr3 size in GiB
- */
-int ddr3_get_size(void)
-{
        return ddr3_size;
 }
index 15a14f2aafe59b3f816fcb8dec68d5169a95a8df..00fc1943f5299f91eafc5d99740eaffe1a0a66fd 100644 (file)
 #include "ddr3_cfg.h"
 #include <asm/arch/ddr3.h>
 
-static int ddr3_size;
 static struct pll_init_data ddr3_400 = DDR3_PLL_400;
 
-void ddr3_init(void)
+u32 ddr3_init(void)
 {
        init_pll(&ddr3_400);
 
        /* No SO-DIMM, 2GB discreet DDR */
        printf("DRAM: 2 GiB\n");
-       ddr3_size = 2;
 
        /* Reset DDR3 PHY after PLL enabled */
        ddr3_reset_ddrphy();
 
        ddr3_init_ddrphy(KS2_DDR3A_DDRPHYC, &ddr3phy_1600_2g);
        ddr3_init_ddremif(KS2_DDR3A_EMIF_CTRL_BASE, &ddr3_1600_2g);
-}
 
-/**
- * ddr3_get_size - return ddr3 size in GiB
- */
-int ddr3_get_size(void)
-{
-       return ddr3_size;
+       return 2;
 }
index 2c10215a1778527559d385243f75f7ae08a76a67..4d8b8a626becb3a3685a9f18bad66bc96e0dfeb6 100644 (file)
@@ -573,48 +573,22 @@ static int reserve_fdt(void)
        return 0;
 }
 
-static int reserve_stacks(void)
+int arch_reserve_stacks(void)
 {
-#ifdef CONFIG_SPL_BUILD
-# ifdef CONFIG_ARM
-       gd->start_addr_sp -= 128;       /* leave 32 words for abort-stack */
-       gd->irq_sp = gd->start_addr_sp;
-# endif
-#else
-# ifdef CONFIG_PPC
-       ulong *s;
-# endif
+       return 0;
+}
 
-       /* setup stack pointer for exceptions */
+static int reserve_stacks(void)
+{
+       /* make stack pointer 16-byte aligned */
        gd->start_addr_sp -= 16;
        gd->start_addr_sp &= ~0xf;
-       gd->irq_sp = gd->start_addr_sp;
 
        /*
-        * Handle architecture-specific things here
-        * TODO(sjg@chromium.org): Perhaps create arch_reserve_stack()
-        * to handle this and put in arch/xxx/lib/stack.c
+        * let the architecture specific code tailor gd->start_addr_sp and
+        * gd->irq_sp
         */
-# if defined(CONFIG_ARM) && !defined(CONFIG_ARM64)
-#  ifdef CONFIG_USE_IRQ
-       gd->start_addr_sp -= (CONFIG_STACKSIZE_IRQ + CONFIG_STACKSIZE_FIQ);
-       debug("Reserving %zu Bytes for IRQ stack at: %08lx\n",
-               CONFIG_STACKSIZE_IRQ + CONFIG_STACKSIZE_FIQ, gd->start_addr_sp);
-
-       /* 8-byte alignment for ARM ABI compliance */
-       gd->start_addr_sp &= ~0x07;
-#  endif
-       /* leave 3 words for abort-stack, plus 1 for alignment */
-       gd->start_addr_sp -= 16;
-# elif defined(CONFIG_PPC)
-       /* Clear initial stack frame */
-       s = (ulong *) gd->start_addr_sp;
-       *s = 0; /* Terminate back chain */
-       *++s = 0; /* NULL return address */
-# endif /* Architecture specific code */
-
-       return 0;
-#endif
+       return arch_reserve_stacks();
 }
 
 static int display_new_sp(void)
@@ -909,7 +883,7 @@ static init_fnc_t init_sequence_f[] = {
 #endif
        announce_dram_init,
        /* TODO: unify all these dram functions? */
-#if defined(CONFIG_ARM) || defined(CONFIG_X86) || defined(CONFIG_MICROBLAZE)
+#if defined(CONFIG_ARM) || defined(CONFIG_X86) || defined(CONFIG_MICROBLAZE) || defined(CONFIG_AVR32)
        dram_init,              /* configure available RAM banks */
 #endif
 #if defined(CONFIG_MIPS) || defined(CONFIG_PPC)
index 907b33cca7624124cd251b656db219a1e5052449..4fcd4f6a7057e3ba8afeb985869f358718fa7c66 100644 (file)
@@ -55,6 +55,9 @@
 #include <dm/root.h>
 #include <linux/compiler.h>
 #include <linux/err.h>
+#ifdef CONFIG_AVR32
+#include <asm/arch/mmu.h>
+#endif
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -459,6 +462,18 @@ static int initr_env(void)
        return 0;
 }
 
+#ifdef CONFIG_SYS_BOOTPARAMS_LEN
+static int initr_malloc_bootparams(void)
+{
+       gd->bd->bi_boot_params = (ulong)malloc(CONFIG_SYS_BOOTPARAMS_LEN);
+       if (!gd->bd->bi_boot_params) {
+               puts("WARNING: Cannot allocate space for boot parameters\n");
+               return -ENOMEM;
+       }
+       return 0;
+}
+#endif
+
 #ifdef CONFIG_SC3
 /* TODO: with new initcalls, move this into the driver */
 extern void sc3_read_eeprom(void);
@@ -486,7 +501,7 @@ static int initr_api(void)
 #endif
 
 /* enable exceptions */
-#ifdef CONFIG_ARM
+#if defined(CONFIG_ARM) || defined(CONFIG_AVR32)
 static int initr_enable_interrupts(void)
 {
        enable_interrupts();
@@ -775,6 +790,9 @@ init_fnc_t init_sequence_r[] = {
        initr_dataflash,
 #endif
        initr_env,
+#ifdef CONFIG_SYS_BOOTPARAMS_LEN
+       initr_malloc_bootparams,
+#endif
        INIT_FUNC_WATCHDOG_RESET
        initr_secondary_cpu,
 #ifdef CONFIG_SC3
@@ -810,10 +828,10 @@ init_fnc_t init_sequence_r[] = {
        initr_kgdb,
 #endif
        interrupt_init,
-#if defined(CONFIG_ARM)
+#if defined(CONFIG_ARM) || defined(CONFIG_AVR32)
        initr_enable_interrupts,
 #endif
-#if defined(CONFIG_X86) || defined(CONFIG_MICROBLAZE)
+#if defined(CONFIG_X86) || defined(CONFIG_MICROBLAZE) || defined(CONFIG_AVR32)
        timer_init,             /* initialize timer */
 #endif
 #if defined(CONFIG_STATUS_LED) && defined(STATUS_LED_BOOT)
@@ -878,6 +896,10 @@ void board_init_r(gd_t *new_gd, ulong dest_addr)
        int i;
 #endif
 
+#ifdef CONFIG_AVR32
+       mmu_init_r(dest_addr);
+#endif
+
 #if !defined(CONFIG_X86) && !defined(CONFIG_ARM) && !defined(CONFIG_ARM64)
        gd = new_gd;
 #endif
index e9eab232f961bb873a019fde8580a06fe4236b80..aa81da227b93b894795f627729e151f18876a6c9 100644 (file)
@@ -345,8 +345,8 @@ int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
        bd_t *bd = gd->bd;
 
        print_num("boot_params",        (ulong)bd->bi_boot_params);
-       print_num("memstart",           (ulong)bd->bi_memstart);
-       print_lnum("memsize",           (u64)bd->bi_memsize);
+       print_num("memstart",           (ulong)bd->bi_dram[0].start);
+       print_lnum("memsize",           (u64)bd->bi_dram[0].size);
        print_num("flashstart",         (ulong)bd->bi_flashstart);
        print_num("flashsize",          (ulong)bd->bi_flashsize);
        print_num("flashoffset",        (ulong)bd->bi_flashoffset);
index b47d11024f2beb007d049bc0cb54a43268d8bde1..778d2a148be67b921be72fb58a155a0813cccdc9 100644 (file)
@@ -1010,9 +1010,7 @@ int fit_image_verify(const void *fit, int image_noffset)
        }
 
        /* Process all hash subnodes of the component image node */
-       for (noffset = fdt_first_subnode(fit, image_noffset);
-            noffset >= 0;
-            noffset = fdt_next_subnode(fit, noffset)) {
+       fdt_for_each_subnode(fit, noffset, image_noffset) {
                const char *name = fit_get_name(fit, noffset, NULL);
 
                /*
index 2c9f0cdf7ae3996b5c57bbe74b9ff7ee5cea58d7..eda5e1353ab0add00db84fd00a53590ac28238cc 100644 (file)
@@ -212,9 +212,7 @@ static int fit_image_verify_sig(const void *fit, int image_noffset,
        int ret;
 
        /* Process all hash subnodes of the component image node */
-       for (noffset = fdt_first_subnode(fit, image_noffset);
-            noffset >= 0;
-            noffset = fdt_next_subnode(fit, noffset)) {
+       fdt_for_each_subnode(fit, noffset, image_noffset) {
                const char *name = fit_get_name(fit, noffset, NULL);
 
                if (!strncmp(name, FIT_SIG_NODENAME,
@@ -262,9 +260,7 @@ int fit_image_verify_required_sigs(const void *fit, int image_noffset,
                return 0;
        }
 
-       for (noffset = fdt_first_subnode(sig_blob, sig_node);
-            noffset >= 0;
-            noffset = fdt_next_subnode(sig_blob, noffset)) {
+       fdt_for_each_subnode(sig_blob, noffset, sig_node) {
                const char *required;
                int ret;
 
@@ -397,9 +393,7 @@ static int fit_config_verify_sig(const void *fit, int conf_noffset,
        int ret;
 
        /* Process all hash subnodes of the component conf node */
-       for (noffset = fdt_first_subnode(fit, conf_noffset);
-            noffset >= 0;
-            noffset = fdt_next_subnode(fit, noffset)) {
+       fdt_for_each_subnode(fit, noffset, conf_noffset) {
                const char *name = fit_get_name(fit, noffset, NULL);
 
                if (!strncmp(name, FIT_SIG_NODENAME,
@@ -444,9 +438,7 @@ int fit_config_verify_required_sigs(const void *fit, int conf_noffset,
                return 0;
        }
 
-       for (noffset = fdt_first_subnode(sig_blob, sig_node);
-            noffset >= 0;
-            noffset = fdt_next_subnode(sig_blob, noffset)) {
+       fdt_for_each_subnode(sig_blob, noffset, sig_node) {
                const char *required;
                int ret;
 
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)
index 2c0e8e00dd2cfeb63021b383cc514725c38d8df2..c2fee01ac1c4717d3094e1fa6d2bcfde3733c46b 100644 (file)
@@ -17,7 +17,7 @@ void spl_nor_load_image(void)
 
 #ifdef CONFIG_SPL_OS_BOOT
        if (!spl_start_uboot()) {
-               struct image_header *header;
+               const struct image_header *header;
 
                /*
                 * Load Linux from its location in NOR flash to its defined
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 fc64f4814484e8052410f4769c60240ae67dc510..24123fcfe536d73861d4de51a19e6257b0fe2ac7 100644 (file)
@@ -989,12 +989,15 @@ int board_nand_init(struct nand_chip *nand)
        if (err)
                return err;
 
-#ifdef CONFIG_NAND_OMAP_GPMC_PREFETCH
        /* TODO: Implement for 16-bit bus width */
        if (nand->options & NAND_BUSWIDTH_16)
                nand->read_buf = nand_read_buf16;
+#ifdef CONFIG_NAND_OMAP_GPMC_PREFETCH
        else
                nand->read_buf = omap_nand_read_prefetch8;
+#else
+       else
+               nand->read_buf = nand_read_buf;
 #endif
 
        nand->dev_ready = omap_dev_ready;
index bedab1d606863494956c99eaca130b3357f57677..35f1a57331318aa42b1d2a068dd273a133e753bd 100644 (file)
@@ -398,8 +398,6 @@ static int keystone2_eth_open(struct eth_device *dev, bd_t *bis)
        sys_has_mdio =
                (eth_priv->sgmii_link_type == SGMII_LINK_MAC_PHY) ? 1 : 0;
 
-       keystone2_net_serdes_setup();
-
        if (sys_has_mdio)
                keystone2_mdio_reset(mdio_bus);
 
@@ -556,6 +554,8 @@ int keystone2_emac_initialize(struct eth_priv_t *eth_priv)
                        return res;
        }
 
+       keystone2_net_serdes_setup();
+
        /* Create phy device and bind it with driver */
 #ifdef CONFIG_KSNET_MDIO_PHY_CONFIG_ENABLE
        phy_dev = phy_connect(mdio_bus, eth_priv->phy_addr,
index ed928574061600118a7ed8c0e83398c5c070291c..378efbfd9fd8033ad2a34c12596394bb03158486 100644 (file)
@@ -223,9 +223,12 @@ void pciauto_prescan_setup_bridge(struct pci_controller *hose,
        struct pci_region *pci_mem = hose->pci_mem;
        struct pci_region *pci_prefetch = hose->pci_prefetch;
        struct pci_region *pci_io = hose->pci_io;
-       u16 cmdstat;
+       u16 cmdstat, prefechable_64;
 
        pci_hose_read_config_word(hose, dev, PCI_COMMAND, &cmdstat);
+       pci_hose_read_config_word(hose, dev, PCI_PREF_MEMORY_BASE,
+                               &prefechable_64);
+       prefechable_64 &= PCI_PREF_RANGE_TYPE_MASK;
 
        /* Configure bus number registers */
        pci_hose_write_config_byte(hose, dev, PCI_PRIMARY_BUS,
@@ -252,12 +255,26 @@ void pciauto_prescan_setup_bridge(struct pci_controller *hose,
                /* Set up memory and I/O filter limits, assume 32-bit I/O space */
                pci_hose_write_config_word(hose, dev, PCI_PREF_MEMORY_BASE,
                                        (pci_prefetch->bus_lower & 0xfff00000) >> 16);
+               if (prefechable_64 == PCI_PREF_RANGE_TYPE_64)
+#ifdef CONFIG_SYS_PCI_64BIT
+                       pci_hose_write_config_dword(hose, dev,
+                                       PCI_PREF_BASE_UPPER32,
+                                       pci_prefetch->bus_lower >> 32);
+#else
+                       pci_hose_write_config_dword(hose, dev,
+                                       PCI_PREF_BASE_UPPER32,
+                                       0x0);
+#endif
 
                cmdstat |= PCI_COMMAND_MEMORY;
        } else {
                /* We don't support prefetchable memory for now, so disable */
                pci_hose_write_config_word(hose, dev, PCI_PREF_MEMORY_BASE, 0x1000);
                pci_hose_write_config_word(hose, dev, PCI_PREF_MEMORY_LIMIT, 0x0);
+               if (prefechable_64 == PCI_PREF_RANGE_TYPE_64) {
+                       pci_hose_write_config_word(hose, dev, PCI_PREF_BASE_UPPER32, 0x0);
+                       pci_hose_write_config_word(hose, dev, PCI_PREF_LIMIT_UPPER32, 0x0);
+               }
        }
 
        if (pci_io) {
@@ -297,11 +314,28 @@ void pciauto_postscan_setup_bridge(struct pci_controller *hose,
        }
 
        if (pci_prefetch) {
+               u16 prefechable_64;
+
+               pci_hose_read_config_word(hose, dev,
+                                       PCI_PREF_MEMORY_LIMIT,
+                                       &prefechable_64);
+               prefechable_64 &= PCI_PREF_RANGE_TYPE_MASK;
+
                /* Round memory allocator to 1MB boundary */
                pciauto_region_align(pci_prefetch, 0x100000);
 
                pci_hose_write_config_word(hose, dev, PCI_PREF_MEMORY_LIMIT,
                                (pci_prefetch->bus_lower - 1) >> 16);
+               if (prefechable_64 == PCI_PREF_RANGE_TYPE_64)
+#ifdef CONFIG_SYS_PCI_64BIT
+                       pci_hose_write_config_dword(hose, dev,
+                                       PCI_PREF_LIMIT_UPPER32,
+                                       (pci_prefetch->bus_lower - 1) >> 32);
+#else
+                       pci_hose_write_config_dword(hose, dev,
+                                       PCI_PREF_LIMIT_UPPER32,
+                                       0x0);
+#endif
        }
 
        if (pci_io) {
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 aef39d78846c9bad7272e84e8fe4587e732a629d..a63a87a2871e52d19f0fb597c5fc7cd4ee58bc62 100644 (file)
@@ -32,6 +32,10 @@ typedef struct bd_info {
        unsigned long   bi_flashoffset; /* reserved area for startup monitor */
        unsigned long   bi_sramstart;   /* start of SRAM memory */
        unsigned long   bi_sramsize;    /* size  of SRAM memory */
+#ifdef CONFIG_AVR32
+       unsigned char   bi_phy_id[4];   /* PHY address for ATAG_ETHERNET */
+       unsigned long   bi_board_number;/* ATAG_BOARDINFO */
+#endif
 #ifdef CONFIG_ARM
        unsigned long   bi_arm_freq; /* arm frequency */
        unsigned long   bi_dsp_freq; /* dsp core frequency */
index 91294547f5cfe1314067a4e1dd8ffa394d0b6b29..77c55c6f26d61940c251d5b26364a6758b471b1a 100644 (file)
@@ -252,6 +252,24 @@ static inline int print_cpuinfo(void)
 int update_flash_size(int flash_size);
 int arch_early_init_r(void);
 
+/**
+ * Reserve all necessary stacks
+ *
+ * This is used in generic board init sequence in common/board_f.c. Each
+ * architecture could provide this function to tailor the required stacks.
+ *
+ * On entry gd->start_addr_sp is pointing to the suggested top of the stack.
+ * The callee ensures gd->start_add_sp is 16-byte aligned, so architectures
+ * require only this can leave it untouched.
+ *
+ * On exit gd->start_addr_sp and gd->irq_sp should be set to the respective
+ * positions of the stack. The stack pointer(s) will be set to this later.
+ * gd->irq_sp is only required, if the architecture needs it.
+ *
+ * @return 0 if no error
+ */
+__weak int arch_reserve_stacks(void);
+
 /**
  * Show the DRAM size in a board-specific way
  *
index 49674f4537541c6014cb2259976c21ee36dab2d3..07a0b3b23472df57a1e38a32ba7085e0c1f65fea 100644 (file)
 #ifndef _CONFIG_CMD_DISTRO_BOOTCMD_H
 #define _CONFIG_CMD_DISTRO_BOOTCMD_H
 
+/* We need the part command */
+#define CONFIG_PARTITION_UUIDS
+#define CONFIG_CMD_PART
+
 #define BOOTENV_SHARED_BLKDEV_BODY(devtypel) \
                "if " #devtypel " dev ${devnum}; then " \
                        "setenv devtype " #devtypel "; " \
index 9c81e3199f916d49d498d6ce3c5a7bd68ec95aec..540e86ae478b76903997ca044341c59aca3b0b5d 100644 (file)
 #define CONFIG_SYS_INIT_SP_ADDR                (CONFIG_SYS_INTRAM_BASE + CONFIG_SYS_INTRAM_SIZE)
 
 #define CONFIG_SYS_MALLOC_LEN                  (256*1024)
-#define CONFIG_SYS_DMA_ALLOC_LEN               (16384)
 
 /* Allow 4MB for the kernel run-time image */
 #define CONFIG_SYS_LOAD_ADDR                   (EBI_SDRAM_BASE + 0x00400000)
index 7b4f9cf2063b8e147c8bdeb96555dc58937e583b..35eae769301c9b6b961b9ceb6788871eaa8d3f9d 100644 (file)
 #define CONFIG_SYS_INIT_SP_ADDR                (CONFIG_SYS_INTRAM_BASE + CONFIG_SYS_INTRAM_SIZE)
 
 #define CONFIG_SYS_MALLOC_LEN          (256*1024)
-#define CONFIG_SYS_DMA_ALLOC_LEN       (16384)
 
 /* Allow 4MB for the kernel run-time image */
 #define CONFIG_SYS_LOAD_ADDR           (EBI_SDRAM_BASE + 0x00400000)
index 8f3fd0bb00018e1cc6725642220cf775519eb10a..a9c064a45dfbb0e40aa9ca84182a45337f13fbe0 100644 (file)
 #define CONFIG_BOOTP_SUBNETMASK
 #define CONFIG_BOOTP_GATEWAY
 
+/* generic board */
+#define CONFIG_SYS_GENERIC_BOARD
+#define CONFIG_BOARD_EARLY_INIT_F
+#define CONFIG_BOARD_EARLY_INIT_R
 
 /*
  * Command line configuration.
 #define CONFIG_SYS_INIT_SP_ADDR                (CONFIG_SYS_INTRAM_BASE + CONFIG_SYS_INTRAM_SIZE)
 
 #define CONFIG_SYS_MALLOC_LEN                  (256*1024)
-#define CONFIG_SYS_DMA_ALLOC_LEN               (16384)
 
 /* Allow 4MB for the kernel run-time image */
 #define CONFIG_SYS_LOAD_ADDR                   (EBI_SDRAM_BASE + 0x00400000)
index bbe0aea8616f9e91c4ead982228c430ed476be56..25090a68fa719fe34b9e7d018d89798f443c03b6 100644 (file)
 #define CONFIG_SYS_INIT_SP_ADDR                (CONFIG_SYS_INTRAM_BASE + CONFIG_SYS_INTRAM_SIZE)
 
 #define CONFIG_SYS_MALLOC_LEN                  (256*1024)
-#define CONFIG_SYS_DMA_ALLOC_LEN               (16384)
 
 /* Allow 4MB for the kernel run-time image */
 #define CONFIG_SYS_LOAD_ADDR                   (EBI_SDRAM_BASE + 0x00400000)
index 338d3dc78239b30a2d71412812fcf0574ee8d827..75bff4ce288af391f6590be8c323dfc71c186996 100644 (file)
 #define CONFIG_SYS_INIT_SP_ADDR                (CONFIG_SYS_INTRAM_BASE + CONFIG_SYS_INTRAM_SIZE)
 
 #define CONFIG_SYS_MALLOC_LEN                  (256*1024)
-#define CONFIG_SYS_DMA_ALLOC_LEN               (16384)
 
 /* Allow 4MB for the kernel run-time image */
 #define CONFIG_SYS_LOAD_ADDR                   (EBI_SDRAM_BASE + 0x00400000)
index 73534addfc1bcf6581515b11f1b9a67f8df00794..54eb9777d778e7d85695154547248a1a920779f6 100644 (file)
 #define CONFIG_USART_BASE              ATMEL_BASE_USART1
 #define CONFIG_USART_ID                        1
 
+#define CONFIG_SYS_GENERIC_BOARD
+#define CONFIG_BOARD_EARLY_INIT_F
+#define CONFIG_BOARD_EARLY_INIT_R
+
 /* User serviceable stuff */
 #define CONFIG_CMDLINE_TAG
 #define CONFIG_SETUP_MEMORY_TAGS
                                         CONFIG_SYS_INTRAM_SIZE)
 
 #define CONFIG_SYS_MALLOC_LEN          (256*1024)
-#define CONFIG_SYS_DMA_ALLOC_LEN       (16384)
 
 /* Allow 4MB for the kernel run-time image */
 #define CONFIG_SYS_LOAD_ADDR           (EBI_SDRAM_BASE + 0x00400000)
index 4f0603abc13290b05e61ee5382e975d4231eb8f1..0bc42f12e0ada1c63bc7256fb8fd70cb80a86657 100644 (file)
 
 #define CONFIG_SYS_MALLOC_LEN                  (256*1024)
 
-#define CONFIG_SYS_DMA_ALLOC_LEN               (16384)
 
 /* Allow 4MB for the kernel run-time image */
 #define CONFIG_SYS_LOAD_ADDR                   (CONFIG_SYS_SDRAM_BASE + 0x00400000)
index 14fd290be1f3c7a7da01acbcd559fc5852b3fb21..12f9d424cb10639ab133cbc2900300c2a4e7b8f0 100644 (file)
@@ -34,6 +34,8 @@
 
 #define        CONFIG_SYS_TEXT_BASE    0xFE000000
 
+#define CONFIG_MISC_INIT_R
+
 /* include common defines/options for all Keymile boards */
 #include "km/keymile-common.h"
 #include "km/km-powerpc.h"
index fc7ecfaee47605af7055ea6c3be2c429543496da..2fd3addc1ad9f780a00499ff6836758f9297a1a7 100644 (file)
 #define CONFIG_SYS_INIT_SP_ADDR                (CONFIG_SYS_INTRAM_BASE + CONFIG_SYS_INTRAM_SIZE)
 
 #define CONFIG_SYS_MALLOC_LEN                  (1024*1024)
-#define CONFIG_SYS_DMA_ALLOC_LEN               (16384)
 
 /* Allow 4MB for the kernel run-time image */
 #define CONFIG_SYS_LOAD_ADDR                   (EBI_SDRAM_BASE + 0x00400000)
index 09889eeb4433c2f923074aacac49a54ea171d092..1238d821b36f85fcd4d0272f18a513f7a936494c 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 */
 
@@ -81,9 +79,6 @@
 #define CONFIG_CMD_MEMORY
 #define CONFIG_CMD_SETEXPR
 
-#define CONFIG_PARTITION_UUIDS
-#define CONFIG_CMD_PART
-
 #define CONFIG_SETUP_MEMORY_TAGS
 #define CONFIG_CMDLINE_TAG
 #define CONFIG_INITRD_TAG
 #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 e4b23eb5b814c12a3cca4ecb5da978d682ebd77b..88770b0611f6bd8b94b358d6256abb8b8a0b788b 100644 (file)
@@ -128,8 +128,6 @@ HOSTLOADLIBES_dumpimage := $(HOSTLOADLIBES_mkimage)
 HOSTLOADLIBES_fit_info := $(HOSTLOADLIBES_mkimage)
 HOSTLOADLIBES_fit_check_sign := $(HOSTLOADLIBES_mkimage)
 
-HOSTLDFLAGS += -T $(srctree)/tools/imagetool.lds
-
 hostprogs-$(CONFIG_EXYNOS5250) += mkexynosspl
 hostprogs-$(CONFIG_EXYNOS5420) += mkexynosspl
 HOSTCFLAGS_mkexynosspl.o := -pedantic
index c9b9f6a16091f1969559f8b0b4eabbcaa47cec45..6f216f9c64c6ec1acf40fcc28fe2af08a4e9ffaf 100644 (file)
@@ -20,3 +20,6 @@
 
 # Block device example
 #/dev/mmcblk0          0xc0000         0x20000
+
+# VFAT example
+#/boot/uboot.env       0x0000          0x4000
index 148e4662b7b366e2b2400639aa733b59e747865f..4b0b73db5277a07629bc306156b37f12ae440d82 100644 (file)
 
 struct image_type_params *imagetool_get_type(int type)
 {
-       struct image_type_params *curr;
-       struct image_type_params *start = ll_entry_start(
-                       struct image_type_params, image_type);
-       struct image_type_params *end = ll_entry_end(
-                       struct image_type_params, image_type);
+       struct image_type_params **curr;
+       INIT_SECTION(image_type);
+
+       struct image_type_params **start = __start_image_type;
+       struct image_type_params **end = __stop_image_type;
 
        for (curr = start; curr != end; curr++) {
-               if (curr->check_image_type) {
-                       if (!curr->check_image_type(type))
-                               return curr;
+               if ((*curr)->check_image_type) {
+                       if (!(*curr)->check_image_type(type))
+                               return *curr;
                }
        }
        return NULL;
@@ -34,16 +34,15 @@ int imagetool_verify_print_header(
        struct image_tool_params *params)
 {
        int retval = -1;
-       struct image_type_params *curr;
+       struct image_type_params **curr;
+       INIT_SECTION(image_type);
 
-       struct image_type_params *start = ll_entry_start(
-                       struct image_type_params, image_type);
-       struct image_type_params *end = ll_entry_end(
-                       struct image_type_params, image_type);
+       struct image_type_params **start = __start_image_type;
+       struct image_type_params **end = __stop_image_type;
 
        for (curr = start; curr != end; curr++) {
-               if (curr->verify_header) {
-                       retval = curr->verify_header((unsigned char *)ptr,
+               if ((*curr)->verify_header) {
+                       retval = (*curr)->verify_header((unsigned char *)ptr,
                                                     sbuf->st_size, params);
 
                        if (retval == 0) {
@@ -51,12 +50,12 @@ int imagetool_verify_print_header(
                                 * Print the image information  if verify is
                                 * successful
                                 */
-                               if (curr->print_header) {
-                                       curr->print_header(ptr);
+                               if ((*curr)->print_header) {
+                                       (*curr)->print_header(ptr);
                                } else {
                                        fprintf(stderr,
                                                "%s: print_header undefined for %s\n",
-                                               params->cmdname, curr->name);
+                                               params->cmdname, (*curr)->name);
                                }
                                break;
                        }
index f35dec71c7190a4b82e817315e998c561f5e064a..3e15b4e22b9a0086c57d3bb6c61a2abe35838a31 100644 (file)
 #include <unistd.h>
 #include <u-boot/sha1.h>
 
-/* define __KERNEL__ in order to get the definitions
- * required by the linker list. This is probably not
- * the best way to do this */
-#ifndef __KERNEL__
-#define __KERNEL__
-#include <linker_lists.h>
-#undef __KERNEL__
-#endif /* __KERNEL__ */
-
 #include "fdt_host.h"
 
 #define ARRAY_SIZE(x)          (sizeof(x) / sizeof((x)[0]))
@@ -194,6 +185,46 @@ int imagetool_save_subimage(
 
 void pbl_load_uboot(int fd, struct image_tool_params *mparams);
 
+#define ___cat(a, b) a ## b
+#define __cat(a, b) ___cat(a, b)
+
+/* we need some special handling for this host tool running eventually on
+ * Darwin. The Mach-O section handling is a bit different than ELF section
+ * handling. The differnces in detail are:
+ *  a) we have segments which have sections
+ *  b) we need a API call to get the respective section symbols */
+#if defined(__MACH__)
+#include <mach-o/getsect.h>
+
+#define INIT_SECTION(name)  do {                                       \
+               unsigned long name ## _len;                             \
+               char *__cat(pstart_, name) = getsectdata("__TEXT",      \
+                       #name, &__cat(name, _len));                     \
+               char *__cat(pstop_, name) = __cat(pstart_, name) +      \
+                       __cat(name, _len);                              \
+               __cat(__start_, name) = (void *)__cat(pstart_, name);   \
+               __cat(__stop_, name) = (void *)__cat(pstop_, name);     \
+       } while (0)
+#define SECTION(name)   __attribute__((section("__TEXT, " #name)))
+
+struct image_type_params **__start_image_type, **__stop_image_type;
+#else
+#define INIT_SECTION(name) /* no-op for ELF */
+#define SECTION(name)   __attribute__((section(#name)))
+
+/* We construct a table of pointers in an ELF section (pointers generally
+ * go unpadded by gcc).  ld creates boundary syms for us. */
+extern struct image_type_params *__start_image_type[], *__stop_image_type[];
+#endif /* __MACH__ */
+
+#if !defined(__used)
+# if __GNUC__ == 3 && __GNUC_MINOR__ < 3
+#  define __used                       __attribute__((__unused__))
+# else
+#  define __used                       __attribute__((__used__))
+# endif
+#endif
+
 #define U_BOOT_IMAGE_TYPE( \
                _id, \
                _name, \
@@ -208,7 +239,8 @@ void pbl_load_uboot(int fd, struct image_tool_params *mparams);
                _fflag_handle, \
                _vrec_header \
        ) \
-       ll_entry_declare(struct image_type_params, _id, image_type) = { \
+       static struct image_type_params __cat(image_type_, _id) = \
+       { \
                .name = _name, \
                .header_size = _header_size, \
                .hdr = _header, \
@@ -220,6 +252,8 @@ void pbl_load_uboot(int fd, struct image_tool_params *mparams);
                .check_image_type = _check_image_type, \
                .fflag_handle = _fflag_handle, \
                .vrec_header = _vrec_header \
-       }
+       }; \
+       static struct image_type_params *SECTION(image_type) __used \
+               __cat(image_type_ptr_, _id) = &__cat(image_type_, _id)
 
 #endif /* _IMAGETOOL_H_ */
diff --git a/tools/imagetool.lds b/tools/imagetool.lds
deleted file mode 100644 (file)
index 7e92b4a..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (c) 2011-2012 The Chromium OS Authors.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-SECTIONS
-{
-
-       . = ALIGN(4);
-       .u_boot_list : {
-               KEEP(*(SORT(.u_boot_list*)));
-       }
-
-       __u_boot_sandbox_option_start = .;
-       _u_boot_sandbox_getopt : { *(.u_boot_sandbox_getopt) }
-       __u_boot_sandbox_option_end = .;
-
-       __bss_start = .;
-}
-
-INSERT BEFORE .data;
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;
        }