g2000.c 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  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 (uicsr, 0xFFFFFFFF); /* clear all ints */
  38. mtdcr (uicer, 0x00000000); /* disable all ints */
  39. mtdcr (uiccr, 0x00000010);
  40. mtdcr (uicpr, 0xFFFF7FF0); /* set int polarities */
  41. mtdcr (uictr, 0x00000010); /* set int trigger levels */
  42. mtdcr (uicsr, 0xFFFFFFFF); /* clear all ints */
  43. #else
  44. mtdcr(uicsr, 0xFFFFFFFF); /* clear all ints */
  45. mtdcr(uicer, 0x00000000); /* disable all ints */
  46. mtdcr(uiccr, 0x00000000); /* set all to be non-critical*/
  47. mtdcr(uicpr, 0xFFFFFFF0); /* set int polarities */
  48. mtdcr(uictr, 0x10000000); /* set int trigger levels */
  49. mtdcr(uicvcr, 0x00000001); /* set vect base=0,INT0 highest priority*/
  50. mtdcr(uicsr, 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 (epcr, 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_r ("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. #define mtsdram0(reg, data) mtdcr(memcfga,reg);mtdcr(memcfgd,data)
  98. /* disable memcontroller so updates work */
  99. mtsdram0( mem_mcopt1, MEM_MCOPT1_INIT_VAL );
  100. mtsdram0( mem_rtr , MEM_RTR_INIT_VAL );
  101. mtsdram0( mem_pmit , MEM_PMIT_INIT_VAL );
  102. mtsdram0( mem_mb0cf , MEM_MB0CF_INIT_VAL );
  103. mtsdram0( mem_mb1cf , MEM_MB1CF_INIT_VAL );
  104. mtsdram0( mem_sdtr1 , MEM_SDTR1_INIT_VAL );
  105. /* SDRAM have a power on delay, 500 micro should do */
  106. udelay(500);
  107. mtsdram0( mem_mcopt1, MEM_MCOPT1_INIT_VAL|SDRAM0_CFG_ENABLE );
  108. return (CONFIG_SYS_SDRAM_SIZE); /* CONFIG_SYS_SDRAM_SIZE is in G2000.h */
  109. }
  110. phys_size_t initdram (int board_type)
  111. {
  112. long int ret;
  113. /* flzt, we can still turn this on in the future */
  114. /* #ifdef CONFIG_SPD_EEPROM
  115. ret = spd_sdram ();
  116. #else
  117. ret = init_sdram_static_settings();
  118. #endif
  119. */
  120. ret = init_sdram_static_settings();
  121. return ret;
  122. }
  123. #if defined(CONFIG_CMD_NAND)
  124. #include <linux/mtd/nand_legacy.h>
  125. extern struct nand_chip nand_dev_desc[CONFIG_SYS_MAX_NAND_DEVICE];
  126. void nand_init(void)
  127. {
  128. nand_probe(CONFIG_SYS_NAND_BASE);
  129. if (nand_dev_desc[0].ChipID != NAND_ChipID_UNKNOWN) {
  130. print_size(nand_dev_desc[0].totlen, "\n");
  131. }
  132. }
  133. #endif
  134. #if 0 /* test-only !!! */
  135. int do_dumpebc(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  136. {
  137. ulong ap, cr;
  138. printf("\nEBC registers for PPC405GP:\n");
  139. mfebc(pb0ap, ap); mfebc(pb0cr, cr);
  140. printf("0: AP=%08lx CP=%08lx\n", ap, cr);
  141. mfebc(pb1ap, ap); mfebc(pb1cr, cr);
  142. printf("1: AP=%08lx CP=%08lx\n", ap, cr);
  143. mfebc(pb2ap, ap); mfebc(pb2cr, cr);
  144. printf("2: AP=%08lx CP=%08lx\n", ap, cr);
  145. mfebc(pb3ap, ap); mfebc(pb3cr, cr);
  146. printf("3: AP=%08lx CP=%08lx\n", ap, cr);
  147. mfebc(pb4ap, ap); mfebc(pb4cr, cr);
  148. printf("4: AP=%08lx CP=%08lx\n", ap, cr);
  149. printf("\n");
  150. return 0;
  151. }
  152. U_BOOT_CMD(
  153. dumpebc, 1, 1, do_dumpebc,
  154. "Dump all EBC registers",
  155. ""
  156. );
  157. int do_dumpdcr(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  158. {
  159. int i;
  160. printf("\nDevice Configuration Registers (DCR's) for PPC405GP:");
  161. for (i=0; i<=0x1e0; i++) {
  162. if (!(i % 0x8)) {
  163. printf("\n%04x ", i);
  164. }
  165. printf("%08lx ", get_dcr(i));
  166. }
  167. printf("\n");
  168. return 0;
  169. }
  170. U_BOOT_CMD(
  171. dumpdcr, 1, 1, do_dumpdcr,
  172. "Dump all DCR registers",
  173. ""
  174. );
  175. int do_dumpspr(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  176. {
  177. printf("\nSpecial Purpose Registers (SPR's) for PPC405GP:");
  178. printf("\n%04x %08x ", 947, mfspr(947));
  179. printf("\n%04x %08x ", 9, mfspr(9));
  180. printf("\n%04x %08x ", 1014, mfspr(1014));
  181. printf("\n%04x %08x ", 1015, mfspr(1015));
  182. printf("\n%04x %08x ", 1010, mfspr(1010));
  183. printf("\n%04x %08x ", 957, mfspr(957));
  184. printf("\n%04x %08x ", 1008, mfspr(1008));
  185. printf("\n%04x %08x ", 1018, mfspr(1018));
  186. printf("\n%04x %08x ", 954, mfspr(954));
  187. printf("\n%04x %08x ", 950, mfspr(950));
  188. printf("\n%04x %08x ", 951, mfspr(951));
  189. printf("\n%04x %08x ", 981, mfspr(981));
  190. printf("\n%04x %08x ", 980, mfspr(980));
  191. printf("\n%04x %08x ", 982, mfspr(982));
  192. printf("\n%04x %08x ", 1012, mfspr(1012));
  193. printf("\n%04x %08x ", 1013, mfspr(1013));
  194. printf("\n%04x %08x ", 948, mfspr(948));
  195. printf("\n%04x %08x ", 949, mfspr(949));
  196. printf("\n%04x %08x ", 1019, mfspr(1019));
  197. printf("\n%04x %08x ", 979, mfspr(979));
  198. printf("\n%04x %08x ", 8, mfspr(8));
  199. printf("\n%04x %08x ", 945, mfspr(945));
  200. printf("\n%04x %08x ", 987, mfspr(987));
  201. printf("\n%04x %08x ", 287, mfspr(287));
  202. printf("\n%04x %08x ", 953, mfspr(953));
  203. printf("\n%04x %08x ", 955, mfspr(955));
  204. printf("\n%04x %08x ", 272, mfspr(272));
  205. printf("\n%04x %08x ", 273, mfspr(273));
  206. printf("\n%04x %08x ", 274, mfspr(274));
  207. printf("\n%04x %08x ", 275, mfspr(275));
  208. printf("\n%04x %08x ", 260, mfspr(260));
  209. printf("\n%04x %08x ", 276, mfspr(276));
  210. printf("\n%04x %08x ", 261, mfspr(261));
  211. printf("\n%04x %08x ", 277, mfspr(277));
  212. printf("\n%04x %08x ", 262, mfspr(262));
  213. printf("\n%04x %08x ", 278, mfspr(278));
  214. printf("\n%04x %08x ", 263, mfspr(263));
  215. printf("\n%04x %08x ", 279, mfspr(279));
  216. printf("\n%04x %08x ", 26, mfspr(26));
  217. printf("\n%04x %08x ", 27, mfspr(27));
  218. printf("\n%04x %08x ", 990, mfspr(990));
  219. printf("\n%04x %08x ", 991, mfspr(991));
  220. printf("\n%04x %08x ", 956, mfspr(956));
  221. printf("\n%04x %08x ", 284, mfspr(284));
  222. printf("\n%04x %08x ", 285, mfspr(285));
  223. printf("\n%04x %08x ", 986, mfspr(986));
  224. printf("\n%04x %08x ", 984, mfspr(984));
  225. printf("\n%04x %08x ", 256, mfspr(256));
  226. printf("\n%04x %08x ", 1, mfspr(1));
  227. printf("\n%04x %08x ", 944, mfspr(944));
  228. printf("\n");
  229. return 0;
  230. }
  231. U_BOOT_CMD(
  232. dumpspr, 1, 1, do_dumpspr,
  233. "Dump all SPR registers",
  234. ""
  235. );
  236. #endif