ddr.c 1.7 KB

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