ddr3_k2hk.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * Keystone2: DDR3 initialization
  3. *
  4. * (C) Copyright 2012-2014
  5. * Texas Instruments Incorporated, <www.ti.com>
  6. *
  7. * SPDX-License-Identifier: GPL-2.0+
  8. */
  9. #include <common.h>
  10. #include "ddr3_cfg.h"
  11. #include <asm/arch/ddr3.h>
  12. #include <asm/arch/hardware.h>
  13. struct pll_init_data ddr3a_333 = DDR3_PLL_333(A);
  14. struct pll_init_data ddr3a_400 = DDR3_PLL_400(A);
  15. u32 ddr3_init(void)
  16. {
  17. u32 ddr3_size;
  18. struct ddr3_spd_cb spd_cb;
  19. if (ddr3_get_dimm_params_from_spd(&spd_cb)) {
  20. printf("Sorry, I don't know how to configure DDR3A.\n"
  21. "Bye :(\n");
  22. for (;;)
  23. ;
  24. }
  25. printf("Detected SO-DIMM [%s]\n", spd_cb.dimm_name);
  26. if ((cpu_revision() > 1) ||
  27. (__raw_readl(KS2_RSTCTRL_RSTYPE) & 0x1)) {
  28. printf("DDR3 speed %d\n", spd_cb.ddrspdclock);
  29. if (spd_cb.ddrspdclock == 1600)
  30. init_pll(&ddr3a_400);
  31. else
  32. init_pll(&ddr3a_333);
  33. }
  34. if (cpu_revision() > 0) {
  35. if (cpu_revision() > 1) {
  36. /* PG 2.0 */
  37. /* Reset DDR3A PHY after PLL enabled */
  38. ddr3_reset_ddrphy();
  39. spd_cb.phy_cfg.zq0cr1 |= 0x10000;
  40. spd_cb.phy_cfg.zq1cr1 |= 0x10000;
  41. spd_cb.phy_cfg.zq2cr1 |= 0x10000;
  42. }
  43. ddr3_init_ddrphy(KS2_DDR3A_DDRPHYC, &spd_cb.phy_cfg);
  44. ddr3_init_ddremif(KS2_DDR3A_EMIF_CTRL_BASE, &spd_cb.emif_cfg);
  45. ddr3_size = spd_cb.ddr_size_gbyte;
  46. } else {
  47. ddr3_init_ddrphy(KS2_DDR3A_DDRPHYC, &spd_cb.phy_cfg);
  48. spd_cb.emif_cfg.sdcfg |= 0x1000;
  49. ddr3_init_ddremif(KS2_DDR3A_EMIF_CTRL_BASE, &spd_cb.emif_cfg);
  50. ddr3_size = spd_cb.ddr_size_gbyte / 2;
  51. }
  52. printf("DRAM: %d GiB (includes reported below)\n", ddr3_size);
  53. /* Apply the workaround for PG 1.0 and 1.1 Silicons */
  54. if (cpu_revision() <= 1)
  55. ddr3_err_reset_workaround();
  56. return ddr3_size;
  57. }