xref: /linux/drivers/pci/controller/dwc/pcie-designware.h (revision 3a2c4d55e32ad65efebdb6de44eef3bfa08bb49d)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Synopsys DesignWare PCIe host controller driver
4  *
5  * Copyright (C) 2013 Samsung Electronics Co., Ltd.
6  *		https://www.samsung.com
7  *
8  * Author: Jingoo Han <jg1.han@samsung.com>
9  */
10 
11 #ifndef _PCIE_DESIGNWARE_H
12 #define _PCIE_DESIGNWARE_H
13 
14 #include <linux/bitfield.h>
15 #include <linux/bitops.h>
16 #include <linux/clk.h>
17 #include <linux/dma-mapping.h>
18 #include <linux/dma/edma.h>
19 #include <linux/gpio/consumer.h>
20 #include <linux/irq.h>
21 #include <linux/msi.h>
22 #include <linux/pci.h>
23 #include <linux/pci-ecam.h>
24 #include <linux/reset.h>
25 
26 #include <linux/pci-epc.h>
27 #include <linux/pci-epf.h>
28 
29 #include "../../pci.h"
30 
31 /* DWC PCIe IP-core versions (native support since v4.70a) */
32 #define DW_PCIE_VER_365A		0x3336352a
33 #define DW_PCIE_VER_460A		0x3436302a
34 #define DW_PCIE_VER_470A		0x3437302a
35 #define DW_PCIE_VER_480A		0x3438302a
36 #define DW_PCIE_VER_490A		0x3439302a
37 #define DW_PCIE_VER_500A		0x3530302a
38 #define DW_PCIE_VER_510A		0x3531302a
39 #define DW_PCIE_VER_520A		0x3532302a
40 #define DW_PCIE_VER_540A		0x3534302a
41 #define DW_PCIE_VER_562A		0x3536322a
42 
43 #define __dw_pcie_ver_cmp(_pci, _ver, _op) \
44 	((_pci)->version _op DW_PCIE_VER_ ## _ver)
45 
46 #define dw_pcie_ver_is(_pci, _ver) __dw_pcie_ver_cmp(_pci, _ver, ==)
47 
48 #define dw_pcie_ver_is_ge(_pci, _ver) __dw_pcie_ver_cmp(_pci, _ver, >=)
49 
50 #define dw_pcie_ver_type_is(_pci, _ver, _type) \
51 	(__dw_pcie_ver_cmp(_pci, _ver, ==) && \
52 	 __dw_pcie_ver_cmp(_pci, TYPE_ ## _type, ==))
53 
54 #define dw_pcie_ver_type_is_ge(_pci, _ver, _type) \
55 	(__dw_pcie_ver_cmp(_pci, _ver, ==) && \
56 	 __dw_pcie_ver_cmp(_pci, TYPE_ ## _type, >=))
57 
58 /* DWC PCIe controller capabilities */
59 #define DW_PCIE_CAP_REQ_RES		0
60 #define DW_PCIE_CAP_IATU_UNROLL		1
61 #define DW_PCIE_CAP_CDM_CHECK		2
62 
63 #define dw_pcie_cap_is(_pci, _cap) \
64 	test_bit(DW_PCIE_CAP_ ## _cap, &(_pci)->caps)
65 
66 #define dw_pcie_cap_set(_pci, _cap) \
67 	set_bit(DW_PCIE_CAP_ ## _cap, &(_pci)->caps)
68 
69 /* Parameters for the waiting for iATU enabled routine */
70 #define LINK_WAIT_MAX_IATU_RETRIES	5
71 #define LINK_WAIT_IATU			9
72 
73 /* Synopsys-specific PCIe configuration registers */
74 #define PCIE_PORT_FORCE			0x708
75 /* Bit[7:0] LINK_NUM: Link Number. Not used for endpoint */
76 #define PORT_LINK_NUM_MASK		GENMASK(7, 0)
77 #define PORT_FORCE_DO_DESKEW_FOR_SRIS	BIT(23)
78 
79 #define PCIE_PORT_AFR			0x70C
80 #define PORT_AFR_N_FTS_MASK		GENMASK(15, 8)
81 #define PORT_AFR_N_FTS(n)		FIELD_PREP(PORT_AFR_N_FTS_MASK, n)
82 #define PORT_AFR_CC_N_FTS_MASK		GENMASK(23, 16)
83 #define PORT_AFR_CC_N_FTS(n)		FIELD_PREP(PORT_AFR_CC_N_FTS_MASK, n)
84 #define PORT_AFR_ENTER_ASPM		BIT(30)
85 #define PORT_AFR_L0S_ENTRANCE_LAT_SHIFT	24
86 #define PORT_AFR_L0S_ENTRANCE_LAT_MASK	GENMASK(26, 24)
87 #define PORT_AFR_L1_ENTRANCE_LAT_SHIFT	27
88 #define PORT_AFR_L1_ENTRANCE_LAT_MASK	GENMASK(29, 27)
89 
90 #define PCIE_PORT_LINK_CONTROL		0x710
91 #define PORT_LINK_DLL_LINK_EN		BIT(5)
92 #define PORT_LINK_FAST_LINK_MODE	BIT(7)
93 #define PORT_LINK_MODE_MASK		GENMASK(21, 16)
94 #define PORT_LINK_MODE(n)		FIELD_PREP(PORT_LINK_MODE_MASK, n)
95 #define PORT_LINK_MODE_1_LANES		PORT_LINK_MODE(0x1)
96 #define PORT_LINK_MODE_2_LANES		PORT_LINK_MODE(0x3)
97 #define PORT_LINK_MODE_4_LANES		PORT_LINK_MODE(0x7)
98 #define PORT_LINK_MODE_8_LANES		PORT_LINK_MODE(0xf)
99 #define PORT_LINK_MODE_16_LANES		PORT_LINK_MODE(0x1f)
100 
101 #define PCIE_PORT_LANE_SKEW		0x714
102 #define PORT_LANE_SKEW_INSERT_MASK	GENMASK(23, 0)
103 
104 /*
105  * PCIE_TIMER_CTRL_MAX_FUNC_NUM: Timer Control and Max Function Number
106  * Register.
107  *
108  * This register holds the ack frequency, latency, replay, fast link
109  * scaling timers, and max function number values.
110  *
111  * Bit[30:29] FAST_LINK_SCALING_FACTOR: Fast Link Timer Scaling Factor.
112  *   0x0 (SF_1024): Scaling Factor is 1024 (1ms is 1us).
113  *     When the LTSSM is in Config or L12 Entry State, 1ms
114  *     timer is 2us, 2ms timer is 4us and 3ms timer is 6us.
115  *   0x1 (SF_256): Scaling Factor is 256 (1ms is 4us)
116  *   0x2 (SF_64): Scaling Factor is 64 (1ms is 16us)
117  *   0x3 (SF_16): Scaling Factor is 16 (1ms is 64us)
118  */
119 #define PCIE_TIMER_CTRL_MAX_FUNC_NUM	0x718
120 #define PORT_FLT_SF_MASK	GENMASK(30, 29)
121 #define PORT_FLT_SF_VAL_1024	0x0
122 #define PORT_FLT_SF_VAL_256	0x1
123 #define PORT_FLT_SF_VAL_64	0x2
124 #define PORT_FLT_SF_VAL_16	0x3
125 
126 #define PCIE_PORT_DEBUG0		0x728
127 #define PORT_LOGIC_LTSSM_STATE_MASK	0x3f
128 #define PORT_LOGIC_LTSSM_STATE_L0	0x11
129 #define PCIE_PORT_DEBUG1		0x72C
130 #define PCIE_PORT_DEBUG1_LINK_UP		BIT(4)
131 #define PCIE_PORT_DEBUG1_LINK_IN_TRAINING	BIT(29)
132 
133 #define PCIE_LINK_WIDTH_SPEED_CONTROL	0x80C
134 #define PORT_LOGIC_N_FTS_MASK		GENMASK(7, 0)
135 #define PORT_LOGIC_SPEED_CHANGE		BIT(17)
136 #define PORT_LOGIC_LINK_WIDTH_MASK	GENMASK(12, 8)
137 #define PORT_LOGIC_LINK_WIDTH(n)	FIELD_PREP(PORT_LOGIC_LINK_WIDTH_MASK, n)
138 #define PORT_LOGIC_LINK_WIDTH_1_LANES	PORT_LOGIC_LINK_WIDTH(0x1)
139 #define PORT_LOGIC_LINK_WIDTH_2_LANES	PORT_LOGIC_LINK_WIDTH(0x2)
140 #define PORT_LOGIC_LINK_WIDTH_4_LANES	PORT_LOGIC_LINK_WIDTH(0x4)
141 #define PORT_LOGIC_LINK_WIDTH_8_LANES	PORT_LOGIC_LINK_WIDTH(0x8)
142 
143 #define PCIE_MSI_ADDR_LO		0x820
144 #define PCIE_MSI_ADDR_HI		0x824
145 #define PCIE_MSI_INTR0_ENABLE		0x828
146 #define PCIE_MSI_INTR0_MASK		0x82C
147 #define PCIE_MSI_INTR0_STATUS		0x830
148 
149 #define GEN3_RELATED_OFF			0x890
150 #define GEN3_RELATED_OFF_GEN3_ZRXDC_NONCOMPL	BIT(0)
151 #define GEN3_RELATED_OFF_EQ_PHASE_2_3		BIT(9)
152 #define GEN3_RELATED_OFF_RXEQ_RGRDLESS_RXTS	BIT(13)
153 #define GEN3_RELATED_OFF_GEN3_EQ_DISABLE	BIT(16)
154 #define GEN3_RELATED_OFF_RATE_SHADOW_SEL_SHIFT	24
155 #define GEN3_RELATED_OFF_RATE_SHADOW_SEL_MASK	GENMASK(25, 24)
156 
157 #define GEN3_EQ_CONTROL_OFF			0x8A8
158 #define GEN3_EQ_CONTROL_OFF_FB_MODE		GENMASK(3, 0)
159 #define GEN3_EQ_CONTROL_OFF_PHASE23_EXIT_MODE	BIT(4)
160 #define GEN3_EQ_CONTROL_OFF_PSET_REQ_VEC	GENMASK(23, 8)
161 #define GEN3_EQ_CONTROL_OFF_FOM_INC_INITIAL_EVAL	BIT(24)
162 
163 #define GEN3_EQ_FB_MODE_DIR_CHANGE_OFF		0x8AC
164 #define GEN3_EQ_FMDC_T_MIN_PHASE23		GENMASK(4, 0)
165 #define GEN3_EQ_FMDC_N_EVALS			GENMASK(9, 5)
166 #define GEN3_EQ_FMDC_MAX_PRE_CURSOR_DELTA	GENMASK(13, 10)
167 #define GEN3_EQ_FMDC_MAX_POST_CURSOR_DELTA	GENMASK(17, 14)
168 
169 #define COHERENCY_CONTROL_1_OFF			0x8E0
170 #define CFG_MEMTYPE_BOUNDARY_LOW_ADDR_MASK	GENMASK(31, 2)
171 #define CFG_MEMTYPE_VALUE			BIT(0)
172 
173 #define COHERENCY_CONTROL_2_OFF			0x8E4
174 #define COHERENCY_CONTROL_3_OFF			0x8E8
175 
176 #define PCIE_PORT_MULTI_LANE_CTRL	0x8C0
177 #define PORT_MLTI_UPCFG_SUPPORT		BIT(7)
178 
179 #define PCIE_VERSION_NUMBER		0x8F8
180 #define PCIE_VERSION_TYPE		0x8FC
181 
182 /*
183  * iATU inbound and outbound windows CSRs. Before the IP-core v4.80a each
184  * iATU region CSRs had been indirectly accessible by means of the dedicated
185  * viewport selector. The iATU/eDMA CSRs space was re-designed in DWC PCIe
186  * v4.80a in a way so the viewport was unrolled into the directly accessible
187  * iATU/eDMA CSRs space.
188  */
189 #define PCIE_ATU_VIEWPORT		0x900
190 #define PCIE_ATU_REGION_DIR_IB		BIT(31)
191 #define PCIE_ATU_REGION_DIR_OB		0
192 #define PCIE_ATU_VIEWPORT_BASE		0x904
193 #define PCIE_ATU_UNROLL_BASE(dir, index) \
194 	(((index) << 9) | ((dir == PCIE_ATU_REGION_DIR_IB) ? BIT(8) : 0))
195 #define PCIE_ATU_VIEWPORT_SIZE		0x2C
196 #define PCIE_ATU_REGION_CTRL1		0x000
197 #define PCIE_ATU_INCREASE_REGION_SIZE	BIT(13)
198 #define PCIE_ATU_TD			BIT(8)
199 #define PCIE_ATU_FUNC_NUM(pf)           ((pf) << 20)
200 #define PCIE_ATU_REGION_CTRL2		0x004
201 #define PCIE_ATU_ENABLE			BIT(31)
202 #define PCIE_ATU_BAR_MODE_ENABLE	BIT(30)
203 #define PCIE_ATU_CFG_SHIFT_MODE_ENABLE	BIT(28)
204 #define PCIE_ATU_INHIBIT_PAYLOAD	BIT(22)
205 #define PCIE_ATU_FUNC_NUM_MATCH_EN      BIT(19)
206 #define PCIE_ATU_LOWER_BASE		0x008
207 #define PCIE_ATU_UPPER_BASE		0x00C
208 #define PCIE_ATU_LIMIT			0x010
209 #define PCIE_ATU_LOWER_TARGET		0x014
210 #define PCIE_ATU_BUS(x)			FIELD_PREP(GENMASK(31, 24), x)
211 #define PCIE_ATU_DEV(x)			FIELD_PREP(GENMASK(23, 19), x)
212 #define PCIE_ATU_FUNC(x)		FIELD_PREP(GENMASK(18, 16), x)
213 #define PCIE_ATU_UPPER_TARGET		0x018
214 #define PCIE_ATU_UPPER_LIMIT		0x020
215 
216 #define PCIE_MISC_CONTROL_1_OFF		0x8BC
217 #define PCIE_DBI_RO_WR_EN		BIT(0)
218 
219 #define PCIE_MSIX_DOORBELL		0x948
220 #define PCIE_MSIX_DOORBELL_PF_SHIFT	24
221 
222 /*
223  * eDMA CSRs. DW PCIe IP-core v4.70a and older had the eDMA registers accessible
224  * over the Port Logic registers space. Afterwards the unrolled mapping was
225  * introduced so eDMA and iATU could be accessed via a dedicated registers
226  * space.
227  */
228 #define PCIE_DMA_VIEWPORT_BASE		0x970
229 #define PCIE_DMA_UNROLL_BASE		0x80000
230 #define PCIE_DMA_CTRL			0x008
231 #define PCIE_DMA_NUM_WR_CHAN		GENMASK(3, 0)
232 #define PCIE_DMA_NUM_RD_CHAN		GENMASK(19, 16)
233 
234 #define PCIE_PL_CHK_REG_CONTROL_STATUS			0xB20
235 #define PCIE_PL_CHK_REG_CHK_REG_START			BIT(0)
236 #define PCIE_PL_CHK_REG_CHK_REG_CONTINUOUS		BIT(1)
237 #define PCIE_PL_CHK_REG_CHK_REG_COMPARISON_ERROR	BIT(16)
238 #define PCIE_PL_CHK_REG_CHK_REG_LOGIC_ERROR		BIT(17)
239 #define PCIE_PL_CHK_REG_CHK_REG_COMPLETE		BIT(18)
240 
241 #define PCIE_PL_CHK_REG_ERR_ADDR			0xB28
242 
243 /*
244  * 16.0 GT/s (Gen 4) lane margining register definitions
245  */
246 #define GEN4_LANE_MARGINING_1_OFF		0xB80
247 #define MARGINING_MAX_VOLTAGE_OFFSET		GENMASK(29, 24)
248 #define MARGINING_NUM_VOLTAGE_STEPS		GENMASK(22, 16)
249 #define MARGINING_MAX_TIMING_OFFSET		GENMASK(13, 8)
250 #define MARGINING_NUM_TIMING_STEPS		GENMASK(5, 0)
251 
252 #define GEN4_LANE_MARGINING_2_OFF		0xB84
253 #define MARGINING_IND_ERROR_SAMPLER		BIT(28)
254 #define MARGINING_SAMPLE_REPORTING_METHOD	BIT(27)
255 #define MARGINING_IND_LEFT_RIGHT_TIMING		BIT(26)
256 #define MARGINING_IND_UP_DOWN_VOLTAGE		BIT(25)
257 #define MARGINING_VOLTAGE_SUPPORTED		BIT(24)
258 #define MARGINING_MAXLANES			GENMASK(20, 16)
259 #define MARGINING_SAMPLE_RATE_TIMING		GENMASK(13, 8)
260 #define MARGINING_SAMPLE_RATE_VOLTAGE		GENMASK(5, 0)
261 /*
262  * iATU Unroll-specific register definitions
263  * From 4.80 core version the address translation will be made by unroll
264  */
265 #define PCIE_ATU_UNR_REGION_CTRL1	0x00
266 #define PCIE_ATU_UNR_REGION_CTRL2	0x04
267 #define PCIE_ATU_UNR_LOWER_BASE		0x08
268 #define PCIE_ATU_UNR_UPPER_BASE		0x0C
269 #define PCIE_ATU_UNR_LOWER_LIMIT	0x10
270 #define PCIE_ATU_UNR_LOWER_TARGET	0x14
271 #define PCIE_ATU_UNR_UPPER_TARGET	0x18
272 #define PCIE_ATU_UNR_UPPER_LIMIT	0x20
273 
274 /*
275  * RAS-DES register definitions
276  */
277 #define PCIE_RAS_DES_EVENT_COUNTER_CONTROL	0x8
278 #define EVENT_COUNTER_ALL_CLEAR		0x3
279 #define EVENT_COUNTER_ENABLE_ALL	0x7
280 #define EVENT_COUNTER_ENABLE_SHIFT	2
281 #define EVENT_COUNTER_EVENT_SEL_MASK	GENMASK(7, 0)
282 #define EVENT_COUNTER_EVENT_SEL_SHIFT	16
283 #define EVENT_COUNTER_EVENT_Tx_L0S	0x2
284 #define EVENT_COUNTER_EVENT_Rx_L0S	0x3
285 #define EVENT_COUNTER_EVENT_L1		0x5
286 #define EVENT_COUNTER_EVENT_L1_1	0x7
287 #define EVENT_COUNTER_EVENT_L1_2	0x8
288 #define EVENT_COUNTER_GROUP_SEL_SHIFT	24
289 #define EVENT_COUNTER_GROUP_5		0x5
290 
291 #define PCIE_RAS_DES_EVENT_COUNTER_DATA		0xc
292 
293 /* PTM register definitions */
294 #define PTM_RES_REQ_CTRL		0x8
295 #define PTM_RES_CCONTEXT_VALID		BIT(0)
296 #define PTM_REQ_AUTO_UPDATE_ENABLED	BIT(0)
297 #define PTM_REQ_START_UPDATE		BIT(1)
298 
299 #define PTM_LOCAL_LSB			0x10
300 #define PTM_LOCAL_MSB			0x14
301 #define PTM_T1_T2_LSB			0x18
302 #define PTM_T1_T2_MSB			0x1c
303 #define PTM_T3_T4_LSB			0x28
304 #define PTM_T3_T4_MSB			0x2c
305 #define PTM_MASTER_LSB			0x38
306 #define PTM_MASTER_MSB			0x3c
307 
308 /*
309  * The default address offset between dbi_base and atu_base. Root controller
310  * drivers are not required to initialize atu_base if the offset matches this
311  * default; the driver core automatically derives atu_base from dbi_base using
312  * this offset, if atu_base not set.
313  */
314 #define DEFAULT_DBI_ATU_OFFSET (0x3 << 20)
315 #define DEFAULT_DBI_DMA_OFFSET PCIE_DMA_UNROLL_BASE
316 
317 #define MAX_MSI_IRQS			256
318 #define MAX_MSI_IRQS_PER_CTRL		32
319 #define MAX_MSI_CTRLS			(MAX_MSI_IRQS / MAX_MSI_IRQS_PER_CTRL)
320 #define MSI_REG_CTRL_BLOCK_SIZE		12
321 #define MSI_DEF_NUM_VECTORS		32
322 
323 /* Maximum number of inbound/outbound iATUs */
324 #define MAX_IATU_IN			256
325 #define MAX_IATU_OUT			256
326 
327 /* Default eDMA LLP memory size */
328 #define DMA_LLP_MEM_SIZE		PAGE_SIZE
329 
330 /* Common struct pci_epc_feature bits among DWC EP glue drivers */
331 #define DWC_EPC_COMMON_FEATURES		.dynamic_inbound_mapping = true, \
332 					.subrange_mapping = true
333 
334 struct dw_pcie;
335 struct dw_pcie_rp;
336 struct dw_pcie_ep;
337 
338 enum dw_pcie_device_mode {
339 	DW_PCIE_UNKNOWN_TYPE,
340 	DW_PCIE_EP_TYPE,
341 	DW_PCIE_LEG_EP_TYPE,
342 	DW_PCIE_RC_TYPE,
343 };
344 
345 enum dw_pcie_app_clk {
346 	DW_PCIE_DBI_CLK,
347 	DW_PCIE_MSTR_CLK,
348 	DW_PCIE_SLV_CLK,
349 	DW_PCIE_NUM_APP_CLKS
350 };
351 
352 enum dw_pcie_core_clk {
353 	DW_PCIE_PIPE_CLK,
354 	DW_PCIE_CORE_CLK,
355 	DW_PCIE_AUX_CLK,
356 	DW_PCIE_REF_CLK,
357 	DW_PCIE_NUM_CORE_CLKS
358 };
359 
360 enum dw_pcie_app_rst {
361 	DW_PCIE_DBI_RST,
362 	DW_PCIE_MSTR_RST,
363 	DW_PCIE_SLV_RST,
364 	DW_PCIE_NUM_APP_RSTS
365 };
366 
367 enum dw_pcie_core_rst {
368 	DW_PCIE_NON_STICKY_RST,
369 	DW_PCIE_STICKY_RST,
370 	DW_PCIE_CORE_RST,
371 	DW_PCIE_PIPE_RST,
372 	DW_PCIE_PHY_RST,
373 	DW_PCIE_HOT_RST,
374 	DW_PCIE_PWR_RST,
375 	DW_PCIE_NUM_CORE_RSTS
376 };
377 
378 enum dw_pcie_ltssm {
379 	/* Need to align with PCIE_PORT_DEBUG0 bits 0:5 */
380 	DW_PCIE_LTSSM_DETECT_QUIET = 0x0,
381 	DW_PCIE_LTSSM_DETECT_ACT = 0x1,
382 	DW_PCIE_LTSSM_POLL_ACTIVE = 0x2,
383 	DW_PCIE_LTSSM_POLL_COMPLIANCE = 0x3,
384 	DW_PCIE_LTSSM_POLL_CONFIG = 0x4,
385 	DW_PCIE_LTSSM_PRE_DETECT_QUIET = 0x5,
386 	DW_PCIE_LTSSM_DETECT_WAIT = 0x6,
387 	DW_PCIE_LTSSM_CFG_LINKWD_START = 0x7,
388 	DW_PCIE_LTSSM_CFG_LINKWD_ACEPT = 0x8,
389 	DW_PCIE_LTSSM_CFG_LANENUM_WAI = 0x9,
390 	DW_PCIE_LTSSM_CFG_LANENUM_ACEPT = 0xa,
391 	DW_PCIE_LTSSM_CFG_COMPLETE = 0xb,
392 	DW_PCIE_LTSSM_CFG_IDLE = 0xc,
393 	DW_PCIE_LTSSM_RCVRY_LOCK = 0xd,
394 	DW_PCIE_LTSSM_RCVRY_SPEED = 0xe,
395 	DW_PCIE_LTSSM_RCVRY_RCVRCFG = 0xf,
396 	DW_PCIE_LTSSM_RCVRY_IDLE = 0x10,
397 	DW_PCIE_LTSSM_L0 = 0x11,
398 	DW_PCIE_LTSSM_L0S = 0x12,
399 	DW_PCIE_LTSSM_L123_SEND_EIDLE = 0x13,
400 	DW_PCIE_LTSSM_L1_IDLE = 0x14,
401 	DW_PCIE_LTSSM_L2_IDLE = 0x15,
402 	DW_PCIE_LTSSM_L2_WAKE = 0x16,
403 	DW_PCIE_LTSSM_DISABLED_ENTRY = 0x17,
404 	DW_PCIE_LTSSM_DISABLED_IDLE = 0x18,
405 	DW_PCIE_LTSSM_DISABLED = 0x19,
406 	DW_PCIE_LTSSM_LPBK_ENTRY = 0x1a,
407 	DW_PCIE_LTSSM_LPBK_ACTIVE = 0x1b,
408 	DW_PCIE_LTSSM_LPBK_EXIT = 0x1c,
409 	DW_PCIE_LTSSM_LPBK_EXIT_TIMEOUT = 0x1d,
410 	DW_PCIE_LTSSM_HOT_RESET_ENTRY = 0x1e,
411 	DW_PCIE_LTSSM_HOT_RESET = 0x1f,
412 	DW_PCIE_LTSSM_RCVRY_EQ0 = 0x20,
413 	DW_PCIE_LTSSM_RCVRY_EQ1 = 0x21,
414 	DW_PCIE_LTSSM_RCVRY_EQ2 = 0x22,
415 	DW_PCIE_LTSSM_RCVRY_EQ3 = 0x23,
416 
417 	/* Vendor glue drivers provide pseudo L1 substates from get_ltssm() */
418 	DW_PCIE_LTSSM_L1_1 = 0x141,
419 	DW_PCIE_LTSSM_L1_2 = 0x142,
420 
421 	DW_PCIE_LTSSM_UNKNOWN = 0xFFFFFFFF,
422 };
423 
424 struct dw_pcie_ob_atu_cfg {
425 	int index;
426 	int type;
427 	u8 func_no;
428 	u8 code;
429 	u8 routing;
430 	u32 ctrl2;
431 	u64 parent_bus_addr;
432 	u64 pci_addr;
433 	u64 size;
434 };
435 
436 struct dw_pcie_host_ops {
437 	int (*init)(struct dw_pcie_rp *pp);
438 	void (*deinit)(struct dw_pcie_rp *pp);
439 	void (*post_init)(struct dw_pcie_rp *pp);
440 	int (*msi_init)(struct dw_pcie_rp *pp);
441 	void (*pme_turn_off)(struct dw_pcie_rp *pp);
442 };
443 
444 struct dw_pcie_rp {
445 	bool			use_imsi_rx:1;
446 	bool			keep_rp_msi_en:1;
447 	bool			cfg0_io_shared:1;
448 	u64			cfg0_base;
449 	void __iomem		*va_cfg0_base;
450 	u32			cfg0_size;
451 	resource_size_t		io_base;
452 	phys_addr_t		io_bus_addr;
453 	u32			io_size;
454 	int			irq;
455 	const struct dw_pcie_host_ops *ops;
456 	int			msi_irq[MAX_MSI_CTRLS];
457 	struct irq_domain	*irq_domain;
458 	dma_addr_t		msi_data;
459 	struct irq_chip		*msi_irq_chip;
460 	u32			num_vectors;
461 	u32			irq_mask[MAX_MSI_CTRLS];
462 	struct pci_host_bridge  *bridge;
463 	raw_spinlock_t		lock;
464 	DECLARE_BITMAP(msi_irq_in_use, MAX_MSI_IRQS);
465 	bool			use_atu_msg;
466 	int			msg_atu_index;
467 	struct resource		*msg_res;
468 	struct pci_eq_presets	presets;
469 	struct pci_config_window *cfg;
470 	bool			ecam_enabled;
471 	bool			native_ecam;
472 	bool                    skip_l23_ready;
473 	bool			skip_pwrctrl_off;
474 };
475 
476 struct dw_pcie_ep_ops {
477 	int	(*pre_init)(struct dw_pcie_ep *ep);
478 	int	(*init)(struct dw_pcie_ep *ep);
479 	int	(*raise_irq)(struct dw_pcie_ep *ep, u8 func_no,
480 			     unsigned int type, u16 interrupt_num);
481 	const struct pci_epc_features* (*get_features)(struct dw_pcie_ep *ep);
482 	/*
483 	 * Provide a method to implement the different func config space
484 	 * access for different platform, if different func have different
485 	 * offset, return the offset of func. if use write a register way
486 	 * return a 0, and implement code in callback function of platform
487 	 * driver.
488 	 */
489 	unsigned int (*get_dbi_offset)(struct dw_pcie_ep *ep, u8 func_no);
490 	unsigned int (*get_dbi2_offset)(struct dw_pcie_ep *ep, u8 func_no);
491 };
492 
493 struct dw_pcie_ep_func {
494 	struct list_head	list;
495 	u8			func_no;
496 	u8			msi_cap;	/* MSI capability offset */
497 	u8			msix_cap;	/* MSI-X capability offset */
498 	u8			bar_to_atu[PCI_STD_NUM_BARS];
499 	struct pci_epf_bar	*epf_bar[PCI_STD_NUM_BARS];
500 
501 	/* Only for Address Match Mode inbound iATU */
502 	u32			*ib_atu_indexes[PCI_STD_NUM_BARS];
503 	unsigned int		num_ib_atu_indexes[PCI_STD_NUM_BARS];
504 };
505 
506 struct dw_pcie_ep {
507 	struct pci_epc		*epc;
508 	struct list_head	func_list;
509 	const struct dw_pcie_ep_ops *ops;
510 	phys_addr_t		phys_base;
511 	size_t			addr_size;
512 	size_t			page_size;
513 	phys_addr_t		*outbound_addr;
514 	unsigned long		*ib_window_map;
515 	unsigned long		*ob_window_map;
516 	void __iomem		*msi_mem;
517 	phys_addr_t		msi_mem_phys;
518 
519 	/* MSI outbound iATU state */
520 	bool			msi_iatu_mapped;
521 	size_t			msi_iatu_mapped_offset;
522 	u64			msi_msg_addr;
523 	size_t			msi_map_size;
524 };
525 
526 struct dw_pcie_ops {
527 	u64	(*cpu_addr_fixup)(struct dw_pcie *pcie, u64 cpu_addr);
528 	u32	(*read_dbi)(struct dw_pcie *pcie, void __iomem *base, u32 reg,
529 			    size_t size);
530 	void	(*write_dbi)(struct dw_pcie *pcie, void __iomem *base, u32 reg,
531 			     size_t size, u32 val);
532 	void    (*write_dbi2)(struct dw_pcie *pcie, void __iomem *base, u32 reg,
533 			      size_t size, u32 val);
534 	bool	(*link_up)(struct dw_pcie *pcie);
535 	enum dw_pcie_ltssm (*get_ltssm)(struct dw_pcie *pcie);
536 	int	(*start_link)(struct dw_pcie *pcie);
537 	void	(*stop_link)(struct dw_pcie *pcie);
538 };
539 
540 struct debugfs_info {
541 	struct dentry		*debug_dir;
542 	void			*rasdes_info;
543 };
544 
545 struct dw_pcie {
546 	struct device		*dev;
547 	void __iomem		*dbi_base;
548 	resource_size_t		dbi_phys_addr;
549 	void __iomem		*dbi_base2;
550 	void __iomem		*atu_base;
551 	void __iomem		*elbi_base;
552 	resource_size_t		atu_phys_addr;
553 	size_t			atu_size;
554 	resource_size_t		parent_bus_offset;
555 	u32			num_ib_windows;
556 	u32			num_ob_windows;
557 	u32			region_align;
558 	u64			region_limit;
559 	struct dw_pcie_rp	pp;
560 	struct dw_pcie_ep	ep;
561 	const struct dw_pcie_ops *ops;
562 	u32			version;
563 	u32			type;
564 	unsigned long		caps;
565 	int			num_lanes;
566 	int			max_link_speed;
567 	u8			n_fts[2];
568 	struct dw_edma_chip	edma;
569 	phys_addr_t		edma_reg_phys;
570 	resource_size_t		edma_reg_size;
571 	bool			l1ss_support;	/* L1 PM Substates support */
572 	struct clk_bulk_data	app_clks[DW_PCIE_NUM_APP_CLKS];
573 	struct clk_bulk_data	core_clks[DW_PCIE_NUM_CORE_CLKS];
574 	struct reset_control_bulk_data	app_rsts[DW_PCIE_NUM_APP_RSTS];
575 	struct reset_control_bulk_data	core_rsts[DW_PCIE_NUM_CORE_RSTS];
576 	struct gpio_desc		*pe_rst;
577 	bool			suspended;
578 	struct debugfs_info	*debugfs;
579 	enum			dw_pcie_device_mode mode;
580 	u16			ptm_vsec_offset;
581 	struct pci_ptm_debugfs	*ptm_debugfs;
582 
583 	/*
584 	 * If iATU input addresses are offset from CPU physical addresses,
585 	 * we previously required .cpu_addr_fixup() to convert them.  We
586 	 * now rely on the devicetree instead.  If .cpu_addr_fixup()
587 	 * exists, we compare its results with devicetree.
588 	 *
589 	 * If .cpu_addr_fixup() does not exist, we assume the offset is
590 	 * zero and warn if devicetree claims otherwise.  If we know all
591 	 * devicetrees correctly describe the offset, set
592 	 * use_parent_dt_ranges to true to avoid this warning.
593 	 */
594 	bool			use_parent_dt_ranges;
595 };
596 
597 #define to_dw_pcie_from_pp(port) container_of((port), struct dw_pcie, pp)
598 
599 #define to_dw_pcie_from_ep(endpoint)   \
600 		container_of((endpoint), struct dw_pcie, ep)
601 
602 int dw_pcie_get_resources(struct dw_pcie *pci);
603 
604 void dw_pcie_version_detect(struct dw_pcie *pci);
605 
606 u8 dw_pcie_find_capability(struct dw_pcie *pci, u8 cap);
607 u16 dw_pcie_find_ext_capability(struct dw_pcie *pci, u8 cap);
608 void dw_pcie_remove_capability(struct dw_pcie *pci, u8 cap);
609 void dw_pcie_remove_ext_capability(struct dw_pcie *pci, u8 cap);
610 u16 dw_pcie_find_rasdes_capability(struct dw_pcie *pci);
611 u16 dw_pcie_find_ptm_capability(struct dw_pcie *pci);
612 
613 int dw_pcie_read(void __iomem *addr, int size, u32 *val);
614 int dw_pcie_write(void __iomem *addr, int size, u32 val);
615 
616 u32 dw_pcie_read_dbi(struct dw_pcie *pci, u32 reg, size_t size);
617 void dw_pcie_write_dbi(struct dw_pcie *pci, u32 reg, size_t size, u32 val);
618 void dw_pcie_write_dbi2(struct dw_pcie *pci, u32 reg, size_t size, u32 val);
619 bool dw_pcie_link_up(struct dw_pcie *pci);
620 void dw_pcie_upconfig_setup(struct dw_pcie *pci);
621 int dw_pcie_wait_for_link(struct dw_pcie *pci);
622 int dw_pcie_link_get_max_link_width(struct dw_pcie *pci);
623 int dw_pcie_prog_outbound_atu(struct dw_pcie *pci,
624 			      const struct dw_pcie_ob_atu_cfg *atu);
625 int dw_pcie_prog_inbound_atu(struct dw_pcie *pci, int index, int type,
626 			     u64 parent_bus_addr, u64 pci_addr, u64 size);
627 int dw_pcie_prog_ep_inbound_atu(struct dw_pcie *pci, u8 func_no, int index,
628 				int type, u64 parent_bus_addr,
629 				u8 bar, size_t size);
630 void dw_pcie_disable_atu(struct dw_pcie *pci, u32 dir, int index);
631 void dw_pcie_hide_unsupported_l1ss(struct dw_pcie *pci);
632 void dw_pcie_program_t_power_on(struct dw_pcie *pci, u32 t_power_on);
633 void dw_pcie_setup(struct dw_pcie *pci);
634 void dw_pcie_iatu_detect(struct dw_pcie *pci);
635 int dw_pcie_edma_detect(struct dw_pcie *pci);
636 void dw_pcie_edma_remove(struct dw_pcie *pci);
637 resource_size_t dw_pcie_parent_bus_offset(struct dw_pcie *pci,
638 					  const char *reg_name,
639 					  resource_size_t cpu_phy_addr);
640 
641 static inline void dw_pcie_writel_dbi(struct dw_pcie *pci, u32 reg, u32 val)
642 {
643 	dw_pcie_write_dbi(pci, reg, 0x4, val);
644 }
645 
646 static inline u32 dw_pcie_readl_dbi(struct dw_pcie *pci, u32 reg)
647 {
648 	return dw_pcie_read_dbi(pci, reg, 0x4);
649 }
650 
651 static inline void dw_pcie_writew_dbi(struct dw_pcie *pci, u32 reg, u16 val)
652 {
653 	dw_pcie_write_dbi(pci, reg, 0x2, val);
654 }
655 
656 static inline u16 dw_pcie_readw_dbi(struct dw_pcie *pci, u32 reg)
657 {
658 	return dw_pcie_read_dbi(pci, reg, 0x2);
659 }
660 
661 static inline void dw_pcie_writeb_dbi(struct dw_pcie *pci, u32 reg, u8 val)
662 {
663 	dw_pcie_write_dbi(pci, reg, 0x1, val);
664 }
665 
666 static inline u8 dw_pcie_readb_dbi(struct dw_pcie *pci, u32 reg)
667 {
668 	return dw_pcie_read_dbi(pci, reg, 0x1);
669 }
670 
671 static inline void dw_pcie_writel_dbi2(struct dw_pcie *pci, u32 reg, u32 val)
672 {
673 	dw_pcie_write_dbi2(pci, reg, 0x4, val);
674 }
675 
676 static inline int dw_pcie_read_cfg_byte(struct dw_pcie *pci, int where,
677 					u8 *val)
678 {
679 	*val = dw_pcie_readb_dbi(pci, where);
680 	return PCIBIOS_SUCCESSFUL;
681 }
682 
683 static inline int dw_pcie_read_cfg_word(struct dw_pcie *pci, int where,
684 					u16 *val)
685 {
686 	*val = dw_pcie_readw_dbi(pci, where);
687 	return PCIBIOS_SUCCESSFUL;
688 }
689 
690 static inline int dw_pcie_read_cfg_dword(struct dw_pcie *pci, int where,
691 					 u32 *val)
692 {
693 	*val = dw_pcie_readl_dbi(pci, where);
694 	return PCIBIOS_SUCCESSFUL;
695 }
696 
697 static inline unsigned int dw_pcie_ep_get_dbi_offset(struct dw_pcie_ep *ep,
698 						     u8 func_no)
699 {
700 	unsigned int dbi_offset = 0;
701 
702 	if (ep->ops->get_dbi_offset)
703 		dbi_offset = ep->ops->get_dbi_offset(ep, func_no);
704 
705 	return dbi_offset;
706 }
707 
708 static inline u32 dw_pcie_ep_read_dbi(struct dw_pcie_ep *ep, u8 func_no,
709 				      u32 reg, size_t size)
710 {
711 	unsigned int offset = dw_pcie_ep_get_dbi_offset(ep, func_no);
712 	struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
713 
714 	return dw_pcie_read_dbi(pci, offset + reg, size);
715 }
716 
717 static inline void dw_pcie_ep_write_dbi(struct dw_pcie_ep *ep, u8 func_no,
718 					u32 reg, size_t size, u32 val)
719 {
720 	unsigned int offset = dw_pcie_ep_get_dbi_offset(ep, func_no);
721 	struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
722 
723 	dw_pcie_write_dbi(pci, offset + reg, size, val);
724 }
725 
726 static inline void dw_pcie_ep_writel_dbi(struct dw_pcie_ep *ep, u8 func_no,
727 					 u32 reg, u32 val)
728 {
729 	dw_pcie_ep_write_dbi(ep, func_no, reg, 0x4, val);
730 }
731 
732 static inline u32 dw_pcie_ep_readl_dbi(struct dw_pcie_ep *ep, u8 func_no,
733 				       u32 reg)
734 {
735 	return dw_pcie_ep_read_dbi(ep, func_no, reg, 0x4);
736 }
737 
738 static inline void dw_pcie_ep_writew_dbi(struct dw_pcie_ep *ep, u8 func_no,
739 					 u32 reg, u16 val)
740 {
741 	dw_pcie_ep_write_dbi(ep, func_no, reg, 0x2, val);
742 }
743 
744 static inline u16 dw_pcie_ep_readw_dbi(struct dw_pcie_ep *ep, u8 func_no,
745 				       u32 reg)
746 {
747 	return dw_pcie_ep_read_dbi(ep, func_no, reg, 0x2);
748 }
749 
750 static inline void dw_pcie_ep_writeb_dbi(struct dw_pcie_ep *ep, u8 func_no,
751 					 u32 reg, u8 val)
752 {
753 	dw_pcie_ep_write_dbi(ep, func_no, reg, 0x1, val);
754 }
755 
756 static inline u8 dw_pcie_ep_readb_dbi(struct dw_pcie_ep *ep, u8 func_no,
757 				      u32 reg)
758 {
759 	return dw_pcie_ep_read_dbi(ep, func_no, reg, 0x1);
760 }
761 
762 static inline int dw_pcie_ep_read_cfg_byte(struct dw_pcie_ep *ep, u8 func_no,
763 					   int where, u8 *val)
764 {
765 	*val = dw_pcie_ep_readb_dbi(ep, func_no, where);
766 	return PCIBIOS_SUCCESSFUL;
767 }
768 
769 static inline int dw_pcie_ep_read_cfg_word(struct dw_pcie_ep *ep, u8 func_no,
770 					   int where, u16 *val)
771 {
772 	*val = dw_pcie_ep_readw_dbi(ep, func_no, where);
773 	return PCIBIOS_SUCCESSFUL;
774 }
775 
776 static inline int dw_pcie_ep_read_cfg_dword(struct dw_pcie_ep *ep, u8 func_no,
777 					    int where, u32 *val)
778 {
779 	*val = dw_pcie_ep_readl_dbi(ep, func_no, where);
780 	return PCIBIOS_SUCCESSFUL;
781 }
782 
783 static inline unsigned int dw_pcie_ep_get_dbi2_offset(struct dw_pcie_ep *ep,
784 						      u8 func_no)
785 {
786 	unsigned int dbi2_offset = 0;
787 
788 	if (ep->ops->get_dbi2_offset)
789 		dbi2_offset = ep->ops->get_dbi2_offset(ep, func_no);
790 	else if (ep->ops->get_dbi_offset)     /* for backward compatibility */
791 		dbi2_offset = ep->ops->get_dbi_offset(ep, func_no);
792 
793 	return dbi2_offset;
794 }
795 
796 static inline void dw_pcie_ep_write_dbi2(struct dw_pcie_ep *ep, u8 func_no,
797 					 u32 reg, size_t size, u32 val)
798 {
799 	unsigned int offset = dw_pcie_ep_get_dbi2_offset(ep, func_no);
800 	struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
801 
802 	dw_pcie_write_dbi2(pci, offset + reg, size, val);
803 }
804 
805 static inline void dw_pcie_ep_writel_dbi2(struct dw_pcie_ep *ep, u8 func_no,
806 					  u32 reg, u32 val)
807 {
808 	dw_pcie_ep_write_dbi2(ep, func_no, reg, 0x4, val);
809 }
810 
811 static inline void dw_pcie_dbi_ro_wr_en(struct dw_pcie *pci)
812 {
813 	u32 reg;
814 	u32 val;
815 
816 	reg = PCIE_MISC_CONTROL_1_OFF;
817 	val = dw_pcie_readl_dbi(pci, reg);
818 	val |= PCIE_DBI_RO_WR_EN;
819 	dw_pcie_writel_dbi(pci, reg, val);
820 }
821 
822 static inline void dw_pcie_dbi_ro_wr_dis(struct dw_pcie *pci)
823 {
824 	u32 reg;
825 	u32 val;
826 
827 	reg = PCIE_MISC_CONTROL_1_OFF;
828 	val = dw_pcie_readl_dbi(pci, reg);
829 	val &= ~PCIE_DBI_RO_WR_EN;
830 	dw_pcie_writel_dbi(pci, reg, val);
831 }
832 
833 static inline int dw_pcie_start_link(struct dw_pcie *pci)
834 {
835 	if (pci->ops && pci->ops->start_link)
836 		return pci->ops->start_link(pci);
837 
838 	return 0;
839 }
840 
841 static inline void dw_pcie_stop_link(struct dw_pcie *pci)
842 {
843 	if (pci->ops && pci->ops->stop_link)
844 		pci->ops->stop_link(pci);
845 }
846 
847 static inline enum dw_pcie_ltssm dw_pcie_get_ltssm(struct dw_pcie *pci)
848 {
849 	u32 val;
850 
851 	if (pci->ops && pci->ops->get_ltssm)
852 		return pci->ops->get_ltssm(pci);
853 
854 	val = dw_pcie_readl_dbi(pci, PCIE_PORT_DEBUG0);
855 
856 	return (enum dw_pcie_ltssm)FIELD_GET(PORT_LOGIC_LTSSM_STATE_MASK, val);
857 }
858 
859 const char *dw_pcie_ltssm_status_string(enum dw_pcie_ltssm ltssm);
860 
861 #ifdef CONFIG_PCIE_DW_HOST
862 int dw_pcie_suspend_noirq(struct dw_pcie *pci);
863 int dw_pcie_resume_noirq(struct dw_pcie *pci);
864 void dw_handle_msi_irq(struct dw_pcie_rp *pp);
865 void dw_pcie_msi_init(struct dw_pcie_rp *pp);
866 int dw_pcie_msi_host_init(struct dw_pcie_rp *pp);
867 void dw_pcie_free_msi(struct dw_pcie_rp *pp);
868 int dw_pcie_setup_rc(struct dw_pcie_rp *pp);
869 int dw_pcie_host_init(struct dw_pcie_rp *pp);
870 void dw_pcie_host_deinit(struct dw_pcie_rp *pp);
871 int dw_pcie_allocate_domains(struct dw_pcie_rp *pp);
872 void __iomem *dw_pcie_own_conf_map_bus(struct pci_bus *bus, unsigned int devfn,
873 				       int where);
874 #else
875 static inline int dw_pcie_suspend_noirq(struct dw_pcie *pci)
876 {
877 	return 0;
878 }
879 
880 static inline int dw_pcie_resume_noirq(struct dw_pcie *pci)
881 {
882 	return 0;
883 }
884 
885 static inline void dw_handle_msi_irq(struct dw_pcie_rp *pp) { }
886 
887 static inline void dw_pcie_msi_init(struct dw_pcie_rp *pp)
888 { }
889 
890 static inline int dw_pcie_msi_host_init(struct dw_pcie_rp *pp)
891 {
892 	return -ENODEV;
893 }
894 
895 static inline void dw_pcie_free_msi(struct dw_pcie_rp *pp)
896 { }
897 
898 static inline int dw_pcie_setup_rc(struct dw_pcie_rp *pp)
899 {
900 	return 0;
901 }
902 
903 static inline int dw_pcie_host_init(struct dw_pcie_rp *pp)
904 {
905 	return 0;
906 }
907 
908 static inline void dw_pcie_host_deinit(struct dw_pcie_rp *pp)
909 {
910 }
911 
912 static inline int dw_pcie_allocate_domains(struct dw_pcie_rp *pp)
913 {
914 	return 0;
915 }
916 static inline void __iomem *dw_pcie_own_conf_map_bus(struct pci_bus *bus,
917 						     unsigned int devfn,
918 						     int where)
919 {
920 	return NULL;
921 }
922 #endif
923 
924 #ifdef CONFIG_PCIE_DW_EP
925 void dw_pcie_ep_linkup(struct dw_pcie_ep *ep);
926 void dw_pcie_ep_linkdown(struct dw_pcie_ep *ep);
927 int dw_pcie_ep_init(struct dw_pcie_ep *ep);
928 int dw_pcie_ep_init_registers(struct dw_pcie_ep *ep);
929 void dw_pcie_ep_deinit(struct dw_pcie_ep *ep);
930 void dw_pcie_ep_cleanup(struct dw_pcie_ep *ep);
931 int dw_pcie_ep_raise_intx_irq(struct dw_pcie_ep *ep, u8 func_no);
932 int dw_pcie_ep_raise_msi_irq(struct dw_pcie_ep *ep, u8 func_no,
933 			     u8 interrupt_num);
934 int dw_pcie_ep_raise_msix_irq(struct dw_pcie_ep *ep, u8 func_no,
935 			     u16 interrupt_num);
936 int dw_pcie_ep_raise_msix_irq_doorbell(struct dw_pcie_ep *ep, u8 func_no,
937 				       u16 interrupt_num);
938 void dw_pcie_ep_reset_bar(struct dw_pcie *pci, enum pci_barno bar);
939 struct dw_pcie_ep_func *
940 dw_pcie_ep_get_func_from_ep(struct dw_pcie_ep *ep, u8 func_no);
941 #else
942 static inline void dw_pcie_ep_linkup(struct dw_pcie_ep *ep)
943 {
944 }
945 
946 static inline void dw_pcie_ep_linkdown(struct dw_pcie_ep *ep)
947 {
948 }
949 
950 static inline int dw_pcie_ep_init(struct dw_pcie_ep *ep)
951 {
952 	return 0;
953 }
954 
955 static inline int dw_pcie_ep_init_registers(struct dw_pcie_ep *ep)
956 {
957 	return 0;
958 }
959 
960 static inline void dw_pcie_ep_deinit(struct dw_pcie_ep *ep)
961 {
962 }
963 
964 static inline void dw_pcie_ep_cleanup(struct dw_pcie_ep *ep)
965 {
966 }
967 
968 static inline int dw_pcie_ep_raise_intx_irq(struct dw_pcie_ep *ep, u8 func_no)
969 {
970 	return 0;
971 }
972 
973 static inline int dw_pcie_ep_raise_msi_irq(struct dw_pcie_ep *ep, u8 func_no,
974 					   u8 interrupt_num)
975 {
976 	return 0;
977 }
978 
979 static inline int dw_pcie_ep_raise_msix_irq(struct dw_pcie_ep *ep, u8 func_no,
980 					   u16 interrupt_num)
981 {
982 	return 0;
983 }
984 
985 static inline int dw_pcie_ep_raise_msix_irq_doorbell(struct dw_pcie_ep *ep,
986 						     u8 func_no,
987 						     u16 interrupt_num)
988 {
989 	return 0;
990 }
991 
992 static inline void dw_pcie_ep_reset_bar(struct dw_pcie *pci, enum pci_barno bar)
993 {
994 }
995 
996 static inline struct dw_pcie_ep_func *
997 dw_pcie_ep_get_func_from_ep(struct dw_pcie_ep *ep, u8 func_no)
998 {
999 	return NULL;
1000 }
1001 #endif
1002 
1003 #ifdef CONFIG_PCIE_DW_DEBUGFS
1004 void dwc_pcie_debugfs_init(struct dw_pcie *pci, enum dw_pcie_device_mode mode);
1005 void dwc_pcie_debugfs_deinit(struct dw_pcie *pci);
1006 #else
1007 static inline void dwc_pcie_debugfs_init(struct dw_pcie *pci,
1008 					 enum dw_pcie_device_mode mode)
1009 {
1010 }
1011 static inline void dwc_pcie_debugfs_deinit(struct dw_pcie *pci)
1012 {
1013 }
1014 #endif
1015 
1016 #endif /* _PCIE_DESIGNWARE_H */
1017