uc100.c 9.8 KB

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