Lines Matching refs:pd

86 static inline u32 smsc9420_reg_read(struct smsc9420_pdata *pd, u32 offset)  in smsc9420_reg_read()  argument
88 return ioread32(pd->ioaddr + offset); in smsc9420_reg_read()
92 smsc9420_reg_write(struct smsc9420_pdata *pd, u32 offset, u32 value) in smsc9420_reg_write() argument
94 iowrite32(value, pd->ioaddr + offset); in smsc9420_reg_write()
97 static inline void smsc9420_pci_flush_write(struct smsc9420_pdata *pd) in smsc9420_pci_flush_write() argument
100 smsc9420_reg_read(pd, ID_REV); in smsc9420_pci_flush_write()
105 struct smsc9420_pdata *pd = (struct smsc9420_pdata *)bus->priv; in smsc9420_mii_read() local
110 spin_lock_irqsave(&pd->phy_lock, flags); in smsc9420_mii_read()
113 if ((smsc9420_reg_read(pd, MII_ACCESS) & MII_ACCESS_MII_BUSY_)) { in smsc9420_mii_read()
114 netif_warn(pd, drv, pd->dev, "MII is busy???\n"); in smsc9420_mii_read()
121 smsc9420_reg_write(pd, MII_ACCESS, addr); in smsc9420_mii_read()
125 if (!(smsc9420_reg_read(pd, MII_ACCESS) & in smsc9420_mii_read()
127 reg = (u16)smsc9420_reg_read(pd, MII_DATA); in smsc9420_mii_read()
133 netif_warn(pd, drv, pd->dev, "MII busy timeout!\n"); in smsc9420_mii_read()
136 spin_unlock_irqrestore(&pd->phy_lock, flags); in smsc9420_mii_read()
143 struct smsc9420_pdata *pd = (struct smsc9420_pdata *)bus->priv; in smsc9420_mii_write() local
148 spin_lock_irqsave(&pd->phy_lock, flags); in smsc9420_mii_write()
151 if ((smsc9420_reg_read(pd, MII_ACCESS) & MII_ACCESS_MII_BUSY_)) { in smsc9420_mii_write()
152 netif_warn(pd, drv, pd->dev, "MII is busy???\n"); in smsc9420_mii_write()
157 smsc9420_reg_write(pd, MII_DATA, (u32)val); in smsc9420_mii_write()
162 smsc9420_reg_write(pd, MII_ACCESS, addr); in smsc9420_mii_write()
166 if (!(smsc9420_reg_read(pd, MII_ACCESS) & in smsc9420_mii_write()
174 netif_warn(pd, drv, pd->dev, "MII busy timeout!\n"); in smsc9420_mii_write()
177 spin_unlock_irqrestore(&pd->phy_lock, flags); in smsc9420_mii_write()
189 static int smsc9420_eeprom_reload(struct smsc9420_pdata *pd) in smsc9420_eeprom_reload() argument
193 BUG_ON(!pd); in smsc9420_eeprom_reload()
195 if (smsc9420_reg_read(pd, E2P_CMD) & E2P_CMD_EPC_BUSY_) { in smsc9420_eeprom_reload()
196 netif_dbg(pd, drv, pd->dev, "%s: Eeprom busy\n", __func__); in smsc9420_eeprom_reload()
200 smsc9420_reg_write(pd, E2P_CMD, in smsc9420_eeprom_reload()
205 if (!(smsc9420_reg_read(pd, E2P_CMD) & E2P_CMD_EPC_BUSY_)) in smsc9420_eeprom_reload()
209 netif_warn(pd, drv, pd->dev, "%s: Eeprom timed out\n", __func__); in smsc9420_eeprom_reload()
216 struct smsc9420_pdata *pd = netdev_priv(netdev); in smsc9420_ethtool_get_drvinfo() local
219 strlcpy(drvinfo->bus_info, pci_name(pd->pdev), in smsc9420_ethtool_get_drvinfo()
226 struct smsc9420_pdata *pd = netdev_priv(netdev); in smsc9420_ethtool_get_msglevel() local
227 return pd->msg_enable; in smsc9420_ethtool_get_msglevel()
232 struct smsc9420_pdata *pd = netdev_priv(netdev); in smsc9420_ethtool_set_msglevel() local
233 pd->msg_enable = data; in smsc9420_ethtool_set_msglevel()
246 struct smsc9420_pdata *pd = netdev_priv(dev); in smsc9420_ethtool_getregs() local
251 regs->version = smsc9420_reg_read(pd, ID_REV); in smsc9420_ethtool_getregs()
253 data[j++] = smsc9420_reg_read(pd, i); in smsc9420_ethtool_getregs()
264 static void smsc9420_eeprom_enable_access(struct smsc9420_pdata *pd) in smsc9420_eeprom_enable_access() argument
266 unsigned int temp = smsc9420_reg_read(pd, GPIO_CFG); in smsc9420_eeprom_enable_access()
268 smsc9420_reg_write(pd, GPIO_CFG, temp); in smsc9420_eeprom_enable_access()
272 static int smsc9420_eeprom_send_cmd(struct smsc9420_pdata *pd, u32 op) in smsc9420_eeprom_send_cmd() argument
277 netif_dbg(pd, hw, pd->dev, "op 0x%08x\n", op); in smsc9420_eeprom_send_cmd()
278 if (smsc9420_reg_read(pd, E2P_CMD) & E2P_CMD_EPC_BUSY_) { in smsc9420_eeprom_send_cmd()
279 netif_warn(pd, hw, pd->dev, "Busy at start\n"); in smsc9420_eeprom_send_cmd()
284 smsc9420_reg_write(pd, E2P_CMD, e2cmd); in smsc9420_eeprom_send_cmd()
288 e2cmd = smsc9420_reg_read(pd, E2P_CMD); in smsc9420_eeprom_send_cmd()
292 netif_info(pd, hw, pd->dev, "TIMED OUT\n"); in smsc9420_eeprom_send_cmd()
297 netif_info(pd, hw, pd->dev, in smsc9420_eeprom_send_cmd()
305 static int smsc9420_eeprom_read_location(struct smsc9420_pdata *pd, in smsc9420_eeprom_read_location() argument
311 netif_dbg(pd, hw, pd->dev, "address 0x%x\n", address); in smsc9420_eeprom_read_location()
312 ret = smsc9420_eeprom_send_cmd(pd, op); in smsc9420_eeprom_read_location()
315 data[address] = smsc9420_reg_read(pd, E2P_DATA); in smsc9420_eeprom_read_location()
320 static int smsc9420_eeprom_write_location(struct smsc9420_pdata *pd, in smsc9420_eeprom_write_location() argument
326 netif_dbg(pd, hw, pd->dev, "address 0x%x, data 0x%x\n", address, data); in smsc9420_eeprom_write_location()
327 ret = smsc9420_eeprom_send_cmd(pd, op); in smsc9420_eeprom_write_location()
331 smsc9420_reg_write(pd, E2P_DATA, (u32)data); in smsc9420_eeprom_write_location()
332 ret = smsc9420_eeprom_send_cmd(pd, op); in smsc9420_eeprom_write_location()
346 struct smsc9420_pdata *pd = netdev_priv(dev); in smsc9420_ethtool_get_eeprom() local
350 smsc9420_eeprom_enable_access(pd); in smsc9420_ethtool_get_eeprom()
354 int ret = smsc9420_eeprom_read_location(pd, i, eeprom_data); in smsc9420_ethtool_get_eeprom()
370 struct smsc9420_pdata *pd = netdev_priv(dev); in smsc9420_ethtool_set_eeprom() local
376 smsc9420_eeprom_enable_access(pd); in smsc9420_ethtool_set_eeprom()
377 smsc9420_eeprom_send_cmd(pd, E2P_CMD_EPC_CMD_EWEN_); in smsc9420_ethtool_set_eeprom()
378 ret = smsc9420_eeprom_write_location(pd, eeprom->offset, *data); in smsc9420_ethtool_set_eeprom()
379 smsc9420_eeprom_send_cmd(pd, E2P_CMD_EPC_CMD_EWDS_); in smsc9420_ethtool_set_eeprom()
406 struct smsc9420_pdata *pd = netdev_priv(dev); in smsc9420_set_mac_address() local
412 smsc9420_reg_write(pd, ADDRH, mac_high16); in smsc9420_set_mac_address()
413 smsc9420_reg_write(pd, ADDRL, mac_low32); in smsc9420_set_mac_address()
418 struct smsc9420_pdata *pd = netdev_priv(dev); in smsc9420_check_mac_address() local
423 netif_dbg(pd, probe, pd->dev, in smsc9420_check_mac_address()
428 u32 mac_high16 = smsc9420_reg_read(pd, ADDRH); in smsc9420_check_mac_address()
429 u32 mac_low32 = smsc9420_reg_read(pd, ADDRL); in smsc9420_check_mac_address()
439 netif_dbg(pd, probe, pd->dev, in smsc9420_check_mac_address()
445 netif_dbg(pd, probe, pd->dev, in smsc9420_check_mac_address()
451 static void smsc9420_stop_tx(struct smsc9420_pdata *pd) in smsc9420_stop_tx() argument
457 dmac_control = smsc9420_reg_read(pd, DMAC_CONTROL); in smsc9420_stop_tx()
459 smsc9420_reg_write(pd, DMAC_CONTROL, dmac_control); in smsc9420_stop_tx()
463 if (smsc9420_reg_read(pd, DMAC_STATUS) & DMAC_STS_TS_) in smsc9420_stop_tx()
469 netif_warn(pd, ifdown, pd->dev, "TX DMAC failed to stop\n"); in smsc9420_stop_tx()
472 smsc9420_reg_write(pd, DMAC_STATUS, DMAC_STS_TXPS_); in smsc9420_stop_tx()
475 dma_intr_ena = smsc9420_reg_read(pd, DMAC_INTR_ENA); in smsc9420_stop_tx()
477 smsc9420_reg_write(pd, DMAC_INTR_ENA, dma_intr_ena); in smsc9420_stop_tx()
478 smsc9420_pci_flush_write(pd); in smsc9420_stop_tx()
481 mac_cr = smsc9420_reg_read(pd, MAC_CR) & (~MAC_CR_TXEN_); in smsc9420_stop_tx()
482 smsc9420_reg_write(pd, MAC_CR, mac_cr); in smsc9420_stop_tx()
483 smsc9420_pci_flush_write(pd); in smsc9420_stop_tx()
486 static void smsc9420_free_tx_ring(struct smsc9420_pdata *pd) in smsc9420_free_tx_ring() argument
490 BUG_ON(!pd->tx_ring); in smsc9420_free_tx_ring()
492 if (!pd->tx_buffers) in smsc9420_free_tx_ring()
496 struct sk_buff *skb = pd->tx_buffers[i].skb; in smsc9420_free_tx_ring()
499 BUG_ON(!pd->tx_buffers[i].mapping); in smsc9420_free_tx_ring()
500 dma_unmap_single(&pd->pdev->dev, in smsc9420_free_tx_ring()
501 pd->tx_buffers[i].mapping, skb->len, in smsc9420_free_tx_ring()
506 pd->tx_ring[i].status = 0; in smsc9420_free_tx_ring()
507 pd->tx_ring[i].length = 0; in smsc9420_free_tx_ring()
508 pd->tx_ring[i].buffer1 = 0; in smsc9420_free_tx_ring()
509 pd->tx_ring[i].buffer2 = 0; in smsc9420_free_tx_ring()
513 kfree(pd->tx_buffers); in smsc9420_free_tx_ring()
514 pd->tx_buffers = NULL; in smsc9420_free_tx_ring()
516 pd->tx_ring_head = 0; in smsc9420_free_tx_ring()
517 pd->tx_ring_tail = 0; in smsc9420_free_tx_ring()
520 static void smsc9420_free_rx_ring(struct smsc9420_pdata *pd) in smsc9420_free_rx_ring() argument
524 BUG_ON(!pd->rx_ring); in smsc9420_free_rx_ring()
526 if (!pd->rx_buffers) in smsc9420_free_rx_ring()
530 if (pd->rx_buffers[i].skb) in smsc9420_free_rx_ring()
531 dev_kfree_skb_any(pd->rx_buffers[i].skb); in smsc9420_free_rx_ring()
533 if (pd->rx_buffers[i].mapping) in smsc9420_free_rx_ring()
534 dma_unmap_single(&pd->pdev->dev, in smsc9420_free_rx_ring()
535 pd->rx_buffers[i].mapping, in smsc9420_free_rx_ring()
538 pd->rx_ring[i].status = 0; in smsc9420_free_rx_ring()
539 pd->rx_ring[i].length = 0; in smsc9420_free_rx_ring()
540 pd->rx_ring[i].buffer1 = 0; in smsc9420_free_rx_ring()
541 pd->rx_ring[i].buffer2 = 0; in smsc9420_free_rx_ring()
545 kfree(pd->rx_buffers); in smsc9420_free_rx_ring()
546 pd->rx_buffers = NULL; in smsc9420_free_rx_ring()
548 pd->rx_ring_head = 0; in smsc9420_free_rx_ring()
549 pd->rx_ring_tail = 0; in smsc9420_free_rx_ring()
552 static void smsc9420_stop_rx(struct smsc9420_pdata *pd) in smsc9420_stop_rx() argument
558 dma_intr_ena = smsc9420_reg_read(pd, DMAC_INTR_ENA); in smsc9420_stop_rx()
560 smsc9420_reg_write(pd, DMAC_INTR_ENA, dma_intr_ena); in smsc9420_stop_rx()
561 smsc9420_pci_flush_write(pd); in smsc9420_stop_rx()
564 mac_cr = smsc9420_reg_read(pd, MAC_CR) & (~MAC_CR_RXEN_); in smsc9420_stop_rx()
565 smsc9420_reg_write(pd, MAC_CR, mac_cr); in smsc9420_stop_rx()
566 smsc9420_pci_flush_write(pd); in smsc9420_stop_rx()
569 dmac_control = smsc9420_reg_read(pd, DMAC_CONTROL); in smsc9420_stop_rx()
571 smsc9420_reg_write(pd, DMAC_CONTROL, dmac_control); in smsc9420_stop_rx()
572 smsc9420_pci_flush_write(pd); in smsc9420_stop_rx()
576 if (smsc9420_reg_read(pd, DMAC_STATUS) & DMAC_STS_RS_) in smsc9420_stop_rx()
582 netif_warn(pd, ifdown, pd->dev, in smsc9420_stop_rx()
586 smsc9420_reg_write(pd, DMAC_STATUS, DMAC_STS_RXPS_); in smsc9420_stop_rx()
591 struct smsc9420_pdata *pd = dev_id; in smsc9420_isr() local
596 BUG_ON(!pd); in smsc9420_isr()
597 BUG_ON(!pd->ioaddr); in smsc9420_isr()
599 int_cfg = smsc9420_reg_read(pd, INT_CFG); in smsc9420_isr()
606 int_sts = smsc9420_reg_read(pd, INT_STAT); in smsc9420_isr()
609 u32 status = smsc9420_reg_read(pd, DMAC_STATUS); in smsc9420_isr()
614 netif_wake_queue(pd->dev); in smsc9420_isr()
619 u32 dma_intr_ena = smsc9420_reg_read(pd, DMAC_INTR_ENA); in smsc9420_isr()
621 smsc9420_reg_write(pd, DMAC_INTR_ENA, dma_intr_ena); in smsc9420_isr()
622 smsc9420_pci_flush_write(pd); in smsc9420_isr()
625 napi_schedule(&pd->napi); in smsc9420_isr()
629 smsc9420_reg_write(pd, DMAC_STATUS, ints_to_clear); in smsc9420_isr()
636 spin_lock_irqsave(&pd->int_lock, flags); in smsc9420_isr()
637 int_ctl = smsc9420_reg_read(pd, INT_CTL); in smsc9420_isr()
639 smsc9420_reg_write(pd, INT_CTL, int_ctl); in smsc9420_isr()
640 spin_unlock_irqrestore(&pd->int_lock, flags); in smsc9420_isr()
642 smsc9420_reg_write(pd, INT_STAT, INT_STAT_SW_INT_); in smsc9420_isr()
643 pd->software_irq_signal = true; in smsc9420_isr()
650 smsc9420_pci_flush_write(pd); in smsc9420_isr()
658 struct smsc9420_pdata *pd = netdev_priv(dev); in smsc9420_poll_controller() local
659 const int irq = pd->pdev->irq; in smsc9420_poll_controller()
667 static void smsc9420_dmac_soft_reset(struct smsc9420_pdata *pd) in smsc9420_dmac_soft_reset() argument
669 smsc9420_reg_write(pd, BUS_MODE, BUS_MODE_SWR_); in smsc9420_dmac_soft_reset()
670 smsc9420_reg_read(pd, BUS_MODE); in smsc9420_dmac_soft_reset()
672 if (smsc9420_reg_read(pd, BUS_MODE) & BUS_MODE_SWR_) in smsc9420_dmac_soft_reset()
673 netif_warn(pd, drv, pd->dev, "Software reset not cleared\n"); in smsc9420_dmac_soft_reset()
678 struct smsc9420_pdata *pd = netdev_priv(dev); in smsc9420_stop() local
682 BUG_ON(!pd); in smsc9420_stop()
686 spin_lock_irqsave(&pd->int_lock, flags); in smsc9420_stop()
687 int_cfg = smsc9420_reg_read(pd, INT_CFG) & (~INT_CFG_IRQ_EN_); in smsc9420_stop()
688 smsc9420_reg_write(pd, INT_CFG, int_cfg); in smsc9420_stop()
689 spin_unlock_irqrestore(&pd->int_lock, flags); in smsc9420_stop()
692 napi_disable(&pd->napi); in smsc9420_stop()
694 smsc9420_stop_tx(pd); in smsc9420_stop()
695 smsc9420_free_tx_ring(pd); in smsc9420_stop()
697 smsc9420_stop_rx(pd); in smsc9420_stop()
698 smsc9420_free_rx_ring(pd); in smsc9420_stop()
700 free_irq(pd->pdev->irq, pd); in smsc9420_stop()
702 smsc9420_dmac_soft_reset(pd); in smsc9420_stop()
707 mdiobus_unregister(pd->mii_bus); in smsc9420_stop()
708 mdiobus_free(pd->mii_bus); in smsc9420_stop()
737 static void smsc9420_rx_handoff(struct smsc9420_pdata *pd, const int index, in smsc9420_rx_handoff() argument
740 struct net_device *dev = pd->dev; in smsc9420_rx_handoff()
748 if (pd->rx_csum) in smsc9420_rx_handoff()
754 dma_unmap_single(&pd->pdev->dev, pd->rx_buffers[index].mapping, in smsc9420_rx_handoff()
756 pd->rx_buffers[index].mapping = 0; in smsc9420_rx_handoff()
758 skb = pd->rx_buffers[index].skb; in smsc9420_rx_handoff()
759 pd->rx_buffers[index].skb = NULL; in smsc9420_rx_handoff()
761 if (pd->rx_csum) { in smsc9420_rx_handoff()
776 static int smsc9420_alloc_rx_buffer(struct smsc9420_pdata *pd, int index) in smsc9420_alloc_rx_buffer() argument
778 struct sk_buff *skb = netdev_alloc_skb(pd->dev, PKT_BUF_SZ); in smsc9420_alloc_rx_buffer()
781 BUG_ON(pd->rx_buffers[index].skb); in smsc9420_alloc_rx_buffer()
782 BUG_ON(pd->rx_buffers[index].mapping); in smsc9420_alloc_rx_buffer()
787 mapping = dma_map_single(&pd->pdev->dev, skb_tail_pointer(skb), in smsc9420_alloc_rx_buffer()
789 if (dma_mapping_error(&pd->pdev->dev, mapping)) { in smsc9420_alloc_rx_buffer()
791 netif_warn(pd, rx_err, pd->dev, "pci_map_single failed!\n"); in smsc9420_alloc_rx_buffer()
795 pd->rx_buffers[index].skb = skb; in smsc9420_alloc_rx_buffer()
796 pd->rx_buffers[index].mapping = mapping; in smsc9420_alloc_rx_buffer()
797 pd->rx_ring[index].buffer1 = mapping + NET_IP_ALIGN; in smsc9420_alloc_rx_buffer()
798 pd->rx_ring[index].status = RDES0_OWN_; in smsc9420_alloc_rx_buffer()
804 static void smsc9420_alloc_new_rx_buffers(struct smsc9420_pdata *pd) in smsc9420_alloc_new_rx_buffers() argument
806 while (pd->rx_ring_tail != pd->rx_ring_head) { in smsc9420_alloc_new_rx_buffers()
807 if (smsc9420_alloc_rx_buffer(pd, pd->rx_ring_tail)) in smsc9420_alloc_new_rx_buffers()
810 pd->rx_ring_tail = (pd->rx_ring_tail + 1) % RX_RING_SIZE; in smsc9420_alloc_new_rx_buffers()
816 struct smsc9420_pdata *pd = in smsc9420_rx_poll() local
818 struct net_device *dev = pd->dev; in smsc9420_rx_poll()
824 status = pd->rx_ring[pd->rx_ring_head].status; in smsc9420_rx_poll()
831 smsc9420_rx_handoff(pd, pd->rx_ring_head, status); in smsc9420_rx_poll()
832 pd->rx_ring_head = (pd->rx_ring_head + 1) % RX_RING_SIZE; in smsc9420_rx_poll()
833 smsc9420_alloc_new_rx_buffers(pd); in smsc9420_rx_poll()
836 drop_frame_cnt = smsc9420_reg_read(pd, MISS_FRAME_CNTR); in smsc9420_rx_poll()
841 smsc9420_reg_write(pd, RX_POLL_DEMAND, 1); in smsc9420_rx_poll()
842 smsc9420_pci_flush_write(pd); in smsc9420_rx_poll()
845 napi_complete_done(&pd->napi, work_done); in smsc9420_rx_poll()
848 dma_intr_ena = smsc9420_reg_read(pd, DMAC_INTR_ENA); in smsc9420_rx_poll()
850 smsc9420_reg_write(pd, DMAC_INTR_ENA, dma_intr_ena); in smsc9420_rx_poll()
851 smsc9420_pci_flush_write(pd); in smsc9420_rx_poll()
887 struct smsc9420_pdata *pd = netdev_priv(dev); in smsc9420_complete_tx() local
889 while (pd->tx_ring_tail != pd->tx_ring_head) { in smsc9420_complete_tx()
890 int index = pd->tx_ring_tail; in smsc9420_complete_tx()
894 status = pd->tx_ring[index].status; in smsc9420_complete_tx()
895 length = pd->tx_ring[index].length; in smsc9420_complete_tx()
903 BUG_ON(!pd->tx_buffers[index].skb); in smsc9420_complete_tx()
904 BUG_ON(!pd->tx_buffers[index].mapping); in smsc9420_complete_tx()
906 dma_unmap_single(&pd->pdev->dev, in smsc9420_complete_tx()
907 pd->tx_buffers[index].mapping, in smsc9420_complete_tx()
908 pd->tx_buffers[index].skb->len, in smsc9420_complete_tx()
910 pd->tx_buffers[index].mapping = 0; in smsc9420_complete_tx()
912 dev_kfree_skb_any(pd->tx_buffers[index].skb); in smsc9420_complete_tx()
913 pd->tx_buffers[index].skb = NULL; in smsc9420_complete_tx()
915 pd->tx_ring[index].buffer1 = 0; in smsc9420_complete_tx()
918 pd->tx_ring_tail = (pd->tx_ring_tail + 1) % TX_RING_SIZE; in smsc9420_complete_tx()
925 struct smsc9420_pdata *pd = netdev_priv(dev); in smsc9420_hard_start_xmit() local
927 int index = pd->tx_ring_head; in smsc9420_hard_start_xmit()
930 (((pd->tx_ring_head + 2) % TX_RING_SIZE) == pd->tx_ring_tail); in smsc9420_hard_start_xmit()
935 BUG_ON(pd->tx_ring[index].status & TDES0_OWN_); in smsc9420_hard_start_xmit()
936 BUG_ON(pd->tx_buffers[index].skb); in smsc9420_hard_start_xmit()
937 BUG_ON(pd->tx_buffers[index].mapping); in smsc9420_hard_start_xmit()
939 mapping = dma_map_single(&pd->pdev->dev, skb->data, skb->len, in smsc9420_hard_start_xmit()
941 if (dma_mapping_error(&pd->pdev->dev, mapping)) { in smsc9420_hard_start_xmit()
942 netif_warn(pd, tx_err, pd->dev, in smsc9420_hard_start_xmit()
947 pd->tx_buffers[index].skb = skb; in smsc9420_hard_start_xmit()
948 pd->tx_buffers[index].mapping = mapping; in smsc9420_hard_start_xmit()
953 netif_stop_queue(pd->dev); in smsc9420_hard_start_xmit()
960 pd->tx_ring[index].buffer1 = mapping; in smsc9420_hard_start_xmit()
961 pd->tx_ring[index].length = tmp_desc1; in smsc9420_hard_start_xmit()
965 pd->tx_ring_head = (pd->tx_ring_head + 1) % TX_RING_SIZE; in smsc9420_hard_start_xmit()
968 pd->tx_ring[index].status = TDES0_OWN_; in smsc9420_hard_start_xmit()
974 smsc9420_reg_write(pd, TX_POLL_DEMAND, 1); in smsc9420_hard_start_xmit()
975 smsc9420_pci_flush_write(pd); in smsc9420_hard_start_xmit()
982 struct smsc9420_pdata *pd = netdev_priv(dev); in smsc9420_get_stats() local
983 u32 counter = smsc9420_reg_read(pd, MISS_FRAME_CNTR); in smsc9420_get_stats()
991 struct smsc9420_pdata *pd = netdev_priv(dev); in smsc9420_set_multicast_list() local
992 u32 mac_cr = smsc9420_reg_read(pd, MAC_CR); in smsc9420_set_multicast_list()
995 netif_dbg(pd, hw, pd->dev, "Promiscuous Mode Enabled\n"); in smsc9420_set_multicast_list()
1000 netif_dbg(pd, hw, pd->dev, "Receive all Multicast Enabled\n"); in smsc9420_set_multicast_list()
1008 netif_dbg(pd, hw, pd->dev, "Multicast filter enabled\n"); in smsc9420_set_multicast_list()
1019 smsc9420_reg_write(pd, HASHH, hash_hi); in smsc9420_set_multicast_list()
1020 smsc9420_reg_write(pd, HASHL, hash_lo); in smsc9420_set_multicast_list()
1026 netif_dbg(pd, hw, pd->dev, "Receive own packets only\n"); in smsc9420_set_multicast_list()
1027 smsc9420_reg_write(pd, HASHH, 0); in smsc9420_set_multicast_list()
1028 smsc9420_reg_write(pd, HASHL, 0); in smsc9420_set_multicast_list()
1035 smsc9420_reg_write(pd, MAC_CR, mac_cr); in smsc9420_set_multicast_list()
1036 smsc9420_pci_flush_write(pd); in smsc9420_set_multicast_list()
1039 static void smsc9420_phy_update_flowcontrol(struct smsc9420_pdata *pd) in smsc9420_phy_update_flowcontrol() argument
1041 struct net_device *dev = pd->dev; in smsc9420_phy_update_flowcontrol()
1055 netif_info(pd, link, pd->dev, "rx pause %s, tx pause %s\n", in smsc9420_phy_update_flowcontrol()
1059 netif_info(pd, link, pd->dev, "half duplex\n"); in smsc9420_phy_update_flowcontrol()
1063 smsc9420_reg_write(pd, FLOW, flow); in smsc9420_phy_update_flowcontrol()
1070 struct smsc9420_pdata *pd = netdev_priv(dev); in smsc9420_phy_adjust_link() local
1074 if (phy_dev->duplex != pd->last_duplex) { in smsc9420_phy_adjust_link()
1075 u32 mac_cr = smsc9420_reg_read(pd, MAC_CR); in smsc9420_phy_adjust_link()
1077 netif_dbg(pd, link, pd->dev, "full duplex mode\n"); in smsc9420_phy_adjust_link()
1080 netif_dbg(pd, link, pd->dev, "half duplex mode\n"); in smsc9420_phy_adjust_link()
1083 smsc9420_reg_write(pd, MAC_CR, mac_cr); in smsc9420_phy_adjust_link()
1085 smsc9420_phy_update_flowcontrol(pd); in smsc9420_phy_adjust_link()
1086 pd->last_duplex = phy_dev->duplex; in smsc9420_phy_adjust_link()
1090 if (carrier != pd->last_carrier) { in smsc9420_phy_adjust_link()
1092 netif_dbg(pd, link, pd->dev, "carrier OK\n"); in smsc9420_phy_adjust_link()
1094 netif_dbg(pd, link, pd->dev, "no carrier\n"); in smsc9420_phy_adjust_link()
1095 pd->last_carrier = carrier; in smsc9420_phy_adjust_link()
1101 struct smsc9420_pdata *pd = netdev_priv(dev); in smsc9420_mii_probe() local
1107 phydev = mdiobus_get_phy(pd->mii_bus, 1); in smsc9420_mii_probe()
1128 pd->last_duplex = -1; in smsc9420_mii_probe()
1129 pd->last_carrier = -1; in smsc9420_mii_probe()
1136 struct smsc9420_pdata *pd = netdev_priv(dev); in smsc9420_mii_init() local
1139 pd->mii_bus = mdiobus_alloc(); in smsc9420_mii_init()
1140 if (!pd->mii_bus) { in smsc9420_mii_init()
1144 pd->mii_bus->name = DRV_MDIONAME; in smsc9420_mii_init()
1145 snprintf(pd->mii_bus->id, MII_BUS_ID_SIZE, "%x", in smsc9420_mii_init()
1146 (pd->pdev->bus->number << 8) | pd->pdev->devfn); in smsc9420_mii_init()
1147 pd->mii_bus->priv = pd; in smsc9420_mii_init()
1148 pd->mii_bus->read = smsc9420_mii_read; in smsc9420_mii_init()
1149 pd->mii_bus->write = smsc9420_mii_write; in smsc9420_mii_init()
1152 pd->mii_bus->phy_mask = ~(1 << 1); in smsc9420_mii_init()
1154 if (mdiobus_register(pd->mii_bus)) { in smsc9420_mii_init()
1155 netif_warn(pd, probe, pd->dev, "Error registering mii bus\n"); in smsc9420_mii_init()
1160 netif_warn(pd, probe, pd->dev, "Error probing mii bus\n"); in smsc9420_mii_init()
1167 mdiobus_unregister(pd->mii_bus); in smsc9420_mii_init()
1169 mdiobus_free(pd->mii_bus); in smsc9420_mii_init()
1174 static int smsc9420_alloc_tx_ring(struct smsc9420_pdata *pd) in smsc9420_alloc_tx_ring() argument
1178 BUG_ON(!pd->tx_ring); in smsc9420_alloc_tx_ring()
1180 pd->tx_buffers = kmalloc_array(TX_RING_SIZE, in smsc9420_alloc_tx_ring()
1183 if (!pd->tx_buffers) in smsc9420_alloc_tx_ring()
1188 pd->tx_buffers[i].skb = NULL; in smsc9420_alloc_tx_ring()
1189 pd->tx_buffers[i].mapping = 0; in smsc9420_alloc_tx_ring()
1190 pd->tx_ring[i].status = 0; in smsc9420_alloc_tx_ring()
1191 pd->tx_ring[i].length = 0; in smsc9420_alloc_tx_ring()
1192 pd->tx_ring[i].buffer1 = 0; in smsc9420_alloc_tx_ring()
1193 pd->tx_ring[i].buffer2 = 0; in smsc9420_alloc_tx_ring()
1195 pd->tx_ring[TX_RING_SIZE - 1].length = TDES1_TER_; in smsc9420_alloc_tx_ring()
1198 pd->tx_ring_head = 0; in smsc9420_alloc_tx_ring()
1199 pd->tx_ring_tail = 0; in smsc9420_alloc_tx_ring()
1201 smsc9420_reg_write(pd, TX_BASE_ADDR, pd->tx_dma_addr); in smsc9420_alloc_tx_ring()
1202 smsc9420_pci_flush_write(pd); in smsc9420_alloc_tx_ring()
1207 static int smsc9420_alloc_rx_ring(struct smsc9420_pdata *pd) in smsc9420_alloc_rx_ring() argument
1211 BUG_ON(!pd->rx_ring); in smsc9420_alloc_rx_ring()
1213 pd->rx_buffers = kmalloc_array(RX_RING_SIZE, in smsc9420_alloc_rx_ring()
1216 if (pd->rx_buffers == NULL) in smsc9420_alloc_rx_ring()
1221 pd->rx_ring[i].status = 0; in smsc9420_alloc_rx_ring()
1222 pd->rx_ring[i].length = PKT_BUF_SZ; in smsc9420_alloc_rx_ring()
1223 pd->rx_ring[i].buffer2 = 0; in smsc9420_alloc_rx_ring()
1224 pd->rx_buffers[i].skb = NULL; in smsc9420_alloc_rx_ring()
1225 pd->rx_buffers[i].mapping = 0; in smsc9420_alloc_rx_ring()
1227 pd->rx_ring[RX_RING_SIZE - 1].length = (PKT_BUF_SZ | RDES1_RER_); in smsc9420_alloc_rx_ring()
1231 if (smsc9420_alloc_rx_buffer(pd, i)) { in smsc9420_alloc_rx_ring()
1232 netif_warn(pd, ifup, pd->dev, in smsc9420_alloc_rx_ring()
1238 pd->rx_ring_head = 0; in smsc9420_alloc_rx_ring()
1239 pd->rx_ring_tail = 0; in smsc9420_alloc_rx_ring()
1241 smsc9420_reg_write(pd, VLAN1, ETH_P_8021Q); in smsc9420_alloc_rx_ring()
1242 netif_dbg(pd, ifup, pd->dev, "VLAN1 = 0x%08x\n", in smsc9420_alloc_rx_ring()
1243 smsc9420_reg_read(pd, VLAN1)); in smsc9420_alloc_rx_ring()
1245 if (pd->rx_csum) { in smsc9420_alloc_rx_ring()
1247 u32 coe = smsc9420_reg_read(pd, COE_CR) | RX_COE_EN; in smsc9420_alloc_rx_ring()
1248 smsc9420_reg_write(pd, COE_CR, coe); in smsc9420_alloc_rx_ring()
1249 netif_dbg(pd, ifup, pd->dev, "COE_CR = 0x%08x\n", coe); in smsc9420_alloc_rx_ring()
1252 smsc9420_reg_write(pd, RX_BASE_ADDR, pd->rx_dma_addr); in smsc9420_alloc_rx_ring()
1253 smsc9420_pci_flush_write(pd); in smsc9420_alloc_rx_ring()
1258 smsc9420_free_rx_ring(pd); in smsc9420_alloc_rx_ring()
1265 struct smsc9420_pdata *pd = netdev_priv(dev); in smsc9420_open() local
1267 const int irq = pd->pdev->irq; in smsc9420_open()
1272 netif_warn(pd, ifup, pd->dev, in smsc9420_open()
1281 spin_lock_irqsave(&pd->int_lock, flags); in smsc9420_open()
1282 int_cfg = smsc9420_reg_read(pd, INT_CFG) & (~INT_CFG_IRQ_EN_); in smsc9420_open()
1283 smsc9420_reg_write(pd, INT_CFG, int_cfg); in smsc9420_open()
1284 smsc9420_reg_write(pd, INT_CTL, 0); in smsc9420_open()
1285 spin_unlock_irqrestore(&pd->int_lock, flags); in smsc9420_open()
1286 smsc9420_reg_write(pd, DMAC_INTR_ENA, 0); in smsc9420_open()
1287 smsc9420_reg_write(pd, INT_STAT, 0xFFFFFFFF); in smsc9420_open()
1288 smsc9420_pci_flush_write(pd); in smsc9420_open()
1290 result = request_irq(irq, smsc9420_isr, IRQF_SHARED, DRV_NAME, pd); in smsc9420_open()
1292 netif_warn(pd, ifup, pd->dev, "Unable to use IRQ = %d\n", irq); in smsc9420_open()
1297 smsc9420_dmac_soft_reset(pd); in smsc9420_open()
1300 smsc9420_reg_write(pd, MAC_CR, 0); in smsc9420_open()
1305 smsc9420_reg_write(pd, GPIO_CFG, in smsc9420_open()
1314 smsc9420_reg_write(pd, BUS_MODE, bus_mode); in smsc9420_open()
1316 smsc9420_pci_flush_write(pd); in smsc9420_open()
1319 smsc9420_reg_write(pd, BUS_CFG, BUS_CFG_RXTXWEIGHT_4_1); in smsc9420_open()
1321 smsc9420_reg_write(pd, DMAC_CONTROL, in smsc9420_open()
1324 smsc9420_pci_flush_write(pd); in smsc9420_open()
1327 netif_dbg(pd, ifup, pd->dev, "Testing ISR using IRQ %d\n", irq); in smsc9420_open()
1328 pd->software_irq_signal = false; in smsc9420_open()
1330 spin_lock_irqsave(&pd->int_lock, flags); in smsc9420_open()
1332 int_cfg = smsc9420_reg_read(pd, INT_CFG) | INT_CFG_IRQ_EN_; in smsc9420_open()
1335 smsc9420_reg_write(pd, INT_CFG, int_cfg); in smsc9420_open()
1338 int_ctl = smsc9420_reg_read(pd, INT_CTL) | INT_CTL_SW_INT_EN_; in smsc9420_open()
1339 smsc9420_reg_write(pd, INT_CTL, int_ctl); in smsc9420_open()
1340 spin_unlock_irqrestore(&pd->int_lock, flags); in smsc9420_open()
1341 smsc9420_pci_flush_write(pd); in smsc9420_open()
1345 if (pd->software_irq_signal) in smsc9420_open()
1351 spin_lock_irqsave(&pd->int_lock, flags); in smsc9420_open()
1352 int_cfg = smsc9420_reg_read(pd, INT_CFG) & (~INT_CFG_IRQ_EN_); in smsc9420_open()
1353 smsc9420_reg_write(pd, INT_CFG, int_cfg); in smsc9420_open()
1354 spin_unlock_irqrestore(&pd->int_lock, flags); in smsc9420_open()
1356 if (!pd->software_irq_signal) { in smsc9420_open()
1357 netif_warn(pd, ifup, pd->dev, "ISR failed signaling test\n"); in smsc9420_open()
1362 netif_dbg(pd, ifup, pd->dev, "ISR passed test using IRQ %d\n", irq); in smsc9420_open()
1364 result = smsc9420_alloc_tx_ring(pd); in smsc9420_open()
1366 netif_warn(pd, ifup, pd->dev, in smsc9420_open()
1372 result = smsc9420_alloc_rx_ring(pd); in smsc9420_open()
1374 netif_warn(pd, ifup, pd->dev, in smsc9420_open()
1382 netif_warn(pd, ifup, pd->dev, "Failed to initialize Phy\n"); in smsc9420_open()
1390 napi_enable(&pd->napi); in smsc9420_open()
1393 mac_cr = smsc9420_reg_read(pd, MAC_CR) | MAC_CR_TXEN_ | MAC_CR_RXEN_; in smsc9420_open()
1394 smsc9420_reg_write(pd, MAC_CR, mac_cr); in smsc9420_open()
1396 dmac_control = smsc9420_reg_read(pd, DMAC_CONTROL); in smsc9420_open()
1398 smsc9420_reg_write(pd, DMAC_CONTROL, dmac_control); in smsc9420_open()
1399 smsc9420_pci_flush_write(pd); in smsc9420_open()
1401 dma_intr_ena = smsc9420_reg_read(pd, DMAC_INTR_ENA); in smsc9420_open()
1404 smsc9420_reg_write(pd, DMAC_INTR_ENA, dma_intr_ena); in smsc9420_open()
1405 smsc9420_pci_flush_write(pd); in smsc9420_open()
1409 smsc9420_reg_write(pd, RX_POLL_DEMAND, 1); in smsc9420_open()
1412 spin_lock_irqsave(&pd->int_lock, flags); in smsc9420_open()
1413 int_cfg = smsc9420_reg_read(pd, INT_CFG) | INT_CFG_IRQ_EN_; in smsc9420_open()
1414 smsc9420_reg_write(pd, INT_CFG, int_cfg); in smsc9420_open()
1415 spin_unlock_irqrestore(&pd->int_lock, flags); in smsc9420_open()
1420 smsc9420_free_rx_ring(pd); in smsc9420_open()
1422 smsc9420_free_tx_ring(pd); in smsc9420_open()
1424 free_irq(irq, pd); in smsc9420_open()
1432 struct smsc9420_pdata *pd = netdev_priv(dev); in smsc9420_suspend() local
1437 spin_lock_irqsave(&pd->int_lock, flags); in smsc9420_suspend()
1438 int_cfg = smsc9420_reg_read(pd, INT_CFG) & (~INT_CFG_IRQ_EN_); in smsc9420_suspend()
1439 smsc9420_reg_write(pd, INT_CFG, int_cfg); in smsc9420_suspend()
1440 spin_unlock_irqrestore(&pd->int_lock, flags); in smsc9420_suspend()
1444 smsc9420_stop_tx(pd); in smsc9420_suspend()
1445 smsc9420_free_tx_ring(pd); in smsc9420_suspend()
1447 napi_disable(&pd->napi); in smsc9420_suspend()
1448 smsc9420_stop_rx(pd); in smsc9420_suspend()
1449 smsc9420_free_rx_ring(pd); in smsc9420_suspend()
1451 free_irq(pd->pdev->irq, pd); in smsc9420_suspend()
1497 struct smsc9420_pdata *pd; in smsc9420_probe() local
1513 dev = alloc_etherdev(sizeof(*pd)); in smsc9420_probe()
1544 pd = netdev_priv(dev); in smsc9420_probe()
1547 pd->rx_ring = dma_alloc_coherent(&pdev->dev, in smsc9420_probe()
1549 &pd->rx_dma_addr, GFP_KERNEL); in smsc9420_probe()
1551 if (!pd->rx_ring) in smsc9420_probe()
1555 pd->tx_ring = (pd->rx_ring + RX_RING_SIZE); in smsc9420_probe()
1556 pd->tx_dma_addr = pd->rx_dma_addr + in smsc9420_probe()
1559 pd->pdev = pdev; in smsc9420_probe()
1560 pd->dev = dev; in smsc9420_probe()
1561 pd->ioaddr = virt_addr; in smsc9420_probe()
1562 pd->msg_enable = smsc_debug; in smsc9420_probe()
1563 pd->rx_csum = true; in smsc9420_probe()
1565 netif_dbg(pd, probe, pd->dev, "lan_base=0x%08lx\n", (ulong)virt_addr); in smsc9420_probe()
1567 id_rev = smsc9420_reg_read(pd, ID_REV); in smsc9420_probe()
1570 netif_info(pd, probe, pd->dev, in smsc9420_probe()
1574 netif_warn(pd, probe, pd->dev, "LAN9420 NOT identified\n"); in smsc9420_probe()
1575 netif_warn(pd, probe, pd->dev, "ID_REV=0x%08X\n", id_rev); in smsc9420_probe()
1579 smsc9420_dmac_soft_reset(pd); in smsc9420_probe()
1580 smsc9420_eeprom_reload(pd); in smsc9420_probe()
1586 netif_napi_add(dev, &pd->napi, smsc9420_rx_poll, NAPI_WEIGHT); in smsc9420_probe()
1590 netif_warn(pd, probe, pd->dev, "error %i registering device\n", in smsc9420_probe()
1597 spin_lock_init(&pd->int_lock); in smsc9420_probe()
1598 spin_lock_init(&pd->phy_lock); in smsc9420_probe()
1607 pd->rx_ring, pd->rx_dma_addr); in smsc9420_probe()
1623 struct smsc9420_pdata *pd; in smsc9420_remove() local
1629 pd = netdev_priv(dev); in smsc9420_remove()
1633 BUG_ON(pd->tx_buffers); in smsc9420_remove()
1634 BUG_ON(pd->rx_buffers); in smsc9420_remove()
1636 BUG_ON(!pd->tx_ring); in smsc9420_remove()
1637 BUG_ON(!pd->rx_ring); in smsc9420_remove()
1641 pd->rx_ring, pd->rx_dma_addr); in smsc9420_remove()
1643 iounmap(pd->ioaddr - LAN9420_CPSR_ENDIAN_OFFSET); in smsc9420_remove()