3 * Driver for Prism II devices which would usually be driven by orinoco_cs,
4 * but are connected to the PCI bus by a Nortel PCI-PCMCIA-Adapter.
6 * Copyright (C) 2002 Tobias Hoffmann
7 * (C) 2003 Christoph Jungegger <disdos@traum404.de>
9 * Some of this code is borrowed from orinoco_plx.c
10 * Copyright (C) 2001 Daniel Barlow
11 * Some of this code is borrowed from orinoco_pci.c
12 * Copyright (C) 2001 Jean Tourrilhes
13 * Some of this code is "inspired" by linux-wlan-ng-0.1.10, but nothing
14 * has been copied from it. linux-wlan-ng-0.1.10 is originally :
15 * Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
17 * The contents of this file are subject to the Mozilla Public License
18 * Version 1.1 (the "License"); you may not use this file except in
19 * compliance with the License. You may obtain a copy of the License
20 * at http://www.mozilla.org/MPL/
22 * Software distributed under the License is distributed on an "AS IS"
23 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
24 * the License for the specific language governing rights and
25 * limitations under the License.
27 * Alternatively, the contents of this file may be used under the
28 * terms of the GNU General Public License version 2 (the "GPL"), in
29 * which case the provisions of the GPL are applicable instead of the
30 * above. If you wish to allow the use of your version of this file
31 * only under the terms of the GPL and not to allow others to use your
32 * version of this file under the MPL, indicate your decision by
33 * deleting the provisions above and replace them with the notice and
34 * other provisions required by the GPL. If you do not delete the
35 * provisions above, a recipient may use your version of this file
36 * under either the MPL or the GPL.
39 #define DRIVER_NAME "orinoco_nortel"
40 #define PFX DRIVER_NAME ": "
42 #include <linux/config.h>
43 #include <linux/module.h>
44 #include <linux/kernel.h>
45 #include <linux/init.h>
46 #include <linux/delay.h>
47 #include <linux/pci.h>
48 #include <pcmcia/cisreg.h>
52 #define COR_OFFSET (0xe0) /* COR attribute offset of Prism2 PC card */
53 #define COR_VALUE (COR_LEVEL_REQ | COR_FUNC_ENA) /* Enable PC card with interrupt in level trigger */
56 /* Nortel specific data */
57 struct nortel_pci_card
{
58 unsigned long iobase1
;
59 unsigned long iobase2
;
63 * Do a soft reset of the PCI card using the Configuration Option Register
64 * We need this to get going...
65 * This is the part of the code that is strongly inspired from wlan-ng
67 * Note bis : Don't try to access HERMES_CMD during the reset phase.
68 * It just won't work !
70 static int nortel_pci_cor_reset(struct orinoco_private
*priv
)
72 struct nortel_pci_card
*card
= priv
->card
;
74 /* Assert the reset until the card notice */
75 outw_p(8, card
->iobase1
+ 2);
76 inw(card
->iobase2
+ COR_OFFSET
);
77 outw_p(0x80, card
->iobase2
+ COR_OFFSET
);
80 /* Give time for the card to recover from this hard effort */
81 outw_p(0, card
->iobase2
+ COR_OFFSET
);
82 outw_p(0, card
->iobase2
+ COR_OFFSET
);
85 /* set COR as usual */
86 outw_p(COR_VALUE
, card
->iobase2
+ COR_OFFSET
);
87 outw_p(COR_VALUE
, card
->iobase2
+ COR_OFFSET
);
90 outw_p(0x228, card
->iobase1
+ 2);
95 int nortel_pci_hw_init(struct nortel_pci_card
*card
)
101 if (inw(card
->iobase1
) & 1) {
102 printk(KERN_ERR PFX
"brg1 answer1 wrong\n");
105 outw_p(0x118, card
->iobase1
+ 2);
106 outw_p(0x108, card
->iobase1
+ 2);
108 outw_p(0x8, card
->iobase1
+ 2);
109 for (i
= 0; i
< 30; i
++) {
111 if (inw(card
->iobase1
) & 0x10) {
116 printk(KERN_ERR PFX
"brg1 timed out\n");
119 if (inw(card
->iobase2
+ 0xe0) & 1) {
120 printk(KERN_ERR PFX
"brg2 answer1 wrong\n");
123 if (inw(card
->iobase2
+ 0xe2) & 1) {
124 printk(KERN_ERR PFX
"brg2 answer2 wrong\n");
127 if (inw(card
->iobase2
+ 0xe4) & 1) {
128 printk(KERN_ERR PFX
"brg2 answer3 wrong\n");
132 /* set the PCMCIA COR-Register */
133 outw_p(COR_VALUE
, card
->iobase2
+ COR_OFFSET
);
135 reg
= inw(card
->iobase2
+ COR_OFFSET
);
136 if (reg
!= COR_VALUE
) {
137 printk(KERN_ERR PFX
"Error setting COR value (reg=%x)\n",
143 outw_p(1, card
->iobase1
+ 10);
147 static int nortel_pci_init_one(struct pci_dev
*pdev
,
148 const struct pci_device_id
*ent
)
151 struct orinoco_private
*priv
;
152 struct nortel_pci_card
*card
;
153 struct net_device
*dev
;
156 err
= pci_enable_device(pdev
);
158 printk(KERN_ERR PFX
"Cannot enable PCI device\n");
162 err
= pci_request_regions(pdev
, DRIVER_NAME
);
164 printk(KERN_ERR PFX
"Cannot obtain PCI resources\n");
168 iomem
= pci_iomap(pdev
, 3, 0);
174 /* Allocate network device */
175 dev
= alloc_orinocodev(sizeof(*card
), nortel_pci_cor_reset
);
177 printk(KERN_ERR PFX
"Cannot allocate network device\n");
182 priv
= netdev_priv(dev
);
184 card
->iobase1
= pci_resource_start(pdev
, 0);
185 card
->iobase2
= pci_resource_start(pdev
, 1);
186 dev
->base_addr
= pci_resource_start(pdev
, 2);
187 SET_MODULE_OWNER(dev
);
188 SET_NETDEV_DEV(dev
, &pdev
->dev
);
190 hermes_struct_init(&priv
->hw
, iomem
, HERMES_16BIT_REGSPACING
);
192 printk(KERN_DEBUG PFX
"Detected Nortel PCI device at %s irq:%d, "
193 "io addr:0x%lx\n", pci_name(pdev
), pdev
->irq
, dev
->base_addr
);
195 err
= request_irq(pdev
->irq
, orinoco_interrupt
, SA_SHIRQ
,
198 printk(KERN_ERR PFX
"Cannot allocate IRQ %d\n", pdev
->irq
);
202 dev
->irq
= pdev
->irq
;
204 err
= nortel_pci_hw_init(card
);
206 printk(KERN_ERR PFX
"Hardware initialization failed\n");
210 err
= nortel_pci_cor_reset(priv
);
212 printk(KERN_ERR PFX
"Initial reset failed\n");
217 err
= register_netdev(dev
);
219 printk(KERN_ERR PFX
"Cannot register network device\n");
223 pci_set_drvdata(pdev
, dev
);
228 free_irq(pdev
->irq
, dev
);
231 pci_set_drvdata(pdev
, NULL
);
232 free_orinocodev(dev
);
235 pci_iounmap(pdev
, iomem
);
238 pci_release_regions(pdev
);
241 pci_disable_device(pdev
);
246 static void __devexit
nortel_pci_remove_one(struct pci_dev
*pdev
)
248 struct net_device
*dev
= pci_get_drvdata(pdev
);
249 struct orinoco_private
*priv
= netdev_priv(dev
);
250 struct nortel_pci_card
*card
= priv
->card
;
253 outw_p(0, card
->iobase1
+ 10);
255 unregister_netdev(dev
);
256 free_irq(dev
->irq
, dev
);
257 pci_set_drvdata(pdev
, NULL
);
258 free_orinocodev(dev
);
259 pci_iounmap(pdev
, priv
->hw
.iobase
);
260 pci_release_regions(pdev
);
261 pci_disable_device(pdev
);
265 static struct pci_device_id nortel_pci_id_table
[] = {
266 /* Nortel emobility PCI */
267 {0x126c, 0x8030, PCI_ANY_ID
, PCI_ANY_ID
,},
271 MODULE_DEVICE_TABLE(pci
, nortel_pci_id_table
);
273 static struct pci_driver nortel_pci_driver
= {
275 .id_table
= nortel_pci_id_table
,
276 .probe
= nortel_pci_init_one
,
277 .remove
= __devexit_p(nortel_pci_remove_one
),
280 static char version
[] __initdata
= DRIVER_NAME
" " DRIVER_VERSION
281 " (Tobias Hoffmann & Christoph Jungegger <disdos@traum404.de>)";
282 MODULE_AUTHOR("Christoph Jungegger <disdos@traum404.de>");
284 ("Driver for wireless LAN cards using the Nortel PCI bridge");
285 MODULE_LICENSE("Dual MPL/GPL");
287 static int __init
nortel_pci_init(void)
289 printk(KERN_DEBUG
"%s\n", version
);
290 return pci_module_init(&nortel_pci_driver
);
293 static void __exit
nortel_pci_exit(void)
295 pci_unregister_driver(&nortel_pci_driver
);
299 module_init(nortel_pci_init
);
300 module_exit(nortel_pci_exit
);