kup4x.c 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. /*
  2. * (C) Copyright 2000-2004
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. * Klaus Heydeck, Kieback & Peter GmbH & Co KG, heydeck@kieback-peter.de
  5. *
  6. * See file CREDITS for list of people who contributed to this
  7. * project.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License as
  11. * published by the Free Software Foundation; either version 2 of
  12. * the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  22. * MA 02111-1307 USA
  23. */
  24. #include <common.h>
  25. #include <mpc8xx.h>
  26. #include <post.h>
  27. #include "../common/kup.h"
  28. #include <asm/io.h>
  29. #define _NOT_USED_ 0xFFFFFFFF
  30. const uint sdram_table[] = {
  31. /*
  32. * Single Read. (Offset 0 in UPMA RAM)
  33. */
  34. 0x1F07FC04, 0xEEAEFC04, 0x11ADFC04, 0xEFBBBC00,
  35. 0x1FF77C47, /* last */
  36. /*
  37. * SDRAM Initialization (offset 5 in UPMA RAM)
  38. *
  39. * This is no UPM entry point. The following definition uses
  40. * the remaining space to establish an initialization
  41. * sequence, which is executed by a RUN command.
  42. *
  43. */
  44. 0x1FF77C35, 0xEFEABC34, 0x1FB57C35, /* last */
  45. /*
  46. * Burst Read. (Offset 8 in UPMA RAM)
  47. */
  48. 0x1F07FC04, 0xEEAEFC04, 0x10ADFC04, 0xF0AFFC00,
  49. 0xF0AFFC00, 0xF1AFFC00, 0xEFBBBC00, 0x1FF77C47, /* last */
  50. _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
  51. _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
  52. /*
  53. * Single Write. (Offset 18 in UPMA RAM)
  54. */
  55. 0x1F27FC04, 0xEEAEBC00, 0x01B93C04, 0x1FF77C47, /* last */
  56. _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
  57. /*
  58. * Burst Write. (Offset 20 in UPMA RAM)
  59. */
  60. 0x1F07FC04, 0xEEAEBC00, 0x10AD7C00, 0xF0AFFC00,
  61. 0xF0AFFC00, 0xE1BBBC04, 0x1FF77C47, /* last */
  62. _NOT_USED_,
  63. _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
  64. _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
  65. /*
  66. * Refresh (Offset 30 in UPMA RAM)
  67. */
  68. 0x1FF5FC84, 0xFFFFFC04, 0xFFFFFC04, 0xFFFFFC04,
  69. 0xFFFFFC84, 0xFFFFFC07, /* last */
  70. _NOT_USED_, _NOT_USED_,
  71. _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
  72. /*
  73. * Exception. (Offset 3c in UPMA RAM)
  74. */
  75. 0x7FFFFC07, /* last */
  76. _NOT_USED_, _NOT_USED_, _NOT_USED_,
  77. };
  78. /*
  79. * Check Board Identity:
  80. */
  81. int checkboard(void)
  82. {
  83. volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
  84. volatile memctl8xx_t *memctl = &immap->im_memctl;
  85. uchar latch, rev, mod;
  86. /*
  87. * Init ChipSelect #4 (CAN + HW-Latch)
  88. */
  89. out_be32(&memctl->memc_or4, 0xFFFF8926);
  90. out_be32(&memctl->memc_br4, 0x90000401);
  91. latch = in_8( (unsigned char *) LATCH_ADDR);
  92. rev = (latch & 0xF8) >> 3;
  93. mod = (latch & 0x03);
  94. printf("Board: KUP4X Rev %d.%d\n", rev, mod);
  95. return 0;
  96. }
  97. phys_size_t initdram(int board_type)
  98. {
  99. volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
  100. volatile memctl8xx_t *memctl = &immap->im_memctl;
  101. upmconfig(UPMA, (uint *) sdram_table,
  102. sizeof (sdram_table) / sizeof (uint));
  103. out_be16(&memctl->memc_mptpr, CONFIG_SYS_MPTPR);
  104. out_be32(&memctl->memc_mar, 0x00000088);
  105. out_be32(&memctl->memc_mamr,
  106. CONFIG_SYS_MAMR & (~(MAMR_PTAE))); /* no refresh yet */
  107. udelay(200);
  108. /* perform SDRAM initializsation sequence */
  109. /* SDRAM bank 0 */
  110. out_be32(&memctl->memc_mcr, 0x80002105);
  111. udelay(1);
  112. out_be32(&memctl->memc_mcr, 0x80002830); /* execute twice */
  113. udelay(1);
  114. out_be32(&memctl->memc_mcr, 0x80002106); /* RUN MRS Pattern from loc 6 */
  115. udelay(1);
  116. /* SDRAM bank 1 */
  117. out_be32(&memctl->memc_mcr, 0x80004105);
  118. udelay(1);
  119. out_be32(&memctl->memc_mcr, 0x80004830); /* execute twice */
  120. udelay(1);
  121. out_be32(&memctl->memc_mcr, 0x80004106); /* RUN MRS Pattern from loc 6 */
  122. udelay(1);
  123. /* SDRAM bank 2 */
  124. out_be32(&memctl->memc_mcr, 0x80006105);
  125. udelay(1);
  126. out_be32(&memctl->memc_mcr, 0x80006830); /* execute twice */
  127. udelay(1);
  128. out_be32(&memctl->memc_mcr, 0x80006106); /* RUN MRS Pattern from loc 6 */
  129. udelay(1);
  130. /* SDRAM bank 3 */
  131. out_be32(&memctl->memc_mcr, 0x8000C105);
  132. udelay(1);
  133. out_be32(&memctl->memc_mcr, 0x8000C830); /* execute twice */
  134. udelay(1);
  135. out_be32(&memctl->memc_mcr, 0x8000C106); /* RUN MRS Pattern from loc 6 */
  136. udelay(1);
  137. setbits_be32(&memctl->memc_mamr, MAMR_PTAE); /* enable refresh */
  138. udelay(1000);
  139. /* 4 x 16 MB */
  140. out_be16(&memctl->memc_mptpr, CONFIG_SYS_MPTPR);
  141. udelay(1000);
  142. out_be32(&memctl->memc_or1, 0xFF000A00);
  143. out_be32(&memctl->memc_br1, 0x00000081);
  144. out_be32(&memctl->memc_or2, 0xFE000A00);
  145. out_be32(&memctl->memc_br2, 0x01000081);
  146. out_be32(&memctl->memc_or3, 0xFD000A00);
  147. out_be32(&memctl->memc_br3, 0x02000081);
  148. out_be32(&memctl->memc_or6, 0xFC000A00);
  149. out_be32(&memctl->memc_br6, 0x03000081);
  150. udelay(10000);
  151. return (4 * 16 * 1024 * 1024);
  152. }
  153. int misc_init_r(void)
  154. {
  155. volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
  156. #ifdef CONFIG_IDE_LED
  157. /* Configure PA8 as output port */
  158. setbits_be16(&immap->im_ioport.iop_padir, PA_8);
  159. setbits_be16(&immap->im_ioport.iop_paodr, PA_8);
  160. clrbits_be16(&immap->im_ioport.iop_papar, PA_8);
  161. setbits_be16(&immap->im_ioport.iop_padat, PA_8); /* turn it off */
  162. #endif
  163. load_sernum_ethaddr();
  164. setenv("hw", "4x");
  165. poweron_key();
  166. return 0;
  167. }