gplugd.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /*
  2. * (C) Copyright 2011
  3. * eInfochips Ltd. <www.einfochips.com>
  4. * Written-by: Ajay Bhargav <ajay.bhargav@einfochips.com>
  5. *
  6. * Based on Aspenite:
  7. * (C) Copyright 2010
  8. * Marvell Semiconductor <www.marvell.com>
  9. * Written-by: Prafulla Wadaskar <prafulla@marvell.com>
  10. * Contributor: Mahavir Jain <mjain@marvell.com>
  11. *
  12. * See file CREDITS for list of people who contributed to this
  13. * project.
  14. *
  15. * This program is free software; you can redistribute it and/or
  16. * modify it under the terms of the GNU General Public License as
  17. * published by the Free Software Foundation; either version 2 of
  18. * the License, or (at your option) any later version.
  19. *
  20. * This program is distributed in the hope that it will be useful,
  21. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. * GNU General Public License for more details.
  24. *
  25. * You should have received a copy of the GNU General Public License
  26. * along with this program; if not, write to the Free Software
  27. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  28. * MA 02110-1301 USA
  29. */
  30. #include <common.h>
  31. #include <mvmfp.h>
  32. #include <asm/arch/cpu.h>
  33. #include <asm/arch/mfp.h>
  34. #include <asm/arch/armada100.h>
  35. #include <asm/gpio.h>
  36. #include <miiphy.h>
  37. #ifdef CONFIG_ARMADA100_FEC
  38. #include <net.h>
  39. #include <netdev.h>
  40. #endif /* CONFIG_ARMADA100_FEC */
  41. DECLARE_GLOBAL_DATA_PTR;
  42. int board_early_init_f(void)
  43. {
  44. u32 mfp_cfg[] = {
  45. /* I2C */
  46. MFP105_CI2C_SDA,
  47. MFP106_CI2C_SCL,
  48. /* Enable Console on UART3 */
  49. MFPO8_UART3_TXD,
  50. MFPO9_UART3_RXD,
  51. /* Ethernet PHY Interface */
  52. MFP086_ETH_TXCLK,
  53. MFP087_ETH_TXEN,
  54. MFP088_ETH_TXDQ3,
  55. MFP089_ETH_TXDQ2,
  56. MFP090_ETH_TXDQ1,
  57. MFP091_ETH_TXDQ0,
  58. MFP092_ETH_CRS,
  59. MFP093_ETH_COL,
  60. MFP094_ETH_RXCLK,
  61. MFP095_ETH_RXER,
  62. MFP096_ETH_RXDQ3,
  63. MFP097_ETH_RXDQ2,
  64. MFP098_ETH_RXDQ1,
  65. MFP099_ETH_RXDQ0,
  66. MFP100_ETH_MDC,
  67. MFP101_ETH_MDIO,
  68. MFP103_ETH_RXDV,
  69. /* SSP2 */
  70. MFP107_SSP2_RXD,
  71. MFP108_SSP2_TXD,
  72. MFP110_SSP2_CS,
  73. MFP111_SSP2_CLK,
  74. MFP_EOC /*End of configuration*/
  75. };
  76. /* configure MFP's */
  77. mfp_config(mfp_cfg);
  78. return 0;
  79. }
  80. int board_init(void)
  81. {
  82. struct armd1apb2_registers *apb2_regs =
  83. (struct armd1apb2_registers *)ARMD1_APBC2_BASE;
  84. /* arch number of Board */
  85. gd->bd->bi_arch_number = MACH_TYPE_SHEEVAD;
  86. /* adress of boot parameters */
  87. gd->bd->bi_boot_params = armd1_sdram_base(0) + 0x100;
  88. /* Assert PHY_RST# */
  89. gpio_direction_output(CONFIG_SYS_GPIO_PHY_RST, GPIO_LOW);
  90. udelay(10);
  91. /* Deassert PHY_RST# */
  92. gpio_set_value(CONFIG_SYS_GPIO_PHY_RST, GPIO_HIGH);
  93. /* Enable SSP2 clock */
  94. writel(SSP2_APBCLK | SSP2_FNCLK, &apb2_regs->ssp2_clkrst);
  95. return 0;
  96. }
  97. #ifdef CONFIG_ARMADA100_FEC
  98. int board_eth_init(bd_t *bis)
  99. {
  100. struct armd1apmu_registers *apmu_regs =
  101. (struct armd1apmu_registers *)ARMD1_APMU_BASE;
  102. /* Enable clock of ethernet controller */
  103. writel(FE_CLK_RST | FE_CLK_ENA, &apmu_regs->fecrc);
  104. return armada100_fec_register(ARMD1_FEC_BASE);
  105. }
  106. #ifdef CONFIG_RESET_PHY_R
  107. /* Configure and initialize PHY chip 88E3015 */
  108. void reset_phy(void)
  109. {
  110. u16 phy_adr;
  111. const char *name = "armd-fec0";
  112. if (miiphy_set_current_dev(name))
  113. return;
  114. /* command to read PHY dev address */
  115. if (miiphy_read(name, 0xff, 0xff, &phy_adr)) {
  116. printf("Err..%s could not read PHY dev address\n", __func__);
  117. return;
  118. }
  119. /* Set Ethernet LED in TX blink mode */
  120. miiphy_write(name, phy_adr, PHY_LED_MAN_REG, 0x00);
  121. miiphy_write(name, phy_adr, PHY_LED_PAR_SEL_REG, PHY_LED_VAL);
  122. /* reset the phy */
  123. miiphy_reset(name, phy_adr);
  124. debug("88E3015 Initialized on %s\n", name);
  125. }
  126. #endif /* CONFIG_RESET_PHY_R */
  127. #endif /* CONFIG_ARMADA100_FEC */