ddr3_k2hk.c 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. char dimm_name[32];
  18. u32 ddr3_size;
  19. ddr3_get_dimm_params(dimm_name);
  20. printf("Detected SO-DIMM [%s]\n", dimm_name);
  21. if (!strcmp(dimm_name, "18KSF1G72HZ-1G6E2 ")) {
  22. init_pll(&ddr3a_400);
  23. if (cpu_revision() > 0) {
  24. if (cpu_revision() > 1) {
  25. /* PG 2.0 */
  26. /* Reset DDR3A PHY after PLL enabled */
  27. ddr3_reset_ddrphy();
  28. ddr3phy_1600_8g.zq0cr1 |= 0x10000;
  29. ddr3phy_1600_8g.zq1cr1 |= 0x10000;
  30. ddr3phy_1600_8g.zq2cr1 |= 0x10000;
  31. ddr3_init_ddrphy(KS2_DDR3A_DDRPHYC,
  32. &ddr3phy_1600_8g);
  33. } else {
  34. /* PG 1.1 */
  35. ddr3_init_ddrphy(KS2_DDR3A_DDRPHYC,
  36. &ddr3phy_1600_8g);
  37. }
  38. ddr3_init_ddremif(KS2_DDR3A_EMIF_CTRL_BASE,
  39. &ddr3_1600_8g);
  40. printf("DRAM: Capacity 8 GiB (includes reported below)\n");
  41. ddr3_size = 8;
  42. } else {
  43. ddr3_init_ddrphy(KS2_DDR3A_DDRPHYC, &ddr3phy_1600_8g);
  44. ddr3_1600_8g.sdcfg |= 0x1000;
  45. ddr3_init_ddremif(KS2_DDR3A_EMIF_CTRL_BASE,
  46. &ddr3_1600_8g);
  47. printf("DRAM: Capacity 4 GiB (includes reported below)\n");
  48. ddr3_size = 4;
  49. }
  50. } else if (!strcmp(dimm_name, "SQR-SD3T-2G1333SED")) {
  51. init_pll(&ddr3a_333);
  52. if (cpu_revision() > 0) {
  53. if (cpu_revision() > 1) {
  54. /* PG 2.0 */
  55. /* Reset DDR3A PHY after PLL enabled */
  56. ddr3_reset_ddrphy();
  57. ddr3phy_1333_2g.zq0cr1 |= 0x10000;
  58. ddr3phy_1333_2g.zq1cr1 |= 0x10000;
  59. ddr3phy_1333_2g.zq2cr1 |= 0x10000;
  60. ddr3_init_ddrphy(KS2_DDR3A_DDRPHYC,
  61. &ddr3phy_1333_2g);
  62. } else {
  63. /* PG 1.1 */
  64. ddr3_init_ddrphy(KS2_DDR3A_DDRPHYC,
  65. &ddr3phy_1333_2g);
  66. }
  67. ddr3_init_ddremif(KS2_DDR3A_EMIF_CTRL_BASE,
  68. &ddr3_1333_2g);
  69. ddr3_size = 2;
  70. printf("DRAM: 2 GiB");
  71. } else {
  72. ddr3_init_ddrphy(KS2_DDR3A_DDRPHYC, &ddr3phy_1333_2g);
  73. ddr3_1333_2g.sdcfg |= 0x1000;
  74. ddr3_init_ddremif(KS2_DDR3A_EMIF_CTRL_BASE,
  75. &ddr3_1333_2g);
  76. ddr3_size = 1;
  77. printf("DRAM: 1 GiB");
  78. }
  79. } else {
  80. printf("Unknown SO-DIMM. Cannot configure DDR3\n");
  81. while (1)
  82. ;
  83. }
  84. /* Apply the workaround for PG 1.0 and 1.1 Silicons */
  85. if (cpu_revision() <= 1)
  86. ddr3_err_reset_workaround();
  87. return ddr3_size;
  88. }