maxbcm.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (C) 2014 Stefan Roese <sr@denx.de>
  4. */
  5. #include <common.h>
  6. #include <miiphy.h>
  7. #include <asm/io.h>
  8. #include <asm/arch/cpu.h>
  9. #include <asm/arch/soc.h>
  10. #include <linux/mbus.h>
  11. #include "../drivers/ddr/marvell/axp/ddr3_hw_training.h"
  12. #include "../arch/arm/mach-mvebu/serdes/axp/high_speed_env_spec.h"
  13. DECLARE_GLOBAL_DATA_PTR;
  14. /* Base addresses for the external device chip selects */
  15. #define DEV_CS0_BASE 0xe0000000
  16. #define DEV_CS1_BASE 0xe1000000
  17. #define DEV_CS2_BASE 0xe2000000
  18. #define DEV_CS3_BASE 0xe3000000
  19. /* DDR3 static configuration */
  20. MV_DRAM_MC_INIT ddr3_b0_maxbcm[MV_MAX_DDR3_STATIC_SIZE] = {
  21. {0x00001400, 0x7301CC30}, /* DDR SDRAM Configuration Register */
  22. {0x00001404, 0x30000820}, /* Dunit Control Low Register */
  23. {0x00001408, 0x5515BAAB}, /* DDR SDRAM Timing (Low) Register */
  24. {0x0000140C, 0x38DA3F97}, /* DDR SDRAM Timing (High) Register */
  25. {0x00001410, 0x20100005}, /* DDR SDRAM Address Control Register */
  26. {0x00001414, 0x0000F3FF}, /* DDR SDRAM Open Pages Control Reg */
  27. {0x00001418, 0x00000e00}, /* DDR SDRAM Operation Register */
  28. {0x0000141C, 0x00000672}, /* DDR SDRAM Mode Register */
  29. {0x00001420, 0x00000004}, /* DDR SDRAM Extended Mode Register */
  30. {0x00001424, 0x0000F3FF}, /* Dunit Control High Register */
  31. {0x00001428, 0x0011A940}, /* Dunit Control High Register */
  32. {0x0000142C, 0x014C5134}, /* Dunit Control High Register */
  33. {0x0000147C, 0x0000D771},
  34. {0x00001494, 0x00010000}, /* DDR SDRAM ODT Control (Low) Reg */
  35. {0x0000149C, 0x00000001}, /* DDR Dunit ODT Control Register */
  36. {0x000014A0, 0x00000001},
  37. {0x000014A8, 0x00000101},
  38. /* Recommended Settings from Marvell for 4 x 16 bit devices: */
  39. {0x000014C0, 0x192424C9}, /* DRAM addr and Ctrl Driving Strenght*/
  40. {0x000014C4, 0xAAA24C9}, /* DRAM Data and DQS Driving Strenght */
  41. /*
  42. * DO NOT Modify - Open Mbus Window - 2G - Mbus is required for the
  43. * training sequence
  44. */
  45. {0x000200e8, 0x3FFF0E01},
  46. {0x00020184, 0x3FFFFFE0}, /* Close fast path Window to - 2G */
  47. {0x0001504, 0x3FFFFFE1}, /* CS0 Size */
  48. {0x000150C, 0x00000000}, /* CS1 Size */
  49. {0x0001514, 0x00000000}, /* CS2 Size */
  50. {0x000151C, 0x00000000}, /* CS3 Size */
  51. {0x0020220, 0x00000007}, /* Reserved */
  52. {0x00001538, 0x0000000B}, /* Read Data Sample Delays Register */
  53. {0x0000153C, 0x0000000B}, /* Read Data Ready Delay Register */
  54. {0x000015D0, 0x00000670}, /* MR0 */
  55. {0x000015D4, 0x00000044}, /* MR1 */
  56. {0x000015D8, 0x00000018}, /* MR2 */
  57. {0x000015DC, 0x00000000}, /* MR3 */
  58. {0x000015E0, 0x00000001},
  59. {0x000015E4, 0x00203c18}, /* ZQDS Configuration Register */
  60. {0x000015EC, 0xF800A225}, /* DDR PHY */
  61. {0x0, 0x0}
  62. };
  63. MV_DRAM_MODES maxbcm_ddr_modes[MV_DDR3_MODES_NUMBER] = {
  64. {"maxbcm_1600-800", 0xB, 0x5, 0x0, A0, ddr3_b0_maxbcm, NULL},
  65. };
  66. extern MV_SERDES_CHANGE_M_PHY serdes_change_m_phy[];
  67. /* MAXBCM: SERDES 0-4 PCIE, Serdes 7 = SGMII 0, all others = unconnected */
  68. MV_BIN_SERDES_CFG maxbcm_serdes_cfg[] = {
  69. { MV_PEX_ROOT_COMPLEX, 0x20011111, 0x00000000,
  70. { PEX_BUS_MODE_X1, PEX_BUS_MODE_X1, PEX_BUS_DISABLED,
  71. PEX_BUS_DISABLED },
  72. 0x1f, serdes_change_m_phy
  73. }
  74. };
  75. MV_DRAM_MODES *ddr3_get_static_ddr_mode(void)
  76. {
  77. /* Only one mode supported for this board */
  78. return &maxbcm_ddr_modes[0];
  79. }
  80. MV_BIN_SERDES_CFG *board_serdes_cfg_get(void)
  81. {
  82. return &maxbcm_serdes_cfg[0];
  83. }
  84. int board_early_init_f(void)
  85. {
  86. /*
  87. * Don't configure MPP (pin multiplexing) and GPIO here,
  88. * its already done in bin_hdr
  89. */
  90. /*
  91. * Setup some board specific mbus address windows
  92. */
  93. mbus_dt_setup_win(&mbus_state, DEV_CS0_BASE, 16 << 20,
  94. CPU_TARGET_DEVICEBUS_BOOTROM_SPI, CPU_ATTR_DEV_CS0);
  95. mbus_dt_setup_win(&mbus_state, DEV_CS1_BASE, 16 << 20,
  96. CPU_TARGET_DEVICEBUS_BOOTROM_SPI, CPU_ATTR_DEV_CS1);
  97. mbus_dt_setup_win(&mbus_state, DEV_CS2_BASE, 16 << 20,
  98. CPU_TARGET_DEVICEBUS_BOOTROM_SPI, CPU_ATTR_DEV_CS2);
  99. mbus_dt_setup_win(&mbus_state, DEV_CS3_BASE, 16 << 20,
  100. CPU_TARGET_DEVICEBUS_BOOTROM_SPI, CPU_ATTR_DEV_CS3);
  101. return 0;
  102. }
  103. int board_init(void)
  104. {
  105. /* adress of boot parameters */
  106. gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
  107. return 0;
  108. }
  109. int checkboard(void)
  110. {
  111. puts("Board: maxBCM\n");
  112. return 0;
  113. }
  114. /* Configure and enable MV88E6185 switch */
  115. int board_phy_config(struct phy_device *phydev)
  116. {
  117. /*
  118. * todo:
  119. * Fill this with the real setup / config code.
  120. * Please see board/Marvell/db-mv784mp-gp/db-mv784mp-gp.c
  121. * for details.
  122. */
  123. printf("88E6185 Initialized\n");
  124. return 0;
  125. }