g2000.c 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. /*
  2. * (C) Copyright 2004
  3. * Stefan Roese, esd gmbh germany, stefan.roese@esd-electronics.com
  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. #include <common.h>
  24. #include <asm/processor.h>
  25. #include <command.h>
  26. #define MEM_MCOPT1_INIT_VAL 0x00800000
  27. #define MEM_RTR_INIT_VAL 0x04070000
  28. #define MEM_PMIT_INIT_VAL 0x07c00000
  29. #define MEM_MB0CF_INIT_VAL 0x00082001
  30. #define MEM_MB1CF_INIT_VAL 0x04082000
  31. #define MEM_SDTR1_INIT_VAL 0x00854005
  32. #define SDRAM0_CFG_ENABLE 0x80000000
  33. #define CONFIG_SYS_SDRAM_SIZE 0x04000000 /* 64 MB */
  34. int board_early_init_f (void)
  35. {
  36. #if 0 /* test-only */
  37. mtdcr (UIC0SR, 0xFFFFFFFF); /* clear all ints */
  38. mtdcr (UIC0ER, 0x00000000); /* disable all ints */
  39. mtdcr (UIC0CR, 0x00000010);
  40. mtdcr (UIC0PR, 0xFFFF7FF0); /* set int polarities */
  41. mtdcr (UIC0TR, 0x00000010); /* set int trigger levels */
  42. mtdcr (UIC0SR, 0xFFFFFFFF); /* clear all ints */
  43. #else
  44. mtdcr(UIC0SR, 0xFFFFFFFF); /* clear all ints */
  45. mtdcr(UIC0ER, 0x00000000); /* disable all ints */
  46. mtdcr(UIC0CR, 0x00000000); /* set all to be non-critical*/
  47. mtdcr(UIC0PR, 0xFFFFFFF0); /* set int polarities */
  48. mtdcr(UIC0TR, 0x10000000); /* set int trigger levels */
  49. mtdcr(UIC0VCR, 0x00000001); /* set vect base=0,INT0 highest priority*/
  50. mtdcr(UIC0SR, 0xFFFFFFFF); /* clear all ints */
  51. #endif
  52. #if 1 /* test-only */
  53. /*
  54. * EBC Configuration Register: set ready timeout to 512 ebc-clks -> ca. 15 us
  55. */
  56. mtebc (EBC0_CFG, 0xa8400000); /* ebc always driven */
  57. #endif
  58. return 0;
  59. }
  60. int misc_init_f (void)
  61. {
  62. return 0; /* dummy implementation */
  63. }
  64. int misc_init_r (void)
  65. {
  66. #if defined(CONFIG_CMD_NAND)
  67. /*
  68. * Set NAND-FLASH GPIO signals to default
  69. */
  70. out32(GPIO0_OR, in32(GPIO0_OR) & ~(CONFIG_SYS_NAND_CLE | CONFIG_SYS_NAND_ALE));
  71. out32(GPIO0_OR, in32(GPIO0_OR) | CONFIG_SYS_NAND_CE);
  72. #endif
  73. return (0);
  74. }
  75. /*
  76. * Check Board Identity:
  77. */
  78. int checkboard (void)
  79. {
  80. char str[64];
  81. int i = getenv_f("serial#", str, sizeof(str));
  82. puts ("Board: ");
  83. if (i == -1) {
  84. puts ("### No HW ID - assuming G2000");
  85. } else {
  86. puts(str);
  87. }
  88. putc ('\n');
  89. return 0;
  90. }
  91. /* -------------------------------------------------------------------------
  92. G2000 rev B is an embeded design. we don't read for spd of this version.
  93. Doing static SDRAM controller configuration in the following section.
  94. ------------------------------------------------------------------------- */
  95. long int init_sdram_static_settings(void)
  96. {
  97. /* disable memcontroller so updates work */
  98. mtsdram(SDRAM0_CFG, MEM_MCOPT1_INIT_VAL);
  99. mtsdram(SDRAM0_RTR, MEM_RTR_INIT_VAL);
  100. mtsdram(SDRAM0_PMIT, MEM_PMIT_INIT_VAL);
  101. mtsdram(SDRAM0_B0CR, MEM_MB0CF_INIT_VAL);
  102. mtsdram(SDRAM0_B1CR, MEM_MB1CF_INIT_VAL);
  103. mtsdram(SDRAM0_TR, MEM_SDTR1_INIT_VAL);
  104. /* SDRAM have a power on delay, 500 micro should do */
  105. udelay(500);
  106. mtsdram(SDRAM0_CFG, MEM_MCOPT1_INIT_VAL|SDRAM0_CFG_ENABLE);
  107. return (CONFIG_SYS_SDRAM_SIZE); /* CONFIG_SYS_SDRAM_SIZE is in G2000.h */
  108. }
  109. phys_size_t initdram (int board_type)
  110. {
  111. long int ret;
  112. /* flzt, we can still turn this on in the future */
  113. /* #ifdef CONFIG_SPD_EEPROM
  114. ret = spd_sdram ();
  115. #else
  116. ret = init_sdram_static_settings();
  117. #endif
  118. */
  119. ret = init_sdram_static_settings();
  120. return ret;
  121. }
  122. #if 0 /* test-only !!! */
  123. int do_dumpebc(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  124. {
  125. ulong ap, cr;
  126. printf("\nEBC registers for PPC405GP:\n");
  127. mfebc(PB0AP, ap); mfebc(PB0CR, cr);
  128. printf("0: AP=%08lx CP=%08lx\n", ap, cr);
  129. mfebc(PB1AP, ap); mfebc(PB1CR, cr);
  130. printf("1: AP=%08lx CP=%08lx\n", ap, cr);
  131. mfebc(PB2AP, ap); mfebc(PB2CR, cr);
  132. printf("2: AP=%08lx CP=%08lx\n", ap, cr);
  133. mfebc(PB3AP, ap); mfebc(PB3CR, cr);
  134. printf("3: AP=%08lx CP=%08lx\n", ap, cr);
  135. mfebc(PB4AP, ap); mfebc(PB4CR, cr);
  136. printf("4: AP=%08lx CP=%08lx\n", ap, cr);
  137. printf("\n");
  138. return 0;
  139. }
  140. U_BOOT_CMD(
  141. dumpebc, 1, 1, do_dumpebc,
  142. "Dump all EBC registers",
  143. ""
  144. );
  145. int do_dumpdcr(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  146. {
  147. int i;
  148. printf("\nDevice Configuration Registers (DCR's) for PPC405GP:");
  149. for (i=0; i<=0x1e0; i++) {
  150. if (!(i % 0x8)) {
  151. printf("\n%04x ", i);
  152. }
  153. printf("%08lx ", get_dcr(i));
  154. }
  155. printf("\n");
  156. return 0;
  157. }
  158. U_BOOT_CMD(
  159. dumpdcr, 1, 1, do_dumpdcr,
  160. "Dump all DCR registers",
  161. ""
  162. );
  163. int do_dumpspr(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  164. {
  165. printf("\nSpecial Purpose Registers (SPR's) for PPC405GP:");
  166. printf("\n%04x %08x ", 947, mfspr(947));
  167. printf("\n%04x %08x ", 9, mfspr(9));
  168. printf("\n%04x %08x ", 1014, mfspr(1014));
  169. printf("\n%04x %08x ", 1015, mfspr(1015));
  170. printf("\n%04x %08x ", 1010, mfspr(1010));
  171. printf("\n%04x %08x ", 957, mfspr(957));
  172. printf("\n%04x %08x ", 1008, mfspr(1008));
  173. printf("\n%04x %08x ", 1018, mfspr(1018));
  174. printf("\n%04x %08x ", 954, mfspr(954));
  175. printf("\n%04x %08x ", 950, mfspr(950));
  176. printf("\n%04x %08x ", 951, mfspr(951));
  177. printf("\n%04x %08x ", 981, mfspr(981));
  178. printf("\n%04x %08x ", 980, mfspr(980));
  179. printf("\n%04x %08x ", 982, mfspr(982));
  180. printf("\n%04x %08x ", 1012, mfspr(1012));
  181. printf("\n%04x %08x ", 1013, mfspr(1013));
  182. printf("\n%04x %08x ", 948, mfspr(948));
  183. printf("\n%04x %08x ", 949, mfspr(949));
  184. printf("\n%04x %08x ", 1019, mfspr(1019));
  185. printf("\n%04x %08x ", 979, mfspr(979));
  186. printf("\n%04x %08x ", 8, mfspr(8));
  187. printf("\n%04x %08x ", 945, mfspr(945));
  188. printf("\n%04x %08x ", 987, mfspr(987));
  189. printf("\n%04x %08x ", 287, mfspr(287));
  190. printf("\n%04x %08x ", 953, mfspr(953));
  191. printf("\n%04x %08x ", 955, mfspr(955));
  192. printf("\n%04x %08x ", 272, mfspr(272));
  193. printf("\n%04x %08x ", 273, mfspr(273));
  194. printf("\n%04x %08x ", 274, mfspr(274));
  195. printf("\n%04x %08x ", 275, mfspr(275));
  196. printf("\n%04x %08x ", 260, mfspr(260));
  197. printf("\n%04x %08x ", 276, mfspr(276));
  198. printf("\n%04x %08x ", 261, mfspr(261));
  199. printf("\n%04x %08x ", 277, mfspr(277));
  200. printf("\n%04x %08x ", 262, mfspr(262));
  201. printf("\n%04x %08x ", 278, mfspr(278));
  202. printf("\n%04x %08x ", 263, mfspr(263));
  203. printf("\n%04x %08x ", 279, mfspr(279));
  204. printf("\n%04x %08x ", 26, mfspr(26));
  205. printf("\n%04x %08x ", 27, mfspr(27));
  206. printf("\n%04x %08x ", 990, mfspr(990));
  207. printf("\n%04x %08x ", 991, mfspr(991));
  208. printf("\n%04x %08x ", 956, mfspr(956));
  209. printf("\n%04x %08x ", 284, mfspr(284));
  210. printf("\n%04x %08x ", 285, mfspr(285));
  211. printf("\n%04x %08x ", 986, mfspr(986));
  212. printf("\n%04x %08x ", 984, mfspr(984));
  213. printf("\n%04x %08x ", 256, mfspr(256));
  214. printf("\n%04x %08x ", 1, mfspr(1));
  215. printf("\n%04x %08x ", 944, mfspr(944));
  216. printf("\n");
  217. return 0;
  218. }
  219. U_BOOT_CMD(
  220. dumpspr, 1, 1, do_dumpspr,
  221. "Dump all SPR registers",
  222. ""
  223. );
  224. #endif