evb64260.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451
  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. /*
  24. * evb64260.c - main board support/init for the Galileo Eval board.
  25. */
  26. #include <common.h>
  27. #include <74xx_7xx.h>
  28. #include <galileo/memory.h>
  29. #include <galileo/pci.h>
  30. #include <galileo/gt64260R.h>
  31. #include <net.h>
  32. #include <netdev.h>
  33. #include <asm/io.h>
  34. #include "eth.h"
  35. #include "mpsc.h"
  36. #include "i2c.h"
  37. #include "64260.h"
  38. DECLARE_GLOBAL_DATA_PTR;
  39. #ifdef CONFIG_ZUMA_V2
  40. extern void zuma_mbox_init(void);
  41. #endif
  42. #undef DEBUG
  43. #define MAP_PCI
  44. #ifdef DEBUG
  45. #define DP(x) x
  46. #else
  47. #define DP(x)
  48. #endif
  49. /* ------------------------------------------------------------------------- */
  50. /* this is the current GT register space location */
  51. /* it starts at CONFIG_SYS_DFL_GT_REGS but moves later to CONFIG_SYS_GT_REGS */
  52. /* Unfortunately, we cant change it while we are in flash, so we initialize it
  53. * to the "final" value. This means that any debug_led calls before
  54. * board_early_init_f wont work right (like in cpu_init_f).
  55. * See also my_remap_gt_regs below. (NTL)
  56. */
  57. unsigned int INTERNAL_REG_BASE_ADDR = CONFIG_SYS_GT_REGS;
  58. /* ------------------------------------------------------------------------- */
  59. /*
  60. * This is a version of the GT register space remapping function that
  61. * doesn't touch globals (meaning, it's ok to run from flash.)
  62. *
  63. * Unfortunately, this has the side effect that a writable
  64. * INTERNAL_REG_BASE_ADDR is impossible. Oh well.
  65. */
  66. void
  67. my_remap_gt_regs(u32 cur_loc, u32 new_loc)
  68. {
  69. u32 temp;
  70. /* check and see if it's already moved */
  71. temp = in_le32((u32 *)(new_loc + INTERNAL_SPACE_DECODE));
  72. if ((temp & 0xffff) == new_loc >> 20)
  73. return;
  74. temp = (in_le32((u32 *)(cur_loc + INTERNAL_SPACE_DECODE)) &
  75. 0xffff0000) | (new_loc >> 20);
  76. out_le32((u32 *)(cur_loc + INTERNAL_SPACE_DECODE), temp);
  77. while (GTREGREAD(INTERNAL_SPACE_DECODE) != temp);
  78. }
  79. static void
  80. gt_pci_config(void)
  81. {
  82. /* move PCI stuff out of the way - NTL */
  83. /* map PCI Host 0 */
  84. pciMapSpace(PCI_HOST0, PCI_REGION0, CONFIG_SYS_PCI0_0_MEM_SPACE,
  85. CONFIG_SYS_PCI0_0_MEM_SPACE, CONFIG_SYS_PCI0_MEM_SIZE);
  86. pciMapSpace(PCI_HOST0, PCI_REGION1, 0, 0, 0);
  87. pciMapSpace(PCI_HOST0, PCI_REGION2, 0, 0, 0);
  88. pciMapSpace(PCI_HOST0, PCI_REGION3, 0, 0, 0);
  89. pciMapSpace(PCI_HOST0, PCI_IO, CONFIG_SYS_PCI0_IO_SPACE_PCI,
  90. CONFIG_SYS_PCI0_IO_SPACE, CONFIG_SYS_PCI0_IO_SIZE);
  91. /* map PCI Host 1 */
  92. pciMapSpace(PCI_HOST1, PCI_REGION0, CONFIG_SYS_PCI1_0_MEM_SPACE,
  93. CONFIG_SYS_PCI1_0_MEM_SPACE, CONFIG_SYS_PCI1_MEM_SIZE);
  94. pciMapSpace(PCI_HOST1, PCI_REGION1, 0, 0, 0);
  95. pciMapSpace(PCI_HOST1, PCI_REGION2, 0, 0, 0);
  96. pciMapSpace(PCI_HOST1, PCI_REGION3, 0, 0, 0);
  97. pciMapSpace(PCI_HOST1, PCI_IO, CONFIG_SYS_PCI1_IO_SPACE_PCI,
  98. CONFIG_SYS_PCI1_IO_SPACE, CONFIG_SYS_PCI1_IO_SIZE);
  99. /* PCI interface settings */
  100. GT_REG_WRITE(PCI_0TIMEOUT_RETRY, 0xffff);
  101. GT_REG_WRITE(PCI_1TIMEOUT_RETRY, 0xffff);
  102. GT_REG_WRITE(PCI_0BASE_ADDRESS_REGISTERS_ENABLE, 0xfffff80e);
  103. GT_REG_WRITE(PCI_1BASE_ADDRESS_REGISTERS_ENABLE, 0xfffff80e);
  104. }
  105. /* Setup CPU interface paramaters */
  106. static void
  107. gt_cpu_config(void)
  108. {
  109. cpu_t cpu = get_cpu_type();
  110. ulong tmp;
  111. /* cpu configuration register */
  112. tmp = GTREGREAD(CPU_CONFIGURATION);
  113. /* set the AACK delay bit
  114. * see Res#14 */
  115. tmp |= CPU_CONF_AACK_DELAY;
  116. tmp &= ~CPU_CONF_AACK_DELAY_2; /* New RGF */
  117. /* Galileo claims this is necessary for all busses >= 100 MHz */
  118. tmp |= CPU_CONF_FAST_CLK;
  119. if (cpu == CPU_750CX) {
  120. tmp &= ~CPU_CONF_DP_VALID; /* Safer, needed for CXe. RGF */
  121. tmp &= ~CPU_CONF_AP_VALID;
  122. } else {
  123. tmp |= CPU_CONF_DP_VALID;
  124. tmp |= CPU_CONF_AP_VALID;
  125. }
  126. /* this only works with the MPX bus */
  127. tmp &= ~CPU_CONF_RD_OOO; /* Safer RGF */
  128. tmp |= CPU_CONF_PIPELINE;
  129. tmp |= CPU_CONF_TA_DELAY;
  130. GT_REG_WRITE(CPU_CONFIGURATION, tmp);
  131. /* CPU master control register */
  132. tmp = GTREGREAD(CPU_MASTER_CONTROL);
  133. tmp |= CPU_MAST_CTL_ARB_EN;
  134. if ((cpu == CPU_7400) ||
  135. (cpu == CPU_7410) ||
  136. (cpu == CPU_7450)) {
  137. tmp |= CPU_MAST_CTL_CLEAN_BLK;
  138. tmp |= CPU_MAST_CTL_FLUSH_BLK;
  139. } else {
  140. /* cleanblock must be cleared for CPUs
  141. * that do not support this command
  142. * see Res#1 */
  143. tmp &= ~CPU_MAST_CTL_CLEAN_BLK;
  144. tmp &= ~CPU_MAST_CTL_FLUSH_BLK;
  145. }
  146. GT_REG_WRITE(CPU_MASTER_CONTROL, tmp);
  147. }
  148. /*
  149. * board_early_init_f.
  150. *
  151. * set up gal. device mappings, etc.
  152. */
  153. int board_early_init_f (void)
  154. {
  155. uchar sram_boot = 0;
  156. /*
  157. * set up the GT the way the kernel wants it
  158. * the call to move the GT register space will obviously
  159. * fail if it has already been done, but we're going to assume
  160. * that if it's not at the power-on location, it's where we put
  161. * it last time. (huber)
  162. */
  163. my_remap_gt_regs(CONFIG_SYS_DFL_GT_REGS, CONFIG_SYS_GT_REGS);
  164. gt_pci_config();
  165. /* mask all external interrupt sources */
  166. GT_REG_WRITE(CPU_INTERRUPT_MASK_REGISTER_LOW, 0);
  167. GT_REG_WRITE(CPU_INTERRUPT_MASK_REGISTER_HIGH, 0);
  168. GT_REG_WRITE(PCI_0INTERRUPT_CAUSE_MASK_REGISTER_LOW, 0);
  169. GT_REG_WRITE(PCI_0INTERRUPT_CAUSE_MASK_REGISTER_HIGH, 0);
  170. GT_REG_WRITE(PCI_1INTERRUPT_CAUSE_MASK_REGISTER_LOW, 0);
  171. GT_REG_WRITE(PCI_1INTERRUPT_CAUSE_MASK_REGISTER_HIGH, 0);
  172. GT_REG_WRITE(CPU_INT_0_MASK, 0);
  173. GT_REG_WRITE(CPU_INT_1_MASK, 0);
  174. GT_REG_WRITE(CPU_INT_2_MASK, 0);
  175. GT_REG_WRITE(CPU_INT_3_MASK, 0);
  176. /* now, onto the configuration */
  177. GT_REG_WRITE(SDRAM_CONFIGURATION, CONFIG_SYS_SDRAM_CONFIG);
  178. /* ----- DEVICE BUS SETTINGS ------ */
  179. /*
  180. * EVB
  181. * 0 - SRAM
  182. * 1 - RTC
  183. * 2 - UART
  184. * 3 - Flash
  185. * boot - BootCS
  186. *
  187. * Zuma
  188. * 0 - Flash
  189. * boot - BootCS
  190. */
  191. /*
  192. * the dual 7450 module requires burst access to the boot
  193. * device, so the serial rom copies the boot device to the
  194. * on-board sram on the eval board, and updates the correct
  195. * registers to boot from the sram. (device0)
  196. */
  197. #if defined(CONFIG_ZUMA_V2) || defined(CONFIG_P3G4)
  198. /* Zuma has no SRAM */
  199. sram_boot = 0;
  200. #else
  201. if (memoryGetDeviceBaseAddress(DEVICE0) && 0xfff00000 == CONFIG_SYS_MONITOR_BASE)
  202. sram_boot = 1;
  203. #endif
  204. memoryMapDeviceSpace(DEVICE0, CONFIG_SYS_DEV0_SPACE, CONFIG_SYS_DEV0_SIZE);
  205. memoryMapDeviceSpace(DEVICE1, CONFIG_SYS_DEV1_SPACE, CONFIG_SYS_DEV1_SIZE);
  206. memoryMapDeviceSpace(DEVICE2, CONFIG_SYS_DEV2_SPACE, CONFIG_SYS_DEV2_SIZE);
  207. memoryMapDeviceSpace(DEVICE3, CONFIG_SYS_DEV3_SPACE, CONFIG_SYS_DEV3_SIZE);
  208. /* configure device timing */
  209. #ifdef CONFIG_SYS_DEV0_PAR
  210. if (!sram_boot)
  211. GT_REG_WRITE(DEVICE_BANK0PARAMETERS, CONFIG_SYS_DEV0_PAR);
  212. #endif
  213. #ifdef CONFIG_SYS_DEV1_PAR
  214. GT_REG_WRITE(DEVICE_BANK1PARAMETERS, CONFIG_SYS_DEV1_PAR);
  215. #endif
  216. #ifdef CONFIG_SYS_DEV2_PAR
  217. GT_REG_WRITE(DEVICE_BANK2PARAMETERS, CONFIG_SYS_DEV2_PAR);
  218. #endif
  219. #ifdef CONFIG_EVB64260
  220. #ifdef CONFIG_SYS_32BIT_BOOT_PAR
  221. /* detect if we are booting from the 32 bit flash */
  222. if (GTREGREAD(DEVICE_BOOT_BANK_PARAMETERS) & (0x3 << 20)) {
  223. /* 32 bit boot flash */
  224. GT_REG_WRITE(DEVICE_BANK3PARAMETERS, CONFIG_SYS_8BIT_BOOT_PAR);
  225. GT_REG_WRITE(DEVICE_BOOT_BANK_PARAMETERS, CONFIG_SYS_32BIT_BOOT_PAR);
  226. } else {
  227. /* 8 bit boot flash */
  228. GT_REG_WRITE(DEVICE_BANK3PARAMETERS, CONFIG_SYS_32BIT_BOOT_PAR);
  229. GT_REG_WRITE(DEVICE_BOOT_BANK_PARAMETERS, CONFIG_SYS_8BIT_BOOT_PAR);
  230. }
  231. #else
  232. /* 8 bit boot flash only */
  233. GT_REG_WRITE(DEVICE_BOOT_BANK_PARAMETERS, CONFIG_SYS_8BIT_BOOT_PAR);
  234. #endif
  235. #else /* CONFIG_EVB64260 not defined */
  236. /* We are booting from 16-bit flash.
  237. */
  238. GT_REG_WRITE(DEVICE_BOOT_BANK_PARAMETERS, CONFIG_SYS_16BIT_BOOT_PAR);
  239. #endif
  240. gt_cpu_config();
  241. /* MPP setup */
  242. GT_REG_WRITE(MPP_CONTROL0, CONFIG_SYS_MPP_CONTROL_0);
  243. GT_REG_WRITE(MPP_CONTROL1, CONFIG_SYS_MPP_CONTROL_1);
  244. GT_REG_WRITE(MPP_CONTROL2, CONFIG_SYS_MPP_CONTROL_2);
  245. GT_REG_WRITE(MPP_CONTROL3, CONFIG_SYS_MPP_CONTROL_3);
  246. GT_REG_WRITE(GPP_LEVEL_CONTROL, CONFIG_SYS_GPP_LEVEL_CONTROL);
  247. GT_REG_WRITE(SERIAL_PORT_MULTIPLEX, CONFIG_SYS_SERIAL_PORT_MUX);
  248. return 0;
  249. }
  250. /* various things to do after relocation */
  251. int misc_init_r (void)
  252. {
  253. icache_enable();
  254. #ifdef CONFIG_SYS_L2
  255. l2cache_enable();
  256. #endif
  257. #ifdef CONFIG_MPSC
  258. mpsc_init2();
  259. #endif
  260. #ifdef CONFIG_ZUMA_V2
  261. zuma_mbox_init();
  262. #endif
  263. return (0);
  264. }
  265. void
  266. after_reloc(ulong dest_addr)
  267. {
  268. /* check to see if we booted from the sram. If so, move things
  269. * back to the way they should be. (we're running from main
  270. * memory at this point now */
  271. if (memoryGetDeviceBaseAddress(DEVICE0) == CONFIG_SYS_MONITOR_BASE) {
  272. memoryMapDeviceSpace(DEVICE0, CONFIG_SYS_DEV0_SPACE, CONFIG_SYS_DEV0_SIZE);
  273. memoryMapDeviceSpace(BOOT_DEVICE, CONFIG_SYS_FLASH_BASE, _1M);
  274. }
  275. /* now, jump to the main U-Boot board init code */
  276. board_init_r ((gd_t *)gd, dest_addr);
  277. /* NOTREACHED */
  278. }
  279. /* ------------------------------------------------------------------------- */
  280. /*
  281. * Check Board Identity:
  282. */
  283. int
  284. checkboard (void)
  285. {
  286. puts ("Board: " CONFIG_SYS_BOARD_NAME "\n");
  287. return (0);
  288. }
  289. /* utility functions */
  290. void
  291. debug_led(int led, int mode)
  292. {
  293. #if !defined(CONFIG_ZUMA_V2) && !defined(CONFIG_P3G4)
  294. volatile int *addr = NULL;
  295. int dummy;
  296. if (mode == 1) {
  297. switch (led) {
  298. case 0:
  299. addr = (int *)((unsigned int)CONFIG_SYS_DEV1_SPACE | 0x08000);
  300. break;
  301. case 1:
  302. addr = (int *)((unsigned int)CONFIG_SYS_DEV1_SPACE | 0x0c000);
  303. break;
  304. case 2:
  305. addr = (int *)((unsigned int)CONFIG_SYS_DEV1_SPACE | 0x10000);
  306. break;
  307. }
  308. } else if (mode == 0) {
  309. switch (led) {
  310. case 0:
  311. addr = (int *)((unsigned int)CONFIG_SYS_DEV1_SPACE | 0x14000);
  312. break;
  313. case 1:
  314. addr = (int *)((unsigned int)CONFIG_SYS_DEV1_SPACE | 0x18000);
  315. break;
  316. case 2:
  317. addr = (int *)((unsigned int)CONFIG_SYS_DEV1_SPACE | 0x1c000);
  318. break;
  319. }
  320. }
  321. WRITE_CHAR(addr, 0);
  322. dummy = *addr;
  323. #endif /* CONFIG_ZUMA_V2 */
  324. }
  325. void
  326. display_mem_map(void)
  327. {
  328. int i,j;
  329. unsigned int base,size,width;
  330. /* SDRAM */
  331. printf("SDRAM\n");
  332. for(i=0;i<=BANK3;i++) {
  333. base = memoryGetBankBaseAddress(i);
  334. size = memoryGetBankSize(i);
  335. if(size !=0)
  336. {
  337. printf("BANK%d: base - 0x%08x\tsize - %dM bytes\n",i,base,size>>20);
  338. }
  339. }
  340. /* CPU's PCI windows */
  341. for(i=0;i<=PCI_HOST1;i++) {
  342. printf("\nCPU's PCI %d windows\n", i);
  343. base=pciGetSpaceBase(i,PCI_IO);
  344. size=pciGetSpaceSize(i,PCI_IO);
  345. printf(" IO: base - 0x%08x\tsize - %dM bytes\n",base,size>>20);
  346. for(j=0;j<=PCI_REGION3;j++) {
  347. base = pciGetSpaceBase(i,j);
  348. size = pciGetSpaceSize(i,j);
  349. printf("MEMORY %d: base - 0x%08x\tsize - %dM bytes\n",j,base,
  350. size>>20);
  351. }
  352. }
  353. /* Devices */
  354. printf("\nDEVICES\n");
  355. for(i=0;i<=DEVICE3;i++) {
  356. base = memoryGetDeviceBaseAddress(i);
  357. size = memoryGetDeviceSize(i);
  358. width= memoryGetDeviceWidth(i) * 8;
  359. printf("DEV %d: base - 0x%08x\tsize - %dM bytes\twidth - %d bits\n",
  360. i, base, size>>20, width);
  361. }
  362. /* Bootrom */
  363. base = memoryGetDeviceBaseAddress(BOOT_DEVICE); /* Boot */
  364. size = memoryGetDeviceSize(BOOT_DEVICE);
  365. width= memoryGetDeviceWidth(BOOT_DEVICE) * 8;
  366. printf(" BOOT: base - 0x%08x\tsize - %dM bytes\twidth - %d bits\n",
  367. base, size>>20, width);
  368. }
  369. int board_eth_init(bd_t *bis)
  370. {
  371. gt6426x_eth_initialize(bis);
  372. return 0;
  373. }