m5249evb.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. * (C) Copyright 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. #include <common.h>
  24. #include <command.h>
  25. #include <malloc.h>
  26. #include <asm/immap.h>
  27. /* Prototypes */
  28. int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
  29. int checkboard (void) {
  30. ulong val;
  31. uchar val8;
  32. puts ("Board: ");
  33. puts("Freescale M5249EVB");
  34. val8 = ((uchar)~((uchar)mbar2_readLong(MCFSIM_GPIO1_READ) >> 4)) & 0xf;
  35. printf(" (Switch=%1X)\n", val8);
  36. /*
  37. * Set LED on
  38. */
  39. val = mbar2_readLong(MCFSIM_GPIO1_OUT) & ~CFG_GPIO1_LED;
  40. mbar2_writeLong(MCFSIM_GPIO1_OUT, val); /* Set LED on */
  41. return 0;
  42. };
  43. long int initdram (int board_type) {
  44. unsigned long junk = 0xa5a59696;
  45. /*
  46. * Note:
  47. * RC = ([(RefreshTime/#rows) / (1/BusClk)] / 16) - 1
  48. */
  49. #ifdef CFG_FAST_CLK
  50. /*
  51. * Busclk=70MHz, RefreshTime=64ms, #rows=4096 (4K)
  52. * SO=1, NAM=0, COC=0, RTIM=01 (6clk refresh), RC=39
  53. */
  54. mbar_writeShort(MCFSIM_DCR, 0x8239);
  55. #elif CFG_PLL_BYPASS
  56. /*
  57. * Busclk=5.6448MHz, RefreshTime=64ms, #rows=8192 (8K)
  58. * SO=1, NAM=0, COC=0, RTIM=01 (6clk refresh), RC=02
  59. */
  60. mbar_writeShort(MCFSIM_DCR, 0x8202);
  61. #else
  62. /*
  63. * Busclk=36MHz, RefreshTime=64ms, #rows=4096 (4K)
  64. * SO=1, NAM=0, COC=0, RTIM=01 (6clk refresh), RC=22 (562 bus clock cycles)
  65. */
  66. mbar_writeShort(MCFSIM_DCR, 0x8222);
  67. #endif
  68. /*
  69. * SDRAM starts at 0x0000_0000, CASL=10, CBM=010, PS=10 (16bit port),
  70. * PM=1 (continuous page mode)
  71. */
  72. /* RE=0 (keep auto-refresh disabled while setting up registers) */
  73. mbar_writeLong(MCFSIM_DACR0, 0x00003324);
  74. /* BAM=007c (bits 22,21 are bank selects; 256kB blocks) */
  75. mbar_writeLong(MCFSIM_DMR0, 0x01fc0001);
  76. /** Precharge sequence **/
  77. mbar_writeLong(MCFSIM_DACR0, 0x0000332c); /* Set DACR0[IP] (bit 3) */
  78. *((volatile unsigned long *) 0x00) = junk; /* write to a memory location to init. precharge */
  79. udelay(0x10); /* Allow several Precharge cycles */
  80. /** Refresh Sequence **/
  81. mbar_writeLong(MCFSIM_DACR0, 0x0000b324); /* Enable the refresh bit, DACR0[RE] (bit 15) */
  82. udelay(0x7d0); /* Allow gobs of refresh cycles */
  83. /** Mode Register initialization **/
  84. mbar_writeLong(MCFSIM_DACR0, 0x0000b364); /* Enable DACR0[IMRS] (bit 6); RE remains enabled */
  85. *((volatile unsigned long *) 0x800) = junk; /* Access RAM to initialize the mode register */
  86. return CFG_SDRAM_SIZE * 1024 * 1024;
  87. };
  88. int testdram (void) {
  89. /* TODO: XXX XXX XXX */
  90. printf ("DRAM test not implemented!\n");
  91. return (0);
  92. }