1 /*******************************************************************************
3 * Wireless device driver for Linux (wlags49).
5 * Copyright (c) 1998-2003 Agere Systems Inc.
9 * Initially developed by TriplePoint, Inc.
10 * http://www.triplepoint.com
12 *------------------------------------------------------------------------------
14 * This file contains processing and initialization specific to Card Services
15 * devices (PCMCIA, CF).
17 *------------------------------------------------------------------------------
21 * This software is provided subject to the following terms and conditions,
22 * which you should read carefully before using the software. Using this
23 * software indicates your acceptance of these terms and conditions. If you do
24 * not agree with these terms and conditions, do not use the software.
26 * Copyright (c) 2003 Agere Systems Inc.
27 * All rights reserved.
29 * Redistribution and use in source or binary forms, with or without
30 * modifications, are permitted provided that the following conditions are met:
32 * . Redistributions of source code must retain the above copyright notice, this
33 * list of conditions and the following Disclaimer as comments in the code as
34 * well as in the documentation and/or other materials provided with the
37 * . Redistributions in binary form must reproduce the above copyright notice,
38 * this list of conditions and the following Disclaimer in the documentation
39 * and/or other materials provided with the distribution.
41 * . Neither the name of Agere Systems Inc. nor the names of the contributors
42 * may be used to endorse or promote products derived from this software
43 * without specific prior written permission.
47 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
48 * INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF
49 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY
50 * USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN
51 * RISK. IN NO EVENT SHALL AGERE SYSTEMS INC. OR CONTRIBUTORS BE LIABLE FOR ANY
52 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
53 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
54 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
55 * ON ANY THEORY OF LIABILITY, INCLUDING, BUT NOT LIMITED TO, CONTRACT, STRICT
56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
57 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
60 ******************************************************************************/
62 /*******************************************************************************
64 ******************************************************************************/
65 #include <wl_version.h>
67 #include <linux/kernel.h>
68 #include <linux/sched.h>
69 #include <linux/ptrace.h>
70 #include <linux/ctype.h>
71 #include <linux/string.h>
72 #include <linux/timer.h>
73 #include <linux/interrupt.h>
75 #include <linux/delay.h>
77 #include <asm/bitops.h>
79 #include <linux/netdevice.h>
80 #include <linux/etherdevice.h>
81 #include <linux/skbuff.h>
82 #include <linux/if_arp.h>
83 #include <linux/ioport.h>
84 #include <linux/module.h>
86 #include <pcmcia/cistpl.h>
87 #include <pcmcia/cisreg.h>
88 #include <pcmcia/ciscode.h>
89 #include <pcmcia/ds.h>
97 #include <wl_internal.h>
100 #include <wl_netdev.h>
104 /*******************************************************************************
106 ******************************************************************************/
108 extern dbg_info_t *DbgInfo;
112 /*******************************************************************************
113 * wl_adapter_attach()
114 *******************************************************************************
118 * Creates an instance of the driver, allocating local data structures for
119 * one device. The device is registered with Card Services.
127 * pointer to an allocated dev_link_t structure
130 ******************************************************************************/
131 static int wl_adapter_attach(struct pcmcia_device *link)
133 struct net_device *dev;
134 struct wl_private *lp;
137 dev = wl_device_alloc();
139 DBG_ERROR(DbgInfo, "wl_device_alloc returned NULL\n");
143 link->resource[0]->end = HCF_NUM_IO_PORTS;
144 link->resource[0]->flags= IO_DATA_PATH_WIDTH_16;
145 link->config_flags |= CONF_ENABLE_IRQ;
146 link->config_index = 5;
147 link->config_regs = PRESENT_OPTION;
153 ret = wl_adapter_insert(link);
155 wl_device_dealloc(dev);
158 } /* wl_adapter_attach */
159 /*============================================================================*/
163 static void wl_adapter_detach(struct pcmcia_device *link)
165 struct net_device *dev = link->priv;
167 DBG_PARAM(DbgInfo, "link", "0x%p", link);
169 wl_adapter_release(link);
172 unregister_netdev(dev);
173 wl_device_dealloc(dev);
175 } /* wl_adapter_detach */
176 /*============================================================================*/
179 void wl_adapter_release(struct pcmcia_device *link)
181 DBG_PARAM(DbgInfo, "link", "0x%p", link);
184 wl_remove(link->priv);
186 pcmcia_disable_device(link);
187 } /* wl_adapter_release */
188 /*============================================================================*/
190 static int wl_adapter_suspend(struct pcmcia_device *link)
192 struct net_device *dev = link->priv;
194 /* if (link->open) { */
195 netif_device_detach(dev);
197 /* CHECK! pcmcia_release_configuration(link->handle); */
201 } /* wl_adapter_suspend */
203 static int wl_adapter_resume(struct pcmcia_device *link)
205 struct net_device *dev = link->priv;
209 netif_device_attach(dev);
212 } /* wl_adapter_resume */
214 int wl_adapter_insert(struct pcmcia_device *link)
216 struct net_device *dev;
219 DBG_PARAM(DbgInfo, "link", "0x%p", link);
223 /* Do we need to allocate an interrupt? */
224 link->config_flags |= CONF_ENABLE_IRQ;
227 ret = pcmcia_request_io(link);
231 ret = pcmcia_request_irq(link, (void *) wl_isr);
235 ret = pcmcia_enable_device(link);
239 dev->irq = link->irq;
240 dev->base_addr = link->resource[0]->start;
242 SET_NETDEV_DEV(dev, &link->dev);
243 ret = register_netdev(dev);
245 printk("%s: register_netdev() failed\n", MODULE_NAME);
249 printk(KERN_INFO "%s: Wireless, io_addr %#03lx, irq %d, mac_address"
250 " %pM\n", dev->name, dev->base_addr, dev->irq, dev->dev_addr);
255 wl_adapter_release(link);
257 } /* wl_adapter_insert */
258 /*============================================================================*/
261 /*******************************************************************************
263 *******************************************************************************
271 * dev - a pointer to a net_device structure representing the network
277 * errno value otherwise
279 ******************************************************************************/
280 int wl_adapter_open(struct net_device *dev)
282 struct wl_private *lp = wl_priv(dev);
283 struct pcmcia_device *link = lp->link;
285 int hcf_status = HCF_SUCCESS;
287 DBG_PRINT("%s\n", VERSION_INFO);
288 DBG_PARAM(DbgInfo, "dev", "%s (0x%p)", dev->name, dev);
290 if (!pcmcia_dev_present(link))
295 hcf_status = wl_open(dev);
297 if (hcf_status != HCF_SUCCESS) {
303 } /* wl_adapter_open */
304 /*============================================================================*/
307 /*******************************************************************************
309 *******************************************************************************
317 * dev - a pointer to a net_device structure representing the network
323 * errno value otherwise
325 ******************************************************************************/
326 int wl_adapter_close(struct net_device *dev)
328 struct wl_private *lp = wl_priv(dev);
329 struct pcmcia_device *link = lp->link;
331 DBG_PARAM(DbgInfo, "dev", "%s (0x%p)", dev->name, dev);
336 DBG_TRACE(DbgInfo, "%s: Shutting down adapter.\n", dev->name);
342 } /* wl_adapter_close */
343 /*============================================================================*/
345 static const struct pcmcia_device_id wl_adapter_ids[] = {
346 #if !((HCF_TYPE) & HCF_TYPE_HII5)
347 PCMCIA_DEVICE_MANF_CARD(0x0156, 0x0003),
348 PCMCIA_DEVICE_PROD_ID12("Agere Systems", "Wireless PC Card Model 0110",
349 0x33103a9b, 0xe175b0dd),
351 PCMCIA_DEVICE_MANF_CARD(0x0156, 0x0004),
352 PCMCIA_DEVICE_PROD_ID12("Linksys", "WCF54G_Wireless-G_CompactFlash_Card",
353 0x0733cc81, 0x98a599e1),
354 #endif /* (HCF_TYPE) & HCF_TYPE_HII5 */
357 MODULE_DEVICE_TABLE(pcmcia, wl_adapter_ids);
359 static struct pcmcia_driver wlags49_driver = {
360 .owner = THIS_MODULE,
362 .probe = wl_adapter_attach,
363 .remove = wl_adapter_detach,
364 .id_table = wl_adapter_ids,
365 .suspend = wl_adapter_suspend,
366 .resume = wl_adapter_resume,
371 /*******************************************************************************
372 * wl_adapter_init_module()
373 *******************************************************************************
377 * Called by init_module() to perform PCMCIA driver initialization.
388 ******************************************************************************/
389 int wl_adapter_init_module(void)
393 DBG_TRACE(DbgInfo, "wl_adapter_init_module() -- PCMCIA\n");
395 ret = pcmcia_register_driver(&wlags49_driver);
398 } /* wl_adapter_init_module */
399 /*============================================================================*/
402 /*******************************************************************************
403 * wl_adapter_cleanup_module()
404 *******************************************************************************
408 * Called by cleanup_module() to perform driver uninitialization.
418 ******************************************************************************/
419 void wl_adapter_cleanup_module(void)
421 DBG_TRACE(DbgInfo, "wl_adapter_cleanup_module() -- PCMCIA\n");
423 pcmcia_unregister_driver(&wlags49_driver);
426 } /* wl_adapter_cleanup_module */
427 /*============================================================================*/
430 /*******************************************************************************
431 * wl_adapter_is_open()
432 *******************************************************************************
436 * Check with Card Services to determine if this device is open.
440 * dev - a pointer to the net_device structure whose open status will be
445 * nonzero if device is open
448 ******************************************************************************/
449 int wl_adapter_is_open(struct net_device *dev)
451 struct wl_private *lp = wl_priv(dev);
452 struct pcmcia_device *link = lp->link;
454 if (!pcmcia_dev_present(link))
458 } /* wl_adapter_is_open */
459 /*============================================================================*/