1. 引脚配置
编辑board.dts
T113有两组RMII引脚, 按理说应该统一选择一组(两组的引脚功能复用号不一样), 硬件工程师为了布线方便, 25Mhz时钟引脚选择了PE10(应该用复用号8), 没想到也能用, 具体原因没有能力深究了, 这里建议选择PG11作为时钟.

a) allwinner,muxsel选择<4>, 如果是PE组, 是<8>
b) phy-mode = “rmii”; 原来的是rgmii, 用于千兆芯片.
c) phy-rst = <&pio PG 7 GPIO_ACTIVE_HIGH>;选择合适的引脚作为复位控制脚.
d) use_ephy25m = <1>; 用芯片生成时钟, 如果IP101外接晶振设为0
gmac0_pins_a: gmac@0 {
allwinner,pins = "PG0", "PG1", "PG2", "PG3", "PG4",
"PG5", "PG12", "PG13", "PG14", "PG15", "PE10"; // seems wrong, but worked..
// should use PG11 as 25Mhz
allwinner,function = "gmac0";
allwinner,muxsel = <4>; // <8>; // 8 is PE
allwinner,drive = <1>;
allwinner,pull = <0>;
};
gmac0_pins_b: gmac@1 {
allwinner,pins = "PG0", "PG1", "PG2", "PG3", "PG4",
"PG5", "PG12", "PG13", "PG14", "PG15", "PE10";
allwinner,function = "gpio_in";
allwinner,muxsel = <0>;
allwinner,drive = <1>;
allwinner,pull = <0>;
};
&gmac0 {
pinctrl-0 = <&gmac0_pins_a>;
pinctrl-1 = <&gmac0_pins_b>;
pinctrl-names = "default", "sleep";
phy-mode = "rmii";
use_ephy25m = <1>;
tx-delay = <7>;
rx-delay = <31>;
phy-rst = <&pio PG 7 GPIO_ACTIVE_HIGH>;
status = "okay";
};
2. 配置内核menuconfig
sudo ./build.sh menuconfig
依次找到以下选项(括号中是快捷键, 可以快速定位, 但是必须在当前页中能看到才可以定位, 如果有多个相同快捷键
则会按顺序定位)
Device Drivers(D)
Nework device support(e)
PHY Device support and infrastructure(P)
ICPlus PHYs(I)

我的开发板是米尔电子的, 原来板上用的是千兆芯片, 还要把原来的Motorcomm PHYS取消选中.
3. 源码修改
在sunxi-gmac.c中有一行代码
phydev->is_gigabit_capable = 1;
参考链接 https://blog.csdn.net/qq_27718231/article/details/140848192
先看了这篇文章, 就不测会不会出问题了. 这个标志位是用来指示用千兆芯片的, IP101GR是百兆, 这里添加一个判断, 如果是百兆就置0.
phydev->is_gigabit_capable = 1;
if ( phydev->interface == PHY_INTERFACE_MODE_RMII ) {
printk("disable is_gigabit_capable\n");
phydev->is_gigabit_capable = 0;
}
mac不固定问题
源码中使用sunxi_get_soc_chipid来获取芯片ID, 然后生成mac
但是原来被定义成空的宏, 无法获取到ID于是生成了随机mac
把它注释掉, 再包含sunxi-sid.h, 头文件中有sunxi_get_soc_chipid的定义.
//#define sunxi_get_soc_chipid(x) {}
#include <linux/sunxi-sid.h>
这样mac地址就固定了.

2509

被折叠的 条评论
为什么被折叠?



