GNU Linux-libre 4.14.254-gnu1
[releases.git] / drivers / pci / host / pci-aardvark.c
1 /*
2  * Driver for the Aardvark PCIe controller, used on Marvell Armada
3  * 3700.
4  *
5  * Copyright (C) 2016 Marvell
6  *
7  * Author: Hezi Shahmoon <hezi.shahmoon@marvell.com>
8  *
9  * This file is licensed under the terms of the GNU General Public
10  * License version 2.  This program is licensed "as is" without any
11  * warranty of any kind, whether express or implied.
12  */
13
14 #include <linux/delay.h>
15 #include <linux/interrupt.h>
16 #include <linux/irq.h>
17 #include <linux/irqdomain.h>
18 #include <linux/kernel.h>
19 #include <linux/pci.h>
20 #include <linux/init.h>
21 #include <linux/platform_device.h>
22 #include <linux/of_address.h>
23 #include <linux/of_pci.h>
24
25 /* PCIe core registers */
26 #define PCIE_CORE_CMD_STATUS_REG                                0x4
27 #define     PCIE_CORE_CMD_IO_ACCESS_EN                          BIT(0)
28 #define     PCIE_CORE_CMD_MEM_ACCESS_EN                         BIT(1)
29 #define     PCIE_CORE_CMD_MEM_IO_REQ_EN                         BIT(2)
30 #define PCIE_CORE_DEV_CTRL_STATS_REG                            0xc8
31 #define     PCIE_CORE_DEV_CTRL_STATS_RELAX_ORDER_DISABLE        (0 << 4)
32 #define     PCIE_CORE_DEV_CTRL_STATS_MAX_PAYLOAD_SZ_SHIFT       5
33 #define     PCIE_CORE_DEV_CTRL_STATS_SNOOP_DISABLE              (0 << 11)
34 #define     PCIE_CORE_DEV_CTRL_STATS_MAX_RD_REQ_SIZE_SHIFT      12
35 #define     PCIE_CORE_DEV_CTRL_STATS_MAX_RD_REQ_SZ              0x2
36 #define PCIE_CORE_LINK_CTRL_STAT_REG                            0xd0
37 #define     PCIE_CORE_LINK_L0S_ENTRY                            BIT(0)
38 #define     PCIE_CORE_LINK_TRAINING                             BIT(5)
39 #define     PCIE_CORE_LINK_WIDTH_SHIFT                          20
40 #define PCIE_CORE_ERR_CAPCTL_REG                                0x118
41 #define     PCIE_CORE_ERR_CAPCTL_ECRC_CHK_TX                    BIT(5)
42 #define     PCIE_CORE_ERR_CAPCTL_ECRC_CHK_TX_EN                 BIT(6)
43 #define     PCIE_CORE_ERR_CAPCTL_ECRC_CHCK                      BIT(7)
44 #define     PCIE_CORE_ERR_CAPCTL_ECRC_CHCK_RCV                  BIT(8)
45
46 /* PIO registers base address and register offsets */
47 #define PIO_BASE_ADDR                           0x4000
48 #define PIO_CTRL                                (PIO_BASE_ADDR + 0x0)
49 #define   PIO_CTRL_TYPE_MASK                    GENMASK(3, 0)
50 #define   PIO_CTRL_ADDR_WIN_DISABLE             BIT(24)
51 #define PIO_STAT                                (PIO_BASE_ADDR + 0x4)
52 #define   PIO_COMPLETION_STATUS_SHIFT           7
53 #define   PIO_COMPLETION_STATUS_MASK            GENMASK(9, 7)
54 #define   PIO_COMPLETION_STATUS_OK              0
55 #define   PIO_COMPLETION_STATUS_UR              1
56 #define   PIO_COMPLETION_STATUS_CRS             2
57 #define   PIO_COMPLETION_STATUS_CA              4
58 #define   PIO_NON_POSTED_REQ                    BIT(10)
59 #define   PIO_ERR_STATUS                        BIT(11)
60 #define PIO_ADDR_LS                             (PIO_BASE_ADDR + 0x8)
61 #define PIO_ADDR_MS                             (PIO_BASE_ADDR + 0xc)
62 #define PIO_WR_DATA                             (PIO_BASE_ADDR + 0x10)
63 #define PIO_WR_DATA_STRB                        (PIO_BASE_ADDR + 0x14)
64 #define PIO_RD_DATA                             (PIO_BASE_ADDR + 0x18)
65 #define PIO_START                               (PIO_BASE_ADDR + 0x1c)
66 #define PIO_ISR                                 (PIO_BASE_ADDR + 0x20)
67 #define PIO_ISRM                                (PIO_BASE_ADDR + 0x24)
68
69 /* Aardvark Control registers */
70 #define CONTROL_BASE_ADDR                       0x4800
71 #define PCIE_CORE_CTRL0_REG                     (CONTROL_BASE_ADDR + 0x0)
72 #define     PCIE_GEN_SEL_MSK                    0x3
73 #define     PCIE_GEN_SEL_SHIFT                  0x0
74 #define     SPEED_GEN_1                         0
75 #define     SPEED_GEN_2                         1
76 #define     SPEED_GEN_3                         2
77 #define     IS_RC_MSK                           1
78 #define     IS_RC_SHIFT                         2
79 #define     LANE_CNT_MSK                        0x18
80 #define     LANE_CNT_SHIFT                      0x3
81 #define     LANE_COUNT_1                        (0 << LANE_CNT_SHIFT)
82 #define     LANE_COUNT_2                        (1 << LANE_CNT_SHIFT)
83 #define     LANE_COUNT_4                        (2 << LANE_CNT_SHIFT)
84 #define     LANE_COUNT_8                        (3 << LANE_CNT_SHIFT)
85 #define     LINK_TRAINING_EN                    BIT(6)
86 #define     LEGACY_INTA                         BIT(28)
87 #define     LEGACY_INTB                         BIT(29)
88 #define     LEGACY_INTC                         BIT(30)
89 #define     LEGACY_INTD                         BIT(31)
90 #define PCIE_CORE_CTRL1_REG                     (CONTROL_BASE_ADDR + 0x4)
91 #define     HOT_RESET_GEN                       BIT(0)
92 #define PCIE_CORE_CTRL2_REG                     (CONTROL_BASE_ADDR + 0x8)
93 #define     PCIE_CORE_CTRL2_RESERVED            0x7
94 #define     PCIE_CORE_CTRL2_TD_ENABLE           BIT(4)
95 #define     PCIE_CORE_CTRL2_STRICT_ORDER_ENABLE BIT(5)
96 #define     PCIE_CORE_CTRL2_OB_WIN_ENABLE       BIT(6)
97 #define     PCIE_CORE_CTRL2_MSI_ENABLE          BIT(10)
98 #define PCIE_ISR0_REG                           (CONTROL_BASE_ADDR + 0x40)
99 #define PCIE_ISR0_MASK_REG                      (CONTROL_BASE_ADDR + 0x44)
100 #define     PCIE_ISR0_MSI_INT_PENDING           BIT(24)
101 #define     PCIE_ISR0_INTX_ASSERT(val)          BIT(16 + (val))
102 #define     PCIE_ISR0_INTX_DEASSERT(val)        BIT(20 + (val))
103 #define     PCIE_ISR0_ALL_MASK                  GENMASK(26, 0)
104 #define PCIE_ISR1_REG                           (CONTROL_BASE_ADDR + 0x48)
105 #define PCIE_ISR1_MASK_REG                      (CONTROL_BASE_ADDR + 0x4C)
106 #define     PCIE_ISR1_POWER_STATE_CHANGE        BIT(4)
107 #define     PCIE_ISR1_FLUSH                     BIT(5)
108 #define     PCIE_ISR1_INTX_ASSERT(val)          BIT(8 + (val))
109 #define     PCIE_ISR1_ALL_MASK                  GENMASK(11, 4)
110 #define PCIE_MSI_ADDR_LOW_REG                   (CONTROL_BASE_ADDR + 0x50)
111 #define PCIE_MSI_ADDR_HIGH_REG                  (CONTROL_BASE_ADDR + 0x54)
112 #define PCIE_MSI_STATUS_REG                     (CONTROL_BASE_ADDR + 0x58)
113 #define PCIE_MSI_MASK_REG                       (CONTROL_BASE_ADDR + 0x5C)
114 #define PCIE_MSI_PAYLOAD_REG                    (CONTROL_BASE_ADDR + 0x9C)
115
116 /* PCIe window configuration */
117 #define OB_WIN_BASE_ADDR                        0x4c00
118 #define OB_WIN_BLOCK_SIZE                       0x20
119 #define OB_WIN_REG_ADDR(win, offset)            (OB_WIN_BASE_ADDR + \
120                                                  OB_WIN_BLOCK_SIZE * (win) + \
121                                                  (offset))
122 #define OB_WIN_MATCH_LS(win)                    OB_WIN_REG_ADDR(win, 0x00)
123 #define OB_WIN_MATCH_MS(win)                    OB_WIN_REG_ADDR(win, 0x04)
124 #define OB_WIN_REMAP_LS(win)                    OB_WIN_REG_ADDR(win, 0x08)
125 #define OB_WIN_REMAP_MS(win)                    OB_WIN_REG_ADDR(win, 0x0c)
126 #define OB_WIN_MASK_LS(win)                     OB_WIN_REG_ADDR(win, 0x10)
127 #define OB_WIN_MASK_MS(win)                     OB_WIN_REG_ADDR(win, 0x14)
128 #define OB_WIN_ACTIONS(win)                     OB_WIN_REG_ADDR(win, 0x18)
129
130 /* PCIe window types */
131 #define OB_PCIE_MEM                             0x0
132 #define OB_PCIE_IO                              0x4
133
134 /* LMI registers base address and register offsets */
135 #define LMI_BASE_ADDR                           0x6000
136 #define CFG_REG                                 (LMI_BASE_ADDR + 0x0)
137 #define     LTSSM_SHIFT                         24
138 #define     LTSSM_MASK                          0x3f
139 #define     LTSSM_L0                            0x10
140 #define     RC_BAR_CONFIG                       0x300
141
142 /* PCIe core controller registers */
143 #define CTRL_CORE_BASE_ADDR                     0x18000
144 #define CTRL_CONFIG_REG                         (CTRL_CORE_BASE_ADDR + 0x0)
145 #define     CTRL_MODE_SHIFT                     0x0
146 #define     CTRL_MODE_MASK                      0x1
147 #define     PCIE_CORE_MODE_DIRECT               0x0
148 #define     PCIE_CORE_MODE_COMMAND              0x1
149
150 /* PCIe Central Interrupts Registers */
151 #define CENTRAL_INT_BASE_ADDR                   0x1b000
152 #define HOST_CTRL_INT_STATUS_REG                (CENTRAL_INT_BASE_ADDR + 0x0)
153 #define HOST_CTRL_INT_MASK_REG                  (CENTRAL_INT_BASE_ADDR + 0x4)
154 #define     PCIE_IRQ_CMDQ_INT                   BIT(0)
155 #define     PCIE_IRQ_MSI_STATUS_INT             BIT(1)
156 #define     PCIE_IRQ_CMD_SENT_DONE              BIT(3)
157 #define     PCIE_IRQ_DMA_INT                    BIT(4)
158 #define     PCIE_IRQ_IB_DXFERDONE               BIT(5)
159 #define     PCIE_IRQ_OB_DXFERDONE               BIT(6)
160 #define     PCIE_IRQ_OB_RXFERDONE               BIT(7)
161 #define     PCIE_IRQ_COMPQ_INT                  BIT(12)
162 #define     PCIE_IRQ_DIR_RD_DDR_DET             BIT(13)
163 #define     PCIE_IRQ_DIR_WR_DDR_DET             BIT(14)
164 #define     PCIE_IRQ_CORE_INT                   BIT(16)
165 #define     PCIE_IRQ_CORE_INT_PIO               BIT(17)
166 #define     PCIE_IRQ_DPMU_INT                   BIT(18)
167 #define     PCIE_IRQ_PCIE_MIS_INT               BIT(19)
168 #define     PCIE_IRQ_MSI_INT1_DET               BIT(20)
169 #define     PCIE_IRQ_MSI_INT2_DET               BIT(21)
170 #define     PCIE_IRQ_RC_DBELL_DET               BIT(22)
171 #define     PCIE_IRQ_EP_STATUS                  BIT(23)
172 #define     PCIE_IRQ_ALL_MASK                   0xfff0fb
173 #define     PCIE_IRQ_ENABLE_INTS_MASK           PCIE_IRQ_CORE_INT
174
175 /* Transaction types */
176 #define PCIE_CONFIG_RD_TYPE0                    0x8
177 #define PCIE_CONFIG_RD_TYPE1                    0x9
178 #define PCIE_CONFIG_WR_TYPE0                    0xa
179 #define PCIE_CONFIG_WR_TYPE1                    0xb
180
181 #define PCIE_CONF_BUS(bus)                      (((bus) & 0xff) << 20)
182 #define PCIE_CONF_DEV(dev)                      (((dev) & 0x1f) << 15)
183 #define PCIE_CONF_FUNC(fun)                     (((fun) & 0x7)  << 12)
184 #define PCIE_CONF_REG(reg)                      ((reg) & 0xffc)
185 #define PCIE_CONF_ADDR(bus, devfn, where)       \
186         (PCIE_CONF_BUS(bus) | PCIE_CONF_DEV(PCI_SLOT(devfn))    | \
187          PCIE_CONF_FUNC(PCI_FUNC(devfn)) | PCIE_CONF_REG(where))
188
189 #define PIO_RETRY_CNT                   750000 /* 1.5 s */
190 #define PIO_RETRY_DELAY                 2 /* 2 us*/
191
192 #define LINK_WAIT_MAX_RETRIES           10
193 #define LINK_WAIT_USLEEP_MIN            90000
194 #define LINK_WAIT_USLEEP_MAX            100000
195
196 #define MSI_IRQ_NUM                     32
197
198 struct advk_pcie {
199         struct platform_device *pdev;
200         void __iomem *base;
201         struct list_head resources;
202         struct irq_domain *irq_domain;
203         struct irq_chip irq_chip;
204         raw_spinlock_t irq_lock;
205         struct irq_domain *msi_domain;
206         struct irq_domain *msi_inner_domain;
207         struct irq_chip msi_bottom_irq_chip;
208         struct irq_chip msi_irq_chip;
209         struct msi_domain_info msi_domain_info;
210         DECLARE_BITMAP(msi_used, MSI_IRQ_NUM);
211         struct mutex msi_used_lock;
212         u16 msi_msg;
213         int root_bus_nr;
214 };
215
216 static inline void advk_writel(struct advk_pcie *pcie, u32 val, u64 reg)
217 {
218         writel(val, pcie->base + reg);
219 }
220
221 static inline u32 advk_readl(struct advk_pcie *pcie, u64 reg)
222 {
223         return readl(pcie->base + reg);
224 }
225
226 static int advk_pcie_link_up(struct advk_pcie *pcie)
227 {
228         u32 val, ltssm_state;
229
230         val = advk_readl(pcie, CFG_REG);
231         ltssm_state = (val >> LTSSM_SHIFT) & LTSSM_MASK;
232         return ltssm_state >= LTSSM_L0;
233 }
234
235 static int advk_pcie_wait_for_link(struct advk_pcie *pcie)
236 {
237         struct device *dev = &pcie->pdev->dev;
238         int retries;
239
240         /* check if the link is up or not */
241         for (retries = 0; retries < LINK_WAIT_MAX_RETRIES; retries++) {
242                 if (advk_pcie_link_up(pcie)) {
243                         dev_info(dev, "link up\n");
244                         return 0;
245                 }
246
247                 usleep_range(LINK_WAIT_USLEEP_MIN, LINK_WAIT_USLEEP_MAX);
248         }
249
250         dev_err(dev, "link never came up\n");
251         return -ETIMEDOUT;
252 }
253
254 /*
255  * Set PCIe address window register which could be used for memory
256  * mapping.
257  */
258 static void advk_pcie_set_ob_win(struct advk_pcie *pcie,
259                                  u32 win_num, u32 match_ms,
260                                  u32 match_ls, u32 mask_ms,
261                                  u32 mask_ls, u32 remap_ms,
262                                  u32 remap_ls, u32 action)
263 {
264         advk_writel(pcie, match_ls, OB_WIN_MATCH_LS(win_num));
265         advk_writel(pcie, match_ms, OB_WIN_MATCH_MS(win_num));
266         advk_writel(pcie, mask_ms, OB_WIN_MASK_MS(win_num));
267         advk_writel(pcie, mask_ls, OB_WIN_MASK_LS(win_num));
268         advk_writel(pcie, remap_ms, OB_WIN_REMAP_MS(win_num));
269         advk_writel(pcie, remap_ls, OB_WIN_REMAP_LS(win_num));
270         advk_writel(pcie, action, OB_WIN_ACTIONS(win_num));
271         advk_writel(pcie, match_ls | BIT(0), OB_WIN_MATCH_LS(win_num));
272 }
273
274 static void advk_pcie_setup_hw(struct advk_pcie *pcie)
275 {
276         u32 reg;
277         int i;
278
279         /* Point PCIe unit MBUS decode windows to DRAM space */
280         for (i = 0; i < 8; i++)
281                 advk_pcie_set_ob_win(pcie, i, 0, 0, 0, 0, 0, 0, 0);
282
283         /* Set to Direct mode */
284         reg = advk_readl(pcie, CTRL_CONFIG_REG);
285         reg &= ~(CTRL_MODE_MASK << CTRL_MODE_SHIFT);
286         reg |= ((PCIE_CORE_MODE_DIRECT & CTRL_MODE_MASK) << CTRL_MODE_SHIFT);
287         advk_writel(pcie, reg, CTRL_CONFIG_REG);
288
289         /* Set PCI global control register to RC mode */
290         reg = advk_readl(pcie, PCIE_CORE_CTRL0_REG);
291         reg |= (IS_RC_MSK << IS_RC_SHIFT);
292         advk_writel(pcie, reg, PCIE_CORE_CTRL0_REG);
293
294         /* Set Advanced Error Capabilities and Control PF0 register */
295         reg = PCIE_CORE_ERR_CAPCTL_ECRC_CHK_TX |
296                 PCIE_CORE_ERR_CAPCTL_ECRC_CHK_TX_EN |
297                 PCIE_CORE_ERR_CAPCTL_ECRC_CHCK |
298                 PCIE_CORE_ERR_CAPCTL_ECRC_CHCK_RCV;
299         advk_writel(pcie, reg, PCIE_CORE_ERR_CAPCTL_REG);
300
301         /* Set PCIe Device Control and Status 1 PF0 register */
302         reg = PCIE_CORE_DEV_CTRL_STATS_RELAX_ORDER_DISABLE |
303                 (7 << PCIE_CORE_DEV_CTRL_STATS_MAX_PAYLOAD_SZ_SHIFT) |
304                 PCIE_CORE_DEV_CTRL_STATS_SNOOP_DISABLE |
305                 (PCIE_CORE_DEV_CTRL_STATS_MAX_RD_REQ_SZ <<
306                  PCIE_CORE_DEV_CTRL_STATS_MAX_RD_REQ_SIZE_SHIFT);
307         advk_writel(pcie, reg, PCIE_CORE_DEV_CTRL_STATS_REG);
308
309         /* Program PCIe Control 2 to disable strict ordering */
310         reg = PCIE_CORE_CTRL2_RESERVED |
311                 PCIE_CORE_CTRL2_TD_ENABLE;
312         advk_writel(pcie, reg, PCIE_CORE_CTRL2_REG);
313
314         /* Set GEN2 */
315         reg = advk_readl(pcie, PCIE_CORE_CTRL0_REG);
316         reg &= ~PCIE_GEN_SEL_MSK;
317         reg |= SPEED_GEN_2;
318         advk_writel(pcie, reg, PCIE_CORE_CTRL0_REG);
319
320         /* Set lane X1 */
321         reg = advk_readl(pcie, PCIE_CORE_CTRL0_REG);
322         reg &= ~LANE_CNT_MSK;
323         reg |= LANE_COUNT_1;
324         advk_writel(pcie, reg, PCIE_CORE_CTRL0_REG);
325
326         /* Enable link training */
327         reg = advk_readl(pcie, PCIE_CORE_CTRL0_REG);
328         reg |= LINK_TRAINING_EN;
329         advk_writel(pcie, reg, PCIE_CORE_CTRL0_REG);
330
331         /* Enable MSI */
332         reg = advk_readl(pcie, PCIE_CORE_CTRL2_REG);
333         reg |= PCIE_CORE_CTRL2_MSI_ENABLE;
334         advk_writel(pcie, reg, PCIE_CORE_CTRL2_REG);
335
336         /* Clear all interrupts */
337         advk_writel(pcie, PCIE_ISR0_ALL_MASK, PCIE_ISR0_REG);
338         advk_writel(pcie, PCIE_ISR1_ALL_MASK, PCIE_ISR1_REG);
339         advk_writel(pcie, PCIE_IRQ_ALL_MASK, HOST_CTRL_INT_STATUS_REG);
340
341         /* Disable All ISR0/1 Sources */
342         reg = PCIE_ISR0_ALL_MASK;
343         reg &= ~PCIE_ISR0_MSI_INT_PENDING;
344         advk_writel(pcie, reg, PCIE_ISR0_MASK_REG);
345
346         advk_writel(pcie, PCIE_ISR1_ALL_MASK, PCIE_ISR1_MASK_REG);
347
348         /* Unmask all MSI's */
349         advk_writel(pcie, 0, PCIE_MSI_MASK_REG);
350
351         /* Enable summary interrupt for GIC SPI source */
352         reg = PCIE_IRQ_ALL_MASK & (~PCIE_IRQ_ENABLE_INTS_MASK);
353         advk_writel(pcie, reg, HOST_CTRL_INT_MASK_REG);
354
355         reg = advk_readl(pcie, PCIE_CORE_CTRL2_REG);
356         reg |= PCIE_CORE_CTRL2_OB_WIN_ENABLE;
357         advk_writel(pcie, reg, PCIE_CORE_CTRL2_REG);
358
359         /* Bypass the address window mapping for PIO */
360         reg = advk_readl(pcie, PIO_CTRL);
361         reg |= PIO_CTRL_ADDR_WIN_DISABLE;
362         advk_writel(pcie, reg, PIO_CTRL);
363
364         /* Start link training */
365         reg = advk_readl(pcie, PCIE_CORE_LINK_CTRL_STAT_REG);
366         reg |= PCIE_CORE_LINK_TRAINING;
367         advk_writel(pcie, reg, PCIE_CORE_LINK_CTRL_STAT_REG);
368
369         advk_pcie_wait_for_link(pcie);
370
371         reg = advk_readl(pcie, PCIE_CORE_CMD_STATUS_REG);
372         reg |= PCIE_CORE_CMD_MEM_ACCESS_EN |
373                 PCIE_CORE_CMD_IO_ACCESS_EN |
374                 PCIE_CORE_CMD_MEM_IO_REQ_EN;
375         advk_writel(pcie, reg, PCIE_CORE_CMD_STATUS_REG);
376 }
377
378 static int advk_pcie_check_pio_status(struct advk_pcie *pcie, u32 *val)
379 {
380         struct device *dev = &pcie->pdev->dev;
381         u32 reg;
382         unsigned int status;
383         char *strcomp_status, *str_posted;
384
385         reg = advk_readl(pcie, PIO_STAT);
386         status = (reg & PIO_COMPLETION_STATUS_MASK) >>
387                 PIO_COMPLETION_STATUS_SHIFT;
388
389         /*
390          * According to HW spec, the PIO status check sequence as below:
391          * 1) even if COMPLETION_STATUS(bit9:7) indicates successful,
392          *    it still needs to check Error Status(bit11), only when this bit
393          *    indicates no error happen, the operation is successful.
394          * 2) value Unsupported Request(1) of COMPLETION_STATUS(bit9:7) only
395          *    means a PIO write error, and for PIO read it is successful with
396          *    a read value of 0xFFFFFFFF.
397          * 3) value Completion Retry Status(CRS) of COMPLETION_STATUS(bit9:7)
398          *    only means a PIO write error, and for PIO read it is successful
399          *    with a read value of 0xFFFF0001.
400          * 4) value Completer Abort (CA) of COMPLETION_STATUS(bit9:7) means
401          *    error for both PIO read and PIO write operation.
402          * 5) other errors are indicated as 'unknown'.
403          */
404         switch (status) {
405         case PIO_COMPLETION_STATUS_OK:
406                 if (reg & PIO_ERR_STATUS) {
407                         strcomp_status = "COMP_ERR";
408                         break;
409                 }
410                 /* Get the read result */
411                 if (val)
412                         *val = advk_readl(pcie, PIO_RD_DATA);
413                 /* No error */
414                 strcomp_status = NULL;
415                 break;
416         case PIO_COMPLETION_STATUS_UR:
417                 strcomp_status = "UR";
418                 break;
419         case PIO_COMPLETION_STATUS_CRS:
420                 /* PCIe r4.0, sec 2.3.2, says:
421                  * If CRS Software Visibility is not enabled, the Root Complex
422                  * must re-issue the Configuration Request as a new Request.
423                  * A Root Complex implementation may choose to limit the number
424                  * of Configuration Request/CRS Completion Status loops before
425                  * determining that something is wrong with the target of the
426                  * Request and taking appropriate action, e.g., complete the
427                  * Request to the host as a failed transaction.
428                  *
429                  * To simplify implementation do not re-issue the Configuration
430                  * Request and complete the Request as a failed transaction.
431                  */
432                 strcomp_status = "CRS";
433                 break;
434         case PIO_COMPLETION_STATUS_CA:
435                 strcomp_status = "CA";
436                 break;
437         default:
438                 strcomp_status = "Unknown";
439                 break;
440         }
441
442         if (!strcomp_status)
443                 return 0;
444
445         if (reg & PIO_NON_POSTED_REQ)
446                 str_posted = "Non-posted";
447         else
448                 str_posted = "Posted";
449
450         dev_err(dev, "%s PIO Response Status: %s, %#x @ %#x\n",
451                 str_posted, strcomp_status, reg, advk_readl(pcie, PIO_ADDR_LS));
452
453         return -EFAULT;
454 }
455
456 static int advk_pcie_wait_pio(struct advk_pcie *pcie)
457 {
458         struct device *dev = &pcie->pdev->dev;
459         int i;
460
461         for (i = 0; i < PIO_RETRY_CNT; i++) {
462                 u32 start, isr;
463
464                 start = advk_readl(pcie, PIO_START);
465                 isr = advk_readl(pcie, PIO_ISR);
466                 if (!start && isr)
467                         return 0;
468                 udelay(PIO_RETRY_DELAY);
469         }
470
471         dev_err(dev, "PIO read/write transfer time out\n");
472         return -ETIMEDOUT;
473 }
474
475 static bool advk_pcie_pio_is_running(struct advk_pcie *pcie)
476 {
477         struct device *dev = &pcie->pdev->dev;
478
479         /*
480          * Trying to start a new PIO transfer when previous has not completed
481          * cause External Abort on CPU which results in kernel panic:
482          *
483          *     SError Interrupt on CPU0, code 0xbf000002 -- SError
484          *     Kernel panic - not syncing: Asynchronous SError Interrupt
485          *
486          * Functions advk_pcie_rd_conf() and advk_pcie_wr_conf() are protected
487          * by raw_spin_lock_irqsave() at pci_lock_config() level to prevent
488          * concurrent calls at the same time. But because PIO transfer may take
489          * about 1.5s when link is down or card is disconnected, it means that
490          * advk_pcie_wait_pio() does not always have to wait for completion.
491          *
492          * Some versions of ARM Trusted Firmware handles this External Abort at
493          * EL3 level and mask it to prevent kernel panic. Relevant TF-A commit:
494          * https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/commit/?id=3c7dcdac5c50
495          */
496         if (advk_readl(pcie, PIO_START)) {
497                 dev_err(dev, "Previous PIO read/write transfer is still running\n");
498                 return true;
499         }
500
501         return false;
502 }
503
504 static int advk_pcie_rd_conf(struct pci_bus *bus, u32 devfn,
505                              int where, int size, u32 *val)
506 {
507         struct advk_pcie *pcie = bus->sysdata;
508         u32 reg;
509         int ret;
510
511         if ((bus->number == pcie->root_bus_nr) && PCI_SLOT(devfn) != 0) {
512                 *val = 0xffffffff;
513                 return PCIBIOS_DEVICE_NOT_FOUND;
514         }
515
516         if (advk_pcie_pio_is_running(pcie)) {
517                 *val = 0xffffffff;
518                 return PCIBIOS_SET_FAILED;
519         }
520
521         /* Program the control register */
522         reg = advk_readl(pcie, PIO_CTRL);
523         reg &= ~PIO_CTRL_TYPE_MASK;
524         if (bus->number ==  pcie->root_bus_nr)
525                 reg |= PCIE_CONFIG_RD_TYPE0;
526         else
527                 reg |= PCIE_CONFIG_RD_TYPE1;
528         advk_writel(pcie, reg, PIO_CTRL);
529
530         /* Program the address registers */
531         reg = PCIE_CONF_ADDR(bus->number, devfn, where);
532         advk_writel(pcie, reg, PIO_ADDR_LS);
533         advk_writel(pcie, 0, PIO_ADDR_MS);
534
535         /* Program the data strobe */
536         advk_writel(pcie, 0xf, PIO_WR_DATA_STRB);
537
538         /* Clear PIO DONE ISR and start the transfer */
539         advk_writel(pcie, 1, PIO_ISR);
540         advk_writel(pcie, 1, PIO_START);
541
542         ret = advk_pcie_wait_pio(pcie);
543         if (ret < 0)
544                 return PCIBIOS_SET_FAILED;
545
546         /* Check PIO status and get the read result */
547         ret = advk_pcie_check_pio_status(pcie, val);
548         if (ret < 0) {
549                 *val = 0xffffffff;
550                 return PCIBIOS_SET_FAILED;
551         }
552
553         if (size == 1)
554                 *val = (*val >> (8 * (where & 3))) & 0xff;
555         else if (size == 2)
556                 *val = (*val >> (8 * (where & 3))) & 0xffff;
557
558         return PCIBIOS_SUCCESSFUL;
559 }
560
561 static int advk_pcie_wr_conf(struct pci_bus *bus, u32 devfn,
562                                 int where, int size, u32 val)
563 {
564         struct advk_pcie *pcie = bus->sysdata;
565         u32 reg;
566         u32 data_strobe = 0x0;
567         int offset;
568         int ret;
569
570         if ((bus->number == pcie->root_bus_nr) && PCI_SLOT(devfn) != 0)
571                 return PCIBIOS_DEVICE_NOT_FOUND;
572
573         if (where % size)
574                 return PCIBIOS_SET_FAILED;
575
576         if (advk_pcie_pio_is_running(pcie))
577                 return PCIBIOS_SET_FAILED;
578
579         /* Program the control register */
580         reg = advk_readl(pcie, PIO_CTRL);
581         reg &= ~PIO_CTRL_TYPE_MASK;
582         if (bus->number == pcie->root_bus_nr)
583                 reg |= PCIE_CONFIG_WR_TYPE0;
584         else
585                 reg |= PCIE_CONFIG_WR_TYPE1;
586         advk_writel(pcie, reg, PIO_CTRL);
587
588         /* Program the address registers */
589         reg = PCIE_CONF_ADDR(bus->number, devfn, where);
590         advk_writel(pcie, reg, PIO_ADDR_LS);
591         advk_writel(pcie, 0, PIO_ADDR_MS);
592
593         /* Calculate the write strobe */
594         offset      = where & 0x3;
595         reg         = val << (8 * offset);
596         data_strobe = GENMASK(size - 1, 0) << offset;
597
598         /* Program the data register */
599         advk_writel(pcie, reg, PIO_WR_DATA);
600
601         /* Program the data strobe */
602         advk_writel(pcie, data_strobe, PIO_WR_DATA_STRB);
603
604         /* Clear PIO DONE ISR and start the transfer */
605         advk_writel(pcie, 1, PIO_ISR);
606         advk_writel(pcie, 1, PIO_START);
607
608         ret = advk_pcie_wait_pio(pcie);
609         if (ret < 0)
610                 return PCIBIOS_SET_FAILED;
611
612         ret = advk_pcie_check_pio_status(pcie, NULL);
613         if (ret < 0)
614                 return PCIBIOS_SET_FAILED;
615
616         return PCIBIOS_SUCCESSFUL;
617 }
618
619 static struct pci_ops advk_pcie_ops = {
620         .read = advk_pcie_rd_conf,
621         .write = advk_pcie_wr_conf,
622 };
623
624 static void advk_msi_irq_compose_msi_msg(struct irq_data *data,
625                                          struct msi_msg *msg)
626 {
627         struct advk_pcie *pcie = irq_data_get_irq_chip_data(data);
628         phys_addr_t msi_msg = virt_to_phys(&pcie->msi_msg);
629
630         msg->address_lo = lower_32_bits(msi_msg);
631         msg->address_hi = upper_32_bits(msi_msg);
632         msg->data = data->irq;
633 }
634
635 static int advk_msi_set_affinity(struct irq_data *irq_data,
636                                  const struct cpumask *mask, bool force)
637 {
638         return -EINVAL;
639 }
640
641 static int advk_msi_irq_domain_alloc(struct irq_domain *domain,
642                                      unsigned int virq,
643                                      unsigned int nr_irqs, void *args)
644 {
645         struct advk_pcie *pcie = domain->host_data;
646         int hwirq, i;
647
648         mutex_lock(&pcie->msi_used_lock);
649         hwirq = bitmap_find_next_zero_area(pcie->msi_used, MSI_IRQ_NUM,
650                                            0, nr_irqs, 0);
651         if (hwirq >= MSI_IRQ_NUM) {
652                 mutex_unlock(&pcie->msi_used_lock);
653                 return -ENOSPC;
654         }
655
656         bitmap_set(pcie->msi_used, hwirq, nr_irqs);
657         mutex_unlock(&pcie->msi_used_lock);
658
659         for (i = 0; i < nr_irqs; i++)
660                 irq_domain_set_info(domain, virq + i, hwirq + i,
661                                     &pcie->msi_bottom_irq_chip,
662                                     domain->host_data, handle_simple_irq,
663                                     NULL, NULL);
664
665         return hwirq;
666 }
667
668 static void advk_msi_irq_domain_free(struct irq_domain *domain,
669                                      unsigned int virq, unsigned int nr_irqs)
670 {
671         struct irq_data *d = irq_domain_get_irq_data(domain, virq);
672         struct advk_pcie *pcie = domain->host_data;
673
674         mutex_lock(&pcie->msi_used_lock);
675         bitmap_clear(pcie->msi_used, d->hwirq, nr_irqs);
676         mutex_unlock(&pcie->msi_used_lock);
677 }
678
679 static const struct irq_domain_ops advk_msi_domain_ops = {
680         .alloc = advk_msi_irq_domain_alloc,
681         .free = advk_msi_irq_domain_free,
682 };
683
684 static void advk_pcie_irq_mask(struct irq_data *d)
685 {
686         struct advk_pcie *pcie = d->domain->host_data;
687         irq_hw_number_t hwirq = irqd_to_hwirq(d);
688         unsigned long flags;
689         u32 mask;
690
691         raw_spin_lock_irqsave(&pcie->irq_lock, flags);
692         mask = advk_readl(pcie, PCIE_ISR1_MASK_REG);
693         mask |= PCIE_ISR1_INTX_ASSERT(hwirq);
694         advk_writel(pcie, mask, PCIE_ISR1_MASK_REG);
695         raw_spin_unlock_irqrestore(&pcie->irq_lock, flags);
696 }
697
698 static void advk_pcie_irq_unmask(struct irq_data *d)
699 {
700         struct advk_pcie *pcie = d->domain->host_data;
701         irq_hw_number_t hwirq = irqd_to_hwirq(d);
702         unsigned long flags;
703         u32 mask;
704
705         raw_spin_lock_irqsave(&pcie->irq_lock, flags);
706         mask = advk_readl(pcie, PCIE_ISR1_MASK_REG);
707         mask &= ~PCIE_ISR1_INTX_ASSERT(hwirq);
708         advk_writel(pcie, mask, PCIE_ISR1_MASK_REG);
709         raw_spin_unlock_irqrestore(&pcie->irq_lock, flags);
710 }
711
712 static int advk_pcie_irq_map(struct irq_domain *h,
713                              unsigned int virq, irq_hw_number_t hwirq)
714 {
715         struct advk_pcie *pcie = h->host_data;
716
717         advk_pcie_irq_mask(irq_get_irq_data(virq));
718         irq_set_status_flags(virq, IRQ_LEVEL);
719         irq_set_chip_and_handler(virq, &pcie->irq_chip,
720                                  handle_level_irq);
721         irq_set_chip_data(virq, pcie);
722
723         return 0;
724 }
725
726 static const struct irq_domain_ops advk_pcie_irq_domain_ops = {
727         .map = advk_pcie_irq_map,
728         .xlate = irq_domain_xlate_onecell,
729 };
730
731 static int advk_pcie_init_msi_irq_domain(struct advk_pcie *pcie)
732 {
733         struct device *dev = &pcie->pdev->dev;
734         struct device_node *node = dev->of_node;
735         struct irq_chip *bottom_ic, *msi_ic;
736         struct msi_domain_info *msi_di;
737         phys_addr_t msi_msg_phys;
738
739         mutex_init(&pcie->msi_used_lock);
740
741         bottom_ic = &pcie->msi_bottom_irq_chip;
742
743         bottom_ic->name = "MSI";
744         bottom_ic->irq_compose_msi_msg = advk_msi_irq_compose_msi_msg;
745         bottom_ic->irq_set_affinity = advk_msi_set_affinity;
746
747         msi_ic = &pcie->msi_irq_chip;
748         msi_ic->name = "advk-MSI";
749
750         msi_di = &pcie->msi_domain_info;
751         msi_di->flags = MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS |
752                 MSI_FLAG_MULTI_PCI_MSI;
753         msi_di->chip = msi_ic;
754
755         msi_msg_phys = virt_to_phys(&pcie->msi_msg);
756
757         advk_writel(pcie, lower_32_bits(msi_msg_phys),
758                     PCIE_MSI_ADDR_LOW_REG);
759         advk_writel(pcie, upper_32_bits(msi_msg_phys),
760                     PCIE_MSI_ADDR_HIGH_REG);
761
762         pcie->msi_inner_domain =
763                 irq_domain_add_linear(NULL, MSI_IRQ_NUM,
764                                       &advk_msi_domain_ops, pcie);
765         if (!pcie->msi_inner_domain)
766                 return -ENOMEM;
767
768         pcie->msi_domain =
769                 pci_msi_create_irq_domain(of_node_to_fwnode(node),
770                                           msi_di, pcie->msi_inner_domain);
771         if (!pcie->msi_domain) {
772                 irq_domain_remove(pcie->msi_inner_domain);
773                 return -ENOMEM;
774         }
775
776         return 0;
777 }
778
779 static void advk_pcie_remove_msi_irq_domain(struct advk_pcie *pcie)
780 {
781         irq_domain_remove(pcie->msi_domain);
782         irq_domain_remove(pcie->msi_inner_domain);
783 }
784
785 static int advk_pcie_init_irq_domain(struct advk_pcie *pcie)
786 {
787         struct device *dev = &pcie->pdev->dev;
788         struct device_node *node = dev->of_node;
789         struct device_node *pcie_intc_node;
790         struct irq_chip *irq_chip;
791
792         raw_spin_lock_init(&pcie->irq_lock);
793
794         pcie_intc_node =  of_get_next_child(node, NULL);
795         if (!pcie_intc_node) {
796                 dev_err(dev, "No PCIe Intc node found\n");
797                 return -ENODEV;
798         }
799
800         irq_chip = &pcie->irq_chip;
801
802         irq_chip->name = devm_kasprintf(dev, GFP_KERNEL, "%s-irq",
803                                         dev_name(dev));
804         if (!irq_chip->name) {
805                 of_node_put(pcie_intc_node);
806                 return -ENOMEM;
807         }
808
809         irq_chip->irq_mask = advk_pcie_irq_mask;
810         irq_chip->irq_mask_ack = advk_pcie_irq_mask;
811         irq_chip->irq_unmask = advk_pcie_irq_unmask;
812
813         pcie->irq_domain =
814                 irq_domain_add_linear(pcie_intc_node, PCI_NUM_INTX,
815                                       &advk_pcie_irq_domain_ops, pcie);
816         if (!pcie->irq_domain) {
817                 dev_err(dev, "Failed to get a INTx IRQ domain\n");
818                 of_node_put(pcie_intc_node);
819                 return -ENOMEM;
820         }
821
822         return 0;
823 }
824
825 static void advk_pcie_remove_irq_domain(struct advk_pcie *pcie)
826 {
827         irq_domain_remove(pcie->irq_domain);
828 }
829
830 static void advk_pcie_handle_msi(struct advk_pcie *pcie)
831 {
832         u32 msi_val, msi_mask, msi_status, msi_idx;
833         u16 msi_data;
834
835         msi_mask = advk_readl(pcie, PCIE_MSI_MASK_REG);
836         msi_val = advk_readl(pcie, PCIE_MSI_STATUS_REG);
837         msi_status = msi_val & ~msi_mask;
838
839         for (msi_idx = 0; msi_idx < MSI_IRQ_NUM; msi_idx++) {
840                 if (!(BIT(msi_idx) & msi_status))
841                         continue;
842
843                 advk_writel(pcie, BIT(msi_idx), PCIE_MSI_STATUS_REG);
844                 msi_data = advk_readl(pcie, PCIE_MSI_PAYLOAD_REG) & 0xFF;
845                 generic_handle_irq(msi_data);
846         }
847
848         advk_writel(pcie, PCIE_ISR0_MSI_INT_PENDING,
849                     PCIE_ISR0_REG);
850 }
851
852 static void advk_pcie_handle_int(struct advk_pcie *pcie)
853 {
854         u32 isr0_val, isr0_mask, isr0_status;
855         u32 isr1_val, isr1_mask, isr1_status;
856         int i, virq;
857
858         isr0_val = advk_readl(pcie, PCIE_ISR0_REG);
859         isr0_mask = advk_readl(pcie, PCIE_ISR0_MASK_REG);
860         isr0_status = isr0_val & ((~isr0_mask) & PCIE_ISR0_ALL_MASK);
861
862         isr1_val = advk_readl(pcie, PCIE_ISR1_REG);
863         isr1_mask = advk_readl(pcie, PCIE_ISR1_MASK_REG);
864         isr1_status = isr1_val & ((~isr1_mask) & PCIE_ISR1_ALL_MASK);
865
866         if (!isr0_status && !isr1_status) {
867                 advk_writel(pcie, isr0_val, PCIE_ISR0_REG);
868                 advk_writel(pcie, isr1_val, PCIE_ISR1_REG);
869                 return;
870         }
871
872         /* Process MSI interrupts */
873         if (isr0_status & PCIE_ISR0_MSI_INT_PENDING)
874                 advk_pcie_handle_msi(pcie);
875
876         /* Process legacy interrupts */
877         for (i = 0; i < PCI_NUM_INTX; i++) {
878                 if (!(isr1_status & PCIE_ISR1_INTX_ASSERT(i)))
879                         continue;
880
881                 advk_writel(pcie, PCIE_ISR1_INTX_ASSERT(i),
882                             PCIE_ISR1_REG);
883
884                 virq = irq_find_mapping(pcie->irq_domain, i);
885                 generic_handle_irq(virq);
886         }
887 }
888
889 static irqreturn_t advk_pcie_irq_handler(int irq, void *arg)
890 {
891         struct advk_pcie *pcie = arg;
892         u32 status;
893
894         status = advk_readl(pcie, HOST_CTRL_INT_STATUS_REG);
895         if (!(status & PCIE_IRQ_CORE_INT))
896                 return IRQ_NONE;
897
898         advk_pcie_handle_int(pcie);
899
900         /* Clear interrupt */
901         advk_writel(pcie, PCIE_IRQ_CORE_INT, HOST_CTRL_INT_STATUS_REG);
902
903         return IRQ_HANDLED;
904 }
905
906 static int advk_pcie_parse_request_of_pci_ranges(struct advk_pcie *pcie)
907 {
908         int err, res_valid = 0;
909         struct device *dev = &pcie->pdev->dev;
910         struct device_node *np = dev->of_node;
911         struct resource_entry *win, *tmp;
912         resource_size_t iobase;
913
914         INIT_LIST_HEAD(&pcie->resources);
915
916         err = of_pci_get_host_bridge_resources(np, 0, 0xff, &pcie->resources,
917                                                &iobase);
918         if (err)
919                 return err;
920
921         err = devm_request_pci_bus_resources(dev, &pcie->resources);
922         if (err)
923                 goto out_release_res;
924
925         resource_list_for_each_entry_safe(win, tmp, &pcie->resources) {
926                 struct resource *res = win->res;
927
928                 switch (resource_type(res)) {
929                 case IORESOURCE_IO:
930                         advk_pcie_set_ob_win(pcie, 1,
931                                              upper_32_bits(res->start),
932                                              lower_32_bits(res->start),
933                                              0, 0xF8000000, 0,
934                                              lower_32_bits(res->start),
935                                              OB_PCIE_IO);
936                         err = pci_remap_iospace(res, iobase);
937                         if (err) {
938                                 dev_warn(dev, "error %d: failed to map resource %pR\n",
939                                          err, res);
940                                 resource_list_destroy_entry(win);
941                         }
942                         break;
943                 case IORESOURCE_MEM:
944                         advk_pcie_set_ob_win(pcie, 0,
945                                              upper_32_bits(res->start),
946                                              lower_32_bits(res->start),
947                                              0x0, 0xF8000000, 0,
948                                              lower_32_bits(res->start),
949                                              (2 << 20) | OB_PCIE_MEM);
950                         res_valid |= !(res->flags & IORESOURCE_PREFETCH);
951                         break;
952                 case IORESOURCE_BUS:
953                         pcie->root_bus_nr = res->start;
954                         break;
955                 }
956         }
957
958         if (!res_valid) {
959                 dev_err(dev, "non-prefetchable memory resource required\n");
960                 err = -EINVAL;
961                 goto out_release_res;
962         }
963
964         return 0;
965
966 out_release_res:
967         pci_free_resource_list(&pcie->resources);
968         return err;
969 }
970
971 static int advk_pcie_probe(struct platform_device *pdev)
972 {
973         struct device *dev = &pdev->dev;
974         struct advk_pcie *pcie;
975         struct resource *res;
976         struct pci_bus *bus, *child;
977         struct pci_host_bridge *bridge;
978         int ret, irq;
979
980         bridge = devm_pci_alloc_host_bridge(dev, sizeof(struct advk_pcie));
981         if (!bridge)
982                 return -ENOMEM;
983
984         pcie = pci_host_bridge_priv(bridge);
985         pcie->pdev = pdev;
986
987         res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
988         pcie->base = devm_ioremap_resource(dev, res);
989         if (IS_ERR(pcie->base))
990                 return PTR_ERR(pcie->base);
991
992         irq = platform_get_irq(pdev, 0);
993         ret = devm_request_irq(dev, irq, advk_pcie_irq_handler,
994                                IRQF_SHARED | IRQF_NO_THREAD, "advk-pcie",
995                                pcie);
996         if (ret) {
997                 dev_err(dev, "Failed to register interrupt\n");
998                 return ret;
999         }
1000
1001         ret = advk_pcie_parse_request_of_pci_ranges(pcie);
1002         if (ret) {
1003                 dev_err(dev, "Failed to parse resources\n");
1004                 return ret;
1005         }
1006
1007         advk_pcie_setup_hw(pcie);
1008
1009         ret = advk_pcie_init_irq_domain(pcie);
1010         if (ret) {
1011                 dev_err(dev, "Failed to initialize irq\n");
1012                 return ret;
1013         }
1014
1015         ret = advk_pcie_init_msi_irq_domain(pcie);
1016         if (ret) {
1017                 dev_err(dev, "Failed to initialize irq\n");
1018                 advk_pcie_remove_irq_domain(pcie);
1019                 return ret;
1020         }
1021
1022         list_splice_init(&pcie->resources, &bridge->windows);
1023         bridge->dev.parent = dev;
1024         bridge->sysdata = pcie;
1025         bridge->busnr = 0;
1026         bridge->ops = &advk_pcie_ops;
1027         bridge->map_irq = of_irq_parse_and_map_pci;
1028         bridge->swizzle_irq = pci_common_swizzle;
1029
1030         ret = pci_scan_root_bus_bridge(bridge);
1031         if (ret < 0) {
1032                 advk_pcie_remove_msi_irq_domain(pcie);
1033                 advk_pcie_remove_irq_domain(pcie);
1034                 return ret;
1035         }
1036
1037         bus = bridge->bus;
1038
1039         pci_bus_size_bridges(bus);
1040         pci_bus_assign_resources(bus);
1041
1042         list_for_each_entry(child, &bus->children, node)
1043                 pcie_bus_configure_settings(child);
1044
1045         pci_bus_add_devices(bus);
1046         return 0;
1047 }
1048
1049 static const struct of_device_id advk_pcie_of_match_table[] = {
1050         { .compatible = "marvell,armada-3700-pcie", },
1051         {},
1052 };
1053
1054 static struct platform_driver advk_pcie_driver = {
1055         .driver = {
1056                 .name = "advk-pcie",
1057                 .of_match_table = advk_pcie_of_match_table,
1058                 /* Driver unloading/unbinding currently not supported */
1059                 .suppress_bind_attrs = true,
1060         },
1061         .probe = advk_pcie_probe,
1062 };
1063 builtin_platform_driver(advk_pcie_driver);