quark.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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. /* Port 0x04: Remote Management Unit Message Port Registers */
  31. /* ACPI PBLK Base Address Register */
  32. #define PBLK_BA 0x70
  33. /* Control Register */
  34. #define RMU_CTRL 0x71
  35. /* SPI DMA Base Address Register */
  36. #define SPI_DMA_BA 0x7a
  37. /* Thermal Sensor Register */
  38. #define TS_MODE 0xb0
  39. #define TS_TEMP 0xb1
  40. #define TS_TRIP 0xb2
  41. /* Port 0x05: Memory Manager Message Port Registers */
  42. /* eSRAM Block Page Control */
  43. #define ESRAM_BLK_CTRL 0x82
  44. #define ESRAM_BLOCK_MODE 0x10000000
  45. /* Port 0x14: USB2 AFE Unit Port Registers */
  46. #define USB2_GLOBAL_PORT 0x4001
  47. #define USB2_PLL1 0x7f02
  48. #define USB2_PLL2 0x7f03
  49. #define USB2_COMPBG 0x7f04
  50. /* Port 0x16: PCIe AFE Unit Port Registers */
  51. #define PCIE_RXPICTRL0_L0 0x2080
  52. #define PCIE_RXPICTRL0_L1 0x2180
  53. /* Port 0x31: SoC Unit Port Registers */
  54. /* Thermal Sensor Config */
  55. #define TS_CFG1 0x31
  56. #define TS_CFG2 0x32
  57. #define TS_CFG3 0x33
  58. #define TS_CFG4 0x34
  59. /* PCIe Controller Config */
  60. #define PCIE_CFG 0x36
  61. #define PCIE_CTLR_PRI_RST 0x00010000
  62. #define PCIE_PHY_SB_RST 0x00020000
  63. #define PCIE_CTLR_SB_RST 0x00040000
  64. #define PCIE_PHY_LANE_RST 0x00090000
  65. #define PCIE_CTLR_MAIN_RST 0x00100000
  66. /* DRAM */
  67. #define DRAM_BASE 0x00000000
  68. #define DRAM_MAX_SIZE 0x80000000
  69. /* eSRAM */
  70. #define ESRAM_SIZE 0x80000
  71. /* Memory BAR Enable */
  72. #define MEM_BAR_EN 0x00000001
  73. /* I/O BAR Enable */
  74. #define IO_BAR_EN 0x80000000
  75. /* 64KiB of RMU binary in flash */
  76. #define RMU_BINARY_SIZE 0x10000
  77. /* PCIe Root Port Configuration Registers */
  78. #define PCIE_RP_CCFG 0xd0
  79. #define CCFG_UPRS (1 << 14)
  80. #define CCFG_UNRS (1 << 15)
  81. #define CCFG_UNSD (1 << 23)
  82. #define CCFG_UPSD (1 << 24)
  83. #define PCIE_RP_MPC2 0xd4
  84. #define MPC2_IPF (1 << 11)
  85. #define PCIE_RP_MBC 0xf4
  86. #define MBC_SBIC (3 << 16)
  87. /* Legacy Bridge PCI Configuration Registers */
  88. #define LB_GBA 0x44
  89. #define LB_PM1BLK 0x48
  90. #define LB_GPE0BLK 0x4c
  91. #define LB_ACTL 0x58
  92. #define LB_PABCDRC 0x60
  93. #define LB_PEFGHRC 0x64
  94. #define LB_WDTBA 0x84
  95. #define LB_BCE 0xd4
  96. #define LB_BC 0xd8
  97. #define LB_RCBA 0xf0
  98. /* USB EHCI memory-mapped registers */
  99. #define EHCI_INSNREG01 0x94
  100. /* USB device memory-mapped registers */
  101. #define USBD_INT_MASK 0x410
  102. #define USBD_EP_INT_STS 0x414
  103. #define USBD_EP_INT_MASK 0x418
  104. #ifndef __ASSEMBLY__
  105. /* Root Complex Register Block */
  106. struct quark_rcba {
  107. u32 rctl;
  108. u32 esd;
  109. u32 rsvd1[3150];
  110. u16 rmu_ir;
  111. u16 d23_ir;
  112. u16 core_ir;
  113. u16 d20d21_ir;
  114. };
  115. #include <asm/io.h>
  116. #include <asm/pci.h>
  117. /**
  118. * qrk_pci_read_config_dword() - Read a configuration value
  119. *
  120. * @dev: PCI device address: bus, device and function
  121. * @offset: Dword offset within the device's configuration space
  122. * @valuep: Place to put the returned value
  123. *
  124. * Note: This routine is inlined to provide better performance on Quark
  125. */
  126. static inline void qrk_pci_read_config_dword(pci_dev_t dev, int offset,
  127. u32 *valuep)
  128. {
  129. outl(dev | offset | PCI_CFG_EN, PCI_REG_ADDR);
  130. *valuep = inl(PCI_REG_DATA);
  131. }
  132. /**
  133. * qrk_pci_write_config_dword() - Write a PCI configuration value
  134. *
  135. * @dev: PCI device address: bus, device and function
  136. * @offset: Dword offset within the device's configuration space
  137. * @value: Value to write
  138. *
  139. * Note: This routine is inlined to provide better performance on Quark
  140. */
  141. static inline void qrk_pci_write_config_dword(pci_dev_t dev, int offset,
  142. u32 value)
  143. {
  144. outl(dev | offset | PCI_CFG_EN, PCI_REG_ADDR);
  145. outl(value, PCI_REG_DATA);
  146. }
  147. /**
  148. * board_assert_perst() - Assert the PERST# pin
  149. *
  150. * The CPU interface to the PERST# signal on Quark is platform dependent.
  151. * Board-specific codes need supply this routine to assert PCIe slot reset.
  152. *
  153. * The tricky part in this routine is that any APIs that may trigger PCI
  154. * enumeration process are strictly forbidden, as any access to PCIe root
  155. * port's configuration registers will cause system hang while it is held
  156. * in reset.
  157. */
  158. void board_assert_perst(void);
  159. /**
  160. * board_deassert_perst() - De-assert the PERST# pin
  161. *
  162. * The CPU interface to the PERST# signal on Quark is platform dependent.
  163. * Board-specific codes need supply this routine to de-assert PCIe slot reset.
  164. *
  165. * The tricky part in this routine is that any APIs that may trigger PCI
  166. * enumeration process are strictly forbidden, as any access to PCIe root
  167. * port's configuration registers will cause system hang while it is held
  168. * in reset.
  169. */
  170. void board_deassert_perst(void);
  171. #endif /* __ASSEMBLY__ */
  172. #endif /* _QUARK_H_ */