openrd.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /*
  2. * (C) Copyright 2009
  3. * Net Insight <www.netinsight.net>
  4. * Written-by: Simon Kagstrom <simon.kagstrom@netinsight.net>
  5. *
  6. * Based on sheevaplug.c:
  7. * (C) Copyright 2009
  8. * Marvell Semiconductor <www.marvell.com>
  9. * Written-by: Prafulla Wadaskar <prafulla@marvell.com>
  10. *
  11. * See file CREDITS for list of people who contributed to this
  12. * project.
  13. *
  14. * This program is free software; you can redistribute it and/or
  15. * modify it under the terms of the GNU General Public License as
  16. * published by the Free Software Foundation; either version 2 of
  17. * the License, or (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program; if not, write to the Free Software
  26. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  27. * MA 02110-1301 USA
  28. */
  29. #include <common.h>
  30. #include <miiphy.h>
  31. #include <asm/arch/cpu.h>
  32. #include <asm/arch/kirkwood.h>
  33. #include <asm/arch/mpp.h>
  34. #include "openrd.h"
  35. DECLARE_GLOBAL_DATA_PTR;
  36. int board_early_init_f(void)
  37. {
  38. /*
  39. * default gpio configuration
  40. * There are maximum 64 gpios controlled through 2 sets of registers
  41. * the below configuration configures mainly initial LED status
  42. */
  43. kw_config_gpio(OPENRD_OE_VAL_LOW,
  44. OPENRD_OE_VAL_HIGH,
  45. OPENRD_OE_LOW, OPENRD_OE_HIGH);
  46. /* Multi-Purpose Pins Functionality configuration */
  47. u32 kwmpp_config[] = {
  48. MPP0_NF_IO2,
  49. MPP1_NF_IO3,
  50. MPP2_NF_IO4,
  51. MPP3_NF_IO5,
  52. MPP4_NF_IO6,
  53. MPP5_NF_IO7,
  54. MPP6_SYSRST_OUTn,
  55. MPP7_GPO,
  56. MPP8_TW_SDA,
  57. MPP9_TW_SCK,
  58. MPP10_UART0_TXD,
  59. MPP11_UART0_RXD,
  60. MPP12_SD_CLK,
  61. MPP13_SD_CMD, /* Alt UART1_TXD */
  62. MPP14_SD_D0, /* Alt UART1_RXD */
  63. MPP15_SD_D1,
  64. MPP16_SD_D2,
  65. MPP17_SD_D3,
  66. MPP18_NF_IO0,
  67. MPP19_NF_IO1,
  68. MPP20_GE1_0,
  69. MPP21_GE1_1,
  70. MPP22_GE1_2,
  71. MPP23_GE1_3,
  72. MPP24_GE1_4,
  73. MPP25_GE1_5,
  74. MPP26_GE1_6,
  75. MPP27_GE1_7,
  76. MPP28_GPIO,
  77. MPP29_TSMP9,
  78. MPP30_GE1_10,
  79. MPP31_GE1_11,
  80. MPP32_GE1_12,
  81. MPP33_GE1_13,
  82. MPP34_GPIO, /* UART1 / SD sel */
  83. MPP35_TDM_CH0_TX_QL,
  84. MPP36_TDM_SPI_CS1,
  85. MPP37_TDM_CH2_TX_QL,
  86. MPP38_TDM_CH2_RX_QL,
  87. MPP39_AUDIO_I2SBCLK,
  88. MPP40_AUDIO_I2SDO,
  89. MPP41_AUDIO_I2SLRC,
  90. MPP42_AUDIO_I2SMCLK,
  91. MPP43_AUDIO_I2SDI,
  92. MPP44_AUDIO_EXTCLK,
  93. MPP45_TDM_PCLK,
  94. MPP46_TDM_FS,
  95. MPP47_TDM_DRX,
  96. MPP48_TDM_DTX,
  97. MPP49_TDM_CH0_RX_QL,
  98. 0
  99. };
  100. kirkwood_mpp_conf(kwmpp_config);
  101. return 0;
  102. }
  103. int board_init(void)
  104. {
  105. /*
  106. * arch number of board
  107. */
  108. #if defined(CONFIG_BOARD_IS_OPENRD_BASE)
  109. gd->bd->bi_arch_number = MACH_TYPE_OPENRD_BASE;
  110. #elif defined(CONFIG_BOARD_IS_OPENRD_CLIENT)
  111. gd->bd->bi_arch_number = MACH_TYPE_OPENRD_CLIENT;
  112. #elif defined(CONFIG_BOARD_IS_OPENRD_ULTIMATE)
  113. gd->bd->bi_arch_number = MACH_TYPE_OPENRD_ULTIMATE;
  114. #endif
  115. /* adress of boot parameters */
  116. gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
  117. return 0;
  118. }
  119. #ifdef CONFIG_RESET_PHY_R
  120. /* Configure and enable MV88E1116/88E1121 PHY */
  121. void mv_phy_init(char *name)
  122. {
  123. u16 reg;
  124. u16 devadr;
  125. if (miiphy_set_current_dev(name))
  126. return;
  127. /* command to read PHY dev address */
  128. if (miiphy_read(name, 0xEE, 0xEE, (u16 *) &devadr)) {
  129. printf("Err..%s could not read PHY dev address\n",
  130. __FUNCTION__);
  131. return;
  132. }
  133. /*
  134. * Enable RGMII delay on Tx and Rx for CPU port
  135. * Ref: sec 4.7.2 of chip datasheet
  136. */
  137. miiphy_write(name, devadr, MV88E1116_PGADR_REG, 2);
  138. miiphy_read(name, devadr, MV88E1116_MAC_CTRL_REG, &reg);
  139. reg |= (MV88E1116_RGMII_RXTM_CTRL | MV88E1116_RGMII_TXTM_CTRL);
  140. miiphy_write(name, devadr, MV88E1116_MAC_CTRL_REG, reg);
  141. miiphy_write(name, devadr, MV88E1116_PGADR_REG, 0);
  142. /* reset the phy */
  143. miiphy_reset(name, devadr);
  144. printf(PHY_NO" Initialized on %s\n", name);
  145. }
  146. void reset_phy(void)
  147. {
  148. mv_phy_init("egiga0");
  149. #ifdef CONFIG_BOARD_IS_OPENRD_CLIENT
  150. /* Kirkwood ethernet driver is written with the assumption that in case
  151. * of multiple PHYs, their addresses are consecutive. But unfortunately
  152. * in case of OpenRD-Client, PHY addresses are not consecutive.*/
  153. miiphy_write("egiga1", 0xEE, 0xEE, 24);
  154. #endif
  155. #if defined(CONFIG_BOARD_IS_OPENRD_CLIENT) || \
  156. defined(CONFIG_BOARD_IS_OPENRD_ULTIMATE)
  157. /* configure and initialize both PHY's */
  158. mv_phy_init("egiga1");
  159. #endif
  160. }
  161. #endif /* CONFIG_RESET_PHY_R */