diff options
author | Dave Jones <davej@redhat.com> | 2008-07-15 19:54:53 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@redhat.com> | 2008-07-22 17:59:21 -0400 |
commit | eb5813481a97582c80c8d402ecb371149c77b4e0 (patch) | |
tree | 8805569946cabbb707b99fb00f479f06306604be /drivers/net | |
parent | 7239016d52c6d568d069f083bdcd17f35ab79fd8 (diff) |
8139too: Make PIO/MMIO a runtime decision through a module parameter.
This is needed to support devices that only work with PIO without
penalising devices that work fine with MMIO in distro kernels.
It also allows us to eventually use PIO as a fallback when setting
up MMIO fails.
Signed-off-by: Dave Jones <davej@redhat.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/8139too.c | 128 |
1 files changed, 64 insertions, 64 deletions
diff --git a/drivers/net/8139too.c b/drivers/net/8139too.c index 75317a14ad1c..f172b5d822d7 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 @@ | |||
156 | static int media[MAX_UNITS] = {-1, -1, -1, -1, -1, -1, -1, -1}; | 150 | static int media[MAX_UNITS] = {-1, -1, -1, -1, -1, -1, -1, -1}; |
157 | static int full_duplex[MAX_UNITS] = {-1, -1, -1, -1, -1, -1, -1, -1}; | 151 | static 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 | ||
155 | static int use_io = 1; | ||
156 | #else | ||
157 | static 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. */ |
161 | static int multicast_filter_limit = 32; | 162 | static int multicast_filter_limit = 32; |
@@ -614,6 +615,8 @@ MODULE_DESCRIPTION ("RealTek RTL-8139 Fast Ethernet driver"); | |||
614 | MODULE_LICENSE("GPL"); | 615 | MODULE_LICENSE("GPL"); |
615 | MODULE_VERSION(DRV_VERSION); | 616 | MODULE_VERSION(DRV_VERSION); |
616 | 617 | ||
618 | module_param(use_io, int, 0); | ||
619 | MODULE_PARM_DESC(use_io, "Force use of I/O access mode. 0=MMIO 1=PIO"); | ||
617 | module_param(multicast_filter_limit, int, 0); | 620 | module_param(multicast_filter_limit, int, 0); |
618 | module_param_array(media, int, NULL, 0); | 621 | module_param_array(media, int, NULL, 0); |
619 | module_param_array(full_duplex, int, NULL, 0); | 622 | module_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,32 @@ 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 | 791 | if (use_io) { |
794 | /* make sure PCI base addr 0 is PIO */ | 792 | /* make sure PCI base addr 0 is PIO */ |
795 | if (!(pio_flags & IORESOURCE_IO)) { | 793 | if (!(pio_flags & IORESOURCE_IO)) { |
796 | dev_err(&pdev->dev, "region #0 not a PIO resource, aborting\n"); | 794 | dev_err(&pdev->dev, "region #0 not a PIO resource, aborting\n"); |
797 | rc = -ENODEV; | 795 | rc = -ENODEV; |
798 | goto err_out; | 796 | goto err_out; |
799 | } | 797 | } |
800 | /* check for weird/broken PCI region reporting */ | 798 | /* check for weird/broken PCI region reporting */ |
801 | if (pio_len < RTL_MIN_IO_SIZE) { | 799 | if (pio_len < RTL_MIN_IO_SIZE) { |
802 | dev_err(&pdev->dev, "Invalid PCI I/O region size(s), aborting\n"); | 800 | dev_err(&pdev->dev, "Invalid PCI I/O region size(s), aborting\n"); |
803 | rc = -ENODEV; | 801 | rc = -ENODEV; |
804 | goto err_out; | 802 | goto err_out; |
805 | } | 803 | } |
806 | #else | 804 | } else { |
807 | /* make sure PCI base addr 1 is MMIO */ | 805 | /* make sure PCI base addr 1 is MMIO */ |
808 | if (!(mmio_flags & IORESOURCE_MEM)) { | 806 | if (!(mmio_flags & IORESOURCE_MEM)) { |
809 | dev_err(&pdev->dev, "region #1 not an MMIO resource, aborting\n"); | 807 | dev_err(&pdev->dev, "region #1 not an MMIO resource, aborting\n"); |
810 | rc = -ENODEV; | 808 | rc = -ENODEV; |
811 | goto err_out; | 809 | goto err_out; |
812 | } | 810 | } |
813 | if (mmio_len < RTL_MIN_IO_SIZE) { | 811 | if (mmio_len < RTL_MIN_IO_SIZE) { |
814 | dev_err(&pdev->dev, "Invalid PCI mem region size(s), aborting\n"); | 812 | dev_err(&pdev->dev, "Invalid PCI mem region size(s), aborting\n"); |
815 | rc = -ENODEV; | 813 | rc = -ENODEV; |
816 | goto err_out; | 814 | goto err_out; |
815 | } | ||
817 | } | 816 | } |
818 | #endif | ||
819 | 817 | ||
820 | rc = pci_request_regions (pdev, DRV_NAME); | 818 | rc = pci_request_regions (pdev, DRV_NAME); |
821 | if (rc) | 819 | if (rc) |
@@ -825,28 +823,27 @@ static int __devinit rtl8139_init_board (struct pci_dev *pdev, | |||
825 | /* enable PCI bus-mastering */ | 823 | /* enable PCI bus-mastering */ |
826 | pci_set_master (pdev); | 824 | pci_set_master (pdev); |
827 | 825 | ||
828 | #ifdef USE_IO_OPS | 826 | if (use_io) { |
829 | ioaddr = ioport_map(pio_start, pio_len); | 827 | ioaddr = pci_iomap(pdev, 0, 0); |
830 | if (!ioaddr) { | 828 | if (!ioaddr) { |
831 | dev_err(&pdev->dev, "cannot map PIO, aborting\n"); | 829 | dev_err(&pdev->dev, "cannot map PIO, aborting\n"); |
832 | rc = -EIO; | 830 | rc = -EIO; |
833 | goto err_out; | 831 | goto err_out; |
834 | } | 832 | } |
835 | dev->base_addr = pio_start; | 833 | dev->base_addr = pio_start; |
836 | tp->mmio_addr = ioaddr; | 834 | tp->regs_len = pio_len; |
837 | tp->regs_len = pio_len; | 835 | } else { |
838 | #else | 836 | /* ioremap MMIO region */ |
839 | /* ioremap MMIO region */ | 837 | ioaddr = pci_iomap(pdev, 1, 0); |
840 | ioaddr = pci_iomap(pdev, 1, 0); | 838 | if (ioaddr == NULL) { |
841 | if (ioaddr == NULL) { | 839 | dev_err(&pdev->dev, "cannot remap MMIO, aborting\n"); |
842 | dev_err(&pdev->dev, "cannot remap MMIO, aborting\n"); | 840 | rc = -EIO; |
843 | rc = -EIO; | 841 | goto err_out; |
844 | goto err_out; | 842 | } |
843 | dev->base_addr = (long) ioaddr; | ||
844 | tp->regs_len = mmio_len; | ||
845 | } | 845 | } |
846 | dev->base_addr = (long) ioaddr; | ||
847 | tp->mmio_addr = ioaddr; | 846 | tp->mmio_addr = ioaddr; |
848 | tp->regs_len = mmio_len; | ||
849 | #endif /* USE_IO_OPS */ | ||
850 | 847 | ||
851 | /* Bring old chips out of low-power mode. */ | 848 | /* Bring old chips out of low-power mode. */ |
852 | RTL_W8 (HltClk, 'R'); | 849 | RTL_W8 (HltClk, 'R'); |
@@ -2381,20 +2378,24 @@ static void rtl8139_set_msglevel(struct net_device *dev, u32 datum) | |||
2381 | np->msg_enable = datum; | 2378 | np->msg_enable = datum; |
2382 | } | 2379 | } |
2383 | 2380 | ||
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 | ||
2389 | static int rtl8139_get_regs_len(struct net_device *dev) | 2381 | static int rtl8139_get_regs_len(struct net_device *dev) |
2390 | { | 2382 | { |
2391 | struct rtl8139_private *np = netdev_priv(dev); | 2383 | struct rtl8139_private *np; |
2384 | /* TODO: we are too slack to do reg dumping for pio, for now */ | ||
2385 | if (use_io) | ||
2386 | return 0; | ||
2387 | np = netdev_priv(dev); | ||
2392 | return np->regs_len; | 2388 | return np->regs_len; |
2393 | } | 2389 | } |
2394 | 2390 | ||
2395 | static void rtl8139_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *regbuf) | 2391 | static void rtl8139_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *regbuf) |
2396 | { | 2392 | { |
2397 | struct rtl8139_private *np = netdev_priv(dev); | 2393 | struct rtl8139_private *np; |
2394 | |||
2395 | /* TODO: we are too slack to do reg dumping for pio, for now */ | ||
2396 | if (use_io) | ||
2397 | return; | ||
2398 | np = netdev_priv(dev); | ||
2398 | 2399 | ||
2399 | regs->version = RTL_REGS_VER; | 2400 | regs->version = RTL_REGS_VER; |
2400 | 2401 | ||
@@ -2402,7 +2403,6 @@ static void rtl8139_get_regs(struct net_device *dev, struct ethtool_regs *regs, | |||
2402 | memcpy_fromio(regbuf, np->mmio_addr, regs->len); | 2403 | memcpy_fromio(regbuf, np->mmio_addr, regs->len); |
2403 | spin_unlock_irq(&np->lock); | 2404 | spin_unlock_irq(&np->lock); |
2404 | } | 2405 | } |
2405 | #endif /* CONFIG_8139TOO_MMIO */ | ||
2406 | 2406 | ||
2407 | static int rtl8139_get_sset_count(struct net_device *dev, int sset) | 2407 | static int rtl8139_get_sset_count(struct net_device *dev, int sset) |
2408 | { | 2408 | { |