|
10 | 10 | #define PLDA_MAX_NUM_MSI_IRQS 32
|
11 | 11 |
|
12 | 12 | /* PCIe Bridge Phy Regs */
|
| 13 | +#define GEN_SETTINGS 0x80 |
| 14 | +#define RP_ENABLE 1 |
| 15 | +#define PCIE_PCI_IDS_DW1 0x9c |
| 16 | +#define IDS_CLASS_CODE_SHIFT 16 |
| 17 | +#define REVISION_ID_MASK GENMASK(7, 0) |
| 18 | +#define CLASS_CODE_ID_MASK GENMASK(31, 8) |
13 | 19 | #define PCIE_PCI_IRQ_DW0 0xa8
|
14 | 20 | #define MSIX_CAP_MASK BIT(31)
|
15 | 21 | #define NUM_MSI_MSGS_MASK GENMASK(6, 4)
|
16 | 22 | #define NUM_MSI_MSGS_SHIFT 4
|
| 23 | +#define PCI_MISC 0xb4 |
| 24 | +#define PHY_FUNCTION_DIS BIT(15) |
| 25 | +#define PCIE_WINROM 0xfc |
| 26 | +#define PREF_MEM_WIN_64_SUPPORT BIT(3) |
17 | 27 |
|
18 | 28 | #define IMASK_LOCAL 0x180
|
19 | 29 | #define DMA_END_ENGINE_0_MASK 0x00000000u
|
|
65 | 75 | #define ISTATUS_HOST 0x18c
|
66 | 76 | #define IMSI_ADDR 0x190
|
67 | 77 | #define ISTATUS_MSI 0x194
|
| 78 | +#define PMSG_SUPPORT_RX 0x3f0 |
| 79 | +#define PMSG_LTR_SUPPORT BIT(2) |
68 | 80 |
|
69 | 81 | /* PCIe Master table init defines */
|
70 | 82 | #define ATR0_PCIE_WIN0_SRCADDR_PARAM 0x600u
|
|
86 | 98 | #define PCIE_TX_RX_INTERFACE 0x00000000u
|
87 | 99 | #define PCIE_CONFIG_INTERFACE 0x00000001u
|
88 | 100 |
|
| 101 | +#define CONFIG_SPACE_ADDR_OFFSET 0x1000u |
| 102 | + |
89 | 103 | #define ATR_ENTRY_SIZE 32
|
90 | 104 |
|
91 | 105 | enum plda_int_event {
|
@@ -201,4 +215,59 @@ static inline void plda_set_default_msi(struct plda_msi *msi)
|
201 | 215 | msi->vector_phy = IMSI_ADDR;
|
202 | 216 | msi->num_vectors = PLDA_MAX_NUM_MSI_IRQS;
|
203 | 217 | }
|
204 |
| -#endif |
| 218 | + |
| 219 | +static inline void plda_pcie_enable_root_port(struct plda_pcie_rp *plda) |
| 220 | +{ |
| 221 | + u32 value; |
| 222 | + |
| 223 | + value = readl_relaxed(plda->bridge_addr + GEN_SETTINGS); |
| 224 | + value |= RP_ENABLE; |
| 225 | + writel_relaxed(value, plda->bridge_addr + GEN_SETTINGS); |
| 226 | +} |
| 227 | + |
| 228 | +static inline void plda_pcie_set_standard_class(struct plda_pcie_rp *plda) |
| 229 | +{ |
| 230 | + u32 value; |
| 231 | + |
| 232 | + /* set class code and reserve revision id */ |
| 233 | + value = readl_relaxed(plda->bridge_addr + PCIE_PCI_IDS_DW1); |
| 234 | + value &= REVISION_ID_MASK; |
| 235 | + value |= (PCI_CLASS_BRIDGE_PCI << IDS_CLASS_CODE_SHIFT); |
| 236 | + writel_relaxed(value, plda->bridge_addr + PCIE_PCI_IDS_DW1); |
| 237 | +} |
| 238 | + |
| 239 | +static inline void plda_pcie_set_pref_win_64bit(struct plda_pcie_rp *plda) |
| 240 | +{ |
| 241 | + u32 value; |
| 242 | + |
| 243 | + value = readl_relaxed(plda->bridge_addr + PCIE_WINROM); |
| 244 | + value |= PREF_MEM_WIN_64_SUPPORT; |
| 245 | + writel_relaxed(value, plda->bridge_addr + PCIE_WINROM); |
| 246 | +} |
| 247 | + |
| 248 | +static inline void plda_pcie_disable_ltr(struct plda_pcie_rp *plda) |
| 249 | +{ |
| 250 | + u32 value; |
| 251 | + |
| 252 | + value = readl_relaxed(plda->bridge_addr + PMSG_SUPPORT_RX); |
| 253 | + value &= ~PMSG_LTR_SUPPORT; |
| 254 | + writel_relaxed(value, plda->bridge_addr + PMSG_SUPPORT_RX); |
| 255 | +} |
| 256 | + |
| 257 | +static inline void plda_pcie_disable_func(struct plda_pcie_rp *plda) |
| 258 | +{ |
| 259 | + u32 value; |
| 260 | + |
| 261 | + value = readl_relaxed(plda->bridge_addr + PCI_MISC); |
| 262 | + value |= PHY_FUNCTION_DIS; |
| 263 | + writel_relaxed(value, plda->bridge_addr + PCI_MISC); |
| 264 | +} |
| 265 | + |
| 266 | +static inline void plda_pcie_write_rc_bar(struct plda_pcie_rp *plda, u64 val) |
| 267 | +{ |
| 268 | + void __iomem *addr = plda->bridge_addr + CONFIG_SPACE_ADDR_OFFSET; |
| 269 | + |
| 270 | + writel_relaxed(lower_32_bits(val), addr + PCI_BASE_ADDRESS_0); |
| 271 | + writel_relaxed(upper_32_bits(val), addr + PCI_BASE_ADDRESS_1); |
| 272 | +} |
| 273 | +#endif /* _PCIE_PLDA_H */ |
0 commit comments