diff options
author | Jeff Kirsher <jeffrey.t.kirsher@intel.com> | 2011-06-14 12:56:50 -0700 |
---|---|---|
committer | Jeff Kirsher <jeffrey.t.kirsher@intel.com> | 2011-08-12 03:41:10 -0700 |
commit | b544dbac41218fd015ac79455cfc1e57736e9b0c (patch) | |
tree | 6881af397456d0237dbb123ccb585a1a8086c166 /drivers/net/tlan.c | |
parent | de69a4f240a1d43bc6a587c836c5ce1c66e36f23 (diff) |
davinci*/tlan/cpmac: Move the Texas Instruments (TI) drivers
Move the Texas Instruments drivers to drivers/net/ethernet/ti/ and
make the necessary Kconfig and Makefile changes.
CC: Sriram <srk@ti.com>
CC: Vinay Hegde <vinay.hegde@ti.com>
CC: Cyril Chemparathy <cyril@ti.com>
CC: Samuel Chessman <chessman@tux.org>
CC: <torben.mathiasen@compaq.com>
CC: Eugene Konev <ejka@imfi.kspu.ru>
CC: Florian Fainelli <florian@openwrt.org>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Diffstat (limited to 'drivers/net/tlan.c')
-rw-r--r-- | drivers/net/tlan.c | 3258 |
1 files changed, 0 insertions, 3258 deletions
diff --git a/drivers/net/tlan.c b/drivers/net/tlan.c deleted file mode 100644 index 145871b3130..00000000000 --- a/drivers/net/tlan.c +++ /dev/null @@ -1,3258 +0,0 @@ -/******************************************************************************* - * - * Linux ThunderLAN Driver - * - * tlan.c - * by James Banks - * - * (C) 1997-1998 Caldera, Inc. - * (C) 1998 James Banks - * (C) 1999-2001 Torben Mathiasen - * (C) 2002 Samuel Chessman - * - * This software may be used and distributed according to the terms - * of the GNU General Public License, incorporated herein by reference. - * - ** Useful (if not required) reading: - * - * Texas Instruments, ThunderLAN Programmer's Guide, - * TI Literature Number SPWU013A - * available in PDF format from www.ti.com - * Level One, LXT901 and LXT970 Data Sheets - * available in PDF format from www.level1.com - * National Semiconductor, DP83840A Data Sheet - * available in PDF format from www.national.com - * Microchip Technology, 24C01A/02A/04A Data Sheet - * available in PDF format from www.microchip.com - * - ******************************************************************************/ - -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - -#include <linux/hardirq.h> -#include <linux/module.h> -#include <linux/init.h> -#include <linux/interrupt.h> -#include <linux/ioport.h> -#include <linux/eisa.h> -#include <linux/pci.h> -#include <linux/dma-mapping.h> -#include <linux/netdevice.h> -#include <linux/etherdevice.h> -#include <linux/delay.h> -#include <linux/spinlock.h> -#include <linux/workqueue.h> -#include <linux/mii.h> - -#include "tlan.h" - - -/* For removing EISA devices */ -static struct net_device *tlan_eisa_devices; - -static int tlan_devices_installed; - -/* Set speed, duplex and aui settings */ -static int aui[MAX_TLAN_BOARDS]; -static int duplex[MAX_TLAN_BOARDS]; -static int speed[MAX_TLAN_BOARDS]; -static int boards_found; -module_param_array(aui, int, NULL, 0); -module_param_array(duplex, int, NULL, 0); -module_param_array(speed, int, NULL, 0); -MODULE_PARM_DESC(aui, "ThunderLAN use AUI port(s) (0-1)"); -MODULE_PARM_DESC(duplex, - "ThunderLAN duplex setting(s) (0-default, 1-half, 2-full)"); -MODULE_PARM_DESC(speed, "ThunderLAN port speed setting(s) (0,10,100)"); - -MODULE_AUTHOR("Maintainer: Samuel Chessman <chessman@tux.org>"); -MODULE_DESCRIPTION("Driver for TI ThunderLAN based ethernet PCI adapters"); -MODULE_LICENSE("GPL"); - - -/* Define this to enable Link beat monitoring */ -#undef MONITOR - -/* Turn on debugging. See Documentation/networking/tlan.txt for details */ -static int debug; -module_param(debug, int, 0); -MODULE_PARM_DESC(debug, "ThunderLAN debug mask"); - -static const char tlan_signature[] = "TLAN"; -static const char tlan_banner[] = "ThunderLAN driver v1.17\n"; -static int tlan_have_pci; -static int tlan_have_eisa; - -static const char * const media[] = { - "10BaseT-HD", "10BaseT-FD", "100baseTx-HD", - "100BaseTx-FD", "100BaseT4", NULL -}; - -static struct board { - const char *device_label; - u32 flags; - u16 addr_ofs; -} board_info[] = { - { "Compaq Netelligent 10 T PCI UTP", TLAN_ADAPTER_ACTIVITY_LED, 0x83 }, - { "Compaq Netelligent 10/100 TX PCI UTP", - TLAN_ADAPTER_ACTIVITY_LED, 0x83 }, - { "Compaq Integrated NetFlex-3/P", TLAN_ADAPTER_NONE, 0x83 }, - { "Compaq NetFlex-3/P", - TLAN_ADAPTER_UNMANAGED_PHY | TLAN_ADAPTER_BIT_RATE_PHY, 0x83 }, - { "Compaq NetFlex-3/P", TLAN_ADAPTER_NONE, 0x83 }, - { "Compaq Netelligent Integrated 10/100 TX UTP", - TLAN_ADAPTER_ACTIVITY_LED, 0x83 }, - { "Compaq Netelligent Dual 10/100 TX PCI UTP", - TLAN_ADAPTER_NONE, 0x83 }, - { "Compaq Netelligent 10/100 TX Embedded UTP", - TLAN_ADAPTER_NONE, 0x83 }, - { "Olicom OC-2183/2185", TLAN_ADAPTER_USE_INTERN_10, 0x83 }, - { "Olicom OC-2325", TLAN_ADAPTER_UNMANAGED_PHY, 0xf8 }, - { "Olicom OC-2326", TLAN_ADAPTER_USE_INTERN_10, 0xf8 }, - { "Compaq Netelligent 10/100 TX UTP", TLAN_ADAPTER_ACTIVITY_LED, 0x83 }, - { "Compaq Netelligent 10 T/2 PCI UTP/coax", TLAN_ADAPTER_NONE, 0x83 }, - { "Compaq NetFlex-3/E", - TLAN_ADAPTER_ACTIVITY_LED | /* EISA card */ - TLAN_ADAPTER_UNMANAGED_PHY | TLAN_ADAPTER_BIT_RATE_PHY, 0x83 }, - { "Compaq NetFlex-3/E", - TLAN_ADAPTER_ACTIVITY_LED, 0x83 }, /* EISA card */ -}; - -static DEFINE_PCI_DEVICE_TABLE(tlan_pci_tbl) = { - { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_NETEL10, - PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, - { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_NETEL100, - PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1 }, - { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_NETFLEX3I, - PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2 }, - { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_THUNDER, - PCI_ANY_ID, PCI_ANY_ID, 0, 0, 3 }, - { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_NETFLEX3B, - PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4 }, - { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_NETEL100PI, - PCI_ANY_ID, PCI_ANY_ID, 0, 0, 5 }, - { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_NETEL100D, - PCI_ANY_ID, PCI_ANY_ID, 0, 0, 6 }, - { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_NETEL100I, - PCI_ANY_ID, PCI_ANY_ID, 0, 0, 7 }, - { PCI_VENDOR_ID_OLICOM, PCI_DEVICE_ID_OLICOM_OC2183, - PCI_ANY_ID, PCI_ANY_ID, 0, 0, 8 }, - { PCI_VENDOR_ID_OLICOM, PCI_DEVICE_ID_OLICOM_OC2325, - PCI_ANY_ID, PCI_ANY_ID, 0, 0, 9 }, - { PCI_VENDOR_ID_OLICOM, PCI_DEVICE_ID_OLICOM_OC2326, - PCI_ANY_ID, PCI_ANY_ID, 0, 0, 10 }, - { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_NETELLIGENT_10_100_WS_5100, - PCI_ANY_ID, PCI_ANY_ID, 0, 0, 11 }, - { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_NETELLIGENT_10_T2, - PCI_ANY_ID, PCI_ANY_ID, 0, 0, 12 }, - { 0,} -}; -MODULE_DEVICE_TABLE(pci, tlan_pci_tbl); - -static void tlan_eisa_probe(void); -static void tlan_eisa_cleanup(void); -static int tlan_init(struct net_device *); -static int tlan_open(struct net_device *dev); -static netdev_tx_t tlan_start_tx(struct sk_buff *, struct net_device *); -static irqreturn_t tlan_handle_interrupt(int, void *); -static int tlan_close(struct net_device *); -static struct net_device_stats *tlan_get_stats(struct net_device *); -static void tlan_set_multicast_list(struct net_device *); -static int tlan_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); -static int tlan_probe1(struct pci_dev *pdev, long ioaddr, - int irq, int rev, const struct pci_device_id *ent); -static void tlan_tx_timeout(struct net_device *dev); -static void tlan_tx_timeout_work(struct work_struct *work); -static int tlan_init_one(struct pci_dev *pdev, - const struct pci_device_id *ent); - -static u32 tlan_handle_tx_eof(struct net_device *, u16); -static u32 tlan_handle_stat_overflow(struct net_device *, u16); -static u32 tlan_handle_rx_eof(struct net_device *, u16); -static u32 tlan_handle_dummy(struct net_device *, u16); -static u32 tlan_handle_tx_eoc(struct net_device *, u16); -static u32 tlan_handle_status_check(struct net_device *, u16); -static u32 tlan_handle_rx_eoc(struct net_device *, u16); - -static void tlan_timer(unsigned long); - -static void tlan_reset_lists(struct net_device *); -static void tlan_free_lists(struct net_device *); -static void tlan_print_dio(u16); -static void tlan_print_list(struct tlan_list *, char *, int); -static void tlan_read_and_clear_stats(struct net_device *, int); -static void tlan_reset_adapter(struct net_device *); -static void tlan_finish_reset(struct net_device *); -static void tlan_set_mac(struct net_device *, int areg, char *mac); - -static void tlan_phy_print(struct net_device *); -static void tlan_phy_detect(struct net_device *); -static void tlan_phy_power_down(struct net_device *); -static void tlan_phy_power_up(struct net_device *); -static void tlan_phy_reset(struct net_device *); -static void tlan_phy_start_link(struct net_device *); -static void tlan_phy_finish_auto_neg(struct net_device *); -#ifdef MONITOR -static void tlan_phy_monitor(struct net_device *); -#endif - -/* - static int tlan_phy_nop(struct net_device *); - static int tlan_phy_internal_check(struct net_device *); - static int tlan_phy_internal_service(struct net_device *); - static int tlan_phy_dp83840a_check(struct net_device *); -*/ - -static bool tlan_mii_read_reg(struct net_device *, u16, u16, u16 *); -static void tlan_mii_send_data(u16, u32, unsigned); -static void tlan_mii_sync(u16); -static void tlan_mii_write_reg(struct net_device *, u16, u16, u16); - -static void tlan_ee_send_start(u16); -static int tlan_ee_send_byte(u16, u8, int); -static void tlan_ee_receive_byte(u16, u8 *, int); -static int tlan_ee_read_byte(struct net_device *, u8, u8 *); - - -static inline void -tlan_store_skb(struct tlan_list *tag, struct sk_buff *skb) -{ - unsigned long addr = (unsigned long)skb; - tag->buffer[9].address = addr; - tag->buffer[8].address = upper_32_bits(addr); -} - -static inline struct sk_buff * -tlan_get_skb(const struct tlan_list *tag) -{ - unsigned long addr; - - addr = tag->buffer[9].address; - addr |= (tag->buffer[8].address << 16) << 16; - return (struct sk_buff *) addr; -} - -static u32 -(*tlan_int_vector[TLAN_INT_NUMBER_OF_INTS])(struct net_device *, u16) = { - NULL, - tlan_handle_tx_eof, - tlan_handle_stat_overflow, - tlan_handle_rx_eof, - tlan_handle_dummy, - tlan_handle_tx_eoc, - tlan_handle_status_check, - tlan_handle_rx_eoc -}; - -static inline void -tlan_set_timer(struct net_device *dev, u32 ticks, u32 type) -{ - struct tlan_priv *priv = netdev_priv(dev); - unsigned long flags = 0; - - if (!in_irq()) - spin_lock_irqsave(&priv->lock, flags); - if (priv->timer.function != NULL && - priv->timer_type != TLAN_TIMER_ACTIVITY) { - if (!in_irq()) - spin_unlock_irqrestore(&priv->lock, flags); - return; - } - priv->timer.function = tlan_timer; - if (!in_irq()) - spin_unlock_irqrestore(&priv->lock, flags); - - priv->timer.data = (unsigned long) dev; - priv->timer_set_at = jiffies; - priv->timer_type = type; - mod_timer(&priv->timer, jiffies + ticks); - -} - - -/***************************************************************************** -****************************************************************************** - -ThunderLAN driver primary functions - -these functions are more or less common to all linux network drivers. - -****************************************************************************** -*****************************************************************************/ - - - - - -/*************************************************************** - * tlan_remove_one - * - * Returns: - * Nothing - * Parms: - * None - * - * Goes through the TLanDevices list and frees the device - * structs and memory associated with each device (lists - * and buffers). It also ureserves the IO port regions - * associated with this device. - * - **************************************************************/ - - -static void __devexit tlan_remove_one(struct pci_dev *pdev) -{ - struct net_device *dev = pci_get_drvdata(pdev); - struct tlan_priv *priv = netdev_priv(dev); - - unregister_netdev(dev); - - if (priv->dma_storage) { - pci_free_consistent(priv->pci_dev, - priv->dma_size, priv->dma_storage, - priv->dma_storage_dma); - } - -#ifdef CONFIG_PCI - pci_release_regions(pdev); -#endif - - free_netdev(dev); - - pci_set_drvdata(pdev, NULL); -} - -static void tlan_start(struct net_device *dev) -{ - tlan_reset_lists(dev); - /* NOTE: It might not be necessary to read the stats before a - reset if you don't care what the values are. - */ - tlan_read_and_clear_stats(dev, TLAN_IGNORE); - tlan_reset_adapter(dev); - netif_wake_queue(dev); -} - -static void tlan_stop(struct net_device *dev) -{ - struct tlan_priv *priv = netdev_priv(dev); - - tlan_read_and_clear_stats(dev, TLAN_RECORD); - outl(TLAN_HC_AD_RST, dev->base_addr + TLAN_HOST_CMD); - /* Reset and power down phy */ - tlan_reset_adapter(dev); - if (priv->timer.function != NULL) { - del_timer_sync(&priv->timer); - priv->timer.function = NULL; - } -} - -#ifdef CONFIG_PM - -static int tlan_suspend(struct pci_dev *pdev, pm_message_t state) -{ - struct net_device *dev = pci_get_drvdata(pdev); - - if (netif_running(dev)) - tlan_stop(dev); - - netif_device_detach(dev); - pci_save_state(pdev); - pci_disable_device(pdev); - pci_wake_from_d3(pdev, false); - pci_set_power_state(pdev, PCI_D3hot); - - return 0; -} - -static int tlan_resume(struct pci_dev *pdev) -{ - struct net_device *dev = pci_get_drvdata(pdev); - - pci_set_power_state(pdev, PCI_D0); - pci_restore_state(pdev); - pci_enable_wake(pdev, 0, 0); - netif_device_attach(dev); - - if (netif_running(dev)) - tlan_start(dev); - - return 0; -} - -#else /* CONFIG_PM */ - -#define tlan_suspend NULL -#define tlan_resume NULL - -#endif /* CONFIG_PM */ - - -static struct pci_driver tlan_driver = { - .name = "tlan", - .id_table = tlan_pci_tbl, - .probe = tlan_init_one, - .remove = __devexit_p(tlan_remove_one), - .suspend = tlan_suspend, - .resume = tlan_resume, -}; - -static int __init tlan_probe(void) -{ - int rc = -ENODEV; - - pr_info("%s", tlan_banner); - - TLAN_DBG(TLAN_DEBUG_PROBE, "Starting PCI Probe....\n"); - - /* Use new style PCI probing. Now the kernel will - do most of this for us */ - rc = pci_register_driver(&tlan_driver); - - if (rc != 0) { - pr_err("Could not register pci driver\n"); - goto err_out_pci_free; - } - - TLAN_DBG(TLAN_DEBUG_PROBE, "Starting EISA Probe....\n"); - tlan_eisa_probe(); - - pr_info("%d device%s installed, PCI: %d EISA: %d\n", - tlan_devices_installed, tlan_devices_installed == 1 ? "" : "s", - tlan_have_pci, tlan_have_eisa); - - if (tlan_devices_installed == 0) { - rc = -ENODEV; - goto err_out_pci_unreg; - } - return 0; - -err_out_pci_unreg: - pci_unregister_driver(&tlan_driver); -err_out_pci_free: - return rc; -} - - -static int __devinit tlan_init_one(struct pci_dev *pdev, - const struct pci_device_id *ent) -{ - return tlan_probe1(pdev, -1, -1, 0, ent); -} - - -/* -*************************************************************** -* tlan_probe1 -* -* Returns: -* 0 on success, error code on error -* Parms: -* none -* -* The name is lower case to fit in with all the rest of -* the netcard_probe names. This function looks for -* another TLan based adapter, setting it up with the -* allocated device struct if one is found. -* tlan_probe has been ported to the new net API and -* now allocates its own device structure. This function -* is also used by modules. -* -**************************************************************/ - -static int __devinit tlan_probe1(struct pci_dev *pdev, - long ioaddr, int irq, int rev, - const struct pci_device_id *ent) -{ - - struct net_device *dev; - struct tlan_priv *priv; - u16 device_id; - int reg, rc = -ENODEV; - -#ifdef CONFIG_PCI - if (pdev) { - rc = pci_enable_device(pdev); - if (rc) - return rc; - - rc = pci_request_regions(pdev, tlan_signature); - if (rc) { - pr_err("Could not reserve IO regions\n"); - goto err_out; - } - } -#endif /* CONFIG_PCI */ - - dev = alloc_etherdev(sizeof(struct tlan_priv)); - if (dev == NULL) { - pr_err("Could not allocate memory for device\n"); - rc = -ENOMEM; - goto err_out_regions; - } - SET_NETDEV_DEV(dev, &pdev->dev); - - priv = netdev_priv(dev); - - priv->pci_dev = pdev; - priv->dev = dev; - - /* Is this a PCI device? */ - if (pdev) { - u32 pci_io_base = 0; - - priv->adapter = &board_info[ent->driver_data]; - - rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); - if (rc) { - pr_err("No suitable PCI mapping available\n"); - goto err_out_free_dev; - } - - for (reg = 0; reg <= 5; reg++) { - if (pci_resource_flags(pdev, reg) & IORESOURCE_IO) { - pci_io_base = pci_resource_start(pdev, reg); - TLAN_DBG(TLAN_DEBUG_GNRL, - "IO mapping is available at %x.\n", - pci_io_base); - break; - } - } - if (!pci_io_base) { - pr_err("No IO mappings available\n"); - rc = -EIO; - goto err_out_free_dev; - } - - dev->base_addr = pci_io_base; - dev->irq = pdev->irq; - priv->adapter_rev = pdev->revision; - pci_set_master(pdev); - pci_set_drvdata(pdev, dev); - - } else { /* EISA card */ - /* This is a hack. We need to know which board structure - * is suited for this adapter */ - device_id = inw(ioaddr + EISA_ID2); - priv->is_eisa = 1; - if (device_id == 0x20F1) { - priv->adapter = &board_info[13]; /* NetFlex-3/E */ - priv->adapter_rev = 23; /* TLAN 2.3 */ - } else { - priv->adapter = &board_info[14]; - priv->adapter_rev = 10; /* TLAN 1.0 */ - } - dev->base_addr = ioaddr; - dev->irq = irq; - } - - /* Kernel parameters */ - if (dev->mem_start) { - priv->aui = dev->mem_start & 0x01; - priv->duplex = ((dev->mem_start & 0x06) == 0x06) ? 0 - : (dev->mem_start & 0x06) >> 1; - priv->speed = ((dev->mem_start & 0x18) == 0x18) ? 0 - : (dev->mem_start & 0x18) >> 3; - - if (priv->speed == 0x1) - priv->speed = TLAN_SPEED_10; - else if (priv->speed == 0x2) - priv->speed = TLAN_SPEED_100; - - debug = priv->debug = dev->mem_end; - } else { - priv->aui = aui[boards_found]; - priv->speed = speed[boards_found]; - priv->duplex = duplex[boards_found]; - priv->debug = debug; - } - - /* This will be used when we get an adapter error from - * within our irq handler */ - INIT_WORK(&priv->tlan_tqueue, tlan_tx_timeout_work); - - spin_lock_init(&priv->lock); - - rc = tlan_init(dev); - if (rc) { - pr_err("Could not set up device\n"); - goto err_out_free_dev; - } - - rc = register_netdev(dev); - if (rc) { - pr_err("Could not register device\n"); - goto err_out_uninit; - } - - - tlan_devices_installed++; - boards_found++; - - /* pdev is NULL if this is an EISA device */ - if (pdev) - tlan_have_pci++; - else { - priv->next_device = tlan_eisa_devices; - tlan_eisa_devices = dev; - tlan_have_eisa++; - } - - netdev_info(dev, "irq=%2d, io=%04x, %s, Rev. %d\n", - (int)dev->irq, - (int)dev->base_addr, - priv->adapter->device_label, - priv->adapter_rev); - return 0; - -err_out_uninit: - pci_free_consistent(priv->pci_dev, priv->dma_size, priv->dma_storage, - priv->dma_storage_dma); -err_out_free_dev: - free_netdev(dev); -err_out_regions: -#ifdef CONFIG_PCI - if (pdev) - pci_release_regions(pdev); -#endif -err_out: - if (pdev) - pci_disable_device(pdev); - return rc; -} - - -static void tlan_eisa_cleanup(void) -{ - struct net_device *dev; - struct tlan_priv *priv; - - while (tlan_have_eisa) { - dev = tlan_eisa_devices; - priv = netdev_priv(dev); - if (priv->dma_storage) { - pci_free_consistent(priv->pci_dev, priv->dma_size, - priv->dma_storage, - priv->dma_storage_dma); - } - release_region(dev->base_addr, 0x10); - unregister_netdev(dev); - tlan_eisa_devices = priv->next_device; - free_netdev(dev); - tlan_have_eisa--; - } -} - - -static void __exit tlan_exit(void) -{ - pci_unregister_driver(&tlan_driver); - - if (tlan_have_eisa) - tlan_eisa_cleanup(); - -} - - -/* Module loading/unloading */ -module_init(tlan_probe); -module_exit(tlan_exit); - - - -/************************************************************** - * tlan_eisa_probe - * - * Returns: 0 on success, 1 otherwise - * - * Parms: None - * - * - * This functions probes for EISA devices and calls - * TLan_probe1 when one is found. - * - *************************************************************/ - -static void __init tlan_eisa_probe(void) -{ - long ioaddr; - int rc = -ENODEV; - int irq; - u16 device_id; - - if (!EISA_bus) { - TLAN_DBG(TLAN_DEBUG_PROBE, "No EISA bus present\n"); - return; - } - - /* Loop through all slots of the EISA bus */ - for (ioaddr = 0x1000; ioaddr < 0x9000; ioaddr += 0x1000) { - - TLAN_DBG(TLAN_DEBUG_PROBE, "EISA_ID 0x%4x: 0x%4x\n", - (int) ioaddr + 0xc80, inw(ioaddr + EISA_ID)); - TLAN_DBG(TLAN_DEBUG_PROBE, "EISA_ID 0x%4x: 0x%4x\n", - (int) ioaddr + 0xc82, inw(ioaddr + EISA_ID2)); - - - TLAN_DBG(TLAN_DEBUG_PROBE, - "Probing for EISA adapter at IO: 0x%4x : ", - (int) ioaddr); - if (request_region(ioaddr, 0x10, tlan_signature) == NULL) - goto out; - - if (inw(ioaddr + EISA_ID) != 0x110E) { - release_region(ioaddr, 0x10); - goto out; - } - - device_id = inw(ioaddr + EISA_ID2); - if (device_id != 0x20F1 && device_id != 0x40F1) { - release_region(ioaddr, 0x10); - goto out; - } - - /* check if adapter is enabled */ - if (inb(ioaddr + EISA_CR) != 0x1) { - release_region(ioaddr, 0x10); - goto out2; - } - - if (debug == 0x10) - pr_info("Found one\n"); - - - /* Get irq from board */ - switch (inb(ioaddr + 0xcc0)) { - case(0x10): - irq = 5; - break; - case(0x20): - irq = 9; - break; - case(0x40): - irq = 10; - break; - case(0x80): - irq = 11; - break; - default: - goto out; - } - - - /* Setup the newly found eisa adapter */ - rc = tlan_probe1(NULL, ioaddr, irq, - 12, NULL); - continue; - -out: - if (debug == 0x10) - pr_info("None found\n"); - continue; - -out2: - if (debug == 0x10) - pr_info("Card found but it is not enabled, skipping\n"); - continue; - - } - -} - -#ifdef CONFIG_NET_POLL_CONTROLLER -static void tlan_poll(struct net_device *dev) -{ - disable_irq(dev->irq); - tlan_handle_interrupt(dev->irq, dev); - enable_irq(dev->irq); -} -#endif - -static const struct net_device_ops tlan_netdev_ops = { - .ndo_open = tlan_open, - .ndo_stop = tlan_close, - .ndo_start_xmit = tlan_start_tx, - .ndo_tx_timeout = tlan_tx_timeout, - .ndo_get_stats = tlan_get_stats, - .ndo_set_multicast_list = tlan_set_multicast_list, - .ndo_do_ioctl = tlan_ioctl, - .ndo_change_mtu = eth_change_mtu, - .ndo_set_mac_address = eth_mac_addr, - .ndo_validate_addr = eth_validate_addr, -#ifdef CONFIG_NET_POLL_CONTROLLER - .ndo_poll_controller = tlan_poll, -#endif -}; - - - -/*************************************************************** - * tlan_init - * - * Returns: - * 0 on success, error code otherwise. - * Parms: - * dev The structure of the device to be - * init'ed. - * - * This function completes the initialization of the - * device structure and driver. It reserves the IO - * addresses, allocates memory for the lists and bounce - * buffers, retrieves the MAC address from the eeprom - * and assignes the device's methods. - * - **************************************************************/ - -static int tlan_init(struct net_device *dev) -{ - int dma_size; - int err; - int i; - struct tlan_priv *priv; - - priv = netdev_priv(dev); - - dma_size = (TLAN_NUM_RX_LISTS + TLAN_NUM_TX_LISTS) - * (sizeof(struct tlan_list)); - priv->dma_storage = pci_alloc_consistent(priv->pci_dev, - dma_size, - &priv->dma_storage_dma); - priv->dma_size = dma_size; - - if (priv->dma_storage == NULL) { - pr_err("Could not allocate lists and buffers for %s\n", - dev->name); - return -ENOMEM; - } - memset(priv->dma_storage, 0, dma_size); - priv->rx_list = (struct tlan_list *) - ALIGN((unsigned long)priv->dma_storage, 8); - priv->rx_list_dma = ALIGN(priv->dma_storage_dma, 8); - priv->tx_list = priv->rx_list + TLAN_NUM_RX_LISTS; - priv->tx_list_dma = - priv->rx_list_dma + sizeof(struct tlan_list)*TLAN_NUM_RX_LISTS; - - err = 0; - for (i = 0; i < 6 ; i++) - err |= tlan_ee_read_byte(dev, - (u8) priv->adapter->addr_ofs + i, - (u8 *) &dev->dev_addr[i]); - if (err) { - pr_err("%s: Error reading MAC from eeprom: %d\n", - dev->name, err); - } - dev->addr_len = 6; - - netif_carrier_off(dev); - - /* Device methods */ - dev->netdev_ops = &tlan_netdev_ops; - dev->watchdog_timeo = TX_TIMEOUT; - - return 0; - -} - - - - -/*************************************************************** - * tlan_open - * - * Returns: - * 0 on success, error code otherwise. - * Parms: - * dev Structure of device to be opened. - * - * This routine puts the driver and TLAN adapter in a - * state where it is ready to send and receive packets. - * It allocates the IRQ, resets and brings the adapter - * out of reset, and allows interrupts. It also delays - * the startup for autonegotiation or sends a Rx GO - * command to the adapter, as appropriate. - * - **************************************************************/ - -static int tlan_open(struct net_device *dev) -{ - struct tlan_priv *priv = netdev_priv(dev); - int err; - - priv->tlan_rev = tlan_dio_read8(dev->base_addr, TLAN_DEF_REVISION); - err = request_irq(dev->irq, tlan_handle_interrupt, IRQF_SHARED, - dev->name, dev); - - if (err) { - netdev_err(dev, "Cannot open because IRQ %d is already in use\n", - dev->irq); - return err; - } - - init_timer(&priv->timer); - - tlan_start(dev); - - TLAN_DBG(TLAN_DEBUG_GNRL, "%s: Opened. TLAN Chip Rev: %x\n", - dev->name, priv->tlan_rev); - - return 0; - -} - - - -/************************************************************** - * tlan_ioctl - * - * Returns: - * 0 on success, error code otherwise - * Params: - * dev structure of device to receive ioctl. - * - * rq ifreq structure to hold userspace data. - * - * cmd ioctl command. - * - * - *************************************************************/ - -static int tlan_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) -{ - struct tlan_priv *priv = netdev_priv(dev); - struct mii_ioctl_data *data = if_mii(rq); - u32 phy = priv->phy[priv->phy_num]; - - if (!priv->phy_online) - return -EAGAIN; - - switch (cmd) { - case SIOCGMIIPHY: /* get address of MII PHY in use. */ - data->phy_id = phy; - - - case SIOCGMIIREG: /* read MII PHY register. */ - tlan_mii_read_reg(dev, data->phy_id & 0x1f, - data->reg_num & 0x1f, &data->val_out); - return 0; - - - case SIOCSMIIREG: /* write MII PHY register. */ - tlan_mii_write_reg(dev, data->phy_id & 0x1f, - data->reg_num & 0x1f, data->val_in); - return 0; - default: - return -EOPNOTSUPP; - } -} - - -/*************************************************************** - * tlan_tx_timeout - * - * Returns: nothing - * - * Params: - * dev structure of device which timed out - * during transmit. - * - **************************************************************/ - -static void tlan_tx_timeout(struct net_device *dev) -{ - - TLAN_DBG(TLAN_DEBUG_GNRL, "%s: Transmit timed out.\n", dev->name); - - /* Ok so we timed out, lets see what we can do about it...*/ - tlan_free_lists(dev); - tlan_reset_lists(dev); - tlan_read_and_clear_stats(dev, TLAN_IGNORE); - tlan_reset_adapter(dev); - dev->trans_start = jiffies; /* prevent tx timeout */ - netif_wake_queue(dev); - -} - - -/*************************************************************** - * tlan_tx_timeout_work - * - * Returns: nothing - * - * Params: - * work work item of device which timed out - * - **************************************************************/ - -static void tlan_tx_timeout_work(struct work_struct *work) -{ - struct tlan_priv *priv = - container_of(work, struct tlan_priv, tlan_tqueue); - - tlan_tx_timeout(priv->dev); -} - - - -/*************************************************************** - * tlan_start_tx - * - * Returns: - * 0 on success, non-zero on failure. - * Parms: - * skb A pointer to the sk_buff containing the - * frame to be sent. - * dev The device to send the data on. - * - * This function adds a frame to the Tx list to be sent - * ASAP. First it verifies that the adapter is ready and - * there is room in the queue. Then it sets up the next - * available list, copies the frame to the corresponding - * buffer. If the adapter Tx channel is idle, it gives - * the adapter a Tx Go command on the list, otherwise it - * sets the forward address of the previous list to point - * to this one. Then it frees the sk_buff. - * - **************************************************************/ - -static netdev_tx_t tlan_start_tx(struct sk_buff *skb, struct net_device *dev) -{ - struct tlan_priv *priv = netdev_priv(dev); - dma_addr_t tail_list_phys; - struct tlan_list *tail_list; - unsigned long flags; - unsigned int txlen; - - if (!priv->phy_online) { - TLAN_DBG(TLAN_DEBUG_TX, "TRANSMIT: %s PHY is not ready\n", - dev->name); - dev_kfree_skb_any(skb); - return NETDEV_TX_OK; - } - - if (skb_padto(skb, TLAN_MIN_FRAME_SIZE)) - return NETDEV_TX_OK; - txlen = max(skb->len, (unsigned int)TLAN_MIN_FRAME_SIZE); - - tail_list = priv->tx_list + priv->tx_tail; - tail_list_phys = - priv->tx_list_dma + sizeof(struct tlan_list)*priv->tx_tail; - - if (tail_list->c_stat != TLAN_CSTAT_UNUSED) { - TLAN_DBG(TLAN_DEBUG_TX, - "TRANSMIT: %s is busy (Head=%d Tail=%d)\n", - dev->name, priv->tx_head, priv->tx_tail); - netif_stop_queue(dev); - priv->tx_busy_count++; - return NETDEV_TX_BUSY; - } - - tail_list->forward = 0; - - tail_list->buffer[0].address = pci_map_single(priv->pci_dev, - skb->data, txlen, - PCI_DMA_TODEVICE); - tlan_store_skb(tail_list, skb); - - tail_list->frame_size = (u16) txlen; - tail_list->buffer[0].count = TLAN_LAST_BUFFER | (u32) txlen; - tail_list->buffer[1].count = 0; - tail_list->buffer[1].address = 0; - - spin_lock_irqsave(&priv->lock, flags); - tail_list->c_stat = TLAN_CSTAT_READY; - if (!priv->tx_in_progress) { - priv->tx_in_progress = 1; - TLAN_DBG(TLAN_DEBUG_TX, - "TRANSMIT: Starting TX on buffer %d\n", - priv->tx_tail); - outl(tail_list_phys, dev->base_addr + TLAN_CH_PARM); - outl(TLAN_HC_GO, dev->base_addr + TLAN_HOST_CMD); - } else { - TLAN_DBG(TLAN_DEBUG_TX, - "TRANSMIT: Adding buffer %d to TX channel\n", - priv->tx_tail); - if (priv->tx_tail == 0) { - (priv->tx_list + (TLAN_NUM_TX_LISTS - 1))->forward - = tail_list_phys; - } else { - (priv->tx_list + (priv->tx_tail - 1))->forward - = tail_list_phys; - } - } - spin_unlock_irqrestore(&priv->lock, flags); - - CIRC_INC(priv->tx_tail, TLAN_NUM_TX_LISTS); - - return NETDEV_TX_OK; - -} - - - - -/*************************************************************** - * tlan_handle_interrupt - * - * Returns: - * Nothing - * Parms: - * irq The line on which the interrupt - * occurred. - * dev_id A pointer to the device assigned to - * this irq line. - * - * This function handles an interrupt generated by its - * assigned TLAN adapter. The function deactivates - * interrupts on its adapter, records the type of - * interrupt, executes the appropriate subhandler, and - * acknowdges the interrupt to the adapter (thus - * re-enabling adapter interrupts. - * - **************************************************************/ - -static irqreturn_t tlan_handle_interrupt(int irq, void *dev_id) -{ - struct net_device *dev = dev_id; - struct tlan_priv *priv = netdev_priv(dev); - u16 host_int; - u16 type; - - spin_lock(&priv->lock); - - host_int = inw(dev->base_addr + TLAN_HOST_INT); - type = (host_int & TLAN_HI_IT_MASK) >> 2; - if (type) { - u32 ack; - u32 host_cmd; - - outw(host_int, dev->base_addr + TLAN_HOST_INT); - ack = tlan_int_vector[type](dev, host_int); - - if (ack) { - host_cmd = TLAN_HC_ACK | ack | (type << 18); - outl(host_cmd, dev->base_addr + TLAN_HOST_CMD); - } - } - - spin_unlock(&priv->lock); - - return IRQ_RETVAL(type); -} - - - - -/*************************************************************** - * tlan_close - * - * Returns: - * An error code. - * Parms: - * dev The device structure of the device to - * close. - * - * This function shuts down the adapter. It records any - * stats, puts the adapter into reset state, deactivates - * its time as needed, and frees the irq it is using. - * - **************************************************************/ - -static int tlan_close(struct net_device *dev) -{ - struct tlan_priv *priv = netdev_priv(dev); - - priv->neg_be_verbose = 0; - tlan_stop(dev); - - free_irq(dev->irq, dev); - tlan_free_lists(dev); - TLAN_DBG(TLAN_DEBUG_GNRL, "Device %s closed.\n", dev->name); - - return 0; - -} - - - - -/*************** |