source: rtems/c/src/lib/libbsp/arm/raspberrypi/include/raspberrypi.h @ 1c62f7ee

5
Last change on this file since 1c62f7ee was 1c62f7ee, checked in by Deval Shah <deval.maker@…>, on 07/22/16 at 08:27:11

Added USB interrupt handler. And defined some macros regarding USB.

  • Property mode set to 100644
File size: 10.2 KB
Line 
1/**
2 * @file raspberrypi.h
3 *
4 * @ingroup raspberrypi_reg
5 *
6 * @brief Register definitions.
7 */
8
9/*
10 *  Copyright (c) 2014-2015 Andre Marques <andre.lousa.marques at gmail.com>
11 *  Copyright (c) 2013 Alan Cudmore.
12 *  Copyright (c) 2015 Yang Qiao
13 *
14 *  The license and distribution terms for this file may be
15 *  found in the file LICENSE in this distribution or at
16 *
17 *  http://www.rtems.org/license/LICENSE
18 *
19 */
20
21#ifndef LIBBSP_ARM_RASPBERRYPI_RASPBERRYPI_H
22#define LIBBSP_ARM_RASPBERRYPI_RASPBERRYPI_H
23
24#include <bspopts.h>
25#include <stdint.h>
26#include <bsp/utility.h>
27
28/**
29 * @defgroup raspberrypi_reg Register Definitions
30 *
31 * @ingroup arm_raspberrypi
32 *
33 * @brief Register Definitions
34 *
35 * @{
36 */
37
38/**
39 * @name Register Macros
40 *
41 * @{
42 */
43
44#define BCM2835_REG(x)           (*(volatile uint32_t *)(x))
45#define BCM2835_BIT(n)           (1 << (n))
46
47/** @} */
48
49/**
50 * @name Peripheral Base Register Address
51 *
52 * @{
53 */
54
55#if (BSP_IS_RPI2 == 1)
56   #define RPI_PERIPHERAL_BASE      0x3F000000
57#else
58   #define RPI_PERIPHERAL_BASE      0x20000000
59#endif
60
61#define RPI_PERIPHERAL_SIZE         0x01000000
62
63/**
64 * @name Internal ARM Timer Registers
65 *
66 * @{
67 */
68
69#define BCM2835_CLOCK_FREQ       250000000
70
71#define BCM2835_TIMER_BASE       (RPI_PERIPHERAL_BASE + 0xB400)
72
73#define BCM2835_TIMER_LOD        (BCM2835_TIMER_BASE + 0x00)
74#define BCM2835_TIMER_VAL        (BCM2835_TIMER_BASE + 0x04)
75#define BCM2835_TIMER_CTL        (BCM2835_TIMER_BASE + 0x08)
76#define BCM2835_TIMER_CLI        (BCM2835_TIMER_BASE + 0x0C)
77#define BCM2835_TIMER_RIS        (BCM2835_TIMER_BASE + 0x10)
78#define BCM2835_TIMER_MIS        (BCM2835_TIMER_BASE + 0x14)
79#define BCM2835_TIMER_RLD        (BCM2835_TIMER_BASE + 0x18)
80#define BCM2835_TIMER_DIV        (BCM2835_TIMER_BASE + 0x1C)
81#define BCM2835_TIMER_CNT        (BCM2835_TIMER_BASE + 0x20)
82
83#define BCM2835_TIMER_PRESCALE    0xF9
84
85/** @} */
86
87/**
88 * @name GPIO Registers
89 *
90 * @{
91 */
92
93#define BCM2835_GPIO_REGS_BASE   (RPI_PERIPHERAL_BASE + 0x200000)
94
95#define BCM2835_GPIO_GPFSEL1     (BCM2835_GPIO_REGS_BASE + 0x04)
96#define BCM2835_GPIO_GPSET0      (BCM2835_GPIO_REGS_BASE + 0x1C)
97#define BCM2835_GPIO_GPCLR0      (BCM2835_GPIO_REGS_BASE + 0x28)
98#define BCM2835_GPIO_GPLEV0      (BCM2835_GPIO_REGS_BASE + 0x34)
99#define BCM2835_GPIO_GPEDS0      (BCM2835_GPIO_REGS_BASE + 0x40)
100#define BCM2835_GPIO_GPREN0      (BCM2835_GPIO_REGS_BASE + 0x4C)
101#define BCM2835_GPIO_GPFEN0      (BCM2835_GPIO_REGS_BASE + 0x58)
102#define BCM2835_GPIO_GPHEN0      (BCM2835_GPIO_REGS_BASE + 0x64)
103#define BCM2835_GPIO_GPLEN0      (BCM2835_GPIO_REGS_BASE + 0x70)
104#define BCM2835_GPIO_GPAREN0     (BCM2835_GPIO_REGS_BASE + 0x7C)
105#define BCM2835_GPIO_GPAFEN0     (BCM2835_GPIO_REGS_BASE + 0x88)
106#define BCM2835_GPIO_GPPUD       (BCM2835_GPIO_REGS_BASE + 0x94)
107#define BCM2835_GPIO_GPPUDCLK0   (BCM2835_GPIO_REGS_BASE + 0x98)
108
109/** @} */
110
111/**
112 * @name AUX Registers
113 *
114 * @{
115 */
116
117#define BCM2835_AUX_BASE         (RPI_PERIPHERAL_BASE + 0x215000)
118
119#define AUX_ENABLES              (BCM2835_AUX_BASE + 0x04)
120#define AUX_MU_IO_REG            (BCM2835_AUX_BASE + 0x40)
121#define AUX_MU_IER_REG           (BCM2835_AUX_BASE + 0x44)
122#define AUX_MU_IIR_REG           (BCM2835_AUX_BASE + 0x48)
123#define AUX_MU_LCR_REG           (BCM2835_AUX_BASE + 0x4C)
124#define AUX_MU_MCR_REG           (BCM2835_AUX_BASE + 0x50)
125#define AUX_MU_LSR_REG           (BCM2835_AUX_BASE + 0x54)
126#define AUX_MU_MSR_REG           (BCM2835_AUX_BASE + 0x58)
127#define AUX_MU_SCRATCH           (BCM2835_AUX_BASE + 0x5C)
128#define AUX_MU_CNTL_REG          (BCM2835_AUX_BASE + 0x60)
129#define AUX_MU_STAT_REG          (BCM2835_AUX_BASE + 0x64)
130#define AUX_MU_BAUD_REG          (BCM2835_AUX_BASE + 0x68)
131
132/** @} */
133
134/**
135 * @name UART 0 (PL011) Registers
136 *
137 * @{
138 */
139
140#define BCM2835_UART0_BASE       (RPI_PERIPHERAL_BASE + 0x201000)
141
142#define BCM2835_UART0_DR         (BCM2835_UART0_BASE + 0x00)
143#define BCM2835_UART0_RSRECR     (BCM2835_UART0_BASE + 0x04)
144#define BCM2835_UART0_FR         (BCM2835_UART0_BASE + 0x18)
145#define BCM2835_UART0_ILPR       (BCM2835_UART0_BASE + 0x20)
146#define BCM2835_UART0_IBRD       (BCM2835_UART0_BASE + 0x24)
147#define BCM2835_UART0_FBRD       (BCM2835_UART0_BASE + 0x28)
148#define BCM2835_UART0_LCRH       (BCM2835_UART0_BASE + 0x2C)
149#define BCM2835_UART0_CR         (BCM2835_UART0_BASE + 0x30)
150#define BCM2835_UART0_IFLS       (BCM2835_UART0_BASE + 0x34)
151#define BCM2835_UART0_IMSC       (BCM2835_UART0_BASE + 0x38)
152#define BCM2835_UART0_RIS        (BCM2835_UART0_BASE + 0x3C)
153#define BCM2835_UART0_MIS        (BCM2835_UART0_BASE + 0x40)
154#define BCM2835_UART0_ICR        (BCM2835_UART0_BASE + 0x44)
155#define BCM2835_UART0_DMACR      (BCM2835_UART0_BASE + 0x48)
156#define BCM2835_UART0_ITCR       (BCM2835_UART0_BASE + 0x80)
157#define BCM2835_UART0_ITIP       (BCM2835_UART0_BASE + 0x84)
158#define BCM2835_UART0_ITOP       (BCM2835_UART0_BASE + 0x88)
159#define BCM2835_UART0_TDR        (BCM2835_UART0_BASE + 0x8C)
160
161#define BCM2835_UART0_MIS_RX    0x10
162#define BCM2835_UART0_MIS_TX    0x20
163#define BCM2835_UART0_IMSC_RX   0x10
164#define BCM2835_UART0_IMSC_TX   0x20
165#define BCM2835_UART0_FR_RXFE   0x10
166#define BCM2835_UART0_FR_TXFF   0x20
167#define BCM2835_UART0_ICR_RX    0x10
168#define BCM2835_UART0_ICR_TX    0x20
169
170/** @} */
171
172/**
173 * @name I2C (BSC) Registers
174 *
175 * @{
176 */
177
178#define BCM2835_I2C_BASE           (RPI_PERIPHERAL_BASE + 0x804000)
179
180#define BCM2835_I2C_C              (BCM2835_I2C_BASE + 0x00)
181#define BCM2835_I2C_S              (BCM2835_I2C_BASE + 0x04)
182#define BCM2835_I2C_DLEN           (BCM2835_I2C_BASE + 0x08)
183#define BCM2835_I2C_A              (BCM2835_I2C_BASE + 0x0C)
184#define BCM2835_I2C_FIFO           (BCM2835_I2C_BASE + 0x10)
185#define BCM2835_I2C_DIV            (BCM2835_I2C_BASE + 0x14)
186#define BCM2835_I2C_DEL            (BCM2835_I2C_BASE + 0x18)
187#define BCM2835_I2C_CLKT           (BCM2835_I2C_BASE + 0x1C)
188
189/** @} */
190
191/**
192 * @name SPI Registers
193 *
194 * @{
195 */
196
197#define BCM2835_SPI_BASE           (RPI_PERIPHERAL_BASE + 0x204000)
198
199#define BCM2835_SPI_CS             (BCM2835_SPI_BASE + 0x00)
200#define BCM2835_SPI_FIFO           (BCM2835_SPI_BASE + 0x04)
201#define BCM2835_SPI_CLK            (BCM2835_SPI_BASE + 0x08)
202#define BCM2835_SPI_DLEN           (BCM2835_SPI_BASE + 0x0C)
203#define BCM2835_SPI_LTOH           (BCM2835_SPI_BASE + 0x10)
204#define BCM2835_SPI_DC             (BCM2835_SPI_BASE + 0x14)
205
206/** @} */
207
208/**
209 * @name I2C/SPI slave BSC Registers
210 *
211 * @{
212 */
213
214#define BCM2835_I2C_SPI_BASE       (RPI_PERIPHERAL_BASE + 0x214000)
215
216#define BCM2835_I2C_SPI_DR         (BCM2835_I2C_SPI_BASE + 0x00)
217#define BCM2835_I2C_SPI_RSR        (BCM2835_I2C_SPI_BASE + 0x04)
218#define BCM2835_I2C_SPI_SLV        (BCM2835_I2C_SPI_BASE + 0x08)
219#define BCM2835_I2C_SPI_CR         (BCM2835_I2C_SPI_BASE + 0x0C)
220#define BCM2835_I2C_SPI_FR         (BCM2835_I2C_SPI_BASE + 0x10)
221#define BCM2835_I2C_SPI_IFLS       (BCM2835_I2C_SPI_BASE + 0x14)
222#define BCM2835_I2C_SPI_IMSC       (BCM2835_I2C_SPI_BASE + 0x18)
223#define BCM2835_I2C_SPI_RIS        (BCM2835_I2C_SPI_BASE + 0x1C)
224#define BCM2835_I2C_SPI_MIS        (BCM2835_I2C_SPI_BASE + 0x20)
225#define BCM2835_I2C_SPI_ICR        (BCM2835_I2C_SPI_BASE + 0x24)
226#define BCM2835_I2C_SPI_DMACR      (BCM2835_I2C_SPI_BASE + 0x28)
227#define BCM2835_I2C_SPI_TDR        (BCM2835_I2C_SPI_BASE + 0x2C)
228#define BCM2835_I2C_SPI_GPUSTAT    (BCM2835_I2C_SPI_BASE + 0x30)
229#define BCM2835_I2C_SPI_HCTRL      (BCM2835_I2C_SPI_BASE + 0x34)
230
231/** @} */
232
233/**
234 * @name IRQ Registers
235 *
236 * @{
237 */
238
239#define BCM2835_BASE_INTC         (RPI_PERIPHERAL_BASE + 0xB200)
240
241#define BCM2835_IRQ_BASIC         (BCM2835_BASE_INTC + 0x00)
242#define BCM2835_IRQ_PENDING1      (BCM2835_BASE_INTC + 0x04)
243#define BCM2835_IRQ_PENDING2      (BCM2835_BASE_INTC + 0x08)
244#define BCM2835_IRQ_FIQ_CTRL      (BCM2835_BASE_INTC + 0x0C)
245#define BCM2835_IRQ_ENABLE1       (BCM2835_BASE_INTC + 0x10)
246#define BCM2835_IRQ_ENABLE2       (BCM2835_BASE_INTC + 0x14)
247#define BCM2835_IRQ_ENABLE_BASIC  (BCM2835_BASE_INTC + 0x18)
248#define BCM2835_IRQ_DISABLE1      (BCM2835_BASE_INTC + 0x1C)
249#define BCM2835_IRQ_DISABLE2      (BCM2835_BASE_INTC + 0x20)
250#define BCM2835_IRQ_DISABLE_BASIC (BCM2835_BASE_INTC + 0x24)
251
252/** @} */
253
254/**
255 * @name GPU Timer Registers
256 *
257 * @{
258 */
259
260/**
261 * NOTE: The GPU uses Compare registers 0 and 2 for
262 *       it's own RTOS. 1 and 3 are available for use in
263 *       RTEMS.
264 */
265#define BCM2835_GPU_TIMER_BASE    (RPI_PERIPHERAL_BASE + 0x3000)
266
267#define BCM2835_GPU_TIMER_CS      (BCM2835_TIMER_BASE + 0x00)
268#define BCM2835_GPU_TIMER_CLO     (BCM2835_TIMER_BASE + 0x04)
269#define BCM2835_GPU_TIMER_CHI     (BCM2835_TIMER_BASE + 0x08)
270#define BCM2835_GPU_TIMER_C0      (BCM2835_TIMER_BASE + 0x0C)
271#define BCM2835_GPU_TIMER_C1      (BCM2835_TIMER_BASE + 0x10)
272#define BCM2835_GPU_TIMER_C2      (BCM2835_TIMER_BASE + 0x14)
273#define BCM2835_GPU_TIMER_C3      (BCM2835_TIMER_BASE + 0x18)
274
275/** @} */
276
277/**
278 * @name EMMC Registers
279 *
280 * @{
281 */
282
283/**
284 * NOTE: Since the SD controller follows the SDHCI standard,
285 *       the rtems-libbsd tree already provides the remaining registers.
286 */
287
288#define BCM2835_EMMC_BASE              (RPI_PERIPHERAL_BASE + 0x300000)
289
290/** @} */
291
292/**
293* @name Mailbox Registers
294*
295* @{
296*/
297
298#define BCM2835_MBOX_BASE   (RPI_PERIPHERAL_BASE+0xB880)
299
300#define BCM2835_MBOX_PEEK   (BCM2835_MBOX_BASE+0x10)
301#define BCM2835_MBOX_READ   (BCM2835_MBOX_BASE+0x00)
302#define BCM2835_MBOX_WRITE  (BCM2835_MBOX_BASE+0x20)
303#define BCM2835_MBOX_STATUS (BCM2835_MBOX_BASE+0x18)
304#define BCM2835_MBOX_SENDER (BCM2835_MBOX_BASE+0x14)
305#define BCM2835_MBOX_CONFIG (BCM2835_MBOX_BASE+0x1C)
306
307#define BCM2835_MBOX_FULL   0x80000000
308#define BCM2835_MBOX_EMPTY  0x40000000
309
310/** @} */
311
312/**
313* @name Mailbox Channels
314*
315* @{
316*/
317
318/* Power Manager channel */
319#define BCM2835_MBOX_CHANNEL_PM         0
320/* Framebuffer channel */
321#define BCM2835_MBOX_CHANNEL_FB         1
322 /* Virtual UART channel */
323#define BCM2835_MBOX_CHANNEL_VUART      2
324 /* VCHIQ channel */
325#define BCM2835_MBOX_CHANNEL_VCHIQ      3
326 /* LEDs channel */
327#define BCM2835_MBOX_CHANNEL_LED        4
328 /* Button channel */
329#define BCM2835_MBOX_CHANNEL_BUTTON     5
330 /* Touch screen channel */
331#define BCM2835_MBOX_CHANNEL_TOUCHS     6
332/* Property tags (ARM <-> VC) channel */
333#define BCM2835_MBOX_CHANNEL_PROP_AVC   8
334 /* Property tags (VC <-> ARM) channel */
335#define BCM2835_MBOX_CHANNEL_PROP_VCA   9
336
337/** @} */
338
339/**
340* @name USB Registers
341*
342* @{
343*/
344
345#define BCM2835_USB_BASE        (RPI_PERIPHERAL_BASE + 0x980000) /* DTC_OTG USB controller */
346
347/** @} */
348
349/** @} */
350
351#endif /* LIBBSP_ARM_RASPBERRYPI_RASPBERRYPI_H */
Note: See TracBrowser for help on using the repository browser.