1ba7e87c5SBjorn Helgaas /* SPDX-License-Identifier: GPL-2.0 */
2de80f95cSTom Joseph // Copyright (c) 2017 Cadence
3de80f95cSTom Joseph // Cadence PCIe controller driver.
4de80f95cSTom Joseph // Author: Cyrille Pitchen <cyrille.pitchen@free-electrons.com>
5de80f95cSTom Joseph
6de80f95cSTom Joseph #ifndef _PCIE_CADENCE_H
7de80f95cSTom Joseph #define _PCIE_CADENCE_H
8de80f95cSTom Joseph
9de80f95cSTom Joseph #include <linux/kernel.h>
10de80f95cSTom Joseph #include <linux/pci.h>
110cf985d6SKishon Vijay Abraham I #include <linux/pci-epf.h>
12de80f95cSTom Joseph #include <linux/phy/phy.h>
13de80f95cSTom Joseph
1440d957e6SKishon Vijay Abraham I /* Parameters for the waiting for link up routine */
1540d957e6SKishon Vijay Abraham I #define LINK_WAIT_MAX_RETRIES 10
1640d957e6SKishon Vijay Abraham I #define LINK_WAIT_USLEEP_MIN 90000
1740d957e6SKishon Vijay Abraham I #define LINK_WAIT_USLEEP_MAX 100000
1840d957e6SKishon Vijay Abraham I
19de80f95cSTom Joseph /*
20de80f95cSTom Joseph * Local Management Registers
21de80f95cSTom Joseph */
22de80f95cSTom Joseph #define CDNS_PCIE_LM_BASE 0x00100000
23de80f95cSTom Joseph
24de80f95cSTom Joseph /* Vendor ID Register */
25de80f95cSTom Joseph #define CDNS_PCIE_LM_ID (CDNS_PCIE_LM_BASE + 0x0044)
26de80f95cSTom Joseph #define CDNS_PCIE_LM_ID_VENDOR_MASK GENMASK(15, 0)
27de80f95cSTom Joseph #define CDNS_PCIE_LM_ID_VENDOR_SHIFT 0
28de80f95cSTom Joseph #define CDNS_PCIE_LM_ID_VENDOR(vid) \
29de80f95cSTom Joseph (((vid) << CDNS_PCIE_LM_ID_VENDOR_SHIFT) & CDNS_PCIE_LM_ID_VENDOR_MASK)
30de80f95cSTom Joseph #define CDNS_PCIE_LM_ID_SUBSYS_MASK GENMASK(31, 16)
31de80f95cSTom Joseph #define CDNS_PCIE_LM_ID_SUBSYS_SHIFT 16
32de80f95cSTom Joseph #define CDNS_PCIE_LM_ID_SUBSYS(sub) \
33de80f95cSTom Joseph (((sub) << CDNS_PCIE_LM_ID_SUBSYS_SHIFT) & CDNS_PCIE_LM_ID_SUBSYS_MASK)
34de80f95cSTom Joseph
3586b4ad7dSBjorn Helgaas /* Root Port Requester ID Register */
36de80f95cSTom Joseph #define CDNS_PCIE_LM_RP_RID (CDNS_PCIE_LM_BASE + 0x0228)
37de80f95cSTom Joseph #define CDNS_PCIE_LM_RP_RID_MASK GENMASK(15, 0)
38de80f95cSTom Joseph #define CDNS_PCIE_LM_RP_RID_SHIFT 0
39de80f95cSTom Joseph #define CDNS_PCIE_LM_RP_RID_(rid) \
40de80f95cSTom Joseph (((rid) << CDNS_PCIE_LM_RP_RID_SHIFT) & CDNS_PCIE_LM_RP_RID_MASK)
41de80f95cSTom Joseph
42de80f95cSTom Joseph /* Endpoint Bus and Device Number Register */
43de80f95cSTom Joseph #define CDNS_PCIE_LM_EP_ID (CDNS_PCIE_LM_BASE + 0x022c)
44de80f95cSTom Joseph #define CDNS_PCIE_LM_EP_ID_DEV_MASK GENMASK(4, 0)
45de80f95cSTom Joseph #define CDNS_PCIE_LM_EP_ID_DEV_SHIFT 0
46de80f95cSTom Joseph #define CDNS_PCIE_LM_EP_ID_BUS_MASK GENMASK(15, 8)
47de80f95cSTom Joseph #define CDNS_PCIE_LM_EP_ID_BUS_SHIFT 8
48de80f95cSTom Joseph
49de80f95cSTom Joseph /* Endpoint Function f BAR b Configuration Registers */
500cf985d6SKishon Vijay Abraham I #define CDNS_PCIE_LM_EP_FUNC_BAR_CFG(bar, fn) \
510cf985d6SKishon Vijay Abraham I (((bar) < BAR_4) ? CDNS_PCIE_LM_EP_FUNC_BAR_CFG0(fn) : CDNS_PCIE_LM_EP_FUNC_BAR_CFG1(fn))
52de80f95cSTom Joseph #define CDNS_PCIE_LM_EP_FUNC_BAR_CFG0(fn) \
53de80f95cSTom Joseph (CDNS_PCIE_LM_BASE + 0x0240 + (fn) * 0x0008)
54de80f95cSTom Joseph #define CDNS_PCIE_LM_EP_FUNC_BAR_CFG1(fn) \
55de80f95cSTom Joseph (CDNS_PCIE_LM_BASE + 0x0244 + (fn) * 0x0008)
56e19a0adfSKishon Vijay Abraham I #define CDNS_PCIE_LM_EP_VFUNC_BAR_CFG(bar, fn) \
57e19a0adfSKishon Vijay Abraham I (((bar) < BAR_4) ? CDNS_PCIE_LM_EP_VFUNC_BAR_CFG0(fn) : CDNS_PCIE_LM_EP_VFUNC_BAR_CFG1(fn))
58e19a0adfSKishon Vijay Abraham I #define CDNS_PCIE_LM_EP_VFUNC_BAR_CFG0(fn) \
59e19a0adfSKishon Vijay Abraham I (CDNS_PCIE_LM_BASE + 0x0280 + (fn) * 0x0008)
60e19a0adfSKishon Vijay Abraham I #define CDNS_PCIE_LM_EP_VFUNC_BAR_CFG1(fn) \
61e19a0adfSKishon Vijay Abraham I (CDNS_PCIE_LM_BASE + 0x0284 + (fn) * 0x0008)
62de80f95cSTom Joseph #define CDNS_PCIE_LM_EP_FUNC_BAR_CFG_BAR_APERTURE_MASK(b) \
63de80f95cSTom Joseph (GENMASK(4, 0) << ((b) * 8))
64de80f95cSTom Joseph #define CDNS_PCIE_LM_EP_FUNC_BAR_CFG_BAR_APERTURE(b, a) \
65de80f95cSTom Joseph (((a) << ((b) * 8)) & CDNS_PCIE_LM_EP_FUNC_BAR_CFG_BAR_APERTURE_MASK(b))
66de80f95cSTom Joseph #define CDNS_PCIE_LM_EP_FUNC_BAR_CFG_BAR_CTRL_MASK(b) \
67de80f95cSTom Joseph (GENMASK(7, 5) << ((b) * 8))
68de80f95cSTom Joseph #define CDNS_PCIE_LM_EP_FUNC_BAR_CFG_BAR_CTRL(b, c) \
69de80f95cSTom Joseph (((c) << ((b) * 8 + 5)) & CDNS_PCIE_LM_EP_FUNC_BAR_CFG_BAR_CTRL_MASK(b))
70de80f95cSTom Joseph
71de80f95cSTom Joseph /* Endpoint Function Configuration Register */
72de80f95cSTom Joseph #define CDNS_PCIE_LM_EP_FUNC_CFG (CDNS_PCIE_LM_BASE + 0x02c0)
73de80f95cSTom Joseph
74de80f95cSTom Joseph /* Root Complex BAR Configuration Register */
75de80f95cSTom Joseph #define CDNS_PCIE_LM_RC_BAR_CFG (CDNS_PCIE_LM_BASE + 0x0300)
76de80f95cSTom Joseph #define CDNS_PCIE_LM_RC_BAR_CFG_BAR0_APERTURE_MASK GENMASK(5, 0)
77de80f95cSTom Joseph #define CDNS_PCIE_LM_RC_BAR_CFG_BAR0_APERTURE(a) \
78de80f95cSTom Joseph (((a) << 0) & CDNS_PCIE_LM_RC_BAR_CFG_BAR0_APERTURE_MASK)
79de80f95cSTom Joseph #define CDNS_PCIE_LM_RC_BAR_CFG_BAR0_CTRL_MASK GENMASK(8, 6)
80de80f95cSTom Joseph #define CDNS_PCIE_LM_RC_BAR_CFG_BAR0_CTRL(c) \
81de80f95cSTom Joseph (((c) << 6) & CDNS_PCIE_LM_RC_BAR_CFG_BAR0_CTRL_MASK)
82de80f95cSTom Joseph #define CDNS_PCIE_LM_RC_BAR_CFG_BAR1_APERTURE_MASK GENMASK(13, 9)
83de80f95cSTom Joseph #define CDNS_PCIE_LM_RC_BAR_CFG_BAR1_APERTURE(a) \
84de80f95cSTom Joseph (((a) << 9) & CDNS_PCIE_LM_RC_BAR_CFG_BAR1_APERTURE_MASK)
85de80f95cSTom Joseph #define CDNS_PCIE_LM_RC_BAR_CFG_BAR1_CTRL_MASK GENMASK(16, 14)
86de80f95cSTom Joseph #define CDNS_PCIE_LM_RC_BAR_CFG_BAR1_CTRL(c) \
87de80f95cSTom Joseph (((c) << 14) & CDNS_PCIE_LM_RC_BAR_CFG_BAR1_CTRL_MASK)
88de80f95cSTom Joseph #define CDNS_PCIE_LM_RC_BAR_CFG_PREFETCH_MEM_ENABLE BIT(17)
89de80f95cSTom Joseph #define CDNS_PCIE_LM_RC_BAR_CFG_PREFETCH_MEM_32BITS 0
90de80f95cSTom Joseph #define CDNS_PCIE_LM_RC_BAR_CFG_PREFETCH_MEM_64BITS BIT(18)
91de80f95cSTom Joseph #define CDNS_PCIE_LM_RC_BAR_CFG_IO_ENABLE BIT(19)
92de80f95cSTom Joseph #define CDNS_PCIE_LM_RC_BAR_CFG_IO_16BITS 0
93de80f95cSTom Joseph #define CDNS_PCIE_LM_RC_BAR_CFG_IO_32BITS BIT(20)
94de80f95cSTom Joseph #define CDNS_PCIE_LM_RC_BAR_CFG_CHECK_ENABLE BIT(31)
95de80f95cSTom Joseph
96de80f95cSTom Joseph /* BAR control values applicable to both Endpoint Function and Root Complex */
97de80f95cSTom Joseph #define CDNS_PCIE_LM_BAR_CFG_CTRL_DISABLED 0x0
98de80f95cSTom Joseph #define CDNS_PCIE_LM_BAR_CFG_CTRL_IO_32BITS 0x1
99de80f95cSTom Joseph #define CDNS_PCIE_LM_BAR_CFG_CTRL_MEM_32BITS 0x4
100de80f95cSTom Joseph #define CDNS_PCIE_LM_BAR_CFG_CTRL_PREFETCH_MEM_32BITS 0x5
101de80f95cSTom Joseph #define CDNS_PCIE_LM_BAR_CFG_CTRL_MEM_64BITS 0x6
102de80f95cSTom Joseph #define CDNS_PCIE_LM_BAR_CFG_CTRL_PREFETCH_MEM_64BITS 0x7
103de80f95cSTom Joseph
1045d3d063aSKishon Vijay Abraham I #define LM_RC_BAR_CFG_CTRL_DISABLED(bar) \
1055d3d063aSKishon Vijay Abraham I (CDNS_PCIE_LM_BAR_CFG_CTRL_DISABLED << (((bar) * 8) + 6))
1065d3d063aSKishon Vijay Abraham I #define LM_RC_BAR_CFG_CTRL_IO_32BITS(bar) \
1075d3d063aSKishon Vijay Abraham I (CDNS_PCIE_LM_BAR_CFG_CTRL_IO_32BITS << (((bar) * 8) + 6))
1085d3d063aSKishon Vijay Abraham I #define LM_RC_BAR_CFG_CTRL_MEM_32BITS(bar) \
1095d3d063aSKishon Vijay Abraham I (CDNS_PCIE_LM_BAR_CFG_CTRL_MEM_32BITS << (((bar) * 8) + 6))
1105d3d063aSKishon Vijay Abraham I #define LM_RC_BAR_CFG_CTRL_PREF_MEM_32BITS(bar) \
1115d3d063aSKishon Vijay Abraham I (CDNS_PCIE_LM_BAR_CFG_CTRL_PREFETCH_MEM_32BITS << (((bar) * 8) + 6))
1125d3d063aSKishon Vijay Abraham I #define LM_RC_BAR_CFG_CTRL_MEM_64BITS(bar) \
1135d3d063aSKishon Vijay Abraham I (CDNS_PCIE_LM_BAR_CFG_CTRL_MEM_64BITS << (((bar) * 8) + 6))
1145d3d063aSKishon Vijay Abraham I #define LM_RC_BAR_CFG_CTRL_PREF_MEM_64BITS(bar) \
1155d3d063aSKishon Vijay Abraham I (CDNS_PCIE_LM_BAR_CFG_CTRL_PREFETCH_MEM_64BITS << (((bar) * 8) + 6))
1165d3d063aSKishon Vijay Abraham I #define LM_RC_BAR_CFG_APERTURE(bar, aperture) \
1175d3d063aSKishon Vijay Abraham I (((aperture) - 2) << ((bar) * 8))
118de80f95cSTom Joseph
119a1f67bc1SChristian Gmeiner /* PTM Control Register */
120a1f67bc1SChristian Gmeiner #define CDNS_PCIE_LM_PTM_CTRL (CDNS_PCIE_LM_BASE + 0x0da8)
121a1f67bc1SChristian Gmeiner #define CDNS_PCIE_LM_TPM_CTRL_PTMRSEN BIT(17)
122a1f67bc1SChristian Gmeiner
123de80f95cSTom Joseph /*
124de80f95cSTom Joseph * Endpoint Function Registers (PCI configuration space for endpoint functions)
125de80f95cSTom Joseph */
126de80f95cSTom Joseph #define CDNS_PCIE_EP_FUNC_BASE(fn) (((fn) << 12) & GENMASK(19, 12))
127de80f95cSTom Joseph
128de80f95cSTom Joseph #define CDNS_PCIE_EP_FUNC_MSI_CAP_OFFSET 0x90
1293ef5d16fSAlan Douglas #define CDNS_PCIE_EP_FUNC_MSIX_CAP_OFFSET 0xb0
13095b00f68SParshuram Thombare #define CDNS_PCIE_EP_FUNC_DEV_CAP_OFFSET 0xc0
131e19a0adfSKishon Vijay Abraham I #define CDNS_PCIE_EP_FUNC_SRIOV_CAP_OFFSET 0x200
132de80f95cSTom Joseph
133de80f95cSTom Joseph /*
134de80f95cSTom Joseph * Root Port Registers (PCI configuration space for the root port function)
135de80f95cSTom Joseph */
136de80f95cSTom Joseph #define CDNS_PCIE_RP_BASE 0x00200000
1374740b969SNadeem Athani #define CDNS_PCIE_RP_CAP_OFFSET 0xc0
138de80f95cSTom Joseph
139de80f95cSTom Joseph /*
140de80f95cSTom Joseph * Address Translation Registers
141de80f95cSTom Joseph */
142de80f95cSTom Joseph #define CDNS_PCIE_AT_BASE 0x00400000
143de80f95cSTom Joseph
144de80f95cSTom Joseph /* Region r Outbound AXI to PCIe Address Translation Register 0 */
145de80f95cSTom Joseph #define CDNS_PCIE_AT_OB_REGION_PCI_ADDR0(r) \
146de80f95cSTom Joseph (CDNS_PCIE_AT_BASE + 0x0000 + ((r) & 0x1f) * 0x0020)
147de80f95cSTom Joseph #define CDNS_PCIE_AT_OB_REGION_PCI_ADDR0_NBITS_MASK GENMASK(5, 0)
148de80f95cSTom Joseph #define CDNS_PCIE_AT_OB_REGION_PCI_ADDR0_NBITS(nbits) \
149de80f95cSTom Joseph (((nbits) - 1) & CDNS_PCIE_AT_OB_REGION_PCI_ADDR0_NBITS_MASK)
150de80f95cSTom Joseph #define CDNS_PCIE_AT_OB_REGION_PCI_ADDR0_DEVFN_MASK GENMASK(19, 12)
151de80f95cSTom Joseph #define CDNS_PCIE_AT_OB_REGION_PCI_ADDR0_DEVFN(devfn) \
152de80f95cSTom Joseph (((devfn) << 12) & CDNS_PCIE_AT_OB_REGION_PCI_ADDR0_DEVFN_MASK)
153de80f95cSTom Joseph #define CDNS_PCIE_AT_OB_REGION_PCI_ADDR0_BUS_MASK GENMASK(27, 20)
154de80f95cSTom Joseph #define CDNS_PCIE_AT_OB_REGION_PCI_ADDR0_BUS(bus) \
155de80f95cSTom Joseph (((bus) << 20) & CDNS_PCIE_AT_OB_REGION_PCI_ADDR0_BUS_MASK)
156de80f95cSTom Joseph
157de80f95cSTom Joseph /* Region r Outbound AXI to PCIe Address Translation Register 1 */
158de80f95cSTom Joseph #define CDNS_PCIE_AT_OB_REGION_PCI_ADDR1(r) \
159de80f95cSTom Joseph (CDNS_PCIE_AT_BASE + 0x0004 + ((r) & 0x1f) * 0x0020)
160de80f95cSTom Joseph
161de80f95cSTom Joseph /* Region r Outbound PCIe Descriptor Register 0 */
162de80f95cSTom Joseph #define CDNS_PCIE_AT_OB_REGION_DESC0(r) \
163de80f95cSTom Joseph (CDNS_PCIE_AT_BASE + 0x0008 + ((r) & 0x1f) * 0x0020)
164de80f95cSTom Joseph #define CDNS_PCIE_AT_OB_REGION_DESC0_TYPE_MASK GENMASK(3, 0)
165de80f95cSTom Joseph #define CDNS_PCIE_AT_OB_REGION_DESC0_TYPE_MEM 0x2
166de80f95cSTom Joseph #define CDNS_PCIE_AT_OB_REGION_DESC0_TYPE_IO 0x6
167de80f95cSTom Joseph #define CDNS_PCIE_AT_OB_REGION_DESC0_TYPE_CONF_TYPE0 0xa
168de80f95cSTom Joseph #define CDNS_PCIE_AT_OB_REGION_DESC0_TYPE_CONF_TYPE1 0xb
169de80f95cSTom Joseph #define CDNS_PCIE_AT_OB_REGION_DESC0_TYPE_NORMAL_MSG 0xc
170de80f95cSTom Joseph #define CDNS_PCIE_AT_OB_REGION_DESC0_TYPE_VENDOR_MSG 0xd
171de80f95cSTom Joseph /* Bit 23 MUST be set in RC mode. */
172de80f95cSTom Joseph #define CDNS_PCIE_AT_OB_REGION_DESC0_HARDCODED_RID BIT(23)
173de80f95cSTom Joseph #define CDNS_PCIE_AT_OB_REGION_DESC0_DEVFN_MASK GENMASK(31, 24)
174de80f95cSTom Joseph #define CDNS_PCIE_AT_OB_REGION_DESC0_DEVFN(devfn) \
175de80f95cSTom Joseph (((devfn) << 24) & CDNS_PCIE_AT_OB_REGION_DESC0_DEVFN_MASK)
176de80f95cSTom Joseph
177de80f95cSTom Joseph /* Region r Outbound PCIe Descriptor Register 1 */
178de80f95cSTom Joseph #define CDNS_PCIE_AT_OB_REGION_DESC1(r) \
179de80f95cSTom Joseph (CDNS_PCIE_AT_BASE + 0x000c + ((r) & 0x1f) * 0x0020)
180de80f95cSTom Joseph #define CDNS_PCIE_AT_OB_REGION_DESC1_BUS_MASK GENMASK(7, 0)
181de80f95cSTom Joseph #define CDNS_PCIE_AT_OB_REGION_DESC1_BUS(bus) \
182de80f95cSTom Joseph ((bus) & CDNS_PCIE_AT_OB_REGION_DESC1_BUS_MASK)
183de80f95cSTom Joseph
184de80f95cSTom Joseph /* Region r AXI Region Base Address Register 0 */
185de80f95cSTom Joseph #define CDNS_PCIE_AT_OB_REGION_CPU_ADDR0(r) \
186de80f95cSTom Joseph (CDNS_PCIE_AT_BASE + 0x0018 + ((r) & 0x1f) * 0x0020)
187de80f95cSTom Joseph #define CDNS_PCIE_AT_OB_REGION_CPU_ADDR0_NBITS_MASK GENMASK(5, 0)
188de80f95cSTom Joseph #define CDNS_PCIE_AT_OB_REGION_CPU_ADDR0_NBITS(nbits) \
189de80f95cSTom Joseph (((nbits) - 1) & CDNS_PCIE_AT_OB_REGION_CPU_ADDR0_NBITS_MASK)
190de80f95cSTom Joseph
191de80f95cSTom Joseph /* Region r AXI Region Base Address Register 1 */
192de80f95cSTom Joseph #define CDNS_PCIE_AT_OB_REGION_CPU_ADDR1(r) \
193de80f95cSTom Joseph (CDNS_PCIE_AT_BASE + 0x001c + ((r) & 0x1f) * 0x0020)
194de80f95cSTom Joseph
195de80f95cSTom Joseph /* Root Port BAR Inbound PCIe to AXI Address Translation Register */
196de80f95cSTom Joseph #define CDNS_PCIE_AT_IB_RP_BAR_ADDR0(bar) \
197de80f95cSTom Joseph (CDNS_PCIE_AT_BASE + 0x0800 + (bar) * 0x0008)
198de80f95cSTom Joseph #define CDNS_PCIE_AT_IB_RP_BAR_ADDR0_NBITS_MASK GENMASK(5, 0)
199de80f95cSTom Joseph #define CDNS_PCIE_AT_IB_RP_BAR_ADDR0_NBITS(nbits) \
200de80f95cSTom Joseph (((nbits) - 1) & CDNS_PCIE_AT_IB_RP_BAR_ADDR0_NBITS_MASK)
201de80f95cSTom Joseph #define CDNS_PCIE_AT_IB_RP_BAR_ADDR1(bar) \
202de80f95cSTom Joseph (CDNS_PCIE_AT_BASE + 0x0804 + (bar) * 0x0008)
203de80f95cSTom Joseph
204de80f95cSTom Joseph /* AXI link down register */
205de80f95cSTom Joseph #define CDNS_PCIE_AT_LINKDOWN (CDNS_PCIE_AT_BASE + 0x0824)
206de80f95cSTom Joseph
20709c24094SNadeem Athani /* LTSSM Capabilities register */
20809c24094SNadeem Athani #define CDNS_PCIE_LTSSM_CONTROL_CAP (CDNS_PCIE_LM_BASE + 0x0054)
20909c24094SNadeem Athani #define CDNS_PCIE_DETECT_QUIET_MIN_DELAY_MASK GENMASK(2, 1)
21009c24094SNadeem Athani #define CDNS_PCIE_DETECT_QUIET_MIN_DELAY_SHIFT 1
21109c24094SNadeem Athani #define CDNS_PCIE_DETECT_QUIET_MIN_DELAY(delay) \
21209c24094SNadeem Athani (((delay) << CDNS_PCIE_DETECT_QUIET_MIN_DELAY_SHIFT) & \
21309c24094SNadeem Athani CDNS_PCIE_DETECT_QUIET_MIN_DELAY_MASK)
21409c24094SNadeem Athani
215de80f95cSTom Joseph enum cdns_pcie_rp_bar {
2165d3d063aSKishon Vijay Abraham I RP_BAR_UNDEFINED = -1,
217de80f95cSTom Joseph RP_BAR0,
218de80f95cSTom Joseph RP_BAR1,
219de80f95cSTom Joseph RP_NO_BAR
220de80f95cSTom Joseph };
221de80f95cSTom Joseph
2225d3d063aSKishon Vijay Abraham I #define CDNS_PCIE_RP_MAX_IB 0x3
223e87d17caSKishon Vijay Abraham I #define CDNS_PCIE_MAX_OB 32
2245d3d063aSKishon Vijay Abraham I
2255d3d063aSKishon Vijay Abraham I struct cdns_pcie_rp_ib_bar {
2265d3d063aSKishon Vijay Abraham I u64 size;
2275d3d063aSKishon Vijay Abraham I bool free;
2285d3d063aSKishon Vijay Abraham I };
2295d3d063aSKishon Vijay Abraham I
230de80f95cSTom Joseph /* Endpoint Function BAR Inbound PCIe to AXI Address Translation Register */
231de80f95cSTom Joseph #define CDNS_PCIE_AT_IB_EP_FUNC_BAR_ADDR0(fn, bar) \
232de80f95cSTom Joseph (CDNS_PCIE_AT_BASE + 0x0840 + (fn) * 0x0040 + (bar) * 0x0008)
233de80f95cSTom Joseph #define CDNS_PCIE_AT_IB_EP_FUNC_BAR_ADDR1(fn, bar) \
234de80f95cSTom Joseph (CDNS_PCIE_AT_BASE + 0x0844 + (fn) * 0x0040 + (bar) * 0x0008)
235de80f95cSTom Joseph
236de80f95cSTom Joseph /* Normal/Vendor specific message access: offset inside some outbound region */
237de80f95cSTom Joseph #define CDNS_PCIE_NORMAL_MSG_ROUTING_MASK GENMASK(7, 5)
238de80f95cSTom Joseph #define CDNS_PCIE_NORMAL_MSG_ROUTING(route) \
239de80f95cSTom Joseph (((route) << 5) & CDNS_PCIE_NORMAL_MSG_ROUTING_MASK)
240de80f95cSTom Joseph #define CDNS_PCIE_NORMAL_MSG_CODE_MASK GENMASK(15, 8)
241de80f95cSTom Joseph #define CDNS_PCIE_NORMAL_MSG_CODE(code) \
242de80f95cSTom Joseph (((code) << 8) & CDNS_PCIE_NORMAL_MSG_CODE_MASK)
243de80f95cSTom Joseph #define CDNS_PCIE_MSG_NO_DATA BIT(16)
244de80f95cSTom Joseph
245de80f95cSTom Joseph struct cdns_pcie;
246de80f95cSTom Joseph
247de80f95cSTom Joseph enum cdns_pcie_msg_code {
248de80f95cSTom Joseph MSG_CODE_ASSERT_INTA = 0x20,
249de80f95cSTom Joseph MSG_CODE_ASSERT_INTB = 0x21,
250de80f95cSTom Joseph MSG_CODE_ASSERT_INTC = 0x22,
251de80f95cSTom Joseph MSG_CODE_ASSERT_INTD = 0x23,
252de80f95cSTom Joseph MSG_CODE_DEASSERT_INTA = 0x24,
253de80f95cSTom Joseph MSG_CODE_DEASSERT_INTB = 0x25,
254de80f95cSTom Joseph MSG_CODE_DEASSERT_INTC = 0x26,
255de80f95cSTom Joseph MSG_CODE_DEASSERT_INTD = 0x27,
256de80f95cSTom Joseph };
257de80f95cSTom Joseph
258de80f95cSTom Joseph enum cdns_pcie_msg_routing {
259de80f95cSTom Joseph /* Route to Root Complex */
260de80f95cSTom Joseph MSG_ROUTING_TO_RC,
261de80f95cSTom Joseph
262de80f95cSTom Joseph /* Use Address Routing */
263de80f95cSTom Joseph MSG_ROUTING_BY_ADDR,
264de80f95cSTom Joseph
265de80f95cSTom Joseph /* Use ID Routing */
266de80f95cSTom Joseph MSG_ROUTING_BY_ID,
267de80f95cSTom Joseph
268de80f95cSTom Joseph /* Route as Broadcast Message from Root Complex */
269de80f95cSTom Joseph MSG_ROUTING_BCAST,
270de80f95cSTom Joseph
271de80f95cSTom Joseph /* Local message; terminate at receiver (INTx messages) */
272de80f95cSTom Joseph MSG_ROUTING_LOCAL,
273de80f95cSTom Joseph
274de80f95cSTom Joseph /* Gather & route to Root Complex (PME_TO_Ack message) */
275de80f95cSTom Joseph MSG_ROUTING_GATHER,
276de80f95cSTom Joseph };
277de80f95cSTom Joseph
27840d957e6SKishon Vijay Abraham I struct cdns_pcie_ops {
27940d957e6SKishon Vijay Abraham I int (*start_link)(struct cdns_pcie *pcie);
28040d957e6SKishon Vijay Abraham I void (*stop_link)(struct cdns_pcie *pcie);
28140d957e6SKishon Vijay Abraham I bool (*link_up)(struct cdns_pcie *pcie);
282d07701a1SKishon Vijay Abraham I u64 (*cpu_addr_fixup)(struct cdns_pcie *pcie, u64 cpu_addr);
28340d957e6SKishon Vijay Abraham I };
28440d957e6SKishon Vijay Abraham I
285de80f95cSTom Joseph /**
286de80f95cSTom Joseph * struct cdns_pcie - private data for Cadence PCIe controller drivers
287de80f95cSTom Joseph * @reg_base: IO mapped register base
288de80f95cSTom Joseph * @mem_res: start/end offsets in the physical system memory to map PCI accesses
289347269c1SKrzysztof Wilczyński * @dev: PCIe controller
290de80f95cSTom Joseph * @is_rc: tell whether the PCIe controller mode is Root Complex or Endpoint.
291347269c1SKrzysztof Wilczyński * @phy_count: number of supported PHY devices
292347269c1SKrzysztof Wilczyński * @phy: list of pointers to specific PHY control blocks
293347269c1SKrzysztof Wilczyński * @link: list of pointers to corresponding device link representations
294347269c1SKrzysztof Wilczyński * @ops: Platform-specific ops to control various inputs from Cadence PCIe
29540d957e6SKishon Vijay Abraham I * wrapper
296de80f95cSTom Joseph */
297de80f95cSTom Joseph struct cdns_pcie {
298de80f95cSTom Joseph void __iomem *reg_base;
299de80f95cSTom Joseph struct resource *mem_res;
300de80f95cSTom Joseph struct device *dev;
301de80f95cSTom Joseph bool is_rc;
302de80f95cSTom Joseph int phy_count;
303de80f95cSTom Joseph struct phy **phy;
304de80f95cSTom Joseph struct device_link **link;
30540d957e6SKishon Vijay Abraham I const struct cdns_pcie_ops *ops;
306de80f95cSTom Joseph };
307de80f95cSTom Joseph
308de80f95cSTom Joseph /**
309de80f95cSTom Joseph * struct cdns_pcie_rc - private data for this PCIe Root Complex driver
310de80f95cSTom Joseph * @pcie: Cadence PCIe controller
311de80f95cSTom Joseph * @dev: pointer to PCIe device
312de80f95cSTom Joseph * @cfg_res: start/end offsets in the physical system memory to map PCI
313de80f95cSTom Joseph * configuration space accesses
314de80f95cSTom Joseph * @cfg_base: IO mapped window to access the PCI configuration space of a
315de80f95cSTom Joseph * single function at a time
316de80f95cSTom Joseph * @vendor_id: PCI vendor ID
317de80f95cSTom Joseph * @device_id: PCI device ID
318ccd36795SKrzysztof Wilczyński * @avail_ib_bar: Status of RP_BAR0, RP_BAR1 and RP_NO_BAR if it's free or
3195d3d063aSKishon Vijay Abraham I * available
3204740b969SNadeem Athani * @quirk_retrain_flag: Retrain link as quirk for PCIe Gen2
32109c24094SNadeem Athani * @quirk_detect_quiet_flag: LTSSM Detect Quiet min delay set as quirk
322de80f95cSTom Joseph */
323de80f95cSTom Joseph struct cdns_pcie_rc {
324de80f95cSTom Joseph struct cdns_pcie pcie;
325de80f95cSTom Joseph struct resource *cfg_res;
326de80f95cSTom Joseph void __iomem *cfg_base;
3277fb39bf2SKishon Vijay Abraham I u32 vendor_id;
3287fb39bf2SKishon Vijay Abraham I u32 device_id;
3295d3d063aSKishon Vijay Abraham I bool avail_ib_bar[CDNS_PCIE_RP_MAX_IB];
330f4455748SKishon Vijay Abraham I unsigned int quirk_retrain_flag:1;
33109c24094SNadeem Athani unsigned int quirk_detect_quiet_flag:1;
332de80f95cSTom Joseph };
333de80f95cSTom Joseph
334de80f95cSTom Joseph /**
3353ef5d16fSAlan Douglas * struct cdns_pcie_epf - Structure to hold info about endpoint function
336e19a0adfSKishon Vijay Abraham I * @epf: Info about virtual functions attached to the physical function
3373ef5d16fSAlan Douglas * @epf_bar: reference to the pci_epf_bar for the six Base Address Registers
3383ef5d16fSAlan Douglas */
3393ef5d16fSAlan Douglas struct cdns_pcie_epf {
340e19a0adfSKishon Vijay Abraham I struct cdns_pcie_epf *epf;
3413ef5d16fSAlan Douglas struct pci_epf_bar *epf_bar[PCI_STD_NUM_BARS];
3423ef5d16fSAlan Douglas };
3433ef5d16fSAlan Douglas
3443ef5d16fSAlan Douglas /**
345de80f95cSTom Joseph * struct cdns_pcie_ep - private data for this PCIe endpoint controller driver
346de80f95cSTom Joseph * @pcie: Cadence PCIe controller
347de80f95cSTom Joseph * @max_regions: maximum number of regions supported by hardware
348de80f95cSTom Joseph * @ob_region_map: bitmask of mapped outbound regions
349de80f95cSTom Joseph * @ob_addr: base addresses in the AXI bus where the outbound regions start
350de80f95cSTom Joseph * @irq_phys_addr: base address on the AXI bus where the MSI/legacy IRQ
351de80f95cSTom Joseph * dedicated outbound regions is mapped.
352de80f95cSTom Joseph * @irq_cpu_addr: base address in the CPU space where a write access triggers
353de80f95cSTom Joseph * the sending of a memory write (MSI) / normal message (legacy
354de80f95cSTom Joseph * IRQ) TLP through the PCIe bus.
355de80f95cSTom Joseph * @irq_pci_addr: used to save the current mapping of the MSI/legacy IRQ
356de80f95cSTom Joseph * dedicated outbound region.
357de80f95cSTom Joseph * @irq_pci_fn: the latest PCI function that has updated the mapping of
358de80f95cSTom Joseph * the MSI/legacy IRQ dedicated outbound region.
359de80f95cSTom Joseph * @irq_pending: bitmask of asserted legacy IRQs.
360a8b661ebSKishon Vijay Abraham I * @lock: spin lock to disable interrupts while modifying PCIe controller
361a8b661ebSKishon Vijay Abraham I * registers fields (RMW) accessible by both remote RC and EP to
362a8b661ebSKishon Vijay Abraham I * minimize time between read and write
3633ef5d16fSAlan Douglas * @epf: Structure to hold info about endpoint function
36409c24094SNadeem Athani * @quirk_detect_quiet_flag: LTSSM Detect Quiet min delay set as quirk
36595b00f68SParshuram Thombare * @quirk_disable_flr: Disable FLR (Function Level Reset) quirk flag
366de80f95cSTom Joseph */
367de80f95cSTom Joseph struct cdns_pcie_ep {
368de80f95cSTom Joseph struct cdns_pcie pcie;
369de80f95cSTom Joseph u32 max_regions;
370de80f95cSTom Joseph unsigned long ob_region_map;
371de80f95cSTom Joseph phys_addr_t *ob_addr;
372de80f95cSTom Joseph phys_addr_t irq_phys_addr;
373de80f95cSTom Joseph void __iomem *irq_cpu_addr;
374de80f95cSTom Joseph u64 irq_pci_addr;
375de80f95cSTom Joseph u8 irq_pci_fn;
376de80f95cSTom Joseph u8 irq_pending;
377a8b661ebSKishon Vijay Abraham I /* protect writing to PCI_STATUS while raising legacy interrupts */
378a8b661ebSKishon Vijay Abraham I spinlock_t lock;
3793ef5d16fSAlan Douglas struct cdns_pcie_epf *epf;
38009c24094SNadeem Athani unsigned int quirk_detect_quiet_flag:1;
38195b00f68SParshuram Thombare unsigned int quirk_disable_flr:1;
382de80f95cSTom Joseph };
383de80f95cSTom Joseph
384de80f95cSTom Joseph
385de80f95cSTom Joseph /* Register access */
cdns_pcie_writel(struct cdns_pcie * pcie,u32 reg,u32 value)386de80f95cSTom Joseph static inline void cdns_pcie_writel(struct cdns_pcie *pcie, u32 reg, u32 value)
387de80f95cSTom Joseph {
388de80f95cSTom Joseph writel(value, pcie->reg_base + reg);
389de80f95cSTom Joseph }
390de80f95cSTom Joseph
cdns_pcie_readl(struct cdns_pcie * pcie,u32 reg)391de80f95cSTom Joseph static inline u32 cdns_pcie_readl(struct cdns_pcie *pcie, u32 reg)
392de80f95cSTom Joseph {
393de80f95cSTom Joseph return readl(pcie->reg_base + reg);
394de80f95cSTom Joseph }
395de80f95cSTom Joseph
cdns_pcie_read_sz(void __iomem * addr,int size)396a8b661ebSKishon Vijay Abraham I static inline u32 cdns_pcie_read_sz(void __iomem *addr, int size)
397a8b661ebSKishon Vijay Abraham I {
398a8b661ebSKishon Vijay Abraham I void __iomem *aligned_addr = PTR_ALIGN_DOWN(addr, 0x4);
399a8b661ebSKishon Vijay Abraham I unsigned int offset = (unsigned long)addr & 0x3;
400a8b661ebSKishon Vijay Abraham I u32 val = readl(aligned_addr);
401a8b661ebSKishon Vijay Abraham I
402a8b661ebSKishon Vijay Abraham I if (!IS_ALIGNED((uintptr_t)addr, size)) {
403a8b661ebSKishon Vijay Abraham I pr_warn("Address %p and size %d are not aligned\n", addr, size);
404a8b661ebSKishon Vijay Abraham I return 0;
405a8b661ebSKishon Vijay Abraham I }
406a8b661ebSKishon Vijay Abraham I
407a8b661ebSKishon Vijay Abraham I if (size > 2)
408a8b661ebSKishon Vijay Abraham I return val;
409a8b661ebSKishon Vijay Abraham I
410a8b661ebSKishon Vijay Abraham I return (val >> (8 * offset)) & ((1 << (size * 8)) - 1);
411a8b661ebSKishon Vijay Abraham I }
412a8b661ebSKishon Vijay Abraham I
cdns_pcie_write_sz(void __iomem * addr,int size,u32 value)413a8b661ebSKishon Vijay Abraham I static inline void cdns_pcie_write_sz(void __iomem *addr, int size, u32 value)
414a8b661ebSKishon Vijay Abraham I {
415a8b661ebSKishon Vijay Abraham I void __iomem *aligned_addr = PTR_ALIGN_DOWN(addr, 0x4);
416a8b661ebSKishon Vijay Abraham I unsigned int offset = (unsigned long)addr & 0x3;
417a8b661ebSKishon Vijay Abraham I u32 mask;
418a8b661ebSKishon Vijay Abraham I u32 val;
419a8b661ebSKishon Vijay Abraham I
420a8b661ebSKishon Vijay Abraham I if (!IS_ALIGNED((uintptr_t)addr, size)) {
421a8b661ebSKishon Vijay Abraham I pr_warn("Address %p and size %d are not aligned\n", addr, size);
422a8b661ebSKishon Vijay Abraham I return;
423a8b661ebSKishon Vijay Abraham I }
424a8b661ebSKishon Vijay Abraham I
425a8b661ebSKishon Vijay Abraham I if (size > 2) {
426a8b661ebSKishon Vijay Abraham I writel(value, addr);
427a8b661ebSKishon Vijay Abraham I return;
428a8b661ebSKishon Vijay Abraham I }
429a8b661ebSKishon Vijay Abraham I
430a8b661ebSKishon Vijay Abraham I mask = ~(((1 << (size * 8)) - 1) << (offset * 8));
431a8b661ebSKishon Vijay Abraham I val = readl(aligned_addr) & mask;
432a8b661ebSKishon Vijay Abraham I val |= value << (offset * 8);
433a8b661ebSKishon Vijay Abraham I writel(val, aligned_addr);
434a8b661ebSKishon Vijay Abraham I }
435a8b661ebSKishon Vijay Abraham I
436de80f95cSTom Joseph /* Root Port register access */
cdns_pcie_rp_writeb(struct cdns_pcie * pcie,u32 reg,u8 value)437de80f95cSTom Joseph static inline void cdns_pcie_rp_writeb(struct cdns_pcie *pcie,
438de80f95cSTom Joseph u32 reg, u8 value)
439de80f95cSTom Joseph {
440a8b661ebSKishon Vijay Abraham I void __iomem *addr = pcie->reg_base + CDNS_PCIE_RP_BASE + reg;
441a8b661ebSKishon Vijay Abraham I
442a8b661ebSKishon Vijay Abraham I cdns_pcie_write_sz(addr, 0x1, value);
443de80f95cSTom Joseph }
444de80f95cSTom Joseph
cdns_pcie_rp_writew(struct cdns_pcie * pcie,u32 reg,u16 value)445de80f95cSTom Joseph static inline void cdns_pcie_rp_writew(struct cdns_pcie *pcie,
446de80f95cSTom Joseph u32 reg, u16 value)
447de80f95cSTom Joseph {
448a8b661ebSKishon Vijay Abraham I void __iomem *addr = pcie->reg_base + CDNS_PCIE_RP_BASE + reg;
449a8b661ebSKishon Vijay Abraham I
450a8b661ebSKishon Vijay Abraham I cdns_pcie_write_sz(addr, 0x2, value);
451de80f95cSTom Joseph }
452de80f95cSTom Joseph
cdns_pcie_rp_readw(struct cdns_pcie * pcie,u32 reg)4534740b969SNadeem Athani static inline u16 cdns_pcie_rp_readw(struct cdns_pcie *pcie, u32 reg)
4544740b969SNadeem Athani {
4554740b969SNadeem Athani void __iomem *addr = pcie->reg_base + CDNS_PCIE_RP_BASE + reg;
4564740b969SNadeem Athani
4574740b969SNadeem Athani return cdns_pcie_read_sz(addr, 0x2);
4584740b969SNadeem Athani }
4594740b969SNadeem Athani
460de80f95cSTom Joseph /* Endpoint Function register access */
cdns_pcie_ep_fn_writeb(struct cdns_pcie * pcie,u8 fn,u32 reg,u8 value)461de80f95cSTom Joseph static inline void cdns_pcie_ep_fn_writeb(struct cdns_pcie *pcie, u8 fn,
462de80f95cSTom Joseph u32 reg, u8 value)
463de80f95cSTom Joseph {
464a8b661ebSKishon Vijay Abraham I void __iomem *addr = pcie->reg_base + CDNS_PCIE_EP_FUNC_BASE(fn) + reg;
465a8b661ebSKishon Vijay Abraham I
466a8b661ebSKishon Vijay Abraham I cdns_pcie_write_sz(addr, 0x1, value);
467de80f95cSTom Joseph }
468de80f95cSTom Joseph
cdns_pcie_ep_fn_writew(struct cdns_pcie * pcie,u8 fn,u32 reg,u16 value)469de80f95cSTom Joseph static inline void cdns_pcie_ep_fn_writew(struct cdns_pcie *pcie, u8 fn,
470de80f95cSTom Joseph u32 reg, u16 value)
471de80f95cSTom Joseph {
472a8b661ebSKishon Vijay Abraham I void __iomem *addr = pcie->reg_base + CDNS_PCIE_EP_FUNC_BASE(fn) + reg;
473a8b661ebSKishon Vijay Abraham I
474a8b661ebSKishon Vijay Abraham I cdns_pcie_write_sz(addr, 0x2, value);
475de80f95cSTom Joseph }
476de80f95cSTom Joseph
cdns_pcie_ep_fn_writel(struct cdns_pcie * pcie,u8 fn,u32 reg,u32 value)477de80f95cSTom Joseph static inline void cdns_pcie_ep_fn_writel(struct cdns_pcie *pcie, u8 fn,
478de80f95cSTom Joseph u32 reg, u32 value)
479de80f95cSTom Joseph {
480de80f95cSTom Joseph writel(value, pcie->reg_base + CDNS_PCIE_EP_FUNC_BASE(fn) + reg);
481de80f95cSTom Joseph }
482de80f95cSTom Joseph
cdns_pcie_ep_fn_readw(struct cdns_pcie * pcie,u8 fn,u32 reg)483de80f95cSTom Joseph static inline u16 cdns_pcie_ep_fn_readw(struct cdns_pcie *pcie, u8 fn, u32 reg)
484de80f95cSTom Joseph {
485a8b661ebSKishon Vijay Abraham I void __iomem *addr = pcie->reg_base + CDNS_PCIE_EP_FUNC_BASE(fn) + reg;
486a8b661ebSKishon Vijay Abraham I
487a8b661ebSKishon Vijay Abraham I return cdns_pcie_read_sz(addr, 0x2);
488de80f95cSTom Joseph }
489de80f95cSTom Joseph
cdns_pcie_ep_fn_readl(struct cdns_pcie * pcie,u8 fn,u32 reg)490de80f95cSTom Joseph static inline u32 cdns_pcie_ep_fn_readl(struct cdns_pcie *pcie, u8 fn, u32 reg)
491de80f95cSTom Joseph {
492de80f95cSTom Joseph return readl(pcie->reg_base + CDNS_PCIE_EP_FUNC_BASE(fn) + reg);
493de80f95cSTom Joseph }
494de80f95cSTom Joseph
cdns_pcie_start_link(struct cdns_pcie * pcie)49540d957e6SKishon Vijay Abraham I static inline int cdns_pcie_start_link(struct cdns_pcie *pcie)
49640d957e6SKishon Vijay Abraham I {
49740d957e6SKishon Vijay Abraham I if (pcie->ops->start_link)
49840d957e6SKishon Vijay Abraham I return pcie->ops->start_link(pcie);
49940d957e6SKishon Vijay Abraham I
50040d957e6SKishon Vijay Abraham I return 0;
50140d957e6SKishon Vijay Abraham I }
50240d957e6SKishon Vijay Abraham I
cdns_pcie_stop_link(struct cdns_pcie * pcie)50340d957e6SKishon Vijay Abraham I static inline void cdns_pcie_stop_link(struct cdns_pcie *pcie)
50440d957e6SKishon Vijay Abraham I {
50540d957e6SKishon Vijay Abraham I if (pcie->ops->stop_link)
50640d957e6SKishon Vijay Abraham I pcie->ops->stop_link(pcie);
50740d957e6SKishon Vijay Abraham I }
50840d957e6SKishon Vijay Abraham I
cdns_pcie_link_up(struct cdns_pcie * pcie)50940d957e6SKishon Vijay Abraham I static inline bool cdns_pcie_link_up(struct cdns_pcie *pcie)
51040d957e6SKishon Vijay Abraham I {
51140d957e6SKishon Vijay Abraham I if (pcie->ops->link_up)
51240d957e6SKishon Vijay Abraham I return pcie->ops->link_up(pcie);
51340d957e6SKishon Vijay Abraham I
51440d957e6SKishon Vijay Abraham I return true;
51540d957e6SKishon Vijay Abraham I }
51640d957e6SKishon Vijay Abraham I
517de80f95cSTom Joseph #ifdef CONFIG_PCIE_CADENCE_HOST
5184231df76SThomas Richard int cdns_pcie_host_link_setup(struct cdns_pcie_rc *rc);
519*762de299SThomas Richard int cdns_pcie_host_init(struct cdns_pcie_rc *rc);
520de80f95cSTom Joseph int cdns_pcie_host_setup(struct cdns_pcie_rc *rc);
521f3e25911SKishon Vijay Abraham I void __iomem *cdns_pci_map_bus(struct pci_bus *bus, unsigned int devfn,
522f3e25911SKishon Vijay Abraham I int where);
523de80f95cSTom Joseph #else
cdns_pcie_host_link_setup(struct cdns_pcie_rc * rc)5244231df76SThomas Richard static inline int cdns_pcie_host_link_setup(struct cdns_pcie_rc *rc)
5254231df76SThomas Richard {
5264231df76SThomas Richard return 0;
5274231df76SThomas Richard }
5284231df76SThomas Richard
cdns_pcie_host_init(struct cdns_pcie_rc * rc)529*762de299SThomas Richard static inline int cdns_pcie_host_init(struct cdns_pcie_rc *rc)
530*762de299SThomas Richard {
531*762de299SThomas Richard return 0;
532*762de299SThomas Richard }
533*762de299SThomas Richard
cdns_pcie_host_setup(struct cdns_pcie_rc * rc)534de80f95cSTom Joseph static inline int cdns_pcie_host_setup(struct cdns_pcie_rc *rc)
535de80f95cSTom Joseph {
536de80f95cSTom Joseph return 0;
537de80f95cSTom Joseph }
538f3e25911SKishon Vijay Abraham I
cdns_pci_map_bus(struct pci_bus * bus,unsigned int devfn,int where)539f3e25911SKishon Vijay Abraham I static inline void __iomem *cdns_pci_map_bus(struct pci_bus *bus, unsigned int devfn,
540f3e25911SKishon Vijay Abraham I int where)
541f3e25911SKishon Vijay Abraham I {
542f3e25911SKishon Vijay Abraham I return NULL;
543f3e25911SKishon Vijay Abraham I }
544de80f95cSTom Joseph #endif
545de80f95cSTom Joseph
546de80f95cSTom Joseph #ifdef CONFIG_PCIE_CADENCE_EP
547de80f95cSTom Joseph int cdns_pcie_ep_setup(struct cdns_pcie_ep *ep);
548de80f95cSTom Joseph #else
cdns_pcie_ep_setup(struct cdns_pcie_ep * ep)549de80f95cSTom Joseph static inline int cdns_pcie_ep_setup(struct cdns_pcie_ep *ep)
550de80f95cSTom Joseph {
551de80f95cSTom Joseph return 0;
552de80f95cSTom Joseph }
553de80f95cSTom Joseph #endif
55409c24094SNadeem Athani
55509c24094SNadeem Athani void cdns_pcie_detect_quiet_min_delay_set(struct cdns_pcie *pcie);
55609c24094SNadeem Athani
557ec64e279SRob Herring void cdns_pcie_set_outbound_region(struct cdns_pcie *pcie, u8 busnr, u8 fn,
558de80f95cSTom Joseph u32 r, bool is_io,
559de80f95cSTom Joseph u64 cpu_addr, u64 pci_addr, size_t size);
560de80f95cSTom Joseph
561ec64e279SRob Herring void cdns_pcie_set_outbound_region_for_normal_msg(struct cdns_pcie *pcie,
562ec64e279SRob Herring u8 busnr, u8 fn,
563de80f95cSTom Joseph u32 r, u64 cpu_addr);
564de80f95cSTom Joseph
565de80f95cSTom Joseph void cdns_pcie_reset_outbound_region(struct cdns_pcie *pcie, u32 r);
566de80f95cSTom Joseph void cdns_pcie_disable_phy(struct cdns_pcie *pcie);
567de80f95cSTom Joseph int cdns_pcie_enable_phy(struct cdns_pcie *pcie);
568de80f95cSTom Joseph int cdns_pcie_init_phy(struct device *dev, struct cdns_pcie *pcie);
569de80f95cSTom Joseph extern const struct dev_pm_ops cdns_pcie_pm_ops;
570de80f95cSTom Joseph
571de80f95cSTom Joseph #endif /* _PCIE_CADENCE_H */
572