ddr.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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(ddr1_spd_eeprom_t *spd, unsigned char i2c_address)
  14. {
  15. i2c_read(i2c_address, 0, 1, (uchar *)spd, sizeof(ddr1_spd_eeprom_t));
  16. }
  17. void
  18. fsl_ddr_get_spd(ddr1_spd_eeprom_t *ctrl_dimms_spd,
  19. unsigned int ctrl_num)
  20. {
  21. unsigned int i;
  22. unsigned int i2c_address = 0;
  23. for (i = 0; i < CONFIG_DIMM_SLOTS_PER_CTLR; i++) {
  24. if (ctrl_num == 0 && i == 0) {
  25. i2c_address = SPD_EEPROM_ADDRESS;
  26. }
  27. get_spd(&(ctrl_dimms_spd[i]), i2c_address);
  28. }
  29. }
  30. void fsl_ddr_board_options(memctl_options_t *popts,
  31. dimm_params_t *pdimm,
  32. unsigned int ctrl_num)
  33. {
  34. /*
  35. * Factors to consider for CPO:
  36. * - frequency
  37. * - ddr1 vs. ddr2
  38. */
  39. popts->cpo_override = 0;
  40. /*
  41. * Factors to consider for write data delay:
  42. * - number of DIMMs
  43. *
  44. * 1 = 1/4 clock delay
  45. * 2 = 1/2 clock delay
  46. * 3 = 3/4 clock delay
  47. * 4 = 1 clock delay
  48. * 5 = 5/4 clock delay
  49. * 6 = 3/2 clock delay
  50. */
  51. popts->write_data_delay = 3;
  52. /* 2T timing enable */
  53. popts->twoT_en = 1;
  54. /*
  55. * Factors to consider for half-strength driver enable:
  56. * - number of DIMMs installed
  57. */
  58. popts->half_strength_driver_enable = 0;
  59. }