xref: /rk3399_ARM-atf/plat/rpi/rpi4/include/rpi_hw.h (revision 5e6d821cb3b32fc6eadb38c25a96f8efe217efba)
1f5cb15b0SAndre Przywara /*
2f5cb15b0SAndre Przywara  * Copyright (c) 2016-2019, ARM Limited and Contributors. All rights reserved.
3f5cb15b0SAndre Przywara  *
4f5cb15b0SAndre Przywara  * SPDX-License-Identifier: BSD-3-Clause
5f5cb15b0SAndre Przywara  */
6f5cb15b0SAndre Przywara 
7f5cb15b0SAndre Przywara #ifndef RPI_HW_H
8f5cb15b0SAndre Przywara #define RPI_HW_H
9f5cb15b0SAndre Przywara 
10f5cb15b0SAndre Przywara #include <lib/utils_def.h>
11f5cb15b0SAndre Przywara 
12f5cb15b0SAndre Przywara /*
13f5cb15b0SAndre Przywara  * Peripherals
14f5cb15b0SAndre Przywara  */
15f5cb15b0SAndre Przywara 
16f5cb15b0SAndre Przywara #define RPI_IO_BASE			ULL(0xFE000000)
17f5cb15b0SAndre Przywara #define RPI_IO_SIZE			ULL(0x02000000)
18f5cb15b0SAndre Przywara 
19f5cb15b0SAndre Przywara /*
20f5cb15b0SAndre Przywara  * ARM <-> VideoCore mailboxes
21f5cb15b0SAndre Przywara  */
22f5cb15b0SAndre Przywara #define RPI3_MBOX_OFFSET		ULL(0x0000B880)
23f5cb15b0SAndre Przywara #define RPI3_MBOX_BASE			(RPI_IO_BASE + RPI3_MBOX_OFFSET)
24f5cb15b0SAndre Przywara /* VideoCore -> ARM */
25f5cb15b0SAndre Przywara #define RPI3_MBOX0_READ_OFFSET		ULL(0x00000000)
26f5cb15b0SAndre Przywara #define RPI3_MBOX0_PEEK_OFFSET		ULL(0x00000010)
27f5cb15b0SAndre Przywara #define RPI3_MBOX0_SENDER_OFFSET	ULL(0x00000014)
28f5cb15b0SAndre Przywara #define RPI3_MBOX0_STATUS_OFFSET	ULL(0x00000018)
29f5cb15b0SAndre Przywara #define RPI3_MBOX0_CONFIG_OFFSET	ULL(0x0000001C)
30f5cb15b0SAndre Przywara /* ARM -> VideoCore */
31f5cb15b0SAndre Przywara #define RPI3_MBOX1_WRITE_OFFSET		ULL(0x00000020)
32f5cb15b0SAndre Przywara #define RPI3_MBOX1_PEEK_OFFSET		ULL(0x00000030)
33f5cb15b0SAndre Przywara #define RPI3_MBOX1_SENDER_OFFSET	ULL(0x00000034)
34f5cb15b0SAndre Przywara #define RPI3_MBOX1_STATUS_OFFSET	ULL(0x00000038)
35f5cb15b0SAndre Przywara #define RPI3_MBOX1_CONFIG_OFFSET	ULL(0x0000003C)
36f5cb15b0SAndre Przywara /* Mailbox status constants */
37f5cb15b0SAndre Przywara #define RPI3_MBOX_STATUS_FULL_MASK	U(0x80000000) /* Set if full */
38f5cb15b0SAndre Przywara #define RPI3_MBOX_STATUS_EMPTY_MASK	U(0x40000000) /* Set if empty */
39f5cb15b0SAndre Przywara 
40f5cb15b0SAndre Przywara /*
41f5cb15b0SAndre Przywara  * Power management, reset controller, watchdog.
42f5cb15b0SAndre Przywara  */
43f5cb15b0SAndre Przywara #define RPI3_IO_PM_OFFSET		ULL(0x00100000)
44f5cb15b0SAndre Przywara #define RPI3_PM_BASE			(RPI_IO_BASE + RPI3_IO_PM_OFFSET)
45f5cb15b0SAndre Przywara /* Registers on top of RPI3_PM_BASE. */
46f5cb15b0SAndre Przywara #define RPI3_PM_RSTC_OFFSET		ULL(0x0000001C)
47f5cb15b0SAndre Przywara #define RPI3_PM_RSTS_OFFSET		ULL(0x00000020)
48f5cb15b0SAndre Przywara #define RPI3_PM_WDOG_OFFSET		ULL(0x00000024)
49f5cb15b0SAndre Przywara /* Watchdog constants */
50f5cb15b0SAndre Przywara #define RPI3_PM_PASSWORD		U(0x5A000000)
51f5cb15b0SAndre Przywara #define RPI3_PM_RSTC_WRCFG_MASK		U(0x00000030)
52f5cb15b0SAndre Przywara #define RPI3_PM_RSTC_WRCFG_FULL_RESET	U(0x00000020)
53f5cb15b0SAndre Przywara /*
54f5cb15b0SAndre Przywara  * The RSTS register is used by the VideoCore firmware when booting the
55f5cb15b0SAndre Przywara  * Raspberry Pi to know which partition to boot from. The partition value is
56f5cb15b0SAndre Przywara  * formed by bits 0, 2, 4, 6, 8 and 10. Partition 63 is used by said firmware
57f5cb15b0SAndre Przywara  * to indicate halt.
58f5cb15b0SAndre Przywara  */
59f5cb15b0SAndre Przywara #define RPI3_PM_RSTS_WRCFG_HALT		U(0x00000555)
60f5cb15b0SAndre Przywara 
61f5cb15b0SAndre Przywara /*
62f5cb15b0SAndre Przywara  * Hardware random number generator.
63f5cb15b0SAndre Przywara  */
64f5cb15b0SAndre Przywara #define RPI3_IO_RNG_OFFSET		ULL(0x00104000)
65f5cb15b0SAndre Przywara #define RPI3_RNG_BASE			(RPI_IO_BASE + RPI3_IO_RNG_OFFSET)
66f5cb15b0SAndre Przywara #define RPI3_RNG_CTRL_OFFSET		ULL(0x00000000)
67f5cb15b0SAndre Przywara #define RPI3_RNG_STATUS_OFFSET		ULL(0x00000004)
68f5cb15b0SAndre Przywara #define RPI3_RNG_DATA_OFFSET		ULL(0x00000008)
69f5cb15b0SAndre Przywara #define RPI3_RNG_INT_MASK_OFFSET	ULL(0x00000010)
70f5cb15b0SAndre Przywara /* Enable/disable RNG */
71f5cb15b0SAndre Przywara #define RPI3_RNG_CTRL_ENABLE		U(0x1)
72f5cb15b0SAndre Przywara #define RPI3_RNG_CTRL_DISABLE		U(0x0)
73f5cb15b0SAndre Przywara /* Number of currently available words */
74f5cb15b0SAndre Przywara #define RPI3_RNG_STATUS_NUM_WORDS_SHIFT	U(24)
75f5cb15b0SAndre Przywara #define RPI3_RNG_STATUS_NUM_WORDS_MASK	U(0xFF)
76f5cb15b0SAndre Przywara /* Value to mask interrupts caused by the RNG */
77f5cb15b0SAndre Przywara #define RPI3_RNG_INT_MASK_DISABLE	U(0x1)
78f5cb15b0SAndre Przywara 
79f5cb15b0SAndre Przywara /*
80*5e6d821cSAndre Przywara  * Serial ports:
81*5e6d821cSAndre Przywara  * 'Mini UART' in the BCM docucmentation is the 8250 compatible UART.
82*5e6d821cSAndre Przywara  * There is also a PL011 UART, multiplexed to the same pins.
83f5cb15b0SAndre Przywara  */
84795aefe5SAndre Przywara #define RPI4_IO_MINI_UART_OFFSET	ULL(0x00215040)
85795aefe5SAndre Przywara #define RPI4_MINI_UART_BASE		(RPI_IO_BASE + RPI4_IO_MINI_UART_OFFSET)
86*5e6d821cSAndre Przywara #define RPI4_IO_PL011_UART_OFFSET	ULL(0x00201000)
87*5e6d821cSAndre Przywara #define RPI4_PL011_UART_BASE		(RPI_IO_BASE + RPI4_IO_PL011_UART_OFFSET)
88*5e6d821cSAndre Przywara #define RPI4_PL011_UART_CLOCK		ULL(48000000)
89f5cb15b0SAndre Przywara 
90f5cb15b0SAndre Przywara /*
91f5cb15b0SAndre Przywara  * GPIO controller
92f5cb15b0SAndre Przywara  */
93f5cb15b0SAndre Przywara #define RPI3_IO_GPIO_OFFSET		ULL(0x00200000)
94f5cb15b0SAndre Przywara #define RPI3_GPIO_BASE			(RPI_IO_BASE + RPI3_IO_GPIO_OFFSET)
95f5cb15b0SAndre Przywara 
96f5cb15b0SAndre Przywara /*
97f5cb15b0SAndre Przywara  * SDHost controller
98f5cb15b0SAndre Przywara  */
99f5cb15b0SAndre Przywara #define RPI3_IO_SDHOST_OFFSET           ULL(0x00202000)
100f5cb15b0SAndre Przywara #define RPI3_SDHOST_BASE                (RPI_IO_BASE + RPI3_IO_SDHOST_OFFSET)
101f5cb15b0SAndre Przywara 
102f5cb15b0SAndre Przywara /*
103f5cb15b0SAndre Przywara  * GIC interrupt controller
104f5cb15b0SAndre Przywara  */
105f5cb15b0SAndre Przywara #define RPI_HAVE_GIC
106f5cb15b0SAndre Przywara #define RPI4_GIC_GICD_BASE		ULL(0xff841000)
107f5cb15b0SAndre Przywara #define RPI4_GIC_GICC_BASE		ULL(0xff842000)
108f5cb15b0SAndre Przywara 
109f5cb15b0SAndre Przywara #define	RPI4_LOCAL_CONTROL_BASE_ADDRESS		ULL(0xff800000)
110f5cb15b0SAndre Przywara #define	RPI4_LOCAL_CONTROL_PRESCALER		ULL(0xff800008)
111f5cb15b0SAndre Przywara 
112f5cb15b0SAndre Przywara #endif /* RPI_HW_H */
113