Stephen Warren | 0d04f34 | 2012-08-05 16:07:22 +0000 | [diff] [blame] | 1 | /* |
Stephen Warren | 4641429 | 2015-02-16 12:16:15 -0700 | [diff] [blame] | 2 | * (C) Copyright 2012-2013,2015 Stephen Warren |
Stephen Warren | 0d04f34 | 2012-08-05 16:07:22 +0000 | [diff] [blame] | 3 | * |
Stephen Warren | a033171 | 2015-02-16 12:16:13 -0700 | [diff] [blame] | 4 | * SPDX-License-Identifier: GPL-2.0 |
Stephen Warren | 0d04f34 | 2012-08-05 16:07:22 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
Stephen Warren | ea697ae | 2013-05-27 18:31:18 +0000 | [diff] [blame] | 8 | #include <config.h> |
Simon Glass | 41e98e0 | 2014-09-22 17:30:56 -0600 | [diff] [blame] | 9 | #include <dm.h> |
Jeroen Hofstee | 5dfd162 | 2014-07-13 22:01:51 +0200 | [diff] [blame] | 10 | #include <fdt_support.h> |
Nikita Kiryanov | 033167c | 2015-02-03 13:32:31 +0200 | [diff] [blame] | 11 | #include <fdt_simplefb.h> |
Stephen Warren | ea697ae | 2013-05-27 18:31:18 +0000 | [diff] [blame] | 12 | #include <lcd.h> |
Simon Glass | cf92e05 | 2015-09-02 17:24:58 -0600 | [diff] [blame] | 13 | #include <memalign.h> |
Jeroen Hofstee | 5dfd162 | 2014-07-13 22:01:51 +0200 | [diff] [blame] | 14 | #include <mmc.h> |
Simon Glass | 41e98e0 | 2014-09-22 17:30:56 -0600 | [diff] [blame] | 15 | #include <asm/gpio.h> |
Stephen Warren | 3f39778 | 2013-01-29 16:37:37 +0000 | [diff] [blame] | 16 | #include <asm/arch/mbox.h> |
Stephen Warren | 131a1e6 | 2013-01-29 16:37:42 +0000 | [diff] [blame] | 17 | #include <asm/arch/sdhci.h> |
Stephen Warren | 0d04f34 | 2012-08-05 16:07:22 +0000 | [diff] [blame] | 18 | #include <asm/global_data.h> |
Simon Glass | 1150666 | 2014-11-24 21:36:34 -0700 | [diff] [blame] | 19 | #include <dm/platform_data/serial_pl01x.h> |
Stephen Warren | 0d04f34 | 2012-08-05 16:07:22 +0000 | [diff] [blame] | 20 | |
| 21 | DECLARE_GLOBAL_DATA_PTR; |
| 22 | |
Simon Glass | 41e98e0 | 2014-09-22 17:30:56 -0600 | [diff] [blame] | 23 | static const struct bcm2835_gpio_platdata gpio_platdata = { |
| 24 | .base = BCM2835_GPIO_BASE, |
| 25 | }; |
| 26 | |
| 27 | U_BOOT_DEVICE(bcm2835_gpios) = { |
| 28 | .name = "gpio_bcm2835", |
| 29 | .platdata = &gpio_platdata, |
| 30 | }; |
| 31 | |
Simon Glass | 1150666 | 2014-11-24 21:36:34 -0700 | [diff] [blame] | 32 | static const struct pl01x_serial_platdata serial_platdata = { |
Stephen Warren | 4641429 | 2015-02-16 12:16:15 -0700 | [diff] [blame] | 33 | #ifdef CONFIG_BCM2836 |
| 34 | .base = 0x3f201000, |
| 35 | #else |
Simon Glass | 1150666 | 2014-11-24 21:36:34 -0700 | [diff] [blame] | 36 | .base = 0x20201000, |
Stephen Warren | 4641429 | 2015-02-16 12:16:15 -0700 | [diff] [blame] | 37 | #endif |
Simon Glass | 1150666 | 2014-11-24 21:36:34 -0700 | [diff] [blame] | 38 | .type = TYPE_PL011, |
| 39 | .clock = 3000000, |
| 40 | }; |
| 41 | |
| 42 | U_BOOT_DEVICE(bcm2835_serials) = { |
| 43 | .name = "serial_pl01x", |
| 44 | .platdata = &serial_platdata, |
| 45 | }; |
| 46 | |
Stephen Warren | 3f39778 | 2013-01-29 16:37:37 +0000 | [diff] [blame] | 47 | struct msg_get_arm_mem { |
| 48 | struct bcm2835_mbox_hdr hdr; |
| 49 | struct bcm2835_mbox_tag_get_arm_mem get_arm_mem; |
| 50 | u32 end_tag; |
| 51 | }; |
| 52 | |
Stephen Warren | 6fe7845 | 2014-11-18 21:40:21 -0700 | [diff] [blame] | 53 | struct msg_get_board_rev { |
| 54 | struct bcm2835_mbox_hdr hdr; |
| 55 | struct bcm2835_mbox_tag_get_board_rev get_board_rev; |
| 56 | u32 end_tag; |
| 57 | }; |
| 58 | |
Stephen Warren | 4f80a06 | 2014-09-26 20:51:39 -0600 | [diff] [blame] | 59 | struct msg_get_mac_address { |
| 60 | struct bcm2835_mbox_hdr hdr; |
| 61 | struct bcm2835_mbox_tag_get_mac_address get_mac_address; |
| 62 | u32 end_tag; |
| 63 | }; |
| 64 | |
Stephen Warren | f66f2aa | 2014-01-13 19:50:11 -0700 | [diff] [blame] | 65 | struct msg_set_power_state { |
| 66 | struct bcm2835_mbox_hdr hdr; |
| 67 | struct bcm2835_mbox_tag_set_power_state set_power_state; |
| 68 | u32 end_tag; |
| 69 | }; |
| 70 | |
Stephen Warren | 131a1e6 | 2013-01-29 16:37:42 +0000 | [diff] [blame] | 71 | struct msg_get_clock_rate { |
| 72 | struct bcm2835_mbox_hdr hdr; |
| 73 | struct bcm2835_mbox_tag_get_clock_rate get_clock_rate; |
| 74 | u32 end_tag; |
| 75 | }; |
| 76 | |
Stephen Warren | 6fe7845 | 2014-11-18 21:40:21 -0700 | [diff] [blame] | 77 | /* See comments in mbox.h for data source */ |
| 78 | static const struct { |
| 79 | const char *name; |
| 80 | const char *fdtfile; |
Stephen Warren | 3207d8f | 2014-12-05 20:56:46 -0700 | [diff] [blame] | 81 | bool has_onboard_eth; |
Stephen Warren | 6fe7845 | 2014-11-18 21:40:21 -0700 | [diff] [blame] | 82 | } models[] = { |
Stephen Warren | 914627f | 2014-12-23 20:01:44 -0700 | [diff] [blame] | 83 | [0] = { |
| 84 | "Unknown model", |
Stephen Warren | 4641429 | 2015-02-16 12:16:15 -0700 | [diff] [blame] | 85 | #ifdef CONFIG_BCM2836 |
| 86 | "bcm2836-rpi-other.dtb", |
| 87 | #else |
Stephen Warren | 914627f | 2014-12-23 20:01:44 -0700 | [diff] [blame] | 88 | "bcm2835-rpi-other.dtb", |
Stephen Warren | 4641429 | 2015-02-16 12:16:15 -0700 | [diff] [blame] | 89 | #endif |
Stephen Warren | 914627f | 2014-12-23 20:01:44 -0700 | [diff] [blame] | 90 | false, |
| 91 | }, |
Stephen Warren | 4641429 | 2015-02-16 12:16:15 -0700 | [diff] [blame] | 92 | #ifdef CONFIG_BCM2836 |
| 93 | [BCM2836_BOARD_REV_2_B] = { |
| 94 | "2 Model B", |
| 95 | "bcm2836-rpi-2-b.dtb", |
| 96 | true, |
| 97 | }, |
| 98 | #else |
Stephen Warren | 6fe7845 | 2014-11-18 21:40:21 -0700 | [diff] [blame] | 99 | [BCM2835_BOARD_REV_B_I2C0_2] = { |
| 100 | "Model B (no P5)", |
| 101 | "bcm2835-rpi-b-i2c0.dtb", |
Stephen Warren | 3207d8f | 2014-12-05 20:56:46 -0700 | [diff] [blame] | 102 | true, |
Stephen Warren | 6fe7845 | 2014-11-18 21:40:21 -0700 | [diff] [blame] | 103 | }, |
| 104 | [BCM2835_BOARD_REV_B_I2C0_3] = { |
| 105 | "Model B (no P5)", |
| 106 | "bcm2835-rpi-b-i2c0.dtb", |
Stephen Warren | 3207d8f | 2014-12-05 20:56:46 -0700 | [diff] [blame] | 107 | true, |
Stephen Warren | 6fe7845 | 2014-11-18 21:40:21 -0700 | [diff] [blame] | 108 | }, |
| 109 | [BCM2835_BOARD_REV_B_I2C1_4] = { |
| 110 | "Model B", |
| 111 | "bcm2835-rpi-b.dtb", |
Stephen Warren | 3207d8f | 2014-12-05 20:56:46 -0700 | [diff] [blame] | 112 | true, |
Stephen Warren | 6fe7845 | 2014-11-18 21:40:21 -0700 | [diff] [blame] | 113 | }, |
| 114 | [BCM2835_BOARD_REV_B_I2C1_5] = { |
| 115 | "Model B", |
| 116 | "bcm2835-rpi-b.dtb", |
Stephen Warren | 3207d8f | 2014-12-05 20:56:46 -0700 | [diff] [blame] | 117 | true, |
Stephen Warren | 6fe7845 | 2014-11-18 21:40:21 -0700 | [diff] [blame] | 118 | }, |
| 119 | [BCM2835_BOARD_REV_B_I2C1_6] = { |
| 120 | "Model B", |
| 121 | "bcm2835-rpi-b.dtb", |
Stephen Warren | 3207d8f | 2014-12-05 20:56:46 -0700 | [diff] [blame] | 122 | true, |
Stephen Warren | 6fe7845 | 2014-11-18 21:40:21 -0700 | [diff] [blame] | 123 | }, |
| 124 | [BCM2835_BOARD_REV_A_7] = { |
| 125 | "Model A", |
| 126 | "bcm2835-rpi-a.dtb", |
Stephen Warren | 3207d8f | 2014-12-05 20:56:46 -0700 | [diff] [blame] | 127 | false, |
Stephen Warren | 6fe7845 | 2014-11-18 21:40:21 -0700 | [diff] [blame] | 128 | }, |
| 129 | [BCM2835_BOARD_REV_A_8] = { |
| 130 | "Model A", |
| 131 | "bcm2835-rpi-a.dtb", |
Stephen Warren | 3207d8f | 2014-12-05 20:56:46 -0700 | [diff] [blame] | 132 | false, |
Stephen Warren | 6fe7845 | 2014-11-18 21:40:21 -0700 | [diff] [blame] | 133 | }, |
| 134 | [BCM2835_BOARD_REV_A_9] = { |
| 135 | "Model A", |
| 136 | "bcm2835-rpi-a.dtb", |
Stephen Warren | 3207d8f | 2014-12-05 20:56:46 -0700 | [diff] [blame] | 137 | false, |
Stephen Warren | 6fe7845 | 2014-11-18 21:40:21 -0700 | [diff] [blame] | 138 | }, |
| 139 | [BCM2835_BOARD_REV_B_REV2_d] = { |
| 140 | "Model B rev2", |
| 141 | "bcm2835-rpi-b-rev2.dtb", |
Stephen Warren | 3207d8f | 2014-12-05 20:56:46 -0700 | [diff] [blame] | 142 | true, |
Stephen Warren | 6fe7845 | 2014-11-18 21:40:21 -0700 | [diff] [blame] | 143 | }, |
| 144 | [BCM2835_BOARD_REV_B_REV2_e] = { |
| 145 | "Model B rev2", |
| 146 | "bcm2835-rpi-b-rev2.dtb", |
Stephen Warren | 3207d8f | 2014-12-05 20:56:46 -0700 | [diff] [blame] | 147 | true, |
Stephen Warren | 6fe7845 | 2014-11-18 21:40:21 -0700 | [diff] [blame] | 148 | }, |
| 149 | [BCM2835_BOARD_REV_B_REV2_f] = { |
| 150 | "Model B rev2", |
| 151 | "bcm2835-rpi-b-rev2.dtb", |
Stephen Warren | 3207d8f | 2014-12-05 20:56:46 -0700 | [diff] [blame] | 152 | true, |
Stephen Warren | 6fe7845 | 2014-11-18 21:40:21 -0700 | [diff] [blame] | 153 | }, |
| 154 | [BCM2835_BOARD_REV_B_PLUS] = { |
| 155 | "Model B+", |
| 156 | "bcm2835-rpi-b-plus.dtb", |
Stephen Warren | 3207d8f | 2014-12-05 20:56:46 -0700 | [diff] [blame] | 157 | true, |
Stephen Warren | 6fe7845 | 2014-11-18 21:40:21 -0700 | [diff] [blame] | 158 | }, |
| 159 | [BCM2835_BOARD_REV_CM] = { |
| 160 | "Compute Module", |
| 161 | "bcm2835-rpi-cm.dtb", |
Stephen Warren | 3207d8f | 2014-12-05 20:56:46 -0700 | [diff] [blame] | 162 | false, |
Stephen Warren | 6fe7845 | 2014-11-18 21:40:21 -0700 | [diff] [blame] | 163 | }, |
Stephen Warren | 47705ef | 2014-12-23 20:01:43 -0700 | [diff] [blame] | 164 | [BCM2835_BOARD_REV_A_PLUS] = { |
| 165 | "Model A+", |
| 166 | "bcm2835-rpi-a-plus.dtb", |
| 167 | false, |
| 168 | }, |
Stephen Warren | 787affb | 2015-04-12 21:43:25 -0600 | [diff] [blame] | 169 | [BCM2835_BOARD_REV_B_PLUS_13] = { |
| 170 | "Model B+", |
| 171 | "bcm2835-rpi-b-plus.dtb", |
| 172 | true, |
| 173 | }, |
| 174 | [BCM2835_BOARD_REV_CM_14] = { |
| 175 | "Compute Module", |
| 176 | "bcm2835-rpi-cm.dtb", |
| 177 | false, |
| 178 | }, |
Lubomir Rintel | 79ad5ce | 2015-10-14 17:17:54 +0200 | [diff] [blame] | 179 | [BCM2835_BOARD_REV_A_PLUS_15] = { |
| 180 | "Model A+", |
| 181 | "bcm2835-rpi-a-plus.dtb", |
| 182 | false, |
| 183 | }, |
Stephen Warren | 4641429 | 2015-02-16 12:16:15 -0700 | [diff] [blame] | 184 | #endif |
Stephen Warren | 6fe7845 | 2014-11-18 21:40:21 -0700 | [diff] [blame] | 185 | }; |
| 186 | |
| 187 | u32 rpi_board_rev = 0; |
| 188 | |
Stephen Warren | 0d04f34 | 2012-08-05 16:07:22 +0000 | [diff] [blame] | 189 | int dram_init(void) |
| 190 | { |
Alexander Stein | 927753a | 2015-07-24 09:22:12 +0200 | [diff] [blame] | 191 | ALLOC_CACHE_ALIGN_BUFFER(struct msg_get_arm_mem, msg, 1); |
Stephen Warren | 3f39778 | 2013-01-29 16:37:37 +0000 | [diff] [blame] | 192 | int ret; |
| 193 | |
| 194 | BCM2835_MBOX_INIT_HDR(msg); |
| 195 | BCM2835_MBOX_INIT_TAG(&msg->get_arm_mem, GET_ARM_MEMORY); |
| 196 | |
| 197 | ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg->hdr); |
| 198 | if (ret) { |
| 199 | printf("bcm2835: Could not query ARM memory size\n"); |
| 200 | return -1; |
| 201 | } |
| 202 | |
| 203 | gd->ram_size = msg->get_arm_mem.body.resp.mem_size; |
Stephen Warren | 0d04f34 | 2012-08-05 16:07:22 +0000 | [diff] [blame] | 204 | |
| 205 | return 0; |
| 206 | } |
| 207 | |
Stephen Warren | 6fe7845 | 2014-11-18 21:40:21 -0700 | [diff] [blame] | 208 | static void set_fdtfile(void) |
| 209 | { |
| 210 | const char *fdtfile; |
| 211 | |
| 212 | if (getenv("fdtfile")) |
| 213 | return; |
| 214 | |
| 215 | fdtfile = models[rpi_board_rev].fdtfile; |
Stephen Warren | 6fe7845 | 2014-11-18 21:40:21 -0700 | [diff] [blame] | 216 | setenv("fdtfile", fdtfile); |
| 217 | } |
| 218 | |
| 219 | static void set_usbethaddr(void) |
Stephen Warren | 4f80a06 | 2014-09-26 20:51:39 -0600 | [diff] [blame] | 220 | { |
Alexander Stein | 927753a | 2015-07-24 09:22:12 +0200 | [diff] [blame] | 221 | ALLOC_CACHE_ALIGN_BUFFER(struct msg_get_mac_address, msg, 1); |
Stephen Warren | 4f80a06 | 2014-09-26 20:51:39 -0600 | [diff] [blame] | 222 | int ret; |
| 223 | |
Stephen Warren | 3207d8f | 2014-12-05 20:56:46 -0700 | [diff] [blame] | 224 | if (!models[rpi_board_rev].has_onboard_eth) |
| 225 | return; |
| 226 | |
Stephen Warren | 4f80a06 | 2014-09-26 20:51:39 -0600 | [diff] [blame] | 227 | if (getenv("usbethaddr")) |
Stephen Warren | 6fe7845 | 2014-11-18 21:40:21 -0700 | [diff] [blame] | 228 | return; |
Stephen Warren | 4f80a06 | 2014-09-26 20:51:39 -0600 | [diff] [blame] | 229 | |
| 230 | BCM2835_MBOX_INIT_HDR(msg); |
| 231 | BCM2835_MBOX_INIT_TAG(&msg->get_mac_address, GET_MAC_ADDRESS); |
| 232 | |
| 233 | ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg->hdr); |
| 234 | if (ret) { |
| 235 | printf("bcm2835: Could not query MAC address\n"); |
| 236 | /* Ignore error; not critical */ |
Stephen Warren | 6fe7845 | 2014-11-18 21:40:21 -0700 | [diff] [blame] | 237 | return; |
Stephen Warren | 4f80a06 | 2014-09-26 20:51:39 -0600 | [diff] [blame] | 238 | } |
| 239 | |
| 240 | eth_setenv_enetaddr("usbethaddr", msg->get_mac_address.body.resp.mac); |
| 241 | |
Stephen Warren | 6fe7845 | 2014-11-18 21:40:21 -0700 | [diff] [blame] | 242 | return; |
| 243 | } |
| 244 | |
Guillaume GARDET | bff7856 | 2015-08-25 15:10:26 +0200 | [diff] [blame] | 245 | #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG |
| 246 | static void set_board_info(void) |
| 247 | { |
| 248 | char str_rev[11]; |
| 249 | sprintf(str_rev, "0x%X", rpi_board_rev); |
| 250 | setenv("board_rev", str_rev); |
| 251 | setenv("board_name", models[rpi_board_rev].name); |
| 252 | } |
| 253 | #endif /* CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG */ |
| 254 | |
Stephen Warren | 6fe7845 | 2014-11-18 21:40:21 -0700 | [diff] [blame] | 255 | int misc_init_r(void) |
| 256 | { |
| 257 | set_fdtfile(); |
| 258 | set_usbethaddr(); |
Guillaume GARDET | bff7856 | 2015-08-25 15:10:26 +0200 | [diff] [blame] | 259 | #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG |
| 260 | set_board_info(); |
| 261 | #endif |
Stephen Warren | 4f80a06 | 2014-09-26 20:51:39 -0600 | [diff] [blame] | 262 | return 0; |
| 263 | } |
| 264 | |
Stephen Warren | f66f2aa | 2014-01-13 19:50:11 -0700 | [diff] [blame] | 265 | static int power_on_module(u32 module) |
| 266 | { |
Alexander Stein | 927753a | 2015-07-24 09:22:12 +0200 | [diff] [blame] | 267 | ALLOC_CACHE_ALIGN_BUFFER(struct msg_set_power_state, msg_pwr, 1); |
Stephen Warren | f66f2aa | 2014-01-13 19:50:11 -0700 | [diff] [blame] | 268 | int ret; |
| 269 | |
| 270 | BCM2835_MBOX_INIT_HDR(msg_pwr); |
| 271 | BCM2835_MBOX_INIT_TAG(&msg_pwr->set_power_state, |
| 272 | SET_POWER_STATE); |
| 273 | msg_pwr->set_power_state.body.req.device_id = module; |
| 274 | msg_pwr->set_power_state.body.req.state = |
| 275 | BCM2835_MBOX_SET_POWER_STATE_REQ_ON | |
| 276 | BCM2835_MBOX_SET_POWER_STATE_REQ_WAIT; |
| 277 | |
| 278 | ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, |
| 279 | &msg_pwr->hdr); |
| 280 | if (ret) { |
| 281 | printf("bcm2835: Could not set module %u power state\n", |
| 282 | module); |
| 283 | return -1; |
| 284 | } |
| 285 | |
| 286 | return 0; |
| 287 | } |
| 288 | |
Stephen Warren | 6fe7845 | 2014-11-18 21:40:21 -0700 | [diff] [blame] | 289 | static void get_board_rev(void) |
| 290 | { |
Alexander Stein | 927753a | 2015-07-24 09:22:12 +0200 | [diff] [blame] | 291 | ALLOC_CACHE_ALIGN_BUFFER(struct msg_get_board_rev, msg, 1); |
Stephen Warren | 6fe7845 | 2014-11-18 21:40:21 -0700 | [diff] [blame] | 292 | int ret; |
| 293 | const char *name; |
| 294 | |
| 295 | BCM2835_MBOX_INIT_HDR(msg); |
| 296 | BCM2835_MBOX_INIT_TAG(&msg->get_board_rev, GET_BOARD_REV); |
| 297 | |
| 298 | ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg->hdr); |
| 299 | if (ret) { |
| 300 | printf("bcm2835: Could not query board revision\n"); |
| 301 | /* Ignore error; not critical */ |
| 302 | return; |
| 303 | } |
| 304 | |
Stephen Warren | 4641429 | 2015-02-16 12:16:15 -0700 | [diff] [blame] | 305 | /* |
| 306 | * For details of old-vs-new scheme, see: |
| 307 | * https://github.com/pimoroni/RPi.version/blob/master/RPi/version.py |
| 308 | * http://www.raspberrypi.org/forums/viewtopic.php?f=63&t=99293&p=690282 |
| 309 | * (a few posts down) |
Stephen Warren | 95b4f11 | 2015-03-23 23:00:25 -0600 | [diff] [blame] | 310 | * |
| 311 | * For the RPi 1, bit 24 is the "warranty bit", so we mask off just the |
| 312 | * lower byte to use as the board rev: |
| 313 | * http://www.raspberrypi.org/forums/viewtopic.php?f=63&t=98367&start=250 |
| 314 | * http://www.raspberrypi.org/forums/viewtopic.php?f=31&t=20594 |
Stephen Warren | 4641429 | 2015-02-16 12:16:15 -0700 | [diff] [blame] | 315 | */ |
Stephen Warren | 6fe7845 | 2014-11-18 21:40:21 -0700 | [diff] [blame] | 316 | rpi_board_rev = msg->get_board_rev.body.resp.rev; |
Stephen Warren | 4641429 | 2015-02-16 12:16:15 -0700 | [diff] [blame] | 317 | if (rpi_board_rev & 0x800000) |
| 318 | rpi_board_rev = (rpi_board_rev >> 4) & 0xff; |
Stephen Warren | 95b4f11 | 2015-03-23 23:00:25 -0600 | [diff] [blame] | 319 | else |
| 320 | rpi_board_rev &= 0xff; |
Stephen Warren | 47705ef | 2014-12-23 20:01:43 -0700 | [diff] [blame] | 321 | if (rpi_board_rev >= ARRAY_SIZE(models)) { |
| 322 | printf("RPI: Board rev %u outside known range\n", |
| 323 | rpi_board_rev); |
Stephen Warren | 6fe7845 | 2014-11-18 21:40:21 -0700 | [diff] [blame] | 324 | rpi_board_rev = 0; |
Stephen Warren | 47705ef | 2014-12-23 20:01:43 -0700 | [diff] [blame] | 325 | } |
Stephen Warren | 914627f | 2014-12-23 20:01:44 -0700 | [diff] [blame] | 326 | if (!models[rpi_board_rev].name) { |
| 327 | printf("RPI: Board rev %u unknown\n", rpi_board_rev); |
| 328 | rpi_board_rev = 0; |
| 329 | } |
Stephen Warren | 6fe7845 | 2014-11-18 21:40:21 -0700 | [diff] [blame] | 330 | |
| 331 | name = models[rpi_board_rev].name; |
Stephen Warren | 4641429 | 2015-02-16 12:16:15 -0700 | [diff] [blame] | 332 | printf("RPI %s\n", name); |
Stephen Warren | 6fe7845 | 2014-11-18 21:40:21 -0700 | [diff] [blame] | 333 | } |
| 334 | |
Stephen Warren | 0d04f34 | 2012-08-05 16:07:22 +0000 | [diff] [blame] | 335 | int board_init(void) |
| 336 | { |
Stephen Warren | 6fe7845 | 2014-11-18 21:40:21 -0700 | [diff] [blame] | 337 | get_board_rev(); |
| 338 | |
Stephen Warren | 0d04f34 | 2012-08-05 16:07:22 +0000 | [diff] [blame] | 339 | gd->bd->bi_boot_params = 0x100; |
| 340 | |
Stephen Warren | f66f2aa | 2014-01-13 19:50:11 -0700 | [diff] [blame] | 341 | return power_on_module(BCM2835_MBOX_POWER_DEVID_USB_HCD); |
Stephen Warren | 0d04f34 | 2012-08-05 16:07:22 +0000 | [diff] [blame] | 342 | } |
Stephen Warren | 131a1e6 | 2013-01-29 16:37:42 +0000 | [diff] [blame] | 343 | |
Jeroen Hofstee | 5dfd162 | 2014-07-13 22:01:51 +0200 | [diff] [blame] | 344 | int board_mmc_init(bd_t *bis) |
Stephen Warren | 131a1e6 | 2013-01-29 16:37:42 +0000 | [diff] [blame] | 345 | { |
Alexander Stein | 927753a | 2015-07-24 09:22:12 +0200 | [diff] [blame] | 346 | ALLOC_CACHE_ALIGN_BUFFER(struct msg_get_clock_rate, msg_clk, 1); |
Stephen Warren | 131a1e6 | 2013-01-29 16:37:42 +0000 | [diff] [blame] | 347 | int ret; |
| 348 | |
Stephen Warren | f66f2aa | 2014-01-13 19:50:11 -0700 | [diff] [blame] | 349 | power_on_module(BCM2835_MBOX_POWER_DEVID_SDHCI); |
| 350 | |
Stephen Warren | 131a1e6 | 2013-01-29 16:37:42 +0000 | [diff] [blame] | 351 | BCM2835_MBOX_INIT_HDR(msg_clk); |
| 352 | BCM2835_MBOX_INIT_TAG(&msg_clk->get_clock_rate, GET_CLOCK_RATE); |
| 353 | msg_clk->get_clock_rate.body.req.clock_id = BCM2835_MBOX_CLOCK_ID_EMMC; |
| 354 | |
| 355 | ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg_clk->hdr); |
| 356 | if (ret) { |
| 357 | printf("bcm2835: Could not query eMMC clock rate\n"); |
| 358 | return -1; |
| 359 | } |
| 360 | |
| 361 | return bcm2835_sdhci_init(BCM2835_SDHCI_BASE, |
| 362 | msg_clk->get_clock_rate.body.resp.rate_hz); |
| 363 | } |
Stephen Warren | ea697ae | 2013-05-27 18:31:18 +0000 | [diff] [blame] | 364 | |
Simon Glass | e895a4b | 2014-10-23 18:58:47 -0600 | [diff] [blame] | 365 | int ft_board_setup(void *blob, bd_t *bd) |
Stephen Warren | ea697ae | 2013-05-27 18:31:18 +0000 | [diff] [blame] | 366 | { |
| 367 | /* |
| 368 | * For now, we simply always add the simplefb DT node. Later, we |
| 369 | * should be more intelligent, and e.g. only do this if no enabled DT |
| 370 | * node exists for the "real" graphics driver. |
| 371 | */ |
| 372 | lcd_dt_simplefb_add_node(blob); |
Simon Glass | e895a4b | 2014-10-23 18:58:47 -0600 | [diff] [blame] | 373 | |
| 374 | return 0; |
Stephen Warren | ea697ae | 2013-05-27 18:31:18 +0000 | [diff] [blame] | 375 | } |