pci-xgene.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  1. /**
  2. * APM X-Gene PCIe Driver
  3. *
  4. * Copyright (c) 2014 Applied Micro Circuits Corporation.
  5. *
  6. * Author: Tanmay Inamdar <tinamdar@apm.com>.
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License as published by the
  10. * Free Software Foundation; either version 2 of the License, or (at your
  11. * option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. */
  19. #include <linux/clk-private.h>
  20. #include <linux/delay.h>
  21. #include <linux/io.h>
  22. #include <linux/jiffies.h>
  23. #include <linux/memblock.h>
  24. #include <linux/module.h>
  25. #include <linux/of.h>
  26. #include <linux/of_address.h>
  27. #include <linux/of_irq.h>
  28. #include <linux/of_pci.h>
  29. #include <linux/pci.h>
  30. #include <linux/platform_device.h>
  31. #include <linux/slab.h>
  32. #define PCIECORE_CTLANDSTATUS 0x50
  33. #define PIM1_1L 0x80
  34. #define IBAR2 0x98
  35. #define IR2MSK 0x9c
  36. #define PIM2_1L 0xa0
  37. #define IBAR3L 0xb4
  38. #define IR3MSKL 0xbc
  39. #define PIM3_1L 0xc4
  40. #define OMR1BARL 0x100
  41. #define OMR2BARL 0x118
  42. #define OMR3BARL 0x130
  43. #define CFGBARL 0x154
  44. #define CFGBARH 0x158
  45. #define CFGCTL 0x15c
  46. #define RTDID 0x160
  47. #define BRIDGE_CFG_0 0x2000
  48. #define BRIDGE_CFG_4 0x2010
  49. #define BRIDGE_STATUS_0 0x2600
  50. #define LINK_UP_MASK 0x00000100
  51. #define AXI_EP_CFG_ACCESS 0x10000
  52. #define EN_COHERENCY 0xF0000000
  53. #define EN_REG 0x00000001
  54. #define OB_LO_IO 0x00000002
  55. #define XGENE_PCIE_VENDORID 0x10E8
  56. #define XGENE_PCIE_DEVICEID 0xE004
  57. #define SZ_1T (SZ_1G*1024ULL)
  58. #define PIPE_PHY_RATE_RD(src) ((0xc000 & (u32)(src)) >> 0xe)
  59. struct xgene_pcie_port {
  60. struct device_node *node;
  61. struct device *dev;
  62. struct clk *clk;
  63. void __iomem *csr_base;
  64. void __iomem *cfg_base;
  65. unsigned long cfg_addr;
  66. bool link_up;
  67. };
  68. static inline u32 pcie_bar_low_val(u32 addr, u32 flags)
  69. {
  70. return (addr & PCI_BASE_ADDRESS_MEM_MASK) | flags;
  71. }
  72. /* PCIe Configuration Out/In */
  73. static inline void xgene_pcie_cfg_out32(void __iomem *addr, int offset, u32 val)
  74. {
  75. writel(val, addr + offset);
  76. }
  77. static inline void xgene_pcie_cfg_out16(void __iomem *addr, int offset, u16 val)
  78. {
  79. u32 val32 = readl(addr + (offset & ~0x3));
  80. switch (offset & 0x3) {
  81. case 2:
  82. val32 &= ~0xFFFF0000;
  83. val32 |= (u32)val << 16;
  84. break;
  85. case 0:
  86. default:
  87. val32 &= ~0xFFFF;
  88. val32 |= val;
  89. break;
  90. }
  91. writel(val32, addr + (offset & ~0x3));
  92. }
  93. static inline void xgene_pcie_cfg_out8(void __iomem *addr, int offset, u8 val)
  94. {
  95. u32 val32 = readl(addr + (offset & ~0x3));
  96. switch (offset & 0x3) {
  97. case 0:
  98. val32 &= ~0xFF;
  99. val32 |= val;
  100. break;
  101. case 1:
  102. val32 &= ~0xFF00;
  103. val32 |= (u32)val << 8;
  104. break;
  105. case 2:
  106. val32 &= ~0xFF0000;
  107. val32 |= (u32)val << 16;
  108. break;
  109. case 3:
  110. default:
  111. val32 &= ~0xFF000000;
  112. val32 |= (u32)val << 24;
  113. break;
  114. }
  115. writel(val32, addr + (offset & ~0x3));
  116. }
  117. static inline void xgene_pcie_cfg_in32(void __iomem *addr, int offset, u32 *val)
  118. {
  119. *val = readl(addr + offset);
  120. }
  121. static inline void xgene_pcie_cfg_in16(void __iomem *addr, int offset, u32 *val)
  122. {
  123. *val = readl(addr + (offset & ~0x3));
  124. switch (offset & 0x3) {
  125. case 2:
  126. *val >>= 16;
  127. break;
  128. }
  129. *val &= 0xFFFF;
  130. }
  131. static inline void xgene_pcie_cfg_in8(void __iomem *addr, int offset, u32 *val)
  132. {
  133. *val = readl(addr + (offset & ~0x3));
  134. switch (offset & 0x3) {
  135. case 3:
  136. *val = *val >> 24;
  137. break;
  138. case 2:
  139. *val = *val >> 16;
  140. break;
  141. case 1:
  142. *val = *val >> 8;
  143. break;
  144. }
  145. *val &= 0xFF;
  146. }
  147. /*
  148. * When the address bit [17:16] is 2'b01, the Configuration access will be
  149. * treated as Type 1 and it will be forwarded to external PCIe device.
  150. */
  151. static void __iomem *xgene_pcie_get_cfg_base(struct pci_bus *bus)
  152. {
  153. struct xgene_pcie_port *port = bus->sysdata;
  154. if (bus->number >= (bus->primary + 1))
  155. return port->cfg_base + AXI_EP_CFG_ACCESS;
  156. return port->cfg_base;
  157. }
  158. /*
  159. * For Configuration request, RTDID register is used as Bus Number,
  160. * Device Number and Function number of the header fields.
  161. */
  162. static void xgene_pcie_set_rtdid_reg(struct pci_bus *bus, uint devfn)
  163. {
  164. struct xgene_pcie_port *port = bus->sysdata;
  165. unsigned int b, d, f;
  166. u32 rtdid_val = 0;
  167. b = bus->number;
  168. d = PCI_SLOT(devfn);
  169. f = PCI_FUNC(devfn);
  170. if (!pci_is_root_bus(bus))
  171. rtdid_val = (b << 8) | (d << 3) | f;
  172. writel(rtdid_val, port->csr_base + RTDID);
  173. /* read the register back to ensure flush */
  174. readl(port->csr_base + RTDID);
  175. }
  176. /*
  177. * X-Gene PCIe port uses BAR0-BAR1 of RC's configuration space as
  178. * the translation from PCI bus to native BUS. Entire DDR region
  179. * is mapped into PCIe space using these registers, so it can be
  180. * reached by DMA from EP devices. The BAR0/1 of bridge should be
  181. * hidden during enumeration to avoid the sizing and resource allocation
  182. * by PCIe core.
  183. */
  184. static bool xgene_pcie_hide_rc_bars(struct pci_bus *bus, int offset)
  185. {
  186. if (pci_is_root_bus(bus) && ((offset == PCI_BASE_ADDRESS_0) ||
  187. (offset == PCI_BASE_ADDRESS_1)))
  188. return true;
  189. return false;
  190. }
  191. static int xgene_pcie_read_config(struct pci_bus *bus, unsigned int devfn,
  192. int offset, int len, u32 *val)
  193. {
  194. struct xgene_pcie_port *port = bus->sysdata;
  195. void __iomem *addr;
  196. if ((pci_is_root_bus(bus) && devfn != 0) || !port->link_up)
  197. return PCIBIOS_DEVICE_NOT_FOUND;
  198. if (xgene_pcie_hide_rc_bars(bus, offset)) {
  199. *val = 0;
  200. return PCIBIOS_SUCCESSFUL;
  201. }
  202. xgene_pcie_set_rtdid_reg(bus, devfn);
  203. addr = xgene_pcie_get_cfg_base(bus);
  204. switch (len) {
  205. case 1:
  206. xgene_pcie_cfg_in8(addr, offset, val);
  207. break;
  208. case 2:
  209. xgene_pcie_cfg_in16(addr, offset, val);
  210. break;
  211. default:
  212. xgene_pcie_cfg_in32(addr, offset, val);
  213. break;
  214. }
  215. return PCIBIOS_SUCCESSFUL;
  216. }
  217. static int xgene_pcie_write_config(struct pci_bus *bus, unsigned int devfn,
  218. int offset, int len, u32 val)
  219. {
  220. struct xgene_pcie_port *port = bus->sysdata;
  221. void __iomem *addr;
  222. if ((pci_is_root_bus(bus) && devfn != 0) || !port->link_up)
  223. return PCIBIOS_DEVICE_NOT_FOUND;
  224. if (xgene_pcie_hide_rc_bars(bus, offset))
  225. return PCIBIOS_SUCCESSFUL;
  226. xgene_pcie_set_rtdid_reg(bus, devfn);
  227. addr = xgene_pcie_get_cfg_base(bus);
  228. switch (len) {
  229. case 1:
  230. xgene_pcie_cfg_out8(addr, offset, (u8)val);
  231. break;
  232. case 2:
  233. xgene_pcie_cfg_out16(addr, offset, (u16)val);
  234. break;
  235. default:
  236. xgene_pcie_cfg_out32(addr, offset, val);
  237. break;
  238. }
  239. return PCIBIOS_SUCCESSFUL;
  240. }
  241. static struct pci_ops xgene_pcie_ops = {
  242. .read = xgene_pcie_read_config,
  243. .write = xgene_pcie_write_config
  244. };
  245. static u64 xgene_pcie_set_ib_mask(void __iomem *csr_base, u32 addr,
  246. u32 flags, u64 size)
  247. {
  248. u64 mask = (~(size - 1) & PCI_BASE_ADDRESS_MEM_MASK) | flags;
  249. u32 val32 = 0;
  250. u32 val;
  251. val32 = readl(csr_base + addr);
  252. val = (val32 & 0x0000ffff) | (lower_32_bits(mask) << 16);
  253. writel(val, csr_base + addr);
  254. val32 = readl(csr_base + addr + 0x04);
  255. val = (val32 & 0xffff0000) | (lower_32_bits(mask) >> 16);
  256. writel(val, csr_base + addr + 0x04);
  257. val32 = readl(csr_base + addr + 0x04);
  258. val = (val32 & 0x0000ffff) | (upper_32_bits(mask) << 16);
  259. writel(val, csr_base + addr + 0x04);
  260. val32 = readl(csr_base + addr + 0x08);
  261. val = (val32 & 0xffff0000) | (upper_32_bits(mask) >> 16);
  262. writel(val, csr_base + addr + 0x08);
  263. return mask;
  264. }
  265. static void xgene_pcie_linkup(struct xgene_pcie_port *port,
  266. u32 *lanes, u32 *speed)
  267. {
  268. void __iomem *csr_base = port->csr_base;
  269. u32 val32;
  270. port->link_up = false;
  271. val32 = readl(csr_base + PCIECORE_CTLANDSTATUS);
  272. if (val32 & LINK_UP_MASK) {
  273. port->link_up = true;
  274. *speed = PIPE_PHY_RATE_RD(val32);
  275. val32 = readl(csr_base + BRIDGE_STATUS_0);
  276. *lanes = val32 >> 26;
  277. }
  278. }
  279. static int xgene_pcie_init_port(struct xgene_pcie_port *port)
  280. {
  281. int rc;
  282. port->clk = clk_get(port->dev, NULL);
  283. if (IS_ERR(port->clk)) {
  284. dev_err(port->dev, "clock not available\n");
  285. return -ENODEV;
  286. }
  287. rc = clk_prepare_enable(port->clk);
  288. if (rc) {
  289. dev_err(port->dev, "clock enable failed\n");
  290. return rc;
  291. }
  292. return 0;
  293. }
  294. static int xgene_pcie_map_reg(struct xgene_pcie_port *port,
  295. struct platform_device *pdev)
  296. {
  297. struct resource *res;
  298. res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "csr");
  299. port->csr_base = devm_ioremap_resource(port->dev, res);
  300. if (IS_ERR(port->csr_base))
  301. return PTR_ERR(port->csr_base);
  302. res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "cfg");
  303. port->cfg_base = devm_ioremap_resource(port->dev, res);
  304. if (IS_ERR(port->cfg_base))
  305. return PTR_ERR(port->cfg_base);
  306. port->cfg_addr = res->start;
  307. return 0;
  308. }
  309. static void xgene_pcie_setup_ob_reg(struct xgene_pcie_port *port,
  310. struct resource *res, u32 offset,
  311. u64 cpu_addr, u64 pci_addr)
  312. {
  313. void __iomem *base = port->csr_base + offset;
  314. resource_size_t size = resource_size(res);
  315. u64 restype = resource_type(res);
  316. u64 mask = 0;
  317. u32 min_size;
  318. u32 flag = EN_REG;
  319. if (restype == IORESOURCE_MEM) {
  320. min_size = SZ_128M;
  321. } else {
  322. min_size = 128;
  323. flag |= OB_LO_IO;
  324. }
  325. if (size >= min_size)
  326. mask = ~(size - 1) | flag;
  327. else
  328. dev_warn(port->dev, "res size 0x%llx less than minimum 0x%x\n",
  329. (u64)size, min_size);
  330. writel(lower_32_bits(cpu_addr), base);
  331. writel(upper_32_bits(cpu_addr), base + 0x04);
  332. writel(lower_32_bits(mask), base + 0x08);
  333. writel(upper_32_bits(mask), base + 0x0c);
  334. writel(lower_32_bits(pci_addr), base + 0x10);
  335. writel(upper_32_bits(pci_addr), base + 0x14);
  336. }
  337. static void xgene_pcie_setup_cfg_reg(void __iomem *csr_base, u64 addr)
  338. {
  339. writel(lower_32_bits(addr), csr_base + CFGBARL);
  340. writel(upper_32_bits(addr), csr_base + CFGBARH);
  341. writel(EN_REG, csr_base + CFGCTL);
  342. }
  343. static int xgene_pcie_map_ranges(struct xgene_pcie_port *port,
  344. struct list_head *res,
  345. resource_size_t io_base)
  346. {
  347. struct pci_host_bridge_window *window;
  348. struct device *dev = port->dev;
  349. int ret;
  350. list_for_each_entry(window, res, list) {
  351. struct resource *res = window->res;
  352. u64 restype = resource_type(res);
  353. dev_dbg(port->dev, "%pR\n", res);
  354. switch (restype) {
  355. case IORESOURCE_IO:
  356. xgene_pcie_setup_ob_reg(port, res, OMR3BARL, io_base,
  357. res->start - window->offset);
  358. ret = pci_remap_iospace(res, io_base);
  359. if (ret < 0)
  360. return ret;
  361. break;
  362. case IORESOURCE_MEM:
  363. xgene_pcie_setup_ob_reg(port, res, OMR1BARL, res->start,
  364. res->start - window->offset);
  365. break;
  366. case IORESOURCE_BUS:
  367. break;
  368. default:
  369. dev_err(dev, "invalid resource %pR\n", res);
  370. return -EINVAL;
  371. }
  372. }
  373. xgene_pcie_setup_cfg_reg(port->csr_base, port->cfg_addr);
  374. return 0;
  375. }
  376. static void xgene_pcie_setup_pims(void *addr, u64 pim, u64 size)
  377. {
  378. writel(lower_32_bits(pim), addr);
  379. writel(upper_32_bits(pim) | EN_COHERENCY, addr + 0x04);
  380. writel(lower_32_bits(size), addr + 0x10);
  381. writel(upper_32_bits(size), addr + 0x14);
  382. }
  383. /*
  384. * X-Gene PCIe support maximum 3 inbound memory regions
  385. * This function helps to select a region based on size of region
  386. */
  387. static int xgene_pcie_select_ib_reg(u8 *ib_reg_mask, u64 size)
  388. {
  389. if ((size > 4) && (size < SZ_16M) && !(*ib_reg_mask & (1 << 1))) {
  390. *ib_reg_mask |= (1 << 1);
  391. return 1;
  392. }
  393. if ((size > SZ_1K) && (size < SZ_1T) && !(*ib_reg_mask & (1 << 0))) {
  394. *ib_reg_mask |= (1 << 0);
  395. return 0;
  396. }
  397. if ((size > SZ_1M) && (size < SZ_1T) && !(*ib_reg_mask & (1 << 2))) {
  398. *ib_reg_mask |= (1 << 2);
  399. return 2;
  400. }
  401. return -EINVAL;
  402. }
  403. static void xgene_pcie_setup_ib_reg(struct xgene_pcie_port *port,
  404. struct of_pci_range *range, u8 *ib_reg_mask)
  405. {
  406. void __iomem *csr_base = port->csr_base;
  407. void __iomem *cfg_base = port->cfg_base;
  408. void *bar_addr;
  409. void *pim_addr;
  410. u64 cpu_addr = range->cpu_addr;
  411. u64 pci_addr = range->pci_addr;
  412. u64 size = range->size;
  413. u64 mask = ~(size - 1) | EN_REG;
  414. u32 flags = PCI_BASE_ADDRESS_MEM_TYPE_64;
  415. u32 bar_low;
  416. int region;
  417. region = xgene_pcie_select_ib_reg(ib_reg_mask, range->size);
  418. if (region < 0) {
  419. dev_warn(port->dev, "invalid pcie dma-range config\n");
  420. return;
  421. }
  422. if (range->flags & IORESOURCE_PREFETCH)
  423. flags |= PCI_BASE_ADDRESS_MEM_PREFETCH;
  424. bar_low = pcie_bar_low_val((u32)cpu_addr, flags);
  425. switch (region) {
  426. case 0:
  427. xgene_pcie_set_ib_mask(csr_base, BRIDGE_CFG_4, flags, size);
  428. bar_addr = cfg_base + PCI_BASE_ADDRESS_0;
  429. writel(bar_low, bar_addr);
  430. writel(upper_32_bits(cpu_addr), bar_addr + 0x4);
  431. pim_addr = csr_base + PIM1_1L;
  432. break;
  433. case 1:
  434. bar_addr = csr_base + IBAR2;
  435. writel(bar_low, bar_addr);
  436. writel(lower_32_bits(mask), csr_base + IR2MSK);
  437. pim_addr = csr_base + PIM2_1L;
  438. break;
  439. case 2:
  440. bar_addr = csr_base + IBAR3L;
  441. writel(bar_low, bar_addr);
  442. writel(upper_32_bits(cpu_addr), bar_addr + 0x4);
  443. writel(lower_32_bits(mask), csr_base + IR3MSKL);
  444. writel(upper_32_bits(mask), csr_base + IR3MSKL + 0x4);
  445. pim_addr = csr_base + PIM3_1L;
  446. break;
  447. }
  448. xgene_pcie_setup_pims(pim_addr, pci_addr, ~(size - 1));
  449. }
  450. static int pci_dma_range_parser_init(struct of_pci_range_parser *parser,
  451. struct device_node *node)
  452. {
  453. const int na = 3, ns = 2;
  454. int rlen;
  455. parser->node = node;
  456. parser->pna = of_n_addr_cells(node);
  457. parser->np = parser->pna + na + ns;
  458. parser->range = of_get_property(node, "dma-ranges", &rlen);
  459. if (!parser->range)
  460. return -ENOENT;
  461. parser->end = parser->range + rlen / sizeof(__be32);
  462. return 0;
  463. }
  464. static int xgene_pcie_parse_map_dma_ranges(struct xgene_pcie_port *port)
  465. {
  466. struct device_node *np = port->node;
  467. struct of_pci_range range;
  468. struct of_pci_range_parser parser;
  469. struct device *dev = port->dev;
  470. u8 ib_reg_mask = 0;
  471. if (pci_dma_range_parser_init(&parser, np)) {
  472. dev_err(dev, "missing dma-ranges property\n");
  473. return -EINVAL;
  474. }
  475. /* Get the dma-ranges from DT */
  476. for_each_of_pci_range(&parser, &range) {
  477. u64 end = range.cpu_addr + range.size - 1;
  478. dev_dbg(port->dev, "0x%08x 0x%016llx..0x%016llx -> 0x%016llx\n",
  479. range.flags, range.cpu_addr, end, range.pci_addr);
  480. xgene_pcie_setup_ib_reg(port, &range, &ib_reg_mask);
  481. }
  482. return 0;
  483. }
  484. /* clear BAR configuration which was done by firmware */
  485. static void xgene_pcie_clear_config(struct xgene_pcie_port *port)
  486. {
  487. int i;
  488. for (i = PIM1_1L; i <= CFGCTL; i += 4)
  489. writel(0x0, port->csr_base + i);
  490. }
  491. static int xgene_pcie_setup(struct xgene_pcie_port *port,
  492. struct list_head *res,
  493. resource_size_t io_base)
  494. {
  495. u32 val, lanes = 0, speed = 0;
  496. int ret;
  497. xgene_pcie_clear_config(port);
  498. /* setup the vendor and device IDs correctly */
  499. val = (XGENE_PCIE_DEVICEID << 16) | XGENE_PCIE_VENDORID;
  500. writel(val, port->csr_base + BRIDGE_CFG_0);
  501. ret = xgene_pcie_map_ranges(port, res, io_base);
  502. if (ret)
  503. return ret;
  504. ret = xgene_pcie_parse_map_dma_ranges(port);
  505. if (ret)
  506. return ret;
  507. xgene_pcie_linkup(port, &lanes, &speed);
  508. if (!port->link_up)
  509. dev_info(port->dev, "(rc) link down\n");
  510. else
  511. dev_info(port->dev, "(rc) x%d gen-%d link up\n",
  512. lanes, speed + 1);
  513. return 0;
  514. }
  515. static int xgene_pcie_probe_bridge(struct platform_device *pdev)
  516. {
  517. struct device_node *dn = pdev->dev.of_node;
  518. struct xgene_pcie_port *port;
  519. resource_size_t iobase = 0;
  520. struct pci_bus *bus;
  521. int ret;
  522. LIST_HEAD(res);
  523. port = devm_kzalloc(&pdev->dev, sizeof(*port), GFP_KERNEL);
  524. if (!port)
  525. return -ENOMEM;
  526. port->node = of_node_get(pdev->dev.of_node);
  527. port->dev = &pdev->dev;
  528. ret = xgene_pcie_map_reg(port, pdev);
  529. if (ret)
  530. return ret;
  531. ret = xgene_pcie_init_port(port);
  532. if (ret)
  533. return ret;
  534. ret = of_pci_get_host_bridge_resources(dn, 0, 0xff, &res, &iobase);
  535. if (ret)
  536. return ret;
  537. ret = xgene_pcie_setup(port, &res, iobase);
  538. if (ret)
  539. return ret;
  540. bus = pci_create_root_bus(&pdev->dev, 0,
  541. &xgene_pcie_ops, port, &res);
  542. if (!bus)
  543. return -ENOMEM;
  544. pci_scan_child_bus(bus);
  545. pci_assign_unassigned_bus_resources(bus);
  546. pci_bus_add_devices(bus);
  547. platform_set_drvdata(pdev, port);
  548. return 0;
  549. }
  550. static const struct of_device_id xgene_pcie_match_table[] = {
  551. {.compatible = "apm,xgene-pcie",},
  552. {},
  553. };
  554. static struct platform_driver xgene_pcie_driver = {
  555. .driver = {
  556. .name = "xgene-pcie",
  557. .of_match_table = of_match_ptr(xgene_pcie_match_table),
  558. },
  559. .probe = xgene_pcie_probe_bridge,
  560. };
  561. module_platform_driver(xgene_pcie_driver);
  562. MODULE_AUTHOR("Tanmay Inamdar <tinamdar@apm.com>");
  563. MODULE_DESCRIPTION("APM X-Gene PCIe driver");
  564. MODULE_LICENSE("GPL v2");