98
98
#include <linux/compiler.h>
99
99
#include <linux/pci.h>
100
100
#include <linux/init.h>
101
- #include <linux/ioport.h>
102
101
#include <linux/netdevice.h>
103
102
#include <linux/etherdevice.h>
104
103
#include <linux/rtnetlink.h>
120
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
122
/* define to 1, 2 or 3 to enable copious debugging info */
129
123
#define RTL8139_DEBUG 0
130
124
156
150
static int media [MAX_UNITS ] = {-1 , -1 , -1 , -1 , -1 , -1 , -1 , -1 };
157
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
160
/* Maximum number of multicast addresses to filter (vs. Rx-all-multicast).
160
161
The RTL chips use a 64 element hash table based on the Ethernet CRC. */
161
162
static int multicast_filter_limit = 32 ;
@@ -614,6 +615,8 @@ MODULE_DESCRIPTION ("RealTek RTL-8139 Fast Ethernet driver");
614
615
MODULE_LICENSE ("GPL" );
615
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
620
module_param (multicast_filter_limit , int , 0 );
618
621
module_param_array (media , int , NULL , 0 );
619
622
module_param_array (full_duplex , int , NULL , 0 );
@@ -709,13 +712,8 @@ static void __rtl8139_cleanup_dev (struct net_device *dev)
709
712
assert (tp -> pci_dev != NULL );
710
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
715
if (tp -> mmio_addr )
717
716
pci_iounmap (pdev , tp -> mmio_addr );
718
- #endif /* USE_IO_OPS */
719
717
720
718
/* it's ok to call this even if we have no regions to free */
721
719
pci_release_regions (pdev );
@@ -790,32 +788,33 @@ static int __devinit rtl8139_init_board (struct pci_dev *pdev,
790
788
DPRINTK ("PIO region size == 0x%02X\n" , pio_len );
791
789
DPRINTK ("MMIO region size == 0x%02lX\n" , mmio_len );
792
790
793
- #ifdef USE_IO_OPS
794
- /* make sure PCI base addr 0 is PIO */
795
- if (!(pio_flags & IORESOURCE_IO )) {
796
- dev_err (& pdev -> dev , "region #0 not a PIO resource, aborting\n" );
797
- rc = - ENODEV ;
798
- goto err_out ;
799
- }
800
- /* check for weird/broken PCI region reporting */
801
- if (pio_len < RTL_MIN_IO_SIZE ) {
802
- dev_err (& pdev -> dev , "Invalid PCI I/O region size(s), aborting\n" );
803
- rc = - ENODEV ;
804
- goto err_out ;
805
- }
806
- #else
807
- /* make sure PCI base addr 1 is MMIO */
808
- if (!(mmio_flags & IORESOURCE_MEM )) {
809
- dev_err (& pdev -> dev , "region #1 not an MMIO resource, aborting\n" );
810
- rc = - ENODEV ;
811
- goto err_out ;
812
- }
813
- if (mmio_len < RTL_MIN_IO_SIZE ) {
814
- dev_err (& pdev -> dev , "Invalid PCI mem region size(s), aborting\n" );
815
- rc = - ENODEV ;
816
- goto err_out ;
791
+ retry :
792
+ if (use_io ) {
793
+ /* make sure PCI base addr 0 is PIO */
794
+ if (!(pio_flags & IORESOURCE_IO )) {
795
+ dev_err (& pdev -> dev , "region #0 not a PIO resource, aborting\n" );
796
+ rc = - ENODEV ;
797
+ goto err_out ;
798
+ }
799
+ /* check for weird/broken PCI region reporting */
800
+ if (pio_len < RTL_MIN_IO_SIZE ) {
801
+ dev_err (& pdev -> dev , "Invalid PCI I/O region size(s), aborting\n" );
802
+ rc = - ENODEV ;
803
+ goto err_out ;
804
+ }
805
+ } else {
806
+ /* make sure PCI base addr 1 is MMIO */
807
+ if (!(mmio_flags & IORESOURCE_MEM )) {
808
+ dev_err (& pdev -> dev , "region #1 not an MMIO resource, aborting\n" );
809
+ rc = - ENODEV ;
810
+ goto err_out ;
811
+ }
812
+ if (mmio_len < RTL_MIN_IO_SIZE ) {
813
+ dev_err (& pdev -> dev , "Invalid PCI mem region size(s), aborting\n" );
814
+ rc = - ENODEV ;
815
+ goto err_out ;
816
+ }
817
817
}
818
- #endif
819
818
820
819
rc = pci_request_regions (pdev , DRV_NAME );
821
820
if (rc )
@@ -825,28 +824,28 @@ static int __devinit rtl8139_init_board (struct pci_dev *pdev,
825
824
/* enable PCI bus-mastering */
826
825
pci_set_master (pdev );
827
826
828
- #ifdef USE_IO_OPS
829
- ioaddr = ioport_map (pio_start , pio_len );
830
- if (!ioaddr ) {
831
- dev_err (& pdev -> dev , "cannot map PIO, aborting\n" );
832
- rc = - EIO ;
833
- goto err_out ;
834
- }
835
- dev -> base_addr = pio_start ;
836
- tp -> mmio_addr = ioaddr ;
837
- tp -> regs_len = pio_len ;
838
- #else
839
- /* ioremap MMIO region */
840
- ioaddr = pci_iomap (pdev , 1 , 0 );
841
- if (ioaddr == NULL ) {
842
- dev_err (& pdev -> dev , "cannot remap MMIO, aborting\n" );
843
- rc = - EIO ;
844
- goto err_out ;
827
+ if (use_io ) {
828
+ ioaddr = pci_iomap (pdev , 0 , 0 );
829
+ if (!ioaddr ) {
830
+ dev_err (& pdev -> dev , "cannot map PIO, aborting\n" );
831
+ rc = - EIO ;
832
+ goto err_out ;
833
+ }
834
+ dev -> base_addr = pio_start ;
835
+ tp -> regs_len = pio_len ;
836
+ } else {
837
+ /* ioremap MMIO region */
838
+ ioaddr = pci_iomap (pdev , 1 , 0 );
839
+ if (ioaddr == NULL ) {
840
+ dev_err (& pdev -> dev , "cannot remap MMIO, trying PIO\n" );
841
+ pci_release_regions (pdev );
842
+ use_io = 1 ;
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
848
tp -> mmio_addr = ioaddr ;
848
- tp -> regs_len = mmio_len ;
849
- #endif /* USE_IO_OPS */
850
849
851
850
/* Bring old chips out of low-power mode. */
852
851
RTL_W8 (HltClk , 'R' );
@@ -952,6 +951,14 @@ static int __devinit rtl8139_init_one (struct pci_dev *pdev,
952
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
962
i = rtl8139_init_board (pdev , & dev );
956
963
if (i < 0 )
957
964
return i ;
@@ -2381,28 +2388,31 @@ static void rtl8139_set_msglevel(struct net_device *dev, u32 datum)
2381
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
2389
2391
static 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
2398
return np -> regs_len ;
2393
2399
}
2394
2400
2395
2401
static 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
2410
regs -> version = RTL_REGS_VER ;
2400
2411
2401
2412
spin_lock_irq (& np -> lock );
2402
2413
memcpy_fromio (regbuf , np -> mmio_addr , regs -> len );
2403
2414
spin_unlock_irq (& np -> lock );
2404
2415
}
2405
- #endif /* CONFIG_8139TOO_MMIO */
2406
2416
2407
2417
static int rtl8139_get_sset_count (struct net_device * dev , int sset )
2408
2418
{
0 commit comments