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.
7 * Copyright (C) 2002 Tobias Hoffmann
8 * (C) 2003 Christoph Jungegger <disdos@traum404.de>
10 * Some of this code is borrowed from orinoco_plx.c
11 * Copyright (C) 2001 Daniel Barlow
12 * Some of this code is borrowed from orinoco_pci.c
13 * Copyright (C) 2001 Jean Tourrilhes
14 * Some of this code is "inspired" by linux-wlan-ng-0.1.10, but nothing
15 * has been copied from it. linux-wlan-ng-0.1.10 is originally :
16 * Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
18 * The contents of this file are subject to the Mozilla Public License
19 * Version 1.1 (the "License"); you may not use this file except in
20 * compliance with the License. You may obtain a copy of the License
21 * at http://www.mozilla.org/MPL/
23 * Software distributed under the License is distributed on an "AS IS"
24 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
25 * the License for the specific language governing rights and
26 * limitations under the License.
28 * Alternatively, the contents of this file may be used under the
29 * terms of the GNU General Public License version 2 (the "GPL"), in
30 * which case the provisions of the GPL are applicable instead of the
31 * above. If you wish to allow the use of your version of this file
32 * only under the terms of the GPL and not to allow others to use your
33 * version of this file under the MPL, indicate your decision by
34 * deleting the provisions above and replace them with the notice and
35 * other provisions required by the GPL. If you do not delete the
36 * provisions above, a recipient may use your version of this file
37 * under either the MPL or the GPL.
40 #define DRIVER_NAME "orinoco_nortel"
41 #define PFX DRIVER_NAME ": "
43 #include <linux/config.h>
44 #include <linux/module.h>
45 #include <linux/kernel.h>
46 #include <linux/init.h>
47 #include <linux/delay.h>
48 #include <linux/pci.h>
49 #include <pcmcia/cisreg.h>
52 #include "orinoco_pci.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 */
59 * Do a soft reset of the card using the Configuration Option Register
60 * We need this to get going...
61 * This is the part of the code that is strongly inspired from wlan-ng
63 * Note bis : Don't try to access HERMES_CMD during the reset phase.
64 * It just won't work !
66 static int orinoco_nortel_cor_reset(struct orinoco_private
*priv
)
68 struct orinoco_pci_card
*card
= priv
->card
;
70 /* Assert the reset until the card notices */
71 iowrite16(8, card
->bridge_io
+ 2);
72 ioread16(card
->attr_io
+ COR_OFFSET
);
73 iowrite16(0x80, card
->attr_io
+ COR_OFFSET
);
76 /* Give time for the card to recover from this hard effort */
77 iowrite16(0, card
->attr_io
+ COR_OFFSET
);
78 iowrite16(0, card
->attr_io
+ COR_OFFSET
);
81 /* Set COR as usual */
82 iowrite16(COR_VALUE
, card
->attr_io
+ COR_OFFSET
);
83 iowrite16(COR_VALUE
, card
->attr_io
+ COR_OFFSET
);
86 iowrite16(0x228, card
->bridge_io
+ 2);
91 static int orinoco_nortel_hw_init(struct orinoco_pci_card
*card
)
97 if (ioread16(card
->bridge_io
) & 1) {
98 printk(KERN_ERR PFX
"brg1 answer1 wrong\n");
101 iowrite16(0x118, card
->bridge_io
+ 2);
102 iowrite16(0x108, card
->bridge_io
+ 2);
104 iowrite16(0x8, card
->bridge_io
+ 2);
105 for (i
= 0; i
< 30; i
++) {
107 if (ioread16(card
->bridge_io
) & 0x10) {
112 printk(KERN_ERR PFX
"brg1 timed out\n");
115 if (ioread16(card
->attr_io
+ COR_OFFSET
) & 1) {
116 printk(KERN_ERR PFX
"brg2 answer1 wrong\n");
119 if (ioread16(card
->attr_io
+ COR_OFFSET
+ 2) & 1) {
120 printk(KERN_ERR PFX
"brg2 answer2 wrong\n");
123 if (ioread16(card
->attr_io
+ COR_OFFSET
+ 4) & 1) {
124 printk(KERN_ERR PFX
"brg2 answer3 wrong\n");
128 /* Set the PCMCIA COR register */
129 iowrite16(COR_VALUE
, card
->attr_io
+ COR_OFFSET
);
131 reg
= ioread16(card
->attr_io
+ COR_OFFSET
);
132 if (reg
!= COR_VALUE
) {
133 printk(KERN_ERR PFX
"Error setting COR value (reg=%x)\n",
139 iowrite16(1, card
->bridge_io
+ 10);
143 static int orinoco_nortel_init_one(struct pci_dev
*pdev
,
144 const struct pci_device_id
*ent
)
147 struct orinoco_private
*priv
;
148 struct orinoco_pci_card
*card
;
149 struct net_device
*dev
;
150 void __iomem
*hermes_io
, *bridge_io
, *attr_io
;
152 err
= pci_enable_device(pdev
);
154 printk(KERN_ERR PFX
"Cannot enable PCI device\n");
158 err
= pci_request_regions(pdev
, DRIVER_NAME
);
160 printk(KERN_ERR PFX
"Cannot obtain PCI resources\n");
164 bridge_io
= pci_iomap(pdev
, 0, 0);
166 printk(KERN_ERR PFX
"Cannot map bridge registers\n");
168 goto fail_map_bridge
;
171 attr_io
= pci_iomap(pdev
, 1, 0);
173 printk(KERN_ERR PFX
"Cannot map PCMCIA attributes\n");
178 hermes_io
= pci_iomap(pdev
, 2, 0);
180 printk(KERN_ERR PFX
"Cannot map chipset registers\n");
182 goto fail_map_hermes
;
185 /* Allocate network device */
186 dev
= alloc_orinocodev(sizeof(*card
), orinoco_nortel_cor_reset
);
188 printk(KERN_ERR PFX
"Cannot allocate network device\n");
193 priv
= netdev_priv(dev
);
195 card
->bridge_io
= bridge_io
;
196 card
->attr_io
= attr_io
;
197 SET_MODULE_OWNER(dev
);
198 SET_NETDEV_DEV(dev
, &pdev
->dev
);
200 hermes_struct_init(&priv
->hw
, hermes_io
, HERMES_16BIT_REGSPACING
);
202 err
= request_irq(pdev
->irq
, orinoco_interrupt
, SA_SHIRQ
,
205 printk(KERN_ERR PFX
"Cannot allocate IRQ %d\n", pdev
->irq
);
210 err
= orinoco_nortel_hw_init(card
);
212 printk(KERN_ERR PFX
"Hardware initialization failed\n");
216 err
= orinoco_nortel_cor_reset(priv
);
218 printk(KERN_ERR PFX
"Initial reset failed\n");
222 err
= register_netdev(dev
);
224 printk(KERN_ERR PFX
"Cannot register network device\n");
228 pci_set_drvdata(pdev
, dev
);
229 printk(KERN_DEBUG
"%s: " DRIVER_NAME
" at %s\n", dev
->name
,
235 free_irq(pdev
->irq
, dev
);
238 pci_set_drvdata(pdev
, NULL
);
239 free_orinocodev(dev
);
242 pci_iounmap(pdev
, hermes_io
);
245 pci_iounmap(pdev
, attr_io
);
248 pci_iounmap(pdev
, bridge_io
);
251 pci_release_regions(pdev
);
254 pci_disable_device(pdev
);
259 static void __devexit
orinoco_nortel_remove_one(struct pci_dev
*pdev
)
261 struct net_device
*dev
= pci_get_drvdata(pdev
);
262 struct orinoco_private
*priv
= netdev_priv(dev
);
263 struct orinoco_pci_card
*card
= priv
->card
;
266 iowrite16(0, card
->bridge_io
+ 10);
268 unregister_netdev(dev
);
269 free_irq(pdev
->irq
, dev
);
270 pci_set_drvdata(pdev
, NULL
);
271 free_orinocodev(dev
);
272 pci_iounmap(pdev
, priv
->hw
.iobase
);
273 pci_iounmap(pdev
, card
->attr_io
);
274 pci_iounmap(pdev
, card
->bridge_io
);
275 pci_release_regions(pdev
);
276 pci_disable_device(pdev
);
279 static struct pci_device_id orinoco_nortel_id_table
[] = {
280 /* Nortel emobility PCI */
281 {0x126c, 0x8030, PCI_ANY_ID
, PCI_ANY_ID
,},
282 /* Symbol LA-4123 PCI */
283 {0x1562, 0x0001, PCI_ANY_ID
, PCI_ANY_ID
,},
287 MODULE_DEVICE_TABLE(pci
, orinoco_nortel_id_table
);
289 static struct pci_driver orinoco_nortel_driver
= {
291 .id_table
= orinoco_nortel_id_table
,
292 .probe
= orinoco_nortel_init_one
,
293 .remove
= __devexit_p(orinoco_nortel_remove_one
),
294 .suspend
= orinoco_pci_suspend
,
295 .resume
= orinoco_pci_resume
,
298 static char version
[] __initdata
= DRIVER_NAME
" " DRIVER_VERSION
299 " (Tobias Hoffmann & Christoph Jungegger <disdos@traum404.de>)";
300 MODULE_AUTHOR("Christoph Jungegger <disdos@traum404.de>");
302 ("Driver for wireless LAN cards using the Nortel PCI bridge");
303 MODULE_LICENSE("Dual MPL/GPL");
305 static int __init
orinoco_nortel_init(void)
307 printk(KERN_DEBUG
"%s\n", version
);
308 return pci_module_init(&orinoco_nortel_driver
);
311 static void __exit
orinoco_nortel_exit(void)
313 pci_unregister_driver(&orinoco_nortel_driver
);
316 module_init(orinoco_nortel_init
);
317 module_exit(orinoco_nortel_exit
);