xref: /linux/drivers/pci/controller/pcie-iproc.h (revision fab183d632628381b466a41479489541ac0e29a0)
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  * @ep_is_internal: indicates an internal emulated endpoint device is connected
65  * @iproc_cfg_read: indicates the iProc config read function should be used
66  * @rej_unconfig_pf: indicates the root complex needs to detect and reject
67  * enumeration against unconfigured physical functions emulated in the ASIC
68  * @has_apb_err_disable: indicates the controller can be configured to prevent
69  * unsupported request from being forwarded as an APB bus error
70  * @fix_paxc_cap: indicates the controller has corrupted capability list in its
71  * config space registers and requires SW based fixup
72  *
73  * @need_ob_cfg: indicates SW needs to configure the outbound mapping window
74  * @ob: outbound mapping related parameters
75  * @ob_map: outbound mapping related parameters specific to the controller
76  *
77  * @need_ib_cfg: indicates SW needs to configure the inbound mapping window
78  * @ib: inbound mapping related parameters
79  * @ib_map: outbound mapping region related parameters
80  *
81  * @need_msi_steer: indicates additional configuration of the iProc PCIe
82  * controller is required to steer MSI writes to external interrupt controller
83  * @msi: MSI data
84  */
85 struct iproc_pcie {
86 	struct device *dev;
87 	enum iproc_pcie_type type;
88 	u16 *reg_offsets;
89 	void __iomem *base;
90 	phys_addr_t base_addr;
91 	struct resource mem;
92 	struct phy *phy;
93 	bool ep_is_internal;
94 	bool iproc_cfg_read;
95 	bool rej_unconfig_pf;
96 	bool has_apb_err_disable;
97 	bool fix_paxc_cap;
98 
99 	bool need_ob_cfg;
100 	struct iproc_pcie_ob ob;
101 	const struct iproc_pcie_ob_map *ob_map;
102 
103 	bool need_ib_cfg;
104 	struct iproc_pcie_ib ib;
105 	const struct iproc_pcie_ib_map *ib_map;
106 
107 	bool need_msi_steer;
108 	struct iproc_msi *msi;
109 };
110 
111 int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res);
112 void iproc_pcie_remove(struct iproc_pcie *pcie);
113 int iproc_pcie_shutdown(struct iproc_pcie *pcie);
114 
115 #ifdef CONFIG_PCIE_IPROC_MSI
116 int iproc_msi_init(struct iproc_pcie *pcie, struct device_node *node);
117 void iproc_msi_exit(struct iproc_pcie *pcie);
118 #else
iproc_msi_init(struct iproc_pcie * pcie,struct device_node * node)119 static inline int iproc_msi_init(struct iproc_pcie *pcie,
120 				 struct device_node *node)
121 {
122 	return -ENODEV;
123 }
iproc_msi_exit(struct iproc_pcie * pcie)124 static inline void iproc_msi_exit(struct iproc_pcie *pcie)
125 {
126 }
127 #endif
128 
129 #endif /* _PCIE_IPROC_H */
130