1.概述
NXP i.MX93處理器有兩個以太網控制器,其中eqos是TSN網絡控制器。另外一個Fec以太網外圍設備使設備能夠在以太網上傳輸和接收符合IEEE 802.3-2002標準的數據,提供了一個可配置的、靈活的外設,以滿足各種應用程序和客戶的需求。一般情況CPU集成MAC,PHY采用獨立芯片;CPU不集成MAC,MAC和PHY采用集成芯片。MAC和PHY工作在OSI模型的數據鏈路層和物理層。i.MX93的MAC集成在CPU內部,所以還需要外接PHY芯片。
MYD-LMX9X開發板外接了兩個YT8531SH千兆PHY芯片,ENET1原理圖如圖1-1:
圖1-1. ENET1原理圖
查看原理圖與《MYD-LMX9X-PinList-V1.0.pdf》得出 ENET1數據管腳與i.MX93的對應關系如表1-2:
表1-2. ENET1引腳對應關系
原理圖引腳 | 對應PinList管腳 | 管腳功能 | 管腳功能碼 |
ENET1_MDC | B31 | ENET1_MDC | 0 |
ENET1_MDIO | B32 | ENET1_MDIO | 0 |
ENET1_TXC | B22 | ENET1_TXC | 0 |
ENET1_TX_CTL | B23 | ENET1_TX_CTL | 0 |
ENET1_TD0 | B3 | ENET1_TD0 | 0 |
ENET1_TD1 | B21 | ENET1_TD1 | 0 |
ENET1_TD2 | B2 | ENET1_TD2 | 0 |
ENET1_TD3 | B1 | ENET1_TD3 | 0 |
ENET1_RXC | B30 | ENET1_RXC | 0 |
ENET1_RX_CTL | B29 | ENET1_RX_CTL | 0 |
ENET1_RD0 | B28 | ENET1_RD0 | 0 |
ENET1_RD1 | B27 | ENET1_RD1 | 0 |
ENET1_RD2 | B26 | ENET1_RD2 | 0 |
ENET1_RD3 | B25 | ENET1_RD3 | 0 |
ENET2原理圖如圖1-3:
圖1-3. ENET2原理圖查看原理圖與《MYD-LMX9X-PinList-V1.0.pdf》得出 ENET2數據管腳與MYD-LMX9X的對應關系如表1-4:
表1-4. ENET2引腳對應關系
原理圖引腳 | 對應PinList管腳 | 管腳功能 | 復用功能 |
ENET2_MDC | B5 | ENET2_MDC | 0 |
ENET2_MDIO | B6 | ENET2_MDIO | 0 |
ENET2_TXC | B19 | ENET2_TXC | 0 |
ENET2_TX_CTL | B14 | ENET2_TX_CTL | 0 |
ENET2_TD0 | B17 | ENET2_TD0 | 0 |
ENET2_TD1 | B16 | ENET2_TD1 | 0 |
ENET2_TD2 | B15 | ENET2_TD2 | 0 |
ENET2_TD3 | B18 | ENET2_TD3 | 0 |
ENET2_RXC | B12 | ENET2_RXC | 0 |
ENET2_RX_CTL | B10 | ENET2_RX_CTL | 0 |
ENET2_RD0 | B11 | ENET2_RD0 | 0 |
ENET2_RD1 | B8 | ENET2_RD1 | 0 |
ENET2_RD2 | B9 | ENET2_RD2 | 0 |
ENET2_RD3 | B7 | ENET2_RD3 | 0 |
2.網卡驅動移植2-1.查看內核設備引腳定義在內核中,有對i.MX93芯片的網口設備樹資源做了定義,此部分由芯片產商提供,屬于公共資源,實際上我們不需要修改這部分,只需要引用即可,如下:
PC:~/myd-lmx9x-bsp/myir-imx-linux$ cat arch/arm64/boot/dts/myir/imx93.dtsi...... fec: ethernet@42890000 { compatible = "fsl,imx93-fec", "fsl,imx8mp-fec", "fsl,imx8mq-fec"; reg = <0x42890000 0x10000>; interrupts = , , , ; clocks = <&clk IMX93_CLK_ENET1_GATE>, <&clk IMX93_CLK_ENET1_GATE>, <&clk IMX93_CLK_ENET_TIMER1>, <&clk IMX93_CLK_ENET_REF>, <&clk IMX93_CLK_ENET_REF_PHY>; clock-names = "ipg", "ahb", "ptp", "enet_clk_ref", "enet_out"; assigned-clocks = <&clk IMX93_CLK_ENET_TIMER1>, <&clk IMX93_CLK_ENET_REF>, <&clk IMX93_CLK_ENET_REF_PHY>; assigned-clock-parents = <&clk IMX93_CLK_SYS_PLL_PFD1_DIV2>, <&clk IMX93_CLK_SYS_PLL_PFD0_DIV2>, <&clk IMX93_CLK_SYS_PLL_PFD1_DIV2>; assigned-clock-rates = <100000000>, <250000000>, <50000000>; fsl,num-tx-queues = <3>; fsl,num-rx-queues = <3>; fsl,stop-mode = <&wakeupmix_gpr 0x0c 1>; status = "disabled"; };
eqos: ethernet@428a0000 { compatible = "nxp,imx93-dwmac-eqos", "snps,dwmac-5.10a"; reg = <0x428a0000 0x10000>; interrupts = , ; interrupt-names = "eth_wake_irq", "macirq"; clocks = <&clk IMX93_CLK_ENET_QOS_GATE>, <&clk IMX93_CLK_ENET_QOS_GATE>, <&clk IMX93_CLK_ENET_TIMER2>, <&clk IMX93_CLK_ENET>, <&clk IMX93_CLK_ENET_QOS_GATE>; clock-names = "stmmaceth", "pclk", "ptp_ref", "tx", "mem"; assigned-clocks = <&clk IMX93_CLK_ENET_TIMER2>, <&clk IMX93_CLK_ENET>; assigned-clock-parents = <&clk IMX93_CLK_SYS_PLL_PFD1_DIV2>, <&clk IMX93_CLK_SYS_PLL_PFD0_DIV2>; assigned-clock-rates = <100000000>, <250000000>; intf_mode = <&wakeupmix_gpr 0x28>; clk_csr = <0>; nvmem-cells =
上述只是對網口做了基本的初始化,并沒有對具體的硬件設備進行適配,在實際的情況下需要對具體的網口設備進行硬件引腳資源的適配。
2-2. 添加網卡設備樹節點根據原理圖的定義添加網口的設備樹配置,修改myir-imx93-11x11.dts文件,如下:
PC:~/myd-lmx9x-bsp/myir-imx-linux$ cat arch/arm64/boot/dts/myir/myir-imx93-11x11.dts......&eqos { pinctrl-names = "default"; pinctrl-0 = <&pinctrl_eqos>; phy-mode = "rgmii-id"; phy-handle =
mdio { compatible = "snps,dwmac-mdio"; #address-cells = <1>; #size-cells = <0>; clock-frequency = <5000000>;
ethphy1: ethernet-phy@1 { compatible = "ethernet-phy-ieee802.3-c22"; reg = <4>; eee-broken-1000t; }; };};
&fec { pinctrl-names = "default"; pinctrl-0 = <&pinctrl_fec>; phy-mode = "rgmii-id"; phy-handle =
mdio { compatible = "snps,dwmac-mdio"; #address-cells = <1>; #size-cells = <0>; clock-frequency = <5000000>;
ethphy2: ethernet-phy@2 { compatible = "ethernet-phy-ieee802.3-c22"; reg = <6>; eee-broken-1000t; }; };};
2-3. 網卡設備數配置添加網卡設備樹節點的eth1_pins和eth2_pins引腳定義:
pinctrl_eqos: eqosgrp { fsl,pins = < MX93_PAD_ENET1_MDC__ENET_QOS_MDC 0x57e MX93_PAD_ENET1_MDIO__ENET_QOS_MDIO 0x57e MX93_PAD_ENET1_RD0__ENET_QOS_RGMII_RD0 0x57e MX93_PAD_ENET1_RD1__ENET_QOS_RGMII_RD1 0x57e MX93_PAD_ENET1_RD2__ENET_QOS_RGMII_RD2 0x57e MX93_PAD_ENET1_RD3__ENET_QOS_RGMII_RD3 0x57e MX93_PAD_ENET1_RXC__CCM_ENET_QOS_CLOCK_GENERATE_RX_CLK 0x5fe MX93_PAD_ENET1_RX_CTL__ENET_QOS_RGMII_RX_CTL 0x57e MX93_PAD_ENET1_TD0__ENET_QOS_RGMII_TD0 0x57e MX93_PAD_ENET1_TD1__ENET_QOS_RGMII_TD1 0x57e MX93_PAD_ENET1_TD2__ENET_QOS_RGMII_TD2 0x57e MX93_PAD_ENET1_TD3__ENET_QOS_RGMII_TD3 0x57e MX93_PAD_ENET1_TXC__CCM_ENET_QOS_CLOCK_GENERATE_TX_CLK 0x5fe MX93_PAD_ENET1_TX_CTL__ENET_QOS_RGMII_TX_CTL 0x57e >; };
pinctrl_fec: fecgrp { fsl,pins = < MX93_PAD_ENET2_MDC__ENET1_MDC 0x57e MX93_PAD_ENET2_MDIO__ENET1_MDIO 0x57e MX93_PAD_ENET2_RD0__ENET1_RGMII_RD0 0x57e MX93_PAD_ENET2_RD1__ENET1_RGMII_RD1 0x57e MX93_PAD_ENET2_RD2__ENET1_RGMII_RD2 0x57e MX93_PAD_ENET2_RD3__ENET1_RGMII_RD3 0x57e MX93_PAD_ENET2_RXC__ENET1_RGMII_RXC 0x5fe MX93_PAD_ENET2_RX_CTL__ENET1_RGMII_RX_CTL 0x57e MX93_PAD_ENET2_TD0__ENET1_RGMII_TD0 0x57e MX93_PAD_ENET2_TD1__ENET1_RGMII_TD1 0x57e MX93_PAD_ENET2_TD2__ENET1_RGMII_TD2 0x57e MX93_PAD_ENET2_TD3__ENET1_RGMII_TD3 0x57e MX93_PAD_ENET2_TXC__ENET1_RGMII_TXC 0x5fe MX93_PAD_ENET2_TX_CTL__ENET1_RGMII_TX_CTL 0x57e >; };
2-4. 配置內核PHY驅動位于drivers/net/phy/motorcomm.c,我們只需要把這個驅動打開,編譯進內核即可,內核已默認配置網卡驅動,這里我們不再描述。最后編譯內核源碼,把新生成的設備樹dtb文件更新到板子即可。
2-5. 網絡測試
- 測試ENET1
root@myd-lmx9x:/# ping www.baidu.com -I eth0PING www.baidu.com (14.215.177.39): 56 data bytes64 bytes from 14.215.177.39: seq=0 ttl=56 time=7.987 ms64 bytes from 14.215.177.39: seq=1 ttl=56 time=8.030 ms64 bytes from 14.215.177.39: seq=2 ttl=56 time=7.250 ms
- 測試ENET2
root@myd-lmx9x:/# ping www.baidu.com -I eth1PING www.baidu.com (14.215.177.39): 56 data bytes64 bytes from 14.215.177.39: seq=3 ttl=56 time=7.507 ms64 bytes from 14.215.177.39: seq=4 ttl=56 time=7.488 ms64 bytes from 14.215.177.39: seq=5 ttl=56 time=7.151 ms64 bytes from 14.215.177.39: seq=6 ttl=56 time=7.043 ms
-
處理器
+關注
關注
68文章
18784瀏覽量
226110 -
開發板
+關注
關注
25文章
4701瀏覽量
95713 -
網卡驅動
+關注
關注
0文章
35瀏覽量
17611 -
米爾電子
+關注
關注
0文章
84瀏覽量
409
發布評論請先 登錄
相關推薦
評論