mpc8544ds.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. /*
  2. * Copyright 2007 Freescale Semiconductor, Inc.
  3. *
  4. * See file CREDITS for list of people who contributed to this
  5. * project.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  20. * MA 02111-1307 USA
  21. */
  22. #include <common.h>
  23. #include <command.h>
  24. #include <asm/processor.h>
  25. #include <asm/immap_85xx.h>
  26. #include <spd.h>
  27. #include <miiphy.h>
  28. #include "../common/pixis.h"
  29. #if defined(CONFIG_OF_FLAT_TREE)
  30. #include <ft_build.h>
  31. extern void ft_cpu_setup(void *blob, bd_t *bd);
  32. #endif
  33. #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
  34. extern void ddr_enable_ecc(unsigned int dram_size);
  35. #endif
  36. extern long int spd_sdram(void);
  37. void sdram_init(void);
  38. int board_early_init_f (void)
  39. {
  40. return 0;
  41. }
  42. int checkboard (void)
  43. {
  44. volatile immap_t *immap = (immap_t *) CFG_CCSRBAR;
  45. volatile ccsr_gur_t *gur = &immap->im_gur;
  46. if ((uint)&gur->porpllsr != 0xe00e0000) {
  47. printf("immap size error %x\n",&gur->porpllsr);
  48. }
  49. printf ("Board: MPC8544DS\n");
  50. return 0;
  51. }
  52. long int
  53. initdram(int board_type)
  54. {
  55. long dram_size = 0;
  56. puts("Initializing\n");
  57. dram_size = spd_sdram();
  58. #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
  59. /*
  60. * Initialize and enable DDR ECC.
  61. */
  62. ddr_enable_ecc(dram_size);
  63. #endif
  64. puts(" DDR: ");
  65. return dram_size;
  66. }
  67. #if defined(CFG_DRAM_TEST)
  68. int
  69. testdram(void)
  70. {
  71. uint *pstart = (uint *) CFG_MEMTEST_START;
  72. uint *pend = (uint *) CFG_MEMTEST_END;
  73. uint *p;
  74. printf("Testing DRAM from 0x%08x to 0x%08x\n",
  75. CFG_MEMTEST_START,
  76. CFG_MEMTEST_END);
  77. printf("DRAM test phase 1:\n");
  78. for (p = pstart; p < pend; p++)
  79. *p = 0xaaaaaaaa;
  80. for (p = pstart; p < pend; p++) {
  81. if (*p != 0xaaaaaaaa) {
  82. printf ("DRAM test fails at: %08x\n", (uint) p);
  83. return 1;
  84. }
  85. }
  86. printf("DRAM test phase 2:\n");
  87. for (p = pstart; p < pend; p++)
  88. *p = 0x55555555;
  89. for (p = pstart; p < pend; p++) {
  90. if (*p != 0x55555555) {
  91. printf ("DRAM test fails at: %08x\n", (uint) p);
  92. return 1;
  93. }
  94. }
  95. printf("DRAM test passed.\n");
  96. return 0;
  97. }
  98. #endif
  99. int last_stage_init(void)
  100. {
  101. return 0;
  102. }
  103. unsigned long
  104. get_board_sys_clk(ulong dummy)
  105. {
  106. u8 i, go_bit, rd_clks;
  107. ulong val = 0;
  108. go_bit = in8(PIXIS_BASE + PIXIS_VCTL);
  109. go_bit &= 0x01;
  110. rd_clks = in8(PIXIS_BASE + PIXIS_VCFGEN0);
  111. rd_clks &= 0x1C;
  112. /*
  113. * Only if both go bit and the SCLK bit in VCFGEN0 are set
  114. * should we be using the AUX register. Remember, we also set the
  115. * GO bit to boot from the alternate bank on the on-board flash
  116. */
  117. if (go_bit) {
  118. if (rd_clks == 0x1c)
  119. i = in8(PIXIS_BASE + PIXIS_AUX);
  120. else
  121. i = in8(PIXIS_BASE + PIXIS_SPD);
  122. } else {
  123. i = in8(PIXIS_BASE + PIXIS_SPD);
  124. }
  125. i &= 0x07;
  126. switch (i) {
  127. case 0:
  128. val = 33333333;
  129. break;
  130. case 1:
  131. val = 40000000;
  132. break;
  133. case 2:
  134. val = 50000000;
  135. break;
  136. case 3:
  137. val = 66666666;
  138. break;
  139. case 4:
  140. val = 83000000;
  141. break;
  142. case 5:
  143. val = 100000000;
  144. break;
  145. case 6:
  146. val = 133333333;
  147. break;
  148. case 7:
  149. val = 166666666;
  150. break;
  151. }
  152. return val;
  153. }
  154. #if defined(CONFIG_OF_FLAT_TREE) && defined(CONFIG_OF_BOARD_SETUP)
  155. void
  156. ft_board_setup(void *blob, bd_t *bd)
  157. {
  158. u32 *p;
  159. int len;
  160. ft_cpu_setup(blob, bd);
  161. p = ft_get_prop(blob, "/memory/reg", &len);
  162. if (p != NULL) {
  163. *p++ = cpu_to_be32(bd->bi_memstart);
  164. *p = cpu_to_be32(bd->bi_memsize);
  165. }
  166. }
  167. #endif