2
0

raspi_platform.h 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. /*
  2. * bcm2708 aka bcm2835/2836 aka Raspberry Pi/Pi2 SoC platform defines
  3. *
  4. * These definitions are derived from those in Raspbian Linux at
  5. * arch/arm/mach-{bcm2708,bcm2709}/include/mach/platform.h
  6. * where they carry the following notice:
  7. *
  8. * Copyright (C) 2010 Broadcom
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  22. *
  23. * Various undocumented addresses and names come from Herman Hermitage's VC4
  24. * documentation:
  25. * https://github.com/hermanhermitage/videocoreiv/wiki/MMIO-Register-map
  26. */
  27. #ifndef HW_ARM_RASPI_PLATFORM_H
  28. #define HW_ARM_RASPI_PLATFORM_H
  29. #include "hw/boards.h"
  30. #include "hw/arm/boot.h"
  31. /* Registered machine type (matches RPi Foundation bootloader and U-Boot) */
  32. #define MACH_TYPE_BCM2708 3138
  33. #define TYPE_RASPI_BASE_MACHINE MACHINE_TYPE_NAME("raspi-base")
  34. OBJECT_DECLARE_TYPE(RaspiBaseMachineState, RaspiBaseMachineClass,
  35. RASPI_BASE_MACHINE)
  36. struct RaspiBaseMachineState {
  37. /*< private >*/
  38. MachineState parent_obj;
  39. /*< public >*/
  40. struct arm_boot_info binfo;
  41. };
  42. struct RaspiBaseMachineClass {
  43. /*< private >*/
  44. MachineClass parent_obj;
  45. /*< public >*/
  46. uint32_t board_rev;
  47. };
  48. /* Common functions for raspberry pi machines */
  49. const char *board_soc_type(uint32_t board_rev);
  50. void raspi_machine_init(MachineState *machine);
  51. typedef struct BCM283XBaseState BCM283XBaseState;
  52. void raspi_base_machine_init(MachineState *machine,
  53. BCM283XBaseState *soc);
  54. void raspi_machine_class_common_init(MachineClass *mc,
  55. uint32_t board_rev);
  56. uint64_t board_ram_size(uint32_t board_rev);
  57. #define MSYNC_OFFSET 0x0000 /* Multicore Sync Block */
  58. #define CCPT_OFFSET 0x1000 /* Compact Camera Port 2 TX */
  59. #define INTE_OFFSET 0x2000 /* VC Interrupt controller */
  60. #define ST_OFFSET 0x3000 /* System Timer */
  61. #define TXP_OFFSET 0x4000 /* Transposer */
  62. #define JPEG_OFFSET 0x5000
  63. #define MPHI_OFFSET 0x6000 /* Message-based Parallel Host Intf. */
  64. #define DMA_OFFSET 0x7000 /* DMA controller, channels 0-14 */
  65. #define ARBA_OFFSET 0x9000
  66. #define BRDG_OFFSET 0xa000 /* RPiVid ASB for BCM2838 (BCM2711) */
  67. #define ARM_OFFSET 0xB000 /* ARM control block */
  68. #define ARMCTRL_OFFSET (ARM_OFFSET + 0x000)
  69. #define ARMCTRL_IC_OFFSET (ARM_OFFSET + 0x200) /* Interrupt controller */
  70. #define ARMCTRL_TIMER0_1_OFFSET (ARM_OFFSET + 0x400) /* Timer 0 and 1 (SP804) */
  71. #define ARMCTRL_0_SBM_OFFSET (ARM_OFFSET + 0x800) /* User 0 (ARM) Semaphores
  72. * Doorbells & Mailboxes */
  73. #define PM_OFFSET 0x100000 /* Power Management */
  74. #define CPRMAN_OFFSET 0x101000 /* Clock Management */
  75. #define AVS_OFFSET 0x103000 /* Audio Video Standard */
  76. #define RNG_OFFSET 0x104000
  77. #define GPIO_OFFSET 0x200000
  78. #define UART0_OFFSET 0x201000 /* PL011 */
  79. #define MMCI0_OFFSET 0x202000 /* Legacy MMC */
  80. #define I2S_OFFSET 0x203000 /* PCM */
  81. #define SPI0_OFFSET 0x204000 /* SPI master */
  82. #define BSC0_OFFSET 0x205000 /* BSC0 I2C/TWI */
  83. #define PIXV0_OFFSET 0x206000
  84. #define PIXV1_OFFSET 0x207000
  85. #define DPI_OFFSET 0x208000
  86. #define DSI0_OFFSET 0x209000 /* Display Serial Interface */
  87. #define PWM_OFFSET 0x20c000
  88. #define PERM_OFFSET 0x20d000
  89. #define TEC_OFFSET 0x20e000
  90. #define OTP_OFFSET 0x20f000
  91. #define SLIM_OFFSET 0x210000 /* SLIMbus */
  92. #define CPG_OFFSET 0x211000
  93. #define THERMAL_OFFSET 0x212000
  94. #define AVSP_OFFSET 0x213000
  95. #define BSC_SL_OFFSET 0x214000 /* SPI slave (bootrom) */
  96. #define AUX_OFFSET 0x215000 /* AUX: UART1/SPI1/SPI2 */
  97. #define EMMC1_OFFSET 0x300000
  98. #define EMMC2_OFFSET 0x340000
  99. #define HVS_OFFSET 0x400000
  100. #define SMI_OFFSET 0x600000
  101. #define DSI1_OFFSET 0x700000
  102. #define UCAM_OFFSET 0x800000
  103. #define CMI_OFFSET 0x802000
  104. #define BSC1_OFFSET 0x804000 /* BSC1 I2C/TWI */
  105. #define BSC2_OFFSET 0x805000 /* BSC2 I2C/TWI */
  106. #define VECA_OFFSET 0x806000
  107. #define PIXV2_OFFSET 0x807000
  108. #define HDMI_OFFSET 0x808000
  109. #define HDCP_OFFSET 0x809000
  110. #define ARBR0_OFFSET 0x80a000
  111. #define DBUS_OFFSET 0x900000
  112. #define AVE0_OFFSET 0x910000
  113. #define USB_OTG_OFFSET 0x980000 /* DTC_OTG USB controller */
  114. #define V3D_OFFSET 0xc00000
  115. #define SDRAMC_OFFSET 0xe00000
  116. #define L2CC_OFFSET 0xe01000 /* Level 2 Cache controller */
  117. #define L1CC_OFFSET 0xe02000 /* Level 1 Cache controller */
  118. #define ARBR1_OFFSET 0xe04000
  119. #define DMA15_OFFSET 0xE05000 /* DMA controller, channel 15 */
  120. #define DCRC_OFFSET 0xe07000
  121. #define AXIP_OFFSET 0xe08000
  122. /* GPU interrupts */
  123. #define INTERRUPT_TIMER0 0
  124. #define INTERRUPT_TIMER1 1
  125. #define INTERRUPT_TIMER2 2
  126. #define INTERRUPT_TIMER3 3
  127. #define INTERRUPT_CODEC0 4
  128. #define INTERRUPT_CODEC1 5
  129. #define INTERRUPT_CODEC2 6
  130. #define INTERRUPT_JPEG 7
  131. #define INTERRUPT_ISP 8
  132. #define INTERRUPT_USB 9
  133. #define INTERRUPT_3D 10
  134. #define INTERRUPT_TRANSPOSER 11
  135. #define INTERRUPT_MULTICORESYNC0 12
  136. #define INTERRUPT_MULTICORESYNC1 13
  137. #define INTERRUPT_MULTICORESYNC2 14
  138. #define INTERRUPT_MULTICORESYNC3 15
  139. #define INTERRUPT_DMA0 16
  140. #define INTERRUPT_DMA1 17
  141. #define INTERRUPT_DMA2 18
  142. #define INTERRUPT_DMA3 19
  143. #define INTERRUPT_DMA4 20
  144. #define INTERRUPT_DMA5 21
  145. #define INTERRUPT_DMA6 22
  146. #define INTERRUPT_DMA7 23
  147. #define INTERRUPT_DMA8 24
  148. #define INTERRUPT_DMA9 25
  149. #define INTERRUPT_DMA10 26
  150. #define INTERRUPT_DMA11 27
  151. #define INTERRUPT_DMA12 28
  152. #define INTERRUPT_AUX 29
  153. #define INTERRUPT_ARM 30
  154. #define INTERRUPT_VPUDMA 31
  155. #define INTERRUPT_HOSTPORT 32
  156. #define INTERRUPT_VIDEOSCALER 33
  157. #define INTERRUPT_CCP2TX 34
  158. #define INTERRUPT_SDC 35
  159. #define INTERRUPT_DSI0 36
  160. #define INTERRUPT_AVE 37
  161. #define INTERRUPT_CAM0 38
  162. #define INTERRUPT_CAM1 39
  163. #define INTERRUPT_HDMI0 40
  164. #define INTERRUPT_HDMI1 41
  165. #define INTERRUPT_PIXELVALVE1 42
  166. #define INTERRUPT_I2CSPISLV 43
  167. #define INTERRUPT_DSI1 44
  168. #define INTERRUPT_PWA0 45
  169. #define INTERRUPT_PWA1 46
  170. #define INTERRUPT_CPR 47
  171. #define INTERRUPT_SMI 48
  172. #define INTERRUPT_GPIO0 49
  173. #define INTERRUPT_GPIO1 50
  174. #define INTERRUPT_GPIO2 51
  175. #define INTERRUPT_GPIO3 52
  176. #define INTERRUPT_I2C 53
  177. #define INTERRUPT_SPI 54
  178. #define INTERRUPT_I2SPCM 55
  179. #define INTERRUPT_SDIO 56
  180. #define INTERRUPT_UART0 57
  181. #define INTERRUPT_SLIMBUS 58
  182. #define INTERRUPT_VEC 59
  183. #define INTERRUPT_CPG 60
  184. #define INTERRUPT_RNG 61
  185. #define INTERRUPT_ARASANSDIO 62
  186. #define INTERRUPT_AVSPMON 63
  187. /* ARM CPU IRQs use a private number space */
  188. #define INTERRUPT_ARM_TIMER 0
  189. #define INTERRUPT_ARM_MAILBOX 1
  190. #define INTERRUPT_ARM_DOORBELL_0 2
  191. #define INTERRUPT_ARM_DOORBELL_1 3
  192. #define INTERRUPT_VPU0_HALTED 4
  193. #define INTERRUPT_VPU1_HALTED 5
  194. #define INTERRUPT_ILLEGAL_TYPE0 6
  195. #define INTERRUPT_ILLEGAL_TYPE1 7
  196. /* Clock rates */
  197. #define RPI_FIRMWARE_EMMC_CLK_RATE 50000000
  198. #define RPI_FIRMWARE_UART_CLK_RATE 3000000
  199. /*
  200. * TODO: this is really SoC-specific; we might want to
  201. * set it per-SoC if it turns out any guests care.
  202. */
  203. #define RPI_FIRMWARE_CORE_CLK_RATE 350000000
  204. #define RPI_FIRMWARE_DEFAULT_CLK_RATE 700000000
  205. #endif