From: Albert ARIBAUD <albert.u.boot@aribaud.net>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/2] ARM: rpi_b: use bcm2835 mbox driver to get memory size
Date: Thu, 18 Oct 2012 22:28:48 +0200 [thread overview]
Message-ID: <20121018222848.33e2a88b@lilith> (raw)
In-Reply-To: <1350364236-23982-2-git-send-email-swarren@wwwdotorg.org>
Hi Stephen,
On Mon, 15 Oct 2012 23:10:36 -0600, Stephen Warren
<swarren@wwwdotorg.org> wrote:
> 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 <swarren@wwwdotorg.org>
> ---
> 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 <common.h>
> +#include <asm/arch/mbox.h>
> #include <asm/global_data.h>
>
> 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;
> }
Either move the buffer processing into mbox (as an opaque "ask mbox for
memory size" function) or move the memory request struct in here (this
is in order to have a self-consistent mbox interface where either the
mbox API does not know at all about the mem size request, or it knows
all about it).
Amicalement,
--
Albert.
next prev parent reply other threads:[~2012-10-18 20:28 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-16 5:10 [U-Boot] [PATCH 1/2] ARM: bcm2835: add mailbox driver Stephen Warren
2012-10-16 5:10 ` [U-Boot] [PATCH 2/2] ARM: rpi_b: use bcm2835 mbox driver to get memory size Stephen Warren
2012-10-18 20:28 ` Albert ARIBAUD [this message]
2012-10-18 21:51 ` Stephen Warren
2012-10-18 20:23 ` [U-Boot] [PATCH 1/2] ARM: bcm2835: add mailbox driver Albert ARIBAUD
2012-10-18 20:34 ` Stephen Warren
2012-10-18 23:21 ` Albert ARIBAUD
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20121018222848.33e2a88b@lilith \
--to=albert.u.boot@aribaud.net \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox