eth_t102xrdb.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*
  2. * Copyright 2014 Freescale Semiconductor, Inc.
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #include <common.h>
  7. #include <command.h>
  8. #include <netdev.h>
  9. #include <asm/mmu.h>
  10. #include <asm/processor.h>
  11. #include <asm/immap_85xx.h>
  12. #include <asm/fsl_law.h>
  13. #include <asm/fsl_serdes.h>
  14. #include <asm/fsl_portals.h>
  15. #include <asm/fsl_liodn.h>
  16. #include <malloc.h>
  17. #include <fm_eth.h>
  18. #include <fsl_mdio.h>
  19. #include <miiphy.h>
  20. #include <phy.h>
  21. #include <asm/fsl_dtsec.h>
  22. #include <asm/fsl_serdes.h>
  23. #include "../common/fman.h"
  24. int board_eth_init(bd_t *bis)
  25. {
  26. #if defined(CONFIG_FMAN_ENET)
  27. int i, interface;
  28. struct memac_mdio_info dtsec_mdio_info;
  29. struct memac_mdio_info tgec_mdio_info;
  30. struct mii_dev *dev;
  31. ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  32. u32 srds_s1;
  33. srds_s1 = in_be32(&gur->rcwsr[4]) &
  34. FSL_CORENET2_RCWSR4_SRDS1_PRTCL;
  35. srds_s1 >>= FSL_CORENET2_RCWSR4_SRDS1_PRTCL_SHIFT;
  36. dtsec_mdio_info.regs =
  37. (struct memac_mdio_controller *)CONFIG_SYS_FM1_DTSEC_MDIO_ADDR;
  38. dtsec_mdio_info.name = DEFAULT_FM_MDIO_NAME;
  39. /* Register the 1G MDIO bus */
  40. fm_memac_mdio_init(bis, &dtsec_mdio_info);
  41. tgec_mdio_info.regs =
  42. (struct memac_mdio_controller *)CONFIG_SYS_FM1_TGEC_MDIO_ADDR;
  43. tgec_mdio_info.name = DEFAULT_FM_TGEC_MDIO_NAME;
  44. /* Register the 10G MDIO bus */
  45. fm_memac_mdio_init(bis, &tgec_mdio_info);
  46. /* Set the on-board RGMII PHY address */
  47. fm_info_set_phy_address(FM1_DTSEC4, RGMII_PHY1_ADDR);
  48. switch (srds_s1) {
  49. case 0x95:
  50. /* set the on-board RGMII2 PHY */
  51. fm_info_set_phy_address(FM1_DTSEC3, RGMII_PHY2_ADDR);
  52. /* set 10G XFI with Aquantia AQR105 PHY */
  53. fm_info_set_phy_address(FM1_10GEC1, FM1_10GEC1_PHY_ADDR);
  54. break;
  55. case 0x77:
  56. case 0x135:
  57. /* set the on-board 2.5G SGMII AQR105 PHY */
  58. fm_info_set_phy_address(FM1_DTSEC3, SGMII_PHY1_ADDR);
  59. break;
  60. default:
  61. printf("SerDes protocol 0x%x is not supported on T102xRDB\n",
  62. srds_s1);
  63. break;
  64. }
  65. for (i = FM1_DTSEC1; i < FM1_DTSEC1 + CONFIG_SYS_NUM_FM1_DTSEC; i++) {
  66. interface = fm_info_get_enet_if(i);
  67. switch (interface) {
  68. case PHY_INTERFACE_MODE_RGMII:
  69. dev = miiphy_get_dev_by_name(DEFAULT_FM_MDIO_NAME);
  70. fm_info_set_mdio(i, dev);
  71. break;
  72. case PHY_INTERFACE_MODE_SGMII_2500:
  73. dev = miiphy_get_dev_by_name(DEFAULT_FM_TGEC_MDIO_NAME);
  74. fm_info_set_mdio(i, dev);
  75. break;
  76. default:
  77. break;
  78. }
  79. }
  80. for (i = FM1_10GEC1; i < FM1_10GEC1 + CONFIG_SYS_NUM_FM1_10GEC; i++) {
  81. switch (fm_info_get_enet_if(i)) {
  82. case PHY_INTERFACE_MODE_XGMII:
  83. dev = miiphy_get_dev_by_name(DEFAULT_FM_TGEC_MDIO_NAME);
  84. fm_info_set_mdio(i, dev);
  85. break;
  86. default:
  87. break;
  88. }
  89. }
  90. cpu_eth_init(bis);
  91. #endif /* CONFIG_FMAN_ENET */
  92. return pci_eth_init(bis);
  93. }
  94. void board_ft_fman_fixup_port(void *fdt, char *compat, phys_addr_t addr,
  95. enum fm_port port, int offset)
  96. {
  97. if ((fm_info_get_enet_if(port) == PHY_INTERFACE_MODE_SGMII_2500) &&
  98. (port == FM1_DTSEC3)) {
  99. fdt_set_phy_handle(fdt, compat, addr, "sg_2500_aqr105_phy4");
  100. fdt_setprop(fdt, offset, "phy-connection-type",
  101. "sgmii-2500", 10);
  102. fdt_status_disabled_by_alias(fdt, "xg_aqr105_phy3");
  103. }
  104. }
  105. void fdt_fixup_board_enet(void *fdt)
  106. {
  107. }