m5275evb.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*
  2. * (C) Copyright 2000-2003
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. *
  5. * Copyright (C) 2005-2008 Arthur Shipkowski (art@videon-central.com)
  6. *
  7. * See file CREDITS for list of people who contributed to this
  8. * project.
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License as
  12. * published by the Free Software Foundation; either version 2 of
  13. * the License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  23. * MA 02111-1307 USA
  24. */
  25. #include <common.h>
  26. #include <asm/immap.h>
  27. #define PERIOD 13 /* system bus period in ns */
  28. #define SDRAM_TREFI 7800 /* in ns */
  29. int checkboard(void)
  30. {
  31. puts("Board: ");
  32. puts("Freescale MCF5275 EVB\n");
  33. return 0;
  34. };
  35. phys_size_t initdram(int board_type)
  36. {
  37. volatile sdramctrl_t *sdp = (sdramctrl_t *)(MMAP_SDRAM);
  38. volatile gpio_t *gpio_reg = (gpio_t *)(MMAP_GPIO);
  39. gpio_reg->par_sdram = 0x3FF; /* Enable SDRAM */
  40. /* Set up chip select */
  41. sdp->sdbar0 = CONFIG_SYS_SDRAM_BASE;
  42. sdp->sdbmr0 = MCF_SDRAMC_SDMRn_BAM_32M | MCF_SDRAMC_SDMRn_V;
  43. /* Set up timing */
  44. sdp->sdcfg1 = 0x83711630;
  45. sdp->sdcfg2 = 0x46770000;
  46. /* Enable clock */
  47. sdp->sdcr = MCF_SDRAMC_SDCR_MODE_EN | MCF_SDRAMC_SDCR_CKE;
  48. /* Set precharge */
  49. sdp->sdcr |= MCF_SDRAMC_SDCR_IPALL;
  50. /* Dummy write to start SDRAM */
  51. *((volatile unsigned long *)CONFIG_SYS_SDRAM_BASE) = 0xa5a59696;
  52. /* Send LEMR */
  53. sdp->sdmr = MCF_SDRAMC_SDMR_BNKAD_LEMR
  54. | MCF_SDRAMC_SDMR_AD(0x0)
  55. | MCF_SDRAMC_SDMR_CMD;
  56. *((volatile unsigned long *)CONFIG_SYS_SDRAM_BASE) = 0xa5a59696;
  57. /* Send LMR */
  58. sdp->sdmr = 0x058d0000;
  59. *((volatile unsigned long *)CONFIG_SYS_SDRAM_BASE) = 0xa5a59696;
  60. /* Stop sending commands */
  61. sdp->sdmr &= ~(MCF_SDRAMC_SDMR_CMD);
  62. /* Set precharge */
  63. sdp->sdcr |= MCF_SDRAMC_SDCR_IPALL;
  64. *((volatile unsigned long *)CONFIG_SYS_SDRAM_BASE) = 0xa5a59696;
  65. /* Stop manual precharge, send 2 IREF */
  66. sdp->sdcr &= ~(MCF_SDRAMC_SDCR_IPALL);
  67. sdp->sdcr |= MCF_SDRAMC_SDCR_IREF;
  68. *((volatile unsigned long *)CONFIG_SYS_SDRAM_BASE) = 0xa5a59696;
  69. *((volatile unsigned long *)CONFIG_SYS_SDRAM_BASE) = 0xa5a59696;
  70. /* Write mode register, clear reset DLL */
  71. sdp->sdmr = 0x018d0000;
  72. *((volatile unsigned long *)CONFIG_SYS_SDRAM_BASE) = 0xa5a59696;
  73. /* Stop sending commands */
  74. sdp->sdmr &= ~(MCF_SDRAMC_SDMR_CMD);
  75. sdp->sdcr &= ~(MCF_SDRAMC_SDCR_MODE_EN);
  76. /* Turn on auto refresh, lock SDMR */
  77. sdp->sdcr =
  78. MCF_SDRAMC_SDCR_CKE
  79. | MCF_SDRAMC_SDCR_REF
  80. | MCF_SDRAMC_SDCR_MUX(1)
  81. /* 1 added to round up */
  82. | MCF_SDRAMC_SDCR_RCNT((SDRAM_TREFI/(PERIOD*64)) - 1 + 1)
  83. | MCF_SDRAMC_SDCR_DQS_OE(0x3);
  84. return CONFIG_SYS_SDRAM_SIZE * 1024 * 1024;
  85. };
  86. int testdram(void)
  87. {
  88. /* TODO: XXX XXX XXX */
  89. printf("DRAM test not implemented!\n");
  90. return (0);
  91. }