blob: 16d442aa625f344e9674df812f1f195625d9891f [file] [log] [blame]
Stephen Warren0e012c32012-08-05 16:07:22 +00001/*
Stephen Warrenaa44d532013-05-27 18:31:18 +00002 * (C) Copyright 2012-2013 Stephen Warren
Stephen Warren0e012c32012-08-05 16:07:22 +00003 *
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 Warrenaa44d532013-05-27 18:31:18 +000018#include <config.h>
19#include <lcd.h>
Stephen Warrenacc8bf42013-01-29 16:37:37 +000020#include <asm/arch/mbox.h>
Stephen Warrenc4ab9712013-01-29 16:37:42 +000021#include <asm/arch/sdhci.h>
Stephen Warren0e012c32012-08-05 16:07:22 +000022#include <asm/global_data.h>
23
24DECLARE_GLOBAL_DATA_PTR;
25
Stephen Warrenacc8bf42013-01-29 16:37:37 +000026struct msg_get_arm_mem {
27 struct bcm2835_mbox_hdr hdr;
28 struct bcm2835_mbox_tag_get_arm_mem get_arm_mem;
29 u32 end_tag;
30};
31
Stephen Warrenc4ab9712013-01-29 16:37:42 +000032struct msg_get_clock_rate {
33 struct bcm2835_mbox_hdr hdr;
34 struct bcm2835_mbox_tag_get_clock_rate get_clock_rate;
35 u32 end_tag;
36};
37
Stephen Warren0e012c32012-08-05 16:07:22 +000038int dram_init(void)
39{
Stephen Warrenacc8bf42013-01-29 16:37:37 +000040 ALLOC_ALIGN_BUFFER(struct msg_get_arm_mem, msg, 1, 16);
41 int ret;
42
43 BCM2835_MBOX_INIT_HDR(msg);
44 BCM2835_MBOX_INIT_TAG(&msg->get_arm_mem, GET_ARM_MEMORY);
45
46 ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg->hdr);
47 if (ret) {
48 printf("bcm2835: Could not query ARM memory size\n");
49 return -1;
50 }
51
52 gd->ram_size = msg->get_arm_mem.body.resp.mem_size;
Stephen Warren0e012c32012-08-05 16:07:22 +000053
54 return 0;
55}
56
57int board_init(void)
58{
59 gd->bd->bi_boot_params = 0x100;
60
61 return 0;
62}
Stephen Warrenc4ab9712013-01-29 16:37:42 +000063
64int board_mmc_init(void)
65{
66 ALLOC_ALIGN_BUFFER(struct msg_get_clock_rate, msg_clk, 1, 16);
67 int ret;
68
69 BCM2835_MBOX_INIT_HDR(msg_clk);
70 BCM2835_MBOX_INIT_TAG(&msg_clk->get_clock_rate, GET_CLOCK_RATE);
71 msg_clk->get_clock_rate.body.req.clock_id = BCM2835_MBOX_CLOCK_ID_EMMC;
72
73 ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg_clk->hdr);
74 if (ret) {
75 printf("bcm2835: Could not query eMMC clock rate\n");
76 return -1;
77 }
78
79 return bcm2835_sdhci_init(BCM2835_SDHCI_BASE,
80 msg_clk->get_clock_rate.body.resp.rate_hz);
81}
Stephen Warrenaa44d532013-05-27 18:31:18 +000082
83void ft_board_setup(void *blob, bd_t *bd)
84{
85 /*
86 * For now, we simply always add the simplefb DT node. Later, we
87 * should be more intelligent, and e.g. only do this if no enabled DT
88 * node exists for the "real" graphics driver.
89 */
90 lcd_dt_simplefb_add_node(blob);
91}