fsl_pci.c 31 KB

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