ddr3_k2hk.c 1.6 KB

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