r5200.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*
  2. * (C) Copyright 2000-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. #include <common.h>
  24. #include <asm/m5271.h>
  25. #include <asm/immap_5271.h>
  26. int checkboard (void) {
  27. puts ("Board: R5200 Ethernet Module\n");
  28. return 0;
  29. };
  30. long int initdram (int board_type) {
  31. int i;
  32. /*
  33. * Set CS2 pin to be SD_CS0
  34. */
  35. mbar_writeByte(MCF_GPIO_PAR_CS, mbar_readByte(MCF_GPIO_PAR_CS)
  36. | MCF_GPIO_PAR_CS_PAR_CS2);
  37. mbar_writeByte(MCF_GPIO_PAR_SDRAM, mbar_readByte(MCF_GPIO_PAR_SDRAM)
  38. | MCF_GPIO_PAR_SDRAM_PAR_CSSDCS(0x01));
  39. /*
  40. * Check to see if the SDRAM has already been initialized
  41. * by a run control tool
  42. */
  43. if (!(mbar_readLong(MCF_SDRAMC_DACR0) & MCF_SDRAMC_DACRn_RE)) {
  44. /*
  45. * Initialize DRAM Control Register: DCR
  46. */
  47. mbar_writeShort(MCF_SDRAMC_DCR, MCF_SDRAMC_DCR_RTIM(0x01)
  48. | MCF_SDRAMC_DCR_RC(0x30));
  49. /*
  50. * Initialize DACR0
  51. */
  52. mbar_writeLong(MCF_SDRAMC_DACR0,
  53. MCF_SDRAMC_DACRn_BA(CFG_SDRAM_BASE>>18)
  54. | MCF_SDRAMC_DACRn_CASL(0)
  55. | MCF_SDRAMC_DACRn_CBM(3)
  56. | MCF_SDRAMC_DACRn_PS(2));
  57. /*
  58. * Initialize DMR0
  59. */
  60. mbar_writeLong(MCF_SDRAMC_DMR0,
  61. MCF_SDRAMC_DMRn_BAM_8M
  62. | MCF_SDRAMC_DMRn_V);
  63. /*
  64. * Set IP bit in DACR
  65. */
  66. mbar_writeLong(MCF_SDRAMC_DACR0, mbar_readLong(MCF_SDRAMC_DACR0)
  67. | MCF_SDRAMC_DACRn_IP);
  68. /*
  69. * Wait at least 20ns to allow banks to precharge
  70. */
  71. for (i = 0; i < 5; i++)
  72. asm(" nop");
  73. /*
  74. * Write to this block to initiate precharge
  75. */
  76. *(u16 *)(CFG_SDRAM_BASE) = 0x9696;
  77. /*
  78. * Set RE bit in DACR
  79. */
  80. mbar_writeLong(MCF_SDRAMC_DACR0, mbar_readLong(MCF_SDRAMC_DACR0)
  81. | MCF_SDRAMC_DACRn_RE);
  82. /*
  83. * Wait for at least 8 auto refresh cycles to occur
  84. */
  85. for (i = 0; i < 2000; i++)
  86. asm(" nop");
  87. /*
  88. * Finish the configuration by issuing the MRS.
  89. */
  90. mbar_writeLong(MCF_SDRAMC_DACR0, mbar_readLong(MCF_SDRAMC_DACR0)
  91. | MCF_SDRAMC_DACRn_MRS);
  92. /*
  93. * Write to the SDRAM Mode Register
  94. */
  95. *(u16 *)(CFG_SDRAM_BASE + 0x1000) = 0x9696;
  96. }
  97. return CFG_SDRAM_SIZE * 1024 * 1024;
  98. };
  99. int testdram (void) {
  100. /* TODO: XXX XXX XXX */
  101. printf ("DRAM test not implemented!\n");
  102. return (0);
  103. }