guruplug.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /*
  2. * (C) Copyright 2009
  3. * Marvell Semiconductor <www.marvell.com>
  4. * Written-by: Siddarth Gore <gores@marvell.com>
  5. *
  6. * See file CREDITS for list of people who contributed to this
  7. * project.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License as
  11. * published by the Free Software Foundation; either version 2 of
  12. * the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  22. * MA 02110-1301 USA
  23. */
  24. #include <common.h>
  25. #include <miiphy.h>
  26. #include <asm/arch/kirkwood.h>
  27. #include <asm/arch/mpp.h>
  28. #include "guruplug.h"
  29. DECLARE_GLOBAL_DATA_PTR;
  30. int board_init(void)
  31. {
  32. /*
  33. * default gpio configuration
  34. * There are maximum 64 gpios controlled through 2 sets of registers
  35. * the below configuration configures mainly initial LED status
  36. */
  37. kw_config_gpio(GURUPLUG_OE_VAL_LOW,
  38. GURUPLUG_OE_VAL_HIGH,
  39. GURUPLUG_OE_LOW, GURUPLUG_OE_HIGH);
  40. /* Multi-Purpose Pins Functionality configuration */
  41. u32 kwmpp_config[] = {
  42. MPP0_NF_IO2,
  43. MPP1_NF_IO3,
  44. MPP2_NF_IO4,
  45. MPP3_NF_IO5,
  46. MPP4_NF_IO6,
  47. MPP5_NF_IO7,
  48. MPP6_SYSRST_OUTn,
  49. MPP7_GPO, /* GPIO_RST */
  50. MPP8_TW_SDA,
  51. MPP9_TW_SCK,
  52. MPP10_UART0_TXD,
  53. MPP11_UART0_RXD,
  54. MPP12_SD_CLK,
  55. MPP13_SD_CMD,
  56. MPP14_SD_D0,
  57. MPP15_SD_D1,
  58. MPP16_SD_D2,
  59. MPP17_SD_D3,
  60. MPP18_NF_IO0,
  61. MPP19_NF_IO1,
  62. MPP20_GE1_0,
  63. MPP21_GE1_1,
  64. MPP22_GE1_2,
  65. MPP23_GE1_3,
  66. MPP24_GE1_4,
  67. MPP25_GE1_5,
  68. MPP26_GE1_6,
  69. MPP27_GE1_7,
  70. MPP28_GE1_8,
  71. MPP29_GE1_9,
  72. MPP30_GE1_10,
  73. MPP31_GE1_11,
  74. MPP32_GE1_12,
  75. MPP33_GE1_13,
  76. MPP34_GE1_14,
  77. MPP35_GE1_15,
  78. MPP36_GPIO,
  79. MPP37_GPIO,
  80. MPP38_GPIO,
  81. MPP39_GPIO,
  82. MPP40_TDM_SPI_SCK,
  83. MPP41_TDM_SPI_MISO,
  84. MPP42_TDM_SPI_MOSI,
  85. MPP43_GPIO,
  86. MPP44_GPIO,
  87. MPP45_GPIO,
  88. MPP46_GPIO, /* M_RLED */
  89. MPP47_GPIO, /* M_GLED */
  90. MPP48_GPIO, /* B_RLED */
  91. MPP49_GPIO, /* B_GLED */
  92. 0
  93. };
  94. kirkwood_mpp_conf(kwmpp_config);
  95. /*
  96. * arch number of board
  97. */
  98. gd->bd->bi_arch_number = MACH_TYPE_GURUPLUG;
  99. /* adress of boot parameters */
  100. gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
  101. return 0;
  102. }
  103. #ifdef CONFIG_RESET_PHY_R
  104. void mv_phy_88e1121_init(char *name)
  105. {
  106. u16 reg;
  107. u16 devadr;
  108. if (miiphy_set_current_dev(name))
  109. return;
  110. /* command to read PHY dev address */
  111. if (miiphy_read(name, 0xEE, 0xEE, (u16 *) &devadr)) {
  112. printf("Err..%s could not read PHY dev address\n",
  113. __FUNCTION__);
  114. return;
  115. }
  116. /*
  117. * Enable RGMII delay on Tx and Rx for CPU port
  118. * Ref: sec 4.7.2 of chip datasheet
  119. */
  120. miiphy_write(name, devadr, MV88E1121_PGADR_REG, 2);
  121. miiphy_read(name, devadr, MV88E1121_MAC_CTRL2_REG, &reg);
  122. reg |= (MV88E1121_RGMII_RXTM_CTRL | MV88E1121_RGMII_TXTM_CTRL);
  123. miiphy_write(name, devadr, MV88E1121_MAC_CTRL2_REG, reg);
  124. miiphy_write(name, devadr, MV88E1121_PGADR_REG, 0);
  125. /* reset the phy */
  126. miiphy_reset(name, devadr);
  127. printf("88E1121 Initialized on %s\n", name);
  128. }
  129. void reset_phy(void)
  130. {
  131. /* configure and initialize both PHY's */
  132. mv_phy_88e1121_init("egiga0");
  133. mv_phy_88e1121_init("egiga1");
  134. }
  135. #endif /* CONFIG_RESET_PHY_R */