From patchwork Wed Nov 30 06:07:53 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gabe Black X-Patchwork-Id: 128413 X-Patchwork-Delegate: graeme.russ@gmail.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 D36801007D1 for ; Wed, 30 Nov 2011 17:08:26 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 254A228354; Wed, 30 Nov 2011 07:08:20 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 FS5b+RkfT3LV; Wed, 30 Nov 2011 07:08:19 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 389DE28369; Wed, 30 Nov 2011 07:08:10 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5462C28353 for ; Wed, 30 Nov 2011 07:08:06 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 evdBPVmcCFjT for ; Wed, 30 Nov 2011 07:08:03 +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-yw0-f74.google.com (mail-yw0-f74.google.com [209.85.213.74]) by theia.denx.de (Postfix) with ESMTPS id 825A128354 for ; Wed, 30 Nov 2011 07:08:01 +0100 (CET) Received: by ywb26 with SMTP id 26so30868ywb.3 for ; Tue, 29 Nov 2011 22:08:00 -0800 (PST) Received: by 10.236.156.98 with SMTP id l62mr2267368yhk.4.1322633280731; Tue, 29 Nov 2011 22:08:00 -0800 (PST) Received: by 10.236.156.98 with SMTP id l62mr2267339yhk.4.1322633280661; Tue, 29 Nov 2011 22:08:00 -0800 (PST) Received: from wpzn3.hot.corp.google.com (216-239-44-65.google.com [216.239.44.65]) by gmr-mx.google.com with ESMTPS id r67si308549yhe.6.2011.11.29.22.08.00 (version=TLSv1/SSLv3 cipher=AES128-SHA); Tue, 29 Nov 2011 22:08:00 -0800 (PST) Received: from wpaz9.hot.corp.google.com (wpaz9.hot.corp.google.com [172.24.198.73]) by wpzn3.hot.corp.google.com (Postfix) with ESMTPS id 9A72B10004D; Tue, 29 Nov 2011 22:08:00 -0800 (PST) Received: from gabeblack.mtv.corp.google.com (gabeblack.mtv.corp.google.com [172.22.72.31]) by wpaz9.hot.corp.google.com with ESMTP id pAU67x9H026693; Tue, 29 Nov 2011 22:07:59 -0800 Received: by gabeblack.mtv.corp.google.com (Postfix, from userid 134246) id 0DC9D200EDB; Tue, 29 Nov 2011 22:07:58 -0800 (PST) From: Gabe Black To: U-Boot Mailing List Date: Tue, 29 Nov 2011 22:07:53 -0800 Message-Id: <1322633275-10542-3-git-send-email-gabeblack@chromium.org> X-Mailer: git-send-email 1.7.3.1 In-Reply-To: <1322633275-10542-1-git-send-email-gabeblack@chromium.org> References: <1322633275-10542-1-git-send-email-gabeblack@chromium.org> X-System-Of-Record: true Subject: [U-Boot] [PATCH 2/4] x86: Determine the ram size using the coreboot tables X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de This is really only an approximation using the largest RAM address available in the tables. There may be areas which are marked as reserved which are actually at the end of RAM. Signed-off-by: Gabe Black --- arch/x86/cpu/coreboot/sdram.c | 18 +++++++++++++++++- 1 files changed, 17 insertions(+), 1 deletions(-) diff --git a/arch/x86/cpu/coreboot/sdram.c b/arch/x86/cpu/coreboot/sdram.c index b56085a..b5b086b 100644 --- a/arch/x86/cpu/coreboot/sdram.c +++ b/arch/x86/cpu/coreboot/sdram.c @@ -24,12 +24,28 @@ #include #include +#include +#include +#include DECLARE_GLOBAL_DATA_PTR; int dram_init_f(void) { - gd->ram_size = 64*1024*1024; + int i; + phys_size_t ram_size = 0; + for (i = 0; i < lib_sysinfo.n_memranges; i++) { + unsigned long long end = \ + lib_sysinfo.memrange[i].base + + lib_sysinfo.memrange[i].size; + if (lib_sysinfo.memrange[i].type == CB_MEM_RAM && + end > ram_size) { + ram_size = end; + } + } + gd->ram_size = ram_size; + if (ram_size == 0) + return -1; return 0; }