From patchwork Fri Feb 6 22:06:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_Bie=C3=9Fmann?= X-Patchwork-Id: 437480 X-Patchwork-Delegate: andreas.biessmann@googlemail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 256B2140168 for ; Sat, 7 Feb 2015 09:07:53 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 3F2474B164; Fri, 6 Feb 2015 23:07:45 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id RFAn1z2FFbkx; Fri, 6 Feb 2015 23:07:45 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 552C24B5CD; Fri, 6 Feb 2015 23:07:44 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1342C4B5B9 for ; Fri, 6 Feb 2015 23:07:40 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nUM9ImaOXVn4 for ; Fri, 6 Feb 2015 23:07:40 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-wg0-f49.google.com (mail-wg0-f49.google.com [74.125.82.49]) by theia.denx.de (Postfix) with ESMTPS id 8DF0B4B615 for ; Fri, 6 Feb 2015 23:07:32 +0100 (CET) Received: by mail-wg0-f49.google.com with SMTP id k14so16101666wgh.8 for ; Fri, 06 Feb 2015 14:07:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=+owMePuGrEVl9g0Cnx3myCQYrsboNZfO2OTWLeG80r4=; b=TCnxM7M/uT4Zh898njrDNJw6UsKbSg8DAEqv1bZAqHiM2Gj38c+q4UE2ro+T5S5XD7 QVJd+1r5EeyaM2IQIosYGffqFlPYi/nCKhhw5um1oBAis+qtMB9jJZjrBmYAFRo5/s8S FE080ap7L4g5a7Q6zCDTJAXXdIu35NanLn5iShJJvW2Cnm4rCFPEp5IqPuEHOAe8DQ8l lawcBH/y5MgmG5g2bivyrzO22j3SioyonLaeMrbKTlngJsHxkW4xVn6S9BOJ9ciQvFGx X4oiBqFX39RiKWhNvBwIGwxHMatnMWK56HK5VysTJQUDsAIDnm1C6vW/+s750S6y7thG YrNQ== X-Received: by 10.194.78.231 with SMTP id e7mr12186273wjx.33.1423260452653; Fri, 06 Feb 2015 14:07:32 -0800 (PST) Received: from localhost (dockstar.er.biessmann.org. [2a01:198:47b:1::10]) by mx.google.com with ESMTPSA id hd5sm3140039wib.21.2015.02.06.14.07.31 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 06 Feb 2015 14:07:32 -0800 (PST) From: =?UTF-8?q?Andreas=20Bie=C3=9Fmann?= To: U-Boot List Date: Fri, 6 Feb 2015 23:06:43 +0100 Message-Id: <1423260410-9290-6-git-send-email-andreas.devel@googlemail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1423260410-9290-1-git-send-email-andreas.devel@googlemail.com> References: <1423260410-9290-1-git-send-email-andreas.devel@googlemail.com> MIME-Version: 1.0 Cc: Kim Phillips , Waldemar Brodkorb , Kumar Gala , Alex Raimondi , Andy Fleming , Stefan Roese , Mark Jackson Subject: [U-Boot] [PATCH v3 05/12] avr32: convert to dram_init() X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Signed-off-by: Andreas Bießmann Reviewed-by: Simon Glass --- Changes in v3: None Changes in v2: - new since v1 Changes in v1: None arch/avr32/include/asm/u-boot.h | 1 + arch/avr32/lib/Makefile | 1 + arch/avr32/lib/board.c | 20 ++++++++++---------- arch/avr32/lib/dram_init.c | 17 +++++++++++++++++ board/atmel/atngw100/atngw100.c | 20 ++------------------ board/atmel/atngw100mkii/atngw100mkii.c | 21 +++------------------ board/atmel/atstk1000/atstk1000.c | 21 +++------------------ board/earthlcd/favr-32-ezkit/favr-32-ezkit.c | 21 +++------------------ board/in-circuit/grasshopper/grasshopper.c | 20 ++------------------ board/mimc/mimc200/mimc200.c | 20 ++------------------ board/miromico/hammerhead/hammerhead.c | 20 ++------------------ 11 files changed, 46 insertions(+), 136 deletions(-) create mode 100644 arch/avr32/lib/dram_init.c diff --git a/arch/avr32/include/asm/u-boot.h b/arch/avr32/include/asm/u-boot.h index 2387f8a..232350e 100644 --- a/arch/avr32/include/asm/u-boot.h +++ b/arch/avr32/include/asm/u-boot.h @@ -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__ */ diff --git a/arch/avr32/lib/Makefile b/arch/avr32/lib/Makefile index bb45cbe..5f2d97b 100644 --- a/arch/avr32/lib/Makefile +++ b/arch/avr32/lib/Makefile @@ -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 diff --git a/arch/avr32/lib/board.c b/arch/avr32/lib/board.c index e86530f..13b7fed 100644 --- a/arch/avr32/lib/board.c +++ b/arch/avr32/lib/board.c @@ -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 index 0000000..5078e77 --- /dev/null +++ b/arch/avr32/lib/dram_init.c @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2015 Andreas Bießmann + * + * SPDX-License-Identifier: GPL-2.0+ + */ +#include + +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; +} diff --git a/board/atmel/atngw100/atngw100.c b/board/atmel/atngw100/atngw100.c index ed09c8c..dacd427 100644 --- a/board/atmel/atngw100/atngw100.c +++ b/board/atmel/atngw100/atngw100.c @@ -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; diff --git a/board/atmel/atngw100mkii/atngw100mkii.c b/board/atmel/atngw100mkii/atngw100mkii.c index 912ea10..8e215d5 100644 --- a/board/atmel/atngw100mkii/atngw100mkii.c +++ b/board/atmel/atngw100mkii/atngw100mkii.c @@ -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; diff --git a/board/atmel/atstk1000/atstk1000.c b/board/atmel/atstk1000/atstk1000.c index f354694..fd4363b 100644 --- a/board/atmel/atstk1000/atstk1000.c +++ b/board/atmel/atstk1000/atstk1000.c @@ -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; diff --git a/board/earthlcd/favr-32-ezkit/favr-32-ezkit.c b/board/earthlcd/favr-32-ezkit/favr-32-ezkit.c index f9fde79..f9ac330 100644 --- a/board/earthlcd/favr-32-ezkit/favr-32-ezkit.c +++ b/board/earthlcd/favr-32-ezkit/favr-32-ezkit.c @@ -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; diff --git a/board/in-circuit/grasshopper/grasshopper.c b/board/in-circuit/grasshopper/grasshopper.c index 2ac54db..91b4116 100644 --- a/board/in-circuit/grasshopper/grasshopper.c +++ b/board/in-circuit/grasshopper/grasshopper.c @@ -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; diff --git a/board/mimc/mimc200/mimc200.c b/board/mimc/mimc200/mimc200.c index 186ac7d..f078295 100644 --- a/board/mimc/mimc200/mimc200.c +++ b/board/mimc/mimc200/mimc200.c @@ -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; diff --git a/board/miromico/hammerhead/hammerhead.c b/board/miromico/hammerhead/hammerhead.c index e9a9e4b..a0c7d3b 100644 --- a/board/miromico/hammerhead/hammerhead.c +++ b/board/miromico/hammerhead/hammerhead.c @@ -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;