RTEMS
7.0-rc1
Loading...
Searching...
No Matches
bsps
arm
raspberrypi
include
bsp
raspberrypi.h
Go to the documentation of this file.
1
/* SPDX-License-Identifier: GPL-2.0+-with-RTEMS-exception */
2
11
/*
12
* Copyright (c) 2014-2015 Andre Marques <andre.lousa.marques at gmail.com>
13
* Copyright (c) 2013 Alan Cudmore.
14
* Copyright (c) 2015 Yang Qiao
15
*
16
* The license and distribution terms for this file may be
17
* found in the file LICENSE in this distribution or at
18
*
19
* http://www.rtems.org/license/LICENSE
20
*
21
*/
22
23
#ifndef LIBBSP_ARM_RASPBERRYPI_RASPBERRYPI_H
24
#define LIBBSP_ARM_RASPBERRYPI_RASPBERRYPI_H
25
26
#include <bspopts.h>
27
#include <stdint.h>
28
#include <
bsp/utility.h
>
29
46
#define BCM2835_REG(x) (*(volatile uint32_t *)(x))
47
#define BCM2835_BIT(n) (1 << (n))
48
57
#if (BSP_IS_RPI2 == 1)
58
#define RPI_PERIPHERAL_BASE 0x3F000000
59
#define BASE_OFFSET 0X3F000000
60
#else
61
#define RPI_PERIPHERAL_BASE 0x20000000
62
#define BASE_OFFSET 0X5E000000
63
#endif
64
65
#define RPI_PERIPHERAL_SIZE 0x01000000
66
73
#define BUS_TO_PHY(x) ((x) - BASE_OFFSET)
74
83
#define BCM2835_CLOCK_FREQ 250000000
84
85
#define BCM2835_TIMER_BASE (RPI_PERIPHERAL_BASE + 0xB400)
86
87
#define BCM2835_TIMER_LOD (BCM2835_TIMER_BASE + 0x00)
88
#define BCM2835_TIMER_VAL (BCM2835_TIMER_BASE + 0x04)
89
#define BCM2835_TIMER_CTL (BCM2835_TIMER_BASE + 0x08)
90
#define BCM2835_TIMER_CLI (BCM2835_TIMER_BASE + 0x0C)
91
#define BCM2835_TIMER_RIS (BCM2835_TIMER_BASE + 0x10)
92
#define BCM2835_TIMER_MIS (BCM2835_TIMER_BASE + 0x14)
93
#define BCM2835_TIMER_RLD (BCM2835_TIMER_BASE + 0x18)
94
#define BCM2835_TIMER_DIV (BCM2835_TIMER_BASE + 0x1C)
95
#define BCM2835_TIMER_CNT (BCM2835_TIMER_BASE + 0x20)
96
97
#define BCM2835_TIMER_PRESCALE 0xF9
98
107
#define BCM2835_PM_PASSWD_MAGIC 0x5a000000
108
109
#define BCM2835_PM_BASE (RPI_PERIPHERAL_BASE + 0x100000)
110
111
#define BCM2835_PM_GNRIC (BCM2835_PM_BASE + 0x00)
112
#define BCM2835_PM_GNRIC_POWUP 0x00000001
113
#define BCM2835_PM_GNRIC_POWOK 0x00000002
114
#define BCM2835_PM_GNRIC_ISPOW 0x00000004
115
#define BCM2835_PM_GNRIC_MEMREP 0x00000008
116
#define BCM2835_PM_GNRIC_MRDONE 0x00000010
117
#define BCM2835_PM_GNRIC_ISFUNC 0x00000020
118
#define BCM2835_PM_GNRIC_RSTN 0x00000fc0
119
#define BCM2835_PM_GNRIC_ENAB 0x00001000
120
#define BCM2835_PM_GNRIC_CFG 0x007f0000
121
122
#define BCM2835_PM_AUDIO (BCM2835_PM_BASE + 0x04)
123
#define BCM2835_PM_AUDIO_APSM 0x000fffff
124
#define BCM2835_PM_AUDIO_CTRLEN 0x00100000
125
#define BCM2835_PM_AUDIO_RSTN 0x00200000
126
127
#define BCM2835_PM_STATUS (BCM2835_PM_BASE + 0x18)
128
129
#define BCM2835_PM_RSTC (BCM2835_PM_BASE + 0x1c)
130
#define BCM2835_PM_RSTC_DRCFG 0x00000003
131
#define BCM2835_PM_RSTC_WRCFG 0x00000030
132
#define BCM2835_PM_RSTC_WRCFG_FULL 0x00000020
133
#define BCM2835_PM_RSTC_SRCFG 0x00000300
134
#define BCM2835_PM_RSTC_QRCFG 0x00003000
135
#define BCM2835_PM_RSTC_FRCFG 0x00030000
136
#define BCM2835_PM_RSTC_HRCFG 0x00300000
137
138
#define BCM2835_PM_RSTS (BCM2835_PM_BASE + 0x20)
139
#define BCM2835_PM_RSTS_HADDRQ 0x00000001
140
#define BCM2835_PM_RSTS_HADDRF 0x00000002
141
#define BCM2835_PM_RSTS_HADDRH 0x00000004
142
#define BCM2835_PM_RSTS_HADWRQ 0x00000010
143
#define BCM2835_PM_RSTS_HADWRF 0x00000020
144
#define BCM2835_PM_RSTS_HADWRH 0x00000040
145
#define BCM2835_PM_RSTS_HADSRQ 0x00000100
146
#define BCM2835_PM_RSTS_HADSRF 0x00000200
147
#define BCM2835_PM_RSTS_HADSRH 0x00000400
148
#define BCM2835_PM_RSTS_HADPOR 0x00001000
149
150
#define BCM2835_PM_WDOG (BCM2835_PM_BASE + 0x24)
151
160
#define BCM2835_GPIO_REGS_BASE (RPI_PERIPHERAL_BASE + 0x200000)
161
162
#define BCM2835_GPIO_GPFSEL1 (BCM2835_GPIO_REGS_BASE + 0x04)
163
#define BCM2835_GPIO_GPSET0 (BCM2835_GPIO_REGS_BASE + 0x1C)
164
#define BCM2835_GPIO_GPCLR0 (BCM2835_GPIO_REGS_BASE + 0x28)
165
#define BCM2835_GPIO_GPLEV0 (BCM2835_GPIO_REGS_BASE + 0x34)
166
#define BCM2835_GPIO_GPEDS0 (BCM2835_GPIO_REGS_BASE + 0x40)
167
#define BCM2835_GPIO_GPREN0 (BCM2835_GPIO_REGS_BASE + 0x4C)
168
#define BCM2835_GPIO_GPFEN0 (BCM2835_GPIO_REGS_BASE + 0x58)
169
#define BCM2835_GPIO_GPHEN0 (BCM2835_GPIO_REGS_BASE + 0x64)
170
#define BCM2835_GPIO_GPLEN0 (BCM2835_GPIO_REGS_BASE + 0x70)
171
#define BCM2835_GPIO_GPAREN0 (BCM2835_GPIO_REGS_BASE + 0x7C)
172
#define BCM2835_GPIO_GPAFEN0 (BCM2835_GPIO_REGS_BASE + 0x88)
173
#define BCM2835_GPIO_GPPUD (BCM2835_GPIO_REGS_BASE + 0x94)
174
#define BCM2835_GPIO_GPPUDCLK0 (BCM2835_GPIO_REGS_BASE + 0x98)
175
184
#define BCM2835_AUX_BASE (RPI_PERIPHERAL_BASE + 0x215000)
185
186
#define AUX_ENABLES (BCM2835_AUX_BASE + 0x04)
187
#define AUX_MU_IO_REG (BCM2835_AUX_BASE + 0x40)
188
#define AUX_MU_IER_REG (BCM2835_AUX_BASE + 0x44)
189
#define AUX_MU_IIR_REG (BCM2835_AUX_BASE + 0x48)
190
#define AUX_MU_LCR_REG (BCM2835_AUX_BASE + 0x4C)
191
#define AUX_MU_MCR_REG (BCM2835_AUX_BASE + 0x50)
192
#define AUX_MU_LSR_REG (BCM2835_AUX_BASE + 0x54)
193
#define AUX_MU_MSR_REG (BCM2835_AUX_BASE + 0x58)
194
#define AUX_MU_SCRATCH (BCM2835_AUX_BASE + 0x5C)
195
#define AUX_MU_CNTL_REG (BCM2835_AUX_BASE + 0x60)
196
#define AUX_MU_STAT_REG (BCM2835_AUX_BASE + 0x64)
197
#define AUX_MU_BAUD_REG (BCM2835_AUX_BASE + 0x68)
198
209
#define BCM2835_I2C_BASE (RPI_PERIPHERAL_BASE + 0x804000)
210
211
#define BCM2835_I2C_C (BCM2835_I2C_BASE + 0x00)
212
#define BCM2835_I2C_S (BCM2835_I2C_BASE + 0x04)
213
#define BCM2835_I2C_DLEN (BCM2835_I2C_BASE + 0x08)
214
#define BCM2835_I2C_A (BCM2835_I2C_BASE + 0x0C)
215
#define BCM2835_I2C_FIFO (BCM2835_I2C_BASE + 0x10)
216
#define BCM2835_I2C_DIV (BCM2835_I2C_BASE + 0x14)
217
#define BCM2835_I2C_DEL (BCM2835_I2C_BASE + 0x18)
218
#define BCM2835_I2C_CLKT (BCM2835_I2C_BASE + 0x1C)
219
228
#define BCM2835_SPI_BASE (RPI_PERIPHERAL_BASE + 0x204000)
229
230
#define BCM2835_SPI_CS (BCM2835_SPI_BASE + 0x00)
231
#define BCM2835_SPI_FIFO (BCM2835_SPI_BASE + 0x04)
232
#define BCM2835_SPI_CLK (BCM2835_SPI_BASE + 0x08)
233
#define BCM2835_SPI_DLEN (BCM2835_SPI_BASE + 0x0C)
234
#define BCM2835_SPI_LTOH (BCM2835_SPI_BASE + 0x10)
235
#define BCM2835_SPI_DC (BCM2835_SPI_BASE + 0x14)
236
245
#define BCM2835_I2C_SPI_BASE (RPI_PERIPHERAL_BASE + 0x214000)
246
247
#define BCM2835_I2C_SPI_DR (BCM2835_I2C_SPI_BASE + 0x00)
248
#define BCM2835_I2C_SPI_RSR (BCM2835_I2C_SPI_BASE + 0x04)
249
#define BCM2835_I2C_SPI_SLV (BCM2835_I2C_SPI_BASE + 0x08)
250
#define BCM2835_I2C_SPI_CR (BCM2835_I2C_SPI_BASE + 0x0C)
251
#define BCM2835_I2C_SPI_FR (BCM2835_I2C_SPI_BASE + 0x10)
252
#define BCM2835_I2C_SPI_IFLS (BCM2835_I2C_SPI_BASE + 0x14)
253
#define BCM2835_I2C_SPI_IMSC (BCM2835_I2C_SPI_BASE + 0x18)
254
#define BCM2835_I2C_SPI_RIS (BCM2835_I2C_SPI_BASE + 0x1C)
255
#define BCM2835_I2C_SPI_MIS (BCM2835_I2C_SPI_BASE + 0x20)
256
#define BCM2835_I2C_SPI_ICR (BCM2835_I2C_SPI_BASE + 0x24)
257
#define BCM2835_I2C_SPI_DMACR (BCM2835_I2C_SPI_BASE + 0x28)
258
#define BCM2835_I2C_SPI_TDR (BCM2835_I2C_SPI_BASE + 0x2C)
259
#define BCM2835_I2C_SPI_GPUSTAT (BCM2835_I2C_SPI_BASE + 0x30)
260
#define BCM2835_I2C_SPI_HCTRL (BCM2835_I2C_SPI_BASE + 0x34)
261
270
#define BCM2835_BASE_INTC (RPI_PERIPHERAL_BASE + 0xB200)
271
272
#define BCM2835_IRQ_BASIC (BCM2835_BASE_INTC + 0x00)
273
#define BCM2835_IRQ_PENDING1 (BCM2835_BASE_INTC + 0x04)
274
#define BCM2835_IRQ_PENDING2 (BCM2835_BASE_INTC + 0x08)
275
#define BCM2835_IRQ_FIQ_CTRL (BCM2835_BASE_INTC + 0x0C)
276
#define BCM2835_IRQ_ENABLE1 (BCM2835_BASE_INTC + 0x10)
277
#define BCM2835_IRQ_ENABLE2 (BCM2835_BASE_INTC + 0x14)
278
#define BCM2835_IRQ_ENABLE_BASIC (BCM2835_BASE_INTC + 0x18)
279
#define BCM2835_IRQ_DISABLE1 (BCM2835_BASE_INTC + 0x1C)
280
#define BCM2835_IRQ_DISABLE2 (BCM2835_BASE_INTC + 0x20)
281
#define BCM2835_IRQ_DISABLE_BASIC (BCM2835_BASE_INTC + 0x24)
282
296
#define BCM2835_GPU_TIMER_BASE (RPI_PERIPHERAL_BASE + 0x3000)
297
298
#define BCM2835_GPU_TIMER_CS (BCM2835_GPU_TIMER_BASE + 0x00)
299
#define BCM2835_GPU_TIMER_CS_M0 0x00000001
300
#define BCM2835_GPU_TIMER_CS_M1 0x00000002
301
#define BCM2835_GPU_TIMER_CS_M2 0x00000004
302
#define BCM2835_GPU_TIMER_CS_M3 0x00000008
303
#define BCM2835_GPU_TIMER_CLO (BCM2835_GPU_TIMER_BASE + 0x04)
304
#define BCM2835_GPU_TIMER_CHI (BCM2835_GPU_TIMER_BASE + 0x08)
305
#define BCM2835_GPU_TIMER_C0 (BCM2835_GPU_TIMER_BASE + 0x0C)
306
#define BCM2835_GPU_TIMER_C1 (BCM2835_GPU_TIMER_BASE + 0x10)
307
#define BCM2835_GPU_TIMER_C2 (BCM2835_GPU_TIMER_BASE + 0x14)
308
#define BCM2835_GPU_TIMER_C3 (BCM2835_GPU_TIMER_BASE + 0x18)
309
323
#define BCM2835_EMMC_BASE (RPI_PERIPHERAL_BASE + 0x300000)
324
333
#define BCM2835_MBOX_BASE (RPI_PERIPHERAL_BASE+0xB880)
334
335
#define BCM2835_MBOX_PEEK (BCM2835_MBOX_BASE+0x10)
336
#define BCM2835_MBOX_READ (BCM2835_MBOX_BASE+0x00)
337
#define BCM2835_MBOX_WRITE (BCM2835_MBOX_BASE+0x20)
338
#define BCM2835_MBOX_STATUS (BCM2835_MBOX_BASE+0x18)
339
#define BCM2835_MBOX_SENDER (BCM2835_MBOX_BASE+0x14)
340
#define BCM2835_MBOX_CONFIG (BCM2835_MBOX_BASE+0x1C)
341
342
#define BCM2835_MBOX_FULL 0x80000000
343
#define BCM2835_MBOX_EMPTY 0x40000000
344
353
/* Power Manager channel */
354
#define BCM2835_MBOX_CHANNEL_PM 0
355
/* Framebuffer channel */
356
#define BCM2835_MBOX_CHANNEL_FB 1
357
/* Virtual UART channel */
358
#define BCM2835_MBOX_CHANNEL_VUART 2
359
/* VCHIQ channel */
360
#define BCM2835_MBOX_CHANNEL_VCHIQ 3
361
/* LEDs channel */
362
#define BCM2835_MBOX_CHANNEL_LED 4
363
/* Button channel */
364
#define BCM2835_MBOX_CHANNEL_BUTTON 5
365
/* Touch screen channel */
366
#define BCM2835_MBOX_CHANNEL_TOUCHS 6
367
/* Property tags (ARM <-> VC) channel */
368
#define BCM2835_MBOX_CHANNEL_PROP_AVC 8
369
/* Property tags (VC <-> ARM) channel */
370
#define BCM2835_MBOX_CHANNEL_PROP_VCA 9
371
380
#define BCM2835_USB_BASE (RPI_PERIPHERAL_BASE + 0x980000)
/* DTC_OTG USB controller */
381
390
#define BCM2836_CORE_LOCAL_PERIPH_BASE 0x40000000
391
#define BCM2836_CORE_LOCAL_PERIPH_SIZE 0x00040000
392
401
#define BCM2836_MAILBOX_0_WRITE_SET_BASE 0x40000080
402
#define BCM2836_MAILBOX_1_WRITE_SET_BASE 0x40000084
403
#define BCM2836_MAILBOX_2_WRITE_SET_BASE 0x40000088
404
#define BCM2836_MAILBOX_3_WRITE_SET_BASE 0x4000008C
405
#define BCM2836_MAILBOX_0_READ_CLEAR_BASE 0x400000C0
406
#define BCM2836_MAILBOX_1_READ_CLEAR_BASE 0x400000C4
407
#define BCM2836_MAILBOX_2_READ_CLEAR_BASE 0x400000C8
408
#define BCM2836_MAILBOX_3_READ_CLEAR_BASE 0x400000CC
409
418
#define BCM2836_CORE_TIMER_CTRL 0x40000000
419
420
#define BCM2836_CORE_TIMER_CTRL_APB_CLK 0x00000100
421
#define BCM2836_CORE_TIMER_CTRL_INC_2 0x00000200
422
423
#define BCM2836_CORE_TIMER_PRESCALER 0x40000008
424
425
#define BCM2836_CORE_TIMER_LS32 0x4000001C
426
#define BCM2836_CORE_TIMER_MS32 0x40000020
427
436
#define BCM2836_LOCAL_TIMER_CTRL 0x40000034
437
438
#define BCM2836_LOCAL_TIMER_CTRL_IRQ_FLAG 0x80000000
439
#define BCM2836_LOCAL_TIMER_CTRL_IRQ_EN 0x20000000
440
#define BCM2836_LOCAL_TIMER_CTRL_TIMER_EN 0x10000000
441
#define BCM2836_LOCAL_TIMER_RELOAD 0x0FFFFFFF
442
443
#define BCM2836_LOCAL_TIMER_IRQ_RELOAD 0x40000038
444
445
#define BCM2836_LOCAL_TIMER_IRQ_CLEAR 0x80000000
446
#define BCM2836_LOCAL_TIMER_RELOAD_NOW 0x40000000
447
448
#define BCM2836_LOCAL_TIMER_IRQ_ROUTING 0x40000024
449
#define BCM2836_LOCAL_TIMER_ROU_CORE0_IRQ 0x00
450
#define BCM2836_LOCAL_TIMER_ROU_CORE1_IRQ 0x01
451
#define BCM2836_LOCAL_TIMER_ROU_CORE2_IRQ 0x02
452
#define BCM2836_LOCAL_TIMER_ROU_CORE3_IRQ 0x03
453
#define BCM2836_LOCAL_TIMER_ROU_CORE0_FIQ 0x04
454
#define BCM2836_LOCAL_TIMER_ROU_CORE1_FIQ 0x05
455
#define BCM2836_LOCAL_TIMER_ROU_CORE2_FIQ 0x06
456
#define BCM2836_LOCAL_TIMER_ROU_CORE3_FIQ 0x07
457
466
#define BCM2836_GPU_IRQ_ROUTING 0x4000000C
467
468
#define BCM2836_GPU_IRQ_ROU_GPU_IRQ_CORE0 0x00000000
469
#define BCM2836_GPU_IRQ_ROU_GPU_IRQ_CORE1 0x00000001
470
#define BCM2836_GPU_IRQ_ROU_GPU_IRQ_CORE2 0x00000002
471
#define BCM2836_GPU_IRQ_ROU_GPU_IRQ_CORE4 0x00000003
472
473
#define BCM2836_GPU_IRQ_ROU_GPU_FIQ_CORE0 0x00000000
474
#define BCM2836_GPU_IRQ_ROU_GPU_FIQ_CORE1 0x00000004
475
#define BCM2836_GPU_IRQ_ROU_GPU_FIQ_CORE2 0x00000008
476
#define BCM2836_GPU_IRQ_ROU_GPU_FIQ_CORE4 0x0000000C
477
478
#define BCM2836_GPU_IRQ_ROU_GPU_FIQ_CORE4 0x0000000C
479
480
489
/* Timers interrupt control registers */
490
#define BCM2836_CORE0_TIMER_IRQ_CTRL_BASE 0x40000040
491
#define BCM2836_CORE1_TIMER_IRQ_CTRL_BASE 0x40000044
492
#define BCM2836_CORE2_TIMER_IRQ_CTRL_BASE 0x40000048
493
#define BCM2836_CORE3_TIMER_IRQ_CTRL_BASE 0x4000004C
494
495
#define BCM2836_CORE_TIMER_IRQ_CTRL(cpuidx) \
496
(BCM2836_CORE0_TIMER_IRQ_CTRL_BASE + 0x4 * (cpuidx))
497
498
/*
499
* Where to route timer interrupt to, IRQ/FIQ
500
* Setting both the IRQ and FIQ bit gives an FIQ
501
*/
502
#define BCM2836_CORE_TIMER_IRQ_CTRL_TIMER0_IRQ 0x01
503
#define BCM2836_CORE_TIMER_IRQ_CTRL_TIMER1_IRQ 0x02
504
#define BCM2836_CORE_TIMER_IRQ_CTRL_TIMER2_IRQ 0x04
505
#define BCM2836_CORE_TIMER_IRQ_CTRL_TIMER3_IRQ 0x08
506
#define BCM2836_CORE_TIMER_IRQ_CTRL_TIMER0_FIQ 0x10
507
#define BCM2836_CORE_TIMER_IRQ_CTRL_TIMER1_FIQ 0x20
508
#define BCM2836_CORE_TIMER_IRQ_CTRL_TIMER2_FIQ 0x40
509
#define BCM2836_CORE_TIMER_IRQ_CTRL_TIMER3_FIQ 0x80
510
511
/* CPU mailbox registers */
512
#define BCM2836_MAILBOX_IRQ_CTRL_BASE 0x40000050
513
#define BCM2836_MAILBOX_IRQ_CTRL(cpuidx) \
514
(BCM2836_MAILBOX_IRQ_CTRL_BASE + 0x4 * (cpuidx))
515
/*
516
* Where to route mailbox interrupt to, IRQ/FIQ
517
* Setting both the IRQ and FIQ bit gives an FIQ
518
*/
519
#define BCM2836_MAILBOX_IRQ_CTRL_MBOX0_IRQ 0x01
520
#define BCM2836_MAILBOX_IRQ_CTRL_MBOX1_IRQ 0x02
521
#define BCM2836_MAILBOX_IRQ_CTRL_MBOX2_IRQ 0x04
522
#define BCM2836_MAILBOX_IRQ_CTRL_MBOX3_IRQ 0x08
523
#define BCM2836_MAILBOX_IRQ_CTRL_MBOX0_FIQ 0x10
524
#define BCM2836_MAILBOX_IRQ_CTRL_MBOX1_FIQ 0x20
525
#define BCM2836_MAILBOX_IRQ_CTRL_MBOX2_FIQ 0x40
526
#define BCM2836_MAILBOX_IRQ_CTRL_MBOX3_FIQ 0x80
527
528
#define BCM2836_IRQ_SOURCE_REG_BASE 0x40000060
529
#define BCM2836_IRQ_SOURCE_REG(cpuidx) \
530
(BCM2836_IRQ_SOURCE_REG_BASE + 0x4 * (cpuidx))
531
532
#define BCM2836_FIQ_SOURCE_REG_BASE 0x40000070
533
#define BCM2836_FIQ_SOURCE_REG(cpuidx) \
534
(BCM2836_FIQ_SOURCE_REG_BASE + 0x4 * (cpuidx))
535
536
#define BCM2836_IRQ_SOURCE_TIMER0 0x00000001
537
#define BCM2836_IRQ_SOURCE_TIMER1 0x00000002
538
#define BCM2836_IRQ_SOURCE_TIMER2 0x00000004
539
#define BCM2836_IRQ_SOURCE_TIMER3 0x00000008
540
#define BCM2836_IRQ_SOURCE_MBOX0 0x00000010
541
#define BCM2836_IRQ_SOURCE_MBOX1 0x00000020
542
#define BCM2836_IRQ_SOURCE_MBOX2 0x00000040
543
#define BCM2836_IRQ_SOURCE_MBOX3 0x00000080
544
#define BCM2836_IRQ_SOURCE_GPU 0x00000100
545
#define BCM2836_IRQ_SOURCE_PMU 0x00000200
546
#define BCM2836_IRQ_SOURCE_LOCAL_TIMER 0x00000800
547
550
#endif
/* LIBBSP_ARM_RASPBERRYPI_RASPBERRYPI_H */
utility.h
This header file provides utility macros for BSPs.
Generated by
1.9.6