ddr.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 <i2c.h>
  10. #include <asm/fsl_ddr_sdram.h>
  11. #include <asm/fsl_ddr_dimm_params.h>
  12. static void
  13. get_spd(ddr2_spd_eeprom_t *spd, unsigned char i2c_address)
  14. {
  15. i2c_read(i2c_address, 0, 1, (uchar *)spd, sizeof(ddr2_spd_eeprom_t));
  16. }
  17. unsigned int fsl_ddr_get_mem_data_rate(void)
  18. {
  19. return get_ddr_freq(0);
  20. }
  21. void fsl_ddr_get_spd(ddr2_spd_eeprom_t *ctrl_dimms_spd,
  22. unsigned int ctrl_num)
  23. {
  24. unsigned int i;
  25. if (ctrl_num) {
  26. printf("%s unexpected ctrl_num = %u\n", __FUNCTION__, ctrl_num);
  27. return;
  28. }
  29. for (i = 0; i < CONFIG_DIMM_SLOTS_PER_CTLR; i++) {
  30. get_spd(&(ctrl_dimms_spd[i]), SPD_EEPROM_ADDRESS);
  31. }
  32. }
  33. void fsl_ddr_board_options(memctl_options_t *popts,
  34. dimm_params_t *pdimm,
  35. unsigned int ctrl_num)
  36. {
  37. /*
  38. * Factors to consider for clock adjust:
  39. * - number of chips on bus
  40. * - position of slot
  41. * - DDR1 vs. DDR2?
  42. * - ???
  43. *
  44. * This needs to be determined on a board-by-board basis.
  45. * 0110 3/4 cycle late
  46. * 0111 7/8 cycle late
  47. */
  48. popts->clk_adjust = 7;
  49. /*
  50. * Factors to consider for CPO:
  51. * - frequency
  52. * - ddr1 vs. ddr2
  53. */
  54. popts->cpo_override = 0;
  55. /*
  56. * Factors to consider for write data delay:
  57. * - number of DIMMs
  58. *
  59. * 1 = 1/4 clock delay
  60. * 2 = 1/2 clock delay
  61. * 3 = 3/4 clock delay
  62. * 4 = 1 clock delay
  63. * 5 = 5/4 clock delay
  64. * 6 = 3/2 clock delay
  65. */
  66. popts->write_data_delay = 3;
  67. /*
  68. * Factors to consider for half-strength driver enable:
  69. * - number of DIMMs installed
  70. */
  71. popts->half_strength_driver_enable = 0;
  72. }