db-mv784mp-gp.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*
  2. * Copyright (C) 2014 Stefan Roese <sr@denx.de>
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #include <common.h>
  7. #include <miiphy.h>
  8. #include <netdev.h>
  9. #include <asm/io.h>
  10. #include <asm/arch/cpu.h>
  11. #include <asm/arch/soc.h>
  12. DECLARE_GLOBAL_DATA_PTR;
  13. #define ETH_PHY_CTRL_REG 0
  14. #define ETH_PHY_CTRL_POWER_DOWN_BIT 11
  15. #define ETH_PHY_CTRL_POWER_DOWN_MASK (1 << ETH_PHY_CTRL_POWER_DOWN_BIT)
  16. /*
  17. * Those values and defines are taken from the Marvell U-Boot version
  18. * "u-boot-2011.12-2014_T1.0" for the board rd78460gp aka
  19. * "RD-AXP-GP rev 1.0".
  20. *
  21. * GPPs
  22. * MPP# NAME IN/OUT
  23. * ----------------------------------------------
  24. * 21 SW_Reset_ OUT
  25. * 25 Phy_Int# IN
  26. * 28 SDI_WP IN
  27. * 29 SDI_Status IN
  28. * 54-61 On GPP Connector ?
  29. * 62 Switch Interrupt IN
  30. * 63-65 Reserved from SW Board ?
  31. * 66 SW_BRD connected IN
  32. */
  33. #define RD_78460_GP_GPP_OUT_ENA_LOW (~(BIT(21) | BIT(20)))
  34. #define RD_78460_GP_GPP_OUT_ENA_MID (~(BIT(26) | BIT(27)))
  35. #define RD_78460_GP_GPP_OUT_ENA_HIGH (~(0x0))
  36. #define RD_78460_GP_GPP_OUT_VAL_LOW (BIT(21) | BIT(20))
  37. #define RD_78460_GP_GPP_OUT_VAL_MID (BIT(26) | BIT(27))
  38. #define RD_78460_GP_GPP_OUT_VAL_HIGH 0x0
  39. int board_early_init_f(void)
  40. {
  41. /* Configure MPP */
  42. writel(0x00000000, MVEBU_MPP_BASE + 0x00);
  43. writel(0x00000000, MVEBU_MPP_BASE + 0x04);
  44. writel(0x33000000, MVEBU_MPP_BASE + 0x08);
  45. writel(0x11000000, MVEBU_MPP_BASE + 0x0c);
  46. writel(0x11111111, MVEBU_MPP_BASE + 0x10);
  47. writel(0x00221100, MVEBU_MPP_BASE + 0x14);
  48. writel(0x00000003, MVEBU_MPP_BASE + 0x18);
  49. writel(0x00000000, MVEBU_MPP_BASE + 0x1c);
  50. writel(0x00000000, MVEBU_MPP_BASE + 0x20);
  51. /* Configure GPIO */
  52. writel(RD_78460_GP_GPP_OUT_VAL_LOW, MVEBU_GPIO0_BASE + 0x00);
  53. writel(RD_78460_GP_GPP_OUT_ENA_LOW, MVEBU_GPIO0_BASE + 0x04);
  54. writel(RD_78460_GP_GPP_OUT_VAL_MID, MVEBU_GPIO1_BASE + 0x00);
  55. writel(RD_78460_GP_GPP_OUT_ENA_MID, MVEBU_GPIO1_BASE + 0x04);
  56. writel(RD_78460_GP_GPP_OUT_VAL_HIGH, MVEBU_GPIO2_BASE + 0x00);
  57. writel(RD_78460_GP_GPP_OUT_ENA_HIGH, MVEBU_GPIO2_BASE + 0x04);
  58. return 0;
  59. }
  60. int board_init(void)
  61. {
  62. /* adress of boot parameters */
  63. gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
  64. return 0;
  65. }
  66. int checkboard(void)
  67. {
  68. puts("Board: Marvell DB-MV784MP-GP\n");
  69. return 0;
  70. }
  71. int board_eth_init(bd_t *bis)
  72. {
  73. cpu_eth_init(bis); /* Built in controller(s) come first */
  74. return pci_eth_init(bis);
  75. }
  76. int board_phy_config(struct phy_device *phydev)
  77. {
  78. u16 reg;
  79. /* Enable QSGMII AN */
  80. /* Set page to 4 */
  81. phy_write(phydev, MDIO_DEVAD_NONE, 0x16, 4);
  82. /* Enable AN */
  83. phy_write(phydev, MDIO_DEVAD_NONE, 0x0, 0x1140);
  84. /* Set page to 0 */
  85. phy_write(phydev, MDIO_DEVAD_NONE, 0x16, 0);
  86. /* Phy C_ANEG */
  87. reg = phy_read(phydev, MDIO_DEVAD_NONE, 0x4);
  88. reg |= 0x1E0;
  89. phy_write(phydev, MDIO_DEVAD_NONE, 0x4, reg);
  90. /* Soft-Reset */
  91. phy_write(phydev, MDIO_DEVAD_NONE, 22, 0x0000);
  92. phy_write(phydev, MDIO_DEVAD_NONE, 0, 0x9140);
  93. /* Power up the phy */
  94. reg = phy_read(phydev, MDIO_DEVAD_NONE, ETH_PHY_CTRL_REG);
  95. reg &= ~(ETH_PHY_CTRL_POWER_DOWN_MASK);
  96. phy_write(phydev, MDIO_DEVAD_NONE, ETH_PHY_CTRL_REG, reg);
  97. printf("88E1545 Initialized\n");
  98. return 0;
  99. }