440spe_pcie.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592
  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), 0x0000000c);
  127. mtdcr(DCRN_PEGPL_REGBAL(PCIE0), 0x20000000);
  128. mtdcr(DCRN_PEGPL_REGMSK(PCIE0), 0x00007001);
  129. mtdcr(DCRN_PEGPL_SPECIAL(PCIE0), 0x68782800);
  130. break;
  131. case 1:
  132. mtdcr(DCRN_PEGPL_REGBAH(PCIE1), 0x0000000c);
  133. mtdcr(DCRN_PEGPL_REGBAL(PCIE1), 0x20001000);
  134. mtdcr(DCRN_PEGPL_REGMSK(PCIE1), 0x00007001);
  135. mtdcr(DCRN_PEGPL_SPECIAL(PCIE1), 0x68782800);
  136. break;
  137. case 2:
  138. mtdcr(DCRN_PEGPL_REGBAH(PCIE2), 0x0000000c);
  139. mtdcr(DCRN_PEGPL_REGBAL(PCIE2), 0x20002000);
  140. mtdcr(DCRN_PEGPL_REGMSK(PCIE2), 0x00007001);
  141. mtdcr(DCRN_PEGPL_SPECIAL(PCIE2), 0x68782800);
  142. break;
  143. }
  144. utl_base = (unsigned int *)(CFG_PCIE_BASE + 0x1000 * port);
  145. /*
  146. * Set buffer allocations and then assert VRB and TXE.
  147. */
  148. out_be32(utl_base + PEUTL_OUTTR, 0x08000000);
  149. out_be32(utl_base + PEUTL_INTR, 0x02000000);
  150. out_be32(utl_base + PEUTL_OPDBSZ, 0x10000000);
  151. out_be32(utl_base + PEUTL_PBBSZ, 0x53000000);
  152. out_be32(utl_base + PEUTL_IPHBSZ, 0x08000000);
  153. out_be32(utl_base + PEUTL_IPDBSZ, 0x10000000);
  154. out_be32(utl_base + PEUTL_RCIRQEN, 0x00f00000);
  155. out_be32(utl_base + PEUTL_PCTL, 0x80800066);
  156. }
  157. static int check_error(void)
  158. {
  159. u32 valPE0, valPE1, valPE2;
  160. int err = 0;
  161. /* SDR0_PEGPLLLCT1 reset */
  162. if (!(valPE0 = SDR_READ(PESDR0_PLLLCT1) & 0x01000000)) {
  163. printf("PCIE: SDR0_PEGPLLLCT1 reset error 0x%x\n", valPE0);
  164. }
  165. valPE0 = SDR_READ(PESDR0_RCSSET);
  166. valPE1 = SDR_READ(PESDR1_RCSSET);
  167. valPE2 = SDR_READ(PESDR2_RCSSET);
  168. /* SDR0_PExRCSSET rstgu */
  169. if (!(valPE0 & 0x01000000) ||
  170. !(valPE1 & 0x01000000) ||
  171. !(valPE2 & 0x01000000)) {
  172. printf("PCIE: SDR0_PExRCSSET rstgu error\n");
  173. err = -1;
  174. }
  175. /* SDR0_PExRCSSET rstdl */
  176. if (!(valPE0 & 0x00010000) ||
  177. !(valPE1 & 0x00010000) ||
  178. !(valPE2 & 0x00010000)) {
  179. printf("PCIE: SDR0_PExRCSSET rstdl error\n");
  180. err = -1;
  181. }
  182. /* SDR0_PExRCSSET rstpyn */
  183. if ((valPE0 & 0x00001000) ||
  184. (valPE1 & 0x00001000) ||
  185. (valPE2 & 0x00001000)) {
  186. printf("PCIE: SDR0_PExRCSSET rstpyn error\n");
  187. err = -1;
  188. }
  189. /* SDR0_PExRCSSET hldplb */
  190. if ((valPE0 & 0x10000000) ||
  191. (valPE1 & 0x10000000) ||
  192. (valPE2 & 0x10000000)) {
  193. printf("PCIE: SDR0_PExRCSSET hldplb error\n");
  194. err = -1;
  195. }
  196. /* SDR0_PExRCSSET rdy */
  197. if ((valPE0 & 0x00100000) ||
  198. (valPE1 & 0x00100000) ||
  199. (valPE2 & 0x00100000)) {
  200. printf("PCIE: SDR0_PExRCSSET rdy error\n");
  201. err = -1;
  202. }
  203. /* SDR0_PExRCSSET shutdown */
  204. if ((valPE0 & 0x00000100) ||
  205. (valPE1 & 0x00000100) ||
  206. (valPE2 & 0x00000100)) {
  207. printf("PCIE: SDR0_PExRCSSET shutdown error\n");
  208. err = -1;
  209. }
  210. return err;
  211. }
  212. /*
  213. * Initialize PCI Express core
  214. */
  215. int ppc440spe_init_pcie(void)
  216. {
  217. int time_out = 20;
  218. /* Set PLL clock receiver to LVPECL */
  219. SDR_WRITE(PESDR0_PLLLCT1, SDR_READ(PESDR0_PLLLCT1) | 1 << 28);
  220. if (check_error())
  221. return -1;
  222. if (!(SDR_READ(PESDR0_PLLLCT2) & 0x10000))
  223. {
  224. printf("PCIE: PESDR_PLLCT2 resistance calibration failed (0x%08x)\n",
  225. SDR_READ(PESDR0_PLLLCT2));
  226. return -1;
  227. }
  228. /* De-assert reset of PCIe PLL, wait for lock */
  229. SDR_WRITE(PESDR0_PLLLCT1, SDR_READ(PESDR0_PLLLCT1) & ~(1 << 24));
  230. udelay(3);
  231. while(time_out) {
  232. if (!(SDR_READ(PESDR0_PLLLCT3) & 0x10000000)) {
  233. time_out--;
  234. udelay(1);
  235. } else
  236. break;
  237. }
  238. if (!time_out) {
  239. printf("PCIE: VCO output not locked\n");
  240. return -1;
  241. }
  242. return 0;
  243. }
  244. int ppc440spe_init_pcie_rootport(int port)
  245. {
  246. static int core_init;
  247. volatile u32 val = 0;
  248. int attempts;
  249. if (!core_init) {
  250. ++core_init;
  251. if (ppc440spe_init_pcie())
  252. return -1;
  253. }
  254. /*
  255. * Initialize various parts of the PCI Express core for our port:
  256. *
  257. * - Set as a root port and enable max width
  258. * (PXIE0 -> X8, PCIE1 and PCIE2 -> X4).
  259. * - Set up UTL configuration.
  260. * - Increase SERDES drive strength to levels suggested by AMCC.
  261. * - De-assert RSTPYN, RSTDL and RSTGU.
  262. *
  263. * NOTICE for revB chip: PESDRn_UTLSET2 is not set - we leave it with
  264. * default setting 0x11310000. The register has new fields,
  265. * PESDRn_UTLSET2[LKINE] in particular: clearing it leads to PCIE core
  266. * hang.
  267. */
  268. switch (port) {
  269. case 0:
  270. SDR_WRITE(PESDR0_DLPSET, 1 << 24 | PTYPE_ROOT_PORT << 20 | LNKW_X8 << 12);
  271. SDR_WRITE(PESDR0_UTLSET1, 0x21222222);
  272. if (!ppc440spe_revB())
  273. SDR_WRITE(PESDR0_UTLSET2, 0x11000000);
  274. SDR_WRITE(PESDR0_HSSL0SET1, 0x35000000);
  275. SDR_WRITE(PESDR0_HSSL1SET1, 0x35000000);
  276. SDR_WRITE(PESDR0_HSSL2SET1, 0x35000000);
  277. SDR_WRITE(PESDR0_HSSL3SET1, 0x35000000);
  278. SDR_WRITE(PESDR0_HSSL4SET1, 0x35000000);
  279. SDR_WRITE(PESDR0_HSSL5SET1, 0x35000000);
  280. SDR_WRITE(PESDR0_HSSL6SET1, 0x35000000);
  281. SDR_WRITE(PESDR0_HSSL7SET1, 0x35000000);
  282. SDR_WRITE(PESDR0_RCSSET,
  283. (SDR_READ(PESDR0_RCSSET) & ~(1 << 24 | 1 << 16)) | 1 << 12);
  284. break;
  285. case 1:
  286. SDR_WRITE(PESDR1_DLPSET, 1 << 24 | PTYPE_ROOT_PORT << 20 | LNKW_X4 << 12);
  287. SDR_WRITE(PESDR1_UTLSET1, 0x21222222);
  288. if (!ppc440spe_revB())
  289. SDR_WRITE(PESDR1_UTLSET2, 0x11000000);
  290. SDR_WRITE(PESDR1_HSSL0SET1, 0x35000000);
  291. SDR_WRITE(PESDR1_HSSL1SET1, 0x35000000);
  292. SDR_WRITE(PESDR1_HSSL2SET1, 0x35000000);
  293. SDR_WRITE(PESDR1_HSSL3SET1, 0x35000000);
  294. SDR_WRITE(PESDR1_RCSSET,
  295. (SDR_READ(PESDR1_RCSSET) & ~(1 << 24 | 1 << 16)) | 1 << 12);
  296. break;
  297. case 2:
  298. SDR_WRITE(PESDR2_DLPSET, 1 << 24 | PTYPE_ROOT_PORT << 20 | LNKW_X4 << 12);
  299. SDR_WRITE(PESDR2_UTLSET1, 0x21222222);
  300. if (!ppc440spe_revB())
  301. SDR_WRITE(PESDR2_UTLSET2, 0x11000000);
  302. SDR_WRITE(PESDR2_HSSL0SET1, 0x35000000);
  303. SDR_WRITE(PESDR2_HSSL1SET1, 0x35000000);
  304. SDR_WRITE(PESDR2_HSSL2SET1, 0x35000000);
  305. SDR_WRITE(PESDR2_HSSL3SET1, 0x35000000);
  306. SDR_WRITE(PESDR2_RCSSET,
  307. (SDR_READ(PESDR2_RCSSET) & ~(1 << 24 | 1 << 16)) | 1 << 12);
  308. break;
  309. }
  310. /*
  311. * Notice: the following delay has critical impact on device
  312. * initialization - if too short (<50ms) the link doesn't get up.
  313. */
  314. mdelay(100);
  315. switch (port) {
  316. case 0: val = SDR_READ(PESDR0_RCSSTS); break;
  317. case 1: val = SDR_READ(PESDR1_RCSSTS); break;
  318. case 2: val = SDR_READ(PESDR2_RCSSTS); break;
  319. }
  320. if (val & (1 << 20)) {
  321. printf("PCIE%d: PGRST failed %08x\n", port, val);
  322. return -1;
  323. }
  324. /*
  325. * Verify link is up
  326. */
  327. val = 0;
  328. switch (port)
  329. {
  330. case 0:
  331. val = SDR_READ(PESDR0_LOOP);
  332. break;
  333. case 1:
  334. val = SDR_READ(PESDR1_LOOP);
  335. break;
  336. case 2:
  337. val = SDR_READ(PESDR2_LOOP);
  338. break;
  339. }
  340. if (!(val & 0x00001000)) {
  341. printf("PCIE%d: link is not up.\n", port);
  342. return -1;
  343. }
  344. /*
  345. * Setup UTL registers - but only on revA!
  346. * We use default settings for revB chip.
  347. */
  348. if (!ppc440spe_revB())
  349. ppc440spe_setup_utl(port);
  350. /*
  351. * We map PCI Express configuration access into the 512MB regions
  352. *
  353. * NOTICE: revB is very strict about PLB real addressess and ranges to
  354. * be mapped for config space; it seems to only work with d_nnnn_nnnn
  355. * range (hangs the core upon config transaction attempts when set
  356. * otherwise) while revA uses c_nnnn_nnnn.
  357. *
  358. * For revA:
  359. * PCIE0: 0xc_4000_0000
  360. * PCIE1: 0xc_8000_0000
  361. * PCIE2: 0xc_c000_0000
  362. *
  363. * For revB:
  364. * PCIE0: 0xd_0000_0000
  365. * PCIE1: 0xd_2000_0000
  366. * PCIE2: 0xd_4000_0000
  367. */
  368. switch (port) {
  369. case 0:
  370. if (ppc440spe_revB()) {
  371. mtdcr(DCRN_PEGPL_CFGBAH(PCIE0), 0x0000000d);
  372. mtdcr(DCRN_PEGPL_CFGBAL(PCIE0), 0x00000000);
  373. } else {
  374. /* revA */
  375. mtdcr(DCRN_PEGPL_CFGBAH(PCIE0), 0x0000000c);
  376. mtdcr(DCRN_PEGPL_CFGBAL(PCIE0), 0x40000000);
  377. }
  378. mtdcr(DCRN_PEGPL_CFGMSK(PCIE0), 0xe0000001); /* 512MB region, valid */
  379. break;
  380. case 1:
  381. if (ppc440spe_revB()) {
  382. mtdcr(DCRN_PEGPL_CFGBAH(PCIE1), 0x0000000d);
  383. mtdcr(DCRN_PEGPL_CFGBAL(PCIE1), 0x20000000);
  384. } else {
  385. mtdcr(DCRN_PEGPL_CFGBAH(PCIE1), 0x0000000c);
  386. mtdcr(DCRN_PEGPL_CFGBAL(PCIE1), 0x80000000);
  387. }
  388. mtdcr(DCRN_PEGPL_CFGMSK(PCIE1), 0xe0000001); /* 512MB region, valid */
  389. break;
  390. case 2:
  391. if (ppc440spe_revB()) {
  392. mtdcr(DCRN_PEGPL_CFGBAH(PCIE2), 0x0000000d);
  393. mtdcr(DCRN_PEGPL_CFGBAL(PCIE2), 0x40000000);
  394. } else {
  395. mtdcr(DCRN_PEGPL_CFGBAH(PCIE2), 0x0000000c);
  396. mtdcr(DCRN_PEGPL_CFGBAL(PCIE2), 0xc0000000);
  397. }
  398. mtdcr(DCRN_PEGPL_CFGMSK(PCIE2), 0xe0000001); /* 512MB region, valid */
  399. break;
  400. }
  401. /*
  402. * Check for VC0 active and assert RDY.
  403. */
  404. attempts = 10;
  405. switch (port) {
  406. case 0:
  407. while(!(SDR_READ(PESDR0_RCSSTS) & (1 << 16))) {
  408. if (!(attempts--)) {
  409. printf("PCIE0: VC0 not active\n");
  410. return -1;
  411. }
  412. mdelay(1000);
  413. }
  414. SDR_WRITE(PESDR0_RCSSET, SDR_READ(PESDR0_RCSSET) | 1 << 20);
  415. break;
  416. case 1:
  417. while(!(SDR_READ(PESDR1_RCSSTS) & (1 << 16))) {
  418. if (!(attempts--)) {
  419. printf("PCIE1: VC0 not active\n");
  420. return -1;
  421. }
  422. mdelay(1000);
  423. }
  424. SDR_WRITE(PESDR1_RCSSET, SDR_READ(PESDR1_RCSSET) | 1 << 20);
  425. break;
  426. case 2:
  427. while(!(SDR_READ(PESDR2_RCSSTS) & (1 << 16))) {
  428. if (!(attempts--)) {
  429. printf("PCIE2: VC0 not active\n");
  430. return -1;
  431. }
  432. mdelay(1000);
  433. }
  434. SDR_WRITE(PESDR2_RCSSET, SDR_READ(PESDR2_RCSSET) | 1 << 20);
  435. break;
  436. }
  437. mdelay(100);
  438. return 0;
  439. }
  440. void ppc440spe_setup_pcie(struct pci_controller *hose, int port)
  441. {
  442. volatile void *mbase = NULL;
  443. pci_set_ops(hose,
  444. pcie_read_config_byte,
  445. pcie_read_config_word,
  446. pcie_read_config_dword,
  447. pcie_write_config_byte,
  448. pcie_write_config_word,
  449. pcie_write_config_dword);
  450. switch(port) {
  451. case 0:
  452. mbase = (u32 *)CFG_PCIE0_XCFGBASE;
  453. hose->cfg_data = (u8 *)CFG_PCIE0_CFGBASE;
  454. break;
  455. case 1:
  456. mbase = (u32 *)CFG_PCIE1_XCFGBASE;
  457. hose->cfg_data = (u8 *)CFG_PCIE1_CFGBASE;
  458. break;
  459. case 2:
  460. mbase = (u32 *)CFG_PCIE2_XCFGBASE;
  461. hose->cfg_data = (u8 *)CFG_PCIE2_CFGBASE;
  462. break;
  463. }
  464. /*
  465. * Set bus numbers on our root port
  466. */
  467. if (ppc440spe_revB()) {
  468. out_8((u8 *)mbase + PCI_PRIMARY_BUS, 0);
  469. out_8((u8 *)mbase + PCI_SECONDARY_BUS, 1);
  470. out_8((u8 *)mbase + PCI_SUBORDINATE_BUS, 1);
  471. } else {
  472. out_8((u8 *)mbase + PCI_PRIMARY_BUS, 0);
  473. out_8((u8 *)mbase + PCI_SECONDARY_BUS, 0);
  474. }
  475. /*
  476. * Set up outbound translation to hose->mem_space from PLB
  477. * addresses at an offset of 0xd_0000_0000. We set the low
  478. * bits of the mask to 11 to turn off splitting into 8
  479. * subregions and to enable the outbound translation.
  480. */
  481. out_le32(mbase + PECFG_POM0LAH, 0x00000000);
  482. out_le32(mbase + PECFG_POM0LAL, (CFG_PCIE_MEMBASE +
  483. port * CFG_PCIE_MEMSIZE));
  484. switch (port) {
  485. case 0:
  486. mtdcr(DCRN_PEGPL_OMR1BAH(PCIE0), 0x0000000d);
  487. mtdcr(DCRN_PEGPL_OMR1BAL(PCIE0), CFG_PCIE_MEMBASE +
  488. port * CFG_PCIE_MEMSIZE);
  489. mtdcr(DCRN_PEGPL_OMR1MSKH(PCIE0), 0x7fffffff);
  490. mtdcr(DCRN_PEGPL_OMR1MSKL(PCIE0),
  491. ~(CFG_PCIE_MEMSIZE - 1) | 3);
  492. break;
  493. case 1:
  494. mtdcr(DCRN_PEGPL_OMR1BAH(PCIE1), 0x0000000d);
  495. mtdcr(DCRN_PEGPL_OMR1BAL(PCIE1), (CFG_PCIE_MEMBASE +
  496. port * CFG_PCIE_MEMSIZE));
  497. mtdcr(DCRN_PEGPL_OMR1MSKH(PCIE1), 0x7fffffff);
  498. mtdcr(DCRN_PEGPL_OMR1MSKL(PCIE1),
  499. ~(CFG_PCIE_MEMSIZE - 1) | 3);
  500. break;
  501. case 2:
  502. mtdcr(DCRN_PEGPL_OMR1BAH(PCIE2), 0x0000000d);
  503. mtdcr(DCRN_PEGPL_OMR1BAL(PCIE2), (CFG_PCIE_MEMBASE +
  504. port * CFG_PCIE_MEMSIZE));
  505. mtdcr(DCRN_PEGPL_OMR1MSKH(PCIE2), 0x7fffffff);
  506. mtdcr(DCRN_PEGPL_OMR1MSKL(PCIE2),
  507. ~(CFG_PCIE_MEMSIZE - 1) | 3);
  508. break;
  509. }
  510. /* Set up 16GB inbound memory window at 0 */
  511. out_le32(mbase + PCI_BASE_ADDRESS_0, 0);
  512. out_le32(mbase + PCI_BASE_ADDRESS_1, 0);
  513. out_le32(mbase + PECFG_BAR0HMPA, 0x7fffffc);
  514. out_le32(mbase + PECFG_BAR0LMPA, 0);
  515. out_le32(mbase + PECFG_PIM0LAL, 0);
  516. out_le32(mbase + PECFG_PIM0LAH, 0);
  517. out_le32(mbase + PECFG_PIMEN, 0x1);
  518. /* Enable I/O, Mem, and Busmaster cycles */
  519. out_le16((u16 *)(mbase + PCI_COMMAND),
  520. in_le16((u16 *)(mbase + PCI_COMMAND)) |
  521. PCI_COMMAND_IO | PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER);
  522. }
  523. #endif /* CONFIG_PCI */
  524. #endif /* CONFIG_440SPE */