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