Lines Matching +full:tp +full:- +full:link
35 #include <linux/dma-mapping.h>
159 TxDMAShift = 8, /* DMA burst value (0-7) is shift this many bits */
191 LSEN = 0x08000000, // TSO ? -- FR
209 LINK = 0x00010000, enumerator
224 RxDescCountMask = 0x7f000000, // multi-desc pkt when > 1 ? -- FR
345 } debug = { -1 };
349 MODULE_PARM_DESC(rx_copybreak, "Copy breakpoint for copy-only-tiny-frames");
360 * Maximum number of multicast addresses to filter (vs. Rx-all-multicast).
400 struct sis190_private *tp = netdev_priv(dev); in __mdio_write() local
402 mdio_write(tp->mmio_addr, phy_id, reg, val); in __mdio_write()
407 struct sis190_private *tp = netdev_priv(dev); in __mdio_read() local
409 return mdio_read(tp->mmio_addr, phy_id, reg); in __mdio_read()
458 desc->size |= cpu_to_le32(RingEnd); in sis190_mark_as_last_descriptor()
463 u32 eor = le32_to_cpu(desc->size) & RingEnd; in sis190_give_to_asic()
465 desc->PSize = 0x0; in sis190_give_to_asic()
466 desc->size = cpu_to_le32((rx_buf_sz & RX_BUF_MASK) | eor); in sis190_give_to_asic()
468 desc->status = cpu_to_le32(OWNbit | INTbit); in sis190_give_to_asic()
474 desc->addr = cpu_to_le32(mapping); in sis190_map_to_asic()
480 desc->PSize = 0x0; in sis190_make_unusable_by_asic()
481 desc->addr = cpu_to_le32(0xdeadbeef); in sis190_make_unusable_by_asic()
482 desc->size &= cpu_to_le32(RingEnd); in sis190_make_unusable_by_asic()
484 desc->status = 0x0; in sis190_make_unusable_by_asic()
487 static struct sk_buff *sis190_alloc_rx_skb(struct sis190_private *tp, in sis190_alloc_rx_skb() argument
490 u32 rx_buf_sz = tp->rx_buf_sz; in sis190_alloc_rx_skb()
494 skb = netdev_alloc_skb(tp->dev, rx_buf_sz); in sis190_alloc_rx_skb()
497 mapping = dma_map_single(&tp->pci_dev->dev, skb->data, tp->rx_buf_sz, in sis190_alloc_rx_skb()
499 if (dma_mapping_error(&tp->pci_dev->dev, mapping)) in sis190_alloc_rx_skb()
512 static u32 sis190_rx_fill(struct sis190_private *tp, struct net_device *dev, in sis190_rx_fill() argument
520 if (tp->Rx_skbuff[i]) in sis190_rx_fill()
523 tp->Rx_skbuff[i] = sis190_alloc_rx_skb(tp, tp->RxDescRing + i); in sis190_rx_fill()
525 if (!tp->Rx_skbuff[i]) in sis190_rx_fill()
528 return cur - start; in sis190_rx_fill()
531 static bool sis190_try_rx_copy(struct sis190_private *tp, in sis190_try_rx_copy() argument
541 skb = netdev_alloc_skb_ip_align(tp->dev, pkt_size); in sis190_try_rx_copy()
545 dma_sync_single_for_cpu(&tp->pci_dev->dev, addr, tp->rx_buf_sz, in sis190_try_rx_copy()
547 skb_copy_to_linear_data(skb, sk_buff[0]->data, pkt_size); in sis190_try_rx_copy()
562 stats->rx_crc_errors++; in sis190_rx_pkt_err()
564 stats->rx_over_errors++; in sis190_rx_pkt_err()
566 stats->rx_length_errors++; in sis190_rx_pkt_err()
568 stats->rx_frame_errors++; in sis190_rx_pkt_err()
570 stats->rx_errors++; in sis190_rx_pkt_err()
571 return -1; in sis190_rx_pkt_err()
575 struct sis190_private *tp, void __iomem *ioaddr) in sis190_rx_interrupt() argument
577 struct net_device_stats *stats = &dev->stats; in sis190_rx_interrupt()
578 u32 rx_left, cur_rx = tp->cur_rx; in sis190_rx_interrupt()
581 rx_left = NUM_RX_DESC + tp->dirty_rx - cur_rx; in sis190_rx_interrupt()
582 rx_left = sis190_rx_quota(rx_left, (u32) dev->quota); in sis190_rx_interrupt()
584 for (; rx_left > 0; rx_left--, cur_rx++) { in sis190_rx_interrupt()
586 struct RxDesc *desc = tp->RxDescRing + entry; in sis190_rx_interrupt()
589 if (le32_to_cpu(desc->status) & OWNbit) in sis190_rx_interrupt()
592 status = le32_to_cpu(desc->PSize); in sis190_rx_interrupt()
594 //netif_info(tp, intr, dev, "Rx PSize = %08x\n", status); in sis190_rx_interrupt()
597 sis190_give_to_asic(desc, tp->rx_buf_sz); in sis190_rx_interrupt()
599 struct sk_buff *skb = tp->Rx_skbuff[entry]; in sis190_rx_interrupt()
600 dma_addr_t addr = le32_to_cpu(desc->addr); in sis190_rx_interrupt()
601 int pkt_size = (status & RxSizeMask) - 4; in sis190_rx_interrupt()
602 struct pci_dev *pdev = tp->pci_dev; in sis190_rx_interrupt()
604 if (unlikely(pkt_size > tp->rx_buf_sz)) { in sis190_rx_interrupt()
605 netif_info(tp, intr, dev, in sis190_rx_interrupt()
607 stats->rx_dropped++; in sis190_rx_interrupt()
608 stats->rx_length_errors++; in sis190_rx_interrupt()
609 sis190_give_to_asic(desc, tp->rx_buf_sz); in sis190_rx_interrupt()
614 if (sis190_try_rx_copy(tp, &skb, pkt_size, addr)) { in sis190_rx_interrupt()
615 dma_sync_single_for_device(&pdev->dev, addr, in sis190_rx_interrupt()
616 tp->rx_buf_sz, in sis190_rx_interrupt()
618 sis190_give_to_asic(desc, tp->rx_buf_sz); in sis190_rx_interrupt()
620 dma_unmap_single(&pdev->dev, addr, in sis190_rx_interrupt()
621 tp->rx_buf_sz, in sis190_rx_interrupt()
623 tp->Rx_skbuff[entry] = NULL; in sis190_rx_interrupt()
628 skb->protocol = eth_type_trans(skb, dev); in sis190_rx_interrupt()
632 stats->rx_packets++; in sis190_rx_interrupt()
633 stats->rx_bytes += pkt_size; in sis190_rx_interrupt()
635 stats->multicast++; in sis190_rx_interrupt()
638 count = cur_rx - tp->cur_rx; in sis190_rx_interrupt()
639 tp->cur_rx = cur_rx; in sis190_rx_interrupt()
641 delta = sis190_rx_fill(tp, dev, tp->dirty_rx, tp->cur_rx); in sis190_rx_interrupt()
643 netif_info(tp, intr, dev, "no Rx buffer allocated\n"); in sis190_rx_interrupt()
644 tp->dirty_rx += delta; in sis190_rx_interrupt()
646 if ((tp->dirty_rx + NUM_RX_DESC) == tp->cur_rx) in sis190_rx_interrupt()
647 netif_emerg(tp, intr, dev, "Rx buffers exhausted\n"); in sis190_rx_interrupt()
657 len = skb->len < ETH_ZLEN ? ETH_ZLEN : skb->len; in sis190_unmap_tx_skb()
659 dma_unmap_single(&pdev->dev, le32_to_cpu(desc->addr), len, in sis190_unmap_tx_skb()
667 #define TxErrMask (WND | TABRT | FIFO | LINK) in sis190_tx_pkt_err()
673 stats->tx_window_errors++; in sis190_tx_pkt_err()
675 stats->tx_aborted_errors++; in sis190_tx_pkt_err()
677 stats->tx_fifo_errors++; in sis190_tx_pkt_err()
678 if (status & LINK) in sis190_tx_pkt_err()
679 stats->tx_carrier_errors++; in sis190_tx_pkt_err()
681 stats->tx_errors++; in sis190_tx_pkt_err()
683 return -1; in sis190_tx_pkt_err()
687 struct sis190_private *tp, void __iomem *ioaddr) in sis190_tx_interrupt() argument
689 struct net_device_stats *stats = &dev->stats; in sis190_tx_interrupt()
690 u32 pending, dirty_tx = tp->dirty_tx; in sis190_tx_interrupt()
698 pending = tp->cur_tx - dirty_tx; in sis190_tx_interrupt()
701 for (; pending; pending--, dirty_tx++) { in sis190_tx_interrupt()
703 struct TxDesc *txd = tp->TxDescRing + entry; in sis190_tx_interrupt()
704 u32 status = le32_to_cpu(txd->status); in sis190_tx_interrupt()
710 skb = tp->Tx_skbuff[entry]; in sis190_tx_interrupt()
713 stats->tx_packets++; in sis190_tx_interrupt()
714 stats->tx_bytes += skb->len; in sis190_tx_interrupt()
715 stats->collisions += ((status & ColCountMask) - 1); in sis190_tx_interrupt()
718 sis190_unmap_tx_skb(tp->pci_dev, skb, txd); in sis190_tx_interrupt()
719 tp->Tx_skbuff[entry] = NULL; in sis190_tx_interrupt()
723 if (tp->dirty_tx != dirty_tx) { in sis190_tx_interrupt()
724 tp->dirty_tx = dirty_tx; in sis190_tx_interrupt()
738 struct sis190_private *tp = netdev_priv(dev); in sis190_irq() local
739 void __iomem *ioaddr = tp->mmio_addr; in sis190_irq()
757 // netif_info(tp, intr, dev, "status = %08x\n", status); in sis190_irq()
760 netif_info(tp, intr, dev, "link change\n"); in sis190_irq()
761 del_timer(&tp->timer); in sis190_irq()
762 schedule_work(&tp->phy_task); in sis190_irq()
766 sis190_rx_interrupt(dev, tp, ioaddr); in sis190_irq()
769 sis190_tx_interrupt(dev, tp, ioaddr); in sis190_irq()
777 struct sis190_private *tp = netdev_priv(dev); in sis190_netpoll() local
778 const int irq = tp->pci_dev->irq; in sis190_netpoll()
786 static void sis190_free_rx_skb(struct sis190_private *tp, in sis190_free_rx_skb() argument
789 struct pci_dev *pdev = tp->pci_dev; in sis190_free_rx_skb()
791 dma_unmap_single(&pdev->dev, le32_to_cpu(desc->addr), tp->rx_buf_sz, in sis190_free_rx_skb()
798 static void sis190_rx_clear(struct sis190_private *tp) in sis190_rx_clear() argument
803 if (!tp->Rx_skbuff[i]) in sis190_rx_clear()
805 sis190_free_rx_skb(tp, tp->Rx_skbuff + i, tp->RxDescRing + i); in sis190_rx_clear()
809 static void sis190_init_ring_indexes(struct sis190_private *tp) in sis190_init_ring_indexes() argument
811 tp->dirty_tx = tp->dirty_rx = tp->cur_tx = tp->cur_rx = 0; in sis190_init_ring_indexes()
816 struct sis190_private *tp = netdev_priv(dev); in sis190_init_ring() local
818 sis190_init_ring_indexes(tp); in sis190_init_ring()
820 memset(tp->Tx_skbuff, 0x0, NUM_TX_DESC * sizeof(struct sk_buff *)); in sis190_init_ring()
821 memset(tp->Rx_skbuff, 0x0, NUM_RX_DESC * sizeof(struct sk_buff *)); in sis190_init_ring()
823 if (sis190_rx_fill(tp, dev, 0, NUM_RX_DESC) != NUM_RX_DESC) in sis190_init_ring()
826 sis190_mark_as_last_descriptor(tp->RxDescRing + NUM_RX_DESC - 1); in sis190_init_ring()
831 sis190_rx_clear(tp); in sis190_init_ring()
832 return -ENOMEM; in sis190_init_ring()
837 struct sis190_private *tp = netdev_priv(dev); in sis190_set_rx_mode() local
838 void __iomem *ioaddr = tp->mmio_addr; in sis190_set_rx_mode()
843 if (dev->flags & IFF_PROMISC) { in sis190_set_rx_mode()
849 (dev->flags & IFF_ALLMULTI)) { in sis190_set_rx_mode()
850 /* Too many to filter perfectly -- accept all multicasts. */ in sis190_set_rx_mode()
860 ether_crc(ETH_ALEN, ha->addr) & 0x3f; in sis190_set_rx_mode()
866 spin_lock_irqsave(&tp->lock, flags); in sis190_set_rx_mode()
872 spin_unlock_irqrestore(&tp->lock, flags); in sis190_set_rx_mode()
885 struct sis190_private *tp = netdev_priv(dev); in sis190_hw_start() local
886 void __iomem *ioaddr = tp->mmio_addr; in sis190_hw_start()
890 SIS_W32(TxDescStartAddr, tp->tx_dma); in sis190_hw_start()
891 SIS_W32(RxDescStartAddr, tp->rx_dma); in sis190_hw_start()
918 struct sis190_private *tp = in sis190_phy_task() local
920 struct net_device *dev = tp->dev; in sis190_phy_task()
921 void __iomem *ioaddr = tp->mmio_addr; in sis190_phy_task()
922 int phy_id = tp->mii_if.phy_id; in sis190_phy_task()
932 // FIXME: needlessly high ? -- FR 02/07/2005 in sis190_phy_task()
933 mod_timer(&tp->timer, jiffies + HZ/10); in sis190_phy_task()
938 if (!(val & BMSR_ANEGCOMPLETE) && tp->link_status != LNK_AUTONEG) { in sis190_phy_task()
940 netif_warn(tp, link, dev, "auto-negotiating...\n"); in sis190_phy_task()
941 tp->link_status = LNK_AUTONEG; in sis190_phy_task()
942 } else if ((val & BMSR_LSTATUS) && tp->link_status != LNK_ON) { in sis190_phy_task()
966 netif_info(tp, link, dev, "mii ext = %04x\n", val); in sis190_phy_task()
971 netif_info(tp, link, dev, "mii lpa=%04x adv=%04x exp=%04x\n", in sis190_phy_task()
987 for (p = reg31; p->val; p++) { in sis190_phy_task()
988 if ((val & p->val) == p->val) in sis190_phy_task()
993 p->ctl |= SIS_R32(StationControl) & ~0x0f001c00; in sis190_phy_task()
995 if ((tp->features & F_HAS_RGMII) && in sis190_phy_task()
996 (tp->features & F_PHY_BCM5461)) { in sis190_phy_task()
1001 p->ctl |= 0x03000000; in sis190_phy_task()
1004 SIS_W32(StationControl, p->ctl); in sis190_phy_task()
1006 if (tp->features & F_HAS_RGMII) { in sis190_phy_task()
1011 tp->negotiated_lpa = p->val; in sis190_phy_task()
1013 netif_info(tp, link, dev, "link on %s mode\n", p->msg); in sis190_phy_task()
1015 tp->link_status = LNK_ON; in sis190_phy_task()
1016 } else if (!(val & BMSR_LSTATUS) && tp->link_status != LNK_AUTONEG) in sis190_phy_task()
1017 tp->link_status = LNK_OFF; in sis190_phy_task()
1018 mod_timer(&tp->timer, jiffies + SIS190_PHY_TIMEOUT); in sis190_phy_task()
1026 struct sis190_private *tp = from_timer(tp, t, timer); in sis190_phy_timer() local
1027 struct net_device *dev = tp->dev; in sis190_phy_timer()
1030 schedule_work(&tp->phy_task); in sis190_phy_timer()
1035 struct sis190_private *tp = netdev_priv(dev); in sis190_delete_timer() local
1037 del_timer_sync(&tp->timer); in sis190_delete_timer()
1042 struct sis190_private *tp = netdev_priv(dev); in sis190_request_timer() local
1043 struct timer_list *timer = &tp->timer; in sis190_request_timer()
1046 timer->expires = jiffies + SIS190_PHY_TIMEOUT; in sis190_request_timer()
1050 static void sis190_set_rxbufsize(struct sis190_private *tp, in sis190_set_rxbufsize() argument
1053 unsigned int mtu = dev->mtu; in sis190_set_rxbufsize()
1055 tp->rx_buf_sz = (mtu > RX_BUF_SIZE) ? mtu + ETH_HLEN + 8 : RX_BUF_SIZE; in sis190_set_rxbufsize()
1056 /* RxDesc->size has a licence to kill the lower bits */ in sis190_set_rxbufsize()
1057 if (tp->rx_buf_sz & 0x07) { in sis190_set_rxbufsize()
1058 tp->rx_buf_sz += 8; in sis190_set_rxbufsize()
1059 tp->rx_buf_sz &= RX_BUF_MASK; in sis190_set_rxbufsize()
1065 struct sis190_private *tp = netdev_priv(dev); in sis190_open() local
1066 struct pci_dev *pdev = tp->pci_dev; in sis190_open()
1067 int rc = -ENOMEM; in sis190_open()
1069 sis190_set_rxbufsize(tp, dev); in sis190_open()
1075 tp->TxDescRing = dma_alloc_coherent(&pdev->dev, TX_RING_BYTES, in sis190_open()
1076 &tp->tx_dma, GFP_KERNEL); in sis190_open()
1077 if (!tp->TxDescRing) in sis190_open()
1080 tp->RxDescRing = dma_alloc_coherent(&pdev->dev, RX_RING_BYTES, in sis190_open()
1081 &tp->rx_dma, GFP_KERNEL); in sis190_open()
1082 if (!tp->RxDescRing) in sis190_open()
1091 rc = request_irq(pdev->irq, sis190_irq, IRQF_SHARED, dev->name, dev); in sis190_open()
1101 sis190_rx_clear(tp); in sis190_open()
1103 dma_free_coherent(&pdev->dev, RX_RING_BYTES, tp->RxDescRing, in sis190_open()
1104 tp->rx_dma); in sis190_open()
1106 dma_free_coherent(&pdev->dev, TX_RING_BYTES, tp->TxDescRing, in sis190_open()
1107 tp->tx_dma); in sis190_open()
1111 static void sis190_tx_clear(struct sis190_private *tp) in sis190_tx_clear() argument
1116 struct sk_buff *skb = tp->Tx_skbuff[i]; in sis190_tx_clear()
1121 sis190_unmap_tx_skb(tp->pci_dev, skb, tp->TxDescRing + i); in sis190_tx_clear()
1122 tp->Tx_skbuff[i] = NULL; in sis190_tx_clear()
1125 tp->dev->stats.tx_dropped++; in sis190_tx_clear()
1127 tp->cur_tx = tp->dirty_tx = 0; in sis190_tx_clear()
1132 struct sis190_private *tp = netdev_priv(dev); in sis190_down() local
1133 void __iomem *ioaddr = tp->mmio_addr; in sis190_down()
1141 spin_lock_irq(&tp->lock); in sis190_down()
1145 spin_unlock_irq(&tp->lock); in sis190_down()
1147 synchronize_irq(tp->pci_dev->irq); in sis190_down()
1156 sis190_tx_clear(tp); in sis190_down()
1157 sis190_rx_clear(tp); in sis190_down()
1162 struct sis190_private *tp = netdev_priv(dev); in sis190_close() local
1163 struct pci_dev *pdev = tp->pci_dev; in sis190_close()
1167 free_irq(pdev->irq, dev); in sis190_close()
1169 dma_free_coherent(&pdev->dev, TX_RING_BYTES, tp->TxDescRing, in sis190_close()
1170 tp->tx_dma); in sis190_close()
1171 dma_free_coherent(&pdev->dev, RX_RING_BYTES, tp->RxDescRing, in sis190_close()
1172 tp->rx_dma); in sis190_close()
1174 tp->TxDescRing = NULL; in sis190_close()
1175 tp->RxDescRing = NULL; in sis190_close()
1183 struct sis190_private *tp = netdev_priv(dev); in sis190_start_xmit() local
1184 void __iomem *ioaddr = tp->mmio_addr; in sis190_start_xmit()
1189 if (unlikely(skb->len < ETH_ZLEN)) { in sis190_start_xmit()
1191 dev->stats.tx_dropped++; in sis190_start_xmit()
1196 len = skb->len; in sis190_start_xmit()
1199 entry = tp->cur_tx % NUM_TX_DESC; in sis190_start_xmit()
1200 desc = tp->TxDescRing + entry; in sis190_start_xmit()
1202 if (unlikely(le32_to_cpu(desc->status) & OWNbit)) { in sis190_start_xmit()
1204 netif_err(tp, tx_err, dev, in sis190_start_xmit()
1209 mapping = dma_map_single(&tp->pci_dev->dev, skb->data, len, in sis190_start_xmit()
1211 if (dma_mapping_error(&tp->pci_dev->dev, mapping)) { in sis190_start_xmit()
1212 netif_err(tp, tx_err, dev, in sis190_start_xmit()
1217 tp->Tx_skbuff[entry] = skb; in sis190_start_xmit()
1219 desc->PSize = cpu_to_le32(len); in sis190_start_xmit()
1220 desc->addr = cpu_to_le32(mapping); in sis190_start_xmit()
1222 desc->size = cpu_to_le32(len); in sis190_start_xmit()
1223 if (entry == (NUM_TX_DESC - 1)) in sis190_start_xmit()
1224 desc->size |= cpu_to_le32(RingEnd); in sis190_start_xmit()
1228 desc->status = cpu_to_le32(OWNbit | INTbit | DEFbit | CRCbit | PADbit); in sis190_start_xmit()
1229 if (tp->negotiated_lpa & (LPA_1000HALF | LPA_100HALF | LPA_10HALF)) { in sis190_start_xmit()
1231 desc->status |= cpu_to_le32(COLEN | CRSEN | BKFEN); in sis190_start_xmit()
1232 if (tp->negotiated_lpa & (LPA_1000HALF | LPA_1000FULL)) in sis190_start_xmit()
1233 desc->status |= cpu_to_le32(EXTEN | BSTEN); /* gigabit HD */ in sis190_start_xmit()
1236 tp->cur_tx++; in sis190_start_xmit()
1242 dirty_tx = tp->dirty_tx; in sis190_start_xmit()
1243 if ((tp->cur_tx - NUM_TX_DESC) == dirty_tx) { in sis190_start_xmit()
1246 if (dirty_tx != tp->dirty_tx) in sis190_start_xmit()
1263 * sis190_default_phy - Select default PHY for sis190 mac.
1266 * Select first detected PHY with link as default.
1267 * If no one is link on, select PHY whose types is HOME as default.
1273 struct sis190_private *tp = netdev_priv(dev); in sis190_default_phy() local
1274 struct mii_if_info *mii_if = &tp->mii_if; in sis190_default_phy()
1275 void __iomem *ioaddr = tp->mmio_addr; in sis190_default_phy()
1280 list_for_each_entry(phy, &tp->first_phy, list) { in sis190_default_phy()
1281 status = mdio_read_latched(ioaddr, phy->phy_id, MII_BMSR); in sis190_default_phy()
1283 // Link ON & Not select default PHY & not ghost PHY. in sis190_default_phy()
1286 (phy->type != UNKNOWN)) { in sis190_default_phy()
1289 status = mdio_read(ioaddr, phy->phy_id, MII_BMCR); in sis190_default_phy()
1290 mdio_write(ioaddr, phy->phy_id, MII_BMCR, in sis190_default_phy()
1292 if (phy->type == HOME) in sis190_default_phy()
1294 else if (phy->type == LAN) in sis190_default_phy()
1305 phy_default = list_first_entry(&tp->first_phy, in sis190_default_phy()
1309 if (mii_if->phy_id != phy_default->phy_id) { in sis190_default_phy()
1310 mii_if->phy_id = phy_default->phy_id; in sis190_default_phy()
1311 if (netif_msg_probe(tp)) in sis190_default_phy()
1313 pci_name(tp->pci_dev), mii_if->phy_id); in sis190_default_phy()
1316 status = mdio_read(ioaddr, mii_if->phy_id, MII_BMCR); in sis190_default_phy()
1319 mdio_write(ioaddr, mii_if->phy_id, MII_BMCR, status); in sis190_default_phy()
1320 status = mdio_read_latched(ioaddr, mii_if->phy_id, MII_BMSR); in sis190_default_phy()
1325 static void sis190_init_phy(struct net_device *dev, struct sis190_private *tp, in sis190_init_phy() argument
1329 void __iomem *ioaddr = tp->mmio_addr; in sis190_init_phy()
1332 INIT_LIST_HEAD(&phy->list); in sis190_init_phy()
1333 phy->status = mii_status; in sis190_init_phy()
1334 phy->phy_id = phy_id; in sis190_init_phy()
1336 phy->id[0] = mdio_read(ioaddr, phy_id, MII_PHYSID1); in sis190_init_phy()
1337 phy->id[1] = mdio_read(ioaddr, phy_id, MII_PHYSID2); in sis190_init_phy()
1339 for (p = mii_chip_table; p->type; p++) { in sis190_init_phy()
1340 if ((p->id[0] == phy->id[0]) && in sis190_init_phy()
1341 (p->id[1] == (phy->id[1] & 0xfff0))) { in sis190_init_phy()
1346 if (p->id[1]) { in sis190_init_phy()
1347 phy->type = (p->type == MIX) ? in sis190_init_phy()
1349 LAN : HOME) : p->type; in sis190_init_phy()
1350 tp->features |= p->feature; in sis190_init_phy()
1351 if (netif_msg_probe(tp)) in sis190_init_phy()
1353 pci_name(tp->pci_dev), p->name, phy_id); in sis190_init_phy()
1355 phy->type = UNKNOWN; in sis190_init_phy()
1356 if (netif_msg_probe(tp)) in sis190_init_phy()
1358 pci_name(tp->pci_dev), in sis190_init_phy()
1359 phy->id[0], (phy->id[1] & 0xfff0), phy_id); in sis190_init_phy()
1363 static void sis190_mii_probe_88e1111_fixup(struct sis190_private *tp) in sis190_mii_probe_88e1111_fixup() argument
1365 if (tp->features & F_PHY_88E1111) { in sis190_mii_probe_88e1111_fixup()
1366 void __iomem *ioaddr = tp->mmio_addr; in sis190_mii_probe_88e1111_fixup()
1367 int phy_id = tp->mii_if.phy_id; in sis190_mii_probe_88e1111_fixup()
1373 p = (tp->features & F_HAS_RGMII) ? reg[0] : reg[1]; in sis190_mii_probe_88e1111_fixup()
1383 * sis190_mii_probe - Probe MII PHY for sis190
1392 struct sis190_private *tp = netdev_priv(dev); in sis190_mii_probe() local
1393 struct mii_if_info *mii_if = &tp->mii_if; in sis190_mii_probe()
1394 void __iomem *ioaddr = tp->mmio_addr; in sis190_mii_probe()
1398 INIT_LIST_HEAD(&tp->first_phy); in sis190_mii_probe()
1412 sis190_free_phy(&tp->first_phy); in sis190_mii_probe()
1413 rc = -ENOMEM; in sis190_mii_probe()
1417 sis190_init_phy(dev, tp, phy, phy_id, status); in sis190_mii_probe()
1419 list_add(&tp->first_phy, &phy->list); in sis190_mii_probe()
1422 if (list_empty(&tp->first_phy)) { in sis190_mii_probe()
1423 if (netif_msg_probe(tp)) in sis190_mii_probe()
1425 pci_name(tp->pci_dev)); in sis190_mii_probe()
1426 rc = -EIO; in sis190_mii_probe()
1433 sis190_mii_probe_88e1111_fixup(tp); in sis190_mii_probe()
1435 mii_if->dev = dev; in sis190_mii_probe()
1436 mii_if->mdio_read = __mdio_read; in sis190_mii_probe()
1437 mii_if->mdio_write = __mdio_write; in sis190_mii_probe()
1438 mii_if->phy_id_mask = PHY_ID_ANY; in sis190_mii_probe()
1439 mii_if->reg_num_mask = MII_REG_ANY; in sis190_mii_probe()
1446 struct sis190_private *tp = netdev_priv(dev); in sis190_mii_remove() local
1448 sis190_free_phy(&tp->first_phy); in sis190_mii_remove()
1454 struct sis190_private *tp = netdev_priv(dev); in sis190_release_board() local
1456 iounmap(tp->mmio_addr); in sis190_release_board()
1464 struct sis190_private *tp; in sis190_init_board() local
1469 dev = alloc_etherdev(sizeof(*tp)); in sis190_init_board()
1471 rc = -ENOMEM; in sis190_init_board()
1475 SET_NETDEV_DEV(dev, &pdev->dev); in sis190_init_board()
1477 tp = netdev_priv(dev); in sis190_init_board()
1478 tp->dev = dev; in sis190_init_board()
1479 tp->msg_enable = netif_msg_init(debug.msg_enable, SIS190_MSG_DEFAULT); in sis190_init_board()
1483 if (netif_msg_probe(tp)) in sis190_init_board()
1488 rc = -ENODEV; in sis190_init_board()
1491 if (netif_msg_probe(tp)) in sis190_init_board()
1497 if (netif_msg_probe(tp)) in sis190_init_board()
1505 if (netif_msg_probe(tp)) in sis190_init_board()
1511 rc = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)); in sis190_init_board()
1513 if (netif_msg_probe(tp)) in sis190_init_board()
1523 if (netif_msg_probe(tp)) in sis190_init_board()
1526 rc = -EIO; in sis190_init_board()
1530 tp->pci_dev = pdev; in sis190_init_board()
1531 tp->mmio_addr = ioaddr; in sis190_init_board()
1532 tp->link_status = LNK_OFF; in sis190_init_board()
1553 struct sis190_private *tp = netdev_priv(dev); in sis190_tx_timeout() local
1554 void __iomem *ioaddr = tp->mmio_addr; in sis190_tx_timeout()
1562 netif_info(tp, tx_err, dev, "Transmit timeout, status %08x %08x\n", in sis190_tx_timeout()
1569 spin_lock_irq(&tp->lock); in sis190_tx_timeout()
1570 sis190_tx_clear(tp); in sis190_tx_timeout()
1571 spin_unlock_irq(&tp->lock); in sis190_tx_timeout()
1579 static void sis190_set_rgmii(struct sis190_private *tp, u8 reg) in sis190_set_rgmii() argument
1581 tp->features |= (reg & 0x80) ? F_HAS_RGMII : 0; in sis190_set_rgmii()
1587 struct sis190_private *tp = netdev_priv(dev); in sis190_get_mac_addr_from_eeprom() local
1588 void __iomem *ioaddr = tp->mmio_addr; in sis190_get_mac_addr_from_eeprom()
1593 if (netif_msg_probe(tp)) in sis190_get_mac_addr_from_eeprom()
1600 if (netif_msg_probe(tp)) in sis190_get_mac_addr_from_eeprom()
1603 return -EIO; in sis190_get_mac_addr_from_eeprom()
1614 sis190_set_rgmii(tp, sis190_read_eeprom(ioaddr, EEPROMInfo)); in sis190_get_mac_addr_from_eeprom()
1620 * sis190_get_mac_addr_from_apc - Get MAC address for SiS96x model
1626 * MAC address is read into @net_dev->dev_addr.
1632 struct sis190_private *tp = netdev_priv(dev); in sis190_get_mac_addr_from_apc() local
1638 if (netif_msg_probe(tp)) in sis190_get_mac_addr_from_apc()
1648 if (netif_msg_probe(tp)) in sis190_get_mac_addr_from_apc()
1651 return -EIO; in sis190_get_mac_addr_from_apc()
1670 sis190_set_rgmii(tp, reg); in sis190_get_mac_addr_from_apc()
1680 * sis190_init_rxfilter - Initialize the Rx filter
1688 struct sis190_private *tp = netdev_priv(dev); in sis190_init_rxfilter() local
1689 void __iomem *ioaddr = tp->mmio_addr; in sis190_init_rxfilter()
1697 * only and followed by RxMacAddr (6 bytes). Strange. -- FR in sis190_init_rxfilter()
1702 SIS_W8(RxMacAddr + i, dev->dev_addr[i]); in sis190_init_rxfilter()
1726 struct sis190_private *tp = netdev_priv(dev); in sis190_set_speed_auto() local
1727 void __iomem *ioaddr = tp->mmio_addr; in sis190_set_speed_auto()
1728 int phy_id = tp->mii_if.phy_id; in sis190_set_speed_auto()
1731 netif_info(tp, link, dev, "Enabling Auto-negotiation\n"); in sis190_set_speed_auto()
1744 // Enable auto-negotiation and restart auto-negotiation. in sis190_set_speed_auto()
1752 struct sis190_private *tp = netdev_priv(dev); in sis190_get_link_ksettings() local
1754 mii_ethtool_get_link_ksettings(&tp->mii_if, cmd); in sis190_get_link_ksettings()
1762 struct sis190_private *tp = netdev_priv(dev); in sis190_set_link_ksettings() local
1764 return mii_ethtool_set_link_ksettings(&tp->mii_if, cmd); in sis190_set_link_ksettings()
1770 struct sis190_private *tp = netdev_priv(dev); in sis190_get_drvinfo() local
1772 strscpy(info->driver, DRV_NAME, sizeof(info->driver)); in sis190_get_drvinfo()
1773 strscpy(info->version, DRV_VERSION, sizeof(info->version)); in sis190_get_drvinfo()
1774 strscpy(info->bus_info, pci_name(tp->pci_dev), in sis190_get_drvinfo()
1775 sizeof(info->bus_info)); in sis190_get_drvinfo()
1786 struct sis190_private *tp = netdev_priv(dev); in sis190_get_regs() local
1789 spin_lock_irqsave(&tp->lock, flags); in sis190_get_regs()
1790 memcpy_fromio(p, tp->mmio_addr, regs->len); in sis190_get_regs()
1791 spin_unlock_irqrestore(&tp->lock, flags); in sis190_get_regs()
1796 struct sis190_private *tp = netdev_priv(dev); in sis190_nway_reset() local
1798 return mii_nway_restart(&tp->mii_if); in sis190_nway_reset()
1803 struct sis190_private *tp = netdev_priv(dev); in sis190_get_msglevel() local
1805 return tp->msg_enable; in sis190_get_msglevel()
1810 struct sis190_private *tp = netdev_priv(dev); in sis190_set_msglevel() local
1812 tp->msg_enable = value; in sis190_set_msglevel()
1829 struct sis190_private *tp = netdev_priv(dev); in sis190_ioctl() local
1831 return !netif_running(dev) ? -EINVAL : in sis190_ioctl()
1832 generic_mii_ioctl(&tp->mii_if, if_mii(ifr), cmd, NULL); in sis190_ioctl()
1863 struct sis190_private *tp; in sis190_init_one() local
1882 tp = netdev_priv(dev); in sis190_init_one()
1883 ioaddr = tp->mmio_addr; in sis190_init_one()
1891 INIT_WORK(&tp->phy_task, sis190_phy_task); in sis190_init_one()
1893 dev->netdev_ops = &sis190_netdev_ops; in sis190_init_one()
1895 dev->ethtool_ops = &sis190_ethtool_ops; in sis190_init_one()
1896 dev->watchdog_timeo = SIS190_TX_TIMEOUT; in sis190_init_one()
1898 spin_lock_init(&tp->lock); in sis190_init_one()
1908 if (netif_msg_probe(tp)) { in sis190_init_one()
1911 sis_chip_info[ent->driver_data].name, in sis190_init_one()
1912 ioaddr, pdev->irq, dev->dev_addr); in sis190_init_one()
1914 (tp->features & F_HAS_RGMII) ? "RGMII" : "GMII"); in sis190_init_one()
1933 struct sis190_private *tp = netdev_priv(dev); in sis190_remove_one() local
1936 cancel_work_sync(&tp->phy_task); in sis190_remove_one()