cpci750.c 30 KB

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