]> git.sur5r.net Git - u-boot/commitdiff
avr32: convert to dram_init()
authorAndreas Bießmann <andreas.devel@googlemail.com>
Fri, 6 Feb 2015 22:06:43 +0000 (23:06 +0100)
committerAndreas Bießmann <andreas.devel@googlemail.com>
Tue, 17 Feb 2015 21:52:41 +0000 (22:52 +0100)
Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
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]
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/mimc/mimc200/mimc200.c
board/miromico/hammerhead/hammerhead.c

index 2387f8af62b9a75c73ecb643799f4c90538e24ff..232350ead8c9a4525a57c379871829e49920c4d5 100644 (file)
@@ -26,5 +26,6 @@ typedef struct bd_info {
 #define IH_ARCH_DEFAULT IH_ARCH_AVR32
 
 int arch_cpu_init(void);
+int dram_init(void);
 
 #endif /* __ASM_U_BOOT_H__ */
index bb45cbe1538460591c80b6ff9268e9dbc50f3af1..5f2d97bfc7d2f959b94d5d9a5ac291fcc478063e 100644 (file)
@@ -11,3 +11,4 @@ obj-y += memset.o
 obj-y  += board.o
 obj-$(CONFIG_CMD_BOOTM) += bootm.o
 obj-y  += interrupts.o
+obj-y  += dram_init.o
index e86530fe772fe451f328ba3207ee14c6dd15b11e..13b7fede74bf499b7c024baf523099e45381d3f1 100644 (file)
@@ -29,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)
 {
@@ -82,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));
@@ -97,10 +102,10 @@ void board_init_f(ulong board_type)
        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");
 
        /*
@@ -114,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;
 
        /*
@@ -156,12 +161,7 @@ void board_init_f(ulong board_type)
        *(--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));
 
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 ed09c8c7e41ceb28d73450be128b36eb72cac8e9..dacd4278314c5b3ed0c0c10a44f0c951da621e3c 100644 (file)
@@ -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 912ea10fe405816611b64dcb4a26dbf536215366..8e215d5fcf2f062dfe8dd4b020b5a3b6bfd7a8eb 100644 (file)
@@ -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 f3546946c4a516548ea350ca8d878499c80209bc..fd4363beceb1222384c5887c3bff3e3b7947cd34 100644 (file)
@@ -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 f9fde793f5cb8447756b8ae1efa344470eb8fb9b..f9ac330c33edee7aa790893524f66d3dbd212133 100644 (file)
@@ -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 2ac54db2956eebd1414b972ea7654204236823f6..91b41162de95ea7ed9e6abb47c1c150181c972e6 100644 (file)
@@ -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 186ac7df62583773ae33cbf7f27692aac592cca5..f07829550821c43923adc9b04ea2a3caa334e1f0 100644 (file)
@@ -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 e9a9e4b3cf6d6e88c902fb636f7d30fa83d1e8fa..a0c7d3b3232c66cabeb934e135f25b9a0e9d8253 100644 (file)
@@ -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;