tqm85xx.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  1. /*
  2. * (C) Copyright 2005
  3. * Stefan Roese, DENX Software Engineering, sr@denx.de.
  4. *
  5. * Copyright 2004 Freescale Semiconductor.
  6. * (C) Copyright 2002,2003, Motorola Inc.
  7. * Xianghua Xiao, (X.Xiao@motorola.com)
  8. *
  9. * (C) Copyright 2002 Scott McNutt <smcnutt@artesyncp.com>
  10. *
  11. * See file CREDITS for list of people who contributed to this
  12. * project.
  13. *
  14. * This program is free software; you can redistribute it and/or
  15. * modify it under the terms of the GNU General Public License as
  16. * published by the Free Software Foundation; either version 2 of
  17. * the License, or (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program; if not, write to the Free Software
  26. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  27. * MA 02111-1307 USA
  28. */
  29. #include <common.h>
  30. #include <pci.h>
  31. #include <asm/processor.h>
  32. #include <asm/immap_85xx.h>
  33. #include <ioports.h>
  34. #include <flash.h>
  35. DECLARE_GLOBAL_DATA_PTR;
  36. extern flash_info_t flash_info[]; /* FLASH chips info */
  37. void local_bus_init (void);
  38. ulong flash_get_size (ulong base, int banknum);
  39. #ifdef CONFIG_PS2MULT
  40. void ps2mult_early_init (void);
  41. #endif
  42. #ifdef CONFIG_CPM2
  43. /*
  44. * I/O Port configuration table
  45. *
  46. * if conf is 1, then that port pin will be configured at boot time
  47. * according to the five values podr/pdir/ppar/psor/pdat for that entry
  48. */
  49. const iop_conf_t iop_conf_tab[4][32] = {
  50. /* Port A: conf, ppar, psor, pdir, podr, pdat */
  51. {
  52. {1, 1, 1, 0, 0, 0}, /* PA31: FCC1 MII COL */
  53. {1, 1, 1, 0, 0, 0}, /* PA30: FCC1 MII CRS */
  54. {1, 1, 1, 1, 0, 0}, /* PA29: FCC1 MII TX_ER */
  55. {1, 1, 1, 1, 0, 0}, /* PA28: FCC1 MII TX_EN */
  56. {1, 1, 1, 0, 0, 0}, /* PA27: FCC1 MII RX_DV */
  57. {1, 1, 1, 0, 0, 0}, /* PA26: FCC1 MII RX_ER */
  58. {0, 1, 0, 1, 0, 0}, /* PA25: FCC1 ATMTXD[0] */
  59. {0, 1, 0, 1, 0, 0}, /* PA24: FCC1 ATMTXD[1] */
  60. {0, 1, 0, 1, 0, 0}, /* PA23: FCC1 ATMTXD[2] */
  61. {0, 1, 0, 1, 0, 0}, /* PA22: FCC1 ATMTXD[3] */
  62. {1, 1, 0, 1, 0, 0}, /* PA21: FCC1 MII TxD[3] */
  63. {1, 1, 0, 1, 0, 0}, /* PA20: FCC1 MII TxD[2] */
  64. {1, 1, 0, 1, 0, 0}, /* PA19: FCC1 MII TxD[1] */
  65. {1, 1, 0, 1, 0, 0}, /* PA18: FCC1 MII TxD[0] */
  66. {1, 1, 0, 0, 0, 0}, /* PA17: FCC1 MII RxD[0] */
  67. {1, 1, 0, 0, 0, 0}, /* PA16: FCC1 MII RxD[1] */
  68. {1, 1, 0, 0, 0, 0}, /* PA15: FCC1 MII RxD[2] */
  69. {1, 1, 0, 0, 0, 0}, /* PA14: FCC1 MII RxD[3] */
  70. {0, 1, 0, 0, 0, 0}, /* PA13: FCC1 ATMRXD[3] */
  71. {0, 1, 0, 0, 0, 0}, /* PA12: FCC1 ATMRXD[2] */
  72. {0, 1, 0, 0, 0, 0}, /* PA11: FCC1 ATMRXD[1] */
  73. {0, 1, 0, 0, 0, 0}, /* PA10: FCC1 ATMRXD[0] */
  74. {0, 1, 1, 1, 0, 0}, /* PA9 : FCC1 L1TXD */
  75. {0, 1, 1, 0, 0, 0}, /* PA8 : FCC1 L1RXD */
  76. {0, 0, 0, 1, 0, 0}, /* PA7 : PA7 */
  77. {0, 1, 1, 1, 0, 0}, /* PA6 : TDM A1 L1RSYNC */
  78. {0, 0, 0, 1, 0, 0}, /* PA5 : PA5 */
  79. {0, 0, 0, 1, 0, 0}, /* PA4 : PA4 */
  80. {0, 0, 0, 1, 0, 0}, /* PA3 : PA3 */
  81. {0, 0, 0, 1, 0, 0}, /* PA2 : PA2 */
  82. {0, 0, 0, 0, 0, 0}, /* PA1 : FREERUN */
  83. {0, 0, 0, 1, 0, 0} /* PA0 : PA0 */
  84. },
  85. /* Port B: conf, ppar, psor, pdir, podr, pdat */
  86. {
  87. {1, 1, 0, 1, 0, 0}, /* PB31: FCC2 MII TX_ER */
  88. {1, 1, 0, 0, 0, 0}, /* PB30: FCC2 MII RX_DV */
  89. {1, 1, 1, 1, 0, 0}, /* PB29: FCC2 MII TX_EN */
  90. {1, 1, 0, 0, 0, 0}, /* PB28: FCC2 MII RX_ER */
  91. {1, 1, 0, 0, 0, 0}, /* PB27: FCC2 MII COL */
  92. {1, 1, 0, 0, 0, 0}, /* PB26: FCC2 MII CRS */
  93. {1, 1, 0, 1, 0, 0}, /* PB25: FCC2 MII TxD[3] */
  94. {1, 1, 0, 1, 0, 0}, /* PB24: FCC2 MII TxD[2] */
  95. {1, 1, 0, 1, 0, 0}, /* PB23: FCC2 MII TxD[1] */
  96. {1, 1, 0, 1, 0, 0}, /* PB22: FCC2 MII TxD[0] */
  97. {1, 1, 0, 0, 0, 0}, /* PB21: FCC2 MII RxD[0] */
  98. {1, 1, 0, 0, 0, 0}, /* PB20: FCC2 MII RxD[1] */
  99. {1, 1, 0, 0, 0, 0}, /* PB19: FCC2 MII RxD[2] */
  100. {1, 1, 0, 0, 0, 0}, /* PB18: FCC2 MII RxD[3] */
  101. {1, 1, 0, 0, 0, 0}, /* PB17: FCC3:RX_DIV */
  102. {1, 1, 0, 0, 0, 0}, /* PB16: FCC3:RX_ERR */
  103. {1, 1, 0, 1, 0, 0}, /* PB15: FCC3:TX_ERR */
  104. {1, 1, 0, 1, 0, 0}, /* PB14: FCC3:TX_EN */
  105. {1, 1, 0, 0, 0, 0}, /* PB13: FCC3:COL */
  106. {1, 1, 0, 0, 0, 0}, /* PB12: FCC3:CRS */
  107. {1, 1, 0, 0, 0, 0}, /* PB11: FCC3:RXD */
  108. {1, 1, 0, 0, 0, 0}, /* PB10: FCC3:RXD */
  109. {1, 1, 0, 0, 0, 0}, /* PB9 : FCC3:RXD */
  110. {1, 1, 0, 0, 0, 0}, /* PB8 : FCC3:RXD */
  111. {1, 1, 0, 1, 0, 0}, /* PB7 : FCC3:TXD */
  112. {1, 1, 0, 1, 0, 0}, /* PB6 : FCC3:TXD */
  113. {1, 1, 0, 1, 0, 0}, /* PB5 : FCC3:TXD */
  114. {1, 1, 0, 1, 0, 0}, /* PB4 : FCC3:TXD */
  115. {0, 0, 0, 0, 0, 0}, /* PB3 : pin doesn't exist */
  116. {0, 0, 0, 0, 0, 0}, /* PB2 : pin doesn't exist */
  117. {0, 0, 0, 0, 0, 0}, /* PB1 : pin doesn't exist */
  118. {0, 0, 0, 0, 0, 0} /* PB0 : pin doesn't exist */
  119. },
  120. /* Port C: conf, ppar, psor, pdir, podr, pdat */
  121. {
  122. {0, 0, 0, 1, 0, 0}, /* PC31: PC31 */
  123. {0, 0, 0, 1, 0, 0}, /* PC30: PC30 */
  124. {0, 1, 1, 0, 0, 0}, /* PC29: SCC1 EN *CLSN */
  125. {0, 0, 0, 1, 0, 0}, /* PC28: PC28 */
  126. {0, 0, 0, 1, 0, 0}, /* PC27: UART Clock in */
  127. {0, 0, 0, 1, 0, 0}, /* PC26: PC26 */
  128. {0, 0, 0, 1, 0, 0}, /* PC25: PC25 */
  129. {0, 0, 0, 1, 0, 0}, /* PC24: PC24 */
  130. {0, 1, 0, 1, 0, 0}, /* PC23: ATMTFCLK */
  131. {0, 1, 0, 0, 0, 0}, /* PC22: ATMRFCLK */
  132. {1, 1, 0, 0, 0, 0}, /* PC21: SCC1 EN RXCLK */
  133. {1, 1, 0, 0, 0, 0}, /* PC20: SCC1 EN TXCLK */
  134. {1, 1, 0, 0, 0, 0}, /* PC19: FCC2 MII RX_CLK CLK13 */
  135. {1, 1, 0, 0, 0, 0}, /* PC18: FCC Tx Clock (CLK14) */
  136. {1, 1, 0, 0, 0, 0}, /* PC17: PC17 */
  137. {1, 1, 0, 0, 0, 0}, /* PC16: FCC Tx Clock (CLK16) */
  138. {0, 1, 0, 0, 0, 0}, /* PC15: PC15 */
  139. {0, 1, 0, 0, 0, 0}, /* PC14: SCC1 EN *CD */
  140. {0, 1, 0, 0, 0, 0}, /* PC13: PC13 */
  141. {0, 1, 0, 1, 0, 0}, /* PC12: PC12 */
  142. {0, 0, 0, 1, 0, 0}, /* PC11: LXT971 transmit control */
  143. {0, 0, 0, 1, 0, 0}, /* PC10: FETHMDC */
  144. {0, 0, 0, 0, 0, 0}, /* PC9 : FETHMDIO */
  145. {0, 0, 0, 1, 0, 0}, /* PC8 : PC8 */
  146. {0, 0, 0, 1, 0, 0}, /* PC7 : PC7 */
  147. {0, 0, 0, 1, 0, 0}, /* PC6 : PC6 */
  148. {0, 0, 0, 1, 0, 0}, /* PC5 : PC5 */
  149. {0, 0, 0, 1, 0, 0}, /* PC4 : PC4 */
  150. {0, 0, 0, 1, 0, 0}, /* PC3 : PC3 */
  151. {0, 0, 0, 1, 0, 1}, /* PC2 : ENET FDE */
  152. {0, 0, 0, 1, 0, 0}, /* PC1 : ENET DSQE */
  153. {0, 0, 0, 1, 0, 0}, /* PC0 : ENET LBK */
  154. },
  155. /* Port D: conf, ppar, psor, pdir, podr, pdat */
  156. {
  157. #ifdef CONFIG_TQM8560
  158. {1, 1, 0, 0, 0, 0}, /* PD31: SCC1 EN RxD */
  159. {1, 1, 1, 1, 0, 0}, /* PD30: SCC1 EN TxD */
  160. {1, 1, 0, 1, 0, 0}, /* PD29: SCC1 EN TENA */
  161. #else /* !CONFIG_TQM8560 */
  162. {0, 0, 0, 0, 0, 0}, /* PD31: PD31 */
  163. {0, 0, 0, 0, 0, 0}, /* PD30: PD30 */
  164. {0, 0, 0, 0, 0, 0}, /* PD29: PD29 */
  165. #endif /* CONFIG_TQM8560 */
  166. {1, 1, 0, 0, 0, 0}, /* PD28: PD28 */
  167. {1, 1, 0, 1, 0, 0}, /* PD27: PD27 */
  168. {1, 1, 0, 1, 0, 0}, /* PD26: PD26 */
  169. {0, 0, 0, 1, 0, 0}, /* PD25: PD25 */
  170. {0, 0, 0, 1, 0, 0}, /* PD24: PD24 */
  171. {0, 0, 0, 1, 0, 0}, /* PD23: PD23 */
  172. {0, 0, 0, 1, 0, 0}, /* PD22: PD22 */
  173. {0, 0, 0, 1, 0, 0}, /* PD21: PD21 */
  174. {0, 0, 0, 1, 0, 0}, /* PD20: PD20 */
  175. {0, 0, 0, 1, 0, 0}, /* PD19: PD19 */
  176. {0, 0, 0, 1, 0, 0}, /* PD18: PD18 */
  177. {0, 1, 0, 0, 0, 0}, /* PD17: FCC1 ATMRXPRTY */
  178. {0, 1, 0, 1, 0, 0}, /* PD16: FCC1 ATMTXPRTY */
  179. {0, 1, 1, 0, 1, 0}, /* PD15: I2C SDA */
  180. {0, 0, 0, 1, 0, 0}, /* PD14: LED */
  181. {0, 0, 0, 0, 0, 0}, /* PD13: PD13 */
  182. {0, 0, 0, 0, 0, 0}, /* PD12: PD12 */
  183. {0, 0, 0, 0, 0, 0}, /* PD11: PD11 */
  184. {0, 0, 0, 0, 0, 0}, /* PD10: PD10 */
  185. {0, 1, 0, 1, 0, 0}, /* PD9 : SMC1 TXD */
  186. {0, 1, 0, 0, 0, 0}, /* PD8 : SMC1 RXD */
  187. {0, 0, 0, 1, 0, 1}, /* PD7 : PD7 */
  188. {0, 0, 0, 1, 0, 1}, /* PD6 : PD6 */
  189. {0, 0, 0, 1, 0, 1}, /* PD5 : PD5 */
  190. {0, 0, 0, 1, 0, 1}, /* PD4 : PD4 */
  191. {0, 0, 0, 0, 0, 0}, /* PD3 : pin doesn't exist */
  192. {0, 0, 0, 0, 0, 0}, /* PD2 : pin doesn't exist */
  193. {0, 0, 0, 0, 0, 0}, /* PD1 : pin doesn't exist */
  194. {0, 0, 0, 0, 0, 0} /* PD0 : pin doesn't exist */
  195. }
  196. };
  197. #endif /* CONFIG_CPM2 */
  198. #define CASL_STRING1 "casl=xx"
  199. #define CASL_STRING2 "casl="
  200. static const int casl_table[] = { 20, 25, 30 };
  201. #define N_CASL (sizeof(casl_table) / sizeof(casl_table[0]))
  202. int cas_latency (void)
  203. {
  204. char *s = getenv ("serial#");
  205. int casl;
  206. int val;
  207. int i;
  208. casl = CONFIG_DDR_DEFAULT_CL;
  209. if (s != NULL) {
  210. if (strncmp(s + strlen (s) - strlen (CASL_STRING1),
  211. CASL_STRING2, strlen (CASL_STRING2)) == 0) {
  212. val = simple_strtoul (s + strlen (s) - 2, NULL, 10);
  213. for (i = 0; i < N_CASL; ++i) {
  214. if (val == casl_table[i]) {
  215. return val;
  216. }
  217. }
  218. }
  219. }
  220. return casl;
  221. }
  222. int checkboard (void)
  223. {
  224. char *s = getenv ("serial#");
  225. printf ("Board: %s", CONFIG_BOARDNAME);
  226. if (s != NULL) {
  227. puts (", serial# ");
  228. puts (s);
  229. }
  230. putc ('\n');
  231. #ifdef CONFIG_PCI
  232. printf ("PCI1: 32 bit, %d MHz (compiled)\n",
  233. CONFIG_SYS_CLK_FREQ / 1000000);
  234. #else
  235. printf ("PCI1: disabled\n");
  236. #endif
  237. /*
  238. * Initialize local bus.
  239. */
  240. local_bus_init ();
  241. return 0;
  242. }
  243. int misc_init_r (void)
  244. {
  245. volatile ccsr_lbc_t *memctl = (void *)(CFG_MPC85xx_LBC_ADDR);
  246. /*
  247. * Adjust flash start and offset to detected values
  248. */
  249. gd->bd->bi_flashstart = 0 - gd->bd->bi_flashsize;
  250. gd->bd->bi_flashoffset = 0;
  251. /*
  252. * Check if boot FLASH isn't max size
  253. */
  254. if (gd->bd->bi_flashsize < (0 - CFG_FLASH0)) {
  255. memctl->or0 =
  256. gd->bd->bi_flashstart | (CFG_OR0_PRELIM & 0x00007fff);
  257. memctl->br0 =
  258. gd->bd->bi_flashstart | (CFG_BR0_PRELIM & 0x00007fff);
  259. /*
  260. * Re-check to get correct base address
  261. */
  262. flash_get_size (gd->bd->bi_flashstart, CFG_MAX_FLASH_BANKS - 1);
  263. }
  264. /*
  265. * Check if only one FLASH bank is available
  266. */
  267. if (gd->bd->bi_flashsize != CFG_MAX_FLASH_BANKS * (0 - CFG_FLASH0)) {
  268. memctl->or1 = 0;
  269. memctl->br1 = 0;
  270. /*
  271. * Re-do flash protection upon new addresses
  272. */
  273. flash_protect (FLAG_PROTECT_CLEAR,
  274. gd->bd->bi_flashstart, 0xffffffff,
  275. &flash_info[CFG_MAX_FLASH_BANKS - 1]);
  276. /* Monitor protection ON by default */
  277. flash_protect (FLAG_PROTECT_SET,
  278. CFG_MONITOR_BASE,
  279. CFG_MONITOR_BASE + monitor_flash_len - 1,
  280. &flash_info[CFG_MAX_FLASH_BANKS - 1]);
  281. /* Environment protection ON by default */
  282. flash_protect (FLAG_PROTECT_SET,
  283. CFG_ENV_ADDR,
  284. CFG_ENV_ADDR + CFG_ENV_SECT_SIZE - 1,
  285. &flash_info[CFG_MAX_FLASH_BANKS - 1]);
  286. /* Redundant environment protection ON by default */
  287. flash_protect (FLAG_PROTECT_SET,
  288. CFG_ENV_ADDR_REDUND,
  289. CFG_ENV_ADDR_REDUND + CFG_ENV_SIZE_REDUND - 1,
  290. &flash_info[CFG_MAX_FLASH_BANKS - 1]);
  291. }
  292. return 0;
  293. }
  294. /*
  295. * Initialize Local Bus
  296. */
  297. void local_bus_init (void)
  298. {
  299. volatile ccsr_gur_t *gur = (void *)(CFG_MPC85xx_GUTS_ADDR);
  300. volatile ccsr_lbc_t *lbc = (void *)(CFG_MPC85xx_LBC_ADDR);
  301. uint clkdiv;
  302. uint lbc_hz;
  303. sys_info_t sysinfo;
  304. /*
  305. * Errata LBC11.
  306. * Fix Local Bus clock glitch when DLL is enabled.
  307. *
  308. * If localbus freq is < 66Mhz, DLL bypass mode must be used.
  309. * If localbus freq is > 133Mhz, DLL can be safely enabled.
  310. * Between 66 and 133, the DLL is enabled with an override workaround.
  311. */
  312. get_sys_info (&sysinfo);
  313. clkdiv = lbc->lcrr & 0x0f;
  314. lbc_hz = sysinfo.freqSystemBus / 1000000 / clkdiv;
  315. if (lbc_hz < 66) {
  316. lbc->lcrr = CFG_LBC_LCRR | 0x80000000; /* DLL Bypass */
  317. lbc->ltedr = 0xa4c80000; /* DK: !!! */
  318. } else if (lbc_hz >= 133) {
  319. lbc->lcrr = CFG_LBC_LCRR & (~0x80000000); /* DLL Enabled */
  320. } else {
  321. /*
  322. * On REV1 boards, need to change CLKDIV before enable DLL.
  323. * Default CLKDIV is 8, change it to 4 temporarily.
  324. */
  325. uint pvr = get_pvr ();
  326. uint temp_lbcdll = 0;
  327. if (pvr == PVR_85xx_REV1) {
  328. /* FIXME: Justify the high bit here. */
  329. lbc->lcrr = 0x10000004;
  330. }
  331. lbc->lcrr = CFG_LBC_LCRR & (~0x80000000); /* DLL Enabled */
  332. udelay (200);
  333. /*
  334. * Sample LBC DLL ctrl reg, upshift it to set the
  335. * override bits.
  336. */
  337. temp_lbcdll = gur->lbcdllcr;
  338. gur->lbcdllcr = (((temp_lbcdll & 0xff) << 16) | 0x80000000);
  339. asm ("sync;isync;msync");
  340. }
  341. }
  342. #if defined(CONFIG_PCI)
  343. /*
  344. * Initialize PCI Devices, report devices found.
  345. */
  346. #ifndef CONFIG_PCI_PNP
  347. static struct pci_config_table pci_mpc85xxads_config_table[] = {
  348. {PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
  349. PCI_IDSEL_NUMBER, PCI_ANY_ID,
  350. pci_cfgfunc_config_device, {PCI_ENET0_IOADDR,
  351. PCI_ENET0_MEMADDR,
  352. PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER}},
  353. {}
  354. };
  355. #endif
  356. static struct pci_controller hose = {
  357. #ifndef CONFIG_PCI_PNP
  358. config_table:pci_mpc85xxads_config_table,
  359. #endif
  360. };
  361. #endif /* CONFIG_PCI */
  362. void pci_init_board (void)
  363. {
  364. #ifdef CONFIG_PCI
  365. pci_mpc85xx_init (&hose);
  366. #endif /* CONFIG_PCI */
  367. }
  368. #ifdef CONFIG_BOARD_EARLY_INIT_R
  369. int board_early_init_r (void)
  370. {
  371. #ifdef CONFIG_PS2MULT
  372. ps2mult_early_init ();
  373. #endif /* CONFIG_PS2MULT */
  374. return (0);
  375. }
  376. #endif /* CONFIG_BOARD_EARLY_INIT_R */