fsl_pci.c 31 KB

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