ddr.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright 2010 Freescale Semiconductor, Inc.
  4. * Authors: Srikanth Srinivasan <srikanth.srinivasan@freescale.com>
  5. * Timur Tabi <timur@freescale.com>
  6. */
  7. #include <common.h>
  8. #include <i2c.h>
  9. #include <fsl_ddr_sdram.h>
  10. #include <fsl_ddr_dimm_params.h>
  11. void fsl_ddr_board_options(memctl_options_t *popts, dimm_params_t *pdimm,
  12. unsigned int ctrl_num)
  13. {
  14. unsigned int i;
  15. if (ctrl_num) {
  16. printf("Wrong parameter for controller number %d", ctrl_num);
  17. return;
  18. }
  19. if (!pdimm->n_ranks)
  20. return;
  21. /* set odt_rd_cfg and odt_wr_cfg. */
  22. for (i = 0; i < CONFIG_CHIP_SELECTS_PER_CTRL; i++) {
  23. popts->cs_local_opts[i].odt_rd_cfg = 0;
  24. popts->cs_local_opts[i].odt_wr_cfg = 1;
  25. }
  26. popts->clk_adjust = 5;
  27. popts->cpo_override = 0x1f;
  28. popts->write_data_delay = 2;
  29. popts->half_strength_driver_enable = 1;
  30. /* Per AN4039, enable ZQ calibration. */
  31. popts->zq_en = 1;
  32. }
  33. #ifdef CONFIG_SPD_EEPROM
  34. /*
  35. * we only have a "fake" SPD-EEPROM here, which has 16 bit addresses
  36. */
  37. void get_spd(generic_spd_eeprom_t *spd, u8 i2c_address)
  38. {
  39. int ret = i2c_read(i2c_address, 0, 2, (uchar *)spd,
  40. sizeof(generic_spd_eeprom_t));
  41. if (ret) {
  42. if (i2c_address ==
  43. #ifdef SPD_EEPROM_ADDRESS
  44. SPD_EEPROM_ADDRESS
  45. #elif defined(SPD_EEPROM_ADDRESS1)
  46. SPD_EEPROM_ADDRESS1
  47. #endif
  48. ) {
  49. printf("DDR: failed to read SPD from address %u\n",
  50. i2c_address);
  51. } else {
  52. debug("DDR: failed to read SPD from address %u\n",
  53. i2c_address);
  54. }
  55. memset(spd, 0, sizeof(generic_spd_eeprom_t));
  56. }
  57. }
  58. #endif