dreamplug.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*
  2. * (C) Copyright 2011
  3. * Jason Cooper <u-boot@lakedaemon.net>
  4. *
  5. * Based on work by:
  6. * Marvell Semiconductor <www.marvell.com>
  7. * Written-by: Siddarth Gore <gores@marvell.com>
  8. *
  9. * SPDX-License-Identifier: GPL-2.0+
  10. */
  11. #include <common.h>
  12. #include <miiphy.h>
  13. #include <asm/arch/cpu.h>
  14. #include <asm/arch/soc.h>
  15. #include <asm/arch/mpp.h>
  16. #include "dreamplug.h"
  17. DECLARE_GLOBAL_DATA_PTR;
  18. int board_early_init_f(void)
  19. {
  20. /*
  21. * default gpio configuration
  22. * There are maximum 64 gpios controlled through 2 sets of registers
  23. * the below configuration configures mainly initial LED status
  24. */
  25. mvebu_config_gpio(DREAMPLUG_OE_VAL_LOW,
  26. DREAMPLUG_OE_VAL_HIGH,
  27. DREAMPLUG_OE_LOW, DREAMPLUG_OE_HIGH);
  28. /* Multi-Purpose Pins Functionality configuration */
  29. static const u32 kwmpp_config[] = {
  30. MPP0_SPI_SCn, /* SPI Flash */
  31. MPP1_SPI_MOSI,
  32. MPP2_SPI_SCK,
  33. MPP3_SPI_MISO,
  34. MPP4_NF_IO6,
  35. MPP5_NF_IO7,
  36. MPP6_SYSRST_OUTn,
  37. MPP7_GPO,
  38. MPP8_TW_SDA,
  39. MPP9_TW_SCK,
  40. MPP10_UART0_TXD, /* Serial */
  41. MPP11_UART0_RXD,
  42. MPP12_SD_CLK, /* SDIO Slot */
  43. MPP13_SD_CMD,
  44. MPP14_SD_D0,
  45. MPP15_SD_D1,
  46. MPP16_SD_D2,
  47. MPP17_SD_D3,
  48. MPP18_NF_IO0,
  49. MPP19_NF_IO1,
  50. MPP20_GE1_0, /* Gigabit Ethernet */
  51. MPP21_GE1_1,
  52. MPP22_GE1_2,
  53. MPP23_GE1_3,
  54. MPP24_GE1_4,
  55. MPP25_GE1_5,
  56. MPP26_GE1_6,
  57. MPP27_GE1_7,
  58. MPP28_GE1_8,
  59. MPP29_GE1_9,
  60. MPP30_GE1_10,
  61. MPP31_GE1_11,
  62. MPP32_GE1_12,
  63. MPP33_GE1_13,
  64. MPP34_GE1_14,
  65. MPP35_GE1_15,
  66. MPP36_GPIO, /* 7 external GPIO pins (36 - 45) */
  67. MPP37_GPIO,
  68. MPP38_GPIO,
  69. MPP39_GPIO,
  70. MPP40_TDM_SPI_SCK,
  71. MPP41_TDM_SPI_MISO,
  72. MPP42_TDM_SPI_MOSI,
  73. MPP43_GPIO,
  74. MPP44_GPIO,
  75. MPP45_GPIO,
  76. MPP46_GPIO,
  77. MPP47_GPIO, /* Bluetooth LED */
  78. MPP48_GPIO, /* Wifi LED */
  79. MPP49_GPIO, /* Wifi AP LED */
  80. 0
  81. };
  82. kirkwood_mpp_conf(kwmpp_config, NULL);
  83. return 0;
  84. }
  85. int board_init(void)
  86. {
  87. /* adress of boot parameters */
  88. gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
  89. return 0;
  90. }
  91. #ifdef CONFIG_RESET_PHY_R
  92. void mv_phy_88e1116_init(char *name)
  93. {
  94. u16 reg;
  95. u16 devadr;
  96. if (miiphy_set_current_dev(name))
  97. return;
  98. /* command to read PHY dev address */
  99. if (miiphy_read(name, 0xEE, 0xEE, (u16 *) &devadr)) {
  100. printf("Err..%s could not read PHY dev address\n",
  101. __func__);
  102. return;
  103. }
  104. /*
  105. * Enable RGMII delay on Tx and Rx for CPU port
  106. * Ref: sec 4.7.2 of chip datasheet
  107. */
  108. miiphy_write(name, devadr, MV88E1116_PGADR_REG, 2);
  109. miiphy_read(name, devadr, MV88E1116_MAC_CTRL2_REG, &reg);
  110. reg |= (MV88E1116_RGMII_RXTM_CTRL | MV88E1116_RGMII_TXTM_CTRL);
  111. miiphy_write(name, devadr, MV88E1116_MAC_CTRL2_REG, reg);
  112. miiphy_write(name, devadr, MV88E1116_PGADR_REG, 0);
  113. /* reset the phy */
  114. miiphy_reset(name, devadr);
  115. printf("88E1116 Initialized on %s\n", name);
  116. }
  117. void reset_phy(void)
  118. {
  119. /* configure and initialize both PHY's */
  120. mv_phy_88e1116_init("egiga0");
  121. mv_phy_88e1116_init("egiga1");
  122. }
  123. #endif /* CONFIG_RESET_PHY_R */