gplugd.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /*
  2. * (C) Copyright 2011
  3. * eInfochips Ltd. <www.einfochips.com>
  4. * Written-by: Ajay Bhargav <contact@8051projects.net>
  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. * SPDX-License-Identifier: GPL-2.0+
  13. */
  14. #include <common.h>
  15. #include <mvmfp.h>
  16. #include <asm/arch/cpu.h>
  17. #include <asm/arch/mfp.h>
  18. #include <asm/arch/armada100.h>
  19. #include <asm/gpio.h>
  20. #include <miiphy.h>
  21. #ifdef CONFIG_ARMADA100_FEC
  22. #include <net.h>
  23. #include <netdev.h>
  24. #endif /* CONFIG_ARMADA100_FEC */
  25. DECLARE_GLOBAL_DATA_PTR;
  26. int board_early_init_f(void)
  27. {
  28. u32 mfp_cfg[] = {
  29. /* I2C */
  30. MFP105_CI2C_SDA,
  31. MFP106_CI2C_SCL,
  32. /* Enable Console on UART3 */
  33. MFPO8_UART3_TXD,
  34. MFPO9_UART3_RXD,
  35. /* Ethernet PHY Interface */
  36. MFP086_ETH_TXCLK,
  37. MFP087_ETH_TXEN,
  38. MFP088_ETH_TXDQ3,
  39. MFP089_ETH_TXDQ2,
  40. MFP090_ETH_TXDQ1,
  41. MFP091_ETH_TXDQ0,
  42. MFP092_ETH_CRS,
  43. MFP093_ETH_COL,
  44. MFP094_ETH_RXCLK,
  45. MFP095_ETH_RXER,
  46. MFP096_ETH_RXDQ3,
  47. MFP097_ETH_RXDQ2,
  48. MFP098_ETH_RXDQ1,
  49. MFP099_ETH_RXDQ0,
  50. MFP100_ETH_MDC,
  51. MFP101_ETH_MDIO,
  52. MFP103_ETH_RXDV,
  53. /* SSP2 */
  54. MFP107_SSP2_RXD,
  55. MFP108_SSP2_TXD,
  56. MFP110_SSP2_CS,
  57. MFP111_SSP2_CLK,
  58. MFP_EOC /*End of configuration*/
  59. };
  60. /* configure MFP's */
  61. mfp_config(mfp_cfg);
  62. return 0;
  63. }
  64. int board_init(void)
  65. {
  66. struct armd1apb2_registers *apb2_regs =
  67. (struct armd1apb2_registers *)ARMD1_APBC2_BASE;
  68. /* arch number of Board */
  69. gd->bd->bi_arch_number = MACH_TYPE_SHEEVAD;
  70. /* adress of boot parameters */
  71. gd->bd->bi_boot_params = armd1_sdram_base(0) + 0x100;
  72. /* Assert PHY_RST# */
  73. gpio_direction_output(CONFIG_SYS_GPIO_PHY_RST, GPIO_LOW);
  74. udelay(10);
  75. /* Deassert PHY_RST# */
  76. gpio_set_value(CONFIG_SYS_GPIO_PHY_RST, GPIO_HIGH);
  77. /* Enable SSP2 clock */
  78. writel(SSP2_APBCLK | SSP2_FNCLK, &apb2_regs->ssp2_clkrst);
  79. return 0;
  80. }
  81. #ifdef CONFIG_ARMADA100_FEC
  82. int board_eth_init(bd_t *bis)
  83. {
  84. struct armd1apmu_registers *apmu_regs =
  85. (struct armd1apmu_registers *)ARMD1_APMU_BASE;
  86. /* Enable clock of ethernet controller */
  87. writel(FE_CLK_RST | FE_CLK_ENA, &apmu_regs->fecrc);
  88. return armada100_fec_register(ARMD1_FEC_BASE);
  89. }
  90. #ifdef CONFIG_RESET_PHY_R
  91. /* Configure and initialize PHY chip 88E3015 */
  92. void reset_phy(void)
  93. {
  94. u16 phy_adr;
  95. const char *name = "armd-fec0";
  96. if (miiphy_set_current_dev(name))
  97. return;
  98. /* command to read PHY dev address */
  99. if (miiphy_read(name, 0xff, 0xff, &phy_adr)) {
  100. printf("Err..%s could not read PHY dev address\n", __func__);
  101. return;
  102. }
  103. /* Set Ethernet LED in TX blink mode */
  104. miiphy_write(name, phy_adr, PHY_LED_MAN_REG, 0x00);
  105. miiphy_write(name, phy_adr, PHY_LED_PAR_SEL_REG, PHY_LED_VAL);
  106. /* reset the phy */
  107. miiphy_reset(name, phy_adr);
  108. debug("88E3015 Initialized on %s\n", name);
  109. }
  110. #endif /* CONFIG_RESET_PHY_R */
  111. #endif /* CONFIG_ARMADA100_FEC */