17c62aeb8SAndrew Baumann /* 27c62aeb8SAndrew Baumann * bcm2708 aka bcm2835/2836 aka Raspberry Pi/Pi2 SoC platform defines 37c62aeb8SAndrew Baumann * 47c62aeb8SAndrew Baumann * These definitions are derived from those in Raspbian Linux at 57c62aeb8SAndrew Baumann * arch/arm/mach-{bcm2708,bcm2709}/include/mach/platform.h 67c62aeb8SAndrew Baumann * where they carry the following notice: 77c62aeb8SAndrew Baumann * 87c62aeb8SAndrew Baumann * Copyright (C) 2010 Broadcom 97c62aeb8SAndrew Baumann * 107c62aeb8SAndrew Baumann * This program is free software; you can redistribute it and/or modify 117c62aeb8SAndrew Baumann * it under the terms of the GNU General Public License as published by 127c62aeb8SAndrew Baumann * the Free Software Foundation; either version 2 of the License, or 137c62aeb8SAndrew Baumann * (at your option) any later version. 147c62aeb8SAndrew Baumann * 157c62aeb8SAndrew Baumann * This program is distributed in the hope that it will be useful, 167c62aeb8SAndrew Baumann * but WITHOUT ANY WARRANTY; without even the implied warranty of 177c62aeb8SAndrew Baumann * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 187c62aeb8SAndrew Baumann * GNU General Public License for more details. 197c62aeb8SAndrew Baumann * 207c62aeb8SAndrew Baumann * You should have received a copy of the GNU General Public License 210c201cc1SKhadija Kamran * along with this program. If not, see <https://www.gnu.org/licenses/>. 22d8e53d7bSPhilippe Mathieu-Daudé * 23d8e53d7bSPhilippe Mathieu-Daudé * Various undocumented addresses and names come from Herman Hermitage's VC4 24d8e53d7bSPhilippe Mathieu-Daudé * documentation: 25d8e53d7bSPhilippe Mathieu-Daudé * https://github.com/hermanhermitage/videocoreiv/wiki/MMIO-Register-map 267c62aeb8SAndrew Baumann */ 277c62aeb8SAndrew Baumann 28f91005e1SMarkus Armbruster #ifndef HW_ARM_RASPI_PLATFORM_H 29f91005e1SMarkus Armbruster #define HW_ARM_RASPI_PLATFORM_H 30f91005e1SMarkus Armbruster 3108df0676SSergey Kambalin #include "hw/boards.h" 3208df0676SSergey Kambalin #include "hw/arm/boot.h" 3308df0676SSergey Kambalin 34*bf1da4b3SSergey Kambalin /* Registered machine type (matches RPi Foundation bootloader and U-Boot) */ 35*bf1da4b3SSergey Kambalin #define MACH_TYPE_BCM2708 3138 36*bf1da4b3SSergey Kambalin 3708df0676SSergey Kambalin #define TYPE_RASPI_BASE_MACHINE MACHINE_TYPE_NAME("raspi-base") 3808df0676SSergey Kambalin OBJECT_DECLARE_TYPE(RaspiBaseMachineState, RaspiBaseMachineClass, 3908df0676SSergey Kambalin RASPI_BASE_MACHINE) 4008df0676SSergey Kambalin 4108df0676SSergey Kambalin struct RaspiBaseMachineState { 4208df0676SSergey Kambalin /*< private >*/ 4308df0676SSergey Kambalin MachineState parent_obj; 4408df0676SSergey Kambalin /*< public >*/ 4508df0676SSergey Kambalin struct arm_boot_info binfo; 4608df0676SSergey Kambalin }; 4708df0676SSergey Kambalin 4808df0676SSergey Kambalin struct RaspiBaseMachineClass { 4908df0676SSergey Kambalin /*< private >*/ 5008df0676SSergey Kambalin MachineClass parent_obj; 5108df0676SSergey Kambalin /*< public >*/ 5208df0676SSergey Kambalin uint32_t board_rev; 5308df0676SSergey Kambalin }; 5408df0676SSergey Kambalin 557785e8eaSSergey Kambalin /* Common functions for raspberry pi machines */ 567785e8eaSSergey Kambalin const char *board_soc_type(uint32_t board_rev); 577785e8eaSSergey Kambalin void raspi_machine_init(MachineState *machine); 587785e8eaSSergey Kambalin 597785e8eaSSergey Kambalin typedef struct BCM283XBaseState BCM283XBaseState; 607785e8eaSSergey Kambalin void raspi_base_machine_init(MachineState *machine, 617785e8eaSSergey Kambalin BCM283XBaseState *soc); 627785e8eaSSergey Kambalin 637785e8eaSSergey Kambalin void raspi_machine_class_common_init(MachineClass *mc, 647785e8eaSSergey Kambalin uint32_t board_rev); 65*bf1da4b3SSergey Kambalin uint64_t board_ram_size(uint32_t board_rev); 667785e8eaSSergey Kambalin 675cd436f9SPhilippe Mathieu-Daudé #define MSYNC_OFFSET 0x0000 /* Multicore Sync Block */ 68d8e53d7bSPhilippe Mathieu-Daudé #define CCPT_OFFSET 0x1000 /* Compact Camera Port 2 TX */ 69d8e53d7bSPhilippe Mathieu-Daudé #define INTE_OFFSET 0x2000 /* VC Interrupt controller */ 707c62aeb8SAndrew Baumann #define ST_OFFSET 0x3000 /* System Timer */ 71d8e53d7bSPhilippe Mathieu-Daudé #define TXP_OFFSET 0x4000 /* Transposer */ 72d8e53d7bSPhilippe Mathieu-Daudé #define JPEG_OFFSET 0x5000 737c62aeb8SAndrew Baumann #define MPHI_OFFSET 0x6000 /* Message-based Parallel Host Intf. */ 747c62aeb8SAndrew Baumann #define DMA_OFFSET 0x7000 /* DMA controller, channels 0-14 */ 75d8e53d7bSPhilippe Mathieu-Daudé #define ARBA_OFFSET 0x9000 76d8e53d7bSPhilippe Mathieu-Daudé #define BRDG_OFFSET 0xa000 77d8e53d7bSPhilippe Mathieu-Daudé #define ARM_OFFSET 0xB000 /* ARM control block */ 787c62aeb8SAndrew Baumann #define ARMCTRL_OFFSET (ARM_OFFSET + 0x000) 797c62aeb8SAndrew Baumann #define ARMCTRL_IC_OFFSET (ARM_OFFSET + 0x200) /* Interrupt controller */ 80d8e53d7bSPhilippe Mathieu-Daudé #define ARMCTRL_TIMER0_1_OFFSET (ARM_OFFSET + 0x400) /* Timer 0 and 1 (SP804) */ 817c62aeb8SAndrew Baumann #define ARMCTRL_0_SBM_OFFSET (ARM_OFFSET + 0x800) /* User 0 (ARM) Semaphores 827c62aeb8SAndrew Baumann * Doorbells & Mailboxes */ 8374de7145SLuc Michel #define PM_OFFSET 0x100000 /* Power Management */ 8474de7145SLuc Michel #define CPRMAN_OFFSET 0x101000 /* Clock Management */ 8500cbd5bdSPhilippe Mathieu-Daudé #define AVS_OFFSET 0x103000 /* Audio Video Standard */ 867c62aeb8SAndrew Baumann #define RNG_OFFSET 0x104000 877c62aeb8SAndrew Baumann #define GPIO_OFFSET 0x200000 88d8e53d7bSPhilippe Mathieu-Daudé #define UART0_OFFSET 0x201000 /* PL011 */ 89d8e53d7bSPhilippe Mathieu-Daudé #define MMCI0_OFFSET 0x202000 /* Legacy MMC */ 90d8e53d7bSPhilippe Mathieu-Daudé #define I2S_OFFSET 0x203000 /* PCM */ 91d8e53d7bSPhilippe Mathieu-Daudé #define SPI0_OFFSET 0x204000 /* SPI master */ 927c62aeb8SAndrew Baumann #define BSC0_OFFSET 0x205000 /* BSC0 I2C/TWI */ 93d8e53d7bSPhilippe Mathieu-Daudé #define PIXV0_OFFSET 0x206000 94d8e53d7bSPhilippe Mathieu-Daudé #define PIXV1_OFFSET 0x207000 95d8e53d7bSPhilippe Mathieu-Daudé #define DPI_OFFSET 0x208000 96d8e53d7bSPhilippe Mathieu-Daudé #define DSI0_OFFSET 0x209000 /* Display Serial Interface */ 97d8e53d7bSPhilippe Mathieu-Daudé #define PWM_OFFSET 0x20c000 98d8e53d7bSPhilippe Mathieu-Daudé #define PERM_OFFSET 0x20d000 99d8e53d7bSPhilippe Mathieu-Daudé #define TEC_OFFSET 0x20e000 10000cbd5bdSPhilippe Mathieu-Daudé #define OTP_OFFSET 0x20f000 101d8e53d7bSPhilippe Mathieu-Daudé #define SLIM_OFFSET 0x210000 /* SLIMbus */ 102d8e53d7bSPhilippe Mathieu-Daudé #define CPG_OFFSET 0x211000 103d442d95fSPhilippe Mathieu-Daudé #define THERMAL_OFFSET 0x212000 104d8e53d7bSPhilippe Mathieu-Daudé #define AVSP_OFFSET 0x213000 105d8e53d7bSPhilippe Mathieu-Daudé #define BSC_SL_OFFSET 0x214000 /* SPI slave (bootrom) */ 1065cd436f9SPhilippe Mathieu-Daudé #define AUX_OFFSET 0x215000 /* AUX: UART1/SPI1/SPI2 */ 1075cd436f9SPhilippe Mathieu-Daudé #define EMMC1_OFFSET 0x300000 108d8e53d7bSPhilippe Mathieu-Daudé #define EMMC2_OFFSET 0x340000 109d8e53d7bSPhilippe Mathieu-Daudé #define HVS_OFFSET 0x400000 1107c62aeb8SAndrew Baumann #define SMI_OFFSET 0x600000 111d8e53d7bSPhilippe Mathieu-Daudé #define DSI1_OFFSET 0x700000 112d8e53d7bSPhilippe Mathieu-Daudé #define UCAM_OFFSET 0x800000 113d8e53d7bSPhilippe Mathieu-Daudé #define CMI_OFFSET 0x802000 1147c62aeb8SAndrew Baumann #define BSC1_OFFSET 0x804000 /* BSC1 I2C/TWI */ 11500cbd5bdSPhilippe Mathieu-Daudé #define BSC2_OFFSET 0x805000 /* BSC2 I2C/TWI */ 116d8e53d7bSPhilippe Mathieu-Daudé #define VECA_OFFSET 0x806000 117d8e53d7bSPhilippe Mathieu-Daudé #define PIXV2_OFFSET 0x807000 118d8e53d7bSPhilippe Mathieu-Daudé #define HDMI_OFFSET 0x808000 119d8e53d7bSPhilippe Mathieu-Daudé #define HDCP_OFFSET 0x809000 120d8e53d7bSPhilippe Mathieu-Daudé #define ARBR0_OFFSET 0x80a000 12100cbd5bdSPhilippe Mathieu-Daudé #define DBUS_OFFSET 0x900000 12200cbd5bdSPhilippe Mathieu-Daudé #define AVE0_OFFSET 0x910000 1235cd436f9SPhilippe Mathieu-Daudé #define USB_OTG_OFFSET 0x980000 /* DTC_OTG USB controller */ 124d8e53d7bSPhilippe Mathieu-Daudé #define V3D_OFFSET 0xc00000 12500cbd5bdSPhilippe Mathieu-Daudé #define SDRAMC_OFFSET 0xe00000 126d8e53d7bSPhilippe Mathieu-Daudé #define L2CC_OFFSET 0xe01000 /* Level 2 Cache controller */ 127d8e53d7bSPhilippe Mathieu-Daudé #define L1CC_OFFSET 0xe02000 /* Level 1 Cache controller */ 128d8e53d7bSPhilippe Mathieu-Daudé #define ARBR1_OFFSET 0xe04000 1297c62aeb8SAndrew Baumann #define DMA15_OFFSET 0xE05000 /* DMA controller, channel 15 */ 130d8e53d7bSPhilippe Mathieu-Daudé #define DCRC_OFFSET 0xe07000 131d8e53d7bSPhilippe Mathieu-Daudé #define AXIP_OFFSET 0xe08000 1327c62aeb8SAndrew Baumann 1337c62aeb8SAndrew Baumann /* GPU interrupts */ 1347c62aeb8SAndrew Baumann #define INTERRUPT_TIMER0 0 1357c62aeb8SAndrew Baumann #define INTERRUPT_TIMER1 1 1367c62aeb8SAndrew Baumann #define INTERRUPT_TIMER2 2 1377c62aeb8SAndrew Baumann #define INTERRUPT_TIMER3 3 1387c62aeb8SAndrew Baumann #define INTERRUPT_CODEC0 4 1397c62aeb8SAndrew Baumann #define INTERRUPT_CODEC1 5 1407c62aeb8SAndrew Baumann #define INTERRUPT_CODEC2 6 1417c62aeb8SAndrew Baumann #define INTERRUPT_JPEG 7 1427c62aeb8SAndrew Baumann #define INTERRUPT_ISP 8 1437c62aeb8SAndrew Baumann #define INTERRUPT_USB 9 1447c62aeb8SAndrew Baumann #define INTERRUPT_3D 10 1457c62aeb8SAndrew Baumann #define INTERRUPT_TRANSPOSER 11 1467c62aeb8SAndrew Baumann #define INTERRUPT_MULTICORESYNC0 12 1477c62aeb8SAndrew Baumann #define INTERRUPT_MULTICORESYNC1 13 1487c62aeb8SAndrew Baumann #define INTERRUPT_MULTICORESYNC2 14 1497c62aeb8SAndrew Baumann #define INTERRUPT_MULTICORESYNC3 15 1507c62aeb8SAndrew Baumann #define INTERRUPT_DMA0 16 1517c62aeb8SAndrew Baumann #define INTERRUPT_DMA1 17 1527c62aeb8SAndrew Baumann #define INTERRUPT_DMA2 18 1537c62aeb8SAndrew Baumann #define INTERRUPT_DMA3 19 1547c62aeb8SAndrew Baumann #define INTERRUPT_DMA4 20 1557c62aeb8SAndrew Baumann #define INTERRUPT_DMA5 21 1567c62aeb8SAndrew Baumann #define INTERRUPT_DMA6 22 1577c62aeb8SAndrew Baumann #define INTERRUPT_DMA7 23 1587c62aeb8SAndrew Baumann #define INTERRUPT_DMA8 24 1597c62aeb8SAndrew Baumann #define INTERRUPT_DMA9 25 1607c62aeb8SAndrew Baumann #define INTERRUPT_DMA10 26 1617c62aeb8SAndrew Baumann #define INTERRUPT_DMA11 27 1627c62aeb8SAndrew Baumann #define INTERRUPT_DMA12 28 1637c62aeb8SAndrew Baumann #define INTERRUPT_AUX 29 1647c62aeb8SAndrew Baumann #define INTERRUPT_ARM 30 1657c62aeb8SAndrew Baumann #define INTERRUPT_VPUDMA 31 1667c62aeb8SAndrew Baumann #define INTERRUPT_HOSTPORT 32 1677c62aeb8SAndrew Baumann #define INTERRUPT_VIDEOSCALER 33 1687c62aeb8SAndrew Baumann #define INTERRUPT_CCP2TX 34 1697c62aeb8SAndrew Baumann #define INTERRUPT_SDC 35 1707c62aeb8SAndrew Baumann #define INTERRUPT_DSI0 36 1717c62aeb8SAndrew Baumann #define INTERRUPT_AVE 37 1727c62aeb8SAndrew Baumann #define INTERRUPT_CAM0 38 1737c62aeb8SAndrew Baumann #define INTERRUPT_CAM1 39 1747c62aeb8SAndrew Baumann #define INTERRUPT_HDMI0 40 1757c62aeb8SAndrew Baumann #define INTERRUPT_HDMI1 41 1767c62aeb8SAndrew Baumann #define INTERRUPT_PIXELVALVE1 42 1777c62aeb8SAndrew Baumann #define INTERRUPT_I2CSPISLV 43 1787c62aeb8SAndrew Baumann #define INTERRUPT_DSI1 44 1797c62aeb8SAndrew Baumann #define INTERRUPT_PWA0 45 1807c62aeb8SAndrew Baumann #define INTERRUPT_PWA1 46 1817c62aeb8SAndrew Baumann #define INTERRUPT_CPR 47 1827c62aeb8SAndrew Baumann #define INTERRUPT_SMI 48 1837c62aeb8SAndrew Baumann #define INTERRUPT_GPIO0 49 1847c62aeb8SAndrew Baumann #define INTERRUPT_GPIO1 50 1857c62aeb8SAndrew Baumann #define INTERRUPT_GPIO2 51 1867c62aeb8SAndrew Baumann #define INTERRUPT_GPIO3 52 1877c62aeb8SAndrew Baumann #define INTERRUPT_I2C 53 1887c62aeb8SAndrew Baumann #define INTERRUPT_SPI 54 1897c62aeb8SAndrew Baumann #define INTERRUPT_I2SPCM 55 1907c62aeb8SAndrew Baumann #define INTERRUPT_SDIO 56 1915cd436f9SPhilippe Mathieu-Daudé #define INTERRUPT_UART0 57 1927c62aeb8SAndrew Baumann #define INTERRUPT_SLIMBUS 58 1937c62aeb8SAndrew Baumann #define INTERRUPT_VEC 59 1947c62aeb8SAndrew Baumann #define INTERRUPT_CPG 60 1957c62aeb8SAndrew Baumann #define INTERRUPT_RNG 61 1967c62aeb8SAndrew Baumann #define INTERRUPT_ARASANSDIO 62 1977c62aeb8SAndrew Baumann #define INTERRUPT_AVSPMON 63 1987c62aeb8SAndrew Baumann 1997c62aeb8SAndrew Baumann /* ARM CPU IRQs use a private number space */ 2007c62aeb8SAndrew Baumann #define INTERRUPT_ARM_TIMER 0 2017c62aeb8SAndrew Baumann #define INTERRUPT_ARM_MAILBOX 1 2027c62aeb8SAndrew Baumann #define INTERRUPT_ARM_DOORBELL_0 2 2037c62aeb8SAndrew Baumann #define INTERRUPT_ARM_DOORBELL_1 3 2047c62aeb8SAndrew Baumann #define INTERRUPT_VPU0_HALTED 4 2057c62aeb8SAndrew Baumann #define INTERRUPT_VPU1_HALTED 5 2067c62aeb8SAndrew Baumann #define INTERRUPT_ILLEGAL_TYPE0 6 2077c62aeb8SAndrew Baumann #define INTERRUPT_ILLEGAL_TYPE1 7 208f91005e1SMarkus Armbruster 2095dc49636SSergey Kambalin /* Clock rates */ 2105dc49636SSergey Kambalin #define RPI_FIRMWARE_EMMC_CLK_RATE 50000000 2115dc49636SSergey Kambalin #define RPI_FIRMWARE_UART_CLK_RATE 3000000 212074259c0SSergey Kambalin /* 213074259c0SSergey Kambalin * TODO: this is really SoC-specific; we might want to 214074259c0SSergey Kambalin * set it per-SoC if it turns out any guests care. 215074259c0SSergey Kambalin */ 216074259c0SSergey Kambalin #define RPI_FIRMWARE_CORE_CLK_RATE 350000000 2175dc49636SSergey Kambalin #define RPI_FIRMWARE_DEFAULT_CLK_RATE 700000000 2185dc49636SSergey Kambalin 219f91005e1SMarkus Armbruster #endif 220