2 * PCIe driver for Marvell Armada 370 and Armada XP SoCs
4 * This file is licensed under the terms of the GNU General Public
5 * License version 2. This program is licensed "as is" without any
6 * warranty of any kind, whether express or implied.
9 #include <linux/kernel.h>
10 #include <linux/pci.h>
11 #include <linux/clk.h>
12 #include <linux/module.h>
13 #include <linux/mbus.h>
14 #include <linux/slab.h>
15 #include <linux/platform_device.h>
16 #include <linux/of_address.h>
17 #include <linux/of_pci.h>
18 #include <linux/of_irq.h>
19 #include <linux/of_platform.h>
22 * PCIe unit register offsets.
24 #define PCIE_DEV_ID_OFF 0x0000
25 #define PCIE_CMD_OFF 0x0004
26 #define PCIE_DEV_REV_OFF 0x0008
27 #define PCIE_BAR_LO_OFF(n) (0x0010 + ((n) << 3))
28 #define PCIE_BAR_HI_OFF(n) (0x0014 + ((n) << 3))
29 #define PCIE_HEADER_LOG_4_OFF 0x0128
30 #define PCIE_BAR_CTRL_OFF(n) (0x1804 + (((n) - 1) * 4))
31 #define PCIE_WIN04_CTRL_OFF(n) (0x1820 + ((n) << 4))
32 #define PCIE_WIN04_BASE_OFF(n) (0x1824 + ((n) << 4))
33 #define PCIE_WIN04_REMAP_OFF(n) (0x182c + ((n) << 4))
34 #define PCIE_WIN5_CTRL_OFF 0x1880
35 #define PCIE_WIN5_BASE_OFF 0x1884
36 #define PCIE_WIN5_REMAP_OFF 0x188c
37 #define PCIE_CONF_ADDR_OFF 0x18f8
38 #define PCIE_CONF_ADDR_EN 0x80000000
39 #define PCIE_CONF_REG(r) ((((r) & 0xf00) << 16) | ((r) & 0xfc))
40 #define PCIE_CONF_BUS(b) (((b) & 0xff) << 16)
41 #define PCIE_CONF_DEV(d) (((d) & 0x1f) << 11)
42 #define PCIE_CONF_FUNC(f) (((f) & 0x7) << 8)
43 #define PCIE_CONF_ADDR(bus, devfn, where) \
44 (PCIE_CONF_BUS(bus) | PCIE_CONF_DEV(PCI_SLOT(devfn)) | \
45 PCIE_CONF_FUNC(PCI_FUNC(devfn)) | PCIE_CONF_REG(where) | \
47 #define PCIE_CONF_DATA_OFF 0x18fc
48 #define PCIE_MASK_OFF 0x1910
49 #define PCIE_MASK_ENABLE_INTS 0x0f000000
50 #define PCIE_CTRL_OFF 0x1a00
51 #define PCIE_CTRL_X1_MODE 0x0001
52 #define PCIE_STAT_OFF 0x1a04
53 #define PCIE_STAT_BUS 0xff00
54 #define PCIE_STAT_LINK_DOWN BIT(0)
55 #define PCIE_DEBUG_CTRL 0x1a60
56 #define PCIE_DEBUG_SOFT_RESET BIT(20)
59 * This product ID is registered by Marvell, and used when the Marvell
60 * SoC is not the root complex, but an endpoint on the PCIe bus. It is
61 * therefore safe to re-use this PCI ID for our emulated PCI-to-PCI
64 #define MARVELL_EMULATED_PCI_PCI_BRIDGE_ID 0x7846
66 /* PCI configuration space of a PCI-to-PCI bridge */
67 struct mvebu_sw_pci_bridge {
83 u8 secondary_latency_timer;
104 struct mvebu_pcie_port;
106 /* Structure representing all PCIe interfaces */
108 struct platform_device *pdev;
109 struct mvebu_pcie_port *ports;
111 struct resource realio;
113 struct resource busn;
117 /* Structure representing one PCIe interface */
118 struct mvebu_pcie_port {
121 spinlock_t conf_lock;
127 struct mvebu_sw_pci_bridge bridge;
128 struct device_node *dn;
129 struct mvebu_pcie *pcie;
130 phys_addr_t memwin_base;
132 phys_addr_t iowin_base;
136 static bool mvebu_pcie_link_up(struct mvebu_pcie_port *port)
138 return !(readl(port->base + PCIE_STAT_OFF) & PCIE_STAT_LINK_DOWN);
141 static void mvebu_pcie_set_local_bus_nr(struct mvebu_pcie_port *port, int nr)
145 stat = readl(port->base + PCIE_STAT_OFF);
146 stat &= ~PCIE_STAT_BUS;
148 writel(stat, port->base + PCIE_STAT_OFF);
152 * Setup PCIE BARs and Address Decode Wins:
153 * BAR[0,2] -> disabled, BAR[1] -> covers all DRAM banks
154 * WIN[0-3] -> DRAM bank[0-3]
156 static void __init mvebu_pcie_setup_wins(struct mvebu_pcie_port *port)
158 const struct mbus_dram_target_info *dram;
162 dram = mv_mbus_dram_info();
164 /* First, disable and clear BARs and windows. */
165 for (i = 1; i < 3; i++) {
166 writel(0, port->base + PCIE_BAR_CTRL_OFF(i));
167 writel(0, port->base + PCIE_BAR_LO_OFF(i));
168 writel(0, port->base + PCIE_BAR_HI_OFF(i));
171 for (i = 0; i < 5; i++) {
172 writel(0, port->base + PCIE_WIN04_CTRL_OFF(i));
173 writel(0, port->base + PCIE_WIN04_BASE_OFF(i));
174 writel(0, port->base + PCIE_WIN04_REMAP_OFF(i));
177 writel(0, port->base + PCIE_WIN5_CTRL_OFF);
178 writel(0, port->base + PCIE_WIN5_BASE_OFF);
179 writel(0, port->base + PCIE_WIN5_REMAP_OFF);
181 /* Setup windows for DDR banks. Count total DDR size on the fly. */
183 for (i = 0; i < dram->num_cs; i++) {
184 const struct mbus_dram_window *cs = dram->cs + i;
186 writel(cs->base & 0xffff0000,
187 port->base + PCIE_WIN04_BASE_OFF(i));
188 writel(0, port->base + PCIE_WIN04_REMAP_OFF(i));
189 writel(((cs->size - 1) & 0xffff0000) |
190 (cs->mbus_attr << 8) |
191 (dram->mbus_dram_target_id << 4) | 1,
192 port->base + PCIE_WIN04_CTRL_OFF(i));
197 /* Round up 'size' to the nearest power of two. */
198 if ((size & (size - 1)) != 0)
199 size = 1 << fls(size);
201 /* Setup BAR[1] to all DRAM banks. */
202 writel(dram->cs[0].base, port->base + PCIE_BAR_LO_OFF(1));
203 writel(0, port->base + PCIE_BAR_HI_OFF(1));
204 writel(((size - 1) & 0xffff0000) | 1,
205 port->base + PCIE_BAR_CTRL_OFF(1));
208 static void __init mvebu_pcie_setup_hw(struct mvebu_pcie_port *port)
213 /* Point PCIe unit MBUS decode windows to DRAM space. */
214 mvebu_pcie_setup_wins(port);
216 /* Master + slave enable. */
217 cmd = readw(port->base + PCIE_CMD_OFF);
218 cmd |= PCI_COMMAND_IO;
219 cmd |= PCI_COMMAND_MEMORY;
220 cmd |= PCI_COMMAND_MASTER;
221 writew(cmd, port->base + PCIE_CMD_OFF);
223 /* Enable interrupt lines A-D. */
224 mask = readl(port->base + PCIE_MASK_OFF);
225 mask |= PCIE_MASK_ENABLE_INTS;
226 writel(mask, port->base + PCIE_MASK_OFF);
229 static int mvebu_pcie_hw_rd_conf(struct mvebu_pcie_port *port,
231 u32 devfn, int where, int size, u32 *val)
233 writel(PCIE_CONF_ADDR(bus->number, devfn, where),
234 port->base + PCIE_CONF_ADDR_OFF);
236 *val = readl(port->base + PCIE_CONF_DATA_OFF);
239 *val = (*val >> (8 * (where & 3))) & 0xff;
241 *val = (*val >> (8 * (where & 3))) & 0xffff;
243 return PCIBIOS_SUCCESSFUL;
246 static int mvebu_pcie_hw_wr_conf(struct mvebu_pcie_port *port,
248 u32 devfn, int where, int size, u32 val)
250 int ret = PCIBIOS_SUCCESSFUL;
252 writel(PCIE_CONF_ADDR(bus->number, devfn, where),
253 port->base + PCIE_CONF_ADDR_OFF);
256 writel(val, port->base + PCIE_CONF_DATA_OFF);
258 writew(val, port->base + PCIE_CONF_DATA_OFF + (where & 3));
260 writeb(val, port->base + PCIE_CONF_DATA_OFF + (where & 3));
262 ret = PCIBIOS_BAD_REGISTER_NUMBER;
267 static void mvebu_pcie_handle_iobase_change(struct mvebu_pcie_port *port)
271 /* Are the new iobase/iolimit values invalid? */
272 if (port->bridge.iolimit < port->bridge.iobase ||
273 port->bridge.iolimitupper < port->bridge.iobaseupper) {
275 /* If a window was configured, remove it */
276 if (port->iowin_base) {
277 mvebu_mbus_del_window(port->iowin_base,
279 port->iowin_base = 0;
280 port->iowin_size = 0;
287 * We read the PCI-to-PCI bridge emulated registers, and
288 * calculate the base address and size of the address decoding
289 * window to setup, according to the PCI-to-PCI bridge
290 * specifications. iobase is the bus address, port->iowin_base
291 * is the CPU address.
293 iobase = ((port->bridge.iobase & 0xF0) << 8) |
294 (port->bridge.iobaseupper << 16);
295 port->iowin_base = port->pcie->io.start + iobase;
296 port->iowin_size = ((0xFFF | ((port->bridge.iolimit & 0xF0) << 8) |
297 (port->bridge.iolimitupper << 16)) -
300 mvebu_mbus_add_window_remap_flags(port->name, port->iowin_base,
305 pci_ioremap_io(iobase, port->iowin_base);
308 static void mvebu_pcie_handle_membase_change(struct mvebu_pcie_port *port)
310 /* Are the new membase/memlimit values invalid? */
311 if (port->bridge.memlimit < port->bridge.membase) {
313 /* If a window was configured, remove it */
314 if (port->memwin_base) {
315 mvebu_mbus_del_window(port->memwin_base,
317 port->memwin_base = 0;
318 port->memwin_size = 0;
325 * We read the PCI-to-PCI bridge emulated registers, and
326 * calculate the base address and size of the address decoding
327 * window to setup, according to the PCI-to-PCI bridge
330 port->memwin_base = ((port->bridge.membase & 0xFFF0) << 16);
332 (((port->bridge.memlimit & 0xFFF0) << 16) | 0xFFFFF) -
335 mvebu_mbus_add_window_remap_flags(port->name, port->memwin_base,
342 * Initialize the configuration space of the PCI-to-PCI bridge
343 * associated with the given PCIe interface.
345 static void mvebu_sw_pci_bridge_init(struct mvebu_pcie_port *port)
347 struct mvebu_sw_pci_bridge *bridge = &port->bridge;
349 memset(bridge, 0, sizeof(struct mvebu_sw_pci_bridge));
351 bridge->status = PCI_STATUS_CAP_LIST;
352 bridge->class = PCI_CLASS_BRIDGE_PCI;
353 bridge->vendor = PCI_VENDOR_ID_MARVELL;
354 bridge->device = MARVELL_EMULATED_PCI_PCI_BRIDGE_ID;
355 bridge->header_type = PCI_HEADER_TYPE_BRIDGE;
356 bridge->cache_line_size = 0x10;
358 /* We support 32 bits I/O addressing */
359 bridge->iobase = PCI_IO_RANGE_TYPE_32;
360 bridge->iolimit = PCI_IO_RANGE_TYPE_32;
364 * Read the configuration space of the PCI-to-PCI bridge associated to
365 * the given PCIe interface.
367 static int mvebu_sw_pci_bridge_read(struct mvebu_pcie_port *port,
368 unsigned int where, int size, u32 *value)
370 struct mvebu_sw_pci_bridge *bridge = &port->bridge;
372 switch (where & ~3) {
374 *value = bridge->device << 16 | bridge->vendor;
378 *value = bridge->status << 16 | bridge->command;
381 case PCI_CLASS_REVISION:
382 *value = bridge->class << 16 | bridge->interface << 8 |
386 case PCI_CACHE_LINE_SIZE:
387 *value = bridge->bist << 24 | bridge->header_type << 16 |
388 bridge->latency_timer << 8 | bridge->cache_line_size;
391 case PCI_BASE_ADDRESS_0 ... PCI_BASE_ADDRESS_1:
392 *value = bridge->bar[((where & ~3) - PCI_BASE_ADDRESS_0) / 4];
395 case PCI_PRIMARY_BUS:
396 *value = (bridge->secondary_latency_timer << 24 |
397 bridge->subordinate_bus << 16 |
398 bridge->secondary_bus << 8 |
399 bridge->primary_bus);
403 *value = (bridge->secondary_status << 16 |
404 bridge->iolimit << 8 |
408 case PCI_MEMORY_BASE:
409 *value = (bridge->memlimit << 16 | bridge->membase);
412 case PCI_PREF_MEMORY_BASE:
413 *value = (bridge->prefmemlimit << 16 | bridge->prefmembase);
416 case PCI_PREF_BASE_UPPER32:
417 *value = bridge->prefbaseupper;
420 case PCI_PREF_LIMIT_UPPER32:
421 *value = bridge->preflimitupper;
424 case PCI_IO_BASE_UPPER16:
425 *value = (bridge->iolimitupper << 16 | bridge->iobaseupper);
428 case PCI_ROM_ADDRESS1:
434 return PCIBIOS_BAD_REGISTER_NUMBER;
438 *value = (*value >> (8 * (where & 3))) & 0xffff;
440 *value = (*value >> (8 * (where & 3))) & 0xff;
442 return PCIBIOS_SUCCESSFUL;
445 /* Write to the PCI-to-PCI bridge configuration space */
446 static int mvebu_sw_pci_bridge_write(struct mvebu_pcie_port *port,
447 unsigned int where, int size, u32 value)
449 struct mvebu_sw_pci_bridge *bridge = &port->bridge;
456 mask = ~(0xffff << ((where & 3) * 8));
458 mask = ~(0xff << ((where & 3) * 8));
460 return PCIBIOS_BAD_REGISTER_NUMBER;
462 err = mvebu_sw_pci_bridge_read(port, where & ~3, 4, ®);
466 value = (reg & mask) | value << ((where & 3) * 8);
468 switch (where & ~3) {
470 bridge->command = value & 0xffff;
471 bridge->status = value >> 16;
474 case PCI_BASE_ADDRESS_0 ... PCI_BASE_ADDRESS_1:
475 bridge->bar[((where & ~3) - PCI_BASE_ADDRESS_0) / 4] = value;
480 * We also keep bit 1 set, it is a read-only bit that
481 * indicates we support 32 bits addressing for the
484 bridge->iobase = (value & 0xff) | PCI_IO_RANGE_TYPE_32;
485 bridge->iolimit = ((value >> 8) & 0xff) | PCI_IO_RANGE_TYPE_32;
486 bridge->secondary_status = value >> 16;
487 mvebu_pcie_handle_iobase_change(port);
490 case PCI_MEMORY_BASE:
491 bridge->membase = value & 0xffff;
492 bridge->memlimit = value >> 16;
493 mvebu_pcie_handle_membase_change(port);
496 case PCI_PREF_MEMORY_BASE:
497 bridge->prefmembase = value & 0xffff;
498 bridge->prefmemlimit = value >> 16;
501 case PCI_PREF_BASE_UPPER32:
502 bridge->prefbaseupper = value;
505 case PCI_PREF_LIMIT_UPPER32:
506 bridge->preflimitupper = value;
509 case PCI_IO_BASE_UPPER16:
510 bridge->iobaseupper = value & 0xffff;
511 bridge->iolimitupper = value >> 16;
512 mvebu_pcie_handle_iobase_change(port);
515 case PCI_PRIMARY_BUS:
516 bridge->primary_bus = value & 0xff;
517 bridge->secondary_bus = (value >> 8) & 0xff;
518 bridge->subordinate_bus = (value >> 16) & 0xff;
519 bridge->secondary_latency_timer = (value >> 24) & 0xff;
520 mvebu_pcie_set_local_bus_nr(port, bridge->secondary_bus);
527 return PCIBIOS_SUCCESSFUL;
530 static inline struct mvebu_pcie *sys_to_pcie(struct pci_sys_data *sys)
532 return sys->private_data;
535 static struct mvebu_pcie_port *
536 mvebu_pcie_find_port(struct mvebu_pcie *pcie, struct pci_bus *bus,
541 for (i = 0; i < pcie->nports; i++) {
542 struct mvebu_pcie_port *port = &pcie->ports[i];
543 if (bus->number == 0 && port->devfn == devfn)
545 if (bus->number != 0 &&
546 port->bridge.secondary_bus == bus->number)
553 /* PCI configuration space write function */
554 static int mvebu_pcie_wr_conf(struct pci_bus *bus, u32 devfn,
555 int where, int size, u32 val)
557 struct mvebu_pcie *pcie = sys_to_pcie(bus->sysdata);
558 struct mvebu_pcie_port *port;
562 port = mvebu_pcie_find_port(pcie, bus, devfn);
564 return PCIBIOS_DEVICE_NOT_FOUND;
566 /* Access the emulated PCI-to-PCI bridge */
567 if (bus->number == 0)
568 return mvebu_sw_pci_bridge_write(port, where, size, val);
570 if (!port->haslink || PCI_SLOT(devfn) != 0)
571 return PCIBIOS_DEVICE_NOT_FOUND;
573 /* Access the real PCIe interface */
574 spin_lock_irqsave(&port->conf_lock, flags);
575 ret = mvebu_pcie_hw_wr_conf(port, bus,
576 PCI_DEVFN(1, PCI_FUNC(devfn)),
578 spin_unlock_irqrestore(&port->conf_lock, flags);
583 /* PCI configuration space read function */
584 static int mvebu_pcie_rd_conf(struct pci_bus *bus, u32 devfn, int where,
587 struct mvebu_pcie *pcie = sys_to_pcie(bus->sysdata);
588 struct mvebu_pcie_port *port;
592 port = mvebu_pcie_find_port(pcie, bus, devfn);
595 return PCIBIOS_DEVICE_NOT_FOUND;
598 /* Access the emulated PCI-to-PCI bridge */
599 if (bus->number == 0)
600 return mvebu_sw_pci_bridge_read(port, where, size, val);
602 if (!port->haslink || PCI_SLOT(devfn) != 0) {
604 return PCIBIOS_DEVICE_NOT_FOUND;
607 /* Access the real PCIe interface */
608 spin_lock_irqsave(&port->conf_lock, flags);
609 ret = mvebu_pcie_hw_rd_conf(port, bus,
610 PCI_DEVFN(1, PCI_FUNC(devfn)),
612 spin_unlock_irqrestore(&port->conf_lock, flags);
617 static struct pci_ops mvebu_pcie_ops = {
618 .read = mvebu_pcie_rd_conf,
619 .write = mvebu_pcie_wr_conf,
622 static int __init mvebu_pcie_setup(int nr, struct pci_sys_data *sys)
624 struct mvebu_pcie *pcie = sys_to_pcie(sys);
627 pci_add_resource_offset(&sys->resources, &pcie->realio, sys->io_offset);
628 pci_add_resource_offset(&sys->resources, &pcie->mem, sys->mem_offset);
629 pci_add_resource(&sys->resources, &pcie->busn);
631 for (i = 0; i < pcie->nports; i++) {
632 struct mvebu_pcie_port *port = &pcie->ports[i];
633 mvebu_pcie_setup_hw(port);
639 static int __init mvebu_pcie_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
644 ret = of_irq_map_pci(dev, &oirq);
648 return irq_create_of_mapping(oirq.controller, oirq.specifier,
652 static struct pci_bus *mvebu_pcie_scan_bus(int nr, struct pci_sys_data *sys)
654 struct mvebu_pcie *pcie = sys_to_pcie(sys);
657 bus = pci_create_root_bus(&pcie->pdev->dev, sys->busnr,
658 &mvebu_pcie_ops, sys, &sys->resources);
662 pci_scan_child_bus(bus);
667 resource_size_t mvebu_pcie_align_resource(struct pci_dev *dev,
668 const struct resource *res,
669 resource_size_t start,
670 resource_size_t size,
671 resource_size_t align)
673 if (dev->bus->number != 0)
677 * On the PCI-to-PCI bridge side, the I/O windows must have at
678 * least a 64 KB size and be aligned on their size, and the
679 * memory windows must have at least a 1 MB size and be
680 * aligned on their size
682 if (res->flags & IORESOURCE_IO)
683 return round_up(start, max((resource_size_t)SZ_64K, size));
684 else if (res->flags & IORESOURCE_MEM)
685 return round_up(start, max((resource_size_t)SZ_1M, size));
690 static void __init mvebu_pcie_enable(struct mvebu_pcie *pcie)
694 memset(&hw, 0, sizeof(hw));
696 hw.nr_controllers = 1;
697 hw.private_data = (void **)&pcie;
698 hw.setup = mvebu_pcie_setup;
699 hw.scan = mvebu_pcie_scan_bus;
700 hw.map_irq = mvebu_pcie_map_irq;
701 hw.ops = &mvebu_pcie_ops;
702 hw.align_resource = mvebu_pcie_align_resource;
704 pci_common_init(&hw);
708 * Looks up the list of register addresses encoded into the reg =
709 * <...> property for one that matches the given port/lane. Once
712 static void __iomem * __init
713 mvebu_pcie_map_registers(struct platform_device *pdev,
714 struct device_node *np,
715 struct mvebu_pcie_port *port)
717 struct resource regs;
720 ret = of_address_to_resource(np, 0, ®s);
724 return devm_request_and_ioremap(&pdev->dev, ®s);
727 static int __init mvebu_pcie_probe(struct platform_device *pdev)
729 struct mvebu_pcie *pcie;
730 struct device_node *np = pdev->dev.of_node;
731 struct of_pci_range range;
732 struct of_pci_range_parser parser;
733 struct device_node *child;
736 pcie = devm_kzalloc(&pdev->dev, sizeof(struct mvebu_pcie),
743 if (of_pci_range_parser_init(&parser, np))
746 /* Get the I/O and memory ranges from DT */
747 for_each_of_pci_range(&parser, &range) {
748 unsigned long restype = range.flags & IORESOURCE_TYPE_BITS;
749 if (restype == IORESOURCE_IO) {
750 of_pci_range_to_resource(&range, np, &pcie->io);
751 of_pci_range_to_resource(&range, np, &pcie->realio);
752 pcie->io.name = "I/O";
753 pcie->realio.start = max_t(resource_size_t,
756 pcie->realio.end = min_t(resource_size_t,
758 range.pci_addr + range.size);
760 if (restype == IORESOURCE_MEM) {
761 of_pci_range_to_resource(&range, np, &pcie->mem);
762 pcie->mem.name = "MEM";
766 /* Get the bus range */
767 ret = of_pci_parse_bus_range(np, &pcie->busn);
769 dev_err(&pdev->dev, "failed to parse bus-range property: %d\n",
774 for_each_child_of_node(pdev->dev.of_node, child) {
775 if (!of_device_is_available(child))
780 pcie->ports = devm_kzalloc(&pdev->dev, pcie->nports *
781 sizeof(struct mvebu_pcie_port),
787 for_each_child_of_node(pdev->dev.of_node, child) {
788 struct mvebu_pcie_port *port = &pcie->ports[i];
790 if (!of_device_is_available(child))
795 if (of_property_read_u32(child, "marvell,pcie-port",
798 "ignoring PCIe DT node, missing pcie-port property\n");
802 if (of_property_read_u32(child, "marvell,pcie-lane",
806 port->name = kasprintf(GFP_KERNEL, "pcie%d.%d",
807 port->port, port->lane);
809 port->devfn = of_pci_get_devfn(child);
813 port->base = mvebu_pcie_map_registers(pdev, child, port);
815 dev_err(&pdev->dev, "PCIe%d.%d: cannot map registers\n",
816 port->port, port->lane);
820 if (mvebu_pcie_link_up(port)) {
822 dev_info(&pdev->dev, "PCIe%d.%d: link up\n",
823 port->port, port->lane);
826 dev_info(&pdev->dev, "PCIe%d.%d: link down\n",
827 port->port, port->lane);
830 port->clk = of_clk_get_by_name(child, NULL);
831 if (IS_ERR(port->clk)) {
832 dev_err(&pdev->dev, "PCIe%d.%d: cannot get clock\n",
833 port->port, port->lane);
841 clk_prepare_enable(port->clk);
842 spin_lock_init(&port->conf_lock);
844 mvebu_sw_pci_bridge_init(port);
849 mvebu_pcie_enable(pcie);
854 static const struct of_device_id mvebu_pcie_of_match_table[] = {
855 { .compatible = "marvell,armada-xp-pcie", },
856 { .compatible = "marvell,armada-370-pcie", },
859 MODULE_DEVICE_TABLE(of, mvebu_pcie_of_match_table);
861 static struct platform_driver mvebu_pcie_driver = {
863 .owner = THIS_MODULE,
864 .name = "mvebu-pcie",
866 of_match_ptr(mvebu_pcie_of_match_table),
870 static int __init mvebu_pcie_init(void)
872 return platform_driver_probe(&mvebu_pcie_driver,
876 subsys_initcall(mvebu_pcie_init);
878 MODULE_AUTHOR("Thomas Petazzoni <thomas.petazzoni@free-electrons.com>");
879 MODULE_DESCRIPTION("Marvell EBU PCIe driver");
880 MODULE_LICENSE("GPLv2");