quark.h 4.9 KB

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