summaryrefslogtreecommitdiffstats
path: root/bsps/arm/raspberrypi/start/bspstart.c
blob: 6ff286f8404143be95cd13247f56d3674788e38c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/**
 * @file
 *
 * @ingroup arm_start
 *
 * @brief Raspberry pi startup code.
 */

/*
 * Copyright (c) 2013 by Alan Cudmore
 *
 *  The license and distribution terms for this file may be
 *  found in the file LICENSE in this distribution or at
 *
 *  http://www.rtems.org/license/LICENSE
 */

#include <bsp.h>
#include <bsp/bootcard.h>
#include <bsp/irq-generic.h>
#include <bsp/irq.h>
#include <bsp/linker-symbols.h>
#include <bsp/stackalloc.h>
#include <bsp/raspberrypi.h>
#include <bsp/vc.h>

static const struct {
    uint32_t code;
    const char* label;
} rpi_codes[] =
{
    { 0x900021, "A+ 1.1 (512MB)" },
    { 0x900032, "B+ 1.2 (512MB)" },
    { 0x900092, "Zero 1.2 (512MB)" },
    { 0x900093, "Zero 1.3 (512MB)" },
    { 0x9000c1, "Zero W 1.1 (512MB)" },
    { 0x9020e0, "3A+ 1.0 (512MB)" },
    { 0x920092, "Zero 1.2 (512MB)" },
    { 0x920093, "Zero 1.3 (512MB)" },
    { 0x900061, "CM 1.1 (512MB)" },
    { 0xa01040, "2B 1.0 (1GB)" },
    { 0xa01041, "2B 1.1 (1GB)" },
    { 0xa02082, "3B 1.2 (1GB)" },
    { 0xa020a0, "CM3 1.0 (1GB)" },
    { 0xa020d3, "3B+ 1.3 (1GB)" },
    { 0xa21041, "2B 1.1 (1GB)" },
    { 0xa22042, "2B 1,2 (with BCM2837) (1GB)" },
    { 0xa22082, "3B 1.2 (1GB)" },
    { 0xa220a0, "CM3 1.0 (1GB)" },
    { 0xa32082, "3B 1.2 (1GB)" },
    { 0xa52082, "3B 1.2 (1GB)" },
    { 0xa22083, "3B 1.3 (1GB)" },
    { 0xa02100, "CM3+ 1.0 (1GB)" },
    { 0xa03111, "4B 1.1 (1GB)" },
    { 0xb03111, "4B 1.1 (2GB)" },
    { 0xc03111, "4B 1.1 (4GB)" },
};

static const char* rpi_types[] = {
    "A",
    "B",
    "A+",
    "B+",
    "2B",
    "Alpha (early prototype)",
    "CM1",
    "3B",
    "Zero",
    "CM3",
    "Zero W",
    "3B+",
    "3A+",
    "Internal use only",
    "CM3+",
    "4B",
};

static const char* rpi_mem[] =
{
    "256MB",
    "512MB",
    "1GB",
    "2GB",
    "4GB"
};

#define NUMOF(_s) (sizeof(_s) / sizeof(_s[0]))

void bsp_start(void)
{
    bcm2835_get_board_spec_entries spec = { 0 };

    printk("\nRTEMS RPi ");
    if (bcm2835_mailbox_get_board_revision( &spec ) >= 0) {
	size_t i;
	for (i = 0; i < NUMOF(rpi_codes); ++i) {
	    if (rpi_codes[i].code == spec.spec) {
		printk("%s [%08x]", rpi_codes[i].label, spec.spec);
		break;
	    }
	}
	if (i >= NUMOF(rpi_codes)) {
	    uint32_t type = (spec.spec >> 4) & 0xff;
	    uint32_t mem = (spec.spec >> (4 + 4 + 8 + 4)) & 0xf;
	    printk(" unknown code [%08x] ", spec.spec);
	    if (type < NUMOF(rpi_types))
		printk(rpi_types[type]);
	    else
		printk("type: %02x", type);
	    if (mem < NUMOF(rpi_mem))
		printk(" %s", rpi_mem[mem]);
	    else
		printk(" mem: %x", mem);
	}
	printk("\n");
    }
    else {
	printk(": ERROR reading mailbox\n");
    }

    bsp_interrupt_initialize();
}