tqm85xx.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626
  1. /*
  2. * (C) Copyright 2008 Wolfgang Grandegger <wg@denx.de>
  3. *
  4. * (C) Copyright 2006
  5. * Thomas Waehner, TQ-Systems GmbH, thomas.waehner@tqs.de.
  6. *
  7. * (C) Copyright 2005
  8. * Stefan Roese, DENX Software Engineering, sr@denx.de.
  9. *
  10. * Copyright 2004 Freescale Semiconductor.
  11. * (C) Copyright 2002,2003, Motorola Inc.
  12. * Xianghua Xiao, (X.Xiao@motorola.com)
  13. *
  14. * (C) Copyright 2002 Scott McNutt <smcnutt@artesyncp.com>
  15. *
  16. * See file CREDITS for list of people who contributed to this
  17. * project.
  18. *
  19. * This program is free software; you can redistribute it and/or
  20. * modify it under the terms of the GNU General Public License as
  21. * published by the Free Software Foundation; either version 2 of
  22. * the License, or (at your option) any later version.
  23. *
  24. * This program is distributed in the hope that it will be useful,
  25. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  26. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  27. * GNU General Public License for more details.
  28. *
  29. * You should have received a copy of the GNU General Public License
  30. * along with this program; if not, write to the Free Software
  31. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  32. * MA 02111-1307 USA
  33. */
  34. #include <common.h>
  35. #include <pci.h>
  36. #include <asm/processor.h>
  37. #include <asm/immap_85xx.h>
  38. #include <asm/fsl_pci.h>
  39. #include <asm/io.h>
  40. #include <asm/fsl_serdes.h>
  41. #include <linux/compiler.h>
  42. #include <ioports.h>
  43. #include <flash.h>
  44. #include <libfdt.h>
  45. #include <fdt_support.h>
  46. #include <netdev.h>
  47. DECLARE_GLOBAL_DATA_PTR;
  48. extern flash_info_t flash_info[]; /* FLASH chips info */
  49. void local_bus_init (void);
  50. ulong flash_get_size (ulong base, int banknum);
  51. #ifdef CONFIG_PS2MULT
  52. void ps2mult_early_init (void);
  53. #endif
  54. #ifdef CONFIG_CPM2
  55. /*
  56. * I/O Port configuration table
  57. *
  58. * if conf is 1, then that port pin will be configured at boot time
  59. * according to the five values podr/pdir/ppar/psor/pdat for that entry
  60. */
  61. const iop_conf_t iop_conf_tab[4][32] = {
  62. /* Port A: conf, ppar, psor, pdir, podr, pdat */
  63. {
  64. {1, 1, 1, 0, 0, 0}, /* PA31: FCC1 MII COL */
  65. {1, 1, 1, 0, 0, 0}, /* PA30: FCC1 MII CRS */
  66. {1, 1, 1, 1, 0, 0}, /* PA29: FCC1 MII TX_ER */
  67. {1, 1, 1, 1, 0, 0}, /* PA28: FCC1 MII TX_EN */
  68. {1, 1, 1, 0, 0, 0}, /* PA27: FCC1 MII RX_DV */
  69. {1, 1, 1, 0, 0, 0}, /* PA26: FCC1 MII RX_ER */
  70. {0, 1, 0, 1, 0, 0}, /* PA25: FCC1 ATMTXD[0] */
  71. {0, 1, 0, 1, 0, 0}, /* PA24: FCC1 ATMTXD[1] */
  72. {0, 1, 0, 1, 0, 0}, /* PA23: FCC1 ATMTXD[2] */
  73. {0, 1, 0, 1, 0, 0}, /* PA22: FCC1 ATMTXD[3] */
  74. {1, 1, 0, 1, 0, 0}, /* PA21: FCC1 MII TxD[3] */
  75. {1, 1, 0, 1, 0, 0}, /* PA20: FCC1 MII TxD[2] */
  76. {1, 1, 0, 1, 0, 0}, /* PA19: FCC1 MII TxD[1] */
  77. {1, 1, 0, 1, 0, 0}, /* PA18: FCC1 MII TxD[0] */
  78. {1, 1, 0, 0, 0, 0}, /* PA17: FCC1 MII RxD[0] */
  79. {1, 1, 0, 0, 0, 0}, /* PA16: FCC1 MII RxD[1] */
  80. {1, 1, 0, 0, 0, 0}, /* PA15: FCC1 MII RxD[2] */
  81. {1, 1, 0, 0, 0, 0}, /* PA14: FCC1 MII RxD[3] */
  82. {0, 1, 0, 0, 0, 0}, /* PA13: FCC1 ATMRXD[3] */
  83. {0, 1, 0, 0, 0, 0}, /* PA12: FCC1 ATMRXD[2] */
  84. {0, 1, 0, 0, 0, 0}, /* PA11: FCC1 ATMRXD[1] */
  85. {0, 1, 0, 0, 0, 0}, /* PA10: FCC1 ATMRXD[0] */
  86. {0, 1, 1, 1, 0, 0}, /* PA9 : FCC1 L1TXD */
  87. {0, 1, 1, 0, 0, 0}, /* PA8 : FCC1 L1RXD */
  88. {0, 0, 0, 1, 0, 0}, /* PA7 : PA7 */
  89. {0, 1, 1, 1, 0, 0}, /* PA6 : TDM A1 L1RSYNC */
  90. {0, 0, 0, 1, 0, 0}, /* PA5 : PA5 */
  91. {0, 0, 0, 1, 0, 0}, /* PA4 : PA4 */
  92. {0, 0, 0, 1, 0, 0}, /* PA3 : PA3 */
  93. {0, 0, 0, 1, 0, 0}, /* PA2 : PA2 */
  94. {0, 0, 0, 0, 0, 0}, /* PA1 : FREERUN */
  95. {0, 0, 0, 1, 0, 0} /* PA0 : PA0 */
  96. },
  97. /* Port B: conf, ppar, psor, pdir, podr, pdat */
  98. {
  99. {1, 1, 0, 1, 0, 0}, /* PB31: FCC2 MII TX_ER */
  100. {1, 1, 0, 0, 0, 0}, /* PB30: FCC2 MII RX_DV */
  101. {1, 1, 1, 1, 0, 0}, /* PB29: FCC2 MII TX_EN */
  102. {1, 1, 0, 0, 0, 0}, /* PB28: FCC2 MII RX_ER */
  103. {1, 1, 0, 0, 0, 0}, /* PB27: FCC2 MII COL */
  104. {1, 1, 0, 0, 0, 0}, /* PB26: FCC2 MII CRS */
  105. {1, 1, 0, 1, 0, 0}, /* PB25: FCC2 MII TxD[3] */
  106. {1, 1, 0, 1, 0, 0}, /* PB24: FCC2 MII TxD[2] */
  107. {1, 1, 0, 1, 0, 0}, /* PB23: FCC2 MII TxD[1] */
  108. {1, 1, 0, 1, 0, 0}, /* PB22: FCC2 MII TxD[0] */
  109. {1, 1, 0, 0, 0, 0}, /* PB21: FCC2 MII RxD[0] */
  110. {1, 1, 0, 0, 0, 0}, /* PB20: FCC2 MII RxD[1] */
  111. {1, 1, 0, 0, 0, 0}, /* PB19: FCC2 MII RxD[2] */
  112. {1, 1, 0, 0, 0, 0}, /* PB18: FCC2 MII RxD[3] */
  113. {1, 1, 0, 0, 0, 0}, /* PB17: FCC3:RX_DIV */
  114. {1, 1, 0, 0, 0, 0}, /* PB16: FCC3:RX_ERR */
  115. {1, 1, 0, 1, 0, 0}, /* PB15: FCC3:TX_ERR */
  116. {1, 1, 0, 1, 0, 0}, /* PB14: FCC3:TX_EN */
  117. {1, 1, 0, 0, 0, 0}, /* PB13: FCC3:COL */
  118. {1, 1, 0, 0, 0, 0}, /* PB12: FCC3:CRS */
  119. {1, 1, 0, 0, 0, 0}, /* PB11: FCC3:RXD */
  120. {1, 1, 0, 0, 0, 0}, /* PB10: FCC3:RXD */
  121. {1, 1, 0, 0, 0, 0}, /* PB9 : FCC3:RXD */
  122. {1, 1, 0, 0, 0, 0}, /* PB8 : FCC3:RXD */
  123. {1, 1, 0, 1, 0, 0}, /* PB7 : FCC3:TXD */
  124. {1, 1, 0, 1, 0, 0}, /* PB6 : FCC3:TXD */
  125. {1, 1, 0, 1, 0, 0}, /* PB5 : FCC3:TXD */
  126. {1, 1, 0, 1, 0, 0}, /* PB4 : FCC3:TXD */
  127. {0, 0, 0, 0, 0, 0}, /* PB3 : pin doesn't exist */
  128. {0, 0, 0, 0, 0, 0}, /* PB2 : pin doesn't exist */
  129. {0, 0, 0, 0, 0, 0}, /* PB1 : pin doesn't exist */
  130. {0, 0, 0, 0, 0, 0} /* PB0 : pin doesn't exist */
  131. },
  132. /* Port C: conf, ppar, psor, pdir, podr, pdat */
  133. {
  134. {0, 0, 0, 1, 0, 0}, /* PC31: PC31 */
  135. {0, 0, 0, 1, 0, 0}, /* PC30: PC30 */
  136. {0, 1, 1, 0, 0, 0}, /* PC29: SCC1 EN *CLSN */
  137. {0, 0, 0, 1, 0, 0}, /* PC28: PC28 */
  138. {0, 0, 0, 1, 0, 0}, /* PC27: UART Clock in */
  139. {0, 0, 0, 1, 0, 0}, /* PC26: PC26 */
  140. {0, 0, 0, 1, 0, 0}, /* PC25: PC25 */
  141. {0, 0, 0, 1, 0, 0}, /* PC24: PC24 */
  142. {0, 1, 0, 1, 0, 0}, /* PC23: ATMTFCLK */
  143. {0, 1, 0, 0, 0, 0}, /* PC22: ATMRFCLK */
  144. {1, 1, 0, 0, 0, 0}, /* PC21: SCC1 EN RXCLK */
  145. {1, 1, 0, 0, 0, 0}, /* PC20: SCC1 EN TXCLK */
  146. {1, 1, 0, 0, 0, 0}, /* PC19: FCC2 MII RX_CLK CLK13 */
  147. {1, 1, 0, 0, 0, 0}, /* PC18: FCC Tx Clock (CLK14) */
  148. {1, 1, 0, 0, 0, 0}, /* PC17: PC17 */
  149. {1, 1, 0, 0, 0, 0}, /* PC16: FCC Tx Clock (CLK16) */
  150. {0, 1, 0, 0, 0, 0}, /* PC15: PC15 */
  151. {0, 1, 0, 0, 0, 0}, /* PC14: SCC1 EN *CD */
  152. {0, 1, 0, 0, 0, 0}, /* PC13: PC13 */
  153. {0, 1, 0, 1, 0, 0}, /* PC12: PC12 */
  154. {0, 0, 0, 1, 0, 0}, /* PC11: LXT971 transmit control */
  155. {0, 0, 0, 1, 0, 0}, /* PC10: FETHMDC */
  156. {0, 0, 0, 0, 0, 0}, /* PC9 : FETHMDIO */
  157. {0, 0, 0, 1, 0, 0}, /* PC8 : PC8 */
  158. {0, 0, 0, 1, 0, 0}, /* PC7 : PC7 */
  159. {0, 0, 0, 1, 0, 0}, /* PC6 : PC6 */
  160. {0, 0, 0, 1, 0, 0}, /* PC5 : PC5 */
  161. {0, 0, 0, 1, 0, 0}, /* PC4 : PC4 */
  162. {0, 0, 0, 1, 0, 0}, /* PC3 : PC3 */
  163. {0, 0, 0, 1, 0, 1}, /* PC2 : ENET FDE */
  164. {0, 0, 0, 1, 0, 0}, /* PC1 : ENET DSQE */
  165. {0, 0, 0, 1, 0, 0}, /* PC0 : ENET LBK */
  166. },
  167. /* Port D: conf, ppar, psor, pdir, podr, pdat */
  168. {
  169. #ifdef CONFIG_TQM8560
  170. {1, 1, 0, 0, 0, 0}, /* PD31: SCC1 EN RxD */
  171. {1, 1, 1, 1, 0, 0}, /* PD30: SCC1 EN TxD */
  172. {1, 1, 0, 1, 0, 0}, /* PD29: SCC1 EN TENA */
  173. #else /* !CONFIG_TQM8560 */
  174. {0, 0, 0, 0, 0, 0}, /* PD31: PD31 */
  175. {0, 0, 0, 0, 0, 0}, /* PD30: PD30 */
  176. {0, 0, 0, 0, 0, 0}, /* PD29: PD29 */
  177. #endif /* CONFIG_TQM8560 */
  178. {1, 1, 0, 0, 0, 0}, /* PD28: PD28 */
  179. {1, 1, 0, 1, 0, 0}, /* PD27: PD27 */
  180. {1, 1, 0, 1, 0, 0}, /* PD26: PD26 */
  181. {0, 0, 0, 1, 0, 0}, /* PD25: PD25 */
  182. {0, 0, 0, 1, 0, 0}, /* PD24: PD24 */
  183. {0, 0, 0, 1, 0, 0}, /* PD23: PD23 */
  184. {0, 0, 0, 1, 0, 0}, /* PD22: PD22 */
  185. {0, 0, 0, 1, 0, 0}, /* PD21: PD21 */
  186. {0, 0, 0, 1, 0, 0}, /* PD20: PD20 */
  187. {0, 0, 0, 1, 0, 0}, /* PD19: PD19 */
  188. {0, 0, 0, 1, 0, 0}, /* PD18: PD18 */
  189. {0, 1, 0, 0, 0, 0}, /* PD17: FCC1 ATMRXPRTY */
  190. {0, 1, 0, 1, 0, 0}, /* PD16: FCC1 ATMTXPRTY */
  191. {0, 1, 1, 0, 1, 0}, /* PD15: I2C SDA */
  192. {0, 0, 0, 1, 0, 0}, /* PD14: LED */
  193. {0, 0, 0, 0, 0, 0}, /* PD13: PD13 */
  194. {0, 0, 0, 0, 0, 0}, /* PD12: PD12 */
  195. {0, 0, 0, 0, 0, 0}, /* PD11: PD11 */
  196. {0, 0, 0, 0, 0, 0}, /* PD10: PD10 */
  197. {0, 1, 0, 1, 0, 0}, /* PD9 : SMC1 TXD */
  198. {0, 1, 0, 0, 0, 0}, /* PD8 : SMC1 RXD */
  199. {0, 0, 0, 1, 0, 1}, /* PD7 : PD7 */
  200. {0, 0, 0, 1, 0, 1}, /* PD6 : PD6 */
  201. {0, 0, 0, 1, 0, 1}, /* PD5 : PD5 */
  202. {0, 0, 0, 1, 0, 1}, /* PD4 : PD4 */
  203. {0, 0, 0, 0, 0, 0}, /* PD3 : pin doesn't exist */
  204. {0, 0, 0, 0, 0, 0}, /* PD2 : pin doesn't exist */
  205. {0, 0, 0, 0, 0, 0}, /* PD1 : pin doesn't exist */
  206. {0, 0, 0, 0, 0, 0} /* PD0 : pin doesn't exist */
  207. }
  208. };
  209. #endif /* CONFIG_CPM2 */
  210. #define CASL_STRING1 "casl=xx"
  211. #define CASL_STRING2 "casl="
  212. static const int casl_table[] = { 20, 25, 30 };
  213. #define N_CASL (sizeof(casl_table) / sizeof(casl_table[0]))
  214. int cas_latency (void)
  215. {
  216. char buf[128];
  217. int casl;
  218. int val;
  219. int i;
  220. casl = CONFIG_DDR_DEFAULT_CL;
  221. i = getenv_f("serial#", buf, sizeof(buf));
  222. if (i >0) {
  223. if (strncmp(buf + strlen (buf) - strlen (CASL_STRING1),
  224. CASL_STRING2, strlen (CASL_STRING2)) == 0) {
  225. val = simple_strtoul (buf + strlen (buf) - 2, NULL, 10);
  226. for (i = 0; i < N_CASL; ++i) {
  227. if (val == casl_table[i]) {
  228. return val;
  229. }
  230. }
  231. }
  232. }
  233. return casl;
  234. }
  235. int checkboard (void)
  236. {
  237. char buf[64];
  238. int i = getenv_f("serial#", buf, sizeof(buf));
  239. printf ("Board: %s", CONFIG_BOARDNAME);
  240. if (i > 0) {
  241. puts(", serial# ");
  242. puts(buf);
  243. }
  244. putc ('\n');
  245. /*
  246. * Initialize local bus.
  247. */
  248. local_bus_init ();
  249. return 0;
  250. }
  251. int misc_init_r (void)
  252. {
  253. /*
  254. * Adjust flash start and offset to detected values
  255. */
  256. gd->bd->bi_flashstart = 0 - gd->bd->bi_flashsize;
  257. gd->bd->bi_flashoffset = 0;
  258. /*
  259. * Recalculate CS configuration if second FLASH bank is available
  260. */
  261. if (flash_info[0].size > 0) {
  262. set_lbc_or(1, ((-flash_info[0].size) & 0xffff8000) |
  263. (CONFIG_SYS_OR1_PRELIM & 0x00007fff));
  264. set_lbc_br(1, gd->bd->bi_flashstart |
  265. (CONFIG_SYS_BR1_PRELIM & 0x00007fff));
  266. /*
  267. * Re-check to get correct base address for bank 1
  268. */
  269. flash_get_size (gd->bd->bi_flashstart, 0);
  270. } else {
  271. set_lbc_or(1, 0);
  272. set_lbc_br(1, 0);
  273. }
  274. /*
  275. * If bank 1 is equipped, bank 0 is mapped after bank 1
  276. */
  277. set_lbc_or(0, ((-flash_info[1].size) & 0xffff8000) |
  278. (CONFIG_SYS_OR0_PRELIM & 0x00007fff));
  279. set_lbc_br(0, (gd->bd->bi_flashstart + flash_info[0].size) |
  280. (CONFIG_SYS_BR0_PRELIM & 0x00007fff));
  281. /*
  282. * Re-check to get correct base address for bank 0
  283. */
  284. flash_get_size (gd->bd->bi_flashstart + flash_info[0].size, 1);
  285. /*
  286. * Re-do flash protection upon new addresses
  287. */
  288. flash_protect (FLAG_PROTECT_CLEAR,
  289. gd->bd->bi_flashstart, 0xffffffff,
  290. &flash_info[CONFIG_SYS_MAX_FLASH_BANKS - 1]);
  291. /* Monitor protection ON by default */
  292. flash_protect (FLAG_PROTECT_SET,
  293. CONFIG_SYS_MONITOR_BASE, 0xffffffff,
  294. &flash_info[CONFIG_SYS_MAX_FLASH_BANKS - 1]);
  295. /* Environment protection ON by default */
  296. flash_protect (FLAG_PROTECT_SET,
  297. CONFIG_ENV_ADDR,
  298. CONFIG_ENV_ADDR + CONFIG_ENV_SECT_SIZE - 1,
  299. &flash_info[CONFIG_SYS_MAX_FLASH_BANKS - 1]);
  300. #ifdef CONFIG_ENV_ADDR_REDUND
  301. /* Redundant environment protection ON by default */
  302. flash_protect (FLAG_PROTECT_SET,
  303. CONFIG_ENV_ADDR_REDUND,
  304. CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SECT_SIZE - 1,
  305. &flash_info[CONFIG_SYS_MAX_FLASH_BANKS - 1]);
  306. #endif
  307. return 0;
  308. }
  309. #ifdef CONFIG_CAN_DRIVER
  310. /*
  311. * Initialize UPMC RAM
  312. */
  313. static void upmc_write (u_char addr, uint val)
  314. {
  315. volatile fsl_lbc_t *lbc = LBC_BASE_ADDR;
  316. out_be32 (&lbc->mdr, val);
  317. clrsetbits_be32(&lbc->mcmr, MxMR_MAD_MSK,
  318. MxMR_OP_WARR | (addr & MxMR_MAD_MSK));
  319. /* dummy access to perform write */
  320. out_8 ((void __iomem *)CONFIG_SYS_CAN_BASE, 0);
  321. /* normal operation */
  322. clrbits_be32(&lbc->mcmr, MxMR_OP_WARR);
  323. }
  324. #endif /* CONFIG_CAN_DRIVER */
  325. uint get_lbc_clock (void)
  326. {
  327. volatile fsl_lbc_t *lbc = LBC_BASE_ADDR;
  328. sys_info_t sys_info;
  329. ulong clkdiv = lbc->lcrr & LCRR_CLKDIV;
  330. get_sys_info (&sys_info);
  331. if (clkdiv == 2 || clkdiv == 4 || clkdiv == 8) {
  332. #ifdef CONFIG_MPC8548
  333. /*
  334. * Yes, the entire PQ38 family use the same
  335. * bit-representation for twice the clock divider value.
  336. */
  337. clkdiv *= 2;
  338. #endif
  339. return sys_info.freqSystemBus / clkdiv;
  340. }
  341. puts("Invalid clock divider value in CONFIG_SYS_LBC_LCRR\n");
  342. return 0;
  343. }
  344. /*
  345. * Initialize Local Bus
  346. */
  347. void local_bus_init (void)
  348. {
  349. volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  350. volatile fsl_lbc_t *lbc = LBC_BASE_ADDR;
  351. uint lbc_mhz = get_lbc_clock () / 1000000;
  352. #ifdef CONFIG_MPC8548
  353. uint svr = get_svr ();
  354. uint lcrr;
  355. /*
  356. * MPC revision < 2.0
  357. * According to MPC8548E_Device_Errata Rev. L, Erratum LBIU1:
  358. * Modify engineering use only register at address 0xE_0F20.
  359. * "1. Read register at offset 0xE_0F20
  360. * 2. And value with 0x0000_FFFF
  361. * 3. OR result with 0x0000_0004
  362. * 4. Write result back to offset 0xE_0F20."
  363. *
  364. * According to MPC8548E_Device_Errata Rev. L, Erratum LBIU2:
  365. * Modify engineering use only register at address 0xE_0F20.
  366. * "1. Read register at offset 0xE_0F20
  367. * 2. And value with 0xFFFF_FFDF
  368. * 3. Write result back to offset 0xE_0F20."
  369. *
  370. * Since it is the same register, we do the modification in one step.
  371. */
  372. if (SVR_MAJ (svr) < 2) {
  373. uint dummy = gur->lbiuiplldcr1;
  374. dummy &= 0x0000FFDF;
  375. dummy |= 0x00000004;
  376. gur->lbiuiplldcr1 = dummy;
  377. }
  378. lcrr = CONFIG_SYS_LBC_LCRR;
  379. /*
  380. * Local Bus Clock > 83.3 MHz. According to timing
  381. * specifications set LCRR[EADC] to 2 delay cycles.
  382. */
  383. if (lbc_mhz > 83) {
  384. lcrr &= ~LCRR_EADC;
  385. lcrr |= LCRR_EADC_2;
  386. }
  387. /*
  388. * According to MPC8548ERMAD Rev. 1.3, 13.3.1.16, 13-30
  389. * disable PLL bypass for Local Bus Clock > 83 MHz.
  390. */
  391. if (lbc_mhz >= 66)
  392. lcrr &= (~LCRR_DBYP); /* DLL Enabled */
  393. else
  394. lcrr |= LCRR_DBYP; /* DLL Bypass */
  395. lbc->lcrr = lcrr;
  396. asm ("sync;isync;msync");
  397. /*
  398. * According to MPC8548ERMAD Rev.1.3 read back LCRR
  399. * and terminate with isync
  400. */
  401. lcrr = lbc->lcrr;
  402. asm ("isync;");
  403. /* let DLL stabilize */
  404. udelay (500);
  405. #else /* !CONFIG_MPC8548 */
  406. /*
  407. * Errata LBC11.
  408. * Fix Local Bus clock glitch when DLL is enabled.
  409. *
  410. * If localbus freq is < 66MHz, DLL bypass mode must be used.
  411. * If localbus freq is > 133MHz, DLL can be safely enabled.
  412. * Between 66 and 133, the DLL is enabled with an override workaround.
  413. */
  414. if (lbc_mhz < 66) {
  415. lbc->lcrr = CONFIG_SYS_LBC_LCRR | LCRR_DBYP; /* DLL Bypass */
  416. lbc->ltedr = LTEDR_BMD | LTEDR_PARD | LTEDR_WPD | LTEDR_WARA |
  417. LTEDR_RAWA | LTEDR_CSD; /* Disable all error checking */
  418. } else if (lbc_mhz >= 133) {
  419. lbc->lcrr = CONFIG_SYS_LBC_LCRR & (~LCRR_DBYP); /* DLL Enabled */
  420. } else {
  421. /*
  422. * On REV1 boards, need to change CLKDIV before enable DLL.
  423. * Default CLKDIV is 8, change it to 4 temporarily.
  424. */
  425. uint pvr = get_pvr ();
  426. uint temp_lbcdll = 0;
  427. if (pvr == PVR_85xx_REV1) {
  428. /* FIXME: Justify the high bit here. */
  429. lbc->lcrr = 0x10000004;
  430. }
  431. lbc->lcrr = CONFIG_SYS_LBC_LCRR & (~LCRR_DBYP); /* DLL Enabled */
  432. udelay (200);
  433. /*
  434. * Sample LBC DLL ctrl reg, upshift it to set the
  435. * override bits.
  436. */
  437. temp_lbcdll = gur->lbcdllcr;
  438. gur->lbcdllcr = (((temp_lbcdll & 0xff) << 16) | 0x80000000);
  439. asm ("sync;isync;msync");
  440. }
  441. #endif /* !CONFIG_MPC8548 */
  442. #ifdef CONFIG_CAN_DRIVER
  443. /*
  444. * According to timing specifications EAD must be
  445. * set if Local Bus Clock is > 83 MHz.
  446. */
  447. if (lbc_mhz > 83)
  448. set_lbc_or(2, CONFIG_SYS_OR2_CAN | OR_UPM_EAD);
  449. else
  450. set_lbc_or(2, CONFIG_SYS_OR2_CAN);
  451. set_lbc_br(2, CONFIG_SYS_BR2_CAN);
  452. /* LGPL4 is UPWAIT */
  453. out_be32(&lbc->mcmr, MxMR_DSx_3_CYCL | MxMR_GPL_x4DIS | MxMR_WLFx_3X);
  454. /* Initialize UPMC for CAN: single read */
  455. upmc_write (0x00, 0xFFFFED00);
  456. upmc_write (0x01, 0xCCFFCC00);
  457. upmc_write (0x02, 0x00FFCF00);
  458. upmc_write (0x03, 0x00FFCF00);
  459. upmc_write (0x04, 0x00FFDC00);
  460. upmc_write (0x05, 0x00FFCF00);
  461. upmc_write (0x06, 0x00FFED00);
  462. upmc_write (0x07, 0x3FFFCC07);
  463. /* Initialize UPMC for CAN: single write */
  464. upmc_write (0x18, 0xFFFFED00);
  465. upmc_write (0x19, 0xCCFFEC00);
  466. upmc_write (0x1A, 0x00FFED80);
  467. upmc_write (0x1B, 0x00FFED80);
  468. upmc_write (0x1C, 0x00FFFC00);
  469. upmc_write (0x1D, 0x0FFFEC00);
  470. upmc_write (0x1E, 0x0FFFEF00);
  471. upmc_write (0x1F, 0x3FFFEC05);
  472. #endif /* CONFIG_CAN_DRIVER */
  473. }
  474. /*
  475. * Initialize PCI Devices, report devices found.
  476. */
  477. #ifdef CONFIG_PCI1
  478. static struct pci_controller pci1_hose;
  479. #endif /* CONFIG_PCI1 */
  480. void pci_init_board (void)
  481. {
  482. volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  483. int first_free_busno = 0;
  484. #ifdef CONFIG_PCI1
  485. struct fsl_pci_info pci_info;
  486. int pcie_ep;
  487. u32 devdisr = in_be32(&gur->devdisr);
  488. uint pci_32 = in_be32(&gur->pordevsr) & MPC85xx_PORDEVSR_PCI1_PCI32;
  489. uint pci_arb = in_be32(&gur->pordevsr) & MPC85xx_PORDEVSR_PCI1_ARB;
  490. uint pci_speed = CONFIG_SYS_CLK_FREQ; /* PCI PSPEED in [4:5] */
  491. uint pci_clk_sel = in_be32(&gur->porpllsr) & MPC85xx_PORDEVSR_PCI1_SPD;
  492. if (!(devdisr & MPC85xx_DEVDISR_PCI1)) {
  493. SET_STD_PCI_INFO(pci_info, 1);
  494. set_next_law(pci_info.mem_phys,
  495. law_size_bits(pci_info.mem_size), pci_info.law);
  496. set_next_law(pci_info.io_phys,
  497. law_size_bits(pci_info.io_size), pci_info.law);
  498. pcie_ep = fsl_setup_hose(&pci1_hose, pci_info.regs);
  499. printf("PCI1: %d bit, %s MHz, %s, %s, %s\n",
  500. (pci_32) ? 32 : 64,
  501. (pci_speed == 33333333) ? "33" :
  502. (pci_speed == 66666666) ? "66" : "unknown",
  503. pci_clk_sel ? "sync" : "async",
  504. pcie_ep ? "agent" : "host",
  505. pci_arb ? "arbiter" : "external-arbiter");
  506. first_free_busno = fsl_pci_init_port(&pci_info,
  507. &pci1_hose, first_free_busno);
  508. #ifdef CONFIG_PCIX_CHECK
  509. if (!(in_be32(&gur->pordevsr) & MPC85xx_PORDEVSR_PCI1)) {
  510. ushort reg16 =
  511. PCI_X_CMD_MAX_SPLIT | PCI_X_CMD_MAX_READ |
  512. PCI_X_CMD_ERO | PCI_X_CMD_DPERR_E;
  513. uint dev = PCI_BDF(0, 0, 0);
  514. /* PCI-X init */
  515. if (CONFIG_SYS_CLK_FREQ < 66000000)
  516. puts ("PCI-X will only work at 66 MHz\n");
  517. pci_write_config_word(dev, PCIX_COMMAND, reg16);
  518. }
  519. #endif
  520. } else {
  521. printf("PCI1: disabled\n");
  522. }
  523. #else
  524. setbits_be32(&gur->devdisr, MPC85xx_DEVDISR_PCI1);
  525. #endif
  526. fsl_pcie_init_board(first_free_busno);
  527. }
  528. #ifdef CONFIG_OF_BOARD_SETUP
  529. void ft_board_setup (void *blob, bd_t *bd)
  530. {
  531. ft_cpu_setup (blob, bd);
  532. FT_FSL_PCI_SETUP;
  533. }
  534. #endif /* CONFIG_OF_BOARD_SETUP */
  535. #ifdef CONFIG_BOARD_EARLY_INIT_R
  536. int board_early_init_r (void)
  537. {
  538. #ifdef CONFIG_PS2MULT
  539. ps2mult_early_init ();
  540. #endif /* CONFIG_PS2MULT */
  541. return (0);
  542. }
  543. #endif /* CONFIG_BOARD_EARLY_INIT_R */
  544. int board_eth_init(bd_t *bis)
  545. {
  546. cpu_eth_init(bis); /* Intialize TSECs first */
  547. return pci_eth_init(bis);
  548. }