/* * Open and Initialize the interface * * Set up everything, reset the card, etc.. */ static int bfin_mac_open(struct net_device *dev) { struct bfin_mac_local *lp = netdev_priv(dev); int retval; pr_debug("%s: %s\n", dev->name, __func__); /* * Check that the address is valid. If its not, refuse * to bring the device up. The user must specify an * address using ifconfig eth0 hw ether xx:xx:xx:xx:xx:xx */ if (!is_valid_ether_addr(dev->dev_addr)) { printk(KERN_WARNING DRV_NAME ": no valid ethernet hw addr\n"); return -EINVAL; } /* initial rx and tx list */ retval = desc_list_init(); if (retval) return retval; phy_start(lp->phydev); phy_write(lp->phydev, MII_BMCR, BMCR_RESET); setup_system_regs(dev); setup_mac_addr(dev->dev_addr); bfin_mac_disable(); bfin_mac_enable(); pr_debug("hardware init finished\n"); netif_start_queue(dev); netif_carrier_on(dev); return 0; }
/* Init RDC MAC */ static int r6040_up(struct net_device *dev) { struct r6040_private *lp = netdev_priv(dev); void __iomem *ioaddr = lp->base; int ret; /* Initialise and alloc RX/TX buffers */ r6040_init_txbufs(dev); ret = r6040_alloc_rxbufs(dev); if (ret) return ret; /* improve performance (by RDC guys) */ r6040_phy_write(ioaddr, 30, 17, (r6040_phy_read(ioaddr, 30, 17) | 0x4000)); r6040_phy_write(ioaddr, 30, 17, ~((~r6040_phy_read(ioaddr, 30, 17)) | 0x2000)); r6040_phy_write(ioaddr, 0, 19, 0x0000); r6040_phy_write(ioaddr, 0, 30, 0x01F0); /* Initialize all MAC registers */ r6040_init_mac_regs(dev); phy_start(lp->phydev); return 0; }
static int s6gmac_open(struct net_device *dev) { struct s6gmac *pd = netdev_priv(dev); unsigned long flags; phy_read_status(pd->phydev); spin_lock_irqsave(&pd->lock, flags); pd->link.mbit = 0; s6gmac_linkisup(dev, pd->phydev->link); s6gmac_init_device(dev); s6gmac_init_stats(dev); s6gmac_init_dmac(dev); s6gmac_rx_fillfifo(pd); s6dmac_enable_chan(pd->rx_dma, pd->rx_chan, 2, 1, 0, 1, 0, 0, 0, 7, -1, 2, 0, 1); s6dmac_enable_chan(pd->tx_dma, pd->tx_chan, 2, 0, 1, 0, 0, 0, 0, 7, -1, 2, 0, 1); writel(0 << S6_GMAC_HOST_INT_TXBURSTOVER | 0 << S6_GMAC_HOST_INT_TXPREWOVER | 0 << S6_GMAC_HOST_INT_RXBURSTUNDER | 0 << S6_GMAC_HOST_INT_RXPOSTRFULL | 0 << S6_GMAC_HOST_INT_RXPOSTRUNDER, pd->reg + S6_GMAC_HOST_INTMASK); spin_unlock_irqrestore(&pd->lock, flags); phy_start(pd->phydev); netif_start_queue(dev); return 0; }
static int au1000_open(struct net_device *dev) { int retval; struct au1000_private *aup = netdev_priv(dev); if (au1000_debug > 4) printk("%s: open: dev=%p\n", dev->name, dev); if ((retval = request_irq(dev->irq, &au1000_interrupt, 0, dev->name, dev))) { printk(KERN_ERR "%s: unable to get IRQ %d\n", dev->name, dev->irq); return retval; } if ((retval = au1000_init(dev))) { printk(KERN_ERR "%s: error in au1000_init\n", dev->name); free_irq(dev->irq, dev); return retval; } if (aup->phy_dev) { /* cause the PHY state machine to schedule a link state check */ aup->phy_dev->state = PHY_CHANGELINK; phy_start(aup->phy_dev); } netif_start_queue(dev); if (au1000_debug > 4) printk("%s: open: Initialization done.\n", dev->name); return 0; }
static int bgmac_open(struct net_device *net_dev) { struct bgmac *bgmac = netdev_priv(net_dev); int err = 0; bgmac_chip_reset(bgmac); err = bgmac_dma_init(bgmac); if (err) return err; /* Specs say about reclaiming rings here, but we do that in DMA init */ bgmac_chip_init(bgmac); err = request_irq(bgmac->core->irq, bgmac_interrupt, IRQF_SHARED, KBUILD_MODNAME, net_dev); if (err < 0) { bgmac_err(bgmac, "IRQ request error: %d!\n", err); bgmac_dma_cleanup(bgmac); return err; } napi_enable(&bgmac->napi); phy_start(bgmac->phy_dev); netif_carrier_on(net_dev); return 0; }
/* Open the interface. * The interface is opened whenever "ifconfig" actives it. */ static int emac_open(struct net_device *dev) { struct emac_board_info *db = netdev_priv(dev); int ret; if (netif_msg_ifup(db)) dev_dbg(db->dev, "enabling %s\n", dev->name); if (request_irq(dev->irq, &emac_interrupt, 0, dev->name, dev)) return -EAGAIN; /* Initialize EMAC board */ emac_reset(db); emac_init_device(dev); ret = emac_mdio_probe(dev); if (ret < 0) { free_irq(dev->irq, dev); netdev_err(dev, "cannot probe MDIO bus\n"); return ret; } phy_start(dev->phydev); netif_start_queue(dev); return 0; }
static int fs_enet_open(struct net_device *dev) { struct fs_enet_private *fep = netdev_priv(dev); int r; int err; if (fep->fpi->use_napi) napi_enable(&fep->napi); /* Install our interrupt handler. */ r = fs_request_irq(dev, fep->interrupt, "fs_enet-mac", fs_enet_interrupt); if (r != 0) { printk(KERN_ERR DRV_MODULE_NAME ": %s Could not allocate FS_ENET IRQ!", dev->name); if (fep->fpi->use_napi) napi_disable(&fep->napi); return -EINVAL; } err = fs_init_phy(dev); if (err) { if (fep->fpi->use_napi) napi_disable(&fep->napi); return err; } phy_start(fep->phydev); return 0; }
/** * phylink_start() - start a phylink instance * @pl: a pointer to a &struct phylink returned from phylink_create() * * Start the phylink instance specified by @pl, configuring the MAC for the * desired link mode(s) and negotiation style. This should be called from the * network device driver's &struct net_device_ops ndo_open() method. */ void phylink_start(struct phylink *pl) { ASSERT_RTNL(); netdev_info(pl->netdev, "configuring for %s/%s link mode\n", phylink_an_mode_str(pl->link_an_mode), phy_modes(pl->link_config.interface)); /* Always set the carrier off */ netif_carrier_off(pl->netdev); /* Apply the link configuration to the MAC when starting. This allows * a fixed-link to start with the correct parameters, and also * ensures that we set the appropriate advertisement for Serdes links. */ phylink_resolve_flow(pl, &pl->link_config); phylink_mac_config(pl, &pl->link_config); /* Restart autonegotiation if using 802.3z to ensure that the link * parameters are properly negotiated. This is necessary for DSA * switches using 802.3z negotiation to ensure they see our modes. */ phylink_mac_an_restart(pl); clear_bit(PHYLINK_DISABLE_STOPPED, &pl->phylink_disable_state); phylink_run_resolve(pl); if (pl->link_an_mode == MLO_AN_FIXED && !IS_ERR(pl->link_gpio)) mod_timer(&pl->link_poll, jiffies + HZ); if (pl->sfp_bus) sfp_upstream_start(pl->sfp_bus); if (pl->phydev) phy_start(pl->phydev); }
static int hip04_mac_open(struct net_device *ndev) { struct hip04_priv *priv = netdev_priv(ndev); int i; priv->rx_head = 0; priv->tx_head = 0; priv->tx_tail = 0; hip04_reset_ppe(priv); for (i = 0; i < RX_DESC_NUM; i++) { dma_addr_t phys; phys = dma_map_single(&ndev->dev, priv->rx_buf[i], RX_BUF_SIZE, DMA_FROM_DEVICE); if (dma_mapping_error(&ndev->dev, phys)) return -EIO; priv->rx_phys[i] = phys; hip04_set_recv_desc(priv, phys); } if (priv->phy) phy_start(priv->phy); netdev_reset_queue(ndev); netif_start_queue(ndev); hip04_mac_enable(ndev); napi_enable(&priv->napi); return 0; }
/* Open the ethernet interface */ static int at91ether_open(struct net_device *dev) { struct macb *lp = netdev_priv(dev); u32 ctl; int ret; /* Clear internal statistics */ ctl = macb_readl(lp, NCR); macb_writel(lp, NCR, ctl | MACB_BIT(CLRSTAT)); macb_set_hwaddr(lp); ret = at91ether_start(dev); if (ret) return ret; /* Enable MAC interrupts */ macb_writel(lp, IER, MACB_BIT(RCOMP) | MACB_BIT(RXUBR) | MACB_BIT(ISR_TUND) | MACB_BIT(ISR_RLE) | MACB_BIT(TCOMP) | MACB_BIT(ISR_ROVR) | MACB_BIT(HRESP)); /* schedule a link state check */ phy_start(lp->phy_dev); netif_start_queue(dev); return 0; }
int bgmac_enet_resume(struct bgmac *bgmac) { int rc; if (!netif_running(bgmac->net_dev)) return 0; rc = bgmac_dma_init(bgmac); if (rc) return rc; bgmac_chip_init(bgmac); napi_enable(&bgmac->napi); netif_tx_lock(bgmac->net_dev); netif_device_attach(bgmac->net_dev); netif_tx_unlock(bgmac->net_dev); netif_start_queue(bgmac->net_dev); phy_start(bgmac->net_dev->phydev); return 0; }
static int bfin_mac_open(struct net_device *dev) { struct bfin_mac_local *lp = netdev_priv(dev); int retval; pr_debug("%s: %s\n", dev->name, __func__); if (!is_valid_ether_addr(dev->dev_addr)) { printk(KERN_WARNING DRV_NAME ": no valid ethernet hw addr\n"); return -EINVAL; } retval = desc_list_init(); if (retval) return retval; phy_start(lp->phydev); phy_write(lp->phydev, MII_BMCR, BMCR_RESET); setup_system_regs(dev); setup_mac_addr(dev->dev_addr); bfin_mac_disable(); bfin_mac_enable(); pr_debug("hardware init finished\n"); netif_start_queue(dev); netif_carrier_on(dev); return 0; }
static void sfp_sm_probe_phy(struct sfp *sfp) { struct phy_device *phy; int err; msleep(T_PHY_RESET_MS); phy = mdiobus_scan(sfp->i2c_mii, SFP_PHY_ADDR); if (IS_ERR(phy)) { dev_err(sfp->dev, "mdiobus scan returned %ld\n", PTR_ERR(phy)); return; } if (!phy) { dev_info(sfp->dev, "no PHY detected\n"); return; } err = sfp_add_phy(sfp->sfp_bus, phy); if (err) { phy_device_remove(phy); phy_device_free(phy); dev_err(sfp->dev, "sfp_add_phy failed: %d\n", err); return; } sfp->mod_phy = phy; phy_start(phy); }
static void ramips_phy_start(struct raeth_priv *re) { if (re->phy_dev) { phy_start(re->phy_dev); } else { re->link = 1; ramips_link_adjust(re); } }
static int dsa_slave_open(struct net_device *dev) { struct dsa_slave_priv *p = netdev_priv(dev); struct net_device *master = p->parent->dst->master_netdev; struct dsa_switch *ds = p->parent; u8 stp_state = dsa_port_is_bridged(p) ? BR_STATE_BLOCKING : BR_STATE_FORWARDING; int err; if (!(master->flags & IFF_UP)) return -ENETDOWN; if (!ether_addr_equal(dev->dev_addr, master->dev_addr)) { err = dev_uc_add(master, dev->dev_addr); if (err < 0) goto out; } if (dev->flags & IFF_ALLMULTI) { err = dev_set_allmulti(master, 1); if (err < 0) goto del_unicast; } if (dev->flags & IFF_PROMISC) { err = dev_set_promiscuity(master, 1); if (err < 0) goto clear_allmulti; } if (ds->drv->port_enable) { err = ds->drv->port_enable(ds, p->port, p->phy); if (err) goto clear_promisc; } if (ds->drv->port_stp_update) ds->drv->port_stp_update(ds, p->port, stp_state); if (p->phy) phy_start(p->phy); return 0; clear_promisc: if (dev->flags & IFF_PROMISC) dev_set_promiscuity(master, -1); clear_allmulti: if (dev->flags & IFF_ALLMULTI) dev_set_allmulti(master, -1); del_unicast: if (!ether_addr_equal(dev->dev_addr, master->dev_addr)) dev_uc_del(master, dev->dev_addr); out: return err; }
int dsa_slave_resume(struct net_device *slave_dev) { struct dsa_slave_priv *p = netdev_priv(slave_dev); netif_device_attach(slave_dev); if (p->phy) { phy_resume(p->phy); phy_start(p->phy); } return 0; }
void ag71xx_phy_start(struct ag71xx *ag) { struct ag71xx_platform_data *pdata = ag71xx_get_pdata(ag); if (ag->phy_dev) { phy_start(ag->phy_dev); } else if (pdata->mii_bus_dev && pdata->switch_data) { ag71xx_ar7240_start(ag); } else { ag->link = 1; ag71xx_link_adjust(ag); } }
void ag71xx_phy_start(struct ag71xx *ag) { if (ag->phy_dev) { phy_start(ag->phy_dev); } else { struct ag71xx_platform_data *pdata = ag71xx_get_pdata(ag); ag->duplex = pdata->duplex; ag->speed = pdata->speed; ag->link = 1; ag71xx_phy_link_update(ag); } }
/* Init RDC MAC */ static int pci_eth_up(struct net_device *dev) { struct pci_eth_private *priv = netdev_priv(dev); void __iomem *ioaddr = dev->base_addr; int ret; /* TODO: Initialise and alloc RX/TX buffers */ /* TODO: Initialize all MAC registers */ phy_start(priv->phydev); return 0; }
static void ramips_phy_start(struct raeth_priv *re) { unsigned long flags; if (re->phy_dev) { phy_start(re->phy_dev); } else { spin_lock_irqsave(&re->phy_lock, flags); re->link = 1; ramips_link_adjust(re); spin_unlock_irqrestore(&re->phy_lock, flags); } }
static void fs_timeout(struct net_device *dev) { struct fs_enet_private *fep = netdev_priv(dev); unsigned long flags; int wake = 0; fep->stats.tx_errors++; spin_lock_irqsave(&fep->lock, flags); if (dev->flags & IFF_UP) { phy_stop(fep->phydev); (*fep->ops->stop)(dev); (*fep->ops->restart)(dev); phy_start(fep->phydev); } phy_start(fep->phydev); wake = fep->tx_free && !(CBDR_SC(fep->cur_tx) & BD_ENET_TX_READY); spin_unlock_irqrestore(&fep->lock, flags); if (wake) netif_wake_queue(dev); }
/* PHY control start function */ static int sh_eth_phy_start(struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); int ret; ret = sh_eth_phy_init(ndev); if (ret) return ret; /* reset phy - this also wakes it from PDOWN */ phy_write(mdp->phydev, MII_BMCR, BMCR_RESET); phy_start(mdp->phydev); return 0; }
static int mvphy_start(phy_handle_t *ph) { int rv; rv = phy_start(ph); /* * If not autonegotiating, then we need to reset the PHY according to * Marvell. I don't think this is according to the spec. Apparently * the register states are not lost during this. */ if ((rv == 0) && (!ph->phy_adv_aneg)) { rv = ph->phy_reset(ph); } return (rv); }
static void mtk_phy_start(struct mtk_mac *mac) { struct mtk_eth *eth = mac->hw; unsigned long flags; int i; for (i = 0; i < 8; i++) { if (eth->phy->phy_fixed[i]) { spin_lock_irqsave(ð->phy->lock, flags); eth->link[i] = 1; if (eth->soc->mdio_adjust_link) eth->soc->mdio_adjust_link(eth, i); spin_unlock_irqrestore(ð->phy->lock, flags); } else if (eth->phy->phy[i]) { phy_start(eth->phy->phy[i]); } } }
static int yatse_open(struct net_device *ndev){ struct yatse_private *priv = netdev_priv(ndev); int ret; unsigned long flags; printk(KERN_INFO "yatse: opening\n"); priv->link = 0; #if 0 ret = dma_set_mask(&ndev->dev, 0xffffffffULL); /* 32-bit DMA addresses */ if(ret) goto out; #endif spin_lock_irqsave(&priv->dma.rx_lock, flags); spin_lock(&priv->dma.tx_lock); ret = yatse_dma_init(ndev); spin_unlock(&priv->dma.tx_lock); spin_unlock_irqrestore(&priv->dma.rx_lock, flags); if(ret) goto out; tasklet_init(&priv->tx_tasklet, yatse_tx_complete, (unsigned long)ndev); ret = yatse_init_phy(ndev); if(ret) goto out; ret = yatse_init_mac(ndev); if(ret) goto out; napi_enable(&priv->napi); phy_start(priv->phydev); if(priv->phy_irq != PHY_POLL) phy_start_interrupts(priv->phydev); netif_start_queue(ndev); printk(KERN_INFO "yatse: open done, interface up\n"); out: return ret; }
static int stmmac_resume(struct device *dev) { struct net_device *ndev = dev_get_drvdata(dev); struct stmmac_priv *priv = netdev_priv(ndev); if (!netif_running(ndev)) return 0; spin_lock(&priv->lock); /* Power Down bit, into the PM register, is cleared * automatically as soon as a magic packet or a Wake-up frame * is received. Anyway, it's better to manually clear * this bit because it can generate problems while resuming * from another devices (e.g. serial console). */ if (device_may_wakeup(priv->device)) priv->hw->mac->pmt(priv->ioaddr, 0); netif_device_attach(ndev); /* Enable the MAC and DMA */ stmmac_enable_mac(priv->ioaddr); priv->hw->dma->start_tx(priv->ioaddr); priv->hw->dma->start_rx(priv->ioaddr); #ifdef CONFIG_STMMAC_TIMER if (likely(priv->tm->enable)) priv->tm->timer_start(tmrate); #endif napi_enable(&priv->napi); if (priv->phydev) phy_start(priv->phydev); netif_start_queue(ndev); spin_unlock(&priv->lock); return 0; }
static int hisi_femac_net_open(struct net_device *dev) { struct hisi_femac_priv *priv = netdev_priv(dev); hisi_femac_port_reset(priv); hisi_femac_set_hw_mac_addr(priv, dev->dev_addr); hisi_femac_rx_refill(priv); netif_carrier_off(dev); netdev_reset_queue(dev); netif_start_queue(dev); napi_enable(&priv->napi); priv->link_status = 0; if (dev->phydev) phy_start(dev->phydev); writel(IRQ_ENA_PORT0_MASK, priv->glb_base + GLB_IRQ_RAW); hisi_femac_irq_enable(priv, IRQ_ENA_ALL | IRQ_ENA_PORT0 | DEF_INT_MASK); return 0; }
void phylink_start(struct phylink *pl) { WARN_ON(!lockdep_rtnl_is_held()); netdev_info(pl->netdev, "configuring for %s/%s link mode\n", phylink_an_mode_str(pl->link_an_mode), phy_modes(pl->link_config.interface)); /* Apply the link configuration to the MAC when starting. This allows * a fixed-link to start with the correct parameters, and also * ensures that we set the appropriate advertisment for Serdes links. */ phylink_resolve_flow(pl, &pl->link_config); phylink_mac_config(pl, &pl->link_config); clear_bit(PHYLINK_DISABLE_STOPPED, &pl->phylink_disable_state); phylink_run_resolve(pl); if (pl->sfp_bus) sfp_upstream_start(pl->sfp_bus); if (pl->phydev) phy_start(pl->phydev); }
static int xge_open(struct net_device *ndev) { struct xge_pdata *pdata = netdev_priv(ndev); int ret; ret = xge_create_desc_rings(ndev); if (ret) return ret; napi_enable(&pdata->napi); ret = xge_request_irq(ndev); if (ret) return ret; xge_intr_enable(pdata); xge_wr_csr(pdata, DMARXCTRL, 1); phy_start(ndev->phydev); xge_mac_enable(pdata); netif_start_queue(ndev); return 0; }
static int fs_enet_open(struct net_device *dev) { struct fs_enet_private *fep = netdev_priv(dev); int r; int err; /* to initialize the fep->cur_rx,... */ /* not doing this, will cause a crash in fs_enet_rx_napi */ fs_init_bds(fep->ndev); if (fep->fpi->use_napi) napi_enable(&fep->napi); /* Install our interrupt handler. */ r = request_irq(fep->interrupt, fs_enet_interrupt, IRQF_SHARED, "fs_enet-mac", dev); if (r != 0) { printk(KERN_ERR DRV_MODULE_NAME ": %s Could not allocate FS_ENET IRQ!", dev->name); if (fep->fpi->use_napi) napi_disable(&fep->napi); return -EINVAL; } err = fs_init_phy(dev); if (err) { free_irq(fep->interrupt, dev); if (fep->fpi->use_napi) napi_disable(&fep->napi); return err; } phy_start(fep->phydev); netif_start_queue(dev); return 0; }