m5271evb.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*
  2. * (C) Copyright 2000-2006
  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/immap.h>
  25. int checkboard (void) {
  26. puts ("Board: Freescale M5271EVB\n");
  27. return 0;
  28. };
  29. phys_size_t initdram (int board_type) {
  30. int i;
  31. /* Enable Address lines 23-21 and lower 16bits of data path */
  32. mbar_writeByte(MCF_GPIO_PAR_AD, MCF_GPIO_AD_ADDR23 |
  33. MCF_GPIO_AD_ADDR22 | MCF_GPIO_AD_ADDR21 |
  34. MCF_GPIO_AD_DATAL);
  35. /* Set CS2 pin to be SD_CS0 */
  36. mbar_writeByte(MCF_GPIO_PAR_CS, mbar_readByte(MCF_GPIO_PAR_CS)
  37. | MCF_GPIO_PAR_CS_PAR_CS2);
  38. /* Configure SDRAM Control Pin Assignemnt Register */
  39. mbar_writeByte(MCF_GPIO_PAR_SDRAM, MCF_GPIO_SDRAM_CSSDCS_00 |
  40. MCF_GPIO_SDRAM_SDWE | MCF_GPIO_SDRAM_SCAS |
  41. MCF_GPIO_SDRAM_SRAS | MCF_GPIO_SDRAM_SCKE |
  42. MCF_GPIO_SDRAM_SDCS_11);
  43. asm(" nop");
  44. /*
  45. * Check to see if the SDRAM has already been initialized
  46. * by a run control tool
  47. */
  48. if (!(mbar_readLong(MCF_SDRAMC_DACR0) & MCF_SDRAMC_DACRn_RE)) {
  49. /* Initialize DRAM Control Register: DCR */
  50. mbar_writeShort(MCF_SDRAMC_DCR,
  51. MCF_SDRAMC_DCR_RTIM(2)
  52. | MCF_SDRAMC_DCR_RC(0x2E));
  53. asm(" nop");
  54. /*
  55. * Initialize DACR0
  56. *
  57. * CASL: 01
  58. * CBM: cmd at A20, bank select bits 21 and up
  59. * PS: 32bit port size
  60. */
  61. mbar_writeLong(MCF_SDRAMC_DACR0,
  62. MCF_SDRAMC_DACRn_BA(CONFIG_SYS_SDRAM_BASE>>18)
  63. | MCF_SDRAMC_DACRn_CASL(1)
  64. | MCF_SDRAMC_DACRn_CBM(3)
  65. | MCF_SDRAMC_DACRn_PS(0));
  66. asm(" nop");
  67. /* Initialize DMR0 */
  68. mbar_writeLong(MCF_SDRAMC_DMR0,
  69. MCF_SDRAMC_DMRn_BAM_16M
  70. | MCF_SDRAMC_DMRn_V);
  71. asm(" nop");
  72. /* Set IP bit in DACR */
  73. mbar_writeLong(MCF_SDRAMC_DACR0, mbar_readLong(MCF_SDRAMC_DACR0)
  74. | MCF_SDRAMC_DACRn_IP);
  75. asm(" nop");
  76. /* Wait at least 20ns to allow banks to precharge */
  77. for (i = 0; i < 5; i++)
  78. asm(" nop");
  79. /* Write to this block to initiate precharge */
  80. *(u32 *)(CONFIG_SYS_SDRAM_BASE) = 0xa5a5a5a5;
  81. asm(" nop");
  82. /* Set RE bit in DACR */
  83. mbar_writeLong(MCF_SDRAMC_DACR0, mbar_readLong(MCF_SDRAMC_DACR0)
  84. | MCF_SDRAMC_DACRn_RE);
  85. /* Wait for at least 8 auto refresh cycles to occur */
  86. for (i = 0; i < 2000; i++)
  87. asm(" nop");
  88. /* Finish the configuration by issuing the MRS */
  89. mbar_writeLong(MCF_SDRAMC_DACR0, mbar_readLong(MCF_SDRAMC_DACR0)
  90. | MCF_SDRAMC_DACRn_MRS);
  91. asm(" nop");
  92. /*
  93. * Write to the SDRAM Mode Register A0-A11 = 0x400
  94. *
  95. * Write Burst Mode = Programmed Burst Length
  96. * Op Mode = Standard Op
  97. * CAS Latency = 2
  98. * Burst Type = Sequential
  99. * Burst Length = 1
  100. */
  101. *(u32 *)(CONFIG_SYS_SDRAM_BASE + 0x400) = 0xa5a5a5a5;
  102. asm(" nop");
  103. }
  104. return CONFIG_SYS_SDRAM_SIZE * 1024 * 1024;
  105. };
  106. int testdram (void) {
  107. /* TODO: XXX XXX XXX */
  108. printf ("DRAM test not implemented!\n");
  109. return (0);
  110. }