clearfog.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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-15t1-clearfog"
  22. */
  23. #define BOARD_GPP_OUT_ENA_LOW 0xffffffff
  24. #define BOARD_GPP_OUT_ENA_MID 0xffffffff
  25. #define BOARD_GPP_OUT_VAL_LOW 0x0
  26. #define BOARD_GPP_OUT_VAL_MID 0x0
  27. #define BOARD_GPP_POL_LOW 0x0
  28. #define BOARD_GPP_POL_MID 0x0
  29. /* IO expander on Marvell GP board includes e.g. fan enabling */
  30. struct marvell_io_exp {
  31. u8 chip;
  32. u8 addr;
  33. u8 val;
  34. };
  35. static struct marvell_io_exp io_exp[] = {
  36. { 0x20, 2, 0x40 }, /* Deassert both mini pcie reset signals */
  37. { 0x20, 6, 0xf9 },
  38. { 0x20, 2, 0x46 }, /* rst signals and ena USB3 current limiter */
  39. { 0x20, 6, 0xb9 },
  40. { 0x20, 3, 0x00 }, /* Set SFP_TX_DIS to zero */
  41. { 0x20, 7, 0xbf }, /* Drive SFP_TX_DIS to zero */
  42. };
  43. static struct serdes_map board_serdes_map[] = {
  44. {SATA0, SERDES_SPEED_3_GBPS, SERDES_DEFAULT_MODE, 0, 0},
  45. {SGMII1, SERDES_SPEED_1_25_GBPS, SERDES_DEFAULT_MODE, 0, 0},
  46. {PEX1, SERDES_SPEED_5_GBPS, PEX_ROOT_COMPLEX_X1, 0, 0},
  47. {USB3_HOST1, SERDES_SPEED_5_GBPS, SERDES_DEFAULT_MODE, 0, 0},
  48. {PEX2, SERDES_SPEED_5_GBPS, PEX_ROOT_COMPLEX_X1, 0, 0},
  49. {SGMII2, SERDES_SPEED_1_25_GBPS, SERDES_DEFAULT_MODE, 0, 0},
  50. };
  51. int hws_board_topology_load(struct serdes_map **serdes_map_array, u8 *count)
  52. {
  53. *serdes_map_array = board_serdes_map;
  54. *count = ARRAY_SIZE(board_serdes_map);
  55. return 0;
  56. }
  57. /*
  58. * Define the DDR layout / topology here in the board file. This will
  59. * be used by the DDR3 init code in the SPL U-Boot version to configure
  60. * the DDR3 controller.
  61. */
  62. static struct hws_topology_map board_topology_map = {
  63. 0x1, /* active interfaces */
  64. /* cs_mask, mirror, dqs_swap, ck_swap X PUPs */
  65. { { { {0x1, 0, 0, 0},
  66. {0x1, 0, 0, 0},
  67. {0x1, 0, 0, 0},
  68. {0x1, 0, 0, 0},
  69. {0x1, 0, 0, 0} },
  70. SPEED_BIN_DDR_1600K, /* speed_bin */
  71. BUS_WIDTH_16, /* memory_width */
  72. MEM_4G, /* mem_size */
  73. DDR_FREQ_800, /* frequency */
  74. 0, 0, /* cas_l cas_wl */
  75. HWS_TEMP_LOW} }, /* temperature */
  76. 5, /* Num Of Bus Per Interface*/
  77. BUS_MASK_32BIT /* Busses mask */
  78. };
  79. struct hws_topology_map *ddr3_get_topology_map(void)
  80. {
  81. /* Return the board topology as defined in the board code */
  82. return &board_topology_map;
  83. }
  84. int board_early_init_f(void)
  85. {
  86. /* Configure MPP */
  87. writel(0x11111111, MVEBU_MPP_BASE + 0x00);
  88. writel(0x11111111, MVEBU_MPP_BASE + 0x04);
  89. writel(0x10400011, MVEBU_MPP_BASE + 0x08);
  90. writel(0x22043333, MVEBU_MPP_BASE + 0x0c);
  91. writel(0x44400002, MVEBU_MPP_BASE + 0x10);
  92. writel(0x41144004, MVEBU_MPP_BASE + 0x14);
  93. writel(0x40333333, MVEBU_MPP_BASE + 0x18);
  94. writel(0x00004444, MVEBU_MPP_BASE + 0x1c);
  95. /* Set GPP Out value */
  96. writel(BOARD_GPP_OUT_VAL_LOW, MVEBU_GPIO0_BASE + 0x00);
  97. writel(BOARD_GPP_OUT_VAL_MID, MVEBU_GPIO1_BASE + 0x00);
  98. /* Set GPP Polarity */
  99. writel(BOARD_GPP_POL_LOW, MVEBU_GPIO0_BASE + 0x0c);
  100. writel(BOARD_GPP_POL_MID, MVEBU_GPIO1_BASE + 0x0c);
  101. /* Set GPP Out Enable */
  102. writel(BOARD_GPP_OUT_ENA_LOW, MVEBU_GPIO0_BASE + 0x04);
  103. writel(BOARD_GPP_OUT_ENA_MID, MVEBU_GPIO1_BASE + 0x04);
  104. return 0;
  105. }
  106. int board_init(void)
  107. {
  108. int i;
  109. /* Address of boot parameters */
  110. gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
  111. /* Toggle GPIO41 to reset onboard switch and phy */
  112. clrbits_le32(MVEBU_GPIO1_BASE + 0x0, BIT(9));
  113. clrbits_le32(MVEBU_GPIO1_BASE + 0x4, BIT(9));
  114. mdelay(1);
  115. setbits_le32(MVEBU_GPIO1_BASE + 0x0, BIT(9));
  116. mdelay(10);
  117. /* Init I2C IO expanders */
  118. for (i = 0; i < ARRAY_SIZE(io_exp); i++)
  119. i2c_write(io_exp[i].chip, io_exp[i].addr, 1, &io_exp[i].val, 1);
  120. return 0;
  121. }
  122. int checkboard(void)
  123. {
  124. puts("Board: SolidRun ClearFog\n");
  125. return 0;
  126. }
  127. int board_eth_init(bd_t *bis)
  128. {
  129. cpu_eth_init(bis); /* Built in controller(s) come first */
  130. return pci_eth_init(bis);
  131. }