ddr.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * Copyright 2008 Freescale Semiconductor, Inc.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * Version 2 as published by the Free Software Foundation.
  7. */
  8. #include <common.h>
  9. #include <asm/fsl_ddr_sdram.h>
  10. #include <asm/fsl_ddr_dimm_params.h>
  11. void fsl_ddr_board_options(memctl_options_t *popts,
  12. dimm_params_t *pdimm,
  13. unsigned int ctrl_num)
  14. {
  15. /*
  16. * Factors to consider for clock adjust:
  17. * - number of chips on bus
  18. * - position of slot
  19. * - DDR1 vs. DDR2?
  20. * - ???
  21. *
  22. * This needs to be determined on a board-by-board basis.
  23. * 0110 3/4 cycle late
  24. * 0111 7/8 cycle late
  25. */
  26. popts->clk_adjust = 7;
  27. /*
  28. * Factors to consider for CPO:
  29. * - frequency
  30. * - ddr1 vs. ddr2
  31. */
  32. popts->cpo_override = 10;
  33. /*
  34. * Factors to consider for write data delay:
  35. * - number of DIMMs
  36. *
  37. * 1 = 1/4 clock delay
  38. * 2 = 1/2 clock delay
  39. * 3 = 3/4 clock delay
  40. * 4 = 1 clock delay
  41. * 5 = 5/4 clock delay
  42. * 6 = 3/2 clock delay
  43. */
  44. popts->write_data_delay = 3;
  45. /*
  46. * Factors to consider for half-strength driver enable:
  47. * - number of DIMMs installed
  48. */
  49. popts->half_strength_driver_enable = 0;
  50. }
  51. #if !defined(CONFIG_SPD_EEPROM)
  52. /*
  53. * fixed_sdram init -- doesn't use serial presence detect.
  54. * Assumes 256MB DDR2 SDRAM SODIMM, without ECC, running at DDR400 speed.
  55. */
  56. phys_size_t fixed_sdram(void)
  57. {
  58. volatile ccsr_ddr_t *ddr = (void *)(CONFIG_SYS_MPC85xx_DDR_ADDR);
  59. out_be32(&ddr->cs0_bnds, 0x0000007f);
  60. out_be32(&ddr->cs1_bnds, 0x008000ff);
  61. out_be32(&ddr->cs2_bnds, 0x00000000);
  62. out_be32(&ddr->cs3_bnds, 0x00000000);
  63. out_be32(&ddr->cs0_config, 0x80010101);
  64. out_be32(&ddr->cs1_config, 0x80010101);
  65. out_be32(&ddr->cs2_config, 0x00000000);
  66. out_be32(&ddr->cs3_config, 0x00000000);
  67. out_be32(&ddr->timing_cfg_3, 0x00000000);
  68. out_be32(&ddr->timing_cfg_0, 0x00220802);
  69. out_be32(&ddr->timing_cfg_1, 0x38377322);
  70. out_be32(&ddr->timing_cfg_2, 0x0fa044C7);
  71. out_be32(&ddr->sdram_cfg, 0x4300C000);
  72. out_be32(&ddr->sdram_cfg_2, 0x24401000);
  73. out_be32(&ddr->sdram_mode, 0x23C00542);
  74. out_be32(&ddr->sdram_mode_2, 0x00000000);
  75. out_be32(&ddr->sdram_interval, 0x05080100);
  76. out_be32(&ddr->sdram_md_cntl, 0x00000000);
  77. out_be32(&ddr->sdram_data_init, 0x00000000);
  78. out_be32(&ddr->sdram_clk_cntl, 0x03800000);
  79. asm("sync;isync;msync");
  80. udelay(500);
  81. #ifdef CONFIG_DDR_ECC
  82. /* Enable ECC checking */
  83. out_be32(&ddr->sdram_cfg, CONFIG_SYS_DDR_CONTROL | 0x20000000);
  84. #else
  85. out_be32(&ddr->sdram_cfg, CONFIG_SYS_DDR_CONTROL);
  86. #endif
  87. return CONFIG_SYS_SDRAM_SIZE * 1024 * 1024;
  88. }
  89. #endif