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 * If you have an update for this please contact prism54-devel@prism54.org
42 * The latest list can be found at http://prism54.org/supported_cards.php */
43 static const struct pci_device_id prism54_id_tbl[] = {
44 /* 3COM 3CRWE154G72 Wireless LAN adapter */
46 PCIVENDOR_3COM, PCIDEVICE_3COM6001,
47 PCIVENDOR_3COM, PCIDEVICE_3COM6001,
51 /* D-Link Air Plus Xtreme G A1 - DWL-g650 A1 */
53 PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890,
54 PCIVENDOR_DLINK, 0x3202UL,
58 /* I-O Data WN-G54/CB - WN-G54/CB */
60 PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890,
61 PCIVENDOR_IODATA, 0xd019UL,
67 PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890,
68 PCIVENDOR_NETGEAR, 0x4800UL,
72 /* Tekram Technology clones, Allnet, Netcomm, Zyxel */
74 PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890,
75 PCIVENDOR_TTL, 0x1605UL,
81 PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890,
82 PCIVENDOR_SMC, 0x2802UL,
88 PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890,
89 PCIVENDOR_SMC, 0x2835UL,
93 /* Corega CG-WLCB54GT */
95 PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890,
96 PCIVENDOR_ATI, 0xc104UL,
100 /* I4 Z-Com XG-600 */
102 PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890,
103 PCIVENDOR_I4, 0x0014UL,
107 /* I4 Z-Com XG-900 and clones Macer, Ovislink, Planex, Peabird, */
108 /* Sitecom, Xterasys */
110 PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890,
111 PCIVENDOR_I4, 0x0020UL,
117 PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890,
118 PCIVENDOR_ACCTON, 0xee03UL,
124 PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890,
125 PCIVENDOR_SMC, 0xa835UL,
129 /* Intersil PRISM Indigo Wireless LAN adapter */
131 PCIVENDOR_INTERSIL, PCIDEVICE_ISL3877,
132 PCI_ANY_ID, PCI_ANY_ID,
136 /* Intersil PRISM Duette/Prism GT Wireless LAN adapter */
139 PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890,
140 PCI_ANY_ID, PCI_ANY_ID,
148 /* register the device with the Hotplug facilities of the kernel */
149 MODULE_DEVICE_TABLE(pci, prism54_id_tbl);
151 static int prism54_probe(struct pci_dev *, const struct pci_device_id *);
152 static void prism54_remove(struct pci_dev *);
153 static int prism54_suspend(struct pci_dev *, u32 state);
154 static int prism54_resume(struct pci_dev *);
156 static struct pci_driver prism54_driver = {
158 .id_table = prism54_id_tbl,
159 .probe = prism54_probe,
160 .remove = prism54_remove,
161 .suspend = prism54_suspend,
162 .resume = prism54_resume,
163 /* .enable_wake ; we don't support this yet */
167 prism54_get_card_model(struct net_device *ndev)
169 islpci_private *priv;
173 priv = netdev_priv(ndev);
174 switch (priv->pdev->subsystem_device) {
175 case PCIDEVICE_ISL3877:
176 modelp = "PRISM Indigo";
178 case PCIDEVICE_ISL3886:
179 modelp = "PRISM Javelin / Xbow";
181 case PCIDEVICE_3COM6001:
182 modelp = "3COM 3CRWE154G72";
185 modelp = "D-Link DWL-g650 A1";
188 modelp = "WN-G54/CB";
191 modelp = "Netgear WG511";
197 modelp = "SMC2802W V2";
204 modelp = "SMC2835W V2";
208 modelp = "CG-WLCB54GT";
211 modelp = "Tekram Technology clone";
213 /* Let's leave this one out for now since it seems bogus/wrong
214 * Even if the manufacturer did use 0x0000UL it may not be correct
215 * by their part, therefore deserving no name ;) */
217 * modelp = "SparkLAN WL-850F";
220 /* We have two reported for the one below :( */
222 modelp = "I4 Z-Com XG-600 and clones";
225 modelp = "I4 Z-Com XG-900 and clones";
229 case PCIDEVICE_ISL3890:
230 modelp = "PRISM Duette/GT";
234 modelp = "PRISM Duette/GT";
236 printk(KERN_DEBUG "%s: %s driver detected card model: %s\n",
237 ndev->name, DRV_NAME, modelp);
239 printk(KERN_DEBUG "%s: %s Warning - This may not work\n",
240 ndev->name, DRV_NAME);
245 /******************************************************************************
246 Module initialization functions
247 ******************************************************************************/
250 prism54_probe(struct pci_dev *pdev, const struct pci_device_id *id)
252 struct net_device *ndev;
255 islpci_private *priv;
258 /* TRACE(DRV_NAME); */
261 /* Enable the pci device */
262 if (pci_enable_device(pdev)) {
263 printk(KERN_ERR "%s: pci_enable_device() failed.\n", DRV_NAME);
267 /* check whether the latency timer is set correctly */
268 pci_read_config_byte(pdev, PCI_LATENCY_TIMER, &latency_tmr);
269 #if VERBOSE > SHOW_ERROR_MESSAGES
270 DEBUG(SHOW_TRACING, "latency timer: %x\n", latency_tmr);
272 if (latency_tmr < PCIDEVICE_LATENCY_TIMER_MIN) {
273 /* set the latency timer */
274 pci_write_config_byte(pdev, PCI_LATENCY_TIMER,
275 PCIDEVICE_LATENCY_TIMER_VAL);
279 if (pci_set_dma_mask(pdev, 0xffffffff)) {
280 printk(KERN_ERR "%s: 32-bit PCI DMA not supported", DRV_NAME);
281 goto do_pci_disable_device;
284 /* 0x40 is the programmable timer to configure the response timeout (TRDY_TIMEOUT)
285 * 0x41 is the programmable timer to configure the retry timeout (RETRY_TIMEOUT)
286 * The RETRY_TIMEOUT is used to set the number of retries that the core, as a
287 * Master, will perform before abandoning a cycle. The default value for
288 * RETRY_TIMEOUT is 0x80, which far exceeds the PCI 2.1 requirement for new
289 * devices. A write of zero to the RETRY_TIMEOUT register disables this
290 * function to allow use with any non-compliant legacy devices that may
291 * execute more retries.
293 * Writing zero to both these two registers will disable both timeouts and
294 * *can* solve problems caused by devices that are slow to respond.
296 /* I am taking these out, we should not be poking around in the
297 * programmable timers - MSW
299 /* Do not zero the programmable timers
300 pci_write_config_byte(pdev, 0x40, 0);
301 pci_write_config_byte(pdev, 0x41, 0);
304 /* request the pci device I/O regions */
305 rvalue = pci_request_regions(pdev, DRV_NAME);
307 printk(KERN_ERR "%s: pci_request_regions failure (rc=%d)\n",
309 goto do_pci_disable_device;
312 /* check if the memory window is indeed set */
313 rvalue = pci_read_config_dword(pdev, PCI_BASE_ADDRESS_0, &mem_addr);
314 if (rvalue || !mem_addr) {
315 printk(KERN_ERR "%s: PCI device memory region not configured; fix your BIOS or CardBus bridge/drivers\n",
317 goto do_pci_disable_device;
320 /* enable PCI bus-mastering */
321 DEBUG(SHOW_TRACING, "%s: pci_set_master(pdev)\n", DRV_NAME);
322 pci_set_master(pdev);
327 /* setup the network device interface and its structure */
328 if (!(ndev = islpci_setup(pdev))) {
329 /* error configuring the driver as a network device */
330 printk(KERN_ERR "%s: could not configure network device\n",
332 goto do_pci_release_regions;
335 priv = netdev_priv(ndev);
336 islpci_set_state(priv, PRV_STATE_PREBOOT); /* we are attempting to boot */
338 /* card is in unknown state yet, might have some interrupts pending */
339 isl38xx_disable_interrupts(priv->device_base);
341 /* request for the interrupt before uploading the firmware */
342 rvalue = request_irq(pdev->irq, &islpci_interrupt,
343 SA_SHIRQ, ndev->name, priv);
346 /* error, could not hook the handler to the irq */
347 printk(KERN_ERR "%s: could not install IRQ handler\n",
349 goto do_unregister_netdev;
352 /* firmware upload is triggered in islpci_open */
354 /* Pretty card model discovery output */
355 prism54_get_card_model(ndev);
359 do_unregister_netdev:
360 unregister_netdev(ndev);
361 islpci_free_memory(priv);
362 pci_set_drvdata(pdev, 0);
365 do_pci_release_regions:
366 pci_release_regions(pdev);
367 do_pci_disable_device:
368 pci_disable_device(pdev);
372 /* set by cleanup_module */
373 static volatile int __in_cleanup_module = 0;
375 /* this one removes one(!!) instance only */
377 prism54_remove(struct pci_dev *pdev)
379 struct net_device *ndev = pci_get_drvdata(pdev);
380 islpci_private *priv = ndev ? netdev_priv(ndev) : 0;
383 if (!__in_cleanup_module) {
384 printk(KERN_DEBUG "%s: hot unplug detected\n", ndev->name);
385 islpci_set_state(priv, PRV_STATE_OFF);
388 printk(KERN_DEBUG "%s: removing device\n", ndev->name);
390 unregister_netdev(ndev);
392 /* free the interrupt request */
394 if (islpci_get_state(priv) != PRV_STATE_OFF) {
395 isl38xx_disable_interrupts(priv->device_base);
396 islpci_set_state(priv, PRV_STATE_OFF);
397 /* This bellow causes a lockup at rmmod time. It might be
398 * because some interrupts still linger after rmmod time,
400 /* pci_set_power_state(pdev, 3);*/ /* try to power-off */
403 free_irq(pdev->irq, priv);
405 /* free the PCI memory and unmap the remapped page */
406 islpci_free_memory(priv);
408 pci_set_drvdata(pdev, 0);
412 pci_release_regions(pdev);
414 pci_disable_device(pdev);
418 prism54_suspend(struct pci_dev *pdev, u32 state)
420 struct net_device *ndev = pci_get_drvdata(pdev);
421 islpci_private *priv = ndev ? netdev_priv(ndev) : 0;
424 printk(KERN_NOTICE "%s: got suspend request (state %d)\n",
427 pci_save_state(pdev, priv->pci_state);
429 /* tell the device not to trigger interrupts for now... */
430 isl38xx_disable_interrupts(priv->device_base);
432 /* from now on assume the hardware was already powered down
433 and don't touch it anymore */
434 islpci_set_state(priv, PRV_STATE_OFF);
436 netif_stop_queue(ndev);
437 netif_device_detach(ndev);
443 prism54_resume(struct pci_dev *pdev)
445 struct net_device *ndev = pci_get_drvdata(pdev);
446 islpci_private *priv = ndev ? netdev_priv(ndev) : 0;
449 printk(KERN_NOTICE "%s: got resume request\n", ndev->name);
451 pci_restore_state(pdev, priv->pci_state);
453 /* alright let's go into the PREBOOT state */
454 islpci_reset(priv, 1);
456 netif_device_attach(ndev);
457 netif_start_queue(ndev);
463 prism54_module_init(void)
465 printk(KERN_INFO "Loaded %s driver, version %s\n",
466 DRV_NAME, DRV_VERSION);
468 __bug_on_wrong_struct_sizes ();
470 return pci_module_init(&prism54_driver);
473 /* by the time prism54_module_exit() terminates, as a postcondition
474 * all instances will have been destroyed by calls to
475 * prism54_remove() */
477 prism54_module_exit(void)
479 __in_cleanup_module = 1;
481 pci_unregister_driver(&prism54_driver);
483 printk(KERN_INFO "Unloaded %s driver\n", DRV_NAME);
485 __in_cleanup_module = 0;
488 /* register entry points */
489 module_init(prism54_module_init);
490 module_exit(prism54_module_exit);