cpci750.c 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074
  1. /*
  2. * (C) Copyright 2001
  3. * Josh Huber <huber@mclx.com>, Mission Critical Linux, Inc.
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. *
  23. * modifications for the DB64360 eval board based by Ingo.Assmus@keymile.com
  24. * modifications for the cpci750 by reinhard.arlt@esd-electronics.com
  25. */
  26. /*
  27. * cpci750.c - main board support/init for the esd cpci750.
  28. */
  29. #include <common.h>
  30. #include <command.h>
  31. #include <74xx_7xx.h>
  32. #include "../../Marvell/include/memory.h"
  33. #include "../../Marvell/include/pci.h"
  34. #include "../../Marvell/include/mv_gen_reg.h"
  35. #include <net.h>
  36. #include "eth.h"
  37. #include "mpsc.h"
  38. #include "i2c.h"
  39. #include "64360.h"
  40. #include "mv_regs.h"
  41. #undef DEBUG
  42. /*#define DEBUG */
  43. #ifdef CONFIG_PCI
  44. #define MAP_PCI
  45. #endif /* of CONFIG_PCI */
  46. #ifdef DEBUG
  47. #define DP(x) x
  48. #else
  49. #define DP(x)
  50. #endif
  51. static char show_config_tab[][15] = {{"PCI0DLL_2 "}, /* 31 */
  52. {"PCI0DLL_1 "}, /* 30 */
  53. {"PCI0DLL_0 "}, /* 29 */
  54. {"PCI1DLL_2 "}, /* 28 */
  55. {"PCI1DLL_1 "}, /* 27 */
  56. {"PCI1DLL_0 "}, /* 26 */
  57. {"BbEP2En "}, /* 25 */
  58. {"SDRAMRdDataDel"}, /* 24 */
  59. {"SDRAMRdDel "}, /* 23 */
  60. {"SDRAMSync "}, /* 22 */
  61. {"SDRAMPipeSel_1"}, /* 21 */
  62. {"SDRAMPipeSel_0"}, /* 20 */
  63. {"SDRAMAddDel "}, /* 19 */
  64. {"SDRAMClkSel "}, /* 18 */
  65. {"Reserved(1!) "}, /* 17 */
  66. {"PCIRty "}, /* 16 */
  67. {"BootCSWidth_1 "}, /* 15 */
  68. {"BootCSWidth_0 "}, /* 14 */
  69. {"PCI1PadsCal "}, /* 13 */
  70. {"PCI0PadsCal "}, /* 12 */
  71. {"MultiMVId_1 "}, /* 11 */
  72. {"MultiMVId_0 "}, /* 10 */
  73. {"MultiGTEn "}, /* 09 */
  74. {"Int60xArb "}, /* 08 */
  75. {"CPUBusConfig_1"}, /* 07 */
  76. {"CPUBusConfig_0"}, /* 06 */
  77. {"DefIntSpc "}, /* 05 */
  78. {0 }, /* 04 */
  79. {"SROMAdd_1 "}, /* 03 */
  80. {"SROMAdd_0 "}, /* 02 */
  81. {"DRAMPadCal "}, /* 01 */
  82. {"SInitEn "}, /* 00 */
  83. {0 }, /* 31 */
  84. {0 }, /* 30 */
  85. {0 }, /* 29 */
  86. {0 }, /* 28 */
  87. {0 }, /* 27 */
  88. {0 }, /* 26 */
  89. {0 }, /* 25 */
  90. {0 }, /* 24 */
  91. {0 }, /* 23 */
  92. {0 }, /* 22 */
  93. {"JTAGCalBy "}, /* 21 */
  94. {"GB2Sel "}, /* 20 */
  95. {"GB1Sel "}, /* 19 */
  96. {"DRAMPLL_MDiv_5"}, /* 18 */
  97. {"DRAMPLL_MDiv_4"}, /* 17 */
  98. {"DRAMPLL_MDiv_3"}, /* 16 */
  99. {"DRAMPLL_MDiv_2"}, /* 15 */
  100. {"DRAMPLL_MDiv_1"}, /* 14 */
  101. {"DRAMPLL_MDiv_0"}, /* 13 */
  102. {"GB0Sel "}, /* 12 */
  103. {"DRAMPLLPU "}, /* 11 */
  104. {"DRAMPLL_HIKVCO"}, /* 10 */
  105. {"DRAMPLLNP "}, /* 09 */
  106. {"DRAMPLL_NDiv_7"}, /* 08 */
  107. {"DRAMPLL_NDiv_6"}, /* 07 */
  108. {"CPUPadCal "}, /* 06 */
  109. {"DRAMPLL_NDiv_5"}, /* 05 */
  110. {"DRAMPLL_NDiv_4"}, /* 04 */
  111. {"DRAMPLL_NDiv_3"}, /* 03 */
  112. {"DRAMPLL_NDiv_2"}, /* 02 */
  113. {"DRAMPLL_NDiv_1"}, /* 01 */
  114. {"DRAMPLL_NDiv_0"}}; /* 00 */
  115. extern flash_info_t flash_info[];
  116. extern int do_bootm (cmd_tbl_t *, int, int, char *[]);
  117. extern int do_bootvx (cmd_tbl_t *, int, int, char *[]);
  118. /* ------------------------------------------------------------------------- */
  119. /* this is the current GT register space location */
  120. /* it starts at CONFIG_SYS_DFL_GT_REGS but moves later to CONFIG_SYS_GT_REGS */
  121. /* Unfortunately, we cant change it while we are in flash, so we initialize it
  122. * to the "final" value. This means that any debug_led calls before
  123. * board_early_init_f wont work right (like in cpu_init_f).
  124. * See also my_remap_gt_regs below. (NTL)
  125. */
  126. void board_prebootm_init (void);
  127. unsigned int INTERNAL_REG_BASE_ADDR = CONFIG_SYS_GT_REGS;
  128. int display_mem_map (void);
  129. /* ------------------------------------------------------------------------- */
  130. /*
  131. * This is a version of the GT register space remapping function that
  132. * doesn't touch globals (meaning, it's ok to run from flash.)
  133. *
  134. * Unfortunately, this has the side effect that a writable
  135. * INTERNAL_REG_BASE_ADDR is impossible. Oh well.
  136. */
  137. void my_remap_gt_regs (u32 cur_loc, u32 new_loc)
  138. {
  139. u32 temp;
  140. /* check and see if it's already moved */
  141. /* original ppcboot 1.1.6 source
  142. temp = in_le32((u32 *)(new_loc + INTERNAL_SPACE_DECODE));
  143. if ((temp & 0xffff) == new_loc >> 20)
  144. return;
  145. temp = (in_le32((u32 *)(cur_loc + INTERNAL_SPACE_DECODE)) &
  146. 0xffff0000) | (new_loc >> 20);
  147. out_le32((u32 *)(cur_loc + INTERNAL_SPACE_DECODE), temp);
  148. while (GTREGREAD(INTERNAL_SPACE_DECODE) != temp);
  149. original ppcboot 1.1.6 source end */
  150. temp = in_le32 ((u32 *) (new_loc + INTERNAL_SPACE_DECODE));
  151. if ((temp & 0xffff) == new_loc >> 16)
  152. return;
  153. temp = (in_le32 ((u32 *) (cur_loc + INTERNAL_SPACE_DECODE)) &
  154. 0xffff0000) | (new_loc >> 16);
  155. out_le32 ((u32 *) (cur_loc + INTERNAL_SPACE_DECODE), temp);
  156. while (GTREGREAD (INTERNAL_SPACE_DECODE) != temp);
  157. }
  158. #ifdef CONFIG_PCI
  159. static void gt_pci_config (void)
  160. {
  161. unsigned int stat;
  162. unsigned int val = 0x00fff864; /* DINK32: BusNum 23:16, DevNum 15:11, FuncNum 10:8, RegNum 7:2 */
  163. /* In PCIX mode devices provide their own bus and device numbers. We query the Discovery II's
  164. * config registers by writing ones to the bus and device.
  165. * We then update the Virtual register with the correct value for the bus and device.
  166. */
  167. if ((GTREGREAD (PCI_0_MODE) & (BIT4 | BIT5)) != 0) { /*if PCI-X */
  168. GT_REG_WRITE (PCI_0_CONFIG_ADDR, BIT31 | val);
  169. GT_REG_READ (PCI_0_CONFIG_DATA_VIRTUAL_REG, &stat);
  170. GT_REG_WRITE (PCI_0_CONFIG_ADDR, BIT31 | val);
  171. GT_REG_WRITE (PCI_0_CONFIG_DATA_VIRTUAL_REG,
  172. (stat & 0xffff0000) | CONFIG_SYS_PCI_IDSEL);
  173. }
  174. if ((GTREGREAD (PCI_1_MODE) & (BIT4 | BIT5)) != 0) { /*if PCI-X */
  175. GT_REG_WRITE (PCI_1_CONFIG_ADDR, BIT31 | val);
  176. GT_REG_READ (PCI_1_CONFIG_DATA_VIRTUAL_REG, &stat);
  177. GT_REG_WRITE (PCI_1_CONFIG_ADDR, BIT31 | val);
  178. GT_REG_WRITE (PCI_1_CONFIG_DATA_VIRTUAL_REG,
  179. (stat & 0xffff0000) | CONFIG_SYS_PCI_IDSEL);
  180. }
  181. /* Enable master */
  182. PCI_MASTER_ENABLE (0, SELF);
  183. PCI_MASTER_ENABLE (1, SELF);
  184. /* Enable PCI0/1 Mem0 and IO 0 disable all others */
  185. GT_REG_READ (BASE_ADDR_ENABLE, &stat);
  186. stat |= (1 << 11) | (1 << 12) | (1 << 13) | (1 << 16) | (1 << 17) | (1
  187. <<
  188. 18);
  189. stat &= ~((1 << 9) | (1 << 10) | (1 << 14) | (1 << 15));
  190. GT_REG_WRITE (BASE_ADDR_ENABLE, stat);
  191. /* ronen- add write to pci remap registers for 64460.
  192. in 64360 when writing to pci base go and overide remap automaticaly,
  193. in 64460 it doesn't */
  194. GT_REG_WRITE (PCI_0_IO_BASE_ADDR, CONFIG_SYS_PCI0_IO_SPACE >> 16);
  195. GT_REG_WRITE (PCI_0I_O_ADDRESS_REMAP, CONFIG_SYS_PCI0_IO_SPACE_PCI >> 16);
  196. GT_REG_WRITE (PCI_0_IO_SIZE, (CONFIG_SYS_PCI0_IO_SIZE - 1) >> 16);
  197. GT_REG_WRITE (PCI_0_MEMORY0_BASE_ADDR, CONFIG_SYS_PCI0_MEM_BASE >> 16);
  198. GT_REG_WRITE (PCI_0MEMORY0_ADDRESS_REMAP, CONFIG_SYS_PCI0_MEM_BASE >> 16);
  199. GT_REG_WRITE (PCI_0_MEMORY0_SIZE, (CONFIG_SYS_PCI0_MEM_SIZE - 1) >> 16);
  200. GT_REG_WRITE (PCI_1_IO_BASE_ADDR, CONFIG_SYS_PCI1_IO_SPACE >> 16);
  201. GT_REG_WRITE (PCI_1I_O_ADDRESS_REMAP, CONFIG_SYS_PCI1_IO_SPACE_PCI >> 16);
  202. GT_REG_WRITE (PCI_1_IO_SIZE, (CONFIG_SYS_PCI1_IO_SIZE - 1) >> 16);
  203. GT_REG_WRITE (PCI_1_MEMORY0_BASE_ADDR, CONFIG_SYS_PCI1_MEM_BASE >> 16);
  204. GT_REG_WRITE (PCI_1MEMORY0_ADDRESS_REMAP, CONFIG_SYS_PCI1_MEM_BASE >> 16);
  205. GT_REG_WRITE (PCI_1_MEMORY0_SIZE, (CONFIG_SYS_PCI1_MEM_SIZE - 1) >> 16);
  206. /* PCI interface settings */
  207. /* Timeout set to retry forever */
  208. GT_REG_WRITE (PCI_0TIMEOUT_RETRY, 0x0);
  209. GT_REG_WRITE (PCI_1TIMEOUT_RETRY, 0x0);
  210. /* ronen - enable only CS0 and Internal reg!! */
  211. GT_REG_WRITE (PCI_0BASE_ADDRESS_REGISTERS_ENABLE, 0xfffffdfe);
  212. GT_REG_WRITE (PCI_1BASE_ADDRESS_REGISTERS_ENABLE, 0xfffffdfe);
  213. /*ronen update the pci internal registers base address.*/
  214. #ifdef MAP_PCI
  215. for (stat = 0; stat <= PCI_HOST1; stat++)
  216. pciWriteConfigReg (stat,
  217. PCI_INTERNAL_REGISTERS_MEMORY_MAPPED_BASE_ADDRESS,
  218. SELF, CONFIG_SYS_GT_REGS);
  219. #endif
  220. }
  221. #endif
  222. /* Setup CPU interface paramaters */
  223. static void gt_cpu_config (void)
  224. {
  225. cpu_t cpu = get_cpu_type ();
  226. ulong tmp;
  227. /* cpu configuration register */
  228. tmp = GTREGREAD (CPU_CONFIGURATION);
  229. /* set the SINGLE_CPU bit see MV64360 P.399 */
  230. #ifndef CONFIG_SYS_GT_DUAL_CPU /* SINGLE_CPU seems to cause JTAG problems */
  231. tmp |= CPU_CONF_SINGLE_CPU;
  232. #endif
  233. tmp &= ~CPU_CONF_AACK_DELAY_2;
  234. tmp |= CPU_CONF_DP_VALID;
  235. tmp |= CPU_CONF_AP_VALID;
  236. tmp |= CPU_CONF_PIPELINE;
  237. GT_REG_WRITE (CPU_CONFIGURATION, tmp); /* Marvell (VXWorks) writes 0x20220FF */
  238. /* CPU master control register */
  239. tmp = GTREGREAD (CPU_MASTER_CONTROL);
  240. tmp |= CPU_MAST_CTL_ARB_EN;
  241. if ((cpu == CPU_7400) ||
  242. (cpu == CPU_7410) || (cpu == CPU_7455) || (cpu == CPU_7450)) {
  243. tmp |= CPU_MAST_CTL_CLEAN_BLK;
  244. tmp |= CPU_MAST_CTL_FLUSH_BLK;
  245. } else {
  246. /* cleanblock must be cleared for CPUs
  247. * that do not support this command (603e, 750)
  248. * see Res#1 */
  249. tmp &= ~CPU_MAST_CTL_CLEAN_BLK;
  250. tmp &= ~CPU_MAST_CTL_FLUSH_BLK;
  251. }
  252. GT_REG_WRITE (CPU_MASTER_CONTROL, tmp);
  253. }
  254. /*
  255. * board_early_init_f.
  256. *
  257. * set up gal. device mappings, etc.
  258. */
  259. int board_early_init_f (void)
  260. {
  261. /*
  262. * set up the GT the way the kernel wants it
  263. * the call to move the GT register space will obviously
  264. * fail if it has already been done, but we're going to assume
  265. * that if it's not at the power-on location, it's where we put
  266. * it last time. (huber)
  267. */
  268. my_remap_gt_regs (CONFIG_SYS_DFL_GT_REGS, CONFIG_SYS_GT_REGS);
  269. /* No PCI in first release of Port To_do: enable it. */
  270. #ifdef CONFIG_PCI
  271. gt_pci_config ();
  272. #endif
  273. /* mask all external interrupt sources */
  274. GT_REG_WRITE (CPU_INTERRUPT_MASK_REGISTER_LOW, 0);
  275. GT_REG_WRITE (CPU_INTERRUPT_MASK_REGISTER_HIGH, 0);
  276. /* new in MV6436x */
  277. GT_REG_WRITE (CPU_INTERRUPT_1_MASK_REGISTER_LOW, 0);
  278. GT_REG_WRITE (CPU_INTERRUPT_1_MASK_REGISTER_HIGH, 0);
  279. /* --------------------- */
  280. GT_REG_WRITE (PCI_0INTERRUPT_CAUSE_MASK_REGISTER_LOW, 0);
  281. GT_REG_WRITE (PCI_0INTERRUPT_CAUSE_MASK_REGISTER_HIGH, 0);
  282. GT_REG_WRITE (PCI_1INTERRUPT_CAUSE_MASK_REGISTER_LOW, 0);
  283. GT_REG_WRITE (PCI_1INTERRUPT_CAUSE_MASK_REGISTER_HIGH, 0);
  284. /* does not exist in MV6436x
  285. GT_REG_WRITE(CPU_INT_0_MASK, 0);
  286. GT_REG_WRITE(CPU_INT_1_MASK, 0);
  287. GT_REG_WRITE(CPU_INT_2_MASK, 0);
  288. GT_REG_WRITE(CPU_INT_3_MASK, 0);
  289. --------------------- */
  290. /* ----- DEVICE BUS SETTINGS ------ */
  291. /*
  292. * EVB
  293. * 0 - SRAM ????
  294. * 1 - RTC ????
  295. * 2 - UART ????
  296. * 3 - Flash checked 32Bit Intel Strata
  297. * boot - BootCS checked 8Bit 29LV040B
  298. *
  299. */
  300. /*
  301. * the dual 7450 module requires burst access to the boot
  302. * device, so the serial rom copies the boot device to the
  303. * on-board sram on the eval board, and updates the correct
  304. * registers to boot from the sram. (device0)
  305. */
  306. memoryMapDeviceSpace (DEVICE0, CONFIG_SYS_DEV0_SPACE, CONFIG_SYS_DEV0_SIZE);
  307. memoryMapDeviceSpace (DEVICE1, CONFIG_SYS_DEV1_SPACE, CONFIG_SYS_DEV1_SIZE);
  308. memoryMapDeviceSpace (DEVICE2, CONFIG_SYS_DEV2_SPACE, CONFIG_SYS_DEV2_SIZE);
  309. memoryMapDeviceSpace (DEVICE3, CONFIG_SYS_DEV3_SPACE, CONFIG_SYS_DEV3_SIZE);
  310. /* configure device timing */
  311. GT_REG_WRITE (DEVICE_BANK0PARAMETERS, CONFIG_SYS_DEV0_PAR);
  312. GT_REG_WRITE (DEVICE_BANK1PARAMETERS, CONFIG_SYS_DEV1_PAR);
  313. GT_REG_WRITE (DEVICE_BANK2PARAMETERS, CONFIG_SYS_DEV2_PAR);
  314. GT_REG_WRITE (DEVICE_BANK3PARAMETERS, CONFIG_SYS_DEV3_PAR);
  315. #ifdef CONFIG_SYS_32BIT_BOOT_PAR /* set port parameters for Flash device module access */
  316. /* detect if we are booting from the 32 bit flash */
  317. if (GTREGREAD (DEVICE_BOOT_BANK_PARAMETERS) & (0x3 << 20)) {
  318. /* 32 bit boot flash */
  319. GT_REG_WRITE (DEVICE_BANK3PARAMETERS, CONFIG_SYS_8BIT_BOOT_PAR);
  320. GT_REG_WRITE (DEVICE_BOOT_BANK_PARAMETERS,
  321. CONFIG_SYS_32BIT_BOOT_PAR);
  322. } else {
  323. /* 8 bit boot flash */
  324. GT_REG_WRITE (DEVICE_BANK3PARAMETERS, CONFIG_SYS_32BIT_BOOT_PAR);
  325. GT_REG_WRITE (DEVICE_BOOT_BANK_PARAMETERS, CONFIG_SYS_8BIT_BOOT_PAR);
  326. }
  327. #else
  328. /* 8 bit boot flash only */
  329. /* GT_REG_WRITE(DEVICE_BOOT_BANK_PARAMETERS, CONFIG_SYS_8BIT_BOOT_PAR);*/
  330. #endif
  331. gt_cpu_config ();
  332. /* MPP setup */
  333. GT_REG_WRITE (MPP_CONTROL0, CONFIG_SYS_MPP_CONTROL_0);
  334. GT_REG_WRITE (MPP_CONTROL1, CONFIG_SYS_MPP_CONTROL_1);
  335. GT_REG_WRITE (MPP_CONTROL2, CONFIG_SYS_MPP_CONTROL_2);
  336. GT_REG_WRITE (MPP_CONTROL3, CONFIG_SYS_MPP_CONTROL_3);
  337. GT_REG_WRITE (GPP_LEVEL_CONTROL, CONFIG_SYS_GPP_LEVEL_CONTROL);
  338. DEBUG_LED0_ON ();
  339. DEBUG_LED1_ON ();
  340. DEBUG_LED2_ON ();
  341. return 0;
  342. }
  343. /* various things to do after relocation */
  344. int misc_init_r ()
  345. {
  346. icache_enable ();
  347. #ifdef CONFIG_SYS_L2
  348. l2cache_enable ();
  349. #endif
  350. #ifdef CONFIG_MPSC
  351. mpsc_sdma_init ();
  352. mpsc_init2 ();
  353. #endif
  354. #if 0
  355. /* disable the dcache and MMU */
  356. dcache_lock ();
  357. #endif
  358. if (flash_info[3].size < CONFIG_SYS_FLASH_INCREMENT) {
  359. unsigned int flash_offset;
  360. unsigned int l;
  361. flash_offset = CONFIG_SYS_FLASH_INCREMENT - flash_info[3].size;
  362. for (l = 0; l < CONFIG_SYS_MAX_FLASH_SECT; l++) {
  363. if (flash_info[3].start[l] != 0) {
  364. flash_info[3].start[l] += flash_offset;
  365. }
  366. }
  367. flash_protect (FLAG_PROTECT_SET,
  368. CONFIG_SYS_MONITOR_BASE,
  369. CONFIG_SYS_MONITOR_BASE + monitor_flash_len - 1,
  370. &flash_info[3]);
  371. }
  372. return 0;
  373. }
  374. void after_reloc (ulong dest_addr, gd_t * gd)
  375. {
  376. memoryMapDeviceSpace (BOOT_DEVICE, CONFIG_SYS_BOOT_SPACE, CONFIG_SYS_BOOT_SIZE);
  377. display_mem_map ();
  378. /* now, jump to the main ppcboot board init code */
  379. board_init_r (gd, dest_addr);
  380. /* NOTREACHED */
  381. }
  382. /* ------------------------------------------------------------------------- */
  383. /*
  384. * Check Board Identity:
  385. *
  386. * right now, assume borad type. (there is just one...after all)
  387. */
  388. int checkboard (void)
  389. {
  390. int l_type = 0;
  391. printf ("BOARD: %s\n", CONFIG_SYS_BOARD_NAME);
  392. return (l_type);
  393. }
  394. /* utility functions */
  395. void debug_led (int led, int mode)
  396. {
  397. }
  398. int display_mem_map (void)
  399. {
  400. int i, j;
  401. unsigned int base, size, width;
  402. /* SDRAM */
  403. printf ("SD (DDR) RAM\n");
  404. for (i = 0; i <= BANK3; i++) {
  405. base = memoryGetBankBaseAddress (i);
  406. size = memoryGetBankSize (i);
  407. if (size != 0) {
  408. printf ("BANK%d: base - 0x%08x\tsize - %dM bytes\n",
  409. i, base, size >> 20);
  410. }
  411. }
  412. #ifdef CONFIG_PCI
  413. /* CPU's PCI windows */
  414. for (i = 0; i <= PCI_HOST1; i++) {
  415. printf ("\nCPU's PCI %d windows\n", i);
  416. base = pciGetSpaceBase (i, PCI_IO);
  417. size = pciGetSpaceSize (i, PCI_IO);
  418. printf (" IO: base - 0x%08x\tsize - %dM bytes\n", base,
  419. size >> 20);
  420. for (j = 0;
  421. j <=
  422. PCI_REGION0
  423. /*ronen currently only first PCI MEM is used 3 */ ;
  424. j++) {
  425. base = pciGetSpaceBase (i, j);
  426. size = pciGetSpaceSize (i, j);
  427. printf ("MEMORY %d: base - 0x%08x\tsize - %dM bytes\n", j, base, size >> 20);
  428. }
  429. }
  430. #endif /* of CONFIG_PCI */
  431. /* Devices */
  432. printf ("\nDEVICES\n");
  433. for (i = 0; i <= DEVICE3; i++) {
  434. base = memoryGetDeviceBaseAddress (i);
  435. size = memoryGetDeviceSize (i);
  436. width = memoryGetDeviceWidth (i) * 8;
  437. printf ("DEV %d: base - 0x%08x size - %dM bytes\twidth - %d bits", i, base, size >> 20, width);
  438. if (i == 0)
  439. printf ("\t- FLASH\n");
  440. else if (i == 1)
  441. printf ("\t- FLASH\n");
  442. else if (i == 2)
  443. printf ("\t- FLASH\n");
  444. else
  445. printf ("\t- RTC/REGS/CAN\n");
  446. }
  447. /* Bootrom */
  448. base = memoryGetDeviceBaseAddress (BOOT_DEVICE); /* Boot */
  449. size = memoryGetDeviceSize (BOOT_DEVICE);
  450. width = memoryGetDeviceWidth (BOOT_DEVICE) * 8;
  451. printf (" BOOT: base - 0x%08x size - %dM bytes\twidth - %d bits\t- FLASH\n",
  452. base, size >> 20, width);
  453. return (0);
  454. }
  455. /*
  456. * Command loadpci: wait for signal from host and boot image.
  457. */
  458. int do_loadpci(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  459. {
  460. volatile unsigned int *ptr;
  461. int count = 0;
  462. int count2 = 0;
  463. int status;
  464. char addr[16];
  465. char str[] = "\\|/-";
  466. char *local_args[2];
  467. /*
  468. * Mark sync address
  469. */
  470. ptr = 0;
  471. ptr[0] = 0xffffffff;
  472. ptr[1] = 0xffffffff;
  473. puts("\nWaiting for image from pci host -");
  474. /*
  475. * Wait for host to write the start address
  476. */
  477. while (*ptr == 0xffffffff) {
  478. count++;
  479. if (!(count % 100)) {
  480. count2++;
  481. putc(0x08); /* backspace */
  482. putc(str[count2 % 4]);
  483. }
  484. /* Abort if ctrl-c was pressed */
  485. if (ctrlc()) {
  486. puts("\nAbort\n");
  487. return 0;
  488. }
  489. udelay(1000);
  490. }
  491. sprintf(addr, "%08x", *ptr);
  492. printf("\nBooting Image at addr 0x%s ...\n", addr);
  493. setenv("loadaddr", addr);
  494. switch (ptr[1] == 0) {
  495. case 0:
  496. /*
  497. * Boot image via bootm
  498. */
  499. local_args[0] = argv[0];
  500. local_args[1] = NULL;
  501. status = do_bootm (cmdtp, 0, 1, local_args);
  502. break;
  503. case 1:
  504. /*
  505. * Boot image via bootvx
  506. */
  507. local_args[0] = argv[0];
  508. local_args[1] = NULL;
  509. status = do_bootvx (cmdtp, 0, 1, local_args);
  510. break;
  511. }
  512. return 0;
  513. }
  514. U_BOOT_CMD(
  515. loadpci, 1, 1, do_loadpci,
  516. "loadpci - Wait for pci-image and boot it\n",
  517. NULL
  518. );
  519. /* DRAM check routines copied from gw8260 */
  520. #if defined (CONFIG_SYS_DRAM_TEST)
  521. /*********************************************************************/
  522. /* NAME: move64() - moves a double word (64-bit) */
  523. /* */
  524. /* DESCRIPTION: */
  525. /* this function performs a double word move from the data at */
  526. /* the source pointer to the location at the destination pointer. */
  527. /* */
  528. /* INPUTS: */
  529. /* unsigned long long *src - pointer to data to move */
  530. /* */
  531. /* OUTPUTS: */
  532. /* unsigned long long *dest - pointer to locate to move data */
  533. /* */
  534. /* RETURNS: */
  535. /* None */
  536. /* */
  537. /* RESTRICTIONS/LIMITATIONS: */
  538. /* May cloober fr0. */
  539. /* */
  540. /*********************************************************************/
  541. static void move64 (unsigned long long *src, unsigned long long *dest)
  542. {
  543. asm ("lfd 0, 0(3)\n\t" /* fpr0 = *scr */
  544. "stfd 0, 0(4)" /* *dest = fpr0 */
  545. : : : "fr0"); /* Clobbers fr0 */
  546. return;
  547. }
  548. #if defined (CONFIG_SYS_DRAM_TEST_DATA)
  549. unsigned long long pattern[] = {
  550. 0xaaaaaaaaaaaaaaaaLL,
  551. 0xccccccccccccccccLL,
  552. 0xf0f0f0f0f0f0f0f0LL,
  553. 0xff00ff00ff00ff00LL,
  554. 0xffff0000ffff0000LL,
  555. 0xffffffff00000000LL,
  556. 0x00000000ffffffffLL,
  557. 0x0000ffff0000ffffLL,
  558. 0x00ff00ff00ff00ffLL,
  559. 0x0f0f0f0f0f0f0f0fLL,
  560. 0x3333333333333333LL,
  561. 0x5555555555555555LL,
  562. };
  563. /*********************************************************************/
  564. /* NAME: mem_test_data() - test data lines for shorts and opens */
  565. /* */
  566. /* DESCRIPTION: */
  567. /* Tests data lines for shorts and opens by forcing adjacent data */
  568. /* to opposite states. Because the data lines could be routed in */
  569. /* an arbitrary manner the must ensure test patterns ensure that */
  570. /* every case is tested. By using the following series of binary */
  571. /* patterns every combination of adjacent bits is test regardless */
  572. /* of routing. */
  573. /* */
  574. /* ...101010101010101010101010 */
  575. /* ...110011001100110011001100 */
  576. /* ...111100001111000011110000 */
  577. /* ...111111110000000011111111 */
  578. /* */
  579. /* Carrying this out, gives us six hex patterns as follows: */
  580. /* */
  581. /* 0xaaaaaaaaaaaaaaaa */
  582. /* 0xcccccccccccccccc */
  583. /* 0xf0f0f0f0f0f0f0f0 */
  584. /* 0xff00ff00ff00ff00 */
  585. /* 0xffff0000ffff0000 */
  586. /* 0xffffffff00000000 */
  587. /* */
  588. /* The number test patterns will always be given by: */
  589. /* */
  590. /* log(base 2)(number data bits) = log2 (64) = 6 */
  591. /* */
  592. /* To test for short and opens to other signals on our boards. we */
  593. /* simply */
  594. /* test with the 1's complemnt of the paterns as well. */
  595. /* */
  596. /* OUTPUTS: */
  597. /* Displays failing test pattern */
  598. /* */
  599. /* RETURNS: */
  600. /* 0 - Passed test */
  601. /* 1 - Failed test */
  602. /* */
  603. /* RESTRICTIONS/LIMITATIONS: */
  604. /* Assumes only one one SDRAM bank */
  605. /* */
  606. /*********************************************************************/
  607. int mem_test_data (void)
  608. {
  609. unsigned long long *pmem = (unsigned long long *) CONFIG_SYS_MEMTEST_START;
  610. unsigned long long temp64 = 0;
  611. int num_patterns = sizeof (pattern) / sizeof (pattern[0]);
  612. int i;
  613. unsigned int hi, lo;
  614. for (i = 0; i < num_patterns; i++) {
  615. move64 (&(pattern[i]), pmem);
  616. move64 (pmem, &temp64);
  617. /* hi = (temp64>>32) & 0xffffffff; */
  618. /* lo = temp64 & 0xffffffff; */
  619. /* printf("\ntemp64 = 0x%08x%08x", hi, lo); */
  620. hi = (pattern[i] >> 32) & 0xffffffff;
  621. lo = pattern[i] & 0xffffffff;
  622. /* printf("\npattern[%d] = 0x%08x%08x", i, hi, lo); */
  623. if (temp64 != pattern[i]) {
  624. printf ("\n Data Test Failed, pattern 0x%08x%08x",
  625. hi, lo);
  626. return 1;
  627. }
  628. }
  629. return 0;
  630. }
  631. #endif /* CONFIG_SYS_DRAM_TEST_DATA */
  632. #if defined (CONFIG_SYS_DRAM_TEST_ADDRESS)
  633. /*********************************************************************/
  634. /* NAME: mem_test_address() - test address lines */
  635. /* */
  636. /* DESCRIPTION: */
  637. /* This function performs a test to verify that each word im */
  638. /* memory is uniquly addressable. The test sequence is as follows: */
  639. /* */
  640. /* 1) write the address of each word to each word. */
  641. /* 2) verify that each location equals its address */
  642. /* */
  643. /* OUTPUTS: */
  644. /* Displays failing test pattern and address */
  645. /* */
  646. /* RETURNS: */
  647. /* 0 - Passed test */
  648. /* 1 - Failed test */
  649. /* */
  650. /* RESTRICTIONS/LIMITATIONS: */
  651. /* */
  652. /* */
  653. /*********************************************************************/
  654. int mem_test_address (void)
  655. {
  656. volatile unsigned int *pmem =
  657. (volatile unsigned int *) CONFIG_SYS_MEMTEST_START;
  658. const unsigned int size = (CONFIG_SYS_MEMTEST_END - CONFIG_SYS_MEMTEST_START) / 4;
  659. unsigned int i;
  660. /* write address to each location */
  661. for (i = 0; i < size; i++) {
  662. pmem[i] = i;
  663. }
  664. /* verify each loaction */
  665. for (i = 0; i < size; i++) {
  666. if (pmem[i] != i) {
  667. printf ("\n Address Test Failed at 0x%x", i);
  668. return 1;
  669. }
  670. }
  671. return 0;
  672. }
  673. #endif /* CONFIG_SYS_DRAM_TEST_ADDRESS */
  674. #if defined (CONFIG_SYS_DRAM_TEST_WALK)
  675. /*********************************************************************/
  676. /* NAME: mem_march() - memory march */
  677. /* */
  678. /* DESCRIPTION: */
  679. /* Marches up through memory. At each location verifies rmask if */
  680. /* read = 1. At each location write wmask if write = 1. Displays */
  681. /* failing address and pattern. */
  682. /* */
  683. /* INPUTS: */
  684. /* volatile unsigned long long * base - start address of test */
  685. /* unsigned int size - number of dwords(64-bit) to test */
  686. /* unsigned long long rmask - read verify mask */
  687. /* unsigned long long wmask - wrtie verify mask */
  688. /* short read - verifies rmask if read = 1 */
  689. /* short write - writes wmask if write = 1 */
  690. /* */
  691. /* OUTPUTS: */
  692. /* Displays failing test pattern and address */
  693. /* */
  694. /* RETURNS: */
  695. /* 0 - Passed test */
  696. /* 1 - Failed test */
  697. /* */
  698. /* RESTRICTIONS/LIMITATIONS: */
  699. /* */
  700. /* */
  701. /*********************************************************************/
  702. int mem_march (volatile unsigned long long *base,
  703. unsigned int size,
  704. unsigned long long rmask,
  705. unsigned long long wmask, short read, short write)
  706. {
  707. unsigned int i;
  708. unsigned long long temp = 0;
  709. unsigned int hitemp, lotemp, himask, lomask;
  710. for (i = 0; i < size; i++) {
  711. if (read != 0) {
  712. /* temp = base[i]; */
  713. move64 ((unsigned long long *) &(base[i]), &temp);
  714. if (rmask != temp) {
  715. hitemp = (temp >> 32) & 0xffffffff;
  716. lotemp = temp & 0xffffffff;
  717. himask = (rmask >> 32) & 0xffffffff;
  718. lomask = rmask & 0xffffffff;
  719. printf ("\n Walking one's test failed: address = 0x%08x," "\n\texpected 0x%08x%08x, found 0x%08x%08x", i << 3, himask, lomask, hitemp, lotemp);
  720. return 1;
  721. }
  722. }
  723. if (write != 0) {
  724. /* base[i] = wmask; */
  725. move64 (&wmask, (unsigned long long *) &(base[i]));
  726. }
  727. }
  728. return 0;
  729. }
  730. #endif /* CONFIG_SYS_DRAM_TEST_WALK */
  731. /*********************************************************************/
  732. /* NAME: mem_test_walk() - a simple walking ones test */
  733. /* */
  734. /* DESCRIPTION: */
  735. /* Performs a walking ones through entire physical memory. The */
  736. /* test uses as series of memory marches, mem_march(), to verify */
  737. /* and write the test patterns to memory. The test sequence is as */
  738. /* follows: */
  739. /* 1) march writing 0000...0001 */
  740. /* 2) march verifying 0000...0001 , writing 0000...0010 */
  741. /* 3) repeat step 2 shifting masks left 1 bit each time unitl */
  742. /* the write mask equals 1000...0000 */
  743. /* 4) march verifying 1000...0000 */
  744. /* The test fails if any of the memory marches return a failure. */
  745. /* */
  746. /* OUTPUTS: */
  747. /* Displays which pass on the memory test is executing */
  748. /* */
  749. /* RETURNS: */
  750. /* 0 - Passed test */
  751. /* 1 - Failed test */
  752. /* */
  753. /* RESTRICTIONS/LIMITATIONS: */
  754. /* */
  755. /* */
  756. /*********************************************************************/
  757. int mem_test_walk (void)
  758. {
  759. unsigned long long mask;
  760. volatile unsigned long long *pmem =
  761. (volatile unsigned long long *) CONFIG_SYS_MEMTEST_START;
  762. const unsigned long size = (CONFIG_SYS_MEMTEST_END - CONFIG_SYS_MEMTEST_START) / 8;
  763. unsigned int i;
  764. mask = 0x01;
  765. printf ("Initial Pass");
  766. mem_march (pmem, size, 0x0, 0x1, 0, 1);
  767. printf ("\b\b\b\b\b\b\b\b\b\b\b\b");
  768. printf (" ");
  769. printf (" ");
  770. printf ("\b\b\b\b\b\b\b\b\b\b\b\b");
  771. for (i = 0; i < 63; i++) {
  772. printf ("Pass %2d", i + 2);
  773. if (mem_march (pmem, size, mask, mask << 1, 1, 1) != 0) {
  774. /*printf("mask: 0x%x, pass: %d, ", mask, i); */
  775. return 1;
  776. }
  777. mask = mask << 1;
  778. printf ("\b\b\b\b\b\b\b");
  779. }
  780. printf ("Last Pass");
  781. if (mem_march (pmem, size, 0, mask, 0, 1) != 0) {
  782. /* printf("mask: 0x%x", mask); */
  783. return 1;
  784. }
  785. printf ("\b\b\b\b\b\b\b\b\b");
  786. printf (" ");
  787. printf ("\b\b\b\b\b\b\b\b\b");
  788. return 0;
  789. }
  790. /*********************************************************************/
  791. /* NAME: testdram() - calls any enabled memory tests */
  792. /* */
  793. /* DESCRIPTION: */
  794. /* Runs memory tests if the environment test variables are set to */
  795. /* 'y'. */
  796. /* */
  797. /* INPUTS: */
  798. /* testdramdata - If set to 'y', data test is run. */
  799. /* testdramaddress - If set to 'y', address test is run. */
  800. /* testdramwalk - If set to 'y', walking ones test is run */
  801. /* */
  802. /* OUTPUTS: */
  803. /* None */
  804. /* */
  805. /* RETURNS: */
  806. /* 0 - Passed test */
  807. /* 1 - Failed test */
  808. /* */
  809. /* RESTRICTIONS/LIMITATIONS: */
  810. /* */
  811. /* */
  812. /*********************************************************************/
  813. int testdram (void)
  814. {
  815. char *s;
  816. int rundata = 0;
  817. int runaddress = 0;
  818. int runwalk = 0;
  819. #ifdef CONFIG_SYS_DRAM_TEST_DATA
  820. s = getenv ("testdramdata");
  821. rundata = (s && (*s == 'y')) ? 1 : 0;
  822. #endif
  823. #ifdef CONFIG_SYS_DRAM_TEST_ADDRESS
  824. s = getenv ("testdramaddress");
  825. runaddress = (s && (*s == 'y')) ? 1 : 0;
  826. #endif
  827. #ifdef CONFIG_SYS_DRAM_TEST_WALK
  828. s = getenv ("testdramwalk");
  829. runwalk = (s && (*s == 'y')) ? 1 : 0;
  830. #endif
  831. if ((rundata == 1) || (runaddress == 1) || (runwalk == 1)) {
  832. printf ("Testing RAM from 0x%08x to 0x%08x ... (don't panic... that will take a moment !!!!)\n", CONFIG_SYS_MEMTEST_START, CONFIG_SYS_MEMTEST_END);
  833. }
  834. #ifdef CONFIG_SYS_DRAM_TEST_DATA
  835. if (rundata == 1) {
  836. printf ("Test DATA ... ");
  837. if (mem_test_data () == 1) {
  838. printf ("failed \n");
  839. return 1;
  840. } else
  841. printf ("ok \n");
  842. }
  843. #endif
  844. #ifdef CONFIG_SYS_DRAM_TEST_ADDRESS
  845. if (runaddress == 1) {
  846. printf ("Test ADDRESS ... ");
  847. if (mem_test_address () == 1) {
  848. printf ("failed \n");
  849. return 1;
  850. } else
  851. printf ("ok \n");
  852. }
  853. #endif
  854. #ifdef CONFIG_SYS_DRAM_TEST_WALK
  855. if (runwalk == 1) {
  856. printf ("Test WALKING ONEs ... ");
  857. if (mem_test_walk () == 1) {
  858. printf ("failed \n");
  859. return 1;
  860. } else
  861. printf ("ok \n");
  862. }
  863. #endif
  864. if ((rundata == 1) || (runaddress == 1) || (runwalk == 1)) {
  865. printf ("passed\n");
  866. }
  867. return 0;
  868. }
  869. #endif /* CONFIG_SYS_DRAM_TEST */
  870. /* ronen - the below functions are used by the bootm function */
  871. /* - we map the base register to fbe00000 (same mapping as in the LSP) */
  872. /* - we turn off the RX gig dmas - to prevent the dma from overunning */
  873. /* the kernel data areas. */
  874. /* - we diable and invalidate the icache and dcache. */
  875. void my_remap_gt_regs_bootm (u32 cur_loc, u32 new_loc)
  876. {
  877. u32 temp;
  878. temp = in_le32 ((u32 *) (new_loc + INTERNAL_SPACE_DECODE));
  879. if ((temp & 0xffff) == new_loc >> 16)
  880. return;
  881. temp = (in_le32 ((u32 *) (cur_loc + INTERNAL_SPACE_DECODE)) &
  882. 0xffff0000) | (new_loc >> 16);
  883. out_le32 ((u32 *) (cur_loc + INTERNAL_SPACE_DECODE), temp);
  884. while ((WORD_SWAP (*((volatile unsigned int *) (NONE_CACHEABLE |
  885. new_loc |
  886. (INTERNAL_SPACE_DECODE)))))
  887. != temp);
  888. }
  889. void board_prebootm_init ()
  890. {
  891. /* change window size of PCI1 IO in order tp prevent overlaping with REG BASE. */
  892. GT_REG_WRITE (PCI_1_IO_SIZE, (_64K - 1) >> 16);
  893. /* Stop GigE Rx DMA engines */
  894. GT_REG_WRITE (MV64360_ETH_RECEIVE_QUEUE_COMMAND_REG (0), 0x0000ff00);
  895. /* GT_REG_WRITE (MV64360_ETH_RECEIVE_QUEUE_COMMAND_REG (1), 0x0000ff00); */
  896. /* GV_REG_WRITE (MV64360_ETH_RECEIVE_QUEUE_COMMAND_REG (2), 0x0000ff00); */
  897. /* Relocate MV64360 internal regs */
  898. my_remap_gt_regs_bootm (CONFIG_SYS_GT_REGS, CONFIG_SYS_DFL_GT_REGS);
  899. icache_disable ();
  900. dcache_disable ();
  901. }
  902. int do_show_config(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
  903. {
  904. unsigned int reset_sample_low;
  905. unsigned int reset_sample_high;
  906. unsigned int l, l1, l2;
  907. GT_REG_READ(0x3c4, &reset_sample_low);
  908. GT_REG_READ(0x3d4, &reset_sample_high);
  909. printf("Reset configuration 0x%08x 0x%08x\n", reset_sample_low, reset_sample_high);
  910. l2 = 0;
  911. for (l=0; l<63; l++) {
  912. if (show_config_tab[l][0] != 0) {
  913. printf("%14s:%1x ", show_config_tab[l],
  914. ((reset_sample_low >> (31 - (l & 0x1f)))) & 0x01);
  915. l2++;
  916. if ((l2 % 4) == 0)
  917. printf("\n");
  918. } else {
  919. l1++;
  920. }
  921. if (l == 32)
  922. reset_sample_low = reset_sample_high;
  923. }
  924. printf("\n");
  925. return(0);
  926. }
  927. U_BOOT_CMD(
  928. show_config, 1, 1, do_show_config,
  929. "Show Marvell strapping register",
  930. "Show Marvell strapping register (ResetSampleLow ResetSampleHigh)"
  931. );