quark.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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_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. /* Extended Configuration Space */
  27. #define HEC_REG 0x09
  28. /* Port 0x04: Remote Management Unit Message Port Registers */
  29. /* ACPI PBLK Base Address Register */
  30. #define PBLK_BA 0x70
  31. /* SPI DMA Base Address Register */
  32. #define SPI_DMA_BA 0x7a
  33. /* Port 0x05: Memory Manager Message Port Registers */
  34. /* eSRAM Block Page Control */
  35. #define ESRAM_BLK_CTRL 0x82
  36. #define ESRAM_BLOCK_MODE 0x10000000
  37. /* Port 0x16: PCIe AFE Unit Port Registers */
  38. #define PCIE_RXPICTRL0_L0 0x2080
  39. #define PCIE_RXPICTRL0_L1 0x2180
  40. /* Port 0x31: SoC Unit Port Registers */
  41. /* PCIe Controller Config */
  42. #define PCIE_CFG 0x36
  43. #define PCIE_CTLR_PRI_RST 0x00010000
  44. #define PCIE_PHY_SB_RST 0x00020000
  45. #define PCIE_CTLR_SB_RST 0x00040000
  46. #define PCIE_PHY_LANE_RST 0x00090000
  47. #define PCIE_CTLR_MAIN_RST 0x00100000
  48. /* DRAM */
  49. #define DRAM_BASE 0x00000000
  50. #define DRAM_MAX_SIZE 0x80000000
  51. /* eSRAM */
  52. #define ESRAM_SIZE 0x80000
  53. /* Memory BAR Enable */
  54. #define MEM_BAR_EN 0x00000001
  55. /* I/O BAR Enable */
  56. #define IO_BAR_EN 0x80000000
  57. /* 64KiB of RMU binary in flash */
  58. #define RMU_BINARY_SIZE 0x10000
  59. /* Legacy Bridge PCI Configuration Registers */
  60. #define LB_GBA 0x44
  61. #define LB_PM1BLK 0x48
  62. #define LB_GPE0BLK 0x4c
  63. #define LB_ACTL 0x58
  64. #define LB_PABCDRC 0x60
  65. #define LB_PEFGHRC 0x64
  66. #define LB_WDTBA 0x84
  67. #define LB_BCE 0xd4
  68. #define LB_BC 0xd8
  69. #define LB_RCBA 0xf0
  70. #ifndef __ASSEMBLY__
  71. /* Root Complex Register Block */
  72. struct quark_rcba {
  73. u32 rctl;
  74. u32 esd;
  75. u32 rsvd1[3150];
  76. u16 rmu_ir;
  77. u16 d23_ir;
  78. u16 core_ir;
  79. u16 d20d21_ir;
  80. };
  81. #include <asm/io.h>
  82. #include <asm/pci.h>
  83. /**
  84. * qrk_pci_read_config_dword() - Read a configuration value
  85. *
  86. * @dev: PCI device address: bus, device and function
  87. * @offset: Dword offset within the device's configuration space
  88. * @valuep: Place to put the returned value
  89. *
  90. * Note: This routine is inlined to provide better performance on Quark
  91. */
  92. static inline void qrk_pci_read_config_dword(pci_dev_t dev, int offset,
  93. u32 *valuep)
  94. {
  95. outl(dev | offset | PCI_CFG_EN, PCI_REG_ADDR);
  96. *valuep = inl(PCI_REG_DATA);
  97. }
  98. /**
  99. * qrk_pci_write_config_dword() - Write a PCI configuration value
  100. *
  101. * @dev: PCI device address: bus, device and function
  102. * @offset: Dword offset within the device's configuration space
  103. * @value: Value to write
  104. *
  105. * Note: This routine is inlined to provide better performance on Quark
  106. */
  107. static inline void qrk_pci_write_config_dword(pci_dev_t dev, int offset,
  108. u32 value)
  109. {
  110. outl(dev | offset | PCI_CFG_EN, PCI_REG_ADDR);
  111. outl(value, PCI_REG_DATA);
  112. }
  113. /**
  114. * board_assert_perst() - Assert the PERST# pin
  115. *
  116. * The CPU interface to the PERST# signal on Quark is platform dependent.
  117. * Board-specific codes need supply this routine to assert PCIe slot reset.
  118. *
  119. * The tricky part in this routine is that any APIs that may trigger PCI
  120. * enumeration process are strictly forbidden, as any access to PCIe root
  121. * port's configuration registers will cause system hang while it is held
  122. * in reset.
  123. */
  124. void board_assert_perst(void);
  125. /**
  126. * board_deassert_perst() - De-assert the PERST# pin
  127. *
  128. * The CPU interface to the PERST# signal on Quark is platform dependent.
  129. * Board-specific codes need supply this routine to de-assert PCIe slot reset.
  130. *
  131. * The tricky part in this routine is that any APIs that may trigger PCI
  132. * enumeration process are strictly forbidden, as any access to PCIe root
  133. * port's configuration registers will cause system hang while it is held
  134. * in reset.
  135. */
  136. void board_deassert_perst(void);
  137. #endif /* __ASSEMBLY__ */
  138. #endif /* _QUARK_H_ */