From patchwork Tue Oct 16 05:10:36 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Warren X-Patchwork-Id: 191721 X-Patchwork-Delegate: albert.aribaud@free.fr 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 F18A82C009F for ; Tue, 16 Oct 2012 16:11:12 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 696714A152; Tue, 16 Oct 2012 07:11:05 +0200 (CEST) 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 KDzEKzelxcfK; Tue, 16 Oct 2012 07:11:04 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C64B64A143; Tue, 16 Oct 2012 07:11:02 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2C8004A143 for ; Tue, 16 Oct 2012 07:11:01 +0200 (CEST) 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 NtqnN-RKnB23 for ; Tue, 16 Oct 2012 07:11:00 +0200 (CEST) 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 avon.wwwdotorg.org (avon.wwwdotorg.org [70.85.31.133]) by theia.denx.de (Postfix) with ESMTPS id 294944A13F for ; Tue, 16 Oct 2012 07:10:58 +0200 (CEST) Received: from severn.wwwdotorg.org (unknown [192.168.65.5]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by avon.wwwdotorg.org (Postfix) with ESMTPS id C2120622C; Mon, 15 Oct 2012 23:11:23 -0600 (MDT) Received: from dart.wwwdotorg.org (c-24-9-124-73.hsd1.co.comcast.net [24.9.124.73]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by severn.wwwdotorg.org (Postfix) with ESMTPSA id EE9C5E4105; Mon, 15 Oct 2012 23:10:55 -0600 (MDT) From: Stephen Warren To: Albert Aribaud Date: Mon, 15 Oct 2012 23:10:36 -0600 Message-Id: <1350364236-23982-2-git-send-email-swarren@wwwdotorg.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1350364236-23982-1-git-send-email-swarren@wwwdotorg.org> References: <1350364236-23982-1-git-send-email-swarren@wwwdotorg.org> X-NVConfidentiality: public X-Virus-Scanned: clamav-milter 0.96.5 at avon.wwwdotorg.org X-Virus-Status: Clean Cc: u-boot@lists.denx.de, linux-rpi-kernel@lists.infradead.org Subject: [U-Boot] [PATCH 2/2] ARM: rpi_b: use bcm2835 mbox driver to get memory size 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 The firmware running on the bcm2835 SoC's VideoCore CPU determines how much of the system RAM is available for use by the ARM CPU. Previously, U-Boot assumed that only 128MB was available, since this was the smallest value configured by any public firmware. However, we can now query the actual value at run-time from the firmware using the mbox property protocol. Signed-off-by: Stephen Warren --- board/raspberrypi/rpi_b/rpi_b.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/board/raspberrypi/rpi_b/rpi_b.c b/board/raspberrypi/rpi_b/rpi_b.c index 688b0aa..88f8c58 100644 --- a/board/raspberrypi/rpi_b/rpi_b.c +++ b/board/raspberrypi/rpi_b/rpi_b.c @@ -15,13 +15,31 @@ */ #include +#include #include DECLARE_GLOBAL_DATA_PTR; int dram_init(void) { - gd->ram_size = CONFIG_SYS_SDRAM_SIZE; + ALLOC_ALIGN_BUFFER(struct bcm2835_mbox_buf_get_arm_mem, buf, 1, 16); + + memset(buf, 0, sizeof(*buf)); + buf->hdr.buf_size = sizeof(*buf); + buf->hdr.code = BCM2835_MBOX_REQ_CODE; + buf->tag_hdr.tag = BCM2835_MBOX_TAG_GET_ARM_MEMORY; + buf->tag_hdr.val_buf_size = sizeof(buf->body); + buf->tag_hdr.val_len = sizeof(buf->body.req); + + bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &buf->hdr); + + if ((buf->hdr.code != BCM2835_MBOX_RESP_CODE_SUCCESS) || + (!(buf->tag_hdr.val_len & BCM2835_MBOX_TAG_VAL_LEN_RESPONSE))) { + printf("BCM2835_MBOX_TAG_GET_ARM_MEMORY failed\n"); + return -1; + } + + gd->ram_size = buf->body.resp.mem_size; return 0; }