g2000.c 6.5 KB

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