NXP i.MX6 ARM-Linux 修改RGMII成RMII

作者:陈善焕

项目场景:

在眺望电子TW-IMX6DL-EVM开发板上将默认的千兆以太网接口改成百兆以太网接口:

编译环境及开发包:
主机:ubuntu18.04
交叉编译器:arm-linux-gnueabihf-gcc
QT5.12.8:qt-everywhere-opensource-src-5.12.8
开发板:TW-IMX6DL-EVM
Linux:Linux-4.1.15
串口工具:Xshell

注意:本文章的所有命令涉及到的路径均为眺望电子官方环境路径,需根据自身实际环境改变。本文所演示的平台来自于眺望电子 iMX6 ARM嵌入式平台,这是一个基于NXP iMX6 ARM处理器,支持单核/双核Cortex-A9的核心板。


解决方案:

1.修改设备树

1.1修改网卡模式为百兆

目录:arch/arm/boot/dts/imx6qdl-sabresd.dtsi

&fec {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_enet>;
phy-mode = "rmii"; /* 原rgmii修改为rmii */
phy-reset-gpios = <&gpio3 18 0>;
fsl,magic-packet;
status = "okay";

1.2修改引脚

目录:arch/arm/boot/dts/imx6qdl-sabresd.dtsi

&iomuxc {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_hog>;

imx6qdl-sabresd {
pinctrl_hog: hoggrp {
fsl,pins = <
...
/*MX6QDL_PAD_ENET_TXD1__GPIO1_IO29 0x80000000*/
...
/*MX6QDL_PAD_ENET_CRS_DV__GPIO1_IO25 0x80000000*/
...
/*MX6QDL_PAD_ENET_RXD0__GPIO1_IO27 0x80000000*/
...

pinctrl_enet: enetgrp {
fsl,pins = <
/* 注释如下 */
/*
MX6QDL_PAD_ENET_MDIO__ENET_MDIO 0x1b0b0
MX6QDL_PAD_ENET_MDC__ENET_MDC 0x1b0b0
MX6QDL_PAD_RGMII_TXC__RGMII_TXC 0x1b0b0
MX6QDL_PAD_RGMII_TD0__RGMII_TD0 0x1b0b0
MX6QDL_PAD_RGMII_TD1__RGMII_TD1 0x1b0b0
MX6QDL_PAD_RGMII_TD2__RGMII_TD2 0x1b0b0
MX6QDL_PAD_RGMII_TD3__RGMII_TD3 0x1b0b0
MX6QDL_PAD_RGMII_TX_CTL__RGMII_TX_CTL 0x1b0b0
MX6QDL_PAD_ENET_REF_CLK__ENET_TX_CLK 0x1b0b0
MX6QDL_PAD_RGMII_RXC__RGMII_RXC 0x1b0b0
MX6QDL_PAD_RGMII_RD0__RGMII_RD0 0x1b0b0
MX6QDL_PAD_RGMII_RD1__RGMII_RD1 0x1b0b0
MX6QDL_PAD_RGMII_RD2__RGMII_RD2 0x1b0b0
MX6QDL_PAD_RGMII_RD3__RGMII_RD3 0x1b0b0
MX6QDL_PAD_RGMII_RX_CTL__RGMII_RX_CTL 0x1b0b0
MX6QDL_PAD_GPIO_16__ENET_REF_CLK 0x4001b0a8
>;
*/
/* 新增如下 */
MX6QDL_PAD_ENET_MDIO__ENET_MDIO 0x1b0b0
MX6QDL_PAD_ENET_MDC__ENET_MDC 0x1b0b0
MX6QDL_PAD_ENET_RXD0__ENET_RX_DATA0 0x1b0b0
MX6QDL_PAD_ENET_RXD1__ENET_RX_DATA1 0x1b0b0
MX6QDL_PAD_ENET_CRS_DV__ENET_RX_EN 0x1b0b0
MX6QDL_PAD_ENET_TXD0__ENET_TX_DATA0 0x1b0b0
MX6QDL_PAD_ENET_TXD1__ENET_TX_DATA1 0x1b0b0
MX6QDL_PAD_ENET_TX_EN__ENET_TX_EN 0x1b0b0
MX6QDL_PAD_GPIO_16__ENET_REF_CLK 0x4001b0a8
MX6QDL_PAD_ENET_RX_ER__ENET_RX_ER 0x1b0b0
MX6QDL_PAD_EIM_D18__GPIO3_IO18 0x80000000 /* 复位引脚 */
>;
};

1.3修改时钟

目录:arch/arm/mach-imx/clk-imx6q.c

static void init_ldb_clks(struct device_node *np)
{
...
//clk_set_rate(clk[IMX6QDL_CLK_ENET_REF], 125000000); /* 注释 */
clk_set_rate(clk[IMX6QDL_CLK_ENET_REF], 50000000); /* 新增 */
...
}

1.3驱动修改

目录:arch/arm/mach-imx/mach-imx6q.c

/* 设置ar8031_phy_fixup为空函数 */
static int ar8031_phy_fixup(struct phy_device *dev)
{
#if 0
...
#endif
return 0;
}
...
static inline void imx6q_enet_init(void)
{
struct regmap *gpr; /* 新增 */
gpr = syscon_regmap_lookup_by_compatible("fsl,imx6q-iomuxc-gpr"); /* 新增 */
regmap_update_bits(gpr, IOMUXC_GPR1, 1 << 21, 1); /* 新增 */
...
}

目录:drivers/net/ethernet/freescale/fec_main.c

static int fec_enet_mii_probe(struct net_device *ndev)
{
...
     if (fep->quirks & FEC_QUIRK_HAS_GBIT) {
         //phy_dev->supported &= PHY_GBIT_FEATURES;                       /* 注释 */
         phy_dev->supported &= PHY_BASIC_FEATURES;                        /* 新增 */
/*                                                                       /* 注释如下段 */
         phy_dev->supported &= ~SUPPORTED_1000baseT_Half;
 #if !defined(CONFIG_M5272)
         phy_dev->supported |= SUPPORTED_Pause;
 #endif
*/                                                                       /* 注释结束 */
}
上一篇:SAS truncover scanover pad missover选项


下一篇:FFmpeg代码导读——HEVC在RTMP中的扩展