440spe_pcie.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593
  1. /*
  2. * (C) Copyright 2006
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. *
  5. * Copyright (c) 2005 Cisco Systems. All rights reserved.
  6. * Roland Dreier <rolandd@cisco.com>
  7. *
  8. * See file CREDITS for list of people who contributed to this
  9. * project.
  10. *
  11. * This program is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU General Public License as
  13. * published by the Free Software Foundation; either version 2 of
  14. * the License, or (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. */
  22. #include <asm/processor.h>
  23. #include <asm-ppc/io.h>
  24. #include <ppc4xx.h>
  25. #include <common.h>
  26. #include <pci.h>
  27. #include "440spe_pcie.h"
  28. #if defined(CONFIG_440SPE)
  29. #if defined(CONFIG_PCI)
  30. enum {
  31. PTYPE_ENDPOINT = 0x0,
  32. PTYPE_LEGACY_ENDPOINT = 0x1,
  33. PTYPE_ROOT_PORT = 0x4,
  34. LNKW_X1 = 0x1,
  35. LNKW_X4 = 0x4,
  36. LNKW_X8 = 0x8
  37. };
  38. static int pcie_read_config(struct pci_controller *hose, unsigned int devfn,
  39. int offset, int len, u32 *val) {
  40. *val = 0;
  41. /*
  42. * 440SPE implements only one function per port
  43. */
  44. if (!((PCI_FUNC(devfn) == 0) && (PCI_DEV(devfn) == 1)))
  45. return 0;
  46. devfn = PCI_BDF(0,0,0);
  47. offset += devfn << 4;
  48. switch (len) {
  49. case 1:
  50. *val = in_8(hose->cfg_data + offset);
  51. break;
  52. case 2:
  53. *val = in_le16((u16 *)(hose->cfg_data + offset));
  54. break;
  55. default:
  56. *val = in_le32((u32 *)(hose->cfg_data + offset));
  57. break;
  58. }
  59. return 0;
  60. }
  61. static int pcie_write_config(struct pci_controller *hose, unsigned int devfn,
  62. int offset, int len, u32 val) {
  63. /*
  64. * 440SPE implements only one function per port
  65. */
  66. if (!((PCI_FUNC(devfn) == 0) && (PCI_DEV(devfn) == 1)))
  67. return 0;
  68. devfn = PCI_BDF(0,0,0);
  69. offset += devfn << 4;
  70. switch (len) {
  71. case 1:
  72. out_8(hose->cfg_data + offset, val);
  73. break;
  74. case 2:
  75. out_le16((u16 *)(hose->cfg_data + offset), val);
  76. break;
  77. default:
  78. out_le32((u32 *)(hose->cfg_data + offset), val);
  79. break;
  80. }
  81. return 0;
  82. }
  83. int pcie_read_config_byte(struct pci_controller *hose,pci_dev_t dev,int offset,u8 *val)
  84. {
  85. u32 v;
  86. int rv;
  87. rv = pcie_read_config(hose, dev, offset, 1, &v);
  88. *val = (u8)v;
  89. return rv;
  90. }
  91. int pcie_read_config_word(struct pci_controller *hose,pci_dev_t dev,int offset,u16 *val)
  92. {
  93. u32 v;
  94. int rv;
  95. rv = pcie_read_config(hose, dev, offset, 2, &v);
  96. *val = (u16)v;
  97. return rv;
  98. }
  99. int pcie_read_config_dword(struct pci_controller *hose,pci_dev_t dev,int offset,u32 *val)
  100. {
  101. u32 v;
  102. int rv;
  103. rv = pcie_read_config(hose, dev, offset, 3, &v);
  104. *val = (u32)v;
  105. return rv;
  106. }
  107. int pcie_write_config_byte(struct pci_controller *hose,pci_dev_t dev,int offset,u8 val)
  108. {
  109. return pcie_write_config(hose,(u32)dev,offset,1,val);
  110. }
  111. int pcie_write_config_word(struct pci_controller *hose,pci_dev_t dev,int offset,u16 val)
  112. {
  113. return pcie_write_config(hose,(u32)dev,offset,2,(u32 )val);
  114. }
  115. int pcie_write_config_dword(struct pci_controller *hose,pci_dev_t dev,int offset,u32 val)
  116. {
  117. return pcie_write_config(hose,(u32)dev,offset,3,(u32 )val);
  118. }
  119. static void ppc440spe_setup_utl(u32 port) {
  120. volatile void *utl_base = NULL;
  121. /*
  122. * Map UTL registers
  123. */
  124. switch (port) {
  125. case 0:
  126. mtdcr(DCRN_PEGPL_REGBAH(PCIE0), 0x0000000d);
  127. mtdcr(DCRN_PEGPL_REGBAL(PCIE0), 0x60000400);
  128. mtdcr(DCRN_PEGPL_REGMSK(PCIE0), 0xFFFFFC01);
  129. mtdcr(DCRN_PEGPL_SPECIAL(PCIE0), 0x68782800);
  130. utl_base = (unsigned int *)(CFG_PCIE1_REGBASE);
  131. break;
  132. case 1:
  133. mtdcr(DCRN_PEGPL_REGBAH(PCIE1), 0x0000000d);
  134. mtdcr(DCRN_PEGPL_REGBAL(PCIE1), 0x60001400);
  135. mtdcr(DCRN_PEGPL_REGMSK(PCIE1), 0xFFFFFC01);
  136. mtdcr(DCRN_PEGPL_SPECIAL(PCIE1), 0x68782800);
  137. utl_base = (unsigned int *)(CFG_PCIE3_REGBASE);
  138. break;
  139. case 2:
  140. mtdcr(DCRN_PEGPL_REGBAH(PCIE2), 0x0000000d);
  141. mtdcr(DCRN_PEGPL_REGBAL(PCIE2), 0x60002400);
  142. mtdcr(DCRN_PEGPL_REGMSK(PCIE2), 0xFFFFFC01);
  143. mtdcr(DCRN_PEGPL_SPECIAL(PCIE2), 0x68782800);
  144. utl_base = (unsigned int *)(CFG_PCIE5_REGBASE);
  145. break;
  146. }
  147. /*
  148. * Set buffer allocations and then assert VRB and TXE.
  149. */
  150. out_be32(utl_base + PEUTL_OUTTR, 0x08000000);
  151. out_be32(utl_base + PEUTL_INTR, 0x02000000);
  152. out_be32(utl_base + PEUTL_OPDBSZ, 0x10000000);
  153. out_be32(utl_base + PEUTL_PBBSZ, 0x53000000);
  154. out_be32(utl_base + PEUTL_IPHBSZ, 0x08000000);
  155. out_be32(utl_base + PEUTL_IPDBSZ, 0x10000000);
  156. out_be32(utl_base + PEUTL_RCIRQEN, 0x00f00000);
  157. out_be32(utl_base + PEUTL_PCTL, 0x8080007d);
  158. }
  159. static int check_error(void)
  160. {
  161. u32 valPE0, valPE1, valPE2;
  162. int err = 0;
  163. /* SDR0_PEGPLLLCT1 reset */
  164. if (!(valPE0 = SDR_READ(PESDR0_PLLLCT1) & 0x01000000)) {
  165. printf("PCIE: SDR0_PEGPLLLCT1 reset error 0x%x\n", valPE0);
  166. }
  167. valPE0 = SDR_READ(PESDR0_RCSSET);
  168. valPE1 = SDR_READ(PESDR1_RCSSET);
  169. valPE2 = SDR_READ(PESDR2_RCSSET);
  170. /* SDR0_PExRCSSET rstgu */
  171. if (!(valPE0 & 0x01000000) ||
  172. !(valPE1 & 0x01000000) ||
  173. !(valPE2 & 0x01000000)) {
  174. printf("PCIE: SDR0_PExRCSSET rstgu error\n");
  175. err = -1;
  176. }
  177. /* SDR0_PExRCSSET rstdl */
  178. if (!(valPE0 & 0x00010000) ||
  179. !(valPE1 & 0x00010000) ||
  180. !(valPE2 & 0x00010000)) {
  181. printf("PCIE: SDR0_PExRCSSET rstdl error\n");
  182. err = -1;
  183. }
  184. /* SDR0_PExRCSSET rstpyn */
  185. if ((valPE0 & 0x00001000) ||
  186. (valPE1 & 0x00001000) ||
  187. (valPE2 & 0x00001000)) {
  188. printf("PCIE: SDR0_PExRCSSET rstpyn error\n");
  189. err = -1;
  190. }
  191. /* SDR0_PExRCSSET hldplb */
  192. if ((valPE0 & 0x10000000) ||
  193. (valPE1 & 0x10000000) ||
  194. (valPE2 & 0x10000000)) {
  195. printf("PCIE: SDR0_PExRCSSET hldplb error\n");
  196. err = -1;
  197. }
  198. /* SDR0_PExRCSSET rdy */
  199. if ((valPE0 & 0x00100000) ||
  200. (valPE1 & 0x00100000) ||
  201. (valPE2 & 0x00100000)) {
  202. printf("PCIE: SDR0_PExRCSSET rdy error\n");
  203. err = -1;
  204. }
  205. /* SDR0_PExRCSSET shutdown */
  206. if ((valPE0 & 0x00000100) ||
  207. (valPE1 & 0x00000100) ||
  208. (valPE2 & 0x00000100)) {
  209. printf("PCIE: SDR0_PExRCSSET shutdown error\n");
  210. err = -1;
  211. }
  212. return err;
  213. }
  214. /*
  215. * Initialize PCI Express core
  216. */
  217. int ppc440spe_init_pcie(void)
  218. {
  219. int time_out = 20;
  220. /* Set PLL clock receiver to LVPECL */
  221. SDR_WRITE(PESDR0_PLLLCT1, SDR_READ(PESDR0_PLLLCT1) | 1 << 28);
  222. if (check_error())
  223. return -1;
  224. if (!(SDR_READ(PESDR0_PLLLCT2) & 0x10000))
  225. {
  226. printf("PCIE: PESDR_PLLCT2 resistance calibration failed (0x%08x)\n",
  227. SDR_READ(PESDR0_PLLLCT2));
  228. return -1;
  229. }
  230. /* De-assert reset of PCIe PLL, wait for lock */
  231. SDR_WRITE(PESDR0_PLLLCT1, SDR_READ(PESDR0_PLLLCT1) & ~(1 << 24));
  232. udelay(3);
  233. while(time_out) {
  234. if (!(SDR_READ(PESDR0_PLLLCT3) & 0x10000000)) {
  235. time_out--;
  236. udelay(1);
  237. } else
  238. break;
  239. }
  240. if (!time_out) {
  241. printf("PCIE: VCO output not locked\n");
  242. return -1;
  243. }
  244. return 0;
  245. }
  246. int ppc440spe_init_pcie_rootport(int port)
  247. {
  248. static int core_init;
  249. volatile u32 val = 0;
  250. int attempts;
  251. if (!core_init) {
  252. ++core_init;
  253. if (ppc440spe_init_pcie())
  254. return -1;
  255. }
  256. /*
  257. * Initialize various parts of the PCI Express core for our port:
  258. *
  259. * - Set as a root port and enable max width
  260. * (PXIE0 -> X8, PCIE1 and PCIE2 -> X4).
  261. * - Set up UTL configuration.
  262. * - Increase SERDES drive strength to levels suggested by AMCC.
  263. * - De-assert RSTPYN, RSTDL and RSTGU.
  264. *
  265. * NOTICE for revB chip: PESDRn_UTLSET2 is not set - we leave it with
  266. * default setting 0x11310000. The register has new fields,
  267. * PESDRn_UTLSET2[LKINE] in particular: clearing it leads to PCIE core
  268. * hang.
  269. */
  270. switch (port) {
  271. case 0:
  272. SDR_WRITE(PESDR0_DLPSET, 1 << 24 | PTYPE_ROOT_PORT << 20 | LNKW_X8 << 12);
  273. SDR_WRITE(PESDR0_UTLSET1, 0x21222222);
  274. if (!ppc440spe_revB())
  275. SDR_WRITE(PESDR0_UTLSET2, 0x11000000);
  276. SDR_WRITE(PESDR0_HSSL0SET1, 0x35000000);
  277. SDR_WRITE(PESDR0_HSSL1SET1, 0x35000000);
  278. SDR_WRITE(PESDR0_HSSL2SET1, 0x35000000);
  279. SDR_WRITE(PESDR0_HSSL3SET1, 0x35000000);
  280. SDR_WRITE(PESDR0_HSSL4SET1, 0x35000000);
  281. SDR_WRITE(PESDR0_HSSL5SET1, 0x35000000);
  282. SDR_WRITE(PESDR0_HSSL6SET1, 0x35000000);
  283. SDR_WRITE(PESDR0_HSSL7SET1, 0x35000000);
  284. SDR_WRITE(PESDR0_RCSSET,
  285. (SDR_READ(PESDR0_RCSSET) & ~(1 << 24 | 1 << 16)) | 1 << 12);
  286. break;
  287. case 1:
  288. SDR_WRITE(PESDR1_DLPSET, 1 << 24 | PTYPE_ROOT_PORT << 20 | LNKW_X4 << 12);
  289. SDR_WRITE(PESDR1_UTLSET1, 0x21222222);
  290. if (!ppc440spe_revB())
  291. SDR_WRITE(PESDR1_UTLSET2, 0x11000000);
  292. SDR_WRITE(PESDR1_HSSL0SET1, 0x35000000);
  293. SDR_WRITE(PESDR1_HSSL1SET1, 0x35000000);
  294. SDR_WRITE(PESDR1_HSSL2SET1, 0x35000000);
  295. SDR_WRITE(PESDR1_HSSL3SET1, 0x35000000);
  296. SDR_WRITE(PESDR1_RCSSET,
  297. (SDR_READ(PESDR1_RCSSET) & ~(1 << 24 | 1 << 16)) | 1 << 12);
  298. break;
  299. case 2:
  300. SDR_WRITE(PESDR2_DLPSET, 1 << 24 | PTYPE_ROOT_PORT << 20 | LNKW_X4 << 12);
  301. SDR_WRITE(PESDR2_UTLSET1, 0x21222222);
  302. if (!ppc440spe_revB())
  303. SDR_WRITE(PESDR2_UTLSET2, 0x11000000);
  304. SDR_WRITE(PESDR2_HSSL0SET1, 0x35000000);
  305. SDR_WRITE(PESDR2_HSSL1SET1, 0x35000000);
  306. SDR_WRITE(PESDR2_HSSL2SET1, 0x35000000);
  307. SDR_WRITE(PESDR2_HSSL3SET1, 0x35000000);
  308. SDR_WRITE(PESDR2_RCSSET,
  309. (SDR_READ(PESDR2_RCSSET) & ~(1 << 24 | 1 << 16)) | 1 << 12);
  310. break;
  311. }
  312. /*
  313. * Notice: the following delay has critical impact on device
  314. * initialization - if too short (<50ms) the link doesn't get up.
  315. */
  316. mdelay(100);
  317. switch (port) {
  318. case 0: val = SDR_READ(PESDR0_RCSSTS); break;
  319. case 1: val = SDR_READ(PESDR1_RCSSTS); break;
  320. case 2: val = SDR_READ(PESDR2_RCSSTS); break;
  321. }
  322. if (val & (1 << 20)) {
  323. printf("PCIE%d: PGRST failed %08x\n", port, val);
  324. return -1;
  325. }
  326. /*
  327. * Verify link is up
  328. */
  329. val = 0;
  330. switch (port)
  331. {
  332. case 0:
  333. val = SDR_READ(PESDR0_LOOP);
  334. break;
  335. case 1:
  336. val = SDR_READ(PESDR1_LOOP);
  337. break;
  338. case 2:
  339. val = SDR_READ(PESDR2_LOOP);
  340. break;
  341. }
  342. if (!(val & 0x00001000)) {
  343. printf("PCIE%d: link is not up.\n", port);
  344. return -1;
  345. }
  346. /*
  347. * Setup UTL registers - but only on revA!
  348. * We use default settings for revB chip.
  349. */
  350. if (!ppc440spe_revB())
  351. ppc440spe_setup_utl(port);
  352. /*
  353. * We map PCI Express configuration access into the 512MB regions
  354. *
  355. * NOTICE: revB is very strict about PLB real addressess and ranges to
  356. * be mapped for config space; it seems to only work with d_nnnn_nnnn
  357. * range (hangs the core upon config transaction attempts when set
  358. * otherwise) while revA uses c_nnnn_nnnn.
  359. *
  360. * For revA:
  361. * PCIE0: 0xc_4000_0000
  362. * PCIE1: 0xc_8000_0000
  363. * PCIE2: 0xc_c000_0000
  364. *
  365. * For revB:
  366. * PCIE0: 0xd_0000_0000
  367. * PCIE1: 0xd_2000_0000
  368. * PCIE2: 0xd_4000_0000
  369. */
  370. switch (port) {
  371. case 0:
  372. if (ppc440spe_revB()) {
  373. mtdcr(DCRN_PEGPL_CFGBAH(PCIE0), 0x0000000d);
  374. mtdcr(DCRN_PEGPL_CFGBAL(PCIE0), 0x00000000);
  375. } else {
  376. /* revA */
  377. mtdcr(DCRN_PEGPL_CFGBAH(PCIE0), 0x0000000c);
  378. mtdcr(DCRN_PEGPL_CFGBAL(PCIE0), 0x40000000);
  379. }
  380. mtdcr(DCRN_PEGPL_CFGMSK(PCIE0), 0xe0000001); /* 512MB region, valid */
  381. break;
  382. case 1:
  383. if (ppc440spe_revB()) {
  384. mtdcr(DCRN_PEGPL_CFGBAH(PCIE1), 0x0000000d);
  385. mtdcr(DCRN_PEGPL_CFGBAL(PCIE1), 0x20000000);
  386. } else {
  387. mtdcr(DCRN_PEGPL_CFGBAH(PCIE1), 0x0000000c);
  388. mtdcr(DCRN_PEGPL_CFGBAL(PCIE1), 0x80000000);
  389. }
  390. mtdcr(DCRN_PEGPL_CFGMSK(PCIE1), 0xe0000001); /* 512MB region, valid */
  391. break;
  392. case 2:
  393. if (ppc440spe_revB()) {
  394. mtdcr(DCRN_PEGPL_CFGBAH(PCIE2), 0x0000000d);
  395. mtdcr(DCRN_PEGPL_CFGBAL(PCIE2), 0x40000000);
  396. } else {
  397. mtdcr(DCRN_PEGPL_CFGBAH(PCIE2), 0x0000000c);
  398. mtdcr(DCRN_PEGPL_CFGBAL(PCIE2), 0xc0000000);
  399. }
  400. mtdcr(DCRN_PEGPL_CFGMSK(PCIE2), 0xe0000001); /* 512MB region, valid */
  401. break;
  402. }
  403. /*
  404. * Check for VC0 active and assert RDY.
  405. */
  406. attempts = 10;
  407. switch (port) {
  408. case 0:
  409. while(!(SDR_READ(PESDR0_RCSSTS) & (1 << 16))) {
  410. if (!(attempts--)) {
  411. printf("PCIE0: VC0 not active\n");
  412. return -1;
  413. }
  414. mdelay(1000);
  415. }
  416. SDR_WRITE(PESDR0_RCSSET, SDR_READ(PESDR0_RCSSET) | 1 << 20);
  417. break;
  418. case 1:
  419. while(!(SDR_READ(PESDR1_RCSSTS) & (1 << 16))) {
  420. if (!(attempts--)) {
  421. printf("PCIE1: VC0 not active\n");
  422. return -1;
  423. }
  424. mdelay(1000);
  425. }
  426. SDR_WRITE(PESDR1_RCSSET, SDR_READ(PESDR1_RCSSET) | 1 << 20);
  427. break;
  428. case 2:
  429. while(!(SDR_READ(PESDR2_RCSSTS) & (1 << 16))) {
  430. if (!(attempts--)) {
  431. printf("PCIE2: VC0 not active\n");
  432. return -1;
  433. }
  434. mdelay(1000);
  435. }
  436. SDR_WRITE(PESDR2_RCSSET, SDR_READ(PESDR2_RCSSET) | 1 << 20);
  437. break;
  438. }
  439. mdelay(100);
  440. return 0;
  441. }
  442. void ppc440spe_setup_pcie(struct pci_controller *hose, int port)
  443. {
  444. volatile void *mbase = NULL;
  445. pci_set_ops(hose,
  446. pcie_read_config_byte,
  447. pcie_read_config_word,
  448. pcie_read_config_dword,
  449. pcie_write_config_byte,
  450. pcie_write_config_word,
  451. pcie_write_config_dword);
  452. switch(port) {
  453. case 0:
  454. mbase = (u32 *)CFG_PCIE0_XCFGBASE;
  455. hose->cfg_data = (u8 *)CFG_PCIE0_CFGBASE;
  456. break;
  457. case 1:
  458. mbase = (u32 *)CFG_PCIE1_XCFGBASE;
  459. hose->cfg_data = (u8 *)CFG_PCIE1_CFGBASE;
  460. break;
  461. case 2:
  462. mbase = (u32 *)CFG_PCIE2_XCFGBASE;
  463. hose->cfg_data = (u8 *)CFG_PCIE2_CFGBASE;
  464. break;
  465. }
  466. /*
  467. * Set bus numbers on our root port
  468. */
  469. if (ppc440spe_revB()) {
  470. out_8((u8 *)mbase + PCI_PRIMARY_BUS, 0);
  471. out_8((u8 *)mbase + PCI_SECONDARY_BUS, 1);
  472. out_8((u8 *)mbase + PCI_SUBORDINATE_BUS, 1);
  473. } else {
  474. out_8((u8 *)mbase + PCI_PRIMARY_BUS, 0);
  475. out_8((u8 *)mbase + PCI_SECONDARY_BUS, 0);
  476. }
  477. /*
  478. * Set up outbound translation to hose->mem_space from PLB
  479. * addresses at an offset of 0xd_0000_0000. We set the low
  480. * bits of the mask to 11 to turn off splitting into 8
  481. * subregions and to enable the outbound translation.
  482. */
  483. out_le32(mbase + PECFG_POM0LAH, 0x00000000);
  484. out_le32(mbase + PECFG_POM0LAL, (CFG_PCIE_MEMBASE +
  485. port * CFG_PCIE_MEMSIZE));
  486. switch (port) {
  487. case 0:
  488. mtdcr(DCRN_PEGPL_OMR1BAH(PCIE0), 0x0000000d);
  489. mtdcr(DCRN_PEGPL_OMR1BAL(PCIE0), CFG_PCIE_MEMBASE +
  490. port * CFG_PCIE_MEMSIZE);
  491. mtdcr(DCRN_PEGPL_OMR1MSKH(PCIE0), 0x7fffffff);
  492. mtdcr(DCRN_PEGPL_OMR1MSKL(PCIE0),
  493. ~(CFG_PCIE_MEMSIZE - 1) | 3);
  494. break;
  495. case 1:
  496. mtdcr(DCRN_PEGPL_OMR1BAH(PCIE1), 0x0000000d);
  497. mtdcr(DCRN_PEGPL_OMR1BAL(PCIE1), (CFG_PCIE_MEMBASE +
  498. port * CFG_PCIE_MEMSIZE));
  499. mtdcr(DCRN_PEGPL_OMR1MSKH(PCIE1), 0x7fffffff);
  500. mtdcr(DCRN_PEGPL_OMR1MSKL(PCIE1),
  501. ~(CFG_PCIE_MEMSIZE - 1) | 3);
  502. break;
  503. case 2:
  504. mtdcr(DCRN_PEGPL_OMR1BAH(PCIE2), 0x0000000d);
  505. mtdcr(DCRN_PEGPL_OMR1BAL(PCIE2), (CFG_PCIE_MEMBASE +
  506. port * CFG_PCIE_MEMSIZE));
  507. mtdcr(DCRN_PEGPL_OMR1MSKH(PCIE2), 0x7fffffff);
  508. mtdcr(DCRN_PEGPL_OMR1MSKL(PCIE2),
  509. ~(CFG_PCIE_MEMSIZE - 1) | 3);
  510. break;
  511. }
  512. /* Set up 16GB inbound memory window at 0 */
  513. out_le32(mbase + PCI_BASE_ADDRESS_0, 0);
  514. out_le32(mbase + PCI_BASE_ADDRESS_1, 0);
  515. out_le32(mbase + PECFG_BAR0HMPA, 0x7fffffc);
  516. out_le32(mbase + PECFG_BAR0LMPA, 0);
  517. out_le32(mbase + PECFG_PIM0LAL, 0);
  518. out_le32(mbase + PECFG_PIM0LAH, 0);
  519. out_le32(mbase + PECFG_PIMEN, 0x1);
  520. /* Enable I/O, Mem, and Busmaster cycles */
  521. out_le16((u16 *)(mbase + PCI_COMMAND),
  522. in_le16((u16 *)(mbase + PCI_COMMAND)) |
  523. PCI_COMMAND_IO | PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER);
  524. }
  525. #endif /* CONFIG_PCI */
  526. #endif /* CONFIG_440SPE */