68898c3beb87c74c36e13b22509401624ef13757
[openwrt/staging/ynezz.git] / target / linux / oxnas / files / drivers / pci / host / pcie-oxnas.c
1 /*
2 * PCIe driver for PLX NAS782X SoCs
3 *
4 * Author: Ma Haijun <mahaijuns@gmail.com>
5 *
6 * This file is licensed under the terms of the GNU General Public
7 * License version 2. This program is licensed "as is" without any
8 * warranty of any kind, whether express or implied.
9 */
10
11 #include <linux/kernel.h>
12 #include <linux/pci.h>
13 #include <linux/clk.h>
14 #include <linux/module.h>
15 #include <linux/mbus.h>
16 #include <linux/mfd/syscon.h>
17 #include <linux/slab.h>
18 #include <linux/platform_device.h>
19 #include <linux/of_address.h>
20 #include <linux/of_device.h>
21 #include <linux/of_gpio.h>
22 #include <linux/of_irq.h>
23 #include <linux/of_pci.h>
24 #include <linux/of_platform.h>
25 #include <linux/gpio.h>
26 #include <linux/delay.h>
27 #include <linux/clk.h>
28 #include <linux/phy.h>
29 #include <linux/phy/phy.h>
30 #include <linux/regmap.h>
31 #include <linux/reset.h>
32 #include <linux/io.h>
33 #include <linux/sizes.h>
34
35 #define SYS_CTRL_HCSL_CTRL_REGOFFSET 0x114
36
37 static inline void oxnas_register_clear_mask(void __iomem *p, unsigned mask)
38 {
39 u32 val = readl_relaxed(p);
40
41 val &= ~mask;
42 writel_relaxed(val, p);
43 }
44
45 static inline void oxnas_register_set_mask(void __iomem *p, unsigned mask)
46 {
47 u32 val = readl_relaxed(p);
48
49 val |= mask;
50 writel_relaxed(val, p);
51 }
52
53 static inline void oxnas_register_value_mask(void __iomem *p,
54 unsigned mask, unsigned new_value)
55 {
56 /* TODO sanity check mask & new_value = new_value */
57 u32 val = readl_relaxed(p);
58
59 val &= ~mask;
60 val |= new_value;
61 writel_relaxed(val, p);
62 }
63
64 #define VERSION_ID_MAGIC 0x082510b5
65 #define LINK_UP_TIMEOUT_SECONDS 1
66 #define NUM_CONTROLLERS 1
67
68 enum {
69 PCIE_DEVICE_TYPE_MASK = 0x0F,
70 PCIE_DEVICE_TYPE_ENDPOINT = 0,
71 PCIE_DEVICE_TYPE_LEGACY_ENDPOINT = 1,
72 PCIE_DEVICE_TYPE_ROOT = 4,
73
74 PCIE_LTSSM = BIT(4),
75 PCIE_READY_ENTR_L23 = BIT(9),
76 PCIE_LINK_UP = BIT(11),
77 PCIE_OBTRANS = BIT(12),
78 };
79
80 /* core config registers */
81 enum {
82 PCI_CONFIG_VERSION_DEVICEID = 0,
83 PCI_CONFIG_COMMAND_STATUS = 4,
84 };
85
86 /* inbound config registers */
87 enum {
88 IB_ADDR_XLATE_ENABLE = 0xFC,
89
90 /* bits */
91 ENABLE_IN_ADDR_TRANS = BIT(0),
92 };
93
94 /* outbound config registers, offset relative to PCIE_POM0_MEM_ADDR */
95 enum {
96 PCIE_POM0_MEM_ADDR = 0,
97 PCIE_POM1_MEM_ADDR = 4,
98 PCIE_IN0_MEM_ADDR = 8,
99 PCIE_IN1_MEM_ADDR = 12,
100 PCIE_IN_IO_ADDR = 16,
101 PCIE_IN_CFG0_ADDR = 20,
102 PCIE_IN_CFG1_ADDR = 24,
103 PCIE_IN_MSG_ADDR = 28,
104 PCIE_IN0_MEM_LIMIT = 32,
105 PCIE_IN1_MEM_LIMIT = 36,
106 PCIE_IN_IO_LIMIT = 40,
107 PCIE_IN_CFG0_LIMIT = 44,
108 PCIE_IN_CFG1_LIMIT = 48,
109 PCIE_IN_MSG_LIMIT = 52,
110 PCIE_AHB_SLAVE_CTRL = 56,
111
112 PCIE_SLAVE_BE_SHIFT = 22,
113 };
114
115 #define PCIE_SLAVE_BE(val) ((val) << PCIE_SLAVE_BE_SHIFT)
116 #define PCIE_SLAVE_BE_MASK PCIE_SLAVE_BE(0xF)
117
118 struct oxnas_pcie_shared {
119 /* seems all access are serialized, no lock required */
120 int refcount;
121 };
122
123 /* Structure representing one PCIe interfaces */
124 struct oxnas_pcie {
125 void __iomem *cfgbase;
126 void __iomem *base;
127 void __iomem *inbound;
128 struct regmap *sys_ctrl;
129 unsigned int outbound_offset;
130 unsigned int pcie_ctrl_offset;
131 struct phy *phy;
132 int haslink;
133 struct platform_device *pdev;
134 struct resource io;
135 struct resource cfg;
136 struct resource pre_mem; /* prefetchable */
137 struct resource non_mem; /* non-prefetchable */
138 struct resource busn; /* max available bus numbers */
139 int card_reset; /* gpio pin, optional */
140 unsigned hcsl_en; /* hcsl pci enable bit */
141 struct clk *clk;
142 struct clk *busclk; /* for pcie bus, actually the PLLB */
143 void *private_data[1];
144 spinlock_t lock;
145 };
146
147 static struct oxnas_pcie_shared pcie_shared = {
148 .refcount = 0,
149 };
150
151 static inline struct oxnas_pcie *sys_to_pcie(struct pci_sys_data *sys)
152 {
153 return sys->private_data;
154 }
155
156
157 static inline void set_out_lanes(struct oxnas_pcie *pcie, unsigned lanes)
158 {
159 regmap_update_bits(pcie->sys_ctrl, pcie->outbound_offset + PCIE_AHB_SLAVE_CTRL,
160 PCIE_SLAVE_BE_MASK, PCIE_SLAVE_BE(lanes));
161 wmb();
162 }
163
164 static int oxnas_pcie_link_up(struct oxnas_pcie *pcie)
165 {
166 unsigned long end;
167 unsigned int val;
168
169 /* Poll for PCIE link up */
170 end = jiffies + (LINK_UP_TIMEOUT_SECONDS * HZ);
171 while (!time_after(jiffies, end)) {
172 regmap_read(pcie->sys_ctrl, pcie->pcie_ctrl_offset, &val);
173 if (val & PCIE_LINK_UP)
174 return 1;
175 }
176 return 0;
177 }
178
179 static void oxnas_pcie_setup_hw(struct oxnas_pcie *pcie)
180 {
181 /* We won't have any inbound address translation. This allows PCI
182 * devices to access anywhere in the AHB address map. Might be regarded
183 * as a bit dangerous, but let's get things working before we worry
184 * about that
185 */
186 oxnas_register_clear_mask(pcie->inbound + IB_ADDR_XLATE_ENABLE,
187 ENABLE_IN_ADDR_TRANS);
188 wmb();
189
190 /*
191 * Program outbound translation windows
192 *
193 * Outbound window is what is referred to as "PCI client" region in HRM
194 *
195 * Could use the larger alternative address space to get >>64M regions
196 * for graphics cards etc., but will not bother at this point.
197 *
198 * IP bug means that AMBA window size must be a power of 2
199 *
200 * Set mem0 window for first 16MB of outbound window non-prefetchable
201 * Set mem1 window for second 16MB of outbound window prefetchable
202 * Set io window for next 16MB of outbound window
203 * Set cfg0 for final 1MB of outbound window
204 *
205 * Ignore mem1, cfg1 and msg windows for now as no obvious use cases for
206 * 820 that would need them
207 *
208 * Probably ideally want no offset between mem0 window start as seen by
209 * ARM and as seen on PCI bus and get Linux to assign memory regions to
210 * PCI devices using the same "PCI client" region start address as seen
211 * by ARM
212 */
213
214 /* Set PCIeA mem0 region to be 1st 16MB of the 64MB PCIeA window */
215 regmap_write(pcie->sys_ctrl, pcie->outbound_offset + PCIE_IN0_MEM_ADDR, pcie->non_mem.start);
216 regmap_write(pcie->sys_ctrl, pcie->outbound_offset + PCIE_IN0_MEM_LIMIT, pcie->non_mem.end);
217 regmap_write(pcie->sys_ctrl, pcie->outbound_offset + PCIE_POM0_MEM_ADDR, pcie->non_mem.start);
218
219 /* Set PCIeA mem1 region to be 2nd 16MB of the 64MB PCIeA window */
220 regmap_write(pcie->sys_ctrl, pcie->outbound_offset + PCIE_IN1_MEM_ADDR, pcie->pre_mem.start);
221 regmap_write(pcie->sys_ctrl, pcie->outbound_offset + PCIE_IN1_MEM_LIMIT, pcie->pre_mem.end);
222 regmap_write(pcie->sys_ctrl, pcie->outbound_offset + PCIE_POM1_MEM_ADDR, pcie->pre_mem.start);
223
224 /* Set PCIeA io to be third 16M region of the 64MB PCIeA window*/
225 regmap_write(pcie->sys_ctrl, pcie->outbound_offset + PCIE_IN_IO_ADDR, pcie->io.start);
226 regmap_write(pcie->sys_ctrl, pcie->outbound_offset + PCIE_IN_IO_LIMIT, pcie->io.end);
227
228
229 /* Set PCIeA cgf0 to be last 16M region of the 64MB PCIeA window*/
230 regmap_write(pcie->sys_ctrl, pcie->outbound_offset + PCIE_IN_CFG0_ADDR, pcie->cfg.start);
231 regmap_write(pcie->sys_ctrl, pcie->outbound_offset + PCIE_IN_CFG0_LIMIT, pcie->cfg.end);
232 wmb();
233
234 /* Enable outbound address translation */
235 regmap_write_bits(pcie->sys_ctrl, pcie->pcie_ctrl_offset, PCIE_OBTRANS, PCIE_OBTRANS);
236 wmb();
237
238 /*
239 * Program PCIe command register for core to:
240 * enable memory space
241 * enable bus master
242 * enable io
243 */
244 writel_relaxed(7, pcie->base + PCI_CONFIG_COMMAND_STATUS);
245 /* which is which */
246 wmb();
247 }
248
249 static unsigned oxnas_pcie_cfg_to_offset(
250 struct pci_sys_data *sys,
251 unsigned char bus_number,
252 unsigned int devfn,
253 int where)
254 {
255 unsigned int function = PCI_FUNC(devfn);
256 unsigned int slot = PCI_SLOT(devfn);
257 unsigned char bus_number_offset;
258
259 bus_number_offset = bus_number - sys->busnr;
260
261 /*
262 * We'll assume for now that the offset, function, slot, bus encoding
263 * should map onto linear, contiguous addresses in PCIe config space,
264 * albeit that the majority will be unused as only slot 0 is valid for
265 * any PCIe bus and most devices have only function 0
266 *
267 * Could be that PCIe in fact works by not encoding the slot number into
268 * the config space address as it's known that only slot 0 is valid.
269 * We'll have to experiment if/when we get a PCIe switch connected to
270 * the PCIe host
271 */
272 return (bus_number_offset << 20) | (slot << 15) | (function << 12) |
273 (where & ~3);
274 }
275
276 /* PCI configuration space write function */
277 static int oxnas_pcie_wr_conf(struct pci_bus *bus, u32 devfn,
278 int where, int size, u32 val)
279 {
280 unsigned long flags;
281 struct oxnas_pcie *pcie = sys_to_pcie(bus->sysdata);
282 unsigned offset;
283 u32 value;
284 u32 lanes;
285
286 /* Only a single device per bus for PCIe point-to-point links */
287 if (PCI_SLOT(devfn) > 0)
288 return PCIBIOS_DEVICE_NOT_FOUND;
289
290 if (!pcie->haslink)
291 return PCIBIOS_DEVICE_NOT_FOUND;
292
293 offset = oxnas_pcie_cfg_to_offset(bus->sysdata, bus->number, devfn,
294 where);
295
296 value = val << (8 * (where & 3));
297 lanes = (0xf >> (4-size)) << (where & 3);
298 /* it race with mem and io write, but the possibility is low, normally
299 * all config writes happens at driver initialize stage, wont interleave
300 * with others.
301 * and many pcie cards use dword (4bytes) access mem/io access only,
302 * so not bother to copy that ugly work-around now. */
303 spin_lock_irqsave(&pcie->lock, flags);
304 set_out_lanes(pcie, lanes);
305 writel_relaxed(value, pcie->cfgbase + offset);
306 set_out_lanes(pcie, 0xf);
307 spin_unlock_irqrestore(&pcie->lock, flags);
308
309 return PCIBIOS_SUCCESSFUL;
310 }
311
312 /* PCI configuration space read function */
313 static int oxnas_pcie_rd_conf(struct pci_bus *bus, u32 devfn, int where,
314 int size, u32 *val)
315 {
316 struct oxnas_pcie *pcie = sys_to_pcie(bus->sysdata);
317 unsigned offset;
318 u32 value;
319 u32 left_bytes, right_bytes;
320
321 /* Only a single device per bus for PCIe point-to-point links */
322 if (PCI_SLOT(devfn) > 0) {
323 *val = 0xffffffff;
324 return PCIBIOS_DEVICE_NOT_FOUND;
325 }
326
327 if (!pcie->haslink) {
328 *val = 0xffffffff;
329 return PCIBIOS_DEVICE_NOT_FOUND;
330 }
331
332 offset = oxnas_pcie_cfg_to_offset(bus->sysdata, bus->number, devfn,
333 where);
334 value = readl_relaxed(pcie->cfgbase + offset);
335 left_bytes = where & 3;
336 right_bytes = 4 - left_bytes - size;
337 value <<= right_bytes * 8;
338 value >>= (left_bytes + right_bytes) * 8;
339 *val = value;
340
341 return PCIBIOS_SUCCESSFUL;
342 }
343
344 static struct pci_ops oxnas_pcie_ops = {
345 .read = oxnas_pcie_rd_conf,
346 .write = oxnas_pcie_wr_conf,
347 };
348
349 static int oxnas_pcie_setup(int nr, struct pci_sys_data *sys)
350 {
351 struct oxnas_pcie *pcie = sys_to_pcie(sys);
352
353 pci_add_resource_offset(&sys->resources, &pcie->non_mem, sys->mem_offset);
354 pci_add_resource_offset(&sys->resources, &pcie->pre_mem, sys->mem_offset);
355 pci_add_resource_offset(&sys->resources, &pcie->io, sys->io_offset);
356 pci_add_resource(&sys->resources, &pcie->busn);
357 if (sys->busnr == 0) { /* default one */
358 sys->busnr = pcie->busn.start;
359 }
360 /* do not use devm_ioremap_resource, it does not like cfg resource */
361 pcie->cfgbase = devm_ioremap(&pcie->pdev->dev, pcie->cfg.start,
362 resource_size(&pcie->cfg));
363 if (!pcie->cfgbase)
364 return -ENOMEM;
365
366 oxnas_pcie_setup_hw(pcie);
367
368 return 1;
369 }
370
371 static void oxnas_pcie_enable(struct device *dev, struct oxnas_pcie *pcie)
372 {
373 struct hw_pci hw;
374 int i;
375
376 memset(&hw, 0, sizeof(hw));
377 for (i = 0; i < NUM_CONTROLLERS; i++)
378 pcie->private_data[i] = pcie;
379
380 hw.nr_controllers = NUM_CONTROLLERS;
381 /* I think use stack pointer is a bad idea though it is valid in this case */
382 hw.private_data = pcie->private_data;
383 hw.setup = oxnas_pcie_setup;
384 hw.map_irq = of_irq_parse_and_map_pci;
385 hw.ops = &oxnas_pcie_ops;
386
387 /* pass dev to maintain of tree, interrupt mapping rely on this */
388 pci_common_init_dev(dev, &hw);
389 }
390
391 static int oxnas_pcie_shared_init(struct platform_device *pdev, struct oxnas_pcie *pcie)
392 {
393 if (++pcie_shared.refcount == 1) {
394 phy_init(pcie->phy);
395 phy_power_on(pcie->phy);
396 return 0;
397 } else {
398 return 0;
399 }
400 }
401
402 #if 0
403 /* maybe we will call it when enter low power state */
404 static void oxnas_pcie_shared_deinit(struct platform_device *pdev)
405 {
406 if (--pcie_shared.refcount == 0) {
407 /* no cleanup needed */;
408 }
409 }
410 #endif
411
412 static int
413 oxnas_pcie_map_registers(struct platform_device *pdev,
414 struct device_node *np,
415 struct oxnas_pcie *pcie)
416 {
417 struct resource regs;
418 int ret = 0;
419 u32 outbound_ctrl_offset;
420 u32 pcie_ctrl_offset;
421
422 ret = of_address_to_resource(np, 0, &regs);
423 if (ret)
424 return -EINVAL;
425 pcie->base = devm_ioremap_resource(&pdev->dev, &regs);
426 if (!pcie->base)
427 return -ENOMEM;
428
429 ret = of_address_to_resource(np, 1, &regs);
430 if (ret)
431 return -EINVAL;
432 pcie->inbound = devm_ioremap_resource(&pdev->dev, &regs);
433 if (!pcie->inbound)
434 return -ENOMEM;
435
436 pcie->phy = devm_of_phy_get(&pdev->dev, np, NULL);
437 if (IS_ERR(pcie->phy)) {
438 if (PTR_ERR(pcie->phy) == -EPROBE_DEFER)
439 return PTR_ERR(pcie->phy);
440 pcie->phy = NULL;
441 }
442
443 if (of_property_read_u32(np, "plxtech,pcie-outbound-offset",
444 &outbound_ctrl_offset))
445 return -EINVAL;
446 pcie->outbound_offset = outbound_ctrl_offset;
447
448 if (of_property_read_u32(np, "plxtech,pcie-ctrl-offset",
449 &pcie_ctrl_offset))
450 return -EINVAL;
451 pcie->pcie_ctrl_offset = pcie_ctrl_offset;
452
453 return 0;
454 }
455
456 static int oxnas_pcie_init_res(struct platform_device *pdev,
457 struct oxnas_pcie *pcie,
458 struct device_node *np)
459 {
460 struct of_pci_range range;
461 struct of_pci_range_parser parser;
462 int ret;
463
464 if (of_pci_range_parser_init(&parser, np))
465 return -EINVAL;
466
467 /* Get the I/O and memory ranges from DT */
468 for_each_of_pci_range(&parser, &range) {
469
470 unsigned long restype = range.flags & IORESOURCE_TYPE_BITS;
471 if (restype == IORESOURCE_IO) {
472 of_pci_range_to_resource(&range, np, &pcie->io);
473 pcie->io.name = "I/O";
474 }
475 if (restype == IORESOURCE_MEM) {
476 if (range.flags & IORESOURCE_PREFETCH) {
477 of_pci_range_to_resource(&range, np, &pcie->pre_mem);
478 pcie->pre_mem.name = "PRE MEM";
479 } else {
480 of_pci_range_to_resource(&range, np, &pcie->non_mem);
481 pcie->non_mem.name = "NON MEM";
482 }
483
484 }
485 if (restype == 0)
486 of_pci_range_to_resource(&range, np, &pcie->cfg);
487 }
488
489 /* Get the bus range */
490 ret = of_pci_parse_bus_range(np, &pcie->busn);
491
492 if (ret) {
493 dev_err(&pdev->dev, "failed to parse bus-range property: %d\n",
494 ret);
495 return ret;
496 }
497
498 pcie->card_reset = of_get_gpio(np, 0);
499 if (pcie->card_reset < 0)
500 dev_info(&pdev->dev, "card reset gpio pin not exists\n");
501
502 if (of_property_read_u32(np, "plxtech,pcie-hcsl-bit", &pcie->hcsl_en))
503 return -EINVAL;
504
505 pcie->clk = of_clk_get_by_name(np, "pcie");
506 if (IS_ERR(pcie->clk)) {
507 return PTR_ERR(pcie->clk);
508 }
509
510 pcie->busclk = of_clk_get_by_name(np, "busclk");
511 if (IS_ERR(pcie->busclk)) {
512 clk_put(pcie->clk);
513 return PTR_ERR(pcie->busclk);
514 }
515
516 return 0;
517 }
518
519 static void oxnas_pcie_init_hw(struct platform_device *pdev,
520 struct oxnas_pcie *pcie)
521 {
522 u32 version_id;
523 int ret;
524
525 clk_prepare_enable(pcie->busclk);
526
527 /* reset PCIe cards use hard-wired gpio pin */
528 if (pcie->card_reset >= 0 &&
529 !gpio_direction_output(pcie->card_reset, 0)) {
530 wmb();
531 mdelay(10);
532 /* must tri-state the pin to pull it up */
533 gpio_direction_input(pcie->card_reset);
534 wmb();
535 mdelay(100);
536 }
537
538 /* ToDo: use phy power-on port... */
539 regmap_update_bits(pcie->sys_ctrl, SYS_CTRL_HCSL_CTRL_REGOFFSET,
540 BIT(pcie->hcsl_en), BIT(pcie->hcsl_en));
541
542 /* core */
543 ret = device_reset(&pdev->dev);
544 if (ret) {
545 dev_err(&pdev->dev, "core reset failed %d\n", ret);
546 return;
547 }
548
549 /* Start PCIe core clocks */
550 clk_prepare_enable(pcie->clk);
551
552 version_id = readl_relaxed(pcie->base + PCI_CONFIG_VERSION_DEVICEID);
553 dev_info(&pdev->dev, "PCIe version/deviceID 0x%x\n", version_id);
554
555 if (version_id != VERSION_ID_MAGIC) {
556 dev_info(&pdev->dev, "PCIe controller not found\n");
557 pcie->haslink = 0;
558 return;
559 }
560
561 /* allow entry to L23 state */
562 regmap_write_bits(pcie->sys_ctrl, pcie->pcie_ctrl_offset,
563 PCIE_READY_ENTR_L23, PCIE_READY_ENTR_L23);
564
565 /* Set PCIe core into RootCore mode */
566 regmap_write_bits(pcie->sys_ctrl, pcie->pcie_ctrl_offset,
567 PCIE_DEVICE_TYPE_MASK, PCIE_DEVICE_TYPE_ROOT);
568 wmb();
569
570 /* Bring up the PCI core */
571 regmap_write_bits(pcie->sys_ctrl, pcie->pcie_ctrl_offset,
572 PCIE_LTSSM, PCIE_LTSSM);
573 wmb();
574 }
575
576 static int oxnas_pcie_probe(struct platform_device *pdev)
577 {
578 struct oxnas_pcie *pcie;
579 struct device_node *np = pdev->dev.of_node;
580 int ret;
581
582 pcie = devm_kzalloc(&pdev->dev, sizeof(struct oxnas_pcie),
583 GFP_KERNEL);
584 if (!pcie)
585 return -ENOMEM;
586
587 pcie->pdev = pdev;
588 pcie->haslink = 1;
589 spin_lock_init(&pcie->lock);
590
591 pcie->sys_ctrl = syscon_regmap_lookup_by_compatible("oxsemi,ox820-sys-ctrl");
592 if (IS_ERR(pcie->sys_ctrl))
593 return PTR_ERR(pcie->sys_ctrl);
594
595 ret = oxnas_pcie_init_res(pdev, pcie, np);
596 if (ret)
597 return ret;
598 if (pcie->card_reset >= 0) {
599 ret = gpio_request_one(pcie->card_reset, GPIOF_DIR_IN,
600 dev_name(&pdev->dev));
601 if (ret) {
602 dev_err(&pdev->dev, "cannot request gpio pin %d\n",
603 pcie->card_reset);
604 return ret;
605 }
606 }
607
608 ret = oxnas_pcie_map_registers(pdev, np, pcie);
609 if (ret) {
610 dev_err(&pdev->dev, "cannot map registers\n");
611 goto err_free_gpio;
612 }
613
614 ret = oxnas_pcie_shared_init(pdev, pcie);
615 if (ret)
616 goto err_free_gpio;
617
618 /* if hw not found, haslink cleared */
619 oxnas_pcie_init_hw(pdev, pcie);
620
621 if (pcie->haslink && oxnas_pcie_link_up(pcie)) {
622 pcie->haslink = 1;
623 dev_info(&pdev->dev, "link up\n");
624 } else {
625 pcie->haslink = 0;
626 dev_info(&pdev->dev, "link down\n");
627 }
628 /* should we register our controller even when pcie->haslink is 0 ? */
629 /* register the controller with framework */
630 oxnas_pcie_enable(&pdev->dev, pcie);
631
632 return 0;
633
634 err_free_gpio:
635 if (pcie->card_reset)
636 gpio_free(pcie->card_reset);
637
638 return ret;
639 }
640
641 static const struct of_device_id oxnas_pcie_of_match_table[] = {
642 { .compatible = "plxtech,nas782x-pcie", },
643 {},
644 };
645
646 static struct platform_driver oxnas_pcie_driver = {
647 .driver = {
648 .name = "oxnas-pcie",
649 .suppress_bind_attrs = true,
650 .of_match_table = oxnas_pcie_of_match_table,
651 },
652 .probe = oxnas_pcie_probe,
653 };
654
655 builtin_platform_driver(oxnas_pcie_driver);