1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @ingroup arm_start |
---|
5 | * |
---|
6 | * @brief Raspberry pi startup code. |
---|
7 | */ |
---|
8 | |
---|
9 | /* |
---|
10 | * Copyright (c) 2013 by Alan Cudmore |
---|
11 | * |
---|
12 | * The license and distribution terms for this file may be |
---|
13 | * found in the file LICENSE in this distribution or at |
---|
14 | * |
---|
15 | * http://www.rtems.org/license/LICENSE |
---|
16 | */ |
---|
17 | |
---|
18 | #include <bsp.h> |
---|
19 | #include <bsp/bootcard.h> |
---|
20 | #include <bsp/irq-generic.h> |
---|
21 | #include <bsp/irq.h> |
---|
22 | #include <bsp/linker-symbols.h> |
---|
23 | #include <bsp/stackalloc.h> |
---|
24 | #include <bsp/raspberrypi.h> |
---|
25 | #include <bsp/vc.h> |
---|
26 | |
---|
27 | static const struct { |
---|
28 | uint32_t code; |
---|
29 | const char* label; |
---|
30 | } rpi_codes[] = |
---|
31 | { |
---|
32 | { 0x900021, "A+ 1.1 (512MB)" }, |
---|
33 | { 0x900032, "B+ 1.2 (512MB)" }, |
---|
34 | { 0x900092, "Zero 1.2 (512MB)" }, |
---|
35 | { 0x900093, "Zero 1.3 (512MB)" }, |
---|
36 | { 0x9000c1, "Zero W 1.1 (512MB)" }, |
---|
37 | { 0x9020e0, "3A+ 1.0 (512MB)" }, |
---|
38 | { 0x920092, "Zero 1.2 (512MB)" }, |
---|
39 | { 0x920093, "Zero 1.3 (512MB)" }, |
---|
40 | { 0x900061, "CM 1.1 (512MB)" }, |
---|
41 | { 0xa01040, "2B 1.0 (1GB)" }, |
---|
42 | { 0xa01041, "2B 1.1 (1GB)" }, |
---|
43 | { 0xa02082, "3B 1.2 (1GB)" }, |
---|
44 | { 0xa020a0, "CM3 1.0 (1GB)" }, |
---|
45 | { 0xa020d3, "3B+ 1.3 (1GB)" }, |
---|
46 | { 0xa21041, "2B 1.1 (1GB)" }, |
---|
47 | { 0xa22042, "2B 1,2 (with BCM2837) (1GB)" }, |
---|
48 | { 0xa22082, "3B 1.2 (1GB)" }, |
---|
49 | { 0xa220a0, "CM3 1.0 (1GB)" }, |
---|
50 | { 0xa32082, "3B 1.2 (1GB)" }, |
---|
51 | { 0xa52082, "3B 1.2 (1GB)" }, |
---|
52 | { 0xa22083, "3B 1.3 (1GB)" }, |
---|
53 | { 0xa02100, "CM3+ 1.0 (1GB)" }, |
---|
54 | { 0xa03111, "4B 1.1 (1GB)" }, |
---|
55 | { 0xb03111, "4B 1.1 (2GB)" }, |
---|
56 | { 0xc03111, "4B 1.1 (4GB)" }, |
---|
57 | }; |
---|
58 | |
---|
59 | static const char* rpi_types[] = { |
---|
60 | "A", |
---|
61 | "B", |
---|
62 | "A+", |
---|
63 | "B+", |
---|
64 | "2B", |
---|
65 | "Alpha (early prototype)", |
---|
66 | "CM1", |
---|
67 | "3B", |
---|
68 | "Zero", |
---|
69 | "CM3", |
---|
70 | "Zero W", |
---|
71 | "3B+", |
---|
72 | "3A+", |
---|
73 | "Internal use only", |
---|
74 | "CM3+", |
---|
75 | "4B", |
---|
76 | }; |
---|
77 | |
---|
78 | static const char* rpi_mem[] = |
---|
79 | { |
---|
80 | "256MB", |
---|
81 | "512MB", |
---|
82 | "1GB", |
---|
83 | "2GB", |
---|
84 | "4GB" |
---|
85 | }; |
---|
86 | |
---|
87 | #define NUMOF(_s) (sizeof(_s) / sizeof(_s[0])) |
---|
88 | |
---|
89 | void bsp_start(void) |
---|
90 | { |
---|
91 | bcm2835_get_board_spec_entries spec = { 0 }; |
---|
92 | |
---|
93 | printk("\nRTEMS RPi "); |
---|
94 | if (bcm2835_mailbox_get_board_revision( &spec ) >= 0) { |
---|
95 | size_t i; |
---|
96 | for (i = 0; i < NUMOF(rpi_codes); ++i) { |
---|
97 | if (rpi_codes[i].code == spec.spec) { |
---|
98 | printk("%s [%08x]", rpi_codes[i].label, spec.spec); |
---|
99 | break; |
---|
100 | } |
---|
101 | } |
---|
102 | if (i >= NUMOF(rpi_codes)) { |
---|
103 | uint32_t type = (spec.spec >> 4) & 0xff; |
---|
104 | uint32_t mem = (spec.spec >> (4 + 4 + 8 + 4)) & 0xf; |
---|
105 | printk(" unknown code [%08x] ", spec.spec); |
---|
106 | if (type < NUMOF(rpi_types)) |
---|
107 | printk(rpi_types[type]); |
---|
108 | else |
---|
109 | printk("type: %02x", type); |
---|
110 | if (mem < NUMOF(rpi_mem)) |
---|
111 | printk(" %s", rpi_mem[mem]); |
---|
112 | else |
---|
113 | printk(" mem: %x", mem); |
---|
114 | } |
---|
115 | printk("\n"); |
---|
116 | } |
---|
117 | else { |
---|
118 | printk(": ERROR reading mailbox\n"); |
---|
119 | } |
---|
120 | |
---|
121 | bsp_interrupt_initialize(); |
---|
122 | } |
---|