1/*
2 * Copyright 2015, Brian McKenzie <mckenzba@gmail.com>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without modification,
6 * are permitted provided that the following conditions are met:
7 *
8 *   Redistributions of source code must retain the above copyright notice, this
9 *   list of conditions and the following disclaimer.
10 *
11 *   Redistributions in binary form must reproduce the above copyright notice, this
12 *   list of conditions and the following disclaimer in the documentation and/or
13 *   other materials provided with the distribution.
14 *
15 *   If you are going to use this software in any form that does not involve
16 *   releasing the source to this project or improving it, let me know beforehand.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
22 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
25 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29/*
30 * Platform expert for BCM2836.
31 */
32
33#if defined(BOARD_CONFIG_RASPBERRYPI2)
34
35#include <vm/pmap.h>
36#include <arm/pmap.h>
37
38#include <mach/mach_types.h>
39
40#include <pexpert/pexpert.h>
41#include <pexpert/arm/protos.h>
42#include <pexpert/arm/boot.h>
43
44#include <machine/machine_routines.h>
45
46#include "pe_bcm2836.h"
47
48#define KPRINTF_PREFIX  "PE_BCM2836: "
49
50extern void rtclock_intr(arm_saved_state_t * regs);
51extern void rtc_configure(uint64_t hz);
52
53static boolean_t clock_initialized = FALSE;
54static boolean_t clock_had_irq = FALSE;
55static uint64_t clock_decrementer = 0;
56static uint64_t clock_absolute_time = 0;
57
58static void timer_configure(void)
59{
60}
61
62void bcm2836_putc(int c)
63{
64    return;
65}
66
67int bcm2836_getc(void)
68{
69    int c;
70    return c;
71}
72
73void bcm2836_uart_init(void)
74{
75    return;
76}
77
78void bcm2836_interrupt_init(void)
79{
80    return;
81}
82
83void bcm2836_timebase_init(void)
84{
85    return;
86}
87
88void bcm2836_handle_interrupt(void *context)
89{
90    return;
91}
92
93uint64_t bcm2836_get_timebase(void)
94{
95    return;
96}
97
98uint64_t bcm2836_timer_value(void)
99{
100    return;
101}
102
103void bcm2836_timer_enabled(int enable)
104{
105    return;
106}
107
108/*
109 * Stub for printing out to framebuffer.
110 */
111void vcputc(__unused int l, __unused int u, int c);
112
113static void _fb_putc(int c)
114{
115    if (c == '\n') {
116        _fb_putc('\r');
117    }
118    vcputc(0, 0, c);
119    bcm2836_putc(c);
120}
121
122void bcm2836_framebuffer_init(void)
123{
124    return;
125}
126
127
128/*
129 * Setup the BCM2836 SoC dispatch table
130 */
131void PE_init_SocSupport_bcm2836(void)
132{
133    gPESocDispatch.uart_getc = bcm2836_getc;
134    gPESocDispatch.uart_putc = bcm2836_putc;
135    gPESocDispatch.uart_init = bcm2836_uart_init;
136
137    gPESocDispatch.interrupt_init = bcm2836_interrupt_init;
138    gPESocDispatch.timebase_init = bcm2836_timebase_init;
139
140    gPESocDispatch.get_timebase = bcm2836_get_timebase;
141
142    gPESocDispatch.handle_interrupt = bcm2836_handle_interrupt;
143
144    gPESocDispatch.timer_value = bcm2836_timer_value;
145    gPESocDispatch.timer_enabled = bcm2836_timer_enabled;
146
147    gPESocDispatch.framebuffer_init = bcm2836_framebuffer_init;
148
149    bcm2836_uart_init();
150    bcm2836_framebuffer_init();
151
152}
153
154/*
155 * Initialize SoC support for BCM2836.
156 */
157void PE_init_SocSupport_stub(void)
158{
159    PE_early_puts("PE_init_SocSupport: Initializing for Broadcom BCM2836\n");
160    PE_init_SocSupport_bcm2836();
161}
162
163#endif /* !BOARD_CONFIG_RASPBERRYPI2 */
164