3 * Driver for Prism II devices which would usually be driven by orinoco_cs,
4 * but are connected to the PCI bus by a PCI-to-PCMCIA adapter used in
5 * Nortel emobility, Symbol LA-4113 and Symbol LA-4123.
6 * but are connected to the PCI bus by a Nortel PCI-PCMCIA-Adapter.
8 * Copyright (C) 2002 Tobias Hoffmann
9 * (C) 2003 Christoph Jungegger <disdos@traum404.de>
11 * Some of this code is borrowed from orinoco_plx.c
12 * Copyright (C) 2001 Daniel Barlow
13 * Some of this code is borrowed from orinoco_pci.c
14 * Copyright (C) 2001 Jean Tourrilhes
15 * Some of this code is "inspired" by linux-wlan-ng-0.1.10, but nothing
16 * has been copied from it. linux-wlan-ng-0.1.10 is originally :
17 * Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
19 * The contents of this file are subject to the Mozilla Public License
20 * Version 1.1 (the "License"); you may not use this file except in
21 * compliance with the License. You may obtain a copy of the License
22 * at http://www.mozilla.org/MPL/
24 * Software distributed under the License is distributed on an "AS IS"
25 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
26 * the License for the specific language governing rights and
27 * limitations under the License.
29 * Alternatively, the contents of this file may be used under the
30 * terms of the GNU General Public License version 2 (the "GPL"), in
31 * which case the provisions of the GPL are applicable instead of the
32 * above. If you wish to allow the use of your version of this file
33 * only under the terms of the GPL and not to allow others to use your
34 * version of this file under the MPL, indicate your decision by
35 * deleting the provisions above and replace them with the notice and
36 * other provisions required by the GPL. If you do not delete the
37 * provisions above, a recipient may use your version of this file
38 * under either the MPL or the GPL.
41 #define DRIVER_NAME "orinoco_nortel"
42 #define PFX DRIVER_NAME ": "
44 #include <linux/config.h>
45 #include <linux/module.h>
46 #include <linux/kernel.h>
47 #include <linux/init.h>
48 #include <linux/delay.h>
49 #include <linux/pci.h>
50 #include <pcmcia/cisreg.h>
54 #define COR_OFFSET (0xe0) /* COR attribute offset of Prism2 PC card */
55 #define COR_VALUE (COR_LEVEL_REQ | COR_FUNC_ENA) /* Enable PC card with interrupt in level trigger */
58 /* Nortel specific data */
59 struct nortel_pci_card
{
60 unsigned long iobase1
;
61 unsigned long iobase2
;
65 * Do a soft reset of the PCI card using the Configuration Option Register
66 * We need this to get going...
67 * This is the part of the code that is strongly inspired from wlan-ng
69 * Note bis : Don't try to access HERMES_CMD during the reset phase.
70 * It just won't work !
72 static int nortel_pci_cor_reset(struct orinoco_private
*priv
)
74 struct nortel_pci_card
*card
= priv
->card
;
76 /* Assert the reset until the card notice */
77 outw_p(8, card
->iobase1
+ 2);
78 inw(card
->iobase2
+ COR_OFFSET
);
79 outw_p(0x80, card
->iobase2
+ COR_OFFSET
);
82 /* Give time for the card to recover from this hard effort */
83 outw_p(0, card
->iobase2
+ COR_OFFSET
);
84 outw_p(0, card
->iobase2
+ COR_OFFSET
);
87 /* set COR as usual */
88 outw_p(COR_VALUE
, card
->iobase2
+ COR_OFFSET
);
89 outw_p(COR_VALUE
, card
->iobase2
+ COR_OFFSET
);
92 outw_p(0x228, card
->iobase1
+ 2);
97 static int nortel_pci_hw_init(struct nortel_pci_card
*card
)
103 if (inw(card
->iobase1
) & 1) {
104 printk(KERN_ERR PFX
"brg1 answer1 wrong\n");
107 outw_p(0x118, card
->iobase1
+ 2);
108 outw_p(0x108, card
->iobase1
+ 2);
110 outw_p(0x8, card
->iobase1
+ 2);
111 for (i
= 0; i
< 30; i
++) {
113 if (inw(card
->iobase1
) & 0x10) {
118 printk(KERN_ERR PFX
"brg1 timed out\n");
121 if (inw(card
->iobase2
+ 0xe0) & 1) {
122 printk(KERN_ERR PFX
"brg2 answer1 wrong\n");
125 if (inw(card
->iobase2
+ 0xe2) & 1) {
126 printk(KERN_ERR PFX
"brg2 answer2 wrong\n");
129 if (inw(card
->iobase2
+ 0xe4) & 1) {
130 printk(KERN_ERR PFX
"brg2 answer3 wrong\n");
134 /* set the PCMCIA COR-Register */
135 outw_p(COR_VALUE
, card
->iobase2
+ COR_OFFSET
);
137 reg
= inw(card
->iobase2
+ COR_OFFSET
);
138 if (reg
!= COR_VALUE
) {
139 printk(KERN_ERR PFX
"Error setting COR value (reg=%x)\n",
145 outw_p(1, card
->iobase1
+ 10);
149 static int nortel_pci_init_one(struct pci_dev
*pdev
,
150 const struct pci_device_id
*ent
)
153 struct orinoco_private
*priv
;
154 struct nortel_pci_card
*card
;
155 struct net_device
*dev
;
158 err
= pci_enable_device(pdev
);
160 printk(KERN_ERR PFX
"Cannot enable PCI device\n");
164 err
= pci_request_regions(pdev
, DRIVER_NAME
);
166 printk(KERN_ERR PFX
"Cannot obtain PCI resources\n");
170 iomem
= pci_iomap(pdev
, 2, 0);
176 /* Allocate network device */
177 dev
= alloc_orinocodev(sizeof(*card
), nortel_pci_cor_reset
);
179 printk(KERN_ERR PFX
"Cannot allocate network device\n");
184 priv
= netdev_priv(dev
);
186 card
->iobase1
= pci_resource_start(pdev
, 0);
187 card
->iobase2
= pci_resource_start(pdev
, 1);
188 dev
->base_addr
= pci_resource_start(pdev
, 2);
189 SET_MODULE_OWNER(dev
);
190 SET_NETDEV_DEV(dev
, &pdev
->dev
);
192 hermes_struct_init(&priv
->hw
, iomem
, HERMES_16BIT_REGSPACING
);
194 printk(KERN_DEBUG PFX
"Detected Nortel PCI device at %s irq:%d, "
195 "io addr:0x%lx\n", pci_name(pdev
), pdev
->irq
, dev
->base_addr
);
197 err
= request_irq(pdev
->irq
, orinoco_interrupt
, SA_SHIRQ
,
200 printk(KERN_ERR PFX
"Cannot allocate IRQ %d\n", pdev
->irq
);
204 dev
->irq
= pdev
->irq
;
206 err
= nortel_pci_hw_init(card
);
208 printk(KERN_ERR PFX
"Hardware initialization failed\n");
212 err
= nortel_pci_cor_reset(priv
);
214 printk(KERN_ERR PFX
"Initial reset failed\n");
219 err
= register_netdev(dev
);
221 printk(KERN_ERR PFX
"Cannot register network device\n");
225 pci_set_drvdata(pdev
, dev
);
230 free_irq(pdev
->irq
, dev
);
233 pci_set_drvdata(pdev
, NULL
);
234 free_orinocodev(dev
);
237 pci_iounmap(pdev
, iomem
);
240 pci_release_regions(pdev
);
243 pci_disable_device(pdev
);
248 static void __devexit
nortel_pci_remove_one(struct pci_dev
*pdev
)
250 struct net_device
*dev
= pci_get_drvdata(pdev
);
251 struct orinoco_private
*priv
= netdev_priv(dev
);
252 struct nortel_pci_card
*card
= priv
->card
;
255 outw_p(0, card
->iobase1
+ 10);
257 unregister_netdev(dev
);
258 free_irq(dev
->irq
, dev
);
259 pci_set_drvdata(pdev
, NULL
);
260 free_orinocodev(dev
);
261 pci_iounmap(pdev
, priv
->hw
.iobase
);
262 pci_release_regions(pdev
);
263 pci_disable_device(pdev
);
267 static struct pci_device_id nortel_pci_id_table
[] = {
268 /* Nortel emobility PCI */
269 {0x126c, 0x8030, PCI_ANY_ID
, PCI_ANY_ID
,},
270 /* Symbol LA-4123 PCI */
271 {0x1562, 0x0001, PCI_ANY_ID
, PCI_ANY_ID
,},
275 MODULE_DEVICE_TABLE(pci
, nortel_pci_id_table
);
277 static struct pci_driver nortel_pci_driver
= {
279 .id_table
= nortel_pci_id_table
,
280 .probe
= nortel_pci_init_one
,
281 .remove
= __devexit_p(nortel_pci_remove_one
),
284 static char version
[] __initdata
= DRIVER_NAME
" " DRIVER_VERSION
285 " (Tobias Hoffmann & Christoph Jungegger <disdos@traum404.de>)";
286 MODULE_AUTHOR("Christoph Jungegger <disdos@traum404.de>");
288 ("Driver for wireless LAN cards using the Nortel PCI bridge");
289 MODULE_LICENSE("Dual MPL/GPL");
291 static int __init
nortel_pci_init(void)
293 printk(KERN_DEBUG
"%s\n", version
);
294 return pci_module_init(&nortel_pci_driver
);
297 static void __exit
nortel_pci_exit(void)
299 pci_unregister_driver(&nortel_pci_driver
);
303 module_init(nortel_pci_init
);
304 module_exit(nortel_pci_exit
);