memory.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*
  2. * (C) Copyright 2007
  3. * Stefan Roese, DENX Software Engineering, sr@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. /* define DEBUG for debugging output (obviously ;-)) */
  24. #if 0
  25. #define DEBUG
  26. #endif
  27. #include <common.h>
  28. #include <asm/processor.h>
  29. #include <asm/io.h>
  30. #include <asm/gpio.h>
  31. extern void board_pll_init_f(void);
  32. /*
  33. * sdram_init - Dummy implementation for start.S, spd_sdram used on this board!
  34. */
  35. void sdram_init(void)
  36. {
  37. return;
  38. }
  39. #if !defined(CONFIG_NAND_U_BOOT) || defined(CONFIG_NAND_SPL)
  40. static void cram_bcr_write(u32 wr_val)
  41. {
  42. wr_val <<= 2;
  43. /* set CRAM_CRE to 1 */
  44. gpio_write_bit(CFG_GPIO_CRAM_CRE, 1);
  45. /* Write BCR to CRAM on CS1 */
  46. out32(wr_val + 0x00200000, 0);
  47. debug("CRAM VAL: %08x for CS1 ", wr_val + 0x00200000);
  48. /* Write BCR to CRAM on CS2 */
  49. out32(wr_val + 0x02200000, 0);
  50. debug("CRAM VAL: %08x for CS2\n", wr_val + 0x02200000);
  51. sync();
  52. eieio();
  53. /* set CRAM_CRE back to 0 (normal operation) */
  54. gpio_write_bit(CFG_GPIO_CRAM_CRE, 0);
  55. return;
  56. }
  57. #endif
  58. long int initdram(int board_type)
  59. {
  60. #if defined(CONFIG_NAND_SPL)
  61. u32 reg;
  62. /* don't reinit PLL when booting via I2C bootstrap option */
  63. mfsdr(SDR_PINSTP, reg);
  64. if (reg != 0xf0000000)
  65. board_pll_init_f();
  66. #endif
  67. #if !defined(CONFIG_NAND_U_BOOT) || defined(CONFIG_NAND_SPL)
  68. int i;
  69. u32 val;
  70. /* 1. EBC need to program READY, CLK, ADV for ASync mode */
  71. gpio_config(CFG_GPIO_CRAM_CLK, GPIO_OUT, GPIO_SEL, GPIO_OUT_0);
  72. gpio_config(CFG_GPIO_CRAM_ADV, GPIO_OUT, GPIO_SEL, GPIO_OUT_0);
  73. gpio_config(CFG_GPIO_CRAM_CRE, GPIO_OUT, GPIO_SEL, GPIO_OUT_0);
  74. gpio_config(CFG_GPIO_CRAM_WAIT, GPIO_IN, GPIO_SEL, GPIO_OUT_NO_CHG);
  75. /* 2. EBC in Async mode */
  76. mtebc(pb1ap, 0x078F1EC0);
  77. mtebc(pb2ap, 0x078F1EC0);
  78. mtebc(pb1cr, 0x000BC000);
  79. mtebc(pb2cr, 0x020BC000);
  80. /* 3. Set CRAM in Sync mode */
  81. cram_bcr_write(0x7012); /* CRAM burst setting */
  82. /* 4. EBC in Sync mode */
  83. mtebc(pb1ap, 0x9C0201C0);
  84. mtebc(pb2ap, 0x9C0201C0);
  85. /* Set GPIO pins back to alternate function */
  86. gpio_config(CFG_GPIO_CRAM_CLK, GPIO_OUT, GPIO_ALT1, GPIO_OUT_NO_CHG);
  87. gpio_config(CFG_GPIO_CRAM_ADV, GPIO_OUT, GPIO_ALT1, GPIO_OUT_NO_CHG);
  88. /* Config EBC to use RDY */
  89. mfsdr(sdrultra0, val);
  90. mtsdr(sdrultra0, val | SDR_ULTRA0_EBCRDYEN);
  91. /* Wait a short while, since for NAND booting this is too fast */
  92. for (i=0; i<200000; i++)
  93. ;
  94. #endif
  95. return (CFG_MBYTES_RAM << 20);
  96. }
  97. int testdram(void)
  98. {
  99. return (0);
  100. }