ddr.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * Copyright 2008 Freescale Semiconductor, Inc.
  3. *
  4. * SPDX-License-Identifier: GPL-2.0
  5. */
  6. #include <common.h>
  7. #include <i2c.h>
  8. #include <fsl_ddr_sdram.h>
  9. #include <fsl_ddr_dimm_params.h>
  10. void get_spd(ddr2_spd_eeprom_t *spd, unsigned char i2c_address)
  11. {
  12. i2c_read(i2c_address, 0, 1, (uchar *)spd, sizeof(ddr2_spd_eeprom_t));
  13. /* We use soldered memory, but use an SPD EEPROM to describe it.
  14. * The SPD has an unspecified dimm type, but the DDR2 initialization
  15. * code requires a specific type to be specified. This sets the type
  16. * as a standard unregistered SO-DIMM. */
  17. if (spd->dimm_type == 0) {
  18. spd->dimm_type = 0x4;
  19. ((uchar *)spd)[63] += 0x4;
  20. }
  21. }
  22. void fsl_ddr_board_options(memctl_options_t *popts,
  23. dimm_params_t *pdimm,
  24. unsigned int ctrl_num)
  25. {
  26. /*
  27. * Factors to consider for clock adjust:
  28. * - number of chips on bus
  29. * - position of slot
  30. * - DDR1 vs. DDR2?
  31. * - ???
  32. *
  33. * This needs to be determined on a board-by-board basis.
  34. * 0110 3/4 cycle late
  35. * 0111 7/8 cycle late
  36. */
  37. popts->clk_adjust = 7;
  38. /*
  39. * Factors to consider for CPO:
  40. * - frequency
  41. * - ddr1 vs. ddr2
  42. */
  43. popts->cpo_override = 9;
  44. /*
  45. * Factors to consider for write data delay:
  46. * - number of DIMMs
  47. *
  48. * 1 = 1/4 clock delay
  49. * 2 = 1/2 clock delay
  50. * 3 = 3/4 clock delay
  51. * 4 = 1 clock delay
  52. * 5 = 5/4 clock delay
  53. * 6 = 3/2 clock delay
  54. */
  55. popts->write_data_delay = 3;
  56. /*
  57. * Factors to consider for half-strength driver enable:
  58. * - number of DIMMs installed
  59. */
  60. popts->half_strength_driver_enable = 0;
  61. }