ddr3_k2e.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Keystone2: DDR3 initialization
  3. *
  4. * (C) Copyright 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. static struct pll_init_data ddr3_400 = DDR3_PLL_400;
  13. u32 ddr3_init(void)
  14. {
  15. u32 ddr3_size;
  16. char dimm_name[32];
  17. if (~(readl(KS2_PLL_CNTRL_BASE + KS2_RSTCTRL_RSTYPE) & 0x1))
  18. init_pll(&ddr3_400);
  19. ddr3_get_dimm_params(dimm_name);
  20. printf("Detected SO-DIMM [%s]\n", dimm_name);
  21. /* Reset DDR3 PHY after PLL enabled */
  22. ddr3_reset_ddrphy();
  23. if (!strcmp(dimm_name, "18KSF1G72HZ-1G6E2 ")) {
  24. /* 8G SO-DIMM */
  25. ddr3_size = 8;
  26. printf("DRAM: 8 GiB\n");
  27. ddr3phy_1600_8g.zq0cr1 |= 0x10000;
  28. ddr3phy_1600_8g.zq1cr1 |= 0x10000;
  29. ddr3phy_1600_8g.zq2cr1 |= 0x10000;
  30. ddr3_init_ddrphy(KS2_DDR3A_DDRPHYC, &ddr3phy_1600_8g);
  31. ddr3_init_ddremif(KS2_DDR3A_EMIF_CTRL_BASE, &ddr3_1600_8g);
  32. } else if (!strcmp(dimm_name, "18KSF51272HZ-1G6K2")) {
  33. /* 4G SO-DIMM */
  34. ddr3_size = 4;
  35. printf("DRAM: 4 GiB\n");
  36. ddr3_init_ddrphy(KS2_DDR3A_DDRPHYC, &ddr3phy_1600_4g);
  37. ddr3_init_ddremif(KS2_DDR3A_EMIF_CTRL_BASE, &ddr3_1600_4g);
  38. } else {
  39. printf("Unknown SO-DIMM. Cannot configure DDR3\n");
  40. while (1)
  41. ;
  42. }
  43. return ddr3_size;
  44. }