source: rtems/bsps/arm/raspberrypi/start/bspstart.c @ 362cf319

5
Last change on this file since 362cf319 was 362cf319, checked in by G S Niteesh <gsnb.gn@…>, on 01/04/20 at 19:50:46

bsp/raspberrypi: Updated the console API.

Replaces the legacy termios API with new termios API (#3034)
Replaces the custom PL011 serial driver with RTEMS arm-pl011.
Update #3034

  • Property mode set to 100644
File size: 2.9 KB
Line 
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#include <libfdt.h>
28
29static const struct {
30    uint32_t code;
31    const char* label;
32} rpi_codes[] =
33{
34    { 0x900021, "A+ 1.1 (512MB)" },
35    { 0x900032, "B+ 1.2 (512MB)" },
36    { 0x900092, "Zero 1.2 (512MB)" },
37    { 0x900093, "Zero 1.3 (512MB)" },
38    { 0x9000c1, "Zero W 1.1 (512MB)" },
39    { 0x9020e0, "3A+ 1.0 (512MB)" },
40    { 0x920092, "Zero 1.2 (512MB)" },
41    { 0x920093, "Zero 1.3 (512MB)" },
42    { 0x900061, "CM 1.1 (512MB)" },
43    { 0xa01040, "2B 1.0 (1GB)" },
44    { 0xa01041, "2B 1.1 (1GB)" },
45    { 0xa02082, "3B 1.2 (1GB)" },
46    { 0xa020a0, "CM3 1.0 (1GB)" },
47    { 0xa020d3, "3B+ 1.3 (1GB)" },
48    { 0xa21041, "2B 1.1 (1GB)" },
49    { 0xa22042, "2B 1,2 (with BCM2837) (1GB)" },
50    { 0xa22082, "3B 1.2 (1GB)" },
51    { 0xa220a0, "CM3 1.0 (1GB)" },
52    { 0xa32082, "3B 1.2 (1GB)" },
53    { 0xa52082, "3B 1.2 (1GB)" },
54    { 0xa22083, "3B 1.3 (1GB)" },
55    { 0xa02100, "CM3+ 1.0 (1GB)" },
56    { 0xa03111, "4B 1.1 (1GB)" },
57    { 0xb03111, "4B 1.1 (2GB)" },
58    { 0xc03111, "4B 1.1 (4GB)" },
59};
60
61static const char* rpi_types[] = {
62    "A",
63    "B",
64    "A+",
65    "B+",
66    "2B",
67    "Alpha (early prototype)",
68    "CM1",
69    "3B",
70    "Zero",
71    "CM3",
72    "Zero W",
73    "3B+",
74    "3A+",
75    "Internal use only",
76    "CM3+",
77    "4B",
78};
79
80static const char* rpi_mem[] =
81{
82    "256MB",
83    "512MB",
84    "1GB",
85    "2GB",
86    "4GB"
87};
88
89#define NUMOF(_s) (sizeof(_s) / sizeof(_s[0]))
90
91void *raspberrypi_get_reg_of_node(const void *fdt, int node)
92{
93  int len;
94  const uint32_t *val;
95
96  val = fdt_getprop(fdt, node, "reg", &len);
97  if (val == NULL || len < 4) {
98    return NULL;
99  }
100
101  return (BUS_TO_PHY((void *) fdt32_to_cpu(val[0])));
102}
103
104void bsp_start(void)
105{
106    bcm2835_get_board_spec_entries spec = { 0 };
107
108    printk("\nRTEMS RPi ");
109    if (bcm2835_mailbox_get_board_revision( &spec ) >= 0) {
110        size_t i;
111        for (i = 0; i < NUMOF(rpi_codes); ++i) {
112            if (rpi_codes[i].code == spec.spec) {
113                printk("%s [%08x]", rpi_codes[i].label, spec.spec);
114                break;
115            }
116        }
117        if (i >= NUMOF(rpi_codes)) {
118            uint32_t type = (spec.spec >> 4) & 0xff;
119            uint32_t mem = (spec.spec >> (4 + 4 + 8 + 4)) & 0xf;
120            printk(" unknown code [%08x] ", spec.spec);
121            if (type < NUMOF(rpi_types))
122                printk(rpi_types[type]);
123            else
124                printk("type: %02x", type);
125            if (mem < NUMOF(rpi_mem))
126                printk(" %s", rpi_mem[mem]);
127            else
128                printk(" mem: %x", mem);
129        }
130        printk("\n");
131    }
132    else {
133        printk(": ERROR reading mailbox\n");
134    }
135
136    bsp_interrupt_initialize();
137}
Note: See TracBrowser for help on using the repository browser.