quark.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. /*
  2. * Copyright (C) 2015, Bin Meng <bmeng.cn@gmail.com>
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #ifndef _QUARK_H_
  7. #define _QUARK_H_
  8. /* Message Bus Ports */
  9. #define MSG_PORT_MEM_ARBITER 0x00
  10. #define MSG_PORT_HOST_BRIDGE 0x03
  11. #define MSG_PORT_RMU 0x04
  12. #define MSG_PORT_MEM_MGR 0x05
  13. #define MSG_PORT_USB_AFE 0x14
  14. #define MSG_PORT_PCIE_AFE 0x16
  15. #define MSG_PORT_SOC_UNIT 0x31
  16. /* Port 0x00: Memory Arbiter Message Port Registers */
  17. /* Enhanced Configuration Space */
  18. #define AEC_CTRL 0x00
  19. /* Port 0x03: Host Bridge Message Port Registers */
  20. /* Host Miscellaneous Controls 2 */
  21. #define HMISC2 0x03
  22. #define HMISC2_SEGE 0x00000002
  23. #define HMISC2_SEGF 0x00000004
  24. #define HMISC2_SEGAB 0x00000010
  25. /* Host Memory I/O Boundary */
  26. #define HM_BOUND 0x08
  27. #define HM_BOUND_LOCK 0x00000001
  28. /* Extended Configuration Space */
  29. #define HEC_REG 0x09
  30. /* MTRR Registers */
  31. #define MTRR_CAP 0x40
  32. #define MTRR_DEF_TYPE 0x41
  33. #define MTRR_FIX_64K_00000 0x42
  34. #define MTRR_FIX_64K_40000 0x43
  35. #define MTRR_FIX_16K_80000 0x44
  36. #define MTRR_FIX_16K_90000 0x45
  37. #define MTRR_FIX_16K_A0000 0x46
  38. #define MTRR_FIX_16K_B0000 0x47
  39. #define MTRR_FIX_4K_C0000 0x48
  40. #define MTRR_FIX_4K_C4000 0x49
  41. #define MTRR_FIX_4K_C8000 0x4a
  42. #define MTRR_FIX_4K_CC000 0x4b
  43. #define MTRR_FIX_4K_D0000 0x4c
  44. #define MTRR_FIX_4K_D4000 0x4d
  45. #define MTRR_FIX_4K_D8000 0x4e
  46. #define MTRR_FIX_4K_DC000 0x4f
  47. #define MTRR_FIX_4K_E0000 0x50
  48. #define MTRR_FIX_4K_E4000 0x51
  49. #define MTRR_FIX_4K_E8000 0x52
  50. #define MTRR_FIX_4K_EC000 0x53
  51. #define MTRR_FIX_4K_F0000 0x54
  52. #define MTRR_FIX_4K_F4000 0x55
  53. #define MTRR_FIX_4K_F8000 0x56
  54. #define MTRR_FIX_4K_FC000 0x57
  55. #define MTRR_SMRR_PHYBASE 0x58
  56. #define MTRR_SMRR_PHYMASK 0x59
  57. #define MTRR_VAR_PHYBASE(n) (0x5a + 2 * (n))
  58. #define MTRR_VAR_PHYMASK(n) (0x5b + 2 * (n))
  59. #ifndef __ASSEMBLY__
  60. /* variable range MTRR usage */
  61. enum {
  62. MTRR_VAR_ROM,
  63. MTRR_VAR_ESRAM,
  64. MTRR_VAR_RAM
  65. };
  66. #endif /* __ASSEMBLY__ */
  67. /* Port 0x04: Remote Management Unit Message Port Registers */
  68. /* ACPI PBLK Base Address Register */
  69. #define PBLK_BA 0x70
  70. /* Control Register */
  71. #define RMU_CTRL 0x71
  72. /* SPI DMA Base Address Register */
  73. #define SPI_DMA_BA 0x7a
  74. /* Thermal Sensor Register */
  75. #define TS_MODE 0xb0
  76. #define TS_TEMP 0xb1
  77. #define TS_TRIP 0xb2
  78. /* Port 0x05: Memory Manager Message Port Registers */
  79. /* eSRAM Block Page Control */
  80. #define ESRAM_BLK_CTRL 0x82
  81. #define ESRAM_BLOCK_MODE 0x10000000
  82. /* Port 0x14: USB2 AFE Unit Port Registers */
  83. #define USB2_GLOBAL_PORT 0x4001
  84. #define USB2_PLL1 0x7f02
  85. #define USB2_PLL2 0x7f03
  86. #define USB2_COMPBG 0x7f04
  87. /* Port 0x16: PCIe AFE Unit Port Registers */
  88. #define PCIE_RXPICTRL0_L0 0x2080
  89. #define PCIE_RXPICTRL0_L1 0x2180
  90. /* Port 0x31: SoC Unit Port Registers */
  91. /* Thermal Sensor Config */
  92. #define TS_CFG1 0x31
  93. #define TS_CFG2 0x32
  94. #define TS_CFG3 0x33
  95. #define TS_CFG4 0x34
  96. /* PCIe Controller Config */
  97. #define PCIE_CFG 0x36
  98. #define PCIE_CTLR_PRI_RST 0x00010000
  99. #define PCIE_PHY_SB_RST 0x00020000
  100. #define PCIE_CTLR_SB_RST 0x00040000
  101. #define PCIE_PHY_LANE_RST 0x00090000
  102. #define PCIE_CTLR_MAIN_RST 0x00100000
  103. /* DRAM */
  104. #define DRAM_BASE 0x00000000
  105. #define DRAM_MAX_SIZE 0x80000000
  106. /* eSRAM */
  107. #define ESRAM_SIZE 0x80000
  108. /* Memory BAR Enable */
  109. #define MEM_BAR_EN 0x00000001
  110. /* I/O BAR Enable */
  111. #define IO_BAR_EN 0x80000000
  112. /* 64KiB of RMU binary in flash */
  113. #define RMU_BINARY_SIZE 0x10000
  114. /* PCIe Root Port Configuration Registers */
  115. #define PCIE_RP_CCFG 0xd0
  116. #define CCFG_UPRS (1 << 14)
  117. #define CCFG_UNRS (1 << 15)
  118. #define CCFG_UNSD (1 << 23)
  119. #define CCFG_UPSD (1 << 24)
  120. #define PCIE_RP_MPC2 0xd4
  121. #define MPC2_IPF (1 << 11)
  122. #define PCIE_RP_MBC 0xf4
  123. #define MBC_SBIC (3 << 16)
  124. /* Legacy Bridge PCI Configuration Registers */
  125. #define LB_GBA 0x44
  126. #define LB_PM1BLK 0x48
  127. #define LB_GPE0BLK 0x4c
  128. #define LB_ACTL 0x58
  129. #define LB_PABCDRC 0x60
  130. #define LB_PEFGHRC 0x64
  131. #define LB_WDTBA 0x84
  132. #define LB_BCE 0xd4
  133. #define LB_BC 0xd8
  134. #define LB_RCBA 0xf0
  135. /* USB EHCI memory-mapped registers */
  136. #define EHCI_INSNREG01 0x94
  137. /* USB device memory-mapped registers */
  138. #define USBD_INT_MASK 0x410
  139. #define USBD_EP_INT_STS 0x414
  140. #define USBD_EP_INT_MASK 0x418
  141. #ifndef __ASSEMBLY__
  142. /* Root Complex Register Block */
  143. struct quark_rcba {
  144. u32 rctl;
  145. u32 esd;
  146. u32 rsvd1[3150];
  147. u16 rmu_ir;
  148. u16 d23_ir;
  149. u16 core_ir;
  150. u16 d20d21_ir;
  151. };
  152. #include <asm/io.h>
  153. #include <asm/pci.h>
  154. /**
  155. * qrk_pci_read_config_dword() - Read a configuration value
  156. *
  157. * @dev: PCI device address: bus, device and function
  158. * @offset: Dword offset within the device's configuration space
  159. * @valuep: Place to put the returned value
  160. *
  161. * Note: This routine is inlined to provide better performance on Quark
  162. */
  163. static inline void qrk_pci_read_config_dword(pci_dev_t dev, int offset,
  164. u32 *valuep)
  165. {
  166. outl(dev | offset | PCI_CFG_EN, PCI_REG_ADDR);
  167. *valuep = inl(PCI_REG_DATA);
  168. }
  169. /**
  170. * qrk_pci_write_config_dword() - Write a PCI configuration value
  171. *
  172. * @dev: PCI device address: bus, device and function
  173. * @offset: Dword offset within the device's configuration space
  174. * @value: Value to write
  175. *
  176. * Note: This routine is inlined to provide better performance on Quark
  177. */
  178. static inline void qrk_pci_write_config_dword(pci_dev_t dev, int offset,
  179. u32 value)
  180. {
  181. outl(dev | offset | PCI_CFG_EN, PCI_REG_ADDR);
  182. outl(value, PCI_REG_DATA);
  183. }
  184. /**
  185. * board_assert_perst() - Assert the PERST# pin
  186. *
  187. * The CPU interface to the PERST# signal on Quark is platform dependent.
  188. * Board-specific codes need supply this routine to assert PCIe slot reset.
  189. *
  190. * The tricky part in this routine is that any APIs that may trigger PCI
  191. * enumeration process are strictly forbidden, as any access to PCIe root
  192. * port's configuration registers will cause system hang while it is held
  193. * in reset.
  194. */
  195. void board_assert_perst(void);
  196. /**
  197. * board_deassert_perst() - De-assert the PERST# pin
  198. *
  199. * The CPU interface to the PERST# signal on Quark is platform dependent.
  200. * Board-specific codes need supply this routine to de-assert PCIe slot reset.
  201. *
  202. * The tricky part in this routine is that any APIs that may trigger PCI
  203. * enumeration process are strictly forbidden, as any access to PCIe root
  204. * port's configuration registers will cause system hang while it is held
  205. * in reset.
  206. */
  207. void board_deassert_perst(void);
  208. #endif /* __ASSEMBLY__ */
  209. #endif /* _QUARK_H_ */