spl.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (C) 2016 Compulab, Ltd.
  4. */
  5. #include <common.h>
  6. #include <spl.h>
  7. #include <i2c.h>
  8. #include <asm/arch/clock.h>
  9. #include <asm/arch/ddr_defs.h>
  10. #include <asm/gpio.h>
  11. #include <power/pmic.h>
  12. #include <power/tps65218.h>
  13. #include "board.h"
  14. const struct dpll_params dpll_mpu = { 800, 24, 1, -1, -1, -1, -1 };
  15. const struct dpll_params dpll_core = { 1000, 24, -1, -1, 10, 8, 4 };
  16. const struct dpll_params dpll_per = { 960, 24, 5, -1, -1, -1, -1 };
  17. const struct dpll_params dpll_ddr = { 400, 23, 1, -1, 1, -1, -1 };
  18. const struct ctrl_ioregs ioregs_ddr3 = {
  19. .cm0ioctl = DDR3_ADDRCTRL_IOCTRL_VALUE,
  20. .cm1ioctl = DDR3_ADDRCTRL_WD0_IOCTRL_VALUE,
  21. .cm2ioctl = DDR3_ADDRCTRL_WD1_IOCTRL_VALUE,
  22. .dt0ioctl = DDR3_DATA0_IOCTRL_VALUE,
  23. .dt1ioctl = DDR3_DATA0_IOCTRL_VALUE,
  24. .dt2ioctrl = DDR3_DATA0_IOCTRL_VALUE,
  25. .dt3ioctrl = DDR3_DATA0_IOCTRL_VALUE,
  26. .emif_sdram_config_ext = 0x0143,
  27. };
  28. /* EMIF DDR3 Configurations are different for production AM43X GP EVMs */
  29. struct emif_regs ddr3_emif_regs = {
  30. .sdram_config = 0x638413B2,
  31. .ref_ctrl = 0x00000C30,
  32. .sdram_tim1 = 0xEAAAD4DB,
  33. .sdram_tim2 = 0x266B7FDA,
  34. .sdram_tim3 = 0x107F8678,
  35. .read_idle_ctrl = 0x00050000,
  36. .zq_config = 0x50074BE4,
  37. .temp_alert_config = 0x0,
  38. .emif_ddr_phy_ctlr_1 = 0x0E004008,
  39. .emif_ddr_ext_phy_ctrl_1 = 0x08020080,
  40. .emif_ddr_ext_phy_ctrl_2 = 0x00000066,
  41. .emif_ddr_ext_phy_ctrl_3 = 0x00000091,
  42. .emif_ddr_ext_phy_ctrl_4 = 0x000000B9,
  43. .emif_ddr_ext_phy_ctrl_5 = 0x000000E6,
  44. .emif_rd_wr_exec_thresh = 0x80000405,
  45. .emif_prio_class_serv_map = 0x80000001,
  46. .emif_connect_id_serv_1_map = 0x80000094,
  47. .emif_connect_id_serv_2_map = 0x00000000,
  48. .emif_cos_config = 0x000FFFFF
  49. };
  50. const u32 ext_phy_ctrl_const_base_ddr3[] = {
  51. 0x00000000,
  52. 0x00000044,
  53. 0x00000044,
  54. 0x00000046,
  55. 0x00000046,
  56. 0x00000000,
  57. 0x00000059,
  58. 0x00000077,
  59. 0x00000093,
  60. 0x000000A8,
  61. 0x00000000,
  62. 0x00000019,
  63. 0x00000037,
  64. 0x00000053,
  65. 0x00000068,
  66. 0x00000000,
  67. 0x0,
  68. 0x0,
  69. 0x40000000,
  70. 0x08102040
  71. };
  72. void emif_get_ext_phy_ctrl_const_regs(const u32 **regs, u32 *size)
  73. {
  74. *regs = ext_phy_ctrl_const_base_ddr3;
  75. *size = ARRAY_SIZE(ext_phy_ctrl_const_base_ddr3);
  76. }
  77. const struct dpll_params *get_dpll_ddr_params(void)
  78. {
  79. return &dpll_ddr;
  80. }
  81. const struct dpll_params *get_dpll_mpu_params(void)
  82. {
  83. return &dpll_mpu;
  84. }
  85. const struct dpll_params *get_dpll_core_params(void)
  86. {
  87. return &dpll_core;
  88. }
  89. const struct dpll_params *get_dpll_per_params(void)
  90. {
  91. return &dpll_per;
  92. }
  93. void scale_vcores(void)
  94. {
  95. set_i2c_pin_mux();
  96. i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED, CONFIG_SYS_OMAP24_I2C_SLAVE);
  97. if (i2c_probe(TPS65218_CHIP_PM))
  98. return;
  99. tps65218_voltage_update(TPS65218_DCDC1, TPS65218_DCDC_VOLT_SEL_1100MV);
  100. tps65218_voltage_update(TPS65218_DCDC2, TPS65218_DCDC_VOLT_SEL_1100MV);
  101. }
  102. void sdram_init(void)
  103. {
  104. unsigned long ram_size;
  105. config_ddr(0, &ioregs_ddr3, NULL, NULL, &ddr3_emif_regs, 0);
  106. ram_size = get_ram_size((long int *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
  107. if (ram_size == 0x80000000 ||
  108. ram_size == 0x40000000 ||
  109. ram_size == 0x20000000)
  110. return;
  111. ddr3_emif_regs.sdram_config = 0x638453B2;
  112. config_ddr(0, &ioregs_ddr3, NULL, NULL, &ddr3_emif_regs, 0);
  113. ram_size = get_ram_size((long int *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
  114. if (ram_size == 0x08000000)
  115. return;
  116. hang();
  117. }