各位大神好,我们的板使用AM3352,网络芯片使用DP83848J,双网卡,u-boot驱动使用通用的CPSW,在驱动注册的时候,mdio寄存器的mdio-control第30bit写入1失败。具体代码如下:
static void cpsw_mdio_init(char *name, u32 mdio_base, u32 div)
{
struct mii_dev *bus = mdio_alloc();
mdio_regs = (struct cpsw_mdio_regs *)mdio_base;
/* set enable and clock divider */
__raw_writel(div | CONTROL_ENABLE, &mdio_regs->control);
/*
* wait for scan logic to settle:
* the scan time consists of (a) a large fixed component, and (b) a
* small component that varies with the mii bus frequency. These
* were estimated using measurements at 1.1 and 2.2 MHz on tnetv107x
* silicon. Since the effect of (b) was found to be largely
* negligible, we keep things simple here.
*/
udelay(1000);
bus->read = cpsw_mdio_read;
bus->write = cpsw_mdio_write;
sprintf(bus->name, name);
mdio_register(bus);
}
u-boot启动时,就停在红色代码的地方。mdio寄存器的地址为0x4a101000,control的地址为0x4a101004,使用CCS6.1连仿真器,查看0x4a101000寄存器为写保护,但是根据TRM,control的第30bit是R/W的,红色代码部分就是将0x400000FF写入control,即第30bit和0~7bit写入1,但是就是写入不成功。
另外:CPU和网络芯片使用MII接口,已设置gmii_sel寄存器为GMII模式。
Yaoming Qin:
请问您用的是什么版本的sdk?
这里是mii的接口,为什么要设为GMII?
Mark Liao:
回复 Yaoming Qin:
不好意思,写错了,是设置成MII模式。SDK使用的1.0的,具体就是ti-processor-sdk-linux-am335x-evm-01.00.00.03-Linux-x86-Install.bin
Mark Liao:
回复 Yaoming Qin:
在board_eth_init()中设置MII模式
if (board_is_bone(&header) || board_is_bone_lt(&header) ||board_is_idk(&header))
{ writel(MII_MODE_ENABLE, &cdev->miisel);cpsw_slaves[0].phy_if = cpsw_slaves[1].phy_if = PHY_INTERFACE_MODE_MII; } else { /* writel((RGMII_MODE_ENABLE | RGMII_INT_DELAY), &cdev->miisel); cpsw_slaves[0].phy_if = cpsw_slaves[1].phy_if = PHY_INTERFACE_MODE_RGMII; */ writel((MII_MODE_ENABLE), &cdev->miisel); cpsw_slaves[0].phy_if = cpsw_slaves[1].phy_if = PHY_INTERFACE_MODE_MII; }
rv = cpsw_register(&cpsw_data);