gplugd.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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/mfp.h>
  33. #include <asm/arch/armada100.h>
  34. #include <asm/gpio.h>
  35. #include <miiphy.h>
  36. #ifdef CONFIG_ARMADA100_FEC
  37. #include <net.h>
  38. #include <netdev.h>
  39. #endif /* CONFIG_ARMADA100_FEC */
  40. DECLARE_GLOBAL_DATA_PTR;
  41. int board_early_init_f(void)
  42. {
  43. u32 mfp_cfg[] = {
  44. /* I2C */
  45. MFP105_CI2C_SDA,
  46. MFP106_CI2C_SCL,
  47. /* Enable Console on UART3 */
  48. MFPO8_UART3_TXD,
  49. MFPO9_UART3_RXD,
  50. /* Ethernet PHY Interface */
  51. MFP086_ETH_TXCLK,
  52. MFP087_ETH_TXEN,
  53. MFP088_ETH_TXDQ3,
  54. MFP089_ETH_TXDQ2,
  55. MFP090_ETH_TXDQ1,
  56. MFP091_ETH_TXDQ0,
  57. MFP092_ETH_CRS,
  58. MFP093_ETH_COL,
  59. MFP094_ETH_RXCLK,
  60. MFP095_ETH_RXER,
  61. MFP096_ETH_RXDQ3,
  62. MFP097_ETH_RXDQ2,
  63. MFP098_ETH_RXDQ1,
  64. MFP099_ETH_RXDQ0,
  65. MFP100_ETH_MDC,
  66. MFP101_ETH_MDIO,
  67. MFP103_ETH_RXDV,
  68. MFP_EOC /*End of configuration*/
  69. };
  70. /* configure MFP's */
  71. mfp_config(mfp_cfg);
  72. return 0;
  73. }
  74. int board_init(void)
  75. {
  76. /* arch number of Board */
  77. gd->bd->bi_arch_number = MACH_TYPE_SHEEVAD;
  78. /* adress of boot parameters */
  79. gd->bd->bi_boot_params = armd1_sdram_base(0) + 0x100;
  80. /* Assert PHY_RST# */
  81. gpio_direction_output(CONFIG_SYS_GPIO_PHY_RST, GPIO_LOW);
  82. udelay(10);
  83. /* Deassert PHY_RST# */
  84. gpio_set_value(CONFIG_SYS_GPIO_PHY_RST, GPIO_HIGH);
  85. return 0;
  86. }
  87. #ifdef CONFIG_ARMADA100_FEC
  88. int board_eth_init(bd_t *bis)
  89. {
  90. struct armd1apmu_registers *apmu_regs =
  91. (struct armd1apmu_registers *)ARMD1_APMU_BASE;
  92. /* Enable clock of ethernet controller */
  93. writel(FE_CLK_RST | FE_CLK_ENA, &apmu_regs->fecrc);
  94. return armada100_fec_register(ARMD1_FEC_BASE);
  95. }
  96. #ifdef CONFIG_RESET_PHY_R
  97. /* Configure and initialize PHY chip 88E3015 */
  98. void reset_phy(void)
  99. {
  100. u16 phy_adr;
  101. const char *name = "armd-fec0";
  102. if (miiphy_set_current_dev(name))
  103. return;
  104. /* command to read PHY dev address */
  105. if (miiphy_read(name, 0xff, 0xff, &phy_adr)) {
  106. printf("Err..%s could not read PHY dev address\n", __func__);
  107. return;
  108. }
  109. /* Set Ethernet LED in TX blink mode */
  110. miiphy_write(name, phy_adr, PHY_LED_MAN_REG, 0x00);
  111. miiphy_write(name, phy_adr, PHY_LED_PAR_SEL_REG, PHY_LED_VAL);
  112. /* reset the phy */
  113. miiphy_reset(name, phy_adr);
  114. debug("88E3015 Initialized on %s\n", name);
  115. }
  116. #endif /* CONFIG_RESET_PHY_R */
  117. #endif /* CONFIG_ARMADA100_FEC */