sdram.c 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * (C) Copyright 2006
  3. * Sylvie Gohl, AMCC/IBM, gohl.sylvie@fr.ibm.com
  4. * Jacqueline Pira-Ferriol, AMCC/IBM, jpira-ferriol@fr.ibm.com
  5. * Thierry Roman, AMCC/IBM, thierry_roman@fr.ibm.com
  6. * Alain Saurel, AMCC/IBM, alain.saurel@fr.ibm.com
  7. * Robert Snyder, AMCC/IBM, rob.snyder@fr.ibm.com
  8. *
  9. * (C) Copyright 2006-2007
  10. * Stefan Roese, DENX Software Engineering, sr@denx.de.
  11. *
  12. * SPDX-License-Identifier: GPL-2.0+
  13. */
  14. /* define DEBUG for debug output */
  15. #undef DEBUG
  16. #include <common.h>
  17. #include <asm/processor.h>
  18. #include <asm/io.h>
  19. #include <asm/ppc440.h>
  20. /*-----------------------------------------------------------------------------+
  21. * Prototypes
  22. *-----------------------------------------------------------------------------*/
  23. extern int denali_wait_for_dlllock(void);
  24. extern void denali_core_search_data_eye(void);
  25. /*************************************************************************
  26. *
  27. * initdram -- 440EPx's DDR controller is a DENALI Core
  28. *
  29. ************************************************************************/
  30. phys_size_t initdram (int board_type)
  31. {
  32. #if !defined(CONFIG_SYS_RAMBOOT)
  33. ulong speed = get_bus_freq(0);
  34. mtsdram(DDR0_02, 0x00000000);
  35. mtsdram(DDR0_00, 0x0000190A);
  36. mtsdram(DDR0_01, 0x01000000);
  37. mtsdram(DDR0_03, 0x02030602);
  38. mtsdram(DDR0_04, 0x0A020200);
  39. mtsdram(DDR0_05, 0x02020308);
  40. mtsdram(DDR0_06, 0x0102C812);
  41. mtsdram(DDR0_07, 0x000D0100);
  42. mtsdram(DDR0_08, 0x02430001);
  43. mtsdram(DDR0_09, 0x00011D5F);
  44. mtsdram(DDR0_10, 0x00000100);
  45. mtsdram(DDR0_11, 0x0027C800);
  46. mtsdram(DDR0_12, 0x00000003);
  47. mtsdram(DDR0_14, 0x00000000);
  48. mtsdram(DDR0_17, 0x19000000);
  49. mtsdram(DDR0_18, 0x19191919);
  50. mtsdram(DDR0_19, 0x19191919);
  51. mtsdram(DDR0_20, 0x0B0B0B0B);
  52. mtsdram(DDR0_21, 0x0B0B0B0B);
  53. mtsdram(DDR0_22, 0x00267F0B);
  54. mtsdram(DDR0_23, 0x00000000);
  55. mtsdram(DDR0_24, 0x01010002);
  56. if (speed > 133333334)
  57. mtsdram(DDR0_26, 0x5B26050C);
  58. else
  59. mtsdram(DDR0_26, 0x5B260408);
  60. mtsdram(DDR0_27, 0x0000682B);
  61. mtsdram(DDR0_28, 0x00000000);
  62. mtsdram(DDR0_31, 0x00000000);
  63. mtsdram(DDR0_42, 0x01000006);
  64. mtsdram(DDR0_43, 0x030A0200);
  65. mtsdram(DDR0_44, 0x00000003);
  66. mtsdram(DDR0_02, 0x00000001);
  67. denali_wait_for_dlllock();
  68. #endif /* #ifndef CONFIG_SYS_RAMBOOT */
  69. #ifdef CONFIG_DDR_DATA_EYE
  70. /* -----------------------------------------------------------+
  71. * Perform data eye search if requested.
  72. * ----------------------------------------------------------*/
  73. denali_core_search_data_eye();
  74. #endif
  75. /*
  76. * Clear possible errors resulting from data-eye-search.
  77. * If not done, then we could get an interrupt later on when
  78. * exceptions are enabled.
  79. */
  80. set_mcsr(get_mcsr());
  81. return (CONFIG_SYS_MBYTES_SDRAM << 20);
  82. }