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 "islpci_dev.h"
28 #include "islpci_mgt.h" /* for pc_debug */
31 #define DRV_NAME "prism54"
32 #define DRV_VERSION "1.1"
34 MODULE_AUTHOR("[Intersil] R.Bastings and W.Termorshuizen, The prism54.org Development Team <prism54-devel@prism54.org>");
35 MODULE_DESCRIPTION("The Prism54 802.11 Wireless LAN adapter");
36 MODULE_LICENSE("GPL");
38 /* In this order: vendor, device, subvendor, subdevice, class, class_mask,
40 * Note: for driver_data we put the device's name
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[] = {
45 PCIVENDOR_3COM, PCIDEVICE_3COM6001,
46 PCIVENDOR_3COM, PCIDEVICE_3COM6001,
48 (unsigned long) "3COM 3CRWE154G72 Wireless LAN adapter"},
50 PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890,
51 PCIVENDOR_DLINK, 0x3202UL,
53 (unsigned long) "D-Link Air Plus Xtreme G A1 - DWL-g650 A1"},
55 PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890,
56 PCIVENDOR_IODATA, 0xd019UL,
58 (unsigned long) "I-O Data WN-G54/CB - WN-G54/CB"},
60 PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890,
61 PCIVENDOR_NETGEAR, 0x4800UL,
63 (unsigned long) "Netgear WG511"},
65 PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890,
66 PCIVENDOR_I4, 0x0020UL,
68 (unsigned long) "PLANEX GW-DS54G"},
70 PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890,
71 PCIVENDOR_SMC, 0x2802UL,
73 (unsigned long) "EZ Connect g 2.4GHz 54 Mbps Wireless PCI Card - SMC2802W"},
75 PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890,
76 PCIVENDOR_SMC, 0x2835UL,
78 (unsigned long) "EZ Connect g 2.4GHz 54 Mbps Wireless Cardbus Adapter - SMC2835W"},
80 PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890,
81 PCIVENDOR_INTERSIL, 0x0000UL, /* This was probably a bogus reading... */
83 (unsigned long) "SparkLAN WL-850F"},
85 PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890,
86 PCIVENDOR_I4, 0x0014UL,
88 (unsigned long) "I4 Z-Com XG-600"},
90 PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890,
91 PCIVENDOR_I4, 0x0020UL,
93 (unsigned long) "I4 Z-Com XG-900/PLANEX GW-DS54G"},
95 PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890,
96 PCIVENDOR_ACCTON, 0xee03UL,
98 (unsigned long) "SMC 2802Wv2"},
100 PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890,
101 PCIVENDOR_SMC, 0xa835UL,
103 (unsigned long) "SMC 2835Wv2"},
105 PCIVENDOR_INTERSIL, PCIDEVICE_ISL3877,
106 PCI_ANY_ID, PCI_ANY_ID,
108 (unsigned long) "Intersil PRISM Indigo Wireless LAN adapter"},
110 PCIVENDOR_INTERSIL, PCIDEVICE_ISL3890,
111 PCI_ANY_ID, PCI_ANY_ID,
113 (unsigned long) "Intersil PRISM Duette/Prism GT Wireless LAN adapter"},
117 /* register the device with the Hotplug facilities of the kernel */
118 MODULE_DEVICE_TABLE(pci, prism54_id_tbl);
120 static int prism54_probe(struct pci_dev *, const struct pci_device_id *);
121 static void prism54_remove(struct pci_dev *);
122 static int prism54_suspend(struct pci_dev *, u32 state);
123 static int prism54_resume(struct pci_dev *);
125 static struct pci_driver prism54_driver = {
127 .id_table = prism54_id_tbl,
128 .probe = prism54_probe,
129 .remove = prism54_remove,
130 .suspend = prism54_suspend,
131 .resume = prism54_resume,
132 /* .enable_wake ; we don't support this yet */
136 prism54_get_card_model(struct net_device *ndev)
138 islpci_private *priv;
141 priv = netdev_priv(ndev);
142 switch (priv->pdev->subsystem_device) {
143 case PCIDEVICE_ISL3877:
144 modelp = "PRISM Indigo";
146 case PCIDEVICE_3COM6001:
147 modelp = "3COM 3CRWE154G72";
150 modelp = "D-Link DWL-g650 A1";
153 modelp = "WN-G54/CB";
156 modelp = "Netgear WG511";
162 modelp = "SMC2802W V2";
168 modelp = "SMC2835W V2";
170 /* Let's leave this one out for now since it seems bogus/wrong
171 * Even if the manufacturer did use 0x0000UL it may not be correct
172 * by their part, therefore deserving no name ;) */
174 * modelp = "SparkLAN WL-850F";
177 /* We have two reported for the one below :( */
182 modelp = "XG-900/GW-DS54G";
186 case PCIDEVICE_ISL3890:
187 modelp = "PRISM Duette/GT";
191 modelp = "PRISM Duette/GT";
193 printk(KERN_DEBUG "%s: %s driver detected card model: %s\n",
194 ndev->name, DRV_NAME, modelp);
198 /******************************************************************************
199 Module initialization functions
200 ******************************************************************************/
203 prism54_probe(struct pci_dev *pdev, const struct pci_device_id *id)
205 struct net_device *ndev;
208 islpci_private *priv;
211 /* TRACE(DRV_NAME); */
214 /* Enable the pci device */
215 if (pci_enable_device(pdev)) {
216 printk(KERN_ERR "%s: pci_enable_device() failed.\n", DRV_NAME);
220 /* check whether the latency timer is set correctly */
221 pci_read_config_byte(pdev, PCI_LATENCY_TIMER, &latency_tmr);
222 #if VERBOSE > SHOW_ERROR_MESSAGES
223 DEBUG(SHOW_TRACING, "latency timer: %x\n", latency_tmr);
225 if (latency_tmr < PCIDEVICE_LATENCY_TIMER_MIN) {
226 /* set the latency timer */
227 pci_write_config_byte(pdev, PCI_LATENCY_TIMER,
228 PCIDEVICE_LATENCY_TIMER_VAL);
232 if (pci_set_dma_mask(pdev, 0xffffffff)) {
233 printk(KERN_ERR "%s: 32-bit PCI DMA not supported", DRV_NAME);
234 goto do_pci_disable_device;
237 /* 0x40 is the programmable timer to configure the response timeout (TRDY_TIMEOUT)
238 * 0x41 is the programmable timer to configure the retry timeout (RETRY_TIMEOUT)
239 * The RETRY_TIMEOUT is used to set the number of retries that the core, as a
240 * Master, will perform before abandoning a cycle. The default value for
241 * RETRY_TIMEOUT is 0x80, which far exceeds the PCI 2.1 requirement for new
242 * devices. A write of zero to the RETRY_TIMEOUT register disables this
243 * function to allow use with any non-compliant legacy devices that may
244 * execute more retries.
246 * Writing zero to both these two registers will disable both timeouts and
247 * *can* solve problems caused by devices that are slow to respond.
249 pci_write_config_byte(pdev, 0x40, 0);
250 pci_write_config_byte(pdev, 0x41, 0);
252 /* request the pci device I/O regions */
253 rvalue = pci_request_regions(pdev, DRV_NAME);
255 printk(KERN_ERR "%s: pci_request_regions failure (rc=%d)\n",
257 goto do_pci_disable_device;
260 /* check if the memory window is indeed set */
261 rvalue = pci_read_config_dword(pdev, PCI_BASE_ADDRESS_0, &mem_addr);
262 if (rvalue || !mem_addr) {
263 printk(KERN_ERR "%s: PCI device memory region not configured; fix your BIOS or CardBus bridge/drivers\n",
265 goto do_pci_disable_device;
268 /* enable PCI bus-mastering */
269 DEBUG(SHOW_TRACING, "%s: pci_set_master(pdev)\n", DRV_NAME);
270 pci_set_master(pdev);
272 /* setup the network device interface and its structure */
273 if (!(ndev = islpci_setup(pdev))) {
274 /* error configuring the driver as a network device */
275 printk(KERN_ERR "%s: could not configure network device\n",
277 goto do_pci_release_regions;
280 priv = netdev_priv(ndev);
281 islpci_set_state(priv, PRV_STATE_PREBOOT); /* we are attempting to boot */
283 /* card is in unknown state yet, might have some interrupts pending */
284 isl38xx_disable_interrupts(priv->device_base);
286 /* request for the interrupt before uploading the firmware */
287 rvalue = request_irq(pdev->irq, &islpci_interrupt,
288 SA_SHIRQ, ndev->name, priv);
291 /* error, could not hook the handler to the irq */
292 printk(KERN_ERR "%s: could not install IRQ handler\n",
294 goto do_unregister_netdev;
297 /* firmware upload is triggered in islpci_open */
299 /* Pretty card model discovery output */
300 prism54_get_card_model(ndev);
304 do_unregister_netdev:
305 unregister_netdev(ndev);
306 islpci_free_memory(priv);
307 pci_set_drvdata(pdev, 0);
310 do_pci_release_regions:
311 pci_release_regions(pdev);
312 do_pci_disable_device:
313 pci_disable_device(pdev);
317 /* set by cleanup_module */
318 static volatile int __in_cleanup_module = 0;
320 /* this one removes one(!!) instance only */
322 prism54_remove(struct pci_dev *pdev)
324 struct net_device *ndev = pci_get_drvdata(pdev);
325 islpci_private *priv = ndev ? netdev_priv(ndev) : 0;
328 if (!__in_cleanup_module) {
329 printk(KERN_DEBUG "%s: hot unplug detected\n", ndev->name);
330 islpci_set_state(priv, PRV_STATE_OFF);
333 printk(KERN_DEBUG "%s: removing device\n", ndev->name);
335 unregister_netdev(ndev);
337 /* free the interrupt request */
339 if (islpci_get_state(priv) != PRV_STATE_OFF) {
340 isl38xx_disable_interrupts(priv->device_base);
341 islpci_set_state(priv, PRV_STATE_OFF);
342 /* This bellow causes a lockup at rmmod time. It might be
343 * because some interrupts still linger after rmmod time,
345 /* pci_set_power_state(pdev, 3);*/ /* try to power-off */
348 free_irq(pdev->irq, priv);
350 /* free the PCI memory and unmap the remapped page */
351 islpci_free_memory(priv);
353 pci_set_drvdata(pdev, 0);
357 pci_release_regions(pdev);
359 pci_disable_device(pdev);
363 prism54_suspend(struct pci_dev *pdev, u32 state)
365 struct net_device *ndev = pci_get_drvdata(pdev);
366 islpci_private *priv = ndev ? netdev_priv(ndev) : 0;
369 printk(KERN_NOTICE "%s: got suspend request (state %d)\n",
372 pci_save_state(pdev, priv->pci_state);
374 /* tell the device not to trigger interrupts for now... */
375 isl38xx_disable_interrupts(priv->device_base);
377 /* from now on assume the hardware was already powered down
378 and don't touch it anymore */
379 islpci_set_state(priv, PRV_STATE_OFF);
381 netif_stop_queue(ndev);
382 netif_device_detach(ndev);
388 prism54_resume(struct pci_dev *pdev)
390 struct net_device *ndev = pci_get_drvdata(pdev);
391 islpci_private *priv = ndev ? netdev_priv(ndev) : 0;
394 printk(KERN_NOTICE "%s: got resume request\n", ndev->name);
396 pci_restore_state(pdev, priv->pci_state);
398 /* alright let's go into the PREBOOT state */
399 islpci_reset(priv, 1);
401 netif_device_attach(ndev);
402 netif_start_queue(ndev);
408 prism54_module_init(void)
410 printk(KERN_INFO "Loaded %s driver, version %s\n",
411 DRV_NAME, DRV_VERSION);
413 __bug_on_wrong_struct_sizes ();
415 return pci_module_init(&prism54_driver);
418 /* by the time prism54_module_exit() terminates, as a postcondition
419 * all instances will have been destroyed by calls to
420 * prism54_remove() */
422 prism54_module_exit(void)
424 __in_cleanup_module = 1;
426 pci_unregister_driver(&prism54_driver);
428 printk(KERN_INFO "Unloaded %s driver\n", DRV_NAME);
430 __in_cleanup_module = 0;
433 /* register entry points */
434 module_init(prism54_module_init);
435 module_exit(prism54_module_exit);