v37.c 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. /*
  2. * (C) Copyright 2003
  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. /*
  24. * Yoo. Jonghoon, IPone, yooth@ipone.co.kr
  25. * U-Boot port on RPXlite board
  26. *
  27. * DRAM related UPMA register values are modified.
  28. * See RPXLite engineering note : 50MHz/60ns - UPM RAM WORDS
  29. */
  30. #include <common.h>
  31. #include "mpc8xx.h"
  32. /* ------------------------------------------------------------------------- */
  33. static long int dram_size (void);
  34. /* ------------------------------------------------------------------------- */
  35. #define MBYTE (1024*1024)
  36. #define DRAM_DELAY 0x00000379 /* DRAM delay count */
  37. #define _NOT_USED_ 0xFFFFCC25
  38. const uint sdram_table[] =
  39. {
  40. /* single read. (offset 0 in upm RAM) */
  41. 0x1F07D004, 0xEEAEE004, 0x11ADD004, 0xEFBBA000,
  42. 0x1FF75447, 0x1FF77C34, 0xEFEABC34, 0x1FB57C35,
  43. /* burst read. (Offset 8 in upm RAM) */
  44. 0x1F07D004, 0xEEAEE004, 0x00ADC004, 0x00AFC000,
  45. 0x00AFC000, 0x01AFC000, 0x0FBB8000, 0x1FF75447,
  46. 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
  47. 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
  48. /* single write. (Offset 0x18 in upm RAM) */
  49. 0x1F27D004, 0xEEAEA000, 0x01B90004, 0x1FF75447,
  50. 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
  51. /* burst write. (Offset 0x20 in upm RAM) */
  52. 0x1F07D004, 0xEEAEA000, 0x00AD4000, 0x00AFC000,
  53. 0x00AFC000, 0x01BB8004, 0x1FF75447, 0xFFFFFFFF,
  54. 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
  55. 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
  56. /* Refresh cycle, offset 0x30 */
  57. 0x1FF5DC84, 0xFFFFFC04, 0xFFFFFC04, 0xFFFFFC04,
  58. 0xFFFFFC84, 0xFFFFFC07, 0xFFFFFFFF, 0xFFFFFFFF,
  59. 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
  60. /* Exception, 0ffset 0x3C */
  61. 0x7FFFFC07, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
  62. };
  63. /* ------------------------------------------------------------------------- */
  64. /*
  65. * Check Board Identity:
  66. *
  67. * Return 1 for now.
  68. *
  69. */
  70. int checkboard (void)
  71. {
  72. printf("Marel V37\n") ;
  73. return (0) ;
  74. }
  75. /* ------------------------------------------------------------------------- */
  76. long int initdram (int board_type)
  77. {
  78. volatile immap_t *immap = (immap_t *)CFG_IMMR;
  79. volatile memctl8xx_t *memctl = &immap->im_memctl;
  80. unsigned long temp;
  81. volatile int delay_cnt;
  82. long int ramsize;
  83. ramsize = dram_size();
  84. /* Refresh clock prescalar */
  85. memctl->memc_mptpr = 0x400 ;
  86. if( ramsize == 32*MBYTE )
  87. temp = 0xd0904110;
  88. else /* 16MB */
  89. temp = 0xd0802110;
  90. memctl->memc_mbmr = temp;
  91. upmconfig(UPMB, (uint *)sdram_table, sizeof(sdram_table)/sizeof(uint));
  92. /* Map controller banks 2 to the SDRAM bank */
  93. memctl->memc_or2 = 0xA00 | (0 - ramsize);
  94. memctl->memc_br2 = 0xC1;
  95. memctl->memc_mbmr = temp | 0x08;
  96. memctl->memc_mcr = 0x80804130;
  97. delay_cnt = 0;
  98. while( delay_cnt++ < DRAM_DELAY )
  99. ;
  100. /* Run MRS command in location 5-8 of UPMB */
  101. memctl->memc_mbmr = temp | 0x04;
  102. memctl->memc_mar = 0x88;
  103. memctl->memc_mcr = 0x80804105;
  104. delay_cnt = 0;
  105. while( delay_cnt++ < DRAM_DELAY )
  106. ;
  107. #ifdef CONFIG_CAN_DRIVER
  108. /* Initialize OR3 / BR3 */
  109. memctl->memc_or3 = CFG_OR3_CAN;
  110. memctl->memc_br3 = CFG_BR3_CAN;
  111. /* Initialize MBMR */
  112. memctl->memc_mamr = MAMR_GPL_A4DIS; /* GPL_A4 ouput line Disable */
  113. /* Initialize UPMB for CAN: single read */
  114. memctl->memc_mdr = 0xFFFFC004;
  115. memctl->memc_mcr = 0x0100 | UPMA;
  116. memctl->memc_mdr = 0x0FFFD004;
  117. memctl->memc_mcr = 0x0101 | UPMA;
  118. memctl->memc_mdr = 0x0FFFC000;
  119. memctl->memc_mcr = 0x0102 | UPMA;
  120. memctl->memc_mdr = 0x3FFFC004;
  121. memctl->memc_mcr = 0x0103 | UPMA;
  122. memctl->memc_mdr = 0xFFFFDC05;
  123. memctl->memc_mcr = 0x0104 | UPMA;
  124. /* Initialize UPMB for CAN: single write */
  125. memctl->memc_mdr = 0xFFFCC004;
  126. memctl->memc_mcr = 0x0118 | UPMA;
  127. memctl->memc_mdr = 0xCFFCD004;
  128. memctl->memc_mcr = 0x0119 | UPMA;
  129. memctl->memc_mdr = 0x0FFCC000;
  130. memctl->memc_mcr = 0x011A | UPMA;
  131. memctl->memc_mdr = 0x7FFCC004;
  132. memctl->memc_mcr = 0x011B | UPMA;
  133. memctl->memc_mdr = 0xFFFDCC05;
  134. memctl->memc_mcr = 0x011C | UPMA;
  135. #endif /* CONFIG_CAN_DRIVER */
  136. return (dram_size());
  137. }
  138. /* ------------------------------------------------------------------------- */
  139. /*
  140. * Find size of RAM from configuration pins.
  141. * The input pins that contain the memory size are also the debug port
  142. * pins. Normally they are configured as debug port pins. To be able
  143. * to read the memory configuration, we must deactivate the debug port
  144. * and enable the pcmcia input pins. Then return the register to
  145. * previous state.
  146. */
  147. static long int dram_size ()
  148. {
  149. volatile immap_t *immap = (immap_t *)CFG_IMMR;
  150. volatile sysconf8xx_t *siu = &immap->im_siu_conf;
  151. volatile pcmconf8xx_t *pcm = &immap->im_pcmcia;
  152. long int i, memory=1;
  153. unsigned long siu_mcr;
  154. siu_mcr = siu->sc_siumcr;
  155. siu->sc_siumcr = siu_mcr & 0xFF9FFFFF;
  156. for(i=0; i<10; i++) i = i;
  157. memory = (pcm->pcmc_pipr>>12) & 0x3;
  158. siu->sc_siumcr = siu_mcr;
  159. switch( memory )
  160. {
  161. case 1:
  162. return( 32*MBYTE );
  163. case 2:
  164. return( 64*MBYTE );
  165. default:
  166. break;
  167. }
  168. return( 16*MBYTE );
  169. }