m5249evb.c 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2004
  4. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  5. */
  6. #include <common.h>
  7. #include <command.h>
  8. #include <malloc.h>
  9. #include <asm/immap.h>
  10. DECLARE_GLOBAL_DATA_PTR;
  11. int checkboard (void) {
  12. ulong val;
  13. uchar val8;
  14. puts ("Board: ");
  15. puts("Freescale M5249EVB");
  16. val8 = ((uchar)~((uchar)mbar2_readLong(MCFSIM_GPIO1_READ) >> 4)) & 0xf;
  17. printf(" (Switch=%1X)\n", val8);
  18. /*
  19. * Set LED on
  20. */
  21. val = mbar2_readLong(MCFSIM_GPIO1_OUT) & ~CONFIG_SYS_GPIO1_LED;
  22. mbar2_writeLong(MCFSIM_GPIO1_OUT, val); /* Set LED on */
  23. return 0;
  24. };
  25. int dram_init(void)
  26. {
  27. unsigned long junk = 0xa5a59696;
  28. /*
  29. * Note:
  30. * RC = ([(RefreshTime/#rows) / (1/BusClk)] / 16) - 1
  31. */
  32. #ifdef CONFIG_SYS_FAST_CLK
  33. /*
  34. * Busclk=70MHz, RefreshTime=64ms, #rows=4096 (4K)
  35. * SO=1, NAM=0, COC=0, RTIM=01 (6clk refresh), RC=39
  36. */
  37. mbar_writeShort(MCFSIM_DCR, 0x8239);
  38. #elif CONFIG_SYS_PLL_BYPASS
  39. /*
  40. * Busclk=5.6448MHz, RefreshTime=64ms, #rows=8192 (8K)
  41. * SO=1, NAM=0, COC=0, RTIM=01 (6clk refresh), RC=02
  42. */
  43. mbar_writeShort(MCFSIM_DCR, 0x8202);
  44. #else
  45. /*
  46. * Busclk=36MHz, RefreshTime=64ms, #rows=4096 (4K)
  47. * SO=1, NAM=0, COC=0, RTIM=01 (6clk refresh), RC=22 (562 bus clock cycles)
  48. */
  49. mbar_writeShort(MCFSIM_DCR, 0x8222);
  50. #endif
  51. /*
  52. * SDRAM starts at 0x0000_0000, CASL=10, CBM=010, PS=10 (16bit port),
  53. * PM=1 (continuous page mode)
  54. */
  55. /* RE=0 (keep auto-refresh disabled while setting up registers) */
  56. mbar_writeLong(MCFSIM_DACR0, 0x00003324);
  57. /* BAM=007c (bits 22,21 are bank selects; 256kB blocks) */
  58. mbar_writeLong(MCFSIM_DMR0, 0x01fc0001);
  59. /** Precharge sequence **/
  60. mbar_writeLong(MCFSIM_DACR0, 0x0000332c); /* Set DACR0[IP] (bit 3) */
  61. *((volatile unsigned long *) 0x00) = junk; /* write to a memory location to init. precharge */
  62. udelay(0x10); /* Allow several Precharge cycles */
  63. /** Refresh Sequence **/
  64. mbar_writeLong(MCFSIM_DACR0, 0x0000b324); /* Enable the refresh bit, DACR0[RE] (bit 15) */
  65. udelay(0x7d0); /* Allow gobs of refresh cycles */
  66. /** Mode Register initialization **/
  67. mbar_writeLong(MCFSIM_DACR0, 0x0000b364); /* Enable DACR0[IMRS] (bit 6); RE remains enabled */
  68. *((volatile unsigned long *) 0x800) = junk; /* Access RAM to initialize the mode register */
  69. gd->ram_size = CONFIG_SYS_SDRAM_SIZE * 1024 * 1024;
  70. return 0;
  71. };
  72. int testdram (void) {
  73. /* TODO: XXX XXX XXX */
  74. printf ("DRAM test not implemented!\n");
  75. return (0);
  76. }