aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/8139too.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-07-22 22:09:51 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-07-22 22:09:51 -0400
commitc010b2f76c3032e48097a6eef291d8593d5d79a6 (patch)
tree16077c83703527732991a55dea1abe330c0ccdc6 /drivers/net/8139too.c
parent6069fb2ef5d4f47432359c97f350e0cfcc4d208e (diff)
parent521c4d96e0840ecce25b956e00f416ed499ef2ba (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6: (82 commits) ipw2200: Call netif_*_queue() interfaces properly. netxen: Needs to include linux/vmalloc.h [netdrvr] atl1d: fix !CONFIG_PM build r6040: rework init_one error handling r6040: bump release number to 0.18 r6040: handle RX fifo full and no descriptor interrupts r6040: change the default waiting time r6040: use definitions for magic values in descriptor status r6040: completely rework the RX path r6040: call napi_disable when puting down the interface and set lp->dev accordingly. mv643xx_eth: fix NETPOLL build r6040: rework the RX buffers allocation routine r6040: fix scheduling while atomic in r6040_tx_timeout r6040: fix null pointer access and tx timeouts r6040: prefix all functions with r6040 rndis_host: support WM6 devices as modems at91_ether: use netstats in net_device structure sfc: Create one RX queue and interrupt per CPU package by default sfc: Use a separate workqueue for resets sfc: I2C adapter initialisation fixes ...
Diffstat (limited to 'drivers/net/8139too.c')
-rw-r--r--drivers/net/8139too.c138
1 files changed, 74 insertions, 64 deletions
diff --git a/drivers/net/8139too.c b/drivers/net/8139too.c
index 75317a14ad1c..8a5b0d293f75 100644
--- a/drivers/net/8139too.c
+++ b/drivers/net/8139too.c
@@ -98,7 +98,6 @@
98#include <linux/compiler.h> 98#include <linux/compiler.h>
99#include <linux/pci.h> 99#include <linux/pci.h>
100#include <linux/init.h> 100#include <linux/init.h>
101#include <linux/ioport.h>
102#include <linux/netdevice.h> 101#include <linux/netdevice.h>
103#include <linux/etherdevice.h> 102#include <linux/etherdevice.h>
104#include <linux/rtnetlink.h> 103#include <linux/rtnetlink.h>
@@ -120,11 +119,6 @@
120 NETIF_MSG_LINK) 119 NETIF_MSG_LINK)
121 120
122 121
123/* enable PIO instead of MMIO, if CONFIG_8139TOO_PIO is selected */
124#ifdef CONFIG_8139TOO_PIO
125#define USE_IO_OPS 1
126#endif
127
128/* define to 1, 2 or 3 to enable copious debugging info */ 122/* define to 1, 2 or 3 to enable copious debugging info */
129#define RTL8139_DEBUG 0 123#define RTL8139_DEBUG 0
130 124
@@ -156,6 +150,13 @@
156static int media[MAX_UNITS] = {-1, -1, -1, -1, -1, -1, -1, -1}; 150static int media[MAX_UNITS] = {-1, -1, -1, -1, -1, -1, -1, -1};
157static int full_duplex[MAX_UNITS] = {-1, -1, -1, -1, -1, -1, -1, -1}; 151static int full_duplex[MAX_UNITS] = {-1, -1, -1, -1, -1, -1, -1, -1};
158 152
153/* Whether to use MMIO or PIO. Default to MMIO. */
154#ifdef CONFIG_8139TOO_PIO
155static int use_io = 1;
156#else
157static int use_io = 0;
158#endif
159
159/* Maximum number of multicast addresses to filter (vs. Rx-all-multicast). 160/* Maximum number of multicast addresses to filter (vs. Rx-all-multicast).
160 The RTL chips use a 64 element hash table based on the Ethernet CRC. */ 161 The RTL chips use a 64 element hash table based on the Ethernet CRC. */
161static int multicast_filter_limit = 32; 162static int multicast_filter_limit = 32;
@@ -614,6 +615,8 @@ MODULE_DESCRIPTION ("RealTek RTL-8139 Fast Ethernet driver");
614MODULE_LICENSE("GPL"); 615MODULE_LICENSE("GPL");
615MODULE_VERSION(DRV_VERSION); 616MODULE_VERSION(DRV_VERSION);
616 617
618module_param(use_io, int, 0);
619MODULE_PARM_DESC(use_io, "Force use of I/O access mode. 0=MMIO 1=PIO");
617module_param(multicast_filter_limit, int, 0); 620module_param(multicast_filter_limit, int, 0);
618module_param_array(media, int, NULL, 0); 621module_param_array(media, int, NULL, 0);
619module_param_array(full_duplex, int, NULL, 0); 622module_param_array(full_duplex, int, NULL, 0);
@@ -709,13 +712,8 @@ static void __rtl8139_cleanup_dev (struct net_device *dev)
709 assert (tp->pci_dev != NULL); 712 assert (tp->pci_dev != NULL);
710 pdev = tp->pci_dev; 713 pdev = tp->pci_dev;
711 714
712#ifdef USE_IO_OPS
713 if (tp->mmio_addr)
714 ioport_unmap (tp->mmio_addr);
715#else
716 if (tp->mmio_addr) 715 if (tp->mmio_addr)
717 pci_iounmap (pdev, tp->mmio_addr); 716 pci_iounmap (pdev, tp->mmio_addr);
718#endif /* USE_IO_OPS */
719 717
720 /* it's ok to call this even if we have no regions to free */ 718 /* it's ok to call this even if we have no regions to free */
721 pci_release_regions (pdev); 719 pci_release_regions (pdev);
@@ -790,32 +788,33 @@ static int __devinit rtl8139_init_board (struct pci_dev *pdev,
790 DPRINTK("PIO region size == 0x%02X\n", pio_len); 788 DPRINTK("PIO region size == 0x%02X\n", pio_len);
791 DPRINTK("MMIO region size == 0x%02lX\n", mmio_len); 789 DPRINTK("MMIO region size == 0x%02lX\n", mmio_len);
792 790
793#ifdef USE_IO_OPS 791retry:
794 /* make sure PCI base addr 0 is PIO */ 792 if (use_io) {
795 if (!(pio_flags & IORESOURCE_IO)) { 793 /* make sure PCI base addr 0 is PIO */
796 dev_err(&pdev->dev, "region #0 not a PIO resource, aborting\n"); 794 if (!(pio_flags & IORESOURCE_IO)) {
797 rc = -ENODEV; 795 dev_err(&pdev->dev, "region #0 not a PIO resource, aborting\n");
798 goto err_out; 796 rc = -ENODEV;
799 } 797 goto err_out;
800 /* check for weird/broken PCI region reporting */ 798 }
801 if (pio_len < RTL_MIN_IO_SIZE) { 799 /* check for weird/broken PCI region reporting */
802 dev_err(&pdev->dev, "Invalid PCI I/O region size(s), aborting\n"); 800 if (pio_len < RTL_MIN_IO_SIZE) {
803 rc = -ENODEV; 801 dev_err(&pdev->dev, "Invalid PCI I/O region size(s), aborting\n");
804 goto err_out; 802 rc = -ENODEV;
805 } 803 goto err_out;
806#else 804 }
807 /* make sure PCI base addr 1 is MMIO */ 805 } else {
808 if (!(mmio_flags & IORESOURCE_MEM)) { 806 /* make sure PCI base addr 1 is MMIO */
809 dev_err(&pdev->dev, "region #1 not an MMIO resource, aborting\n"); 807 if (!(mmio_flags & IORESOURCE_MEM)) {
810 rc = -ENODEV; 808 dev_err(&pdev->dev, "region #1 not an MMIO resource, aborting\n");
811 goto err_out; 809 rc = -ENODEV;
812 } 810 goto err_out;
813 if (mmio_len < RTL_MIN_IO_SIZE) { 811 }
814 dev_err(&pdev->dev, "Invalid PCI mem region size(s), aborting\n"); 812 if (mmio_len < RTL_MIN_IO_SIZE) {
815 rc = -ENODEV; 813 dev_err(&pdev->dev, "Invalid PCI mem region size(s), aborting\n");
816 goto err_out; 814 rc = -ENODEV;
815 goto err_out;
816 }
817 } 817 }
818#endif
819 818
820 rc = pci_request_regions (pdev, DRV_NAME); 819 rc = pci_request_regions (pdev, DRV_NAME);
821 if (rc) 820 if (rc)
@@ -825,28 +824,28 @@ static int __devinit rtl8139_init_board (struct pci_dev *pdev,
825 /* enable PCI bus-mastering */ 824 /* enable PCI bus-mastering */
826 pci_set_master (pdev); 825 pci_set_master (pdev);
827 826
828#ifdef USE_IO_OPS 827 if (use_io) {
829 ioaddr = ioport_map(pio_start, pio_len); 828 ioaddr = pci_iomap(pdev, 0, 0);
830 if (!ioaddr) { 829 if (!ioaddr) {
831 dev_err(&pdev->dev, "cannot map PIO, aborting\n"); 830 dev_err(&pdev->dev, "cannot map PIO, aborting\n");
832 rc = -EIO; 831 rc = -EIO;
833 goto err_out; 832 goto err_out;
834 } 833 }
835 dev->base_addr = pio_start; 834 dev->base_addr = pio_start;
836 tp->mmio_addr = ioaddr; 835 tp->regs_len = pio_len;
837 tp->regs_len = pio_len; 836 } else {
838#else 837 /* ioremap MMIO region */
839 /* ioremap MMIO region */ 838 ioaddr = pci_iomap(pdev, 1, 0);
840 ioaddr = pci_iomap(pdev, 1, 0); 839 if (ioaddr == NULL) {
841 if (ioaddr == NULL) { 840 dev_err(&pdev->dev, "cannot remap MMIO, trying PIO\n");
842 dev_err(&pdev->dev, "cannot remap MMIO, aborting\n"); 841 pci_release_regions(pdev);
843 rc = -EIO; 842 use_io = 1;
844 goto err_out; 843 goto retry;
844 }
845 dev->base_addr = (long) ioaddr;
846 tp->regs_len = mmio_len;
845 } 847 }
846 dev->base_addr = (long) ioaddr;
847 tp->mmio_addr = ioaddr; 848 tp->mmio_addr = ioaddr;
848 tp->regs_len = mmio_len;
849#endif /* USE_IO_OPS */
850 849
851 /* Bring old chips out of low-power mode. */ 850 /* Bring old chips out of low-power mode. */
852 RTL_W8 (HltClk, 'R'); 851 RTL_W8 (HltClk, 'R');
@@ -952,6 +951,14 @@ static int __devinit rtl8139_init_one (struct pci_dev *pdev,
952 "Use the \"8139cp\" driver for improved performance and stability.\n"); 951 "Use the \"8139cp\" driver for improved performance and stability.\n");
953 } 952 }
954 953
954 if (pdev->vendor == PCI_VENDOR_ID_REALTEK &&
955 pdev->device == PCI_DEVICE_ID_REALTEK_8139 &&
956 pdev->subsystem_vendor == PCI_VENDOR_ID_ATHEROS &&
957 pdev->subsystem_device == PCI_DEVICE_ID_REALTEK_8139) {
958 printk(KERN_INFO "8139too: OQO Model 2 detected. Forcing PIO\n");
959 use_io = 1;
960 }
961
955 i = rtl8139_init_board (pdev, &dev); 962 i = rtl8139_init_board (pdev, &dev);
956 if (i < 0) 963 if (i < 0)
957 return i; 964 return i;
@@ -2381,20 +2388,24 @@ static void rtl8139_set_msglevel(struct net_device *dev, u32 datum)
2381 np->msg_enable = datum; 2388 np->msg_enable = datum;
2382} 2389}
2383 2390
2384/* TODO: we are too slack to do reg dumping for pio, for now */
2385#ifdef CONFIG_8139TOO_PIO
2386#define rtl8139_get_regs_len NULL
2387#define rtl8139_get_regs NULL
2388#else
2389static int rtl8139_get_regs_len(struct net_device *dev) 2391static int rtl8139_get_regs_len(struct net_device *dev)
2390{ 2392{
2391 struct rtl8139_private *np = netdev_priv(dev); 2393 struct rtl8139_private *np;
2394 /* TODO: we are too slack to do reg dumping for pio, for now */
2395 if (use_io)
2396 return 0;
2397 np = netdev_priv(dev);
2392 return np->regs_len; 2398 return np->regs_len;
2393} 2399}
2394 2400
2395static void rtl8139_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *regbuf) 2401static void rtl8139_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *regbuf)
2396{ 2402{
2397 struct rtl8139_private *np = netdev_priv(dev); 2403 struct rtl8139_private *np;
2404
2405 /* TODO: we are too slack to do reg dumping for pio, for now */
2406 if (use_io)
2407 return;
2408 np = netdev_priv(dev);
2398 2409
2399 regs->version = RTL_REGS_VER; 2410 regs->version = RTL_REGS_VER;
2400 2411
@@ -2402,7 +2413,6 @@ static void rtl8139_get_regs(struct net_device *dev, struct ethtool_regs *regs,
2402 memcpy_fromio(regbuf, np->mmio_addr, regs->len); 2413 memcpy_fromio(regbuf, np->mmio_addr, regs->len);
2403 spin_unlock_irq(&np->lock); 2414 spin_unlock_irq(&np->lock);
2404} 2415}
2405#endif /* CONFIG_8139TOO_MMIO */
2406 2416
2407static int rtl8139_get_sset_count(struct net_device *dev, int sset) 2417static int rtl8139_get_sset_count(struct net_device *dev, int sset)
2408{ 2418{