Lines Matching full:pd

87 static inline u32 smsc9420_reg_read(struct smsc9420_pdata *pd, u32 offset)  in smsc9420_reg_read()  argument
89 return ioread32(pd->ioaddr + offset); in smsc9420_reg_read()
93 smsc9420_reg_write(struct smsc9420_pdata *pd, u32 offset, u32 value) in smsc9420_reg_write() argument
95 iowrite32(value, pd->ioaddr + offset); in smsc9420_reg_write()
98 static inline void smsc9420_pci_flush_write(struct smsc9420_pdata *pd) in smsc9420_pci_flush_write() argument
101 smsc9420_reg_read(pd, ID_REV); in smsc9420_pci_flush_write()
106 struct smsc9420_pdata *pd = bus->priv; in smsc9420_mii_read() local
111 spin_lock_irqsave(&pd->phy_lock, flags); in smsc9420_mii_read()
114 if ((smsc9420_reg_read(pd, MII_ACCESS) & MII_ACCESS_MII_BUSY_)) { in smsc9420_mii_read()
115 netif_warn(pd, drv, pd->dev, "MII is busy???\n"); in smsc9420_mii_read()
122 smsc9420_reg_write(pd, MII_ACCESS, addr); in smsc9420_mii_read()
126 if (!(smsc9420_reg_read(pd, MII_ACCESS) & in smsc9420_mii_read()
128 reg = (u16)smsc9420_reg_read(pd, MII_DATA); in smsc9420_mii_read()
134 netif_warn(pd, drv, pd->dev, "MII busy timeout!\n"); in smsc9420_mii_read()
137 spin_unlock_irqrestore(&pd->phy_lock, flags); in smsc9420_mii_read()
144 struct smsc9420_pdata *pd = bus->priv; in smsc9420_mii_write() local
149 spin_lock_irqsave(&pd->phy_lock, flags); in smsc9420_mii_write()
152 if ((smsc9420_reg_read(pd, MII_ACCESS) & MII_ACCESS_MII_BUSY_)) { in smsc9420_mii_write()
153 netif_warn(pd, drv, pd->dev, "MII is busy???\n"); in smsc9420_mii_write()
158 smsc9420_reg_write(pd, MII_DATA, (u32)val); in smsc9420_mii_write()
163 smsc9420_reg_write(pd, MII_ACCESS, addr); in smsc9420_mii_write()
167 if (!(smsc9420_reg_read(pd, MII_ACCESS) & in smsc9420_mii_write()
175 netif_warn(pd, drv, pd->dev, "MII busy timeout!\n"); in smsc9420_mii_write()
178 spin_unlock_irqrestore(&pd->phy_lock, flags); in smsc9420_mii_write()
190 static int smsc9420_eeprom_reload(struct smsc9420_pdata *pd) in smsc9420_eeprom_reload() argument
194 BUG_ON(!pd); in smsc9420_eeprom_reload()
196 if (smsc9420_reg_read(pd, E2P_CMD) & E2P_CMD_EPC_BUSY_) { in smsc9420_eeprom_reload()
197 netif_dbg(pd, drv, pd->dev, "%s: Eeprom busy\n", __func__); in smsc9420_eeprom_reload()
201 smsc9420_reg_write(pd, E2P_CMD, in smsc9420_eeprom_reload()
206 if (!(smsc9420_reg_read(pd, E2P_CMD) & E2P_CMD_EPC_BUSY_)) in smsc9420_eeprom_reload()
210 netif_warn(pd, drv, pd->dev, "%s: Eeprom timed out\n", __func__); in smsc9420_eeprom_reload()
217 struct smsc9420_pdata *pd = netdev_priv(netdev); in smsc9420_ethtool_get_drvinfo() local
220 strscpy(drvinfo->bus_info, pci_name(pd->pdev), in smsc9420_ethtool_get_drvinfo()
227 struct smsc9420_pdata *pd = netdev_priv(netdev); in smsc9420_ethtool_get_msglevel() local
228 return pd->msg_enable; in smsc9420_ethtool_get_msglevel()
233 struct smsc9420_pdata *pd = netdev_priv(netdev); in smsc9420_ethtool_set_msglevel() local
234 pd->msg_enable = data; in smsc9420_ethtool_set_msglevel()
247 struct smsc9420_pdata *pd = netdev_priv(dev); in smsc9420_ethtool_getregs() local
252 regs->version = smsc9420_reg_read(pd, ID_REV); in smsc9420_ethtool_getregs()
254 data[j++] = smsc9420_reg_read(pd, i); in smsc9420_ethtool_getregs()
265 static void smsc9420_eeprom_enable_access(struct smsc9420_pdata *pd) in smsc9420_eeprom_enable_access() argument
267 unsigned int temp = smsc9420_reg_read(pd, GPIO_CFG); in smsc9420_eeprom_enable_access()
269 smsc9420_reg_write(pd, GPIO_CFG, temp); in smsc9420_eeprom_enable_access()
273 static int smsc9420_eeprom_send_cmd(struct smsc9420_pdata *pd, u32 op) in smsc9420_eeprom_send_cmd() argument
278 netif_dbg(pd, hw, pd->dev, "op 0x%08x\n", op); in smsc9420_eeprom_send_cmd()
279 if (smsc9420_reg_read(pd, E2P_CMD) & E2P_CMD_EPC_BUSY_) { in smsc9420_eeprom_send_cmd()
280 netif_warn(pd, hw, pd->dev, "Busy at start\n"); in smsc9420_eeprom_send_cmd()
285 smsc9420_reg_write(pd, E2P_CMD, e2cmd); in smsc9420_eeprom_send_cmd()
289 e2cmd = smsc9420_reg_read(pd, E2P_CMD); in smsc9420_eeprom_send_cmd()
293 netif_info(pd, hw, pd->dev, "TIMED OUT\n"); in smsc9420_eeprom_send_cmd()
298 netif_info(pd, hw, pd->dev, in smsc9420_eeprom_send_cmd()
306 static int smsc9420_eeprom_read_location(struct smsc9420_pdata *pd, in smsc9420_eeprom_read_location() argument
312 netif_dbg(pd, hw, pd->dev, "address 0x%x\n", address); in smsc9420_eeprom_read_location()
313 ret = smsc9420_eeprom_send_cmd(pd, op); in smsc9420_eeprom_read_location()
316 data[address] = smsc9420_reg_read(pd, E2P_DATA); in smsc9420_eeprom_read_location()
321 static int smsc9420_eeprom_write_location(struct smsc9420_pdata *pd, in smsc9420_eeprom_write_location() argument
327 netif_dbg(pd, hw, pd->dev, "address 0x%x, data 0x%x\n", address, data); in smsc9420_eeprom_write_location()
328 ret = smsc9420_eeprom_send_cmd(pd, op); in smsc9420_eeprom_write_location()
332 smsc9420_reg_write(pd, E2P_DATA, (u32)data); in smsc9420_eeprom_write_location()
333 ret = smsc9420_eeprom_send_cmd(pd, op); in smsc9420_eeprom_write_location()
347 struct smsc9420_pdata *pd = netdev_priv(dev); in smsc9420_ethtool_get_eeprom() local
351 smsc9420_eeprom_enable_access(pd); in smsc9420_ethtool_get_eeprom()
355 int ret = smsc9420_eeprom_read_location(pd, i, eeprom_data); in smsc9420_ethtool_get_eeprom()
371 struct smsc9420_pdata *pd = netdev_priv(dev); in smsc9420_ethtool_set_eeprom() local
377 smsc9420_eeprom_enable_access(pd); in smsc9420_ethtool_set_eeprom()
378 smsc9420_eeprom_send_cmd(pd, E2P_CMD_EPC_CMD_EWEN_); in smsc9420_ethtool_set_eeprom()
379 ret = smsc9420_eeprom_write_location(pd, eeprom->offset, *data); in smsc9420_ethtool_set_eeprom()
380 smsc9420_eeprom_send_cmd(pd, E2P_CMD_EPC_CMD_EWDS_); in smsc9420_ethtool_set_eeprom()
407 struct smsc9420_pdata *pd = netdev_priv(dev); in smsc9420_set_mac_address() local
413 smsc9420_reg_write(pd, ADDRH, mac_high16); in smsc9420_set_mac_address()
414 smsc9420_reg_write(pd, ADDRL, mac_low32); in smsc9420_set_mac_address()
419 struct smsc9420_pdata *pd = netdev_priv(dev); in smsc9420_check_mac_address() local
425 netif_dbg(pd, probe, pd->dev, in smsc9420_check_mac_address()
430 u32 mac_high16 = smsc9420_reg_read(pd, ADDRH); in smsc9420_check_mac_address()
431 u32 mac_low32 = smsc9420_reg_read(pd, ADDRL); in smsc9420_check_mac_address()
442 netif_dbg(pd, probe, pd->dev, in smsc9420_check_mac_address()
448 netif_dbg(pd, probe, pd->dev, in smsc9420_check_mac_address()
454 static void smsc9420_stop_tx(struct smsc9420_pdata *pd) in smsc9420_stop_tx() argument
460 dmac_control = smsc9420_reg_read(pd, DMAC_CONTROL); in smsc9420_stop_tx()
462 smsc9420_reg_write(pd, DMAC_CONTROL, dmac_control); in smsc9420_stop_tx()
466 if (smsc9420_reg_read(pd, DMAC_STATUS) & DMAC_STS_TS_) in smsc9420_stop_tx()
472 netif_warn(pd, ifdown, pd->dev, "TX DMAC failed to stop\n"); in smsc9420_stop_tx()
475 smsc9420_reg_write(pd, DMAC_STATUS, DMAC_STS_TXPS_); in smsc9420_stop_tx()
478 dma_intr_ena = smsc9420_reg_read(pd, DMAC_INTR_ENA); in smsc9420_stop_tx()
480 smsc9420_reg_write(pd, DMAC_INTR_ENA, dma_intr_ena); in smsc9420_stop_tx()
481 smsc9420_pci_flush_write(pd); in smsc9420_stop_tx()
484 mac_cr = smsc9420_reg_read(pd, MAC_CR) & (~MAC_CR_TXEN_); in smsc9420_stop_tx()
485 smsc9420_reg_write(pd, MAC_CR, mac_cr); in smsc9420_stop_tx()
486 smsc9420_pci_flush_write(pd); in smsc9420_stop_tx()
489 static void smsc9420_free_tx_ring(struct smsc9420_pdata *pd) in smsc9420_free_tx_ring() argument
493 BUG_ON(!pd->tx_ring); in smsc9420_free_tx_ring()
495 if (!pd->tx_buffers) in smsc9420_free_tx_ring()
499 struct sk_buff *skb = pd->tx_buffers[i].skb; in smsc9420_free_tx_ring()
502 BUG_ON(!pd->tx_buffers[i].mapping); in smsc9420_free_tx_ring()
503 dma_unmap_single(&pd->pdev->dev, in smsc9420_free_tx_ring()
504 pd->tx_buffers[i].mapping, skb->len, in smsc9420_free_tx_ring()
509 pd->tx_ring[i].status = 0; in smsc9420_free_tx_ring()
510 pd->tx_ring[i].length = 0; in smsc9420_free_tx_ring()
511 pd->tx_ring[i].buffer1 = 0; in smsc9420_free_tx_ring()
512 pd->tx_ring[i].buffer2 = 0; in smsc9420_free_tx_ring()
516 kfree(pd->tx_buffers); in smsc9420_free_tx_ring()
517 pd->tx_buffers = NULL; in smsc9420_free_tx_ring()
519 pd->tx_ring_head = 0; in smsc9420_free_tx_ring()
520 pd->tx_ring_tail = 0; in smsc9420_free_tx_ring()
523 static void smsc9420_free_rx_ring(struct smsc9420_pdata *pd) in smsc9420_free_rx_ring() argument
527 BUG_ON(!pd->rx_ring); in smsc9420_free_rx_ring()
529 if (!pd->rx_buffers) in smsc9420_free_rx_ring()
533 if (pd->rx_buffers[i].skb) in smsc9420_free_rx_ring()
534 dev_kfree_skb_any(pd->rx_buffers[i].skb); in smsc9420_free_rx_ring()
536 if (pd->rx_buffers[i].mapping) in smsc9420_free_rx_ring()
537 dma_unmap_single(&pd->pdev->dev, in smsc9420_free_rx_ring()
538 pd->rx_buffers[i].mapping, in smsc9420_free_rx_ring()
541 pd->rx_ring[i].status = 0; in smsc9420_free_rx_ring()
542 pd->rx_ring[i].length = 0; in smsc9420_free_rx_ring()
543 pd->rx_ring[i].buffer1 = 0; in smsc9420_free_rx_ring()
544 pd->rx_ring[i].buffer2 = 0; in smsc9420_free_rx_ring()
548 kfree(pd->rx_buffers); in smsc9420_free_rx_ring()
549 pd->rx_buffers = NULL; in smsc9420_free_rx_ring()
551 pd->rx_ring_head = 0; in smsc9420_free_rx_ring()
552 pd->rx_ring_tail = 0; in smsc9420_free_rx_ring()
555 static void smsc9420_stop_rx(struct smsc9420_pdata *pd) in smsc9420_stop_rx() argument
561 dma_intr_ena = smsc9420_reg_read(pd, DMAC_INTR_ENA); in smsc9420_stop_rx()
563 smsc9420_reg_write(pd, DMAC_INTR_ENA, dma_intr_ena); in smsc9420_stop_rx()
564 smsc9420_pci_flush_write(pd); in smsc9420_stop_rx()
567 mac_cr = smsc9420_reg_read(pd, MAC_CR) & (~MAC_CR_RXEN_); in smsc9420_stop_rx()
568 smsc9420_reg_write(pd, MAC_CR, mac_cr); in smsc9420_stop_rx()
569 smsc9420_pci_flush_write(pd); in smsc9420_stop_rx()
572 dmac_control = smsc9420_reg_read(pd, DMAC_CONTROL); in smsc9420_stop_rx()
574 smsc9420_reg_write(pd, DMAC_CONTROL, dmac_control); in smsc9420_stop_rx()
575 smsc9420_pci_flush_write(pd); in smsc9420_stop_rx()
579 if (smsc9420_reg_read(pd, DMAC_STATUS) & DMAC_STS_RS_) in smsc9420_stop_rx()
585 netif_warn(pd, ifdown, pd->dev, in smsc9420_stop_rx()
589 smsc9420_reg_write(pd, DMAC_STATUS, DMAC_STS_RXPS_); in smsc9420_stop_rx()
594 struct smsc9420_pdata *pd = dev_id; in smsc9420_isr() local
599 BUG_ON(!pd); in smsc9420_isr()
600 BUG_ON(!pd->ioaddr); in smsc9420_isr()
602 int_cfg = smsc9420_reg_read(pd, INT_CFG); in smsc9420_isr()
609 int_sts = smsc9420_reg_read(pd, INT_STAT); in smsc9420_isr()
612 u32 status = smsc9420_reg_read(pd, DMAC_STATUS); in smsc9420_isr()
617 netif_wake_queue(pd->dev); in smsc9420_isr()
622 u32 dma_intr_ena = smsc9420_reg_read(pd, DMAC_INTR_ENA); in smsc9420_isr()
624 smsc9420_reg_write(pd, DMAC_INTR_ENA, dma_intr_ena); in smsc9420_isr()
625 smsc9420_pci_flush_write(pd); in smsc9420_isr()
628 napi_schedule(&pd->napi); in smsc9420_isr()
632 smsc9420_reg_write(pd, DMAC_STATUS, ints_to_clear); in smsc9420_isr()
639 spin_lock_irqsave(&pd->int_lock, flags); in smsc9420_isr()
640 int_ctl = smsc9420_reg_read(pd, INT_CTL); in smsc9420_isr()
642 smsc9420_reg_write(pd, INT_CTL, int_ctl); in smsc9420_isr()
643 spin_unlock_irqrestore(&pd->int_lock, flags); in smsc9420_isr()
645 smsc9420_reg_write(pd, INT_STAT, INT_STAT_SW_INT_); in smsc9420_isr()
646 pd->software_irq_signal = true; in smsc9420_isr()
653 smsc9420_pci_flush_write(pd); in smsc9420_isr()
661 struct smsc9420_pdata *pd = netdev_priv(dev); in smsc9420_poll_controller() local
662 const int irq = pd->pdev->irq; in smsc9420_poll_controller()
670 static void smsc9420_dmac_soft_reset(struct smsc9420_pdata *pd) in smsc9420_dmac_soft_reset() argument
672 smsc9420_reg_write(pd, BUS_MODE, BUS_MODE_SWR_); in smsc9420_dmac_soft_reset()
673 smsc9420_reg_read(pd, BUS_MODE); in smsc9420_dmac_soft_reset()
675 if (smsc9420_reg_read(pd, BUS_MODE) & BUS_MODE_SWR_) in smsc9420_dmac_soft_reset()
676 netif_warn(pd, drv, pd->dev, "Software reset not cleared\n"); in smsc9420_dmac_soft_reset()
681 struct smsc9420_pdata *pd = netdev_priv(dev); in smsc9420_stop() local
685 BUG_ON(!pd); in smsc9420_stop()
689 spin_lock_irqsave(&pd->int_lock, flags); in smsc9420_stop()
690 int_cfg = smsc9420_reg_read(pd, INT_CFG) & (~INT_CFG_IRQ_EN_); in smsc9420_stop()
691 smsc9420_reg_write(pd, INT_CFG, int_cfg); in smsc9420_stop()
692 spin_unlock_irqrestore(&pd->int_lock, flags); in smsc9420_stop()
695 napi_disable(&pd->napi); in smsc9420_stop()
697 smsc9420_stop_tx(pd); in smsc9420_stop()
698 smsc9420_free_tx_ring(pd); in smsc9420_stop()
700 smsc9420_stop_rx(pd); in smsc9420_stop()
701 smsc9420_free_rx_ring(pd); in smsc9420_stop()
703 free_irq(pd->pdev->irq, pd); in smsc9420_stop()
705 smsc9420_dmac_soft_reset(pd); in smsc9420_stop()
710 mdiobus_unregister(pd->mii_bus); in smsc9420_stop()
711 mdiobus_free(pd->mii_bus); in smsc9420_stop()
740 static void smsc9420_rx_handoff(struct smsc9420_pdata *pd, const int index, in smsc9420_rx_handoff() argument
743 struct net_device *dev = pd->dev; in smsc9420_rx_handoff()
751 if (pd->rx_csum) in smsc9420_rx_handoff()
757 dma_unmap_single(&pd->pdev->dev, pd->rx_buffers[index].mapping, in smsc9420_rx_handoff()
759 pd->rx_buffers[index].mapping = 0; in smsc9420_rx_handoff()
761 skb = pd->rx_buffers[index].skb; in smsc9420_rx_handoff()
762 pd->rx_buffers[index].skb = NULL; in smsc9420_rx_handoff()
764 if (pd->rx_csum) { in smsc9420_rx_handoff()
779 static int smsc9420_alloc_rx_buffer(struct smsc9420_pdata *pd, int index) in smsc9420_alloc_rx_buffer() argument
781 struct sk_buff *skb = netdev_alloc_skb(pd->dev, PKT_BUF_SZ); in smsc9420_alloc_rx_buffer()
784 BUG_ON(pd->rx_buffers[index].skb); in smsc9420_alloc_rx_buffer()
785 BUG_ON(pd->rx_buffers[index].mapping); in smsc9420_alloc_rx_buffer()
790 mapping = dma_map_single(&pd->pdev->dev, skb_tail_pointer(skb), in smsc9420_alloc_rx_buffer()
792 if (dma_mapping_error(&pd->pdev->dev, mapping)) { in smsc9420_alloc_rx_buffer()
794 netif_warn(pd, rx_err, pd->dev, "dma_map_single failed!\n"); in smsc9420_alloc_rx_buffer()
798 pd->rx_buffers[index].skb = skb; in smsc9420_alloc_rx_buffer()
799 pd->rx_buffers[index].mapping = mapping; in smsc9420_alloc_rx_buffer()
800 pd->rx_ring[index].buffer1 = mapping + NET_IP_ALIGN; in smsc9420_alloc_rx_buffer()
801 pd->rx_ring[index].status = RDES0_OWN_; in smsc9420_alloc_rx_buffer()
807 static void smsc9420_alloc_new_rx_buffers(struct smsc9420_pdata *pd) in smsc9420_alloc_new_rx_buffers() argument
809 while (pd->rx_ring_tail != pd->rx_ring_head) { in smsc9420_alloc_new_rx_buffers()
810 if (smsc9420_alloc_rx_buffer(pd, pd->rx_ring_tail)) in smsc9420_alloc_new_rx_buffers()
813 pd->rx_ring_tail = (pd->rx_ring_tail + 1) % RX_RING_SIZE; in smsc9420_alloc_new_rx_buffers()
819 struct smsc9420_pdata *pd = in smsc9420_rx_poll() local
821 struct net_device *dev = pd->dev; in smsc9420_rx_poll()
827 status = pd->rx_ring[pd->rx_ring_head].status; in smsc9420_rx_poll()
834 smsc9420_rx_handoff(pd, pd->rx_ring_head, status); in smsc9420_rx_poll()
835 pd->rx_ring_head = (pd->rx_ring_head + 1) % RX_RING_SIZE; in smsc9420_rx_poll()
836 smsc9420_alloc_new_rx_buffers(pd); in smsc9420_rx_poll()
839 drop_frame_cnt = smsc9420_reg_read(pd, MISS_FRAME_CNTR); in smsc9420_rx_poll()
844 smsc9420_reg_write(pd, RX_POLL_DEMAND, 1); in smsc9420_rx_poll()
845 smsc9420_pci_flush_write(pd); in smsc9420_rx_poll()
848 napi_complete_done(&pd->napi, work_done); in smsc9420_rx_poll()
851 dma_intr_ena = smsc9420_reg_read(pd, DMAC_INTR_ENA); in smsc9420_rx_poll()
853 smsc9420_reg_write(pd, DMAC_INTR_ENA, dma_intr_ena); in smsc9420_rx_poll()
854 smsc9420_pci_flush_write(pd); in smsc9420_rx_poll()
890 struct smsc9420_pdata *pd = netdev_priv(dev); in smsc9420_complete_tx() local
892 while (pd->tx_ring_tail != pd->tx_ring_head) { in smsc9420_complete_tx()
893 int index = pd->tx_ring_tail; in smsc9420_complete_tx()
897 status = pd->tx_ring[index].status; in smsc9420_complete_tx()
898 length = pd->tx_ring[index].length; in smsc9420_complete_tx()
906 BUG_ON(!pd->tx_buffers[index].skb); in smsc9420_complete_tx()
907 BUG_ON(!pd->tx_buffers[index].mapping); in smsc9420_complete_tx()
909 dma_unmap_single(&pd->pdev->dev, in smsc9420_complete_tx()
910 pd->tx_buffers[index].mapping, in smsc9420_complete_tx()
911 pd->tx_buffers[index].skb->len, in smsc9420_complete_tx()
913 pd->tx_buffers[index].mapping = 0; in smsc9420_complete_tx()
915 dev_kfree_skb_any(pd->tx_buffers[index].skb); in smsc9420_complete_tx()
916 pd->tx_buffers[index].skb = NULL; in smsc9420_complete_tx()
918 pd->tx_ring[index].buffer1 = 0; in smsc9420_complete_tx()
921 pd->tx_ring_tail = (pd->tx_ring_tail + 1) % TX_RING_SIZE; in smsc9420_complete_tx()
928 struct smsc9420_pdata *pd = netdev_priv(dev); in smsc9420_hard_start_xmit() local
930 int index = pd->tx_ring_head; in smsc9420_hard_start_xmit()
933 (((pd->tx_ring_head + 2) % TX_RING_SIZE) == pd->tx_ring_tail); in smsc9420_hard_start_xmit()
938 BUG_ON(pd->tx_ring[index].status & TDES0_OWN_); in smsc9420_hard_start_xmit()
939 BUG_ON(pd->tx_buffers[index].skb); in smsc9420_hard_start_xmit()
940 BUG_ON(pd->tx_buffers[index].mapping); in smsc9420_hard_start_xmit()
942 mapping = dma_map_single(&pd->pdev->dev, skb->data, skb->len, in smsc9420_hard_start_xmit()
944 if (dma_mapping_error(&pd->pdev->dev, mapping)) { in smsc9420_hard_start_xmit()
945 netif_warn(pd, tx_err, pd->dev, in smsc9420_hard_start_xmit()
950 pd->tx_buffers[index].skb = skb; in smsc9420_hard_start_xmit()
951 pd->tx_buffers[index].mapping = mapping; in smsc9420_hard_start_xmit()
956 netif_stop_queue(pd->dev); in smsc9420_hard_start_xmit()
963 pd->tx_ring[index].buffer1 = mapping; in smsc9420_hard_start_xmit()
964 pd->tx_ring[index].length = tmp_desc1; in smsc9420_hard_start_xmit()
968 pd->tx_ring_head = (pd->tx_ring_head + 1) % TX_RING_SIZE; in smsc9420_hard_start_xmit()
971 pd->tx_ring[index].status = TDES0_OWN_; in smsc9420_hard_start_xmit()
977 smsc9420_reg_write(pd, TX_POLL_DEMAND, 1); in smsc9420_hard_start_xmit()
978 smsc9420_pci_flush_write(pd); in smsc9420_hard_start_xmit()
985 struct smsc9420_pdata *pd = netdev_priv(dev); in smsc9420_get_stats() local
986 u32 counter = smsc9420_reg_read(pd, MISS_FRAME_CNTR); in smsc9420_get_stats()
994 struct smsc9420_pdata *pd = netdev_priv(dev); in smsc9420_set_multicast_list() local
995 u32 mac_cr = smsc9420_reg_read(pd, MAC_CR); in smsc9420_set_multicast_list()
998 netif_dbg(pd, hw, pd->dev, "Promiscuous Mode Enabled\n"); in smsc9420_set_multicast_list()
1003 netif_dbg(pd, hw, pd->dev, "Receive all Multicast Enabled\n"); in smsc9420_set_multicast_list()
1011 netif_dbg(pd, hw, pd->dev, "Multicast filter enabled\n"); in smsc9420_set_multicast_list()
1022 smsc9420_reg_write(pd, HASHH, hash_hi); in smsc9420_set_multicast_list()
1023 smsc9420_reg_write(pd, HASHL, hash_lo); in smsc9420_set_multicast_list()
1029 netif_dbg(pd, hw, pd->dev, "Receive own packets only\n"); in smsc9420_set_multicast_list()
1030 smsc9420_reg_write(pd, HASHH, 0); in smsc9420_set_multicast_list()
1031 smsc9420_reg_write(pd, HASHL, 0); in smsc9420_set_multicast_list()
1038 smsc9420_reg_write(pd, MAC_CR, mac_cr); in smsc9420_set_multicast_list()
1039 smsc9420_pci_flush_write(pd); in smsc9420_set_multicast_list()
1042 static void smsc9420_phy_update_flowcontrol(struct smsc9420_pdata *pd) in smsc9420_phy_update_flowcontrol() argument
1044 struct net_device *dev = pd->dev; in smsc9420_phy_update_flowcontrol()
1058 netif_info(pd, link, pd->dev, "rx pause %s, tx pause %s\n", in smsc9420_phy_update_flowcontrol()
1062 netif_info(pd, link, pd->dev, "half duplex\n"); in smsc9420_phy_update_flowcontrol()
1066 smsc9420_reg_write(pd, FLOW, flow); in smsc9420_phy_update_flowcontrol()
1073 struct smsc9420_pdata *pd = netdev_priv(dev); in smsc9420_phy_adjust_link() local
1077 if (phy_dev->duplex != pd->last_duplex) { in smsc9420_phy_adjust_link()
1078 u32 mac_cr = smsc9420_reg_read(pd, MAC_CR); in smsc9420_phy_adjust_link()
1080 netif_dbg(pd, link, pd->dev, "full duplex mode\n"); in smsc9420_phy_adjust_link()
1083 netif_dbg(pd, link, pd->dev, "half duplex mode\n"); in smsc9420_phy_adjust_link()
1086 smsc9420_reg_write(pd, MAC_CR, mac_cr); in smsc9420_phy_adjust_link()
1088 smsc9420_phy_update_flowcontrol(pd); in smsc9420_phy_adjust_link()
1089 pd->last_duplex = phy_dev->duplex; in smsc9420_phy_adjust_link()
1093 if (carrier != pd->last_carrier) { in smsc9420_phy_adjust_link()
1095 netif_dbg(pd, link, pd->dev, "carrier OK\n"); in smsc9420_phy_adjust_link()
1097 netif_dbg(pd, link, pd->dev, "no carrier\n"); in smsc9420_phy_adjust_link()
1098 pd->last_carrier = carrier; in smsc9420_phy_adjust_link()
1104 struct smsc9420_pdata *pd = netdev_priv(dev); in smsc9420_mii_probe() local
1110 phydev = mdiobus_get_phy(pd->mii_bus, 1); in smsc9420_mii_probe()
1131 pd->last_duplex = -1; in smsc9420_mii_probe()
1132 pd->last_carrier = -1; in smsc9420_mii_probe()
1139 struct smsc9420_pdata *pd = netdev_priv(dev); in smsc9420_mii_init() local
1142 pd->mii_bus = mdiobus_alloc(); in smsc9420_mii_init()
1143 if (!pd->mii_bus) { in smsc9420_mii_init()
1147 pd->mii_bus->name = DRV_MDIONAME; in smsc9420_mii_init()
1148 snprintf(pd->mii_bus->id, MII_BUS_ID_SIZE, "%x", pci_dev_id(pd->pdev)); in smsc9420_mii_init()
1149 pd->mii_bus->priv = pd; in smsc9420_mii_init()
1150 pd->mii_bus->read = smsc9420_mii_read; in smsc9420_mii_init()
1151 pd->mii_bus->write = smsc9420_mii_write; in smsc9420_mii_init()
1154 pd->mii_bus->phy_mask = ~(1 << 1); in smsc9420_mii_init()
1156 if (mdiobus_register(pd->mii_bus)) { in smsc9420_mii_init()
1157 netif_warn(pd, probe, pd->dev, "Error registering mii bus\n"); in smsc9420_mii_init()
1162 netif_warn(pd, probe, pd->dev, "Error probing mii bus\n"); in smsc9420_mii_init()
1169 mdiobus_unregister(pd->mii_bus); in smsc9420_mii_init()
1171 mdiobus_free(pd->mii_bus); in smsc9420_mii_init()
1176 static int smsc9420_alloc_tx_ring(struct smsc9420_pdata *pd) in smsc9420_alloc_tx_ring() argument
1180 BUG_ON(!pd->tx_ring); in smsc9420_alloc_tx_ring()
1182 pd->tx_buffers = kmalloc_array(TX_RING_SIZE, in smsc9420_alloc_tx_ring()
1185 if (!pd->tx_buffers) in smsc9420_alloc_tx_ring()
1190 pd->tx_buffers[i].skb = NULL; in smsc9420_alloc_tx_ring()
1191 pd->tx_buffers[i].mapping = 0; in smsc9420_alloc_tx_ring()
1192 pd->tx_ring[i].status = 0; in smsc9420_alloc_tx_ring()
1193 pd->tx_ring[i].length = 0; in smsc9420_alloc_tx_ring()
1194 pd->tx_ring[i].buffer1 = 0; in smsc9420_alloc_tx_ring()
1195 pd->tx_ring[i].buffer2 = 0; in smsc9420_alloc_tx_ring()
1197 pd->tx_ring[TX_RING_SIZE - 1].length = TDES1_TER_; in smsc9420_alloc_tx_ring()
1200 pd->tx_ring_head = 0; in smsc9420_alloc_tx_ring()
1201 pd->tx_ring_tail = 0; in smsc9420_alloc_tx_ring()
1203 smsc9420_reg_write(pd, TX_BASE_ADDR, pd->tx_dma_addr); in smsc9420_alloc_tx_ring()
1204 smsc9420_pci_flush_write(pd); in smsc9420_alloc_tx_ring()
1209 static int smsc9420_alloc_rx_ring(struct smsc9420_pdata *pd) in smsc9420_alloc_rx_ring() argument
1213 BUG_ON(!pd->rx_ring); in smsc9420_alloc_rx_ring()
1215 pd->rx_buffers = kmalloc_array(RX_RING_SIZE, in smsc9420_alloc_rx_ring()
1218 if (pd->rx_buffers == NULL) in smsc9420_alloc_rx_ring()
1223 pd->rx_ring[i].status = 0; in smsc9420_alloc_rx_ring()
1224 pd->rx_ring[i].length = PKT_BUF_SZ; in smsc9420_alloc_rx_ring()
1225 pd->rx_ring[i].buffer2 = 0; in smsc9420_alloc_rx_ring()
1226 pd->rx_buffers[i].skb = NULL; in smsc9420_alloc_rx_ring()
1227 pd->rx_buffers[i].mapping = 0; in smsc9420_alloc_rx_ring()
1229 pd->rx_ring[RX_RING_SIZE - 1].length = (PKT_BUF_SZ | RDES1_RER_); in smsc9420_alloc_rx_ring()
1233 if (smsc9420_alloc_rx_buffer(pd, i)) { in smsc9420_alloc_rx_ring()
1234 netif_warn(pd, ifup, pd->dev, in smsc9420_alloc_rx_ring()
1240 pd->rx_ring_head = 0; in smsc9420_alloc_rx_ring()
1241 pd->rx_ring_tail = 0; in smsc9420_alloc_rx_ring()
1243 smsc9420_reg_write(pd, VLAN1, ETH_P_8021Q); in smsc9420_alloc_rx_ring()
1244 netif_dbg(pd, ifup, pd->dev, "VLAN1 = 0x%08x\n", in smsc9420_alloc_rx_ring()
1245 smsc9420_reg_read(pd, VLAN1)); in smsc9420_alloc_rx_ring()
1247 if (pd->rx_csum) { in smsc9420_alloc_rx_ring()
1249 u32 coe = smsc9420_reg_read(pd, COE_CR) | RX_COE_EN; in smsc9420_alloc_rx_ring()
1250 smsc9420_reg_write(pd, COE_CR, coe); in smsc9420_alloc_rx_ring()
1251 netif_dbg(pd, ifup, pd->dev, "COE_CR = 0x%08x\n", coe); in smsc9420_alloc_rx_ring()
1254 smsc9420_reg_write(pd, RX_BASE_ADDR, pd->rx_dma_addr); in smsc9420_alloc_rx_ring()
1255 smsc9420_pci_flush_write(pd); in smsc9420_alloc_rx_ring()
1260 smsc9420_free_rx_ring(pd); in smsc9420_alloc_rx_ring()
1267 struct smsc9420_pdata *pd = netdev_priv(dev); in smsc9420_open() local
1269 const int irq = pd->pdev->irq; in smsc9420_open()
1274 netif_warn(pd, ifup, pd->dev, in smsc9420_open()
1283 spin_lock_irqsave(&pd->int_lock, flags); in smsc9420_open()
1284 int_cfg = smsc9420_reg_read(pd, INT_CFG) & (~INT_CFG_IRQ_EN_); in smsc9420_open()
1285 smsc9420_reg_write(pd, INT_CFG, int_cfg); in smsc9420_open()
1286 smsc9420_reg_write(pd, INT_CTL, 0); in smsc9420_open()
1287 spin_unlock_irqrestore(&pd->int_lock, flags); in smsc9420_open()
1288 smsc9420_reg_write(pd, DMAC_INTR_ENA, 0); in smsc9420_open()
1289 smsc9420_reg_write(pd, INT_STAT, 0xFFFFFFFF); in smsc9420_open()
1290 smsc9420_pci_flush_write(pd); in smsc9420_open()
1292 result = request_irq(irq, smsc9420_isr, IRQF_SHARED, DRV_NAME, pd); in smsc9420_open()
1294 netif_warn(pd, ifup, pd->dev, "Unable to use IRQ = %d\n", irq); in smsc9420_open()
1299 smsc9420_dmac_soft_reset(pd); in smsc9420_open()
1302 smsc9420_reg_write(pd, MAC_CR, 0); in smsc9420_open()
1307 smsc9420_reg_write(pd, GPIO_CFG, in smsc9420_open()
1316 smsc9420_reg_write(pd, BUS_MODE, bus_mode); in smsc9420_open()
1318 smsc9420_pci_flush_write(pd); in smsc9420_open()
1321 smsc9420_reg_write(pd, BUS_CFG, BUS_CFG_RXTXWEIGHT_4_1); in smsc9420_open()
1323 smsc9420_reg_write(pd, DMAC_CONTROL, in smsc9420_open()
1326 smsc9420_pci_flush_write(pd); in smsc9420_open()
1329 netif_dbg(pd, ifup, pd->dev, "Testing ISR using IRQ %d\n", irq); in smsc9420_open()
1330 pd->software_irq_signal = false; in smsc9420_open()
1332 spin_lock_irqsave(&pd->int_lock, flags); in smsc9420_open()
1334 int_cfg = smsc9420_reg_read(pd, INT_CFG) | INT_CFG_IRQ_EN_; in smsc9420_open()
1337 smsc9420_reg_write(pd, INT_CFG, int_cfg); in smsc9420_open()
1340 int_ctl = smsc9420_reg_read(pd, INT_CTL) | INT_CTL_SW_INT_EN_; in smsc9420_open()
1341 smsc9420_reg_write(pd, INT_CTL, int_ctl); in smsc9420_open()
1342 spin_unlock_irqrestore(&pd->int_lock, flags); in smsc9420_open()
1343 smsc9420_pci_flush_write(pd); in smsc9420_open()
1347 if (pd->software_irq_signal) in smsc9420_open()
1353 spin_lock_irqsave(&pd->int_lock, flags); in smsc9420_open()
1354 int_cfg = smsc9420_reg_read(pd, INT_CFG) & (~INT_CFG_IRQ_EN_); in smsc9420_open()
1355 smsc9420_reg_write(pd, INT_CFG, int_cfg); in smsc9420_open()
1356 spin_unlock_irqrestore(&pd->int_lock, flags); in smsc9420_open()
1358 if (!pd->software_irq_signal) { in smsc9420_open()
1359 netif_warn(pd, ifup, pd->dev, "ISR failed signaling test\n"); in smsc9420_open()
1364 netif_dbg(pd, ifup, pd->dev, "ISR passed test using IRQ %d\n", irq); in smsc9420_open()
1366 result = smsc9420_alloc_tx_ring(pd); in smsc9420_open()
1368 netif_warn(pd, ifup, pd->dev, in smsc9420_open()
1374 result = smsc9420_alloc_rx_ring(pd); in smsc9420_open()
1376 netif_warn(pd, ifup, pd->dev, in smsc9420_open()
1384 netif_warn(pd, ifup, pd->dev, "Failed to initialize Phy\n"); in smsc9420_open()
1392 napi_enable(&pd->napi); in smsc9420_open()
1395 mac_cr = smsc9420_reg_read(pd, MAC_CR) | MAC_CR_TXEN_ | MAC_CR_RXEN_; in smsc9420_open()
1396 smsc9420_reg_write(pd, MAC_CR, mac_cr); in smsc9420_open()
1398 dmac_control = smsc9420_reg_read(pd, DMAC_CONTROL); in smsc9420_open()
1400 smsc9420_reg_write(pd, DMAC_CONTROL, dmac_control); in smsc9420_open()
1401 smsc9420_pci_flush_write(pd); in smsc9420_open()
1403 dma_intr_ena = smsc9420_reg_read(pd, DMAC_INTR_ENA); in smsc9420_open()
1406 smsc9420_reg_write(pd, DMAC_INTR_ENA, dma_intr_ena); in smsc9420_open()
1407 smsc9420_pci_flush_write(pd); in smsc9420_open()
1411 smsc9420_reg_write(pd, RX_POLL_DEMAND, 1); in smsc9420_open()
1414 spin_lock_irqsave(&pd->int_lock, flags); in smsc9420_open()
1415 int_cfg = smsc9420_reg_read(pd, INT_CFG) | INT_CFG_IRQ_EN_; in smsc9420_open()
1416 smsc9420_reg_write(pd, INT_CFG, int_cfg); in smsc9420_open()
1417 spin_unlock_irqrestore(&pd->int_lock, flags); in smsc9420_open()
1422 smsc9420_free_rx_ring(pd); in smsc9420_open()
1424 smsc9420_free_tx_ring(pd); in smsc9420_open()
1426 free_irq(irq, pd); in smsc9420_open()
1434 struct smsc9420_pdata *pd = netdev_priv(dev); in smsc9420_suspend() local
1439 spin_lock_irqsave(&pd->int_lock, flags); in smsc9420_suspend()
1440 int_cfg = smsc9420_reg_read(pd, INT_CFG) & (~INT_CFG_IRQ_EN_); in smsc9420_suspend()
1441 smsc9420_reg_write(pd, INT_CFG, int_cfg); in smsc9420_suspend()
1442 spin_unlock_irqrestore(&pd->int_lock, flags); in smsc9420_suspend()
1446 smsc9420_stop_tx(pd); in smsc9420_suspend()
1447 smsc9420_free_tx_ring(pd); in smsc9420_suspend()
1449 napi_disable(&pd->napi); in smsc9420_suspend()
1450 smsc9420_stop_rx(pd); in smsc9420_suspend()
1451 smsc9420_free_rx_ring(pd); in smsc9420_suspend()
1453 free_irq(pd->pdev->irq, pd); in smsc9420_suspend()
1499 struct smsc9420_pdata *pd; in smsc9420_probe() local
1515 dev = alloc_etherdev(sizeof(*pd)); in smsc9420_probe()
1546 pd = netdev_priv(dev); in smsc9420_probe()
1549 pd->rx_ring = dma_alloc_coherent(&pdev->dev, in smsc9420_probe()
1551 &pd->rx_dma_addr, GFP_KERNEL); in smsc9420_probe()
1553 if (!pd->rx_ring) in smsc9420_probe()
1557 pd->tx_ring = (pd->rx_ring + RX_RING_SIZE); in smsc9420_probe()
1558 pd->tx_dma_addr = pd->rx_dma_addr + in smsc9420_probe()
1561 pd->pdev = pdev; in smsc9420_probe()
1562 pd->dev = dev; in smsc9420_probe()
1563 pd->ioaddr = virt_addr; in smsc9420_probe()
1564 pd->msg_enable = smsc_debug; in smsc9420_probe()
1565 pd->rx_csum = true; in smsc9420_probe()
1567 netif_dbg(pd, probe, pd->dev, "lan_base=0x%08lx\n", (ulong)virt_addr); in smsc9420_probe()
1569 id_rev = smsc9420_reg_read(pd, ID_REV); in smsc9420_probe()
1572 netif_info(pd, probe, pd->dev, in smsc9420_probe()
1576 netif_warn(pd, probe, pd->dev, "LAN9420 NOT identified\n"); in smsc9420_probe()
1577 netif_warn(pd, probe, pd->dev, "ID_REV=0x%08X\n", id_rev); in smsc9420_probe()
1581 smsc9420_dmac_soft_reset(pd); in smsc9420_probe()
1582 smsc9420_eeprom_reload(pd); in smsc9420_probe()
1588 netif_napi_add(dev, &pd->napi, smsc9420_rx_poll); in smsc9420_probe()
1592 netif_warn(pd, probe, pd->dev, "error %i registering device\n", in smsc9420_probe()
1599 spin_lock_init(&pd->int_lock); in smsc9420_probe()
1600 spin_lock_init(&pd->phy_lock); in smsc9420_probe()
1609 pd->rx_ring, pd->rx_dma_addr); in smsc9420_probe()
1625 struct smsc9420_pdata *pd; in smsc9420_remove() local
1631 pd = netdev_priv(dev); in smsc9420_remove()
1635 BUG_ON(pd->tx_buffers); in smsc9420_remove()
1636 BUG_ON(pd->rx_buffers); in smsc9420_remove()
1638 BUG_ON(!pd->tx_ring); in smsc9420_remove()
1639 BUG_ON(!pd->rx_ring); in smsc9420_remove()
1643 pd->rx_ring, pd->rx_dma_addr); in smsc9420_remove()
1645 iounmap(pd->ioaddr - LAN9420_CPSR_ENDIAN_OFFSET); in smsc9420_remove()