evb64260.c 11 KB

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