fsl_pci.c 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234
  1. /*
  2. * MPC83xx/85xx/86xx PCI/PCIE support routing.
  3. *
  4. * Copyright 2007-2012 Freescale Semiconductor, Inc.
  5. * Copyright 2008-2009 MontaVista Software, Inc.
  6. *
  7. * Initial author: Xianghua Xiao <x.xiao@freescale.com>
  8. * Recode: ZHANG WEI <wei.zhang@freescale.com>
  9. * Rewrite the routing for Frescale PCI and PCI Express
  10. * Roy Zang <tie-fei.zang@freescale.com>
  11. * MPC83xx PCI-Express support:
  12. * Tony Li <tony.li@freescale.com>
  13. * Anton Vorontsov <avorontsov@ru.mvista.com>
  14. *
  15. * This program is free software; you can redistribute it and/or modify it
  16. * under the terms of the GNU General Public License as published by the
  17. * Free Software Foundation; either version 2 of the License, or (at your
  18. * option) any later version.
  19. */
  20. #include <linux/kernel.h>
  21. #include <linux/pci.h>
  22. #include <linux/delay.h>
  23. #include <linux/string.h>
  24. #include <linux/init.h>
  25. #include <linux/interrupt.h>
  26. #include <linux/memblock.h>
  27. #include <linux/log2.h>
  28. #include <linux/slab.h>
  29. #include <linux/suspend.h>
  30. #include <linux/syscore_ops.h>
  31. #include <linux/uaccess.h>
  32. #include <asm/io.h>
  33. #include <asm/prom.h>
  34. #include <asm/pci-bridge.h>
  35. #include <asm/ppc-pci.h>
  36. #include <asm/machdep.h>
  37. #include <asm/disassemble.h>
  38. #include <asm/ppc-opcode.h>
  39. #include <sysdev/fsl_soc.h>
  40. #include <sysdev/fsl_pci.h>
  41. static int fsl_pcie_bus_fixup, is_mpc83xx_pci;
  42. static void quirk_fsl_pcie_early(struct pci_dev *dev)
  43. {
  44. u8 hdr_type;
  45. /* if we aren't a PCIe don't bother */
  46. if (!pci_is_pcie(dev))
  47. return;
  48. /* if we aren't in host mode don't bother */
  49. pci_read_config_byte(dev, PCI_HEADER_TYPE, &hdr_type);
  50. if ((hdr_type & 0x7f) != PCI_HEADER_TYPE_BRIDGE)
  51. return;
  52. dev->class = PCI_CLASS_BRIDGE_PCI << 8;
  53. fsl_pcie_bus_fixup = 1;
  54. return;
  55. }
  56. static int fsl_indirect_read_config(struct pci_bus *, unsigned int,
  57. int, int, u32 *);
  58. static int fsl_pcie_check_link(struct pci_controller *hose)
  59. {
  60. u32 val = 0;
  61. if (hose->indirect_type & PPC_INDIRECT_TYPE_FSL_CFG_REG_LINK) {
  62. if (hose->ops->read == fsl_indirect_read_config)
  63. __indirect_read_config(hose, hose->first_busno, 0,
  64. PCIE_LTSSM, 4, &val);
  65. else
  66. early_read_config_dword(hose, 0, 0, PCIE_LTSSM, &val);
  67. if (val < PCIE_LTSSM_L0)
  68. return 1;
  69. } else {
  70. struct ccsr_pci __iomem *pci = hose->private_data;
  71. /* for PCIe IP rev 3.0 or greater use CSR0 for link state */
  72. val = (in_be32(&pci->pex_csr0) & PEX_CSR0_LTSSM_MASK)
  73. >> PEX_CSR0_LTSSM_SHIFT;
  74. if (val != PEX_CSR0_LTSSM_L0)
  75. return 1;
  76. }
  77. return 0;
  78. }
  79. static int fsl_indirect_read_config(struct pci_bus *bus, unsigned int devfn,
  80. int offset, int len, u32 *val)
  81. {
  82. struct pci_controller *hose = pci_bus_to_host(bus);
  83. if (fsl_pcie_check_link(hose))
  84. hose->indirect_type |= PPC_INDIRECT_TYPE_NO_PCIE_LINK;
  85. else
  86. hose->indirect_type &= ~PPC_INDIRECT_TYPE_NO_PCIE_LINK;
  87. return indirect_read_config(bus, devfn, offset, len, val);
  88. }
  89. #if defined(CONFIG_FSL_SOC_BOOKE) || defined(CONFIG_PPC_86xx)
  90. static struct pci_ops fsl_indirect_pcie_ops =
  91. {
  92. .read = fsl_indirect_read_config,
  93. .write = indirect_write_config,
  94. };
  95. #define MAX_PHYS_ADDR_BITS 40
  96. static u64 pci64_dma_offset = 1ull << MAX_PHYS_ADDR_BITS;
  97. static int fsl_pci_dma_set_mask(struct device *dev, u64 dma_mask)
  98. {
  99. if (!dev->dma_mask || !dma_supported(dev, dma_mask))
  100. return -EIO;
  101. /*
  102. * Fixup PCI devices that are able to DMA to above the physical
  103. * address width of the SoC such that we can address any internal
  104. * SoC address from across PCI if needed
  105. */
  106. if ((dev_is_pci(dev)) &&
  107. dma_mask >= DMA_BIT_MASK(MAX_PHYS_ADDR_BITS)) {
  108. set_dma_ops(dev, &dma_direct_ops);
  109. set_dma_offset(dev, pci64_dma_offset);
  110. }
  111. *dev->dma_mask = dma_mask;
  112. return 0;
  113. }
  114. static int setup_one_atmu(struct ccsr_pci __iomem *pci,
  115. unsigned int index, const struct resource *res,
  116. resource_size_t offset)
  117. {
  118. resource_size_t pci_addr = res->start - offset;
  119. resource_size_t phys_addr = res->start;
  120. resource_size_t size = resource_size(res);
  121. u32 flags = 0x80044000; /* enable & mem R/W */
  122. unsigned int i;
  123. pr_debug("PCI MEM resource start 0x%016llx, size 0x%016llx.\n",
  124. (u64)res->start, (u64)size);
  125. if (res->flags & IORESOURCE_PREFETCH)
  126. flags |= 0x10000000; /* enable relaxed ordering */
  127. for (i = 0; size > 0; i++) {
  128. unsigned int bits = min_t(u32, ilog2(size),
  129. __ffs(pci_addr | phys_addr));
  130. if (index + i >= 5)
  131. return -1;
  132. out_be32(&pci->pow[index + i].potar, pci_addr >> 12);
  133. out_be32(&pci->pow[index + i].potear, (u64)pci_addr >> 44);
  134. out_be32(&pci->pow[index + i].powbar, phys_addr >> 12);
  135. out_be32(&pci->pow[index + i].powar, flags | (bits - 1));
  136. pci_addr += (resource_size_t)1U << bits;
  137. phys_addr += (resource_size_t)1U << bits;
  138. size -= (resource_size_t)1U << bits;
  139. }
  140. return i;
  141. }
  142. /* atmu setup for fsl pci/pcie controller */
  143. static void setup_pci_atmu(struct pci_controller *hose)
  144. {
  145. struct ccsr_pci __iomem *pci = hose->private_data;
  146. int i, j, n, mem_log, win_idx = 3, start_idx = 1, end_idx = 4;
  147. u64 mem, sz, paddr_hi = 0;
  148. u64 offset = 0, paddr_lo = ULLONG_MAX;
  149. u32 pcicsrbar = 0, pcicsrbar_sz;
  150. u32 piwar = PIWAR_EN | PIWAR_PF | PIWAR_TGI_LOCAL |
  151. PIWAR_READ_SNOOP | PIWAR_WRITE_SNOOP;
  152. const char *name = hose->dn->full_name;
  153. const u64 *reg;
  154. int len;
  155. if (early_find_capability(hose, 0, 0, PCI_CAP_ID_EXP)) {
  156. if (in_be32(&pci->block_rev1) >= PCIE_IP_REV_2_2) {
  157. win_idx = 2;
  158. start_idx = 0;
  159. end_idx = 3;
  160. }
  161. }
  162. /* Disable all windows (except powar0 since it's ignored) */
  163. for(i = 1; i < 5; i++)
  164. out_be32(&pci->pow[i].powar, 0);
  165. for (i = start_idx; i < end_idx; i++)
  166. out_be32(&pci->piw[i].piwar, 0);
  167. /* Setup outbound MEM window */
  168. for(i = 0, j = 1; i < 3; i++) {
  169. if (!(hose->mem_resources[i].flags & IORESOURCE_MEM))
  170. continue;
  171. paddr_lo = min(paddr_lo, (u64)hose->mem_resources[i].start);
  172. paddr_hi = max(paddr_hi, (u64)hose->mem_resources[i].end);
  173. /* We assume all memory resources have the same offset */
  174. offset = hose->mem_offset[i];
  175. n = setup_one_atmu(pci, j, &hose->mem_resources[i], offset);
  176. if (n < 0 || j >= 5) {
  177. pr_err("Ran out of outbound PCI ATMUs for resource %d!\n", i);
  178. hose->mem_resources[i].flags |= IORESOURCE_DISABLED;
  179. } else
  180. j += n;
  181. }
  182. /* Setup outbound IO window */
  183. if (hose->io_resource.flags & IORESOURCE_IO) {
  184. if (j >= 5) {
  185. pr_err("Ran out of outbound PCI ATMUs for IO resource\n");
  186. } else {
  187. pr_debug("PCI IO resource start 0x%016llx, size 0x%016llx, "
  188. "phy base 0x%016llx.\n",
  189. (u64)hose->io_resource.start,
  190. (u64)resource_size(&hose->io_resource),
  191. (u64)hose->io_base_phys);
  192. out_be32(&pci->pow[j].potar, (hose->io_resource.start >> 12));
  193. out_be32(&pci->pow[j].potear, 0);
  194. out_be32(&pci->pow[j].powbar, (hose->io_base_phys >> 12));
  195. /* Enable, IO R/W */
  196. out_be32(&pci->pow[j].powar, 0x80088000
  197. | (ilog2(hose->io_resource.end
  198. - hose->io_resource.start + 1) - 1));
  199. }
  200. }
  201. /* convert to pci address space */
  202. paddr_hi -= offset;
  203. paddr_lo -= offset;
  204. if (paddr_hi == paddr_lo) {
  205. pr_err("%s: No outbound window space\n", name);
  206. return;
  207. }
  208. if (paddr_lo == 0) {
  209. pr_err("%s: No space for inbound window\n", name);
  210. return;
  211. }
  212. /* setup PCSRBAR/PEXCSRBAR */
  213. early_write_config_dword(hose, 0, 0, PCI_BASE_ADDRESS_0, 0xffffffff);
  214. early_read_config_dword(hose, 0, 0, PCI_BASE_ADDRESS_0, &pcicsrbar_sz);
  215. pcicsrbar_sz = ~pcicsrbar_sz + 1;
  216. if (paddr_hi < (0x100000000ull - pcicsrbar_sz) ||
  217. (paddr_lo > 0x100000000ull))
  218. pcicsrbar = 0x100000000ull - pcicsrbar_sz;
  219. else
  220. pcicsrbar = (paddr_lo - pcicsrbar_sz) & -pcicsrbar_sz;
  221. early_write_config_dword(hose, 0, 0, PCI_BASE_ADDRESS_0, pcicsrbar);
  222. paddr_lo = min(paddr_lo, (u64)pcicsrbar);
  223. pr_info("%s: PCICSRBAR @ 0x%x\n", name, pcicsrbar);
  224. /* Setup inbound mem window */
  225. mem = memblock_end_of_DRAM();
  226. /*
  227. * The msi-address-64 property, if it exists, indicates the physical
  228. * address of the MSIIR register. Normally, this register is located
  229. * inside CCSR, so the ATMU that covers all of CCSR is used. But if
  230. * this property exists, then we normally need to create a new ATMU
  231. * for it. For now, however, we cheat. The only entity that creates
  232. * this property is the Freescale hypervisor, and the address is
  233. * specified in the partition configuration. Typically, the address
  234. * is located in the page immediately after the end of DDR. If so, we
  235. * can avoid allocating a new ATMU by extending the DDR ATMU by one
  236. * page.
  237. */
  238. reg = of_get_property(hose->dn, "msi-address-64", &len);
  239. if (reg && (len == sizeof(u64))) {
  240. u64 address = be64_to_cpup(reg);
  241. if ((address >= mem) && (address < (mem + PAGE_SIZE))) {
  242. pr_info("%s: extending DDR ATMU to cover MSIIR", name);
  243. mem += PAGE_SIZE;
  244. } else {
  245. /* TODO: Create a new ATMU for MSIIR */
  246. pr_warn("%s: msi-address-64 address of %llx is "
  247. "unsupported\n", name, address);
  248. }
  249. }
  250. sz = min(mem, paddr_lo);
  251. mem_log = ilog2(sz);
  252. /* PCIe can overmap inbound & outbound since RX & TX are separated */
  253. if (early_find_capability(hose, 0, 0, PCI_CAP_ID_EXP)) {
  254. /* Size window to exact size if power-of-two or one size up */
  255. if ((1ull << mem_log) != mem) {
  256. mem_log++;
  257. if ((1ull << mem_log) > mem)
  258. pr_info("%s: Setting PCI inbound window "
  259. "greater than memory size\n", name);
  260. }
  261. piwar |= ((mem_log - 1) & PIWAR_SZ_MASK);
  262. /* Setup inbound memory window */
  263. out_be32(&pci->piw[win_idx].pitar, 0x00000000);
  264. out_be32(&pci->piw[win_idx].piwbar, 0x00000000);
  265. out_be32(&pci->piw[win_idx].piwar, piwar);
  266. win_idx--;
  267. hose->dma_window_base_cur = 0x00000000;
  268. hose->dma_window_size = (resource_size_t)sz;
  269. /*
  270. * if we have >4G of memory setup second PCI inbound window to
  271. * let devices that are 64-bit address capable to work w/o
  272. * SWIOTLB and access the full range of memory
  273. */
  274. if (sz != mem) {
  275. mem_log = ilog2(mem);
  276. /* Size window up if we dont fit in exact power-of-2 */
  277. if ((1ull << mem_log) != mem)
  278. mem_log++;
  279. piwar = (piwar & ~PIWAR_SZ_MASK) | (mem_log - 1);
  280. /* Setup inbound memory window */
  281. out_be32(&pci->piw[win_idx].pitar, 0x00000000);
  282. out_be32(&pci->piw[win_idx].piwbear,
  283. pci64_dma_offset >> 44);
  284. out_be32(&pci->piw[win_idx].piwbar,
  285. pci64_dma_offset >> 12);
  286. out_be32(&pci->piw[win_idx].piwar, piwar);
  287. /*
  288. * install our own dma_set_mask handler to fixup dma_ops
  289. * and dma_offset
  290. */
  291. ppc_md.dma_set_mask = fsl_pci_dma_set_mask;
  292. pr_info("%s: Setup 64-bit PCI DMA window\n", name);
  293. }
  294. } else {
  295. u64 paddr = 0;
  296. /* Setup inbound memory window */
  297. out_be32(&pci->piw[win_idx].pitar, paddr >> 12);
  298. out_be32(&pci->piw[win_idx].piwbar, paddr >> 12);
  299. out_be32(&pci->piw[win_idx].piwar, (piwar | (mem_log - 1)));
  300. win_idx--;
  301. paddr += 1ull << mem_log;
  302. sz -= 1ull << mem_log;
  303. if (sz) {
  304. mem_log = ilog2(sz);
  305. piwar |= (mem_log - 1);
  306. out_be32(&pci->piw[win_idx].pitar, paddr >> 12);
  307. out_be32(&pci->piw[win_idx].piwbar, paddr >> 12);
  308. out_be32(&pci->piw[win_idx].piwar, piwar);
  309. win_idx--;
  310. paddr += 1ull << mem_log;
  311. }
  312. hose->dma_window_base_cur = 0x00000000;
  313. hose->dma_window_size = (resource_size_t)paddr;
  314. }
  315. if (hose->dma_window_size < mem) {
  316. #ifdef CONFIG_SWIOTLB
  317. ppc_swiotlb_enable = 1;
  318. #else
  319. pr_err("%s: ERROR: Memory size exceeds PCI ATMU ability to "
  320. "map - enable CONFIG_SWIOTLB to avoid dma errors.\n",
  321. name);
  322. #endif
  323. /* adjusting outbound windows could reclaim space in mem map */
  324. if (paddr_hi < 0xffffffffull)
  325. pr_warning("%s: WARNING: Outbound window cfg leaves "
  326. "gaps in memory map. Adjusting the memory map "
  327. "could reduce unnecessary bounce buffering.\n",
  328. name);
  329. pr_info("%s: DMA window size is 0x%llx\n", name,
  330. (u64)hose->dma_window_size);
  331. }
  332. }
  333. static void __init setup_pci_cmd(struct pci_controller *hose)
  334. {
  335. u16 cmd;
  336. int cap_x;
  337. early_read_config_word(hose, 0, 0, PCI_COMMAND, &cmd);
  338. cmd |= PCI_COMMAND_SERR | PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY
  339. | PCI_COMMAND_IO;
  340. early_write_config_word(hose, 0, 0, PCI_COMMAND, cmd);
  341. cap_x = early_find_capability(hose, 0, 0, PCI_CAP_ID_PCIX);
  342. if (cap_x) {
  343. int pci_x_cmd = cap_x + PCI_X_CMD;
  344. cmd = PCI_X_CMD_MAX_SPLIT | PCI_X_CMD_MAX_READ
  345. | PCI_X_CMD_ERO | PCI_X_CMD_DPERR_E;
  346. early_write_config_word(hose, 0, 0, pci_x_cmd, cmd);
  347. } else {
  348. early_write_config_byte(hose, 0, 0, PCI_LATENCY_TIMER, 0x80);
  349. }
  350. }
  351. void fsl_pcibios_fixup_bus(struct pci_bus *bus)
  352. {
  353. struct pci_controller *hose = pci_bus_to_host(bus);
  354. int i, is_pcie = 0, no_link;
  355. /* The root complex bridge comes up with bogus resources,
  356. * we copy the PHB ones in.
  357. *
  358. * With the current generic PCI code, the PHB bus no longer
  359. * has bus->resource[0..4] set, so things are a bit more
  360. * tricky.
  361. */
  362. if (fsl_pcie_bus_fixup)
  363. is_pcie = early_find_capability(hose, 0, 0, PCI_CAP_ID_EXP);
  364. no_link = !!(hose->indirect_type & PPC_INDIRECT_TYPE_NO_PCIE_LINK);
  365. if (bus->parent == hose->bus && (is_pcie || no_link)) {
  366. for (i = 0; i < PCI_BRIDGE_RESOURCE_NUM; ++i) {
  367. struct resource *res = bus->resource[i];
  368. struct resource *par;
  369. if (!res)
  370. continue;
  371. if (i == 0)
  372. par = &hose->io_resource;
  373. else if (i < 4)
  374. par = &hose->mem_resources[i-1];
  375. else par = NULL;
  376. res->start = par ? par->start : 0;
  377. res->end = par ? par->end : 0;
  378. res->flags = par ? par->flags : 0;
  379. }
  380. }
  381. }
  382. int fsl_add_bridge(struct platform_device *pdev, int is_primary)
  383. {
  384. int len;
  385. struct pci_controller *hose;
  386. struct resource rsrc;
  387. const int *bus_range;
  388. u8 hdr_type, progif;
  389. struct device_node *dev;
  390. struct ccsr_pci __iomem *pci;
  391. dev = pdev->dev.of_node;
  392. if (!of_device_is_available(dev)) {
  393. pr_warning("%s: disabled\n", dev->full_name);
  394. return -ENODEV;
  395. }
  396. pr_debug("Adding PCI host bridge %s\n", dev->full_name);
  397. /* Fetch host bridge registers address */
  398. if (of_address_to_resource(dev, 0, &rsrc)) {
  399. printk(KERN_WARNING "Can't get pci register base!");
  400. return -ENOMEM;
  401. }
  402. /* Get bus range if any */
  403. bus_range = of_get_property(dev, "bus-range", &len);
  404. if (bus_range == NULL || len < 2 * sizeof(int))
  405. printk(KERN_WARNING "Can't get bus-range for %s, assume"
  406. " bus 0\n", dev->full_name);
  407. pci_add_flags(PCI_REASSIGN_ALL_BUS);
  408. hose = pcibios_alloc_controller(dev);
  409. if (!hose)
  410. return -ENOMEM;
  411. /* set platform device as the parent */
  412. hose->parent = &pdev->dev;
  413. hose->first_busno = bus_range ? bus_range[0] : 0x0;
  414. hose->last_busno = bus_range ? bus_range[1] : 0xff;
  415. pr_debug("PCI memory map start 0x%016llx, size 0x%016llx\n",
  416. (u64)rsrc.start, (u64)resource_size(&rsrc));
  417. pci = hose->private_data = ioremap(rsrc.start, resource_size(&rsrc));
  418. if (!hose->private_data)
  419. goto no_bridge;
  420. setup_indirect_pci(hose, rsrc.start, rsrc.start + 0x4,
  421. PPC_INDIRECT_TYPE_BIG_ENDIAN);
  422. if (in_be32(&pci->block_rev1) < PCIE_IP_REV_3_0)
  423. hose->indirect_type |= PPC_INDIRECT_TYPE_FSL_CFG_REG_LINK;
  424. if (early_find_capability(hose, 0, 0, PCI_CAP_ID_EXP)) {
  425. /* use fsl_indirect_read_config for PCIe */
  426. hose->ops = &fsl_indirect_pcie_ops;
  427. /* For PCIE read HEADER_TYPE to identify controler mode */
  428. early_read_config_byte(hose, 0, 0, PCI_HEADER_TYPE, &hdr_type);
  429. if ((hdr_type & 0x7f) != PCI_HEADER_TYPE_BRIDGE)
  430. goto no_bridge;
  431. } else {
  432. /* For PCI read PROG to identify controller mode */
  433. early_read_config_byte(hose, 0, 0, PCI_CLASS_PROG, &progif);
  434. if ((progif & 1) &&
  435. !of_property_read_bool(dev, "fsl,pci-agent-force-enum"))
  436. goto no_bridge;
  437. }
  438. setup_pci_cmd(hose);
  439. /* check PCI express link status */
  440. if (early_find_capability(hose, 0, 0, PCI_CAP_ID_EXP)) {
  441. hose->indirect_type |= PPC_INDIRECT_TYPE_EXT_REG |
  442. PPC_INDIRECT_TYPE_SURPRESS_PRIMARY_BUS;
  443. if (fsl_pcie_check_link(hose))
  444. hose->indirect_type |= PPC_INDIRECT_TYPE_NO_PCIE_LINK;
  445. }
  446. printk(KERN_INFO "Found FSL PCI host bridge at 0x%016llx. "
  447. "Firmware bus number: %d->%d\n",
  448. (unsigned long long)rsrc.start, hose->first_busno,
  449. hose->last_busno);
  450. pr_debug(" ->Hose at 0x%p, cfg_addr=0x%p,cfg_data=0x%p\n",
  451. hose, hose->cfg_addr, hose->cfg_data);
  452. /* Interpret the "ranges" property */
  453. /* This also maps the I/O region and sets isa_io/mem_base */
  454. pci_process_bridge_OF_ranges(hose, dev, is_primary);
  455. /* Setup PEX window registers */
  456. setup_pci_atmu(hose);
  457. return 0;
  458. no_bridge:
  459. iounmap(hose->private_data);
  460. /* unmap cfg_data & cfg_addr separately if not on same page */
  461. if (((unsigned long)hose->cfg_data & PAGE_MASK) !=
  462. ((unsigned long)hose->cfg_addr & PAGE_MASK))
  463. iounmap(hose->cfg_data);
  464. iounmap(hose->cfg_addr);
  465. pcibios_free_controller(hose);
  466. return -ENODEV;
  467. }
  468. #endif /* CONFIG_FSL_SOC_BOOKE || CONFIG_PPC_86xx */
  469. DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_FREESCALE, PCI_ANY_ID,
  470. quirk_fsl_pcie_early);
  471. #if defined(CONFIG_PPC_83xx) || defined(CONFIG_PPC_MPC512x)
  472. struct mpc83xx_pcie_priv {
  473. void __iomem *cfg_type0;
  474. void __iomem *cfg_type1;
  475. u32 dev_base;
  476. };
  477. struct pex_inbound_window {
  478. u32 ar;
  479. u32 tar;
  480. u32 barl;
  481. u32 barh;
  482. };
  483. /*
  484. * With the convention of u-boot, the PCIE outbound window 0 serves
  485. * as configuration transactions outbound.
  486. */
  487. #define PEX_OUTWIN0_BAR 0xCA4
  488. #define PEX_OUTWIN0_TAL 0xCA8
  489. #define PEX_OUTWIN0_TAH 0xCAC
  490. #define PEX_RC_INWIN_BASE 0xE60
  491. #define PEX_RCIWARn_EN 0x1
  492. static int mpc83xx_pcie_exclude_device(struct pci_bus *bus, unsigned int devfn)
  493. {
  494. struct pci_controller *hose = pci_bus_to_host(bus);
  495. if (hose->indirect_type & PPC_INDIRECT_TYPE_NO_PCIE_LINK)
  496. return PCIBIOS_DEVICE_NOT_FOUND;
  497. /*
  498. * Workaround for the HW bug: for Type 0 configure transactions the
  499. * PCI-E controller does not check the device number bits and just
  500. * assumes that the device number bits are 0.
  501. */
  502. if (bus->number == hose->first_busno ||
  503. bus->primary == hose->first_busno) {
  504. if (devfn & 0xf8)
  505. return PCIBIOS_DEVICE_NOT_FOUND;
  506. }
  507. if (ppc_md.pci_exclude_device) {
  508. if (ppc_md.pci_exclude_device(hose, bus->number, devfn))
  509. return PCIBIOS_DEVICE_NOT_FOUND;
  510. }
  511. return PCIBIOS_SUCCESSFUL;
  512. }
  513. static void __iomem *mpc83xx_pcie_remap_cfg(struct pci_bus *bus,
  514. unsigned int devfn, int offset)
  515. {
  516. struct pci_controller *hose = pci_bus_to_host(bus);
  517. struct mpc83xx_pcie_priv *pcie = hose->dn->data;
  518. u32 dev_base = bus->number << 24 | devfn << 16;
  519. int ret;
  520. ret = mpc83xx_pcie_exclude_device(bus, devfn);
  521. if (ret)
  522. return NULL;
  523. offset &= 0xfff;
  524. /* Type 0 */
  525. if (bus->number == hose->first_busno)
  526. return pcie->cfg_type0 + offset;
  527. if (pcie->dev_base == dev_base)
  528. goto mapped;
  529. out_le32(pcie->cfg_type0 + PEX_OUTWIN0_TAL, dev_base);
  530. pcie->dev_base = dev_base;
  531. mapped:
  532. return pcie->cfg_type1 + offset;
  533. }
  534. static int mpc83xx_pcie_write_config(struct pci_bus *bus, unsigned int devfn,
  535. int offset, int len, u32 val)
  536. {
  537. struct pci_controller *hose = pci_bus_to_host(bus);
  538. /* PPC_INDIRECT_TYPE_SURPRESS_PRIMARY_BUS */
  539. if (offset == PCI_PRIMARY_BUS && bus->number == hose->first_busno)
  540. val &= 0xffffff00;
  541. return pci_generic_config_write(bus, devfn, offset, len, val);
  542. }
  543. static struct pci_ops mpc83xx_pcie_ops = {
  544. .map_bus = mpc83xx_pcie_remap_cfg,
  545. .read = pci_generic_config_read,
  546. .write = mpc83xx_pcie_write_config,
  547. };
  548. static int __init mpc83xx_pcie_setup(struct pci_controller *hose,
  549. struct resource *reg)
  550. {
  551. struct mpc83xx_pcie_priv *pcie;
  552. u32 cfg_bar;
  553. int ret = -ENOMEM;
  554. pcie = zalloc_maybe_bootmem(sizeof(*pcie), GFP_KERNEL);
  555. if (!pcie)
  556. return ret;
  557. pcie->cfg_type0 = ioremap(reg->start, resource_size(reg));
  558. if (!pcie->cfg_type0)
  559. goto err0;
  560. cfg_bar = in_le32(pcie->cfg_type0 + PEX_OUTWIN0_BAR);
  561. if (!cfg_bar) {
  562. /* PCI-E isn't configured. */
  563. ret = -ENODEV;
  564. goto err1;
  565. }
  566. pcie->cfg_type1 = ioremap(cfg_bar, 0x1000);
  567. if (!pcie->cfg_type1)
  568. goto err1;
  569. WARN_ON(hose->dn->data);
  570. hose->dn->data = pcie;
  571. hose->ops = &mpc83xx_pcie_ops;
  572. hose->indirect_type |= PPC_INDIRECT_TYPE_FSL_CFG_REG_LINK;
  573. out_le32(pcie->cfg_type0 + PEX_OUTWIN0_TAH, 0);
  574. out_le32(pcie->cfg_type0 + PEX_OUTWIN0_TAL, 0);
  575. if (fsl_pcie_check_link(hose))
  576. hose->indirect_type |= PPC_INDIRECT_TYPE_NO_PCIE_LINK;
  577. return 0;
  578. err1:
  579. iounmap(pcie->cfg_type0);
  580. err0:
  581. kfree(pcie);
  582. return ret;
  583. }
  584. int __init mpc83xx_add_bridge(struct device_node *dev)
  585. {
  586. int ret;
  587. int len;
  588. struct pci_controller *hose;
  589. struct resource rsrc_reg;
  590. struct resource rsrc_cfg;
  591. const int *bus_range;
  592. int primary;
  593. is_mpc83xx_pci = 1;
  594. if (!of_device_is_available(dev)) {
  595. pr_warning("%s: disabled by the firmware.\n",
  596. dev->full_name);
  597. return -ENODEV;
  598. }
  599. pr_debug("Adding PCI host bridge %s\n", dev->full_name);
  600. /* Fetch host bridge registers address */
  601. if (of_address_to_resource(dev, 0, &rsrc_reg)) {
  602. printk(KERN_WARNING "Can't get pci register base!\n");
  603. return -ENOMEM;
  604. }
  605. memset(&rsrc_cfg, 0, sizeof(rsrc_cfg));
  606. if (of_address_to_resource(dev, 1, &rsrc_cfg)) {
  607. printk(KERN_WARNING
  608. "No pci config register base in dev tree, "
  609. "using default\n");
  610. /*
  611. * MPC83xx supports up to two host controllers
  612. * one at 0x8500 has config space registers at 0x8300
  613. * one at 0x8600 has config space registers at 0x8380
  614. */
  615. if ((rsrc_reg.start & 0xfffff) == 0x8500)
  616. rsrc_cfg.start = (rsrc_reg.start & 0xfff00000) + 0x8300;
  617. else if ((rsrc_reg.start & 0xfffff) == 0x8600)
  618. rsrc_cfg.start = (rsrc_reg.start & 0xfff00000) + 0x8380;
  619. }
  620. /*
  621. * Controller at offset 0x8500 is primary
  622. */
  623. if ((rsrc_reg.start & 0xfffff) == 0x8500)
  624. primary = 1;
  625. else
  626. primary = 0;
  627. /* Get bus range if any */
  628. bus_range = of_get_property(dev, "bus-range", &len);
  629. if (bus_range == NULL || len < 2 * sizeof(int)) {
  630. printk(KERN_WARNING "Can't get bus-range for %s, assume"
  631. " bus 0\n", dev->full_name);
  632. }
  633. pci_add_flags(PCI_REASSIGN_ALL_BUS);
  634. hose = pcibios_alloc_controller(dev);
  635. if (!hose)
  636. return -ENOMEM;
  637. hose->first_busno = bus_range ? bus_range[0] : 0;
  638. hose->last_busno = bus_range ? bus_range[1] : 0xff;
  639. if (of_device_is_compatible(dev, "fsl,mpc8314-pcie")) {
  640. ret = mpc83xx_pcie_setup(hose, &rsrc_reg);
  641. if (ret)
  642. goto err0;
  643. } else {
  644. setup_indirect_pci(hose, rsrc_cfg.start,
  645. rsrc_cfg.start + 4, 0);
  646. }
  647. printk(KERN_INFO "Found FSL PCI host bridge at 0x%016llx. "
  648. "Firmware bus number: %d->%d\n",
  649. (unsigned long long)rsrc_reg.start, hose->first_busno,
  650. hose->last_busno);
  651. pr_debug(" ->Hose at 0x%p, cfg_addr=0x%p,cfg_data=0x%p\n",
  652. hose, hose->cfg_addr, hose->cfg_data);
  653. /* Interpret the "ranges" property */
  654. /* This also maps the I/O region and sets isa_io/mem_base */
  655. pci_process_bridge_OF_ranges(hose, dev, primary);
  656. return 0;
  657. err0:
  658. pcibios_free_controller(hose);
  659. return ret;
  660. }
  661. #endif /* CONFIG_PPC_83xx */
  662. u64 fsl_pci_immrbar_base(struct pci_controller *hose)
  663. {
  664. #ifdef CONFIG_PPC_83xx
  665. if (is_mpc83xx_pci) {
  666. struct mpc83xx_pcie_priv *pcie = hose->dn->data;
  667. struct pex_inbound_window *in;
  668. int i;
  669. /* Walk the Root Complex Inbound windows to match IMMR base */
  670. in = pcie->cfg_type0 + PEX_RC_INWIN_BASE;
  671. for (i = 0; i < 4; i++) {
  672. /* not enabled, skip */
  673. if (!(in_le32(&in[i].ar) & PEX_RCIWARn_EN))
  674. continue;
  675. if (get_immrbase() == in_le32(&in[i].tar))
  676. return (u64)in_le32(&in[i].barh) << 32 |
  677. in_le32(&in[i].barl);
  678. }
  679. printk(KERN_WARNING "could not find PCI BAR matching IMMR\n");
  680. }
  681. #endif
  682. #if defined(CONFIG_FSL_SOC_BOOKE) || defined(CONFIG_PPC_86xx)
  683. if (!is_mpc83xx_pci) {
  684. u32 base;
  685. pci_bus_read_config_dword(hose->bus,
  686. PCI_DEVFN(0, 0), PCI_BASE_ADDRESS_0, &base);
  687. /*
  688. * For PEXCSRBAR, bit 3-0 indicate prefetchable and
  689. * address type. So when getting base address, these
  690. * bits should be masked
  691. */
  692. base &= PCI_BASE_ADDRESS_MEM_MASK;
  693. return base;
  694. }
  695. #endif
  696. return 0;
  697. }
  698. #ifdef CONFIG_E500
  699. static int mcheck_handle_load(struct pt_regs *regs, u32 inst)
  700. {
  701. unsigned int rd, ra, rb, d;
  702. rd = get_rt(inst);
  703. ra = get_ra(inst);
  704. rb = get_rb(inst);
  705. d = get_d(inst);
  706. switch (get_op(inst)) {
  707. case 31:
  708. switch (get_xop(inst)) {
  709. case OP_31_XOP_LWZX:
  710. case OP_31_XOP_LWBRX:
  711. regs->gpr[rd] = 0xffffffff;
  712. break;
  713. case OP_31_XOP_LWZUX:
  714. regs->gpr[rd] = 0xffffffff;
  715. regs->gpr[ra] += regs->gpr[rb];
  716. break;
  717. case OP_31_XOP_LBZX:
  718. regs->gpr[rd] = 0xff;
  719. break;
  720. case OP_31_XOP_LBZUX:
  721. regs->gpr[rd] = 0xff;
  722. regs->gpr[ra] += regs->gpr[rb];
  723. break;
  724. case OP_31_XOP_LHZX:
  725. case OP_31_XOP_LHBRX:
  726. regs->gpr[rd] = 0xffff;
  727. break;
  728. case OP_31_XOP_LHZUX:
  729. regs->gpr[rd] = 0xffff;
  730. regs->gpr[ra] += regs->gpr[rb];
  731. break;
  732. case OP_31_XOP_LHAX:
  733. regs->gpr[rd] = ~0UL;
  734. break;
  735. case OP_31_XOP_LHAUX:
  736. regs->gpr[rd] = ~0UL;
  737. regs->gpr[ra] += regs->gpr[rb];
  738. break;
  739. default:
  740. return 0;
  741. }
  742. break;
  743. case OP_LWZ:
  744. regs->gpr[rd] = 0xffffffff;
  745. break;
  746. case OP_LWZU:
  747. regs->gpr[rd] = 0xffffffff;
  748. regs->gpr[ra] += (s16)d;
  749. break;
  750. case OP_LBZ:
  751. regs->gpr[rd] = 0xff;
  752. break;
  753. case OP_LBZU:
  754. regs->gpr[rd] = 0xff;
  755. regs->gpr[ra] += (s16)d;
  756. break;
  757. case OP_LHZ:
  758. regs->gpr[rd] = 0xffff;
  759. break;
  760. case OP_LHZU:
  761. regs->gpr[rd] = 0xffff;
  762. regs->gpr[ra] += (s16)d;
  763. break;
  764. case OP_LHA:
  765. regs->gpr[rd] = ~0UL;
  766. break;
  767. case OP_LHAU:
  768. regs->gpr[rd] = ~0UL;
  769. regs->gpr[ra] += (s16)d;
  770. break;
  771. default:
  772. return 0;
  773. }
  774. return 1;
  775. }
  776. static int is_in_pci_mem_space(phys_addr_t addr)
  777. {
  778. struct pci_controller *hose;
  779. struct resource *res;
  780. int i;
  781. list_for_each_entry(hose, &hose_list, list_node) {
  782. if (!(hose->indirect_type & PPC_INDIRECT_TYPE_EXT_REG))
  783. continue;
  784. for (i = 0; i < 3; i++) {
  785. res = &hose->mem_resources[i];
  786. if ((res->flags & IORESOURCE_MEM) &&
  787. addr >= res->start && addr <= res->end)
  788. return 1;
  789. }
  790. }
  791. return 0;
  792. }
  793. int fsl_pci_mcheck_exception(struct pt_regs *regs)
  794. {
  795. u32 inst;
  796. int ret;
  797. phys_addr_t addr = 0;
  798. /* Let KVM/QEMU deal with the exception */
  799. if (regs->msr & MSR_GS)
  800. return 0;
  801. #ifdef CONFIG_PHYS_64BIT
  802. addr = mfspr(SPRN_MCARU);
  803. addr <<= 32;
  804. #endif
  805. addr += mfspr(SPRN_MCAR);
  806. if (is_in_pci_mem_space(addr)) {
  807. if (user_mode(regs)) {
  808. pagefault_disable();
  809. ret = get_user(regs->nip, &inst);
  810. pagefault_enable();
  811. } else {
  812. ret = probe_kernel_address(regs->nip, inst);
  813. }
  814. if (mcheck_handle_load(regs, inst)) {
  815. regs->nip += 4;
  816. return 1;
  817. }
  818. }
  819. return 0;
  820. }
  821. #endif
  822. #if defined(CONFIG_FSL_SOC_BOOKE) || defined(CONFIG_PPC_86xx)
  823. static const struct of_device_id pci_ids[] = {
  824. { .compatible = "fsl,mpc8540-pci", },
  825. { .compatible = "fsl,mpc8548-pcie", },
  826. { .compatible = "fsl,mpc8610-pci", },
  827. { .compatible = "fsl,mpc8641-pcie", },
  828. { .compatible = "fsl,qoriq-pcie", },
  829. { .compatible = "fsl,qoriq-pcie-v2.1", },
  830. { .compatible = "fsl,qoriq-pcie-v2.2", },
  831. { .compatible = "fsl,qoriq-pcie-v2.3", },
  832. { .compatible = "fsl,qoriq-pcie-v2.4", },
  833. { .compatible = "fsl,qoriq-pcie-v3.0", },
  834. /*
  835. * The following entries are for compatibility with older device
  836. * trees.
  837. */
  838. { .compatible = "fsl,p1022-pcie", },
  839. { .compatible = "fsl,p4080-pcie", },
  840. {},
  841. };
  842. struct device_node *fsl_pci_primary;
  843. void fsl_pci_assign_primary(void)
  844. {
  845. struct device_node *np;
  846. /* Callers can specify the primary bus using other means. */
  847. if (fsl_pci_primary)
  848. return;
  849. /* If a PCI host bridge contains an ISA node, it's primary. */
  850. np = of_find_node_by_type(NULL, "isa");
  851. while ((fsl_pci_primary = of_get_parent(np))) {
  852. of_node_put(np);
  853. np = fsl_pci_primary;
  854. if (of_match_node(pci_ids, np) && of_device_is_available(np))
  855. return;
  856. }
  857. /*
  858. * If there's no PCI host bridge with ISA, arbitrarily
  859. * designate one as primary. This can go away once
  860. * various bugs with primary-less systems are fixed.
  861. */
  862. for_each_matching_node(np, pci_ids) {
  863. if (of_device_is_available(np)) {
  864. fsl_pci_primary = np;
  865. of_node_put(np);
  866. return;
  867. }
  868. }
  869. }
  870. #ifdef CONFIG_PM_SLEEP
  871. static irqreturn_t fsl_pci_pme_handle(int irq, void *dev_id)
  872. {
  873. struct pci_controller *hose = dev_id;
  874. struct ccsr_pci __iomem *pci = hose->private_data;
  875. u32 dr;
  876. dr = in_be32(&pci->pex_pme_mes_dr);
  877. if (!dr)
  878. return IRQ_NONE;
  879. out_be32(&pci->pex_pme_mes_dr, dr);
  880. return IRQ_HANDLED;
  881. }
  882. static int fsl_pci_pme_probe(struct pci_controller *hose)
  883. {
  884. struct ccsr_pci __iomem *pci;
  885. struct pci_dev *dev;
  886. int pme_irq;
  887. int res;
  888. u16 pms;
  889. /* Get hose's pci_dev */
  890. dev = list_first_entry(&hose->bus->devices, typeof(*dev), bus_list);
  891. /* PME Disable */
  892. pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pms);
  893. pms &= ~PCI_PM_CTRL_PME_ENABLE;
  894. pci_write_config_word(dev, dev->pm_cap + PCI_PM_CTRL, pms);
  895. pme_irq = irq_of_parse_and_map(hose->dn, 0);
  896. if (!pme_irq) {
  897. dev_err(&dev->dev, "Failed to map PME interrupt.\n");
  898. return -ENXIO;
  899. }
  900. res = devm_request_irq(hose->parent, pme_irq,
  901. fsl_pci_pme_handle,
  902. IRQF_SHARED,
  903. "[PCI] PME", hose);
  904. if (res < 0) {
  905. dev_err(&dev->dev, "Unable to requiest irq %d for PME\n", pme_irq);
  906. irq_dispose_mapping(pme_irq);
  907. return -ENODEV;
  908. }
  909. pci = hose->private_data;
  910. /* Enable PTOD, ENL23D & EXL23D */
  911. clrbits32(&pci->pex_pme_mes_disr,
  912. PME_DISR_EN_PTOD | PME_DISR_EN_ENL23D | PME_DISR_EN_EXL23D);
  913. out_be32(&pci->pex_pme_mes_ier, 0);
  914. setbits32(&pci->pex_pme_mes_ier,
  915. PME_DISR_EN_PTOD | PME_DISR_EN_ENL23D | PME_DISR_EN_EXL23D);
  916. /* PME Enable */
  917. pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pms);
  918. pms |= PCI_PM_CTRL_PME_ENABLE;
  919. pci_write_config_word(dev, dev->pm_cap + PCI_PM_CTRL, pms);
  920. return 0;
  921. }
  922. static void send_pme_turnoff_message(struct pci_controller *hose)
  923. {
  924. struct ccsr_pci __iomem *pci = hose->private_data;
  925. u32 dr;
  926. int i;
  927. /* Send PME_Turn_Off Message Request */
  928. setbits32(&pci->pex_pmcr, PEX_PMCR_PTOMR);
  929. /* Wait trun off done */
  930. for (i = 0; i < 150; i++) {
  931. dr = in_be32(&pci->pex_pme_mes_dr);
  932. if (dr) {
  933. out_be32(&pci->pex_pme_mes_dr, dr);
  934. break;
  935. }
  936. udelay(1000);
  937. }
  938. }
  939. static void fsl_pci_syscore_do_suspend(struct pci_controller *hose)
  940. {
  941. send_pme_turnoff_message(hose);
  942. }
  943. static int fsl_pci_syscore_suspend(void)
  944. {
  945. struct pci_controller *hose, *tmp;
  946. list_for_each_entry_safe(hose, tmp, &hose_list, list_node)
  947. fsl_pci_syscore_do_suspend(hose);
  948. return 0;
  949. }
  950. static void fsl_pci_syscore_do_resume(struct pci_controller *hose)
  951. {
  952. struct ccsr_pci __iomem *pci = hose->private_data;
  953. u32 dr;
  954. int i;
  955. /* Send Exit L2 State Message */
  956. setbits32(&pci->pex_pmcr, PEX_PMCR_EXL2S);
  957. /* Wait exit done */
  958. for (i = 0; i < 150; i++) {
  959. dr = in_be32(&pci->pex_pme_mes_dr);
  960. if (dr) {
  961. out_be32(&pci->pex_pme_mes_dr, dr);
  962. break;
  963. }
  964. udelay(1000);
  965. }
  966. setup_pci_atmu(hose);
  967. }
  968. static void fsl_pci_syscore_resume(void)
  969. {
  970. struct pci_controller *hose, *tmp;
  971. list_for_each_entry_safe(hose, tmp, &hose_list, list_node)
  972. fsl_pci_syscore_do_resume(hose);
  973. }
  974. static struct syscore_ops pci_syscore_pm_ops = {
  975. .suspend = fsl_pci_syscore_suspend,
  976. .resume = fsl_pci_syscore_resume,
  977. };
  978. #endif
  979. void fsl_pcibios_fixup_phb(struct pci_controller *phb)
  980. {
  981. #ifdef CONFIG_PM_SLEEP
  982. fsl_pci_pme_probe(phb);
  983. #endif
  984. }
  985. static int fsl_pci_probe(struct platform_device *pdev)
  986. {
  987. struct device_node *node;
  988. int ret;
  989. node = pdev->dev.of_node;
  990. ret = fsl_add_bridge(pdev, fsl_pci_primary == node);
  991. mpc85xx_pci_err_probe(pdev);
  992. return 0;
  993. }
  994. static struct platform_driver fsl_pci_driver = {
  995. .driver = {
  996. .name = "fsl-pci",
  997. .of_match_table = pci_ids,
  998. },
  999. .probe = fsl_pci_probe,
  1000. };
  1001. static int __init fsl_pci_init(void)
  1002. {
  1003. #ifdef CONFIG_PM_SLEEP
  1004. register_syscore_ops(&pci_syscore_pm_ops);
  1005. #endif
  1006. return platform_driver_register(&fsl_pci_driver);
  1007. }
  1008. arch_initcall(fsl_pci_init);
  1009. #endif