openrd_base.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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/kirkwood.h>
  32. #include <asm/arch/mpp.h>
  33. #include "openrd_base.h"
  34. DECLARE_GLOBAL_DATA_PTR;
  35. int board_init(void)
  36. {
  37. /*
  38. * default gpio configuration
  39. * There are maximum 64 gpios controlled through 2 sets of registers
  40. * the below configuration configures mainly initial LED status
  41. */
  42. kw_config_gpio(OPENRD_OE_VAL_LOW,
  43. OPENRD_OE_VAL_HIGH,
  44. OPENRD_OE_LOW, OPENRD_OE_HIGH);
  45. /* Multi-Purpose Pins Functionality configuration */
  46. u32 kwmpp_config[] = {
  47. MPP0_NF_IO2,
  48. MPP1_NF_IO3,
  49. MPP2_NF_IO4,
  50. MPP3_NF_IO5,
  51. MPP4_NF_IO6,
  52. MPP5_NF_IO7,
  53. MPP6_SYSRST_OUTn,
  54. MPP7_GPO,
  55. MPP8_TW_SDA,
  56. MPP9_TW_SCK,
  57. MPP10_UART0_TXD,
  58. MPP11_UART0_RXD,
  59. MPP12_SD_CLK,
  60. MPP13_SD_CMD, /* Alt UART1_TXD */
  61. MPP14_SD_D0, /* Alt UART1_RXD */
  62. MPP15_SD_D1,
  63. MPP16_SD_D2,
  64. MPP17_SD_D3,
  65. MPP18_NF_IO0,
  66. MPP19_NF_IO1,
  67. MPP20_GE1_0,
  68. MPP21_GE1_1,
  69. MPP22_GE1_2,
  70. MPP23_GE1_3,
  71. MPP24_GE1_4,
  72. MPP25_GE1_5,
  73. MPP26_GE1_6,
  74. MPP27_GE1_7,
  75. MPP28_GPIO,
  76. MPP29_TSMP9,
  77. MPP30_GE1_10,
  78. MPP31_GE1_11,
  79. MPP32_GE1_12,
  80. MPP33_GE1_13,
  81. MPP34_GPIO, /* UART1 / SD sel */
  82. MPP35_TDM_CH0_TX_QL,
  83. MPP36_TDM_SPI_CS1,
  84. MPP37_TDM_CH2_TX_QL,
  85. MPP38_TDM_CH2_RX_QL,
  86. MPP39_AUDIO_I2SBCLK,
  87. MPP40_AUDIO_I2SDO,
  88. MPP41_AUDIO_I2SLRC,
  89. MPP42_AUDIO_I2SMCLK,
  90. MPP43_AUDIO_I2SDI,
  91. MPP44_AUDIO_EXTCLK,
  92. MPP45_TDM_PCLK,
  93. MPP46_TDM_FS,
  94. MPP47_TDM_DRX,
  95. MPP48_TDM_DTX,
  96. MPP49_TDM_CH0_RX_QL,
  97. 0
  98. };
  99. kirkwood_mpp_conf(kwmpp_config);
  100. /*
  101. * arch number of board
  102. */
  103. gd->bd->bi_arch_number = MACH_TYPE_OPENRD_BASE;
  104. /* adress of boot parameters */
  105. gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
  106. return 0;
  107. }
  108. #ifdef CONFIG_RESET_PHY_R
  109. /* Configure and enable MV88E1116 PHY */
  110. void reset_phy(void)
  111. {
  112. u16 reg;
  113. u16 devadr;
  114. char *name = "egiga0";
  115. if (miiphy_set_current_dev(name))
  116. return;
  117. /* command to read PHY dev address */
  118. if (miiphy_read(name, 0xEE, 0xEE, (u16 *) &devadr)) {
  119. printf("Err..%s could not read PHY dev address\n",
  120. __FUNCTION__);
  121. return;
  122. }
  123. /*
  124. * Enable RGMII delay on Tx and Rx for CPU port
  125. * Ref: sec 4.7.2 of chip datasheet
  126. */
  127. miiphy_write(name, devadr, MV88E1116_PGADR_REG, 2);
  128. miiphy_read(name, devadr, MV88E1116_MAC_CTRL_REG, &reg);
  129. reg |= (MV88E1116_RGMII_RXTM_CTRL | MV88E1116_RGMII_TXTM_CTRL);
  130. miiphy_write(name, devadr, MV88E1116_MAC_CTRL_REG, reg);
  131. miiphy_write(name, devadr, MV88E1116_PGADR_REG, 0);
  132. /* reset the phy */
  133. miiphy_reset(name, devadr);
  134. printf("88E1116 Initialized on %s\n", name);
  135. }
  136. #endif /* CONFIG_RESET_PHY_R */