eth.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright 2016 Freescale Semiconductor, Inc.
  4. */
  5. #include <common.h>
  6. #include <asm/io.h>
  7. #include <netdev.h>
  8. #include <fm_eth.h>
  9. #include <fsl_dtsec.h>
  10. #include <fsl_mdio.h>
  11. #include <malloc.h>
  12. #include "../common/fman.h"
  13. int board_eth_init(bd_t *bis)
  14. {
  15. #ifdef CONFIG_FMAN_ENET
  16. int i;
  17. struct memac_mdio_info dtsec_mdio_info;
  18. struct memac_mdio_info tgec_mdio_info;
  19. struct mii_dev *dev;
  20. u32 srds_s1;
  21. struct ccsr_gur *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR);
  22. srds_s1 = in_be32(&gur->rcwsr[4]) &
  23. FSL_CHASSIS2_RCWSR4_SRDS1_PRTCL_MASK;
  24. srds_s1 >>= FSL_CHASSIS2_RCWSR4_SRDS1_PRTCL_SHIFT;
  25. dtsec_mdio_info.regs =
  26. (struct memac_mdio_controller *)CONFIG_SYS_FM1_DTSEC_MDIO_ADDR;
  27. dtsec_mdio_info.name = DEFAULT_FM_MDIO_NAME;
  28. /* Register the 1G MDIO bus */
  29. fm_memac_mdio_init(bis, &dtsec_mdio_info);
  30. tgec_mdio_info.regs =
  31. (struct memac_mdio_controller *)CONFIG_SYS_FM1_TGEC_MDIO_ADDR;
  32. tgec_mdio_info.name = DEFAULT_FM_TGEC_MDIO_NAME;
  33. /* Register the 10G MDIO bus */
  34. fm_memac_mdio_init(bis, &tgec_mdio_info);
  35. /* Set the two on-board RGMII PHY address */
  36. fm_info_set_phy_address(FM1_DTSEC3, RGMII_PHY1_ADDR);
  37. fm_info_set_phy_address(FM1_DTSEC4, RGMII_PHY2_ADDR);
  38. /* Set the two on-board SGMII PHY address */
  39. fm_info_set_phy_address(FM1_DTSEC5, SGMII_PHY1_ADDR);
  40. fm_info_set_phy_address(FM1_DTSEC6, SGMII_PHY2_ADDR);
  41. /* Set the on-board AQ PHY address */
  42. fm_info_set_phy_address(FM1_10GEC1, FM1_10GEC1_PHY_ADDR);
  43. switch (srds_s1) {
  44. case 0x1133:
  45. break;
  46. default:
  47. printf("Invalid SerDes protocol 0x%x for LS1046ARDB\n",
  48. srds_s1);
  49. break;
  50. }
  51. dev = miiphy_get_dev_by_name(DEFAULT_FM_MDIO_NAME);
  52. for (i = FM1_DTSEC1; i < FM1_DTSEC1 + CONFIG_SYS_NUM_FM1_DTSEC; i++)
  53. fm_info_set_mdio(i, dev);
  54. /* XFI on lane A, MAC 9 */
  55. dev = miiphy_get_dev_by_name(DEFAULT_FM_TGEC_MDIO_NAME);
  56. fm_info_set_mdio(FM1_10GEC1, dev);
  57. cpu_eth_init(bis);
  58. #endif
  59. return pci_eth_init(bis);
  60. }
  61. #ifdef CONFIG_FMAN_ENET
  62. int fdt_update_ethernet_dt(void *blob)
  63. {
  64. u32 srds_s1;
  65. int i, prop;
  66. int offset, nodeoff;
  67. const char *path;
  68. struct ccsr_gur *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR);
  69. srds_s1 = in_be32(&gur->rcwsr[4]) &
  70. FSL_CHASSIS2_RCWSR4_SRDS1_PRTCL_MASK;
  71. srds_s1 >>= FSL_CHASSIS2_RCWSR4_SRDS1_PRTCL_SHIFT;
  72. /* Cycle through all aliases */
  73. for (prop = 0; ; prop++) {
  74. const char *name;
  75. /* FDT might have been edited, recompute the offset */
  76. offset = fdt_first_property_offset(blob,
  77. fdt_path_offset(blob,
  78. "/aliases")
  79. );
  80. /* Select property number 'prop' */
  81. for (i = 0; i < prop; i++)
  82. offset = fdt_next_property_offset(blob, offset);
  83. if (offset < 0)
  84. break;
  85. path = fdt_getprop_by_offset(blob, offset, &name, NULL);
  86. nodeoff = fdt_path_offset(blob, path);
  87. switch (srds_s1) {
  88. case 0x1133:
  89. if (!strcmp(name, "ethernet0"))
  90. fdt_status_disabled(blob, nodeoff);
  91. if (!strcmp(name, "ethernet1"))
  92. fdt_status_disabled(blob, nodeoff);
  93. break;
  94. default:
  95. printf("%s: Invalid SerDes prtcl 0x%x for LS1046ARDB\n",
  96. __func__, srds_s1);
  97. break;
  98. }
  99. }
  100. return 0;
  101. }
  102. #endif