uc100.c 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. /*
  2. * (C) Copyright 2000-2004
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  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. #if 0
  24. #define DEBUG
  25. #endif
  26. #include <common.h>
  27. #include <mpc8xx.h>
  28. #include <i2c.h>
  29. /*********************************************************************/
  30. /* UPMA Pre Initilization Table by WV (Miron MT48LC16M16A2-7E B) */
  31. /*********************************************************************/
  32. const uint sdram_init_upm_table[] = {
  33. /* SDRAM Initialisation Sequence (offset 0 in UPMA RAM) WV */
  34. /* NOP - Precharge - AutoRefr - NOP - NOP */
  35. /* NOP - AutoRefr - NOP */
  36. /* NOP - NOP - LoadModeR - NOP - Active */
  37. /* Position of Single Read */
  38. 0x0ffffc04, 0x0ff77c04, 0x0ff5fc04, 0x0ffffc04, 0x0ffffc04,
  39. 0x0ffffc04, 0x0ff5fc04, 0x0ffffc04,
  40. /* Burst Read. (offset 8 in UPMA RAM) */
  41. /* Cycle lent for Initialisation WV */
  42. 0x0ffffc04, 0x0ffffc34, 0x0f057c34, 0x0ffffc30, 0x1ff7fc05,
  43. 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
  44. 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
  45. /* Single Write. (offset 18 in UPMA RAM) */
  46. 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
  47. 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
  48. /* Burst Write. (offset 20 in UPMA RAM) */
  49. 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
  50. 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
  51. 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
  52. /* Refresh (offset 30 in UPMA RAM) */
  53. 0x0FF77C04, 0x0FFFFC04, 0x0FF5FC84, 0x0FFFFC04, 0x0FFFFC04,
  54. 0x0FFFFC84, 0x1FFFFC05, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
  55. 0xFFFFFFFF, 0xFFFFFFFF,
  56. /* Exception. (offset 3c in UPMA RAM) */
  57. 0x7FFFFC05, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
  58. };
  59. /*********************************************************************/
  60. /* UPMA initilization table. */
  61. /*********************************************************************/
  62. const uint sdram_upm_table[] = {
  63. /* single read. (offset 0 in UPMA RAM) */
  64. 0x0F07FC04, 0x0FFFFC04, 0x00BDFC04, 0x0FF77C00, 0x1FFFFC05,
  65. 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, /* 0x05-0x07 new WV */
  66. /* Burst Read. (offset 8 in UPMA RAM) */
  67. 0x0F07FC04, 0x0FFFFC04, 0x00BDFC04, 0x00FFFC00, 0x00FFFC00,
  68. 0x00FFFC00, 0x0FF77C00, 0x1FFFFC05, 0xFFFFFFFF, 0xFFFFFFFF,
  69. 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
  70. /* Single Write. (offset 18 in UPMA RAM) */
  71. 0x0F07FC04, 0x0FFFFC00, 0x00BD7C04, 0x0FFFFC04, 0x0FF77C04,
  72. 0x1FFFFC05, 0xFFFFFFFF, 0xFFFFFFFF,
  73. /* Burst Write. (offset 20 in UPMA RAM) */
  74. 0x0F07FC04, 0x0FFFFC00, 0x00BD7C00, 0x00FFFC00, 0x00FFFC00,
  75. 0x00FFFC04, 0x0FFFFC04, 0x0FF77C04, 0x1FFFFC05, 0xFFFFFFFF,
  76. 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
  77. /* Refresh (offset 30 in UPMA RAM) */
  78. 0x0FF77C04, 0x0FFFFC04, 0x0FF5FC84, 0x0FFFFC04, 0x0FFFFC04,
  79. 0x0FFFFC84, 0x1FFFFC05, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
  80. 0xFFFFFFFF, 0xFFFFFFFF,
  81. /* Exception. (offset 3c in UPMA RAM) */
  82. 0x7FFFFC05, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, /* 0x3C new WV */
  83. };
  84. /*********************************************************************/
  85. /* UPMB initilization table. */
  86. /*********************************************************************/
  87. const uint mpm_upm_table[] = {
  88. /* single read. (offset 0 in upm RAM) */
  89. 0x8FF00004, 0x0FF00004, 0x0FF81004, 0x1FF00001,
  90. 0x1FF00001, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
  91. /* burst read. (Offset 8 in upm RAM) */
  92. 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
  93. 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
  94. 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
  95. 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
  96. /* single write. (Offset 0x18 in upm RAM) */
  97. 0x8FF00004, 0x0FF00004, 0x0FF81004, 0x0FF00004,
  98. 0x0FF00004, 0x1FF00001, 0xFFFFFFFF, 0xFFFFFFFF,
  99. /* burst write. (Offset 0x20 in upm RAM) */
  100. 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
  101. 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
  102. 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
  103. 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
  104. /* Refresh cycle, offset 0x30 */
  105. 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
  106. 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
  107. 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
  108. /* Exception, 0ffset 0x3C */
  109. 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
  110. };
  111. int board_switch(void)
  112. {
  113. volatile pcmconf8xx_t *pcmp;
  114. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
  115. return ((pcmp->pcmc_pipr >> 24) & 0xf);
  116. }
  117. /*
  118. * Check Board Identity:
  119. */
  120. int checkboard (void)
  121. {
  122. unsigned char str[64];
  123. int i = getenv_r ("serial#", str, sizeof(str));
  124. puts ("Board: ");
  125. if (i == -1) {
  126. puts ("### No HW ID - assuming UC100");
  127. } else {
  128. puts(str);
  129. }
  130. printf (" (SWITCH=%1X)\n", board_switch());
  131. return 0;
  132. }
  133. /*
  134. * Initialize SDRAM
  135. */
  136. long int initdram (int board_type)
  137. {
  138. volatile immap_t *immap = (immap_t *) CFG_IMMR;
  139. volatile memctl8xx_t *memctl = &immap->im_memctl;
  140. /*---------------------------------------------------------------------*/
  141. /* Initialize the UPMA/UPMB registers with the appropriate table. */
  142. /*---------------------------------------------------------------------*/
  143. upmconfig (UPMA, (uint *) sdram_init_upm_table,
  144. sizeof (sdram_init_upm_table) / sizeof (uint));
  145. upmconfig (UPMB, (uint *) mpm_upm_table,
  146. sizeof (mpm_upm_table) / sizeof (uint));
  147. /*---------------------------------------------------------------------*/
  148. /* Memory Periodic Timer Prescaler: divide by 16 */
  149. /*---------------------------------------------------------------------*/
  150. memctl->memc_mptpr = 0x0200; /* Divide by 32 WV */
  151. memctl->memc_mamr = CFG_MAMR_VAL & 0xFF7FFFFF; /* Bit 8 := "0" Kein Refresh WV */
  152. memctl->memc_mbmr = CFG_MBMR_VAL;
  153. /*---------------------------------------------------------------------*/
  154. /* Initialize the Memory Controller registers, MPTPR, Chip Select 1 */
  155. /* for SDRAM */
  156. /* */
  157. /* NOTE: The refresh rate in MAMR reg is set according to the lowest */
  158. /* clock rate (16.67MHz) to allow proper operation for all ADS */
  159. /* clock frequencies. */
  160. /*---------------------------------------------------------------------*/
  161. memctl->memc_or1 = CFG_OR1_PRELIM;
  162. memctl->memc_br1 = CFG_BR1_PRELIM;
  163. /*-------------------------------------------------------------------*/
  164. /* Wait at least 200 usec for DRAM to stabilize, this magic number */
  165. /* obtained from the init code. */
  166. /*-------------------------------------------------------------------*/
  167. udelay(200);
  168. memctl->memc_mamr = (memctl->memc_mamr | 0x04) & ~0x08;
  169. memctl->memc_br1 = CFG_BR1_PRELIM;
  170. memctl->memc_or1 = CFG_OR1_PRELIM;
  171. /*---------------------------------------------------------------------*/
  172. /* run MRS command in location 5-8 of UPMB. */
  173. /*---------------------------------------------------------------------*/
  174. memctl->memc_mar = 0x88;
  175. /* RUN UPMA on CS1 1-time from UPMA addr 0x05 */
  176. memctl->memc_mcr = 0x80002100;
  177. /* RUN UPMA on CS1 1-time from UPMA addr 0x00 WV */
  178. udelay(200);
  179. /*---------------------------------------------------------------------*/
  180. /* Initialisation for normal access WV */
  181. /*---------------------------------------------------------------------*/
  182. /*---------------------------------------------------------------------*/
  183. /* Initialize the UPMA register with the appropriate table. */
  184. /*---------------------------------------------------------------------*/
  185. upmconfig (UPMA, (uint *) sdram_upm_table,
  186. sizeof (sdram_upm_table) / sizeof (uint));
  187. /*---------------------------------------------------------------------*/
  188. /* rerstore MBMR value (4-beat refresh burst.) */
  189. /*---------------------------------------------------------------------*/
  190. memctl->memc_mamr = CFG_MAMR_VAL | 0x00800000; /* Bit 8 := "1" Refresh Enable WV */
  191. udelay(200);
  192. return (64 * 1024 * 1024); /* fixed setup for 64MBytes! */
  193. }
  194. int misc_init_r (void)
  195. {
  196. uchar val;
  197. /*
  198. * Make sure that RTC has clock output enabled (triggers watchdog!)
  199. */
  200. val = i2c_reg_read (CFG_I2C_RTC_ADDR, 0x0D);
  201. val |= 0x80;
  202. i2c_reg_write (CFG_I2C_RTC_ADDR, 0x0D, val);
  203. return 0;
  204. }
  205. #ifdef CONFIG_POST
  206. /*
  207. * Returns 1 if keys pressed to start the power-on long-running tests
  208. * Called from board_init_f().
  209. */
  210. int post_hotkeys_pressed (void)
  211. {
  212. return 0; /* No hotkeys supported */
  213. }
  214. #endif