db-88f6820-amc.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*
  2. * Copyright (C) 2015 Stefan Roese <sr@denx.de>
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #include <common.h>
  7. #include <i2c.h>
  8. #include <miiphy.h>
  9. #include <netdev.h>
  10. #include <asm/io.h>
  11. #include <asm/arch/cpu.h>
  12. #include <asm/arch/soc.h>
  13. #include "../drivers/ddr/marvell/a38x/ddr3_a38x_topology.h"
  14. #include <../serdes/a38x/high_speed_env_spec.h>
  15. DECLARE_GLOBAL_DATA_PTR;
  16. #define ETH_PHY_CTRL_REG 0
  17. #define ETH_PHY_CTRL_POWER_DOWN_BIT 11
  18. #define ETH_PHY_CTRL_POWER_DOWN_MASK (1 << ETH_PHY_CTRL_POWER_DOWN_BIT)
  19. /*
  20. * Those values and defines are taken from the Marvell U-Boot version
  21. * "u-boot-2013.01-2016_T1.0.eng_drop_v10"
  22. */
  23. #define DB_AMC_88F68XX_GPP_OUT_ENA_LOW \
  24. (~(BIT(29)))
  25. #define DB_AMC_88F68XX_GPP_OUT_ENA_MID \
  26. (~(BIT(12) | BIT(17) | BIT(18) | BIT(20) | BIT(21)))
  27. #define DB_AMC_88F68XX_GPP_OUT_VAL_LOW (BIT(29))
  28. #define DB_AMC_88F68XX_GPP_OUT_VAL_MID 0x0
  29. #define DB_AMC_88F68XX_GPP_OUT_VAL_HIGH 0x0
  30. #define DB_AMC_88F68XX_GPP_POL_LOW 0x0
  31. #define DB_AMC_88F68XX_GPP_POL_MID 0x0
  32. static struct serdes_map board_serdes_map[] = {
  33. {PEX0, SERDES_SPEED_5_GBPS, PEX_ROOT_COMPLEX_X1, 0, 0},
  34. {DEFAULT_SERDES, SERDES_SPEED_5_GBPS, SERDES_DEFAULT_MODE, 0, 0},
  35. {DEFAULT_SERDES, SERDES_SPEED_5_GBPS, SERDES_DEFAULT_MODE, 0, 0},
  36. {DEFAULT_SERDES, SERDES_SPEED_5_GBPS, SERDES_DEFAULT_MODE, 0, 0},
  37. {SGMII1, SERDES_SPEED_1_25_GBPS, SERDES_DEFAULT_MODE, 0, 0},
  38. {SGMII2, SERDES_SPEED_1_25_GBPS, SERDES_DEFAULT_MODE, 0, 0}
  39. };
  40. int hws_board_topology_load(struct serdes_map **serdes_map_array, u8 *count)
  41. {
  42. *serdes_map_array = board_serdes_map;
  43. *count = ARRAY_SIZE(board_serdes_map);
  44. return 0;
  45. }
  46. /*
  47. * Define the DDR layout / topology here in the board file. This will
  48. * be used by the DDR3 init code in the SPL U-Boot version to configure
  49. * the DDR3 controller.
  50. */
  51. static struct hws_topology_map board_topology_map = {
  52. 0x1, /* active interfaces */
  53. /* cs_mask, mirror, dqs_swap, ck_swap X PUPs */
  54. { { { {0x1, 0, 0, 0},
  55. {0x1, 0, 0, 0},
  56. {0x1, 0, 0, 0},
  57. {0x1, 0, 0, 0},
  58. {0x1, 0, 0, 0} },
  59. SPEED_BIN_DDR_1866L, /* speed_bin */
  60. BUS_WIDTH_8, /* memory_width */
  61. MEM_4G, /* mem_size */
  62. DDR_FREQ_800, /* frequency */
  63. 0, 0, /* cas_l cas_wl */
  64. HWS_TEMP_LOW} }, /* temperature */
  65. 5, /* Num Of Bus Per Interface*/
  66. BUS_MASK_32BIT /* Busses mask */
  67. };
  68. struct hws_topology_map *ddr3_get_topology_map(void)
  69. {
  70. /* Return the board topology as defined in the board code */
  71. return &board_topology_map;
  72. }
  73. int board_early_init_f(void)
  74. {
  75. /* Configure MPP */
  76. writel(0x11111111, MVEBU_MPP_BASE + 0x00);
  77. writel(0x11111111, MVEBU_MPP_BASE + 0x04);
  78. writel(0x55066011, MVEBU_MPP_BASE + 0x08);
  79. writel(0x05055550, MVEBU_MPP_BASE + 0x0c);
  80. writel(0x05055555, MVEBU_MPP_BASE + 0x10);
  81. writel(0x01106565, MVEBU_MPP_BASE + 0x14);
  82. writel(0x40000000, MVEBU_MPP_BASE + 0x18);
  83. writel(0x00004444, MVEBU_MPP_BASE + 0x1c);
  84. /* Set GPP Out value */
  85. writel(DB_AMC_88F68XX_GPP_OUT_VAL_LOW, MVEBU_GPIO0_BASE + 0x00);
  86. writel(DB_AMC_88F68XX_GPP_OUT_VAL_MID, MVEBU_GPIO1_BASE + 0x00);
  87. /* Set GPP Polarity */
  88. writel(DB_AMC_88F68XX_GPP_POL_LOW, MVEBU_GPIO0_BASE + 0x0c);
  89. writel(DB_AMC_88F68XX_GPP_POL_MID, MVEBU_GPIO1_BASE + 0x0c);
  90. /* Set GPP Out Enable */
  91. writel(DB_AMC_88F68XX_GPP_OUT_ENA_LOW, MVEBU_GPIO0_BASE + 0x04);
  92. writel(DB_AMC_88F68XX_GPP_OUT_ENA_MID, MVEBU_GPIO1_BASE + 0x04);
  93. return 0;
  94. }
  95. int board_init(void)
  96. {
  97. /* adress of boot parameters */
  98. gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
  99. return 0;
  100. }
  101. int checkboard(void)
  102. {
  103. puts("Board: Marvell DB-88F6820-AMC\n");
  104. return 0;
  105. }
  106. int board_eth_init(bd_t *bis)
  107. {
  108. cpu_eth_init(bis); /* Built in controller(s) come first */
  109. return pci_eth_init(bis);
  110. }