evb64260.c 12 KB

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