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