2 * (C) Copyright 2012-2013 Stephen Warren
4 * See file CREDITS for list of people who contributed to this
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.
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.
19 #include <fdt_support.h>
22 #include <asm/arch/mbox.h>
23 #include <asm/arch/sdhci.h>
24 #include <asm/global_data.h>
26 DECLARE_GLOBAL_DATA_PTR;
28 struct msg_get_arm_mem {
29 struct bcm2835_mbox_hdr hdr;
30 struct bcm2835_mbox_tag_get_arm_mem get_arm_mem;
34 struct msg_set_power_state {
35 struct bcm2835_mbox_hdr hdr;
36 struct bcm2835_mbox_tag_set_power_state set_power_state;
40 struct msg_get_clock_rate {
41 struct bcm2835_mbox_hdr hdr;
42 struct bcm2835_mbox_tag_get_clock_rate get_clock_rate;
48 ALLOC_ALIGN_BUFFER(struct msg_get_arm_mem, msg, 1, 16);
51 BCM2835_MBOX_INIT_HDR(msg);
52 BCM2835_MBOX_INIT_TAG(&msg->get_arm_mem, GET_ARM_MEMORY);
54 ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg->hdr);
56 printf("bcm2835: Could not query ARM memory size\n");
60 gd->ram_size = msg->get_arm_mem.body.resp.mem_size;
65 static int power_on_module(u32 module)
67 ALLOC_ALIGN_BUFFER(struct msg_set_power_state, msg_pwr, 1, 16);
70 BCM2835_MBOX_INIT_HDR(msg_pwr);
71 BCM2835_MBOX_INIT_TAG(&msg_pwr->set_power_state,
73 msg_pwr->set_power_state.body.req.device_id = module;
74 msg_pwr->set_power_state.body.req.state =
75 BCM2835_MBOX_SET_POWER_STATE_REQ_ON |
76 BCM2835_MBOX_SET_POWER_STATE_REQ_WAIT;
78 ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN,
81 printf("bcm2835: Could not set module %u power state\n",
91 gd->bd->bi_boot_params = 0x100;
93 return power_on_module(BCM2835_MBOX_POWER_DEVID_USB_HCD);
96 int board_mmc_init(bd_t *bis)
98 ALLOC_ALIGN_BUFFER(struct msg_get_clock_rate, msg_clk, 1, 16);
101 power_on_module(BCM2835_MBOX_POWER_DEVID_SDHCI);
103 BCM2835_MBOX_INIT_HDR(msg_clk);
104 BCM2835_MBOX_INIT_TAG(&msg_clk->get_clock_rate, GET_CLOCK_RATE);
105 msg_clk->get_clock_rate.body.req.clock_id = BCM2835_MBOX_CLOCK_ID_EMMC;
107 ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg_clk->hdr);
109 printf("bcm2835: Could not query eMMC clock rate\n");
113 return bcm2835_sdhci_init(BCM2835_SDHCI_BASE,
114 msg_clk->get_clock_rate.body.resp.rate_hz);
117 void ft_board_setup(void *blob, bd_t *bd)
120 * For now, we simply always add the simplefb DT node. Later, we
121 * should be more intelligent, and e.g. only do this if no enabled DT
122 * node exists for the "real" graphics driver.
124 lcd_dt_simplefb_add_node(blob);