Lines Matching +full:wait +full:- +full:monitoring +full:- +full:ns

8  *  (C) 1997-1998 Caldera, Inc.
10 * (C) 1999-2001 Torben Mathiasen
39 #include <linux/dma-mapping.h>
63 MODULE_PARM_DESC(aui, "ThunderLAN use AUI port(s) (0-1)");
65 "ThunderLAN duplex setting(s) (0-default, 1-half, 2-full)");
85 "10BaseT-HD", "10BaseT-FD", "100baseTx-HD",
86 "100BaseTx-FD", "100BaseT4", NULL
97 { "Compaq Integrated NetFlex-3/P", TLAN_ADAPTER_NONE, 0x83 },
98 { "Compaq NetFlex-3/P",
100 { "Compaq NetFlex-3/P", TLAN_ADAPTER_NONE, 0x83 },
107 { "Olicom OC-2183/2185", TLAN_ADAPTER_USE_INTERN_10, 0x83 },
108 { "Olicom OC-2325", TLAN_ADAPTER_ACTIVITY_LED |
110 { "Olicom OC-2326", TLAN_ADAPTER_ACTIVITY_LED |
114 { "Compaq NetFlex-3/E",
117 { "Compaq NetFlex-3/E",
222 tag->buffer[9].address = addr; in tlan_store_skb()
223 tag->buffer[8].address = upper_32_bits(addr); in tlan_store_skb()
231 addr = tag->buffer[9].address; in tlan_get_skb()
232 addr |= ((unsigned long) tag->buffer[8].address << 16) << 16; in tlan_get_skb()
254 spin_lock_irqsave(&priv->lock, flags); in tlan_set_timer()
255 if (priv->timer.function != NULL && in tlan_set_timer()
256 priv->timer_type != TLAN_TIMER_ACTIVITY) { in tlan_set_timer()
257 spin_unlock_irqrestore(&priv->lock, flags); in tlan_set_timer()
260 priv->timer.function = tlan_timer; in tlan_set_timer()
261 spin_unlock_irqrestore(&priv->lock, flags); in tlan_set_timer()
263 priv->timer_set_at = jiffies; in tlan_set_timer()
264 priv->timer_type = type; in tlan_set_timer()
265 mod_timer(&priv->timer, jiffies + ticks); in tlan_set_timer()
307 if (priv->dma_storage) { in tlan_remove_one()
308 dma_free_coherent(&priv->pci_dev->dev, priv->dma_size, in tlan_remove_one()
309 priv->dma_storage, priv->dma_storage_dma); in tlan_remove_one()
316 cancel_work_sync(&priv->tlan_tqueue); in tlan_remove_one()
335 del_timer_sync(&priv->media_timer); in tlan_stop()
337 outl(TLAN_HC_AD_RST, dev->base_addr + TLAN_HOST_CMD); in tlan_stop()
340 if (priv->timer.function != NULL) { in tlan_stop()
341 del_timer_sync(&priv->timer); in tlan_stop()
342 priv->timer.function = NULL; in tlan_stop()
381 int rc = -ENODEV; in tlan_probe()
404 rc = -ENODEV; in tlan_probe()
419 return tlan_probe1(pdev, -1, -1, 0, ent); in tlan_init_one()
449 int reg, rc = -ENODEV; in tlan_probe1()
467 rc = -ENOMEM; in tlan_probe1()
470 SET_NETDEV_DEV(dev, &pdev->dev); in tlan_probe1()
474 priv->pci_dev = pdev; in tlan_probe1()
475 priv->dev = dev; in tlan_probe1()
481 priv->adapter = &board_info[ent->driver_data]; in tlan_probe1()
483 rc = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)); in tlan_probe1()
500 rc = -EIO; in tlan_probe1()
504 dev->base_addr = pci_io_base; in tlan_probe1()
505 dev->irq = pdev->irq; in tlan_probe1()
506 priv->adapter_rev = pdev->revision; in tlan_probe1()
515 priv->adapter = &board_info[13]; /* NetFlex-3/E */ in tlan_probe1()
516 priv->adapter_rev = 23; /* TLAN 2.3 */ in tlan_probe1()
518 priv->adapter = &board_info[14]; in tlan_probe1()
519 priv->adapter_rev = 10; /* TLAN 1.0 */ in tlan_probe1()
521 dev->base_addr = ioaddr; in tlan_probe1()
522 dev->irq = irq; in tlan_probe1()
526 if (dev->mem_start) { in tlan_probe1()
527 priv->aui = dev->mem_start & 0x01; in tlan_probe1()
528 priv->duplex = ((dev->mem_start & 0x06) == 0x06) ? 0 in tlan_probe1()
529 : (dev->mem_start & 0x06) >> 1; in tlan_probe1()
530 priv->speed = ((dev->mem_start & 0x18) == 0x18) ? 0 in tlan_probe1()
531 : (dev->mem_start & 0x18) >> 3; in tlan_probe1()
533 if (priv->speed == 0x1) in tlan_probe1()
534 priv->speed = TLAN_SPEED_10; in tlan_probe1()
535 else if (priv->speed == 0x2) in tlan_probe1()
536 priv->speed = TLAN_SPEED_100; in tlan_probe1()
538 debug = priv->debug = dev->mem_end; in tlan_probe1()
540 priv->aui = aui[boards_found]; in tlan_probe1()
541 priv->speed = speed[boards_found]; in tlan_probe1()
542 priv->duplex = duplex[boards_found]; in tlan_probe1()
543 priv->debug = debug; in tlan_probe1()
548 INIT_WORK(&priv->tlan_tqueue, tlan_tx_timeout_work); in tlan_probe1()
550 spin_lock_init(&priv->lock); in tlan_probe1()
572 priv->next_device = tlan_eisa_devices; in tlan_probe1()
578 (int)dev->irq, in tlan_probe1()
579 (int)dev->base_addr, in tlan_probe1()
580 priv->adapter->device_label, in tlan_probe1()
581 priv->adapter_rev); in tlan_probe1()
585 dma_free_coherent(&priv->pci_dev->dev, priv->dma_size, in tlan_probe1()
586 priv->dma_storage, priv->dma_storage_dma); in tlan_probe1()
609 if (priv->dma_storage) { in tlan_eisa_cleanup()
610 dma_free_coherent(&priv->pci_dev->dev, priv->dma_size, in tlan_eisa_cleanup()
611 priv->dma_storage, in tlan_eisa_cleanup()
612 priv->dma_storage_dma); in tlan_eisa_cleanup()
614 release_region(dev->base_addr, 0x10); in tlan_eisa_cleanup()
616 tlan_eisa_devices = priv->next_device; in tlan_eisa_cleanup()
618 tlan_have_eisa--; in tlan_eisa_cleanup()
739 disable_irq(dev->irq); in tlan_poll()
740 tlan_handle_interrupt(dev->irq, dev); in tlan_poll()
741 enable_irq(dev->irq); in tlan_poll()
765 strscpy(info->driver, KBUILD_MODNAME, sizeof(info->driver)); in tlan_get_drvinfo()
766 if (priv->pci_dev) in tlan_get_drvinfo()
767 strscpy(info->bus_info, pci_name(priv->pci_dev), in tlan_get_drvinfo()
768 sizeof(info->bus_info)); in tlan_get_drvinfo()
770 strscpy(info->bus_info, "EISA", sizeof(info->bus_info)); in tlan_get_drvinfo()
785 return -EIO; in tlan_get_eeprom()
826 priv->dma_storage = dma_alloc_coherent(&priv->pci_dev->dev, dma_size, in tlan_init()
827 &priv->dma_storage_dma, GFP_KERNEL); in tlan_init()
828 priv->dma_size = dma_size; in tlan_init()
830 if (priv->dma_storage == NULL) { in tlan_init()
832 dev->name); in tlan_init()
833 return -ENOMEM; in tlan_init()
835 priv->rx_list = (struct tlan_list *) in tlan_init()
836 ALIGN((unsigned long)priv->dma_storage, 8); in tlan_init()
837 priv->rx_list_dma = ALIGN(priv->dma_storage_dma, 8); in tlan_init()
838 priv->tx_list = priv->rx_list + TLAN_NUM_RX_LISTS; in tlan_init()
839 priv->tx_list_dma = in tlan_init()
840 priv->rx_list_dma + sizeof(struct tlan_list)*TLAN_NUM_RX_LISTS; in tlan_init()
845 (u8) priv->adapter->addr_ofs + i, in tlan_init()
849 dev->name, err); in tlan_init()
851 /* Olicom OC-2325/OC-2326 have the address byte-swapped */ in tlan_init()
852 if (priv->adapter->addr_ofs == 0xf8) { in tlan_init()
864 dev->netdev_ops = &tlan_netdev_ops; in tlan_init()
865 dev->ethtool_ops = &tlan_ethtool_ops; in tlan_init()
866 dev->watchdog_timeo = TX_TIMEOUT; in tlan_init()
897 priv->tlan_rev = tlan_dio_read8(dev->base_addr, TLAN_DEF_REVISION); in tlan_open()
898 err = request_irq(dev->irq, tlan_handle_interrupt, IRQF_SHARED, in tlan_open()
899 dev->name, dev); in tlan_open()
903 dev->irq); in tlan_open()
907 timer_setup(&priv->timer, NULL, 0); in tlan_open()
908 timer_setup(&priv->media_timer, tlan_phy_monitor, 0); in tlan_open()
913 dev->name, priv->tlan_rev); in tlan_open()
940 u32 phy = priv->phy[priv->phy_num]; in tlan_ioctl()
942 if (!priv->phy_online) in tlan_ioctl()
943 return -EAGAIN; in tlan_ioctl()
947 data->phy_id = phy; in tlan_ioctl()
952 tlan_mii_read_reg(dev, data->phy_id & 0x1f, in tlan_ioctl()
953 data->reg_num & 0x1f, &data->val_out); in tlan_ioctl()
958 tlan_mii_write_reg(dev, data->phy_id & 0x1f, in tlan_ioctl()
959 data->reg_num & 0x1f, data->val_in); in tlan_ioctl()
962 return -EOPNOTSUPP; in tlan_ioctl()
981 TLAN_DBG(TLAN_DEBUG_GNRL, "%s: Transmit timed out.\n", dev->name); in tlan_tx_timeout()
1009 tlan_tx_timeout(priv->dev, UINT_MAX); in tlan_tx_timeout_work()
1018 * 0 on success, non-zero on failure.
1043 if (!priv->phy_online) { in tlan_start_tx()
1045 dev->name); in tlan_start_tx()
1052 txlen = max(skb->len, (unsigned int)TLAN_MIN_FRAME_SIZE); in tlan_start_tx()
1054 tail_list = priv->tx_list + priv->tx_tail; in tlan_start_tx()
1056 priv->tx_list_dma + sizeof(struct tlan_list)*priv->tx_tail; in tlan_start_tx()
1058 if (tail_list->c_stat != TLAN_CSTAT_UNUSED) { in tlan_start_tx()
1061 dev->name, priv->tx_head, priv->tx_tail); in tlan_start_tx()
1063 priv->tx_busy_count++; in tlan_start_tx()
1067 tail_list->forward = 0; in tlan_start_tx()
1069 tail_list->buffer[0].address = dma_map_single(&priv->pci_dev->dev, in tlan_start_tx()
1070 skb->data, txlen, in tlan_start_tx()
1074 tail_list->frame_size = (u16) txlen; in tlan_start_tx()
1075 tail_list->buffer[0].count = TLAN_LAST_BUFFER | (u32) txlen; in tlan_start_tx()
1076 tail_list->buffer[1].count = 0; in tlan_start_tx()
1077 tail_list->buffer[1].address = 0; in tlan_start_tx()
1079 spin_lock_irqsave(&priv->lock, flags); in tlan_start_tx()
1080 tail_list->c_stat = TLAN_CSTAT_READY; in tlan_start_tx()
1081 if (!priv->tx_in_progress) { in tlan_start_tx()
1082 priv->tx_in_progress = 1; in tlan_start_tx()
1085 priv->tx_tail); in tlan_start_tx()
1086 outl(tail_list_phys, dev->base_addr + TLAN_CH_PARM); in tlan_start_tx()
1087 outl(TLAN_HC_GO, dev->base_addr + TLAN_HOST_CMD); in tlan_start_tx()
1091 priv->tx_tail); in tlan_start_tx()
1092 if (priv->tx_tail == 0) { in tlan_start_tx()
1093 (priv->tx_list + (TLAN_NUM_TX_LISTS - 1))->forward in tlan_start_tx()
1096 (priv->tx_list + (priv->tx_tail - 1))->forward in tlan_start_tx()
1100 spin_unlock_irqrestore(&priv->lock, flags); in tlan_start_tx()
1102 CIRC_INC(priv->tx_tail, TLAN_NUM_TX_LISTS); in tlan_start_tx()
1127 * re-enabling adapter interrupts.
1138 spin_lock(&priv->lock); in tlan_handle_interrupt()
1140 host_int = inw(dev->base_addr + TLAN_HOST_INT); in tlan_handle_interrupt()
1146 outw(host_int, dev->base_addr + TLAN_HOST_INT); in tlan_handle_interrupt()
1151 outl(host_cmd, dev->base_addr + TLAN_HOST_CMD); in tlan_handle_interrupt()
1155 spin_unlock(&priv->lock); in tlan_handle_interrupt()
1182 free_irq(dev->irq, dev); in tlan_close()
1184 TLAN_DBG(TLAN_DEBUG_GNRL, "Device %s closed.\n", dev->name); in tlan_close()
1216 TLAN_DBG(TLAN_DEBUG_RX, "RECEIVE: %s EOC count = %d\n", dev->name, in tlan_get_stats()
1217 priv->rx_eoc_count); in tlan_get_stats()
1218 TLAN_DBG(TLAN_DEBUG_TX, "TRANSMIT: %s Busy count = %d\n", dev->name, in tlan_get_stats()
1219 priv->tx_busy_count); in tlan_get_stats()
1221 tlan_print_dio(dev->base_addr); in tlan_get_stats()
1226 tlan_print_list(priv->rx_list + i, "RX", i); in tlan_get_stats()
1228 tlan_print_list(priv->tx_list + i, "TX", i); in tlan_get_stats()
1231 return &dev->stats; in tlan_get_stats()
1253 * stored in AREG_1-3, and the rest are selected via the
1267 if (dev->flags & IFF_PROMISC) { in tlan_set_multicast_list()
1268 tmp = tlan_dio_read8(dev->base_addr, TLAN_NET_CMD); in tlan_set_multicast_list()
1269 tlan_dio_write8(dev->base_addr, in tlan_set_multicast_list()
1272 tmp = tlan_dio_read8(dev->base_addr, TLAN_NET_CMD); in tlan_set_multicast_list()
1273 tlan_dio_write8(dev->base_addr, in tlan_set_multicast_list()
1275 if (dev->flags & IFF_ALLMULTI) { in tlan_set_multicast_list()
1278 tlan_dio_write32(dev->base_addr, TLAN_HASH_1, in tlan_set_multicast_list()
1280 tlan_dio_write32(dev->base_addr, TLAN_HASH_2, in tlan_set_multicast_list()
1287 (char *) &ha->addr); in tlan_set_multicast_list()
1290 tlan_hash_func((u8 *)&ha->addr); in tlan_set_multicast_list()
1294 hash2 |= (1 << (offset - 32)); in tlan_set_multicast_list()
1300 tlan_dio_write32(dev->base_addr, TLAN_HASH_1, hash1); in tlan_set_multicast_list()
1301 tlan_dio_write32(dev->base_addr, TLAN_HASH_2, hash2); in tlan_set_multicast_list()
1357 priv->tx_head, priv->tx_tail); in tlan_handle_tx_eof()
1358 head_list = priv->tx_list + priv->tx_head; in tlan_handle_tx_eof()
1360 while (((tmp_c_stat = head_list->c_stat) & TLAN_CSTAT_FRM_CMP) in tlan_handle_tx_eof()
1365 dma_unmap_single(&priv->pci_dev->dev, in tlan_handle_tx_eof()
1366 head_list->buffer[0].address, in tlan_handle_tx_eof()
1367 max(skb->len, (unsigned int)TLAN_MIN_FRAME_SIZE), in tlan_handle_tx_eof()
1370 head_list->buffer[8].address = 0; in tlan_handle_tx_eof()
1371 head_list->buffer[9].address = 0; in tlan_handle_tx_eof()
1376 dev->stats.tx_bytes += head_list->frame_size; in tlan_handle_tx_eof()
1378 head_list->c_stat = TLAN_CSTAT_UNUSED; in tlan_handle_tx_eof()
1380 CIRC_INC(priv->tx_head, TLAN_NUM_TX_LISTS); in tlan_handle_tx_eof()
1381 head_list = priv->tx_list + priv->tx_head; in tlan_handle_tx_eof()
1391 priv->tx_head, priv->tx_tail); in tlan_handle_tx_eof()
1392 head_list = priv->tx_list + priv->tx_head; in tlan_handle_tx_eof()
1393 head_list_phys = priv->tx_list_dma in tlan_handle_tx_eof()
1394 + sizeof(struct tlan_list)*priv->tx_head; in tlan_handle_tx_eof()
1395 if ((head_list->c_stat & TLAN_CSTAT_READY) in tlan_handle_tx_eof()
1397 outl(head_list_phys, dev->base_addr + TLAN_CH_PARM); in tlan_handle_tx_eof()
1400 priv->tx_in_progress = 0; in tlan_handle_tx_eof()
1404 if (priv->adapter->flags & TLAN_ADAPTER_ACTIVITY_LED) { in tlan_handle_tx_eof()
1405 tlan_dio_write8(dev->base_addr, in tlan_handle_tx_eof()
1407 if (priv->timer.function == NULL) { in tlan_handle_tx_eof()
1408 priv->timer.function = tlan_timer; in tlan_handle_tx_eof()
1409 priv->timer.expires = jiffies + TLAN_TIMER_ACT_DELAY; in tlan_handle_tx_eof()
1410 priv->timer_set_at = jiffies; in tlan_handle_tx_eof()
1411 priv->timer_type = TLAN_TIMER_ACTIVITY; in tlan_handle_tx_eof()
1412 add_timer(&priv->timer); in tlan_handle_tx_eof()
1413 } else if (priv->timer_type == TLAN_TIMER_ACTIVITY) { in tlan_handle_tx_eof()
1414 priv->timer_set_at = jiffies; in tlan_handle_tx_eof()
1490 priv->rx_head, priv->rx_tail); in tlan_handle_rx_eof()
1491 head_list = priv->rx_list + priv->rx_head; in tlan_handle_rx_eof()
1493 priv->rx_list_dma + sizeof(struct tlan_list)*priv->rx_head; in tlan_handle_rx_eof()
1495 while (((tmp_c_stat = head_list->c_stat) & TLAN_CSTAT_FRM_CMP) in tlan_handle_rx_eof()
1497 dma_addr_t frame_dma = head_list->buffer[0].address; in tlan_handle_rx_eof()
1498 u32 frame_size = head_list->frame_size; in tlan_handle_rx_eof()
1511 dma_unmap_single(&priv->pci_dev->dev, frame_dma, in tlan_handle_rx_eof()
1515 dev->stats.rx_bytes += frame_size; in tlan_handle_rx_eof()
1517 skb->protocol = eth_type_trans(skb, dev); in tlan_handle_rx_eof()
1520 head_list->buffer[0].address = in tlan_handle_rx_eof()
1521 dma_map_single(&priv->pci_dev->dev, new_skb->data, in tlan_handle_rx_eof()
1526 head_list->forward = 0; in tlan_handle_rx_eof()
1527 head_list->c_stat = 0; in tlan_handle_rx_eof()
1528 tail_list = priv->rx_list + priv->rx_tail; in tlan_handle_rx_eof()
1529 tail_list->forward = head_list_phys; in tlan_handle_rx_eof()
1531 CIRC_INC(priv->rx_head, TLAN_NUM_RX_LISTS); in tlan_handle_rx_eof()
1532 CIRC_INC(priv->rx_tail, TLAN_NUM_RX_LISTS); in tlan_handle_rx_eof()
1533 head_list = priv->rx_list + priv->rx_head; in tlan_handle_rx_eof()
1534 head_list_phys = priv->rx_list_dma in tlan_handle_rx_eof()
1535 + sizeof(struct tlan_list)*priv->rx_head; in tlan_handle_rx_eof()
1546 priv->rx_head, priv->rx_tail); in tlan_handle_rx_eof()
1547 head_list = priv->rx_list + priv->rx_head; in tlan_handle_rx_eof()
1548 head_list_phys = priv->rx_list_dma in tlan_handle_rx_eof()
1549 + sizeof(struct tlan_list)*priv->rx_head; in tlan_handle_rx_eof()
1550 outl(head_list_phys, dev->base_addr + TLAN_CH_PARM); in tlan_handle_rx_eof()
1552 priv->rx_eoc_count++; in tlan_handle_rx_eof()
1555 if (priv->adapter->flags & TLAN_ADAPTER_ACTIVITY_LED) { in tlan_handle_rx_eof()
1556 tlan_dio_write8(dev->base_addr, in tlan_handle_rx_eof()
1558 if (priv->timer.function == NULL) { in tlan_handle_rx_eof()
1559 priv->timer.function = tlan_timer; in tlan_handle_rx_eof()
1560 priv->timer.expires = jiffies + TLAN_TIMER_ACT_DELAY; in tlan_handle_rx_eof()
1561 priv->timer_set_at = jiffies; in tlan_handle_rx_eof()
1562 priv->timer_type = TLAN_TIMER_ACTIVITY; in tlan_handle_rx_eof()
1563 add_timer(&priv->timer); in tlan_handle_rx_eof()
1564 } else if (priv->timer_type == TLAN_TIMER_ACTIVITY) { in tlan_handle_rx_eof()
1565 priv->timer_set_at = jiffies; in tlan_handle_rx_eof()
1630 if (priv->tlan_rev < 0x30) { in tlan_handle_tx_eoc()
1632 "TRANSMIT: handling TX EOC (Head=%d Tail=%d) -- IRQ\n", in tlan_handle_tx_eoc()
1633 priv->tx_head, priv->tx_tail); in tlan_handle_tx_eoc()
1634 head_list = priv->tx_list + priv->tx_head; in tlan_handle_tx_eoc()
1635 head_list_phys = priv->tx_list_dma in tlan_handle_tx_eoc()
1636 + sizeof(struct tlan_list)*priv->tx_head; in tlan_handle_tx_eoc()
1637 if ((head_list->c_stat & TLAN_CSTAT_READY) in tlan_handle_tx_eoc()
1640 outl(head_list_phys, dev->base_addr + TLAN_CH_PARM); in tlan_handle_tx_eoc()
1643 priv->tx_in_progress = 0; in tlan_handle_tx_eoc()
1687 error = inl(dev->base_addr + TLAN_CH_PARM); in tlan_handle_status_check()
1690 outl(TLAN_HC_AD_RST, dev->base_addr + TLAN_HOST_CMD); in tlan_handle_status_check()
1692 schedule_work(&priv->tlan_tqueue); in tlan_handle_status_check()
1697 TLAN_DBG(TLAN_DEBUG_GNRL, "%s: Status Check\n", dev->name); in tlan_handle_status_check()
1698 phy = priv->phy[priv->phy_num]; in tlan_handle_status_check()
1700 net_sts = tlan_dio_read8(dev->base_addr, TLAN_NET_STS); in tlan_handle_status_check()
1702 tlan_dio_write8(dev->base_addr, TLAN_NET_STS, net_sts); in tlan_handle_status_check()
1704 dev->name, (unsigned) net_sts); in tlan_handle_status_check()
1706 if ((net_sts & TLAN_NET_STS_MIRQ) && (priv->phy_num == 0)) { in tlan_handle_status_check()
1749 * pre-3.0, process EOC interrupts normally.
1759 if (priv->tlan_rev < 0x30) { in tlan_handle_rx_eoc()
1761 "RECEIVE: Handling RX EOC (head=%d tail=%d) -- IRQ\n", in tlan_handle_rx_eoc()
1762 priv->rx_head, priv->rx_tail); in tlan_handle_rx_eoc()
1763 head_list_phys = priv->rx_list_dma in tlan_handle_rx_eoc()
1764 + sizeof(struct tlan_list)*priv->rx_head; in tlan_handle_rx_eoc()
1765 outl(head_list_phys, dev->base_addr + TLAN_CH_PARM); in tlan_handle_rx_eoc()
1767 priv->rx_eoc_count++; in tlan_handle_rx_eoc()
1798 * - Autonegotiation requires being allowed about
1804 * PHYs were interrupt-capable like the internal
1806 * - The ACT LED, which shows adapter activity, is
1819 struct net_device *dev = priv->dev; in tlan_timer()
1823 priv->timer.function = NULL; in tlan_timer()
1825 switch (priv->timer_type) { in tlan_timer()
1845 spin_lock_irqsave(&priv->lock, flags); in tlan_timer()
1846 if (priv->timer.function == NULL) { in tlan_timer()
1847 elapsed = jiffies - priv->timer_set_at; in tlan_timer()
1849 tlan_dio_write8(dev->base_addr, in tlan_timer()
1852 priv->timer.expires = priv->timer_set_at in tlan_timer()
1854 spin_unlock_irqrestore(&priv->lock, flags); in tlan_timer()
1855 add_timer(&priv->timer); in tlan_timer()
1859 spin_unlock_irqrestore(&priv->lock, flags); in tlan_timer()
1899 priv->tx_head = 0; in tlan_reset_lists()
1900 priv->tx_tail = 0; in tlan_reset_lists()
1902 list = priv->tx_list + i; in tlan_reset_lists()
1903 list->c_stat = TLAN_CSTAT_UNUSED; in tlan_reset_lists()
1904 list->buffer[0].address = 0; in tlan_reset_lists()
1905 list->buffer[2].count = 0; in tlan_reset_lists()
1906 list->buffer[2].address = 0; in tlan_reset_lists()
1907 list->buffer[8].address = 0; in tlan_reset_lists()
1908 list->buffer[9].address = 0; in tlan_reset_lists()
1911 priv->rx_head = 0; in tlan_reset_lists()
1912 priv->rx_tail = TLAN_NUM_RX_LISTS - 1; in tlan_reset_lists()
1914 list = priv->rx_list + i; in tlan_reset_lists()
1915 list_phys = priv->rx_list_dma + sizeof(struct tlan_list)*i; in tlan_reset_lists()
1916 list->c_stat = TLAN_CSTAT_READY; in tlan_reset_lists()
1917 list->frame_size = TLAN_MAX_FRAME_SIZE; in tlan_reset_lists()
1918 list->buffer[0].count = TLAN_MAX_FRAME_SIZE | TLAN_LAST_BUFFER; in tlan_reset_lists()
1923 list->buffer[0].address = dma_map_single(&priv->pci_dev->dev, in tlan_reset_lists()
1924 skb->data, in tlan_reset_lists()
1928 list->buffer[1].count = 0; in tlan_reset_lists()
1929 list->buffer[1].address = 0; in tlan_reset_lists()
1930 list->forward = list_phys + sizeof(struct tlan_list); in tlan_reset_lists()
1935 tlan_store_skb(priv->rx_list + i, NULL); in tlan_reset_lists()
1938 list->forward = 0; in tlan_reset_lists()
1951 list = priv->tx_list + i; in tlan_free_lists()
1954 dma_unmap_single(&priv->pci_dev->dev, in tlan_free_lists()
1955 list->buffer[0].address, in tlan_free_lists()
1956 max(skb->len, (unsigned int)TLAN_MIN_FRAME_SIZE), in tlan_free_lists()
1959 list->buffer[8].address = 0; in tlan_free_lists()
1960 list->buffer[9].address = 0; in tlan_free_lists()
1965 list = priv->rx_list + i; in tlan_free_lists()
1968 dma_unmap_single(&priv->pci_dev->dev, in tlan_free_lists()
1969 list->buffer[0].address, in tlan_free_lists()
1972 list->buffer[8].address = 0; in tlan_free_lists()
1973 list->buffer[9].address = 0; in tlan_free_lists()
2036 pr_info(" Forward = 0x%08x\n", list->forward); in tlan_print_list()
2037 pr_info(" CSTAT = 0x%04hx\n", list->c_stat); in tlan_print_list()
2038 pr_info(" Frame Size = 0x%04hx\n", list->frame_size); in tlan_print_list()
2042 i, list->buffer[i].count, list->buffer[i].address); in tlan_print_list()
2076 outw(TLAN_GOOD_TX_FRMS, dev->base_addr + TLAN_DIO_ADR); in tlan_read_and_clear_stats()
2077 tx_good = inb(dev->base_addr + TLAN_DIO_DATA); in tlan_read_and_clear_stats()
2078 tx_good += inb(dev->base_addr + TLAN_DIO_DATA + 1) << 8; in tlan_read_and_clear_stats()
2079 tx_good += inb(dev->base_addr + TLAN_DIO_DATA + 2) << 16; in tlan_read_and_clear_stats()
2080 tx_under = inb(dev->base_addr + TLAN_DIO_DATA + 3); in tlan_read_and_clear_stats()
2082 outw(TLAN_GOOD_RX_FRMS, dev->base_addr + TLAN_DIO_ADR); in tlan_read_and_clear_stats()
2083 rx_good = inb(dev->base_addr + TLAN_DIO_DATA); in tlan_read_and_clear_stats()
2084 rx_good += inb(dev->base_addr + TLAN_DIO_DATA + 1) << 8; in tlan_read_and_clear_stats()
2085 rx_good += inb(dev->base_addr + TLAN_DIO_DATA + 2) << 16; in tlan_read_and_clear_stats()
2086 rx_over = inb(dev->base_addr + TLAN_DIO_DATA + 3); in tlan_read_and_clear_stats()
2088 outw(TLAN_DEFERRED_TX, dev->base_addr + TLAN_DIO_ADR); in tlan_read_and_clear_stats()
2089 def_tx = inb(dev->base_addr + TLAN_DIO_DATA); in tlan_read_and_clear_stats()
2090 def_tx += inb(dev->base_addr + TLAN_DIO_DATA + 1) << 8; in tlan_read_and_clear_stats()
2091 crc = inb(dev->base_addr + TLAN_DIO_DATA + 2); in tlan_read_and_clear_stats()
2092 code = inb(dev->base_addr + TLAN_DIO_DATA + 3); in tlan_read_and_clear_stats()
2094 outw(TLAN_MULTICOL_FRMS, dev->base_addr + TLAN_DIO_ADR); in tlan_read_and_clear_stats()
2095 multi_col = inb(dev->base_addr + TLAN_DIO_DATA); in tlan_read_and_clear_stats()
2096 multi_col += inb(dev->base_addr + TLAN_DIO_DATA + 1) << 8; in tlan_read_and_clear_stats()
2097 single_col = inb(dev->base_addr + TLAN_DIO_DATA + 2); in tlan_read_and_clear_stats()
2098 single_col += inb(dev->base_addr + TLAN_DIO_DATA + 3) << 8; in tlan_read_and_clear_stats()
2100 outw(TLAN_EXCESSCOL_FRMS, dev->base_addr + TLAN_DIO_ADR); in tlan_read_and_clear_stats()
2101 excess_col = inb(dev->base_addr + TLAN_DIO_DATA); in tlan_read_and_clear_stats()
2102 late_col = inb(dev->base_addr + TLAN_DIO_DATA + 1); in tlan_read_and_clear_stats()
2103 loss = inb(dev->base_addr + TLAN_DIO_DATA + 2); in tlan_read_and_clear_stats()
2106 dev->stats.rx_packets += rx_good; in tlan_read_and_clear_stats()
2107 dev->stats.rx_errors += rx_over + crc + code; in tlan_read_and_clear_stats()
2108 dev->stats.tx_packets += tx_good; in tlan_read_and_clear_stats()
2109 dev->stats.tx_errors += tx_under + loss; in tlan_read_and_clear_stats()
2110 dev->stats.collisions += multi_col in tlan_read_and_clear_stats()
2113 dev->stats.rx_over_errors += rx_over; in tlan_read_and_clear_stats()
2114 dev->stats.rx_crc_errors += crc; in tlan_read_and_clear_stats()
2115 dev->stats.rx_frame_errors += code; in tlan_read_and_clear_stats()
2117 dev->stats.tx_aborted_errors += tx_under; in tlan_read_and_clear_stats()
2118 dev->stats.tx_carrier_errors += loss; in tlan_read_and_clear_stats()
2136 * device. See Chap. 3, pp. 9-10 of the "ThunderLAN
2152 priv->tlan_full_duplex = false; in tlan_reset_adapter()
2153 priv->phy_online = 0; in tlan_reset_adapter()
2158 data = inl(dev->base_addr + TLAN_HOST_CMD); in tlan_reset_adapter()
2160 outl(data, dev->base_addr + TLAN_HOST_CMD); in tlan_reset_adapter()
2166 data = inl(dev->base_addr + TLAN_HOST_CMD); in tlan_reset_adapter()
2168 outl(data, dev->base_addr + TLAN_HOST_CMD); in tlan_reset_adapter()
2173 tlan_dio_write32(dev->base_addr, (u16) i, 0); in tlan_reset_adapter()
2178 tlan_dio_write16(dev->base_addr, TLAN_NET_CONFIG, (u16) data); in tlan_reset_adapter()
2182 outl(TLAN_HC_LD_TMR | 0x3f, dev->base_addr + TLAN_HOST_CMD); in tlan_reset_adapter()
2183 outl(TLAN_HC_LD_THR | 0x9, dev->base_addr + TLAN_HOST_CMD); in tlan_reset_adapter()
2187 outw(TLAN_NET_SIO, dev->base_addr + TLAN_DIO_ADR); in tlan_reset_adapter()
2188 addr = dev->base_addr + TLAN_DIO_DATA + TLAN_NET_SIO; in tlan_reset_adapter()
2193 if (priv->tlan_rev >= 0x30) { in tlan_reset_adapter()
2195 tlan_dio_write8(dev->base_addr, TLAN_INT_DIS, data8); in tlan_reset_adapter()
2200 if (priv->adapter->flags & TLAN_ADAPTER_BIT_RATE_PHY) { in tlan_reset_adapter()
2202 if (priv->aui == 1) { in tlan_reset_adapter()
2203 tlan_dio_write8(dev->base_addr, TLAN_ACOMMIT, 0x0a); in tlan_reset_adapter()
2204 } else if (priv->duplex == TLAN_DUPLEX_FULL) { in tlan_reset_adapter()
2205 tlan_dio_write8(dev->base_addr, TLAN_ACOMMIT, 0x00); in tlan_reset_adapter()
2206 priv->tlan_full_duplex = true; in tlan_reset_adapter()
2208 tlan_dio_write8(dev->base_addr, TLAN_ACOMMIT, 0x08); in tlan_reset_adapter()
2213 if (priv->phy_num == 0 || in tlan_reset_adapter()
2214 (priv->adapter->flags & TLAN_ADAPTER_USE_INTERN_10)) in tlan_reset_adapter()
2216 tlan_dio_write16(dev->base_addr, TLAN_NET_CONFIG, (u16) data); in tlan_reset_adapter()
2218 if (priv->adapter->flags & TLAN_ADAPTER_UNMANAGED_PHY) in tlan_reset_adapter()
2242 phy = priv->phy[priv->phy_num]; in tlan_finish_reset()
2245 if (priv->tlan_full_duplex) in tlan_finish_reset()
2247 tlan_dio_write8(dev->base_addr, TLAN_NET_CMD, data); in tlan_finish_reset()
2249 if (priv->phy_num == 0) in tlan_finish_reset()
2251 tlan_dio_write8(dev->base_addr, TLAN_NET_MASK, data); in tlan_finish_reset()
2252 tlan_dio_write16(dev->base_addr, TLAN_MAX_RX, ((1536)+7)&~7); in tlan_finish_reset()
2256 if ((priv->adapter->flags & TLAN_ADAPTER_UNMANAGED_PHY) || in tlan_finish_reset()
2257 (priv->aui)) { in tlan_finish_reset()
2274 "Link active, %s %uMbps %s-Duplex\n", in tlan_finish_reset()
2287 media[i-5]); in tlan_finish_reset()
2292 /* Enabling link beat monitoring */ in tlan_finish_reset()
2293 priv->media_timer.expires = jiffies + HZ; in tlan_finish_reset()
2294 add_timer(&priv->media_timer); in tlan_finish_reset()
2298 if (priv->phy_num == 0) { in tlan_finish_reset()
2302 sio = tlan_dio_read8(dev->base_addr, TLAN_NET_SIO); in tlan_finish_reset()
2304 tlan_dio_write8(dev->base_addr, TLAN_NET_SIO, sio); in tlan_finish_reset()
2308 tlan_set_mac(dev, 0, dev->dev_addr); in tlan_finish_reset()
2309 priv->phy_online = 1; in tlan_finish_reset()
2310 outb((TLAN_HC_INT_ON >> 8), dev->base_addr + TLAN_HOST_CMD + 1); in tlan_finish_reset()
2313 dev->base_addr + TLAN_HOST_CMD + 1); in tlan_finish_reset()
2314 outl(priv->rx_list_dma, dev->base_addr + TLAN_CH_PARM); in tlan_finish_reset()
2315 outl(TLAN_HC_GO | TLAN_HC_RT, dev->base_addr + TLAN_HOST_CMD); in tlan_finish_reset()
2316 tlan_dio_write8(dev->base_addr, TLAN_LED_REG, TLAN_LED_LINK); in tlan_finish_reset()
2338 * areg The AREG to set the address in (0 - 3).
2359 tlan_dio_write8(dev->base_addr, in tlan_set_mac()
2363 tlan_dio_write8(dev->base_addr, in tlan_set_mac()
2400 lockdep_assert_held(&priv->lock); in __tlan_phy_print()
2402 phy = priv->phy[priv->phy_num]; in __tlan_phy_print()
2404 if (priv->adapter->flags & TLAN_ADAPTER_UNMANAGED_PHY) { in __tlan_phy_print()
2428 spin_lock_irqsave(&priv->lock, flags); in tlan_phy_print()
2430 spin_unlock_irqrestore(&priv->lock, flags); in tlan_phy_print()
2459 if (priv->adapter->flags & TLAN_ADAPTER_UNMANAGED_PHY) { in tlan_phy_detect()
2460 priv->phy_num = 0xffff; in tlan_phy_detect()
2467 priv->phy[0] = TLAN_PHY_MAX_ADDR; in tlan_phy_detect()
2469 priv->phy[0] = TLAN_PHY_NONE; in tlan_phy_detect()
2471 priv->phy[1] = TLAN_PHY_NONE; in tlan_phy_detect()
2481 if ((priv->phy[1] == TLAN_PHY_NONE) && in tlan_phy_detect()
2483 priv->phy[1] = phy; in tlan_phy_detect()
2488 if (priv->phy[1] != TLAN_PHY_NONE) in tlan_phy_detect()
2489 priv->phy_num = 1; in tlan_phy_detect()
2490 else if (priv->phy[0] != TLAN_PHY_NONE) in tlan_phy_detect()
2491 priv->phy_num = 0; in tlan_phy_detect()
2505 TLAN_DBG(TLAN_DEBUG_GNRL, "%s: Powering down PHY(s).\n", dev->name); in tlan_phy_power_down()
2507 tlan_mii_sync(dev->base_addr); in tlan_phy_power_down()
2508 tlan_mii_write_reg(dev, priv->phy[priv->phy_num], MII_GEN_CTL, value); in tlan_phy_power_down()
2509 if ((priv->phy_num == 0) && (priv->phy[1] != TLAN_PHY_NONE)) { in tlan_phy_power_down()
2511 if (priv->adapter->flags & TLAN_ADAPTER_USE_INTERN_10) in tlan_phy_power_down()
2513 tlan_mii_sync(dev->base_addr); in tlan_phy_power_down()
2514 tlan_mii_write_reg(dev, priv->phy[1], MII_GEN_CTL, value); in tlan_phy_power_down()
2517 /* Wait for 50 ms and powerup in tlan_phy_power_down()
2533 TLAN_DBG(TLAN_DEBUG_GNRL, "%s: Powering up PHY.\n", dev->name); in tlan_phy_power_up()
2534 tlan_mii_sync(dev->base_addr); in tlan_phy_power_up()
2536 tlan_mii_write_reg(dev, priv->phy[priv->phy_num], MII_GEN_CTL, value); in tlan_phy_power_up()
2537 tlan_mii_sync(dev->base_addr); in tlan_phy_power_up()
2538 /* Wait for 500 ms and reset the in tlan_phy_power_up()
2556 phy = priv->phy[priv->phy_num]; in tlan_phy_reset()
2558 TLAN_DBG(TLAN_DEBUG_GNRL, "%s: Resetting PHY.\n", dev->name); in tlan_phy_reset()
2559 tlan_mii_sync(dev->base_addr); in tlan_phy_reset()
2570 /* Wait for 500 ms and initialize. in tlan_phy_reset()
2571 * I don't remember why I wait this long. in tlan_phy_reset()
2591 phy = priv->phy[priv->phy_num]; in tlan_phy_start_link()
2592 TLAN_DBG(TLAN_DEBUG_GNRL, "%s: Trying to activate link.\n", dev->name); in tlan_phy_start_link()
2597 (!priv->aui)) { in tlan_phy_start_link()
2599 if (priv->speed == TLAN_SPEED_10 && in tlan_phy_start_link()
2600 priv->duplex == TLAN_DUPLEX_HALF) { in tlan_phy_start_link()
2602 } else if (priv->speed == TLAN_SPEED_10 && in tlan_phy_start_link()
2603 priv->duplex == TLAN_DUPLEX_FULL) { in tlan_phy_start_link()
2604 priv->tlan_full_duplex = true; in tlan_phy_start_link()
2606 } else if (priv->speed == TLAN_SPEED_100 && in tlan_phy_start_link()
2607 priv->duplex == TLAN_DUPLEX_HALF) { in tlan_phy_start_link()
2609 } else if (priv->speed == TLAN_SPEED_100 && in tlan_phy_start_link()
2610 priv->duplex == TLAN_DUPLEX_FULL) { in tlan_phy_start_link()
2611 priv->tlan_full_duplex = true; in tlan_phy_start_link()
2615 /* Set Auto-Neg advertisement */ in tlan_phy_start_link()
2618 /* Enablee Auto-Neg */ in tlan_phy_start_link()
2620 /* Restart Auto-Neg */ in tlan_phy_start_link()
2622 /* Wait for 4 sec for autonegotiation in tlan_phy_start_link()
2634 if ((priv->aui) && (priv->phy_num != 0)) { in tlan_phy_start_link()
2635 priv->phy_num = 0; in tlan_phy_start_link()
2638 tlan_dio_write16(dev->base_addr, TLAN_NET_CONFIG, data); in tlan_phy_start_link()
2641 } else if (priv->phy_num == 0) { in tlan_phy_start_link()
2644 if (priv->aui) { in tlan_phy_start_link()
2648 if (priv->duplex == TLAN_DUPLEX_FULL) { in tlan_phy_start_link()
2650 priv->tlan_full_duplex = true; in tlan_phy_start_link()
2652 if (priv->speed == TLAN_SPEED_100) in tlan_phy_start_link()
2659 /* Wait for 2 sec to give the transceiver time in tlan_phy_start_link()
2678 phy = priv->phy[priv->phy_num]; in tlan_phy_finish_auto_neg()
2685 /* Wait for 8 sec to give the process in tlan_phy_finish_auto_neg()
2697 priv->tlan_full_duplex = true; in tlan_phy_finish_auto_neg()
2699 priv->tlan_full_duplex = true; in tlan_phy_finish_auto_neg()
2703 (priv->adapter->flags & TLAN_ADAPTER_USE_INTERN_10) && in tlan_phy_finish_auto_neg()
2704 (priv->phy_num != 0)) { in tlan_phy_finish_auto_neg()
2705 priv->phy_num = 0; in tlan_phy_finish_auto_neg()
2710 if (priv->phy_num == 0) { in tlan_phy_finish_auto_neg()
2711 if ((priv->duplex == TLAN_DUPLEX_FULL) || in tlan_phy_finish_auto_neg()
2715 netdev_info(dev, "Starting internal PHY with FULL-DUPLEX\n"); in tlan_phy_finish_auto_neg()
2719 netdev_info(dev, "Starting internal PHY with HALF-DUPLEX\n"); in tlan_phy_finish_auto_neg()
2723 /* Wait for 100 ms. No reason in partiticular. in tlan_phy_finish_auto_neg()
2750 struct net_device *dev = priv->dev; in tlan_phy_monitor()
2754 phy = priv->phy[priv->phy_num]; in tlan_phy_monitor()
2763 dev->name); in tlan_phy_monitor()
2764 tlan_dio_write8(dev->base_addr, TLAN_LED_REG, 0); in tlan_phy_monitor()
2766 if (priv->adapter->flags & TLAN_ADAPTER_USE_INTERN_10) { in tlan_phy_monitor()
2771 tlan_mii_sync(dev->base_addr); in tlan_phy_monitor()
2772 tlan_mii_write_reg(dev, priv->phy[0], in tlan_phy_monitor()
2775 priv->phy_num = 1; in tlan_phy_monitor()
2786 tlan_dio_write8(dev->base_addr, TLAN_LED_REG, TLAN_LED_LINK); in tlan_phy_monitor()
2788 dev->name); in tlan_phy_monitor()
2791 priv->media_timer.expires = jiffies + HZ; in tlan_phy_monitor()
2792 add_timer(&priv->media_timer); in tlan_phy_monitor()
2802 "ThunderLAN Programmer's Guide", pp. 15-24.
2827 * and then reads the 16-bit register value from the MII bus via
2842 lockdep_assert_held(&priv->lock); in __tlan_mii_read_reg()
2845 outw(TLAN_NET_SIO, dev->base_addr + TLAN_DIO_ADR); in __tlan_mii_read_reg()
2846 sio = dev->base_addr + TLAN_DIO_DATA + TLAN_NET_SIO; in __tlan_mii_read_reg()
2848 tlan_mii_sync(dev->base_addr); in __tlan_mii_read_reg()
2854 tlan_mii_send_data(dev->base_addr, 0x1, 2); /* start (01b) */ in __tlan_mii_read_reg()
2855 tlan_mii_send_data(dev->base_addr, 0x2, 2); /* read (10b) */ in __tlan_mii_read_reg()
2856 tlan_mii_send_data(dev->base_addr, phy, 5); /* device # */ in __tlan_mii_read_reg()
2857 tlan_mii_send_data(dev->base_addr, reg, 5); /* register # */ in __tlan_mii_read_reg()
2864 tlan_clear_bit(TLAN_NET_SIO_MCLK, sio); /* wait 300ns */ in __tlan_mii_read_reg()
2902 spin_lock_irqsave(&priv->lock, flags); in tlan_mii_read_reg()
2904 spin_unlock_irqrestore(&priv->lock, flags); in tlan_mii_read_reg()
2937 for (i = (0x1 << (num_bits - 1)); i; i >>= 1) { in tlan_mii_send_data()
3001 * writes the 16-bit register value from the MII configuration bus
3013 lockdep_assert_held(&priv->lock); in __tlan_mii_write_reg()
3015 outw(TLAN_NET_SIO, dev->base_addr + TLAN_DIO_ADR); in __tlan_mii_write_reg()
3016 sio = dev->base_addr + TLAN_DIO_DATA + TLAN_NET_SIO; in __tlan_mii_write_reg()
3018 tlan_mii_sync(dev->base_addr); in __tlan_mii_write_reg()
3024 tlan_mii_send_data(dev->base_addr, 0x1, 2); /* start (01b) */ in __tlan_mii_write_reg()
3025 tlan_mii_send_data(dev->base_addr, 0x1, 2); /* write (01b) */ in __tlan_mii_write_reg()
3026 tlan_mii_send_data(dev->base_addr, phy, 5); /* device # */ in __tlan_mii_write_reg()
3027 tlan_mii_send_data(dev->base_addr, reg, 5); /* register # */ in __tlan_mii_write_reg()
3029 tlan_mii_send_data(dev->base_addr, 0x2, 2); /* send ACK */ in __tlan_mii_write_reg()
3030 tlan_mii_send_data(dev->base_addr, val, 16); /* send data */ in __tlan_mii_write_reg()
3046 spin_lock_irqsave(&priv->lock, flags); in tlan_mii_write_reg()
3048 spin_unlock_irqrestore(&priv->lock, flags); in tlan_mii_write_reg()
3249 spin_lock_irqsave(&priv->lock, flags); in tlan_ee_read_byte()
3251 tlan_ee_send_start(dev->base_addr); in tlan_ee_read_byte()
3252 err = tlan_ee_send_byte(dev->base_addr, 0xa0, TLAN_EEPROM_ACK); in tlan_ee_read_byte()
3257 err = tlan_ee_send_byte(dev->base_addr, ee_addr, TLAN_EEPROM_ACK); in tlan_ee_read_byte()
3262 tlan_ee_send_start(dev->base_addr); in tlan_ee_read_byte()
3263 err = tlan_ee_send_byte(dev->base_addr, 0xa1, TLAN_EEPROM_ACK); in tlan_ee_read_byte()
3268 tlan_ee_receive_byte(dev->base_addr, data, TLAN_EEPROM_STOP); in tlan_ee_read_byte()
3270 spin_unlock_irqrestore(&priv->lock, flags); in tlan_ee_read_byte()