airo_cs.c 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. /*======================================================================
  2. Aironet driver for 4500 and 4800 series cards
  3. This code is released under both the GPL version 2 and BSD licenses.
  4. Either license may be used. The respective licenses are found at
  5. the end of this file.
  6. This code was developed by Benjamin Reed <breed@users.sourceforge.net>
  7. including portions of which come from the Aironet PC4500
  8. Developer's Reference Manual and used with permission. Copyright
  9. (C) 1999 Benjamin Reed. All Rights Reserved. Permission to use
  10. code in the Developer's manual was granted for this driver by
  11. Aironet.
  12. In addition this module was derived from dummy_cs.
  13. The initial developer of dummy_cs is David A. Hinds
  14. <dahinds@users.sourceforge.net>. Portions created by David A. Hinds
  15. are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
  16. ======================================================================*/
  17. #ifdef __IN_PCMCIA_PACKAGE__
  18. #include <pcmcia/k_compat.h>
  19. #endif
  20. #include <linux/kernel.h>
  21. #include <linux/module.h>
  22. #include <linux/ptrace.h>
  23. #include <linux/slab.h>
  24. #include <linux/string.h>
  25. #include <linux/timer.h>
  26. #include <linux/netdevice.h>
  27. #include <pcmcia/cistpl.h>
  28. #include <pcmcia/cisreg.h>
  29. #include <pcmcia/ds.h>
  30. #include <linux/io.h>
  31. #include "airo.h"
  32. /*====================================================================*/
  33. MODULE_AUTHOR("Benjamin Reed");
  34. MODULE_DESCRIPTION("Support for Cisco/Aironet 802.11 wireless ethernet "
  35. "cards. This is the module that links the PCMCIA card "
  36. "with the airo module.");
  37. MODULE_LICENSE("Dual BSD/GPL");
  38. MODULE_SUPPORTED_DEVICE("Aironet 4500, 4800 and Cisco 340 PCMCIA cards");
  39. /*====================================================================*/
  40. static int airo_config(struct pcmcia_device *link);
  41. static void airo_release(struct pcmcia_device *link);
  42. static void airo_detach(struct pcmcia_device *p_dev);
  43. struct local_info {
  44. struct net_device *eth_dev;
  45. };
  46. static int airo_probe(struct pcmcia_device *p_dev)
  47. {
  48. struct local_info *local;
  49. dev_dbg(&p_dev->dev, "airo_attach()\n");
  50. /* Allocate space for private device-specific data */
  51. local = kzalloc(sizeof(*local), GFP_KERNEL);
  52. if (!local)
  53. return -ENOMEM;
  54. p_dev->priv = local;
  55. return airo_config(p_dev);
  56. } /* airo_attach */
  57. static void airo_detach(struct pcmcia_device *link)
  58. {
  59. dev_dbg(&link->dev, "airo_detach\n");
  60. airo_release(link);
  61. if (((struct local_info *)link->priv)->eth_dev) {
  62. stop_airo_card(((struct local_info *)link->priv)->eth_dev,
  63. 0);
  64. }
  65. ((struct local_info *)link->priv)->eth_dev = NULL;
  66. kfree(link->priv);
  67. } /* airo_detach */
  68. static int airo_cs_config_check(struct pcmcia_device *p_dev, void *priv_data)
  69. {
  70. if (p_dev->config_index == 0)
  71. return -EINVAL;
  72. return pcmcia_request_io(p_dev);
  73. }
  74. static int airo_config(struct pcmcia_device *link)
  75. {
  76. int ret;
  77. dev_dbg(&link->dev, "airo_config\n");
  78. link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_VPP |
  79. CONF_AUTO_AUDIO | CONF_AUTO_SET_IO;
  80. ret = pcmcia_loop_config(link, airo_cs_config_check, NULL);
  81. if (ret)
  82. goto failed;
  83. if (!link->irq)
  84. goto failed;
  85. ret = pcmcia_enable_device(link);
  86. if (ret)
  87. goto failed;
  88. ((struct local_info *)link->priv)->eth_dev =
  89. init_airo_card(link->irq,
  90. link->resource[0]->start, 1, &link->dev);
  91. if (!((struct local_info *)link->priv)->eth_dev)
  92. goto failed;
  93. return 0;
  94. failed:
  95. airo_release(link);
  96. return -ENODEV;
  97. } /* airo_config */
  98. static void airo_release(struct pcmcia_device *link)
  99. {
  100. dev_dbg(&link->dev, "airo_release\n");
  101. pcmcia_disable_device(link);
  102. }
  103. static int airo_suspend(struct pcmcia_device *link)
  104. {
  105. struct local_info *local = link->priv;
  106. netif_device_detach(local->eth_dev);
  107. return 0;
  108. }
  109. static int airo_resume(struct pcmcia_device *link)
  110. {
  111. struct local_info *local = link->priv;
  112. if (link->open) {
  113. reset_airo_card(local->eth_dev);
  114. netif_device_attach(local->eth_dev);
  115. }
  116. return 0;
  117. }
  118. static const struct pcmcia_device_id airo_ids[] = {
  119. PCMCIA_DEVICE_MANF_CARD(0x015f, 0x000a),
  120. PCMCIA_DEVICE_MANF_CARD(0x015f, 0x0005),
  121. PCMCIA_DEVICE_MANF_CARD(0x015f, 0x0007),
  122. PCMCIA_DEVICE_MANF_CARD(0x0105, 0x0007),
  123. PCMCIA_DEVICE_NULL,
  124. };
  125. MODULE_DEVICE_TABLE(pcmcia, airo_ids);
  126. static struct pcmcia_driver airo_driver = {
  127. .owner = THIS_MODULE,
  128. .name = "airo_cs",
  129. .probe = airo_probe,
  130. .remove = airo_detach,
  131. .id_table = airo_ids,
  132. .suspend = airo_suspend,
  133. .resume = airo_resume,
  134. };
  135. module_pcmcia_driver(airo_driver);
  136. /*
  137. This program is free software; you can redistribute it and/or
  138. modify it under the terms of the GNU General Public License
  139. as published by the Free Software Foundation; either version 2
  140. of the License, or (at your option) any later version.
  141. This program is distributed in the hope that it will be useful,
  142. but WITHOUT ANY WARRANTY; without even the implied warranty of
  143. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  144. GNU General Public License for more details.
  145. In addition:
  146. Redistribution and use in source and binary forms, with or without
  147. modification, are permitted provided that the following conditions
  148. are met:
  149. 1. Redistributions of source code must retain the above copyright
  150. notice, this list of conditions and the following disclaimer.
  151. 2. Redistributions in binary form must reproduce the above copyright
  152. notice, this list of conditions and the following disclaimer in the
  153. documentation and/or other materials provided with the distribution.
  154. 3. The name of the author may not be used to endorse or promote
  155. products derived from this software without specific prior written
  156. permission.
  157. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  158. IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  159. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  160. ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
  161. INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  162. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  163. SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  164. HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  165. STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  166. IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  167. POSSIBILITY OF SUCH DAMAGE.
  168. */