Commit eb581348 authored by Dave Jones's avatar Dave Jones Committed by Jeff Garzik

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: default avatarDave Jones <davej@redhat.com>
Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
parent 7239016d
...@@ -98,7 +98,6 @@ ...@@ -98,7 +98,6 @@
#include <linux/compiler.h> #include <linux/compiler.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/ioport.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/etherdevice.h> #include <linux/etherdevice.h>
#include <linux/rtnetlink.h> #include <linux/rtnetlink.h>
...@@ -120,11 +119,6 @@ ...@@ -120,11 +119,6 @@
NETIF_MSG_LINK) NETIF_MSG_LINK)
/* enable PIO instead of MMIO, if CONFIG_8139TOO_PIO is selected */
#ifdef CONFIG_8139TOO_PIO
#define USE_IO_OPS 1
#endif
/* define to 1, 2 or 3 to enable copious debugging info */ /* define to 1, 2 or 3 to enable copious debugging info */
#define RTL8139_DEBUG 0 #define RTL8139_DEBUG 0
...@@ -156,6 +150,13 @@ ...@@ -156,6 +150,13 @@
static int media[MAX_UNITS] = {-1, -1, -1, -1, -1, -1, -1, -1}; static int media[MAX_UNITS] = {-1, -1, -1, -1, -1, -1, -1, -1};
static int full_duplex[MAX_UNITS] = {-1, -1, -1, -1, -1, -1, -1, -1}; static int full_duplex[MAX_UNITS] = {-1, -1, -1, -1, -1, -1, -1, -1};
/* Whether to use MMIO or PIO. Default to MMIO. */
#ifdef CONFIG_8139TOO_PIO
static int use_io = 1;
#else
static int use_io = 0;
#endif
/* Maximum number of multicast addresses to filter (vs. Rx-all-multicast). /* Maximum number of multicast addresses to filter (vs. Rx-all-multicast).
The RTL chips use a 64 element hash table based on the Ethernet CRC. */ The RTL chips use a 64 element hash table based on the Ethernet CRC. */
static int multicast_filter_limit = 32; static int multicast_filter_limit = 32;
...@@ -614,6 +615,8 @@ MODULE_DESCRIPTION ("RealTek RTL-8139 Fast Ethernet driver"); ...@@ -614,6 +615,8 @@ MODULE_DESCRIPTION ("RealTek RTL-8139 Fast Ethernet driver");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_VERSION(DRV_VERSION); MODULE_VERSION(DRV_VERSION);
module_param(use_io, int, 0);
MODULE_PARM_DESC(use_io, "Force use of I/O access mode. 0=MMIO 1=PIO");
module_param(multicast_filter_limit, int, 0); module_param(multicast_filter_limit, int, 0);
module_param_array(media, int, NULL, 0); module_param_array(media, int, NULL, 0);
module_param_array(full_duplex, int, NULL, 0); module_param_array(full_duplex, int, NULL, 0);
...@@ -709,13 +712,8 @@ static void __rtl8139_cleanup_dev (struct net_device *dev) ...@@ -709,13 +712,8 @@ static void __rtl8139_cleanup_dev (struct net_device *dev)
assert (tp->pci_dev != NULL); assert (tp->pci_dev != NULL);
pdev = tp->pci_dev; pdev = tp->pci_dev;
#ifdef USE_IO_OPS
if (tp->mmio_addr)
ioport_unmap (tp->mmio_addr);
#else
if (tp->mmio_addr) if (tp->mmio_addr)
pci_iounmap (pdev, tp->mmio_addr); pci_iounmap (pdev, tp->mmio_addr);
#endif /* USE_IO_OPS */
/* it's ok to call this even if we have no regions to free */ /* it's ok to call this even if we have no regions to free */
pci_release_regions (pdev); pci_release_regions (pdev);
...@@ -790,7 +788,7 @@ static int __devinit rtl8139_init_board (struct pci_dev *pdev, ...@@ -790,7 +788,7 @@ static int __devinit rtl8139_init_board (struct pci_dev *pdev,
DPRINTK("PIO region size == 0x%02X\n", pio_len); DPRINTK("PIO region size == 0x%02X\n", pio_len);
DPRINTK("MMIO region size == 0x%02lX\n", mmio_len); DPRINTK("MMIO region size == 0x%02lX\n", mmio_len);
#ifdef USE_IO_OPS if (use_io) {
/* make sure PCI base addr 0 is PIO */ /* make sure PCI base addr 0 is PIO */
if (!(pio_flags & IORESOURCE_IO)) { if (!(pio_flags & IORESOURCE_IO)) {
dev_err(&pdev->dev, "region #0 not a PIO resource, aborting\n"); dev_err(&pdev->dev, "region #0 not a PIO resource, aborting\n");
...@@ -803,7 +801,7 @@ static int __devinit rtl8139_init_board (struct pci_dev *pdev, ...@@ -803,7 +801,7 @@ static int __devinit rtl8139_init_board (struct pci_dev *pdev,
rc = -ENODEV; rc = -ENODEV;
goto err_out; goto err_out;
} }
#else } else {
/* make sure PCI base addr 1 is MMIO */ /* make sure PCI base addr 1 is MMIO */
if (!(mmio_flags & IORESOURCE_MEM)) { if (!(mmio_flags & IORESOURCE_MEM)) {
dev_err(&pdev->dev, "region #1 not an MMIO resource, aborting\n"); dev_err(&pdev->dev, "region #1 not an MMIO resource, aborting\n");
...@@ -815,7 +813,7 @@ static int __devinit rtl8139_init_board (struct pci_dev *pdev, ...@@ -815,7 +813,7 @@ static int __devinit rtl8139_init_board (struct pci_dev *pdev,
rc = -ENODEV; rc = -ENODEV;
goto err_out; goto err_out;
} }
#endif }
rc = pci_request_regions (pdev, DRV_NAME); rc = pci_request_regions (pdev, DRV_NAME);
if (rc) if (rc)
...@@ -825,17 +823,16 @@ static int __devinit rtl8139_init_board (struct pci_dev *pdev, ...@@ -825,17 +823,16 @@ static int __devinit rtl8139_init_board (struct pci_dev *pdev,
/* enable PCI bus-mastering */ /* enable PCI bus-mastering */
pci_set_master (pdev); pci_set_master (pdev);
#ifdef USE_IO_OPS if (use_io) {
ioaddr = ioport_map(pio_start, pio_len); ioaddr = pci_iomap(pdev, 0, 0);
if (!ioaddr) { if (!ioaddr) {
dev_err(&pdev->dev, "cannot map PIO, aborting\n"); dev_err(&pdev->dev, "cannot map PIO, aborting\n");
rc = -EIO; rc = -EIO;
goto err_out; goto err_out;
} }
dev->base_addr = pio_start; dev->base_addr = pio_start;
tp->mmio_addr = ioaddr;
tp->regs_len = pio_len; tp->regs_len = pio_len;
#else } else {
/* ioremap MMIO region */ /* ioremap MMIO region */
ioaddr = pci_iomap(pdev, 1, 0); ioaddr = pci_iomap(pdev, 1, 0);
if (ioaddr == NULL) { if (ioaddr == NULL) {
...@@ -844,9 +841,9 @@ static int __devinit rtl8139_init_board (struct pci_dev *pdev, ...@@ -844,9 +841,9 @@ static int __devinit rtl8139_init_board (struct pci_dev *pdev,
goto err_out; goto err_out;
} }
dev->base_addr = (long) ioaddr; dev->base_addr = (long) ioaddr;
tp->mmio_addr = ioaddr;
tp->regs_len = mmio_len; tp->regs_len = mmio_len;
#endif /* USE_IO_OPS */ }
tp->mmio_addr = ioaddr;
/* Bring old chips out of low-power mode. */ /* Bring old chips out of low-power mode. */
RTL_W8 (HltClk, 'R'); RTL_W8 (HltClk, 'R');
...@@ -2381,20 +2378,24 @@ static void rtl8139_set_msglevel(struct net_device *dev, u32 datum) ...@@ -2381,20 +2378,24 @@ static void rtl8139_set_msglevel(struct net_device *dev, u32 datum)
np->msg_enable = datum; np->msg_enable = datum;
} }
/* TODO: we are too slack to do reg dumping for pio, for now */
#ifdef CONFIG_8139TOO_PIO
#define rtl8139_get_regs_len NULL
#define rtl8139_get_regs NULL
#else
static int rtl8139_get_regs_len(struct net_device *dev) static int rtl8139_get_regs_len(struct net_device *dev)
{ {
struct rtl8139_private *np = netdev_priv(dev); struct rtl8139_private *np;
/* TODO: we are too slack to do reg dumping for pio, for now */
if (use_io)
return 0;
np = netdev_priv(dev);
return np->regs_len; return np->regs_len;
} }
static void rtl8139_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *regbuf) static void rtl8139_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *regbuf)
{ {
struct rtl8139_private *np = netdev_priv(dev); struct rtl8139_private *np;
/* TODO: we are too slack to do reg dumping for pio, for now */
if (use_io)
return;
np = netdev_priv(dev);
regs->version = RTL_REGS_VER; regs->version = RTL_REGS_VER;
...@@ -2402,7 +2403,6 @@ static void rtl8139_get_regs(struct net_device *dev, struct ethtool_regs *regs, ...@@ -2402,7 +2403,6 @@ static void rtl8139_get_regs(struct net_device *dev, struct ethtool_regs *regs,
memcpy_fromio(regbuf, np->mmio_addr, regs->len); memcpy_fromio(regbuf, np->mmio_addr, regs->len);
spin_unlock_irq(&np->lock); spin_unlock_irq(&np->lock);
} }
#endif /* CONFIG_8139TOO_MMIO */
static int rtl8139_get_sset_count(struct net_device *dev, int sset) static int rtl8139_get_sset_count(struct net_device *dev, int sset)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment