3 * Driver for Prism II devices which would usually be driven by orinoco_cs,
4 * but are connected to the PCI bus by a TMD7160.
6 * Copyright (C) 2003 Joerg Dorchain <joerg AT dorchain.net>
7 * based heavily upon orinoco_plx.c Copyright (C) 2001 Daniel Barlow
9 * The contents of this file are subject to the Mozilla Public License
10 * Version 1.1 (the "License"); you may not use this file except in
11 * compliance with the License. You may obtain a copy of the License
12 * at http://www.mozilla.org/MPL/
14 * Software distributed under the License is distributed on an "AS IS"
15 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
16 * the License for the specific language governing rights and
17 * limitations under the License.
19 * Alternatively, the contents of this file may be used under the
20 * terms of the GNU General Public License version 2 (the "GPL"), in
21 * which case the provisions of the GPL are applicable instead of the
22 * above. If you wish to allow the use of your version of this file
23 * only under the terms of the GPL and not to allow others to use your
24 * version of this file under the MPL, indicate your decision by
25 * deleting the provisions above and replace them with the notice and
26 * other provisions required by the GPL. If you do not delete the
27 * provisions above, a recipient may use your version of this file
28 * under either the MPL or the GPL.
30 * Caution: this is experimental and probably buggy. For success and
31 * failure reports for different cards and adaptors, see
32 * orinoco_tmd_pci_id_table near the end of the file. If you have a
33 * card we don't have the PCI id for, and looks like it should work,
34 * drop me mail with the id and "it works"/"it doesn't work".
36 * Note: if everything gets detected fine but it doesn't actually send
37 * or receive packets, your first port of call should probably be to
38 * try newer firmware in the card. Especially if you're doing Ad-Hoc
41 * The actual driving is done by orinoco.c, this is just resource
44 * This driver is modeled after the orinoco_plx driver. The main
45 * difference is that the TMD chip has only IO port ranges and no
46 * memory space, i.e. no access to the CIS. Compared to the PLX chip,
47 * the io range functionalities are exchanged.
49 * Pheecom sells cards with the TMD chip as "ASIC version"
52 #define DRIVER_NAME "orinoco_tmd"
53 #define PFX DRIVER_NAME ": "
55 #include <linux/config.h>
57 #include <linux/module.h>
58 #include <linux/kernel.h>
59 #include <linux/init.h>
60 #include <linux/sched.h>
61 #include <linux/ptrace.h>
62 #include <linux/slab.h>
63 #include <linux/string.h>
64 #include <linux/timer.h>
65 #include <linux/ioport.h>
66 #include <asm/uaccess.h>
68 #include <asm/system.h>
69 #include <linux/netdevice.h>
70 #include <linux/if_arp.h>
71 #include <linux/etherdevice.h>
72 #include <linux/list.h>
73 #include <linux/pci.h>
74 #include <linux/fcntl.h>
76 #include <pcmcia/cisreg.h>
81 #define COR_VALUE (COR_LEVEL_REQ | COR_FUNC_ENA) /* Enable PC card with interrupt in level trigger */
83 static int orinoco_tmd_init_one(struct pci_dev
*pdev
,
84 const struct pci_device_id
*ent
)
88 struct orinoco_private
*priv
= NULL
;
89 unsigned long pccard_ioaddr
= 0;
90 unsigned long pccard_iolen
= 0;
91 struct net_device
*dev
= NULL
;
93 err
= pci_enable_device(pdev
);
97 printk(KERN_DEBUG PFX
"TMD setup\n");
98 pccard_ioaddr
= pci_resource_start(pdev
, 2);
99 pccard_iolen
= pci_resource_len(pdev
, 2);
100 if (! request_region(pccard_ioaddr
, pccard_iolen
, DRIVER_NAME
)) {
101 printk(KERN_ERR PFX
"I/O resource at 0x%lx len 0x%lx busy\n",
102 pccard_ioaddr
, pccard_iolen
);
107 addr
= pci_resource_start(pdev
, 1);
108 outb(COR_VALUE
, addr
);
111 if (reg
!= COR_VALUE
) {
112 printk(KERN_ERR PFX
"Error setting TMD COR values %x should be %x\n", reg
, COR_VALUE
);
117 /* Allocate network device */
118 dev
= alloc_orinocodev(0, NULL
);
124 priv
= netdev_priv(dev
);
125 dev
->base_addr
= pccard_ioaddr
;
126 SET_MODULE_OWNER(dev
);
127 SET_NETDEV_DEV(dev
, &pdev
->dev
);
129 printk(KERN_DEBUG PFX
"Detected Orinoco/Prism2 TMD device "
130 "at %s irq:%d, io addr:0x%lx\n", pci_name(pdev
), pdev
->irq
,
133 hermes_struct_init(&(priv
->hw
), dev
->base_addr
,
134 HERMES_IO
, HERMES_16BIT_REGSPACING
);
135 pci_set_drvdata(pdev
, dev
);
137 err
= request_irq(pdev
->irq
, orinoco_interrupt
, SA_SHIRQ
,
140 printk(KERN_ERR PFX
"Error allocating IRQ %d.\n",
145 dev
->irq
= pdev
->irq
;
147 err
= register_netdev(dev
);
154 printk(KERN_DEBUG PFX
"init_one(), FAIL!\n");
158 free_irq(dev
->irq
, dev
);
164 release_region(pccard_ioaddr
, pccard_iolen
);
166 pci_disable_device(pdev
);
171 static void __devexit
orinoco_tmd_remove_one(struct pci_dev
*pdev
)
173 struct net_device
*dev
= pci_get_drvdata(pdev
);
177 unregister_netdev(dev
);
180 free_irq(dev
->irq
, dev
);
182 pci_set_drvdata(pdev
, NULL
);
186 release_region(pci_resource_start(pdev
, 2), pci_resource_len(pdev
, 2));
188 pci_disable_device(pdev
);
192 static struct pci_device_id orinoco_tmd_pci_id_table
[] = {
193 {0x15e8, 0x0131, PCI_ANY_ID
, PCI_ANY_ID
,}, /* NDC and OEMs, e.g. pheecom */
197 MODULE_DEVICE_TABLE(pci
, orinoco_tmd_pci_id_table
);
199 static struct pci_driver orinoco_tmd_driver
= {
201 .id_table
= orinoco_tmd_pci_id_table
,
202 .probe
= orinoco_tmd_init_one
,
203 .remove
= __devexit_p(orinoco_tmd_remove_one
),
206 static char version
[] __initdata
= DRIVER_NAME
" " DRIVER_VERSION
207 " (Joerg Dorchain <joerg@dorchain.net>)";
208 MODULE_AUTHOR("Joerg Dorchain <joerg@dorchain.net>");
209 MODULE_DESCRIPTION("Driver for wireless LAN cards using the TMD7160 PCI bridge");
210 MODULE_LICENSE("Dual MPL/GPL");
212 static int __init
orinoco_tmd_init(void)
214 printk(KERN_DEBUG
"%s\n", version
);
215 return pci_module_init(&orinoco_tmd_driver
);
218 static void __exit
orinoco_tmd_exit(void)
220 pci_unregister_driver(&orinoco_tmd_driver
);
221 current
->state
= TASK_UNINTERRUPTIBLE
;
222 schedule_timeout(HZ
);
225 module_init(orinoco_tmd_init
);
226 module_exit(orinoco_tmd_exit
);