diff options
author | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
---|---|---|
committer | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
commit | c71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch) | |
tree | ecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /drivers/net/wireless/atmel_cs.c | |
parent | ea53c912f8a86a8567697115b6a0d8152beee5c8 (diff) | |
parent | 6a00f206debf8a5c8899055726ad127dbeeed098 (diff) |
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts:
litmus/sched_cedf.c
Diffstat (limited to 'drivers/net/wireless/atmel_cs.c')
-rw-r--r-- | drivers/net/wireless/atmel_cs.c | 141 |
1 files changed, 13 insertions, 128 deletions
diff --git a/drivers/net/wireless/atmel_cs.c b/drivers/net/wireless/atmel_cs.c index 3b632161c106..ec295c4f677d 100644 --- a/drivers/net/wireless/atmel_cs.c +++ b/drivers/net/wireless/atmel_cs.c | |||
@@ -42,7 +42,6 @@ | |||
42 | #include <linux/moduleparam.h> | 42 | #include <linux/moduleparam.h> |
43 | #include <linux/device.h> | 43 | #include <linux/device.h> |
44 | 44 | ||
45 | #include <pcmcia/cs.h> | ||
46 | #include <pcmcia/cistpl.h> | 45 | #include <pcmcia/cistpl.h> |
47 | #include <pcmcia/cisreg.h> | 46 | #include <pcmcia/cisreg.h> |
48 | #include <pcmcia/ds.h> | 47 | #include <pcmcia/ds.h> |
@@ -64,58 +63,21 @@ MODULE_SUPPORTED_DEVICE("Atmel at76c50x PCMCIA cards"); | |||
64 | 63 | ||
65 | /*====================================================================*/ | 64 | /*====================================================================*/ |
66 | 65 | ||
67 | /* | ||
68 | The event() function is this driver's Card Services event handler. | ||
69 | It will be called by Card Services when an appropriate card status | ||
70 | event is received. The config() and release() entry points are | ||
71 | used to configure or release a socket, in response to card | ||
72 | insertion and ejection events. They are invoked from the atmel_cs | ||
73 | event handler. | ||
74 | */ | ||
75 | |||
76 | static int atmel_config(struct pcmcia_device *link); | 66 | static int atmel_config(struct pcmcia_device *link); |
77 | static void atmel_release(struct pcmcia_device *link); | 67 | static void atmel_release(struct pcmcia_device *link); |
78 | 68 | ||
79 | /* | ||
80 | The attach() and detach() entry points are used to create and destroy | ||
81 | "instances" of the driver, where each instance represents everything | ||
82 | needed to manage one actual PCMCIA card. | ||
83 | */ | ||
84 | |||
85 | static void atmel_detach(struct pcmcia_device *p_dev); | 69 | static void atmel_detach(struct pcmcia_device *p_dev); |
86 | 70 | ||
87 | typedef struct local_info_t { | 71 | typedef struct local_info_t { |
88 | struct net_device *eth_dev; | 72 | struct net_device *eth_dev; |
89 | } local_info_t; | 73 | } local_info_t; |
90 | 74 | ||
91 | /*====================================================================== | ||
92 | |||
93 | atmel_attach() creates an "instance" of the driver, allocating | ||
94 | local data structures for one device. The device is registered | ||
95 | with Card Services. | ||
96 | |||
97 | The dev_link structure is initialized, but we don't actually | ||
98 | configure the card at this point -- we wait until we receive a | ||
99 | card insertion event. | ||
100 | |||
101 | ======================================================================*/ | ||
102 | |||
103 | static int atmel_probe(struct pcmcia_device *p_dev) | 75 | static int atmel_probe(struct pcmcia_device *p_dev) |
104 | { | 76 | { |
105 | local_info_t *local; | 77 | local_info_t *local; |
106 | 78 | ||
107 | dev_dbg(&p_dev->dev, "atmel_attach()\n"); | 79 | dev_dbg(&p_dev->dev, "atmel_attach()\n"); |
108 | 80 | ||
109 | /* | ||
110 | General socket configuration defaults can go here. In this | ||
111 | client, we assume very little, and rely on the CIS for almost | ||
112 | everything. In most clients, many details (i.e., number, sizes, | ||
113 | and attributes of IO windows) are fixed by the nature of the | ||
114 | device, and can be hard-wired here. | ||
115 | */ | ||
116 | p_dev->conf.Attributes = 0; | ||
117 | p_dev->conf.IntType = INT_MEMORY_AND_IO; | ||
118 | |||
119 | /* Allocate space for private device-specific data */ | 81 | /* Allocate space for private device-specific data */ |
120 | local = kzalloc(sizeof(local_info_t), GFP_KERNEL); | 82 | local = kzalloc(sizeof(local_info_t), GFP_KERNEL); |
121 | if (!local) { | 83 | if (!local) { |
@@ -127,15 +89,6 @@ static int atmel_probe(struct pcmcia_device *p_dev) | |||
127 | return atmel_config(p_dev); | 89 | return atmel_config(p_dev); |
128 | } /* atmel_attach */ | 90 | } /* atmel_attach */ |
129 | 91 | ||
130 | /*====================================================================== | ||
131 | |||
132 | This deletes a driver "instance". The device is de-registered | ||
133 | with Card Services. If it has been released, all local data | ||
134 | structures are freed. Otherwise, the structures will be freed | ||
135 | when the device is released. | ||
136 | |||
137 | ======================================================================*/ | ||
138 | |||
139 | static void atmel_detach(struct pcmcia_device *link) | 92 | static void atmel_detach(struct pcmcia_device *link) |
140 | { | 93 | { |
141 | dev_dbg(&link->dev, "atmel_detach\n"); | 94 | dev_dbg(&link->dev, "atmel_detach\n"); |
@@ -145,16 +98,8 @@ static void atmel_detach(struct pcmcia_device *link) | |||
145 | kfree(link->priv); | 98 | kfree(link->priv); |
146 | } | 99 | } |
147 | 100 | ||
148 | /*====================================================================== | ||
149 | |||
150 | atmel_config() is scheduled to run after a CARD_INSERTION event | ||
151 | is received, to configure the PCMCIA socket, and to make the | ||
152 | device available to the system. | ||
153 | |||
154 | ======================================================================*/ | ||
155 | |||
156 | /* Call-back function to interrogate PCMCIA-specific information | 101 | /* Call-back function to interrogate PCMCIA-specific information |
157 | about the current existance of the card */ | 102 | about the current existence of the card */ |
158 | static int card_present(void *arg) | 103 | static int card_present(void *arg) |
159 | { | 104 | { |
160 | struct pcmcia_device *link = (struct pcmcia_device *)arg; | 105 | struct pcmcia_device *link = (struct pcmcia_device *)arg; |
@@ -165,47 +110,11 @@ static int card_present(void *arg) | |||
165 | return 0; | 110 | return 0; |
166 | } | 111 | } |
167 | 112 | ||
168 | static int atmel_config_check(struct pcmcia_device *p_dev, | 113 | static int atmel_config_check(struct pcmcia_device *p_dev, void *priv_data) |
169 | cistpl_cftable_entry_t *cfg, | ||
170 | cistpl_cftable_entry_t *dflt, | ||
171 | unsigned int vcc, | ||
172 | void *priv_data) | ||
173 | { | 114 | { |
174 | if (cfg->index == 0) | 115 | if (p_dev->config_index == 0) |
175 | return -ENODEV; | 116 | return -EINVAL; |
176 | |||
177 | /* Does this card need audio output? */ | ||
178 | if (cfg->flags & CISTPL_CFTABLE_AUDIO) { | ||
179 | p_dev->conf.Attributes |= CONF_ENABLE_SPKR; | ||
180 | p_dev->conf.Status = CCSR_AUDIO_ENA; | ||
181 | } | ||
182 | 117 | ||
183 | /* Use power settings for Vcc and Vpp if present */ | ||
184 | /* Note that the CIS values need to be rescaled */ | ||
185 | if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM)) | ||
186 | p_dev->conf.Vpp = cfg->vpp1.param[CISTPL_POWER_VNOM]/10000; | ||
187 | else if (dflt->vpp1.present & (1<<CISTPL_POWER_VNOM)) | ||
188 | p_dev->conf.Vpp = dflt->vpp1.param[CISTPL_POWER_VNOM]/10000; | ||
189 | |||
190 | p_dev->conf.Attributes |= CONF_ENABLE_IRQ; | ||
191 | |||
192 | /* IO window settings */ | ||
193 | p_dev->resource[0]->end = p_dev->resource[1]->end = 0; | ||
194 | if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { | ||
195 | cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; | ||
196 | p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH; | ||
197 | p_dev->resource[0]->flags |= | ||
198 | pcmcia_io_cfg_data_width(io->flags); | ||
199 | p_dev->resource[0]->start = io->win[0].base; | ||
200 | p_dev->resource[0]->end = io->win[0].len; | ||
201 | if (io->nwin > 1) { | ||
202 | p_dev->resource[1]->flags = p_dev->resource[0]->flags; | ||
203 | p_dev->resource[1]->start = io->win[1].base; | ||
204 | p_dev->resource[1]->end = io->win[1].len; | ||
205 | } | ||
206 | } | ||
207 | |||
208 | /* This reserves IO space but doesn't actually enable it */ | ||
209 | return pcmcia_request_io(p_dev); | 118 | return pcmcia_request_io(p_dev); |
210 | } | 119 | } |
211 | 120 | ||
@@ -213,25 +122,16 @@ static int atmel_config(struct pcmcia_device *link) | |||
213 | { | 122 | { |
214 | local_info_t *dev; | 123 | local_info_t *dev; |
215 | int ret; | 124 | int ret; |
216 | struct pcmcia_device_id *did; | 125 | const struct pcmcia_device_id *did; |
217 | 126 | ||
218 | dev = link->priv; | 127 | dev = link->priv; |
219 | did = dev_get_drvdata(&link->dev); | 128 | did = dev_get_drvdata(&link->dev); |
220 | 129 | ||
221 | dev_dbg(&link->dev, "atmel_config\n"); | 130 | dev_dbg(&link->dev, "atmel_config\n"); |
222 | 131 | ||
223 | /* | 132 | link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_VPP | |
224 | In this loop, we scan the CIS for configuration table entries, | 133 | CONF_AUTO_AUDIO | CONF_AUTO_SET_IO; |
225 | each of which describes a valid card configuration, including | 134 | |
226 | voltage, IO window, memory window, and interrupt settings. | ||
227 | |||
228 | We make no assumptions about the card to be configured: we use | ||
229 | just the information available in the CIS. In an ideal world, | ||
230 | this would work for any PCMCIA card, but it requires a complete | ||
231 | and accurate CIS. In practice, a driver usually "knows" most of | ||
232 | these things without consulting the CIS, and most client drivers | ||
233 | will only use the CIS to fill in implementation-defined details. | ||
234 | */ | ||
235 | if (pcmcia_loop_config(link, atmel_config_check, NULL)) | 135 | if (pcmcia_loop_config(link, atmel_config_check, NULL)) |
236 | goto failed; | 136 | goto failed; |
237 | 137 | ||
@@ -240,12 +140,7 @@ static int atmel_config(struct pcmcia_device *link) | |||
240 | goto failed; | 140 | goto failed; |
241 | } | 141 | } |
242 | 142 | ||
243 | /* | 143 | ret = pcmcia_enable_device(link); |
244 | This actually configures the PCMCIA socket -- setting up | ||
245 | the I/O windows and the interrupt mapping, and putting the | ||
246 | card and host interface into "Memory and IO" mode. | ||
247 | */ | ||
248 | ret = pcmcia_request_configuration(link, &link->conf); | ||
249 | if (ret) | 144 | if (ret) |
250 | goto failed; | 145 | goto failed; |
251 | 146 | ||
@@ -267,14 +162,6 @@ static int atmel_config(struct pcmcia_device *link) | |||
267 | return -ENODEV; | 162 | return -ENODEV; |
268 | } | 163 | } |
269 | 164 | ||
270 | /*====================================================================== | ||
271 | |||
272 | After a card is removed, atmel_release() will unregister the | ||
273 | device, and release the PCMCIA configuration. If the device is | ||
274 | still open, this will be postponed until it is closed. | ||
275 | |||
276 | ======================================================================*/ | ||
277 | |||
278 | static void atmel_release(struct pcmcia_device *link) | 165 | static void atmel_release(struct pcmcia_device *link) |
279 | { | 166 | { |
280 | struct net_device *dev = ((local_info_t*)link->priv)->eth_dev; | 167 | struct net_device *dev = ((local_info_t*)link->priv)->eth_dev; |
@@ -324,7 +211,7 @@ static int atmel_resume(struct pcmcia_device *link) | |||
324 | .prod_id_hash = { (vh1), (vh2), 0, 0 }, \ | 211 | .prod_id_hash = { (vh1), (vh2), 0, 0 }, \ |
325 | .driver_info = (kernel_ulong_t)(info), } | 212 | .driver_info = (kernel_ulong_t)(info), } |
326 | 213 | ||
327 | static struct pcmcia_device_id atmel_ids[] = { | 214 | static const struct pcmcia_device_id atmel_ids[] = { |
328 | PCMCIA_DEVICE_MANF_CARD_INFO(0x0101, 0x0620, ATMEL_FW_TYPE_502_3COM), | 215 | PCMCIA_DEVICE_MANF_CARD_INFO(0x0101, 0x0620, ATMEL_FW_TYPE_502_3COM), |
329 | PCMCIA_DEVICE_MANF_CARD_INFO(0x0101, 0x0696, ATMEL_FW_TYPE_502_3COM), | 216 | PCMCIA_DEVICE_MANF_CARD_INFO(0x0101, 0x0696, ATMEL_FW_TYPE_502_3COM), |
330 | PCMCIA_DEVICE_MANF_CARD_INFO(0x01bf, 0x3302, ATMEL_FW_TYPE_502E), | 217 | PCMCIA_DEVICE_MANF_CARD_INFO(0x01bf, 0x3302, ATMEL_FW_TYPE_502E), |
@@ -353,9 +240,7 @@ MODULE_DEVICE_TABLE(pcmcia, atmel_ids); | |||
353 | 240 | ||
354 | static struct pcmcia_driver atmel_driver = { | 241 | static struct pcmcia_driver atmel_driver = { |
355 | .owner = THIS_MODULE, | 242 | .owner = THIS_MODULE, |
356 | .drv = { | 243 | .name = "atmel_cs", |
357 | .name = "atmel_cs", | ||
358 | }, | ||
359 | .probe = atmel_probe, | 244 | .probe = atmel_probe, |
360 | .remove = atmel_detach, | 245 | .remove = atmel_detach, |
361 | .id_table = atmel_ids, | 246 | .id_table = atmel_ids, |
@@ -363,12 +248,12 @@ static struct pcmcia_driver atmel_driver = { | |||
363 | .resume = atmel_resume, | 248 | .resume = atmel_resume, |
364 | }; | 249 | }; |
365 | 250 | ||
366 | static int atmel_cs_init(void) | 251 | static int __init atmel_cs_init(void) |
367 | { | 252 | { |
368 | return pcmcia_register_driver(&atmel_driver); | 253 | return pcmcia_register_driver(&atmel_driver); |
369 | } | 254 | } |
370 | 255 | ||
371 | static void atmel_cs_cleanup(void) | 256 | static void __exit atmel_cs_cleanup(void) |
372 | { | 257 | { |
373 | pcmcia_unregister_driver(&atmel_driver); | 258 | pcmcia_unregister_driver(&atmel_driver); |
374 | } | 259 | } |