hi3635c uboot 初始化网卡ar8035

一、ping

hisilicon # ping 192.168.9.160
ETH0: PHY(phyaddr=1, rgmii) not link!
ETH1: PHY(phyaddr=2, rgmii) not link!
higmac init fail!
ping failed; host 192.168.9.160 is not alive

修改linux-3.18.y\arch\arm\boot\dts\hi3536c-demb.dts

&mdio {
	ethphy: ethernet-phy@1 {
		reg = <2>;
	};
};

reg 改成2

说明这个时候网卡不能用,ping目的是使它进行初始化下,为使下面命令能执行

hisilicon # mii info 
PHY 0x02: OUI = 0x1374, Model = 0x07, Rev = 0x02, 100baseX, FDX

这个是PHY的地址是0x02 ,所以要进行下面的更改。这个是硬件设计决定的,也有可能是0x01。hi3635c 有两个phy接口。

1、修改文件u-boot-2010.06\include\configs\hi3536c.h

hi3635c uboot 初始化网卡ar8035_第1张图片

把 CONFIG_HIGMAC_PHY1_ADDR 1改为2

2、添加内容u-boot-2010.06\drivers\net\higmacv300\higmac.c


static int ar8031_phy_fixup(char *devname, u32 phyaddr)
{
	u16 val;

	/* To enable AR8031 output a 125MHz clk from CLK_25M */
	miiphy_write(devname, phyaddr, 0xd, 0x7);
	miiphy_write(devname, phyaddr, 0xe, 0x8016);
	miiphy_write(devname, phyaddr, 0xd, 0x4007);

	miiphy_read(devname, phyaddr, 0xe, &val);
	val &= 0xffe3;
	val |= 0x18;
	miiphy_write(devname, phyaddr, 0xe, val);

	/* introduce tx clock delay */
	miiphy_write(devname, phyaddr, 0x1d, 0x5);
	miiphy_read(devname, phyaddr, 0x1e, &val);
	val |= 0x0100;
	miiphy_write(devname, phyaddr, 0x1e, val);

	return 0;
}
#define BMCR_PDOWN		0x0800	

static int ar8035_phy_fixup(char *devname, u32 phyaddr)
{
	u16 val;

	/* Ar803x phy SmartEEE feature cause link status generates glitch,
	 * which cause ethernet link down/up issue, so disable SmartEEE
	 */
	miiphy_write(devname, phyaddr, 0xd, 0x3);
	miiphy_write(devname, phyaddr, 0xe, 0x805d);
	miiphy_write(devname, phyaddr, 0xd, 0x4003);

	miiphy_read(devname, phyaddr, 0xe, &val);
	miiphy_write(devname, phyaddr, 0xe, val & ~(1 << 8));

	/*
	 * Enable 125MHz clock from CLK_25M on the AR8031.  This
	 * is fed in to the IMX6 on the ENET_REF_CLK (V22) pad.
	 * Also, introduce a tx clock delay.
	 *
	 * This is the same as is the AR8031 fixup.
	 */
	ar8031_phy_fixup(devname,phyaddr);

	/*check phy power*/
	miiphy_read(devname, phyaddr,0x0, &val);
	if (val & BMCR_PDOWN)
		miiphy_write(devname, phyaddr, 0x0, val & ~BMCR_PDOWN);

	return 0;
}

在这个函数static int phy_fixup(char *devname, unsigned int phyaddr, enum if_mode phymode)里添加

    	/* PHY-AR8035 */
	if (((phy_id & PHY_ID_MASK) == PHY_ID_AR8035)&&
		(phymode == interface_mode_rgmii)) {
		ar8035_phy_fixup(devname,phyaddr);
	}

3、修改函数 uboot\u-boot-2010.06\common\miiphyutil.c

int miiphy_speed (char *devname, unsigned char addr)
{
	u16 bmcr, anlpar;
	u16 btsr, val;


	miiphy_read(devname,addr,PHY_BMSR,&val);


	if(val & BMSR_ESTATEN){
		/*if (miiphy_is_1000base_x (devname, addr)) {
				printf("file: %s function: %s line: %d \n",__FILE__,__FUNCTION__, __LINE__);
			return _1000BASET;
		}*/
	/*
如果不注释掉
miiphy_is_1000base_x (devname, addr)

返回的是1000m网,实际是100m网络。可能还有其他修改寄存器的值来判断是100m 还是1000m,不过现在就这种方式是可行的,其他的没有去调试。如果有1000m的交换机,这里就不需要修改。

不修改出现如下现象

hisilicon # ping 192.168.9.161
get_phy_device phy_id = 0x4dd072 
get_phy_device phy_id = 0x4dd072 
get_phy_device phy_id = 0xffffffff 
eth_init GMAC0_PHY = mdio0,GMAC0_PHY_ADDR = 0 
get_phy_device phy_id = 0x4dd072 
MAC:   00-0C-1C-88-88-00

ARP Retry count exceeded; starting again

ARP Retry count exceeded; starting again

二、修改完后的正常现象

hisilicon # ping 192.168.9.160
ETH0: PHY(phyaddr=2, rgmii) link UP: DUPLEX=FULL : SPEED=100M
MAC:   00-00-23-34-45-66
host 192.168.9.160 is alive


你可能感兴趣的:(uboot)