quark.h 6.2 KB

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