1/*
2 * Copyright 2013, winocm. <winocm@icloud.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 * ARM RealView PB-A8 platform information
31 */
32
33#ifndef _PEXPERT_ARM_REALVIEW_H_
34#define _PEXPERT_ARM_REALVIEW_H_
35
36#define AMBA_UART_FR(base)      (*(volatile unsigned char *)((base) + 0x18))
37#define AMBA_UART_DR(base)      (*(volatile unsigned char *)((base) + 0x00))
38
39#define REALVIEW_UART0_BASE     0x10009000
40#define REALVIEW_PIC0_BASE      0x1E000000
41#define REALVIEW_TIMER0_BASE    0x10011000
42#define REALVIEW_SYSCTL_BASE    0x10000000
43#define REALVIEW_PL111_BASE     0x10020000
44
45#define REALVIEW_EB_PIC0_BASE   0x10050000
46
47#define HARDWARE_REGISTER(x)    *((unsigned int*)(x))
48
49#define LCDTIMING0_PPL(x)           ((((x) / 16 - 1) & 0x3f) << 2)
50#define LCDTIMING1_LPP(x)           (((x) & 0x3ff) - 1)
51#define LCDCONTROL_LCDPWR           (1 << 11)
52#define LCDCONTROL_LCDEN            (1)
53#define LCDCONTROL_LCDBPP(x)        (((x) & 7) << 1)
54#define LCDCONTROL_LCDTFT           (1 << 5)
55
56#define PL111_TIMINGS_0         0x0
57#define PL111_TIMINGS_1         0x4
58#define PL111_TIMINGS_2         0x8
59#define PL111_TIMINGS_3         0xC
60
61#define PL111_UPPER_FB          0x10
62#define PL111_LOWER_FB          0x14
63#define PL111_CONTROL           0x18
64
65#define PIC_ENABLE              0x1
66#define PIC_ALLOW_INTR          0xF0
67
68#define PICPRIOMASK             0x4
69
70#define PIC_INTPRIO             0x10101010
71#define PIC_CPUPRIO             0x01010101
72
73#define TIMER_LOAD              0x0
74#define TIMER_VALUE             0x4
75#define TIMER_CONTROL           0x8
76#define TIMER_INTCLR            0xC
77#define TIMER_RIS               0x10
78#define TIMER_MIS               0x14
79
80#define TIMER_SET_ENABLE            (1 << 7)
81
82#define TIMER_MODE_FREE_RUNNING     (1 << 5)
83#define TIMER_SIZE_32_BIT           (1 << 1)
84#define TIMER_ENABLE                0x1
85
86int RealView_getc(void);
87void RealView_uart_init(void);
88void RealView_interrupt_init(void);
89void RealView_timebase_init(void);
90void RealView_handle_interrupt(void* context);
91uint64_t RealView_get_timebase(void);
92uint64_t RealView_timer_value(void);
93void RealView_timer_enabled(int enable);
94void RealView_framebuffer_init(void);
95
96#endif /* !_PEXPERT_ARM_REALVIEW_H_ */
97
98