static int fec_phy_init(struct fec_priv *priv, struct udevice *dev) { struct phy_device *phydev; int mask = 0xffffffff; #ifdef CONFIG_PHYLIB mask = 1 << CONFIG_FEC_MXC_PHYADDR; #endif phydev = phy_find_by_mask(priv->bus, mask, priv->interface); if (!phydev) return -ENODEV; phy_connect_dev(phydev, dev); priv->phydev = phydev; phy_config(phydev); return 0; }
static int pch_gbe_phy_init(struct eth_device *dev) { struct pch_gbe_priv *priv = dev->priv; struct phy_device *phydev; int mask = 0xffffffff; phydev = phy_find_by_mask(priv->bus, mask, priv->interface); if (!phydev) { printf("pch_gbe: cannot find the phy\n"); return -1; } phy_connect_dev(phydev, dev); phydev->supported &= PHY_GBIT_FEATURES; phydev->advertising = phydev->supported; priv->phydev = phydev; phy_config(phydev); return 1; }
static int tse_phy_init(struct altera_tse_priv *priv, void *dev) { struct phy_device *phydev; unsigned int mask = 0xffffffff; if (priv->phyaddr) mask = 1 << priv->phyaddr; phydev = phy_find_by_mask(priv->bus, mask, priv->interface); if (!phydev) return -ENODEV; phy_connect_dev(phydev, dev); phydev->supported &= PHY_GBIT_FEATURES; phydev->advertising = phydev->supported; priv->phydev = phydev; phy_config(phydev); return 0; }
static int fec_probe(bd_t *bd, int dev_id, uint32_t base_addr, struct mii_dev *bus, int phy_id) #endif { struct eth_device *edev; struct fec_priv *fec; unsigned char ethaddr[6]; uint32_t start; int ret = 0; /* create and fill edev struct */ edev = (struct eth_device *)malloc(sizeof(struct eth_device)); if (!edev) { puts("fec_mxc: not enough malloc memory for eth_device\n"); ret = -ENOMEM; goto err1; } fec = (struct fec_priv *)malloc(sizeof(struct fec_priv)); if (!fec) { puts("fec_mxc: not enough malloc memory for fec_priv\n"); ret = -ENOMEM; goto err2; } memset(edev, 0, sizeof(*edev)); memset(fec, 0, sizeof(*fec)); ret = fec_alloc_descs(fec); if (ret) goto err3; edev->priv = fec; edev->init = fec_init; edev->send = fec_send; edev->recv = fec_recv; edev->halt = fec_halt; edev->write_hwaddr = fec_set_hwaddr; fec->eth = (struct ethernet_regs *)base_addr; fec->bd = bd; fec->xcv_type = CONFIG_FEC_XCV_TYPE; /* Reset chip. */ writel(readl(&fec->eth->ecntrl) | FEC_ECNTRL_RESET, &fec->eth->ecntrl); start = get_timer(0); while (readl(&fec->eth->ecntrl) & FEC_ECNTRL_RESET) { if (get_timer(start) > (CONFIG_SYS_HZ * 5)) { printf("FEC MXC: Timeout reseting chip\n"); goto err4; } udelay(10); } fec_reg_setup(fec); fec_set_dev_name(edev->name, dev_id); fec->dev_id = (dev_id == -1) ? 0 : dev_id; fec->bus = bus; fec_mii_setspeed(bus->priv); #ifdef CONFIG_PHYLIB fec->phydev = phydev; phy_connect_dev(phydev, edev); /* Configure phy */ phy_config(phydev); #else fec->phy_id = phy_id; #endif eth_register(edev); if (fec_get_hwaddr(edev, dev_id, ethaddr) == 0) { debug("got MAC%d address from fuse: %pM\n", dev_id, ethaddr); memcpy(edev->enetaddr, ethaddr, 6); if (!getenv("ethaddr")) eth_setenv_enetaddr("ethaddr", ethaddr); } return ret; err4: fec_free_descs(fec); err3: free(fec); err2: free(edev); err1: return ret; }