blob: 6b3e095ba89bcb96ae5c7b8e3708ca7b92787bd2 [file] [log] [blame]
Stephen Warren0e012c32012-08-05 16:07:22 +00001/*
2 * (C) Copyright 2012 Stephen Warren
3 *
4 * See file CREDITS for list of people who contributed to this
5 * project.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * version 2 as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 */
16
17#include <common.h>
Stephen Warrenacc8bf42013-01-29 16:37:37 +000018#include <asm/arch/mbox.h>
Stephen Warrenc4ab9712013-01-29 16:37:42 +000019#include <asm/arch/sdhci.h>
Stephen Warren0e012c32012-08-05 16:07:22 +000020#include <asm/global_data.h>
21
22DECLARE_GLOBAL_DATA_PTR;
23
Stephen Warrenacc8bf42013-01-29 16:37:37 +000024struct msg_get_arm_mem {
25 struct bcm2835_mbox_hdr hdr;
26 struct bcm2835_mbox_tag_get_arm_mem get_arm_mem;
27 u32 end_tag;
28};
29
Stephen Warrenc4ab9712013-01-29 16:37:42 +000030struct msg_get_clock_rate {
31 struct bcm2835_mbox_hdr hdr;
32 struct bcm2835_mbox_tag_get_clock_rate get_clock_rate;
33 u32 end_tag;
34};
35
Stephen Warren0e012c32012-08-05 16:07:22 +000036int dram_init(void)
37{
Stephen Warrenacc8bf42013-01-29 16:37:37 +000038 ALLOC_ALIGN_BUFFER(struct msg_get_arm_mem, msg, 1, 16);
39 int ret;
40
41 BCM2835_MBOX_INIT_HDR(msg);
42 BCM2835_MBOX_INIT_TAG(&msg->get_arm_mem, GET_ARM_MEMORY);
43
44 ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg->hdr);
45 if (ret) {
46 printf("bcm2835: Could not query ARM memory size\n");
47 return -1;
48 }
49
50 gd->ram_size = msg->get_arm_mem.body.resp.mem_size;
Stephen Warren0e012c32012-08-05 16:07:22 +000051
52 return 0;
53}
54
55int board_init(void)
56{
57 gd->bd->bi_boot_params = 0x100;
58
59 return 0;
60}
Stephen Warrenc4ab9712013-01-29 16:37:42 +000061
62int board_mmc_init(void)
63{
64 ALLOC_ALIGN_BUFFER(struct msg_get_clock_rate, msg_clk, 1, 16);
65 int ret;
66
67 BCM2835_MBOX_INIT_HDR(msg_clk);
68 BCM2835_MBOX_INIT_TAG(&msg_clk->get_clock_rate, GET_CLOCK_RATE);
69 msg_clk->get_clock_rate.body.req.clock_id = BCM2835_MBOX_CLOCK_ID_EMMC;
70
71 ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg_clk->hdr);
72 if (ret) {
73 printf("bcm2835: Could not query eMMC clock rate\n");
74 return -1;
75 }
76
77 return bcm2835_sdhci_init(BCM2835_SDHCI_BASE,
78 msg_clk->get_clock_rate.body.resp.rate_hz);
79}