rd6281a.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. /*
  2. * (C) Copyright 2009
  3. * Marvell Semiconductor <www.marvell.com>
  4. * Written-by: Prafulla Wadaskar <prafulla@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 <netdev.h>
  27. #include <asm/arch/cpu.h>
  28. #include <asm/arch/kirkwood.h>
  29. #include <asm/arch/mpp.h>
  30. #include "rd6281a.h"
  31. DECLARE_GLOBAL_DATA_PTR;
  32. int board_early_init_f(void)
  33. {
  34. /*
  35. * default gpio configuration
  36. * There are maximum 64 gpios controlled through 2 sets of registers
  37. * the below configuration configures mainly initial LED status
  38. */
  39. kw_config_gpio(RD6281A_OE_VAL_LOW,
  40. RD6281A_OE_VAL_HIGH,
  41. RD6281A_OE_LOW, RD6281A_OE_HIGH);
  42. /* Multi-Purpose Pins Functionality configuration */
  43. u32 kwmpp_config[] = {
  44. MPP0_NF_IO2,
  45. MPP1_NF_IO3,
  46. MPP2_NF_IO4,
  47. MPP3_NF_IO5,
  48. MPP4_NF_IO6,
  49. MPP5_NF_IO7,
  50. MPP6_SYSRST_OUTn,
  51. MPP7_GPO,
  52. MPP8_TW_SDA,
  53. MPP9_TW_SCK,
  54. MPP10_UART0_TXD,
  55. MPP11_UART0_RXD,
  56. MPP12_SD_CLK,
  57. MPP13_SD_CMD,
  58. MPP14_SD_D0,
  59. MPP15_SD_D1,
  60. MPP16_SD_D2,
  61. MPP17_SD_D3,
  62. MPP18_NF_IO0,
  63. MPP19_NF_IO1,
  64. MPP20_GE1_0,
  65. MPP21_GE1_1,
  66. MPP22_GE1_2,
  67. MPP23_GE1_3,
  68. MPP24_GE1_4,
  69. MPP25_GE1_5,
  70. MPP26_GE1_6,
  71. MPP27_GE1_7,
  72. MPP28_GPIO,
  73. MPP29_GPIO,
  74. MPP30_GE1_10,
  75. MPP31_GE1_11,
  76. MPP32_GE1_12,
  77. MPP33_GE1_13,
  78. MPP34_GE1_14,
  79. MPP35_GPIO,
  80. MPP36_AUDIO_SPDIFI,
  81. MPP37_AUDIO_SPDIFO,
  82. MPP38_GPIO,
  83. MPP39_TDM_SPI_CS0,
  84. MPP40_TDM_SPI_SCK,
  85. MPP41_TDM_SPI_MISO,
  86. MPP42_TDM_SPI_MOSI,
  87. MPP43_TDM_CODEC_INTn,
  88. MPP44_GPIO,
  89. MPP45_TDM_PCLK,
  90. MPP46_TDM_FS,
  91. MPP47_TDM_DRX,
  92. MPP48_TDM_DTX,
  93. MPP49_GPIO,
  94. 0
  95. };
  96. kirkwood_mpp_conf(kwmpp_config);
  97. return 0;
  98. }
  99. int board_init(void)
  100. {
  101. /*
  102. * arch number of board
  103. */
  104. gd->bd->bi_arch_number = MACH_TYPE_RD88F6281;
  105. /* adress of boot parameters */
  106. gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
  107. return 0;
  108. }
  109. void mv_phy_88e1116_init(char *name)
  110. {
  111. u16 reg;
  112. u16 devadr;
  113. if (miiphy_set_current_dev(name))
  114. return;
  115. /* command to read PHY dev address */
  116. if (miiphy_read(name, 0xEE, 0xEE, (u16 *) &devadr)) {
  117. printf("Err..%s could not read PHY dev address\n",
  118. __FUNCTION__);
  119. return;
  120. }
  121. /*
  122. * Enable RGMII delay on Tx and Rx for CPU port
  123. * Ref: sec 4.7.2 of chip datasheet
  124. */
  125. miiphy_write(name, devadr, MV88E1116_PGADR_REG, 2);
  126. miiphy_read(name, devadr, MV88E1116_MAC_CTRL_REG, &reg);
  127. reg |= (MV88E1116_RGMII_RXTM_CTRL | MV88E1116_RGMII_TXTM_CTRL);
  128. miiphy_write(name, devadr, MV88E1116_MAC_CTRL_REG, reg);
  129. miiphy_write(name, devadr, MV88E1116_PGADR_REG, 0);
  130. /* reset the phy */
  131. if (miiphy_read (name, devadr, MII_BMCR, &reg) != 0) {
  132. printf("Err..(%s) PHY status read failed\n", __FUNCTION__);
  133. return;
  134. }
  135. if (miiphy_write (name, devadr, MII_BMCR, reg | 0x8000) != 0) {
  136. printf("Err..(%s) PHY reset failed\n", __FUNCTION__);
  137. return;
  138. }
  139. printf("88E1116 Initialized on %s\n", name);
  140. }
  141. /* Configure and enable Switch and PHY */
  142. void reset_phy(void)
  143. {
  144. /* configure and initialize switch */
  145. struct mv88e61xx_config swcfg = {
  146. .name = "egiga0",
  147. .vlancfg = MV88E61XX_VLANCFG_ROUTER,
  148. .rgmii_delay = MV88E61XX_RGMII_DELAY_EN,
  149. .led_init = MV88E61XX_LED_INIT_EN,
  150. .portstate = MV88E61XX_PORTSTT_FORWARDING,
  151. .cpuport = (1 << 5),
  152. .ports_enabled = 0x3f,
  153. };
  154. mv88e61xx_switch_initialize(&swcfg);
  155. /* configure and initialize PHY */
  156. mv_phy_88e1116_init("egiga1");
  157. }