rd6281a.c 3.9 KB

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