Lines Matching +full:wake +full:- +full:on +full:- +full:lan
9 Drivers based on this skeleton fall under the GPL and must retain
13 SiS 7016 Fast Ethernet PCI Bus 10/100 Mbps LAN Controller with OnNow Support,
15 SiS 900 Fast Ethernet PCI Bus 10/100 Mbps LAN Single Chip with OnNow Support,
17 SiS 7014 Single Chip 100BASE-TX/10BASE-T Physical Layer Solution,
21 Rev 1.08.09 Sep. 19 2005 Daniele Venzano add Wake on LAN support
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
72 #include <linux/dma-mapping.h>
90 static int sis900_debug = -1; /* Use SIS900_DEF_MSG as value */
127 #define LAN 0x0002 macro
131 { "SiS 900 Internal MII PHY", 0x001d, 0x8000, LAN },
132 { "SiS 7014 Physical Layer Solution", 0x0016, 0xf830, LAN },
133 { "SiS 900 on Foxconn 661 7MI", 0x0143, 0xBC70, LAN },
134 { "Altimata AC101LF PHY", 0x0022, 0x5520, LAN },
135 { "ADM 7001 LAN PHY", 0x002e, 0xcc60, LAN },
136 { "AMD 79C901 10BASE-T PHY", 0x0000, 0x6B70, LAN },
138 { "ICS LAN PHY", 0x0015, 0xF440, LAN },
139 { "ICS LAN PHY", 0x0143, 0xBC70, LAN },
142 { "Realtek RTL8201 PHY", 0x0000, 0x8200, LAN },
143 { "VIA 6103 PHY", 0x0101, 0x8f20, LAN },
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()
282 * sis630e_get_mac_addr - Get MAC address for SiS630E model
288 * MAC address is read into @net_dev->dev_addr.
324 * sis635_get_mac_addr - Get MAC address for SIS635 model
330 * @net_dev->dev_addr.
337 void __iomem *ioaddr = sis_priv->ioaddr; in sis635_get_mac_addr()
364 * sis96x_get_mac_addr - Get MAC address for SiS962 or SiS963 model
370 * LAN and 1394. When accessing EEPROM, send EEREQ signal to hardware first
371 * and wait for EEGNT. If EEGNT is ON, EEPROM is permitted to be accessed
372 * by LAN, otherwise it is not. After MAC address is read from EEPROM, send
373 * EEDONE signal to refuse EEPROM access by LAN.
376 * MAC address is read into @net_dev->dev_addr.
383 void __iomem *ioaddr = sis_priv->ioaddr; in sis96x_get_mac_addr()
422 * sis900_probe - Probe for sis900 device
428 * and assign SiS900-specific entries in the device structure.
442 const char *card_name = card_names[pci_id->driver_data]; in sis900_probe()
456 i = dma_set_mask(&pci_dev->dev, DMA_BIT_MASK(32)); in sis900_probe()
467 return -ENOMEM; in sis900_probe()
468 SET_NETDEV_DEV(net_dev, &pci_dev->dev); in sis900_probe()
478 ret = -ENOMEM; in sis900_probe()
483 sis_priv->ioaddr = ioaddr; in sis900_probe()
484 sis_priv->pci_dev = pci_dev; in sis900_probe()
485 spin_lock_init(&sis_priv->lock); in sis900_probe()
487 sis_priv->eeprom_size = 24; in sis900_probe()
491 ring_space = dma_alloc_coherent(&pci_dev->dev, TX_TOTAL_SIZE, in sis900_probe()
494 ret = -ENOMEM; in sis900_probe()
497 sis_priv->tx_ring = ring_space; in sis900_probe()
498 sis_priv->tx_ring_dma = ring_dma; in sis900_probe()
500 ring_space = dma_alloc_coherent(&pci_dev->dev, RX_TOTAL_SIZE, in sis900_probe()
503 ret = -ENOMEM; in sis900_probe()
506 sis_priv->rx_ring = ring_space; in sis900_probe()
507 sis_priv->rx_ring_dma = ring_dma; in sis900_probe()
509 /* The SiS900-specific entries in the device structure. */ in sis900_probe()
510 net_dev->netdev_ops = &sis900_netdev_ops; in sis900_probe()
511 net_dev->watchdog_timeo = TX_TIMEOUT; in sis900_probe()
512 net_dev->ethtool_ops = &sis900_ethtool_ops; in sis900_probe()
515 sis_priv->msg_enable = sis900_debug; in sis900_probe()
517 sis_priv->msg_enable = SIS900_DEF_MSG; in sis900_probe()
519 sis_priv->mii_info.dev = net_dev; in sis900_probe()
520 sis_priv->mii_info.mdio_read = mdio_read; in sis900_probe()
521 sis_priv->mii_info.mdio_write = mdio_write; in sis900_probe()
522 sis_priv->mii_info.phy_id_mask = 0x1f; in sis900_probe()
523 sis_priv->mii_info.reg_num_mask = 0x1f; in sis900_probe()
526 sis_priv->chipset_rev = pci_dev->revision; in sis900_probe()
530 dev_name, sis_priv->chipset_rev); in sis900_probe()
533 if (sis_priv->chipset_rev == SIS630E_900_REV) in sis900_probe()
535 else if ((sis_priv->chipset_rev > 0x81) && (sis_priv->chipset_rev <= 0x90) ) in sis900_probe()
537 else if (sis_priv->chipset_rev == SIS96x_900_REV) in sis900_probe()
542 if (!ret || !is_valid_ether_addr(net_dev->dev_addr)) { in sis900_probe()
548 /* 630ET : set the mii access mode as software-mode */ in sis900_probe()
549 if (sis_priv->chipset_rev == SIS630ET_900_REV) in sis900_probe()
556 ret = -ENODEV; in sis900_probe()
563 sis_priv->host_bridge_rev = dev->revision; in sis900_probe()
573 net_dev->name, card_name, ioaddr, pci_dev->irq, in sis900_probe()
574 net_dev->dev_addr); in sis900_probe()
576 /* Detect Wake on Lan support */ in sis900_probe()
579 printk(KERN_INFO "%s: Wake on LAN only available from suspend to RAM.", net_dev->name); in sis900_probe()
584 dma_free_coherent(&pci_dev->dev, RX_TOTAL_SIZE, sis_priv->rx_ring, in sis900_probe()
585 sis_priv->rx_ring_dma); in sis900_probe()
587 dma_free_coherent(&pci_dev->dev, TX_TOTAL_SIZE, sis_priv->tx_ring, in sis900_probe()
588 sis_priv->tx_ring_dma); in sis900_probe()
597 * sis900_mii_probe - Probe MII PHY for sis900
608 const char *dev_name = pci_name(sis_priv->pci_dev); in sis900_mii_probe()
613 sis_priv->mii = NULL; in sis900_mii_probe()
634 mii_phy = sis_priv->first_mii; in sis900_mii_probe()
638 mii_phy = mii_phy->next; in sis900_mii_probe()
644 mii_phy->phy_id0 = mdio_read(net_dev, phy_addr, MII_PHY_ID0); in sis900_mii_probe()
645 mii_phy->phy_id1 = mdio_read(net_dev, phy_addr, MII_PHY_ID1); in sis900_mii_probe()
646 mii_phy->phy_addr = phy_addr; in sis900_mii_probe()
647 mii_phy->status = mii_status; in sis900_mii_probe()
648 mii_phy->next = sis_priv->mii; in sis900_mii_probe()
649 sis_priv->mii = mii_phy; in sis900_mii_probe()
650 sis_priv->first_mii = mii_phy; in sis900_mii_probe()
653 if ((mii_phy->phy_id0 == mii_chip_table[i].phy_id0 ) && in sis900_mii_probe()
654 ((mii_phy->phy_id1 & 0xFFF0) == mii_chip_table[i].phy_id1)){ in sis900_mii_probe()
655 mii_phy->phy_types = mii_chip_table[i].phy_types; in sis900_mii_probe()
657 mii_phy->phy_types = in sis900_mii_probe()
658 (mii_status & (MII_STAT_CAN_TX_FDX | MII_STAT_CAN_TX)) ? LAN : HOME; in sis900_mii_probe()
670 mii_phy->phy_types = UNKNOWN; in sis900_mii_probe()
674 if (sis_priv->mii == NULL) { in sis900_mii_probe()
680 sis_priv->mii = NULL; in sis900_mii_probe()
684 if ((sis_priv->mii->phy_id0 == 0x001D) && in sis900_mii_probe()
685 ((sis_priv->mii->phy_id1&0xFFF0) == 0x8000)) in sis900_mii_probe()
686 status = sis900_reset_phy(net_dev, sis_priv->cur_phy); in sis900_mii_probe()
689 if ((sis_priv->mii->phy_id0 == 0x0015) && in sis900_mii_probe()
690 ((sis_priv->mii->phy_id1&0xFFF0) == 0xF440)) in sis900_mii_probe()
691 mdio_write(net_dev, sis_priv->cur_phy, 0x0018, 0xD200); in sis900_mii_probe()
697 poll_bit ^= (mdio_read(net_dev, sis_priv->cur_phy, MII_STATUS) & poll_bit); in sis900_mii_probe()
701 return -ETIME; in sis900_mii_probe()
706 if (sis_priv->chipset_rev == SIS630E_900_REV) { in sis900_mii_probe()
707 /* SiS 630E has some bugs on default value of PHY registers */ in sis900_mii_probe()
708 mdio_write(net_dev, sis_priv->cur_phy, MII_ANADV, 0x05e1); in sis900_mii_probe()
709 mdio_write(net_dev, sis_priv->cur_phy, MII_CONFIG1, 0x22); in sis900_mii_probe()
710 mdio_write(net_dev, sis_priv->cur_phy, MII_CONFIG2, 0xff00); in sis900_mii_probe()
711 mdio_write(net_dev, sis_priv->cur_phy, MII_MASK, 0xffc0); in sis900_mii_probe()
712 //mdio_write(net_dev, sis_priv->cur_phy, MII_CONTROL, 0x1000); in sis900_mii_probe()
715 if (sis_priv->mii->status & MII_STAT_LINK) in sis900_mii_probe()
724 * sis900_default_phy - Select default PHY for sis900 mac.
728 * If no one is link on, select PHY whose types is HOME as default.
729 * If HOME doesn't exist, select LAN.
739 for (phy=sis_priv->first_mii; phy; phy=phy->next) { in sis900_default_phy()
740 status = mdio_read(net_dev, phy->phy_addr, MII_STATUS); in sis900_default_phy()
741 status = mdio_read(net_dev, phy->phy_addr, MII_STATUS); in sis900_default_phy()
743 /* Link ON & Not select default PHY & not ghost PHY */ in sis900_default_phy()
745 (phy->phy_types != UNKNOWN)) { in sis900_default_phy()
748 status = mdio_read(net_dev, phy->phy_addr, MII_CONTROL); in sis900_default_phy()
749 mdio_write(net_dev, phy->phy_addr, MII_CONTROL, in sis900_default_phy()
751 if (phy->phy_types == HOME) in sis900_default_phy()
753 else if(phy->phy_types == LAN) in sis900_default_phy()
763 default_phy = sis_priv->first_mii; in sis900_default_phy()
765 if (sis_priv->mii != default_phy) { in sis900_default_phy()
766 sis_priv->mii = default_phy; in sis900_default_phy()
767 sis_priv->cur_phy = default_phy->phy_addr; in sis900_default_phy()
769 pci_name(sis_priv->pci_dev), sis_priv->cur_phy); in sis900_default_phy()
772 sis_priv->mii_info.phy_id = sis_priv->cur_phy; in sis900_default_phy()
774 status = mdio_read(net_dev, sis_priv->cur_phy, MII_CONTROL); in sis900_default_phy()
777 mdio_write(net_dev, sis_priv->cur_phy, MII_CONTROL, status); in sis900_default_phy()
778 status = mdio_read(net_dev, sis_priv->cur_phy, MII_STATUS); in sis900_default_phy()
779 status = mdio_read(net_dev, sis_priv->cur_phy, MII_STATUS); in sis900_default_phy()
786 * sis900_set_capability - set the media capability of network adapter.
791 * mii status register. It's necessary before auto-negotiate.
798 mdio_read(net_dev, phy->phy_addr, MII_STATUS); in sis900_set_capability()
799 mdio_read(net_dev, phy->phy_addr, MII_STATUS); in sis900_set_capability()
802 ((phy->status & MII_STAT_CAN_TX_FDX)? MII_NWAY_TX_FDX:0) | in sis900_set_capability()
803 ((phy->status & MII_STAT_CAN_TX) ? MII_NWAY_TX:0) | in sis900_set_capability()
804 ((phy->status & MII_STAT_CAN_T_FDX) ? MII_NWAY_T_FDX:0)| in sis900_set_capability()
805 ((phy->status & MII_STAT_CAN_T) ? MII_NWAY_T:0); in sis900_set_capability()
807 mdio_write(net_dev, phy->phy_addr, MII_ANADV, cap); in sis900_set_capability()
815 * read_eeprom - Read Serial EEPROM
835 for (i = 8; i >= 0; i--) { in read_eeprom()
846 /* read the 16-bits data in */ in read_eeprom()
847 for (i = 16; i > 0; i--) { in read_eeprom()
863 /* Read and write the MII management registers using software-generated
870 void __iomem *ioaddr = sp->ioaddr; in mdio_idle()
880 void __iomem *ioaddr = sp->ioaddr; in mdio_reset()
883 for (i = 31; i >= 0; i--) { in mdio_reset()
892 * mdio_read - read MII PHY register
906 void __iomem *ioaddr = sp->ioaddr; in mdio_read()
913 for (i = 15; i >= 0; i--) { in mdio_read()
923 for (i = 16; i > 0; i--) { in mdio_read()
936 * mdio_write - write MII PHY register
952 void __iomem *ioaddr = sp->ioaddr; in mdio_write()
959 for (i = 15; i >= 0; i--) { in mdio_write()
970 for (i = 15; i >= 0; i--) { in mdio_write()
981 for (i = 2; i > 0; i--) { in mdio_write()
992 * sis900_reset_phy - reset sis900 mii phy.
998 * link status change from ON to DOWN.
1016 * Polling 'interrupt' - used by things like netconsole to send skbs
1017 * without having to re-enable interrupts. It's not called while
1023 const int irq = sp->pci_dev->irq; in sis900_poll()
1032 * sis900_open - open sis900 device
1043 void __iomem *ioaddr = sis_priv->ioaddr; in sis900_open()
1050 sis630_set_eq(net_dev, sis_priv->chipset_rev); in sis900_open()
1052 ret = request_irq(sis_priv->pci_dev->irq, sis900_interrupt, IRQF_SHARED, in sis900_open()
1053 net_dev->name, net_dev); in sis900_open()
1074 sis900_check_mode(net_dev, sis_priv->mii); in sis900_open()
1078 timer_setup(&sis_priv->timer, sis900_timer, 0); in sis900_open()
1079 sis_priv->timer.expires = jiffies + HZ; in sis900_open()
1080 add_timer(&sis_priv->timer); in sis900_open()
1086 * sis900_init_rxfilter - Initialize the Rx filter
1097 void __iomem *ioaddr = sis_priv->ioaddr; in sis900_init_rxfilter()
1108 u32 w = (u32) *((const u16 *)(net_dev->dev_addr)+i); in sis900_init_rxfilter()
1115 net_dev->name, i, sr32(rfdr)); in sis900_init_rxfilter()
1124 * sis900_init_tx_ring - Initialize the Tx descriptor ring
1134 void __iomem *ioaddr = sis_priv->ioaddr; in sis900_init_tx_ring()
1137 sis_priv->tx_full = 0; in sis900_init_tx_ring()
1138 sis_priv->dirty_tx = sis_priv->cur_tx = 0; in sis900_init_tx_ring()
1141 sis_priv->tx_skbuff[i] = NULL; in sis900_init_tx_ring()
1143 sis_priv->tx_ring[i].link = sis_priv->tx_ring_dma + in sis900_init_tx_ring()
1145 sis_priv->tx_ring[i].cmdsts = 0; in sis900_init_tx_ring()
1146 sis_priv->tx_ring[i].bufptr = 0; in sis900_init_tx_ring()
1150 sw32(txdp, sis_priv->tx_ring_dma); in sis900_init_tx_ring()
1153 net_dev->name, sr32(txdp)); in sis900_init_tx_ring()
1157 * sis900_init_rx_ring - Initialize the Rx descriptor ring
1161 * and pre-allocate receive buffers (socket buffer)
1168 void __iomem *ioaddr = sis_priv->ioaddr; in sis900_init_rx_ring()
1171 sis_priv->cur_rx = 0; in sis900_init_rx_ring()
1172 sis_priv->dirty_rx = 0; in sis900_init_rx_ring()
1176 sis_priv->rx_skbuff[i] = NULL; in sis900_init_rx_ring()
1178 sis_priv->rx_ring[i].link = sis_priv->rx_ring_dma + in sis900_init_rx_ring()
1180 sis_priv->rx_ring[i].cmdsts = 0; in sis900_init_rx_ring()
1181 sis_priv->rx_ring[i].bufptr = 0; in sis900_init_rx_ring()
1190 on the buffer ring, it is not clear how the in sis900_init_rx_ring()
1195 sis_priv->rx_skbuff[i] = skb; in sis900_init_rx_ring()
1196 sis_priv->rx_ring[i].cmdsts = RX_BUF_SIZE; in sis900_init_rx_ring()
1197 sis_priv->rx_ring[i].bufptr = dma_map_single(&sis_priv->pci_dev->dev, in sis900_init_rx_ring()
1198 skb->data, in sis900_init_rx_ring()
1201 if (unlikely(dma_mapping_error(&sis_priv->pci_dev->dev, in sis900_init_rx_ring()
1202 sis_priv->rx_ring[i].bufptr))) { in sis900_init_rx_ring()
1204 sis_priv->rx_skbuff[i] = NULL; in sis900_init_rx_ring()
1208 sis_priv->dirty_rx = (unsigned int) (i - NUM_RX_DESC); in sis900_init_rx_ring()
1211 sw32(rxdp, sis_priv->rx_ring_dma); in sis900_init_rx_ring()
1214 net_dev->name, sr32(rxdp)); in sis900_init_rx_ring()
1218 * sis630_set_eq - set phy equalizer value for 630 LAN
1220 * @revision: 630 LAN revision number
1224 * Bit 14: 0 -- Automatically detect (default)
1225 * 1 -- Manually set Equalizer filter
1226 * Bit 13: 0 -- (Default)
1227 * 1 -- Speed up convergence of equalizer setting
1228 * Bit 9 : 0 -- (Default)
1229 * 1 -- Disable Baseline Wander
1230 * Bit 3~7 -- Equalizer filter setting
1231 * Link ON: Set Bit 9, 13 to 1, Bit 14 to 0
1236 * When Link is ON and Bit 14 is 0, SIS900PHY will auto-detect proper equalizer value.
1239 * 0 <= max <= 4 --> set equalizer to max
1240 * 5 <= max <= 14 --> set equalizer to max+1 or set equalizer to max+2 if max == min
1241 * max >= 15 --> set equalizer to max+5 or set equalizer to max+6 if max == min
1255 reg14h = mdio_read(net_dev, sis_priv->cur_phy, MII_RESV); in sis630_set_eq()
1256 mdio_write(net_dev, sis_priv->cur_phy, MII_RESV, in sis630_set_eq()
1260 sis_priv->cur_phy, MII_RESV)) >> 3; in sis630_set_eq()
1282 (sis_priv->host_bridge_rev == SIS630B0 || in sis630_set_eq()
1283 sis_priv->host_bridge_rev == SIS630B1)) { in sis630_set_eq()
1290 reg14h = mdio_read(net_dev, sis_priv->cur_phy, MII_RESV); in sis630_set_eq()
1293 mdio_write(net_dev, sis_priv->cur_phy, MII_RESV, reg14h); in sis630_set_eq()
1295 reg14h = mdio_read(net_dev, sis_priv->cur_phy, MII_RESV); in sis630_set_eq()
1297 (sis_priv->host_bridge_rev == SIS630B0 || in sis630_set_eq()
1298 sis_priv->host_bridge_rev == SIS630B1)) in sis630_set_eq()
1299 mdio_write(net_dev, sis_priv->cur_phy, MII_RESV, in sis630_set_eq()
1302 mdio_write(net_dev, sis_priv->cur_phy, MII_RESV, in sis630_set_eq()
1308 * sis900_timer - sis900 timer routine
1311 * On each timer ticks we check two things,
1312 * link status (ON/OFF) and link mode (10/100/Full/Half)
1318 struct net_device *net_dev = sis_priv->mii_info.dev; in sis900_timer()
1319 struct mii_phy *mii_phy = sis_priv->mii; in sis900_timer()
1324 status = mdio_read(net_dev, sis_priv->cur_phy, MII_STATUS); in sis900_timer()
1325 status = mdio_read(net_dev, sis_priv->cur_phy, MII_STATUS); in sis900_timer()
1327 /* Link OFF -> ON */ in sis900_timer()
1332 mii_phy = sis_priv->mii; in sis900_timer()
1340 sis630_set_eq(net_dev, sis_priv->chipset_rev); in sis900_timer()
1345 /* Link ON -> OFF */ in sis900_timer()
1349 printk(KERN_INFO "%s: Media Link Off\n", net_dev->name); in sis900_timer()
1352 if ((mii_phy->phy_id0 == 0x001D) && in sis900_timer()
1353 ((mii_phy->phy_id1 & 0xFFF0) == 0x8000)) in sis900_timer()
1354 sis900_reset_phy(net_dev, sis_priv->cur_phy); in sis900_timer()
1356 sis630_set_eq(net_dev, sis_priv->chipset_rev); in sis900_timer()
1362 sis_priv->timer.expires = jiffies + next_tick; in sis900_timer()
1363 add_timer(&sis_priv->timer); in sis900_timer()
1367 * sis900_check_mode - check the media mode for sis900
1372 * register. Now we set our media capability and auto-negotiate
1374 * If the types of mii phy is HOME, it doesn't need to auto-negotiate
1381 void __iomem *ioaddr = sis_priv->ioaddr; in sis900_check_mode()
1384 if (mii_phy->phy_types == LAN) { in sis900_check_mode()
1387 sis900_auto_negotiate(net_dev, sis_priv->cur_phy); in sis900_check_mode()
1393 sis_priv->autong_complete = 1; in sis900_check_mode()
1398 * sis900_set_mode - Set the media mode of mac register.
1412 void __iomem *ioaddr = sp->ioaddr; in sis900_set_mode()
1448 * sis900_auto_negotiate - Set the Auto-Negotiation Enable/Reset bit.
1452 * If the adapter is link-on, set the auto-negotiate enable/reset bit.
1453 * autong_complete should be set to 0 when starting auto-negotiation.
1454 * autong_complete should be set to 1 if we didn't start auto-negotiation.
1455 * sis900_timer will wait for link on again if autong_complete = 0.
1469 printk(KERN_INFO "%s: Media Link Off\n", net_dev->name); in sis900_auto_negotiate()
1470 sis_priv->autong_complete = 1; in sis900_auto_negotiate()
1478 sis_priv->autong_complete = 0; in sis900_auto_negotiate()
1483 * sis900_read_mode - read media mode for sis900 internal phy
1489 * after auto-negotiation. Use AND operation to get the upper bound
1496 struct mii_phy *phy = sis_priv->mii; in sis900_read_mode()
1497 int phy_addr = sis_priv->cur_phy; in sis900_read_mode()
1521 sis_priv->autong_complete = 1; in sis900_read_mode()
1524 if ((phy->phy_id0 == 0x0000) && ((phy->phy_id1 & 0xFFF0) == 0x8200)) { in sis900_read_mode()
1532 printk(KERN_INFO "%s: Media Link On %s %s-duplex\n", in sis900_read_mode()
1533 net_dev->name, in sis900_read_mode()
1541 * sis900_tx_timeout - sis900 transmit timeout routine
1552 void __iomem *ioaddr = sis_priv->ioaddr; in sis900_tx_timeout()
1558 net_dev->name, sr32(cr), sr32(isr)); in sis900_tx_timeout()
1565 spin_lock_irqsave(&sis_priv->lock, flags); in sis900_tx_timeout()
1568 sis_priv->dirty_tx = sis_priv->cur_tx = 0; in sis900_tx_timeout()
1570 struct sk_buff *skb = sis_priv->tx_skbuff[i]; in sis900_tx_timeout()
1573 dma_unmap_single(&sis_priv->pci_dev->dev, in sis900_tx_timeout()
1574 sis_priv->tx_ring[i].bufptr, in sis900_tx_timeout()
1575 skb->len, DMA_TO_DEVICE); in sis900_tx_timeout()
1577 sis_priv->tx_skbuff[i] = NULL; in sis900_tx_timeout()
1578 sis_priv->tx_ring[i].cmdsts = 0; in sis900_tx_timeout()
1579 sis_priv->tx_ring[i].bufptr = 0; in sis900_tx_timeout()
1580 net_dev->stats.tx_dropped++; in sis900_tx_timeout()
1583 sis_priv->tx_full = 0; in sis900_tx_timeout()
1586 spin_unlock_irqrestore(&sis_priv->lock, flags); in sis900_tx_timeout()
1591 sw32(txdp, sis_priv->tx_ring_dma); in sis900_tx_timeout()
1598 * sis900_start_xmit - sis900 start transmit routine
1611 void __iomem *ioaddr = sis_priv->ioaddr; in sis900_start_xmit()
1617 spin_lock_irqsave(&sis_priv->lock, flags); in sis900_start_xmit()
1620 entry = sis_priv->cur_tx % NUM_TX_DESC; in sis900_start_xmit()
1621 sis_priv->tx_skbuff[entry] = skb; in sis900_start_xmit()
1624 sis_priv->tx_ring[entry].bufptr = dma_map_single(&sis_priv->pci_dev->dev, in sis900_start_xmit()
1625 skb->data, skb->len, in sis900_start_xmit()
1627 if (unlikely(dma_mapping_error(&sis_priv->pci_dev->dev, in sis900_start_xmit()
1628 sis_priv->tx_ring[entry].bufptr))) { in sis900_start_xmit()
1630 sis_priv->tx_skbuff[entry] = NULL; in sis900_start_xmit()
1631 net_dev->stats.tx_dropped++; in sis900_start_xmit()
1632 spin_unlock_irqrestore(&sis_priv->lock, flags); in sis900_start_xmit()
1635 sis_priv->tx_ring[entry].cmdsts = (OWN | INTR | skb->len); in sis900_start_xmit()
1638 sis_priv->cur_tx ++; in sis900_start_xmit()
1639 index_cur_tx = sis_priv->cur_tx; in sis900_start_xmit()
1640 index_dirty_tx = sis_priv->dirty_tx; in sis900_start_xmit()
1647 sis_priv->tx_full = 1; in sis900_start_xmit()
1654 sis_priv->tx_full = 1; in sis900_start_xmit()
1658 spin_unlock_irqrestore(&sis_priv->lock, flags); in sis900_start_xmit()
1663 net_dev->name, skb->data, (int)skb->len, entry); in sis900_start_xmit()
1669 * sis900_interrupt - sis900 interrupt handler
1682 void __iomem *ioaddr = sis_priv->ioaddr; in sis900_interrupt()
1686 spin_lock (&sis_priv->lock); in sis900_interrupt()
1696 /* why dow't we break after Tx/Rx case ?? keyword: full-duplex */ in sis900_interrupt()
1709 "status %#8.8x.\n", net_dev->name, status); in sis900_interrupt()
1712 if (--boguscnt < 0) { in sis900_interrupt()
1716 net_dev->name, status); in sis900_interrupt()
1724 net_dev->name, sr32(isr)); in sis900_interrupt()
1726 spin_unlock (&sis_priv->lock); in sis900_interrupt()
1731 * sis900_rx - sis900 receive routine
1743 void __iomem *ioaddr = sis_priv->ioaddr; in sis900_rx()
1744 unsigned int entry = sis_priv->cur_rx % NUM_RX_DESC; in sis900_rx()
1745 u32 rx_status = sis_priv->rx_ring[entry].cmdsts; in sis900_rx()
1751 sis_priv->cur_rx, sis_priv->dirty_rx, rx_status); in sis900_rx()
1752 rx_work_limit = sis_priv->dirty_rx + NUM_RX_DESC - sis_priv->cur_rx; in sis900_rx()
1758 if (--rx_work_limit < 0) in sis900_rx()
1762 rx_size = data_size - CRC_SIZE; in sis900_rx()
1775 net_dev->name, rx_status, data_size); in sis900_rx()
1776 net_dev->stats.rx_errors++; in sis900_rx()
1778 net_dev->stats.rx_over_errors++; in sis900_rx()
1780 net_dev->stats.rx_length_errors++; in sis900_rx()
1782 net_dev->stats.rx_frame_errors++; in sis900_rx()
1784 net_dev->stats.rx_crc_errors++; in sis900_rx()
1786 sis_priv->rx_ring[entry].cmdsts = RX_BUF_SIZE; in sis900_rx()
1791 dma_unmap_single(&sis_priv->pci_dev->dev, in sis900_rx()
1792 sis_priv->rx_ring[entry].bufptr, in sis900_rx()
1804 skb = sis_priv->rx_skbuff[entry]; in sis900_rx()
1805 net_dev->stats.rx_dropped++; in sis900_rx()
1811 we are working on NULL sk_buff :-( */ in sis900_rx()
1812 if (sis_priv->rx_skbuff[entry] == NULL) { in sis900_rx()
1817 net_dev->name, sis_priv->cur_rx, in sis900_rx()
1818 sis_priv->dirty_rx); in sis900_rx()
1824 rx_skb = sis_priv->rx_skbuff[entry]; in sis900_rx()
1826 rx_skb->protocol = eth_type_trans(rx_skb, net_dev); in sis900_rx()
1831 net_dev->stats.multicast++; in sis900_rx()
1832 net_dev->stats.rx_bytes += rx_size; in sis900_rx()
1833 net_dev->stats.rx_packets++; in sis900_rx()
1834 sis_priv->dirty_rx++; in sis900_rx()
1836 sis_priv->rx_skbuff[entry] = skb; in sis900_rx()
1837 sis_priv->rx_ring[entry].cmdsts = RX_BUF_SIZE; in sis900_rx()
1838 sis_priv->rx_ring[entry].bufptr = in sis900_rx()
1839 dma_map_single(&sis_priv->pci_dev->dev, in sis900_rx()
1840 skb->data, RX_BUF_SIZE, in sis900_rx()
1842 if (unlikely(dma_mapping_error(&sis_priv->pci_dev->dev, in sis900_rx()
1843 sis_priv->rx_ring[entry].bufptr))) { in sis900_rx()
1845 sis_priv->rx_skbuff[entry] = NULL; in sis900_rx()
1849 sis_priv->cur_rx++; in sis900_rx()
1850 entry = sis_priv->cur_rx % NUM_RX_DESC; in sis900_rx()
1851 rx_status = sis_priv->rx_ring[entry].cmdsts; in sis900_rx()
1856 for (; sis_priv->cur_rx != sis_priv->dirty_rx; sis_priv->dirty_rx++) { in sis900_rx()
1859 entry = sis_priv->dirty_rx % NUM_RX_DESC; in sis900_rx()
1861 if (sis_priv->rx_skbuff[entry] == NULL) { in sis900_rx()
1865 * "hole" on the buffer ring, it is not clear in sis900_rx()
1868 net_dev->stats.rx_dropped++; in sis900_rx()
1871 sis_priv->rx_skbuff[entry] = skb; in sis900_rx()
1872 sis_priv->rx_ring[entry].cmdsts = RX_BUF_SIZE; in sis900_rx()
1873 sis_priv->rx_ring[entry].bufptr = in sis900_rx()
1874 dma_map_single(&sis_priv->pci_dev->dev, in sis900_rx()
1875 skb->data, RX_BUF_SIZE, in sis900_rx()
1877 if (unlikely(dma_mapping_error(&sis_priv->pci_dev->dev, in sis900_rx()
1878 sis_priv->rx_ring[entry].bufptr))) { in sis900_rx()
1880 sis_priv->rx_skbuff[entry] = NULL; in sis900_rx()
1885 /* re-enable the potentially idle receive state matchine */ in sis900_rx()
1892 * sis900_finish_xmit - finish up transmission of packets
1893 * @net_dev: the net device to be transmitted on
1905 for (; sis_priv->dirty_tx != sis_priv->cur_tx; sis_priv->dirty_tx++) { in sis900_finish_xmit()
1910 entry = sis_priv->dirty_tx % NUM_TX_DESC; in sis900_finish_xmit()
1911 tx_status = sis_priv->tx_ring[entry].cmdsts; in sis900_finish_xmit()
1916 * on TxDESC interrupt ('descriptor interrupt') */ in sis900_finish_xmit()
1925 net_dev->name, tx_status); in sis900_finish_xmit()
1926 net_dev->stats.tx_errors++; in sis900_finish_xmit()
1928 net_dev->stats.tx_fifo_errors++; in sis900_finish_xmit()
1930 net_dev->stats.tx_aborted_errors++; in sis900_finish_xmit()
1932 net_dev->stats.tx_carrier_errors++; in sis900_finish_xmit()
1934 net_dev->stats.tx_window_errors++; in sis900_finish_xmit()
1937 net_dev->stats.collisions += (tx_status & COLCNT) >> 16; in sis900_finish_xmit()
1938 net_dev->stats.tx_bytes += tx_status & DSIZE; in sis900_finish_xmit()
1939 net_dev->stats.tx_packets++; in sis900_finish_xmit()
1942 skb = sis_priv->tx_skbuff[entry]; in sis900_finish_xmit()
1943 dma_unmap_single(&sis_priv->pci_dev->dev, in sis900_finish_xmit()
1944 sis_priv->tx_ring[entry].bufptr, skb->len, in sis900_finish_xmit()
1947 sis_priv->tx_skbuff[entry] = NULL; in sis900_finish_xmit()
1948 sis_priv->tx_ring[entry].bufptr = 0; in sis900_finish_xmit()
1949 sis_priv->tx_ring[entry].cmdsts = 0; in sis900_finish_xmit()
1952 if (sis_priv->tx_full && netif_queue_stopped(net_dev) && in sis900_finish_xmit()
1953 sis_priv->cur_tx - sis_priv->dirty_tx < NUM_TX_DESC - 4) { in sis900_finish_xmit()
1956 sis_priv->tx_full = 0; in sis900_finish_xmit()
1962 * sis900_close - close sis900 device
1972 struct pci_dev *pdev = sis_priv->pci_dev; in sis900_close()
1973 void __iomem *ioaddr = sis_priv->ioaddr; in sis900_close()
1986 del_timer(&sis_priv->timer); in sis900_close()
1988 free_irq(pdev->irq, net_dev); in sis900_close()
1992 skb = sis_priv->rx_skbuff[i]; in sis900_close()
1994 dma_unmap_single(&pdev->dev, in sis900_close()
1995 sis_priv->rx_ring[i].bufptr, in sis900_close()
1998 sis_priv->rx_skbuff[i] = NULL; in sis900_close()
2002 skb = sis_priv->tx_skbuff[i]; in sis900_close()
2004 dma_unmap_single(&pdev->dev, in sis900_close()
2005 sis_priv->tx_ring[i].bufptr, in sis900_close()
2006 skb->len, DMA_TO_DEVICE); in sis900_close()
2008 sis_priv->tx_skbuff[i] = NULL; in sis900_close()
2012 /* Green! Put the chip in low-power mode. */ in sis900_close()
2018 * sis900_get_drvinfo - Return information about driver
2022 * Process ethtool command such as "ehtool -i" to show information
2030 strscpy(info->driver, SIS900_MODULE_NAME, sizeof(info->driver)); in sis900_get_drvinfo()
2031 strscpy(info->version, SIS900_DRV_VERSION, sizeof(info->version)); in sis900_get_drvinfo()
2032 strscpy(info->bus_info, pci_name(sis_priv->pci_dev), in sis900_get_drvinfo()
2033 sizeof(info->bus_info)); in sis900_get_drvinfo()
2039 return sis_priv->msg_enable; in sis900_get_msglevel()
2045 sis_priv->msg_enable = value; in sis900_set_msglevel()
2051 return mii_link_ok(&sis_priv->mii_info); in sis900_get_link()
2058 spin_lock_irq(&sis_priv->lock); in sis900_get_link_ksettings()
2059 mii_ethtool_get_link_ksettings(&sis_priv->mii_info, cmd); in sis900_get_link_ksettings()
2060 spin_unlock_irq(&sis_priv->lock); in sis900_get_link_ksettings()
2069 spin_lock_irq(&sis_priv->lock); in sis900_set_link_ksettings()
2070 rt = mii_ethtool_set_link_ksettings(&sis_priv->mii_info, cmd); in sis900_set_link_ksettings()
2071 spin_unlock_irq(&sis_priv->lock); in sis900_set_link_ksettings()
2078 return mii_nway_restart(&sis_priv->mii_info); in sis900_nway_reset()
2082 * sis900_set_wol - Set up Wake on Lan registers
2086 * Process ethtool command "wol" to setup wake on lan features.
2095 void __iomem *ioaddr = sis_priv->ioaddr; in sis900_set_wol()
2098 if (wol->wolopts == 0) { in sis900_set_wol()
2099 pci_read_config_dword(sis_priv->pci_dev, CFGPMCSR, &cfgpmcsr); in sis900_set_wol()
2101 pci_write_config_dword(sis_priv->pci_dev, CFGPMCSR, cfgpmcsr); in sis900_set_wol()
2104 printk(KERN_DEBUG "%s: Wake on LAN disabled\n", net_dev->name); in sis900_set_wol()
2108 if (wol->wolopts & (WAKE_MAGICSECURE | WAKE_UCAST | WAKE_MCAST in sis900_set_wol()
2110 return -EINVAL; in sis900_set_wol()
2112 if (wol->wolopts & WAKE_MAGIC) in sis900_set_wol()
2114 if (wol->wolopts & WAKE_PHY) in sis900_set_wol()
2119 pci_read_config_dword(sis_priv->pci_dev, CFGPMCSR, &cfgpmcsr); in sis900_set_wol()
2121 pci_write_config_dword(sis_priv->pci_dev, CFGPMCSR, cfgpmcsr); in sis900_set_wol()
2123 printk(KERN_DEBUG "%s: Wake on LAN enabled\n", net_dev->name); in sis900_set_wol()
2131 void __iomem *ioaddr = sp->ioaddr; in sis900_get_wol()
2136 wol->wolopts |= WAKE_MAGIC; in sis900_get_wol()
2138 wol->wolopts |= WAKE_PHY; in sis900_get_wol()
2140 wol->supported = (WAKE_PHY | WAKE_MAGIC); in sis900_get_wol()
2147 return sis_priv->eeprom_size; in sis900_get_eeprom_len()
2153 void __iomem *ioaddr = sis_priv->ioaddr; in sis900_read_eeprom()
2154 int wait, ret = -EAGAIN; in sis900_read_eeprom()
2159 if (sis_priv->chipset_rev == SIS96x_900_REV) { in sis900_read_eeprom()
2164 for (i = 0; i < sis_priv->eeprom_size / 2; i++) in sis900_read_eeprom()
2176 for (i = 0; i < sis_priv->eeprom_size / 2; i++) in sis900_read_eeprom()
2191 eebuf = kmalloc(sis_priv->eeprom_size, GFP_KERNEL); in sis900_get_eeprom()
2193 return -ENOMEM; in sis900_get_eeprom()
2195 eeprom->magic = SIS900_EEPROM_MAGIC; in sis900_get_eeprom()
2196 spin_lock_irq(&sis_priv->lock); in sis900_get_eeprom()
2198 spin_unlock_irq(&sis_priv->lock); in sis900_get_eeprom()
2200 memcpy(data, eebuf + eeprom->offset, eeprom->len); in sis900_get_eeprom()
2220 * mii_ioctl - process MII i/o control command
2235 data->phy_id = sis_priv->mii->phy_addr; in mii_ioctl()
2239 data->val_out = mdio_read(net_dev, data->phy_id & 0x1f, data->reg_num & 0x1f); in mii_ioctl()
2243 mdio_write(net_dev, data->phy_id & 0x1f, data->reg_num & 0x1f, data->val_in); in mii_ioctl()
2246 return -EOPNOTSUPP; in mii_ioctl()
2251 * sis900_set_config - Set media type by net_device.set_config
2263 struct mii_phy *mii_phy = sis_priv->mii; in sis900_set_config()
2267 if ((map->port != (u_char)(-1)) && (map->port != dev->if_port)) { in sis900_set_config()
2268 /* we switch on the ifmap->port field. I couldn't find anything in sis900_set_config()
2274 switch(map->port){ in sis900_set_config()
2276 WRITE_ONCE(dev->if_port, map->port); in sis900_set_config()
2285 status = mdio_read(dev, mii_phy->phy_addr, MII_CONTROL); in sis900_set_config()
2291 mdio_write(dev, mii_phy->phy_addr, in sis900_set_config()
2297 WRITE_ONCE(dev->if_port, map->port); in sis900_set_config()
2308 status = mdio_read(dev, mii_phy->phy_addr, MII_CONTROL); in sis900_set_config()
2311 mdio_write(dev, mii_phy->phy_addr, in sis900_set_config()
2318 WRITE_ONCE(dev->if_port, map->port); in sis900_set_config()
2329 status = mdio_read(dev, mii_phy->phy_addr, MII_CONTROL); in sis900_set_config()
2330 mdio_write(dev, mii_phy->phy_addr, in sis900_set_config()
2340 return -EOPNOTSUPP; in sis900_set_config()
2343 return -EINVAL; in sis900_set_config()
2350 * sis900_mcast_bitnr - compute hashtable index
2373 * set_rx_mode - Set SiS900 receive mode
2384 void __iomem *ioaddr = sis_priv->ioaddr; in set_rx_mode()
2390 if((sis_priv->chipset_rev >= SIS635A_900_REV) || in set_rx_mode()
2391 (sis_priv->chipset_rev == SIS900B_900_REV)) in set_rx_mode()
2396 if (net_dev->flags & IFF_PROMISC) { in set_rx_mode()
2402 (net_dev->flags & IFF_ALLMULTI)) { in set_rx_mode()
2417 bit_nr = sis900_mcast_bitnr(ha->addr, in set_rx_mode()
2418 sis_priv->chipset_rev); in set_rx_mode()
2434 if (net_dev->flags & IFF_LOOPBACK) { in set_rx_mode()
2448 * sis900_reset - Reset sis900 MAC
2459 void __iomem *ioaddr = sis_priv->ioaddr; in sis900_reset()
2473 if (sis_priv->chipset_rev >= SIS635A_900_REV || in sis900_reset()
2474 sis_priv->chipset_rev == SIS900B_900_REV) in sis900_reset()
2481 * sis900_remove - Remove sis900 device
2494 while (sis_priv->first_mii) { in sis900_remove()
2495 struct mii_phy *phy = sis_priv->first_mii; in sis900_remove()
2497 sis_priv->first_mii = phy->next; in sis900_remove()
2501 dma_free_coherent(&pci_dev->dev, RX_TOTAL_SIZE, sis_priv->rx_ring, in sis900_remove()
2502 sis_priv->rx_ring_dma); in sis900_remove()
2503 dma_free_coherent(&pci_dev->dev, TX_TOTAL_SIZE, sis_priv->tx_ring, in sis900_remove()
2504 sis_priv->tx_ring_dma); in sis900_remove()
2505 pci_iounmap(pci_dev, sis_priv->ioaddr); in sis900_remove()
2513 void __iomem *ioaddr = sis_priv->ioaddr; in sis900_suspend()
2531 void __iomem *ioaddr = sis_priv->ioaddr; in sis900_resume()
2554 sis900_check_mode(net_dev, sis_priv->mii); in sis900_resume()