Lines Matching +full:mii +full:- +full:rt
17 SiS 7014 Single Chip 100BASE-TX/10BASE-T Physical Layer Solution,
25 Rev 1.08.05 Jun. 6 2002 Mufasa Yang bug fix for read_eeprom & Tx descriptor over-boundary
28 Rev 1.08.02 Nov. 30 2001 Hui-Fen Hsu workaround for EDB & bug fix for dhcp problem
29 Rev 1.08.01 Aug. 25 2001 Hui-Fen Hsu update for 630ET & workaround for ICS1893 PHY
30 Rev 1.08.00 Jun. 11 2001 Hui-Fen Hsu workaround for RTL8201 PHY and some bug fix
31 …Rev 1.07.11 Apr. 2 2001 Hui-Fen Hsu updates PCI drivers to use the new pci_set_dma_mask for kerne…
32 Rev 1.07.10 Mar. 1 2001 Hui-Fen Hsu <hfhsu@sis.com.tw> some bug fix & 635M/B support
34 Rev 1.07.08 Jan. 8 2001 Lei-Chun Chang added RTL8201 PHY support
35 …Rev 1.07.07 Nov. 29 2000 Lei-Chun Chang added kernel-doc extractable documentation and 630 workaro…
38 Rev 1.07.04 Sep. 6 2000 Lei-Chun Chang added ICS1893 PHY support
39 …Rev 1.07.03 Aug. 24 2000 Lei-Chun Chang (lcchang@sis.com.tw) modified 630E equalizer workaround ru…
48 Chin-Shan Li (lcs@sis.com.tw) Added AMD Am79c901 HomePNA PHY support
65 #include <linux/mii.h>
72 #include <linux/dma-mapping.h>
90 static int sis900_debug = -1; /* Use SIS900_DEF_MSG as value */
131 { "SiS 900 Internal MII PHY", 0x001d, 0x8000, LAN },
136 { "AMD 79C901 10BASE-T PHY", 0x0000, 0x6B70, LAN },
167 struct mii_phy * mii; member
168 struct mii_phy * first_mii; /* record the first mii structure */
175 u8 autong_complete; /* 1: auto-negotiate complete */
182 /* The saved address of a sent/receive-in-place packet buffer */
248 * sis900_get_mac_addr - Get MAC address for stand alone SiS900 model
253 * MAC address is read from read_eeprom() into @net_dev->dev_addr.
260 void __iomem *ioaddr = sis_priv->ioaddr; in sis900_get_mac_addr()
274 ((u16 *)(net_dev->dev_addr))[i] = read_eeprom(ioaddr, i+EEPROMMACAddr); in sis900_get_mac_addr()
280 * sis630e_get_mac_addr - Get MAC address for SiS630E model
286 * MAC address is read into @net_dev->dev_addr.
309 ((u8 *)(net_dev->dev_addr))[i] = inb(0x71); in sis630e_get_mac_addr()
320 * sis635_get_mac_addr - Get MAC address for SIS635 model
326 * @net_dev->dev_addr.
333 void __iomem *ioaddr = sis_priv->ioaddr; in sis635_get_mac_addr()
348 *( ((u16 *)net_dev->dev_addr) + i) = sr16(rfdr); in sis635_get_mac_addr()
358 * sis96x_get_mac_addr - Get MAC address for SiS962 or SiS963 model
370 * MAC address is read into @net_dev->dev_addr.
377 void __iomem *ioaddr = sis_priv->ioaddr; in sis96x_get_mac_addr()
383 u16 *mac = (u16 *)net_dev->dev_addr; in sis96x_get_mac_addr()
415 * sis900_probe - Probe for sis900 device
421 * and assign SiS900-specific entries in the device structure.
435 const char *card_name = card_names[pci_id->driver_data]; in sis900_probe()
449 i = dma_set_mask(&pci_dev->dev, DMA_BIT_MASK(32)); in sis900_probe()
460 return -ENOMEM; in sis900_probe()
461 SET_NETDEV_DEV(net_dev, &pci_dev->dev); in sis900_probe()
471 ret = -ENOMEM; in sis900_probe()
476 sis_priv->ioaddr = ioaddr; in sis900_probe()
477 sis_priv->pci_dev = pci_dev; in sis900_probe()
478 spin_lock_init(&sis_priv->lock); in sis900_probe()
480 sis_priv->eeprom_size = 24; in sis900_probe()
484 ring_space = dma_alloc_coherent(&pci_dev->dev, TX_TOTAL_SIZE, in sis900_probe()
487 ret = -ENOMEM; in sis900_probe()
490 sis_priv->tx_ring = ring_space; in sis900_probe()
491 sis_priv->tx_ring_dma = ring_dma; in sis900_probe()
493 ring_space = dma_alloc_coherent(&pci_dev->dev, RX_TOTAL_SIZE, in sis900_probe()
496 ret = -ENOMEM; in sis900_probe()
499 sis_priv->rx_ring = ring_space; in sis900_probe()
500 sis_priv->rx_ring_dma = ring_dma; in sis900_probe()
502 /* The SiS900-specific entries in the device structure. */ in sis900_probe()
503 net_dev->netdev_ops = &sis900_netdev_ops; in sis900_probe()
504 net_dev->watchdog_timeo = TX_TIMEOUT; in sis900_probe()
505 net_dev->ethtool_ops = &sis900_ethtool_ops; in sis900_probe()
508 sis_priv->msg_enable = sis900_debug; in sis900_probe()
510 sis_priv->msg_enable = SIS900_DEF_MSG; in sis900_probe()
512 sis_priv->mii_info.dev = net_dev; in sis900_probe()
513 sis_priv->mii_info.mdio_read = mdio_read; in sis900_probe()
514 sis_priv->mii_info.mdio_write = mdio_write; in sis900_probe()
515 sis_priv->mii_info.phy_id_mask = 0x1f; in sis900_probe()
516 sis_priv->mii_info.reg_num_mask = 0x1f; in sis900_probe()
519 sis_priv->chipset_rev = pci_dev->revision; in sis900_probe()
523 dev_name, sis_priv->chipset_rev); in sis900_probe()
526 if (sis_priv->chipset_rev == SIS630E_900_REV) in sis900_probe()
528 else if ((sis_priv->chipset_rev > 0x81) && (sis_priv->chipset_rev <= 0x90) ) in sis900_probe()
530 else if (sis_priv->chipset_rev == SIS96x_900_REV) in sis900_probe()
535 if (!ret || !is_valid_ether_addr(net_dev->dev_addr)) { in sis900_probe()
541 /* 630ET : set the mii access mode as software-mode */ in sis900_probe()
542 if (sis_priv->chipset_rev == SIS630ET_900_REV) in sis900_probe()
545 /* probe for mii transceiver */ in sis900_probe()
547 printk(KERN_WARNING "%s: Error probing MII device.\n", in sis900_probe()
549 ret = -ENODEV; in sis900_probe()
556 sis_priv->host_bridge_rev = dev->revision; in sis900_probe()
566 net_dev->name, card_name, ioaddr, pci_dev->irq, in sis900_probe()
567 net_dev->dev_addr); in sis900_probe()
572 printk(KERN_INFO "%s: Wake on LAN only available from suspend to RAM.", net_dev->name); in sis900_probe()
577 dma_free_coherent(&pci_dev->dev, RX_TOTAL_SIZE, sis_priv->rx_ring, in sis900_probe()
578 sis_priv->rx_ring_dma); in sis900_probe()
580 dma_free_coherent(&pci_dev->dev, TX_TOTAL_SIZE, sis_priv->tx_ring, in sis900_probe()
581 sis_priv->tx_ring_dma); in sis900_probe()
592 * sis900_mii_probe - Probe MII PHY for sis900
595 * Search for total of 32 possible mii phy addresses.
603 const char *dev_name = pci_name(sis_priv->pci_dev); in sis900_mii_probe()
608 sis_priv->mii = NULL; in sis900_mii_probe()
610 /* search for total of 32 possible mii phy addresses */ in sis900_mii_probe()
622 printk(KERN_DEBUG "%s: MII at address %d" in sis900_mii_probe()
629 mii_phy = sis_priv->first_mii; in sis900_mii_probe()
633 mii_phy = mii_phy->next; in sis900_mii_probe()
639 mii_phy->phy_id0 = mdio_read(net_dev, phy_addr, MII_PHY_ID0); in sis900_mii_probe()
640 mii_phy->phy_id1 = mdio_read(net_dev, phy_addr, MII_PHY_ID1); in sis900_mii_probe()
641 mii_phy->phy_addr = phy_addr; in sis900_mii_probe()
642 mii_phy->status = mii_status; in sis900_mii_probe()
643 mii_phy->next = sis_priv->mii; in sis900_mii_probe()
644 sis_priv->mii = mii_phy; in sis900_mii_probe()
645 sis_priv->first_mii = mii_phy; in sis900_mii_probe()
648 if ((mii_phy->phy_id0 == mii_chip_table[i].phy_id0 ) && in sis900_mii_probe()
649 ((mii_phy->phy_id1 & 0xFFF0) == mii_chip_table[i].phy_id1)){ in sis900_mii_probe()
650 mii_phy->phy_types = mii_chip_table[i].phy_types; in sis900_mii_probe()
652 mii_phy->phy_types = in sis900_mii_probe()
665 mii_phy->phy_types = UNKNOWN; in sis900_mii_probe()
669 if (sis_priv->mii == NULL) { in sis900_mii_probe()
670 printk(KERN_INFO "%s: No MII transceivers found!\n", dev_name); in sis900_mii_probe()
675 sis_priv->mii = NULL; in sis900_mii_probe()
679 if ((sis_priv->mii->phy_id0 == 0x001D) && in sis900_mii_probe()
680 ((sis_priv->mii->phy_id1&0xFFF0) == 0x8000)) in sis900_mii_probe()
681 status = sis900_reset_phy(net_dev, sis_priv->cur_phy); in sis900_mii_probe()
684 if ((sis_priv->mii->phy_id0 == 0x0015) && in sis900_mii_probe()
685 ((sis_priv->mii->phy_id1&0xFFF0) == 0xF440)) in sis900_mii_probe()
686 mdio_write(net_dev, sis_priv->cur_phy, 0x0018, 0xD200); in sis900_mii_probe()
692 poll_bit ^= (mdio_read(net_dev, sis_priv->cur_phy, MII_STATUS) & poll_bit); in sis900_mii_probe()
696 return -ETIME; in sis900_mii_probe()
701 if (sis_priv->chipset_rev == SIS630E_900_REV) { in sis900_mii_probe()
703 mdio_write(net_dev, sis_priv->cur_phy, MII_ANADV, 0x05e1); in sis900_mii_probe()
704 mdio_write(net_dev, sis_priv->cur_phy, MII_CONFIG1, 0x22); in sis900_mii_probe()
705 mdio_write(net_dev, sis_priv->cur_phy, MII_CONFIG2, 0xff00); in sis900_mii_probe()
706 mdio_write(net_dev, sis_priv->cur_phy, MII_MASK, 0xffc0); in sis900_mii_probe()
707 //mdio_write(net_dev, sis_priv->cur_phy, MII_CONTROL, 0x1000); in sis900_mii_probe()
710 if (sis_priv->mii->status & MII_STAT_LINK) in sis900_mii_probe()
719 * sis900_default_phy - Select default PHY for sis900 mac.
734 for (phy=sis_priv->first_mii; phy; phy=phy->next) { in sis900_default_phy()
735 status = mdio_read(net_dev, phy->phy_addr, MII_STATUS); in sis900_default_phy()
736 status = mdio_read(net_dev, phy->phy_addr, MII_STATUS); in sis900_default_phy()
740 (phy->phy_types != UNKNOWN)) { in sis900_default_phy()
743 status = mdio_read(net_dev, phy->phy_addr, MII_CONTROL); in sis900_default_phy()
744 mdio_write(net_dev, phy->phy_addr, MII_CONTROL, in sis900_default_phy()
746 if (phy->phy_types == HOME) in sis900_default_phy()
748 else if(phy->phy_types == LAN) in sis900_default_phy()
758 default_phy = sis_priv->first_mii; in sis900_default_phy()
760 if (sis_priv->mii != default_phy) { in sis900_default_phy()
761 sis_priv->mii = default_phy; in sis900_default_phy()
762 sis_priv->cur_phy = default_phy->phy_addr; in sis900_default_phy()
764 pci_name(sis_priv->pci_dev), sis_priv->cur_phy); in sis900_default_phy()
767 sis_priv->mii_info.phy_id = sis_priv->cur_phy; in sis900_default_phy()
769 status = mdio_read(net_dev, sis_priv->cur_phy, MII_CONTROL); in sis900_default_phy()
772 mdio_write(net_dev, sis_priv->cur_phy, MII_CONTROL, status); in sis900_default_phy()
773 status = mdio_read(net_dev, sis_priv->cur_phy, MII_STATUS); in sis900_default_phy()
774 status = mdio_read(net_dev, sis_priv->cur_phy, MII_STATUS); in sis900_default_phy()
781 * sis900_set_capability - set the media capability of network adapter.
786 * mii status register. It's necessary before auto-negotiate.
793 mdio_read(net_dev, phy->phy_addr, MII_STATUS); in sis900_set_capability()
794 mdio_read(net_dev, phy->phy_addr, MII_STATUS); in sis900_set_capability()
797 ((phy->status & MII_STAT_CAN_TX_FDX)? MII_NWAY_TX_FDX:0) | in sis900_set_capability()
798 ((phy->status & MII_STAT_CAN_TX) ? MII_NWAY_TX:0) | in sis900_set_capability()
799 ((phy->status & MII_STAT_CAN_T_FDX) ? MII_NWAY_T_FDX:0)| in sis900_set_capability()
800 ((phy->status & MII_STAT_CAN_T) ? MII_NWAY_T:0); in sis900_set_capability()
802 mdio_write(net_dev, phy->phy_addr, MII_ANADV, cap); in sis900_set_capability()
810 * read_eeprom - Read Serial EEPROM
830 for (i = 8; i >= 0; i--) { in read_eeprom()
841 /* read the 16-bits data in */ in read_eeprom()
842 for (i = 16; i > 0; i--) { in read_eeprom()
858 /* Read and write the MII management registers using software-generated
865 void __iomem *ioaddr = sp->ioaddr; in mdio_idle()
872 /* Synchronize the MII management interface by shifting 32 one bits out. */
875 void __iomem *ioaddr = sp->ioaddr; in mdio_reset()
878 for (i = 31; i >= 0; i--) { in mdio_reset()
887 * mdio_read - read MII PHY register
892 * Read MII registers through MDIO and MDC
901 void __iomem *ioaddr = sp->ioaddr; in mdio_read()
908 for (i = 15; i >= 0; i--) { in mdio_read()
918 for (i = 16; i > 0; i--) { in mdio_read()
931 * mdio_write - write MII PHY register
937 * Write MII registers with @value through MDIO and MDC
947 void __iomem *ioaddr = sp->ioaddr; in mdio_write()
954 for (i = 15; i >= 0; i--) { in mdio_write()
965 for (i = 15; i >= 0; i--) { in mdio_write()
976 for (i = 2; i > 0; i--) { in mdio_write()
987 * sis900_reset_phy - reset sis900 mii phy.
1011 * Polling 'interrupt' - used by things like netconsole to send skbs
1012 * without having to re-enable interrupts. It's not called while
1018 const int irq = sp->pci_dev->irq; in sis900_poll()
1027 * sis900_open - open sis900 device
1038 void __iomem *ioaddr = sis_priv->ioaddr; in sis900_open()
1045 sis630_set_eq(net_dev, sis_priv->chipset_rev); in sis900_open()
1047 ret = request_irq(sis_priv->pci_dev->irq, sis900_interrupt, IRQF_SHARED, in sis900_open()
1048 net_dev->name, net_dev); in sis900_open()
1069 sis900_check_mode(net_dev, sis_priv->mii); in sis900_open()
1073 timer_setup(&sis_priv->timer, sis900_timer, 0); in sis900_open()
1074 sis_priv->timer.expires = jiffies + HZ; in sis900_open()
1075 add_timer(&sis_priv->timer); in sis900_open()
1081 * sis900_init_rxfilter - Initialize the Rx filter
1092 void __iomem *ioaddr = sis_priv->ioaddr; in sis900_init_rxfilter()
1103 u32 w = (u32) *((u16 *)(net_dev->dev_addr)+i); in sis900_init_rxfilter()
1110 net_dev->name, i, sr32(rfdr)); in sis900_init_rxfilter()
1119 * sis900_init_tx_ring - Initialize the Tx descriptor ring
1129 void __iomem *ioaddr = sis_priv->ioaddr; in sis900_init_tx_ring()
1132 sis_priv->tx_full = 0; in sis900_init_tx_ring()
1133 sis_priv->dirty_tx = sis_priv->cur_tx = 0; in sis900_init_tx_ring()
1136 sis_priv->tx_skbuff[i] = NULL; in sis900_init_tx_ring()
1138 sis_priv->tx_ring[i].link = sis_priv->tx_ring_dma + in sis900_init_tx_ring()
1140 sis_priv->tx_ring[i].cmdsts = 0; in sis900_init_tx_ring()
1141 sis_priv->tx_ring[i].bufptr = 0; in sis900_init_tx_ring()
1145 sw32(txdp, sis_priv->tx_ring_dma); in sis900_init_tx_ring()
1148 net_dev->name, sr32(txdp)); in sis900_init_tx_ring()
1152 * sis900_init_rx_ring - Initialize the Rx descriptor ring
1156 * and pre-allocate receive buffers (socket buffer)
1163 void __iomem *ioaddr = sis_priv->ioaddr; in sis900_init_rx_ring()
1166 sis_priv->cur_rx = 0; in sis900_init_rx_ring()
1167 sis_priv->dirty_rx = 0; in sis900_init_rx_ring()
1171 sis_priv->rx_skbuff[i] = NULL; in sis900_init_rx_ring()
1173 sis_priv->rx_ring[i].link = sis_priv->rx_ring_dma + in sis900_init_rx_ring()
1175 sis_priv->rx_ring[i].cmdsts = 0; in sis900_init_rx_ring()
1176 sis_priv->rx_ring[i].bufptr = 0; in sis900_init_rx_ring()
1190 sis_priv->rx_skbuff[i] = skb; in sis900_init_rx_ring()
1191 sis_priv->rx_ring[i].cmdsts = RX_BUF_SIZE; in sis900_init_rx_ring()
1192 sis_priv->rx_ring[i].bufptr = dma_map_single(&sis_priv->pci_dev->dev, in sis900_init_rx_ring()
1193 skb->data, in sis900_init_rx_ring()
1196 if (unlikely(dma_mapping_error(&sis_priv->pci_dev->dev, in sis900_init_rx_ring()
1197 sis_priv->rx_ring[i].bufptr))) { in sis900_init_rx_ring()
1199 sis_priv->rx_skbuff[i] = NULL; in sis900_init_rx_ring()
1203 sis_priv->dirty_rx = (unsigned int) (i - NUM_RX_DESC); in sis900_init_rx_ring()
1206 sw32(rxdp, sis_priv->rx_ring_dma); in sis900_init_rx_ring()
1209 net_dev->name, sr32(rxdp)); in sis900_init_rx_ring()
1213 * sis630_set_eq - set phy equalizer value for 630 LAN
1219 * Bit 14: 0 -- Automatically detect (default)
1220 * 1 -- Manually set Equalizer filter
1221 * Bit 13: 0 -- (Default)
1222 * 1 -- Speed up convergence of equalizer setting
1223 * Bit 9 : 0 -- (Default)
1224 * 1 -- Disable Baseline Wander
1225 * Bit 3~7 -- Equalizer filter setting
1231 * When Link is ON and Bit 14 is 0, SIS900PHY will auto-detect proper equalizer value.
1234 * 0 <= max <= 4 --> set equalizer to max
1235 * 5 <= max <= 14 --> set equalizer to max+1 or set equalizer to max+2 if max == min
1236 * max >= 15 --> set equalizer to max+5 or set equalizer to max+6 if max == min
1250 reg14h = mdio_read(net_dev, sis_priv->cur_phy, MII_RESV); in sis630_set_eq()
1251 mdio_write(net_dev, sis_priv->cur_phy, MII_RESV, in sis630_set_eq()
1255 sis_priv->cur_phy, MII_RESV)) >> 3; in sis630_set_eq()
1277 (sis_priv->host_bridge_rev == SIS630B0 || in sis630_set_eq()
1278 sis_priv->host_bridge_rev == SIS630B1)) { in sis630_set_eq()
1285 reg14h = mdio_read(net_dev, sis_priv->cur_phy, MII_RESV); in sis630_set_eq()
1288 mdio_write(net_dev, sis_priv->cur_phy, MII_RESV, reg14h); in sis630_set_eq()
1290 reg14h = mdio_read(net_dev, sis_priv->cur_phy, MII_RESV); in sis630_set_eq()
1292 (sis_priv->host_bridge_rev == SIS630B0 || in sis630_set_eq()
1293 sis_priv->host_bridge_rev == SIS630B1)) in sis630_set_eq()
1294 mdio_write(net_dev, sis_priv->cur_phy, MII_RESV, in sis630_set_eq()
1297 mdio_write(net_dev, sis_priv->cur_phy, MII_RESV, in sis630_set_eq()
1303 * sis900_timer - sis900 timer routine
1313 struct net_device *net_dev = sis_priv->mii_info.dev; in sis900_timer()
1314 struct mii_phy *mii_phy = sis_priv->mii; in sis900_timer()
1319 status = mdio_read(net_dev, sis_priv->cur_phy, MII_STATUS); in sis900_timer()
1320 status = mdio_read(net_dev, sis_priv->cur_phy, MII_STATUS); in sis900_timer()
1322 /* Link OFF -> ON */ in sis900_timer()
1327 mii_phy = sis_priv->mii; in sis900_timer()
1335 sis630_set_eq(net_dev, sis_priv->chipset_rev); in sis900_timer()
1340 /* Link ON -> OFF */ in sis900_timer()
1344 printk(KERN_INFO "%s: Media Link Off\n", net_dev->name); in sis900_timer()
1347 if ((mii_phy->phy_id0 == 0x001D) && in sis900_timer()
1348 ((mii_phy->phy_id1 & 0xFFF0) == 0x8000)) in sis900_timer()
1349 sis900_reset_phy(net_dev, sis_priv->cur_phy); in sis900_timer()
1351 sis630_set_eq(net_dev, sis_priv->chipset_rev); in sis900_timer()
1357 sis_priv->timer.expires = jiffies + next_tick; in sis900_timer()
1358 add_timer(&sis_priv->timer); in sis900_timer()
1362 * sis900_check_mode - check the media mode for sis900
1364 * @mii_phy: the mii phy
1366 * Older driver gets the media mode from mii status output
1367 * register. Now we set our media capability and auto-negotiate
1369 * If the types of mii phy is HOME, it doesn't need to auto-negotiate
1376 void __iomem *ioaddr = sis_priv->ioaddr; in sis900_check_mode()
1379 if (mii_phy->phy_types == LAN) { in sis900_check_mode()
1382 sis900_auto_negotiate(net_dev, sis_priv->cur_phy); in sis900_check_mode()
1388 sis_priv->autong_complete = 1; in sis900_check_mode()
1393 * sis900_set_mode - Set the media mode of mac register.
1407 void __iomem *ioaddr = sp->ioaddr; in sis900_set_mode()
1443 * sis900_auto_negotiate - Set the Auto-Negotiation Enable/Reset bit.
1445 * @phy_addr: mii phy address
1447 * If the adapter is link-on, set the auto-negotiate enable/reset bit.
1448 * autong_complete should be set to 0 when starting auto-negotiation.
1449 * autong_complete should be set to 1 if we didn't start auto-negotiation.
1464 printk(KERN_INFO "%s: Media Link Off\n", net_dev->name); in sis900_auto_negotiate()
1465 sis_priv->autong_complete = 1; in sis900_auto_negotiate()
1473 sis_priv->autong_complete = 0; in sis900_auto_negotiate()
1478 * sis900_read_mode - read media mode for sis900 internal phy
1483 * The capability of remote end will be put in mii register autorec
1484 * after auto-negotiation. Use AND operation to get the upper bound
1491 struct mii_phy *phy = sis_priv->mii; in sis900_read_mode()
1492 int phy_addr = sis_priv->cur_phy; in sis900_read_mode()
1516 sis_priv->autong_complete = 1; in sis900_read_mode()
1519 if ((phy->phy_id0 == 0x0000) && ((phy->phy_id1 & 0xFFF0) == 0x8200)) { in sis900_read_mode()
1527 printk(KERN_INFO "%s: Media Link On %s %s-duplex\n", in sis900_read_mode()
1528 net_dev->name, in sis900_read_mode()
1536 * sis900_tx_timeout - sis900 transmit timeout routine
1547 void __iomem *ioaddr = sis_priv->ioaddr; in sis900_tx_timeout()
1553 net_dev->name, sr32(cr), sr32(isr)); in sis900_tx_timeout()
1560 spin_lock_irqsave(&sis_priv->lock, flags); in sis900_tx_timeout()
1563 sis_priv->dirty_tx = sis_priv->cur_tx = 0; in sis900_tx_timeout()
1565 struct sk_buff *skb = sis_priv->tx_skbuff[i]; in sis900_tx_timeout()
1568 dma_unmap_single(&sis_priv->pci_dev->dev, in sis900_tx_timeout()
1569 sis_priv->tx_ring[i].bufptr, in sis900_tx_timeout()
1570 skb->len, DMA_TO_DEVICE); in sis900_tx_timeout()
1572 sis_priv->tx_skbuff[i] = NULL; in sis900_tx_timeout()
1573 sis_priv->tx_ring[i].cmdsts = 0; in sis900_tx_timeout()
1574 sis_priv->tx_ring[i].bufptr = 0; in sis900_tx_timeout()
1575 net_dev->stats.tx_dropped++; in sis900_tx_timeout()
1578 sis_priv->tx_full = 0; in sis900_tx_timeout()
1581 spin_unlock_irqrestore(&sis_priv->lock, flags); in sis900_tx_timeout()
1586 sw32(txdp, sis_priv->tx_ring_dma); in sis900_tx_timeout()
1593 * sis900_start_xmit - sis900 start transmit routine
1606 void __iomem *ioaddr = sis_priv->ioaddr; in sis900_start_xmit()
1612 spin_lock_irqsave(&sis_priv->lock, flags); in sis900_start_xmit()
1615 entry = sis_priv->cur_tx % NUM_TX_DESC; in sis900_start_xmit()
1616 sis_priv->tx_skbuff[entry] = skb; in sis900_start_xmit()
1619 sis_priv->tx_ring[entry].bufptr = dma_map_single(&sis_priv->pci_dev->dev, in sis900_start_xmit()
1620 skb->data, skb->len, in sis900_start_xmit()
1622 if (unlikely(dma_mapping_error(&sis_priv->pci_dev->dev, in sis900_start_xmit()
1623 sis_priv->tx_ring[entry].bufptr))) { in sis900_start_xmit()
1625 sis_priv->tx_skbuff[entry] = NULL; in sis900_start_xmit()
1626 net_dev->stats.tx_dropped++; in sis900_start_xmit()
1627 spin_unlock_irqrestore(&sis_priv->lock, flags); in sis900_start_xmit()
1630 sis_priv->tx_ring[entry].cmdsts = (OWN | INTR | skb->len); in sis900_start_xmit()
1633 sis_priv->cur_tx ++; in sis900_start_xmit()
1634 index_cur_tx = sis_priv->cur_tx; in sis900_start_xmit()
1635 index_dirty_tx = sis_priv->dirty_tx; in sis900_start_xmit()
1642 sis_priv->tx_full = 1; in sis900_start_xmit()
1649 sis_priv->tx_full = 1; in sis900_start_xmit()
1653 spin_unlock_irqrestore(&sis_priv->lock, flags); in sis900_start_xmit()
1658 net_dev->name, skb->data, (int)skb->len, entry); in sis900_start_xmit()
1664 * sis900_interrupt - sis900 interrupt handler
1677 void __iomem *ioaddr = sis_priv->ioaddr; in sis900_interrupt()
1681 spin_lock (&sis_priv->lock); in sis900_interrupt()
1691 /* why dow't we break after Tx/Rx case ?? keyword: full-duplex */ in sis900_interrupt()
1704 "status %#8.8x.\n", net_dev->name, status); in sis900_interrupt()
1707 if (--boguscnt < 0) { in sis900_interrupt()
1711 net_dev->name, status); in sis900_interrupt()
1719 net_dev->name, sr32(isr)); in sis900_interrupt()
1721 spin_unlock (&sis_priv->lock); in sis900_interrupt()
1726 * sis900_rx - sis900 receive routine
1738 void __iomem *ioaddr = sis_priv->ioaddr; in sis900_rx()
1739 unsigned int entry = sis_priv->cur_rx % NUM_RX_DESC; in sis900_rx()
1740 u32 rx_status = sis_priv->rx_ring[entry].cmdsts; in sis900_rx()
1746 sis_priv->cur_rx, sis_priv->dirty_rx, rx_status); in sis900_rx()
1747 rx_work_limit = sis_priv->dirty_rx + NUM_RX_DESC - sis_priv->cur_rx; in sis900_rx()
1753 if (--rx_work_limit < 0) in sis900_rx()
1757 rx_size = data_size - CRC_SIZE; in sis900_rx()
1770 net_dev->name, rx_status, data_size); in sis900_rx()
1771 net_dev->stats.rx_errors++; in sis900_rx()
1773 net_dev->stats.rx_over_errors++; in sis900_rx()
1775 net_dev->stats.rx_length_errors++; in sis900_rx()
1777 net_dev->stats.rx_frame_errors++; in sis900_rx()
1779 net_dev->stats.rx_crc_errors++; in sis900_rx()
1781 sis_priv->rx_ring[entry].cmdsts = RX_BUF_SIZE; in sis900_rx()
1786 dma_unmap_single(&sis_priv->pci_dev->dev, in sis900_rx()
1787 sis_priv->rx_ring[entry].bufptr, in sis900_rx()
1799 skb = sis_priv->rx_skbuff[entry]; in sis900_rx()
1800 net_dev->stats.rx_dropped++; in sis900_rx()
1806 we are working on NULL sk_buff :-( */ in sis900_rx()
1807 if (sis_priv->rx_skbuff[entry] == NULL) { in sis900_rx()
1812 net_dev->name, sis_priv->cur_rx, in sis900_rx()
1813 sis_priv->dirty_rx); in sis900_rx()
1819 rx_skb = sis_priv->rx_skbuff[entry]; in sis900_rx()
1821 rx_skb->protocol = eth_type_trans(rx_skb, net_dev); in sis900_rx()
1826 net_dev->stats.multicast++; in sis900_rx()
1827 net_dev->stats.rx_bytes += rx_size; in sis900_rx()
1828 net_dev->stats.rx_packets++; in sis900_rx()
1829 sis_priv->dirty_rx++; in sis900_rx()
1831 sis_priv->rx_skbuff[entry] = skb; in sis900_rx()
1832 sis_priv->rx_ring[entry].cmdsts = RX_BUF_SIZE; in sis900_rx()
1833 sis_priv->rx_ring[entry].bufptr = in sis900_rx()
1834 dma_map_single(&sis_priv->pci_dev->dev, in sis900_rx()
1835 skb->data, RX_BUF_SIZE, in sis900_rx()
1837 if (unlikely(dma_mapping_error(&sis_priv->pci_dev->dev, in sis900_rx()
1838 sis_priv->rx_ring[entry].bufptr))) { in sis900_rx()
1840 sis_priv->rx_skbuff[entry] = NULL; in sis900_rx()
1844 sis_priv->cur_rx++; in sis900_rx()
1845 entry = sis_priv->cur_rx % NUM_RX_DESC; in sis900_rx()
1846 rx_status = sis_priv->rx_ring[entry].cmdsts; in sis900_rx()
1851 for (; sis_priv->cur_rx != sis_priv->dirty_rx; sis_priv->dirty_rx++) { in sis900_rx()
1854 entry = sis_priv->dirty_rx % NUM_RX_DESC; in sis900_rx()
1856 if (sis_priv->rx_skbuff[entry] == NULL) { in sis900_rx()
1863 net_dev->stats.rx_dropped++; in sis900_rx()
1866 sis_priv->rx_skbuff[entry] = skb; in sis900_rx()
1867 sis_priv->rx_ring[entry].cmdsts = RX_BUF_SIZE; in sis900_rx()
1868 sis_priv->rx_ring[entry].bufptr = in sis900_rx()
1869 dma_map_single(&sis_priv->pci_dev->dev, in sis900_rx()
1870 skb->data, RX_BUF_SIZE, in sis900_rx()
1872 if (unlikely(dma_mapping_error(&sis_priv->pci_dev->dev, in sis900_rx()
1873 sis_priv->rx_ring[entry].bufptr))) { in sis900_rx()
1875 sis_priv->rx_skbuff[entry] = NULL; in sis900_rx()
1880 /* re-enable the potentially idle receive state matchine */ in sis900_rx()
1887 * sis900_finish_xmit - finish up transmission of packets
1900 for (; sis_priv->dirty_tx != sis_priv->cur_tx; sis_priv->dirty_tx++) { in sis900_finish_xmit()
1905 entry = sis_priv->dirty_tx % NUM_TX_DESC; in sis900_finish_xmit()
1906 tx_status = sis_priv->tx_ring[entry].cmdsts; in sis900_finish_xmit()
1920 net_dev->name, tx_status); in sis900_finish_xmit()
1921 net_dev->stats.tx_errors++; in sis900_finish_xmit()
1923 net_dev->stats.tx_fifo_errors++; in sis900_finish_xmit()
1925 net_dev->stats.tx_aborted_errors++; in sis900_finish_xmit()
1927 net_dev->stats.tx_carrier_errors++; in sis900_finish_xmit()
1929 net_dev->stats.tx_window_errors++; in sis900_finish_xmit()
1932 net_dev->stats.collisions += (tx_status & COLCNT) >> 16; in sis900_finish_xmit()
1933 net_dev->stats.tx_bytes += tx_status & DSIZE; in sis900_finish_xmit()
1934 net_dev->stats.tx_packets++; in sis900_finish_xmit()
1937 skb = sis_priv->tx_skbuff[entry]; in sis900_finish_xmit()
1938 dma_unmap_single(&sis_priv->pci_dev->dev, in sis900_finish_xmit()
1939 sis_priv->tx_ring[entry].bufptr, skb->len, in sis900_finish_xmit()
1942 sis_priv->tx_skbuff[entry] = NULL; in sis900_finish_xmit()
1943 sis_priv->tx_ring[entry].bufptr = 0; in sis900_finish_xmit()
1944 sis_priv->tx_ring[entry].cmdsts = 0; in sis900_finish_xmit()
1947 if (sis_priv->tx_full && netif_queue_stopped(net_dev) && in sis900_finish_xmit()
1948 sis_priv->cur_tx - sis_priv->dirty_tx < NUM_TX_DESC - 4) { in sis900_finish_xmit()
1951 sis_priv->tx_full = 0; in sis900_finish_xmit()
1957 * sis900_close - close sis900 device
1967 struct pci_dev *pdev = sis_priv->pci_dev; in sis900_close()
1968 void __iomem *ioaddr = sis_priv->ioaddr; in sis900_close()
1981 del_timer(&sis_priv->timer); in sis900_close()
1983 free_irq(pdev->irq, net_dev); in sis900_close()
1987 skb = sis_priv->rx_skbuff[i]; in sis900_close()
1989 dma_unmap_single(&pdev->dev, in sis900_close()
1990 sis_priv->rx_ring[i].bufptr, in sis900_close()
1993 sis_priv->rx_skbuff[i] = NULL; in sis900_close()
1997 skb = sis_priv->tx_skbuff[i]; in sis900_close()
1999 dma_unmap_single(&pdev->dev, in sis900_close()
2000 sis_priv->tx_ring[i].bufptr, in sis900_close()
2001 skb->len, DMA_TO_DEVICE); in sis900_close()
2003 sis_priv->tx_skbuff[i] = NULL; in sis900_close()
2007 /* Green! Put the chip in low-power mode. */ in sis900_close()
2013 * sis900_get_drvinfo - Return information about driver
2017 * Process ethtool command such as "ehtool -i" to show information
2025 strlcpy(info->driver, SIS900_MODULE_NAME, sizeof(info->driver)); in sis900_get_drvinfo()
2026 strlcpy(info->version, SIS900_DRV_VERSION, sizeof(info->version)); in sis900_get_drvinfo()
2027 strlcpy(info->bus_info, pci_name(sis_priv->pci_dev), in sis900_get_drvinfo()
2028 sizeof(info->bus_info)); in sis900_get_drvinfo()
2034 return sis_priv->msg_enable; in sis900_get_msglevel()
2040 sis_priv->msg_enable = value; in sis900_set_msglevel()
2046 return mii_link_ok(&sis_priv->mii_info); in sis900_get_link()
2053 spin_lock_irq(&sis_priv->lock); in sis900_get_link_ksettings()
2054 mii_ethtool_get_link_ksettings(&sis_priv->mii_info, cmd); in sis900_get_link_ksettings()
2055 spin_unlock_irq(&sis_priv->lock); in sis900_get_link_ksettings()
2063 int rt; in sis900_set_link_ksettings() local
2064 spin_lock_irq(&sis_priv->lock); in sis900_set_link_ksettings()
2065 rt = mii_ethtool_set_link_ksettings(&sis_priv->mii_info, cmd); in sis900_set_link_ksettings()
2066 spin_unlock_irq(&sis_priv->lock); in sis900_set_link_ksettings()
2067 return rt; in sis900_set_link_ksettings()
2073 return mii_nway_restart(&sis_priv->mii_info); in sis900_nway_reset()
2077 * sis900_set_wol - Set up Wake on Lan registers
2090 void __iomem *ioaddr = sis_priv->ioaddr; in sis900_set_wol()
2093 if (wol->wolopts == 0) { in sis900_set_wol()
2094 pci_read_config_dword(sis_priv->pci_dev, CFGPMCSR, &cfgpmcsr); in sis900_set_wol()
2096 pci_write_config_dword(sis_priv->pci_dev, CFGPMCSR, cfgpmcsr); in sis900_set_wol()
2099 printk(KERN_DEBUG "%s: Wake on LAN disabled\n", net_dev->name); in sis900_set_wol()
2103 if (wol->wolopts & (WAKE_MAGICSECURE | WAKE_UCAST | WAKE_MCAST in sis900_set_wol()
2105 return -EINVAL; in sis900_set_wol()
2107 if (wol->wolopts & WAKE_MAGIC) in sis900_set_wol()
2109 if (wol->wolopts & WAKE_PHY) in sis900_set_wol()
2114 pci_read_config_dword(sis_priv->pci_dev, CFGPMCSR, &cfgpmcsr); in sis900_set_wol()
2116 pci_write_config_dword(sis_priv->pci_dev, CFGPMCSR, cfgpmcsr); in sis900_set_wol()
2118 printk(KERN_DEBUG "%s: Wake on LAN enabled\n", net_dev->name); in sis900_set_wol()
2126 void __iomem *ioaddr = sp->ioaddr; in sis900_get_wol()
2131 wol->wolopts |= WAKE_MAGIC; in sis900_get_wol()
2133 wol->wolopts |= WAKE_PHY; in sis900_get_wol()
2135 wol->supported = (WAKE_PHY | WAKE_MAGIC); in sis900_get_wol()
2142 return sis_priv->eeprom_size; in sis900_get_eeprom_len()
2148 void __iomem *ioaddr = sis_priv->ioaddr; in sis900_read_eeprom()
2149 int wait, ret = -EAGAIN; in sis900_read_eeprom()
2154 if (sis_priv->chipset_rev == SIS96x_900_REV) { in sis900_read_eeprom()
2159 for (i = 0; i < sis_priv->eeprom_size / 2; i++) in sis900_read_eeprom()
2171 for (i = 0; i < sis_priv->eeprom_size / 2; i++) in sis900_read_eeprom()
2186 eebuf = kmalloc(sis_priv->eeprom_size, GFP_KERNEL); in sis900_get_eeprom()
2188 return -ENOMEM; in sis900_get_eeprom()
2190 eeprom->magic = SIS900_EEPROM_MAGIC; in sis900_get_eeprom()
2191 spin_lock_irq(&sis_priv->lock); in sis900_get_eeprom()
2193 spin_unlock_irq(&sis_priv->lock); in sis900_get_eeprom()
2195 memcpy(data, eebuf + eeprom->offset, eeprom->len); in sis900_get_eeprom()
2215 * mii_ioctl - process MII i/o control command
2220 * Process MII command like read/write MII register
2229 case SIOCGMIIPHY: /* Get address of MII PHY in use. */ in mii_ioctl()
2230 data->phy_id = sis_priv->mii->phy_addr; in mii_ioctl()
2233 case SIOCGMIIREG: /* Read MII PHY register. */ in mii_ioctl()
2234 data->val_out = mdio_read(net_dev, data->phy_id & 0x1f, data->reg_num & 0x1f); in mii_ioctl()
2237 case SIOCSMIIREG: /* Write MII PHY register. */ in mii_ioctl()
2238 mdio_write(net_dev, data->phy_id & 0x1f, data->reg_num & 0x1f, data->val_in); in mii_ioctl()
2241 return -EOPNOTSUPP; in mii_ioctl()
2246 * sis900_set_config - Set media type by net_device.set_config
2258 struct mii_phy *mii_phy = sis_priv->mii; in sis900_set_config()
2262 if ((map->port != (u_char)(-1)) && (map->port != dev->if_port)) { in sis900_set_config()
2263 /* we switch on the ifmap->port field. I couldn't find anything in sis900_set_config()
2269 switch(map->port){ in sis900_set_config()
2271 dev->if_port = map->port; in sis900_set_config()
2280 status = mdio_read(dev, mii_phy->phy_addr, MII_CONTROL); in sis900_set_config()
2286 mdio_write(dev, mii_phy->phy_addr, in sis900_set_config()
2292 dev->if_port = map->port; in sis900_set_config()
2303 status = mdio_read(dev, mii_phy->phy_addr, MII_CONTROL); in sis900_set_config()
2306 mdio_write(dev, mii_phy->phy_addr, in sis900_set_config()
2313 dev->if_port = map->port; in sis900_set_config()
2324 status = mdio_read(dev, mii_phy->phy_addr, MII_CONTROL); in sis900_set_config()
2325 mdio_write(dev, mii_phy->phy_addr, in sis900_set_config()
2335 return -EOPNOTSUPP; in sis900_set_config()
2338 return -EINVAL; in sis900_set_config()
2345 * sis900_mcast_bitnr - compute hashtable index
2368 * set_rx_mode - Set SiS900 receive mode
2379 void __iomem *ioaddr = sis_priv->ioaddr; in set_rx_mode()
2385 if((sis_priv->chipset_rev >= SIS635A_900_REV) || in set_rx_mode()
2386 (sis_priv->chipset_rev == SIS900B_900_REV)) in set_rx_mode()
2391 if (net_dev->flags & IFF_PROMISC) { in set_rx_mode()
2397 (net_dev->flags & IFF_ALLMULTI)) { in set_rx_mode()
2412 bit_nr = sis900_mcast_bitnr(ha->addr, in set_rx_mode()
2413 sis_priv->chipset_rev); in set_rx_mode()
2429 if (net_dev->flags & IFF_LOOPBACK) { in set_rx_mode()
2443 * sis900_reset - Reset sis900 MAC
2454 void __iomem *ioaddr = sis_priv->ioaddr; in sis900_reset()
2468 if (sis_priv->chipset_rev >= SIS635A_900_REV || in sis900_reset()
2469 sis_priv->chipset_rev == SIS900B_900_REV) in sis900_reset()
2476 * sis900_remove - Remove sis900 device
2489 while (sis_priv->first_mii) { in sis900_remove()
2490 struct mii_phy *phy = sis_priv->first_mii; in sis900_remove()
2492 sis_priv->first_mii = phy->next; in sis900_remove()
2496 dma_free_coherent(&pci_dev->dev, RX_TOTAL_SIZE, sis_priv->rx_ring, in sis900_remove()
2497 sis_priv->rx_ring_dma); in sis900_remove()
2498 dma_free_coherent(&pci_dev->dev, TX_TOTAL_SIZE, sis_priv->tx_ring, in sis900_remove()
2499 sis_priv->tx_ring_dma); in sis900_remove()
2500 pci_iounmap(pci_dev, sis_priv->ioaddr); in sis900_remove()
2509 void __iomem *ioaddr = sis_priv->ioaddr; in sis900_suspend()
2527 void __iomem *ioaddr = sis_priv->ioaddr; in sis900_resume()
2550 sis900_check_mode(net_dev, sis_priv->mii); in sis900_resume()