1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23#ifdef __IN_PCMCIA_PACKAGE__
24#include <pcmcia/k_compat.h>
25#endif
26#include <linux/init.h>
27#include <linux/kernel.h>
28#include <linux/module.h>
29#include <linux/ptrace.h>
30#include <linux/slab.h>
31#include <linux/string.h>
32#include <linux/timer.h>
33#include <linux/netdevice.h>
34
35#include <pcmcia/cistpl.h>
36#include <pcmcia/cisreg.h>
37#include <pcmcia/ds.h>
38
39#include <linux/io.h>
40#include <asm/system.h>
41
42#include "airo.h"
43
44
45
46
47MODULE_AUTHOR("Benjamin Reed");
48MODULE_DESCRIPTION("Support for Cisco/Aironet 802.11 wireless ethernet "
49 "cards. This is the module that links the PCMCIA card "
50 "with the airo module.");
51MODULE_LICENSE("Dual BSD/GPL");
52MODULE_SUPPORTED_DEVICE("Aironet 4500, 4800 and Cisco 340 PCMCIA cards");
53
54
55
56static int airo_config(struct pcmcia_device *link);
57static void airo_release(struct pcmcia_device *link);
58
59static void airo_detach(struct pcmcia_device *p_dev);
60
61typedef struct local_info_t {
62 struct net_device *eth_dev;
63} local_info_t;
64
65static int airo_probe(struct pcmcia_device *p_dev)
66{
67 local_info_t *local;
68
69 dev_dbg(&p_dev->dev, "airo_attach()\n");
70
71
72 local = kzalloc(sizeof(local_info_t), GFP_KERNEL);
73 if (!local) {
74 printk(KERN_ERR "airo_cs: no memory for new device\n");
75 return -ENOMEM;
76 }
77 p_dev->priv = local;
78
79 return airo_config(p_dev);
80}
81
82static void airo_detach(struct pcmcia_device *link)
83{
84 dev_dbg(&link->dev, "airo_detach\n");
85
86 airo_release(link);
87
88 if (((local_info_t *)link->priv)->eth_dev) {
89 stop_airo_card(((local_info_t *)link->priv)->eth_dev, 0);
90 }
91 ((local_info_t *)link->priv)->eth_dev = NULL;
92
93 kfree(link->priv);
94}
95
96static int airo_cs_config_check(struct pcmcia_device *p_dev, void *priv_data)
97{
98 if (p_dev->config_index == 0)
99 return -EINVAL;
100
101 return pcmcia_request_io(p_dev);
102}
103
104
105static int airo_config(struct pcmcia_device *link)
106{
107 local_info_t *dev;
108 int ret;
109
110 dev = link->priv;
111
112 dev_dbg(&link->dev, "airo_config\n");
113
114 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_VPP |
115 CONF_AUTO_AUDIO | CONF_AUTO_SET_IO;
116
117 ret = pcmcia_loop_config(link, airo_cs_config_check, NULL);
118 if (ret)
119 goto failed;
120
121 if (!link->irq)
122 goto failed;
123
124 ret = pcmcia_enable_device(link);
125 if (ret)
126 goto failed;
127 ((local_info_t *)link->priv)->eth_dev =
128 init_airo_card(link->irq,
129 link->resource[0]->start, 1, &link->dev);
130 if (!((local_info_t *)link->priv)->eth_dev)
131 goto failed;
132
133 return 0;
134
135 failed:
136 airo_release(link);
137 return -ENODEV;
138}
139
140static void airo_release(struct pcmcia_device *link)
141{
142 dev_dbg(&link->dev, "airo_release\n");
143 pcmcia_disable_device(link);
144}
145
146static int airo_suspend(struct pcmcia_device *link)
147{
148 local_info_t *local = link->priv;
149
150 netif_device_detach(local->eth_dev);
151
152 return 0;
153}
154
155static int airo_resume(struct pcmcia_device *link)
156{
157 local_info_t *local = link->priv;
158
159 if (link->open) {
160 reset_airo_card(local->eth_dev);
161 netif_device_attach(local->eth_dev);
162 }
163
164 return 0;
165}
166
167static const struct pcmcia_device_id airo_ids[] = {
168 PCMCIA_DEVICE_MANF_CARD(0x015f, 0x000a),
169 PCMCIA_DEVICE_MANF_CARD(0x015f, 0x0005),
170 PCMCIA_DEVICE_MANF_CARD(0x015f, 0x0007),
171 PCMCIA_DEVICE_MANF_CARD(0x0105, 0x0007),
172 PCMCIA_DEVICE_NULL,
173};
174MODULE_DEVICE_TABLE(pcmcia, airo_ids);
175
176static struct pcmcia_driver airo_driver = {
177 .owner = THIS_MODULE,
178 .name = "airo_cs",
179 .probe = airo_probe,
180 .remove = airo_detach,
181 .id_table = airo_ids,
182 .suspend = airo_suspend,
183 .resume = airo_resume,
184};
185
186static int __init airo_cs_init(void)
187{
188 return pcmcia_register_driver(&airo_driver);
189}
190
191static void __exit airo_cs_cleanup(void)
192{
193 pcmcia_unregister_driver(&airo_driver);
194}
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235module_init(airo_cs_init);
236module_exit(airo_cs_cleanup);
237