ddr.c 1.5 KB

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