当前位置:   article > 正文

zynq平台 Linux系统 phy 88e1512驱动配置_88ea1512 sgmii

88ea1512 sgmii

88e1512和88e1510是一个系列的phy,采用marvell的通用phy驱动,驱动源码路径:\u-boot\drivers\net\phy\marvell.c

如上图所示,ETH2的工作模式为RGMII TO SGMII,SGMII与交换芯片bcm5396相连。设备树配置为RGMII模式,如下:

  1. &gem0 {
  2. status = "okay";
  3. phy-mode = "rgmii-id";
  4. phy-handle = <&ethernet_phy0>;
  5. ethernet_phy0: ethernet-phy@0 {
  6. reg = <0>;
  7. device_type = "ethernet-phy";
  8. };
  9. };

查看芯片手册Page 18 – Register 20,配置工作模式为RGMII (System mode) to SGMII (Media mode)。

   读写88e1512寄存器,先将要操作的Page number写入Register 22,再配置相应的寄存器。

   88e1512驱动配置步骤:

  • 配置工作模式为100,RGMII (System mode) to SGMII (Media mode)。
  • 所有寄存器配置完成后,将Page Address配置为1,PHY切换至Fiber Page,否则MAC获取的是PHY的Copper Page的link状态,无法获取到Fiber Page的link状态。
  • 关闭自协商,强制link为千兆全双工
    1. static int m88e1518_config(struct phy_device *phydev)
    2. {
    3. u16 reg;
    4. int temp_addr;
    5. /*
    6. * As per Marvell Release Notes - Alaska 88E1510/88E1518/88E1512
    7. * /88E1514 Rev A0, Errata Section 3.1
    8. */
    9. /* EEE initialization */
    10. phy_write(phydev, MDIO_DEVAD_NONE, MIIM_88E1118_PHY_PAGE, 0x00ff);
    11. phy_write(phydev, MDIO_DEVAD_NONE, 17, 0x214B);
    12. phy_write(phydev, MDIO_DEVAD_NONE, 16, 0x2144);
    13. phy_write(phydev, MDIO_DEVAD_NONE, 17, 0x0C28);
    14. phy_write(phydev, MDIO_DEVAD_NONE, 16, 0x2146);
    15. phy_write(phydev, MDIO_DEVAD_NONE, 17, 0xB233);
    16. phy_write(phydev, MDIO_DEVAD_NONE, 16, 0x214D);
    17. phy_write(phydev, MDIO_DEVAD_NONE, 17, 0xCC0C);
    18. phy_write(phydev, MDIO_DEVAD_NONE, 16, 0x2159);
    19. phy_write(phydev, MDIO_DEVAD_NONE, MIIM_88E1118_PHY_PAGE, 0x0000);
    20. /* SGMII-to-Copper mode initialization */
    21. if (phydev->interface == PHY_INTERFACE_MODE_SGMII ||
    22. phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) {
    23. /* Select page 18 */
    24. phy_write(phydev, MDIO_DEVAD_NONE, MIIM_88E1118_PHY_PAGE, 18);
    25. /* In reg 20, write MODE[2:0] = 0x1 (SGMII to Copper) */
    26. if (phydev->interface == PHY_INTERFACE_MODE_SGMII) {
    27. m88e1518_phy_writebits(phydev, MIIM_88E151x_GENERAL_CTRL,
    28. 0, 3, MIIM_88E151x_MODE_SGMII);
    29. }
    30. else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) {
    31. /* In reg 20, write MODE[2:0] = 0x4 (RGMII to SGMII) */
    32. m88e1518_phy_writebits(phydev, MIIM_88E151x_GENERAL_CTRL,
    33. 0, 3, MII_88E151x_MODE_RGMII_TO_SGMII);
    34. }
    35. /* PHY reset is necessary after changing MODE[2:0] */
    36. m88e1518_phy_writebits(phydev, MIIM_88E151x_GENERAL_CTRL,
    37. MIIM_88E151x_RESET_OFFS, 1, 1);
    38. /* Reset page selection */
    39. phy_write(phydev, MDIO_DEVAD_NONE, MIIM_88E1118_PHY_PAGE, 0);
    40. udelay(100);
    41. }
    42. if (phydev->interface == PHY_INTERFACE_MODE_SGMII) {
    43. reg = phy_read(phydev, MDIO_DEVAD_NONE,
    44. MIIM_88E1111_PHY_EXT_SR);
    45. reg &= ~(MIIM_88E1111_HWCFG_MODE_MASK);
    46. reg |= MIIM_88E1111_HWCFG_MODE_SGMII_NO_CLK;
    47. reg |= MIIM_88E1111_HWCFG_FIBER_COPPER_AUTO;
    48. phy_write(phydev, MDIO_DEVAD_NONE,
    49. MIIM_88E1111_PHY_EXT_SR, reg);
    50. }
    51. if (phy_interface_is_rgmii(phydev)) {
    52. phy_write(phydev, MDIO_DEVAD_NONE, MII_MARVELL_PHY_PAGE, 2);
    53. reg = phy_read(phydev, MDIO_DEVAD_NONE, MIIM_88E151x_PHY_MSCR);
    54. reg &= ~MIIM_88E151x_RGMII_RXTX_DELAY;
    55. if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID)
    56. reg |= MIIM_88E151x_RGMII_RXTX_DELAY;
    57. else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID)
    58. reg |= MIIM_88E151x_RGMII_RX_DELAY;
    59. else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID)
    60. reg |= MIIM_88E151x_RGMII_TX_DELAY;
    61. phy_write(phydev, MDIO_DEVAD_NONE, MIIM_88E151x_PHY_MSCR, reg);
    62. phy_write(phydev, MDIO_DEVAD_NONE, MII_MARVELL_PHY_PAGE, 0);
    63. }
    64. phy_write(phydev, MDIO_DEVAD_NONE, MII_MARVELL_PHY_PAGE, MII_MARVELL_FIBER_PAGE);
    65. phydev->autoneg = AUTONEG_DISABLE;
    66. phydev->speed = SPEED_1000;
    67. phydev->duplex = DUPLEX_FULL;
    68. puts("phy_interface_is_rgmii out!!!!!!!!\n");
    69. /* soft reset */
    70. phy_reset(phydev);
    71. genphy_config_aneg(phydev);
    72. //genphy_restart_aneg(phydev);
    73. return 0;
    74. }

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/2023面试高手/article/detail/81746
推荐阅读
相关标签
  

闽ICP备14008679号