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