sheevaplug.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*
  2. * (C) Copyright 2009
  3. * Marvell Semiconductor <www.marvell.com>
  4. * Written-by: Prafulla Wadaskar <prafulla@marvell.com>
  5. *
  6. * SPDX-License-Identifier: GPL-2.0+
  7. */
  8. #include <common.h>
  9. #include <miiphy.h>
  10. #include <asm/arch/cpu.h>
  11. #include <asm/arch/soc.h>
  12. #include <asm/arch/mpp.h>
  13. #include "sheevaplug.h"
  14. DECLARE_GLOBAL_DATA_PTR;
  15. int board_early_init_f(void)
  16. {
  17. /*
  18. * default gpio configuration
  19. * There are maximum 64 gpios controlled through 2 sets of registers
  20. * the below configuration configures mainly initial LED status
  21. */
  22. mvebu_config_gpio(SHEEVAPLUG_OE_VAL_LOW,
  23. SHEEVAPLUG_OE_VAL_HIGH,
  24. SHEEVAPLUG_OE_LOW, SHEEVAPLUG_OE_HIGH);
  25. /* Multi-Purpose Pins Functionality configuration */
  26. static const u32 kwmpp_config[] = {
  27. MPP0_NF_IO2,
  28. MPP1_NF_IO3,
  29. MPP2_NF_IO4,
  30. MPP3_NF_IO5,
  31. MPP4_NF_IO6,
  32. MPP5_NF_IO7,
  33. MPP6_SYSRST_OUTn,
  34. MPP7_GPO,
  35. MPP8_UART0_RTS,
  36. MPP9_UART0_CTS,
  37. MPP10_UART0_TXD,
  38. MPP11_UART0_RXD,
  39. MPP12_SD_CLK,
  40. MPP13_SD_CMD,
  41. MPP14_SD_D0,
  42. MPP15_SD_D1,
  43. MPP16_SD_D2,
  44. MPP17_SD_D3,
  45. MPP18_NF_IO0,
  46. MPP19_NF_IO1,
  47. MPP20_GPIO,
  48. MPP21_GPIO,
  49. MPP22_GPIO,
  50. MPP23_GPIO,
  51. MPP24_GPIO,
  52. MPP25_GPIO,
  53. MPP26_GPIO,
  54. MPP27_GPIO,
  55. MPP28_GPIO,
  56. MPP29_TSMP9,
  57. MPP30_GPIO,
  58. MPP31_GPIO,
  59. MPP32_GPIO,
  60. MPP33_GPIO,
  61. MPP34_GPIO,
  62. MPP35_GPIO,
  63. MPP36_GPIO,
  64. MPP37_GPIO,
  65. MPP38_GPIO,
  66. MPP39_GPIO,
  67. MPP40_GPIO,
  68. MPP41_GPIO,
  69. MPP42_GPIO,
  70. MPP43_GPIO,
  71. MPP44_GPIO,
  72. MPP45_GPIO,
  73. MPP46_GPIO,
  74. MPP47_GPIO,
  75. MPP48_GPIO,
  76. MPP49_GPIO,
  77. 0
  78. };
  79. kirkwood_mpp_conf(kwmpp_config, NULL);
  80. return 0;
  81. }
  82. int board_init(void)
  83. {
  84. /*
  85. * arch number of board
  86. */
  87. gd->bd->bi_arch_number = MACH_TYPE_SHEEVAPLUG;
  88. /* adress of boot parameters */
  89. gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
  90. return 0;
  91. }
  92. #ifdef CONFIG_RESET_PHY_R
  93. /* Configure and enable MV88E1116 PHY */
  94. void reset_phy(void)
  95. {
  96. u16 reg;
  97. u16 devadr;
  98. char *name = "egiga0";
  99. if (miiphy_set_current_dev(name))
  100. return;
  101. /* command to read PHY dev address */
  102. if (miiphy_read(name, 0xEE, 0xEE, (u16 *) &devadr)) {
  103. printf("Err..%s could not read PHY dev address\n",
  104. __FUNCTION__);
  105. return;
  106. }
  107. /*
  108. * Enable RGMII delay on Tx and Rx for CPU port
  109. * Ref: sec 4.7.2 of chip datasheet
  110. */
  111. miiphy_write(name, devadr, MV88E1116_PGADR_REG, 2);
  112. miiphy_read(name, devadr, MV88E1116_MAC_CTRL_REG, &reg);
  113. reg |= (MV88E1116_RGMII_RXTM_CTRL | MV88E1116_RGMII_TXTM_CTRL);
  114. miiphy_write(name, devadr, MV88E1116_MAC_CTRL_REG, reg);
  115. miiphy_write(name, devadr, MV88E1116_PGADR_REG, 0);
  116. /* reset the phy */
  117. miiphy_reset(name, devadr);
  118. printf("88E1116 Initialized on %s\n", name);
  119. }
  120. #endif /* CONFIG_RESET_PHY_R */