guruplug.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /*
  2. * (C) Copyright 2009
  3. * Marvell Semiconductor <www.marvell.com>
  4. * Written-by: Siddarth Gore <gores@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 "guruplug.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(GURUPLUG_OE_VAL_LOW,
  23. GURUPLUG_OE_VAL_HIGH,
  24. GURUPLUG_OE_LOW, GURUPLUG_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, /* GPIO_RST */
  35. MPP8_TW_SDA,
  36. MPP9_TW_SCK,
  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_GE1_0,
  48. MPP21_GE1_1,
  49. MPP22_GE1_2,
  50. MPP23_GE1_3,
  51. MPP24_GE1_4,
  52. MPP25_GE1_5,
  53. MPP26_GE1_6,
  54. MPP27_GE1_7,
  55. MPP28_GE1_8,
  56. MPP29_GE1_9,
  57. MPP30_GE1_10,
  58. MPP31_GE1_11,
  59. MPP32_GE1_12,
  60. MPP33_GE1_13,
  61. MPP34_GE1_14,
  62. MPP35_GE1_15,
  63. MPP36_GPIO,
  64. MPP37_GPIO,
  65. MPP38_GPIO,
  66. MPP39_GPIO,
  67. MPP40_TDM_SPI_SCK,
  68. MPP41_TDM_SPI_MISO,
  69. MPP42_TDM_SPI_MOSI,
  70. MPP43_GPIO,
  71. MPP44_GPIO,
  72. MPP45_GPIO,
  73. MPP46_GPIO, /* M_RLED */
  74. MPP47_GPIO, /* M_GLED */
  75. MPP48_GPIO, /* B_RLED */
  76. MPP49_GPIO, /* B_GLED */
  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_GURUPLUG;
  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. void mv_phy_88e1121_init(char *name)
  94. {
  95. u16 reg;
  96. u16 devadr;
  97. if (miiphy_set_current_dev(name))
  98. return;
  99. /* command to read PHY dev address */
  100. if (miiphy_read(name, 0xEE, 0xEE, (u16 *) &devadr)) {
  101. printf("Err..%s could not read PHY dev address\n",
  102. __FUNCTION__);
  103. return;
  104. }
  105. /*
  106. * Enable RGMII delay on Tx and Rx for CPU port
  107. * Ref: sec 4.7.2 of chip datasheet
  108. */
  109. miiphy_write(name, devadr, MV88E1121_PGADR_REG, 2);
  110. miiphy_read(name, devadr, MV88E1121_MAC_CTRL2_REG, &reg);
  111. reg |= (MV88E1121_RGMII_RXTM_CTRL | MV88E1121_RGMII_TXTM_CTRL);
  112. miiphy_write(name, devadr, MV88E1121_MAC_CTRL2_REG, reg);
  113. miiphy_write(name, devadr, MV88E1121_PGADR_REG, 0);
  114. /* reset the phy */
  115. miiphy_reset(name, devadr);
  116. printf("88E1121 Initialized on %s\n", name);
  117. }
  118. void reset_phy(void)
  119. {
  120. /* configure and initialize both PHY's */
  121. mv_phy_88e1121_init("egiga0");
  122. mv_phy_88e1121_init("egiga1");
  123. }
  124. #endif /* CONFIG_RESET_PHY_R */