基本原理:伪装phy 操作的返回值,以及为phy的属性填充等。
1)driver/net/zynq_gem.c
static int phy_detection(struct udevice *dev)
这个函数中的两处
phyread(priv, priv->phyaddr, PHY_DETECT_REG, &phyreg);
phyreg = PHY_DETECT_MASK;//
2)driver/net/phy/phy.c
int get_phy_id(struct mii_dev *bus, int addr, int devad, u32 *phy_id)
函数最后的返回值,给个合理的ID值,比如:
*phy_id = 0x7989001c;//
3)driver/net/phy/phy.c
static struct phy_device *phy_device_create(struct mii_dev *bus, int addr,
u32 phy_id,
phy_interface_t interface)
dev->duplex = DUPLEX_FULL;//
dev->link = 1;//
dev->interface = interface;//
dev->autoneg = AUTONEG_DISABLE;//AUTONEG_ENABLE;
4)driver/net/phy/phy.c
int phy_reset(struct phy_device *phydev)
函数最后的reg,赋值为0x0;
reg = 0;
5)driver/net/phy/phy.c
int genphy_update_link(struct phy_device *phydev)
unsigned int mii_reg;
phydev->link = 1;//
return 0;
6)driver/net/phy/phy.c
int genphy_parse_link(struct phy_device *phydev)
int mii_reg = phy_read(phydev, MDIO_DEVAD_NONE, MII_BMSR);
phydev->duplex = DUPLEX_FULL;//
phydev->speed = SPEED_1000;//
return 0;//
1)drivers/net/ethernet/cadence/macb.c
static int macb_mii_probe(struct net_device *dev)
强制参数如下:
bp->link = 1;//
bp->speed = SPEED_1000;//
bp->duplex = DUPLEX_FULL;//
2)driver/net/phy/phy_device.c
struct phy_device *phy_device_create(struct mii_bus *bus, int addr, int phy_id,
bool is_c45,
struct phy_c45_device_ids *c45_ids)
强制参数如下:
dev->speed = SPEED_1000;//
dev->duplex = DUPLEX_FULL;//
dev->link = 1;//
dev->interface = PHY_INTERFACE_MODE_RGMII_ID;//
dev->autoneg = AUTONEG_DISABLE;//
3)driver/net/phy/phy_device.c
static int get_phy_id(struct mii_bus *bus, int addr, u32 *phy_id,
bool is_c45, struct phy_c45_device_ids *c45_ids)
强制phy id如下:
*phy_id = 0x7989001c;//
4)driver/net/phy/phy_device.c
static int phy_poll_reset(struct phy_device *phydev)
函数直接强制返回0。
5)driver/net/phy/phy_device.c
static int genphy_config_init(struct phy_device *phydev)
强制参数,忽略phy的读值如下:
/* Do we support autonegotiation? */
val = phy_read(phydev, MII_BMSR);
//printk("val = 0%x\r\n",val);//
features |= SUPPORTED_1000baseT_Full;//
phydev->supported = features;//
phydev->advertising = features;//
return 0;//