3 * Copyright (C) 2002 Intersil Americas Inc.
4 * Copyright (C) 2003 Herbert Valerio Riedel <hvr@gnu.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include <linux/version.h>
22 #include <linux/module.h>
23 #include <linux/pci.h>
24 #include <linux/delay.h>
25 #include <linux/init.h> /* For __init, __exit */
27 #include "prismcompat.h"
28 #include "islpci_dev.h"
29 #include "islpci_mgt.h" /* for pc_debug */
32 #define DRV_NAME "prism54"
33 #define DRV_VERSION "1.2"
35 MODULE_AUTHOR("[Intersil] R.Bastings and W.Termorshuizen, The prism54.org Development Team <prism54-devel@prism54.org>");
36 MODULE_DESCRIPTION("The Prism54 802.11 Wireless LAN adapter");
37 MODULE_LICENSE("GPL");
39 /* In this order: vendor, device, subvendor, subdevice, class, class_mask,
41 * Note: for driver_data we put the device's name
42 * If you have an update for this please contact prism54-devel@prism54.org
43 * The latest list can be found at http://prism54.org/supported_cards.php */
44 static const struct pci_device_id prism54_id_tbl[] = {
46 PCIVENDOR_3COM, PCIDEVICE_3COM6001,
47 PCIVENDOR_3COM, PCIDEVICE_3COM6001,
49 (unsigned long) "3COM 3CRWE154G72 Wireless LAN adapter"},
51 PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890,
52 PCIVENDOR_DLINK, 0x3202UL,
54 (unsigned long) "D-Link Air Plus Xtreme G A1 - DWL-g650 A1"},
56 PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890,
57 PCIVENDOR_IODATA, 0xd019UL,
59 (unsigned long) "I-O Data WN-G54/CB - WN-G54/CB"},
61 PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890,
62 PCIVENDOR_NETGEAR, 0x4800UL,
64 (unsigned long) "Netgear WG511"},
66 PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890,
67 PCIVENDOR_I4, 0x0020UL,
69 (unsigned long) "PLANEX GW-DS54G"},
71 PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890,
72 PCIVENDOR_SMC, 0x2802UL,
74 (unsigned long) "EZ Connect g 2.4GHz 54 Mbps Wireless PCI Card - SMC2802W"},
76 PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890,
77 PCIVENDOR_SMC, 0x2835UL,
79 (unsigned long) "EZ Connect g 2.4GHz 54 Mbps Wireless Cardbus Adapter - SMC2835W"},
81 PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890,
82 PCIVENDOR_INTERSIL, 0x0000UL, /* This was probably a bogus reading... */
84 (unsigned long) "SparkLAN WL-850F"},
86 PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890,
87 PCIVENDOR_I4, 0x0014UL,
89 (unsigned long) "I4 Z-Com XG-600"},
91 PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890,
92 PCIVENDOR_I4, 0x0020UL,
94 (unsigned long) "I4 Z-Com XG-900/PLANEX GW-DS54G"},
96 PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890,
97 PCIVENDOR_ACCTON, 0xee03UL,
99 (unsigned long) "SMC 2802Wv2"},
101 PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890,
102 PCIVENDOR_SMC, 0xa835UL,
104 (unsigned long) "SMC 2835Wv2"},
106 PCIVENDOR_INTERSIL, PCIDEVICE_ISL3877,
107 PCI_ANY_ID, PCI_ANY_ID,
109 (unsigned long) "Intersil PRISM Indigo Wireless LAN adapter"},
111 PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890,
112 PCI_ANY_ID, PCI_ANY_ID,
114 (unsigned long) "Intersil PRISM Duette/Prism GT Wireless LAN adapter"},
118 /* register the device with the Hotplug facilities of the kernel */
119 MODULE_DEVICE_TABLE(pci, prism54_id_tbl);
121 static int prism54_probe(struct pci_dev *, const struct pci_device_id *);
122 static void prism54_remove(struct pci_dev *);
123 static int prism54_suspend(struct pci_dev *, u32 state);
124 static int prism54_resume(struct pci_dev *);
126 static struct pci_driver prism54_driver = {
128 .id_table = prism54_id_tbl,
129 .probe = prism54_probe,
130 .remove = prism54_remove,
131 .suspend = prism54_suspend,
132 .resume = prism54_resume,
133 /* .enable_wake ; we don't support this yet */
137 prism54_get_card_model(struct net_device *ndev)
139 islpci_private *priv;
142 priv = netdev_priv(ndev);
143 switch (priv->pdev->subsystem_device) {
144 case PCIDEVICE_ISL3877:
145 modelp = "PRISM Indigo";
147 case PCIDEVICE_3COM6001:
148 modelp = "3COM 3CRWE154G72";
151 modelp = "D-Link DWL-g650 A1";
154 modelp = "WN-G54/CB";
157 modelp = "Netgear WG511";
163 modelp = "SMC2802W V2";
169 modelp = "SMC2835W V2";
171 /* Let's leave this one out for now since it seems bogus/wrong
172 * Even if the manufacturer did use 0x0000UL it may not be correct
173 * by their part, therefore deserving no name ;) */
175 * modelp = "SparkLAN WL-850F";
178 /* We have two reported for the one below :( */
183 modelp = "XG-900/GW-DS54G";
187 case PCIDEVICE_ISL3890:
188 modelp = "PRISM Duette/GT";
192 modelp = "PRISM Duette/GT";
194 printk(KERN_DEBUG "%s: %s driver detected card model: %s\n",
195 ndev->name, DRV_NAME, modelp);
199 /******************************************************************************
200 Module initialization functions
201 ******************************************************************************/
204 prism54_probe(struct pci_dev *pdev, const struct pci_device_id *id)
206 struct net_device *ndev;
209 islpci_private *priv;
212 /* TRACE(DRV_NAME); */
215 /* Enable the pci device */
216 if (pci_enable_device(pdev)) {
217 printk(KERN_ERR "%s: pci_enable_device() failed.\n", DRV_NAME);
221 /* check whether the latency timer is set correctly */
222 pci_read_config_byte(pdev, PCI_LATENCY_TIMER, &latency_tmr);
223 #if VERBOSE > SHOW_ERROR_MESSAGES
224 DEBUG(SHOW_TRACING, "latency timer: %x\n", latency_tmr);
226 if (latency_tmr < PCIDEVICE_LATENCY_TIMER_MIN) {
227 /* set the latency timer */
228 pci_write_config_byte(pdev, PCI_LATENCY_TIMER,
229 PCIDEVICE_LATENCY_TIMER_VAL);
233 if (pci_set_dma_mask(pdev, 0xffffffff)) {
234 printk(KERN_ERR "%s: 32-bit PCI DMA not supported", DRV_NAME);
235 goto do_pci_disable_device;
238 /* 0x40 is the programmable timer to configure the response timeout (TRDY_TIMEOUT)
239 * 0x41 is the programmable timer to configure the retry timeout (RETRY_TIMEOUT)
240 * The RETRY_TIMEOUT is used to set the number of retries that the core, as a
241 * Master, will perform before abandoning a cycle. The default value for
242 * RETRY_TIMEOUT is 0x80, which far exceeds the PCI 2.1 requirement for new
243 * devices. A write of zero to the RETRY_TIMEOUT register disables this
244 * function to allow use with any non-compliant legacy devices that may
245 * execute more retries.
247 * Writing zero to both these two registers will disable both timeouts and
248 * *can* solve problems caused by devices that are slow to respond.
250 pci_write_config_byte(pdev, 0x40, 0);
251 pci_write_config_byte(pdev, 0x41, 0);
253 /* request the pci device I/O regions */
254 rvalue = pci_request_regions(pdev, DRV_NAME);
256 printk(KERN_ERR "%s: pci_request_regions failure (rc=%d)\n",
258 goto do_pci_disable_device;
261 /* check if the memory window is indeed set */
262 rvalue = pci_read_config_dword(pdev, PCI_BASE_ADDRESS_0, &mem_addr);
263 if (rvalue || !mem_addr) {
264 printk(KERN_ERR "%s: PCI device memory region not configured; fix your BIOS or CardBus bridge/drivers\n",
266 goto do_pci_disable_device;
269 /* enable PCI bus-mastering */
270 DEBUG(SHOW_TRACING, "%s: pci_set_master(pdev)\n", DRV_NAME);
271 pci_set_master(pdev);
273 /* setup the network device interface and its structure */
274 if (!(ndev = islpci_setup(pdev))) {
275 /* error configuring the driver as a network device */
276 printk(KERN_ERR "%s: could not configure network device\n",
278 goto do_pci_release_regions;
281 priv = netdev_priv(ndev);
282 islpci_set_state(priv, PRV_STATE_PREBOOT); /* we are attempting to boot */
284 /* card is in unknown state yet, might have some interrupts pending */
285 isl38xx_disable_interrupts(priv->device_base);
287 /* request for the interrupt before uploading the firmware */
288 rvalue = request_irq(pdev->irq, &islpci_interrupt,
289 SA_SHIRQ, ndev->name, priv);
292 /* error, could not hook the handler to the irq */
293 printk(KERN_ERR "%s: could not install IRQ handler\n",
295 goto do_unregister_netdev;
298 /* firmware upload is triggered in islpci_open */
300 /* Pretty card model discovery output */
301 prism54_get_card_model(ndev);
305 do_unregister_netdev:
306 unregister_netdev(ndev);
307 islpci_free_memory(priv);
308 pci_set_drvdata(pdev, 0);
311 do_pci_release_regions:
312 pci_release_regions(pdev);
313 do_pci_disable_device:
314 pci_disable_device(pdev);
318 /* set by cleanup_module */
319 static volatile int __in_cleanup_module = 0;
321 /* this one removes one(!!) instance only */
323 prism54_remove(struct pci_dev *pdev)
325 struct net_device *ndev = pci_get_drvdata(pdev);
326 islpci_private *priv = ndev ? netdev_priv(ndev) : 0;
329 if (!__in_cleanup_module) {
330 printk(KERN_DEBUG "%s: hot unplug detected\n", ndev->name);
331 islpci_set_state(priv, PRV_STATE_OFF);
334 printk(KERN_DEBUG "%s: removing device\n", ndev->name);
336 unregister_netdev(ndev);
338 /* free the interrupt request */
340 if (islpci_get_state(priv) != PRV_STATE_OFF) {
341 isl38xx_disable_interrupts(priv->device_base);
342 islpci_set_state(priv, PRV_STATE_OFF);
343 /* This bellow causes a lockup at rmmod time. It might be
344 * because some interrupts still linger after rmmod time,
346 /* pci_set_power_state(pdev, 3);*/ /* try to power-off */
349 free_irq(pdev->irq, priv);
351 /* free the PCI memory and unmap the remapped page */
352 islpci_free_memory(priv);
354 pci_set_drvdata(pdev, 0);
358 pci_release_regions(pdev);
360 pci_disable_device(pdev);
364 prism54_suspend(struct pci_dev *pdev, u32 state)
366 struct net_device *ndev = pci_get_drvdata(pdev);
367 islpci_private *priv = ndev ? netdev_priv(ndev) : 0;
370 printk(KERN_NOTICE "%s: got suspend request (state %d)\n",
373 pci_save_state(pdev, priv->pci_state);
375 /* tell the device not to trigger interrupts for now... */
376 isl38xx_disable_interrupts(priv->device_base);
378 /* from now on assume the hardware was already powered down
379 and don't touch it anymore */
380 islpci_set_state(priv, PRV_STATE_OFF);
382 netif_stop_queue(ndev);
383 netif_device_detach(ndev);
389 prism54_resume(struct pci_dev *pdev)
391 struct net_device *ndev = pci_get_drvdata(pdev);
392 islpci_private *priv = ndev ? netdev_priv(ndev) : 0;
395 printk(KERN_NOTICE "%s: got resume request\n", ndev->name);
397 pci_restore_state(pdev, priv->pci_state);
399 /* alright let's go into the PREBOOT state */
400 islpci_reset(priv, 1);
402 netif_device_attach(ndev);
403 netif_start_queue(ndev);
409 prism54_module_init(void)
411 printk(KERN_INFO "Loaded %s driver, version %s\n",
412 DRV_NAME, DRV_VERSION);
414 __bug_on_wrong_struct_sizes ();
416 return pci_module_init(&prism54_driver);
419 /* by the time prism54_module_exit() terminates, as a postcondition
420 * all instances will have been destroyed by calls to
421 * prism54_remove() */
423 prism54_module_exit(void)
425 __in_cleanup_module = 1;
427 pci_unregister_driver(&prism54_driver);
429 printk(KERN_INFO "Unloaded %s driver\n", DRV_NAME);
431 __in_cleanup_module = 0;
434 /* register entry points */
435 module_init(prism54_module_init);
436 module_exit(prism54_module_exit);