1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * Copyright (C) 2014-2015 Broadcom Corporation
4 */
5
6 #ifndef _PCIE_IPROC_H
7 #define _PCIE_IPROC_H
8
9 /**
10 * enum iproc_pcie_type - iProc PCIe interface type
11 * @IPROC_PCIE_PAXB_BCMA: BCMA-based host controllers
12 * @IPROC_PCIE_PAXB: PAXB-based host controllers for
13 * NS, NSP, Cygnus, NS2, and Pegasus SOCs
14 * @IPROC_PCIE_PAXB_V2: PAXB-based host controllers for Stingray SoCs
15 * @IPROC_PCIE_PAXC: PAXC-based host controllers
16 * @IPROC_PCIE_PAXC_V2: PAXC-based host controllers (second generation)
17 *
18 * PAXB is the wrapper used in root complex that can be connected to an
19 * external endpoint device.
20 *
21 * PAXC is the wrapper used in root complex dedicated for internal emulated
22 * endpoint devices.
23 */
24 enum iproc_pcie_type {
25 IPROC_PCIE_PAXB_BCMA = 0,
26 IPROC_PCIE_PAXB,
27 IPROC_PCIE_PAXB_V2,
28 IPROC_PCIE_PAXC,
29 IPROC_PCIE_PAXC_V2,
30 };
31
32 /**
33 * struct iproc_pcie_ob - iProc PCIe outbound mapping
34 * @axi_offset: offset from the AXI address to the internal address used by
35 * the iProc PCIe core
36 * @nr_windows: total number of supported outbound mapping windows
37 */
38 struct iproc_pcie_ob {
39 resource_size_t axi_offset;
40 unsigned int nr_windows;
41 };
42
43 /**
44 * struct iproc_pcie_ib - iProc PCIe inbound mapping
45 * @nr_regions: total number of supported inbound mapping regions
46 */
47 struct iproc_pcie_ib {
48 unsigned int nr_regions;
49 };
50
51 struct iproc_pcie_ob_map;
52 struct iproc_pcie_ib_map;
53 struct iproc_msi;
54
55 /**
56 * struct iproc_pcie - iProc PCIe device
57 * @dev: pointer to device data structure
58 * @type: iProc PCIe interface type
59 * @reg_offsets: register offsets
60 * @base: PCIe host controller I/O register base
61 * @base_addr: PCIe host controller register base physical address
62 * @mem: host bridge memory window resource
63 * @phy: optional PHY device that controls the Serdes
64 * @map_irq: function callback to map interrupts
65 * @ep_is_internal: indicates an internal emulated endpoint device is connected
66 * @iproc_cfg_read: indicates the iProc config read function should be used
67 * @rej_unconfig_pf: indicates the root complex needs to detect and reject
68 * enumeration against unconfigured physical functions emulated in the ASIC
69 * @has_apb_err_disable: indicates the controller can be configured to prevent
70 * unsupported request from being forwarded as an APB bus error
71 * @fix_paxc_cap: indicates the controller has corrupted capability list in its
72 * config space registers and requires SW based fixup
73 *
74 * @need_ob_cfg: indicates SW needs to configure the outbound mapping window
75 * @ob: outbound mapping related parameters
76 * @ob_map: outbound mapping related parameters specific to the controller
77 *
78 * @need_ib_cfg: indicates SW needs to configure the inbound mapping window
79 * @ib: inbound mapping related parameters
80 * @ib_map: outbound mapping region related parameters
81 *
82 * @need_msi_steer: indicates additional configuration of the iProc PCIe
83 * controller is required to steer MSI writes to external interrupt controller
84 * @msi: MSI data
85 */
86 struct iproc_pcie {
87 struct device *dev;
88 enum iproc_pcie_type type;
89 u16 *reg_offsets;
90 void __iomem *base;
91 phys_addr_t base_addr;
92 struct resource mem;
93 struct phy *phy;
94 int (*map_irq)(const struct pci_dev *, u8, u8);
95 bool ep_is_internal;
96 bool iproc_cfg_read;
97 bool rej_unconfig_pf;
98 bool has_apb_err_disable;
99 bool fix_paxc_cap;
100
101 bool need_ob_cfg;
102 struct iproc_pcie_ob ob;
103 const struct iproc_pcie_ob_map *ob_map;
104
105 bool need_ib_cfg;
106 struct iproc_pcie_ib ib;
107 const struct iproc_pcie_ib_map *ib_map;
108
109 bool need_msi_steer;
110 struct iproc_msi *msi;
111 };
112
113 int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res);
114 void iproc_pcie_remove(struct iproc_pcie *pcie);
115 int iproc_pcie_shutdown(struct iproc_pcie *pcie);
116
117 #ifdef CONFIG_PCIE_IPROC_MSI
118 int iproc_msi_init(struct iproc_pcie *pcie, struct device_node *node);
119 void iproc_msi_exit(struct iproc_pcie *pcie);
120 #else
iproc_msi_init(struct iproc_pcie * pcie,struct device_node * node)121 static inline int iproc_msi_init(struct iproc_pcie *pcie,
122 struct device_node *node)
123 {
124 return -ENODEV;
125 }
iproc_msi_exit(struct iproc_pcie * pcie)126 static inline void iproc_msi_exit(struct iproc_pcie *pcie)
127 {
128 }
129 #endif
130
131 #endif /* _PCIE_IPROC_H */
132