aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/wireless/libertas/if_cs.c172
1 files changed, 79 insertions, 93 deletions
diff --git a/drivers/net/wireless/libertas/if_cs.c b/drivers/net/wireless/libertas/if_cs.c
index 5963d92cc94d..873ab10a0786 100644
--- a/drivers/net/wireless/libertas/if_cs.c
+++ b/drivers/net/wireless/libertas/if_cs.c
@@ -159,56 +159,40 @@ static int if_cs_poll_while_fw_download(struct if_cs_card *card, uint addr, u8 r
159 159
160 160
161 161
162/* Host control registers and their bit definitions */ 162/* First the bitmasks for the host/card interrupt/status registers: */
163#define IF_CS_BIT_TX 0x0001
164#define IF_CS_BIT_RX 0x0002
165#define IF_CS_BIT_COMMAND 0x0004
166#define IF_CS_BIT_RESP 0x0008
167#define IF_CS_BIT_EVENT 0x0010
168#define IF_CS_BIT_MASK 0x001f
163 169
164#define IF_CS_H_STATUS 0x00000000 170/* And now the individual registers and assorted masks */
165#define IF_CS_H_STATUS_TX_OVER 0x0001 171#define IF_CS_HOST_STATUS 0x00000000
166#define IF_CS_H_STATUS_RX_OVER 0x0002
167#define IF_CS_H_STATUS_DNLD_OVER 0x0004
168 172
169#define IF_CS_H_INT_CAUSE 0x00000002 173#define IF_CS_HOST_INT_CAUSE 0x00000002
170#define IF_CS_H_IC_TX_OVER 0x0001
171#define IF_CS_H_IC_RX_OVER 0x0002
172#define IF_CS_H_IC_DNLD_OVER 0x0004
173#define IF_CS_H_IC_POWER_DOWN 0x0008
174#define IF_CS_H_IC_HOST_EVENT 0x0010
175#define IF_CS_H_IC_MASK 0x001f
176 174
177#define IF_CS_H_INT_MASK 0x00000004 175#define IF_CS_HOST_INT_MASK 0x00000004
178#define IF_CS_H_IM_MASK 0x001f
179 176
180#define IF_CS_H_WRITE_LEN 0x00000014 177#define IF_CS_HOST_WRITE 0x00000016
178#define IF_CS_HOST_WRITE_LEN 0x00000014
181 179
182#define IF_CS_H_WRITE 0x00000016 180#define IF_CS_HOST_CMD 0x0000001A
181#define IF_CS_HOST_CMD_LEN 0x00000018
183 182
184#define IF_CS_H_CMD_LEN 0x00000018 183#define IF_CS_READ 0x00000010
184#define IF_CS_READ_LEN 0x00000024
185 185
186#define IF_CS_H_CMD 0x0000001A 186#define IF_CS_CARD_CMD 0x00000012
187#define IF_CS_CARD_CMD_LEN 0x00000030
187 188
188#define IF_CS_C_READ_LEN 0x00000024 189#define IF_CS_CARD_STATUS 0x00000020
190#define IF_CS_CARD_STATUS_MASK 0x7f00
189 191
190#define IF_CS_H_READ 0x00000010 192#define IF_CS_CARD_INT_CAUSE 0x00000022
191 193
192/* Card control registers and their bit definitions */ 194#define IF_CS_CARD_SQ_READ_LOW 0x00000028
193 195#define IF_CS_CARD_SQ_HELPER_OK 0x10
194#define IF_CS_C_STATUS 0x00000020
195#define IF_CS_C_S_TX_DNLD_RDY 0x0001
196#define IF_CS_C_S_RX_UPLD_RDY 0x0002
197#define IF_CS_C_S_CMD_DNLD_RDY 0x0004
198#define IF_CS_C_S_CMD_UPLD_RDY 0x0008
199#define IF_CS_C_S_CARDEVENT 0x0010
200#define IF_CS_C_S_MASK 0x001f
201#define IF_CS_C_S_STATUS_MASK 0x7f00
202
203#define IF_CS_C_INT_CAUSE 0x00000022
204#define IF_CS_C_IC_MASK 0x001f
205
206#define IF_CS_C_SQ_READ_LOW 0x00000028
207#define IF_CS_C_SQ_HELPER_OK 0x10
208
209#define IF_CS_C_CMD_LEN 0x00000030
210
211#define IF_CS_C_CMD 0x00000012
212 196
213#define IF_CS_SCRATCH 0x0000003F 197#define IF_CS_SCRATCH 0x0000003F
214 198
@@ -221,13 +205,13 @@ static int if_cs_poll_while_fw_download(struct if_cs_card *card, uint addr, u8 r
221static inline void if_cs_enable_ints(struct if_cs_card *card) 205static inline void if_cs_enable_ints(struct if_cs_card *card)
222{ 206{
223 lbs_deb_enter(LBS_DEB_CS); 207 lbs_deb_enter(LBS_DEB_CS);
224 if_cs_write16(card, IF_CS_H_INT_MASK, 0); 208 if_cs_write16(card, IF_CS_HOST_INT_MASK, 0);
225} 209}
226 210
227static inline void if_cs_disable_ints(struct if_cs_card *card) 211static inline void if_cs_disable_ints(struct if_cs_card *card)
228{ 212{
229 lbs_deb_enter(LBS_DEB_CS); 213 lbs_deb_enter(LBS_DEB_CS);
230 if_cs_write16(card, IF_CS_H_INT_MASK, IF_CS_H_IM_MASK); 214 if_cs_write16(card, IF_CS_HOST_INT_MASK, IF_CS_BIT_MASK);
231} 215}
232 216
233/* 217/*
@@ -244,8 +228,8 @@ static int if_cs_send_cmd(struct lbs_private *priv, u8 *buf, u16 nb)
244 228
245 /* Is hardware ready? */ 229 /* Is hardware ready? */
246 while (1) { 230 while (1) {
247 u16 val = if_cs_read16(card, IF_CS_C_STATUS); 231 u16 val = if_cs_read16(card, IF_CS_CARD_STATUS);
248 if (val & IF_CS_C_S_CMD_DNLD_RDY) 232 if (val & IF_CS_BIT_COMMAND)
249 break; 233 break;
250 if (++loops > 100) { 234 if (++loops > 100) {
251 lbs_pr_err("card not ready for commands\n"); 235 lbs_pr_err("card not ready for commands\n");
@@ -254,20 +238,20 @@ static int if_cs_send_cmd(struct lbs_private *priv, u8 *buf, u16 nb)
254 mdelay(1); 238 mdelay(1);
255 } 239 }
256 240
257 if_cs_write16(card, IF_CS_H_CMD_LEN, nb); 241 if_cs_write16(card, IF_CS_HOST_CMD_LEN, nb);
258 242
259 if_cs_write16_rep(card, IF_CS_H_CMD, buf, nb / 2); 243 if_cs_write16_rep(card, IF_CS_HOST_CMD, buf, nb / 2);
260 /* Are we supposed to transfer an odd amount of bytes? */ 244 /* Are we supposed to transfer an odd amount of bytes? */
261 if (nb & 1) 245 if (nb & 1)
262 if_cs_write8(card, IF_CS_H_CMD, buf[nb-1]); 246 if_cs_write8(card, IF_CS_HOST_CMD, buf[nb-1]);
263 247
264 /* "Assert the download over interrupt command in the Host 248 /* "Assert the download over interrupt command in the Host
265 * status register" */ 249 * status register" */
266 if_cs_write16(card, IF_CS_H_STATUS, IF_CS_H_STATUS_DNLD_OVER); 250 if_cs_write16(card, IF_CS_HOST_STATUS, IF_CS_BIT_COMMAND);
267 251
268 /* "Assert the download over interrupt command in the Card 252 /* "Assert the download over interrupt command in the Card
269 * interrupt case register" */ 253 * interrupt case register" */
270 if_cs_write16(card, IF_CS_H_INT_CAUSE, IF_CS_H_IC_DNLD_OVER); 254 if_cs_write16(card, IF_CS_HOST_INT_CAUSE, IF_CS_BIT_COMMAND);
271 ret = 0; 255 ret = 0;
272 256
273done: 257done:
@@ -287,18 +271,18 @@ static void if_cs_send_data(struct lbs_private *priv, u8 *buf, u16 nb)
287 lbs_deb_enter(LBS_DEB_CS); 271 lbs_deb_enter(LBS_DEB_CS);
288 if_cs_disable_ints(card); 272 if_cs_disable_ints(card);
289 273
290 status = if_cs_read16(card, IF_CS_C_STATUS); 274 status = if_cs_read16(card, IF_CS_CARD_STATUS);
291 BUG_ON((status & IF_CS_C_S_TX_DNLD_RDY) == 0); 275 BUG_ON((status & IF_CS_BIT_TX) == 0);
292 276
293 if_cs_write16(card, IF_CS_H_WRITE_LEN, nb); 277 if_cs_write16(card, IF_CS_HOST_WRITE_LEN, nb);
294 278
295 /* write even number of bytes, then odd byte if necessary */ 279 /* write even number of bytes, then odd byte if necessary */
296 if_cs_write16_rep(card, IF_CS_H_WRITE, buf, nb / 2); 280 if_cs_write16_rep(card, IF_CS_HOST_WRITE, buf, nb / 2);
297 if (nb & 1) 281 if (nb & 1)
298 if_cs_write8(card, IF_CS_H_WRITE, buf[nb-1]); 282 if_cs_write8(card, IF_CS_HOST_WRITE, buf[nb-1]);
299 283
300 if_cs_write16(card, IF_CS_H_STATUS, IF_CS_H_STATUS_TX_OVER); 284 if_cs_write16(card, IF_CS_HOST_STATUS, IF_CS_BIT_TX);
301 if_cs_write16(card, IF_CS_H_INT_CAUSE, IF_CS_H_STATUS_TX_OVER); 285 if_cs_write16(card, IF_CS_HOST_INT_CAUSE, IF_CS_BIT_TX);
302 if_cs_enable_ints(card); 286 if_cs_enable_ints(card);
303 287
304 lbs_deb_leave(LBS_DEB_CS); 288 lbs_deb_leave(LBS_DEB_CS);
@@ -311,27 +295,28 @@ static int if_cs_receive_cmdres(struct lbs_private *priv, u8 *data, u32 *len)
311{ 295{
312 unsigned long flags; 296 unsigned long flags;
313 int ret = -1; 297 int ret = -1;
314 u16 val; 298 u16 status;
315 299
316 lbs_deb_enter(LBS_DEB_CS); 300 lbs_deb_enter(LBS_DEB_CS);
317 301
318 /* is hardware ready? */ 302 /* is hardware ready? */
319 val = if_cs_read16(priv->card, IF_CS_C_STATUS); 303 status = if_cs_read16(priv->card, IF_CS_CARD_STATUS);
320 if ((val & IF_CS_C_S_CMD_UPLD_RDY) == 0) { 304 if ((status & IF_CS_BIT_RESP) == 0) {
321 lbs_pr_err("card not ready for CMD\n"); 305 lbs_pr_err("no cmd response in card\n");
306 *len = 0;
322 goto out; 307 goto out;
323 } 308 }
324 309
325 *len = if_cs_read16(priv->card, IF_CS_C_CMD_LEN); 310 *len = if_cs_read16(priv->card, IF_CS_CARD_CMD_LEN);
326 if ((*len == 0) || (*len > LBS_CMD_BUFFER_SIZE)) { 311 if ((*len == 0) || (*len > LBS_CMD_BUFFER_SIZE)) {
327 lbs_pr_err("card cmd buffer has invalid # of bytes (%d)\n", *len); 312 lbs_pr_err("card cmd buffer has invalid # of bytes (%d)\n", *len);
328 goto out; 313 goto out;
329 } 314 }
330 315
331 /* read even number of bytes, then odd byte if necessary */ 316 /* read even number of bytes, then odd byte if necessary */
332 if_cs_read16_rep(priv->card, IF_CS_C_CMD, data, *len/sizeof(u16)); 317 if_cs_read16_rep(priv->card, IF_CS_CARD_CMD, data, *len/sizeof(u16));
333 if (*len & 1) 318 if (*len & 1)
334 data[*len-1] = if_cs_read8(priv->card, IF_CS_C_CMD); 319 data[*len-1] = if_cs_read8(priv->card, IF_CS_CARD_CMD);
335 320
336 /* This is a workaround for a firmware that reports too much 321 /* This is a workaround for a firmware that reports too much
337 * bytes */ 322 * bytes */
@@ -356,7 +341,7 @@ static struct sk_buff *if_cs_receive_data(struct lbs_private *priv)
356 341
357 lbs_deb_enter(LBS_DEB_CS); 342 lbs_deb_enter(LBS_DEB_CS);
358 343
359 len = if_cs_read16(priv->card, IF_CS_C_READ_LEN); 344 len = if_cs_read16(priv->card, IF_CS_READ_LEN);
360 if (len == 0 || len > MRVDRV_ETH_RX_PACKET_BUFFER_SIZE) { 345 if (len == 0 || len > MRVDRV_ETH_RX_PACKET_BUFFER_SIZE) {
361 lbs_pr_err("card data buffer has invalid # of bytes (%d)\n", len); 346 lbs_pr_err("card data buffer has invalid # of bytes (%d)\n", len);
362 priv->stats.rx_dropped++; 347 priv->stats.rx_dropped++;
@@ -371,13 +356,13 @@ static struct sk_buff *if_cs_receive_data(struct lbs_private *priv)
371 data = skb->data; 356 data = skb->data;
372 357
373 /* read even number of bytes, then odd byte if necessary */ 358 /* read even number of bytes, then odd byte if necessary */
374 if_cs_read16_rep(priv->card, IF_CS_H_READ, data, len/sizeof(u16)); 359 if_cs_read16_rep(priv->card, IF_CS_READ, data, len/sizeof(u16));
375 if (len & 1) 360 if (len & 1)
376 data[len-1] = if_cs_read8(priv->card, IF_CS_H_READ); 361 data[len-1] = if_cs_read8(priv->card, IF_CS_READ);
377 362
378dat_err: 363dat_err:
379 if_cs_write16(priv->card, IF_CS_H_STATUS, IF_CS_H_STATUS_RX_OVER); 364 if_cs_write16(priv->card, IF_CS_HOST_STATUS, IF_CS_BIT_RX);
380 if_cs_write16(priv->card, IF_CS_H_INT_CAUSE, IF_CS_H_IC_RX_OVER); 365 if_cs_write16(priv->card, IF_CS_HOST_INT_CAUSE, IF_CS_BIT_RX);
381 366
382out: 367out:
383 lbs_deb_leave_args(LBS_DEB_CS, "ret %p", skb); 368 lbs_deb_leave_args(LBS_DEB_CS, "ret %p", skb);
@@ -393,7 +378,7 @@ static irqreturn_t if_cs_interrupt(int irq, void *data)
393 lbs_deb_enter(LBS_DEB_CS); 378 lbs_deb_enter(LBS_DEB_CS);
394 379
395 /* Ask card interrupt cause register if there is something for us */ 380 /* Ask card interrupt cause register if there is something for us */
396 cause = if_cs_read16(card, IF_CS_C_INT_CAUSE); 381 cause = if_cs_read16(card, IF_CS_CARD_INT_CAUSE);
397 if (cause == 0) { 382 if (cause == 0) {
398 /* Not for us */ 383 /* Not for us */
399 return IRQ_NONE; 384 return IRQ_NONE;
@@ -406,10 +391,10 @@ static irqreturn_t if_cs_interrupt(int irq, void *data)
406 } 391 }
407 392
408 /* Clear interrupt cause */ 393 /* Clear interrupt cause */
409 if_cs_write16(card, IF_CS_C_INT_CAUSE, cause & IF_CS_C_IC_MASK); 394 if_cs_write16(card, IF_CS_CARD_INT_CAUSE, cause & IF_CS_BIT_MASK);
410 lbs_deb_cs("cause 0x%04x\n", cause); 395 lbs_deb_cs("cause 0x%04x\n", cause);
411 396
412 if (cause & IF_CS_C_S_RX_UPLD_RDY) { 397 if (cause & IF_CS_BIT_RX) {
413 struct sk_buff *skb; 398 struct sk_buff *skb;
414 lbs_deb_cs("rx packet\n"); 399 lbs_deb_cs("rx packet\n");
415 skb = if_cs_receive_data(priv); 400 skb = if_cs_receive_data(priv);
@@ -417,12 +402,12 @@ static irqreturn_t if_cs_interrupt(int irq, void *data)
417 lbs_process_rxed_packet(priv, skb); 402 lbs_process_rxed_packet(priv, skb);
418 } 403 }
419 404
420 if (cause & IF_CS_H_IC_TX_OVER) { 405 if (cause & IF_CS_BIT_TX) {
421 lbs_deb_cs("tx done\n"); 406 lbs_deb_cs("tx done\n");
422 lbs_host_to_card_done(priv); 407 lbs_host_to_card_done(priv);
423 } 408 }
424 409
425 if (cause & IF_CS_C_S_CMD_UPLD_RDY) { 410 if (cause & IF_CS_BIT_RESP) {
426 unsigned long flags; 411 unsigned long flags;
427 u8 i; 412 u8 i;
428 413
@@ -440,11 +425,11 @@ static irqreturn_t if_cs_interrupt(int irq, void *data)
440 spin_unlock_irqrestore(&priv->driver_lock, flags); 425 spin_unlock_irqrestore(&priv->driver_lock, flags);
441 } 426 }
442 427
443 if (cause & IF_CS_H_IC_HOST_EVENT) { 428 if (cause & IF_CS_BIT_EVENT) {
444 u16 event = if_cs_read16(priv->card, IF_CS_C_STATUS) 429 u16 event = if_cs_read16(priv->card, IF_CS_CARD_STATUS)
445 & IF_CS_C_S_STATUS_MASK; 430 & IF_CS_CARD_STATUS_MASK;
446 if_cs_write16(priv->card, IF_CS_H_INT_CAUSE, 431 if_cs_write16(priv->card, IF_CS_HOST_INT_CAUSE,
447 IF_CS_H_IC_HOST_EVENT); 432 IF_CS_BIT_EVENT);
448 lbs_deb_cs("host event 0x%04x\n", event); 433 lbs_deb_cs("host event 0x%04x\n", event);
449 lbs_queue_event(priv, event >> 8 & 0xff); 434 lbs_queue_event(priv, event >> 8 & 0xff);
450 } 435 }
@@ -511,26 +496,26 @@ static int if_cs_prog_helper(struct if_cs_card *card)
511 496
512 /* "write the number of bytes to be sent to the I/O Command 497 /* "write the number of bytes to be sent to the I/O Command
513 * write length register" */ 498 * write length register" */
514 if_cs_write16(card, IF_CS_H_CMD_LEN, count); 499 if_cs_write16(card, IF_CS_HOST_CMD_LEN, count);
515 500
516 /* "write this to I/O Command port register as 16 bit writes */ 501 /* "write this to I/O Command port register as 16 bit writes */
517 if (count) 502 if (count)
518 if_cs_write16_rep(card, IF_CS_H_CMD, 503 if_cs_write16_rep(card, IF_CS_HOST_CMD,
519 &fw->data[sent], 504 &fw->data[sent],
520 count >> 1); 505 count >> 1);
521 506
522 /* "Assert the download over interrupt command in the Host 507 /* "Assert the download over interrupt command in the Host
523 * status register" */ 508 * status register" */
524 if_cs_write8(card, IF_CS_H_STATUS, IF_CS_H_STATUS_DNLD_OVER); 509 if_cs_write8(card, IF_CS_HOST_STATUS, IF_CS_BIT_COMMAND);
525 510
526 /* "Assert the download over interrupt command in the Card 511 /* "Assert the download over interrupt command in the Card
527 * interrupt case register" */ 512 * interrupt case register" */
528 if_cs_write16(card, IF_CS_H_INT_CAUSE, IF_CS_H_IC_DNLD_OVER); 513 if_cs_write16(card, IF_CS_HOST_INT_CAUSE, IF_CS_BIT_COMMAND);
529 514
530 /* "The host polls the Card Status register ... for 50 ms before 515 /* "The host polls the Card Status register ... for 50 ms before
531 declaring a failure */ 516 declaring a failure */
532 ret = if_cs_poll_while_fw_download(card, IF_CS_C_STATUS, 517 ret = if_cs_poll_while_fw_download(card, IF_CS_CARD_STATUS,
533 IF_CS_C_S_CMD_DNLD_RDY); 518 IF_CS_BIT_COMMAND);
534 if (ret < 0) { 519 if (ret < 0) {
535 lbs_pr_err("can't download helper at 0x%x, ret %d\n", 520 lbs_pr_err("can't download helper at 0x%x, ret %d\n",
536 sent, ret); 521 sent, ret);
@@ -572,14 +557,15 @@ static int if_cs_prog_real(struct if_cs_card *card)
572 } 557 }
573 lbs_deb_cs("fw size %td\n", fw->size); 558 lbs_deb_cs("fw size %td\n", fw->size);
574 559
575 ret = if_cs_poll_while_fw_download(card, IF_CS_C_SQ_READ_LOW, IF_CS_C_SQ_HELPER_OK); 560 ret = if_cs_poll_while_fw_download(card, IF_CS_CARD_SQ_READ_LOW,
561 IF_CS_CARD_SQ_HELPER_OK);
576 if (ret < 0) { 562 if (ret < 0) {
577 lbs_pr_err("helper firmware doesn't answer\n"); 563 lbs_pr_err("helper firmware doesn't answer\n");
578 goto err_release; 564 goto err_release;
579 } 565 }
580 566
581 for (sent = 0; sent < fw->size; sent += len) { 567 for (sent = 0; sent < fw->size; sent += len) {
582 len = if_cs_read16(card, IF_CS_C_SQ_READ_LOW); 568 len = if_cs_read16(card, IF_CS_CARD_SQ_READ_LOW);
583 if (len & 1) { 569 if (len & 1) {
584 retry++; 570 retry++;
585 lbs_pr_info("odd, need to retry this firmware block\n"); 571 lbs_pr_info("odd, need to retry this firmware block\n");
@@ -597,16 +583,16 @@ static int if_cs_prog_real(struct if_cs_card *card)
597 } 583 }
598 584
599 585
600 if_cs_write16(card, IF_CS_H_CMD_LEN, len); 586 if_cs_write16(card, IF_CS_HOST_CMD_LEN, len);
601 587
602 if_cs_write16_rep(card, IF_CS_H_CMD, 588 if_cs_write16_rep(card, IF_CS_HOST_CMD,
603 &fw->data[sent], 589 &fw->data[sent],
604 (len+1) >> 1); 590 (len+1) >> 1);
605 if_cs_write8(card, IF_CS_H_STATUS, IF_CS_H_STATUS_DNLD_OVER); 591 if_cs_write8(card, IF_CS_HOST_STATUS, IF_CS_BIT_COMMAND);
606 if_cs_write16(card, IF_CS_H_INT_CAUSE, IF_CS_H_IC_DNLD_OVER); 592 if_cs_write16(card, IF_CS_HOST_INT_CAUSE, IF_CS_BIT_COMMAND);
607 593
608 ret = if_cs_poll_while_fw_download(card, IF_CS_C_STATUS, 594 ret = if_cs_poll_while_fw_download(card, IF_CS_CARD_STATUS,
609 IF_CS_C_S_CMD_DNLD_RDY); 595 IF_CS_BIT_COMMAND);
610 if (ret < 0) { 596 if (ret < 0) {
611 lbs_pr_err("can't download firmware at 0x%x\n", sent); 597 lbs_pr_err("can't download firmware at 0x%x\n", sent);
612 goto err_release; 598 goto err_release;
@@ -834,7 +820,7 @@ static int if_cs_probe(struct pcmcia_device *p_dev)
834 820
835 /* Clear any interrupt cause that happend while sending 821 /* Clear any interrupt cause that happend while sending
836 * firmware/initializing card */ 822 * firmware/initializing card */
837 if_cs_write16(card, IF_CS_C_INT_CAUSE, IF_CS_C_IC_MASK); 823 if_cs_write16(card, IF_CS_CARD_INT_CAUSE, IF_CS_BIT_MASK);
838 if_cs_enable_ints(card); 824 if_cs_enable_ints(card);
839 825
840 /* And finally bring the card up */ 826 /* And finally bring the card up */