Searched refs:card (Results 1 - 200 of 2511) sorted by relevance

1234567891011>>

/linux-4.1.27/sound/soc/generic/
H A DMakefile1 snd-soc-simple-card-objs := simple-card.o
3 obj-$(CONFIG_SND_SIMPLE_CARD) += snd-soc-simple-card.o
/linux-4.1.27/drivers/isdn/isdnloop/
H A Disdnloop.c21 MODULE_DESCRIPTION("ISDN4Linux: Pseudo Driver that simulates an ISDN card");
25 MODULE_PARM_DESC(isdnloop_id, "ID-String of first card");
33 * card = pointer to card struct
37 isdnloop_free_queue(isdnloop_card *card, int channel) isdnloop_free_queue() argument
39 struct sk_buff_head *queue = &card->bqueue[channel]; isdnloop_free_queue()
42 card->sndcount[channel] = 0; isdnloop_free_queue()
46 * Send B-Channel data to another virtual card.
50 * card = pointer to card struct.
54 isdnloop_bchan_send(isdnloop_card *card, int ch) isdnloop_bchan_send() argument
56 isdnloop_card *rcard = card->rcard[ch]; isdnloop_bchan_send()
57 int rch = card->rch[ch], len, ack; isdnloop_bchan_send()
61 while (card->sndcount[ch]) { isdnloop_bchan_send()
62 skb = skb_dequeue(&card->bqueue[ch]); isdnloop_bchan_send()
65 card->sndcount[ch] -= len; isdnloop_bchan_send()
67 cmd.driver = card->myid; isdnloop_bchan_send()
78 card->interface.statcallb(&cmd); isdnloop_bchan_send()
80 card->sndcount[ch] = 0; isdnloop_bchan_send()
90 * data = pointer to card struct, set by kernel timer.data
95 isdnloop_card *card = (isdnloop_card *) data; isdnloop_pollbchan() local
98 if (card->flags & ISDNLOOP_FLAGS_B1ACTIVE) isdnloop_pollbchan()
99 isdnloop_bchan_send(card, 0); isdnloop_pollbchan()
100 if (card->flags & ISDNLOOP_FLAGS_B2ACTIVE) isdnloop_pollbchan()
101 isdnloop_bchan_send(card, 1); isdnloop_pollbchan()
102 if (card->flags & (ISDNLOOP_FLAGS_B1ACTIVE | ISDNLOOP_FLAGS_B2ACTIVE)) { isdnloop_pollbchan()
104 spin_lock_irqsave(&card->isdnloop_lock, flags); isdnloop_pollbchan()
105 card->rb_timer.expires = jiffies + ISDNLOOP_TIMER_BCREAD; isdnloop_pollbchan()
106 add_timer(&card->rb_timer); isdnloop_pollbchan()
107 card->flags |= ISDNLOOP_FLAGS_RBTIMER; isdnloop_pollbchan()
108 spin_unlock_irqrestore(&card->isdnloop_lock, flags); isdnloop_pollbchan()
110 card->flags &= ~ISDNLOOP_FLAGS_RBTIMER; isdnloop_pollbchan()
175 * Parse Status message-strings from virtual card.
182 * card = card where message comes from.
185 isdnloop_parse_status(u_char *status, int channel, isdnloop_card *card) isdnloop_parse_status() argument
201 cmd.driver = card->myid; isdnloop_parse_status()
206 card->flags |= (channel) ? isdnloop_parse_status()
211 card->flags &= ~((channel) ? isdnloop_parse_status()
213 isdnloop_free_queue(card, channel); isdnloop_parse_status()
221 sprintf(cmd.parm.setup.phone, "LEASED%d", card->myid); isdnloop_parse_status()
248 card->flags &= ~ISDNLOOP_FLAGS_B1ACTIVE; isdnloop_parse_status()
249 isdnloop_free_queue(card, 0); isdnloop_parse_status()
251 cmd.driver = card->myid; isdnloop_parse_status()
252 card->interface.statcallb(&cmd); isdnloop_parse_status()
255 cmd.driver = card->myid; isdnloop_parse_status()
256 card->interface.statcallb(&cmd); isdnloop_parse_status()
258 card->flags &= ~ISDNLOOP_FLAGS_B2ACTIVE; isdnloop_parse_status()
259 isdnloop_free_queue(card, 1); isdnloop_parse_status()
261 cmd.driver = card->myid; isdnloop_parse_status()
262 card->interface.statcallb(&cmd); isdnloop_parse_status()
265 cmd.driver = card->myid; isdnloop_parse_status()
268 card->interface.statcallb(&cmd); isdnloop_parse_status()
275 * card = pointer to card struct.
279 isdnloop_putmsg(isdnloop_card *card, unsigned char c) isdnloop_putmsg() argument
283 spin_lock_irqsave(&card->isdnloop_lock, flags); isdnloop_putmsg()
284 *card->msg_buf_write++ = (c == 0xff) ? '\n' : c; isdnloop_putmsg()
285 if (card->msg_buf_write == card->msg_buf_read) { isdnloop_putmsg()
286 if (++card->msg_buf_read > card->msg_buf_end) isdnloop_putmsg()
287 card->msg_buf_read = card->msg_buf; isdnloop_putmsg()
289 if (card->msg_buf_write > card->msg_buf_end) isdnloop_putmsg()
290 card->msg_buf_write = card->msg_buf; isdnloop_putmsg()
291 spin_unlock_irqrestore(&card->isdnloop_lock, flags); isdnloop_putmsg()
296 * If there are new status-replies from the card, copy them to
305 * data = pointer to card struct
310 isdnloop_card *card = (isdnloop_card *) data; isdnloop_polldchan() local
320 skb = skb_dequeue(&card->dqueue); isdnloop_polldchan()
328 isdnloop_putmsg(card, c); isdnloop_polldchan()
329 card->imsg[card->iptr] = c; isdnloop_polldchan()
330 if (card->iptr < 59) isdnloop_polldchan()
331 card->iptr++; isdnloop_polldchan()
334 isdnloop_putmsg(card, '\n'); isdnloop_polldchan()
335 card->imsg[card->iptr] = 0; isdnloop_polldchan()
336 card->iptr = 0; isdnloop_polldchan()
337 if (card->imsg[0] == '0' && card->imsg[1] >= '0' && isdnloop_polldchan()
338 card->imsg[1] <= '2' && card->imsg[2] == ';') { isdnloop_polldchan()
339 ch = (card->imsg[1] - '0') - 1; isdnloop_polldchan()
340 p = &card->imsg[3]; isdnloop_polldchan()
341 isdnloop_parse_status(p, ch, card); isdnloop_polldchan()
343 p = card->imsg; isdnloop_polldchan()
347 card->ptype = ISDN_PTYPE_1TR6; isdnloop_polldchan()
348 card->interface.features |= ISDN_FEATURE_P_1TR6; isdnloop_polldchan()
353 card->ptype = ISDN_PTYPE_EURO; isdnloop_polldchan()
354 card->interface.features |= ISDN_FEATURE_P_EURO; isdnloop_polldchan()
366 cmd.driver = card->myid; isdnloop_polldchan()
368 card->interface.statcallb(&cmd); isdnloop_polldchan()
370 if (card->flags & (ISDNLOOP_FLAGS_B1ACTIVE | ISDNLOOP_FLAGS_B2ACTIVE)) isdnloop_polldchan()
371 if (!(card->flags & ISDNLOOP_FLAGS_RBTIMER)) { isdnloop_polldchan()
373 card->flags |= ISDNLOOP_FLAGS_RBTIMER; isdnloop_polldchan()
374 spin_lock_irqsave(&card->isdnloop_lock, flags); isdnloop_polldchan()
375 del_timer(&card->rb_timer); isdnloop_polldchan()
376 card->rb_timer.function = isdnloop_pollbchan; isdnloop_polldchan()
377 card->rb_timer.data = (unsigned long) card; isdnloop_polldchan()
378 card->rb_timer.expires = jiffies + ISDNLOOP_TIMER_BCREAD; isdnloop_polldchan()
379 add_timer(&card->rb_timer); isdnloop_polldchan()
380 spin_unlock_irqrestore(&card->isdnloop_lock, flags); isdnloop_polldchan()
383 spin_lock_irqsave(&card->isdnloop_lock, flags); isdnloop_polldchan()
384 card->st_timer.expires = jiffies + ISDNLOOP_TIMER_DCREAD; isdnloop_polldchan()
385 add_timer(&card->st_timer); isdnloop_polldchan()
386 spin_unlock_irqrestore(&card->isdnloop_lock, flags); isdnloop_polldchan()
395 * card = pointer to card-struct
400 isdnloop_sendbuf(int channel, struct sk_buff *skb, isdnloop_card *card) isdnloop_sendbuf() argument
412 if (!(card->flags & (channel) ? ISDNLOOP_FLAGS_B2ACTIVE : ISDNLOOP_FLAGS_B1ACTIVE)) isdnloop_sendbuf()
414 if (card->sndcount[channel] > ISDNLOOP_MAX_SQUEUE) isdnloop_sendbuf()
416 spin_lock_irqsave(&card->isdnloop_lock, flags); isdnloop_sendbuf()
421 skb_queue_tail(&card->bqueue[channel], nskb); isdnloop_sendbuf()
425 card->sndcount[channel] += len; isdnloop_sendbuf()
426 spin_unlock_irqrestore(&card->isdnloop_lock, flags); isdnloop_sendbuf()
432 * Read the messages from the card's ringbuffer
438 * card = pointer to card struct.
443 isdnloop_readstatus(u_char __user *buf, int len, isdnloop_card *card) isdnloop_readstatus() argument
449 if (card->msg_buf_read == card->msg_buf_write) isdnloop_readstatus()
451 if (put_user(*card->msg_buf_read++, p)) isdnloop_readstatus()
453 if (card->msg_buf_read > card->msg_buf_end) isdnloop_readstatus()
454 card->msg_buf_read = card->msg_buf; isdnloop_readstatus()
460 * Simulate a card's response by appending it to the cards
464 * card = pointer to card struct.
471 isdnloop_fake(isdnloop_card *card, char *s, int ch) isdnloop_fake() argument
483 skb_queue_tail(&card->dqueue, skb); isdnloop_fake()
513 * Simulate an error-response from a card.
516 * card = pointer to card struct.
519 isdnloop_fake_err(isdnloop_card *card) isdnloop_fake_err() argument
523 snprintf(buf, sizeof(buf), "E%s", card->omsg); isdnloop_fake_err()
524 isdnloop_fake(card, buf, -1); isdnloop_fake_err()
525 isdnloop_fake(card, "NAK", -1); isdnloop_fake_err()
536 * card = pointer to card struct.
543 isdnloop_unicause(isdnloop_card *card, int loc, int cau) isdnloop_unicause() argument
547 switch (card->ptype) { isdnloop_unicause()
565 * card = pointer to card struct.
569 isdnloop_atimeout(isdnloop_card *card, int ch) isdnloop_atimeout() argument
574 spin_lock_irqsave(&card->isdnloop_lock, flags); isdnloop_atimeout()
575 if (card->rcard) { isdnloop_atimeout()
576 isdnloop_fake(card->rcard[ch], "DDIS_I", card->rch[ch] + 1); isdnloop_atimeout()
577 card->rcard[ch]->rcard[card->rch[ch]] = NULL; isdnloop_atimeout()
578 card->rcard[ch] = NULL; isdnloop_atimeout()
580 isdnloop_fake(card, "DDIS_I", ch + 1); isdnloop_atimeout()
582 sprintf(buf, "CAU%s", isdnloop_unicause(card, 1, 3)); isdnloop_atimeout()
583 isdnloop_fake(card, buf, ch + 1); isdnloop_atimeout()
584 spin_unlock_irqrestore(&card->isdnloop_lock, flags); isdnloop_atimeout()
593 isdnloop_card *card = (isdnloop_card *) data; isdnloop_atimeout0() local
594 isdnloop_atimeout(card, 0); isdnloop_atimeout0()
603 isdnloop_card *card = (isdnloop_card *) data; isdnloop_atimeout1() local
604 isdnloop_atimeout(card, 1); isdnloop_atimeout1()
611 * card = pointer to card struct.
615 isdnloop_start_ctimer(isdnloop_card *card, int ch) isdnloop_start_ctimer() argument
619 spin_lock_irqsave(&card->isdnloop_lock, flags); isdnloop_start_ctimer()
620 init_timer(&card->c_timer[ch]); isdnloop_start_ctimer()
621 card->c_timer[ch].expires = jiffies + ISDNLOOP_TIMER_ALERTWAIT; isdnloop_start_ctimer()
623 card->c_timer[ch].function = isdnloop_atimeout1; isdnloop_start_ctimer()
625 card->c_timer[ch].function = isdnloop_atimeout0; isdnloop_start_ctimer()
626 card->c_timer[ch].data = (unsigned long) card; isdnloop_start_ctimer()
627 add_timer(&card->c_timer[ch]); isdnloop_start_ctimer()
628 spin_unlock_irqrestore(&card->isdnloop_lock, flags); isdnloop_start_ctimer()
635 * card = pointer to card struct.
639 isdnloop_kill_ctimer(isdnloop_card *card, int ch) isdnloop_kill_ctimer() argument
643 spin_lock_irqsave(&card->isdnloop_lock, flags); isdnloop_kill_ctimer()
644 del_timer(&card->c_timer[ch]); isdnloop_kill_ctimer()
645 spin_unlock_irqrestore(&card->isdnloop_lock, flags); isdnloop_kill_ctimer()
655 * card = pointer to calling card.
657 * lch = channel of calling card.
666 isdnloop_try_call(isdnloop_card *card, char *p, int lch, isdn_ctrl *cmd) isdnloop_try_call() argument
680 if ((cc == card) && (ch == lch)) isdnloop_try_call()
699 spin_lock_irqsave(&card->isdnloop_lock, flags); isdnloop_try_call()
704 spin_unlock_irqrestore(&card->isdnloop_lock, flags); isdnloop_try_call()
708 cc->rcard[ch] = card; isdnloop_try_call()
710 card->rcard[lch] = cc; isdnloop_try_call()
711 card->rch[lch] = ch; isdnloop_try_call()
712 spin_unlock_irqrestore(&card->isdnloop_lock, flags); isdnloop_try_call()
715 spin_unlock_irqrestore(&card->isdnloop_lock, flags); isdnloop_try_call()
732 * card = pointer to card struct.
739 isdnloop_vstphone(isdnloop_card *card, char *phone, int caller) isdnloop_vstphone() argument
744 if (!card) { isdnloop_vstphone()
748 switch (card->ptype) { isdnloop_vstphone()
752 if (!(strcmp(card->s0num[i], phone))) isdnloop_vstphone()
754 return card->s0num[0]; isdnloop_vstphone()
760 sprintf(nphone, "%s%c", card->s0num[0], phone[0]); isdnloop_vstphone()
770 * Parse an ICN-type command string sent to the 'card'.
774 * card = pointer to card struct.
777 isdnloop_parse_cmd(isdnloop_card *card) isdnloop_parse_cmd() argument
779 char *p = card->omsg; isdnloop_parse_cmd()
787 if ((card->omsg[0] != '0') && (card->omsg[2] != ';')) { isdnloop_parse_cmd()
788 isdnloop_fake_err(card); isdnloop_parse_cmd()
791 ch = card->omsg[1] - '0'; isdnloop_parse_cmd()
793 isdnloop_fake_err(card); isdnloop_parse_cmd()
801 isdnloop_fake_err(card); isdnloop_parse_cmd()
813 if (card->rcard[ch - 1]) { isdnloop_parse_cmd()
814 isdnloop_fake(card->rcard[ch - 1], "BCON_I", isdnloop_parse_cmd()
815 card->rch[ch - 1] + 1); isdnloop_parse_cmd()
816 isdnloop_fake(card, "BCON_C", ch); isdnloop_parse_cmd()
821 if (card->rcard[ch - 1]) { isdnloop_parse_cmd()
822 isdnloop_fake(card->rcard[ch - 1], "BCON_C", isdnloop_parse_cmd()
823 card->rch[ch - 1] + 1); isdnloop_parse_cmd()
828 isdnloop_fake(card, "BDIS_C", ch); isdnloop_parse_cmd()
829 if (card->rcard[ch - 1]) { isdnloop_parse_cmd()
830 isdnloop_fake(card->rcard[ch - 1], "BDIS_I", isdnloop_parse_cmd()
831 card->rch[ch - 1] + 1); isdnloop_parse_cmd()
836 isdnloop_kill_ctimer(card, ch - 1); isdnloop_parse_cmd()
837 if (card->rcard[ch - 1]) { isdnloop_parse_cmd()
838 isdnloop_kill_ctimer(card->rcard[ch - 1], card->rch[ch - 1]); isdnloop_parse_cmd()
839 isdnloop_fake(card->rcard[ch - 1], "DCON_C", isdnloop_parse_cmd()
840 card->rch[ch - 1] + 1); isdnloop_parse_cmd()
841 isdnloop_fake(card, "DCON_C", ch); isdnloop_parse_cmd()
846 isdnloop_kill_ctimer(card, ch - 1); isdnloop_parse_cmd()
847 if (card->rcard[ch - 1]) { isdnloop_parse_cmd()
848 isdnloop_kill_ctimer(card->rcard[ch - 1], card->rch[ch - 1]); isdnloop_parse_cmd()
849 isdnloop_fake(card->rcard[ch - 1], "DDIS_I", isdnloop_parse_cmd()
850 card->rch[ch - 1] + 1); isdnloop_parse_cmd()
851 card->rcard[ch - 1] = NULL; isdnloop_parse_cmd()
853 isdnloop_fake(card, "DDIS_C", ch); isdnloop_parse_cmd()
857 if (card->ptype != ISDN_PTYPE_1TR6) { isdnloop_parse_cmd()
858 isdnloop_fake_err(card); isdnloop_parse_cmd()
865 switch (isdnloop_try_call(card, p, ch - 1, &cmd)) { isdnloop_parse_cmd()
870 isdnloop_vstphone(card, cmd.parm.setup.eazmsn, 1), isdnloop_parse_cmd()
873 isdnloop_vstphone(card->rcard[ch - 1], isdnloop_parse_cmd()
875 isdnloop_fake(card->rcard[ch - 1], buf, card->rch[ch - 1] + 1); isdnloop_parse_cmd()
879 isdnloop_start_ctimer(card, ch - 1); isdnloop_parse_cmd()
883 isdnloop_fake(card, "DDIS_I", ch); isdnloop_parse_cmd()
884 sprintf(buf, "CAU%s", isdnloop_unicause(card, 1, 1)); isdnloop_parse_cmd()
885 isdnloop_fake(card, buf, ch); isdnloop_parse_cmd()
889 isdnloop_fake(card, "DDIS_I", ch); isdnloop_parse_cmd()
890 sprintf(buf, "CAU%s", isdnloop_unicause(card, 1, 2)); isdnloop_parse_cmd()
891 isdnloop_fake(card, buf, ch); isdnloop_parse_cmd()
897 card->eazlist[ch - 1][0] = '\0'; isdnloop_parse_cmd()
902 if (strlen(p) >= sizeof(card->eazlist[0])) isdnloop_parse_cmd()
904 strcpy(card->eazlist[ch - 1], p); isdnloop_parse_cmd()
908 sprintf(buf, "EAZ-LIST: %s", card->eazlist[ch - 1]); isdnloop_parse_cmd()
909 isdnloop_fake(card, buf, ch + 1); isdnloop_parse_cmd()
923 card->sil[ch - 1] |= si2bit[*p - '0']; isdnloop_parse_cmd()
927 isdnloop_fake_err(card); isdnloop_parse_cmd()
934 if (card->sil[ch - 1] & (1 << i)) isdnloop_parse_cmd()
936 isdnloop_fake(card, buf, ch + 1); isdnloop_parse_cmd()
940 card->sil[ch - 1] = 0; isdnloop_parse_cmd()
952 * Put command-strings into the of the 'card'. In reality, execute them
961 * card = pointer to card struct.
966 isdnloop_writecmd(const u_char *buf, int len, int user, isdnloop_card *card) isdnloop_writecmd() argument
984 isdnloop_putmsg(card, '>'); isdnloop_writecmd()
988 isdnloop_putmsg(card, *p); isdnloop_writecmd()
989 card->omsg[card->optr] = *p; isdnloop_writecmd()
991 card->omsg[card->optr] = '\0'; isdnloop_writecmd()
992 card->optr = 0; isdnloop_writecmd()
993 isdnloop_parse_cmd(card); isdnloop_writecmd()
995 isdnloop_putmsg(card, '>'); isdnloop_writecmd()
999 if (card->optr < 59) isdnloop_writecmd()
1000 card->optr++; isdnloop_writecmd()
1006 cmd.driver = card->myid; isdnloop_writecmd()
1008 card->interface.statcallb(&cmd); isdnloop_writecmd()
1013 * Delete card's pending timers, send STOP to linklevel
1016 isdnloop_stopcard(isdnloop_card *card) isdnloop_stopcard() argument
1021 spin_lock_irqsave(&card->isdnloop_lock, flags); isdnloop_stopcard()
1022 if (card->flags & ISDNLOOP_FLAGS_RUNNING) { isdnloop_stopcard()
1023 card->flags &= ~ISDNLOOP_FLAGS_RUNNING; isdnloop_stopcard()
1024 del_timer(&card->st_timer); isdnloop_stopcard()
1025 del_timer(&card->rb_timer); isdnloop_stopcard()
1026 del_timer(&card->c_timer[0]); isdnloop_stopcard()
1027 del_timer(&card->c_timer[1]); isdnloop_stopcard()
1029 cmd.driver = card->myid; isdnloop_stopcard()
1030 card->interface.statcallb(&cmd); isdnloop_stopcard()
1032 spin_unlock_irqrestore(&card->isdnloop_lock, flags); isdnloop_stopcard()
1050 * Start a 'card'. Simulate card's boot message and set the phone
1055 * card = pointer to card struct.
1061 isdnloop_start(isdnloop_card *card, isdnloop_sdef *sdefp) isdnloop_start() argument
1067 if (card->flags & ISDNLOOP_FLAGS_RUNNING) isdnloop_start()
1077 spin_lock_irqsave(&card->isdnloop_lock, flags); isdnloop_start()
1080 if (isdnloop_fake(card, "DRV1.23EC-Q.931-CAPI-CNS-BASIS-20.02.96", isdnloop_start()
1082 spin_unlock_irqrestore(&card->isdnloop_lock, flags); isdnloop_start()
1085 card->sil[0] = card->sil[1] = 4; isdnloop_start()
1086 if (isdnloop_fake(card, "TEI OK", 0)) { isdnloop_start()
1087 spin_unlock_irqrestore(&card->isdnloop_lock, flags); isdnloop_start()
1091 strlcpy(card->s0num[i], sdef.num[i], isdnloop_start()
1092 sizeof(card->s0num[0])); isdnloop_start()
1096 if (isdnloop_fake(card, "DRV1.04TC-1TR6-CAPI-CNS-BASIS-29.11.95", isdnloop_start()
1098 spin_unlock_irqrestore(&card->isdnloop_lock, flags); isdnloop_start()
1101 card->sil[0] = card->sil[1] = 4; isdnloop_start()
1102 if (isdnloop_fake(card, "TEI OK", 0)) { isdnloop_start()
1103 spin_unlock_irqrestore(&card->isdnloop_lock, flags); isdnloop_start()
1106 strlcpy(card->s0num[0], sdef.num[0], sizeof(card->s0num[0])); isdnloop_start()
1107 card->s0num[1][0] = '\0'; isdnloop_start()
1108 card->s0num[2][0] = '\0'; isdnloop_start()
1111 spin_unlock_irqrestore(&card->isdnloop_lock, flags); isdnloop_start()
1116 init_timer(&card->st_timer); isdnloop_start()
1117 card->st_timer.expires = jiffies + ISDNLOOP_TIMER_DCREAD; isdnloop_start()
1118 card->st_timer.function = isdnloop_polldchan; isdnloop_start()
1119 card->st_timer.data = (unsigned long) card; isdnloop_start()
1120 add_timer(&card->st_timer); isdnloop_start()
1121 card->flags |= ISDNLOOP_FLAGS_RUNNING; isdnloop_start()
1122 spin_unlock_irqrestore(&card->isdnloop_lock, flags); isdnloop_start()
1130 isdnloop_command(isdn_ctrl *c, isdnloop_card *card) isdnloop_command() argument
1143 return (ulong) card; isdnloop_command()
1147 return isdnloop_start(card, (isdnloop_sdef *) a); isdnloop_command()
1158 if (!card->leased) { isdnloop_command()
1159 card->leased = 1; isdnloop_command()
1160 while (card->ptype == ISDN_PTYPE_UNKNOWN) isdnloop_command()
1164 i = isdnloop_writecmd(cbuf, strlen(cbuf), 0, card); isdnloop_command()
1169 cmd.driver = card->myid; isdnloop_command()
1171 card->interface.statcallb(&cmd); isdnloop_command()
1174 if (card->leased) { isdnloop_command()
1175 card->leased = 0; isdnloop_command()
1177 i = isdnloop_writecmd(cbuf, strlen(cbuf), 0, card); isdnloop_command()
1182 cmd.driver = card->myid; isdnloop_command()
1184 card->interface.statcallb(&cmd); isdnloop_command()
1193 if (!(card->flags & ISDNLOOP_FLAGS_RUNNING)) isdnloop_command()
1195 if (card->leased) isdnloop_command()
1214 i = isdnloop_writecmd(cbuf, strlen(cbuf), 0, card); isdnloop_command()
1218 if (!(card->flags & ISDNLOOP_FLAGS_RUNNING)) isdnloop_command()
1223 switch (card->l2_proto[a - 1]) { isdnloop_command()
1240 i = isdnloop_writecmd(cbuf, strlen(cbuf), 0, card); isdnloop_command()
1242 i = isdnloop_writecmd(cbuf, strlen(cbuf), 0, card); isdnloop_command()
1246 if (!(card->flags & ISDNLOOP_FLAGS_RUNNING)) isdnloop_command()
1250 switch (card->l2_proto[a - 1]) { isdnloop_command()
1269 i = isdnloop_writecmd(cbuf, strlen(cbuf), 0, card); isdnloop_command()
1272 if (!(card->flags & ISDNLOOP_FLAGS_RUNNING)) isdnloop_command()
1277 i = isdnloop_writecmd(cbuf, strlen(cbuf), 0, card); isdnloop_command()
1281 if (!(card->flags & ISDNLOOP_FLAGS_RUNNING)) isdnloop_command()
1283 if (card->leased) isdnloop_command()
1287 if (card->ptype == ISDN_PTYPE_EURO) { isdnloop_command()
1293 i = isdnloop_writecmd(cbuf, strlen(cbuf), 0, card); isdnloop_command()
1297 if (!(card->flags & ISDNLOOP_FLAGS_RUNNING)) isdnloop_command()
1299 if (card->leased) isdnloop_command()
1303 if (card->ptype == ISDN_PTYPE_EURO) isdnloop_command()
1307 i = isdnloop_writecmd(cbuf, strlen(cbuf), 0, card); isdnloop_command()
1311 if (!(card->flags & ISDNLOOP_FLAGS_RUNNING)) isdnloop_command()
1336 i = isdnloop_writecmd(cbuf, strlen(cbuf), 0, card); isdnloop_command()
1337 card->l2_proto[a & 255] = (a >> 8); isdnloop_command()
1341 if (!(card->flags & ISDNLOOP_FLAGS_RUNNING)) isdnloop_command()
1352 * Find card with given driverId
1373 isdnloop_card *card = isdnloop_findcard(c->driver); if_command() local
1375 if (card) if_command()
1376 return isdnloop_command(c, card); if_command()
1385 isdnloop_card *card = isdnloop_findcard(id); if_writecmd() local
1387 if (card) { if_writecmd()
1388 if (!(card->flags & ISDNLOOP_FLAGS_RUNNING)) if_writecmd()
1390 return isdnloop_writecmd(buf, len, 1, card); if_writecmd()
1400 isdnloop_card *card = isdnloop_findcard(id); if_readstatus() local
1402 if (card) { if_readstatus()
1403 if (!(card->flags & ISDNLOOP_FLAGS_RUNNING)) if_readstatus()
1405 return isdnloop_readstatus(buf, len, card); if_readstatus()
1415 isdnloop_card *card = isdnloop_findcard(id); if_sendbuf() local
1417 if (card) { if_sendbuf()
1418 if (!(card->flags & ISDNLOOP_FLAGS_RUNNING)) if_sendbuf()
1422 return isdnloop_sendbuf(channel, skb, card); if_sendbuf()
1430 * Allocate a new card-struct, initialize it
1436 isdnloop_card *card; isdnloop_initcard() local
1438 card = kzalloc(sizeof(isdnloop_card), GFP_KERNEL); isdnloop_initcard()
1439 if (!card) { isdnloop_initcard()
1441 "isdnloop: (%s) Could not allocate card-struct.\n", id); isdnloop_initcard()
1444 card->interface.owner = THIS_MODULE; isdnloop_initcard()
1445 card->interface.channels = ISDNLOOP_BCH; isdnloop_initcard()
1446 card->interface.hl_hdrlen = 1; /* scratch area for storing ack flag*/ isdnloop_initcard()
1447 card->interface.maxbufsize = 4000; isdnloop_initcard()
1448 card->interface.command = if_command; isdnloop_initcard()
1449 card->interface.writebuf_skb = if_sendbuf; isdnloop_initcard()
1450 card->interface.writecmd = if_writecmd; isdnloop_initcard()
1451 card->interface.readstat = if_readstatus; isdnloop_initcard()
1452 card->interface.features = ISDN_FEATURE_L2_X75I | isdnloop_initcard()
1460 card->ptype = ISDN_PTYPE_UNKNOWN; isdnloop_initcard()
1461 strlcpy(card->interface.id, id, sizeof(card->interface.id)); isdnloop_initcard()
1462 card->msg_buf_write = card->msg_buf; isdnloop_initcard()
1463 card->msg_buf_read = card->msg_buf; isdnloop_initcard()
1464 card->msg_buf_end = &card->msg_buf[sizeof(card->msg_buf) - 1]; isdnloop_initcard()
1466 card->l2_proto[i] = ISDN_PROTO_L2_X75I; isdnloop_initcard()
1467 skb_queue_head_init(&card->bqueue[i]); isdnloop_initcard()
1469 skb_queue_head_init(&card->dqueue); isdnloop_initcard()
1470 spin_lock_init(&card->isdnloop_lock); isdnloop_initcard()
1471 card->next = cards; isdnloop_initcard()
1472 cards = card; isdnloop_initcard()
1473 if (!register_isdn(&card->interface)) { isdnloop_initcard()
1477 kfree(card); isdnloop_initcard()
1480 card->myid = card->interface.channels; isdnloop_initcard()
1481 return card; isdnloop_initcard()
1487 isdnloop_card *card; isdnloop_addcard() local
1488 card = isdnloop_initcard(id1); isdnloop_addcard()
1489 if (!card) { isdnloop_addcard()
1493 "isdnloop: (%s) virtual card added\n", isdnloop_addcard()
1494 card->interface.id); isdnloop_addcard()
1511 isdnloop_card *card = cards; isdnloop_exit() local
1516 while (card) { isdnloop_exit()
1518 cmd.driver = card->myid; isdnloop_exit()
1519 card->interface.statcallb(&cmd); isdnloop_exit()
1521 isdnloop_free_queue(card, i); isdnloop_exit()
1522 card = card->next; isdnloop_exit()
1524 card = cards; isdnloop_exit()
1525 while (card) { isdnloop_exit()
1526 last = card; isdnloop_exit()
1527 skb_queue_purge(&card->dqueue); isdnloop_exit()
1528 card = card->next; isdnloop_exit()
/linux-4.1.27/drivers/isdn/sc/
H A Dcommand.c22 #include "card.h"
25 static int dial(int card, unsigned long channel, setup_parm setup);
26 static int hangup(int card, unsigned long channel);
27 static int answer(int card, unsigned long channel);
28 static int clreaz(int card, unsigned long channel);
29 static int seteaz(int card, unsigned long channel, char *);
30 static int setl2(int card, unsigned long arg);
31 static int setl3(int card, unsigned long arg);
32 static int acceptb(int card, unsigned long channel);
85 int card; command() local
87 card = get_card_from_id(cmd->driver); command()
88 if (!IS_VALID_CARD(card)) { command()
89 pr_debug("Invalid param: %d is not a valid card id\n", card); command()
106 sc_adapter[card]->devicename, cmdptr); command()
109 return sc_ioctl(card, &ioc); command()
112 return dial(card, cmd->arg, cmd->parm.setup); command()
114 return hangup(card, cmd->arg); command()
116 return answer(card, cmd->arg); command()
118 return acceptb(card, cmd->arg); command()
120 return clreaz(card, cmd->arg); command()
122 return seteaz(card, cmd->arg, cmd->parm.num); command()
124 return setl2(card, cmd->arg); command()
126 return setl3(card, cmd->arg); command()
136 int startproc(int card) startproc() argument
140 if (!IS_VALID_CARD(card)) { startproc()
141 pr_debug("Invalid param: %d is not a valid card id\n", card); startproc()
148 status = sendmessage(card, CMPID, cmReqType2, startproc()
152 pr_debug("%s: Sent startProc\n", sc_adapter[card]->devicename); startproc()
161 static int dial(int card, unsigned long channel, setup_parm setup) dial() argument
166 if (!IS_VALID_CARD(card)) { dial()
167 pr_debug("Invalid param: %d is not a valid card id\n", card); dial()
175 status = sendmessage(card, CEPID, ceReqTypePhy, dial()
183 sc_adapter[card]->devicename, Phone, channel + 1); dial()
191 static int answer(int card, unsigned long channel) answer() argument
193 if (!IS_VALID_CARD(card)) { answer()
194 pr_debug("Invalid param: %d is not a valid card id\n", card); answer()
198 if (setup_buffers(card, channel + 1)) { answer()
199 hangup(card, channel + 1); answer()
203 indicate_status(card, ISDN_STAT_BCONN, channel, NULL); answer()
205 sc_adapter[card]->devicename, channel + 1); answer()
212 static int hangup(int card, unsigned long channel) hangup() argument
216 if (!IS_VALID_CARD(card)) { hangup()
217 pr_debug("Invalid param: %d is not a valid card id\n", card); hangup()
221 status = sendmessage(card, CEPID, ceReqTypePhy, hangup()
228 sc_adapter[card]->devicename, channel + 1); hangup()
235 static int setl2(int card, unsigned long arg) setl2() argument
240 if (!IS_VALID_CARD(card)) { setl2()
241 pr_debug("Invalid param: %d is not a valid card id\n", card); setl2()
246 sc_adapter[card]->channel[channel].l2_proto = protocol; setl2()
252 sc_adapter[card]->devicename, channel + 1); setl2()
253 status = sendmessage(card, CEPID, ceReqTypeCall, setl2()
267 static int setl3(int card, unsigned long channel) setl3() argument
271 if (!IS_VALID_CARD(card)) { setl3()
272 pr_debug("Invalid param: %d is not a valid card id\n", card); setl3()
276 sc_adapter[card]->channel[channel].l3_proto = protocol; setl3()
280 static int acceptb(int card, unsigned long channel) acceptb() argument
282 if (!IS_VALID_CARD(card)) { acceptb()
283 pr_debug("Invalid param: %d is not a valid card id\n", card); acceptb()
287 if (setup_buffers(card, channel + 1)) acceptb()
289 hangup(card, channel + 1); acceptb()
294 sc_adapter[card]->devicename, channel + 1); acceptb()
295 indicate_status(card, ISDN_STAT_BCONN, channel, NULL); acceptb()
299 static int clreaz(int card, unsigned long arg) clreaz() argument
301 if (!IS_VALID_CARD(card)) { clreaz()
302 pr_debug("Invalid param: %d is not a valid card id\n", card); clreaz()
306 strcpy(sc_adapter[card]->channel[arg].eazlist, ""); clreaz()
307 sc_adapter[card]->channel[arg].eazclear = 1; clreaz()
309 sc_adapter[card]->devicename, arg + 1); clreaz()
313 static int seteaz(int card, unsigned long arg, char *num) seteaz() argument
315 if (!IS_VALID_CARD(card)) { seteaz()
316 pr_debug("Invalid param: %d is not a valid card id\n", card); seteaz()
320 strcpy(sc_adapter[card]->channel[arg].eazlist, num); seteaz()
321 sc_adapter[card]->channel[arg].eazclear = 0; seteaz()
323 sc_adapter[card]->devicename, arg + 1, seteaz()
324 sc_adapter[card]->channel[arg].eazlist); seteaz()
328 int reset(int card) reset() argument
332 if (!IS_VALID_CARD(card)) { reset()
333 pr_debug("Invalid param: %d is not a valid card id\n", card); reset()
337 indicate_status(card, ISDN_STAT_STOP, 0, NULL); reset()
339 if (sc_adapter[card]->EngineUp) { reset()
340 del_timer(&sc_adapter[card]->stat_timer); reset()
343 sc_adapter[card]->EngineUp = 0; reset()
345 spin_lock_irqsave(&sc_adapter[card]->lock, flags); reset()
346 init_timer(&sc_adapter[card]->reset_timer); reset()
347 sc_adapter[card]->reset_timer.function = sc_check_reset; reset()
348 sc_adapter[card]->reset_timer.data = card; reset()
349 sc_adapter[card]->reset_timer.expires = jiffies + CHECKRESET_TIME; reset()
350 add_timer(&sc_adapter[card]->reset_timer); reset()
351 spin_unlock_irqrestore(&sc_adapter[card]->lock, flags); reset()
353 outb(0x1, sc_adapter[card]->ioport[SFT_RESET]); reset()
355 pr_debug("%s: Adapter Reset\n", sc_adapter[card]->devicename); reset()
359 void flushreadfifo(int card) flushreadfifo() argument
361 while (inb(sc_adapter[card]->ioport[FIFO_STATUS]) & RF_HAS_DATA) flushreadfifo()
362 inb(sc_adapter[card]->ioport[FIFO_READ]); flushreadfifo()
H A Dpacket.c21 #include "card.h"
27 int card; sndpkt() local
30 card = get_card_from_id(devId); sndpkt()
32 if (!IS_VALID_CARD(card)) { sndpkt()
33 pr_debug("invalid param: %d is not a valid card id\n", card); sndpkt()
38 sc_adapter[card]->devicename, sndpkt()
39 sc_adapter[card]->channel[channel].first_sendbuf, sndpkt()
40 sc_adapter[card]->channel[channel].next_sendbuf, sndpkt()
41 sc_adapter[card]->channel[channel].free_sendbufs, sndpkt()
42 sc_adapter[card]->channel[channel].num_sendbufs); sndpkt()
44 if (!sc_adapter[card]->channel[channel].free_sendbufs) { sndpkt()
46 sc_adapter[card]->devicename); sndpkt()
52 sc_adapter[card]->devicename); sndpkt()
56 ReqLnkWrite.buff_offset = sc_adapter[card]->channel[channel].next_sendbuf * sndpkt()
57 BUFFER_SIZE + sc_adapter[card]->channel[channel].first_sendbuf; sndpkt()
60 sc_adapter[card]->devicename, sndpkt()
62 memcpy_toshmem(card, (char *)ReqLnkWrite.buff_offset, data->data, ReqLnkWrite.msg_len); sndpkt()
68 sc_adapter[card]->devicename, sndpkt()
70 sc_adapter[card]->channel[channel].next_sendbuf); sndpkt()
72 status = sendmessage(card, CEPID, ceReqTypeLnk, ceReqClass1, ceReqLnkWrite, sndpkt()
77 sc_adapter[card]->devicename, status); sndpkt()
81 sc_adapter[card]->channel[channel].free_sendbufs--; sndpkt()
82 sc_adapter[card]->channel[channel].next_sendbuf = sndpkt()
83 ++sc_adapter[card]->channel[channel].next_sendbuf == sndpkt()
84 sc_adapter[card]->channel[channel].num_sendbufs ? 0 : sndpkt()
85 sc_adapter[card]->channel[channel].next_sendbuf; sndpkt()
86 pr_debug("%s: packet sent successfully\n", sc_adapter[card]->devicename); sndpkt()
88 indicate_status(card, ISDN_STAT_BSENT, channel, (char *)&len); sndpkt()
93 void rcvpkt(int card, RspMessage *rcvmsg) rcvpkt() argument
98 if (!IS_VALID_CARD(card)) { rcvpkt()
99 pr_debug("invalid param: %d is not a valid card id\n", card); rcvpkt()
108 sc_adapter[card]->devicename, rcvmsg->rsp_status); rcvpkt()
113 sc_adapter[card]->devicename); rcvpkt()
118 sc_adapter[card]->devicename, rcvpkt()
120 memcpy_fromshmem(card, rcvpkt()
124 sc_adapter[card]->card->rcvcallb_skb(sc_adapter[card]->driverId, rcvpkt()
132 sc_adapter[card]->devicename, BUFFER_SIZE); rcvpkt()
133 /* memset_shmem(card, rcvmsg->msg_data.response.buff_offset, 0, BUFFER_SIZE); */ rcvpkt()
137 sc_adapter[card]->devicename, rcvpkt()
139 sendmessage(card, CEPID, ceReqTypeLnk, ceReqClass1, ceReqLnkRead, rcvpkt()
145 int setup_buffers(int card, int c) setup_buffers() argument
151 if (!IS_VALID_CARD(card)) { setup_buffers()
152 pr_debug("invalid param: %d is not a valid card id\n", card); setup_buffers()
160 sc_adapter[card]->devicename); setup_buffers()
162 nBuffers = ((sc_adapter[card]->ramsize - BUFFER_BASE) / buffer_size) / 2; setup_buffers()
165 sc_adapter[card]->devicename, setup_buffers()
169 sc_adapter[card]->devicename); setup_buffers()
174 sc_adapter[card]->devicename, cBase); setup_buffers()
175 sc_adapter[card]->channel[c - 1].first_sendbuf = BUFFER_BASE + cBase; setup_buffers()
176 sc_adapter[card]->channel[c - 1].num_sendbufs = nBuffers / 2; setup_buffers()
177 sc_adapter[card]->channel[c - 1].free_sendbufs = nBuffers / 2; setup_buffers()
178 sc_adapter[card]->channel[c - 1].next_sendbuf = 0; setup_buffers()
180 sc_adapter[card]->devicename, setup_buffers()
181 sc_adapter[card]->channel[c - 1].first_sendbuf, setup_buffers()
182 sc_adapter[card]->channel[c - 1].num_sendbufs, setup_buffers()
183 sc_adapter[card]->channel[c - 1].free_sendbufs, setup_buffers()
184 sc_adapter[card]->channel[c - 1].next_sendbuf); setup_buffers()
190 sc_adapter[card]->devicename, nBuffers / 2); setup_buffers()
193 ((sc_adapter[card]->channel[c - 1].first_sendbuf + setup_buffers()
197 sc_adapter[card]->devicename, setup_buffers()
200 sendmessage(card, CEPID, ceReqTypeLnk, ceReqClass1, ceReqLnkRead, setup_buffers()
H A Dshmem.c22 #include "card.h"
27 void memcpy_toshmem(int card, void *dest, const void *src, size_t n) memcpy_toshmem() argument
33 if (!IS_VALID_CARD(card)) { memcpy_toshmem()
34 pr_debug("Invalid param: %d is not a valid card id\n", card); memcpy_toshmem()
45 pr_debug("%s: loaded page %d\n", sc_adapter[card]->devicename, ch); memcpy_toshmem()
49 spin_lock_irqsave(&sc_adapter[card]->lock, flags); memcpy_toshmem()
51 outb(((sc_adapter[card]->shmem_magic + ch * SRAM_PAGESIZE) >> 14) | 0x80, memcpy_toshmem()
52 sc_adapter[card]->ioport[sc_adapter[card]->shmem_pgport]); memcpy_toshmem()
53 memcpy_toio((void __iomem *)(sc_adapter[card]->rambase + dest_rem), src, n); memcpy_toshmem()
54 spin_unlock_irqrestore(&sc_adapter[card]->lock, flags); memcpy_toshmem()
55 pr_debug("%s: set page to %#x\n", sc_adapter[card]->devicename, memcpy_toshmem()
56 ((sc_adapter[card]->shmem_magic + ch * SRAM_PAGESIZE) >> 14) | 0x80); memcpy_toshmem()
58 sc_adapter[card]->devicename, n, memcpy_toshmem()
60 sc_adapter[card]->rambase + ((unsigned long) dest % 0x4000)); memcpy_toshmem()
66 void memcpy_fromshmem(int card, void *dest, const void *src, size_t n) memcpy_fromshmem() argument
71 if (!IS_VALID_CARD(card)) { memcpy_fromshmem()
72 pr_debug("Invalid param: %d is not a valid card id\n", card); memcpy_fromshmem()
84 pr_debug("%s: loaded page %d\n", sc_adapter[card]->devicename, ch); memcpy_fromshmem()
90 spin_lock_irqsave(&sc_adapter[card]->lock, flags); memcpy_fromshmem()
92 outb(((sc_adapter[card]->shmem_magic + ch * SRAM_PAGESIZE) >> 14) | 0x80, memcpy_fromshmem()
93 sc_adapter[card]->ioport[sc_adapter[card]->shmem_pgport]); memcpy_fromshmem()
94 memcpy_fromio(dest, (void *)(sc_adapter[card]->rambase + memcpy_fromshmem()
96 spin_unlock_irqrestore(&sc_adapter[card]->lock, flags); memcpy_fromshmem()
97 pr_debug("%s: set page to %#x\n", sc_adapter[card]->devicename, memcpy_fromshmem()
98 ((sc_adapter[card]->shmem_magic + ch * SRAM_PAGESIZE) >> 14) | 0x80); memcpy_fromshmem()
100 sc_adapter[card]->devicename, n, memcpy_fromshmem()
101 sc_adapter[card]->rambase + ((unsigned long) src %0x4000), (unsigned long) dest); */ memcpy_fromshmem()
105 void memset_shmem(int card, void *dest, int c, size_t n)
110 if (!IS_VALID_CARD(card)) {
111 pr_debug("Invalid param: %d is not a valid card id\n", card);
123 pr_debug("%s: loaded page %d\n", sc_adapter[card]->devicename, ch);
128 spin_lock_irqsave(&sc_adapter[card]->lock, flags);
130 outb(((sc_adapter[card]->shmem_magic + ch * SRAM_PAGESIZE) >> 14) | 0x80,
131 sc_adapter[card]->ioport[sc_adapter[card]->shmem_pgport]);
132 memset_io(sc_adapter[card]->rambase +
134 pr_debug("%s: set page to %#x\n", sc_adapter[card]->devicename,
135 ((sc_adapter[card]->shmem_magic + ch * SRAM_PAGESIZE) >> 14) | 0x80);
136 spin_unlock_irqrestore(&sc_adapter[card]->lock, flags);
H A Dtimer.c21 #include "card.h"
27 static void setup_ports(int card) setup_ports() argument
30 outb((sc_adapter[card]->rambase >> 12), sc_adapter[card]->ioport[EXP_BASE]); setup_ports()
33 outb((sc_adapter[card]->interrupt | 0x80), setup_ports()
34 sc_adapter[card]->ioport[IRQ_SELECT]); setup_ports()
50 int card = (unsigned int) data; sc_check_reset() local
53 sc_adapter[card]->devicename); sc_check_reset()
56 setup_ports(card); sc_check_reset()
58 spin_lock_irqsave(&sc_adapter[card]->lock, flags); sc_check_reset()
59 outb(sc_adapter[card]->ioport[sc_adapter[card]->shmem_pgport], sc_check_reset()
60 (sc_adapter[card]->shmem_magic >> 14) | 0x80); sc_check_reset()
61 sig = (unsigned long) *((unsigned long *)(sc_adapter[card]->rambase + SIG_OFFSET)); sc_check_reset()
65 flushreadfifo(card); sc_check_reset()
66 spin_unlock_irqrestore(&sc_adapter[card]->lock, flags); sc_check_reset()
68 if (sc_adapter[card]->StartOnReset) sc_check_reset()
69 startproc(card); sc_check_reset()
72 sc_adapter[card]->devicename, CHECKRESET_TIME); sc_check_reset()
73 mod_timer(&sc_adapter[card]->reset_timer, jiffies + CHECKRESET_TIME); sc_check_reset()
74 spin_unlock_irqrestore(&sc_adapter[card]->lock, flags); sc_check_reset()
91 int card = (unsigned int) data; check_phystat() local
93 pr_debug("%s: Checking status...\n", sc_adapter[card]->devicename); check_phystat()
98 if (sc_adapter[card]->nphystat && !sc_adapter[card]->phystat) { /* All is well */ check_phystat()
101 sc_adapter[card]->devicename); check_phystat()
102 indicate_status(card, ISDN_STAT_RUN, 0, NULL); check_phystat()
104 else if (!sc_adapter[card]->nphystat && sc_adapter[card]->phystat) { /* All is not well */ check_phystat()
107 sc_adapter[card]->devicename); check_phystat()
109 indicate_status(card, ISDN_STAT_STOP, 0, NULL); check_phystat()
112 sc_adapter[card]->phystat = sc_adapter[card]->nphystat; check_phystat()
115 spin_lock_irqsave(&sc_adapter[card]->lock, flags); check_phystat()
116 mod_timer(&sc_adapter[card]->stat_timer, jiffies + CHECKSTAT_TIME); check_phystat()
117 spin_unlock_irqrestore(&sc_adapter[card]->lock, flags); check_phystat()
120 sendmessage(card, CEPID, ceReqTypePhy, ceReqClass2, check_phystat()
H A Dmessage.c23 #include "card.h"
28 int receivemessage(int card, RspMessage *rspmsg) receivemessage() argument
33 if (!IS_VALID_CARD(card)) { receivemessage()
34 pr_debug("Invalid param: %d is not a valid card id\n", card); receivemessage()
39 sc_adapter[card]->devicename); receivemessage()
44 if (inb(sc_adapter[card]->ioport[FIFO_STATUS]) & RF_HAS_DATA) { receivemessage()
48 spin_lock_irqsave(&sc_adapter[card]->lock, flags); receivemessage()
49 outb((sc_adapter[card]->shmem_magic >> 14) | 0x80, receivemessage()
50 sc_adapter[card]->ioport[sc_adapter[card]->shmem_pgport]); receivemessage()
51 dpm = (DualPortMemory *) sc_adapter[card]->rambase; receivemessage()
55 inb(sc_adapter[card]->ioport[FIFO_READ]); receivemessage()
56 spin_unlock_irqrestore(&sc_adapter[card]->lock, flags); receivemessage()
63 sc_adapter[card]->devicename, receivemessage()
83 int sendmessage(int card, sendmessage() argument
96 if (!IS_VALID_CARD(card)) { sendmessage()
97 pr_debug("Invalid param: %d is not a valid card id\n", card); sendmessage()
105 if (sc_adapter[card]->EngineUp && procid == CMPID) { sendmessage()
107 sc_adapter[card]->devicename); sendmessage()
111 if (!sc_adapter[card]->EngineUp && procid == CEPID) { sendmessage()
113 sc_adapter[card]->devicename); sendmessage()
132 sndmsg.sequence_no = sc_adapter[card]->seq_no++ % 256; sendmessage()
137 while (!(inb(sc_adapter[card]->ioport[FIFO_STATUS]) & WF_NOT_FULL)) sendmessage()
143 spin_lock_irqsave(&sc_adapter[card]->lock, flags); sendmessage()
144 outb((sc_adapter[card]->shmem_magic >> 14) | 0x80, sendmessage()
145 sc_adapter[card]->ioport[sc_adapter[card]->shmem_pgport]); sendmessage()
146 dpm = (DualPortMemory *) sc_adapter[card]->rambase; /* Fix me */ sendmessage()
149 outb(sndmsg.sequence_no, sc_adapter[card]->ioport[FIFO_WRITE]); sendmessage()
150 spin_unlock_irqrestore(&sc_adapter[card]->lock, flags); sendmessage()
155 sc_adapter[card]->devicename, sendmessage()
168 int send_and_receive(int card, send_and_receive() argument
182 if (!IS_VALID_CARD(card)) { send_and_receive()
183 pr_debug("Invalid param: %d is not a valid card id\n", card); send_and_receive()
187 sc_adapter[card]->want_async_messages = 1; send_and_receive()
188 retval = sendmessage(card, procid, type, class, code, link, send_and_receive()
193 sc_adapter[card]->devicename); send_and_receive()
194 sc_adapter[card]->want_async_messages = 0; send_and_receive()
208 if ((sc_adapter[card]->async_msg.type == type) && send_and_receive()
209 (sc_adapter[card]->async_msg.class == class) && send_and_receive()
210 (sc_adapter[card]->async_msg.code == code) && send_and_receive()
211 (sc_adapter[card]->async_msg.phy_link_no == link)) { send_and_receive()
217 sc_adapter[card]->devicename); send_and_receive()
218 memcpy(mesgdata, &(sc_adapter[card]->async_msg), send_and_receive()
220 sc_adapter[card]->want_async_messages = 0; send_and_receive()
227 pr_debug("%s: SAR message timeout\n", sc_adapter[card]->devicename); send_and_receive()
228 sc_adapter[card]->want_async_messages = 0; send_and_receive()
H A Dinterrupt.c21 #include "card.h"
32 int card = (int)(unsigned long) card_inst; interrupt_handler() local
34 if (!IS_VALID_CARD(card)) { interrupt_handler()
35 pr_debug("Invalid param: %d is not a valid card id\n", card); interrupt_handler()
40 sc_adapter[card]->devicename); interrupt_handler()
45 while (!receivemessage(card, &rcvmsg)) { interrupt_handler()
50 if (sc_adapter[card]->want_async_messages) interrupt_handler()
51 memcpy(&(sc_adapter[card]->async_msg), interrupt_handler()
61 sc_adapter[card]->devicename, interrupt_handler()
72 sc_adapter[card]->devicename, interrupt_handler()
75 rcvpkt(card, &rcvmsg); interrupt_handler()
85 sc_adapter[card]->devicename, interrupt_handler()
87 sc_adapter[card]->channel[rcvmsg.phy_link_no - 1].free_sendbufs++; interrupt_handler()
99 sc_adapter[card]->devicename, interrupt_handler()
108 sc_adapter[card]->devicename); interrupt_handler()
109 indicate_status(card, ISDN_STAT_DCONN, interrupt_handler()
118 sc_adapter[card]->devicename); interrupt_handler()
124 sc_adapter[card]->channel[rcvmsg.phy_link_no - 1].dn, interrupt_handler()
133 indicate_status(card, ISDN_STAT_ICALL, (unsigned long)rcvmsg.phy_link_no - 1, (char *)&setup); interrupt_handler()
134 indicate_status(card, ISDN_STAT_DCONN, (unsigned long)rcvmsg.phy_link_no - 1, NULL); interrupt_handler()
145 sc_adapter[card]->devicename, interrupt_handler()
150 indicate_status(card, ISDN_STAT_BHUP, (unsigned long)rcvmsg.phy_link_no - 1, NULL); interrupt_handler()
151 indicate_status(card, ISDN_STAT_DHUP, (unsigned long)rcvmsg.phy_link_no - 1, NULL); interrupt_handler()
161 sc_adapter[card]->devicename); interrupt_handler()
162 sc_adapter[card]->EngineUp = 1; interrupt_handler()
163 sendmessage(card, CEPID, ceReqTypeCall, ceReqClass0, ceReqCallGetMyNumber, 1, 0, NULL); interrupt_handler()
164 sendmessage(card, CEPID, ceReqTypeCall, ceReqClass0, ceReqCallGetMyNumber, 2, 0, NULL); interrupt_handler()
165 init_timer(&sc_adapter[card]->stat_timer); interrupt_handler()
166 sc_adapter[card]->stat_timer.function = check_phystat; interrupt_handler()
167 sc_adapter[card]->stat_timer.data = card; interrupt_handler()
168 sc_adapter[card]->stat_timer.expires = jiffies + CHECKSTAT_TIME; interrupt_handler()
169 add_timer(&sc_adapter[card]->stat_timer); interrupt_handler()
178 sc_adapter[card]->devicename, interrupt_handler()
187 strlcpy(sc_adapter[card]->channel[rcvmsg.phy_link_no - 1].dn, interrupt_handler()
205 sc_adapter[card]->nphystat = (b2stat >> 8) | b1stat; /* endian?? */ interrupt_handler()
207 sc_adapter[card]->devicename, interrupt_handler()
208 sc_adapter[card]->nphystat); interrupt_handler()
223 sc_adapter[card]->devicename, interrupt_handler()
225 sendmessage(card, CEPID, ceReqTypeCall, interrupt_handler()
238 sc_adapter[card]->devicename, interrupt_handler()
245 sc_adapter[card]->devicename); interrupt_handler()
H A Dioctl.c12 #include "card.h"
15 static int GetStatus(int card, boardInfo *);
20 int sc_ioctl(int card, scs_ioctl *data) sc_ioctl() argument
37 sc_adapter[card]->devicename); sc_ioctl()
38 sc_adapter[card]->StartOnReset = 0; sc_ioctl()
40 return reset(card); sc_ioctl()
53 sc_adapter[card]->devicename); sc_ioctl()
54 if (sc_adapter[card]->EngineUp) { sc_ioctl()
56 sc_adapter[card]->devicename); sc_ioctl()
71 status = send_and_receive(card, CMPID, cmReqType2, cmReqClass0, cmReqLoadProc, sc_ioctl()
78 sc_adapter[card]->devicename, status); sc_ioctl()
83 sc_adapter[card]->devicename); sc_ioctl()
92 sc_adapter[card]->devicename); sc_ioctl()
93 if (sc_adapter[card]->EngineUp) { sc_ioctl()
95 sc_adapter[card]->devicename); sc_ioctl()
99 sc_adapter[card]->StartOnReset = 1; sc_ioctl()
100 startproc(card); sc_ioctl()
107 sc_adapter[card]->devicename); sc_ioctl()
118 sc_adapter[card]->devicename, sc_ioctl()
120 status = send_and_receive(card, CEPID, ceReqTypeCall, ceReqClass0, ceReqCallSetSwitchType, sc_ioctl()
124 sc_adapter[card]->devicename); sc_ioctl()
130 sc_adapter[card]->devicename, status); sc_ioctl()
139 sc_adapter[card]->devicename); sc_ioctl()
144 status = send_and_receive(card, CEPID, ceReqTypeCall, ceReqClass0, sc_ioctl()
148 sc_adapter[card]->devicename); sc_ioctl()
152 sc_adapter[card]->devicename, status); sc_ioctl()
175 sc_adapter[card]->devicename); sc_ioctl()
185 status = send_and_receive(card, CEPID, ceReqTypeCall, ceReqClass0, ceReqCallGetSPID, sc_ioctl()
189 sc_adapter[card]->devicename); sc_ioctl()
192 sc_adapter[card]->devicename, status); sc_ioctl()
216 sc_adapter[card]->devicename); sc_ioctl()
228 sc_adapter[card]->devicename, data->channel, spid); sc_ioctl()
229 status = send_and_receive(card, CEPID, ceReqTypeCall, sc_ioctl()
234 sc_adapter[card]->devicename); sc_ioctl()
241 sc_adapter[card]->devicename, status); sc_ioctl()
251 sc_adapter[card]->devicename); sc_ioctl()
256 status = send_and_receive(card, CEPID, ceReqTypeCall, ceReqClass0, ceReqCallGetMyNumber, sc_ioctl()
260 sc_adapter[card]->devicename); sc_ioctl()
264 sc_adapter[card]->devicename, status); sc_ioctl()
291 sc_adapter[card]->devicename); sc_ioctl()
303 sc_adapter[card]->devicename, data->channel, dn); sc_ioctl()
304 status = send_and_receive(card, CEPID, ceReqTypeCall, sc_ioctl()
309 sc_adapter[card]->devicename); sc_ioctl()
316 sc_adapter[card]->devicename, status); sc_ioctl()
326 sc_adapter[card]->devicename); sc_ioctl()
327 /* sc_adapter[card]->trace = !sc_adapter[card]->trace; sc_ioctl()
329 sc_adapter[card]->devicename, sc_ioctl()
330 sc_adapter[card]->trace ? "ON" : "OFF"); */ sc_ioctl()
338 sc_adapter[card]->devicename); sc_ioctl()
347 GetStatus(card, bi); sc_ioctl()
361 sc_adapter[card]->devicename); sc_ioctl()
366 status = send_and_receive(card, CEPID, ceReqTypeCall, ceReqClass0, sc_ioctl()
370 sc_adapter[card]->devicename); sc_ioctl()
374 sc_adapter[card]->devicename, status); sc_ioctl()
395 sc_adapter[card]->devicename); sc_ioctl()
400 sc_adapter[card]->devicename); sc_ioctl()
412 static int GetStatus(int card, boardInfo *bi) GetStatus() argument
420 bi->modelid = sc_adapter[card]->model; GetStatus()
421 strcpy(bi->serial_no, sc_adapter[card]->hwconfig.serial_no); GetStatus()
422 strcpy(bi->part_no, sc_adapter[card]->hwconfig.part_no); GetStatus()
423 bi->iobase = sc_adapter[card]->iobase; GetStatus()
424 bi->rambase = sc_adapter[card]->rambase; GetStatus()
425 bi->irq = sc_adapter[card]->interrupt; GetStatus()
426 bi->ramsize = sc_adapter[card]->hwconfig.ram_size; GetStatus()
427 bi->interface = sc_adapter[card]->hwconfig.st_u_sense; GetStatus()
428 strcpy(bi->load_ver, sc_adapter[card]->load_ver); GetStatus()
429 strcpy(bi->proc_ver, sc_adapter[card]->proc_ver); GetStatus()
434 status = send_and_receive(card, CEPID, ceReqTypePhy, ceReqClass2, GetStatus()
437 if (sc_adapter[card]->model < PRI_BOARD) { GetStatus()
455 for (i = 0; i < sc_adapter[card]->nChannels; i++) { GetStatus()
456 status = send_and_receive(card, CEPID, ceReqTypeCall, ceReqClass0, GetStatus()
459 if (sc_adapter[card]->model == PRI_BOARD) { GetStatus()
473 if (sc_adapter[card]->model == PRI_BOARD) { GetStatus()
477 status = send_and_receive(card, CEPID, ceReqTypeStat, ceReqClass2, GetStatus()
488 status = send_and_receive(card, CEPID, ceReqTypeStat, ceReqClass2, GetStatus()
500 status = send_and_receive(card, CEPID, ceReqTypeLnk, ceReqClass0, GetStatus()
517 status = send_and_receive(card, CEPID, ceReqTypeLnk, ceReqClass0, GetStatus()
536 status = send_and_receive(card, CEPID, ceReqTypeLnk, ceReqClass0, GetStatus()
565 status = send_and_receive(card, CEPID, ceReqTypeCall, ceReqClass0, GetStatus()
575 status = send_and_receive(card, CEPID, ceReqTypeCall, ceReqClass0, GetStatus()
H A Devent.c21 #include "card.h"
41 int indicate_status(int card, int event, ulong Channel, char *Data) indicate_status() argument
47 sc_adapter[card]->devicename, events[event - 256], Channel); indicate_status()
50 pr_debug("%s: Event data: %s\n", sc_adapter[card]->devicename, indicate_status()
65 cmd.driver = sc_adapter[card]->driverId; indicate_status()
67 return sc_adapter[card]->card->statcallb(&cmd); indicate_status()
H A Dcard.h1 /* $Id: card.h,v 1.1.10.1 2001/09/23 22:24:59 kai Exp $
50 * Macro to determine is a card id is valid
77 isdn_if *card; /* ISDN4Linux structure */ member in struct:__anon5338
107 void memcpy_toshmem(int card, void *dest, const void *src, size_t n);
108 void memcpy_fromshmem(int card, void *dest, const void *src, size_t n);
110 int indicate_status(int card, int event, ulong Channel, char *Data);
113 void rcvpkt(int card, RspMessage *rcvmsg);
115 int reset(int card);
116 int startproc(int card);
117 int send_and_receive(int card, unsigned int procid, unsigned char type,
121 void flushreadfifo(int card);
122 int sendmessage(int card, unsigned int procid, unsigned int type,
125 int receivemessage(int card, RspMessage *rspmsg);
126 int sc_ioctl(int card, scs_ioctl *data);
127 int setup_buffers(int card, int c);
/linux-4.1.27/drivers/s390/net/
H A Dqeth_l2_main.c33 static void qeth_bridgeport_query_support(struct qeth_card *card);
34 static void qeth_bridge_state_change(struct qeth_card *card,
36 static void qeth_bridge_host_event(struct qeth_card *card,
41 struct qeth_card *card = dev->ml_priv; qeth_l2_do_ioctl() local
45 if (!card) qeth_l2_do_ioctl()
48 if (!qeth_card_hw_is_reachable(card)) qeth_l2_do_ioctl()
51 if (card->info.type == QETH_CARD_TYPE_OSN) qeth_l2_do_ioctl()
56 rc = qeth_snmp_command(card, rq->ifr_ifru.ifru_data); qeth_l2_do_ioctl()
59 if ((card->info.type == QETH_CARD_TYPE_OSD || qeth_l2_do_ioctl()
60 card->info.type == QETH_CARD_TYPE_OSM || qeth_l2_do_ioctl()
61 card->info.type == QETH_CARD_TYPE_OSX) && qeth_l2_do_ioctl()
62 !card->info.guestlan) qeth_l2_do_ioctl()
79 rc = qeth_query_oat_command(card, rq->ifr_ifru.ifru_data); qeth_l2_do_ioctl()
85 QETH_CARD_TEXT_(card, 2, "ioce%d", rc); qeth_l2_do_ioctl()
91 struct qeth_card *card; qeth_l2_verify_dev() local
96 list_for_each_entry(card, &qeth_core_card_list.list, list) { qeth_l2_verify_dev()
97 if (card->dev == dev) { qeth_l2_verify_dev()
109 struct qeth_card *card; qeth_l2_netdev_by_devno() local
118 list_for_each_entry(card, &qeth_core_card_list.list, list) { qeth_l2_netdev_by_devno()
119 ccw_device_get_id(CARD_RDEV(card), &read_devid); qeth_l2_netdev_by_devno()
121 ndev = card->dev; qeth_l2_netdev_by_devno()
129 static int qeth_setdel_makerc(struct qeth_card *card, int retcode) qeth_setdel_makerc() argument
134 QETH_CARD_TEXT_(card, 2, "err%04x", retcode); qeth_setdel_makerc()
166 static int qeth_l2_send_setgroupmac(struct qeth_card *card, __u8 *mac) qeth_l2_send_setgroupmac() argument
170 QETH_CARD_TEXT(card, 2, "L2Sgmac"); qeth_l2_send_setgroupmac()
171 rc = qeth_setdel_makerc(card, qeth_l2_send_setdelmac(card, mac, qeth_l2_send_setgroupmac()
175 mac, QETH_CARD_IFNAME(card)); qeth_l2_send_setgroupmac()
178 mac, QETH_CARD_IFNAME(card), rc); qeth_l2_send_setgroupmac()
182 static int qeth_l2_send_delgroupmac(struct qeth_card *card, __u8 *mac) qeth_l2_send_delgroupmac() argument
186 QETH_CARD_TEXT(card, 2, "L2Dgmac"); qeth_l2_send_delgroupmac()
187 rc = qeth_setdel_makerc(card, qeth_l2_send_setdelmac(card, mac, qeth_l2_send_delgroupmac()
192 mac, QETH_CARD_IFNAME(card), rc); qeth_l2_send_delgroupmac()
196 static void qeth_l2_add_mc(struct qeth_card *card, __u8 *mac, int vmac) qeth_l2_add_mc() argument
211 rc = qeth_setdel_makerc(card, qeth_l2_add_mc()
212 qeth_l2_send_setdelmac(card, mac, IPA_CMD_SETVMAC)); qeth_l2_add_mc()
214 rc = qeth_setdel_makerc(card, qeth_l2_add_mc()
215 qeth_l2_send_setgroupmac(card, mac)); qeth_l2_add_mc()
219 list_add_tail(&mc->list, &card->mc_list); qeth_l2_add_mc()
224 static void qeth_l2_del_all_mc(struct qeth_card *card, int del) qeth_l2_del_all_mc() argument
228 spin_lock_bh(&card->mclock); qeth_l2_del_all_mc()
229 list_for_each_entry_safe(mc, tmp, &card->mc_list, list) { qeth_l2_del_all_mc()
232 qeth_l2_send_setdelmac(card, mc->mc_addr, qeth_l2_del_all_mc()
235 qeth_l2_send_delgroupmac(card, mc->mc_addr); qeth_l2_del_all_mc()
240 spin_unlock_bh(&card->mclock); qeth_l2_del_all_mc()
243 static inline int qeth_l2_get_cast_type(struct qeth_card *card, qeth_l2_get_cast_type() argument
246 if (card->info.type == QETH_CARD_TYPE_OSN) qeth_l2_get_cast_type()
255 static void qeth_l2_fill_header(struct qeth_card *card, struct qeth_hdr *hdr, qeth_l2_fill_header() argument
281 static int qeth_l2_send_setdelvlan_cb(struct qeth_card *card, qeth_l2_send_setdelvlan_cb() argument
286 QETH_CARD_TEXT(card, 2, "L2sdvcb"); qeth_l2_send_setdelvlan_cb()
291 QETH_CARD_IFNAME(card), cmd->hdr.return_code); qeth_l2_send_setdelvlan_cb()
292 QETH_CARD_TEXT_(card, 2, "L2VL%4x", cmd->hdr.command); qeth_l2_send_setdelvlan_cb()
293 QETH_CARD_TEXT_(card, 2, "err%d", cmd->hdr.return_code); qeth_l2_send_setdelvlan_cb()
298 static int qeth_l2_send_setdelvlan(struct qeth_card *card, __u16 i, qeth_l2_send_setdelvlan() argument
304 QETH_CARD_TEXT_(card, 4, "L2sdv%x", ipacmd); qeth_l2_send_setdelvlan()
305 iob = qeth_get_ipacmd_buffer(card, ipacmd, QETH_PROT_IPV4); qeth_l2_send_setdelvlan()
310 return qeth_send_ipa_cmd(card, iob, qeth_l2_send_setdelvlan()
314 static void qeth_l2_process_vlans(struct qeth_card *card) qeth_l2_process_vlans() argument
317 QETH_CARD_TEXT(card, 3, "L2prcvln"); qeth_l2_process_vlans()
318 spin_lock_bh(&card->vlanlock); qeth_l2_process_vlans()
319 list_for_each_entry(id, &card->vid_list, list) { qeth_l2_process_vlans()
320 qeth_l2_send_setdelvlan(card, id->vid, IPA_CMD_SETVLAN); qeth_l2_process_vlans()
322 spin_unlock_bh(&card->vlanlock); qeth_l2_process_vlans()
328 struct qeth_card *card = dev->ml_priv; qeth_l2_vlan_rx_add_vid() local
332 QETH_CARD_TEXT_(card, 4, "aid:%d", vid); qeth_l2_vlan_rx_add_vid()
335 if (card->info.type == QETH_CARD_TYPE_OSM) { qeth_l2_vlan_rx_add_vid()
336 QETH_CARD_TEXT(card, 3, "aidOSM"); qeth_l2_vlan_rx_add_vid()
339 if (qeth_wait_for_threads(card, QETH_RECOVER_THREAD)) { qeth_l2_vlan_rx_add_vid()
340 QETH_CARD_TEXT(card, 3, "aidREC"); qeth_l2_vlan_rx_add_vid()
346 rc = qeth_l2_send_setdelvlan(card, vid, IPA_CMD_SETVLAN); qeth_l2_vlan_rx_add_vid()
351 spin_lock_bh(&card->vlanlock); qeth_l2_vlan_rx_add_vid()
352 list_add_tail(&id->list, &card->vid_list); qeth_l2_vlan_rx_add_vid()
353 spin_unlock_bh(&card->vlanlock); qeth_l2_vlan_rx_add_vid()
364 struct qeth_card *card = dev->ml_priv; qeth_l2_vlan_rx_kill_vid() local
367 QETH_CARD_TEXT_(card, 4, "kid:%d", vid); qeth_l2_vlan_rx_kill_vid()
368 if (card->info.type == QETH_CARD_TYPE_OSM) { qeth_l2_vlan_rx_kill_vid()
369 QETH_CARD_TEXT(card, 3, "kidOSM"); qeth_l2_vlan_rx_kill_vid()
372 if (qeth_wait_for_threads(card, QETH_RECOVER_THREAD)) { qeth_l2_vlan_rx_kill_vid()
373 QETH_CARD_TEXT(card, 3, "kidREC"); qeth_l2_vlan_rx_kill_vid()
376 spin_lock_bh(&card->vlanlock); qeth_l2_vlan_rx_kill_vid()
377 list_for_each_entry(id, &card->vid_list, list) { qeth_l2_vlan_rx_kill_vid()
384 spin_unlock_bh(&card->vlanlock); qeth_l2_vlan_rx_kill_vid()
386 rc = qeth_l2_send_setdelvlan(card, vid, IPA_CMD_DELVLAN); qeth_l2_vlan_rx_kill_vid()
389 qeth_l2_set_multicast_list(card->dev); qeth_l2_vlan_rx_kill_vid()
393 static int qeth_l2_stop_card(struct qeth_card *card, int recovery_mode) qeth_l2_stop_card() argument
398 QETH_DBF_HEX(SETUP, 2, &card, sizeof(void *)); qeth_l2_stop_card()
400 qeth_set_allowed_threads(card, 0, 1); qeth_l2_stop_card()
401 if (card->read.state == CH_STATE_UP && qeth_l2_stop_card()
402 card->write.state == CH_STATE_UP && qeth_l2_stop_card()
403 (card->state == CARD_STATE_UP)) { qeth_l2_stop_card()
405 card->info.type != QETH_CARD_TYPE_OSN) { qeth_l2_stop_card()
406 qeth_l2_stop(card->dev); qeth_l2_stop_card()
409 dev_close(card->dev); qeth_l2_stop_card()
412 card->info.mac_bits &= ~QETH_LAYER2_MAC_REGISTERED; qeth_l2_stop_card()
413 card->state = CARD_STATE_SOFTSETUP; qeth_l2_stop_card()
415 if (card->state == CARD_STATE_SOFTSETUP) { qeth_l2_stop_card()
416 qeth_l2_del_all_mc(card, 0); qeth_l2_stop_card()
417 qeth_clear_ipacmd_list(card); qeth_l2_stop_card()
418 card->state = CARD_STATE_HARDSETUP; qeth_l2_stop_card()
420 if (card->state == CARD_STATE_HARDSETUP) { qeth_l2_stop_card()
421 qeth_qdio_clear_card(card, 0); qeth_l2_stop_card()
422 qeth_clear_qdio_buffers(card); qeth_l2_stop_card()
423 qeth_clear_working_pool_list(card); qeth_l2_stop_card()
424 card->state = CARD_STATE_DOWN; qeth_l2_stop_card()
426 if (card->state == CARD_STATE_DOWN) { qeth_l2_stop_card()
427 qeth_clear_cmd_buffers(&card->read); qeth_l2_stop_card()
428 qeth_clear_cmd_buffers(&card->write); qeth_l2_stop_card()
433 static int qeth_l2_process_inbound_buffer(struct qeth_card *card, qeth_l2_process_inbound_buffer() argument
444 skb = qeth_core_get_next_skb(card, qeth_l2_process_inbound_buffer()
445 &card->qdio.in_q->bufs[card->rx.b_index], qeth_l2_process_inbound_buffer()
446 &card->rx.b_element, &card->rx.e_offset, &hdr); qeth_l2_process_inbound_buffer()
451 skb->dev = card->dev; qeth_l2_process_inbound_buffer()
458 *((__u32 *)skb->cb) = ++card->seqno.pkt_seqno; qeth_l2_process_inbound_buffer()
463 if (card->info.type == QETH_CARD_TYPE_OSN) { qeth_l2_process_inbound_buffer()
468 card->osn_info.data_cb(skb); qeth_l2_process_inbound_buffer()
474 QETH_CARD_TEXT(card, 3, "inbunkno"); qeth_l2_process_inbound_buffer()
480 card->stats.rx_packets++; qeth_l2_process_inbound_buffer()
481 card->stats.rx_bytes += len; qeth_l2_process_inbound_buffer()
488 struct qeth_card *card = container_of(napi, struct qeth_card, napi); qeth_l2_poll() local
494 if (card->options.performance_stats) { qeth_l2_poll()
495 card->perf_stats.inbound_cnt++; qeth_l2_poll()
496 card->perf_stats.inbound_start_time = qeth_get_micros(); qeth_l2_poll()
500 if (!card->rx.b_count) { qeth_l2_poll()
501 card->rx.qdio_err = 0; qeth_l2_poll()
502 card->rx.b_count = qdio_get_next_buffers( qeth_l2_poll()
503 card->data.ccwdev, 0, &card->rx.b_index, qeth_l2_poll()
504 &card->rx.qdio_err); qeth_l2_poll()
505 if (card->rx.b_count <= 0) { qeth_l2_poll()
506 card->rx.b_count = 0; qeth_l2_poll()
509 card->rx.b_element = qeth_l2_poll()
510 &card->qdio.in_q->bufs[card->rx.b_index] qeth_l2_poll()
512 card->rx.e_offset = 0; qeth_l2_poll()
515 while (card->rx.b_count) { qeth_l2_poll()
516 buffer = &card->qdio.in_q->bufs[card->rx.b_index]; qeth_l2_poll()
517 if (!(card->rx.qdio_err && qeth_l2_poll()
518 qeth_check_qdio_errors(card, buffer->buffer, qeth_l2_poll()
519 card->rx.qdio_err, "qinerr"))) qeth_l2_poll()
521 card, new_budget, &done); qeth_l2_poll()
526 if (card->options.performance_stats) qeth_l2_poll()
527 card->perf_stats.bufs_rec++; qeth_l2_poll()
528 qeth_put_buffer_pool_entry(card, qeth_l2_poll()
530 qeth_queue_input_buffer(card, card->rx.b_index); qeth_l2_poll()
531 card->rx.b_count--; qeth_l2_poll()
532 if (card->rx.b_count) { qeth_l2_poll()
533 card->rx.b_index = qeth_l2_poll()
534 (card->rx.b_index + 1) % qeth_l2_poll()
536 card->rx.b_element = qeth_l2_poll()
537 &card->qdio.in_q qeth_l2_poll()
538 ->bufs[card->rx.b_index] qeth_l2_poll()
540 card->rx.e_offset = 0; qeth_l2_poll()
552 if (qdio_start_irq(card->data.ccwdev, 0)) qeth_l2_poll()
553 napi_schedule(&card->napi); qeth_l2_poll()
555 if (card->options.performance_stats) qeth_l2_poll()
556 card->perf_stats.inbound_time += qeth_get_micros() - qeth_l2_poll()
557 card->perf_stats.inbound_start_time; qeth_l2_poll()
561 static int qeth_l2_send_setdelmac(struct qeth_card *card, __u8 *mac, qeth_l2_send_setdelmac() argument
567 QETH_CARD_TEXT(card, 2, "L2sdmac"); qeth_l2_send_setdelmac()
568 iob = qeth_get_ipacmd_buffer(card, ipacmd, QETH_PROT_IPV4); qeth_l2_send_setdelmac()
574 return qeth_send_ipa_cmd(card, iob, NULL, NULL); qeth_l2_send_setdelmac()
577 static int qeth_l2_send_setmac(struct qeth_card *card, __u8 *mac) qeth_l2_send_setmac() argument
581 QETH_CARD_TEXT(card, 2, "L2Setmac"); qeth_l2_send_setmac()
582 rc = qeth_setdel_makerc(card, qeth_l2_send_setdelmac(card, mac, qeth_l2_send_setmac()
585 card->info.mac_bits |= QETH_LAYER2_MAC_REGISTERED; qeth_l2_send_setmac()
586 memcpy(card->dev->dev_addr, mac, OSA_ADDR_LEN); qeth_l2_send_setmac()
587 dev_info(&card->gdev->dev, qeth_l2_send_setmac()
589 card->dev->dev_addr, card->dev->name); qeth_l2_send_setmac()
591 card->info.mac_bits &= ~QETH_LAYER2_MAC_REGISTERED; qeth_l2_send_setmac()
594 dev_warn(&card->gdev->dev, qeth_l2_send_setmac()
598 dev_warn(&card->gdev->dev, qeth_l2_send_setmac()
606 static int qeth_l2_send_delmac(struct qeth_card *card, __u8 *mac) qeth_l2_send_delmac() argument
610 QETH_CARD_TEXT(card, 2, "L2Delmac"); qeth_l2_send_delmac()
611 if (!(card->info.mac_bits & QETH_LAYER2_MAC_REGISTERED)) qeth_l2_send_delmac()
613 rc = qeth_setdel_makerc(card, qeth_l2_send_setdelmac(card, mac, qeth_l2_send_delmac()
616 card->info.mac_bits &= ~QETH_LAYER2_MAC_REGISTERED; qeth_l2_send_delmac()
620 static int qeth_l2_request_initial_mac(struct qeth_card *card) qeth_l2_request_initial_mac() argument
626 QETH_DBF_TEXT_(SETUP, 2, "doL2%s", CARD_BUS_ID(card)); qeth_l2_request_initial_mac()
628 if (qeth_is_supported(card, IPA_SETADAPTERPARMS)) { qeth_l2_request_initial_mac()
629 rc = qeth_query_setadapterparms(card); qeth_l2_request_initial_mac()
633 CARD_BUS_ID(card), rc); qeth_l2_request_initial_mac()
637 if (card->info.type == QETH_CARD_TYPE_IQD || qeth_l2_request_initial_mac()
638 card->info.type == QETH_CARD_TYPE_OSM || qeth_l2_request_initial_mac()
639 card->info.type == QETH_CARD_TYPE_OSX || qeth_l2_request_initial_mac()
640 card->info.guestlan) { qeth_l2_request_initial_mac()
641 rc = qeth_setadpparms_change_macaddr(card); qeth_l2_request_initial_mac()
644 "device %s: x%x\n", CARD_BUS_ID(card), rc); qeth_l2_request_initial_mac()
648 QETH_DBF_HEX(SETUP, 2, card->dev->dev_addr, OSA_ADDR_LEN); qeth_l2_request_initial_mac()
650 eth_random_addr(card->dev->dev_addr); qeth_l2_request_initial_mac()
651 memcpy(card->dev->dev_addr, vendor_pre, 3); qeth_l2_request_initial_mac()
659 struct qeth_card *card = dev->ml_priv; qeth_l2_set_mac_address() local
662 QETH_CARD_TEXT(card, 3, "setmac"); qeth_l2_set_mac_address()
665 QETH_CARD_TEXT(card, 3, "setmcINV"); qeth_l2_set_mac_address()
669 if (card->info.type == QETH_CARD_TYPE_OSN || qeth_l2_set_mac_address()
670 card->info.type == QETH_CARD_TYPE_OSM || qeth_l2_set_mac_address()
671 card->info.type == QETH_CARD_TYPE_OSX) { qeth_l2_set_mac_address()
672 QETH_CARD_TEXT(card, 3, "setmcTYP"); qeth_l2_set_mac_address()
675 QETH_CARD_HEX(card, 3, addr->sa_data, OSA_ADDR_LEN); qeth_l2_set_mac_address()
676 if (qeth_wait_for_threads(card, QETH_RECOVER_THREAD)) { qeth_l2_set_mac_address()
677 QETH_CARD_TEXT(card, 3, "setmcREC"); qeth_l2_set_mac_address()
680 rc = qeth_l2_send_delmac(card, &card->dev->dev_addr[0]); qeth_l2_set_mac_address()
682 rc = qeth_l2_send_setmac(card, addr->sa_data); qeth_l2_set_mac_address()
688 struct qeth_card *card = dev->ml_priv; qeth_l2_set_multicast_list() local
691 if (card->info.type == QETH_CARD_TYPE_OSN) qeth_l2_set_multicast_list()
694 QETH_CARD_TEXT(card, 3, "setmulti"); qeth_l2_set_multicast_list()
695 if (qeth_threads_running(card, QETH_RECOVER_THREAD) && qeth_l2_set_multicast_list()
696 (card->state != CARD_STATE_UP)) qeth_l2_set_multicast_list()
698 qeth_l2_del_all_mc(card, 1); qeth_l2_set_multicast_list()
699 spin_lock_bh(&card->mclock); qeth_l2_set_multicast_list()
701 qeth_l2_add_mc(card, ha->addr, 0); qeth_l2_set_multicast_list()
704 qeth_l2_add_mc(card, ha->addr, 1); qeth_l2_set_multicast_list()
706 spin_unlock_bh(&card->mclock); qeth_l2_set_multicast_list()
707 if (!qeth_adp_supported(card, IPA_SETADP_SET_PROMISC_MODE)) qeth_l2_set_multicast_list()
709 qeth_setadp_promisc_mode(card); qeth_l2_set_multicast_list()
717 struct qeth_card *card = dev->ml_priv; qeth_l2_hard_start_xmit() local
719 int cast_type = qeth_l2_get_cast_type(card, skb); qeth_l2_hard_start_xmit()
726 if (card->qdio.do_prio_queueing || (cast_type && qeth_l2_hard_start_xmit()
727 card->info.is_multicast_different)) qeth_l2_hard_start_xmit()
728 queue = card->qdio.out_qs[qeth_get_priority_queue(card, skb, qeth_l2_hard_start_xmit()
731 queue = card->qdio.out_qs[card->qdio.default_out_queue]; qeth_l2_hard_start_xmit()
733 if ((card->state != CARD_STATE_UP) || !card->lan_online) { qeth_l2_hard_start_xmit()
734 card->stats.tx_carrier_errors++; qeth_l2_hard_start_xmit()
738 if ((card->info.type == QETH_CARD_TYPE_OSN) && qeth_l2_hard_start_xmit()
742 if (card->options.performance_stats) { qeth_l2_hard_start_xmit()
743 card->perf_stats.outbound_cnt++; qeth_l2_hard_start_xmit()
744 card->perf_stats.outbound_start_time = qeth_get_micros(); qeth_l2_hard_start_xmit()
748 if (card->info.type == QETH_CARD_TYPE_OSN) qeth_l2_hard_start_xmit()
751 if (card->info.type == QETH_CARD_TYPE_IQD) { qeth_l2_hard_start_xmit()
761 qeth_l2_fill_header(card, hdr, new_skb, cast_type); qeth_l2_hard_start_xmit()
774 qeth_l2_fill_header(card, hdr, new_skb, cast_type); qeth_l2_hard_start_xmit()
778 elements = qeth_get_elements_no(card, new_skb, elements_needed); qeth_l2_hard_start_xmit()
785 if (card->info.type != QETH_CARD_TYPE_IQD) { qeth_l2_hard_start_xmit()
789 rc = qeth_do_send_packet(card, queue, new_skb, hdr, qeth_l2_hard_start_xmit()
792 rc = qeth_do_send_packet_fast(card, queue, new_skb, hdr, qeth_l2_hard_start_xmit()
795 card->stats.tx_packets++; qeth_l2_hard_start_xmit()
796 card->stats.tx_bytes += tx_bytes; qeth_l2_hard_start_xmit()
813 if (card->options.performance_stats) qeth_l2_hard_start_xmit()
814 card->perf_stats.outbound_time += qeth_get_micros() - qeth_l2_hard_start_xmit()
815 card->perf_stats.outbound_start_time; qeth_l2_hard_start_xmit()
819 card->stats.tx_dropped++; qeth_l2_hard_start_xmit()
820 card->stats.tx_errors++; qeth_l2_hard_start_xmit()
830 struct qeth_card *card = dev->ml_priv; __qeth_l2_open() local
833 QETH_CARD_TEXT(card, 4, "qethopen"); __qeth_l2_open()
834 if (card->state == CARD_STATE_UP) __qeth_l2_open()
836 if (card->state != CARD_STATE_SOFTSETUP) __qeth_l2_open()
839 if ((card->info.type != QETH_CARD_TYPE_OSN) && __qeth_l2_open()
840 (!(card->info.mac_bits & QETH_LAYER2_MAC_REGISTERED))) { __qeth_l2_open()
841 QETH_CARD_TEXT(card, 4, "nomacadr"); __qeth_l2_open()
844 card->data.state = CH_STATE_UP; __qeth_l2_open()
845 card->state = CARD_STATE_UP; __qeth_l2_open()
848 if (qdio_stop_irq(card->data.ccwdev, 0) >= 0) { __qeth_l2_open()
849 napi_enable(&card->napi); __qeth_l2_open()
850 napi_schedule(&card->napi); __qeth_l2_open()
858 struct qeth_card *card = dev->ml_priv; qeth_l2_open() local
860 QETH_CARD_TEXT(card, 5, "qethope_"); qeth_l2_open()
861 if (qeth_wait_for_threads(card, QETH_RECOVER_THREAD)) { qeth_l2_open()
862 QETH_CARD_TEXT(card, 3, "openREC"); qeth_l2_open()
870 struct qeth_card *card = dev->ml_priv; qeth_l2_stop() local
872 QETH_CARD_TEXT(card, 4, "qethstop"); qeth_l2_stop()
874 if (card->state == CARD_STATE_UP) { qeth_l2_stop()
875 card->state = CARD_STATE_SOFTSETUP; qeth_l2_stop()
876 napi_disable(&card->napi); qeth_l2_stop()
883 struct qeth_card *card = dev_get_drvdata(&gdev->dev); qeth_l2_probe_device() local
886 INIT_LIST_HEAD(&card->vid_list); qeth_l2_probe_device()
887 INIT_LIST_HEAD(&card->mc_list); qeth_l2_probe_device()
888 card->options.layer2 = 1; qeth_l2_probe_device()
889 card->info.hwtrap = 0; qeth_l2_probe_device()
895 struct qeth_card *card = dev_get_drvdata(&cgdev->dev); qeth_l2_remove_device() local
898 qeth_set_allowed_threads(card, 0, 1); qeth_l2_remove_device()
899 wait_event(card->wait_q, qeth_threads_running(card, 0xffffffff) == 0); qeth_l2_remove_device()
904 if (card->dev) { qeth_l2_remove_device()
905 unregister_netdev(card->dev); qeth_l2_remove_device()
906 card->dev = NULL; qeth_l2_remove_device()
942 static int qeth_l2_setup_netdev(struct qeth_card *card) qeth_l2_setup_netdev() argument
944 switch (card->info.type) { qeth_l2_setup_netdev()
946 card->dev = alloc_netdev(0, "hsi%d", NET_NAME_UNKNOWN, qeth_l2_setup_netdev()
950 card->dev = alloc_netdev(0, "osn%d", NET_NAME_UNKNOWN, qeth_l2_setup_netdev()
952 card->dev->flags |= IFF_NOARP; qeth_l2_setup_netdev()
955 card->dev = alloc_etherdev(0); qeth_l2_setup_netdev()
958 if (!card->dev) qeth_l2_setup_netdev()
961 card->dev->ml_priv = card; qeth_l2_setup_netdev()
962 card->dev->watchdog_timeo = QETH_TX_TIMEOUT; qeth_l2_setup_netdev()
963 card->dev->mtu = card->info.initial_mtu; qeth_l2_setup_netdev()
964 card->dev->netdev_ops = &qeth_l2_netdev_ops; qeth_l2_setup_netdev()
965 card->dev->ethtool_ops = qeth_l2_setup_netdev()
966 (card->info.type != QETH_CARD_TYPE_OSN) ? qeth_l2_setup_netdev()
968 card->dev->features |= NETIF_F_HW_VLAN_CTAG_FILTER; qeth_l2_setup_netdev()
969 card->info.broadcast_capable = 1; qeth_l2_setup_netdev()
970 qeth_l2_request_initial_mac(card); qeth_l2_setup_netdev()
971 SET_NETDEV_DEV(card->dev, &card->gdev->dev); qeth_l2_setup_netdev()
972 netif_napi_add(card->dev, &card->napi, qeth_l2_poll, QETH_NAPI_WEIGHT); qeth_l2_setup_netdev()
973 return register_netdev(card->dev); qeth_l2_setup_netdev()
978 struct qeth_card *card = dev_get_drvdata(&gdev->dev); __qeth_l2_set_online() local
982 mutex_lock(&card->discipline_mutex); __qeth_l2_set_online()
983 mutex_lock(&card->conf_mutex); __qeth_l2_set_online()
985 QETH_DBF_HEX(SETUP, 2, &card, sizeof(void *)); __qeth_l2_set_online()
987 recover_flag = card->state; __qeth_l2_set_online()
988 rc = qeth_core_hardsetup_card(card); __qeth_l2_set_online()
994 qeth_bridgeport_query_support(card); __qeth_l2_set_online()
995 if (card->options.sbp.supported_funcs) __qeth_l2_set_online()
996 dev_info(&card->gdev->dev, __qeth_l2_set_online()
998 qeth_trace_features(card); __qeth_l2_set_online()
1000 if (!card->dev && qeth_l2_setup_netdev(card)) { __qeth_l2_set_online()
1005 if (card->info.type != QETH_CARD_TYPE_OSN) __qeth_l2_set_online()
1006 qeth_l2_send_setmac(card, &card->dev->dev_addr[0]); __qeth_l2_set_online()
1008 if (qeth_is_diagass_supported(card, QETH_DIAGS_CMD_TRAP)) { __qeth_l2_set_online()
1009 if (card->info.hwtrap && __qeth_l2_set_online()
1010 qeth_hw_trap(card, QETH_DIAGS_TRAP_ARM)) __qeth_l2_set_online()
1011 card->info.hwtrap = 0; __qeth_l2_set_online()
1013 card->info.hwtrap = 0; __qeth_l2_set_online()
1015 qeth_l2_setup_bridgeport_attrs(card); __qeth_l2_set_online()
1017 card->state = CARD_STATE_HARDSETUP; __qeth_l2_set_online()
1018 memset(&card->rx, 0, sizeof(struct qeth_rx)); __qeth_l2_set_online()
1019 qeth_print_status_message(card); __qeth_l2_set_online()
1024 rc = qeth_send_startlan(card); __qeth_l2_set_online()
1028 dev_warn(&card->gdev->dev, __qeth_l2_set_online()
1030 card->lan_online = 0; __qeth_l2_set_online()
1036 card->lan_online = 1; __qeth_l2_set_online()
1039 if ((card->info.type == QETH_CARD_TYPE_OSD) || __qeth_l2_set_online()
1040 (card->info.type == QETH_CARD_TYPE_OSX)) { __qeth_l2_set_online()
1042 rc = qeth_set_access_ctrl_online(card, 0); __qeth_l2_set_online()
1049 if (card->info.type != QETH_CARD_TYPE_OSN && __qeth_l2_set_online()
1050 card->info.type != QETH_CARD_TYPE_OSM) __qeth_l2_set_online()
1051 qeth_l2_process_vlans(card); __qeth_l2_set_online()
1053 netif_tx_disable(card->dev); __qeth_l2_set_online()
1055 rc = qeth_init_qdio_queues(card); __qeth_l2_set_online()
1061 card->state = CARD_STATE_SOFTSETUP; __qeth_l2_set_online()
1062 if (card->lan_online) __qeth_l2_set_online()
1063 netif_carrier_on(card->dev); __qeth_l2_set_online()
1065 netif_carrier_off(card->dev); __qeth_l2_set_online()
1067 qeth_set_allowed_threads(card, 0xffffffff, 0); __qeth_l2_set_online()
1070 card->info.type != QETH_CARD_TYPE_OSN) { __qeth_l2_set_online()
1071 __qeth_l2_open(card->dev); __qeth_l2_set_online()
1074 dev_open(card->dev); __qeth_l2_set_online()
1078 qeth_l2_set_multicast_list(card->dev); __qeth_l2_set_online()
1082 mutex_unlock(&card->conf_mutex); __qeth_l2_set_online()
1083 mutex_unlock(&card->discipline_mutex); __qeth_l2_set_online()
1087 qeth_l2_stop_card(card, 0); __qeth_l2_set_online()
1088 ccw_device_set_offline(CARD_DDEV(card)); __qeth_l2_set_online()
1089 ccw_device_set_offline(CARD_WDEV(card)); __qeth_l2_set_online()
1090 ccw_device_set_offline(CARD_RDEV(card)); __qeth_l2_set_online()
1091 qdio_free(CARD_DDEV(card)); __qeth_l2_set_online()
1093 card->state = CARD_STATE_RECOVER; __qeth_l2_set_online()
1095 card->state = CARD_STATE_DOWN; __qeth_l2_set_online()
1096 mutex_unlock(&card->conf_mutex); __qeth_l2_set_online()
1097 mutex_unlock(&card->discipline_mutex); __qeth_l2_set_online()
1109 struct qeth_card *card = dev_get_drvdata(&cgdev->dev); __qeth_l2_set_offline() local
1113 mutex_lock(&card->discipline_mutex); __qeth_l2_set_offline()
1114 mutex_lock(&card->conf_mutex); __qeth_l2_set_offline()
1116 QETH_DBF_HEX(SETUP, 3, &card, sizeof(void *)); __qeth_l2_set_offline()
1118 if (card->dev && netif_carrier_ok(card->dev)) __qeth_l2_set_offline()
1119 netif_carrier_off(card->dev); __qeth_l2_set_offline()
1120 recover_flag = card->state; __qeth_l2_set_offline()
1121 if ((!recovery_mode && card->info.hwtrap) || card->info.hwtrap == 2) { __qeth_l2_set_offline()
1122 qeth_hw_trap(card, QETH_DIAGS_TRAP_DISARM); __qeth_l2_set_offline()
1123 card->info.hwtrap = 1; __qeth_l2_set_offline()
1125 qeth_l2_stop_card(card, recovery_mode); __qeth_l2_set_offline()
1126 rc = ccw_device_set_offline(CARD_DDEV(card)); __qeth_l2_set_offline()
1127 rc2 = ccw_device_set_offline(CARD_WDEV(card)); __qeth_l2_set_offline()
1128 rc3 = ccw_device_set_offline(CARD_RDEV(card)); __qeth_l2_set_offline()
1133 qdio_free(CARD_DDEV(card)); __qeth_l2_set_offline()
1135 card->state = CARD_STATE_RECOVER; __qeth_l2_set_offline()
1138 mutex_unlock(&card->conf_mutex); __qeth_l2_set_offline()
1139 mutex_unlock(&card->discipline_mutex); __qeth_l2_set_offline()
1150 struct qeth_card *card; qeth_l2_recover() local
1153 card = (struct qeth_card *) ptr; qeth_l2_recover()
1154 QETH_CARD_TEXT(card, 2, "recover1"); qeth_l2_recover()
1155 if (!qeth_do_run_thread(card, QETH_RECOVER_THREAD)) qeth_l2_recover()
1157 QETH_CARD_TEXT(card, 2, "recover2"); qeth_l2_recover()
1158 dev_warn(&card->gdev->dev, qeth_l2_recover()
1160 qeth_set_recovery_task(card); qeth_l2_recover()
1161 __qeth_l2_set_offline(card->gdev, 1); qeth_l2_recover()
1162 rc = __qeth_l2_set_online(card->gdev, 1); qeth_l2_recover()
1164 dev_info(&card->gdev->dev, qeth_l2_recover()
1167 qeth_close_dev(card); qeth_l2_recover()
1168 dev_warn(&card->gdev->dev, "The qeth device driver " qeth_l2_recover()
1171 qeth_clear_recovery_task(card); qeth_l2_recover()
1172 qeth_clear_thread_start_bit(card, QETH_RECOVER_THREAD); qeth_l2_recover()
1173 qeth_clear_thread_running_bit(card, QETH_RECOVER_THREAD); qeth_l2_recover()
1190 struct qeth_card *card = dev_get_drvdata(&gdev->dev); qeth_l2_shutdown() local
1191 qeth_set_allowed_threads(card, 0, 1); qeth_l2_shutdown()
1192 if ((gdev->state == CCWGROUP_ONLINE) && card->info.hwtrap) qeth_l2_shutdown()
1193 qeth_hw_trap(card, QETH_DIAGS_TRAP_DISARM); qeth_l2_shutdown()
1194 qeth_qdio_clear_card(card, 0); qeth_l2_shutdown()
1195 qeth_clear_qdio_buffers(card); qeth_l2_shutdown()
1196 qdio_free(CARD_DDEV(card)); qeth_l2_shutdown()
1201 struct qeth_card *card = dev_get_drvdata(&gdev->dev); qeth_l2_pm_suspend() local
1203 if (card->dev) qeth_l2_pm_suspend()
1204 netif_device_detach(card->dev); qeth_l2_pm_suspend()
1205 qeth_set_allowed_threads(card, 0, 1); qeth_l2_pm_suspend()
1206 wait_event(card->wait_q, qeth_threads_running(card, 0xffffffff) == 0); qeth_l2_pm_suspend()
1209 if (card->state == CARD_STATE_UP) { qeth_l2_pm_suspend()
1210 if (card->info.hwtrap) qeth_l2_pm_suspend()
1211 qeth_hw_trap(card, QETH_DIAGS_TRAP_DISARM); qeth_l2_pm_suspend()
1212 __qeth_l2_set_offline(card->gdev, 1); qeth_l2_pm_suspend()
1214 __qeth_l2_set_offline(card->gdev, 0); qeth_l2_pm_suspend()
1220 struct qeth_card *card = dev_get_drvdata(&gdev->dev); qeth_l2_pm_resume() local
1226 if (card->state == CARD_STATE_RECOVER) { qeth_l2_pm_resume()
1227 rc = __qeth_l2_set_online(card->gdev, 1); qeth_l2_pm_resume()
1230 dev_close(card->dev); qeth_l2_pm_resume()
1234 rc = __qeth_l2_set_online(card->gdev, 0); qeth_l2_pm_resume()
1236 qeth_set_allowed_threads(card, 0xffffffff, 0); qeth_l2_pm_resume()
1237 if (card->dev) qeth_l2_pm_resume()
1238 netif_device_attach(card->dev); qeth_l2_pm_resume()
1240 dev_warn(&card->gdev->dev, "The qeth device driver " qeth_l2_pm_resume()
1246 static int qeth_l2_control_event(struct qeth_card *card, qeth_l2_control_event() argument
1253 qeth_bridge_state_change(card, cmd); qeth_l2_control_event()
1258 qeth_bridge_host_event(card, cmd); qeth_l2_control_event()
1282 static int qeth_osn_send_control_data(struct qeth_card *card, int len, qeth_osn_send_control_data() argument
1288 QETH_CARD_TEXT(card, 5, "osndctrd"); qeth_osn_send_control_data()
1290 wait_event(card->wait_q, qeth_osn_send_control_data()
1291 atomic_cmpxchg(&card->write.irq_pending, 0, 1) == 0); qeth_osn_send_control_data()
1292 qeth_prepare_control_data(card, len, iob); qeth_osn_send_control_data()
1293 QETH_CARD_TEXT(card, 6, "osnoirqp"); qeth_osn_send_control_data()
1294 spin_lock_irqsave(get_ccwdev_lock(card->write.ccwdev), flags); qeth_osn_send_control_data()
1295 rc = ccw_device_start(card->write.ccwdev, &card->write.ccw, qeth_osn_send_control_data()
1297 spin_unlock_irqrestore(get_ccwdev_lock(card->write.ccwdev), flags); qeth_osn_send_control_data()
1301 QETH_CARD_TEXT_(card, 2, " err%d", rc); qeth_osn_send_control_data()
1303 atomic_set(&card->write.irq_pending, 0); qeth_osn_send_control_data()
1304 wake_up(&card->wait_q); qeth_osn_send_control_data()
1309 static int qeth_osn_send_ipa_cmd(struct qeth_card *card, qeth_osn_send_ipa_cmd() argument
1314 QETH_CARD_TEXT(card, 4, "osndipa"); qeth_osn_send_ipa_cmd()
1316 qeth_prepare_ipa_cmd(card, iob, QETH_PROT_OSN2); qeth_osn_send_ipa_cmd()
1323 return qeth_osn_send_control_data(card, s1, iob); qeth_osn_send_ipa_cmd()
1329 struct qeth_card *card; qeth_osn_assist() local
1334 card = dev->ml_priv; qeth_osn_assist()
1335 if (!card) qeth_osn_assist()
1337 QETH_CARD_TEXT(card, 2, "osnsdmc"); qeth_osn_assist()
1338 if (!qeth_card_hw_is_reachable(card)) qeth_osn_assist()
1340 iob = qeth_wait_for_buffer(&card->write); qeth_osn_assist()
1342 rc = qeth_osn_send_ipa_cmd(card, iob, data_len); qeth_osn_assist()
1351 struct qeth_card *card; qeth_osn_register() local
1356 card = (*dev)->ml_priv; qeth_osn_register()
1357 if (!card) qeth_osn_register()
1359 QETH_CARD_TEXT(card, 2, "osnreg"); qeth_osn_register()
1362 card->osn_info.assist_cb = assist_cb; qeth_osn_register()
1363 card->osn_info.data_cb = data_cb; qeth_osn_register()
1370 struct qeth_card *card; qeth_osn_deregister() local
1374 card = dev->ml_priv; qeth_osn_deregister()
1375 if (!card) qeth_osn_deregister()
1377 QETH_CARD_TEXT(card, 2, "osndereg"); qeth_osn_deregister()
1378 card->osn_info.assist_cb = NULL; qeth_osn_deregister()
1379 card->osn_info.data_cb = NULL; qeth_osn_deregister()
1390 * @card: qeth_card structure pointer, for udev events.
1403 static void qeth_bridge_emit_host_event(struct qeth_card *card, qeth_bridge_emit_host_event() argument
1448 kobject_uevent_env(&card->gdev->dev.kobj, KOBJ_CHANGE, env); qeth_bridge_emit_host_event()
1453 struct qeth_card *card; member in struct:qeth_bridge_state_data
1475 mutex_lock(&data->card->conf_mutex); qeth_bridge_state_change_worker()
1476 data->card->options.sbp.role = entry->role; qeth_bridge_state_change_worker()
1477 mutex_unlock(&data->card->conf_mutex); qeth_bridge_state_change_worker()
1490 kobject_uevent_env(&data->card->gdev->dev.kobj, qeth_bridge_state_change_worker()
1495 static void qeth_bridge_state_change(struct qeth_card *card, qeth_bridge_state_change() argument
1503 QETH_CARD_TEXT(card, 2, "brstchng"); qeth_bridge_state_change()
1505 QETH_CARD_TEXT_(card, 2, "BPsz%04x", qports->entry_length); qeth_bridge_state_change()
1512 QETH_CARD_TEXT(card, 2, "BPSalloc"); qeth_bridge_state_change()
1516 data->card = card; qeth_bridge_state_change()
1524 struct qeth_card *card; member in struct:qeth_bridge_host_data
1535 dev_info(&data->card->gdev->dev, qeth_bridge_host_event_worker()
1537 data->card->dev->name, qeth_bridge_host_event_worker()
1543 mutex_lock(&data->card->conf_mutex); qeth_bridge_host_event_worker()
1544 data->card->options.sbp.hostnotification = 0; qeth_bridge_host_event_worker()
1545 mutex_unlock(&data->card->conf_mutex); qeth_bridge_host_event_worker()
1546 qeth_bridge_emit_host_event(data->card, anev_abort, qeth_bridge_host_event_worker()
1552 qeth_bridge_emit_host_event(data->card, qeth_bridge_host_event_worker()
1560 static void qeth_bridge_host_event(struct qeth_card *card, qeth_bridge_host_event() argument
1568 QETH_CARD_TEXT(card, 2, "brhostev"); qeth_bridge_host_event()
1574 QETH_CARD_TEXT_(card, 2, "BPHe%04x", qeth_bridge_host_event()
1584 QETH_CARD_TEXT(card, 2, "BPHalloc"); qeth_bridge_host_event()
1588 data->card = card; qeth_bridge_host_event()
1610 * @card: qeth_card structure pointer, for debug messages.
1616 static int qeth_bridgeport_makerc(struct qeth_card *card, qeth_bridgeport_makerc() argument
1632 dev_err(&card->gdev->dev, qeth_bridgeport_makerc()
1639 dev_err(&card->gdev->dev, qeth_bridgeport_makerc()
1644 dev_err(&card->gdev->dev, qeth_bridgeport_makerc()
1653 dev_err(&card->gdev->dev, qeth_bridgeport_makerc()
1658 dev_err(&card->gdev->dev, qeth_bridgeport_makerc()
1663 dev_err(&card->gdev->dev, qeth_bridgeport_makerc()
1668 dev_err(&card->gdev->dev, qeth_bridgeport_makerc()
1685 QETH_CARD_TEXT_(card, 2, "SBPi%04x", cbctl->ipa_rc); qeth_bridgeport_makerc()
1686 QETH_CARD_TEXT_(card, 2, "SBPc%04x", cbctl->cmd_rc); qeth_bridgeport_makerc()
1691 static int qeth_bridgeport_query_support_cb(struct qeth_card *card, qeth_bridgeport_query_support_cb() argument
1696 QETH_CARD_TEXT(card, 2, "brqsupcb"); qeth_bridgeport_query_support_cb()
1710 * @card: qeth_card structure pointer.
1713 * strucutre: card->options.sbp.supported_funcs.
1715 static void qeth_bridgeport_query_support(struct qeth_card *card) qeth_bridgeport_query_support() argument
1721 QETH_CARD_TEXT(card, 2, "brqsuppo"); qeth_bridgeport_query_support()
1722 iob = qeth_get_ipacmd_buffer(card, IPA_CMD_SETBRIDGEPORT, 0); qeth_bridgeport_query_support()
1733 if (qeth_send_ipa_cmd(card, iob, qeth_bridgeport_query_support_cb, qeth_bridgeport_query_support()
1735 qeth_bridgeport_makerc(card, &cbctl, qeth_bridgeport_query_support()
1738 card->options.sbp.role = QETH_SBP_ROLE_NONE; qeth_bridgeport_query_support()
1741 card->options.sbp.supported_funcs = cbctl.data.supported; qeth_bridgeport_query_support()
1744 static int qeth_bridgeport_query_ports_cb(struct qeth_card *card, qeth_bridgeport_query_ports_cb() argument
1751 QETH_CARD_TEXT(card, 2, "brqprtcb"); qeth_bridgeport_query_ports_cb()
1758 QETH_CARD_TEXT_(card, 2, "SBPs%04x", qports->entry_length); qeth_bridgeport_query_ports_cb()
1773 * @card: qeth_card structure pointer.
1781 int qeth_bridgeport_query_ports(struct qeth_card *card, qeth_bridgeport_query_ports() argument
1796 QETH_CARD_TEXT(card, 2, "brqports"); qeth_bridgeport_query_ports()
1797 if (!(card->options.sbp.supported_funcs & IPA_SBP_QUERY_BRIDGE_PORTS)) qeth_bridgeport_query_ports()
1799 iob = qeth_get_ipacmd_buffer(card, IPA_CMD_SETBRIDGEPORT, 0); qeth_bridgeport_query_ports()
1809 rc = qeth_send_ipa_cmd(card, iob, qeth_bridgeport_query_ports_cb, qeth_bridgeport_query_ports()
1813 rc = qeth_bridgeport_makerc(card, &cbctl, IPA_SBP_QUERY_BRIDGE_PORTS); qeth_bridgeport_query_ports()
1818 static int qeth_bridgeport_set_cb(struct qeth_card *card, qeth_bridgeport_set_cb() argument
1823 QETH_CARD_TEXT(card, 2, "brsetrcb"); qeth_bridgeport_set_cb()
1831 * @card: qeth_card structure pointer.
1836 int qeth_bridgeport_setrole(struct qeth_card *card, enum qeth_sbp_roles role) qeth_bridgeport_setrole() argument
1845 QETH_CARD_TEXT(card, 2, "brsetrol"); qeth_bridgeport_setrole()
1865 if (!(card->options.sbp.supported_funcs & setcmd)) qeth_bridgeport_setrole()
1867 iob = qeth_get_ipacmd_buffer(card, IPA_CMD_SETBRIDGEPORT, 0); qeth_bridgeport_setrole()
1875 rc = qeth_send_ipa_cmd(card, iob, qeth_bridgeport_set_cb, qeth_bridgeport_setrole()
1879 rc = qeth_bridgeport_makerc(card, &cbctl, setcmd); qeth_bridgeport_setrole()
1885 * @card: qeth_card structure pointer, for debug messages.
1889 static int qeth_anset_makerc(struct qeth_card *card, int pnso_rc, u16 response) qeth_anset_makerc() argument
1902 dev_err(&card->gdev->dev, qeth_anset_makerc()
1915 QETH_CARD_TEXT_(card, 2, "SBPp%04x", pnso_rc); qeth_anset_makerc()
1916 QETH_CARD_TEXT_(card, 2, "SBPr%04x", response); qeth_anset_makerc()
1924 struct qeth_card *card = (struct qeth_card *)priv; qeth_bridgeport_an_set_cb() local
1937 qeth_bridge_emit_host_event(card, anev_reg_unreg, code, qeth_bridgeport_an_set_cb()
1944 * @card: qeth_card structure pointer.
1952 int qeth_bridgeport_an_set(struct qeth_card *card, int enable) qeth_bridgeport_an_set() argument
1959 if (!card) qeth_bridgeport_an_set()
1961 if (!card->options.sbp.supported_funcs) qeth_bridgeport_an_set()
1963 ddev = CARD_DDEV(card); qeth_bridgeport_an_set()
1967 qeth_bridge_emit_host_event(card, anev_reset, 0, NULL, NULL); qeth_bridgeport_an_set()
1969 qeth_bridgeport_an_set_cb, card); qeth_bridgeport_an_set()
1972 return qeth_anset_makerc(card, rc, response); qeth_bridgeport_an_set()
H A Dqeth_l3_main.c170 int qeth_l3_is_addr_covered_by_ipato(struct qeth_card *card, qeth_l3_is_addr_covered_by_ipato() argument
178 if (!card->ipato.enabled) qeth_l3_is_addr_covered_by_ipato()
183 list_for_each_entry(ipatoe, &card->ipato.entries, entry) { qeth_l3_is_addr_covered_by_ipato()
199 if ((addr->proto == QETH_PROT_IPV4) && card->ipato.invert4) qeth_l3_is_addr_covered_by_ipato()
201 else if ((addr->proto == QETH_PROT_IPV6) && card->ipato.invert6) qeth_l3_is_addr_covered_by_ipato()
212 static int __qeth_l3_insert_ip_todo(struct qeth_card *card, __qeth_l3_insert_ip_todo() argument
218 if (card->options.sniffer) __qeth_l3_insert_ip_todo()
220 list_for_each_entry_safe(tmp, t, card->ip_tbd_list, entry) { __qeth_l3_insert_ip_todo()
256 list_add(&addr->entry, card->ip_tbd_list); __qeth_l3_insert_ip_todo()
261 qeth_l3_is_addr_covered_by_ipato(card, addr)) { __qeth_l3_insert_ip_todo()
262 QETH_CARD_TEXT(card, 2, "tkovaddr"); __qeth_l3_insert_ip_todo()
265 list_add_tail(&addr->entry, card->ip_tbd_list); __qeth_l3_insert_ip_todo()
271 int qeth_l3_delete_ip(struct qeth_card *card, struct qeth_ipaddr *addr) qeth_l3_delete_ip() argument
276 QETH_CARD_TEXT(card, 4, "delip"); qeth_l3_delete_ip()
279 QETH_CARD_HEX(card, 4, &addr->u.a4.addr, 4); qeth_l3_delete_ip()
281 QETH_CARD_HEX(card, 4, &addr->u.a6.addr, 8); qeth_l3_delete_ip()
282 QETH_CARD_HEX(card, 4, ((char *)&addr->u.a6.addr) + 8, 8); qeth_l3_delete_ip()
284 spin_lock_irqsave(&card->ip_lock, flags); qeth_l3_delete_ip()
285 rc = __qeth_l3_insert_ip_todo(card, addr, 0); qeth_l3_delete_ip()
286 spin_unlock_irqrestore(&card->ip_lock, flags); qeth_l3_delete_ip()
290 int qeth_l3_add_ip(struct qeth_card *card, struct qeth_ipaddr *addr) qeth_l3_add_ip() argument
295 QETH_CARD_TEXT(card, 4, "addip"); qeth_l3_add_ip()
297 QETH_CARD_HEX(card, 4, &addr->u.a4.addr, 4); qeth_l3_add_ip()
299 QETH_CARD_HEX(card, 4, &addr->u.a6.addr, 8); qeth_l3_add_ip()
300 QETH_CARD_HEX(card, 4, ((char *)&addr->u.a6.addr) + 8, 8); qeth_l3_add_ip()
302 spin_lock_irqsave(&card->ip_lock, flags); qeth_l3_add_ip()
303 rc = __qeth_l3_insert_ip_todo(card, addr, 1); qeth_l3_add_ip()
304 spin_unlock_irqrestore(&card->ip_lock, flags); qeth_l3_add_ip()
323 static void qeth_l3_delete_mc_addresses(struct qeth_card *card) qeth_l3_delete_mc_addresses() argument
328 QETH_CARD_TEXT(card, 4, "delmc"); qeth_l3_delete_mc_addresses()
331 QETH_CARD_TEXT(card, 2, "dmcnomem"); qeth_l3_delete_mc_addresses()
335 spin_lock_irqsave(&card->ip_lock, flags); qeth_l3_delete_mc_addresses()
336 if (!__qeth_l3_insert_ip_todo(card, iptodo, 0)) qeth_l3_delete_mc_addresses()
338 spin_unlock_irqrestore(&card->ip_lock, flags); qeth_l3_delete_mc_addresses()
342 * Add/remove address to/from card's ip list, i.e. try to add or remove
343 * reference to/from an IP address that is already registered on the card.
345 * 0 address was on card and its reference count has been adjusted,
347 * also returns 0 if card was not on card and the todo was to delete
349 * 1 address was not on card and the todo is to add it to the card's ip
351 * -1 address was on card and its reference count has been decremented
352 * to <= 0 by the todo -> address must be removed from card
354 static int __qeth_l3_ref_ip_on_card(struct qeth_card *card, __qeth_l3_ref_ip_on_card() argument
360 list_for_each_entry(addr, &card->ip_list, entry) { __qeth_l3_ref_ip_on_card()
400 static void __qeth_l3_delete_all_mc(struct qeth_card *card, __qeth_l3_delete_all_mc() argument
409 list_for_each_entry_safe(addr, tmp, &card->ip_list, entry) { __qeth_l3_delete_all_mc()
412 spin_unlock_irqrestore(&card->ip_lock, *flags); __qeth_l3_delete_all_mc()
413 rc = qeth_l3_deregister_addr_entry(card, addr); __qeth_l3_delete_all_mc()
414 spin_lock_irqsave(&card->ip_lock, *flags); __qeth_l3_delete_all_mc()
422 list_splice(&fail_list, &card->ip_list); __qeth_l3_delete_all_mc()
425 void qeth_l3_set_ip_addr_list(struct qeth_card *card) qeth_l3_set_ip_addr_list() argument
432 QETH_CARD_TEXT(card, 2, "sdiplist"); qeth_l3_set_ip_addr_list()
433 QETH_CARD_HEX(card, 2, &card, sizeof(void *)); qeth_l3_set_ip_addr_list()
435 if (!qeth_card_hw_is_reachable(card) || card->options.sniffer) qeth_l3_set_ip_addr_list()
438 spin_lock_irqsave(&card->ip_lock, flags); qeth_l3_set_ip_addr_list()
439 tbd_list = card->ip_tbd_list; qeth_l3_set_ip_addr_list()
440 card->ip_tbd_list = kzalloc(sizeof(struct list_head), GFP_ATOMIC); qeth_l3_set_ip_addr_list()
441 if (!card->ip_tbd_list) { qeth_l3_set_ip_addr_list()
442 QETH_CARD_TEXT(card, 0, "silnomem"); qeth_l3_set_ip_addr_list()
443 card->ip_tbd_list = tbd_list; qeth_l3_set_ip_addr_list()
444 spin_unlock_irqrestore(&card->ip_lock, flags); qeth_l3_set_ip_addr_list()
447 INIT_LIST_HEAD(card->ip_tbd_list); qeth_l3_set_ip_addr_list()
453 __qeth_l3_delete_all_mc(card, &flags); qeth_l3_set_ip_addr_list()
457 rc = __qeth_l3_ref_ip_on_card(card, todo, &addr); qeth_l3_set_ip_addr_list()
462 /* new entry to be added to on-card list */ qeth_l3_set_ip_addr_list()
463 spin_unlock_irqrestore(&card->ip_lock, flags); qeth_l3_set_ip_addr_list()
464 rc = qeth_l3_register_addr_entry(card, todo); qeth_l3_set_ip_addr_list()
465 spin_lock_irqsave(&card->ip_lock, flags); qeth_l3_set_ip_addr_list()
467 list_add_tail(&todo->entry, &card->ip_list); qeth_l3_set_ip_addr_list()
471 /* on-card entry to be removed */ qeth_l3_set_ip_addr_list()
473 spin_unlock_irqrestore(&card->ip_lock, flags); qeth_l3_set_ip_addr_list()
474 rc = qeth_l3_deregister_addr_entry(card, addr); qeth_l3_set_ip_addr_list()
475 spin_lock_irqsave(&card->ip_lock, flags); qeth_l3_set_ip_addr_list()
479 list_add_tail(&addr->entry, &card->ip_list); qeth_l3_set_ip_addr_list()
483 spin_unlock_irqrestore(&card->ip_lock, flags); qeth_l3_set_ip_addr_list()
487 static void qeth_l3_clear_ip_list(struct qeth_card *card, int recover) qeth_l3_clear_ip_list() argument
492 QETH_CARD_TEXT(card, 4, "clearip"); qeth_l3_clear_ip_list()
493 if (recover && card->options.sniffer) qeth_l3_clear_ip_list()
495 spin_lock_irqsave(&card->ip_lock, flags); qeth_l3_clear_ip_list()
497 list_for_each_entry_safe(addr, tmp, card->ip_tbd_list, entry) { qeth_l3_clear_ip_list()
502 while (!list_empty(&card->ip_list)) { qeth_l3_clear_ip_list()
503 addr = list_entry(card->ip_list.next, qeth_l3_clear_ip_list()
510 list_add_tail(&addr->entry, card->ip_tbd_list); qeth_l3_clear_ip_list()
512 spin_unlock_irqrestore(&card->ip_lock, flags); qeth_l3_clear_ip_list()
540 static int qeth_l3_send_setdelmc(struct qeth_card *card, qeth_l3_send_setdelmc() argument
547 QETH_CARD_TEXT(card, 4, "setdelmc"); qeth_l3_send_setdelmc()
549 iob = qeth_get_ipacmd_buffer(card, ipacmd, addr->proto); qeth_l3_send_setdelmc()
560 rc = qeth_send_ipa_cmd(card, iob, NULL, NULL); qeth_l3_send_setdelmc()
579 static int qeth_l3_send_setdelip(struct qeth_card *card, qeth_l3_send_setdelip() argument
587 QETH_CARD_TEXT(card, 4, "setdelip"); qeth_l3_send_setdelip()
588 QETH_CARD_TEXT_(card, 4, "flags%02X", flags); qeth_l3_send_setdelip()
590 iob = qeth_get_ipacmd_buffer(card, ipacmd, addr->proto); qeth_l3_send_setdelip()
607 rc = qeth_send_ipa_cmd(card, iob, NULL, NULL); qeth_l3_send_setdelip()
612 static int qeth_l3_send_setrouting(struct qeth_card *card, qeth_l3_send_setrouting() argument
619 QETH_CARD_TEXT(card, 4, "setroutg"); qeth_l3_send_setrouting()
620 iob = qeth_get_ipacmd_buffer(card, IPA_CMD_SETRTG, prot); qeth_l3_send_setrouting()
625 rc = qeth_send_ipa_cmd(card, iob, NULL, NULL); qeth_l3_send_setrouting()
630 static int qeth_l3_correct_routing_type(struct qeth_card *card, qeth_l3_correct_routing_type() argument
633 if (card->info.type == QETH_CARD_TYPE_IQD) { qeth_l3_correct_routing_type()
650 if (qeth_is_ipafunc_supported(card, prot, qeth_l3_correct_routing_type()
662 int qeth_l3_setrouting_v4(struct qeth_card *card) qeth_l3_setrouting_v4() argument
666 QETH_CARD_TEXT(card, 3, "setrtg4"); qeth_l3_setrouting_v4()
668 rc = qeth_l3_correct_routing_type(card, &card->options.route4.type, qeth_l3_setrouting_v4()
673 rc = qeth_l3_send_setrouting(card, card->options.route4.type, qeth_l3_setrouting_v4()
676 card->options.route4.type = NO_ROUTER; qeth_l3_setrouting_v4()
679 QETH_CARD_IFNAME(card)); qeth_l3_setrouting_v4()
684 int qeth_l3_setrouting_v6(struct qeth_card *card) qeth_l3_setrouting_v6() argument
688 QETH_CARD_TEXT(card, 3, "setrtg6"); qeth_l3_setrouting_v6()
691 if (!qeth_is_supported(card, IPA_IPV6)) qeth_l3_setrouting_v6()
693 rc = qeth_l3_correct_routing_type(card, &card->options.route6.type, qeth_l3_setrouting_v6()
698 rc = qeth_l3_send_setrouting(card, card->options.route6.type, qeth_l3_setrouting_v6()
701 card->options.route6.type = NO_ROUTER; qeth_l3_setrouting_v6()
704 QETH_CARD_IFNAME(card)); qeth_l3_setrouting_v6()
713 static void qeth_l3_clear_ipato_list(struct qeth_card *card) qeth_l3_clear_ipato_list() argument
719 spin_lock_irqsave(&card->ip_lock, flags); qeth_l3_clear_ipato_list()
720 list_for_each_entry_safe(ipatoe, tmp, &card->ipato.entries, entry) { qeth_l3_clear_ipato_list()
724 spin_unlock_irqrestore(&card->ip_lock, flags); qeth_l3_clear_ipato_list()
727 int qeth_l3_add_ipato_entry(struct qeth_card *card, qeth_l3_add_ipato_entry() argument
734 QETH_CARD_TEXT(card, 2, "addipato"); qeth_l3_add_ipato_entry()
735 spin_lock_irqsave(&card->ip_lock, flags); qeth_l3_add_ipato_entry()
736 list_for_each_entry(ipatoe, &card->ipato.entries, entry) { qeth_l3_add_ipato_entry()
747 list_add_tail(&new->entry, &card->ipato.entries); qeth_l3_add_ipato_entry()
749 spin_unlock_irqrestore(&card->ip_lock, flags); qeth_l3_add_ipato_entry()
753 void qeth_l3_del_ipato_entry(struct qeth_card *card, qeth_l3_del_ipato_entry() argument
759 QETH_CARD_TEXT(card, 2, "delipato"); qeth_l3_del_ipato_entry()
760 spin_lock_irqsave(&card->ip_lock, flags); qeth_l3_del_ipato_entry()
761 list_for_each_entry_safe(ipatoe, tmp, &card->ipato.entries, entry) { qeth_l3_del_ipato_entry()
771 spin_unlock_irqrestore(&card->ip_lock, flags); qeth_l3_del_ipato_entry()
777 int qeth_l3_add_vipa(struct qeth_card *card, enum qeth_prot_versions proto, qeth_l3_add_vipa() argument
787 QETH_CARD_TEXT(card, 2, "addvipa4"); qeth_l3_add_vipa()
791 QETH_CARD_TEXT(card, 2, "addvipa6"); qeth_l3_add_vipa()
800 spin_lock_irqsave(&card->ip_lock, flags); qeth_l3_add_vipa()
801 if (qeth_l3_address_exists_in_list(&card->ip_list, ipaddr, 0) || qeth_l3_add_vipa()
802 qeth_l3_address_exists_in_list(card->ip_tbd_list, ipaddr, 0)) qeth_l3_add_vipa()
804 spin_unlock_irqrestore(&card->ip_lock, flags); qeth_l3_add_vipa()
809 if (!qeth_l3_add_ip(card, ipaddr)) qeth_l3_add_vipa()
811 qeth_l3_set_ip_addr_list(card); qeth_l3_add_vipa()
815 void qeth_l3_del_vipa(struct qeth_card *card, enum qeth_prot_versions proto, qeth_l3_del_vipa() argument
823 QETH_CARD_TEXT(card, 2, "delvipa4"); qeth_l3_del_vipa()
827 QETH_CARD_TEXT(card, 2, "delvipa6"); qeth_l3_del_vipa()
834 if (!qeth_l3_delete_ip(card, ipaddr)) qeth_l3_del_vipa()
836 qeth_l3_set_ip_addr_list(card); qeth_l3_del_vipa()
842 int qeth_l3_add_rxip(struct qeth_card *card, enum qeth_prot_versions proto, qeth_l3_add_rxip() argument
852 QETH_CARD_TEXT(card, 2, "addrxip4"); qeth_l3_add_rxip()
856 QETH_CARD_TEXT(card, 2, "addrxip6"); qeth_l3_add_rxip()
865 spin_lock_irqsave(&card->ip_lock, flags); qeth_l3_add_rxip()
866 if (qeth_l3_address_exists_in_list(&card->ip_list, ipaddr, 0) || qeth_l3_add_rxip()
867 qeth_l3_address_exists_in_list(card->ip_tbd_list, ipaddr, 0)) qeth_l3_add_rxip()
869 spin_unlock_irqrestore(&card->ip_lock, flags); qeth_l3_add_rxip()
874 if (!qeth_l3_add_ip(card, ipaddr)) qeth_l3_add_rxip()
876 qeth_l3_set_ip_addr_list(card); qeth_l3_add_rxip()
880 void qeth_l3_del_rxip(struct qeth_card *card, enum qeth_prot_versions proto, qeth_l3_del_rxip() argument
888 QETH_CARD_TEXT(card, 2, "addrxip4"); qeth_l3_del_rxip()
892 QETH_CARD_TEXT(card, 2, "addrxip6"); qeth_l3_del_rxip()
899 if (!qeth_l3_delete_ip(card, ipaddr)) qeth_l3_del_rxip()
901 qeth_l3_set_ip_addr_list(card); qeth_l3_del_rxip()
904 static int qeth_l3_register_addr_entry(struct qeth_card *card, qeth_l3_register_addr_entry() argument
912 QETH_CARD_TEXT(card, 2, "setaddr4"); qeth_l3_register_addr_entry()
913 QETH_CARD_HEX(card, 3, &addr->u.a4.addr, sizeof(int)); qeth_l3_register_addr_entry()
915 QETH_CARD_TEXT(card, 2, "setaddr6"); qeth_l3_register_addr_entry()
916 QETH_CARD_HEX(card, 3, &addr->u.a6.addr, 8); qeth_l3_register_addr_entry()
917 QETH_CARD_HEX(card, 3, ((char *)&addr->u.a6.addr) + 8, 8); qeth_l3_register_addr_entry()
919 QETH_CARD_TEXT(card, 2, "setaddr?"); qeth_l3_register_addr_entry()
920 QETH_CARD_HEX(card, 3, addr, sizeof(struct qeth_ipaddr)); qeth_l3_register_addr_entry()
924 rc = qeth_l3_send_setdelmc(card, addr, IPA_CMD_SETIPM); qeth_l3_register_addr_entry()
926 rc = qeth_l3_send_setdelip(card, addr, IPA_CMD_SETIP, qeth_l3_register_addr_entry()
929 QETH_CARD_TEXT(card, 2, "failed"); qeth_l3_register_addr_entry()
932 QETH_CARD_TEXT(card, 2, "FAILED"); qeth_l3_register_addr_entry()
934 dev_warn(&card->gdev->dev, qeth_l3_register_addr_entry()
940 static int qeth_l3_deregister_addr_entry(struct qeth_card *card, qeth_l3_deregister_addr_entry() argument
946 QETH_CARD_TEXT(card, 2, "deladdr4"); qeth_l3_deregister_addr_entry()
947 QETH_CARD_HEX(card, 3, &addr->u.a4.addr, sizeof(int)); qeth_l3_deregister_addr_entry()
949 QETH_CARD_TEXT(card, 2, "deladdr6"); qeth_l3_deregister_addr_entry()
950 QETH_CARD_HEX(card, 3, &addr->u.a6.addr, 8); qeth_l3_deregister_addr_entry()
951 QETH_CARD_HEX(card, 3, ((char *)&addr->u.a6.addr) + 8, 8); qeth_l3_deregister_addr_entry()
953 QETH_CARD_TEXT(card, 2, "deladdr?"); qeth_l3_deregister_addr_entry()
954 QETH_CARD_HEX(card, 3, addr, sizeof(struct qeth_ipaddr)); qeth_l3_deregister_addr_entry()
957 rc = qeth_l3_send_setdelmc(card, addr, IPA_CMD_DELIPM); qeth_l3_deregister_addr_entry()
959 rc = qeth_l3_send_setdelip(card, addr, IPA_CMD_DELIP, qeth_l3_deregister_addr_entry()
962 QETH_CARD_TEXT(card, 2, "failed"); qeth_l3_deregister_addr_entry()
988 static int qeth_l3_setadapter_parms(struct qeth_card *card) qeth_l3_setadapter_parms() argument
994 if (!qeth_is_supported(card, IPA_SETADAPTERPARMS)) { qeth_l3_setadapter_parms()
995 dev_info(&card->gdev->dev, qeth_l3_setadapter_parms()
1000 rc = qeth_query_setadapterparms(card); qeth_l3_setadapter_parms()
1003 "0x%x\n", dev_name(&card->gdev->dev), rc); qeth_l3_setadapter_parms()
1006 if (qeth_adp_supported(card, IPA_SETADP_ALTER_MAC_ADDRESS)) { qeth_l3_setadapter_parms()
1007 rc = qeth_setadpparms_change_macaddr(card); qeth_l3_setadapter_parms()
1009 dev_warn(&card->gdev->dev, "Reading the adapter MAC" qeth_l3_setadapter_parms()
1016 static int qeth_l3_default_setassparms_cb(struct qeth_card *card, qeth_l3_default_setassparms_cb() argument
1021 QETH_CARD_TEXT(card, 4, "defadpcb"); qeth_l3_default_setassparms_cb()
1027 card->options.ipa4.enabled_funcs = cmd->hdr.ipa_enabled; qeth_l3_default_setassparms_cb()
1029 card->options.ipa6.enabled_funcs = cmd->hdr.ipa_enabled; qeth_l3_default_setassparms_cb()
1033 card->info.csum_mask = cmd->data.setassparms.data.flags_32bit; qeth_l3_default_setassparms_cb()
1034 QETH_CARD_TEXT_(card, 3, "csum:%d", card->info.csum_mask); qeth_l3_default_setassparms_cb()
1038 card->info.tx_csum_mask = qeth_l3_default_setassparms_cb()
1040 QETH_CARD_TEXT_(card, 3, "tcsu:%d", card->info.tx_csum_mask); qeth_l3_default_setassparms_cb()
1047 struct qeth_card *card, enum qeth_ipa_funcs ipa_func, __u16 cmd_code, qeth_l3_get_setassparms_cmd()
1053 QETH_CARD_TEXT(card, 4, "getasscm"); qeth_l3_get_setassparms_cmd()
1054 iob = qeth_get_ipacmd_buffer(card, IPA_CMD_SETASSPARMS, prot); qeth_l3_get_setassparms_cmd()
1068 static int qeth_l3_send_setassparms(struct qeth_card *card, qeth_l3_send_setassparms() argument
1077 QETH_CARD_TEXT(card, 4, "sendassp"); qeth_l3_send_setassparms()
1085 rc = qeth_send_ipa_cmd(card, iob, reply_cb, reply_param); qeth_l3_send_setassparms()
1090 static int qeth_l3_send_simple_setassparms_ipv6(struct qeth_card *card, qeth_l3_send_simple_setassparms_ipv6() argument
1096 QETH_CARD_TEXT(card, 4, "simassp6"); qeth_l3_send_simple_setassparms_ipv6()
1097 iob = qeth_l3_get_setassparms_cmd(card, ipa_func, cmd_code, qeth_l3_send_simple_setassparms_ipv6()
1101 rc = qeth_l3_send_setassparms(card, iob, 0, 0, qeth_l3_send_simple_setassparms_ipv6()
1107 static int qeth_l3_send_simple_setassparms(struct qeth_card *card, qeth_l3_send_simple_setassparms() argument
1114 QETH_CARD_TEXT(card, 4, "simassp4"); qeth_l3_send_simple_setassparms()
1117 iob = qeth_l3_get_setassparms_cmd(card, ipa_func, cmd_code, qeth_l3_send_simple_setassparms()
1121 rc = qeth_l3_send_setassparms(card, iob, length, data, qeth_l3_send_simple_setassparms()
1126 static int qeth_l3_start_ipa_arp_processing(struct qeth_card *card) qeth_l3_start_ipa_arp_processing() argument
1130 QETH_CARD_TEXT(card, 3, "ipaarp"); qeth_l3_start_ipa_arp_processing()
1132 if (!qeth_is_supported(card, IPA_ARP_PROCESSING)) { qeth_l3_start_ipa_arp_processing()
1133 dev_info(&card->gdev->dev, qeth_l3_start_ipa_arp_processing()
1135 QETH_CARD_IFNAME(card)); qeth_l3_start_ipa_arp_processing()
1138 rc = qeth_l3_send_simple_setassparms(card, IPA_ARP_PROCESSING, qeth_l3_start_ipa_arp_processing()
1141 dev_warn(&card->gdev->dev, qeth_l3_start_ipa_arp_processing()
1143 QETH_CARD_IFNAME(card)); qeth_l3_start_ipa_arp_processing()
1148 static int qeth_l3_start_ipa_ip_fragmentation(struct qeth_card *card) qeth_l3_start_ipa_ip_fragmentation() argument
1152 QETH_CARD_TEXT(card, 3, "ipaipfrg"); qeth_l3_start_ipa_ip_fragmentation()
1154 if (!qeth_is_supported(card, IPA_IP_FRAGMENTATION)) { qeth_l3_start_ipa_ip_fragmentation()
1155 dev_info(&card->gdev->dev, qeth_l3_start_ipa_ip_fragmentation()
1157 QETH_CARD_IFNAME(card)); qeth_l3_start_ipa_ip_fragmentation()
1161 rc = qeth_l3_send_simple_setassparms(card, IPA_IP_FRAGMENTATION, qeth_l3_start_ipa_ip_fragmentation()
1164 dev_warn(&card->gdev->dev, qeth_l3_start_ipa_ip_fragmentation()
1166 QETH_CARD_IFNAME(card)); qeth_l3_start_ipa_ip_fragmentation()
1168 dev_info(&card->gdev->dev, qeth_l3_start_ipa_ip_fragmentation()
1173 static int qeth_l3_start_ipa_source_mac(struct qeth_card *card) qeth_l3_start_ipa_source_mac() argument
1177 QETH_CARD_TEXT(card, 3, "stsrcmac"); qeth_l3_start_ipa_source_mac()
1179 if (!qeth_is_supported(card, IPA_SOURCE_MAC)) { qeth_l3_start_ipa_source_mac()
1180 dev_info(&card->gdev->dev, qeth_l3_start_ipa_source_mac()
1182 QETH_CARD_IFNAME(card)); qeth_l3_start_ipa_source_mac()
1186 rc = qeth_l3_send_simple_setassparms(card, IPA_SOURCE_MAC, qeth_l3_start_ipa_source_mac()
1189 dev_warn(&card->gdev->dev, qeth_l3_start_ipa_source_mac()
1191 QETH_CARD_IFNAME(card)); qeth_l3_start_ipa_source_mac()
1195 static int qeth_l3_start_ipa_vlan(struct qeth_card *card) qeth_l3_start_ipa_vlan() argument
1199 QETH_CARD_TEXT(card, 3, "strtvlan"); qeth_l3_start_ipa_vlan()
1201 if (!qeth_is_supported(card, IPA_FULL_VLAN)) { qeth_l3_start_ipa_vlan()
1202 dev_info(&card->gdev->dev, qeth_l3_start_ipa_vlan()
1203 "VLAN not supported on %s\n", QETH_CARD_IFNAME(card)); qeth_l3_start_ipa_vlan()
1207 rc = qeth_l3_send_simple_setassparms(card, IPA_VLAN_PRIO, qeth_l3_start_ipa_vlan()
1210 dev_warn(&card->gdev->dev, qeth_l3_start_ipa_vlan()
1212 QETH_CARD_IFNAME(card)); qeth_l3_start_ipa_vlan()
1214 dev_info(&card->gdev->dev, "VLAN enabled\n"); qeth_l3_start_ipa_vlan()
1219 static int qeth_l3_start_ipa_multicast(struct qeth_card *card) qeth_l3_start_ipa_multicast() argument
1223 QETH_CARD_TEXT(card, 3, "stmcast"); qeth_l3_start_ipa_multicast()
1225 if (!qeth_is_supported(card, IPA_MULTICASTING)) { qeth_l3_start_ipa_multicast()
1226 dev_info(&card->gdev->dev, qeth_l3_start_ipa_multicast()
1228 QETH_CARD_IFNAME(card)); qeth_l3_start_ipa_multicast()
1232 rc = qeth_l3_send_simple_setassparms(card, IPA_MULTICASTING, qeth_l3_start_ipa_multicast()
1235 dev_warn(&card->gdev->dev, qeth_l3_start_ipa_multicast()
1237 QETH_CARD_IFNAME(card)); qeth_l3_start_ipa_multicast()
1239 dev_info(&card->gdev->dev, "Multicast enabled\n"); qeth_l3_start_ipa_multicast()
1240 card->dev->flags |= IFF_MULTICAST; qeth_l3_start_ipa_multicast()
1246 static int qeth_l3_softsetup_ipv6(struct qeth_card *card) qeth_l3_softsetup_ipv6() argument
1250 QETH_CARD_TEXT(card, 3, "softipv6"); qeth_l3_softsetup_ipv6()
1252 if (card->info.type == QETH_CARD_TYPE_IQD) qeth_l3_softsetup_ipv6()
1255 rc = qeth_query_ipassists(card, QETH_PROT_IPV6); qeth_l3_softsetup_ipv6()
1257 dev_err(&card->gdev->dev, qeth_l3_softsetup_ipv6()
1259 QETH_CARD_IFNAME(card)); qeth_l3_softsetup_ipv6()
1262 rc = qeth_l3_send_simple_setassparms(card, IPA_IPV6, qeth_l3_softsetup_ipv6()
1265 dev_err(&card->gdev->dev, qeth_l3_softsetup_ipv6()
1267 QETH_CARD_IFNAME(card)); qeth_l3_softsetup_ipv6()
1270 rc = qeth_l3_send_simple_setassparms_ipv6(card, IPA_IPV6, qeth_l3_softsetup_ipv6()
1273 dev_err(&card->gdev->dev, qeth_l3_softsetup_ipv6()
1275 QETH_CARD_IFNAME(card)); qeth_l3_softsetup_ipv6()
1278 rc = qeth_l3_send_simple_setassparms_ipv6(card, IPA_PASSTHRU, qeth_l3_softsetup_ipv6()
1281 dev_warn(&card->gdev->dev, qeth_l3_softsetup_ipv6()
1283 QETH_CARD_IFNAME(card)); qeth_l3_softsetup_ipv6()
1287 dev_info(&card->gdev->dev, "IPV6 enabled\n"); qeth_l3_softsetup_ipv6()
1292 static int qeth_l3_start_ipa_ipv6(struct qeth_card *card) qeth_l3_start_ipa_ipv6() argument
1296 QETH_CARD_TEXT(card, 3, "strtipv6"); qeth_l3_start_ipa_ipv6()
1298 if (!qeth_is_supported(card, IPA_IPV6)) { qeth_l3_start_ipa_ipv6()
1299 dev_info(&card->gdev->dev, qeth_l3_start_ipa_ipv6()
1300 "IPv6 not supported on %s\n", QETH_CARD_IFNAME(card)); qeth_l3_start_ipa_ipv6()
1304 rc = qeth_l3_softsetup_ipv6(card); qeth_l3_start_ipa_ipv6()
1309 static int qeth_l3_start_ipa_broadcast(struct qeth_card *card) qeth_l3_start_ipa_broadcast() argument
1313 QETH_CARD_TEXT(card, 3, "stbrdcst"); qeth_l3_start_ipa_broadcast()
1314 card->info.broadcast_capable = 0; qeth_l3_start_ipa_broadcast()
1315 if (!qeth_is_supported(card, IPA_FILTERING)) { qeth_l3_start_ipa_broadcast()
1316 dev_info(&card->gdev->dev, qeth_l3_start_ipa_broadcast()
1318 QETH_CARD_IFNAME(card)); qeth_l3_start_ipa_broadcast()
1322 rc = qeth_l3_send_simple_setassparms(card, IPA_FILTERING, qeth_l3_start_ipa_broadcast()
1325 dev_warn(&card->gdev->dev, "Enabling broadcast filtering for " qeth_l3_start_ipa_broadcast()
1326 "%s failed\n", QETH_CARD_IFNAME(card)); qeth_l3_start_ipa_broadcast()
1330 rc = qeth_l3_send_simple_setassparms(card, IPA_FILTERING, qeth_l3_start_ipa_broadcast()
1333 dev_warn(&card->gdev->dev, qeth_l3_start_ipa_broadcast()
1335 QETH_CARD_IFNAME(card)); qeth_l3_start_ipa_broadcast()
1338 card->info.broadcast_capable = QETH_BROADCAST_WITH_ECHO; qeth_l3_start_ipa_broadcast()
1339 dev_info(&card->gdev->dev, "Broadcast enabled\n"); qeth_l3_start_ipa_broadcast()
1340 rc = qeth_l3_send_simple_setassparms(card, IPA_FILTERING, qeth_l3_start_ipa_broadcast()
1343 dev_warn(&card->gdev->dev, "Setting up broadcast echo " qeth_l3_start_ipa_broadcast()
1344 "filtering for %s failed\n", QETH_CARD_IFNAME(card)); qeth_l3_start_ipa_broadcast()
1347 card->info.broadcast_capable = QETH_BROADCAST_WITHOUT_ECHO; qeth_l3_start_ipa_broadcast()
1349 if (card->info.broadcast_capable) qeth_l3_start_ipa_broadcast()
1350 card->dev->flags |= IFF_BROADCAST; qeth_l3_start_ipa_broadcast()
1352 card->dev->flags &= ~IFF_BROADCAST; qeth_l3_start_ipa_broadcast()
1356 static int qeth_l3_send_checksum_command(struct qeth_card *card) qeth_l3_send_checksum_command() argument
1360 rc = qeth_l3_send_simple_setassparms(card, IPA_INBOUND_CHECKSUM, qeth_l3_send_checksum_command()
1363 dev_warn(&card->gdev->dev, "Starting HW checksumming for %s " qeth_l3_send_checksum_command()
1365 QETH_CARD_IFNAME(card)); qeth_l3_send_checksum_command()
1368 rc = qeth_l3_send_simple_setassparms(card, IPA_INBOUND_CHECKSUM, qeth_l3_send_checksum_command()
1370 card->info.csum_mask); qeth_l3_send_checksum_command()
1372 dev_warn(&card->gdev->dev, "Enabling HW checksumming for %s " qeth_l3_send_checksum_command()
1374 QETH_CARD_IFNAME(card)); qeth_l3_send_checksum_command()
1380 static int qeth_l3_set_rx_csum(struct qeth_card *card, int on) qeth_l3_set_rx_csum() argument
1385 rc = qeth_l3_send_checksum_command(card); qeth_l3_set_rx_csum()
1388 dev_info(&card->gdev->dev, qeth_l3_set_rx_csum()
1391 rc = qeth_l3_send_simple_setassparms(card, qeth_l3_set_rx_csum()
1400 static int qeth_l3_start_ipa_checksum(struct qeth_card *card) qeth_l3_start_ipa_checksum() argument
1402 QETH_CARD_TEXT(card, 3, "strtcsum"); qeth_l3_start_ipa_checksum()
1404 if (card->dev->features & NETIF_F_RXCSUM) { qeth_l3_start_ipa_checksum()
1407 card->dev->features &= ~NETIF_F_RXCSUM; qeth_l3_start_ipa_checksum()
1408 netdev_update_features(card->dev); qeth_l3_start_ipa_checksum()
1414 static int qeth_l3_start_ipa_tx_checksum(struct qeth_card *card) qeth_l3_start_ipa_tx_checksum() argument
1418 if (!qeth_is_supported(card, IPA_OUTBOUND_CHECKSUM)) qeth_l3_start_ipa_tx_checksum()
1420 rc = qeth_l3_send_simple_setassparms(card, IPA_OUTBOUND_CHECKSUM, qeth_l3_start_ipa_tx_checksum()
1424 rc = qeth_l3_send_simple_setassparms(card, IPA_OUTBOUND_CHECKSUM, qeth_l3_start_ipa_tx_checksum()
1425 IPA_CMD_ASS_ENABLE, card->info.tx_csum_mask); qeth_l3_start_ipa_tx_checksum()
1428 dev_info(&card->gdev->dev, "HW TX Checksumming enabled\n"); qeth_l3_start_ipa_tx_checksum()
1431 dev_warn(&card->gdev->dev, "Enabling HW TX checksumming for %s " qeth_l3_start_ipa_tx_checksum()
1432 "failed, using SW TX checksumming\n", QETH_CARD_IFNAME(card)); qeth_l3_start_ipa_tx_checksum()
1436 static int qeth_l3_start_ipa_tso(struct qeth_card *card) qeth_l3_start_ipa_tso() argument
1440 QETH_CARD_TEXT(card, 3, "sttso"); qeth_l3_start_ipa_tso()
1442 if (!qeth_is_supported(card, IPA_OUTBOUND_TSO)) { qeth_l3_start_ipa_tso()
1443 dev_info(&card->gdev->dev, qeth_l3_start_ipa_tso()
1445 QETH_CARD_IFNAME(card)); qeth_l3_start_ipa_tso()
1448 rc = qeth_l3_send_simple_setassparms(card, IPA_OUTBOUND_TSO, qeth_l3_start_ipa_tso()
1451 dev_warn(&card->gdev->dev, "Starting outbound TCP " qeth_l3_start_ipa_tso()
1453 QETH_CARD_IFNAME(card)); qeth_l3_start_ipa_tso()
1455 dev_info(&card->gdev->dev, qeth_l3_start_ipa_tso()
1459 card->dev->features &= ~NETIF_F_TSO; qeth_l3_start_ipa_tso()
1463 static int qeth_l3_start_ipassists(struct qeth_card *card) qeth_l3_start_ipassists() argument
1465 QETH_CARD_TEXT(card, 3, "strtipas"); qeth_l3_start_ipassists()
1467 if (qeth_set_access_ctrl_online(card, 0)) qeth_l3_start_ipassists()
1469 qeth_l3_start_ipa_arp_processing(card); /* go on*/ qeth_l3_start_ipassists()
1470 qeth_l3_start_ipa_ip_fragmentation(card); /* go on*/ qeth_l3_start_ipassists()
1471 qeth_l3_start_ipa_source_mac(card); /* go on*/ qeth_l3_start_ipassists()
1472 qeth_l3_start_ipa_vlan(card); /* go on*/ qeth_l3_start_ipassists()
1473 qeth_l3_start_ipa_multicast(card); /* go on*/ qeth_l3_start_ipassists()
1474 qeth_l3_start_ipa_ipv6(card); /* go on*/ qeth_l3_start_ipassists()
1475 qeth_l3_start_ipa_broadcast(card); /* go on*/ qeth_l3_start_ipassists()
1476 qeth_l3_start_ipa_checksum(card); /* go on*/ qeth_l3_start_ipassists()
1477 qeth_l3_start_ipa_tx_checksum(card); qeth_l3_start_ipassists()
1478 qeth_l3_start_ipa_tso(card); /* go on*/ qeth_l3_start_ipassists()
1482 static int qeth_l3_iqd_read_initial_mac_cb(struct qeth_card *card, qeth_l3_iqd_read_initial_mac_cb() argument
1489 memcpy(card->dev->dev_addr, qeth_l3_iqd_read_initial_mac_cb()
1492 eth_random_addr(card->dev->dev_addr); qeth_l3_iqd_read_initial_mac_cb()
1497 static int qeth_l3_iqd_read_initial_mac(struct qeth_card *card) qeth_l3_iqd_read_initial_mac() argument
1505 iob = qeth_get_ipacmd_buffer(card, IPA_CMD_CREATE_ADDR, qeth_l3_iqd_read_initial_mac()
1511 card->info.unique_id; qeth_l3_iqd_read_initial_mac()
1513 rc = qeth_send_ipa_cmd(card, iob, qeth_l3_iqd_read_initial_mac_cb, qeth_l3_iqd_read_initial_mac()
1518 static int qeth_l3_get_unique_id_cb(struct qeth_card *card, qeth_l3_get_unique_id_cb() argument
1525 card->info.unique_id = *((__u16 *) qeth_l3_get_unique_id_cb()
1528 card->info.unique_id = UNIQUE_ID_IF_CREATE_ADDR_FAILED | qeth_l3_get_unique_id_cb()
1530 dev_warn(&card->gdev->dev, "The network adapter failed to " qeth_l3_get_unique_id_cb()
1536 static int qeth_l3_get_unique_id(struct qeth_card *card) qeth_l3_get_unique_id() argument
1544 if (!qeth_is_supported(card, IPA_IPV6)) { qeth_l3_get_unique_id()
1545 card->info.unique_id = UNIQUE_ID_IF_CREATE_ADDR_FAILED | qeth_l3_get_unique_id()
1550 iob = qeth_get_ipacmd_buffer(card, IPA_CMD_CREATE_ADDR, qeth_l3_get_unique_id()
1556 card->info.unique_id; qeth_l3_get_unique_id()
1558 rc = qeth_send_ipa_cmd(card, iob, qeth_l3_get_unique_id_cb, NULL); qeth_l3_get_unique_id()
1563 qeth_diags_trace_cb(struct qeth_card *card, struct qeth_reply *reply, qeth_diags_trace_cb() argument
1574 QETH_CARD_TEXT_(card, 2, "dxter%x", rc); qeth_diags_trace_cb()
1582 card->info.promisc_mode = SET_PROMISC_MODE_OFF; qeth_diags_trace_cb()
1583 dev_info(&card->gdev->dev, "The HiperSockets network " qeth_diags_trace_cb()
1593 card->info.promisc_mode = SET_PROMISC_MODE_ON; qeth_diags_trace_cb()
1594 dev_info(&card->gdev->dev, "The HiperSockets network " qeth_diags_trace_cb()
1598 dev_warn(&card->gdev->dev, "The device is not " qeth_diags_trace_cb()
1603 dev_warn(&card->gdev->dev, "A HiperSockets " qeth_diags_trace_cb()
1613 cmd->data.diagass.action, QETH_CARD_IFNAME(card)); qeth_diags_trace_cb()
1620 qeth_diags_trace(struct qeth_card *card, enum qeth_diags_trace_cmds diags_cmd) qeth_diags_trace() argument
1627 iob = qeth_get_ipacmd_buffer(card, IPA_CMD_SET_DIAG_ASS, 0); qeth_diags_trace()
1635 return qeth_send_ipa_cmd(card, iob, qeth_diags_trace_cb, NULL); qeth_diags_trace()
1644 static void qeth_l3_add_mc(struct qeth_card *card, struct in_device *in4_dev) qeth_l3_add_mc() argument
1650 QETH_CARD_TEXT(card, 4, "addmc"); qeth_l3_add_mc()
1660 if (!qeth_l3_add_ip(card, ipm)) qeth_l3_add_mc()
1666 static void qeth_l3_add_vlan_mc(struct qeth_card *card) qeth_l3_add_vlan_mc() argument
1671 QETH_CARD_TEXT(card, 4, "addmcvl"); qeth_l3_add_vlan_mc()
1672 if (!qeth_is_supported(card, IPA_FULL_VLAN)) qeth_l3_add_vlan_mc()
1675 for_each_set_bit(vid, card->active_vlans, VLAN_N_VID) { qeth_l3_add_vlan_mc()
1678 netdev = __vlan_find_dev_deep_rcu(card->dev, htons(ETH_P_8021Q), qeth_l3_add_vlan_mc()
1686 qeth_l3_add_mc(card, in_dev); qeth_l3_add_vlan_mc()
1690 static void qeth_l3_add_multicast_ipv4(struct qeth_card *card) qeth_l3_add_multicast_ipv4() argument
1694 QETH_CARD_TEXT(card, 4, "chkmcv4"); qeth_l3_add_multicast_ipv4()
1696 in4_dev = __in_dev_get_rcu(card->dev); qeth_l3_add_multicast_ipv4()
1699 qeth_l3_add_mc(card, in4_dev); qeth_l3_add_multicast_ipv4()
1700 qeth_l3_add_vlan_mc(card); qeth_l3_add_multicast_ipv4()
1706 static void qeth_l3_add_mc6(struct qeth_card *card, struct inet6_dev *in6_dev) qeth_l3_add_mc6() argument
1712 QETH_CARD_TEXT(card, 4, "addmc6"); qeth_l3_add_mc6()
1722 if (!qeth_l3_add_ip(card, ipm)) qeth_l3_add_mc6()
1728 static void qeth_l3_add_vlan_mc6(struct qeth_card *card) qeth_l3_add_vlan_mc6() argument
1733 QETH_CARD_TEXT(card, 4, "admc6vl"); qeth_l3_add_vlan_mc6()
1734 if (!qeth_is_supported(card, IPA_FULL_VLAN)) qeth_l3_add_vlan_mc6()
1737 for_each_set_bit(vid, card->active_vlans, VLAN_N_VID) { qeth_l3_add_vlan_mc6()
1740 netdev = __vlan_find_dev_deep_rcu(card->dev, htons(ETH_P_8021Q), qeth_l3_add_vlan_mc6()
1749 qeth_l3_add_mc6(card, in_dev); qeth_l3_add_vlan_mc6()
1755 static void qeth_l3_add_multicast_ipv6(struct qeth_card *card) qeth_l3_add_multicast_ipv6() argument
1759 QETH_CARD_TEXT(card, 4, "chkmcv6"); qeth_l3_add_multicast_ipv6()
1760 if (!qeth_is_supported(card, IPA_IPV6)) qeth_l3_add_multicast_ipv6()
1762 in6_dev = in6_dev_get(card->dev); qeth_l3_add_multicast_ipv6()
1767 qeth_l3_add_mc6(card, in6_dev); qeth_l3_add_multicast_ipv6()
1768 qeth_l3_add_vlan_mc6(card); qeth_l3_add_multicast_ipv6()
1775 static void qeth_l3_free_vlan_addresses4(struct qeth_card *card, qeth_l3_free_vlan_addresses4() argument
1783 QETH_CARD_TEXT(card, 4, "frvaddr4"); qeth_l3_free_vlan_addresses4()
1785 netdev = __vlan_find_dev_deep_rcu(card->dev, htons(ETH_P_8021Q), vid); qeth_l3_free_vlan_addresses4()
1797 if (!qeth_l3_delete_ip(card, addr)) qeth_l3_free_vlan_addresses4()
1804 static void qeth_l3_free_vlan_addresses6(struct qeth_card *card, qeth_l3_free_vlan_addresses6() argument
1813 QETH_CARD_TEXT(card, 4, "frvaddr6"); qeth_l3_free_vlan_addresses6()
1815 netdev = __vlan_find_dev_deep_rcu(card->dev, htons(ETH_P_8021Q), vid); qeth_l3_free_vlan_addresses6()
1828 if (!qeth_l3_delete_ip(card, addr)) qeth_l3_free_vlan_addresses6()
1836 static void qeth_l3_free_vlan_addresses(struct qeth_card *card, qeth_l3_free_vlan_addresses() argument
1840 qeth_l3_free_vlan_addresses4(card, vid); qeth_l3_free_vlan_addresses()
1841 qeth_l3_free_vlan_addresses6(card, vid); qeth_l3_free_vlan_addresses()
1848 struct qeth_card *card = dev->ml_priv; qeth_l3_vlan_rx_add_vid() local
1850 set_bit(vid, card->active_vlans); qeth_l3_vlan_rx_add_vid()
1857 struct qeth_card *card = dev->ml_priv; qeth_l3_vlan_rx_kill_vid() local
1860 QETH_CARD_TEXT_(card, 4, "kid:%d", vid); qeth_l3_vlan_rx_kill_vid()
1861 if (qeth_wait_for_threads(card, QETH_RECOVER_THREAD)) { qeth_l3_vlan_rx_kill_vid()
1862 QETH_CARD_TEXT(card, 3, "kidREC"); qeth_l3_vlan_rx_kill_vid()
1865 spin_lock_irqsave(&card->vlanlock, flags); qeth_l3_vlan_rx_kill_vid()
1867 qeth_l3_free_vlan_addresses(card, vid); qeth_l3_vlan_rx_kill_vid()
1868 clear_bit(vid, card->active_vlans); qeth_l3_vlan_rx_kill_vid()
1869 spin_unlock_irqrestore(&card->vlanlock, flags); qeth_l3_vlan_rx_kill_vid()
1870 qeth_l3_set_multicast_list(card->dev); qeth_l3_vlan_rx_kill_vid()
1874 static inline int qeth_l3_rebuild_skb(struct qeth_card *card, qeth_l3_rebuild_skb() argument
1893 tg_addr, card->dev, 0); qeth_l3_rebuild_skb()
1901 memcpy(tg_addr, card->dev->broadcast, qeth_l3_rebuild_skb()
1902 card->dev->addr_len); qeth_l3_rebuild_skb()
1904 card->stats.multicast++; qeth_l3_rebuild_skb()
1908 memcpy(tg_addr, card->dev->broadcast, qeth_l3_rebuild_skb()
1909 card->dev->addr_len); qeth_l3_rebuild_skb()
1910 card->stats.multicast++; qeth_l3_rebuild_skb()
1917 if (card->options.sniffer) qeth_l3_rebuild_skb()
1921 memcpy(tg_addr, card->dev->dev_addr, qeth_l3_rebuild_skb()
1922 card->dev->addr_len); qeth_l3_rebuild_skb()
1925 card->dev->header_ops->create(skb, card->dev, prot, qeth_l3_rebuild_skb()
1927 card->dev->addr_len); qeth_l3_rebuild_skb()
1929 card->dev->header_ops->create(skb, card->dev, prot, qeth_l3_rebuild_skb()
1930 tg_addr, "FAKELL", card->dev->addr_len); qeth_l3_rebuild_skb()
1933 skb->protocol = eth_type_trans(skb, card->dev); qeth_l3_rebuild_skb()
1942 if (card->dev->features & NETIF_F_RXCSUM) { qeth_l3_rebuild_skb()
1957 static int qeth_l3_process_inbound_buffer(struct qeth_card *card, qeth_l3_process_inbound_buffer() argument
1971 skb = qeth_core_get_next_skb(card, qeth_l3_process_inbound_buffer()
1972 &card->qdio.in_q->bufs[card->rx.b_index], qeth_l3_process_inbound_buffer()
1973 &card->rx.b_element, &card->rx.e_offset, &hdr); qeth_l3_process_inbound_buffer()
1978 skb->dev = card->dev; qeth_l3_process_inbound_buffer()
1982 if ((card->info.type == QETH_CARD_TYPE_IQD) && qeth_l3_process_inbound_buffer()
1987 skb->dev = card->dev; qeth_l3_process_inbound_buffer()
1989 card->dev->header_ops->create(skb, card->dev, 0, qeth_l3_process_inbound_buffer()
1990 card->dev->dev_addr, "FAKELL", qeth_l3_process_inbound_buffer()
1991 card->dev->addr_len); qeth_l3_process_inbound_buffer()
1994 is_vlan = qeth_l3_rebuild_skb(card, skb, hdr, qeth_l3_process_inbound_buffer()
1997 if (is_vlan && !card->options.sniffer) qeth_l3_process_inbound_buffer()
2000 napi_gro_receive(&card->napi, skb); qeth_l3_process_inbound_buffer()
2011 QETH_CARD_TEXT(card, 3, "inbunkno"); qeth_l3_process_inbound_buffer()
2017 card->stats.rx_packets++; qeth_l3_process_inbound_buffer()
2018 card->stats.rx_bytes += len; qeth_l3_process_inbound_buffer()
2025 struct qeth_card *card = container_of(napi, struct qeth_card, napi); qeth_l3_poll() local
2031 if (card->options.performance_stats) { qeth_l3_poll()
2032 card->perf_stats.inbound_cnt++; qeth_l3_poll()
2033 card->perf_stats.inbound_start_time = qeth_get_micros(); qeth_l3_poll()
2037 if (!card->rx.b_count) { qeth_l3_poll()
2038 card->rx.qdio_err = 0; qeth_l3_poll()
2039 card->rx.b_count = qdio_get_next_buffers( qeth_l3_poll()
2040 card->data.ccwdev, 0, &card->rx.b_index, qeth_l3_poll()
2041 &card->rx.qdio_err); qeth_l3_poll()
2042 if (card->rx.b_count <= 0) { qeth_l3_poll()
2043 card->rx.b_count = 0; qeth_l3_poll()
2046 card->rx.b_element = qeth_l3_poll()
2047 &card->qdio.in_q->bufs[card->rx.b_index] qeth_l3_poll()
2049 card->rx.e_offset = 0; qeth_l3_poll()
2052 while (card->rx.b_count) { qeth_l3_poll()
2053 buffer = &card->qdio.in_q->bufs[card->rx.b_index]; qeth_l3_poll()
2054 if (!(card->rx.qdio_err && qeth_l3_poll()
2055 qeth_check_qdio_errors(card, buffer->buffer, qeth_l3_poll()
2056 card->rx.qdio_err, "qinerr"))) qeth_l3_poll()
2058 card, new_budget, &done); qeth_l3_poll()
2063 if (card->options.performance_stats) qeth_l3_poll()
2064 card->perf_stats.bufs_rec++; qeth_l3_poll()
2065 qeth_put_buffer_pool_entry(card, qeth_l3_poll()
2067 qeth_queue_input_buffer(card, card->rx.b_index); qeth_l3_poll()
2068 card->rx.b_count--; qeth_l3_poll()
2069 if (card->rx.b_count) { qeth_l3_poll()
2070 card->rx.b_index = qeth_l3_poll()
2071 (card->rx.b_index + 1) % qeth_l3_poll()
2073 card->rx.b_element = qeth_l3_poll()
2074 &card->qdio.in_q qeth_l3_poll()
2075 ->bufs[card->rx.b_index] qeth_l3_poll()
2077 card->rx.e_offset = 0; qeth_l3_poll()
2089 if (qdio_start_irq(card->data.ccwdev, 0)) qeth_l3_poll()
2090 napi_schedule(&card->napi); qeth_l3_poll()
2092 if (card->options.performance_stats) qeth_l3_poll()
2093 card->perf_stats.inbound_time += qeth_get_micros() - qeth_l3_poll()
2094 card->perf_stats.inbound_start_time; qeth_l3_poll()
2099 struct qeth_card *card) qeth_l3_verify_vlan_dev()
2104 for_each_set_bit(vid, card->active_vlans, VLAN_N_VID) { qeth_l3_verify_vlan_dev()
2108 netdev = __vlan_find_dev_deep_rcu(card->dev, htons(ETH_P_8021Q), qeth_l3_verify_vlan_dev()
2117 if (rc && !(vlan_dev_real_dev(dev)->ml_priv == (void *)card)) qeth_l3_verify_vlan_dev()
2125 struct qeth_card *card; qeth_l3_verify_dev() local
2130 list_for_each_entry(card, &qeth_core_card_list.list, list) { qeth_l3_verify_dev()
2131 if (card->dev == dev) { qeth_l3_verify_dev()
2135 rc = qeth_l3_verify_vlan_dev(dev, card); qeth_l3_verify_dev()
2146 struct qeth_card *card = NULL; qeth_l3_get_card_from_dev() local
2151 card = dev->ml_priv; qeth_l3_get_card_from_dev()
2153 card = vlan_dev_real_dev(dev)->ml_priv; qeth_l3_get_card_from_dev()
2154 if (card && card->options.layer2) qeth_l3_get_card_from_dev()
2155 card = NULL; qeth_l3_get_card_from_dev()
2156 if (card) qeth_l3_get_card_from_dev()
2157 QETH_CARD_TEXT_(card, 4, "%d", rc); qeth_l3_get_card_from_dev()
2158 return card ; qeth_l3_get_card_from_dev()
2161 static int qeth_l3_stop_card(struct qeth_card *card, int recovery_mode) qeth_l3_stop_card() argument
2166 QETH_DBF_HEX(SETUP, 2, &card, sizeof(void *)); qeth_l3_stop_card()
2168 qeth_set_allowed_threads(card, 0, 1); qeth_l3_stop_card()
2169 if (card->options.sniffer && qeth_l3_stop_card()
2170 (card->info.promisc_mode == SET_PROMISC_MODE_ON)) qeth_l3_stop_card()
2171 qeth_diags_trace(card, QETH_DIAGS_CMD_TRACE_DISABLE); qeth_l3_stop_card()
2172 if (card->read.state == CH_STATE_UP && qeth_l3_stop_card()
2173 card->write.state == CH_STATE_UP && qeth_l3_stop_card()
2174 (card->state == CARD_STATE_UP)) { qeth_l3_stop_card()
2176 qeth_l3_stop(card->dev); qeth_l3_stop_card()
2179 dev_close(card->dev); qeth_l3_stop_card()
2182 card->state = CARD_STATE_SOFTSETUP; qeth_l3_stop_card()
2184 if (card->state == CARD_STATE_SOFTSETUP) { qeth_l3_stop_card()
2185 qeth_l3_clear_ip_list(card, 1); qeth_l3_stop_card()
2186 qeth_clear_ipacmd_list(card); qeth_l3_stop_card()
2187 card->state = CARD_STATE_HARDSETUP; qeth_l3_stop_card()
2189 if (card->state == CARD_STATE_HARDSETUP) { qeth_l3_stop_card()
2190 qeth_qdio_clear_card(card, 0); qeth_l3_stop_card()
2191 qeth_clear_qdio_buffers(card); qeth_l3_stop_card()
2192 qeth_clear_working_pool_list(card); qeth_l3_stop_card()
2193 card->state = CARD_STATE_DOWN; qeth_l3_stop_card()
2195 if (card->state == CARD_STATE_DOWN) { qeth_l3_stop_card()
2196 qeth_clear_cmd_buffers(&card->read); qeth_l3_stop_card()
2197 qeth_clear_cmd_buffers(&card->write); qeth_l3_stop_card()
2207 qeth_l3_handle_promisc_mode(struct qeth_card *card) qeth_l3_handle_promisc_mode() argument
2209 struct net_device *dev = card->dev; qeth_l3_handle_promisc_mode()
2212 (card->info.promisc_mode == SET_PROMISC_MODE_ON)) || qeth_l3_handle_promisc_mode()
2214 (card->info.promisc_mode == SET_PROMISC_MODE_OFF))) qeth_l3_handle_promisc_mode()
2217 if (card->info.guestlan) { /* Guestlan trace */ qeth_l3_handle_promisc_mode()
2218 if (qeth_adp_supported(card, IPA_SETADP_SET_PROMISC_MODE)) qeth_l3_handle_promisc_mode()
2219 qeth_setadp_promisc_mode(card); qeth_l3_handle_promisc_mode()
2220 } else if (card->options.sniffer && /* HiperSockets trace */ qeth_l3_handle_promisc_mode()
2221 qeth_adp_supported(card, IPA_SETADP_SET_DIAG_ASSIST)) { qeth_l3_handle_promisc_mode()
2223 QETH_CARD_TEXT(card, 3, "+promisc"); qeth_l3_handle_promisc_mode()
2224 qeth_diags_trace(card, QETH_DIAGS_CMD_TRACE_ENABLE); qeth_l3_handle_promisc_mode()
2226 QETH_CARD_TEXT(card, 3, "-promisc"); qeth_l3_handle_promisc_mode()
2227 qeth_diags_trace(card, QETH_DIAGS_CMD_TRACE_DISABLE); qeth_l3_handle_promisc_mode()
2234 struct qeth_card *card = dev->ml_priv; qeth_l3_set_multicast_list() local
2236 QETH_CARD_TEXT(card, 3, "setmulti"); qeth_l3_set_multicast_list()
2237 if (qeth_threads_running(card, QETH_RECOVER_THREAD) && qeth_l3_set_multicast_list()
2238 (card->state != CARD_STATE_UP)) qeth_l3_set_multicast_list()
2240 if (!card->options.sniffer) { qeth_l3_set_multicast_list()
2241 qeth_l3_delete_mc_addresses(card); qeth_l3_set_multicast_list()
2242 qeth_l3_add_multicast_ipv4(card); qeth_l3_set_multicast_list()
2244 qeth_l3_add_multicast_ipv6(card); qeth_l3_set_multicast_list()
2246 qeth_l3_set_ip_addr_list(card); qeth_l3_set_multicast_list()
2247 if (!qeth_adp_supported(card, IPA_SETADP_SET_PROMISC_MODE)) qeth_l3_set_multicast_list()
2250 qeth_l3_handle_promisc_mode(card); qeth_l3_set_multicast_list()
2276 static int qeth_l3_arp_set_no_entries(struct qeth_card *card, int no_entries) qeth_l3_arp_set_no_entries() argument
2281 QETH_CARD_TEXT(card, 3, "arpstnoe"); qeth_l3_arp_set_no_entries()
2288 if (card->info.guestlan) qeth_l3_arp_set_no_entries()
2290 if (!qeth_is_supported(card, IPA_ARP_PROCESSING)) { qeth_l3_arp_set_no_entries()
2293 rc = qeth_l3_send_simple_setassparms(card, IPA_ARP_PROCESSING, qeth_l3_arp_set_no_entries()
2299 "%s: %s (0x%x/%d)\n", QETH_CARD_IFNAME(card), qeth_l3_arp_set_no_entries()
2305 static __u32 get_arp_entry_size(struct qeth_card *card, get_arp_entry_size() argument
2314 QETH_CARD_TEXT(card, 4, "arpev4"); get_arp_entry_size()
2323 QETH_CARD_TEXT(card, 4, "arpev6"); get_arp_entry_size()
2334 QETH_CARD_TEXT(card, 4, "arpinv"); get_arp_entry_size()
2347 static int qeth_l3_arp_query_cb(struct qeth_card *card, qeth_l3_arp_query_cb() argument
2359 QETH_CARD_TEXT(card, 3, "arpquecb"); qeth_l3_arp_query_cb()
2363 QETH_CARD_TEXT_(card, 4, "%i", cmd->hdr.prot_version); qeth_l3_arp_query_cb()
2365 QETH_CARD_TEXT(card, 4, "arpcberr"); qeth_l3_arp_query_cb()
2366 QETH_CARD_TEXT_(card, 4, "%i", cmd->hdr.return_code); qeth_l3_arp_query_cb()
2371 QETH_CARD_TEXT(card, 4, "setaperr"); qeth_l3_arp_query_cb()
2372 QETH_CARD_TEXT_(card, 4, "%i", cmd->hdr.return_code); qeth_l3_arp_query_cb()
2376 QETH_CARD_TEXT_(card, 4, "anoen%i", qdata->no_entries); qeth_l3_arp_query_cb()
2389 QETH_CARD_TEXT(card, 4, "pmis"); qeth_l3_arp_query_cb()
2390 QETH_CARD_TEXT_(card, 4, "%i", etype->ip); qeth_l3_arp_query_cb()
2393 esize = get_arp_entry_size(card, qdata, etype, qeth_l3_arp_query_cb()
2395 QETH_CARD_TEXT_(card, 5, "esz%i", esize); qeth_l3_arp_query_cb()
2400 QETH_CARD_TEXT_(card, 4, "qaer3%i", -ENOMEM); qeth_l3_arp_query_cb()
2416 QETH_CARD_TEXT_(card, 4, "nove%i", qinfo->no_entries); qeth_l3_arp_query_cb()
2423 QETH_CARD_TEXT_(card, 4, "rc%i", 0); qeth_l3_arp_query_cb()
2431 static int qeth_l3_send_ipa_arp_cmd(struct qeth_card *card, qeth_l3_send_ipa_arp_cmd() argument
2437 QETH_CARD_TEXT(card, 4, "sendarp"); qeth_l3_send_ipa_arp_cmd()
2441 &card->token.ulp_connection_r, QETH_MPC_TOKEN_LENGTH); qeth_l3_send_ipa_arp_cmd()
2442 return qeth_send_control_data(card, IPA_PDU_HEADER_SIZE + len, iob, qeth_l3_send_ipa_arp_cmd()
2446 static int qeth_l3_query_arp_cache_info(struct qeth_card *card, qeth_l3_query_arp_cache_info() argument
2455 QETH_CARD_TEXT_(card, 3, "qarpipv%i", prot); qeth_l3_query_arp_cache_info()
2457 iob = qeth_l3_get_setassparms_cmd(card, IPA_ARP_PROCESSING, qeth_l3_query_arp_cache_info()
2467 rc = qeth_l3_send_ipa_arp_cmd(card, iob, qeth_l3_query_arp_cache_info()
2474 "(0x%x/%d)\n", QETH_CARD_IFNAME(card), qeth_l3_query_arp_cache_info()
2481 static int qeth_l3_arp_query(struct qeth_card *card, char __user *udata) qeth_l3_arp_query() argument
2486 QETH_CARD_TEXT(card, 3, "arpquery"); qeth_l3_arp_query()
2488 if (!qeth_is_supported(card,/*IPA_QUERY_ARP_ADDR_INFO*/ qeth_l3_arp_query()
2490 QETH_CARD_TEXT(card, 3, "arpqnsup"); qeth_l3_arp_query()
2505 rc = qeth_l3_query_arp_cache_info(card, QETH_PROT_IPV4, &qinfo); qeth_l3_arp_query()
2514 qeth_l3_query_arp_cache_info(card, QETH_PROT_IPV6, qeth_l3_arp_query()
2519 QETH_CARD_TEXT(card, 4, "qactf"); qeth_l3_arp_query()
2523 QETH_CARD_TEXT(card, 4, "qacts"); qeth_l3_arp_query()
2531 static int qeth_l3_arp_add_entry(struct qeth_card *card, qeth_l3_arp_add_entry() argument
2539 QETH_CARD_TEXT(card, 3, "arpadent"); qeth_l3_arp_add_entry()
2546 if (card->info.guestlan) qeth_l3_arp_add_entry()
2548 if (!qeth_is_supported(card, IPA_ARP_PROCESSING)) { qeth_l3_arp_add_entry()
2552 iob = qeth_l3_get_setassparms_cmd(card, IPA_ARP_PROCESSING, qeth_l3_arp_add_entry()
2558 rc = qeth_l3_send_setassparms(card, iob, qeth_l3_arp_add_entry()
2566 "on %s: %s (0x%x/%d)\n", buf, QETH_CARD_IFNAME(card), qeth_l3_arp_add_entry()
2572 static int qeth_l3_arp_remove_entry(struct qeth_card *card, qeth_l3_arp_remove_entry() argument
2580 QETH_CARD_TEXT(card, 3, "arprment"); qeth_l3_arp_remove_entry()
2587 if (card->info.guestlan) qeth_l3_arp_remove_entry()
2589 if (!qeth_is_supported(card, IPA_ARP_PROCESSING)) { qeth_l3_arp_remove_entry()
2593 iob = qeth_l3_get_setassparms_cmd(card, IPA_ARP_PROCESSING, qeth_l3_arp_remove_entry()
2599 rc = qeth_l3_send_setassparms(card, iob, qeth_l3_arp_remove_entry()
2607 " on %s: %s (0x%x/%d)\n", buf, QETH_CARD_IFNAME(card), qeth_l3_arp_remove_entry()
2613 static int qeth_l3_arp_flush_cache(struct qeth_card *card) qeth_l3_arp_flush_cache() argument
2618 QETH_CARD_TEXT(card, 3, "arpflush"); qeth_l3_arp_flush_cache()
2625 if (card->info.guestlan || (card->info.type == QETH_CARD_TYPE_IQD)) qeth_l3_arp_flush_cache()
2627 if (!qeth_is_supported(card, IPA_ARP_PROCESSING)) { qeth_l3_arp_flush_cache()
2630 rc = qeth_l3_send_simple_setassparms(card, IPA_ARP_PROCESSING, qeth_l3_arp_flush_cache()
2635 "(0x%x/%d)\n", QETH_CARD_IFNAME(card), qeth_l3_arp_flush_cache()
2643 struct qeth_card *card = dev->ml_priv; qeth_l3_do_ioctl() local
2648 if (!card) qeth_l3_do_ioctl()
2651 if (!qeth_card_hw_is_reachable(card)) qeth_l3_do_ioctl()
2660 rc = qeth_l3_arp_set_no_entries(card, rq->ifr_ifru.ifru_ivalue); qeth_l3_do_ioctl()
2667 rc = qeth_l3_arp_query(card, rq->ifr_ifru.ifru_data); qeth_l3_do_ioctl()
2678 rc = qeth_l3_arp_add_entry(card, &arp_entry); qeth_l3_do_ioctl()
2689 rc = qeth_l3_arp_remove_entry(card, &arp_entry); qeth_l3_do_ioctl()
2696 rc = qeth_l3_arp_flush_cache(card); qeth_l3_do_ioctl()
2699 rc = qeth_snmp_command(card, rq->ifr_ifru.ifru_data); qeth_l3_do_ioctl()
2702 if ((card->info.type == QETH_CARD_TYPE_OSD || qeth_l3_do_ioctl()
2703 card->info.type == QETH_CARD_TYPE_OSX) && qeth_l3_do_ioctl()
2704 !card->info.guestlan) qeth_l3_do_ioctl()
2722 rc = qeth_query_oat_command(card, rq->ifr_ifru.ifru_data); qeth_l3_do_ioctl()
2728 QETH_CARD_TEXT_(card, 2, "ioce%d", rc); qeth_l3_do_ioctl()
2732 int inline qeth_l3_get_cast_type(struct qeth_card *card, struct sk_buff *skb) qeth_l3_get_cast_type() argument
2770 switch (card->info.link_type) { qeth_l3_get_cast_type()
2787 static void qeth_l3_fill_af_iucv_hdr(struct qeth_card *card, qeth_l3_fill_af_iucv_hdr() argument
2794 card->dev->header_ops->create(skb, card->dev, 0, qeth_l3_fill_af_iucv_hdr()
2795 card->dev->dev_addr, card->dev->dev_addr, qeth_l3_fill_af_iucv_hdr()
2796 card->dev->addr_len); qeth_l3_fill_af_iucv_hdr()
2811 static void qeth_l3_fill_header(struct qeth_card *card, struct qeth_hdr *hdr, qeth_l3_fill_header() argument
2825 if ((ipv == 4) || (card->info.type == QETH_CARD_TYPE_IQD)) qeth_l3_fill_header()
2856 if (card->info.type == QETH_CARD_TYPE_IQD) qeth_l3_fill_header()
2874 static inline void qeth_l3_hdr_csum(struct qeth_card *card, qeth_l3_hdr_csum() argument
2887 if (card->options.performance_stats) qeth_l3_hdr_csum()
2888 card->perf_stats.tx_csum++; qeth_l3_hdr_csum()
2891 static void qeth_tso_fill_header(struct qeth_card *card, qeth_tso_fill_header() argument
2946 struct qeth_card *card = dev->ml_priv; qeth_l3_hard_start_xmit() local
2949 int cast_type = qeth_l3_get_cast_type(card, skb); qeth_l3_hard_start_xmit()
2951 card->qdio.out_qs[card->qdio.do_prio_queueing qeth_l3_hard_start_xmit()
2952 || (cast_type && card->info.is_multicast_different) ? qeth_l3_hard_start_xmit()
2953 qeth_get_priority_queue(card, skb, ipv, cast_type) : qeth_l3_hard_start_xmit()
2954 card->qdio.default_out_queue]; qeth_l3_hard_start_xmit()
2960 if (((card->info.type == QETH_CARD_TYPE_IQD) && qeth_l3_hard_start_xmit()
2961 (((card->options.cq != QETH_CQ_ENABLED) && !ipv) || qeth_l3_hard_start_xmit()
2962 ((card->options.cq == QETH_CQ_ENABLED) && qeth_l3_hard_start_xmit()
2964 card->options.sniffer) qeth_l3_hard_start_xmit()
2967 if ((card->state != CARD_STATE_UP) || !card->lan_online) { qeth_l3_hard_start_xmit()
2968 card->stats.tx_carrier_errors++; qeth_l3_hard_start_xmit()
2973 (card->info.broadcast_capable == 0)) qeth_l3_hard_start_xmit()
2976 if (card->options.performance_stats) { qeth_l3_hard_start_xmit()
2977 card->perf_stats.outbound_cnt++; qeth_l3_hard_start_xmit()
2978 card->perf_stats.outbound_start_time = qeth_get_micros(); qeth_l3_hard_start_xmit()
2983 if ((card->info.type == QETH_CARD_TYPE_IQD) && (!large_send) && qeth_l3_hard_start_xmit()
3002 if (card->info.type == QETH_CARD_TYPE_IQD) { qeth_l3_hard_start_xmit()
3032 if (card->options.performance_stats) qeth_l3_hard_start_xmit()
3033 card->perf_stats.tx_lin++; qeth_l3_hard_start_xmit()
3041 qeth_l3_fill_header(card, hdr, new_skb, ipv, cast_type); qeth_l3_hard_start_xmit()
3042 qeth_tso_fill_header(card, hdr, new_skb); qeth_l3_hard_start_xmit()
3048 qeth_l3_fill_header(card, hdr, new_skb, ipv, qeth_l3_hard_start_xmit()
3052 qeth_l3_fill_af_iucv_hdr(card, hdr, new_skb); qeth_l3_hard_start_xmit()
3054 qeth_l3_fill_header(card, hdr, new_skb, ipv, qeth_l3_hard_start_xmit()
3061 qeth_l3_hdr_csum(card, hdr, new_skb); qeth_l3_hard_start_xmit()
3064 elems = qeth_get_elements_no(card, new_skb, elements_needed); qeth_l3_hard_start_xmit()
3073 if (card->info.type != QETH_CARD_TYPE_IQD) { qeth_l3_hard_start_xmit()
3084 rc = qeth_do_send_packet(card, queue, new_skb, hdr, qeth_l3_hard_start_xmit()
3087 rc = qeth_do_send_packet_fast(card, queue, new_skb, hdr, qeth_l3_hard_start_xmit()
3091 card->stats.tx_packets++; qeth_l3_hard_start_xmit()
3092 card->stats.tx_bytes += tx_bytes; qeth_l3_hard_start_xmit()
3095 if (card->options.performance_stats) { qeth_l3_hard_start_xmit()
3097 card->perf_stats.large_send_bytes += tx_bytes; qeth_l3_hard_start_xmit()
3098 card->perf_stats.large_send_cnt++; qeth_l3_hard_start_xmit()
3101 card->perf_stats.sg_skbs_sent++; qeth_l3_hard_start_xmit()
3103 card->perf_stats.sg_frags_sent += nr_frags + 1; qeth_l3_hard_start_xmit()
3120 if (card->options.performance_stats) qeth_l3_hard_start_xmit()
3121 card->perf_stats.outbound_time += qeth_get_micros() - qeth_l3_hard_start_xmit()
3122 card->perf_stats.outbound_start_time; qeth_l3_hard_start_xmit()
3126 card->stats.tx_dropped++; qeth_l3_hard_start_xmit()
3127 card->stats.tx_errors++; qeth_l3_hard_start_xmit()
3137 struct qeth_card *card = dev->ml_priv; __qeth_l3_open() local
3140 QETH_CARD_TEXT(card, 4, "qethopen"); __qeth_l3_open()
3141 if (card->state == CARD_STATE_UP) __qeth_l3_open()
3143 if (card->state != CARD_STATE_SOFTSETUP) __qeth_l3_open()
3145 card->data.state = CH_STATE_UP; __qeth_l3_open()
3146 card->state = CARD_STATE_UP; __qeth_l3_open()
3149 if (qdio_stop_irq(card->data.ccwdev, 0) >= 0) { __qeth_l3_open()
3150 napi_enable(&card->napi); __qeth_l3_open()
3151 napi_schedule(&card->napi); __qeth_l3_open()
3159 struct qeth_card *card = dev->ml_priv; qeth_l3_open() local
3161 QETH_CARD_TEXT(card, 5, "qethope_"); qeth_l3_open()
3162 if (qeth_wait_for_threads(card, QETH_RECOVER_THREAD)) { qeth_l3_open()
3163 QETH_CARD_TEXT(card, 3, "openREC"); qeth_l3_open()
3171 struct qeth_card *card = dev->ml_priv; qeth_l3_stop() local
3173 QETH_CARD_TEXT(card, 4, "qethstop"); qeth_l3_stop()
3175 if (card->state == CARD_STATE_UP) { qeth_l3_stop()
3176 card->state = CARD_STATE_SOFTSETUP; qeth_l3_stop()
3177 napi_disable(&card->napi); qeth_l3_stop()
3185 struct qeth_card *card = dev->ml_priv; qeth_l3_fix_features() local
3187 if (!qeth_is_supported(card, IPA_OUTBOUND_CHECKSUM)) qeth_l3_fix_features()
3189 if (!qeth_is_supported(card, IPA_OUTBOUND_TSO)) qeth_l3_fix_features()
3191 if (!qeth_is_supported(card, IPA_INBOUND_CHECKSUM)) qeth_l3_fix_features()
3200 struct qeth_card *card = dev->ml_priv; qeth_l3_set_features() local
3207 if (card->state == CARD_STATE_DOWN || qeth_l3_set_features()
3208 card->state == CARD_STATE_RECOVER) qeth_l3_set_features()
3211 err = qeth_l3_set_rx_csum(card, features & NETIF_F_RXCSUM); qeth_l3_set_features()
3284 static int qeth_l3_setup_netdev(struct qeth_card *card) qeth_l3_setup_netdev() argument
3288 if (card->info.type == QETH_CARD_TYPE_OSD || qeth_l3_setup_netdev()
3289 card->info.type == QETH_CARD_TYPE_OSX) { qeth_l3_setup_netdev()
3290 if ((card->info.link_type == QETH_LINK_TYPE_LANE_TR) || qeth_l3_setup_netdev()
3291 (card->info.link_type == QETH_LINK_TYPE_HSTR)) { qeth_l3_setup_netdev()
3295 card->dev = alloc_etherdev(0); qeth_l3_setup_netdev()
3296 if (!card->dev) qeth_l3_setup_netdev()
3298 card->dev->netdev_ops = &qeth_l3_osa_netdev_ops; qeth_l3_setup_netdev()
3301 qeth_l3_get_unique_id(card); qeth_l3_setup_netdev()
3302 if (!(card->info.unique_id & UNIQUE_ID_NOT_BY_CARD)) qeth_l3_setup_netdev()
3303 card->dev->dev_id = card->info.unique_id & qeth_l3_setup_netdev()
3305 if (!card->info.guestlan) { qeth_l3_setup_netdev()
3306 card->dev->hw_features = NETIF_F_SG | qeth_l3_setup_netdev()
3309 card->dev->features = NETIF_F_RXCSUM; qeth_l3_setup_netdev()
3312 } else if (card->info.type == QETH_CARD_TYPE_IQD) { qeth_l3_setup_netdev()
3313 card->dev = alloc_netdev(0, "hsi%d", NET_NAME_UNKNOWN, qeth_l3_setup_netdev()
3315 if (!card->dev) qeth_l3_setup_netdev()
3317 card->dev->flags |= IFF_NOARP; qeth_l3_setup_netdev()
3318 card->dev->netdev_ops = &qeth_l3_netdev_ops; qeth_l3_setup_netdev()
3319 rc = qeth_l3_iqd_read_initial_mac(card); qeth_l3_setup_netdev()
3322 if (card->options.hsuid[0]) qeth_l3_setup_netdev()
3323 memcpy(card->dev->perm_addr, card->options.hsuid, 9); qeth_l3_setup_netdev()
3327 card->dev->ml_priv = card; qeth_l3_setup_netdev()
3328 card->dev->watchdog_timeo = QETH_TX_TIMEOUT; qeth_l3_setup_netdev()
3329 card->dev->mtu = card->info.initial_mtu; qeth_l3_setup_netdev()
3330 card->dev->ethtool_ops = &qeth_l3_ethtool_ops; qeth_l3_setup_netdev()
3331 card->dev->features |= NETIF_F_HW_VLAN_CTAG_TX | qeth_l3_setup_netdev()
3334 netif_keep_dst(card->dev); qeth_l3_setup_netdev()
3335 card->dev->gso_max_size = 15 * PAGE_SIZE; qeth_l3_setup_netdev()
3337 SET_NETDEV_DEV(card->dev, &card->gdev->dev); qeth_l3_setup_netdev()
3338 netif_napi_add(card->dev, &card->napi, qeth_l3_poll, QETH_NAPI_WEIGHT); qeth_l3_setup_netdev()
3339 return register_netdev(card->dev); qeth_l3_setup_netdev()
3344 struct qeth_card *card = dev_get_drvdata(&gdev->dev); qeth_l3_probe_device() local
3347 card->options.layer2 = 0; qeth_l3_probe_device()
3348 card->info.hwtrap = 0; qeth_l3_probe_device()
3354 struct qeth_card *card = dev_get_drvdata(&cgdev->dev); qeth_l3_remove_device() local
3358 qeth_set_allowed_threads(card, 0, 1); qeth_l3_remove_device()
3359 wait_event(card->wait_q, qeth_threads_running(card, 0xffffffff) == 0); qeth_l3_remove_device()
3364 if (card->dev) { qeth_l3_remove_device()
3365 unregister_netdev(card->dev); qeth_l3_remove_device()
3366 card->dev = NULL; qeth_l3_remove_device()
3369 qeth_l3_clear_ip_list(card, 0); qeth_l3_remove_device()
3370 qeth_l3_clear_ipato_list(card); qeth_l3_remove_device()
3376 struct qeth_card *card = dev_get_drvdata(&gdev->dev); __qeth_l3_set_online() local
3380 mutex_lock(&card->discipline_mutex); __qeth_l3_set_online()
3381 mutex_lock(&card->conf_mutex); __qeth_l3_set_online()
3383 QETH_DBF_HEX(SETUP, 2, &card, sizeof(void *)); __qeth_l3_set_online()
3385 recover_flag = card->state; __qeth_l3_set_online()
3386 rc = qeth_core_hardsetup_card(card); __qeth_l3_set_online()
3393 if (!card->dev && qeth_l3_setup_netdev(card)) { __qeth_l3_set_online()
3398 if (qeth_is_diagass_supported(card, QETH_DIAGS_CMD_TRAP)) { __qeth_l3_set_online()
3399 if (card->info.hwtrap && __qeth_l3_set_online()
3400 qeth_hw_trap(card, QETH_DIAGS_TRAP_ARM)) __qeth_l3_set_online()
3401 card->info.hwtrap = 0; __qeth_l3_set_online()
3403 card->info.hwtrap = 0; __qeth_l3_set_online()
3405 card->state = CARD_STATE_HARDSETUP; __qeth_l3_set_online()
3406 memset(&card->rx, 0, sizeof(struct qeth_rx)); __qeth_l3_set_online()
3407 qeth_print_status_message(card); __qeth_l3_set_online()
3412 rc = qeth_send_startlan(card); __qeth_l3_set_online()
3416 dev_warn(&card->gdev->dev, __qeth_l3_set_online()
3418 card->lan_online = 0; __qeth_l3_set_online()
3424 card->lan_online = 1; __qeth_l3_set_online()
3427 rc = qeth_l3_setadapter_parms(card); __qeth_l3_set_online()
3430 if (!card->options.sniffer) { __qeth_l3_set_online()
3431 rc = qeth_l3_start_ipassists(card); __qeth_l3_set_online()
3436 rc = qeth_l3_setrouting_v4(card); __qeth_l3_set_online()
3439 rc = qeth_l3_setrouting_v6(card); __qeth_l3_set_online()
3443 netif_tx_disable(card->dev); __qeth_l3_set_online()
3445 rc = qeth_init_qdio_queues(card); __qeth_l3_set_online()
3451 card->state = CARD_STATE_SOFTSETUP; __qeth_l3_set_online()
3453 qeth_set_allowed_threads(card, 0xffffffff, 0); __qeth_l3_set_online()
3454 qeth_l3_set_ip_addr_list(card); __qeth_l3_set_online()
3455 if (card->lan_online) __qeth_l3_set_online()
3456 netif_carrier_on(card->dev); __qeth_l3_set_online()
3458 netif_carrier_off(card->dev); __qeth_l3_set_online()
3462 __qeth_l3_open(card->dev); __qeth_l3_set_online()
3464 dev_open(card->dev); __qeth_l3_set_online()
3465 qeth_l3_set_multicast_list(card->dev); __qeth_l3_set_online()
3468 qeth_trace_features(card); __qeth_l3_set_online()
3471 mutex_unlock(&card->conf_mutex); __qeth_l3_set_online()
3472 mutex_unlock(&card->discipline_mutex); __qeth_l3_set_online()
3475 qeth_l3_stop_card(card, 0); __qeth_l3_set_online()
3476 ccw_device_set_offline(CARD_DDEV(card)); __qeth_l3_set_online()
3477 ccw_device_set_offline(CARD_WDEV(card)); __qeth_l3_set_online()
3478 ccw_device_set_offline(CARD_RDEV(card)); __qeth_l3_set_online()
3479 qdio_free(CARD_DDEV(card)); __qeth_l3_set_online()
3481 card->state = CARD_STATE_RECOVER; __qeth_l3_set_online()
3483 card->state = CARD_STATE_DOWN; __qeth_l3_set_online()
3484 mutex_unlock(&card->conf_mutex); __qeth_l3_set_online()
3485 mutex_unlock(&card->discipline_mutex); __qeth_l3_set_online()
3497 struct qeth_card *card = dev_get_drvdata(&cgdev->dev); __qeth_l3_set_offline() local
3501 mutex_lock(&card->discipline_mutex); __qeth_l3_set_offline()
3502 mutex_lock(&card->conf_mutex); __qeth_l3_set_offline()
3504 QETH_DBF_HEX(SETUP, 3, &card, sizeof(void *)); __qeth_l3_set_offline()
3506 if (card->dev && netif_carrier_ok(card->dev)) __qeth_l3_set_offline()
3507 netif_carrier_off(card->dev); __qeth_l3_set_offline()
3508 recover_flag = card->state; __qeth_l3_set_offline()
3509 if ((!recovery_mode && card->info.hwtrap) || card->info.hwtrap == 2) { __qeth_l3_set_offline()
3510 qeth_hw_trap(card, QETH_DIAGS_TRAP_DISARM); __qeth_l3_set_offline()
3511 card->info.hwtrap = 1; __qeth_l3_set_offline()
3513 qeth_l3_stop_card(card, recovery_mode); __qeth_l3_set_offline()
3514 if ((card->options.cq == QETH_CQ_ENABLED) && card->dev) { __qeth_l3_set_offline()
3516 call_netdevice_notifiers(NETDEV_REBOOT, card->dev); __qeth_l3_set_offline()
3519 rc = ccw_device_set_offline(CARD_DDEV(card)); __qeth_l3_set_offline()
3520 rc2 = ccw_device_set_offline(CARD_WDEV(card)); __qeth_l3_set_offline()
3521 rc3 = ccw_device_set_offline(CARD_RDEV(card)); __qeth_l3_set_offline()
3526 qdio_free(CARD_DDEV(card)); __qeth_l3_set_offline()
3528 card->state = CARD_STATE_RECOVER; __qeth_l3_set_offline()
3531 mutex_unlock(&card->conf_mutex); __qeth_l3_set_offline()
3532 mutex_unlock(&card->discipline_mutex); __qeth_l3_set_offline()
3543 struct qeth_card *card; qeth_l3_recover() local
3546 card = (struct qeth_card *) ptr; qeth_l3_recover()
3547 QETH_CARD_TEXT(card, 2, "recover1"); qeth_l3_recover()
3548 QETH_CARD_HEX(card, 2, &card, sizeof(void *)); qeth_l3_recover()
3549 if (!qeth_do_run_thread(card, QETH_RECOVER_THREAD)) qeth_l3_recover()
3551 QETH_CARD_TEXT(card, 2, "recover2"); qeth_l3_recover()
3552 dev_warn(&card->gdev->dev, qeth_l3_recover()
3554 qeth_set_recovery_task(card); qeth_l3_recover()
3555 __qeth_l3_set_offline(card->gdev, 1); qeth_l3_recover()
3556 rc = __qeth_l3_set_online(card->gdev, 1); qeth_l3_recover()
3558 dev_info(&card->gdev->dev, qeth_l3_recover()
3561 qeth_close_dev(card); qeth_l3_recover()
3562 dev_warn(&card->gdev->dev, "The qeth device driver " qeth_l3_recover()
3565 qeth_clear_recovery_task(card); qeth_l3_recover()
3566 qeth_clear_thread_start_bit(card, QETH_RECOVER_THREAD); qeth_l3_recover()
3567 qeth_clear_thread_running_bit(card, QETH_RECOVER_THREAD); qeth_l3_recover()
3573 struct qeth_card *card = dev_get_drvdata(&gdev->dev); qeth_l3_shutdown() local
3574 qeth_set_allowed_threads(card, 0, 1); qeth_l3_shutdown()
3575 if ((gdev->state == CCWGROUP_ONLINE) && card->info.hwtrap) qeth_l3_shutdown()
3576 qeth_hw_trap(card, QETH_DIAGS_TRAP_DISARM); qeth_l3_shutdown()
3577 qeth_qdio_clear_card(card, 0); qeth_l3_shutdown()
3578 qeth_clear_qdio_buffers(card); qeth_l3_shutdown()
3579 qdio_free(CARD_DDEV(card)); qeth_l3_shutdown()
3584 struct qeth_card *card = dev_get_drvdata(&gdev->dev); qeth_l3_pm_suspend() local
3586 if (card->dev) qeth_l3_pm_suspend()
3587 netif_device_detach(card->dev); qeth_l3_pm_suspend()
3588 qeth_set_allowed_threads(card, 0, 1); qeth_l3_pm_suspend()
3589 wait_event(card->wait_q, qeth_threads_running(card, 0xffffffff) == 0); qeth_l3_pm_suspend()
3592 if (card->state == CARD_STATE_UP) { qeth_l3_pm_suspend()
3593 if (card->info.hwtrap) qeth_l3_pm_suspend()
3594 qeth_hw_trap(card, QETH_DIAGS_TRAP_DISARM); qeth_l3_pm_suspend()
3595 __qeth_l3_set_offline(card->gdev, 1); qeth_l3_pm_suspend()
3597 __qeth_l3_set_offline(card->gdev, 0); qeth_l3_pm_suspend()
3603 struct qeth_card *card = dev_get_drvdata(&gdev->dev); qeth_l3_pm_resume() local
3609 if (card->state == CARD_STATE_RECOVER) { qeth_l3_pm_resume()
3610 rc = __qeth_l3_set_online(card->gdev, 1); qeth_l3_pm_resume()
3613 dev_close(card->dev); qeth_l3_pm_resume()
3617 rc = __qeth_l3_set_online(card->gdev, 0); qeth_l3_pm_resume()
3619 qeth_set_allowed_threads(card, 0xffffffff, 0); qeth_l3_pm_resume()
3620 if (card->dev) qeth_l3_pm_resume()
3621 netif_device_attach(card->dev); qeth_l3_pm_resume()
3623 dev_warn(&card->gdev->dev, "The qeth device driver " qeth_l3_pm_resume()
3629 static int qeth_l3_control_event(struct qeth_card *card, qeth_l3_control_event() argument
3658 struct qeth_card *card; qeth_l3_ip_event() local
3663 card = qeth_l3_get_card_from_dev(dev); qeth_l3_ip_event()
3664 if (!card) qeth_l3_ip_event()
3666 QETH_CARD_TEXT(card, 3, "ipevent"); qeth_l3_ip_event()
3678 if (!qeth_l3_add_ip(card, addr)) qeth_l3_ip_event()
3682 if (!qeth_l3_delete_ip(card, addr)) qeth_l3_ip_event()
3688 qeth_l3_set_ip_addr_list(card); qeth_l3_ip_event()
3708 struct qeth_card *card; qeth_l3_ip6_event() local
3710 card = qeth_l3_get_card_from_dev(dev); qeth_l3_ip6_event()
3711 if (!card) qeth_l3_ip6_event()
3713 QETH_CARD_TEXT(card, 3, "ip6event"); qeth_l3_ip6_event()
3714 if (!qeth_is_supported(card, IPA_IPV6)) qeth_l3_ip6_event()
3727 if (!qeth_l3_add_ip(card, addr)) qeth_l3_ip6_event()
3731 if (!qeth_l3_delete_ip(card, addr)) qeth_l3_ip6_event()
3737 qeth_l3_set_ip_addr_list(card); qeth_l3_ip6_event()
1046 qeth_l3_get_setassparms_cmd( struct qeth_card *card, enum qeth_ipa_funcs ipa_func, __u16 cmd_code, __u16 len, enum qeth_prot_versions prot) qeth_l3_get_setassparms_cmd() argument
2098 qeth_l3_verify_vlan_dev(struct net_device *dev, struct qeth_card *card) qeth_l3_verify_vlan_dev() argument
H A Dqeth_core_main.c76 int qeth_card_hw_is_reachable(struct qeth_card *card) qeth_card_hw_is_reachable() argument
78 return (card->state == CARD_STATE_SOFTSETUP) || qeth_card_hw_is_reachable()
79 (card->state == CARD_STATE_UP); qeth_card_hw_is_reachable()
85 struct qeth_card *card; qeth_close_dev_handler() local
87 card = container_of(work, struct qeth_card, close_dev_work); qeth_close_dev_handler()
88 QETH_CARD_TEXT(card, 2, "cldevhdl"); qeth_close_dev_handler()
90 dev_close(card->dev); qeth_close_dev_handler()
92 ccwgroup_set_offline(card->gdev); qeth_close_dev_handler()
95 void qeth_close_dev(struct qeth_card *card) qeth_close_dev() argument
97 QETH_CARD_TEXT(card, 2, "cldevsubm"); qeth_close_dev()
98 queue_work(qeth_wq, &card->close_dev_work); qeth_close_dev()
102 static inline const char *qeth_get_cardname(struct qeth_card *card) qeth_get_cardname() argument
104 if (card->info.guestlan) { qeth_get_cardname()
105 switch (card->info.type) { qeth_get_cardname()
118 switch (card->info.type) { qeth_get_cardname()
137 const char *qeth_get_cardname_short(struct qeth_card *card) qeth_get_cardname_short() argument
139 if (card->info.guestlan) { qeth_get_cardname_short()
140 switch (card->info.type) { qeth_get_cardname_short()
153 switch (card->info.type) { qeth_get_cardname_short()
155 switch (card->info.link_type) { qeth_get_cardname_short()
190 void qeth_set_recovery_task(struct qeth_card *card) qeth_set_recovery_task() argument
192 card->recovery_task = current; qeth_set_recovery_task()
196 void qeth_clear_recovery_task(struct qeth_card *card) qeth_clear_recovery_task() argument
198 card->recovery_task = NULL; qeth_clear_recovery_task()
202 static bool qeth_is_recovery_task(const struct qeth_card *card) qeth_is_recovery_task() argument
204 return card->recovery_task == current; qeth_is_recovery_task()
207 void qeth_set_allowed_threads(struct qeth_card *card, unsigned long threads, qeth_set_allowed_threads() argument
212 spin_lock_irqsave(&card->thread_mask_lock, flags); qeth_set_allowed_threads()
213 card->thread_allowed_mask = threads; qeth_set_allowed_threads()
215 card->thread_start_mask &= threads; qeth_set_allowed_threads()
216 spin_unlock_irqrestore(&card->thread_mask_lock, flags); qeth_set_allowed_threads()
217 wake_up(&card->wait_q); qeth_set_allowed_threads()
221 int qeth_threads_running(struct qeth_card *card, unsigned long threads) qeth_threads_running() argument
226 spin_lock_irqsave(&card->thread_mask_lock, flags); qeth_threads_running()
227 rc = (card->thread_running_mask & threads); qeth_threads_running()
228 spin_unlock_irqrestore(&card->thread_mask_lock, flags); qeth_threads_running()
233 int qeth_wait_for_threads(struct qeth_card *card, unsigned long threads) qeth_wait_for_threads() argument
235 if (qeth_is_recovery_task(card)) qeth_wait_for_threads()
237 return wait_event_interruptible(card->wait_q, qeth_wait_for_threads()
238 qeth_threads_running(card, threads) == 0); qeth_wait_for_threads()
242 void qeth_clear_working_pool_list(struct qeth_card *card) qeth_clear_working_pool_list() argument
246 QETH_CARD_TEXT(card, 5, "clwrklst"); qeth_clear_working_pool_list()
248 &card->qdio.in_buf_pool.entry_list, list){ qeth_clear_working_pool_list()
254 static int qeth_alloc_buffer_pool(struct qeth_card *card) qeth_alloc_buffer_pool() argument
260 QETH_CARD_TEXT(card, 5, "alocpool"); qeth_alloc_buffer_pool()
261 for (i = 0; i < card->qdio.init_pool.buf_count; ++i) { qeth_alloc_buffer_pool()
264 qeth_free_buffer_pool(card); qeth_alloc_buffer_pool()
267 for (j = 0; j < QETH_MAX_BUFFER_ELEMENTS(card); ++j) { qeth_alloc_buffer_pool()
274 qeth_free_buffer_pool(card); qeth_alloc_buffer_pool()
280 &card->qdio.init_pool.entry_list); qeth_alloc_buffer_pool()
285 int qeth_realloc_buffer_pool(struct qeth_card *card, int bufcnt) qeth_realloc_buffer_pool() argument
287 QETH_CARD_TEXT(card, 2, "realcbp"); qeth_realloc_buffer_pool()
289 if ((card->state != CARD_STATE_DOWN) && qeth_realloc_buffer_pool()
290 (card->state != CARD_STATE_RECOVER)) qeth_realloc_buffer_pool()
293 /* TODO: steel/add buffers from/to a running card's buffer pool (?) */ qeth_realloc_buffer_pool()
294 qeth_clear_working_pool_list(card); qeth_realloc_buffer_pool()
295 qeth_free_buffer_pool(card); qeth_realloc_buffer_pool()
296 card->qdio.in_buf_pool.buf_count = bufcnt; qeth_realloc_buffer_pool()
297 card->qdio.init_pool.buf_count = bufcnt; qeth_realloc_buffer_pool()
298 return qeth_alloc_buffer_pool(card); qeth_realloc_buffer_pool()
331 static inline int qeth_cq_init(struct qeth_card *card) qeth_cq_init() argument
335 if (card->options.cq == QETH_CQ_ENABLED) { qeth_cq_init()
337 qdio_reset_buffers(card->qdio.c_q->qdio_bufs, qeth_cq_init()
339 card->qdio.c_q->next_buf_to_init = 127; qeth_cq_init()
340 rc = do_QDIO(CARD_DDEV(card), QDIO_FLAG_SYNC_INPUT, qeth_cq_init()
341 card->qdio.no_in_queues - 1, 0, qeth_cq_init()
353 static inline int qeth_alloc_cq(struct qeth_card *card) qeth_alloc_cq() argument
357 if (card->options.cq == QETH_CQ_ENABLED) { qeth_alloc_cq()
362 card->qdio.c_q = qeth_alloc_qdio_queue(); qeth_alloc_cq()
363 if (!card->qdio.c_q) { qeth_alloc_cq()
367 card->qdio.no_in_queues = 2; qeth_alloc_cq()
368 card->qdio.out_bufstates = qeth_alloc_cq()
369 kzalloc(card->qdio.no_out_queues * qeth_alloc_cq()
372 outbuf_states = card->qdio.out_bufstates; qeth_alloc_cq()
377 for (i = 0; i < card->qdio.no_out_queues; ++i) { qeth_alloc_cq()
378 card->qdio.out_qs[i]->bufstates = outbuf_states; qeth_alloc_cq()
383 card->qdio.c_q = NULL; qeth_alloc_cq()
384 card->qdio.no_in_queues = 1; qeth_alloc_cq()
386 QETH_DBF_TEXT_(SETUP, 2, "iqc%d", card->qdio.no_in_queues); qeth_alloc_cq()
391 qeth_free_qdio_queue(card->qdio.c_q); qeth_alloc_cq()
392 card->qdio.c_q = NULL; qeth_alloc_cq()
394 dev_err(&card->gdev->dev, "Failed to create completion queue\n"); qeth_alloc_cq()
398 static inline void qeth_free_cq(struct qeth_card *card) qeth_free_cq() argument
400 if (card->qdio.c_q) { qeth_free_cq()
401 --card->qdio.no_in_queues; qeth_free_cq()
402 qeth_free_qdio_queue(card->qdio.c_q); qeth_free_cq()
403 card->qdio.c_q = NULL; qeth_free_cq()
405 kfree(card->qdio.out_bufstates); qeth_free_cq()
406 card->qdio.out_bufstates = NULL; qeth_free_cq()
436 if (q->card->options.cq != QETH_CQ_ENABLED) qeth_cleanup_handled_pending()
448 QETH_CARD_TEXT(f->q->card, 5, "fp"); qeth_cleanup_handled_pending()
449 QETH_CARD_TEXT_(f->q->card, 5, "%lx", (long) f); qeth_cleanup_handled_pending()
471 QETH_CARD_TEXT(q->card, 2, "clprecov"); qeth_cleanup_handled_pending()
476 static inline void qeth_qdio_handle_aob(struct qeth_card *card, qeth_qdio_handle_aob() argument
483 QETH_CARD_TEXT(card, 5, "haob"); qeth_qdio_handle_aob()
484 QETH_CARD_TEXT_(card, 5, "%lx", phys_aob_addr); qeth_qdio_handle_aob()
486 QETH_CARD_TEXT_(card, 5, "%lx", aob->user1); qeth_qdio_handle_aob()
499 QETH_CARD_TEXT_(card, 2, "aorc%02X", aob->aorc); qeth_qdio_handle_aob()
512 static inline int qeth_is_cq(struct qeth_card *card, unsigned int queue) qeth_is_cq() argument
514 return card->options.cq == QETH_CQ_ENABLED && qeth_is_cq()
515 card->qdio.c_q != NULL && qeth_is_cq()
517 queue == card->qdio.no_in_queues - 1; qeth_is_cq()
521 static int qeth_issue_next_read(struct qeth_card *card) qeth_issue_next_read() argument
526 QETH_CARD_TEXT(card, 5, "issnxrd"); qeth_issue_next_read()
527 if (card->read.state != CH_STATE_UP) qeth_issue_next_read()
529 iob = qeth_get_buffer(&card->read); qeth_issue_next_read()
531 dev_warn(&card->gdev->dev, "The qeth device driver " qeth_issue_next_read()
534 "available\n", dev_name(&card->gdev->dev)); qeth_issue_next_read()
537 qeth_setup_ccw(&card->read, iob->data, QETH_BUFSIZE); qeth_issue_next_read()
538 QETH_CARD_TEXT(card, 6, "noirqpnd"); qeth_issue_next_read()
539 rc = ccw_device_start(card->read.ccwdev, &card->read.ccw, qeth_issue_next_read()
543 "rc=%i\n", dev_name(&card->gdev->dev), rc); qeth_issue_next_read()
544 atomic_set(&card->read.irq_pending, 0); qeth_issue_next_read()
545 card->read_or_write_problem = 1; qeth_issue_next_read()
546 qeth_schedule_recovery(card); qeth_issue_next_read()
547 wake_up(&card->wait_q); qeth_issue_next_read()
552 static struct qeth_reply *qeth_alloc_reply(struct qeth_card *card) qeth_alloc_reply() argument
560 reply->card = card; qeth_alloc_reply()
579 struct qeth_card *card) qeth_issue_ipa_msg()
587 ipa_name, com, dev_name(&card->gdev->dev), qeth_issue_ipa_msg()
588 QETH_CARD_IFNAME(card), rc, qeth_issue_ipa_msg()
592 ipa_name, com, dev_name(&card->gdev->dev), qeth_issue_ipa_msg()
593 QETH_CARD_IFNAME(card)); qeth_issue_ipa_msg()
596 static struct qeth_ipa_cmd *qeth_check_ipa_data(struct qeth_card *card, qeth_check_ipa_data() argument
601 QETH_CARD_TEXT(card, 5, "chkipad"); qeth_check_ipa_data()
610 cmd->hdr.return_code, card); qeth_check_ipa_data()
617 dev_err(&card->gdev->dev, qeth_check_ipa_data()
621 QETH_CARD_IFNAME(card)); qeth_check_ipa_data()
622 qeth_close_dev(card); qeth_check_ipa_data()
624 dev_warn(&card->gdev->dev, qeth_check_ipa_data()
627 QETH_CARD_IFNAME(card), qeth_check_ipa_data()
628 card->info.chpid); qeth_check_ipa_data()
630 cmd->hdr.return_code, card); qeth_check_ipa_data()
632 card->lan_online = 0; qeth_check_ipa_data()
633 if (card->dev && netif_carrier_ok(card->dev)) qeth_check_ipa_data()
634 netif_carrier_off(card->dev); qeth_check_ipa_data()
637 dev_info(&card->gdev->dev, qeth_check_ipa_data()
640 QETH_CARD_IFNAME(card), qeth_check_ipa_data()
641 card->info.chpid); qeth_check_ipa_data()
642 netif_carrier_on(card->dev); qeth_check_ipa_data()
643 card->lan_online = 1; qeth_check_ipa_data()
644 if (card->info.hwtrap) qeth_check_ipa_data()
645 card->info.hwtrap = 2; qeth_check_ipa_data()
646 qeth_schedule_recovery(card); qeth_check_ipa_data()
650 if (card->discipline->control_event_handler qeth_check_ipa_data()
651 (card, cmd)) qeth_check_ipa_data()
658 QETH_CARD_TEXT(card, 3, "irla"); qeth_check_ipa_data()
661 QETH_CARD_TEXT(card, 3, "urla"); qeth_check_ipa_data()
673 void qeth_clear_ipacmd_list(struct qeth_card *card) qeth_clear_ipacmd_list() argument
678 QETH_CARD_TEXT(card, 4, "clipalst"); qeth_clear_ipacmd_list()
680 spin_lock_irqsave(&card->lock, flags); qeth_clear_ipacmd_list()
681 list_for_each_entry_safe(reply, r, &card->cmd_waiter_list, list) { qeth_clear_ipacmd_list()
689 spin_unlock_irqrestore(&card->lock, flags); qeth_clear_ipacmd_list()
690 atomic_set(&card->write.irq_pending, 0); qeth_clear_ipacmd_list()
694 static int qeth_check_idx_response(struct qeth_card *card, qeth_check_idx_response() argument
707 QETH_CARD_TEXT(card, 2, "ckidxres"); qeth_check_idx_response()
708 QETH_CARD_TEXT(card, 2, " idxterm"); qeth_check_idx_response()
709 QETH_CARD_TEXT_(card, 2, " rc%d", -EIO); qeth_check_idx_response()
711 dev_err(&card->gdev->dev, qeth_check_idx_response()
723 struct qeth_card *card = dev_get_drvdata(&((struct ccwgroup_device *) CARD_FROM_CDEV() local
725 return card; CARD_FROM_CDEV()
731 struct qeth_card *card; qeth_setup_ccw() local
733 card = CARD_FROM_CDEV(channel->ccwdev); qeth_setup_ccw()
734 QETH_CARD_TEXT(card, 4, "setupccw"); qeth_setup_ccw()
735 if (channel == &card->read) qeth_setup_ccw()
813 struct qeth_card *card; qeth_send_control_data_cb() local
820 card = CARD_FROM_CDEV(channel->ccwdev); qeth_send_control_data_cb()
821 QETH_CARD_TEXT(card, 4, "sndctlcb"); qeth_send_control_data_cb()
822 rc = qeth_check_idx_response(card, iob->data); qeth_send_control_data_cb()
827 qeth_clear_ipacmd_list(card); qeth_send_control_data_cb()
828 qeth_schedule_recovery(card); qeth_send_control_data_cb()
834 cmd = qeth_check_ipa_data(card, iob); qeth_send_control_data_cb()
835 if ((cmd == NULL) && (card->state != CARD_STATE_DOWN)) qeth_send_control_data_cb()
838 if (card->info.type == QETH_CARD_TYPE_OSN && qeth_send_control_data_cb()
841 card->osn_info.assist_cb != NULL) { qeth_send_control_data_cb()
842 card->osn_info.assist_cb(card->dev, cmd); qeth_send_control_data_cb()
846 spin_lock_irqsave(&card->lock, flags); qeth_send_control_data_cb()
847 list_for_each_entry_safe(reply, r, &card->cmd_waiter_list, list) { qeth_send_control_data_cb()
852 spin_unlock_irqrestore(&card->lock, flags); qeth_send_control_data_cb()
858 keep_reply = reply->callback(card, qeth_send_control_data_cb()
862 keep_reply = reply->callback(card, qeth_send_control_data_cb()
871 spin_lock_irqsave(&card->lock, flags); qeth_send_control_data_cb()
873 &card->cmd_waiter_list); qeth_send_control_data_cb()
874 spin_unlock_irqrestore(&card->lock, flags); qeth_send_control_data_cb()
883 spin_unlock_irqrestore(&card->lock, flags); qeth_send_control_data_cb()
885 memcpy(&card->seqno.pdu_hdr_ack, qeth_send_control_data_cb()
920 static int qeth_set_thread_start_bit(struct qeth_card *card, qeth_set_thread_start_bit() argument
925 spin_lock_irqsave(&card->thread_mask_lock, flags); qeth_set_thread_start_bit()
926 if (!(card->thread_allowed_mask & thread) || qeth_set_thread_start_bit()
927 (card->thread_start_mask & thread)) { qeth_set_thread_start_bit()
928 spin_unlock_irqrestore(&card->thread_mask_lock, flags); qeth_set_thread_start_bit()
931 card->thread_start_mask |= thread; qeth_set_thread_start_bit()
932 spin_unlock_irqrestore(&card->thread_mask_lock, flags); qeth_set_thread_start_bit()
936 void qeth_clear_thread_start_bit(struct qeth_card *card, unsigned long thread) qeth_clear_thread_start_bit() argument
940 spin_lock_irqsave(&card->thread_mask_lock, flags); qeth_clear_thread_start_bit()
941 card->thread_start_mask &= ~thread; qeth_clear_thread_start_bit()
942 spin_unlock_irqrestore(&card->thread_mask_lock, flags); qeth_clear_thread_start_bit()
943 wake_up(&card->wait_q); qeth_clear_thread_start_bit()
947 void qeth_clear_thread_running_bit(struct qeth_card *card, unsigned long thread) qeth_clear_thread_running_bit() argument
951 spin_lock_irqsave(&card->thread_mask_lock, flags); qeth_clear_thread_running_bit()
952 card->thread_running_mask &= ~thread; qeth_clear_thread_running_bit()
953 spin_unlock_irqrestore(&card->thread_mask_lock, flags); qeth_clear_thread_running_bit()
954 wake_up(&card->wait_q); qeth_clear_thread_running_bit()
958 static int __qeth_do_run_thread(struct qeth_card *card, unsigned long thread) __qeth_do_run_thread() argument
963 spin_lock_irqsave(&card->thread_mask_lock, flags); __qeth_do_run_thread()
964 if (card->thread_start_mask & thread) { __qeth_do_run_thread()
965 if ((card->thread_allowed_mask & thread) && __qeth_do_run_thread()
966 !(card->thread_running_mask & thread)) { __qeth_do_run_thread()
968 card->thread_start_mask &= ~thread; __qeth_do_run_thread()
969 card->thread_running_mask |= thread; __qeth_do_run_thread()
973 spin_unlock_irqrestore(&card->thread_mask_lock, flags); __qeth_do_run_thread()
977 int qeth_do_run_thread(struct qeth_card *card, unsigned long thread) qeth_do_run_thread() argument
981 wait_event(card->wait_q, qeth_do_run_thread()
982 (rc = __qeth_do_run_thread(card, thread)) >= 0); qeth_do_run_thread()
987 void qeth_schedule_recovery(struct qeth_card *card) qeth_schedule_recovery() argument
989 QETH_CARD_TEXT(card, 2, "startrec"); qeth_schedule_recovery()
990 if (qeth_set_thread_start_bit(card, QETH_RECOVER_THREAD) == 0) qeth_schedule_recovery()
991 schedule_work(&card->kernel_thread_starter); qeth_schedule_recovery()
999 struct qeth_card *card; qeth_get_problem() local
1004 card = CARD_FROM_CDEV(cdev); qeth_get_problem()
1009 QETH_CARD_TEXT(card, 2, "CGENCHK"); qeth_get_problem()
1022 QETH_CARD_TEXT(card, 2, "REVIND"); qeth_get_problem()
1027 QETH_CARD_TEXT(card, 2, "CMDREJi"); qeth_get_problem()
1031 QETH_CARD_TEXT(card, 2, "AFFE"); qeth_get_problem()
1035 QETH_CARD_TEXT(card, 2, "ZEROSEN"); qeth_get_problem()
1038 QETH_CARD_TEXT(card, 2, "DGENCHK"); qeth_get_problem()
1047 struct qeth_card *card; __qeth_check_irb_error() local
1049 card = CARD_FROM_CDEV(cdev); __qeth_check_irb_error()
1051 if (!card || !IS_ERR(irb)) __qeth_check_irb_error()
1058 QETH_CARD_TEXT(card, 2, "ckirberr"); __qeth_check_irb_error()
1059 QETH_CARD_TEXT_(card, 2, " rc%d", -EIO); __qeth_check_irb_error()
1064 QETH_CARD_TEXT(card, 2, "ckirberr"); __qeth_check_irb_error()
1065 QETH_CARD_TEXT_(card, 2, " rc%d", -ETIMEDOUT); __qeth_check_irb_error()
1067 if (card->data.ccwdev == cdev) { __qeth_check_irb_error()
1068 card->data.state = CH_STATE_DOWN; __qeth_check_irb_error()
1069 wake_up(&card->wait_q); __qeth_check_irb_error()
1076 QETH_CARD_TEXT(card, 2, "ckirberr"); __qeth_check_irb_error()
1077 QETH_CARD_TEXT(card, 2, " rc???"); __qeth_check_irb_error()
1089 struct qeth_card *card; qeth_irq() local
1098 card = CARD_FROM_CDEV(cdev); qeth_irq()
1099 if (!card) qeth_irq()
1102 QETH_CARD_TEXT(card, 5, "irq"); qeth_irq()
1104 if (card->read.ccwdev == cdev) { qeth_irq()
1105 channel = &card->read; qeth_irq()
1106 QETH_CARD_TEXT(card, 5, "read"); qeth_irq()
1107 } else if (card->write.ccwdev == cdev) { qeth_irq()
1108 channel = &card->write; qeth_irq()
1109 QETH_CARD_TEXT(card, 5, "write"); qeth_irq()
1111 channel = &card->data; qeth_irq()
1112 QETH_CARD_TEXT(card, 5, "data"); qeth_irq()
1123 if ((channel == &card->data) && (intparm != 0) && qeth_irq()
1128 QETH_CARD_TEXT(card, 6, "clrchpar"); qeth_irq()
1133 QETH_CARD_TEXT(card, 6, "hltchpar"); qeth_irq()
1158 qeth_clear_ipacmd_list(card); qeth_irq()
1159 qeth_schedule_recovery(card); qeth_irq()
1172 if (channel == &card->data) qeth_irq()
1174 if (channel == &card->read && qeth_irq()
1176 qeth_issue_next_read(card); qeth_irq()
1188 wake_up(&card->wait_q); qeth_irq()
1202 QETH_CARD_TEXT_(q->card, 5, "skbn%d", notification); qeth_notify_skbs()
1203 QETH_CARD_TEXT_(q->card, 5, "%lx", (long) skb); qeth_notify_skbs()
1233 QETH_CARD_TEXT(buf->q->card, 5, "skbr"); qeth_release_skbs()
1234 QETH_CARD_TEXT_(buf->q->card, 5, "%lx", (long) skb); qeth_release_skbs()
1260 for (i = 0; i < QETH_MAX_BUFFER_ELEMENTS(queue->card); ++i) { qeth_clear_output_buffer()
1292 void qeth_clear_qdio_buffers(struct qeth_card *card) qeth_clear_qdio_buffers() argument
1296 QETH_CARD_TEXT(card, 2, "clearqdbf"); qeth_clear_qdio_buffers()
1298 for (i = 0; i < card->qdio.no_out_queues; ++i) { qeth_clear_qdio_buffers()
1299 if (card->qdio.out_qs[i]) { qeth_clear_qdio_buffers()
1300 qeth_clear_outq_buffers(card->qdio.out_qs[i], 0); qeth_clear_qdio_buffers()
1306 static void qeth_free_buffer_pool(struct qeth_card *card) qeth_free_buffer_pool() argument
1311 &card->qdio.init_pool.entry_list, init_list){ qeth_free_buffer_pool()
1312 for (i = 0; i < QETH_MAX_BUFFER_ELEMENTS(card); ++i) qeth_free_buffer_pool()
1328 static void qeth_set_single_write_queues(struct qeth_card *card) qeth_set_single_write_queues() argument
1330 if ((atomic_read(&card->qdio.state) != QETH_QDIO_UNINITIALIZED) && qeth_set_single_write_queues()
1331 (card->qdio.no_out_queues == 4)) qeth_set_single_write_queues()
1332 qeth_free_qdio_buffers(card); qeth_set_single_write_queues()
1334 card->qdio.no_out_queues = 1; qeth_set_single_write_queues()
1335 if (card->qdio.default_out_queue != 0) qeth_set_single_write_queues()
1336 dev_info(&card->gdev->dev, "Priority Queueing not supported\n"); qeth_set_single_write_queues()
1338 card->qdio.default_out_queue = 0; qeth_set_single_write_queues()
1341 static void qeth_set_multiple_write_queues(struct qeth_card *card) qeth_set_multiple_write_queues() argument
1343 if ((atomic_read(&card->qdio.state) != QETH_QDIO_UNINITIALIZED) && qeth_set_multiple_write_queues()
1344 (card->qdio.no_out_queues == 1)) { qeth_set_multiple_write_queues()
1345 qeth_free_qdio_buffers(card); qeth_set_multiple_write_queues()
1346 card->qdio.default_out_queue = 2; qeth_set_multiple_write_queues()
1348 card->qdio.no_out_queues = 4; qeth_set_multiple_write_queues()
1351 static void qeth_update_from_chp_desc(struct qeth_card *card) qeth_update_from_chp_desc() argument
1358 ccwdev = card->data.ccwdev; qeth_update_from_chp_desc()
1363 card->info.func_level = 0x4100 + chp_dsc->desc; qeth_update_from_chp_desc()
1364 if (card->info.type == QETH_CARD_TYPE_IQD) qeth_update_from_chp_desc()
1369 qeth_set_single_write_queues(card); qeth_update_from_chp_desc()
1371 qeth_set_multiple_write_queues(card); qeth_update_from_chp_desc()
1374 QETH_DBF_TEXT_(SETUP, 2, "nr:%x", card->qdio.no_out_queues); qeth_update_from_chp_desc()
1375 QETH_DBF_TEXT_(SETUP, 2, "lvl:%02x", card->info.func_level); qeth_update_from_chp_desc()
1378 static void qeth_init_qdio_info(struct qeth_card *card) qeth_init_qdio_info() argument
1381 atomic_set(&card->qdio.state, QETH_QDIO_UNINITIALIZED); qeth_init_qdio_info()
1383 card->qdio.in_buf_size = QETH_IN_BUF_SIZE_DEFAULT; qeth_init_qdio_info()
1384 if (card->info.type == QETH_CARD_TYPE_IQD) qeth_init_qdio_info()
1385 card->qdio.init_pool.buf_count = QETH_IN_BUF_COUNT_HSDEFAULT; qeth_init_qdio_info()
1387 card->qdio.init_pool.buf_count = QETH_IN_BUF_COUNT_DEFAULT; qeth_init_qdio_info()
1388 card->qdio.in_buf_pool.buf_count = card->qdio.init_pool.buf_count; qeth_init_qdio_info()
1389 INIT_LIST_HEAD(&card->qdio.in_buf_pool.entry_list); qeth_init_qdio_info()
1390 INIT_LIST_HEAD(&card->qdio.init_pool.entry_list); qeth_init_qdio_info()
1393 static void qeth_set_intial_options(struct qeth_card *card) qeth_set_intial_options() argument
1395 card->options.route4.type = NO_ROUTER; qeth_set_intial_options()
1396 card->options.route6.type = NO_ROUTER; qeth_set_intial_options()
1397 card->options.fake_broadcast = 0; qeth_set_intial_options()
1398 card->options.add_hhlen = DEFAULT_ADD_HHLEN; qeth_set_intial_options()
1399 card->options.performance_stats = 0; qeth_set_intial_options()
1400 card->options.rx_sg_cb = QETH_RX_SG_CB; qeth_set_intial_options()
1401 card->options.isolation = ISOLATION_MODE_NONE; qeth_set_intial_options()
1402 card->options.cq = QETH_CQ_DISABLED; qeth_set_intial_options()
1405 static int qeth_do_start_thread(struct qeth_card *card, unsigned long thread) qeth_do_start_thread() argument
1410 spin_lock_irqsave(&card->thread_mask_lock, flags); qeth_do_start_thread()
1411 QETH_CARD_TEXT_(card, 4, " %02x%02x%02x", qeth_do_start_thread()
1412 (u8) card->thread_start_mask, qeth_do_start_thread()
1413 (u8) card->thread_allowed_mask, qeth_do_start_thread()
1414 (u8) card->thread_running_mask); qeth_do_start_thread()
1415 rc = (card->thread_start_mask & thread); qeth_do_start_thread()
1416 spin_unlock_irqrestore(&card->thread_mask_lock, flags); qeth_do_start_thread()
1423 struct qeth_card *card = container_of(work, struct qeth_card, qeth_start_kernel_thread() local
1425 QETH_CARD_TEXT(card , 2, "strthrd"); qeth_start_kernel_thread()
1427 if (card->read.state != CH_STATE_UP && qeth_start_kernel_thread()
1428 card->write.state != CH_STATE_UP) qeth_start_kernel_thread()
1430 if (qeth_do_start_thread(card, QETH_RECOVER_THREAD)) { qeth_start_kernel_thread()
1431 ts = kthread_run(card->discipline->recover, (void *)card, qeth_start_kernel_thread()
1434 qeth_clear_thread_start_bit(card, QETH_RECOVER_THREAD); qeth_start_kernel_thread()
1435 qeth_clear_thread_running_bit(card, qeth_start_kernel_thread()
1442 static int qeth_setup_card(struct qeth_card *card) qeth_setup_card() argument
1446 QETH_DBF_HEX(SETUP, 2, &card, sizeof(void *)); qeth_setup_card()
1448 card->read.state = CH_STATE_DOWN; qeth_setup_card()
1449 card->write.state = CH_STATE_DOWN; qeth_setup_card()
1450 card->data.state = CH_STATE_DOWN; qeth_setup_card()
1451 card->state = CARD_STATE_DOWN; qeth_setup_card()
1452 card->lan_online = 0; qeth_setup_card()
1453 card->read_or_write_problem = 0; qeth_setup_card()
1454 card->dev = NULL; qeth_setup_card()
1455 spin_lock_init(&card->vlanlock); qeth_setup_card()
1456 spin_lock_init(&card->mclock); qeth_setup_card()
1457 spin_lock_init(&card->lock); qeth_setup_card()
1458 spin_lock_init(&card->ip_lock); qeth_setup_card()
1459 spin_lock_init(&card->thread_mask_lock); qeth_setup_card()
1460 mutex_init(&card->conf_mutex); qeth_setup_card()
1461 mutex_init(&card->discipline_mutex); qeth_setup_card()
1462 card->thread_start_mask = 0; qeth_setup_card()
1463 card->thread_allowed_mask = 0; qeth_setup_card()
1464 card->thread_running_mask = 0; qeth_setup_card()
1465 INIT_WORK(&card->kernel_thread_starter, qeth_start_kernel_thread); qeth_setup_card()
1466 INIT_LIST_HEAD(&card->ip_list); qeth_setup_card()
1467 INIT_LIST_HEAD(card->ip_tbd_list); qeth_setup_card()
1468 INIT_LIST_HEAD(&card->cmd_waiter_list); qeth_setup_card()
1469 init_waitqueue_head(&card->wait_q); qeth_setup_card()
1471 qeth_set_intial_options(card); qeth_setup_card()
1473 INIT_LIST_HEAD(&card->ipato.entries); qeth_setup_card()
1474 card->ipato.enabled = 0; qeth_setup_card()
1475 card->ipato.invert4 = 0; qeth_setup_card()
1476 card->ipato.invert6 = 0; qeth_setup_card()
1478 qeth_init_qdio_info(card); qeth_setup_card()
1479 INIT_DELAYED_WORK(&card->buffer_reclaim_work, qeth_buffer_reclaim_work); qeth_setup_card()
1480 INIT_WORK(&card->close_dev_work, qeth_close_dev_handler); qeth_setup_card()
1486 struct qeth_card *card = container_of(slr, struct qeth_card, qeth_core_sl_print() local
1488 if (card->info.mcl_level[0]) qeth_core_sl_print()
1490 CARD_BUS_ID(card), card->info.mcl_level); qeth_core_sl_print()
1495 struct qeth_card *card; qeth_alloc_card() local
1498 card = kzalloc(sizeof(struct qeth_card), GFP_DMA|GFP_KERNEL); qeth_alloc_card()
1499 if (!card) qeth_alloc_card()
1501 QETH_DBF_HEX(SETUP, 2, &card, sizeof(void *)); qeth_alloc_card()
1502 card->ip_tbd_list = kzalloc(sizeof(struct list_head), GFP_KERNEL); qeth_alloc_card()
1503 if (!card->ip_tbd_list) { qeth_alloc_card()
1507 if (qeth_setup_channel(&card->read)) qeth_alloc_card()
1509 if (qeth_setup_channel(&card->write)) qeth_alloc_card()
1511 card->options.layer2 = -1; qeth_alloc_card()
1512 card->qeth_service_level.seq_print = qeth_core_sl_print; qeth_alloc_card()
1513 register_service_level(&card->qeth_service_level); qeth_alloc_card()
1514 return card; qeth_alloc_card()
1517 qeth_clean_channel(&card->read); qeth_alloc_card()
1519 kfree(card->ip_tbd_list); qeth_alloc_card()
1521 kfree(card); qeth_alloc_card()
1526 static int qeth_determine_card_type(struct qeth_card *card) qeth_determine_card_type() argument
1532 card->qdio.do_prio_queueing = QETH_PRIOQ_DEFAULT; qeth_determine_card_type()
1533 card->qdio.default_out_queue = QETH_DEFAULT_QUEUE; qeth_determine_card_type()
1535 if ((CARD_RDEV(card)->id.dev_type == qeth_determine_card_type()
1537 (CARD_RDEV(card)->id.dev_model == qeth_determine_card_type()
1539 card->info.type = known_devices[i][QETH_DEV_MODEL_IND]; qeth_determine_card_type()
1540 card->qdio.no_out_queues = qeth_determine_card_type()
1542 card->qdio.no_in_queues = 1; qeth_determine_card_type()
1543 card->info.is_multicast_different = qeth_determine_card_type()
1545 qeth_update_from_chp_desc(card); qeth_determine_card_type()
1550 card->info.type = QETH_CARD_TYPE_UNKNOWN; qeth_determine_card_type()
1551 dev_err(&card->gdev->dev, "The adapter hardware is of an " qeth_determine_card_type()
1559 struct qeth_card *card; qeth_clear_channel() local
1562 card = CARD_FROM_CDEV(channel->ccwdev); qeth_clear_channel()
1563 QETH_CARD_TEXT(card, 3, "clearch"); qeth_clear_channel()
1570 rc = wait_event_interruptible_timeout(card->wait_q, qeth_clear_channel()
1583 struct qeth_card *card; qeth_halt_channel() local
1586 card = CARD_FROM_CDEV(channel->ccwdev); qeth_halt_channel()
1587 QETH_CARD_TEXT(card, 3, "haltch"); qeth_halt_channel()
1594 rc = wait_event_interruptible_timeout(card->wait_q, qeth_halt_channel()
1603 static int qeth_halt_channels(struct qeth_card *card) qeth_halt_channels() argument
1607 QETH_CARD_TEXT(card, 3, "haltchs"); qeth_halt_channels()
1608 rc1 = qeth_halt_channel(&card->read); qeth_halt_channels()
1609 rc2 = qeth_halt_channel(&card->write); qeth_halt_channels()
1610 rc3 = qeth_halt_channel(&card->data); qeth_halt_channels()
1618 static int qeth_clear_channels(struct qeth_card *card) qeth_clear_channels() argument
1622 QETH_CARD_TEXT(card, 3, "clearchs"); qeth_clear_channels()
1623 rc1 = qeth_clear_channel(&card->read); qeth_clear_channels()
1624 rc2 = qeth_clear_channel(&card->write); qeth_clear_channels()
1625 rc3 = qeth_clear_channel(&card->data); qeth_clear_channels()
1633 static int qeth_clear_halt_card(struct qeth_card *card, int halt) qeth_clear_halt_card() argument
1637 QETH_CARD_TEXT(card, 3, "clhacrd"); qeth_clear_halt_card()
1640 rc = qeth_halt_channels(card); qeth_clear_halt_card()
1643 return qeth_clear_channels(card); qeth_clear_halt_card()
1646 int qeth_qdio_clear_card(struct qeth_card *card, int use_halt) qeth_qdio_clear_card() argument
1650 QETH_CARD_TEXT(card, 3, "qdioclr"); qeth_qdio_clear_card()
1651 switch (atomic_cmpxchg(&card->qdio.state, QETH_QDIO_ESTABLISHED, qeth_qdio_clear_card()
1654 if (card->info.type == QETH_CARD_TYPE_IQD) qeth_qdio_clear_card()
1655 rc = qdio_shutdown(CARD_DDEV(card), qeth_qdio_clear_card()
1658 rc = qdio_shutdown(CARD_DDEV(card), qeth_qdio_clear_card()
1661 QETH_CARD_TEXT_(card, 3, "1err%d", rc); qeth_qdio_clear_card()
1662 atomic_set(&card->qdio.state, QETH_QDIO_ALLOCATED); qeth_qdio_clear_card()
1669 rc = qeth_clear_halt_card(card, use_halt); qeth_qdio_clear_card()
1671 QETH_CARD_TEXT_(card, 3, "2err%d", rc); qeth_qdio_clear_card()
1672 card->state = CARD_STATE_DOWN; qeth_qdio_clear_card()
1677 static int qeth_read_conf_data(struct qeth_card *card, void **buffer, qeth_read_conf_data() argument
1683 struct qeth_channel *channel = &card->data; qeth_read_conf_data()
1707 wait_event(card->wait_q, qeth_read_conf_data()
1725 static void qeth_configure_unitaddr(struct qeth_card *card, char *prcd) qeth_configure_unitaddr() argument
1728 card->info.chpid = prcd[30]; qeth_configure_unitaddr()
1729 card->info.unit_addr2 = prcd[31]; qeth_configure_unitaddr()
1730 card->info.cula = prcd[63]; qeth_configure_unitaddr()
1731 card->info.guestlan = ((prcd[0x10] == _ascebc['V']) && qeth_configure_unitaddr()
1735 static void qeth_configure_blkt_default(struct qeth_card *card, char *prcd) qeth_configure_blkt_default() argument
1741 card->info.blkt.time_total = 0; qeth_configure_blkt_default()
1742 card->info.blkt.inter_packet = 0; qeth_configure_blkt_default()
1743 card->info.blkt.inter_packet_jumbo = 0; qeth_configure_blkt_default()
1745 card->info.blkt.time_total = 250; qeth_configure_blkt_default()
1746 card->info.blkt.inter_packet = 5; qeth_configure_blkt_default()
1747 card->info.blkt.inter_packet_jumbo = 15; qeth_configure_blkt_default()
1751 static void qeth_init_tokens(struct qeth_card *card) qeth_init_tokens() argument
1753 card->token.issuer_rm_w = 0x00010103UL; qeth_init_tokens()
1754 card->token.cm_filter_w = 0x00010108UL; qeth_init_tokens()
1755 card->token.cm_connection_w = 0x0001010aUL; qeth_init_tokens()
1756 card->token.ulp_filter_w = 0x0001010bUL; qeth_init_tokens()
1757 card->token.ulp_connection_w = 0x0001010dUL; qeth_init_tokens()
1760 static void qeth_init_func_level(struct qeth_card *card) qeth_init_func_level() argument
1762 switch (card->info.type) { qeth_init_func_level()
1764 card->info.func_level = QETH_IDX_FUNC_LEVEL_IQD; qeth_init_func_level()
1768 card->info.func_level = QETH_IDX_FUNC_LEVEL_OSD; qeth_init_func_level()
1782 struct qeth_card *card; qeth_idx_activate_get_answer() local
1785 card = CARD_FROM_CDEV(channel->ccwdev); qeth_idx_activate_get_answer()
1794 wait_event(card->wait_q, qeth_idx_activate_get_answer()
1806 wake_up(&card->wait_q); qeth_idx_activate_get_answer()
1809 rc = wait_event_interruptible_timeout(card->wait_q, qeth_idx_activate_get_answer()
1826 struct qeth_card *card; qeth_idx_activate_channel() local
1834 card = CARD_FROM_CDEV(channel->ccwdev); qeth_idx_activate_channel()
1845 if (channel == &card->write) { qeth_idx_activate_channel()
1848 &card->seqno.trans_hdr, QETH_SEQ_NO_LENGTH); qeth_idx_activate_channel()
1849 card->seqno.trans_hdr++; qeth_idx_activate_channel()
1853 &card->seqno.trans_hdr, QETH_SEQ_NO_LENGTH); qeth_idx_activate_channel()
1855 tmp = ((__u8)card->info.portno) | 0x80; qeth_idx_activate_channel()
1858 &card->token.issuer_rm_w, QETH_MPC_TOKEN_LENGTH); qeth_idx_activate_channel()
1860 &card->info.func_level, sizeof(__u16)); qeth_idx_activate_channel()
1861 ccw_device_get_id(CARD_DDEV(card), &temp_devid); qeth_idx_activate_channel()
1863 temp = (card->info.cula << 8) + card->info.unit_addr2; qeth_idx_activate_channel()
1866 wait_event(card->wait_q, qeth_idx_activate_channel()
1879 wake_up(&card->wait_q); qeth_idx_activate_channel()
1882 rc = wait_event_interruptible_timeout(card->wait_q, qeth_idx_activate_channel()
1910 struct qeth_card *card; qeth_idx_write_cb() local
1919 card = CARD_FROM_CDEV(channel->ccwdev); qeth_idx_write_cb()
1923 dev_err(&card->write.ccwdev->dev, qeth_idx_write_cb()
1929 dev_name(&card->write.ccwdev->dev)); qeth_idx_write_cb()
1933 if ((temp & ~0x0100) != qeth_peer_func_level(card->info.func_level)) { qeth_idx_write_cb()
1936 "0x%x)\n", dev_name(&card->write.ccwdev->dev), qeth_idx_write_cb()
1937 card->info.func_level, temp); qeth_idx_write_cb()
1948 struct qeth_card *card; qeth_idx_read_cb() local
1957 card = CARD_FROM_CDEV(channel->ccwdev); qeth_idx_read_cb()
1958 if (qeth_check_idx_response(card, iob->data)) qeth_idx_read_cb()
1964 dev_err(&card->write.ccwdev->dev, qeth_idx_read_cb()
1970 dev_err(&card->read.ccwdev->dev, qeth_idx_read_cb()
1977 dev_name(&card->read.ccwdev->dev)); qeth_idx_read_cb()
1979 QETH_CARD_TEXT_(card, 2, "idxread%c", qeth_idx_read_cb()
1989 (card->info.type == QETH_CARD_TYPE_OSD)) qeth_idx_read_cb()
1990 card->info.portname_required = 1; qeth_idx_read_cb()
1993 if (temp != qeth_peer_func_level(card->info.func_level)) { qeth_idx_read_cb()
1996 dev_name(&card->read.ccwdev->dev), qeth_idx_read_cb()
1997 card->info.func_level, temp); qeth_idx_read_cb()
2000 memcpy(&card->token.issuer_rm_r, qeth_idx_read_cb()
2003 memcpy(&card->info.mcl_level[0], qeth_idx_read_cb()
2010 void qeth_prepare_control_data(struct qeth_card *card, int len, qeth_prepare_control_data() argument
2013 qeth_setup_ccw(&card->write, iob->data, len); qeth_prepare_control_data()
2017 &card->seqno.trans_hdr, QETH_SEQ_NO_LENGTH); qeth_prepare_control_data()
2018 card->seqno.trans_hdr++; qeth_prepare_control_data()
2020 &card->seqno.pdu_hdr, QETH_SEQ_NO_LENGTH); qeth_prepare_control_data()
2021 card->seqno.pdu_hdr++; qeth_prepare_control_data()
2023 &card->seqno.pdu_hdr_ack, QETH_SEQ_NO_LENGTH); qeth_prepare_control_data()
2029 * qeth_send_control_data() - send control command to the card
2030 * @card: qeth_card structure pointer
2053 int qeth_send_control_data(struct qeth_card *card, int len, qeth_send_control_data() argument
2066 QETH_CARD_TEXT(card, 2, "sendctl"); qeth_send_control_data()
2068 if (card->read_or_write_problem) { qeth_send_control_data()
2072 reply = qeth_alloc_reply(card); qeth_send_control_data()
2078 if (card->state == CARD_STATE_DOWN) qeth_send_control_data()
2081 reply->seqno = card->seqno.ipa++; qeth_send_control_data()
2083 spin_lock_irqsave(&card->lock, flags); qeth_send_control_data()
2084 list_add_tail(&reply->list, &card->cmd_waiter_list); qeth_send_control_data()
2085 spin_unlock_irqrestore(&card->lock, flags); qeth_send_control_data()
2088 while (atomic_cmpxchg(&card->write.irq_pending, 0, 1)) ; qeth_send_control_data()
2089 qeth_prepare_control_data(card, len, iob); qeth_send_control_data()
2097 QETH_CARD_TEXT(card, 6, "noirqpnd"); qeth_send_control_data()
2098 spin_lock_irqsave(get_ccwdev_lock(card->write.ccwdev), flags); qeth_send_control_data()
2099 rc = ccw_device_start(card->write.ccwdev, &card->write.ccw, qeth_send_control_data()
2101 spin_unlock_irqrestore(get_ccwdev_lock(card->write.ccwdev), flags); qeth_send_control_data()
2105 dev_name(&card->write.ccwdev->dev), rc); qeth_send_control_data()
2106 QETH_CARD_TEXT_(card, 2, " err%d", rc); qeth_send_control_data()
2107 spin_lock_irqsave(&card->lock, flags); qeth_send_control_data()
2110 spin_unlock_irqrestore(&card->lock, flags); qeth_send_control_data()
2112 atomic_set(&card->write.irq_pending, 0); qeth_send_control_data()
2113 wake_up(&card->wait_q); qeth_send_control_data()
2141 spin_lock_irqsave(&reply->card->lock, flags); qeth_send_control_data()
2143 spin_unlock_irqrestore(&reply->card->lock, flags); qeth_send_control_data()
2146 atomic_set(&card->write.irq_pending, 0); qeth_send_control_data()
2148 card->write.buf_no = (card->write.buf_no + 1) % QETH_CMD_BUFFER_NO; qeth_send_control_data()
2155 static int qeth_cm_enable_cb(struct qeth_card *card, struct qeth_reply *reply, qeth_cm_enable_cb() argument
2163 memcpy(&card->token.cm_filter_r, qeth_cm_enable_cb()
2170 static int qeth_cm_enable(struct qeth_card *card) qeth_cm_enable() argument
2177 iob = qeth_wait_for_buffer(&card->write); qeth_cm_enable()
2180 &card->token.issuer_rm_r, QETH_MPC_TOKEN_LENGTH); qeth_cm_enable()
2182 &card->token.cm_filter_w, QETH_MPC_TOKEN_LENGTH); qeth_cm_enable()
2184 rc = qeth_send_control_data(card, CM_ENABLE_SIZE, iob, qeth_cm_enable()
2189 static int qeth_cm_setup_cb(struct qeth_card *card, struct qeth_reply *reply, qeth_cm_setup_cb() argument
2198 memcpy(&card->token.cm_connection_r, qeth_cm_setup_cb()
2205 static int qeth_cm_setup(struct qeth_card *card) qeth_cm_setup() argument
2212 iob = qeth_wait_for_buffer(&card->write); qeth_cm_setup()
2215 &card->token.issuer_rm_r, QETH_MPC_TOKEN_LENGTH); qeth_cm_setup()
2217 &card->token.cm_connection_w, QETH_MPC_TOKEN_LENGTH); qeth_cm_setup()
2219 &card->token.cm_filter_r, QETH_MPC_TOKEN_LENGTH); qeth_cm_setup()
2220 rc = qeth_send_control_data(card, CM_SETUP_SIZE, iob, qeth_cm_setup()
2226 static inline int qeth_get_initial_mtu_for_card(struct qeth_card *card) qeth_get_initial_mtu_for_card() argument
2228 switch (card->info.type) { qeth_get_initial_mtu_for_card()
2232 return card->info.max_mtu; qeth_get_initial_mtu_for_card()
2234 switch (card->info.link_type) { qeth_get_initial_mtu_for_card()
2239 return card->options.layer2 ? 1500 : 1492; qeth_get_initial_mtu_for_card()
2243 return card->options.layer2 ? 1500 : 1492; qeth_get_initial_mtu_for_card()
2265 static inline int qeth_mtu_is_valid(struct qeth_card *card, int mtu) qeth_mtu_is_valid() argument
2267 switch (card->info.type) { qeth_mtu_is_valid()
2273 (mtu <= card->info.max_mtu)); qeth_mtu_is_valid()
2281 static int qeth_ulp_enable_cb(struct qeth_card *card, struct qeth_reply *reply, qeth_ulp_enable_cb() argument
2293 memcpy(&card->token.ulp_filter_r, qeth_ulp_enable_cb()
2296 if (card->info.type == QETH_CARD_TYPE_IQD) { qeth_ulp_enable_cb()
2304 if (card->info.initial_mtu && (card->info.initial_mtu != mtu)) { qeth_ulp_enable_cb()
2306 if (card->dev && qeth_ulp_enable_cb()
2307 ((card->dev->mtu == card->info.initial_mtu) || qeth_ulp_enable_cb()
2308 (card->dev->mtu > mtu))) qeth_ulp_enable_cb()
2309 card->dev->mtu = mtu; qeth_ulp_enable_cb()
2310 qeth_free_qdio_buffers(card); qeth_ulp_enable_cb()
2312 card->info.initial_mtu = mtu; qeth_ulp_enable_cb()
2313 card->info.max_mtu = mtu; qeth_ulp_enable_cb()
2314 card->qdio.in_buf_size = mtu + 2 * PAGE_SIZE; qeth_ulp_enable_cb()
2316 card->info.max_mtu = *(__u16 *)QETH_ULP_ENABLE_RESP_MAX_MTU( qeth_ulp_enable_cb()
2318 card->info.initial_mtu = min(card->info.max_mtu, qeth_ulp_enable_cb()
2319 qeth_get_initial_mtu_for_card(card)); qeth_ulp_enable_cb()
2320 card->qdio.in_buf_size = QETH_IN_BUF_SIZE_DEFAULT; qeth_ulp_enable_cb()
2327 card->info.link_type = link_type; qeth_ulp_enable_cb()
2329 card->info.link_type = 0; qeth_ulp_enable_cb()
2330 QETH_DBF_TEXT_(SETUP, 2, "link%d", card->info.link_type); qeth_ulp_enable_cb()
2335 static int qeth_ulp_enable(struct qeth_card *card) qeth_ulp_enable() argument
2344 iob = qeth_wait_for_buffer(&card->write); qeth_ulp_enable()
2348 (__u8) card->info.portno; qeth_ulp_enable()
2349 if (card->options.layer2) qeth_ulp_enable()
2350 if (card->info.type == QETH_CARD_TYPE_OSN) qeth_ulp_enable()
2359 &card->token.cm_connection_r, QETH_MPC_TOKEN_LENGTH); qeth_ulp_enable()
2361 &card->token.ulp_filter_w, QETH_MPC_TOKEN_LENGTH); qeth_ulp_enable()
2363 card->info.portname, 9); qeth_ulp_enable()
2364 rc = qeth_send_control_data(card, ULP_ENABLE_SIZE, iob, qeth_ulp_enable()
2370 static int qeth_ulp_setup_cb(struct qeth_card *card, struct qeth_reply *reply, qeth_ulp_setup_cb() argument
2378 memcpy(&card->token.ulp_connection_r, qeth_ulp_setup_cb()
2384 dev_err(&card->gdev->dev, "A connection could not be " qeth_ulp_setup_cb()
2392 static int qeth_ulp_setup(struct qeth_card *card) qeth_ulp_setup() argument
2401 iob = qeth_wait_for_buffer(&card->write); qeth_ulp_setup()
2405 &card->token.cm_connection_r, QETH_MPC_TOKEN_LENGTH); qeth_ulp_setup()
2407 &card->token.ulp_connection_w, QETH_MPC_TOKEN_LENGTH); qeth_ulp_setup()
2409 &card->token.ulp_filter_r, QETH_MPC_TOKEN_LENGTH); qeth_ulp_setup()
2411 ccw_device_get_id(CARD_DDEV(card), &dev_id); qeth_ulp_setup()
2413 temp = (card->info.cula << 8) + card->info.unit_addr2; qeth_ulp_setup()
2415 rc = qeth_send_control_data(card, ULP_SETUP_SIZE, iob, qeth_ulp_setup()
2441 QETH_CARD_TEXT_(q->card, 2, "nbs%d", bidx); qeth_init_qdio_out_buf()
2442 QETH_CARD_TEXT_(q->card, 2, "%lx", (long) newbuf); qeth_init_qdio_out_buf()
2443 QETH_CARD_TEXT_(q->card, 2, "%lx", qeth_init_qdio_out_buf()
2473 static int qeth_alloc_qdio_buffers(struct qeth_card *card) qeth_alloc_qdio_buffers() argument
2479 if (atomic_cmpxchg(&card->qdio.state, QETH_QDIO_UNINITIALIZED, qeth_alloc_qdio_buffers()
2484 card->qdio.in_q = qeth_alloc_qdio_queue(); qeth_alloc_qdio_buffers()
2485 if (!card->qdio.in_q) qeth_alloc_qdio_buffers()
2489 if (qeth_alloc_buffer_pool(card)) qeth_alloc_qdio_buffers()
2493 card->qdio.out_qs = qeth_alloc_qdio_buffers()
2494 kzalloc(card->qdio.no_out_queues * qeth_alloc_qdio_buffers()
2496 if (!card->qdio.out_qs) qeth_alloc_qdio_buffers()
2498 for (i = 0; i < card->qdio.no_out_queues; ++i) { qeth_alloc_qdio_buffers()
2499 card->qdio.out_qs[i] = qeth_alloc_qdio_out_buf(); qeth_alloc_qdio_buffers()
2500 if (!card->qdio.out_qs[i]) qeth_alloc_qdio_buffers()
2503 QETH_DBF_HEX(SETUP, 2, &card->qdio.out_qs[i], sizeof(void *)); qeth_alloc_qdio_buffers()
2504 card->qdio.out_qs[i]->queue_no = i; qeth_alloc_qdio_buffers()
2507 WARN_ON(card->qdio.out_qs[i]->bufs[j] != NULL); qeth_alloc_qdio_buffers()
2508 if (qeth_init_qdio_out_buf(card->qdio.out_qs[i], j)) qeth_alloc_qdio_buffers()
2514 if (qeth_alloc_cq(card)) qeth_alloc_qdio_buffers()
2523 card->qdio.out_qs[i]->bufs[j]); qeth_alloc_qdio_buffers()
2524 card->qdio.out_qs[i]->bufs[j] = NULL; qeth_alloc_qdio_buffers()
2528 qeth_free_qdio_out_buf(card->qdio.out_qs[--i]); qeth_alloc_qdio_buffers()
2529 qeth_clear_outq_buffers(card->qdio.out_qs[i], 1); qeth_alloc_qdio_buffers()
2531 kfree(card->qdio.out_qs); qeth_alloc_qdio_buffers()
2532 card->qdio.out_qs = NULL; qeth_alloc_qdio_buffers()
2534 qeth_free_buffer_pool(card); qeth_alloc_qdio_buffers()
2536 qeth_free_qdio_queue(card->qdio.in_q); qeth_alloc_qdio_buffers()
2537 card->qdio.in_q = NULL; qeth_alloc_qdio_buffers()
2539 atomic_set(&card->qdio.state, QETH_QDIO_UNINITIALIZED); qeth_alloc_qdio_buffers()
2543 static void qeth_free_qdio_buffers(struct qeth_card *card) qeth_free_qdio_buffers() argument
2547 if (atomic_xchg(&card->qdio.state, QETH_QDIO_UNINITIALIZED) == qeth_free_qdio_buffers()
2551 qeth_free_cq(card); qeth_free_qdio_buffers()
2552 cancel_delayed_work_sync(&card->buffer_reclaim_work); qeth_free_qdio_buffers()
2554 if (card->qdio.in_q->bufs[j].rx_skb) qeth_free_qdio_buffers()
2555 dev_kfree_skb_any(card->qdio.in_q->bufs[j].rx_skb); qeth_free_qdio_buffers()
2557 qeth_free_qdio_queue(card->qdio.in_q); qeth_free_qdio_buffers()
2558 card->qdio.in_q = NULL; qeth_free_qdio_buffers()
2560 qeth_free_buffer_pool(card); qeth_free_qdio_buffers()
2562 if (card->qdio.out_qs) { qeth_free_qdio_buffers()
2563 for (i = 0; i < card->qdio.no_out_queues; ++i) { qeth_free_qdio_buffers()
2564 qeth_clear_outq_buffers(card->qdio.out_qs[i], 1); qeth_free_qdio_buffers()
2565 qeth_free_qdio_out_buf(card->qdio.out_qs[i]); qeth_free_qdio_buffers()
2567 kfree(card->qdio.out_qs); qeth_free_qdio_buffers()
2568 card->qdio.out_qs = NULL; qeth_free_qdio_buffers()
2572 static void qeth_create_qib_param_field(struct qeth_card *card, qeth_create_qib_param_field() argument
2580 *((unsigned int *) (&param_field[4])) = QETH_PCI_THRESHOLD_A(card); qeth_create_qib_param_field()
2581 *((unsigned int *) (&param_field[8])) = QETH_PCI_THRESHOLD_B(card); qeth_create_qib_param_field()
2582 *((unsigned int *) (&param_field[12])) = QETH_PCI_TIMER_VALUE(card); qeth_create_qib_param_field()
2585 static void qeth_create_qib_param_field_blkt(struct qeth_card *card, qeth_create_qib_param_field_blkt() argument
2592 *((unsigned int *) (&param_field[20])) = card->info.blkt.time_total; qeth_create_qib_param_field_blkt()
2593 *((unsigned int *) (&param_field[24])) = card->info.blkt.inter_packet; qeth_create_qib_param_field_blkt()
2595 card->info.blkt.inter_packet_jumbo; qeth_create_qib_param_field_blkt()
2598 static int qeth_qdio_activate(struct qeth_card *card) qeth_qdio_activate() argument
2601 return qdio_activate(CARD_DDEV(card)); qeth_qdio_activate()
2604 static int qeth_dm_act(struct qeth_card *card) qeth_dm_act() argument
2611 iob = qeth_wait_for_buffer(&card->write); qeth_dm_act()
2615 &card->token.cm_connection_r, QETH_MPC_TOKEN_LENGTH); qeth_dm_act()
2617 &card->token.ulp_connection_r, QETH_MPC_TOKEN_LENGTH); qeth_dm_act()
2618 rc = qeth_send_control_data(card, DM_ACT_SIZE, iob, NULL, NULL); qeth_dm_act()
2622 static int qeth_mpc_initialize(struct qeth_card *card) qeth_mpc_initialize() argument
2628 rc = qeth_issue_next_read(card); qeth_mpc_initialize()
2633 rc = qeth_cm_enable(card); qeth_mpc_initialize()
2638 rc = qeth_cm_setup(card); qeth_mpc_initialize()
2643 rc = qeth_ulp_enable(card); qeth_mpc_initialize()
2648 rc = qeth_ulp_setup(card); qeth_mpc_initialize()
2653 rc = qeth_alloc_qdio_buffers(card); qeth_mpc_initialize()
2658 rc = qeth_qdio_establish(card); qeth_mpc_initialize()
2661 qeth_free_qdio_buffers(card); qeth_mpc_initialize()
2664 rc = qeth_qdio_activate(card); qeth_mpc_initialize()
2669 rc = qeth_dm_act(card); qeth_mpc_initialize()
2677 qeth_qdio_clear_card(card, card->info.type != QETH_CARD_TYPE_IQD); qeth_mpc_initialize()
2678 qdio_free(CARD_DDEV(card)); qeth_mpc_initialize()
2682 static void qeth_print_status_with_portname(struct qeth_card *card) qeth_print_status_with_portname() argument
2687 sprintf(dbf_text, "%s", card->info.portname + 1); qeth_print_status_with_portname()
2692 dev_info(&card->gdev->dev, "Device is a%s card%s%s%s\n" qeth_print_status_with_portname()
2694 qeth_get_cardname(card), qeth_print_status_with_portname()
2695 (card->info.mcl_level[0]) ? " (level: " : "", qeth_print_status_with_portname()
2696 (card->info.mcl_level[0]) ? card->info.mcl_level : "", qeth_print_status_with_portname()
2697 (card->info.mcl_level[0]) ? ")" : "", qeth_print_status_with_portname()
2698 qeth_get_cardname_short(card), qeth_print_status_with_portname()
2703 static void qeth_print_status_no_portname(struct qeth_card *card) qeth_print_status_no_portname() argument
2705 if (card->info.portname[0]) qeth_print_status_no_portname()
2706 dev_info(&card->gdev->dev, "Device is a%s " qeth_print_status_no_portname()
2707 "card%s%s%s\nwith link type %s " qeth_print_status_no_portname()
2709 qeth_get_cardname(card), qeth_print_status_no_portname()
2710 (card->info.mcl_level[0]) ? " (level: " : "", qeth_print_status_no_portname()
2711 (card->info.mcl_level[0]) ? card->info.mcl_level : "", qeth_print_status_no_portname()
2712 (card->info.mcl_level[0]) ? ")" : "", qeth_print_status_no_portname()
2713 qeth_get_cardname_short(card)); qeth_print_status_no_portname()
2715 dev_info(&card->gdev->dev, "Device is a%s " qeth_print_status_no_portname()
2716 "card%s%s%s\nwith link type %s.\n", qeth_print_status_no_portname()
2717 qeth_get_cardname(card), qeth_print_status_no_portname()
2718 (card->info.mcl_level[0]) ? " (level: " : "", qeth_print_status_no_portname()
2719 (card->info.mcl_level[0]) ? card->info.mcl_level : "", qeth_print_status_no_portname()
2720 (card->info.mcl_level[0]) ? ")" : "", qeth_print_status_no_portname()
2721 qeth_get_cardname_short(card)); qeth_print_status_no_portname()
2724 void qeth_print_status_message(struct qeth_card *card) qeth_print_status_message() argument
2726 switch (card->info.type) { qeth_print_status_message()
2734 if (!card->info.mcl_level[0]) { qeth_print_status_message()
2735 sprintf(card->info.mcl_level, "%02x%02x", qeth_print_status_message()
2736 card->info.mcl_level[2], qeth_print_status_message()
2737 card->info.mcl_level[3]); qeth_print_status_message()
2739 card->info.mcl_level[QETH_MCL_LENGTH] = 0; qeth_print_status_message()
2744 if ((card->info.guestlan) || qeth_print_status_message()
2745 (card->info.mcl_level[0] & 0x80)) { qeth_print_status_message()
2746 card->info.mcl_level[0] = (char) _ebcasc[(__u8) qeth_print_status_message()
2747 card->info.mcl_level[0]]; qeth_print_status_message()
2748 card->info.mcl_level[1] = (char) _ebcasc[(__u8) qeth_print_status_message()
2749 card->info.mcl_level[1]]; qeth_print_status_message()
2750 card->info.mcl_level[2] = (char) _ebcasc[(__u8) qeth_print_status_message()
2751 card->info.mcl_level[2]]; qeth_print_status_message()
2752 card->info.mcl_level[3] = (char) _ebcasc[(__u8) qeth_print_status_message()
2753 card->info.mcl_level[3]]; qeth_print_status_message()
2754 card->info.mcl_level[QETH_MCL_LENGTH] = 0; qeth_print_status_message()
2758 memset(&card->info.mcl_level[0], 0, QETH_MCL_LENGTH + 1); qeth_print_status_message()
2760 if (card->info.portname_required) qeth_print_status_message()
2761 qeth_print_status_with_portname(card); qeth_print_status_message()
2763 qeth_print_status_no_portname(card); qeth_print_status_message()
2767 static void qeth_initialize_working_pool_list(struct qeth_card *card) qeth_initialize_working_pool_list() argument
2771 QETH_CARD_TEXT(card, 5, "inwrklst"); qeth_initialize_working_pool_list()
2774 &card->qdio.init_pool.entry_list, init_list) { qeth_initialize_working_pool_list()
2775 qeth_put_buffer_pool_entry(card, entry); qeth_initialize_working_pool_list()
2780 struct qeth_card *card) qeth_find_free_buffer_pool_entry()
2787 if (list_empty(&card->qdio.in_buf_pool.entry_list)) qeth_find_free_buffer_pool_entry()
2790 list_for_each(plh, &card->qdio.in_buf_pool.entry_list) { qeth_find_free_buffer_pool_entry()
2793 for (i = 0; i < QETH_MAX_BUFFER_ELEMENTS(card); ++i) { qeth_find_free_buffer_pool_entry()
2806 entry = list_entry(card->qdio.in_buf_pool.entry_list.next, qeth_find_free_buffer_pool_entry()
2808 for (i = 0; i < QETH_MAX_BUFFER_ELEMENTS(card); ++i) { qeth_find_free_buffer_pool_entry()
2816 if (card->options.performance_stats) qeth_find_free_buffer_pool_entry()
2817 card->perf_stats.sg_alloc_page_rx++; qeth_find_free_buffer_pool_entry()
2825 static int qeth_init_input_buffer(struct qeth_card *card, qeth_init_input_buffer() argument
2831 if ((card->options.cq == QETH_CQ_ENABLED) && (!buf->rx_skb)) { qeth_init_input_buffer()
2837 pool_entry = qeth_find_free_buffer_pool_entry(card); qeth_init_input_buffer()
2849 for (i = 0; i < QETH_MAX_BUFFER_ELEMENTS(card); ++i) { qeth_init_input_buffer()
2852 if (i == QETH_MAX_BUFFER_ELEMENTS(card) - 1) qeth_init_input_buffer()
2861 int qeth_init_qdio_queues(struct qeth_card *card) qeth_init_qdio_queues() argument
2869 qdio_reset_buffers(card->qdio.in_q->qdio_bufs, qeth_init_qdio_queues()
2871 qeth_initialize_working_pool_list(card); qeth_init_qdio_queues()
2873 for (i = 0; i < card->qdio.in_buf_pool.buf_count - 1; ++i) qeth_init_qdio_queues()
2874 qeth_init_input_buffer(card, &card->qdio.in_q->bufs[i]); qeth_init_qdio_queues()
2875 card->qdio.in_q->next_buf_to_init = qeth_init_qdio_queues()
2876 card->qdio.in_buf_pool.buf_count - 1; qeth_init_qdio_queues()
2877 rc = do_QDIO(CARD_DDEV(card), QDIO_FLAG_SYNC_INPUT, 0, 0, qeth_init_qdio_queues()
2878 card->qdio.in_buf_pool.buf_count - 1); qeth_init_qdio_queues()
2885 rc = qeth_cq_init(card); qeth_init_qdio_queues()
2891 for (i = 0; i < card->qdio.no_out_queues; ++i) { qeth_init_qdio_queues()
2892 qdio_reset_buffers(card->qdio.out_qs[i]->qdio_bufs, qeth_init_qdio_queues()
2895 qeth_clear_output_buffer(card->qdio.out_qs[i], qeth_init_qdio_queues()
2896 card->qdio.out_qs[i]->bufs[j], qeth_init_qdio_queues()
2899 card->qdio.out_qs[i]->card = card; qeth_init_qdio_queues()
2900 card->qdio.out_qs[i]->next_buf_to_fill = 0; qeth_init_qdio_queues()
2901 card->qdio.out_qs[i]->do_pack = 0; qeth_init_qdio_queues()
2902 atomic_set(&card->qdio.out_qs[i]->used_buffers, 0); qeth_init_qdio_queues()
2903 atomic_set(&card->qdio.out_qs[i]->set_pci_flags_count, 0); qeth_init_qdio_queues()
2904 atomic_set(&card->qdio.out_qs[i]->state, qeth_init_qdio_queues()
2921 static void qeth_fill_ipacmd_header(struct qeth_card *card, qeth_fill_ipacmd_header() argument
2928 cmd->hdr.seqno = card->seqno.ipa; qeth_fill_ipacmd_header()
2929 cmd->hdr.adapter_type = qeth_get_ipa_adp_type(card->info.link_type); qeth_fill_ipacmd_header()
2930 cmd->hdr.rel_adapter_no = (__u8) card->info.portno; qeth_fill_ipacmd_header()
2931 if (card->options.layer2) qeth_fill_ipacmd_header()
2941 struct qeth_cmd_buffer *qeth_get_ipacmd_buffer(struct qeth_card *card, qeth_get_ipacmd_buffer() argument
2947 iob = qeth_get_buffer(&card->write); qeth_get_ipacmd_buffer()
2950 qeth_fill_ipacmd_header(card, cmd, ipacmd, prot); qeth_get_ipacmd_buffer()
2952 dev_warn(&card->gdev->dev, qeth_get_ipacmd_buffer()
2955 dev_name(&card->gdev->dev)); qeth_get_ipacmd_buffer()
2962 void qeth_prepare_ipa_cmd(struct qeth_card *card, struct qeth_cmd_buffer *iob, qeth_prepare_ipa_cmd() argument
2968 &card->token.ulp_connection_r, QETH_MPC_TOKEN_LENGTH); qeth_prepare_ipa_cmd()
2978 int qeth_send_ipa_cmd(struct qeth_card *card, struct qeth_cmd_buffer *iob, qeth_send_ipa_cmd() argument
2986 QETH_CARD_TEXT(card, 4, "sendipa"); qeth_send_ipa_cmd()
2988 if (card->options.layer2) qeth_send_ipa_cmd()
2989 if (card->info.type == QETH_CARD_TYPE_OSN) qeth_send_ipa_cmd()
2995 qeth_prepare_ipa_cmd(card, iob, prot_type); qeth_send_ipa_cmd()
2996 rc = qeth_send_control_data(card, IPA_CMD_LENGTH, qeth_send_ipa_cmd()
2999 qeth_clear_ipacmd_list(card); qeth_send_ipa_cmd()
3000 qeth_schedule_recovery(card); qeth_send_ipa_cmd()
3006 int qeth_send_startlan(struct qeth_card *card) qeth_send_startlan() argument
3013 iob = qeth_get_ipacmd_buffer(card, IPA_CMD_STARTLAN, 0); qeth_send_startlan()
3016 rc = qeth_send_ipa_cmd(card, iob, NULL, NULL); qeth_send_startlan()
3021 static int qeth_default_setadapterparms_cb(struct qeth_card *card, qeth_default_setadapterparms_cb() argument
3026 QETH_CARD_TEXT(card, 4, "defadpcb"); qeth_default_setadapterparms_cb()
3035 static int qeth_query_setadapterparms_cb(struct qeth_card *card, qeth_query_setadapterparms_cb() argument
3040 QETH_CARD_TEXT(card, 3, "quyadpcb"); qeth_query_setadapterparms_cb()
3044 card->info.link_type = qeth_query_setadapterparms_cb()
3046 QETH_DBF_TEXT_(SETUP, 2, "lnk %d", card->info.link_type); qeth_query_setadapterparms_cb()
3048 card->options.adp.supported_funcs = qeth_query_setadapterparms_cb()
3050 return qeth_default_setadapterparms_cb(card, reply, (unsigned long)cmd); qeth_query_setadapterparms_cb()
3053 static struct qeth_cmd_buffer *qeth_get_adapter_cmd(struct qeth_card *card, qeth_get_adapter_cmd() argument
3059 iob = qeth_get_ipacmd_buffer(card, IPA_CMD_SETADAPTERPARMS, qeth_get_adapter_cmd()
3072 int qeth_query_setadapterparms(struct qeth_card *card) qeth_query_setadapterparms() argument
3077 QETH_CARD_TEXT(card, 3, "queryadp"); qeth_query_setadapterparms()
3078 iob = qeth_get_adapter_cmd(card, IPA_SETADP_QUERY_COMMANDS_SUPPORTED, qeth_query_setadapterparms()
3082 rc = qeth_send_ipa_cmd(card, iob, qeth_query_setadapterparms_cb, NULL); qeth_query_setadapterparms()
3087 static int qeth_query_ipassists_cb(struct qeth_card *card, qeth_query_ipassists_cb() argument
3100 card->options.ipa4.supported_funcs |= IPA_SETADAPTERPARMS; qeth_query_ipassists_cb()
3101 card->options.ipa6.supported_funcs |= IPA_SETADAPTERPARMS; qeth_query_ipassists_cb()
3107 dev_name(&card->gdev->dev), qeth_query_ipassists_cb()
3114 card->options.ipa4.supported_funcs = cmd->hdr.ipa_supported; qeth_query_ipassists_cb()
3115 card->options.ipa4.enabled_funcs = cmd->hdr.ipa_enabled; qeth_query_ipassists_cb()
3117 card->options.ipa6.supported_funcs = cmd->hdr.ipa_supported; qeth_query_ipassists_cb()
3118 card->options.ipa6.enabled_funcs = cmd->hdr.ipa_enabled; qeth_query_ipassists_cb()
3121 "\n", dev_name(&card->gdev->dev)); qeth_query_ipassists_cb()
3125 int qeth_query_ipassists(struct qeth_card *card, enum qeth_prot_versions prot) qeth_query_ipassists() argument
3131 iob = qeth_get_ipacmd_buffer(card, IPA_CMD_QIPASSIST, prot); qeth_query_ipassists()
3134 rc = qeth_send_ipa_cmd(card, iob, qeth_query_ipassists_cb, NULL); qeth_query_ipassists()
3139 static int qeth_query_switch_attributes_cb(struct qeth_card *card, qeth_query_switch_attributes_cb() argument
3146 QETH_CARD_TEXT(card, 2, "qswiatcb"); qeth_query_switch_attributes_cb()
3153 QETH_CARD_TEXT_(card, 2, "%04x%04x", sw_info->capabilities, qeth_query_switch_attributes_cb()
3156 qeth_default_setadapterparms_cb(card, reply, (unsigned long) cmd); qeth_query_switch_attributes_cb()
3161 int qeth_query_switch_attributes(struct qeth_card *card, qeth_query_switch_attributes() argument
3166 QETH_CARD_TEXT(card, 2, "qswiattr"); qeth_query_switch_attributes()
3167 if (!qeth_adp_supported(card, IPA_SETADP_QUERY_SWITCH_ATTRIBUTES)) qeth_query_switch_attributes()
3169 if (!netif_carrier_ok(card->dev)) qeth_query_switch_attributes()
3171 iob = qeth_get_adapter_cmd(card, IPA_SETADP_QUERY_SWITCH_ATTRIBUTES, qeth_query_switch_attributes()
3175 return qeth_send_ipa_cmd(card, iob, qeth_query_switch_attributes()
3180 static int qeth_query_setdiagass_cb(struct qeth_card *card, qeth_query_setdiagass_cb() argument
3189 QETH_CARD_TEXT_(card, 2, "diagq:%x", rc); qeth_query_setdiagass_cb()
3191 card->info.diagass_support = cmd->data.diagass.ext; qeth_query_setdiagass_cb()
3195 static int qeth_query_setdiagass(struct qeth_card *card) qeth_query_setdiagass() argument
3201 iob = qeth_get_ipacmd_buffer(card, IPA_CMD_SET_DIAG_ASS, 0); qeth_query_setdiagass()
3207 return qeth_send_ipa_cmd(card, iob, qeth_query_setdiagass_cb, NULL); qeth_query_setdiagass()
3210 static void qeth_get_trap_id(struct qeth_card *card, struct qeth_trap_id *tid) qeth_get_trap_id() argument
3218 tid->chpid = card->info.chpid; qeth_get_trap_id()
3219 ccw_device_get_id(CARD_RDEV(card), &ccwid); qeth_get_trap_id()
3235 static int qeth_hw_trap_cb(struct qeth_card *card, qeth_hw_trap_cb() argument
3244 QETH_CARD_TEXT_(card, 2, "trapc:%x", rc); qeth_hw_trap_cb()
3248 int qeth_hw_trap(struct qeth_card *card, enum qeth_diags_trap_action action) qeth_hw_trap() argument
3254 iob = qeth_get_ipacmd_buffer(card, IPA_CMD_SET_DIAG_ASS, 0); qeth_hw_trap()
3267 qeth_get_trap_id(card, qeth_hw_trap()
3276 return qeth_send_ipa_cmd(card, iob, qeth_hw_trap_cb, NULL); qeth_hw_trap()
3280 int qeth_check_qdio_errors(struct qeth_card *card, struct qdio_buffer *buf, qeth_check_qdio_errors() argument
3284 QETH_CARD_TEXT(card, 2, dbftext); qeth_check_qdio_errors()
3285 QETH_CARD_TEXT_(card, 2, " F15=%02X", qeth_check_qdio_errors()
3287 QETH_CARD_TEXT_(card, 2, " F14=%02X", qeth_check_qdio_errors()
3289 QETH_CARD_TEXT_(card, 2, " qerr=%X", qdio_error); qeth_check_qdio_errors()
3291 card->stats.rx_dropped++; qeth_check_qdio_errors()
3302 struct qeth_card *card = container_of(work, struct qeth_card, qeth_buffer_reclaim_work() local
3305 QETH_CARD_TEXT_(card, 2, "brw:%x", card->reclaim_index); qeth_buffer_reclaim_work()
3306 qeth_queue_input_buffer(card, card->reclaim_index); qeth_buffer_reclaim_work()
3309 void qeth_queue_input_buffer(struct qeth_card *card, int index) qeth_queue_input_buffer() argument
3311 struct qeth_qdio_q *queue = card->qdio.in_q; qeth_queue_input_buffer()
3319 card->qdio.in_buf_pool.buf_count - qeth_queue_input_buffer()
3321 card->qdio.in_buf_pool.buf_count - qeth_queue_input_buffer()
3324 if (count >= QETH_IN_BUF_REQUEUE_THRESHOLD(card)) { qeth_queue_input_buffer()
3327 if (qeth_init_input_buffer(card, qeth_queue_input_buffer()
3338 atomic_set(&card->force_alloc_skb, 3); qeth_queue_input_buffer()
3341 atomic_add_unless(&card->force_alloc_skb, -1, 0); qeth_queue_input_buffer()
3346 list_for_each(lh, &card->qdio.in_buf_pool.entry_list) qeth_queue_input_buffer()
3348 if (i == card->qdio.in_buf_pool.buf_count) { qeth_queue_input_buffer()
3349 QETH_CARD_TEXT(card, 2, "qsarbw"); qeth_queue_input_buffer()
3350 card->reclaim_index = index; qeth_queue_input_buffer()
3352 &card->buffer_reclaim_work, qeth_queue_input_buffer()
3365 if (card->options.performance_stats) { qeth_queue_input_buffer()
3366 card->perf_stats.inbound_do_qdio_cnt++; qeth_queue_input_buffer()
3367 card->perf_stats.inbound_do_qdio_start_time = qeth_queue_input_buffer()
3370 rc = do_QDIO(CARD_DDEV(card), QDIO_FLAG_SYNC_INPUT, 0, qeth_queue_input_buffer()
3372 if (card->options.performance_stats) qeth_queue_input_buffer()
3373 card->perf_stats.inbound_do_qdio_time += qeth_queue_input_buffer()
3375 card->perf_stats.inbound_do_qdio_start_time; qeth_queue_input_buffer()
3377 QETH_CARD_TEXT(card, 2, "qinberr"); qeth_queue_input_buffer()
3385 static int qeth_handle_send_error(struct qeth_card *card, qeth_handle_send_error() argument
3390 QETH_CARD_TEXT(card, 6, "hdsnderr"); qeth_handle_send_error()
3391 if (card->info.type == QETH_CARD_TYPE_IQD) { qeth_handle_send_error()
3398 qeth_check_qdio_errors(card, buffer->buffer, qdio_err, "qouterr"); qeth_handle_send_error()
3406 QETH_CARD_TEXT(card, 1, "lnkfail"); qeth_handle_send_error()
3407 QETH_CARD_TEXT_(card, 1, "%04x %02x", qeth_handle_send_error()
3422 QETH_CARD_TEXT(queue->card, 6, "np->pack"); qeth_switch_to_packing_if_needed()
3423 if (queue->card->options.performance_stats) qeth_switch_to_packing_if_needed()
3424 queue->card->perf_stats.sc_dp_p++; qeth_switch_to_packing_if_needed()
3445 QETH_CARD_TEXT(queue->card, 6, "pack->np"); qeth_switch_to_nonpacking_if_needed()
3446 if (queue->card->options.performance_stats) qeth_switch_to_nonpacking_if_needed()
3447 queue->card->perf_stats.sc_p_dp++; qeth_switch_to_nonpacking_if_needed()
3505 if (queue->card->info.type == QETH_CARD_TYPE_IQD) qeth_flush_buffers()
3534 queue->card->dev->trans_start = jiffies; qeth_flush_buffers()
3535 if (queue->card->options.performance_stats) { qeth_flush_buffers()
3536 queue->card->perf_stats.outbound_do_qdio_cnt++; qeth_flush_buffers()
3537 queue->card->perf_stats.outbound_do_qdio_start_time = qeth_flush_buffers()
3543 rc = do_QDIO(CARD_DDEV(queue->card), qdio_flags, qeth_flush_buffers()
3545 if (queue->card->options.performance_stats) qeth_flush_buffers()
3546 queue->card->perf_stats.outbound_do_qdio_time += qeth_flush_buffers()
3548 queue->card->perf_stats.outbound_do_qdio_start_time; qeth_flush_buffers()
3551 queue->card->stats.tx_errors += count; qeth_flush_buffers()
3555 QETH_CARD_TEXT(queue->card, 2, "flushbuf"); qeth_flush_buffers()
3556 QETH_CARD_TEXT_(queue->card, 2, " q%d", queue->queue_no); qeth_flush_buffers()
3557 QETH_CARD_TEXT_(queue->card, 2, " idx%d", index); qeth_flush_buffers()
3558 QETH_CARD_TEXT_(queue->card, 2, " c%d", count); qeth_flush_buffers()
3559 QETH_CARD_TEXT_(queue->card, 2, " err%d", rc); qeth_flush_buffers()
3563 qeth_schedule_recovery(queue->card); qeth_flush_buffers()
3566 if (queue->card->options.performance_stats) qeth_flush_buffers()
3567 queue->card->perf_stats.bufs_sent += count; qeth_flush_buffers()
3589 netif_stop_queue(queue->card->dev); qeth_check_outbound_queue()
3599 if (queue->card->options.performance_stats && qeth_check_outbound_queue()
3601 queue->card->perf_stats.bufs_sent_pack += qeth_check_outbound_queue()
3613 struct qeth_card *card = (struct qeth_card *)card_ptr; qeth_qdio_start_poll() local
3615 if (card->dev && (card->dev->flags & IFF_UP)) qeth_qdio_start_poll()
3616 napi_schedule(&card->napi); qeth_qdio_start_poll()
3620 int qeth_configure_cq(struct qeth_card *card, enum qeth_cq cq) qeth_configure_cq() argument
3624 if (card->options.cq == QETH_CQ_NOTAVAILABLE) { qeth_configure_cq()
3628 if (card->options.cq == cq) { qeth_configure_cq()
3633 if (card->state != CARD_STATE_DOWN && qeth_configure_cq()
3634 card->state != CARD_STATE_RECOVER) { qeth_configure_cq()
3639 qeth_free_qdio_buffers(card); qeth_configure_cq()
3640 card->options.cq = cq; qeth_configure_cq()
3650 static void qeth_qdio_cq_handler(struct qeth_card *card, qeth_qdio_cq_handler() argument
3653 struct qeth_qdio_q *cq = card->qdio.c_q; qeth_qdio_cq_handler()
3657 if (!qeth_is_cq(card, queue)) qeth_qdio_cq_handler()
3660 QETH_CARD_TEXT_(card, 5, "qcqhe%d", first_element); qeth_qdio_cq_handler()
3661 QETH_CARD_TEXT_(card, 5, "qcqhc%d", count); qeth_qdio_cq_handler()
3662 QETH_CARD_TEXT_(card, 5, "qcqherr%d", qdio_err); qeth_qdio_cq_handler()
3665 netif_stop_queue(card->dev); qeth_qdio_cq_handler()
3666 qeth_schedule_recovery(card); qeth_qdio_cq_handler()
3670 if (card->options.performance_stats) { qeth_qdio_cq_handler()
3671 card->perf_stats.cq_cnt++; qeth_qdio_cq_handler()
3672 card->perf_stats.cq_start_time = qeth_get_micros(); qeth_qdio_cq_handler()
3685 qeth_qdio_handle_aob(card, phys_aob_addr); qeth_qdio_cq_handler()
3697 rc = do_QDIO(CARD_DDEV(card), QDIO_FLAG_SYNC_INPUT, queue, qeth_qdio_cq_handler()
3698 card->qdio.c_q->next_buf_to_init, qeth_qdio_cq_handler()
3701 dev_warn(&card->gdev->dev, qeth_qdio_cq_handler()
3703 QETH_CARD_TEXT(card, 2, "qcqherr"); qeth_qdio_cq_handler()
3705 card->qdio.c_q->next_buf_to_init = (card->qdio.c_q->next_buf_to_init qeth_qdio_cq_handler()
3708 netif_wake_queue(card->dev); qeth_qdio_cq_handler()
3710 if (card->options.performance_stats) { qeth_qdio_cq_handler()
3712 delta_t -= card->perf_stats.cq_start_time; qeth_qdio_cq_handler()
3713 card->perf_stats.cq_time += delta_t; qeth_qdio_cq_handler()
3723 struct qeth_card *card = (struct qeth_card *)card_ptr; qeth_qdio_input_handler() local
3725 QETH_CARD_TEXT_(card, 2, "qihq%d", queue); qeth_qdio_input_handler()
3726 QETH_CARD_TEXT_(card, 2, "qiec%d", qdio_err); qeth_qdio_input_handler()
3728 if (qeth_is_cq(card, queue)) qeth_qdio_input_handler()
3729 qeth_qdio_cq_handler(card, qdio_err, queue, first_elem, count); qeth_qdio_input_handler()
3731 qeth_schedule_recovery(card); qeth_qdio_input_handler()
3741 struct qeth_card *card = (struct qeth_card *) card_ptr; qeth_qdio_output_handler() local
3742 struct qeth_qdio_out_q *queue = card->qdio.out_qs[__queue]; qeth_qdio_output_handler()
3746 QETH_CARD_TEXT(card, 6, "qdouhdl"); qeth_qdio_output_handler()
3748 QETH_CARD_TEXT(card, 2, "achkcond"); qeth_qdio_output_handler()
3749 netif_stop_queue(card->dev); qeth_qdio_output_handler()
3750 qeth_schedule_recovery(card); qeth_qdio_output_handler()
3753 if (card->options.performance_stats) { qeth_qdio_output_handler()
3754 card->perf_stats.outbound_handler_cnt++; qeth_qdio_output_handler()
3755 card->perf_stats.outbound_handler_start_time = qeth_qdio_output_handler()
3761 qeth_handle_send_error(card, buffer, qdio_error); qeth_qdio_output_handler()
3766 WARN_ON_ONCE(card->options.cq != QETH_CQ_ENABLED); qeth_qdio_output_handler()
3776 QETH_CARD_TEXT_(queue->card, 5, "pel%d", bidx); qeth_qdio_output_handler()
3777 QETH_CARD_TEXT(queue->card, 5, "aob"); qeth_qdio_output_handler()
3778 QETH_CARD_TEXT_(queue->card, 5, "%lx", qeth_qdio_output_handler()
3781 QETH_CARD_TEXT(card, 2, "outofbuf"); qeth_qdio_output_handler()
3782 qeth_schedule_recovery(card); qeth_qdio_output_handler()
3785 if (card->options.cq == QETH_CQ_ENABLED) { qeth_qdio_output_handler()
3800 if (card->info.type != QETH_CARD_TYPE_IQD) qeth_qdio_output_handler()
3803 netif_wake_queue(queue->card->dev); qeth_qdio_output_handler()
3804 if (card->options.performance_stats) qeth_qdio_output_handler()
3805 card->perf_stats.outbound_handler_time += qeth_get_micros() - qeth_qdio_output_handler()
3806 card->perf_stats.outbound_handler_start_time; qeth_qdio_output_handler()
3813 int qeth_get_priority_queue(struct qeth_card *card, struct sk_buff *skb, qeth_get_priority_queue() argument
3819 if (cast_type && card->info.is_multicast_different) qeth_get_priority_queue()
3820 return card->info.is_multicast_different & qeth_get_priority_queue()
3821 (card->qdio.no_out_queues - 1); qeth_get_priority_queue()
3823 switch (card->qdio.do_prio_queueing) { qeth_get_priority_queue()
3834 return card->qdio.default_out_queue; qeth_get_priority_queue()
3836 if (card->qdio.do_prio_queueing == QETH_PRIO_Q_ING_PREC) qeth_get_priority_queue()
3859 return card->qdio.default_out_queue; qeth_get_priority_queue()
3882 int qeth_get_elements_no(struct qeth_card *card, qeth_get_elements_no() argument
3891 if ((elements_needed + elems) > QETH_MAX_BUFFER_ELEMENTS(card)) { qeth_get_elements_no()
4042 QETH_CARD_TEXT(queue->card, 6, "fillbfnp"); qeth_fill_buffer()
4047 QETH_CARD_TEXT(queue->card, 6, "fillbfpa"); qeth_fill_buffer()
4048 if (queue->card->options.performance_stats) qeth_fill_buffer()
4049 queue->card->perf_stats.skbs_sent_pack++; qeth_fill_buffer()
4051 QETH_MAX_BUFFER_ELEMENTS(queue->card)) { qeth_fill_buffer()
4063 int qeth_do_send_packet_fast(struct qeth_card *card, qeth_do_send_packet_fast() argument
4095 int qeth_do_send_packet(struct qeth_card *card, struct qeth_qdio_out_q *queue, qeth_do_send_packet() argument
4124 if ((QETH_MAX_BUFFER_ELEMENTS(card) - qeth_do_send_packet()
4174 if (queue->card->options.performance_stats && do_pack) qeth_do_send_packet()
4175 queue->card->perf_stats.bufs_sent_pack += flush_count; qeth_do_send_packet()
4181 static int qeth_setadp_promisc_mode_cb(struct qeth_card *card, qeth_setadp_promisc_mode_cb() argument
4187 QETH_CARD_TEXT(card, 4, "prmadpcb"); qeth_setadp_promisc_mode_cb()
4192 qeth_default_setadapterparms_cb(card, reply, (unsigned long)cmd); qeth_setadp_promisc_mode_cb()
4194 QETH_CARD_TEXT_(card, 4, "prmrc%x", cmd->hdr.return_code); qeth_setadp_promisc_mode_cb()
4197 card->info.promisc_mode = setparms->data.mode; qeth_setadp_promisc_mode_cb()
4201 void qeth_setadp_promisc_mode(struct qeth_card *card) qeth_setadp_promisc_mode() argument
4204 struct net_device *dev = card->dev; qeth_setadp_promisc_mode()
4208 QETH_CARD_TEXT(card, 4, "setprom"); qeth_setadp_promisc_mode()
4211 (card->info.promisc_mode == SET_PROMISC_MODE_ON)) || qeth_setadp_promisc_mode()
4213 (card->info.promisc_mode == SET_PROMISC_MODE_OFF))) qeth_setadp_promisc_mode()
4218 QETH_CARD_TEXT_(card, 4, "mode:%x", mode); qeth_setadp_promisc_mode()
4220 iob = qeth_get_adapter_cmd(card, IPA_SETADP_SET_PROMISC_MODE, qeth_setadp_promisc_mode()
4226 qeth_send_ipa_cmd(card, iob, qeth_setadp_promisc_mode_cb, NULL); qeth_setadp_promisc_mode()
4232 struct qeth_card *card; qeth_change_mtu() local
4235 card = dev->ml_priv; qeth_change_mtu()
4237 QETH_CARD_TEXT(card, 4, "chgmtu"); qeth_change_mtu()
4239 QETH_CARD_TEXT(card, 4, dbf_text); qeth_change_mtu()
4245 if ((!qeth_is_supported(card, IPA_IP_FRAGMENTATION)) && qeth_change_mtu()
4246 (!qeth_mtu_is_valid(card, new_mtu))) qeth_change_mtu()
4255 struct qeth_card *card; qeth_get_stats() local
4257 card = dev->ml_priv; qeth_get_stats()
4259 QETH_CARD_TEXT(card, 5, "getstat"); qeth_get_stats()
4261 return &card->stats; qeth_get_stats()
4265 static int qeth_setadpparms_change_macaddr_cb(struct qeth_card *card, qeth_setadpparms_change_macaddr_cb() argument
4270 QETH_CARD_TEXT(card, 4, "chgmaccb"); qeth_setadpparms_change_macaddr_cb()
4273 if (!card->options.layer2 || qeth_setadpparms_change_macaddr_cb()
4274 !(card->info.mac_bits & QETH_LAYER2_MAC_READ)) { qeth_setadpparms_change_macaddr_cb()
4275 memcpy(card->dev->dev_addr, qeth_setadpparms_change_macaddr_cb()
4278 card->info.mac_bits |= QETH_LAYER2_MAC_READ; qeth_setadpparms_change_macaddr_cb()
4280 qeth_default_setadapterparms_cb(card, reply, (unsigned long) cmd); qeth_setadpparms_change_macaddr_cb()
4284 int qeth_setadpparms_change_macaddr(struct qeth_card *card) qeth_setadpparms_change_macaddr() argument
4290 QETH_CARD_TEXT(card, 4, "chgmac"); qeth_setadpparms_change_macaddr()
4292 iob = qeth_get_adapter_cmd(card, IPA_SETADP_ALTER_MAC_ADDRESS, qeth_setadpparms_change_macaddr()
4301 card->dev->dev_addr, OSA_ADDR_LEN); qeth_setadpparms_change_macaddr()
4302 rc = qeth_send_ipa_cmd(card, iob, qeth_setadpparms_change_macaddr_cb, qeth_setadpparms_change_macaddr()
4308 static int qeth_setadpparms_set_access_ctrl_cb(struct qeth_card *card, qeth_setadpparms_set_access_ctrl_cb() argument
4315 QETH_CARD_TEXT(card, 4, "setaccb"); qeth_setadpparms_set_access_ctrl_cb()
4320 QETH_DBF_TEXT_(SETUP, 2, "%s", card->gdev->dev.kobj.name); qeth_setadpparms_set_access_ctrl_cb()
4326 card->gdev->dev.kobj.name, qeth_setadpparms_set_access_ctrl_cb()
4331 if (card->options.isolation == ISOLATION_MODE_NONE) { qeth_setadpparms_set_access_ctrl_cb()
4332 dev_info(&card->gdev->dev, qeth_setadpparms_set_access_ctrl_cb()
4335 dev_info(&card->gdev->dev, qeth_setadpparms_set_access_ctrl_cb()
4341 "deactivated\n", dev_name(&card->gdev->dev)); qeth_setadpparms_set_access_ctrl_cb()
4343 card->options.isolation = card->options.prev_isolation; qeth_setadpparms_set_access_ctrl_cb()
4347 " activated\n", dev_name(&card->gdev->dev)); qeth_setadpparms_set_access_ctrl_cb()
4349 card->options.isolation = card->options.prev_isolation; qeth_setadpparms_set_access_ctrl_cb()
4352 dev_err(&card->gdev->dev, "Adapter does not " qeth_setadpparms_set_access_ctrl_cb()
4356 dev_err(&card->gdev->dev, qeth_setadpparms_set_access_ctrl_cb()
4360 card->options.isolation = card->options.prev_isolation; qeth_setadpparms_set_access_ctrl_cb()
4363 dev_err(&card->gdev->dev, qeth_setadpparms_set_access_ctrl_cb()
4366 card->options.isolation = card->options.prev_isolation; qeth_setadpparms_set_access_ctrl_cb()
4369 dev_err(&card->gdev->dev, "The adjacent switch port does not " qeth_setadpparms_set_access_ctrl_cb()
4372 card->options.isolation = card->options.prev_isolation; qeth_setadpparms_set_access_ctrl_cb()
4375 dev_err(&card->gdev->dev, "The reflective relay mode cannot be " qeth_setadpparms_set_access_ctrl_cb()
4378 card->options.isolation = card->options.prev_isolation; qeth_setadpparms_set_access_ctrl_cb()
4381 dev_warn(&card->gdev->dev, "Turning off reflective relay mode " qeth_setadpparms_set_access_ctrl_cb()
4387 card->options.isolation = card->options.prev_isolation; qeth_setadpparms_set_access_ctrl_cb()
4390 qeth_default_setadapterparms_cb(card, reply, (unsigned long) cmd); qeth_setadpparms_set_access_ctrl_cb()
4394 static int qeth_setadpparms_set_access_ctrl(struct qeth_card *card, qeth_setadpparms_set_access_ctrl() argument
4402 QETH_CARD_TEXT(card, 4, "setacctl"); qeth_setadpparms_set_access_ctrl()
4405 QETH_DBF_TEXT_(SETUP, 2, "%s", card->gdev->dev.kobj.name); qeth_setadpparms_set_access_ctrl()
4407 iob = qeth_get_adapter_cmd(card, IPA_SETADP_SET_ACCESS_CONTROL, qeth_setadpparms_set_access_ctrl()
4416 rc = qeth_send_ipa_cmd(card, iob, qeth_setadpparms_set_access_ctrl_cb, qeth_setadpparms_set_access_ctrl()
4422 int qeth_set_access_ctrl_online(struct qeth_card *card, int fallback) qeth_set_access_ctrl_online() argument
4426 QETH_CARD_TEXT(card, 4, "setactlo"); qeth_set_access_ctrl_online()
4428 if ((card->info.type == QETH_CARD_TYPE_OSD || qeth_set_access_ctrl_online()
4429 card->info.type == QETH_CARD_TYPE_OSX) && qeth_set_access_ctrl_online()
4430 qeth_adp_supported(card, IPA_SETADP_SET_ACCESS_CONTROL)) { qeth_set_access_ctrl_online()
4431 rc = qeth_setadpparms_set_access_ctrl(card, qeth_set_access_ctrl_online()
4432 card->options.isolation, fallback); qeth_set_access_ctrl_online()
4436 card->gdev->dev.kobj.name, qeth_set_access_ctrl_online()
4440 } else if (card->options.isolation != ISOLATION_MODE_NONE) { qeth_set_access_ctrl_online()
4441 card->options.isolation = ISOLATION_MODE_NONE; qeth_set_access_ctrl_online()
4443 dev_err(&card->gdev->dev, "Adapter does not " qeth_set_access_ctrl_online()
4453 struct qeth_card *card; qeth_tx_timeout() local
4455 card = dev->ml_priv; qeth_tx_timeout()
4456 QETH_CARD_TEXT(card, 4, "txtimeo"); qeth_tx_timeout()
4457 card->stats.tx_errors++; qeth_tx_timeout()
4458 qeth_schedule_recovery(card); qeth_tx_timeout()
4464 struct qeth_card *card = dev->ml_priv; qeth_mdio_read() local
4470 if ((card->info.link_type != QETH_LINK_TYPE_GBIT_ETH) && qeth_mdio_read()
4471 (card->info.link_type != QETH_LINK_TYPE_OSN) && qeth_mdio_read()
4472 (card->info.link_type != QETH_LINK_TYPE_10GBIT_ETH)) qeth_mdio_read()
4504 rc = card->stats.rx_errors; qeth_mdio_read()
4527 static int qeth_send_ipa_snmp_cmd(struct qeth_card *card, qeth_send_ipa_snmp_cmd() argument
4535 QETH_CARD_TEXT(card, 4, "sendsnmp"); qeth_send_ipa_snmp_cmd()
4539 &card->token.ulp_connection_r, QETH_MPC_TOKEN_LENGTH); qeth_send_ipa_snmp_cmd()
4547 return qeth_send_control_data(card, IPA_PDU_HEADER_SIZE + len, iob, qeth_send_ipa_snmp_cmd()
4551 static int qeth_snmp_command_cb(struct qeth_card *card, qeth_snmp_command_cb() argument
4560 QETH_CARD_TEXT(card, 3, "snpcmdcb"); qeth_snmp_command_cb()
4568 QETH_CARD_TEXT_(card, 4, "scer1%x", cmd->hdr.return_code); qeth_snmp_command_cb()
4574 QETH_CARD_TEXT_(card, 4, "scer2%x", cmd->hdr.return_code); qeth_snmp_command_cb()
4585 QETH_CARD_TEXT_(card, 4, "scer3%i", -ENOMEM); qeth_snmp_command_cb()
4589 QETH_CARD_TEXT_(card, 4, "snore%i", qeth_snmp_command_cb()
4591 QETH_CARD_TEXT_(card, 4, "sseqn%i", qeth_snmp_command_cb()
4605 QETH_CARD_TEXT_(card, 4, "srtot%i", qeth_snmp_command_cb()
4607 QETH_CARD_TEXT_(card, 4, "srseq%i", qeth_snmp_command_cb()
4615 int qeth_snmp_command(struct qeth_card *card, char __user *udata) qeth_snmp_command() argument
4624 QETH_CARD_TEXT(card, 3, "snmpcmd"); qeth_snmp_command()
4626 if (card->info.guestlan) qeth_snmp_command()
4629 if ((!qeth_adp_supported(card, IPA_SETADP_SET_SNMP_CONTROL)) && qeth_snmp_command()
4630 (!card->options.layer2)) { qeth_snmp_command()
4642 QETH_CARD_TEXT(card, 2, "snmpnome"); qeth_snmp_command()
4653 iob = qeth_get_adapter_cmd(card, IPA_SETADP_SET_SNMP_CONTROL, qeth_snmp_command()
4661 rc = qeth_send_ipa_snmp_cmd(card, iob, QETH_SETADP_BASE_LEN + req_len, qeth_snmp_command()
4665 QETH_CARD_IFNAME(card), rc); qeth_snmp_command()
4677 static int qeth_setadpparms_query_oat_cb(struct qeth_card *card, qeth_setadpparms_query_oat_cb() argument
4685 QETH_CARD_TEXT(card, 3, "qoatcb"); qeth_setadpparms_query_oat_cb()
4707 int qeth_query_oat_command(struct qeth_card *card, char __user *udata) qeth_query_oat_command() argument
4717 QETH_CARD_TEXT(card, 3, "qoatcmd"); qeth_query_oat_command()
4719 if (!qeth_adp_supported(card, IPA_SETADP_QUERY_OAT)) { qeth_query_oat_command()
4738 iob = qeth_get_adapter_cmd(card, IPA_SETADP_QUERY_OAT, qeth_query_oat_command()
4749 rc = qeth_send_ipa_cmd(card, iob, qeth_setadpparms_query_oat_cb, qeth_query_oat_command()
4779 static int qeth_query_card_info_cb(struct qeth_card *card, qeth_query_card_info_cb() argument
4786 QETH_CARD_TEXT(card, 2, "qcrdincb"); qeth_query_card_info_cb()
4796 qeth_default_setadapterparms_cb(card, reply, (unsigned long) cmd); qeth_query_card_info_cb()
4800 static int qeth_query_card_info(struct qeth_card *card, qeth_query_card_info() argument
4805 QETH_CARD_TEXT(card, 2, "qcrdinfo"); qeth_query_card_info()
4806 if (!qeth_adp_supported(card, IPA_SETADP_QUERY_CARD_INFO)) qeth_query_card_info()
4808 iob = qeth_get_adapter_cmd(card, IPA_SETADP_QUERY_CARD_INFO, qeth_query_card_info()
4812 return qeth_send_ipa_cmd(card, iob, qeth_query_card_info_cb, qeth_query_card_info()
4816 static inline int qeth_get_qdio_q_format(struct qeth_card *card) qeth_get_qdio_q_format() argument
4818 switch (card->info.type) { qeth_get_qdio_q_format()
4826 static void qeth_determine_capabilities(struct qeth_card *card) qeth_determine_capabilities() argument
4835 ddev = CARD_DDEV(card); qeth_determine_capabilities()
4845 rc = qeth_read_conf_data(card, (void **) &prcd, &length); qeth_determine_capabilities()
4848 dev_name(&card->gdev->dev), rc); qeth_determine_capabilities()
4852 qeth_configure_unitaddr(card, prcd); qeth_determine_capabilities()
4854 qeth_configure_blkt_default(card, prcd); qeth_determine_capabilities()
4857 rc = qdio_get_ssqd_desc(ddev, &card->ssqd); qeth_determine_capabilities()
4861 QETH_DBF_TEXT_(SETUP, 2, "qfmt%d", card->ssqd.qfmt); qeth_determine_capabilities()
4862 QETH_DBF_TEXT_(SETUP, 2, "%d", card->ssqd.qdioac1); qeth_determine_capabilities()
4863 QETH_DBF_TEXT_(SETUP, 2, "%d", card->ssqd.qdioac3); qeth_determine_capabilities()
4864 QETH_DBF_TEXT_(SETUP, 2, "icnt%d", card->ssqd.icnt); qeth_determine_capabilities()
4865 if (!((card->ssqd.qfmt != QDIO_IQDIO_QFMT) || qeth_determine_capabilities()
4866 ((card->ssqd.qdioac1 & CHSC_AC1_INITIATE_INPUTQ) == 0) || qeth_determine_capabilities()
4867 ((card->ssqd.qdioac3 & CHSC_AC3_FORMAT2_CQ_AVAILABLE) == 0))) { qeth_determine_capabilities()
4868 dev_info(&card->gdev->dev, qeth_determine_capabilities()
4871 card->options.cq = QETH_CQ_NOTAVAILABLE; qeth_determine_capabilities()
4882 static inline void qeth_qdio_establish_cq(struct qeth_card *card, qeth_qdio_establish_cq() argument
4887 if (card->options.cq == QETH_CQ_ENABLED) { qeth_qdio_establish_cq()
4889 (card->qdio.no_in_queues - 1); qeth_qdio_establish_cq()
4890 i = QDIO_MAX_BUFFERS_PER_Q * (card->qdio.no_in_queues - 1); qeth_qdio_establish_cq()
4893 virt_to_phys(card->qdio.c_q->bufs[i].buffer); qeth_qdio_establish_cq()
4896 queue_start_poll[card->qdio.no_in_queues - 1] = NULL; qeth_qdio_establish_cq()
4900 static int qeth_qdio_establish(struct qeth_card *card) qeth_qdio_establish() argument
4919 qeth_create_qib_param_field(card, qib_param_field); qeth_qdio_establish()
4920 qeth_create_qib_param_field_blkt(card, qib_param_field); qeth_qdio_establish()
4922 in_sbal_ptrs = kzalloc(card->qdio.no_in_queues * qeth_qdio_establish()
4931 virt_to_phys(card->qdio.in_q->bufs[i].buffer); qeth_qdio_establish()
4934 queue_start_poll = kzalloc(sizeof(void *) * card->qdio.no_in_queues, qeth_qdio_establish()
4940 for (i = 0; i < card->qdio.no_in_queues; ++i) qeth_qdio_establish()
4941 queue_start_poll[i] = card->discipline->start_poll; qeth_qdio_establish()
4943 qeth_qdio_establish_cq(card, in_sbal_ptrs, queue_start_poll); qeth_qdio_establish()
4946 kzalloc(card->qdio.no_out_queues * QDIO_MAX_BUFFERS_PER_Q * qeth_qdio_establish()
4952 for (i = 0, k = 0; i < card->qdio.no_out_queues; ++i) qeth_qdio_establish()
4955 card->qdio.out_qs[i]->bufs[j]->buffer); qeth_qdio_establish()
4959 init_data.cdev = CARD_DDEV(card); qeth_qdio_establish()
4960 init_data.q_format = qeth_get_qdio_q_format(card); qeth_qdio_establish()
4963 init_data.no_input_qs = card->qdio.no_in_queues; qeth_qdio_establish()
4964 init_data.no_output_qs = card->qdio.no_out_queues; qeth_qdio_establish()
4965 init_data.input_handler = card->discipline->input_handler; qeth_qdio_establish()
4966 init_data.output_handler = card->discipline->output_handler; qeth_qdio_establish()
4968 init_data.int_parm = (unsigned long) card; qeth_qdio_establish()
4971 init_data.output_sbal_state_array = card->qdio.out_bufstates; qeth_qdio_establish()
4973 (card->info.type == QETH_CARD_TYPE_IQD) ? 1 : 32; qeth_qdio_establish()
4975 if (atomic_cmpxchg(&card->qdio.state, QETH_QDIO_ALLOCATED, qeth_qdio_establish()
4979 atomic_set(&card->qdio.state, QETH_QDIO_ALLOCATED); qeth_qdio_establish()
4984 atomic_set(&card->qdio.state, QETH_QDIO_ALLOCATED); qeth_qdio_establish()
4985 qdio_free(CARD_DDEV(card)); qeth_qdio_establish()
4989 switch (card->options.cq) { qeth_qdio_establish()
4991 dev_info(&card->gdev->dev, "Completion Queue support enabled"); qeth_qdio_establish()
4994 dev_info(&card->gdev->dev, "Completion Queue support disabled"); qeth_qdio_establish()
5011 static void qeth_core_free_card(struct qeth_card *card) qeth_core_free_card() argument
5015 QETH_DBF_HEX(SETUP, 2, &card, sizeof(void *)); qeth_core_free_card()
5016 qeth_clean_channel(&card->read); qeth_core_free_card()
5017 qeth_clean_channel(&card->write); qeth_core_free_card()
5018 if (card->dev) qeth_core_free_card()
5019 free_netdev(card->dev); qeth_core_free_card()
5020 kfree(card->ip_tbd_list); qeth_core_free_card()
5021 qeth_free_qdio_buffers(card); qeth_core_free_card()
5022 unregister_service_level(&card->qeth_service_level); qeth_core_free_card()
5023 kfree(card); qeth_core_free_card()
5026 void qeth_trace_features(struct qeth_card *card) qeth_trace_features() argument
5028 QETH_CARD_TEXT(card, 2, "features"); qeth_trace_features()
5029 QETH_CARD_TEXT_(card, 2, "%x", card->options.ipa4.supported_funcs); qeth_trace_features()
5030 QETH_CARD_TEXT_(card, 2, "%x", card->options.ipa4.enabled_funcs); qeth_trace_features()
5031 QETH_CARD_TEXT_(card, 2, "%x", card->options.ipa6.supported_funcs); qeth_trace_features()
5032 QETH_CARD_TEXT_(card, 2, "%x", card->options.ipa6.enabled_funcs); qeth_trace_features()
5033 QETH_CARD_TEXT_(card, 2, "%x", card->options.adp.supported_funcs); qeth_trace_features()
5034 QETH_CARD_TEXT_(card, 2, "%x", card->options.adp.enabled_funcs); qeth_trace_features()
5035 QETH_CARD_TEXT_(card, 2, "%x", card->info.diagass_support); qeth_trace_features()
5064 int qeth_core_hardsetup_card(struct qeth_card *card) qeth_core_hardsetup_card() argument
5070 atomic_set(&card->force_alloc_skb, 0); qeth_core_hardsetup_card()
5071 qeth_update_from_chp_desc(card); qeth_core_hardsetup_card()
5075 dev_name(&card->gdev->dev)); qeth_core_hardsetup_card()
5076 rc = qeth_qdio_clear_card(card, card->info.type != QETH_CARD_TYPE_IQD); qeth_core_hardsetup_card()
5077 ccw_device_set_offline(CARD_DDEV(card)); qeth_core_hardsetup_card()
5078 ccw_device_set_offline(CARD_WDEV(card)); qeth_core_hardsetup_card()
5079 ccw_device_set_offline(CARD_RDEV(card)); qeth_core_hardsetup_card()
5080 qdio_free(CARD_DDEV(card)); qeth_core_hardsetup_card()
5081 rc = ccw_device_set_online(CARD_RDEV(card)); qeth_core_hardsetup_card()
5084 rc = ccw_device_set_online(CARD_WDEV(card)); qeth_core_hardsetup_card()
5087 rc = ccw_device_set_online(CARD_DDEV(card)); qeth_core_hardsetup_card()
5101 qeth_determine_capabilities(card); qeth_core_hardsetup_card()
5102 qeth_init_tokens(card); qeth_core_hardsetup_card()
5103 qeth_init_func_level(card); qeth_core_hardsetup_card()
5104 rc = qeth_idx_activate_channel(&card->read, qeth_idx_read_cb); qeth_core_hardsetup_card()
5115 rc = qeth_idx_activate_channel(&card->write, qeth_idx_write_cb); qeth_core_hardsetup_card()
5126 card->read_or_write_problem = 0; qeth_core_hardsetup_card()
5127 rc = qeth_mpc_initialize(card); qeth_core_hardsetup_card()
5133 card->options.ipa4.supported_funcs = 0; qeth_core_hardsetup_card()
5134 card->options.adp.supported_funcs = 0; qeth_core_hardsetup_card()
5135 card->options.sbp.supported_funcs = 0; qeth_core_hardsetup_card()
5136 card->info.diagass_support = 0; qeth_core_hardsetup_card()
5137 rc = qeth_query_ipassists(card, QETH_PROT_IPV4); qeth_core_hardsetup_card()
5140 if (qeth_is_supported(card, IPA_SETADAPTERPARMS)) { qeth_core_hardsetup_card()
5141 rc = qeth_query_setadapterparms(card); qeth_core_hardsetup_card()
5147 if (qeth_adp_supported(card, IPA_SETADP_SET_DIAG_ASSIST)) { qeth_core_hardsetup_card()
5148 rc = qeth_query_setdiagass(card); qeth_core_hardsetup_card()
5156 dev_warn(&card->gdev->dev, "The qeth device driver failed to recover " qeth_core_hardsetup_card()
5159 dev_name(&card->gdev->dev), rc); qeth_core_hardsetup_card()
5214 struct sk_buff *qeth_core_get_next_skb(struct qeth_card *card, qeth_core_get_next_skb() argument
5261 if (((skb_len >= card->options.rx_sg_cb) && qeth_core_get_next_skb()
5262 (!(card->info.type == QETH_CARD_TYPE_OSN)) && qeth_core_get_next_skb()
5263 (!atomic_read(&card->force_alloc_skb))) || qeth_core_get_next_skb()
5264 (card->options.cq == QETH_CQ_ENABLED)) { qeth_core_get_next_skb()
5290 QETH_CARD_TEXT(card, 4, "unexeob"); qeth_core_get_next_skb()
5291 QETH_CARD_HEX(card, 2, buffer, sizeof(void *)); qeth_core_get_next_skb()
5293 card->stats.rx_errors++; qeth_core_get_next_skb()
5305 if (use_rx_sg && card->options.performance_stats) { qeth_core_get_next_skb()
5306 card->perf_stats.sg_skbs_rx++; qeth_core_get_next_skb()
5307 card->perf_stats.sg_frags_rx += skb_shinfo(skb)->nr_frags; qeth_core_get_next_skb()
5312 QETH_CARD_TEXT(card, 2, "noskbmem"); qeth_core_get_next_skb()
5314 card->stats.rx_dropped++; qeth_core_get_next_skb()
5372 int qeth_core_load_discipline(struct qeth_card *card, qeth_core_load_discipline() argument
5379 card->discipline = try_then_request_module( qeth_core_load_discipline()
5383 card->discipline = try_then_request_module( qeth_core_load_discipline()
5387 if (!card->discipline) { qeth_core_load_discipline()
5388 dev_err(&card->gdev->dev, "There is no kernel module to " qeth_core_load_discipline()
5396 void qeth_core_free_discipline(struct qeth_card *card) qeth_core_free_discipline() argument
5398 if (card->options.layer2) qeth_core_free_discipline()
5402 card->discipline = NULL; qeth_core_free_discipline()
5441 static int qeth_add_dbf_entry(struct qeth_card *card, char *name) qeth_add_dbf_entry() argument
5445 card->debug = debug_register(name, 2, 1, 8); qeth_add_dbf_entry()
5446 if (!card->debug) { qeth_add_dbf_entry()
5450 if (debug_register_view(card->debug, &debug_hex_ascii_view)) qeth_add_dbf_entry()
5456 new_entry->dbf_info = card->debug; qeth_add_dbf_entry()
5464 debug_unregister(card->debug); qeth_add_dbf_entry()
5484 struct qeth_card *card; qeth_core_probe_device() local
5498 card = qeth_alloc_card(); qeth_core_probe_device()
5499 if (!card) { qeth_core_probe_device()
5507 card->debug = qeth_get_dbf_entry(dbf_name); qeth_core_probe_device()
5508 if (!card->debug) { qeth_core_probe_device()
5509 rc = qeth_add_dbf_entry(card, dbf_name); qeth_core_probe_device()
5514 card->read.ccwdev = gdev->cdev[0]; qeth_core_probe_device()
5515 card->write.ccwdev = gdev->cdev[1]; qeth_core_probe_device()
5516 card->data.ccwdev = gdev->cdev[2]; qeth_core_probe_device()
5517 dev_set_drvdata(&gdev->dev, card); qeth_core_probe_device()
5518 card->gdev = gdev; qeth_core_probe_device()
5523 rc = qeth_determine_card_type(card); qeth_core_probe_device()
5528 rc = qeth_setup_card(card); qeth_core_probe_device()
5534 if (card->info.type == QETH_CARD_TYPE_OSN) qeth_core_probe_device()
5539 switch (card->info.type) { qeth_core_probe_device()
5542 rc = qeth_core_load_discipline(card, QETH_DISCIPLINE_LAYER2); qeth_core_probe_device()
5545 rc = card->discipline->setup(card->gdev); qeth_core_probe_device()
5555 list_add_tail(&card->list, &qeth_core_card_list.list); qeth_core_probe_device()
5558 qeth_determine_capabilities(card); qeth_core_probe_device()
5562 qeth_core_free_discipline(card); qeth_core_probe_device()
5564 qeth_core_free_card(card); qeth_core_probe_device()
5573 struct qeth_card *card = dev_get_drvdata(&gdev->dev); qeth_core_remove_device() local
5577 if (card->discipline) { qeth_core_remove_device()
5578 card->discipline->remove(gdev); qeth_core_remove_device()
5579 qeth_core_free_discipline(card); qeth_core_remove_device()
5583 list_del(&card->list); qeth_core_remove_device()
5585 qeth_core_free_card(card); qeth_core_remove_device()
5593 struct qeth_card *card = dev_get_drvdata(&gdev->dev); qeth_core_set_online() local
5597 if (!card->discipline) { qeth_core_set_online()
5598 if (card->info.type == QETH_CARD_TYPE_IQD) qeth_core_set_online()
5602 rc = qeth_core_load_discipline(card, def_discipline); qeth_core_set_online()
5605 rc = card->discipline->setup(card->gdev); qeth_core_set_online()
5609 rc = card->discipline->set_online(gdev); qeth_core_set_online()
5616 struct qeth_card *card = dev_get_drvdata(&gdev->dev); qeth_core_set_offline() local
5617 return card->discipline->set_offline(gdev); qeth_core_set_offline()
5622 struct qeth_card *card = dev_get_drvdata(&gdev->dev); qeth_core_shutdown() local
5623 if (card->discipline && card->discipline->shutdown) qeth_core_shutdown()
5624 card->discipline->shutdown(gdev); qeth_core_shutdown()
5629 struct qeth_card *card = dev_get_drvdata(&gdev->dev); qeth_core_prepare() local
5630 if (card->discipline && card->discipline->prepare) qeth_core_prepare()
5631 return card->discipline->prepare(gdev); qeth_core_prepare()
5637 struct qeth_card *card = dev_get_drvdata(&gdev->dev); qeth_core_complete() local
5638 if (card->discipline && card->discipline->complete) qeth_core_complete()
5639 card->discipline->complete(gdev); qeth_core_complete()
5644 struct qeth_card *card = dev_get_drvdata(&gdev->dev); qeth_core_freeze() local
5645 if (card->discipline && card->discipline->freeze) qeth_core_freeze()
5646 return card->discipline->freeze(gdev); qeth_core_freeze()
5652 struct qeth_card *card = dev_get_drvdata(&gdev->dev); qeth_core_thaw() local
5653 if (card->discipline && card->discipline->thaw) qeth_core_thaw()
5654 return card->discipline->thaw(gdev); qeth_core_thaw()
5660 struct qeth_card *card = dev_get_drvdata(&gdev->dev); qeth_core_restore() local
5661 if (card->discipline && card->discipline->restore) qeth_core_restore()
5662 return card->discipline->restore(gdev); qeth_core_restore()
5763 struct qeth_card *card = dev->ml_priv; qeth_core_get_ethtool_stats() local
5764 data[0] = card->stats.rx_packets - qeth_core_get_ethtool_stats()
5765 card->perf_stats.initial_rx_packets; qeth_core_get_ethtool_stats()
5766 data[1] = card->perf_stats.bufs_rec; qeth_core_get_ethtool_stats()
5767 data[2] = card->stats.tx_packets - qeth_core_get_ethtool_stats()
5768 card->perf_stats.initial_tx_packets; qeth_core_get_ethtool_stats()
5769 data[3] = card->perf_stats.bufs_sent; qeth_core_get_ethtool_stats()
5770 data[4] = card->stats.tx_packets - card->perf_stats.initial_tx_packets qeth_core_get_ethtool_stats()
5771 - card->perf_stats.skbs_sent_pack; qeth_core_get_ethtool_stats()
5772 data[5] = card->perf_stats.bufs_sent - card->perf_stats.bufs_sent_pack; qeth_core_get_ethtool_stats()
5773 data[6] = card->perf_stats.skbs_sent_pack; qeth_core_get_ethtool_stats()
5774 data[7] = card->perf_stats.bufs_sent_pack; qeth_core_get_ethtool_stats()
5775 data[8] = card->perf_stats.sg_skbs_sent; qeth_core_get_ethtool_stats()
5776 data[9] = card->perf_stats.sg_frags_sent; qeth_core_get_ethtool_stats()
5777 data[10] = card->perf_stats.sg_skbs_rx; qeth_core_get_ethtool_stats()
5778 data[11] = card->perf_stats.sg_frags_rx; qeth_core_get_ethtool_stats()
5779 data[12] = card->perf_stats.sg_alloc_page_rx; qeth_core_get_ethtool_stats()
5780 data[13] = (card->perf_stats.large_send_bytes >> 10); qeth_core_get_ethtool_stats()
5781 data[14] = card->perf_stats.large_send_cnt; qeth_core_get_ethtool_stats()
5782 data[15] = card->perf_stats.sc_dp_p; qeth_core_get_ethtool_stats()
5783 data[16] = card->perf_stats.sc_p_dp; qeth_core_get_ethtool_stats()
5786 data[19] = atomic_read(&card->qdio.out_qs[0]->used_buffers); qeth_core_get_ethtool_stats()
5787 data[20] = (card->qdio.no_out_queues > 1) ? qeth_core_get_ethtool_stats()
5788 atomic_read(&card->qdio.out_qs[1]->used_buffers) : 0; qeth_core_get_ethtool_stats()
5789 data[21] = (card->qdio.no_out_queues > 2) ? qeth_core_get_ethtool_stats()
5790 atomic_read(&card->qdio.out_qs[2]->used_buffers) : 0; qeth_core_get_ethtool_stats()
5791 data[22] = (card->qdio.no_out_queues > 3) ? qeth_core_get_ethtool_stats()
5792 atomic_read(&card->qdio.out_qs[3]->used_buffers) : 0; qeth_core_get_ethtool_stats()
5793 data[23] = card->perf_stats.inbound_time; qeth_core_get_ethtool_stats()
5794 data[24] = card->perf_stats.inbound_cnt; qeth_core_get_ethtool_stats()
5795 data[25] = card->perf_stats.inbound_do_qdio_time; qeth_core_get_ethtool_stats()
5796 data[26] = card->perf_stats.inbound_do_qdio_cnt; qeth_core_get_ethtool_stats()
5797 data[27] = card->perf_stats.outbound_handler_time; qeth_core_get_ethtool_stats()
5798 data[28] = card->perf_stats.outbound_handler_cnt; qeth_core_get_ethtool_stats()
5799 data[29] = card->perf_stats.outbound_time; qeth_core_get_ethtool_stats()
5800 data[30] = card->perf_stats.outbound_cnt; qeth_core_get_ethtool_stats()
5801 data[31] = card->perf_stats.outbound_do_qdio_time; qeth_core_get_ethtool_stats()
5802 data[32] = card->perf_stats.outbound_do_qdio_cnt; qeth_core_get_ethtool_stats()
5803 data[33] = card->perf_stats.tx_csum; qeth_core_get_ethtool_stats()
5804 data[34] = card->perf_stats.tx_lin; qeth_core_get_ethtool_stats()
5805 data[35] = card->perf_stats.cq_cnt; qeth_core_get_ethtool_stats()
5806 data[36] = card->perf_stats.cq_time; qeth_core_get_ethtool_stats()
5827 struct qeth_card *card = dev->ml_priv; qeth_core_get_drvinfo() local
5829 strlcpy(info->driver, card->options.layer2 ? "qeth_l2" : "qeth_l3", qeth_core_get_drvinfo()
5832 strlcpy(info->fw_version, card->info.mcl_level, qeth_core_get_drvinfo()
5835 CARD_RDEV_ID(card), CARD_WDEV_ID(card), CARD_DDEV_ID(card)); qeth_core_get_drvinfo()
5895 struct qeth_card *card = netdev->ml_priv; qeth_core_ethtool_get_settings() local
5901 if ((card->info.type == QETH_CARD_TYPE_IQD) || (card->info.guestlan)) qeth_core_ethtool_get_settings()
5904 link_type = card->info.link_type; qeth_core_ethtool_get_settings()
5941 if (!qeth_card_hw_is_reachable(card)) qeth_core_ethtool_get_settings()
5943 rc = qeth_query_card_info(card, &carrier_info); qeth_core_ethtool_get_settings()
5951 "card info: card_type=0x%02x, port_mode=0x%04x, port_speed=0x%08x\n", qeth_core_ethtool_get_settings()
578 qeth_issue_ipa_msg(struct qeth_ipa_cmd *cmd, int rc, struct qeth_card *card) qeth_issue_ipa_msg() argument
2779 qeth_find_free_buffer_pool_entry( struct qeth_card *card) qeth_find_free_buffer_pool_entry() argument
H A Dqeth_core_sys.c21 struct qeth_card *card = dev_get_drvdata(dev); qeth_dev_state_show() local
22 if (!card) qeth_dev_state_show()
25 switch (card->state) { qeth_dev_state_show()
33 if (card->lan_online) qeth_dev_state_show()
49 struct qeth_card *card = dev_get_drvdata(dev); qeth_dev_chpid_show() local
50 if (!card) qeth_dev_chpid_show()
53 return sprintf(buf, "%02X\n", card->info.chpid); qeth_dev_chpid_show()
61 struct qeth_card *card = dev_get_drvdata(dev); qeth_dev_if_name_show() local
62 if (!card) qeth_dev_if_name_show()
64 return sprintf(buf, "%s\n", QETH_CARD_IFNAME(card)); qeth_dev_if_name_show()
72 struct qeth_card *card = dev_get_drvdata(dev); qeth_dev_card_type_show() local
73 if (!card) qeth_dev_card_type_show()
76 return sprintf(buf, "%s\n", qeth_get_cardname_short(card)); qeth_dev_card_type_show()
81 static inline const char *qeth_get_bufsize_str(struct qeth_card *card) qeth_get_bufsize_str() argument
83 if (card->qdio.in_buf_size == 16384) qeth_get_bufsize_str()
85 else if (card->qdio.in_buf_size == 24576) qeth_get_bufsize_str()
87 else if (card->qdio.in_buf_size == 32768) qeth_get_bufsize_str()
89 else if (card->qdio.in_buf_size == 40960) qeth_get_bufsize_str()
98 struct qeth_card *card = dev_get_drvdata(dev); qeth_dev_inbuf_size_show() local
99 if (!card) qeth_dev_inbuf_size_show()
102 return sprintf(buf, "%s\n", qeth_get_bufsize_str(card)); qeth_dev_inbuf_size_show()
110 struct qeth_card *card = dev_get_drvdata(dev); qeth_dev_portno_show() local
111 if (!card) qeth_dev_portno_show()
114 return sprintf(buf, "%i\n", card->info.portno); qeth_dev_portno_show()
120 struct qeth_card *card = dev_get_drvdata(dev); qeth_dev_portno_store() local
125 if (!card) qeth_dev_portno_store()
128 mutex_lock(&card->conf_mutex); qeth_dev_portno_store()
129 if ((card->state != CARD_STATE_DOWN) && qeth_dev_portno_store()
130 (card->state != CARD_STATE_RECOVER)) { qeth_dev_portno_store()
140 limit = (card->ssqd.pcnt ? card->ssqd.pcnt - 1 : card->ssqd.pcnt); qeth_dev_portno_store()
145 card->info.portno = portno; qeth_dev_portno_store()
147 mutex_unlock(&card->conf_mutex); qeth_dev_portno_store()
156 struct qeth_card *card = dev_get_drvdata(dev); qeth_dev_portname_show() local
159 if (!card) qeth_dev_portname_show()
162 if (card->info.portname_required) { qeth_dev_portname_show()
163 memcpy(portname, card->info.portname + 1, 8); qeth_dev_portname_show()
173 struct qeth_card *card = dev_get_drvdata(dev); qeth_dev_portname_store() local
177 if (!card) qeth_dev_portname_store()
180 mutex_lock(&card->conf_mutex); qeth_dev_portname_store()
181 if ((card->state != CARD_STATE_DOWN) && qeth_dev_portname_store()
182 (card->state != CARD_STATE_RECOVER)) { qeth_dev_portname_store()
193 card->info.portname[0] = strlen(tmp); qeth_dev_portname_store()
196 card->info.portname[i] = ' '; qeth_dev_portname_store()
197 strcpy(card->info.portname + 1, tmp); qeth_dev_portname_store()
198 ASCEBC(card->info.portname + 1, 8); qeth_dev_portname_store()
200 mutex_unlock(&card->conf_mutex); qeth_dev_portname_store()
210 struct qeth_card *card = dev_get_drvdata(dev); qeth_dev_prioqing_show() local
212 if (!card) qeth_dev_prioqing_show()
215 switch (card->qdio.do_prio_queueing) { qeth_dev_prioqing_show()
226 card->qdio.default_out_queue); qeth_dev_prioqing_show()
233 struct qeth_card *card = dev_get_drvdata(dev); qeth_dev_prioqing_store() local
236 if (!card) qeth_dev_prioqing_store()
239 mutex_lock(&card->conf_mutex); qeth_dev_prioqing_store()
240 if ((card->state != CARD_STATE_DOWN) && qeth_dev_prioqing_store()
241 (card->state != CARD_STATE_RECOVER)) { qeth_dev_prioqing_store()
249 if (card->qdio.no_out_queues == 1) { qeth_dev_prioqing_store()
250 card->qdio.do_prio_queueing = QETH_PRIOQ_DEFAULT; qeth_dev_prioqing_store()
256 card->qdio.do_prio_queueing = QETH_PRIO_Q_ING_PREC; qeth_dev_prioqing_store()
257 card->qdio.default_out_queue = QETH_DEFAULT_QUEUE; qeth_dev_prioqing_store()
259 card->qdio.do_prio_queueing = QETH_PRIO_Q_ING_SKB; qeth_dev_prioqing_store()
260 card->qdio.default_out_queue = QETH_DEFAULT_QUEUE; qeth_dev_prioqing_store()
262 card->qdio.do_prio_queueing = QETH_PRIO_Q_ING_TOS; qeth_dev_prioqing_store()
263 card->qdio.default_out_queue = QETH_DEFAULT_QUEUE; qeth_dev_prioqing_store()
265 if (!card->options.layer2) { qeth_dev_prioqing_store()
269 card->qdio.do_prio_queueing = QETH_PRIO_Q_ING_VLAN; qeth_dev_prioqing_store()
270 card->qdio.default_out_queue = QETH_DEFAULT_QUEUE; qeth_dev_prioqing_store()
272 card->qdio.do_prio_queueing = QETH_NO_PRIO_QUEUEING; qeth_dev_prioqing_store()
273 card->qdio.default_out_queue = 0; qeth_dev_prioqing_store()
275 card->qdio.do_prio_queueing = QETH_NO_PRIO_QUEUEING; qeth_dev_prioqing_store()
276 card->qdio.default_out_queue = 1; qeth_dev_prioqing_store()
278 card->qdio.do_prio_queueing = QETH_NO_PRIO_QUEUEING; qeth_dev_prioqing_store()
279 card->qdio.default_out_queue = 2; qeth_dev_prioqing_store()
281 card->qdio.do_prio_queueing = QETH_NO_PRIO_QUEUEING; qeth_dev_prioqing_store()
282 card->qdio.default_out_queue = 3; qeth_dev_prioqing_store()
284 card->qdio.do_prio_queueing = QETH_NO_PRIO_QUEUEING; qeth_dev_prioqing_store()
285 card->qdio.default_out_queue = QETH_DEFAULT_QUEUE; qeth_dev_prioqing_store()
289 mutex_unlock(&card->conf_mutex); qeth_dev_prioqing_store()
299 struct qeth_card *card = dev_get_drvdata(dev); qeth_dev_bufcnt_show() local
301 if (!card) qeth_dev_bufcnt_show()
304 return sprintf(buf, "%i\n", card->qdio.in_buf_pool.buf_count); qeth_dev_bufcnt_show()
310 struct qeth_card *card = dev_get_drvdata(dev); qeth_dev_bufcnt_store() local
315 if (!card) qeth_dev_bufcnt_store()
318 mutex_lock(&card->conf_mutex); qeth_dev_bufcnt_store()
319 if ((card->state != CARD_STATE_DOWN) && qeth_dev_bufcnt_store()
320 (card->state != CARD_STATE_RECOVER)) { qeth_dev_bufcnt_store()
325 old_cnt = card->qdio.in_buf_pool.buf_count; qeth_dev_bufcnt_store()
330 rc = qeth_realloc_buffer_pool(card, cnt); qeth_dev_bufcnt_store()
333 mutex_unlock(&card->conf_mutex); qeth_dev_bufcnt_store()
343 struct qeth_card *card = dev_get_drvdata(dev); qeth_dev_recover_store() local
347 if (!card) qeth_dev_recover_store()
350 if (card->state != CARD_STATE_UP) qeth_dev_recover_store()
355 qeth_schedule_recovery(card); qeth_dev_recover_store()
365 struct qeth_card *card = dev_get_drvdata(dev); qeth_dev_performance_stats_show() local
367 if (!card) qeth_dev_performance_stats_show()
370 return sprintf(buf, "%i\n", card->options.performance_stats ? 1:0); qeth_dev_performance_stats_show()
376 struct qeth_card *card = dev_get_drvdata(dev); qeth_dev_performance_stats_store() local
380 if (!card) qeth_dev_performance_stats_store()
383 mutex_lock(&card->conf_mutex); qeth_dev_performance_stats_store()
386 if (i == card->options.performance_stats) qeth_dev_performance_stats_store()
388 card->options.performance_stats = i; qeth_dev_performance_stats_store()
390 memset(&card->perf_stats, 0, qeth_dev_performance_stats_store()
392 card->perf_stats.initial_rx_packets = card->stats.rx_packets; qeth_dev_performance_stats_store()
393 card->perf_stats.initial_tx_packets = card->stats.tx_packets; qeth_dev_performance_stats_store()
397 mutex_unlock(&card->conf_mutex); qeth_dev_performance_stats_store()
407 struct qeth_card *card = dev_get_drvdata(dev); qeth_dev_layer2_show() local
409 if (!card) qeth_dev_layer2_show()
412 return sprintf(buf, "%i\n", card->options.layer2); qeth_dev_layer2_show()
418 struct qeth_card *card = dev_get_drvdata(dev); qeth_dev_layer2_store() local
423 if (!card) qeth_dev_layer2_store()
426 mutex_lock(&card->discipline_mutex); qeth_dev_layer2_store()
427 if (card->state != CARD_STATE_DOWN) { qeth_dev_layer2_store()
445 if (card->options.layer2 == newdis) qeth_dev_layer2_store()
448 card->info.mac_bits = 0; qeth_dev_layer2_store()
449 if (card->discipline) { qeth_dev_layer2_store()
450 card->discipline->remove(card->gdev); qeth_dev_layer2_store()
451 qeth_core_free_discipline(card); qeth_dev_layer2_store()
455 rc = qeth_core_load_discipline(card, newdis); qeth_dev_layer2_store()
459 rc = card->discipline->setup(card->gdev); qeth_dev_layer2_store()
461 mutex_unlock(&card->discipline_mutex); qeth_dev_layer2_store()
475 struct qeth_card *card = dev_get_drvdata(dev); qeth_dev_isolation_show() local
477 if (!card) qeth_dev_isolation_show()
480 switch (card->options.isolation) { qeth_dev_isolation_show()
495 struct qeth_card *card = dev_get_drvdata(dev); qeth_dev_isolation_store() local
499 if (!card) qeth_dev_isolation_store()
502 mutex_lock(&card->conf_mutex); qeth_dev_isolation_store()
504 if (card->info.type != QETH_CARD_TYPE_OSD && qeth_dev_isolation_store()
505 card->info.type != QETH_CARD_TYPE_OSX && qeth_dev_isolation_store()
506 card->info.type != QETH_CARD_TYPE_UNKNOWN) { qeth_dev_isolation_store()
508 dev_err(&card->gdev->dev, "Adapter does not " qeth_dev_isolation_store()
527 card->options.prev_isolation = card->options.isolation; qeth_dev_isolation_store()
528 card->options.isolation = isolation; qeth_dev_isolation_store()
529 if (qeth_card_hw_is_reachable(card)) { qeth_dev_isolation_store()
530 int ipa_rc = qeth_set_access_ctrl_online(card, 1); qeth_dev_isolation_store()
535 mutex_unlock(&card->conf_mutex); qeth_dev_isolation_store()
545 struct qeth_card *card = dev_get_drvdata(dev); qeth_dev_switch_attrs_show() local
549 if (!card) qeth_dev_switch_attrs_show()
552 if (!qeth_card_hw_is_reachable(card)) qeth_dev_switch_attrs_show()
555 rc = qeth_query_switch_attributes(card, &sw_info); qeth_dev_switch_attrs_show()
580 struct qeth_card *card = dev_get_drvdata(dev); qeth_hw_trap_show() local
582 if (!card) qeth_hw_trap_show()
584 if (card->info.hwtrap) qeth_hw_trap_show()
593 struct qeth_card *card = dev_get_drvdata(dev); qeth_hw_trap_store() local
597 if (!card) qeth_hw_trap_store()
600 mutex_lock(&card->conf_mutex); qeth_hw_trap_store()
601 if (qeth_card_hw_is_reachable(card)) qeth_hw_trap_store()
604 if (sysfs_streq(buf, "arm") && !card->info.hwtrap) { qeth_hw_trap_store()
606 if (qeth_is_diagass_supported(card, qeth_hw_trap_store()
608 rc = qeth_hw_trap(card, QETH_DIAGS_TRAP_ARM); qeth_hw_trap_store()
610 card->info.hwtrap = 1; qeth_hw_trap_store()
614 card->info.hwtrap = 1; qeth_hw_trap_store()
615 } else if (sysfs_streq(buf, "disarm") && card->info.hwtrap) { qeth_hw_trap_store()
617 rc = qeth_hw_trap(card, QETH_DIAGS_TRAP_DISARM); qeth_hw_trap_store()
619 card->info.hwtrap = 0; qeth_hw_trap_store()
621 card->info.hwtrap = 0; qeth_hw_trap_store()
622 } else if (sysfs_streq(buf, "trap") && state && card->info.hwtrap) qeth_hw_trap_store()
623 rc = qeth_hw_trap(card, QETH_DIAGS_TRAP_CAPTURE); qeth_hw_trap_store()
627 mutex_unlock(&card->conf_mutex); qeth_hw_trap_store()
634 static ssize_t qeth_dev_blkt_show(char *buf, struct qeth_card *card, int value) qeth_dev_blkt_show() argument
637 if (!card) qeth_dev_blkt_show()
643 static ssize_t qeth_dev_blkt_store(struct qeth_card *card, qeth_dev_blkt_store() argument
649 if (!card) qeth_dev_blkt_store()
652 mutex_lock(&card->conf_mutex); qeth_dev_blkt_store()
653 if ((card->state != CARD_STATE_DOWN) && qeth_dev_blkt_store()
654 (card->state != CARD_STATE_RECOVER)) { qeth_dev_blkt_store()
664 mutex_unlock(&card->conf_mutex); qeth_dev_blkt_store()
671 struct qeth_card *card = dev_get_drvdata(dev); qeth_dev_blkt_total_show() local
673 return qeth_dev_blkt_show(buf, card, card->info.blkt.time_total); qeth_dev_blkt_total_show()
679 struct qeth_card *card = dev_get_drvdata(dev); qeth_dev_blkt_total_store() local
681 return qeth_dev_blkt_store(card, buf, count, qeth_dev_blkt_total_store()
682 &card->info.blkt.time_total, 5000); qeth_dev_blkt_total_store()
693 struct qeth_card *card = dev_get_drvdata(dev); qeth_dev_blkt_inter_show() local
695 return qeth_dev_blkt_show(buf, card, card->info.blkt.inter_packet); qeth_dev_blkt_inter_show()
701 struct qeth_card *card = dev_get_drvdata(dev); qeth_dev_blkt_inter_store() local
703 return qeth_dev_blkt_store(card, buf, count, qeth_dev_blkt_inter_store()
704 &card->info.blkt.inter_packet, 1000); qeth_dev_blkt_inter_store()
713 struct qeth_card *card = dev_get_drvdata(dev); qeth_dev_blkt_inter_jumbo_show() local
715 return qeth_dev_blkt_show(buf, card, qeth_dev_blkt_inter_jumbo_show()
716 card->info.blkt.inter_packet_jumbo); qeth_dev_blkt_inter_jumbo_show()
722 struct qeth_card *card = dev_get_drvdata(dev); qeth_dev_blkt_inter_jumbo_store() local
724 return qeth_dev_blkt_store(card, buf, count, qeth_dev_blkt_inter_jumbo_store()
725 &card->info.blkt.inter_packet_jumbo, 1000); qeth_dev_blkt_inter_jumbo_store()
H A Dlcs.c168 * LCS free memory for card and channels.
171 lcs_free_card(struct lcs_card *card) lcs_free_card() argument
174 LCS_DBF_HEX(2, setup, &card, sizeof(void*)); lcs_free_card()
175 kfree(card); lcs_free_card()
179 * LCS alloc memory for card and channels
184 struct lcs_card *card; lcs_alloc_card() local
189 card = kzalloc(sizeof(struct lcs_card), GFP_KERNEL | GFP_DMA); lcs_alloc_card()
190 if (card == NULL) lcs_alloc_card()
192 card->lan_type = LCS_FRAME_TYPE_AUTO; lcs_alloc_card()
193 card->pkt_seq = 0; lcs_alloc_card()
194 card->lancmd_timeout = LCS_LANCMD_TIMEOUT_DEFAULT; lcs_alloc_card()
196 rc = lcs_alloc_channel(&card->read); lcs_alloc_card()
199 lcs_free_card(card); lcs_alloc_card()
203 rc = lcs_alloc_channel(&card->write); lcs_alloc_card()
206 lcs_cleanup_channel(&card->read); lcs_alloc_card()
207 lcs_free_card(card); lcs_alloc_card()
212 INIT_LIST_HEAD(&card->ipm_list); lcs_alloc_card()
214 LCS_DBF_HEX(2, setup, &card, sizeof(void*)); lcs_alloc_card()
215 return card; lcs_alloc_card()
222 lcs_setup_read_ccws(struct lcs_card *card) lcs_setup_read_ccws() argument
228 memset(card->read.ccws, 0, sizeof (struct ccw1) * (LCS_NUM_BUFFS + 1)); lcs_setup_read_ccws()
230 card->read.ccws[cnt].cmd_code = LCS_CCW_READ; lcs_setup_read_ccws()
231 card->read.ccws[cnt].count = LCS_IOBUFFERSIZE; lcs_setup_read_ccws()
232 card->read.ccws[cnt].flags = lcs_setup_read_ccws()
238 card->read.ccws[cnt].cda = lcs_setup_read_ccws()
239 (__u32) __pa(card->read.iob[cnt].data); lcs_setup_read_ccws()
241 card->read.iob[cnt].data)->offset = LCS_ILLEGAL_OFFSET; lcs_setup_read_ccws()
242 card->read.iob[cnt].callback = lcs_get_frames_cb; lcs_setup_read_ccws()
243 card->read.iob[cnt].state = LCS_BUF_STATE_READY; lcs_setup_read_ccws()
244 card->read.iob[cnt].count = LCS_IOBUFFERSIZE; lcs_setup_read_ccws()
246 card->read.ccws[0].flags &= ~CCW_FLAG_PCI; lcs_setup_read_ccws()
247 card->read.ccws[LCS_NUM_BUFFS - 1].flags &= ~CCW_FLAG_PCI; lcs_setup_read_ccws()
248 card->read.ccws[LCS_NUM_BUFFS - 1].flags |= CCW_FLAG_SUSPEND; lcs_setup_read_ccws()
250 card->read.ccws[LCS_NUM_BUFFS].cmd_code = LCS_CCW_TRANSFER; lcs_setup_read_ccws()
251 card->read.ccws[LCS_NUM_BUFFS].cda = lcs_setup_read_ccws()
252 (__u32) __pa(card->read.ccws); lcs_setup_read_ccws()
254 card->read.state = LCS_CH_STATE_INIT; lcs_setup_read_ccws()
256 card->read.io_idx = 0; lcs_setup_read_ccws()
257 card->read.buf_idx = 0; lcs_setup_read_ccws()
261 lcs_setup_read(struct lcs_card *card) lcs_setup_read() argument
265 lcs_setup_read_ccws(card); lcs_setup_read()
267 card->read.irq_tasklet.data = (unsigned long) &card->read; lcs_setup_read()
268 card->read.irq_tasklet.func = lcs_tasklet; lcs_setup_read()
270 init_waitqueue_head(&card->read.wait_q); lcs_setup_read()
277 lcs_setup_write_ccws(struct lcs_card *card) lcs_setup_write_ccws() argument
283 memset(card->write.ccws, 0, sizeof(struct ccw1) * (LCS_NUM_BUFFS + 1)); lcs_setup_write_ccws()
285 card->write.ccws[cnt].cmd_code = LCS_CCW_WRITE; lcs_setup_write_ccws()
286 card->write.ccws[cnt].count = 0; lcs_setup_write_ccws()
287 card->write.ccws[cnt].flags = lcs_setup_write_ccws()
293 card->write.ccws[cnt].cda = lcs_setup_write_ccws()
294 (__u32) __pa(card->write.iob[cnt].data); lcs_setup_write_ccws()
297 card->write.ccws[LCS_NUM_BUFFS].cmd_code = LCS_CCW_TRANSFER; lcs_setup_write_ccws()
298 card->write.ccws[LCS_NUM_BUFFS].cda = lcs_setup_write_ccws()
299 (__u32) __pa(card->write.ccws); lcs_setup_write_ccws()
301 card->read.state = LCS_CH_STATE_INIT; lcs_setup_write_ccws()
303 card->write.io_idx = 0; lcs_setup_write_ccws()
304 card->write.buf_idx = 0; lcs_setup_write_ccws()
308 lcs_setup_write(struct lcs_card *card) lcs_setup_write() argument
312 lcs_setup_write_ccws(card); lcs_setup_write()
314 card->write.irq_tasklet.data = (unsigned long) &card->write; lcs_setup_write()
315 card->write.irq_tasklet.func = lcs_tasklet; lcs_setup_write()
317 init_waitqueue_head(&card->write.wait_q); lcs_setup_write()
321 lcs_set_allowed_threads(struct lcs_card *card, unsigned long threads) lcs_set_allowed_threads() argument
325 spin_lock_irqsave(&card->mask_lock, flags); lcs_set_allowed_threads()
326 card->thread_allowed_mask = threads; lcs_set_allowed_threads()
327 spin_unlock_irqrestore(&card->mask_lock, flags); lcs_set_allowed_threads()
328 wake_up(&card->wait_q); lcs_set_allowed_threads()
331 lcs_threads_running(struct lcs_card *card, unsigned long threads) lcs_threads_running() argument
336 spin_lock_irqsave(&card->mask_lock, flags); lcs_threads_running()
337 rc = (card->thread_running_mask & threads); lcs_threads_running()
338 spin_unlock_irqrestore(&card->mask_lock, flags); lcs_threads_running()
343 lcs_wait_for_threads(struct lcs_card *card, unsigned long threads) lcs_wait_for_threads() argument
345 return wait_event_interruptible(card->wait_q, lcs_wait_for_threads()
346 lcs_threads_running(card, threads) == 0); lcs_wait_for_threads()
350 lcs_set_thread_start_bit(struct lcs_card *card, unsigned long thread) lcs_set_thread_start_bit() argument
354 spin_lock_irqsave(&card->mask_lock, flags); lcs_set_thread_start_bit()
355 if ( !(card->thread_allowed_mask & thread) || lcs_set_thread_start_bit()
356 (card->thread_start_mask & thread) ) { lcs_set_thread_start_bit()
357 spin_unlock_irqrestore(&card->mask_lock, flags); lcs_set_thread_start_bit()
360 card->thread_start_mask |= thread; lcs_set_thread_start_bit()
361 spin_unlock_irqrestore(&card->mask_lock, flags); lcs_set_thread_start_bit()
366 lcs_clear_thread_running_bit(struct lcs_card *card, unsigned long thread) lcs_clear_thread_running_bit() argument
370 spin_lock_irqsave(&card->mask_lock, flags); lcs_clear_thread_running_bit()
371 card->thread_running_mask &= ~thread; lcs_clear_thread_running_bit()
372 spin_unlock_irqrestore(&card->mask_lock, flags); lcs_clear_thread_running_bit()
373 wake_up(&card->wait_q); lcs_clear_thread_running_bit()
377 __lcs_do_run_thread(struct lcs_card *card, unsigned long thread) __lcs_do_run_thread() argument
382 spin_lock_irqsave(&card->mask_lock, flags); __lcs_do_run_thread()
383 if (card->thread_start_mask & thread){ __lcs_do_run_thread()
384 if ((card->thread_allowed_mask & thread) && __lcs_do_run_thread()
385 !(card->thread_running_mask & thread)){ __lcs_do_run_thread()
387 card->thread_start_mask &= ~thread; __lcs_do_run_thread()
388 card->thread_running_mask |= thread; __lcs_do_run_thread()
392 spin_unlock_irqrestore(&card->mask_lock, flags); __lcs_do_run_thread()
397 lcs_do_run_thread(struct lcs_card *card, unsigned long thread) lcs_do_run_thread() argument
400 wait_event(card->wait_q, lcs_do_run_thread()
401 (rc = __lcs_do_run_thread(card, thread)) >= 0); lcs_do_run_thread()
406 lcs_do_start_thread(struct lcs_card *card, unsigned long thread) lcs_do_start_thread() argument
411 spin_lock_irqsave(&card->mask_lock, flags); lcs_do_start_thread()
413 (u8) card->thread_start_mask, lcs_do_start_thread()
414 (u8) card->thread_allowed_mask, lcs_do_start_thread()
415 (u8) card->thread_running_mask); lcs_do_start_thread()
416 rc = (card->thread_start_mask & thread); lcs_do_start_thread()
417 spin_unlock_irqrestore(&card->mask_lock, flags); lcs_do_start_thread()
422 * Initialize channels,card and state machines.
425 lcs_setup_card(struct lcs_card *card) lcs_setup_card() argument
428 LCS_DBF_HEX(2, setup, &card, sizeof(void*)); lcs_setup_card()
430 lcs_setup_read(card); lcs_setup_card()
431 lcs_setup_write(card); lcs_setup_card()
433 card->state = DEV_STATE_DOWN; lcs_setup_card()
434 card->tx_buffer = NULL; lcs_setup_card()
435 card->tx_emitted = 0; lcs_setup_card()
437 init_waitqueue_head(&card->wait_q); lcs_setup_card()
438 spin_lock_init(&card->lock); lcs_setup_card()
439 spin_lock_init(&card->ipm_lock); lcs_setup_card()
440 spin_lock_init(&card->mask_lock); lcs_setup_card()
442 INIT_LIST_HEAD(&card->ipm_list); lcs_setup_card()
444 INIT_LIST_HEAD(&card->lancmd_waiters); lcs_setup_card()
448 lcs_clear_multicast_list(struct lcs_card *card) lcs_clear_multicast_list() argument
456 spin_lock_irqsave(&card->ipm_lock, flags); lcs_clear_multicast_list()
457 while (!list_empty(&card->ipm_list)){ lcs_clear_multicast_list()
458 ipm = list_entry(card->ipm_list.next, lcs_clear_multicast_list()
462 spin_unlock_irqrestore(&card->ipm_lock, flags); lcs_clear_multicast_list()
463 lcs_send_delipm(card, ipm); lcs_clear_multicast_list()
464 spin_lock_irqsave(&card->ipm_lock, flags); lcs_clear_multicast_list()
468 spin_unlock_irqrestore(&card->ipm_lock, flags); lcs_clear_multicast_list()
472 * Cleanup channels,card and state machines.
475 lcs_cleanup_card(struct lcs_card *card) lcs_cleanup_card() argument
479 LCS_DBF_HEX(2,setup,&card,sizeof(void*)); lcs_cleanup_card()
481 if (card->dev != NULL) lcs_cleanup_card()
482 free_netdev(card->dev); lcs_cleanup_card()
484 lcs_cleanup_channel(&card->write); lcs_cleanup_card()
485 lcs_cleanup_channel(&card->read); lcs_cleanup_card()
569 lcs_start_channels(struct lcs_card *card) lcs_start_channels() argument
575 rc = lcs_start_channel(&card->read); lcs_start_channels()
579 rc = lcs_start_channel(&card->write); lcs_start_channels()
581 lcs_stop_channel(&card->read); lcs_start_channels()
589 lcs_stop_channels(struct lcs_card *card) lcs_stop_channels() argument
592 lcs_stop_channel(&card->read); lcs_stop_channels()
593 lcs_stop_channel(&card->write); lcs_stop_channels()
753 lcs_get_lancmd(struct lcs_card *card, int count) lcs_get_lancmd() argument
760 wait_event(card->write.wait_q, lcs_get_lancmd()
761 ((buffer = lcs_get_buffer(&card->write)) != NULL)); lcs_get_lancmd()
814 lcs_notify_lancmd_waiters(struct lcs_card *card, struct lcs_cmd *cmd) lcs_notify_lancmd_waiters() argument
820 spin_lock(&card->lock); lcs_notify_lancmd_waiters()
821 list_for_each_safe(l, n, &card->lancmd_waiters) { lcs_notify_lancmd_waiters()
827 reply->callback(card, cmd); lcs_notify_lancmd_waiters()
835 spin_unlock(&card->lock); lcs_notify_lancmd_waiters()
849 spin_lock_irqsave(&reply->card->lock, flags); lcs_lancmd_timeout()
851 &reply->card->lancmd_waiters,list) { lcs_lancmd_timeout()
855 spin_unlock_irqrestore(&reply->card->lock, flags); lcs_lancmd_timeout()
863 spin_unlock_irqrestore(&reply->card->lock, flags); lcs_lancmd_timeout()
867 lcs_send_lancmd(struct lcs_card *card, struct lcs_buffer *buffer, lcs_send_lancmd() argument
879 cmd->sequence_no = card->sequence_no++; lcs_send_lancmd()
884 reply->card = card; lcs_send_lancmd()
885 spin_lock_irqsave(&card->lock, flags); lcs_send_lancmd()
886 list_add_tail(&reply->list, &card->lancmd_waiters); lcs_send_lancmd()
887 spin_unlock_irqrestore(&card->lock, flags); lcs_send_lancmd()
890 rc = lcs_ready_buffer(&card->write, buffer); lcs_send_lancmd()
896 timer.expires = jiffies + HZ*card->lancmd_timeout; lcs_send_lancmd()
911 lcs_send_startup(struct lcs_card *card, __u8 initiator) lcs_send_startup() argument
917 buffer = lcs_get_lancmd(card, LCS_STD_CMD_SIZE); lcs_send_startup()
922 return lcs_send_lancmd(card, buffer, NULL); lcs_send_startup()
929 lcs_send_shutdown(struct lcs_card *card) lcs_send_shutdown() argument
935 buffer = lcs_get_lancmd(card, LCS_STD_CMD_SIZE); lcs_send_shutdown()
939 return lcs_send_lancmd(card, buffer, NULL); lcs_send_shutdown()
946 __lcs_lanstat_cb(struct lcs_card *card, struct lcs_cmd *cmd) __lcs_lanstat_cb() argument
949 memcpy(card->mac, cmd->cmd.lcs_lanstat_cmd.mac_addr, LCS_MAC_LENGTH); __lcs_lanstat_cb()
953 lcs_send_lanstat(struct lcs_card *card) lcs_send_lanstat() argument
959 buffer = lcs_get_lancmd(card, LCS_STD_CMD_SIZE); lcs_send_lanstat()
964 cmd->cmd.lcs_std_cmd.lan_type = card->lan_type; lcs_send_lanstat()
965 cmd->cmd.lcs_std_cmd.portno = card->portno; lcs_send_lanstat()
966 return lcs_send_lancmd(card, buffer, __lcs_lanstat_cb); lcs_send_lanstat()
973 lcs_send_stoplan(struct lcs_card *card, __u8 initiator) lcs_send_stoplan() argument
979 buffer = lcs_get_lancmd(card, LCS_STD_CMD_SIZE); lcs_send_stoplan()
983 cmd->cmd.lcs_std_cmd.lan_type = card->lan_type; lcs_send_stoplan()
984 cmd->cmd.lcs_std_cmd.portno = card->portno; lcs_send_stoplan()
985 return lcs_send_lancmd(card, buffer, NULL); lcs_send_stoplan()
992 __lcs_send_startlan_cb(struct lcs_card *card, struct lcs_cmd *cmd) __lcs_send_startlan_cb() argument
995 card->lan_type = cmd->cmd.lcs_std_cmd.lan_type; __lcs_send_startlan_cb()
996 card->portno = cmd->cmd.lcs_std_cmd.portno; __lcs_send_startlan_cb()
1000 lcs_send_startlan(struct lcs_card *card, __u8 initiator) lcs_send_startlan() argument
1006 buffer = lcs_get_lancmd(card, LCS_STD_CMD_SIZE); lcs_send_startlan()
1010 cmd->cmd.lcs_std_cmd.lan_type = card->lan_type; lcs_send_startlan()
1011 cmd->cmd.lcs_std_cmd.portno = card->portno; lcs_send_startlan()
1012 return lcs_send_lancmd(card, buffer, __lcs_send_startlan_cb); lcs_send_startlan()
1020 lcs_send_setipm(struct lcs_card *card,struct lcs_ipm_list *ipm_list) lcs_send_setipm() argument
1026 buffer = lcs_get_lancmd(card, LCS_MULTICAST_CMD_SIZE); lcs_send_setipm()
1030 cmd->cmd.lcs_qipassist.lan_type = card->lan_type; lcs_send_setipm()
1031 cmd->cmd.lcs_qipassist.portno = card->portno; lcs_send_setipm()
1037 return lcs_send_lancmd(card, buffer, NULL); lcs_send_setipm()
1044 lcs_send_delipm(struct lcs_card *card,struct lcs_ipm_list *ipm_list) lcs_send_delipm() argument
1050 buffer = lcs_get_lancmd(card, LCS_MULTICAST_CMD_SIZE); lcs_send_delipm()
1054 cmd->cmd.lcs_qipassist.lan_type = card->lan_type; lcs_send_delipm()
1055 cmd->cmd.lcs_qipassist.portno = card->portno; lcs_send_delipm()
1061 return lcs_send_lancmd(card, buffer, NULL); lcs_send_delipm()
1068 __lcs_check_multicast_cb(struct lcs_card *card, struct lcs_cmd *cmd) __lcs_check_multicast_cb() argument
1071 card->ip_assists_supported = __lcs_check_multicast_cb()
1073 card->ip_assists_enabled = __lcs_check_multicast_cb()
1078 lcs_check_multicast_support(struct lcs_card *card) lcs_check_multicast_support() argument
1086 buffer = lcs_get_lancmd(card, LCS_STD_CMD_SIZE); lcs_check_multicast_support()
1090 cmd->cmd.lcs_qipassist.lan_type = card->lan_type; lcs_check_multicast_support()
1091 cmd->cmd.lcs_qipassist.portno = card->portno; lcs_check_multicast_support()
1094 rc = lcs_send_lancmd(card, buffer, __lcs_check_multicast_cb); lcs_check_multicast_support()
1099 if (card->ip_assists_supported & LCS_IPASS_MULTICAST_SUPPORT) lcs_check_multicast_support()
1105 * set or del multicast address on LCS card
1108 lcs_fix_multicast_list(struct lcs_card *card) lcs_fix_multicast_list() argument
1117 spin_lock_irqsave(&card->ipm_lock, flags); lcs_fix_multicast_list()
1119 list_for_each_entry_safe(ipm, tmp, &card->ipm_list, list){ lcs_fix_multicast_list()
1125 spin_unlock_irqrestore(&card->ipm_lock, flags); lcs_fix_multicast_list()
1126 rc = lcs_send_setipm(card, ipm); lcs_fix_multicast_list()
1127 spin_lock_irqsave(&card->ipm_lock, flags); lcs_fix_multicast_list()
1138 list_add_tail(&ipm->list, &card->ipm_list); lcs_fix_multicast_list()
1143 spin_unlock_irqrestore(&card->ipm_lock, flags); lcs_fix_multicast_list()
1144 lcs_send_delipm(card, ipm); lcs_fix_multicast_list()
1145 spin_lock_irqsave(&card->ipm_lock, flags); lcs_fix_multicast_list()
1154 list_move_tail(&ipm->list, &card->ipm_list); lcs_fix_multicast_list()
1156 spin_unlock_irqrestore(&card->ipm_lock, flags); lcs_fix_multicast_list()
1173 lcs_remove_mc_addresses(struct lcs_card *card, struct in_device *in4_dev) lcs_remove_mc_addresses() argument
1182 spin_lock_irqsave(&card->ipm_lock, flags); lcs_remove_mc_addresses()
1183 list_for_each(l, &card->ipm_list) { lcs_remove_mc_addresses()
1187 lcs_get_mac_for_ipm(im4->multiaddr, buf, card->dev); lcs_remove_mc_addresses()
1196 spin_unlock_irqrestore(&card->ipm_lock, flags); lcs_remove_mc_addresses()
1200 lcs_check_addr_entry(struct lcs_card *card, struct ip_mc_list *im4, char *buf) lcs_check_addr_entry() argument
1207 spin_lock_irqsave(&card->ipm_lock, flags); lcs_check_addr_entry()
1208 list_for_each(l, &card->ipm_list) { lcs_check_addr_entry()
1217 spin_unlock_irqrestore(&card->ipm_lock, flags); lcs_check_addr_entry()
1222 lcs_set_mc_addresses(struct lcs_card *card, struct in_device *in4_dev) lcs_set_mc_addresses() argument
1233 lcs_get_mac_for_ipm(im4->multiaddr, buf, card->dev); lcs_set_mc_addresses()
1234 ipm = lcs_check_addr_entry(card, im4, buf); lcs_set_mc_addresses()
1246 spin_lock_irqsave(&card->ipm_lock, flags); lcs_set_mc_addresses()
1248 list_add(&ipm->list, &card->ipm_list); lcs_set_mc_addresses()
1249 spin_unlock_irqrestore(&card->ipm_lock, flags); lcs_set_mc_addresses()
1256 struct lcs_card *card; lcs_register_mc_addresses() local
1259 card = (struct lcs_card *) data; lcs_register_mc_addresses()
1261 if (!lcs_do_run_thread(card, LCS_SET_MC_THREAD)) lcs_register_mc_addresses()
1265 in4_dev = in_dev_get(card->dev); lcs_register_mc_addresses()
1269 lcs_remove_mc_addresses(card,in4_dev); lcs_register_mc_addresses()
1270 lcs_set_mc_addresses(card, in4_dev); lcs_register_mc_addresses()
1274 netif_carrier_off(card->dev); lcs_register_mc_addresses()
1275 netif_tx_disable(card->dev); lcs_register_mc_addresses()
1276 wait_event(card->write.wait_q, lcs_register_mc_addresses()
1277 (card->write.state != LCS_CH_STATE_RUNNING)); lcs_register_mc_addresses()
1278 lcs_fix_multicast_list(card); lcs_register_mc_addresses()
1279 if (card->state == DEV_STATE_UP) { lcs_register_mc_addresses()
1280 netif_carrier_on(card->dev); lcs_register_mc_addresses()
1281 netif_wake_queue(card->dev); lcs_register_mc_addresses()
1284 lcs_clear_thread_running_bit(card, LCS_SET_MC_THREAD); lcs_register_mc_addresses()
1297 struct lcs_card *card; lcs_set_multicast_list() local
1300 card = (struct lcs_card *) dev->ml_priv; lcs_set_multicast_list()
1302 if (!lcs_set_thread_start_bit(card, LCS_SET_MC_THREAD)) lcs_set_multicast_list()
1303 schedule_work(&card->kernel_thread_starter); lcs_set_multicast_list()
1377 lcs_schedule_recovery(struct lcs_card *card) lcs_schedule_recovery() argument
1380 if (!lcs_set_thread_start_bit(card, LCS_RECOVERY_THREAD)) lcs_schedule_recovery()
1381 schedule_work(&card->kernel_thread_starter); lcs_schedule_recovery()
1390 struct lcs_card *card; lcs_irq() local
1398 card = CARD_FROM_DEV(cdev); lcs_irq()
1399 if (card->read.ccwdev == cdev) lcs_irq()
1400 channel = &card->read; lcs_irq()
1402 channel = &card->write; lcs_irq()
1424 lcs_schedule_recovery(card); lcs_irq()
1425 wake_up(&card->wait_q); lcs_irq()
1509 __lcs_emit_txbuffer(struct lcs_card *card) __lcs_emit_txbuffer() argument
1512 *(__u16 *)(card->tx_buffer->data + card->tx_buffer->count) = 0; __lcs_emit_txbuffer()
1513 card->tx_buffer->count += 2; __lcs_emit_txbuffer()
1514 lcs_ready_buffer(&card->write, card->tx_buffer); __lcs_emit_txbuffer()
1515 card->tx_buffer = NULL; __lcs_emit_txbuffer()
1516 card->tx_emitted++; __lcs_emit_txbuffer()
1525 struct lcs_card *card; lcs_txbuffer_cb() local
1530 card = container_of(channel, struct lcs_card, write); lcs_txbuffer_cb()
1531 if (netif_queue_stopped(card->dev) && netif_carrier_ok(card->dev)) lcs_txbuffer_cb()
1532 netif_wake_queue(card->dev); lcs_txbuffer_cb()
1533 spin_lock(&card->lock); lcs_txbuffer_cb()
1534 card->tx_emitted--; lcs_txbuffer_cb()
1535 if (card->tx_emitted <= 0 && card->tx_buffer != NULL) lcs_txbuffer_cb()
1540 __lcs_emit_txbuffer(card); lcs_txbuffer_cb()
1541 spin_unlock(&card->lock); lcs_txbuffer_cb()
1548 __lcs_start_xmit(struct lcs_card *card, struct sk_buff *skb, __lcs_start_xmit() argument
1556 card->stats.tx_dropped++; __lcs_start_xmit()
1557 card->stats.tx_errors++; __lcs_start_xmit()
1560 if (card->state != DEV_STATE_UP) { __lcs_start_xmit()
1562 card->stats.tx_dropped++; __lcs_start_xmit()
1563 card->stats.tx_errors++; __lcs_start_xmit()
1564 card->stats.tx_carrier_errors++; __lcs_start_xmit()
1571 netif_stop_queue(card->dev); __lcs_start_xmit()
1572 spin_lock(&card->lock); __lcs_start_xmit()
1573 if (card->tx_buffer != NULL && __lcs_start_xmit()
1574 card->tx_buffer->count + sizeof(struct lcs_header) + __lcs_start_xmit()
1577 __lcs_emit_txbuffer(card); __lcs_start_xmit()
1578 if (card->tx_buffer == NULL) { __lcs_start_xmit()
1580 card->tx_buffer = lcs_get_buffer(&card->write); __lcs_start_xmit()
1581 if (card->tx_buffer == NULL) { __lcs_start_xmit()
1582 card->stats.tx_dropped++; __lcs_start_xmit()
1586 card->tx_buffer->callback = lcs_txbuffer_cb; __lcs_start_xmit()
1587 card->tx_buffer->count = 0; __lcs_start_xmit()
1590 (card->tx_buffer->data + card->tx_buffer->count); __lcs_start_xmit()
1591 card->tx_buffer->count += skb->len + sizeof(struct lcs_header); __lcs_start_xmit()
1592 header->offset = card->tx_buffer->count; __lcs_start_xmit()
1593 header->type = card->lan_type; __lcs_start_xmit()
1594 header->slot = card->portno; __lcs_start_xmit()
1596 spin_unlock(&card->lock); __lcs_start_xmit()
1597 card->stats.tx_bytes += skb->len; __lcs_start_xmit()
1598 card->stats.tx_packets++; __lcs_start_xmit()
1600 netif_wake_queue(card->dev); __lcs_start_xmit()
1601 spin_lock(&card->lock); __lcs_start_xmit()
1602 if (card->tx_emitted <= 0 && card->tx_buffer != NULL) __lcs_start_xmit()
1604 __lcs_emit_txbuffer(card); __lcs_start_xmit()
1606 spin_unlock(&card->lock); __lcs_start_xmit()
1613 struct lcs_card *card; lcs_start_xmit() local
1617 card = (struct lcs_card *) dev->ml_priv; lcs_start_xmit()
1618 rc = __lcs_start_xmit(card, skb, dev); lcs_start_xmit()
1626 lcs_startlan_auto(struct lcs_card *card) lcs_startlan_auto() argument
1632 card->lan_type = LCS_FRAME_TYPE_ENET; lcs_startlan_auto()
1633 rc = lcs_send_startlan(card, LCS_INITIATOR_TCPIP); lcs_startlan_auto()
1639 card->lan_type = LCS_FRAME_TYPE_FDDI; lcs_startlan_auto()
1640 rc = lcs_send_startlan(card, LCS_INITIATOR_TCPIP); lcs_startlan_auto()
1648 lcs_startlan(struct lcs_card *card) lcs_startlan() argument
1654 if (card->portno != LCS_INVALID_PORT_NO) { lcs_startlan()
1655 if (card->lan_type == LCS_FRAME_TYPE_AUTO) lcs_startlan()
1656 rc = lcs_startlan_auto(card); lcs_startlan()
1658 rc = lcs_send_startlan(card, LCS_INITIATOR_TCPIP); lcs_startlan()
1661 card->portno = i; lcs_startlan()
1662 if (card->lan_type != LCS_FRAME_TYPE_AUTO) lcs_startlan()
1663 rc = lcs_send_startlan(card, lcs_startlan()
1667 rc = lcs_startlan_auto(card); lcs_startlan()
1673 return lcs_send_lanstat(card); lcs_startlan()
1682 lcs_detect(struct lcs_card *card) lcs_detect() argument
1687 /* start/reset card */ lcs_detect()
1688 if (card->dev) lcs_detect()
1689 netif_stop_queue(card->dev); lcs_detect()
1690 rc = lcs_stop_channels(card); lcs_detect()
1692 rc = lcs_start_channels(card); lcs_detect()
1694 rc = lcs_send_startup(card, LCS_INITIATOR_TCPIP); lcs_detect()
1696 rc = lcs_startlan(card); lcs_detect()
1700 card->state = DEV_STATE_UP; lcs_detect()
1702 card->state = DEV_STATE_DOWN; lcs_detect()
1703 card->write.state = LCS_CH_STATE_INIT; lcs_detect()
1704 card->read.state = LCS_CH_STATE_INIT; lcs_detect()
1710 * LCS Stop card
1713 lcs_stopcard(struct lcs_card *card) lcs_stopcard() argument
1719 if (card->read.state != LCS_CH_STATE_STOPPED && lcs_stopcard()
1720 card->write.state != LCS_CH_STATE_STOPPED && lcs_stopcard()
1721 card->read.state != LCS_CH_STATE_ERROR && lcs_stopcard()
1722 card->write.state != LCS_CH_STATE_ERROR && lcs_stopcard()
1723 card->state == DEV_STATE_UP) { lcs_stopcard()
1724 lcs_clear_multicast_list(card); lcs_stopcard()
1725 rc = lcs_send_stoplan(card,LCS_INITIATOR_TCPIP); lcs_stopcard()
1726 rc = lcs_send_shutdown(card); lcs_stopcard()
1728 rc = lcs_stop_channels(card); lcs_stopcard()
1729 card->state = DEV_STATE_DOWN; lcs_stopcard()
1740 struct lcs_card *card = container_of(work, struct lcs_card, kernel_thread_starter); lcs_start_kernel_thread() local
1742 if (lcs_do_start_thread(card, LCS_RECOVERY_THREAD)) lcs_start_kernel_thread()
1743 kthread_run(lcs_recovery, card, "lcs_recover"); lcs_start_kernel_thread()
1745 if (lcs_do_start_thread(card, LCS_SET_MC_THREAD)) lcs_start_kernel_thread()
1746 kthread_run(lcs_register_mc_addresses, card, "regipm"); lcs_start_kernel_thread()
1754 lcs_get_control(struct lcs_card *card, struct lcs_cmd *cmd) lcs_get_control() argument
1761 lcs_schedule_recovery(card); lcs_get_control()
1765 card->dev->name); lcs_get_control()
1766 if (card->dev) lcs_get_control()
1767 netif_carrier_off(card->dev); lcs_get_control()
1774 lcs_notify_lancmd_waiters(card, cmd); lcs_get_control()
1781 lcs_get_skb(struct lcs_card *card, char *skb_data, unsigned int skb_len) lcs_get_skb() argument
1786 if (card->dev == NULL || lcs_get_skb()
1787 card->state != DEV_STATE_UP) lcs_get_skb()
1788 /* The card isn't up. Ignore the packet. */ lcs_get_skb()
1793 dev_err(&card->dev->dev, lcs_get_skb()
1795 card->dev->name); lcs_get_skb()
1796 card->stats.rx_dropped++; lcs_get_skb()
1800 skb->protocol = card->lan_type_trans(skb, card->dev); lcs_get_skb()
1801 card->stats.rx_bytes += skb_len; lcs_get_skb()
1802 card->stats.rx_packets++; lcs_get_skb()
1804 *((__u32 *)skb->cb) = ++card->pkt_seq; lcs_get_skb()
1814 struct lcs_card *card; lcs_get_frames_cb() local
1824 card = container_of(channel, struct lcs_card, read); lcs_get_frames_cb()
1831 card->stats.rx_length_errors++; lcs_get_frames_cb()
1832 card->stats.rx_errors++; lcs_get_frames_cb()
1838 lcs_get_control(card, (struct lcs_cmd *) lcs_hdr); lcs_get_frames_cb()
1843 lcs_get_skb(card, (char *)(lcs_hdr + 1), lcs_get_frames_cb()
1855 lcs_ready_buffer(&card->read, buffer); lcs_get_frames_cb()
1864 struct lcs_card *card; lcs_getstats() local
1867 card = (struct lcs_card *) dev->ml_priv; lcs_getstats()
1868 return &card->stats; lcs_getstats()
1878 struct lcs_card *card; lcs_stop_device() local
1882 card = (struct lcs_card *) dev->ml_priv; lcs_stop_device()
1886 wait_event(card->write.wait_q, lcs_stop_device()
1887 (card->write.state != LCS_CH_STATE_RUNNING)); lcs_stop_device()
1888 rc = lcs_stopcard(card); lcs_stop_device()
1890 dev_err(&card->dev->dev, lcs_stop_device()
1902 struct lcs_card *card; lcs_open_device() local
1906 card = (struct lcs_card *) dev->ml_priv; lcs_open_device()
1908 rc = lcs_detect(card); lcs_open_device()
1916 card->state = DEV_STATE_UP; lcs_open_device()
1927 struct lcs_card *card; lcs_portno_show() local
1929 card = dev_get_drvdata(dev); lcs_portno_show()
1931 if (!card) lcs_portno_show()
1934 return sprintf(buf, "%d\n", card->portno); lcs_portno_show()
1943 struct lcs_card *card; lcs_portno_store() local
1947 card = dev_get_drvdata(dev); lcs_portno_store()
1949 if (!card) lcs_portno_store()
1956 card->portno = value; lcs_portno_store()
1968 "OSA LCS card",
1990 struct lcs_card *card; lcs_timeout_show() local
1992 card = dev_get_drvdata(dev); lcs_timeout_show()
1994 return card ? sprintf(buf, "%u\n", card->lancmd_timeout) : 0; lcs_timeout_show()
2000 struct lcs_card *card; lcs_timeout_store() local
2004 card = dev_get_drvdata(dev); lcs_timeout_store()
2006 if (!card) lcs_timeout_store()
2013 card->lancmd_timeout = value; lcs_timeout_store()
2025 struct lcs_card *card = dev_get_drvdata(dev); lcs_dev_recover_store() local
2029 if (!card) lcs_dev_recover_store()
2031 if (card->state != DEV_STATE_UP) lcs_dev_recover_store()
2035 lcs_schedule_recovery(card); lcs_dev_recover_store()
2066 struct lcs_card *card; lcs_probe_device() local
2072 card = lcs_alloc_card(); lcs_probe_device()
2073 if (!card) { lcs_probe_device()
2078 dev_set_drvdata(&ccwgdev->dev, card); lcs_probe_device()
2081 card->gdev = ccwgdev; lcs_probe_device()
2082 INIT_WORK(&card->kernel_thread_starter, lcs_start_kernel_thread); lcs_probe_device()
2083 card->thread_start_mask = 0; lcs_probe_device()
2084 card->thread_allowed_mask = 0; lcs_probe_device()
2085 card->thread_running_mask = 0; lcs_probe_device()
2094 struct lcs_card *card; lcs_register_netdev() local
2097 card = dev_get_drvdata(&ccwgdev->dev); lcs_register_netdev()
2098 if (card->dev->reg_state != NETREG_UNINITIALIZED) lcs_register_netdev()
2100 SET_NETDEV_DEV(card->dev, &ccwgdev->dev); lcs_register_netdev()
2101 return register_netdev(card->dev); lcs_register_netdev()
2125 struct lcs_card *card; lcs_new_device() local
2130 card = dev_get_drvdata(&ccwgdev->dev); lcs_new_device()
2131 if (!card) lcs_new_device()
2135 LCS_DBF_HEX(3, setup, &card, sizeof(void*)); lcs_new_device()
2136 card->read.ccwdev = ccwgdev->cdev[0]; lcs_new_device()
2137 card->write.ccwdev = ccwgdev->cdev[1]; lcs_new_device()
2139 recover_state = card->state; lcs_new_device()
2140 rc = ccw_device_set_online(card->read.ccwdev); lcs_new_device()
2143 rc = ccw_device_set_online(card->write.ccwdev); lcs_new_device()
2149 lcs_setup_card(card); lcs_new_device()
2150 rc = lcs_detect(card); lcs_new_device()
2153 dev_err(&card->dev->dev, lcs_new_device()
2156 lcs_stopcard(card); lcs_new_device()
2159 if (card->dev) { lcs_new_device()
2161 LCS_DBF_HEX(3, setup, &card, sizeof(void*)); lcs_new_device()
2164 switch (card->lan_type) { lcs_new_device()
2167 card->lan_type_trans = eth_type_trans; lcs_new_device()
2173 card->lan_type_trans = fddi_type_trans; lcs_new_device()
2184 card->dev = dev; lcs_new_device()
2185 card->dev->ml_priv = card; lcs_new_device()
2186 card->dev->netdev_ops = &lcs_netdev_ops; lcs_new_device()
2187 memcpy(card->dev->dev_addr, card->mac, LCS_MAC_LENGTH); lcs_new_device()
2189 if (!lcs_check_multicast_support(card)) lcs_new_device()
2190 card->dev->netdev_ops = &lcs_mc_netdev_ops; lcs_new_device()
2193 lcs_set_allowed_threads(card,0xffffffff); lcs_new_device()
2195 lcs_set_multicast_list(card->dev); lcs_new_device()
2196 card->dev->flags |= IFF_UP; lcs_new_device()
2197 netif_carrier_on(card->dev); lcs_new_device()
2198 netif_wake_queue(card->dev); lcs_new_device()
2199 card->state = DEV_STATE_UP; lcs_new_device()
2201 lcs_stopcard(card); lcs_new_device()
2208 pr_info("LCS device %s %s IPv6 support\n", card->dev->name, lcs_new_device()
2209 (card->ip_assists_supported & LCS_IPASS_IPV6_SUPPORT) ? lcs_new_device()
2212 pr_info("LCS device %s %s Multicast support\n", card->dev->name, lcs_new_device()
2213 (card->ip_assists_supported & LCS_IPASS_MULTICAST_SUPPORT) ? lcs_new_device()
2218 ccw_device_set_offline(card->write.ccwdev); lcs_new_device()
2220 ccw_device_set_offline(card->read.ccwdev); lcs_new_device()
2231 struct lcs_card *card; __lcs_shutdown_device() local
2236 card = dev_get_drvdata(&ccwgdev->dev); __lcs_shutdown_device()
2237 if (!card) __lcs_shutdown_device()
2240 lcs_set_allowed_threads(card, 0); __lcs_shutdown_device()
2241 if (lcs_wait_for_threads(card, LCS_SET_MC_THREAD)) __lcs_shutdown_device()
2244 LCS_DBF_HEX(3, setup, &card, sizeof(void*)); __lcs_shutdown_device()
2245 recover_state = card->state; __lcs_shutdown_device()
2247 ret = lcs_stop_device(card->dev); __lcs_shutdown_device()
2248 ret2 = ccw_device_set_offline(card->read.ccwdev); __lcs_shutdown_device()
2249 ret3 = ccw_device_set_offline(card->write.ccwdev); __lcs_shutdown_device()
2255 card->state = DEV_STATE_RECOVER; __lcs_shutdown_device()
2272 struct lcs_card *card; lcs_recovery() local
2276 card = (struct lcs_card *) ptr; lcs_recovery()
2279 if (!lcs_do_run_thread(card, LCS_RECOVERY_THREAD)) lcs_recovery()
2282 gdev = card->gdev; lcs_recovery()
2289 card->dev->name); lcs_recovery()
2292 card->dev->name); lcs_recovery()
2293 lcs_clear_thread_running_bit(card, LCS_RECOVERY_THREAD); lcs_recovery()
2298 * lcs_remove_device, free buffers and card
2303 struct lcs_card *card; lcs_remove_device() local
2305 card = dev_get_drvdata(&ccwgdev->dev); lcs_remove_device()
2306 if (!card) lcs_remove_device()
2310 LCS_DBF_HEX(3, setup, &card, sizeof(void*)); lcs_remove_device()
2314 if (card->dev) lcs_remove_device()
2315 unregister_netdev(card->dev); lcs_remove_device()
2316 lcs_cleanup_card(card); lcs_remove_device()
2317 lcs_free_card(card); lcs_remove_device()
2322 static int lcs_pm_suspend(struct lcs_card *card) lcs_pm_suspend() argument
2324 if (card->dev) lcs_pm_suspend()
2325 netif_device_detach(card->dev); lcs_pm_suspend()
2326 lcs_set_allowed_threads(card, 0); lcs_pm_suspend()
2327 lcs_wait_for_threads(card, 0xffffffff); lcs_pm_suspend()
2328 if (card->state != DEV_STATE_DOWN) lcs_pm_suspend()
2329 __lcs_shutdown_device(card->gdev, 1); lcs_pm_suspend()
2333 static int lcs_pm_resume(struct lcs_card *card) lcs_pm_resume() argument
2337 if (card->state == DEV_STATE_RECOVER) lcs_pm_resume()
2338 rc = lcs_new_device(card->gdev); lcs_pm_resume()
2339 if (card->dev) lcs_pm_resume()
2340 netif_device_attach(card->dev); lcs_pm_resume()
2342 dev_warn(&card->gdev->dev, "The lcs device driver " lcs_pm_resume()
2360 struct lcs_card *card = dev_get_drvdata(&gdev->dev); lcs_freeze() local
2361 return lcs_pm_suspend(card); lcs_freeze()
2366 struct lcs_card *card = dev_get_drvdata(&gdev->dev); lcs_thaw() local
2367 return lcs_pm_resume(card); lcs_thaw()
2372 struct lcs_card *card = dev_get_drvdata(&gdev->dev); lcs_restore() local
2373 return lcs_pm_resume(card); lcs_restore()
H A Dqeth_l2_sys.c18 struct qeth_card *card = dev_get_drvdata(dev); qeth_bridge_port_role_state_show() local
23 if (!card) qeth_bridge_port_role_state_show()
26 mutex_lock(&card->conf_mutex); qeth_bridge_port_role_state_show()
28 if (qeth_card_hw_is_reachable(card) && qeth_bridge_port_role_state_show()
29 card->options.sbp.supported_funcs) qeth_bridge_port_role_state_show()
30 rc = qeth_bridgeport_query_ports(card, qeth_bridge_port_role_state_show()
31 &card->options.sbp.role, &state); qeth_bridge_port_role_state_show()
45 switch (card->options.sbp.role) { qeth_bridge_port_role_state_show()
56 QETH_CARD_TEXT_(card, 2, "SBP%02x:%02x", qeth_bridge_port_role_state_show()
57 card->options.sbp.role, state); qeth_bridge_port_role_state_show()
62 mutex_unlock(&card->conf_mutex); qeth_bridge_port_role_state_show()
76 struct qeth_card *card = dev_get_drvdata(dev); qeth_bridge_port_role_store() local
80 if (!card) qeth_bridge_port_role_store()
91 mutex_lock(&card->conf_mutex); qeth_bridge_port_role_store()
93 if (qeth_card_hw_is_reachable(card)) { qeth_bridge_port_role_store()
94 rc = qeth_bridgeport_setrole(card, role); qeth_bridge_port_role_store()
96 card->options.sbp.role = role; qeth_bridge_port_role_store()
98 card->options.sbp.role = role; qeth_bridge_port_role_store()
100 mutex_unlock(&card->conf_mutex); qeth_bridge_port_role_store()
120 struct qeth_card *card = dev_get_drvdata(dev); qeth_bridgeport_hostnotification_show() local
123 if (!card) qeth_bridgeport_hostnotification_show()
126 mutex_lock(&card->conf_mutex); qeth_bridgeport_hostnotification_show()
128 enabled = card->options.sbp.hostnotification; qeth_bridgeport_hostnotification_show()
130 mutex_unlock(&card->conf_mutex); qeth_bridgeport_hostnotification_show()
138 struct qeth_card *card = dev_get_drvdata(dev); qeth_bridgeport_hostnotification_store() local
142 if (!card) qeth_bridgeport_hostnotification_store()
152 mutex_lock(&card->conf_mutex); qeth_bridgeport_hostnotification_store()
154 if (qeth_card_hw_is_reachable(card)) { qeth_bridgeport_hostnotification_store()
155 rc = qeth_bridgeport_an_set(card, enable); qeth_bridgeport_hostnotification_store()
157 card->options.sbp.hostnotification = enable; qeth_bridgeport_hostnotification_store()
159 card->options.sbp.hostnotification = enable; qeth_bridgeport_hostnotification_store()
161 mutex_unlock(&card->conf_mutex); qeth_bridgeport_hostnotification_store()
193 * @card: qeth_card structure pointer
197 void qeth_l2_setup_bridgeport_attrs(struct qeth_card *card) qeth_l2_setup_bridgeport_attrs() argument
201 if (!card) qeth_l2_setup_bridgeport_attrs()
203 if (!card->options.sbp.supported_funcs) qeth_l2_setup_bridgeport_attrs()
205 if (card->options.sbp.role != QETH_SBP_ROLE_NONE) { qeth_l2_setup_bridgeport_attrs()
207 qeth_bridgeport_setrole(card, card->options.sbp.role); qeth_l2_setup_bridgeport_attrs()
209 qeth_bridgeport_query_ports(card, qeth_l2_setup_bridgeport_attrs()
210 &card->options.sbp.role, NULL); qeth_l2_setup_bridgeport_attrs()
212 if (card->options.sbp.hostnotification) { qeth_l2_setup_bridgeport_attrs()
213 rc = qeth_bridgeport_an_set(card, 1); qeth_l2_setup_bridgeport_attrs()
215 card->options.sbp.hostnotification = 0; qeth_l2_setup_bridgeport_attrs()
217 qeth_bridgeport_an_set(card, 0); qeth_l2_setup_bridgeport_attrs()
H A Dqeth_l3_sys.c16 static ssize_t qeth_l3_dev_route_show(struct qeth_card *card, qeth_l3_dev_route_show() argument
25 if (card->info.broadcast_capable == QETH_BROADCAST_WITHOUT_ECHO) qeth_l3_dev_route_show()
30 if (card->info.broadcast_capable == QETH_BROADCAST_WITHOUT_ECHO) qeth_l3_dev_route_show()
35 if (card->info.broadcast_capable == QETH_BROADCAST_WITHOUT_ECHO) qeth_l3_dev_route_show()
47 struct qeth_card *card = dev_get_drvdata(dev); qeth_l3_dev_route4_show() local
49 if (!card) qeth_l3_dev_route4_show()
52 return qeth_l3_dev_route_show(card, &card->options.route4, buf); qeth_l3_dev_route4_show()
55 static ssize_t qeth_l3_dev_route_store(struct qeth_card *card, qeth_l3_dev_route_store() argument
62 mutex_lock(&card->conf_mutex); qeth_l3_dev_route_store()
79 if (qeth_card_hw_is_reachable(card) && qeth_l3_dev_route_store()
82 rc = qeth_l3_setrouting_v4(card); qeth_l3_dev_route_store()
84 rc = qeth_l3_setrouting_v6(card); qeth_l3_dev_route_store()
89 mutex_unlock(&card->conf_mutex); qeth_l3_dev_route_store()
96 struct qeth_card *card = dev_get_drvdata(dev); qeth_l3_dev_route4_store() local
98 if (!card) qeth_l3_dev_route4_store()
101 return qeth_l3_dev_route_store(card, &card->options.route4, qeth_l3_dev_route4_store()
111 struct qeth_card *card = dev_get_drvdata(dev); qeth_l3_dev_route6_show() local
113 if (!card) qeth_l3_dev_route6_show()
116 return qeth_l3_dev_route_show(card, &card->options.route6, buf); qeth_l3_dev_route6_show()
122 struct qeth_card *card = dev_get_drvdata(dev); qeth_l3_dev_route6_store() local
124 if (!card) qeth_l3_dev_route6_store()
127 return qeth_l3_dev_route_store(card, &card->options.route6, qeth_l3_dev_route6_store()
137 struct qeth_card *card = dev_get_drvdata(dev); qeth_l3_dev_fake_broadcast_show() local
139 if (!card) qeth_l3_dev_fake_broadcast_show()
142 return sprintf(buf, "%i\n", card->options.fake_broadcast? 1:0); qeth_l3_dev_fake_broadcast_show()
148 struct qeth_card *card = dev_get_drvdata(dev); qeth_l3_dev_fake_broadcast_store() local
152 if (!card) qeth_l3_dev_fake_broadcast_store()
155 mutex_lock(&card->conf_mutex); qeth_l3_dev_fake_broadcast_store()
156 if ((card->state != CARD_STATE_DOWN) && qeth_l3_dev_fake_broadcast_store()
157 (card->state != CARD_STATE_RECOVER)) { qeth_l3_dev_fake_broadcast_store()
164 card->options.fake_broadcast = i; qeth_l3_dev_fake_broadcast_store()
168 mutex_unlock(&card->conf_mutex); qeth_l3_dev_fake_broadcast_store()
178 struct qeth_card *card = dev_get_drvdata(dev); qeth_l3_dev_sniffer_show() local
180 if (!card) qeth_l3_dev_sniffer_show()
183 return sprintf(buf, "%i\n", card->options.sniffer ? 1 : 0); qeth_l3_dev_sniffer_show()
189 struct qeth_card *card = dev_get_drvdata(dev); qeth_l3_dev_sniffer_store() local
193 if (!card) qeth_l3_dev_sniffer_store()
196 if (card->info.type != QETH_CARD_TYPE_IQD) qeth_l3_dev_sniffer_store()
198 if (card->options.cq == QETH_CQ_ENABLED) qeth_l3_dev_sniffer_store()
201 mutex_lock(&card->conf_mutex); qeth_l3_dev_sniffer_store()
202 if ((card->state != CARD_STATE_DOWN) && qeth_l3_dev_sniffer_store()
203 (card->state != CARD_STATE_RECOVER)) { qeth_l3_dev_sniffer_store()
215 card->options.sniffer = i; qeth_l3_dev_sniffer_store()
218 qdio_get_ssqd_desc(CARD_DDEV(card), &card->ssqd); qeth_l3_dev_sniffer_store()
219 if (card->ssqd.qdioac2 & QETH_SNIFF_AVAIL) { qeth_l3_dev_sniffer_store()
220 card->options.sniffer = i; qeth_l3_dev_sniffer_store()
221 if (card->qdio.init_pool.buf_count != qeth_l3_dev_sniffer_store()
223 qeth_realloc_buffer_pool(card, qeth_l3_dev_sniffer_store()
232 mutex_unlock(&card->conf_mutex); qeth_l3_dev_sniffer_store()
243 struct qeth_card *card = dev_get_drvdata(dev); qeth_l3_dev_hsuid_show() local
246 if (!card) qeth_l3_dev_hsuid_show()
249 if (card->info.type != QETH_CARD_TYPE_IQD) qeth_l3_dev_hsuid_show()
252 if (card->state == CARD_STATE_DOWN) qeth_l3_dev_hsuid_show()
255 memcpy(tmp_hsuid, card->options.hsuid, sizeof(tmp_hsuid)); qeth_l3_dev_hsuid_show()
263 struct qeth_card *card = dev_get_drvdata(dev); qeth_l3_dev_hsuid_store() local
268 if (!card) qeth_l3_dev_hsuid_store()
271 if (card->info.type != QETH_CARD_TYPE_IQD) qeth_l3_dev_hsuid_store()
273 if (card->state != CARD_STATE_DOWN && qeth_l3_dev_hsuid_store()
274 card->state != CARD_STATE_RECOVER) qeth_l3_dev_hsuid_store()
276 if (card->options.sniffer) qeth_l3_dev_hsuid_store()
278 if (card->options.cq == QETH_CQ_NOTAVAILABLE) qeth_l3_dev_hsuid_store()
285 if (card->options.hsuid[0]) { qeth_l3_dev_hsuid_store()
293 card->options.hsuid[i - 8]; qeth_l3_dev_hsuid_store()
298 if (!qeth_l3_delete_ip(card, addr)) qeth_l3_dev_hsuid_store()
300 qeth_l3_set_ip_addr_list(card); qeth_l3_dev_hsuid_store()
305 card->options.hsuid[0] = '\0'; qeth_l3_dev_hsuid_store()
306 if (card->dev) qeth_l3_dev_hsuid_store()
307 memcpy(card->dev->perm_addr, card->options.hsuid, 9); qeth_l3_dev_hsuid_store()
308 qeth_configure_cq(card, QETH_CQ_DISABLED); qeth_l3_dev_hsuid_store()
312 if (qeth_configure_cq(card, QETH_CQ_ENABLED)) qeth_l3_dev_hsuid_store()
315 snprintf(card->options.hsuid, sizeof(card->options.hsuid), qeth_l3_dev_hsuid_store()
317 ASCEBC(card->options.hsuid, 8); qeth_l3_dev_hsuid_store()
318 if (card->dev) qeth_l3_dev_hsuid_store()
319 memcpy(card->dev->perm_addr, card->options.hsuid, 9); qeth_l3_dev_hsuid_store()
326 addr->u.a6.addr.s6_addr[i] = card->options.hsuid[i - 8]; qeth_l3_dev_hsuid_store()
331 if (!qeth_l3_add_ip(card, addr)) qeth_l3_dev_hsuid_store()
333 qeth_l3_set_ip_addr_list(card); qeth_l3_dev_hsuid_store()
358 struct qeth_card *card = dev_get_drvdata(dev); qeth_l3_dev_ipato_enable_show() local
360 if (!card) qeth_l3_dev_ipato_enable_show()
363 return sprintf(buf, "%i\n", card->ipato.enabled? 1:0); qeth_l3_dev_ipato_enable_show()
369 struct qeth_card *card = dev_get_drvdata(dev); qeth_l3_dev_ipato_enable_store() local
373 if (!card) qeth_l3_dev_ipato_enable_store()
376 mutex_lock(&card->conf_mutex); qeth_l3_dev_ipato_enable_store()
377 if ((card->state != CARD_STATE_DOWN) && qeth_l3_dev_ipato_enable_store()
378 (card->state != CARD_STATE_RECOVER)) { qeth_l3_dev_ipato_enable_store()
384 card->ipato.enabled = (card->ipato.enabled)? 0 : 1; qeth_l3_dev_ipato_enable_store()
386 card->ipato.enabled = 1; qeth_l3_dev_ipato_enable_store()
387 list_for_each_entry_safe(tmpipa, t, card->ip_tbd_list, entry) { qeth_l3_dev_ipato_enable_store()
389 qeth_l3_is_addr_covered_by_ipato(card, tmpipa)) qeth_l3_dev_ipato_enable_store()
395 card->ipato.enabled = 0; qeth_l3_dev_ipato_enable_store()
396 list_for_each_entry_safe(tmpipa, t, card->ip_tbd_list, entry) { qeth_l3_dev_ipato_enable_store()
405 mutex_unlock(&card->conf_mutex); qeth_l3_dev_ipato_enable_store()
416 struct qeth_card *card = dev_get_drvdata(dev); qeth_l3_dev_ipato_invert4_show() local
418 if (!card) qeth_l3_dev_ipato_invert4_show()
421 return sprintf(buf, "%i\n", card->ipato.invert4? 1:0); qeth_l3_dev_ipato_invert4_show()
428 struct qeth_card *card = dev_get_drvdata(dev); qeth_l3_dev_ipato_invert4_store() local
431 if (!card) qeth_l3_dev_ipato_invert4_store()
434 mutex_lock(&card->conf_mutex); qeth_l3_dev_ipato_invert4_store()
436 card->ipato.invert4 = (card->ipato.invert4)? 0 : 1; qeth_l3_dev_ipato_invert4_store()
438 card->ipato.invert4 = 1; qeth_l3_dev_ipato_invert4_store()
440 card->ipato.invert4 = 0; qeth_l3_dev_ipato_invert4_store()
443 mutex_unlock(&card->conf_mutex); qeth_l3_dev_ipato_invert4_store()
451 static ssize_t qeth_l3_dev_ipato_add_show(char *buf, struct qeth_card *card, qeth_l3_dev_ipato_add_show() argument
463 spin_lock_irqsave(&card->ip_lock, flags); qeth_l3_dev_ipato_add_show()
464 list_for_each_entry(ipatoe, &card->ipato.entries, entry) { qeth_l3_dev_ipato_add_show()
476 spin_unlock_irqrestore(&card->ip_lock, flags); qeth_l3_dev_ipato_add_show()
485 struct qeth_card *card = dev_get_drvdata(dev); qeth_l3_dev_ipato_add4_show() local
487 if (!card) qeth_l3_dev_ipato_add4_show()
490 return qeth_l3_dev_ipato_add_show(buf, card, QETH_PROT_IPV4); qeth_l3_dev_ipato_add4_show()
521 struct qeth_card *card, enum qeth_prot_versions proto) qeth_l3_dev_ipato_add_store()
528 mutex_lock(&card->conf_mutex); qeth_l3_dev_ipato_add_store()
542 rc = qeth_l3_add_ipato_entry(card, ipatoe); qeth_l3_dev_ipato_add_store()
546 mutex_unlock(&card->conf_mutex); qeth_l3_dev_ipato_add_store()
553 struct qeth_card *card = dev_get_drvdata(dev); qeth_l3_dev_ipato_add4_store() local
555 if (!card) qeth_l3_dev_ipato_add4_store()
558 return qeth_l3_dev_ipato_add_store(buf, count, card, QETH_PROT_IPV4); qeth_l3_dev_ipato_add4_store()
566 struct qeth_card *card, enum qeth_prot_versions proto) qeth_l3_dev_ipato_del_store()
572 mutex_lock(&card->conf_mutex); qeth_l3_dev_ipato_del_store()
575 qeth_l3_del_ipato_entry(card, proto, addr, mask_bits); qeth_l3_dev_ipato_del_store()
576 mutex_unlock(&card->conf_mutex); qeth_l3_dev_ipato_del_store()
583 struct qeth_card *card = dev_get_drvdata(dev); qeth_l3_dev_ipato_del4_store() local
585 if (!card) qeth_l3_dev_ipato_del4_store()
588 return qeth_l3_dev_ipato_del_store(buf, count, card, QETH_PROT_IPV4); qeth_l3_dev_ipato_del4_store()
597 struct qeth_card *card = dev_get_drvdata(dev); qeth_l3_dev_ipato_invert6_show() local
599 if (!card) qeth_l3_dev_ipato_invert6_show()
602 return sprintf(buf, "%i\n", card->ipato.invert6? 1:0); qeth_l3_dev_ipato_invert6_show()
608 struct qeth_card *card = dev_get_drvdata(dev); qeth_l3_dev_ipato_invert6_store() local
611 if (!card) qeth_l3_dev_ipato_invert6_store()
614 mutex_lock(&card->conf_mutex); qeth_l3_dev_ipato_invert6_store()
616 card->ipato.invert6 = (card->ipato.invert6)? 0 : 1; qeth_l3_dev_ipato_invert6_store()
618 card->ipato.invert6 = 1; qeth_l3_dev_ipato_invert6_store()
620 card->ipato.invert6 = 0; qeth_l3_dev_ipato_invert6_store()
623 mutex_unlock(&card->conf_mutex); qeth_l3_dev_ipato_invert6_store()
635 struct qeth_card *card = dev_get_drvdata(dev); qeth_l3_dev_ipato_add6_show() local
637 if (!card) qeth_l3_dev_ipato_add6_show()
640 return qeth_l3_dev_ipato_add_show(buf, card, QETH_PROT_IPV6); qeth_l3_dev_ipato_add6_show()
646 struct qeth_card *card = dev_get_drvdata(dev); qeth_l3_dev_ipato_add6_store() local
648 if (!card) qeth_l3_dev_ipato_add6_store()
651 return qeth_l3_dev_ipato_add_store(buf, count, card, QETH_PROT_IPV6); qeth_l3_dev_ipato_add6_store()
661 struct qeth_card *card = dev_get_drvdata(dev); qeth_l3_dev_ipato_del6_store() local
663 if (!card) qeth_l3_dev_ipato_del6_store()
666 return qeth_l3_dev_ipato_del_store(buf, count, card, QETH_PROT_IPV6); qeth_l3_dev_ipato_del6_store()
688 static ssize_t qeth_l3_dev_vipa_add_show(char *buf, struct qeth_card *card, qeth_l3_dev_vipa_add_show() argument
699 spin_lock_irqsave(&card->ip_lock, flags); qeth_l3_dev_vipa_add_show()
700 list_for_each_entry(ipaddr, &card->ip_list, entry) { qeth_l3_dev_vipa_add_show()
714 spin_unlock_irqrestore(&card->ip_lock, flags); qeth_l3_dev_vipa_add_show()
723 struct qeth_card *card = dev_get_drvdata(dev); qeth_l3_dev_vipa_add4_show() local
725 if (!card) qeth_l3_dev_vipa_add4_show()
728 return qeth_l3_dev_vipa_add_show(buf, card, QETH_PROT_IPV4); qeth_l3_dev_vipa_add4_show()
741 struct qeth_card *card, enum qeth_prot_versions proto) qeth_l3_dev_vipa_add_store()
746 mutex_lock(&card->conf_mutex); qeth_l3_dev_vipa_add_store()
749 rc = qeth_l3_add_vipa(card, proto, addr); qeth_l3_dev_vipa_add_store()
750 mutex_unlock(&card->conf_mutex); qeth_l3_dev_vipa_add_store()
757 struct qeth_card *card = dev_get_drvdata(dev); qeth_l3_dev_vipa_add4_store() local
759 if (!card) qeth_l3_dev_vipa_add4_store()
762 return qeth_l3_dev_vipa_add_store(buf, count, card, QETH_PROT_IPV4); qeth_l3_dev_vipa_add4_store()
770 struct qeth_card *card, enum qeth_prot_versions proto) qeth_l3_dev_vipa_del_store()
775 mutex_lock(&card->conf_mutex); qeth_l3_dev_vipa_del_store()
778 qeth_l3_del_vipa(card, proto, addr); qeth_l3_dev_vipa_del_store()
779 mutex_unlock(&card->conf_mutex); qeth_l3_dev_vipa_del_store()
786 struct qeth_card *card = dev_get_drvdata(dev); qeth_l3_dev_vipa_del4_store() local
788 if (!card) qeth_l3_dev_vipa_del4_store()
791 return qeth_l3_dev_vipa_del_store(buf, count, card, QETH_PROT_IPV4); qeth_l3_dev_vipa_del4_store()
800 struct qeth_card *card = dev_get_drvdata(dev); qeth_l3_dev_vipa_add6_show() local
802 if (!card) qeth_l3_dev_vipa_add6_show()
805 return qeth_l3_dev_vipa_add_show(buf, card, QETH_PROT_IPV6); qeth_l3_dev_vipa_add6_show()
811 struct qeth_card *card = dev_get_drvdata(dev); qeth_l3_dev_vipa_add6_store() local
813 if (!card) qeth_l3_dev_vipa_add6_store()
816 return qeth_l3_dev_vipa_add_store(buf, count, card, QETH_PROT_IPV6); qeth_l3_dev_vipa_add6_store()
826 struct qeth_card *card = dev_get_drvdata(dev); qeth_l3_dev_vipa_del6_store() local
828 if (!card) qeth_l3_dev_vipa_del6_store()
831 return qeth_l3_dev_vipa_del_store(buf, count, card, QETH_PROT_IPV6); qeth_l3_dev_vipa_del6_store()
850 static ssize_t qeth_l3_dev_rxip_add_show(char *buf, struct qeth_card *card, qeth_l3_dev_rxip_add_show() argument
861 spin_lock_irqsave(&card->ip_lock, flags); qeth_l3_dev_rxip_add_show()
862 list_for_each_entry(ipaddr, &card->ip_list, entry) { qeth_l3_dev_rxip_add_show()
876 spin_unlock_irqrestore(&card->ip_lock, flags); qeth_l3_dev_rxip_add_show()
885 struct qeth_card *card = dev_get_drvdata(dev); qeth_l3_dev_rxip_add4_show() local
887 if (!card) qeth_l3_dev_rxip_add4_show()
890 return qeth_l3_dev_rxip_add_show(buf, card, QETH_PROT_IPV4); qeth_l3_dev_rxip_add4_show()
903 struct qeth_card *card, enum qeth_prot_versions proto) qeth_l3_dev_rxip_add_store()
908 mutex_lock(&card->conf_mutex); qeth_l3_dev_rxip_add_store()
911 rc = qeth_l3_add_rxip(card, proto, addr); qeth_l3_dev_rxip_add_store()
912 mutex_unlock(&card->conf_mutex); qeth_l3_dev_rxip_add_store()
919 struct qeth_card *card = dev_get_drvdata(dev); qeth_l3_dev_rxip_add4_store() local
921 if (!card) qeth_l3_dev_rxip_add4_store()
924 return qeth_l3_dev_rxip_add_store(buf, count, card, QETH_PROT_IPV4); qeth_l3_dev_rxip_add4_store()
932 struct qeth_card *card, enum qeth_prot_versions proto) qeth_l3_dev_rxip_del_store()
937 mutex_lock(&card->conf_mutex); qeth_l3_dev_rxip_del_store()
940 qeth_l3_del_rxip(card, proto, addr); qeth_l3_dev_rxip_del_store()
941 mutex_unlock(&card->conf_mutex); qeth_l3_dev_rxip_del_store()
948 struct qeth_card *card = dev_get_drvdata(dev); qeth_l3_dev_rxip_del4_store() local
950 if (!card) qeth_l3_dev_rxip_del4_store()
953 return qeth_l3_dev_rxip_del_store(buf, count, card, QETH_PROT_IPV4); qeth_l3_dev_rxip_del4_store()
962 struct qeth_card *card = dev_get_drvdata(dev); qeth_l3_dev_rxip_add6_show() local
964 if (!card) qeth_l3_dev_rxip_add6_show()
967 return qeth_l3_dev_rxip_add_show(buf, card, QETH_PROT_IPV6); qeth_l3_dev_rxip_add6_show()
973 struct qeth_card *card = dev_get_drvdata(dev); qeth_l3_dev_rxip_add6_store() local
975 if (!card) qeth_l3_dev_rxip_add6_store()
978 return qeth_l3_dev_rxip_add_store(buf, count, card, QETH_PROT_IPV6); qeth_l3_dev_rxip_add6_store()
988 struct qeth_card *card = dev_get_drvdata(dev); qeth_l3_dev_rxip_del6_store() local
990 if (!card) qeth_l3_dev_rxip_del6_store()
993 return qeth_l3_dev_rxip_del_store(buf, count, card, QETH_PROT_IPV6); qeth_l3_dev_rxip_del6_store()
520 qeth_l3_dev_ipato_add_store(const char *buf, size_t count, struct qeth_card *card, enum qeth_prot_versions proto) qeth_l3_dev_ipato_add_store() argument
565 qeth_l3_dev_ipato_del_store(const char *buf, size_t count, struct qeth_card *card, enum qeth_prot_versions proto) qeth_l3_dev_ipato_del_store() argument
740 qeth_l3_dev_vipa_add_store(const char *buf, size_t count, struct qeth_card *card, enum qeth_prot_versions proto) qeth_l3_dev_vipa_add_store() argument
769 qeth_l3_dev_vipa_del_store(const char *buf, size_t count, struct qeth_card *card, enum qeth_prot_versions proto) qeth_l3_dev_vipa_del_store() argument
902 qeth_l3_dev_rxip_add_store(const char *buf, size_t count, struct qeth_card *card, enum qeth_prot_versions proto) qeth_l3_dev_rxip_add_store() argument
931 qeth_l3_dev_rxip_del_store(const char *buf, size_t count, struct qeth_card *card, enum qeth_prot_versions proto) qeth_l3_dev_rxip_del_store() argument
H A Dqeth_l2.h13 void qeth_l2_setup_bridgeport_attrs(struct qeth_card *card);
/linux-4.1.27/drivers/isdn/hardware/mISDN/
H A Dw6692.c74 u32 fmask; /* feature mask - bit set per card nr */
96 _set_debug(struct w6692_hw *card) _set_debug() argument
98 card->dch.debug = debug; _set_debug()
99 card->bc[0].bch.debug = debug; _set_debug()
100 card->bc[1].bch.debug = debug; _set_debug()
107 struct w6692_hw *card; set_debug() local
112 list_for_each_entry(card, &Cards, list) set_debug()
113 _set_debug(card); set_debug()
125 MODULE_PARM_DESC(led, "W6692 LED support bitmask (one bit per card)");
127 MODULE_PARM_DESC(pots, "W6692 POTS support bitmask (one bit per card)");
130 ReadW6692(struct w6692_hw *card, u8 offset) ReadW6692() argument
132 return inb(card->addr + offset); ReadW6692()
136 WriteW6692(struct w6692_hw *card, u8 offset, u8 value) WriteW6692() argument
138 outb(value, card->addr + offset); WriteW6692()
154 enable_hwirq(struct w6692_hw *card) enable_hwirq() argument
156 WriteW6692(card, W_IMASK, card->imask); enable_hwirq()
160 disable_hwirq(struct w6692_hw *card) disable_hwirq() argument
162 WriteW6692(card, W_IMASK, 0xff); disable_hwirq()
168 W6692Version(struct w6692_hw *card) W6692Version() argument
172 val = ReadW6692(card, W_D_RBCH); W6692Version()
173 pr_notice("%s: Winbond W6692 version: %s\n", card->name, W6692Version()
178 w6692_led_handler(struct w6692_hw *card, int on) w6692_led_handler() argument
180 if ((!(card->fmask & led)) || card->subtype == W6692_USR) w6692_led_handler()
183 card->xdata &= 0xfb; /* LED ON */ w6692_led_handler()
184 WriteW6692(card, W_XDATA, card->xdata); w6692_led_handler()
186 card->xdata |= 0x04; /* LED OFF */ w6692_led_handler()
187 WriteW6692(card, W_XDATA, card->xdata); w6692_led_handler()
192 ph_command(struct w6692_hw *card, u8 cmd) ph_command() argument
194 pr_debug("%s: ph_command %x\n", card->name, cmd); ph_command()
195 WriteW6692(card, W_CIX, cmd); ph_command()
199 W6692_new_ph(struct w6692_hw *card) W6692_new_ph() argument
201 if (card->state == W_L1CMD_RST) W6692_new_ph()
202 ph_command(card, W_L1CMD_DRC); W6692_new_ph()
203 schedule_event(&card->dch, FLG_PHCHANGE); W6692_new_ph()
209 struct w6692_hw *card = dch->hw; W6692_ph_bh() local
211 switch (card->state) { W6692_ph_bh()
251 card->name, card->state, dch->state); W6692_ph_bh()
254 pr_debug("%s: TE newstate %02x\n", card->name, dch->state); W6692_ph_bh()
258 W6692_empty_Dfifo(struct w6692_hw *card, int count) W6692_empty_Dfifo() argument
260 struct dchannel *dch = &card->dch; W6692_empty_Dfifo()
263 pr_debug("%s: empty_Dfifo %d\n", card->name, count); W6692_empty_Dfifo()
265 dch->rx_skb = mI_alloc_skb(card->dch.maxlen, GFP_ATOMIC); W6692_empty_Dfifo()
267 pr_info("%s: D receive out of memory\n", card->name); W6692_empty_Dfifo()
268 WriteW6692(card, W_D_CMDR, W_D_CMDR_RACK); W6692_empty_Dfifo()
273 pr_debug("%s: empty_Dfifo overrun %d\n", card->name, W6692_empty_Dfifo()
275 WriteW6692(card, W_D_CMDR, W_D_CMDR_RACK); W6692_empty_Dfifo()
279 insb(card->addr + W_D_RFIFO, ptr, count); W6692_empty_Dfifo()
280 WriteW6692(card, W_D_CMDR, W_D_CMDR_RACK); W6692_empty_Dfifo()
282 snprintf(card->log, 63, "D-recv %s %d ", W6692_empty_Dfifo()
283 card->name, count); W6692_empty_Dfifo()
284 print_hex_dump_bytes(card->log, DUMP_PREFIX_OFFSET, ptr, count); W6692_empty_Dfifo()
289 W6692_fill_Dfifo(struct w6692_hw *card) W6692_fill_Dfifo() argument
291 struct dchannel *dch = &card->dch; W6692_fill_Dfifo()
296 pr_debug("%s: fill_Dfifo\n", card->name); W6692_fill_Dfifo()
308 outsb(card->addr + W_D_XFIFO, ptr, count); W6692_fill_Dfifo()
309 WriteW6692(card, W_D_CMDR, cmd); W6692_fill_Dfifo()
311 pr_debug("%s: fill_Dfifo dbusytimer running\n", card->name); W6692_fill_Dfifo()
318 snprintf(card->log, 63, "D-send %s %d ", W6692_fill_Dfifo()
319 card->name, count); W6692_fill_Dfifo()
320 print_hex_dump_bytes(card->log, DUMP_PREFIX_OFFSET, ptr, count); W6692_fill_Dfifo()
325 d_retransmit(struct w6692_hw *card) d_retransmit() argument
327 struct dchannel *dch = &card->dch; d_retransmit()
338 W6692_fill_Dfifo(card); d_retransmit()
340 pr_info("%s: %s without TX_BUSY\n", card->name, __func__); d_retransmit()
343 W6692_fill_Dfifo(card); d_retransmit()
345 pr_info("%s: XDU no TX_BUSY\n", card->name); d_retransmit()
347 W6692_fill_Dfifo(card); d_retransmit()
352 handle_rxD(struct w6692_hw *card) { handle_rxD() argument
356 stat = ReadW6692(card, W_D_RSTA); handle_rxD()
359 pr_debug("%s: D-channel RDOV\n", card->name); handle_rxD()
361 card->dch.err_rx++; handle_rxD()
365 pr_debug("%s: D-channel CRC error\n", card->name); handle_rxD()
367 card->dch.err_crc++; handle_rxD()
371 pr_debug("%s: D-channel ABORT\n", card->name); handle_rxD()
373 card->dch.err_rx++; handle_rxD()
376 if (card->dch.rx_skb) handle_rxD()
377 dev_kfree_skb(card->dch.rx_skb); handle_rxD()
378 card->dch.rx_skb = NULL; handle_rxD()
379 WriteW6692(card, W_D_CMDR, W_D_CMDR_RACK | W_D_CMDR_RRST); handle_rxD()
381 count = ReadW6692(card, W_D_RBCL) & (W_D_FIFO_THRESH - 1); handle_rxD()
384 W6692_empty_Dfifo(card, count); handle_rxD()
385 recv_Dchannel(&card->dch); handle_rxD()
390 handle_txD(struct w6692_hw *card) { handle_txD() argument
391 if (test_and_clear_bit(FLG_BUSY_TIMER, &card->dch.Flags)) handle_txD()
392 del_timer(&card->dch.timer); handle_txD()
393 if (card->dch.tx_skb && card->dch.tx_idx < card->dch.tx_skb->len) { handle_txD()
394 W6692_fill_Dfifo(card); handle_txD()
396 if (card->dch.tx_skb) handle_txD()
397 dev_kfree_skb(card->dch.tx_skb); handle_txD()
398 if (get_next_dframe(&card->dch)) handle_txD()
399 W6692_fill_Dfifo(card); handle_txD()
404 handle_statusD(struct w6692_hw *card) handle_statusD() argument
406 struct dchannel *dch = &card->dch; handle_statusD()
409 exval = ReadW6692(card, W_D_EXIR); handle_statusD()
411 pr_debug("%s: D_EXIR %02x\n", card->name, exval); handle_statusD()
414 pr_debug("%s: D-channel underrun/collision\n", card->name); handle_statusD()
418 d_retransmit(card); handle_statusD()
421 pr_debug("%s: D-channel RDOV\n", card->name); handle_statusD()
422 WriteW6692(card, W_D_CMDR, W_D_CMDR_RRST); handle_statusD()
425 pr_debug("%s: spurious TIN2 interrupt\n", card->name); handle_statusD()
427 v1 = ReadW6692(card, W_MOSR); handle_statusD()
429 card->name, v1); handle_statusD()
432 cir = ReadW6692(card, W_CIR); handle_statusD()
433 pr_debug("%s: ISC CIR %02X\n", card->name, cir); handle_statusD()
436 pr_debug("%s: ph_state_change %x -> %x\n", card->name, handle_statusD()
438 card->state = v1; handle_statusD()
439 if (card->fmask & led) { handle_statusD()
443 w6692_led_handler(card, 1); handle_statusD()
446 w6692_led_handler(card, 0); handle_statusD()
450 W6692_new_ph(card); handle_statusD()
453 v1 = ReadW6692(card, W_SQR); handle_statusD()
454 pr_debug("%s: SCC SQR %02X\n", card->name, v1); handle_statusD()
458 pr_debug("%s: spurious WEXP interrupt!\n", card->name); handle_statusD()
460 pr_debug("%s: spurious TEXP interrupt!\n", card->name); handle_statusD()
466 struct w6692_hw *card = wch->bch.hw; W6692_empty_Bfifo() local
470 pr_debug("%s: empty_Bfifo %d\n", card->name, count); W6692_empty_Bfifo()
472 pr_debug("%s: empty_Bfifo ISDN_P_NONE\n", card->name); W6692_empty_Bfifo()
489 card->name, wch->bch.nr, count); W6692_empty_Bfifo()
496 snprintf(card->log, 63, "B%1d-recv %s %d ", W6692_empty_Bfifo()
497 wch->bch.nr, card->name, count); W6692_empty_Bfifo()
498 print_hex_dump_bytes(card->log, DUMP_PREFIX_OFFSET, ptr, count); W6692_empty_Bfifo()
505 struct w6692_hw *card = wch->bch.hw; W6692_fill_Bfifo() local
509 pr_debug("%s: fill Bfifo\n", card->name); W6692_fill_Bfifo()
527 pr_debug("%s: fill Bfifo%d/%d\n", card->name, W6692_fill_Bfifo()
540 snprintf(card->log, 63, "B%1d-send %s %d ", W6692_fill_Bfifo()
541 wch->bch.nr, card->name, count); W6692_fill_Bfifo()
542 print_hex_dump_bytes(card->log, DUMP_PREFIX_OFFSET, ptr, count); W6692_fill_Bfifo()
550 struct w6692_hw *card = wch->bch.hw;
554 if ((!(card->fmask & pots)) ||
565 card->xaddr &= 0xc7;
567 card->xaddr &= 0xf8;
569 card->xaddr |= val;
570 WriteW6692(card, W_XADDR, card->xaddr);
577 struct w6692_hw *card = wch->bch.hw;
579 if ((!(card->fmask & pots)) ||
585 card->pctl |= ((wch->bch.nr & 2) ? W_PCTL_PCX : 0);
586 WriteW6692(card, W_PCTL, card->pctl);
594 struct w6692_hw *card = wch->bch.hw; disable_pots() local
596 if (!(card->fmask & pots)) disable_pots()
608 struct w6692_hw *card; w6692_mode() local
610 card = wch->bch.hw; w6692_mode()
611 pr_debug("%s: B%d protocol %x-->%x\n", card->name, w6692_mode()
615 if ((card->fmask & pots) && (wch->b_mode & W_B_MODE_EPCM)) w6692_mode()
643 pr_info("%s: protocol %x not known\n", card->name, pr); w6692_mode()
668 W6692B_interrupt(struct w6692_hw *card, int ch) W6692B_interrupt() argument
670 struct w6692_ch *wch = &card->bc[ch]; W6692B_interrupt()
675 pr_debug("%s: B%d EXIR %02x\n", card->name, wch->bch.nr, stat); W6692B_interrupt()
681 pr_debug("%s: B%d RDOV proto=%x\n", card->name, W6692B_interrupt()
690 card->name, wch->bch.nr); W6692B_interrupt()
697 card->name, wch->bch.nr); W6692B_interrupt()
720 pr_debug("%s: B%d RDOV proto=%x\n", card->name, W6692B_interrupt()
736 pr_debug("%s: B%d RDOV IRQ proto=%x\n", card->name, W6692B_interrupt()
748 pr_debug("%s: B%d star %02x\n", card->name, W6692B_interrupt()
752 pr_warning("%s: B%d XDOW proto=%x\n", card->name, W6692B_interrupt()
770 pr_warning("%s: B%d XDUN proto=%x\n", card->name, W6692B_interrupt()
789 struct w6692_hw *card = dev_id; w6692_irq() local
792 spin_lock(&card->lock); w6692_irq()
793 ista = ReadW6692(card, W_ISTA); w6692_irq()
794 if ((ista | card->imask) == card->imask) { w6692_irq()
796 spin_unlock(&card->lock); w6692_irq()
799 card->irqcnt++; w6692_irq()
800 pr_debug("%s: ista %02x\n", card->name, ista); w6692_irq()
801 ista &= ~card->imask; w6692_irq()
803 W6692B_interrupt(card, 0); w6692_irq()
805 W6692B_interrupt(card, 1); w6692_irq()
807 handle_rxD(card); w6692_irq()
809 W6692_empty_Dfifo(card, W_D_FIFO_THRESH); w6692_irq()
811 handle_txD(card); w6692_irq()
813 handle_statusD(card); w6692_irq()
815 pr_debug("%s: W6692 spurious XINT!\n", card->name); w6692_irq()
817 spin_unlock(&card->lock); w6692_irq()
824 struct w6692_hw *card = dch->hw; dbusy_timer_handler() local
829 spin_lock_irqsave(&card->lock, flags); dbusy_timer_handler()
830 rbch = ReadW6692(card, W_D_RBCH); dbusy_timer_handler()
831 star = ReadW6692(card, W_D_STAR); dbusy_timer_handler()
833 card->name, rbch, star); dbusy_timer_handler()
843 card->name); dbusy_timer_handler()
845 WriteW6692(card, W_D_CMDR, W_D_CMDR_XRST); dbusy_timer_handler()
847 spin_unlock_irqrestore(&card->lock, flags); dbusy_timer_handler()
851 void initW6692(struct w6692_hw *card) initW6692() argument
855 card->dch.timer.function = (void *)dbusy_timer_handler; initW6692()
856 card->dch.timer.data = (u_long)&card->dch; initW6692()
857 init_timer(&card->dch.timer); initW6692()
858 w6692_mode(&card->bc[0], ISDN_P_NONE); initW6692()
859 w6692_mode(&card->bc[1], ISDN_P_NONE); initW6692()
860 WriteW6692(card, W_D_CTL, 0x00); initW6692()
861 disable_hwirq(card); initW6692()
862 WriteW6692(card, W_D_SAM, 0xff); initW6692()
863 WriteW6692(card, W_D_TAM, 0xff); initW6692()
864 WriteW6692(card, W_D_MODE, W_D_MODE_RACT); initW6692()
865 card->state = W_L1CMD_RST; initW6692()
866 ph_command(card, W_L1CMD_RST); initW6692()
867 ph_command(card, W_L1CMD_ECK); initW6692()
869 card->imask = 0x18; initW6692()
870 WriteW6692(card, W_D_EXIM, 0x00); initW6692()
871 WriteW6692B(&card->bc[0], W_B_EXIM, 0); initW6692()
872 WriteW6692B(&card->bc[1], W_B_EXIM, 0); initW6692()
874 WriteW6692(card, W_D_CMDR, W_D_CMDR_RRST | W_D_CMDR_XRST); initW6692()
876 WriteW6692B(&card->bc[0], W_B_CMDR, W_B_CMDR_RRST | W_B_CMDR_XRST); initW6692()
877 WriteW6692B(&card->bc[1], W_B_CMDR, W_B_CMDR_RRST | W_B_CMDR_XRST); initW6692()
879 if (card->subtype == W6692_USR) { initW6692()
884 card->pctl = 0x80; initW6692()
885 card->xdata = 0; initW6692()
886 WriteW6692(card, W_PCTL, card->pctl); initW6692()
887 WriteW6692(card, W_XDATA, card->xdata); initW6692()
889 card->pctl = W_PCTL_OE5 | W_PCTL_OE4 | W_PCTL_OE2 | initW6692()
891 card->xaddr = 0x00;/* all sw off */ initW6692()
892 if (card->fmask & pots) initW6692()
893 card->xdata |= 0x06; /* POWER UP/ LED OFF / ALAW */ initW6692()
894 if (card->fmask & led) initW6692()
895 card->xdata |= 0x04; /* LED OFF */ initW6692()
896 if ((card->fmask & pots) || (card->fmask & led)) { initW6692()
897 WriteW6692(card, W_PCTL, card->pctl); initW6692()
898 WriteW6692(card, W_XADDR, card->xaddr); initW6692()
899 WriteW6692(card, W_XDATA, card->xdata); initW6692()
900 val = ReadW6692(card, W_XADDR); initW6692()
903 card->name, val); initW6692()
909 reset_w6692(struct w6692_hw *card) reset_w6692() argument
911 WriteW6692(card, W_D_CTL, W_D_CTL_SRST); reset_w6692()
913 WriteW6692(card, W_D_CTL, 0); reset_w6692()
917 init_card(struct w6692_hw *card) init_card() argument
922 spin_lock_irqsave(&card->lock, flags); init_card()
923 disable_hwirq(card); init_card()
924 spin_unlock_irqrestore(&card->lock, flags); init_card()
925 if (request_irq(card->irq, w6692_irq, IRQF_SHARED, card->name, card)) { init_card()
926 pr_info("%s: couldn't get interrupt %d\n", card->name, init_card()
927 card->irq); init_card()
931 spin_lock_irqsave(&card->lock, flags); init_card()
932 initW6692(card); init_card()
933 enable_hwirq(card); init_card()
934 spin_unlock_irqrestore(&card->lock, flags); init_card()
938 pr_notice("%s: IRQ %d count %d\n", card->name, init_card()
939 card->irq, card->irqcnt); init_card()
940 if (!card->irqcnt) { init_card()
942 card->name, card->irq, 3 - cnt); init_card()
943 reset_w6692(card); init_card()
947 free_irq(card->irq, card); init_card()
956 struct w6692_hw *card = bch->hw; w6692_l2l1B() local
963 spin_lock_irqsave(&card->lock, flags); w6692_l2l1B()
969 spin_unlock_irqrestore(&card->lock, flags); w6692_l2l1B()
972 spin_lock_irqsave(&card->lock, flags); w6692_l2l1B()
977 spin_unlock_irqrestore(&card->lock, flags); w6692_l2l1B()
983 spin_lock_irqsave(&card->lock, flags); w6692_l2l1B()
986 spin_unlock_irqrestore(&card->lock, flags); w6692_l2l1B()
993 card->name, __func__, hh->prim, hh->id); w6692_l2l1B()
1008 open_bchannel(struct w6692_hw *card, struct channel_req *rq) open_bchannel() argument
1016 bch = &card->bc[rq->adr.channel - 1].bch; open_bchannel()
1025 channel_ctrl(struct w6692_hw *card, struct mISDN_ctrl_req *cq) channel_ctrl() argument
1034 ret = l1_event(card->dch.l1, HW_TIMER3_VALUE | (cq->p1 & 0xff)); channel_ctrl()
1037 pr_info("%s: unknown CTRL OP %x\n", card->name, cq->op); channel_ctrl()
1049 struct w6692_hw *card = bch->hw; w6692_bctrl() local
1053 pr_debug("%s: %s cmd:%x %p\n", card->name, __func__, cmd, arg); w6692_bctrl()
1058 spin_lock_irqsave(&card->lock, flags); w6692_bctrl()
1061 spin_unlock_irqrestore(&card->lock, flags); w6692_bctrl()
1072 card->name, __func__, cmd); w6692_bctrl()
1082 struct w6692_hw *card = container_of(dch, struct w6692_hw, dch); w6692_l2l1D() local
1090 spin_lock_irqsave(&card->lock, flags); w6692_l2l1D()
1094 W6692_fill_Dfifo(card); w6692_l2l1D()
1096 spin_unlock_irqrestore(&card->lock, flags); w6692_l2l1D()
1099 spin_unlock_irqrestore(&card->lock, flags); w6692_l2l1D()
1118 struct w6692_hw *card = container_of(dch, struct w6692_hw, dch); w6692_l1callback() local
1121 pr_debug("%s: cmd(%x) state(%02x)\n", card->name, cmd, card->state); w6692_l1callback()
1124 spin_lock_irqsave(&card->lock, flags); w6692_l1callback()
1125 ph_command(card, W_L1CMD_AR8); w6692_l1callback()
1126 spin_unlock_irqrestore(&card->lock, flags); w6692_l1callback()
1129 spin_lock_irqsave(&card->lock, flags); w6692_l1callback()
1130 ph_command(card, W_L1CMD_AR10); w6692_l1callback()
1131 spin_unlock_irqrestore(&card->lock, flags); w6692_l1callback()
1134 spin_lock_irqsave(&card->lock, flags); w6692_l1callback()
1135 if (card->state != W_L1IND_DRD) w6692_l1callback()
1136 ph_command(card, W_L1CMD_RST); w6692_l1callback()
1137 ph_command(card, W_L1CMD_ECK); w6692_l1callback()
1138 spin_unlock_irqrestore(&card->lock, flags); w6692_l1callback()
1156 spin_lock_irqsave(&card->lock, flags); w6692_l1callback()
1157 ph_command(card, W_L1CMD_ECK); w6692_l1callback()
1158 spin_unlock_irqrestore(&card->lock, flags); w6692_l1callback()
1171 pr_debug("%s: %s unknown command %x\n", card->name, w6692_l1callback()
1179 open_dchannel(struct w6692_hw *card, struct channel_req *rq, void *caller) open_dchannel() argument
1181 pr_debug("%s: %s dev(%d) open from %p\n", card->name, __func__, open_dchannel()
1182 card->dch.dev.id, caller); open_dchannel()
1188 rq->ch = &card->dch.dev.D; open_dchannel()
1190 if (card->dch.state == 7) open_dchannel()
1201 struct w6692_hw *card = container_of(dch, struct w6692_hw, dch); w6692_dctrl() local
1205 pr_debug("%s: DCTRL: %x %p\n", card->name, cmd, arg); w6692_dctrl()
1210 err = open_dchannel(card, rq, __builtin_return_address(0)); w6692_dctrl()
1212 err = open_bchannel(card, rq); w6692_dctrl()
1216 pr_info("%s: cannot get module\n", card->name); w6692_dctrl()
1219 pr_debug("%s: dev(%d) close from %p\n", card->name, w6692_dctrl()
1224 err = channel_ctrl(card, arg); w6692_dctrl()
1227 pr_debug("%s: unknown DCTRL command %x\n", card->name, cmd); w6692_dctrl()
1234 setup_w6692(struct w6692_hw *card) setup_w6692() argument
1238 if (!request_region(card->addr, 256, card->name)) { setup_w6692()
1239 pr_info("%s: config port %x-%x already in use\n", card->name, setup_w6692()
1240 card->addr, card->addr + 255); setup_w6692()
1243 W6692Version(card); setup_w6692()
1244 card->bc[0].addr = card->addr; setup_w6692()
1245 card->bc[1].addr = card->addr + 0x40; setup_w6692()
1246 val = ReadW6692(card, W_ISTA); setup_w6692()
1248 pr_notice("%s ISTA=%02x\n", card->name, val); setup_w6692()
1249 val = ReadW6692(card, W_IMASK); setup_w6692()
1251 pr_notice("%s IMASK=%02x\n", card->name, val); setup_w6692()
1252 val = ReadW6692(card, W_D_EXIR); setup_w6692()
1254 pr_notice("%s D_EXIR=%02x\n", card->name, val); setup_w6692()
1255 val = ReadW6692(card, W_D_EXIM); setup_w6692()
1257 pr_notice("%s D_EXIM=%02x\n", card->name, val); setup_w6692()
1258 val = ReadW6692(card, W_D_RSTA); setup_w6692()
1260 pr_notice("%s D_RSTA=%02x\n", card->name, val); setup_w6692()
1265 release_card(struct w6692_hw *card) release_card() argument
1269 spin_lock_irqsave(&card->lock, flags); release_card()
1270 disable_hwirq(card); release_card()
1271 w6692_mode(&card->bc[0], ISDN_P_NONE); release_card()
1272 w6692_mode(&card->bc[1], ISDN_P_NONE); release_card()
1273 if ((card->fmask & led) || card->subtype == W6692_USR) { release_card()
1274 card->xdata |= 0x04; /* LED OFF */ release_card()
1275 WriteW6692(card, W_XDATA, card->xdata); release_card()
1277 spin_unlock_irqrestore(&card->lock, flags); release_card()
1278 free_irq(card->irq, card); release_card()
1279 l1_event(card->dch.l1, CLOSE_CHANNEL); release_card()
1280 mISDN_unregister_device(&card->dch.dev); release_card()
1281 release_region(card->addr, 256); release_card()
1282 mISDN_freebchannel(&card->bc[1].bch); release_card()
1283 mISDN_freebchannel(&card->bc[0].bch); release_card()
1284 mISDN_freedchannel(&card->dch); release_card()
1286 list_del(&card->list); release_card()
1288 pci_disable_device(card->pdev); release_card()
1289 pci_set_drvdata(card->pdev, NULL); release_card()
1290 kfree(card); release_card()
1294 setup_instance(struct w6692_hw *card) setup_instance() argument
1299 snprintf(card->name, MISDN_MAX_IDLEN - 1, "w6692.%d", w6692_cnt + 1); setup_instance()
1301 list_add_tail(&card->list, &Cards); setup_instance()
1303 card->fmask = (1 << w6692_cnt); setup_instance()
1304 _set_debug(card); setup_instance()
1305 spin_lock_init(&card->lock); setup_instance()
1306 mISDN_initdchannel(&card->dch, MAX_DFRAME_LEN_L1, W6692_ph_bh); setup_instance()
1307 card->dch.dev.Dprotocols = (1 << ISDN_P_TE_S0); setup_instance()
1308 card->dch.dev.D.send = w6692_l2l1D; setup_instance()
1309 card->dch.dev.D.ctrl = w6692_dctrl; setup_instance()
1310 card->dch.dev.Bprotocols = (1 << (ISDN_P_B_RAW & ISDN_P_B_MASK)) | setup_instance()
1312 card->dch.hw = card; setup_instance()
1313 card->dch.dev.nrbchan = 2; setup_instance()
1315 mISDN_initbchannel(&card->bc[i].bch, MAX_DATA_MEM, setup_instance()
1317 card->bc[i].bch.hw = card; setup_instance()
1318 card->bc[i].bch.nr = i + 1; setup_instance()
1319 card->bc[i].bch.ch.nr = i + 1; setup_instance()
1320 card->bc[i].bch.ch.send = w6692_l2l1B; setup_instance()
1321 card->bc[i].bch.ch.ctrl = w6692_bctrl; setup_instance()
1322 set_channelmap(i + 1, card->dch.dev.channelmap); setup_instance()
1323 list_add(&card->bc[i].bch.ch.list, &card->dch.dev.bchannels); setup_instance()
1325 err = setup_w6692(card); setup_instance()
1328 err = mISDN_register_device(&card->dch.dev, &card->pdev->dev, setup_instance()
1329 card->name); setup_instance()
1332 err = init_card(card); setup_instance()
1335 err = create_l1(&card->dch, w6692_l1callback); setup_instance()
1342 free_irq(card->irq, card); setup_instance()
1344 mISDN_unregister_device(&card->dch.dev); setup_instance()
1346 release_region(card->addr, 256); setup_instance()
1348 mISDN_freebchannel(&card->bc[1].bch); setup_instance()
1349 mISDN_freebchannel(&card->bc[0].bch); setup_instance()
1350 mISDN_freedchannel(&card->dch); setup_instance()
1352 list_del(&card->list); setup_instance()
1354 kfree(card); setup_instance()
1362 struct w6692_hw *card; w6692_probe() local
1365 card = kzalloc(sizeof(struct w6692_hw), GFP_KERNEL); w6692_probe()
1366 if (!card) { w6692_probe()
1367 pr_info("No kmem for w6692 card\n"); w6692_probe()
1370 card->pdev = pdev; w6692_probe()
1371 card->subtype = m->subtype; w6692_probe()
1374 kfree(card); w6692_probe()
1381 card->addr = pci_resource_start(pdev, 1); w6692_probe()
1382 card->irq = pdev->irq; w6692_probe()
1383 pci_set_drvdata(pdev, card); w6692_probe()
1384 err = setup_instance(card); w6692_probe()
1393 struct w6692_hw *card = pci_get_drvdata(pdev); w6692_remove_pci() local
1395 if (card) w6692_remove_pci()
1396 release_card(card); w6692_remove_pci()
H A Dnetjet.c106 _set_debug(struct tiger_hw *card) _set_debug() argument
108 card->isac.dch.debug = debug; _set_debug()
109 card->bc[0].bch.debug = debug; _set_debug()
110 card->bc[1].bch.debug = debug; _set_debug()
117 struct tiger_hw *card; set_debug() local
122 list_for_each_entry(card, &Cards, list) set_debug()
123 _set_debug(card); set_debug()
136 nj_disable_hwirq(struct tiger_hw *card) nj_disable_hwirq() argument
138 outb(0, card->base + NJ_IRQMASK0); nj_disable_hwirq()
139 outb(0, card->base + NJ_IRQMASK1); nj_disable_hwirq()
146 struct tiger_hw *card = p; ReadISAC_nj() local
149 card->auxd &= 0xfc; ReadISAC_nj()
150 card->auxd |= (offset >> 4) & 3; ReadISAC_nj()
151 outb(card->auxd, card->base + NJ_AUXDATA); ReadISAC_nj()
152 ret = inb(card->base + NJ_ISAC_OFF + ((offset & 0x0f) << 2)); ReadISAC_nj()
159 struct tiger_hw *card = p; WriteISAC_nj() local
161 card->auxd &= 0xfc; WriteISAC_nj()
162 card->auxd |= (offset >> 4) & 3; WriteISAC_nj()
163 outb(card->auxd, card->base + NJ_AUXDATA); WriteISAC_nj()
164 outb(value, card->base + NJ_ISAC_OFF + ((offset & 0x0f) << 2)); WriteISAC_nj()
170 struct tiger_hw *card = p; ReadFiFoISAC_nj() local
172 card->auxd &= 0xfc; ReadFiFoISAC_nj()
173 outb(card->auxd, card->base + NJ_AUXDATA); ReadFiFoISAC_nj()
174 insb(card->base + NJ_ISAC_OFF, data, size); ReadFiFoISAC_nj()
180 struct tiger_hw *card = p; WriteFiFoISAC_nj() local
182 card->auxd &= 0xfc; WriteFiFoISAC_nj()
183 outb(card->auxd, card->base + NJ_AUXDATA); WriteFiFoISAC_nj()
184 outsb(card->base + NJ_ISAC_OFF, data, size); WriteFiFoISAC_nj()
190 struct tiger_hw *card = bc->bch.hw; fill_mem() local
193 pr_debug("%s: B%1d fill %02x len %d idx %d/%d\n", card->name, fill_mem()
194 bc->bch.nr, fill, cnt, idx, card->send.idx); fill_mem()
201 val = card->send.start[idx]; fill_mem()
204 card->send.start[idx++] = val; fill_mem()
205 if (idx >= card->send.size) fill_mem()
213 struct tiger_hw *card = bc->bch.hw; mode_tiger() local
215 pr_debug("%s: B%1d protocol %x-->%x\n", card->name, mode_tiger()
221 fill_mem(bc, 0, card->send.size, 0xff); mode_tiger()
224 if ((card->bc[0].bch.state == ISDN_P_NONE) && mode_tiger()
225 (card->bc[1].bch.state == ISDN_P_NONE)) { mode_tiger()
226 card->dmactrl = 0; mode_tiger()
227 outb(card->dmactrl, card->base + NJ_DMACTRL); mode_tiger()
228 outb(0, card->base + NJ_IRQMASK0); mode_tiger()
240 bc->free = card->send.size / 2; mode_tiger()
244 if (!card->dmactrl) { mode_tiger()
245 card->dmactrl = 1; mode_tiger()
246 outb(card->dmactrl, card->base + NJ_DMACTRL); mode_tiger()
247 outb(0x0f, card->base + NJ_IRQMASK0); mode_tiger()
254 bc->free = card->send.size / 2; mode_tiger()
260 if (!card->dmactrl) { mode_tiger()
261 card->dmactrl = 1; mode_tiger()
262 outb(card->dmactrl, card->base + NJ_DMACTRL); mode_tiger()
263 outb(0x0f, card->base + NJ_IRQMASK0); mode_tiger()
267 pr_info("%s: %s protocol %x not handled\n", card->name, mode_tiger()
271 card->send.dmacur = inl(card->base + NJ_DMA_READ_ADR); mode_tiger()
272 card->recv.dmacur = inl(card->base + NJ_DMA_WRITE_ADR); mode_tiger()
273 card->send.idx = (card->send.dmacur - card->send.dmastart) >> 2; mode_tiger()
274 card->recv.idx = (card->recv.dmacur - card->recv.dmastart) >> 2; mode_tiger()
276 card->name, __func__, mode_tiger()
277 inb(card->base + NJ_DMACTRL), mode_tiger()
278 inb(card->base + NJ_IRQMASK0), mode_tiger()
279 inb(card->base + NJ_IRQSTAT0), mode_tiger()
280 card->send.idx, mode_tiger()
281 card->recv.idx); mode_tiger()
286 nj_reset(struct tiger_hw *card) nj_reset() argument
288 outb(0xff, card->base + NJ_CTRL); /* Reset On */ nj_reset()
293 if (card->typ == NETJET_S_TJ320) /* TJ320 */ nj_reset()
294 card->ctrlreg = 0x40; /* Reset Off and status read clear */ nj_reset()
296 card->ctrlreg = 0x00; /* Reset Off and status read clear */ nj_reset()
297 outb(card->ctrlreg, card->base + NJ_CTRL); nj_reset()
301 card->auxd = 0; nj_reset()
302 card->dmactrl = 0; nj_reset()
303 outb(~NJ_ISACIRQ, card->base + NJ_AUXCTRL); nj_reset()
304 outb(NJ_ISACIRQ, card->base + NJ_IRQMASK1); nj_reset()
305 outb(card->auxd, card->base + NJ_AUXDATA); nj_reset()
309 inittiger(struct tiger_hw *card) inittiger() argument
313 card->dma_p = pci_alloc_consistent(card->pdev, NJ_DMA_SIZE, inittiger()
314 &card->dma); inittiger()
315 if (!card->dma_p) { inittiger()
316 pr_info("%s: No DMA memory\n", card->name); inittiger()
319 if ((u64)card->dma > 0xffffffff) { inittiger()
320 pr_info("%s: DMA outside 32 bit\n", card->name); inittiger()
324 card->bc[i].hsbuf = kmalloc(NJ_DMA_TXSIZE, GFP_ATOMIC); inittiger()
325 if (!card->bc[i].hsbuf) { inittiger()
326 pr_info("%s: no B%d send buffer\n", card->name, i + 1); inittiger()
329 card->bc[i].hrbuf = kmalloc(NJ_DMA_RXSIZE, GFP_ATOMIC); inittiger()
330 if (!card->bc[i].hrbuf) { inittiger()
331 pr_info("%s: no B%d recv buffer\n", card->name, i + 1); inittiger()
335 memset(card->dma_p, 0xff, NJ_DMA_SIZE); inittiger()
337 card->send.start = card->dma_p; inittiger()
338 card->send.dmastart = (u32)card->dma; inittiger()
339 card->send.dmaend = card->send.dmastart + inittiger()
341 card->send.dmairq = card->send.dmastart + inittiger()
343 card->send.size = NJ_DMA_TXSIZE; inittiger()
347 " size %zu u32\n", card->name, inittiger()
348 card->send.dmastart, card->send.dmairq, inittiger()
349 card->send.dmaend, card->send.start, card->send.size); inittiger()
351 outl(card->send.dmastart, card->base + NJ_DMA_READ_START); inittiger()
352 outl(card->send.dmairq, card->base + NJ_DMA_READ_IRQ); inittiger()
353 outl(card->send.dmaend, card->base + NJ_DMA_READ_END); inittiger()
355 card->recv.start = card->dma_p + (NJ_DMA_SIZE / 2); inittiger()
356 card->recv.dmastart = (u32)card->dma + (NJ_DMA_SIZE / 2); inittiger()
357 card->recv.dmaend = card->recv.dmastart + inittiger()
359 card->recv.dmairq = card->recv.dmastart + inittiger()
361 card->recv.size = NJ_DMA_RXSIZE; inittiger()
365 " size %zu u32\n", card->name, inittiger()
366 card->recv.dmastart, card->recv.dmairq, inittiger()
367 card->recv.dmaend, card->recv.start, card->recv.size); inittiger()
369 outl(card->recv.dmastart, card->base + NJ_DMA_WRITE_START); inittiger()
370 outl(card->recv.dmairq, card->base + NJ_DMA_WRITE_IRQ); inittiger()
371 outl(card->recv.dmaend, card->base + NJ_DMA_WRITE_END); inittiger()
378 struct tiger_hw *card = bc->bch.hw; read_dma() local
385 pr_info("%s: B%1d overrun at idx %d\n", card->name, read_dma()
397 card->name, bc->bch.nr, cnt); read_dma()
406 val = card->recv.start[idx++]; read_dma()
409 if (idx >= card->recv.size) read_dma()
426 snprintf(card->log, LOG_SIZE, read_dma()
428 card->name, stat); read_dma()
429 print_hex_dump_bytes(card->log, read_dma()
437 card->name, bc->bch.nr, cnt); read_dma()
442 card->name, bc->bch.nr); read_dma()
445 card->name, bc->bch.nr); read_dma()
448 card->name, bc->bch.nr, bc->bch.maxlen); read_dma()
456 recv_tiger(struct tiger_hw *card, u8 irq_stat) recv_tiger() argument
459 int cnt = card->recv.size / 2; recv_tiger()
462 card->last_is0 &= ~NJ_IRQM0_WR_MASK; recv_tiger()
463 card->last_is0 |= (irq_stat & NJ_IRQM0_WR_MASK); recv_tiger()
468 idx = card->recv.size - 1; recv_tiger()
470 if (test_bit(FLG_ACTIVE, &card->bc[0].bch.Flags)) recv_tiger()
471 read_dma(&card->bc[0], idx, cnt); recv_tiger()
472 if (test_bit(FLG_ACTIVE, &card->bc[1].bch.Flags)) recv_tiger()
473 read_dma(&card->bc[1], idx, cnt); recv_tiger()
478 resync(struct tiger_ch *bc, struct tiger_hw *card) resync() argument
480 card->send.dmacur = inl(card->base | NJ_DMA_READ_ADR); resync()
481 card->send.idx = (card->send.dmacur - card->send.dmastart) >> 2; resync()
482 if (bc->free > card->send.size / 2) resync()
483 bc->free = card->send.size / 2; resync()
488 if (card->send.idx < ((card->send.size / 2) - 1)) resync()
489 bc->idx = (card->recv.size / 2) - 1; resync()
491 bc->idx = card->recv.size - 1; resync()
493 pr_debug("%s: %s B%1d free %d idx %d/%d\n", card->name, resync()
494 __func__, bc->bch.nr, bc->free, bc->idx, card->send.idx); resync()
502 struct tiger_hw *card = bc->bch.hw; fill_hdlc_flag() local
509 pr_debug("%s: %s B%1d %d state %x idx %d/%d\n", card->name, fill_hdlc_flag()
511 bc->idx, card->send.idx); fill_hdlc_flag()
513 resync(bc, card); fill_hdlc_flag()
516 pr_debug("%s: B%1d hdlc encoded %d flags\n", card->name, fill_hdlc_flag()
522 if (bc->idx >= card->send.size) fill_hdlc_flag()
524 v = card->send.start[bc->idx]; fill_hdlc_flag()
527 card->send.start[bc->idx++] = v; fill_hdlc_flag()
530 snprintf(card->log, LOG_SIZE, "B%1d-send %s %d ", fill_hdlc_flag()
531 bc->bch.nr, card->name, count); fill_hdlc_flag()
532 print_hex_dump_bytes(card->log, DUMP_PREFIX_OFFSET, p, count); fill_hdlc_flag()
539 struct tiger_hw *card = bc->bch.hw; fill_dma() local
550 count = card->send.size >> 1; fill_dma()
557 card->name, __func__, bc->bch.nr, count, bc->free, fill_dma()
559 bc->idx, card->send.idx); fill_dma()
563 resync(bc, card); fill_dma()
567 pr_debug("%s: B%1d hdlc encoded %d in %d\n", card->name, fill_dma()
585 if (bc->idx >= card->send.size) fill_dma()
587 v = card->send.start[bc->idx]; fill_dma()
590 card->send.start[bc->idx++] = v; fill_dma()
594 if (bc->idx >= card->send.size) fill_dma()
596 v = card->send.start[bc->idx]; fill_dma()
600 card->send.start[bc->idx++] = v; fill_dma()
604 snprintf(card->log, LOG_SIZE, "B%1d-send %s %d ", fill_dma()
605 bc->bch.nr, card->name, count); fill_dma()
606 print_hex_dump_bytes(card->log, DUMP_PREFIX_OFFSET, p, count); fill_dma()
639 send_tiger_bc(struct tiger_hw *card, struct tiger_ch *bc) send_tiger_bc() argument
643 bc->free += card->send.size / 2; send_tiger_bc()
644 if (bc->free >= card->send.size) { send_tiger_bc()
646 pr_info("%s: B%1d TX underrun state %x\n", card->name, send_tiger_bc()
650 bc->free = card->send.size; send_tiger_bc()
658 pr_debug("%s: B%1d TX no data free %d idx %d/%d\n", card->name, send_tiger_bc()
659 bc->bch.nr, bc->free, bc->idx, card->send.idx); send_tiger_bc()
662 if (bc->free == card->send.size) send_tiger_bc()
669 send_tiger(struct tiger_hw *card, u8 irq_stat) send_tiger() argument
674 if ((irq_stat & card->last_is0) & NJ_IRQM0_RD_MASK) { send_tiger()
676 card->name, irq_stat, card->last_is0); send_tiger()
679 card->last_is0 &= ~NJ_IRQM0_RD_MASK; send_tiger()
680 card->last_is0 |= (irq_stat & NJ_IRQM0_RD_MASK); send_tiger()
683 if (test_bit(FLG_ACTIVE, &card->bc[i].bch.Flags)) send_tiger()
684 send_tiger_bc(card, &card->bc[i]); send_tiger()
691 struct tiger_hw *card = dev_id; nj_irq() local
694 spin_lock(&card->lock); nj_irq()
695 s0val = inb(card->base | NJ_IRQSTAT0); nj_irq()
696 s1val = inb(card->base | NJ_IRQSTAT1); nj_irq()
699 spin_unlock(&card->lock); nj_irq()
702 pr_debug("%s: IRQSTAT0 %02x IRQSTAT1 %02x\n", card->name, s0val, s1val); nj_irq()
703 card->irqcnt++; nj_irq()
705 val = ReadISAC_nj(card, ISAC_ISTA); nj_irq()
707 mISDNisac_irq(&card->isac, val); nj_irq()
712 outb(s0val, card->base | NJ_IRQSTAT0); nj_irq()
717 card->recv.dmacur = inl(card->base | NJ_DMA_WRITE_ADR); nj_irq()
718 card->recv.idx = (card->recv.dmacur - card->recv.dmastart) >> 2; nj_irq()
719 if (card->recv.dmacur < card->recv.dmairq) nj_irq()
724 card->send.dmacur = inl(card->base | NJ_DMA_READ_ADR); nj_irq()
725 card->send.idx = (card->send.dmacur - card->send.dmastart) >> 2; nj_irq()
726 if (card->send.dmacur < card->send.dmairq) nj_irq()
731 pr_debug("%s: DMA Status %02x/%02x/%02x %d/%d\n", card->name, nj_irq()
732 s1val, s0val, card->last_is0, nj_irq()
733 card->recv.idx, card->send.idx); nj_irq()
735 if (s0val != card->last_is0) { nj_irq()
737 (card->last_is0 & NJ_IRQM0_RD_MASK)) nj_irq()
739 send_tiger(card, s0val); nj_irq()
741 (card->last_is0 & NJ_IRQM0_WR_MASK)) nj_irq()
743 recv_tiger(card, s0val); nj_irq()
746 spin_unlock(&card->lock); nj_irq()
756 struct tiger_hw *card = bch->hw; nj_l2l1B() local
762 spin_lock_irqsave(&card->lock, flags); nj_l2l1B()
768 spin_unlock_irqrestore(&card->lock, flags); nj_l2l1B()
771 spin_lock_irqsave(&card->lock, flags); nj_l2l1B()
776 spin_unlock_irqrestore(&card->lock, flags); nj_l2l1B()
782 spin_lock_irqsave(&card->lock, flags); nj_l2l1B()
785 spin_unlock_irqrestore(&card->lock, flags); nj_l2l1B()
807 struct tiger_hw *card = bch->hw; nj_bctrl() local
811 pr_debug("%s: %s cmd:%x %p\n", card->name, __func__, cmd, arg); nj_bctrl()
816 spin_lock_irqsave(&card->lock, flags); nj_bctrl()
819 spin_unlock_irqrestore(&card->lock, flags); nj_bctrl()
829 pr_info("%s: %s unknown prim(%x)\n", card->name, __func__, cmd); nj_bctrl()
835 channel_ctrl(struct tiger_hw *card, struct mISDN_ctrl_req *cq) channel_ctrl() argument
849 ret = card->isac.ctrl(&card->isac, HW_TESTLOOP, cq->channel); channel_ctrl()
852 ret = card->isac.ctrl(&card->isac, HW_TIMER3_VALUE, cq->p1); channel_ctrl()
855 pr_info("%s: %s unknown Op %x\n", card->name, __func__, cq->op); channel_ctrl()
863 open_bchannel(struct tiger_hw *card, struct channel_req *rq) open_bchannel() argument
871 bch = &card->bc[rq->adr.channel - 1].bch; open_bchannel()
888 struct tiger_hw *card = dch->hw; nj_dctrl() local
892 pr_debug("%s: %s cmd:%x %p\n", card->name, __func__, cmd, arg); nj_dctrl()
897 err = card->isac.open(&card->isac, rq); nj_dctrl()
899 err = open_bchannel(card, rq); nj_dctrl()
903 pr_info("%s: cannot get module\n", card->name); nj_dctrl()
906 pr_debug("%s: dev(%d) close from %p\n", card->name, dch->dev.id, nj_dctrl()
911 err = channel_ctrl(card, arg); nj_dctrl()
915 card->name, __func__, cmd); nj_dctrl()
922 nj_init_card(struct tiger_hw *card) nj_init_card() argument
927 spin_lock_irqsave(&card->lock, flags); nj_init_card()
928 nj_disable_hwirq(card); nj_init_card()
929 spin_unlock_irqrestore(&card->lock, flags); nj_init_card()
931 card->irq = card->pdev->irq; nj_init_card()
932 if (request_irq(card->irq, nj_irq, IRQF_SHARED, card->name, card)) { nj_init_card()
934 card->name, card->irq); nj_init_card()
935 card->irq = -1; nj_init_card()
939 spin_lock_irqsave(&card->lock, flags); nj_init_card()
940 nj_reset(card); nj_init_card()
941 ret = card->isac.init(&card->isac); nj_init_card()
944 ret = inittiger(card); nj_init_card()
947 mode_tiger(&card->bc[0], ISDN_P_NONE); nj_init_card()
948 mode_tiger(&card->bc[1], ISDN_P_NONE); nj_init_card()
950 spin_unlock_irqrestore(&card->lock, flags); nj_init_card()
956 nj_release(struct tiger_hw *card) nj_release() argument
961 if (card->base_s) { nj_release()
962 spin_lock_irqsave(&card->lock, flags); nj_release()
963 nj_disable_hwirq(card); nj_release()
964 mode_tiger(&card->bc[0], ISDN_P_NONE); nj_release()
965 mode_tiger(&card->bc[1], ISDN_P_NONE); nj_release()
966 card->isac.release(&card->isac); nj_release()
967 spin_unlock_irqrestore(&card->lock, flags); nj_release()
968 release_region(card->base, card->base_s); nj_release()
969 card->base_s = 0; nj_release()
971 if (card->irq > 0) nj_release()
972 free_irq(card->irq, card); nj_release()
973 if (card->isac.dch.dev.dev.class) nj_release()
974 mISDN_unregister_device(&card->isac.dch.dev); nj_release()
977 mISDN_freebchannel(&card->bc[i].bch); nj_release()
978 kfree(card->bc[i].hsbuf); nj_release()
979 kfree(card->bc[i].hrbuf); nj_release()
981 if (card->dma_p) nj_release()
982 pci_free_consistent(card->pdev, NJ_DMA_SIZE, nj_release()
983 card->dma_p, card->dma); nj_release()
985 list_del(&card->list); nj_release()
987 pci_clear_master(card->pdev); nj_release()
988 pci_disable_device(card->pdev); nj_release()
989 pci_set_drvdata(card->pdev, NULL); nj_release()
990 kfree(card); nj_release()
995 nj_setup(struct tiger_hw *card) nj_setup() argument
997 card->base = pci_resource_start(card->pdev, 0); nj_setup()
998 card->base_s = pci_resource_len(card->pdev, 0); nj_setup()
999 if (!request_region(card->base, card->base_s, card->name)) { nj_setup()
1001 card->name, card->base, nj_setup()
1002 (u32)(card->base + card->base_s - 1)); nj_setup()
1003 card->base_s = 0; nj_setup()
1006 ASSIGN_FUNC(nj, ISAC, card->isac); nj_setup()
1012 setup_instance(struct tiger_hw *card) setup_instance() argument
1017 snprintf(card->name, MISDN_MAX_IDLEN - 1, "netjet.%d", nj_cnt + 1); setup_instance()
1019 list_add_tail(&card->list, &Cards); setup_instance()
1022 _set_debug(card); setup_instance()
1023 card->isac.name = card->name; setup_instance()
1024 spin_lock_init(&card->lock); setup_instance()
1025 card->isac.hwlock = &card->lock; setup_instance()
1026 mISDNisac_init(&card->isac, card); setup_instance()
1028 card->isac.dch.dev.Bprotocols = (1 << (ISDN_P_B_RAW & ISDN_P_B_MASK)) | setup_instance()
1030 card->isac.dch.dev.D.ctrl = nj_dctrl; setup_instance()
1032 card->bc[i].bch.nr = i + 1; setup_instance()
1033 set_channelmap(i + 1, card->isac.dch.dev.channelmap); setup_instance()
1034 mISDN_initbchannel(&card->bc[i].bch, MAX_DATA_MEM, setup_instance()
1036 card->bc[i].bch.hw = card; setup_instance()
1037 card->bc[i].bch.ch.send = nj_l2l1B; setup_instance()
1038 card->bc[i].bch.ch.ctrl = nj_bctrl; setup_instance()
1039 card->bc[i].bch.ch.nr = i + 1; setup_instance()
1040 list_add(&card->bc[i].bch.ch.list, setup_instance()
1041 &card->isac.dch.dev.bchannels); setup_instance()
1042 card->bc[i].bch.hw = card; setup_instance()
1044 err = nj_setup(card); setup_instance()
1047 err = mISDN_register_device(&card->isac.dch.dev, &card->pdev->dev, setup_instance()
1048 card->name); setup_instance()
1051 err = nj_init_card(card); setup_instance()
1058 nj_release(card); setup_instance()
1067 struct tiger_hw *card; nj_probe() local
1087 card = kzalloc(sizeof(struct tiger_hw), GFP_ATOMIC); nj_probe()
1088 if (!card) { nj_probe()
1093 card->pdev = pdev; nj_probe()
1097 kfree(card); nj_probe()
1112 card->typ = NETJET_S_TJ320; nj_probe()
1114 card->typ = NETJET_S_TJ300; nj_probe()
1116 card->base = pci_resource_start(pdev, 0); nj_probe()
1117 card->irq = pdev->irq; nj_probe()
1118 pci_set_drvdata(pdev, card); nj_probe()
1119 err = setup_instance(card); nj_probe()
1129 struct tiger_hw *card = pci_get_drvdata(pdev); nj_remove() local
1131 if (card) nj_remove()
1132 nj_release(card); nj_remove()
H A Dspeedfax.c89 _set_debug(struct sfax_hw *card) _set_debug() argument
91 card->isac.dch.debug = debug; _set_debug()
92 card->isar.ch[0].bch.debug = debug; _set_debug()
93 card->isar.ch[1].bch.debug = debug; _set_debug()
100 struct sfax_hw *card; set_debug() local
105 list_for_each_entry(card, &Cards, list) set_debug()
106 _set_debug(card); set_debug()
178 pr_debug("%s: resetting card\n", sf->name); reset_speedfax()
354 release_card(struct sfax_hw *card) { release_card() argument
357 spin_lock_irqsave(&card->lock, flags); release_card()
358 disable_hwirq(card); release_card()
359 spin_unlock_irqrestore(&card->lock, flags); release_card()
360 card->isac.release(&card->isac); release_card()
361 free_irq(card->irq, card); release_card()
362 card->isar.release(&card->isar); release_card()
363 mISDN_unregister_device(&card->isac.dch.dev); release_card()
364 release_region(card->cfg, 256); release_card()
365 pci_disable_device(card->pdev); release_card()
366 pci_set_drvdata(card->pdev, NULL); release_card()
368 list_del(&card->list); release_card()
370 kfree(card); release_card()
375 setup_instance(struct sfax_hw *card) setup_instance() argument
381 snprintf(card->name, MISDN_MAX_IDLEN - 1, "Speedfax.%d", sfax_cnt + 1); setup_instance()
383 list_add_tail(&card->list, &Cards); setup_instance()
385 _set_debug(card); setup_instance()
386 spin_lock_init(&card->lock); setup_instance()
387 card->isac.hwlock = &card->lock; setup_instance()
388 card->isar.hwlock = &card->lock; setup_instance()
389 card->isar.ctrl = (void *)&sfax_ctrl; setup_instance()
390 card->isac.name = card->name; setup_instance()
391 card->isar.name = card->name; setup_instance()
392 card->isar.owner = THIS_MODULE; setup_instance()
394 err = request_firmware(&firmware, "isdn/ISAR.BIN", &card->pdev->dev); setup_instance()
397 card->name, err); setup_instance()
402 card->name, firmware->size); setup_instance()
404 mISDNisac_init(&card->isac, card); setup_instance()
406 card->isac.dch.dev.D.ctrl = sfax_dctrl; setup_instance()
407 card->isac.dch.dev.Bprotocols = setup_instance()
408 mISDNisar_init(&card->isar, card); setup_instance()
410 set_channelmap(i + 1, card->isac.dch.dev.channelmap); setup_instance()
411 list_add(&card->isar.ch[i].bch.ch.list, setup_instance()
412 &card->isac.dch.dev.bchannels); setup_instance()
415 err = setup_speedfax(card); setup_instance()
418 err = card->isar.init(&card->isar); setup_instance()
421 err = mISDN_register_device(&card->isac.dch.dev, setup_instance()
422 &card->pdev->dev, card->name); setup_instance()
425 err = init_card(card); setup_instance()
428 err = card->isar.firmware(&card->isar, firmware->data, firmware->size); setup_instance()
435 disable_hwirq(card); setup_instance()
436 free_irq(card->irq, card); setup_instance()
438 mISDN_unregister_device(&card->isac.dch.dev); setup_instance()
440 release_region(card->cfg, 256); setup_instance()
442 card->isac.release(&card->isac); setup_instance()
443 card->isar.release(&card->isar); setup_instance()
446 pci_disable_device(card->pdev); setup_instance()
448 list_del(&card->list); setup_instance()
450 kfree(card); setup_instance()
458 struct sfax_hw *card = kzalloc(sizeof(struct sfax_hw), GFP_KERNEL); sfaxpci_probe() local
460 if (!card) { sfaxpci_probe()
464 card->pdev = pdev; sfaxpci_probe()
467 kfree(card); sfaxpci_probe()
474 card->cfg = pci_resource_start(pdev, 0); sfaxpci_probe()
475 card->irq = pdev->irq; sfaxpci_probe()
476 pci_set_drvdata(pdev, card); sfaxpci_probe()
477 err = setup_instance(card); sfaxpci_probe()
486 struct sfax_hw *card = pci_get_drvdata(pdev); sfax_remove_pci() local
488 if (card) sfax_remove_pci()
489 release_card(card); sfax_remove_pci()
/linux-4.1.27/drivers/mmc/core/
H A Dsd.h4 #include <linux/mmc/card.h>
9 int mmc_sd_get_csd(struct mmc_host *host, struct mmc_card *card);
10 void mmc_decode_cid(struct mmc_card *card);
11 int mmc_sd_setup_card(struct mmc_host *host, struct mmc_card *card,
13 unsigned mmc_sd_get_max_clock(struct mmc_card *card);
14 int mmc_sd_switch_hs(struct mmc_card *card);
H A Dmmc.c20 #include <linux/mmc/card.h>
64 static int mmc_decode_cid(struct mmc_card *card) mmc_decode_cid() argument
66 u32 *resp = card->raw_cid; mmc_decode_cid()
72 switch (card->csd.mmca_vsn) { mmc_decode_cid()
75 card->cid.manfid = UNSTUFF_BITS(resp, 104, 24); mmc_decode_cid()
76 card->cid.prod_name[0] = UNSTUFF_BITS(resp, 96, 8); mmc_decode_cid()
77 card->cid.prod_name[1] = UNSTUFF_BITS(resp, 88, 8); mmc_decode_cid()
78 card->cid.prod_name[2] = UNSTUFF_BITS(resp, 80, 8); mmc_decode_cid()
79 card->cid.prod_name[3] = UNSTUFF_BITS(resp, 72, 8); mmc_decode_cid()
80 card->cid.prod_name[4] = UNSTUFF_BITS(resp, 64, 8); mmc_decode_cid()
81 card->cid.prod_name[5] = UNSTUFF_BITS(resp, 56, 8); mmc_decode_cid()
82 card->cid.prod_name[6] = UNSTUFF_BITS(resp, 48, 8); mmc_decode_cid()
83 card->cid.hwrev = UNSTUFF_BITS(resp, 44, 4); mmc_decode_cid()
84 card->cid.fwrev = UNSTUFF_BITS(resp, 40, 4); mmc_decode_cid()
85 card->cid.serial = UNSTUFF_BITS(resp, 16, 24); mmc_decode_cid()
86 card->cid.month = UNSTUFF_BITS(resp, 12, 4); mmc_decode_cid()
87 card->cid.year = UNSTUFF_BITS(resp, 8, 4) + 1997; mmc_decode_cid()
93 card->cid.manfid = UNSTUFF_BITS(resp, 120, 8); mmc_decode_cid()
94 card->cid.oemid = UNSTUFF_BITS(resp, 104, 16); mmc_decode_cid()
95 card->cid.prod_name[0] = UNSTUFF_BITS(resp, 96, 8); mmc_decode_cid()
96 card->cid.prod_name[1] = UNSTUFF_BITS(resp, 88, 8); mmc_decode_cid()
97 card->cid.prod_name[2] = UNSTUFF_BITS(resp, 80, 8); mmc_decode_cid()
98 card->cid.prod_name[3] = UNSTUFF_BITS(resp, 72, 8); mmc_decode_cid()
99 card->cid.prod_name[4] = UNSTUFF_BITS(resp, 64, 8); mmc_decode_cid()
100 card->cid.prod_name[5] = UNSTUFF_BITS(resp, 56, 8); mmc_decode_cid()
101 card->cid.prv = UNSTUFF_BITS(resp, 48, 8); mmc_decode_cid()
102 card->cid.serial = UNSTUFF_BITS(resp, 16, 32); mmc_decode_cid()
103 card->cid.month = UNSTUFF_BITS(resp, 12, 4); mmc_decode_cid()
104 card->cid.year = UNSTUFF_BITS(resp, 8, 4) + 1997; mmc_decode_cid()
108 pr_err("%s: card has unknown MMCA version %d\n", mmc_decode_cid()
109 mmc_hostname(card->host), card->csd.mmca_vsn); mmc_decode_cid()
116 static void mmc_set_erase_size(struct mmc_card *card) mmc_set_erase_size() argument
118 if (card->ext_csd.erase_group_def & 1) mmc_set_erase_size()
119 card->erase_size = card->ext_csd.hc_erase_size; mmc_set_erase_size()
121 card->erase_size = card->csd.erase_size; mmc_set_erase_size()
123 mmc_init_erase(card); mmc_set_erase_size()
127 * Given a 128-bit response, decode to our card CSD structure.
129 static int mmc_decode_csd(struct mmc_card *card) mmc_decode_csd() argument
131 struct mmc_csd *csd = &card->csd; mmc_decode_csd()
133 u32 *resp = card->raw_csd; mmc_decode_csd()
143 mmc_hostname(card->host), csd->structure); mmc_decode_csd()
181 static void mmc_select_card_type(struct mmc_card *card) mmc_select_card_type() argument
183 struct mmc_host *host = card->host; mmc_select_card_type()
184 u8 card_type = card->ext_csd.raw_card_type; mmc_select_card_type()
237 card->ext_csd.hs_max_dtr = hs_max_dtr; mmc_select_card_type()
238 card->ext_csd.hs200_max_dtr = hs200_max_dtr; mmc_select_card_type()
239 card->mmc_avail_type = avail_type; mmc_select_card_type()
242 static void mmc_manage_enhanced_area(struct mmc_card *card, u8 *ext_csd) mmc_manage_enhanced_area() argument
249 card->ext_csd.enhanced_area_offset = -EINVAL; mmc_manage_enhanced_area()
250 card->ext_csd.enhanced_area_size = -EINVAL; mmc_manage_enhanced_area()
254 * card has the Enhanced area enabled. If so, export enhanced mmc_manage_enhanced_area()
259 if (card->ext_csd.partition_setting_completed) { mmc_manage_enhanced_area()
268 card->ext_csd.enhanced_area_offset = mmc_manage_enhanced_area()
271 if (mmc_card_blockaddr(card)) mmc_manage_enhanced_area()
272 card->ext_csd.enhanced_area_offset <<= 9; mmc_manage_enhanced_area()
276 card->ext_csd.enhanced_area_size = mmc_manage_enhanced_area()
279 card->ext_csd.enhanced_area_size *= mmc_manage_enhanced_area()
281 card->ext_csd.enhanced_area_size <<= 9; mmc_manage_enhanced_area()
284 mmc_hostname(card->host)); mmc_manage_enhanced_area()
289 static void mmc_manage_gp_partitions(struct mmc_card *card, u8 *ext_csd) mmc_manage_gp_partitions() argument
312 if (card->ext_csd.partition_setting_completed == 0) { mmc_manage_gp_partitions()
314 mmc_hostname(card->host)); mmc_manage_gp_partitions()
325 mmc_part_add(card, part_size << 19, mmc_manage_gp_partitions()
339 static int mmc_decode_ext_csd(struct mmc_card *card, u8 *ext_csd) mmc_decode_ext_csd() argument
347 card->ext_csd.raw_ext_csd_structure = ext_csd[EXT_CSD_STRUCTURE]; mmc_decode_ext_csd()
348 if (card->csd.structure == 3) { mmc_decode_ext_csd()
349 if (card->ext_csd.raw_ext_csd_structure > 2) { mmc_decode_ext_csd()
351 "version %d\n", mmc_hostname(card->host), mmc_decode_ext_csd()
352 card->ext_csd.raw_ext_csd_structure); mmc_decode_ext_csd()
358 np = mmc_of_find_child_device(card->host, 0); mmc_decode_ext_csd()
359 if (np && of_device_is_compatible(np, "mmc-card")) mmc_decode_ext_csd()
368 card->ext_csd.rev = ext_csd[EXT_CSD_REV]; mmc_decode_ext_csd()
370 card->ext_csd.raw_sectors[0] = ext_csd[EXT_CSD_SEC_CNT + 0]; mmc_decode_ext_csd()
371 card->ext_csd.raw_sectors[1] = ext_csd[EXT_CSD_SEC_CNT + 1]; mmc_decode_ext_csd()
372 card->ext_csd.raw_sectors[2] = ext_csd[EXT_CSD_SEC_CNT + 2]; mmc_decode_ext_csd()
373 card->ext_csd.raw_sectors[3] = ext_csd[EXT_CSD_SEC_CNT + 3]; mmc_decode_ext_csd()
374 if (card->ext_csd.rev >= 2) { mmc_decode_ext_csd()
375 card->ext_csd.sectors = mmc_decode_ext_csd()
382 if (card->ext_csd.sectors > (2u * 1024 * 1024 * 1024) / 512) mmc_decode_ext_csd()
383 mmc_card_set_blockaddr(card); mmc_decode_ext_csd()
386 card->ext_csd.raw_card_type = ext_csd[EXT_CSD_CARD_TYPE]; mmc_decode_ext_csd()
387 mmc_select_card_type(card); mmc_decode_ext_csd()
389 card->ext_csd.raw_s_a_timeout = ext_csd[EXT_CSD_S_A_TIMEOUT]; mmc_decode_ext_csd()
390 card->ext_csd.raw_erase_timeout_mult = mmc_decode_ext_csd()
392 card->ext_csd.raw_hc_erase_grp_size = mmc_decode_ext_csd()
394 if (card->ext_csd.rev >= 3) { mmc_decode_ext_csd()
396 card->ext_csd.part_config = ext_csd[EXT_CSD_PART_CONFIG]; mmc_decode_ext_csd()
399 card->ext_csd.part_time = 10 * ext_csd[EXT_CSD_PART_SWITCH_TIME]; mmc_decode_ext_csd()
401 if (card->ext_csd.part_time && mmc_decode_ext_csd()
402 card->ext_csd.part_time < MMC_MIN_PART_SWITCH_TIME) mmc_decode_ext_csd()
403 card->ext_csd.part_time = MMC_MIN_PART_SWITCH_TIME; mmc_decode_ext_csd()
407 card->ext_csd.sa_timeout = mmc_decode_ext_csd()
409 card->ext_csd.erase_group_def = mmc_decode_ext_csd()
411 card->ext_csd.hc_erase_timeout = 300 * mmc_decode_ext_csd()
413 card->ext_csd.hc_erase_size = mmc_decode_ext_csd()
416 card->ext_csd.rel_sectors = ext_csd[EXT_CSD_REL_WR_SEC_C]; mmc_decode_ext_csd()
422 if (ext_csd[EXT_CSD_BOOT_MULT] && mmc_boot_partition_access(card->host)) { mmc_decode_ext_csd()
425 mmc_part_add(card, part_size, mmc_decode_ext_csd()
433 card->ext_csd.raw_hc_erase_gap_size = mmc_decode_ext_csd()
435 card->ext_csd.raw_sec_trim_mult = mmc_decode_ext_csd()
437 card->ext_csd.raw_sec_erase_mult = mmc_decode_ext_csd()
439 card->ext_csd.raw_sec_feature_support = mmc_decode_ext_csd()
441 card->ext_csd.raw_trim_mult = mmc_decode_ext_csd()
443 card->ext_csd.raw_partition_support = ext_csd[EXT_CSD_PARTITION_SUPPORT]; mmc_decode_ext_csd()
444 if (card->ext_csd.rev >= 4) { mmc_decode_ext_csd()
447 card->ext_csd.partition_setting_completed = 1; mmc_decode_ext_csd()
449 card->ext_csd.partition_setting_completed = 0; mmc_decode_ext_csd()
451 mmc_manage_enhanced_area(card, ext_csd); mmc_decode_ext_csd()
453 mmc_manage_gp_partitions(card, ext_csd); mmc_decode_ext_csd()
455 card->ext_csd.sec_trim_mult = mmc_decode_ext_csd()
457 card->ext_csd.sec_erase_mult = mmc_decode_ext_csd()
459 card->ext_csd.sec_feature_support = mmc_decode_ext_csd()
461 card->ext_csd.trim_timeout = 300 * mmc_decode_ext_csd()
469 card->ext_csd.boot_ro_lock = ext_csd[EXT_CSD_BOOT_WP]; mmc_decode_ext_csd()
470 card->ext_csd.boot_ro_lockable = true; mmc_decode_ext_csd()
473 card->ext_csd.raw_pwr_cl_52_195 = mmc_decode_ext_csd()
475 card->ext_csd.raw_pwr_cl_26_195 = mmc_decode_ext_csd()
477 card->ext_csd.raw_pwr_cl_52_360 = mmc_decode_ext_csd()
479 card->ext_csd.raw_pwr_cl_26_360 = mmc_decode_ext_csd()
481 card->ext_csd.raw_pwr_cl_200_195 = mmc_decode_ext_csd()
483 card->ext_csd.raw_pwr_cl_200_360 = mmc_decode_ext_csd()
485 card->ext_csd.raw_pwr_cl_ddr_52_195 = mmc_decode_ext_csd()
487 card->ext_csd.raw_pwr_cl_ddr_52_360 = mmc_decode_ext_csd()
489 card->ext_csd.raw_pwr_cl_ddr_200_360 = mmc_decode_ext_csd()
493 if (card->ext_csd.rev >= 5) { mmc_decode_ext_csd()
495 if (card->cid.year < 2010) mmc_decode_ext_csd()
496 card->cid.year += 16; mmc_decode_ext_csd()
498 /* check whether the eMMC card supports BKOPS */ mmc_decode_ext_csd()
500 card->ext_csd.bkops = 1; mmc_decode_ext_csd()
501 card->ext_csd.man_bkops_en = mmc_decode_ext_csd()
504 card->ext_csd.raw_bkops_status = mmc_decode_ext_csd()
506 if (!card->ext_csd.man_bkops_en) mmc_decode_ext_csd()
508 mmc_hostname(card->host)); mmc_decode_ext_csd()
511 /* check whether the eMMC card supports HPI */ mmc_decode_ext_csd()
513 card->ext_csd.hpi = 1; mmc_decode_ext_csd()
515 card->ext_csd.hpi_cmd = MMC_STOP_TRANSMISSION; mmc_decode_ext_csd()
517 card->ext_csd.hpi_cmd = MMC_SEND_STATUS; mmc_decode_ext_csd()
522 card->ext_csd.out_of_int_time = mmc_decode_ext_csd()
526 card->ext_csd.rel_param = ext_csd[EXT_CSD_WR_REL_PARAM]; mmc_decode_ext_csd()
527 card->ext_csd.rst_n_function = ext_csd[EXT_CSD_RST_N_FUNCTION]; mmc_decode_ext_csd()
532 card->ext_csd.raw_rpmb_size_mult = ext_csd[EXT_CSD_RPMB_MULT]; mmc_decode_ext_csd()
533 if (ext_csd[EXT_CSD_RPMB_MULT] && mmc_host_cmd23(card->host)) { mmc_decode_ext_csd()
534 mmc_part_add(card, ext_csd[EXT_CSD_RPMB_MULT] << 17, mmc_decode_ext_csd()
541 card->ext_csd.raw_erased_mem_count = ext_csd[EXT_CSD_ERASED_MEM_CONT]; mmc_decode_ext_csd()
543 card->erased_byte = 0xFF; mmc_decode_ext_csd()
545 card->erased_byte = 0x0; mmc_decode_ext_csd()
548 if (card->ext_csd.rev >= 6) { mmc_decode_ext_csd()
549 card->ext_csd.feature_support |= MMC_DISCARD_FEATURE; mmc_decode_ext_csd()
551 card->ext_csd.generic_cmd6_time = 10 * mmc_decode_ext_csd()
553 card->ext_csd.power_off_longtime = 10 * mmc_decode_ext_csd()
556 card->ext_csd.cache_size = mmc_decode_ext_csd()
563 card->ext_csd.data_sector_size = 4096; mmc_decode_ext_csd()
565 card->ext_csd.data_sector_size = 512; mmc_decode_ext_csd()
569 card->ext_csd.data_tag_unit_size = mmc_decode_ext_csd()
571 (card->ext_csd.data_sector_size); mmc_decode_ext_csd()
573 card->ext_csd.data_tag_unit_size = 0; mmc_decode_ext_csd()
576 card->ext_csd.max_packed_writes = mmc_decode_ext_csd()
578 card->ext_csd.max_packed_reads = mmc_decode_ext_csd()
581 card->ext_csd.data_sector_size = 512; mmc_decode_ext_csd()
585 if (card->ext_csd.rev >= 7) { mmc_decode_ext_csd()
586 memcpy(card->ext_csd.fwrev, &ext_csd[EXT_CSD_FIRMWARE_VERSION], mmc_decode_ext_csd()
588 card->ext_csd.ffu_capable = mmc_decode_ext_csd()
596 static int mmc_read_ext_csd(struct mmc_card *card) mmc_read_ext_csd() argument
601 if (!mmc_can_ext_csd(card)) mmc_read_ext_csd()
604 err = mmc_get_ext_csd(card, &ext_csd); mmc_read_ext_csd()
606 /* If the host or the card can't do the switch, mmc_read_ext_csd()
617 if (card->csd.capacity == (4096 * 512)) { mmc_read_ext_csd()
618 pr_err("%s: unable to read EXT_CSD on a possible high capacity card. Card will be ignored.\n", mmc_read_ext_csd()
619 mmc_hostname(card->host)); mmc_read_ext_csd()
622 mmc_hostname(card->host)); mmc_read_ext_csd()
629 err = mmc_decode_ext_csd(card, ext_csd); mmc_read_ext_csd()
634 static int mmc_compare_ext_csds(struct mmc_card *card, unsigned bus_width) mmc_compare_ext_csds() argument
642 err = mmc_get_ext_csd(card, &bw_ext_csd); mmc_compare_ext_csds()
647 err = !((card->ext_csd.raw_partition_support == mmc_compare_ext_csds()
649 (card->ext_csd.raw_erased_mem_count == mmc_compare_ext_csds()
651 (card->ext_csd.rev == mmc_compare_ext_csds()
653 (card->ext_csd.raw_ext_csd_structure == mmc_compare_ext_csds()
655 (card->ext_csd.raw_card_type == mmc_compare_ext_csds()
657 (card->ext_csd.raw_s_a_timeout == mmc_compare_ext_csds()
659 (card->ext_csd.raw_hc_erase_gap_size == mmc_compare_ext_csds()
661 (card->ext_csd.raw_erase_timeout_mult == mmc_compare_ext_csds()
663 (card->ext_csd.raw_hc_erase_grp_size == mmc_compare_ext_csds()
665 (card->ext_csd.raw_sec_trim_mult == mmc_compare_ext_csds()
667 (card->ext_csd.raw_sec_erase_mult == mmc_compare_ext_csds()
669 (card->ext_csd.raw_sec_feature_support == mmc_compare_ext_csds()
671 (card->ext_csd.raw_trim_mult == mmc_compare_ext_csds()
673 (card->ext_csd.raw_sectors[0] == mmc_compare_ext_csds()
675 (card->ext_csd.raw_sectors[1] == mmc_compare_ext_csds()
677 (card->ext_csd.raw_sectors[2] == mmc_compare_ext_csds()
679 (card->ext_csd.raw_sectors[3] == mmc_compare_ext_csds()
681 (card->ext_csd.raw_pwr_cl_52_195 == mmc_compare_ext_csds()
683 (card->ext_csd.raw_pwr_cl_26_195 == mmc_compare_ext_csds()
685 (card->ext_csd.raw_pwr_cl_52_360 == mmc_compare_ext_csds()
687 (card->ext_csd.raw_pwr_cl_26_360 == mmc_compare_ext_csds()
689 (card->ext_csd.raw_pwr_cl_200_195 == mmc_compare_ext_csds()
691 (card->ext_csd.raw_pwr_cl_200_360 == mmc_compare_ext_csds()
693 (card->ext_csd.raw_pwr_cl_ddr_52_195 == mmc_compare_ext_csds()
695 (card->ext_csd.raw_pwr_cl_ddr_52_360 == mmc_compare_ext_csds()
697 (card->ext_csd.raw_pwr_cl_ddr_200_360 == mmc_compare_ext_csds()
707 MMC_DEV_ATTR(cid, "%08x%08x%08x%08x\n", card->raw_cid[0], card->raw_cid[1],
708 card->raw_cid[2], card->raw_cid[3]);
709 MMC_DEV_ATTR(csd, "%08x%08x%08x%08x\n", card->raw_csd[0], card->raw_csd[1],
710 card->raw_csd[2], card->raw_csd[3]);
711 MMC_DEV_ATTR(date, "%02d/%04d\n", card->cid.month, card->cid.year);
712 MMC_DEV_ATTR(erase_size, "%u\n", card->erase_size << 9);
713 MMC_DEV_ATTR(preferred_erase_size, "%u\n", card->pref_erase << 9);
714 MMC_DEV_ATTR(ffu_capable, "%d\n", card->ext_csd.ffu_capable);
715 MMC_DEV_ATTR(hwrev, "0x%x\n", card->cid.hwrev);
716 MMC_DEV_ATTR(manfid, "0x%06x\n", card->cid.manfid);
717 MMC_DEV_ATTR(name, "%s\n", card->cid.prod_name);
718 MMC_DEV_ATTR(oemid, "0x%04x\n", card->cid.oemid);
719 MMC_DEV_ATTR(prv, "0x%x\n", card->cid.prv);
720 MMC_DEV_ATTR(serial, "0x%08x\n", card->cid.serial);
722 card->ext_csd.enhanced_area_offset);
723 MMC_DEV_ATTR(enhanced_area_size, "%u\n", card->ext_csd.enhanced_area_size);
724 MMC_DEV_ATTR(raw_rpmb_size_mult, "%#x\n", card->ext_csd.raw_rpmb_size_mult);
725 MMC_DEV_ATTR(rel_sectors, "%#x\n", card->ext_csd.rel_sectors);
731 struct mmc_card *card = mmc_dev_to_card(dev); mmc_fwrev_show() local
733 if (card->ext_csd.rev < 7) { mmc_fwrev_show()
734 return sprintf(buf, "0x%x\n", card->cid.fwrev); mmc_fwrev_show()
737 card->ext_csd.fwrev); mmc_fwrev_show()
775 static int __mmc_select_powerclass(struct mmc_card *card, __mmc_select_powerclass() argument
778 struct mmc_host *host = card->host; __mmc_select_powerclass()
779 struct mmc_ext_csd *ext_csd = &card->ext_csd; __mmc_select_powerclass()
829 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, __mmc_select_powerclass()
832 card->ext_csd.generic_cmd6_time); __mmc_select_powerclass()
838 static int mmc_select_powerclass(struct mmc_card *card) mmc_select_powerclass() argument
840 struct mmc_host *host = card->host; mmc_select_powerclass()
845 if (!mmc_can_ext_csd(card)) mmc_select_powerclass()
853 ddr = card->mmc_avail_type & EXT_CSD_CARD_TYPE_DDR_52; mmc_select_powerclass()
861 err = __mmc_select_powerclass(card, ext_csd_bits); mmc_select_powerclass()
872 static void mmc_set_bus_speed(struct mmc_card *card) mmc_set_bus_speed() argument
876 if ((mmc_card_hs200(card) || mmc_card_hs400(card)) && mmc_set_bus_speed()
877 max_dtr > card->ext_csd.hs200_max_dtr) mmc_set_bus_speed()
878 max_dtr = card->ext_csd.hs200_max_dtr; mmc_set_bus_speed()
879 else if (mmc_card_hs(card) && max_dtr > card->ext_csd.hs_max_dtr) mmc_set_bus_speed()
880 max_dtr = card->ext_csd.hs_max_dtr; mmc_set_bus_speed()
881 else if (max_dtr > card->csd.max_dtr) mmc_set_bus_speed()
882 max_dtr = card->csd.max_dtr; mmc_set_bus_speed()
884 mmc_set_clock(card->host, max_dtr); mmc_set_bus_speed()
892 static int mmc_select_bus_width(struct mmc_card *card) mmc_select_bus_width() argument
902 struct mmc_host *host = card->host; mmc_select_bus_width()
906 if (!mmc_can_ext_csd(card) || mmc_select_bus_width()
926 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, mmc_select_bus_width()
929 card->ext_csd.generic_cmd6_time); mmc_select_bus_width()
942 err = mmc_compare_ext_csds(card, bus_width); mmc_select_bus_width()
944 err = mmc_bus_test(card, bus_width); mmc_select_bus_width()
961 static int mmc_select_hs(struct mmc_card *card) mmc_select_hs() argument
965 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, mmc_select_hs()
967 card->ext_csd.generic_cmd6_time, mmc_select_hs()
970 mmc_set_timing(card->host, MMC_TIMING_MMC_HS); mmc_select_hs()
978 static int mmc_select_hs_ddr(struct mmc_card *card) mmc_select_hs_ddr() argument
980 struct mmc_host *host = card->host; mmc_select_hs_ddr()
984 if (!(card->mmc_avail_type & EXT_CSD_CARD_TYPE_DDR_52)) mmc_select_hs_ddr()
994 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, mmc_select_hs_ddr()
997 card->ext_csd.generic_cmd6_time); mmc_select_hs_ddr()
1013 * Even (e)MMC card can support 3.3v to 1.2v vccq, but not all mmc_select_hs_ddr()
1030 if (card->mmc_avail_type & EXT_CSD_CARD_TYPE_DDR_1_2V) mmc_select_hs_ddr()
1033 if (err && (card->mmc_avail_type & EXT_CSD_CARD_TYPE_DDR_1_8V)) mmc_select_hs_ddr()
1046 static int mmc_select_hs400(struct mmc_card *card) mmc_select_hs400() argument
1048 struct mmc_host *host = card->host; mmc_select_hs400()
1054 if (!(card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS400 && mmc_select_hs400()
1062 mmc_set_timing(card->host, MMC_TIMING_MMC_HS); mmc_select_hs400()
1063 mmc_set_bus_speed(card); mmc_select_hs400()
1065 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, mmc_select_hs400()
1067 card->ext_csd.generic_cmd6_time, mmc_select_hs400()
1075 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, mmc_select_hs400()
1078 card->ext_csd.generic_cmd6_time); mmc_select_hs400()
1085 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, mmc_select_hs400()
1087 card->ext_csd.generic_cmd6_time, mmc_select_hs400()
1096 mmc_set_bus_speed(card); mmc_select_hs400()
1108 static int mmc_select_hs200(struct mmc_card *card) mmc_select_hs200() argument
1110 struct mmc_host *host = card->host; mmc_select_hs200()
1113 if (card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS200_1_2V) mmc_select_hs200()
1116 if (err && card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS200_1_8V) mmc_select_hs200()
1119 /* If fails try again during next card power cycle */ mmc_select_hs200()
1127 err = mmc_select_bus_width(card); mmc_select_hs200()
1129 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, mmc_select_hs200()
1131 card->ext_csd.generic_cmd6_time, mmc_select_hs200()
1143 static int mmc_select_timing(struct mmc_card *card) mmc_select_timing() argument
1147 if (!mmc_can_ext_csd(card)) mmc_select_timing()
1150 if (card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS200) mmc_select_timing()
1151 err = mmc_select_hs200(card); mmc_select_timing()
1152 else if (card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS) mmc_select_timing()
1153 err = mmc_select_hs(card); mmc_select_timing()
1160 mmc_card_hs(card) ? "high-speed" : mmc_select_timing()
1161 (mmc_card_hs200(card) ? "hs200" : ""), mmc_select_timing()
1162 mmc_hostname(card->host)); mmc_select_timing()
1171 mmc_set_bus_speed(card); mmc_select_timing()
1179 static int mmc_hs200_tuning(struct mmc_card *card) mmc_hs200_tuning() argument
1181 struct mmc_host *host = card->host; mmc_hs200_tuning()
1187 if (card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS400 && mmc_hs200_tuning()
1192 return mmc_execute_tuning(card); mmc_hs200_tuning()
1196 * Handle the detection and initialisation of a card.
1198 * In the case of a resume, "oldcard" will contain the card
1204 struct mmc_card *card; mmc_init_card() local
1240 * Fetch CID from card. mmc_init_card()
1255 card = oldcard; mmc_init_card()
1258 * Allocate card structure. mmc_init_card()
1260 card = mmc_alloc_card(host, &mmc_type); mmc_init_card()
1261 if (IS_ERR(card)) { mmc_init_card()
1262 err = PTR_ERR(card); mmc_init_card()
1266 card->ocr = ocr; mmc_init_card()
1267 card->type = MMC_TYPE_MMC; mmc_init_card()
1268 card->rca = 1; mmc_init_card()
1269 memcpy(card->raw_cid, cid, sizeof(card->raw_cid)); mmc_init_card()
1276 host->ops->init_card(host, card); mmc_init_card()
1279 * For native busses: set card RCA and quit open drain mode. mmc_init_card()
1282 err = mmc_set_relative_addr(card); mmc_init_card()
1291 * Fetch CSD from card. mmc_init_card()
1293 err = mmc_send_csd(card, card->raw_csd); mmc_init_card()
1297 err = mmc_decode_csd(card); mmc_init_card()
1300 err = mmc_decode_cid(card); mmc_init_card()
1309 if (card->csd.dsr_imp && host->dsr_req) mmc_init_card()
1313 * Select card, as all following commands rely on that. mmc_init_card()
1316 err = mmc_select_card(card); mmc_init_card()
1323 err = mmc_read_ext_csd(card); mmc_init_card()
1332 if (!(mmc_card_blockaddr(card)) && (rocr & (1<<30))) mmc_init_card()
1333 mmc_card_set_blockaddr(card); mmc_init_card()
1336 mmc_set_erase_size(card); mmc_init_card()
1343 if (card->ext_csd.partition_setting_completed || mmc_init_card()
1344 (card->ext_csd.rev >= 3 && (host->caps2 & MMC_CAP2_HC_ERASE_SZ))) { mmc_init_card()
1345 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, mmc_init_card()
1347 card->ext_csd.generic_cmd6_time); mmc_init_card()
1359 card->ext_csd.enhanced_area_offset = -EINVAL; mmc_init_card()
1360 card->ext_csd.enhanced_area_size = -EINVAL; mmc_init_card()
1362 card->ext_csd.erase_group_def = 1; mmc_init_card()
1368 mmc_set_erase_size(card); mmc_init_card()
1375 if (card->ext_csd.part_config & EXT_CSD_PART_CONFIG_ACC_MASK) { mmc_init_card()
1376 card->ext_csd.part_config &= ~EXT_CSD_PART_CONFIG_ACC_MASK; mmc_init_card()
1377 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_PART_CONFIG, mmc_init_card()
1378 card->ext_csd.part_config, mmc_init_card()
1379 card->ext_csd.part_time); mmc_init_card()
1387 if (card->ext_csd.rev >= 6) { mmc_init_card()
1388 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, mmc_init_card()
1391 card->ext_csd.generic_cmd6_time); mmc_init_card()
1400 card->ext_csd.power_off_notification = EXT_CSD_POWER_ON; mmc_init_card()
1406 err = mmc_select_timing(card); mmc_init_card()
1410 if (mmc_card_hs200(card)) { mmc_init_card()
1411 err = mmc_hs200_tuning(card); mmc_init_card()
1415 err = mmc_select_hs400(card); mmc_init_card()
1418 } else if (mmc_card_hs(card)) { mmc_init_card()
1420 err = mmc_select_bus_width(card); mmc_init_card()
1422 err = mmc_select_hs_ddr(card); mmc_init_card()
1431 mmc_select_powerclass(card); mmc_init_card()
1436 if (card->ext_csd.hpi) { mmc_init_card()
1437 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, mmc_init_card()
1439 card->ext_csd.generic_cmd6_time); mmc_init_card()
1444 mmc_hostname(card->host)); mmc_init_card()
1447 card->ext_csd.hpi_en = 1; mmc_init_card()
1454 if (card->ext_csd.cache_size > 0) { mmc_init_card()
1455 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, mmc_init_card()
1457 card->ext_csd.generic_cmd6_time); mmc_init_card()
1466 mmc_hostname(card->host), err); mmc_init_card()
1467 card->ext_csd.cache_ctrl = 0; mmc_init_card()
1470 card->ext_csd.cache_ctrl = 1; mmc_init_card()
1478 if (card->ext_csd.max_packed_writes >= 3 && mmc_init_card()
1479 card->ext_csd.max_packed_reads >= 5 && mmc_init_card()
1481 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, mmc_init_card()
1484 card->ext_csd.generic_cmd6_time); mmc_init_card()
1489 mmc_hostname(card->host)); mmc_init_card()
1490 card->ext_csd.packed_event_en = 0; mmc_init_card()
1493 card->ext_csd.packed_event_en = 1; mmc_init_card()
1498 host->card = card; mmc_init_card()
1504 mmc_remove_card(card); mmc_init_card()
1509 static int mmc_can_sleep(struct mmc_card *card) mmc_can_sleep() argument
1511 return (card && card->ext_csd.rev >= 3); mmc_can_sleep()
1517 struct mmc_card *card = host->card; mmc_sleep() local
1518 unsigned int timeout_ms = DIV_ROUND_UP(card->ext_csd.sa_timeout, 10000); mmc_sleep()
1526 cmd.arg = card->rca << 16; mmc_sleep()
1547 * If the host does not wait while the card signals busy, then we will mmc_sleep()
1550 * others) is invalid while the card sleeps. mmc_sleep()
1558 static int mmc_can_poweroff_notify(const struct mmc_card *card) mmc_can_poweroff_notify() argument
1560 return card && mmc_can_poweroff_notify()
1561 mmc_card_mmc(card) && mmc_can_poweroff_notify()
1562 (card->ext_csd.power_off_notification == EXT_CSD_POWER_ON); mmc_can_poweroff_notify()
1565 static int mmc_poweroff_notify(struct mmc_card *card, unsigned int notify_type) mmc_poweroff_notify() argument
1567 unsigned int timeout = card->ext_csd.generic_cmd6_time; mmc_poweroff_notify()
1572 timeout = card->ext_csd.power_off_longtime; mmc_poweroff_notify()
1574 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, mmc_poweroff_notify()
1579 mmc_hostname(card->host), timeout); mmc_poweroff_notify()
1582 card->ext_csd.power_off_notification = EXT_CSD_NO_POWER_NOTIFICATION; mmc_poweroff_notify()
1588 * Host is being removed. Free up the current card.
1593 BUG_ON(!host->card); mmc_remove()
1595 mmc_remove_card(host->card); mmc_remove()
1596 host->card = NULL; mmc_remove()
1600 * Card detection - card is alive.
1604 return mmc_send_status(host->card, NULL); mmc_alive()
1615 BUG_ON(!host->card); mmc_detect()
1617 mmc_get_card(host->card); mmc_detect()
1620 * Just check if our card has been removed. mmc_detect()
1624 mmc_put_card(host->card); mmc_detect()
1643 BUG_ON(!host->card); _mmc_suspend()
1647 if (mmc_card_suspended(host->card)) _mmc_suspend()
1650 if (mmc_card_doing_bkops(host->card)) { _mmc_suspend()
1651 err = mmc_stop_bkops(host->card); _mmc_suspend()
1656 err = mmc_flush_cache(host->card); _mmc_suspend()
1660 if (mmc_can_poweroff_notify(host->card) && _mmc_suspend()
1662 err = mmc_poweroff_notify(host->card, notify_type); _mmc_suspend()
1663 else if (mmc_can_sleep(host->card)) _mmc_suspend()
1670 mmc_card_set_suspended(host->card); _mmc_suspend()
1686 pm_runtime_disable(&host->card->dev); mmc_suspend()
1687 pm_runtime_set_suspended(&host->card->dev); mmc_suspend()
1694 * This function tries to determine if the same card is still present
1702 BUG_ON(!host->card); _mmc_resume()
1706 if (!mmc_card_suspended(host->card)) _mmc_resume()
1709 mmc_power_up(host, host->card->ocr); _mmc_resume()
1710 err = mmc_init_card(host, host->card->ocr, host->card); _mmc_resume()
1711 mmc_card_clr_suspended(host->card); _mmc_resume()
1726 * In a specific case for poweroff notify, we need to resume the card mmc_shutdown()
1729 if (mmc_can_poweroff_notify(host->card) && mmc_shutdown()
1748 pm_runtime_set_active(&host->card->dev); mmc_resume()
1749 pm_runtime_mark_last_busy(&host->card->dev); mmc_resume()
1751 pm_runtime_enable(&host->card->dev); mmc_resume()
1797 ret = mmc_init_card(host, host->card->ocr, host->card); mmc_power_restore()
1803 int mmc_can_reset(struct mmc_card *card) mmc_can_reset() argument
1807 rst_n_function = card->ext_csd.rst_n_function; mmc_can_reset()
1816 struct mmc_card *card = host->card; mmc_reset() local
1822 if (!mmc_can_reset(card)) mmc_reset()
1831 if (!mmc_send_status(card, &status)) { mmc_reset()
1857 * Starting point for MMC card init.
1891 * Can we support the voltage of the card? mmc_attach_mmc()
1899 * Detect and init the card. mmc_attach_mmc()
1906 err = mmc_add_card(host->card); mmc_attach_mmc()
1915 mmc_remove_card(host->card); mmc_attach_mmc()
1917 host->card = NULL; mmc_attach_mmc()
1921 pr_err("%s: error %d whilst initialising MMC card\n", mmc_attach_mmc()
H A Dbus.c11 * MMC card bus driver model
22 #include <linux/mmc/card.h>
34 struct mmc_card *card = mmc_dev_to_card(dev); type_show() local
36 switch (card->type) { type_show()
58 * This currently matches any MMC driver to any MMC card - drivers
59 * themselves make the decision whether to drive this card in their
70 struct mmc_card *card = mmc_dev_to_card(dev); mmc_bus_uevent() local
74 switch (card->type) { mmc_bus_uevent()
97 retval = add_uevent_var(env, "MMC_NAME=%s", mmc_card_name(card)); mmc_bus_uevent()
113 struct mmc_card *card = mmc_dev_to_card(dev); mmc_bus_probe() local
115 return drv->probe(card); mmc_bus_probe()
121 struct mmc_card *card = mmc_dev_to_card(dev); mmc_bus_remove() local
123 drv->remove(card); mmc_bus_remove()
131 struct mmc_card *card = mmc_dev_to_card(dev); mmc_bus_shutdown() local
132 struct mmc_host *host = card->host; mmc_bus_shutdown()
136 drv->shutdown(card); mmc_bus_shutdown()
149 struct mmc_card *card = mmc_dev_to_card(dev); mmc_bus_suspend() local
150 struct mmc_host *host = card->host; mmc_bus_suspend()
163 struct mmc_card *card = mmc_dev_to_card(dev); mmc_bus_resume() local
164 struct mmc_host *host = card->host; mmc_bus_resume()
169 pr_warn("%s: error %d during resume (card was removed?)\n", mmc_bus_resume()
180 struct mmc_card *card = mmc_dev_to_card(dev); mmc_runtime_suspend() local
181 struct mmc_host *host = card->host; mmc_runtime_suspend()
188 struct mmc_card *card = mmc_dev_to_card(dev); mmc_runtime_resume() local
189 struct mmc_host *host = card->host; mmc_runtime_resume()
247 struct mmc_card *card = mmc_dev_to_card(dev); mmc_release_card() local
249 sdio_free_common_cis(card); mmc_release_card()
251 kfree(card->info); mmc_release_card()
253 kfree(card); mmc_release_card()
257 * Allocate and initialise a new MMC card structure.
261 struct mmc_card *card; mmc_alloc_card() local
263 card = kzalloc(sizeof(struct mmc_card), GFP_KERNEL); mmc_alloc_card()
264 if (!card) mmc_alloc_card()
267 card->host = host; mmc_alloc_card()
269 device_initialize(&card->dev); mmc_alloc_card()
271 card->dev.parent = mmc_classdev(host); mmc_alloc_card()
272 card->dev.bus = &mmc_bus_type; mmc_alloc_card()
273 card->dev.release = mmc_release_card; mmc_alloc_card()
274 card->dev.type = type; mmc_alloc_card()
276 return card; mmc_alloc_card()
280 * Register a new MMC card with the driver model.
282 int mmc_add_card(struct mmc_card *card) mmc_add_card() argument
296 dev_set_name(&card->dev, "%s:%04x", mmc_hostname(card->host), card->rca); mmc_add_card()
298 switch (card->type) { mmc_add_card()
304 if (mmc_card_blockaddr(card)) { mmc_add_card()
305 if (mmc_card_ext_capacity(card)) mmc_add_card()
316 if (mmc_card_blockaddr(card)) mmc_add_card()
324 if (mmc_card_uhs(card) && mmc_add_card()
325 (card->sd_bus_speed < ARRAY_SIZE(uhs_speeds))) mmc_add_card()
326 uhs_bus_speed_mode = uhs_speeds[card->sd_bus_speed]; mmc_add_card()
328 if (mmc_host_is_spi(card->host)) { mmc_add_card()
329 pr_info("%s: new %s%s%s card on SPI\n", mmc_add_card()
330 mmc_hostname(card->host), mmc_add_card()
331 mmc_card_hs(card) ? "high speed " : "", mmc_add_card()
332 mmc_card_ddr52(card) ? "DDR " : "", mmc_add_card()
335 pr_info("%s: new %s%s%s%s%s card at address %04x\n", mmc_add_card()
336 mmc_hostname(card->host), mmc_add_card()
337 mmc_card_uhs(card) ? "ultra high speed " : mmc_add_card()
338 (mmc_card_hs(card) ? "high speed " : ""), mmc_add_card()
339 mmc_card_hs400(card) ? "HS400 " : mmc_add_card()
340 (mmc_card_hs200(card) ? "HS200 " : ""), mmc_add_card()
341 mmc_card_ddr52(card) ? "DDR " : "", mmc_add_card()
342 uhs_bus_speed_mode, type, card->rca); mmc_add_card()
346 mmc_add_card_debugfs(card); mmc_add_card()
348 mmc_init_context_info(card->host); mmc_add_card()
350 card->dev.of_node = mmc_of_find_child_device(card->host, 0); mmc_add_card()
352 ret = device_add(&card->dev); mmc_add_card()
356 mmc_card_set_present(card); mmc_add_card()
362 * Unregister a new MMC card with the driver model, and
365 void mmc_remove_card(struct mmc_card *card) mmc_remove_card() argument
368 mmc_remove_card_debugfs(card); mmc_remove_card()
371 if (mmc_card_present(card)) { mmc_remove_card()
372 if (mmc_host_is_spi(card->host)) { mmc_remove_card()
373 pr_info("%s: SPI card removed\n", mmc_remove_card()
374 mmc_hostname(card->host)); mmc_remove_card()
376 pr_info("%s: card %04x removed\n", mmc_remove_card()
377 mmc_hostname(card->host), card->rca); mmc_remove_card()
379 device_del(&card->dev); mmc_remove_card()
380 of_node_put(card->dev.of_node); mmc_remove_card()
383 put_device(&card->dev); mmc_remove_card()
H A Dsd.c20 #include <linux/mmc/card.h>
73 void mmc_decode_cid(struct mmc_card *card) mmc_decode_cid() argument
75 u32 *resp = card->raw_cid; mmc_decode_cid()
77 memset(&card->cid, 0, sizeof(struct mmc_cid)); mmc_decode_cid()
83 card->cid.manfid = UNSTUFF_BITS(resp, 120, 8); mmc_decode_cid()
84 card->cid.oemid = UNSTUFF_BITS(resp, 104, 16); mmc_decode_cid()
85 card->cid.prod_name[0] = UNSTUFF_BITS(resp, 96, 8); mmc_decode_cid()
86 card->cid.prod_name[1] = UNSTUFF_BITS(resp, 88, 8); mmc_decode_cid()
87 card->cid.prod_name[2] = UNSTUFF_BITS(resp, 80, 8); mmc_decode_cid()
88 card->cid.prod_name[3] = UNSTUFF_BITS(resp, 72, 8); mmc_decode_cid()
89 card->cid.prod_name[4] = UNSTUFF_BITS(resp, 64, 8); mmc_decode_cid()
90 card->cid.hwrev = UNSTUFF_BITS(resp, 60, 4); mmc_decode_cid()
91 card->cid.fwrev = UNSTUFF_BITS(resp, 56, 4); mmc_decode_cid()
92 card->cid.serial = UNSTUFF_BITS(resp, 24, 32); mmc_decode_cid()
93 card->cid.year = UNSTUFF_BITS(resp, 12, 8); mmc_decode_cid()
94 card->cid.month = UNSTUFF_BITS(resp, 8, 4); mmc_decode_cid()
96 card->cid.year += 2000; /* SD cards year offset */ mmc_decode_cid()
100 * Given a 128-bit response, decode to our card CSD structure.
102 static int mmc_decode_csd(struct mmc_card *card) mmc_decode_csd() argument
104 struct mmc_csd *csd = &card->csd; mmc_decode_csd()
106 u32 *resp = card->raw_csd; mmc_decode_csd()
144 * This is a block-addressed SDHC or SDXC card. Most mmc_decode_csd()
149 mmc_card_set_blockaddr(card); mmc_decode_csd()
162 mmc_card_set_ext_capacity(card); mmc_decode_csd()
178 mmc_hostname(card->host), csd_struct); mmc_decode_csd()
182 card->erase_size = csd->erase_size; mmc_decode_csd()
188 * Given a 64-bit response, decode to our card SCR structure.
190 static int mmc_decode_scr(struct mmc_card *card) mmc_decode_scr() argument
192 struct sd_scr *scr = &card->scr; mmc_decode_scr()
196 resp[3] = card->raw_scr[1]; mmc_decode_scr()
197 resp[2] = card->raw_scr[0]; mmc_decode_scr()
202 mmc_hostname(card->host), scr_struct); mmc_decode_scr()
213 card->erased_byte = 0xFF; mmc_decode_scr()
215 card->erased_byte = 0x0; mmc_decode_scr()
225 static int mmc_read_ssr(struct mmc_card *card) mmc_read_ssr() argument
231 if (!(card->csd.cmdclass & CCC_APP_SPEC)) { mmc_read_ssr()
232 pr_warn("%s: card lacks mandatory SD Status function\n", mmc_read_ssr()
233 mmc_hostname(card->host)); mmc_read_ssr()
241 err = mmc_app_sd_status(card, ssr); mmc_read_ssr()
244 mmc_hostname(card->host)); mmc_read_ssr()
258 if (au <= 9 || card->scr.sda_spec3) { mmc_read_ssr()
259 card->ssr.au = sd_au_size[au]; mmc_read_ssr()
264 card->ssr.erase_timeout = (et * 1000) / es; mmc_read_ssr()
265 card->ssr.erase_offset = eo * 1000; mmc_read_ssr()
269 mmc_hostname(card->host)); mmc_read_ssr()
280 static int mmc_read_switch(struct mmc_card *card) mmc_read_switch() argument
285 if (card->scr.sda_vsn < SCR_SPEC_VER_1) mmc_read_switch()
288 if (!(card->csd.cmdclass & CCC_SWITCH)) { mmc_read_switch()
289 pr_warn("%s: card lacks mandatory switch function, performance might suffer\n", mmc_read_switch()
290 mmc_hostname(card->host)); mmc_read_switch()
300 mmc_hostname(card->host)); mmc_read_switch()
305 * Find out the card's support bits with a mode 0 operation. mmc_read_switch()
309 err = mmc_sd_switch(card, 0, 0, 0, status); mmc_read_switch()
312 * If the host or the card can't do the switch, mmc_read_switch()
319 mmc_hostname(card->host)); mmc_read_switch()
326 card->sw_caps.hs_max_dtr = HIGH_SPEED_MAX_DTR; mmc_read_switch()
328 if (card->scr.sda_spec3) { mmc_read_switch()
329 card->sw_caps.sd3_bus_mode = status[13]; mmc_read_switch()
330 /* Driver Strengths supported by the card */ mmc_read_switch()
331 card->sw_caps.sd3_drv_type = status[9]; mmc_read_switch()
341 * Test if the card supports high-speed mode and, if so, switch to it.
343 int mmc_sd_switch_hs(struct mmc_card *card) mmc_sd_switch_hs() argument
348 if (card->scr.sda_vsn < SCR_SPEC_VER_1) mmc_sd_switch_hs()
351 if (!(card->csd.cmdclass & CCC_SWITCH)) mmc_sd_switch_hs()
354 if (!(card->host->caps & MMC_CAP_SD_HIGHSPEED)) mmc_sd_switch_hs()
357 if (card->sw_caps.hs_max_dtr == 0) mmc_sd_switch_hs()
365 "switch capabilities.\n", mmc_hostname(card->host)); mmc_sd_switch_hs()
369 err = mmc_sd_switch(card, 1, 0, 1, status); mmc_sd_switch_hs()
374 pr_warn("%s: Problem switching card into high-speed mode!\n", mmc_sd_switch_hs()
375 mmc_hostname(card->host)); mmc_sd_switch_hs()
387 static int sd_select_driver_type(struct mmc_card *card, u8 *status) sd_select_driver_type() argument
399 if (!(card->host->caps & (MMC_CAP_DRIVER_TYPE_A | MMC_CAP_DRIVER_TYPE_C sd_select_driver_type()
403 if (!card->host->ops->select_drive_strength) sd_select_driver_type()
406 if (card->host->caps & MMC_CAP_DRIVER_TYPE_A) sd_select_driver_type()
409 if (card->host->caps & MMC_CAP_DRIVER_TYPE_C) sd_select_driver_type()
412 if (card->host->caps & MMC_CAP_DRIVER_TYPE_D) sd_select_driver_type()
415 if (card->sw_caps.sd3_drv_type & SD_DRIVER_TYPE_A) sd_select_driver_type()
418 if (card->sw_caps.sd3_drv_type & SD_DRIVER_TYPE_C) sd_select_driver_type()
421 if (card->sw_caps.sd3_drv_type & SD_DRIVER_TYPE_D) sd_select_driver_type()
430 mmc_host_clk_hold(card->host); sd_select_driver_type()
431 drive_strength = card->host->ops->select_drive_strength( sd_select_driver_type()
432 card->sw_caps.uhs_max_dtr, sd_select_driver_type()
434 mmc_host_clk_release(card->host); sd_select_driver_type()
436 err = mmc_sd_switch(card, 1, 2, drive_strength, status); sd_select_driver_type()
442 mmc_hostname(card->host)); sd_select_driver_type()
446 mmc_set_driver_type(card->host, drive_strength); sd_select_driver_type()
451 static void sd_update_bus_speed_mode(struct mmc_card *card) sd_update_bus_speed_mode() argument
457 if (!mmc_host_uhs(card->host)) { sd_update_bus_speed_mode()
458 card->sd_bus_speed = 0; sd_update_bus_speed_mode()
462 if ((card->host->caps & MMC_CAP_UHS_SDR104) && sd_update_bus_speed_mode()
463 (card->sw_caps.sd3_bus_mode & SD_MODE_UHS_SDR104)) { sd_update_bus_speed_mode()
464 card->sd_bus_speed = UHS_SDR104_BUS_SPEED; sd_update_bus_speed_mode()
465 } else if ((card->host->caps & MMC_CAP_UHS_DDR50) && sd_update_bus_speed_mode()
466 (card->sw_caps.sd3_bus_mode & SD_MODE_UHS_DDR50)) { sd_update_bus_speed_mode()
467 card->sd_bus_speed = UHS_DDR50_BUS_SPEED; sd_update_bus_speed_mode()
468 } else if ((card->host->caps & (MMC_CAP_UHS_SDR104 | sd_update_bus_speed_mode()
469 MMC_CAP_UHS_SDR50)) && (card->sw_caps.sd3_bus_mode & sd_update_bus_speed_mode()
471 card->sd_bus_speed = UHS_SDR50_BUS_SPEED; sd_update_bus_speed_mode()
472 } else if ((card->host->caps & (MMC_CAP_UHS_SDR104 | sd_update_bus_speed_mode()
474 (card->sw_caps.sd3_bus_mode & SD_MODE_UHS_SDR25)) { sd_update_bus_speed_mode()
475 card->sd_bus_speed = UHS_SDR25_BUS_SPEED; sd_update_bus_speed_mode()
476 } else if ((card->host->caps & (MMC_CAP_UHS_SDR104 | sd_update_bus_speed_mode()
478 MMC_CAP_UHS_SDR12)) && (card->sw_caps.sd3_bus_mode & sd_update_bus_speed_mode()
480 card->sd_bus_speed = UHS_SDR12_BUS_SPEED; sd_update_bus_speed_mode()
484 static int sd_set_bus_speed_mode(struct mmc_card *card, u8 *status) sd_set_bus_speed_mode() argument
489 switch (card->sd_bus_speed) { sd_set_bus_speed_mode()
492 card->sw_caps.uhs_max_dtr = UHS_SDR104_MAX_DTR; sd_set_bus_speed_mode()
496 card->sw_caps.uhs_max_dtr = UHS_DDR50_MAX_DTR; sd_set_bus_speed_mode()
500 card->sw_caps.uhs_max_dtr = UHS_SDR50_MAX_DTR; sd_set_bus_speed_mode()
504 card->sw_caps.uhs_max_dtr = UHS_SDR25_MAX_DTR; sd_set_bus_speed_mode()
508 card->sw_caps.uhs_max_dtr = UHS_SDR12_MAX_DTR; sd_set_bus_speed_mode()
514 err = mmc_sd_switch(card, 1, 0, card->sd_bus_speed, status); sd_set_bus_speed_mode()
518 if ((status[16] & 0xF) != card->sd_bus_speed) sd_set_bus_speed_mode()
520 mmc_hostname(card->host)); sd_set_bus_speed_mode()
522 mmc_set_timing(card->host, timing); sd_set_bus_speed_mode()
523 mmc_set_clock(card->host, card->sw_caps.uhs_max_dtr); sd_set_bus_speed_mode()
554 static int sd_set_current_limit(struct mmc_card *card, u8 *status) sd_set_current_limit() argument
565 if ((card->sd_bus_speed != UHS_SDR50_BUS_SPEED) && sd_set_current_limit()
566 (card->sd_bus_speed != UHS_SDR104_BUS_SPEED) && sd_set_current_limit()
567 (card->sd_bus_speed != UHS_DDR50_BUS_SPEED)) sd_set_current_limit()
574 max_current = sd_get_host_max_current(card->host); sd_set_current_limit()
578 * higher than the card's maximum current, the card will be using its sd_set_current_limit()
579 * maximum current, e.g. if the card's maximum current is 300ma, and sd_set_current_limit()
580 * when we set current limit to 200ma, the card will draw 200ma, and sd_set_current_limit()
581 * when we set current limit to 400/600/800ma, the card will draw its sd_set_current_limit()
594 err = mmc_sd_switch(card, 1, 3, current_limit, status); sd_set_current_limit()
600 mmc_hostname(card->host)); sd_set_current_limit()
610 static int mmc_sd_init_uhs_card(struct mmc_card *card) mmc_sd_init_uhs_card() argument
615 if (!card->scr.sda_spec3) mmc_sd_init_uhs_card()
618 if (!(card->csd.cmdclass & CCC_SWITCH)) mmc_sd_init_uhs_card()
624 "switch capabilities.\n", mmc_hostname(card->host)); mmc_sd_init_uhs_card()
629 if ((card->host->caps & MMC_CAP_4_BIT_DATA) && mmc_sd_init_uhs_card()
630 (card->scr.bus_widths & SD_SCR_BUS_WIDTH_4)) { mmc_sd_init_uhs_card()
631 err = mmc_app_set_bus_width(card, MMC_BUS_WIDTH_4); mmc_sd_init_uhs_card()
635 mmc_set_bus_width(card->host, MMC_BUS_WIDTH_4); mmc_sd_init_uhs_card()
640 * and card capability. mmc_sd_init_uhs_card()
642 sd_update_bus_speed_mode(card); mmc_sd_init_uhs_card()
644 /* Set the driver strength for the card */ mmc_sd_init_uhs_card()
645 err = sd_select_driver_type(card, status); mmc_sd_init_uhs_card()
649 /* Set current limit for the card */ mmc_sd_init_uhs_card()
650 err = sd_set_current_limit(card, status); mmc_sd_init_uhs_card()
654 /* Set bus speed mode of the card */ mmc_sd_init_uhs_card()
655 err = sd_set_bus_speed_mode(card, status); mmc_sd_init_uhs_card()
663 if (!mmc_host_is_spi(card->host) && mmc_sd_init_uhs_card()
664 (card->host->ios.timing == MMC_TIMING_UHS_SDR50 || mmc_sd_init_uhs_card()
665 card->host->ios.timing == MMC_TIMING_UHS_DDR50 || mmc_sd_init_uhs_card()
666 card->host->ios.timing == MMC_TIMING_UHS_SDR104)) { mmc_sd_init_uhs_card()
667 err = mmc_execute_tuning(card); mmc_sd_init_uhs_card()
676 if (err && card->host->ios.timing == MMC_TIMING_UHS_DDR50) { mmc_sd_init_uhs_card()
678 mmc_hostname(card->host)); mmc_sd_init_uhs_card()
689 MMC_DEV_ATTR(cid, "%08x%08x%08x%08x\n", card->raw_cid[0], card->raw_cid[1],
690 card->raw_cid[2], card->raw_cid[3]);
691 MMC_DEV_ATTR(csd, "%08x%08x%08x%08x\n", card->raw_csd[0], card->raw_csd[1],
692 card->raw_csd[2], card->raw_csd[3]);
693 MMC_DEV_ATTR(scr, "%08x%08x\n", card->raw_scr[0], card->raw_scr[1]);
694 MMC_DEV_ATTR(date, "%02d/%04d\n", card->cid.month, card->cid.year);
695 MMC_DEV_ATTR(erase_size, "%u\n", card->erase_size << 9);
696 MMC_DEV_ATTR(preferred_erase_size, "%u\n", card->pref_erase << 9);
697 MMC_DEV_ATTR(fwrev, "0x%x\n", card->cid.fwrev);
698 MMC_DEV_ATTR(hwrev, "0x%x\n", card->cid.hwrev);
699 MMC_DEV_ATTR(manfid, "0x%06x\n", card->cid.manfid);
700 MMC_DEV_ATTR(name, "%s\n", card->cid.prod_name);
701 MMC_DEV_ATTR(oemid, "0x%04x\n", card->cid.oemid);
702 MMC_DEV_ATTR(serial, "0x%08x\n", card->cid.serial);
727 * Fetch CID from card.
752 * compliant card and we should set bit 30 mmc_sd_get_cid()
761 * If the host supports one of UHS-I modes, request the card mmc_sd_get_cid()
762 * to switch to 1.8V signaling level. If the card has failed mmc_sd_get_cid()
805 int mmc_sd_get_csd(struct mmc_host *host, struct mmc_card *card) mmc_sd_get_csd() argument
810 * Fetch CSD from card. mmc_sd_get_csd()
812 err = mmc_send_csd(card, card->raw_csd); mmc_sd_get_csd()
816 err = mmc_decode_csd(card); mmc_sd_get_csd()
823 int mmc_sd_setup_card(struct mmc_host *host, struct mmc_card *card, mmc_sd_setup_card() argument
830 * Fetch SCR from card. mmc_sd_setup_card()
832 err = mmc_app_send_scr(card, card->raw_scr); mmc_sd_setup_card()
836 err = mmc_decode_scr(card); mmc_sd_setup_card()
843 err = mmc_read_ssr(card); mmc_sd_setup_card()
848 mmc_init_erase(card); mmc_sd_setup_card()
851 * Fetch switch information from card. mmc_sd_setup_card()
853 err = mmc_read_switch(card); mmc_sd_setup_card()
861 * card registers because some SDHC cards are not able mmc_sd_setup_card()
877 mmc_host_clk_hold(card->host); mmc_sd_setup_card()
879 mmc_host_clk_release(card->host); mmc_sd_setup_card()
886 mmc_card_set_readonly(card); mmc_sd_setup_card()
893 unsigned mmc_sd_get_max_clock(struct mmc_card *card) mmc_sd_get_max_clock() argument
897 if (mmc_card_hs(card)) { mmc_sd_get_max_clock()
898 if (max_dtr > card->sw_caps.hs_max_dtr) mmc_sd_get_max_clock()
899 max_dtr = card->sw_caps.hs_max_dtr; mmc_sd_get_max_clock()
900 } else if (max_dtr > card->csd.max_dtr) { mmc_sd_get_max_clock()
901 max_dtr = card->csd.max_dtr; mmc_sd_get_max_clock()
908 * Handle the detection and initialisation of a card.
910 * In the case of a resume, "oldcard" will contain the card
916 struct mmc_card *card; mmc_sd_init_card() local
932 card = oldcard; mmc_sd_init_card()
935 * Allocate card structure. mmc_sd_init_card()
937 card = mmc_alloc_card(host, &sd_type); mmc_sd_init_card()
938 if (IS_ERR(card)) mmc_sd_init_card()
939 return PTR_ERR(card); mmc_sd_init_card()
941 card->ocr = ocr; mmc_sd_init_card()
942 card->type = MMC_TYPE_SD; mmc_sd_init_card()
943 memcpy(card->raw_cid, cid, sizeof(card->raw_cid)); mmc_sd_init_card()
950 host->ops->init_card(host, card); mmc_sd_init_card()
953 * For native busses: get card RCA and quit open drain mode. mmc_sd_init_card()
956 err = mmc_send_relative_addr(host, &card->rca); mmc_sd_init_card()
962 err = mmc_sd_get_csd(host, card); mmc_sd_init_card()
966 mmc_decode_cid(card); mmc_sd_init_card()
973 if (card->csd.dsr_imp && host->dsr_req) mmc_sd_init_card()
977 * Select card, as all following commands rely on that. mmc_sd_init_card()
980 err = mmc_select_card(card); mmc_sd_init_card()
985 err = mmc_sd_setup_card(host, card, oldcard != NULL); mmc_sd_init_card()
991 err = mmc_sd_init_uhs_card(card); mmc_sd_init_card()
998 err = mmc_sd_switch_hs(card); mmc_sd_init_card()
1000 mmc_set_timing(card->host, MMC_TIMING_SD_HS); mmc_sd_init_card()
1007 mmc_set_clock(host, mmc_sd_get_max_clock(card)); mmc_sd_init_card()
1013 (card->scr.bus_widths & SD_SCR_BUS_WIDTH_4)) { mmc_sd_init_card()
1014 err = mmc_app_set_bus_width(card, MMC_BUS_WIDTH_4); mmc_sd_init_card()
1022 host->card = card; mmc_sd_init_card()
1027 mmc_remove_card(card); mmc_sd_init_card()
1033 * Host is being removed. Free up the current card.
1038 BUG_ON(!host->card); mmc_sd_remove()
1040 mmc_remove_card(host->card); mmc_sd_remove()
1041 host->card = NULL; mmc_sd_remove()
1045 * Card detection - card is alive.
1049 return mmc_send_status(host->card, NULL); mmc_sd_alive()
1060 BUG_ON(!host->card); mmc_sd_detect()
1062 mmc_get_card(host->card); mmc_sd_detect()
1065 * Just check if our card has been removed. mmc_sd_detect()
1069 mmc_put_card(host->card); mmc_sd_detect()
1086 BUG_ON(!host->card); _mmc_sd_suspend()
1090 if (mmc_card_suspended(host->card)) _mmc_sd_suspend()
1098 mmc_card_set_suspended(host->card); _mmc_sd_suspend()
1115 pm_runtime_disable(&host->card->dev); mmc_sd_suspend()
1116 pm_runtime_set_suspended(&host->card->dev); mmc_sd_suspend()
1123 * This function tries to determine if the same card is still present
1131 BUG_ON(!host->card); _mmc_sd_resume()
1135 if (!mmc_card_suspended(host->card)) _mmc_sd_resume()
1138 mmc_power_up(host, host->card->ocr); _mmc_sd_resume()
1139 err = mmc_sd_init_card(host, host->card->ocr, host->card); _mmc_sd_resume()
1140 mmc_card_clr_suspended(host->card); _mmc_sd_resume()
1156 pm_runtime_set_active(&host->card->dev); mmc_sd_resume()
1157 pm_runtime_mark_last_busy(&host->card->dev); mmc_sd_resume()
1159 pm_runtime_enable(&host->card->dev); mmc_sd_resume()
1205 ret = mmc_sd_init_card(host, host->card->ocr, host->card); mmc_sd_power_restore()
1213 mmc_power_cycle(host, host->card->ocr); mmc_sd_reset()
1231 * Starting point for SD card init.
1263 * Can we support the voltage(s) of the card(s)? mmc_attach_sd()
1271 * Detect and init the card. mmc_attach_sd()
1278 err = mmc_add_card(host->card); mmc_attach_sd()
1287 mmc_remove_card(host->card); mmc_attach_sd()
1288 host->card = NULL; mmc_attach_sd()
1293 pr_err("%s: error %d whilst initialising SD card\n", mmc_attach_sd()
H A Dsdio.c16 #include <linux/mmc/card.h>
36 if (mmc_card_nonstd_func_interface(func->card)) { sdio_read_fbr()
41 ret = mmc_io_rw_direct(func->card, 0, 0, sdio_read_fbr()
49 ret = mmc_io_rw_direct(func->card, 0, 0, sdio_read_fbr()
61 static int sdio_init_func(struct mmc_card *card, unsigned int fn) sdio_init_func() argument
68 func = sdio_alloc_func(card); sdio_init_func()
74 if (!(card->quirks & MMC_QUIRK_NONSTD_SDIO)) { sdio_init_func()
83 func->vendor = func->card->cis.vendor; sdio_init_func()
84 func->device = func->card->cis.device; sdio_init_func()
85 func->max_blksize = func->card->cis.blksize; sdio_init_func()
88 card->sdio_func[fn - 1] = func; sdio_init_func()
101 static int sdio_read_cccr(struct mmc_card *card, u32 ocr) sdio_read_cccr() argument
109 memset(&card->cccr, 0, sizeof(struct sdio_cccr)); sdio_read_cccr()
111 ret = mmc_io_rw_direct(card, 0, 0, SDIO_CCCR_CCCR, 0, &data); sdio_read_cccr()
119 mmc_hostname(card->host), cccr_vsn); sdio_read_cccr()
123 card->cccr.sdio_vsn = (data & 0xf0) >> 4; sdio_read_cccr()
125 ret = mmc_io_rw_direct(card, 0, 0, SDIO_CCCR_CAPS, 0, &data); sdio_read_cccr()
130 card->cccr.multi_block = 1; sdio_read_cccr()
132 card->cccr.low_speed = 1; sdio_read_cccr()
134 card->cccr.wide_bus = 1; sdio_read_cccr()
137 ret = mmc_io_rw_direct(card, 0, 0, SDIO_CCCR_POWER, 0, &data); sdio_read_cccr()
142 card->cccr.high_power = 1; sdio_read_cccr()
146 ret = mmc_io_rw_direct(card, 0, 0, SDIO_CCCR_SPEED, 0, &speed); sdio_read_cccr()
150 card->scr.sda_spec3 = 0; sdio_read_cccr()
151 card->sw_caps.sd3_bus_mode = 0; sdio_read_cccr()
152 card->sw_caps.sd3_drv_type = 0; sdio_read_cccr()
154 card->scr.sda_spec3 = 1; sdio_read_cccr()
155 ret = mmc_io_rw_direct(card, 0, 0, sdio_read_cccr()
160 if (mmc_host_uhs(card->host)) { sdio_read_cccr()
162 card->sw_caps.sd3_bus_mode sdio_read_cccr()
166 card->sw_caps.sd3_bus_mode sdio_read_cccr()
170 card->sw_caps.sd3_bus_mode sdio_read_cccr()
174 ret = mmc_io_rw_direct(card, 0, 0, sdio_read_cccr()
180 card->sw_caps.sd3_drv_type |= SD_DRIVER_TYPE_A; sdio_read_cccr()
182 card->sw_caps.sd3_drv_type |= SD_DRIVER_TYPE_C; sdio_read_cccr()
184 card->sw_caps.sd3_drv_type |= SD_DRIVER_TYPE_D; sdio_read_cccr()
188 if (!card->sw_caps.sd3_bus_mode) { sdio_read_cccr()
190 card->cccr.high_speed = 1; sdio_read_cccr()
191 card->sw_caps.hs_max_dtr = 50000000; sdio_read_cccr()
193 card->cccr.high_speed = 0; sdio_read_cccr()
194 card->sw_caps.hs_max_dtr = 25000000; sdio_read_cccr()
203 static int sdio_enable_wide(struct mmc_card *card) sdio_enable_wide() argument
208 if (!(card->host->caps & MMC_CAP_4_BIT_DATA)) sdio_enable_wide()
211 if (card->cccr.low_speed && !card->cccr.wide_bus) sdio_enable_wide()
214 ret = mmc_io_rw_direct(card, 0, 0, SDIO_CCCR_IF, 0, &ctrl); sdio_enable_wide()
220 mmc_hostname(card->host), ctrl); sdio_enable_wide()
226 ret = mmc_io_rw_direct(card, 1, 0, SDIO_CCCR_IF, ctrl, NULL); sdio_enable_wide()
235 * of the card. This may be required on certain setups of boards,
236 * controllers and embedded sdio device which do not need the card's
237 * pull-up. As a result, card detection is disabled and power is saved.
239 static int sdio_disable_cd(struct mmc_card *card) sdio_disable_cd() argument
244 if (!mmc_card_disable_cd(card)) sdio_disable_cd()
247 ret = mmc_io_rw_direct(card, 0, 0, SDIO_CCCR_IF, 0, &ctrl); sdio_disable_cd()
253 return mmc_io_rw_direct(card, 1, 0, SDIO_CCCR_IF, ctrl, NULL); sdio_disable_cd()
260 static int sdio_disable_wide(struct mmc_card *card) sdio_disable_wide() argument
265 if (!(card->host->caps & MMC_CAP_4_BIT_DATA)) sdio_disable_wide()
268 if (card->cccr.low_speed && !card->cccr.wide_bus) sdio_disable_wide()
271 ret = mmc_io_rw_direct(card, 0, 0, SDIO_CCCR_IF, 0, &ctrl); sdio_disable_wide()
281 ret = mmc_io_rw_direct(card, 1, 0, SDIO_CCCR_IF, ctrl, NULL); sdio_disable_wide()
285 mmc_set_bus_width(card->host, MMC_BUS_WIDTH_1); sdio_disable_wide()
291 static int sdio_enable_4bit_bus(struct mmc_card *card) sdio_enable_4bit_bus() argument
295 if (card->type == MMC_TYPE_SDIO) sdio_enable_4bit_bus()
296 err = sdio_enable_wide(card); sdio_enable_4bit_bus()
297 else if ((card->host->caps & MMC_CAP_4_BIT_DATA) && sdio_enable_4bit_bus()
298 (card->scr.bus_widths & SD_SCR_BUS_WIDTH_4)) { sdio_enable_4bit_bus()
299 err = mmc_app_set_bus_width(card, MMC_BUS_WIDTH_4); sdio_enable_4bit_bus()
302 err = sdio_enable_wide(card); sdio_enable_4bit_bus()
304 mmc_app_set_bus_width(card, MMC_BUS_WIDTH_1); sdio_enable_4bit_bus()
309 mmc_set_bus_width(card->host, MMC_BUS_WIDTH_4); sdio_enable_4bit_bus()
318 * Test if the card supports high-speed mode and, if so, switch to it.
320 static int mmc_sdio_switch_hs(struct mmc_card *card, int enable) mmc_sdio_switch_hs() argument
325 if (!(card->host->caps & MMC_CAP_SD_HIGHSPEED)) mmc_sdio_switch_hs()
328 if (!card->cccr.high_speed) mmc_sdio_switch_hs()
331 ret = mmc_io_rw_direct(card, 0, 0, SDIO_CCCR_SPEED, 0, &speed); mmc_sdio_switch_hs()
340 ret = mmc_io_rw_direct(card, 1, 0, SDIO_CCCR_SPEED, speed, NULL); mmc_sdio_switch_hs()
348 * Enable SDIO/combo card's high-speed mode. Return 0/1 if [not]supported.
350 static int sdio_enable_hs(struct mmc_card *card) sdio_enable_hs() argument
354 ret = mmc_sdio_switch_hs(card, true); sdio_enable_hs()
355 if (ret <= 0 || card->type == MMC_TYPE_SDIO) sdio_enable_hs()
358 ret = mmc_sd_switch_hs(card); sdio_enable_hs()
360 mmc_sdio_switch_hs(card, false); sdio_enable_hs()
365 static unsigned mmc_sdio_get_max_clock(struct mmc_card *card) mmc_sdio_get_max_clock() argument
369 if (mmc_card_hs(card)) { mmc_sdio_get_max_clock()
378 max_dtr = card->cis.max_dtr; mmc_sdio_get_max_clock()
381 if (card->type == MMC_TYPE_SD_COMBO) mmc_sdio_get_max_clock()
382 max_dtr = min(max_dtr, mmc_sd_get_max_clock(card)); mmc_sdio_get_max_clock()
403 static void sdio_select_driver_type(struct mmc_card *card) sdio_select_driver_type() argument
416 if (!(card->host->caps & sdio_select_driver_type()
422 if (!card->host->ops->select_drive_strength) sdio_select_driver_type()
425 if (card->host->caps & MMC_CAP_DRIVER_TYPE_A) sdio_select_driver_type()
428 if (card->host->caps & MMC_CAP_DRIVER_TYPE_C) sdio_select_driver_type()
431 if (card->host->caps & MMC_CAP_DRIVER_TYPE_D) sdio_select_driver_type()
434 if (card->sw_caps.sd3_drv_type & SD_DRIVER_TYPE_A) sdio_select_driver_type()
437 if (card->sw_caps.sd3_drv_type & SD_DRIVER_TYPE_C) sdio_select_driver_type()
440 if (card->sw_caps.sd3_drv_type & SD_DRIVER_TYPE_D) sdio_select_driver_type()
449 drive_strength = card->host->ops->select_drive_strength( sdio_select_driver_type()
450 card->sw_caps.uhs_max_dtr, sdio_select_driver_type()
454 err = mmc_io_rw_direct(card, 0, 0, SDIO_CCCR_DRIVE_STRENGTH, 0, sdio_select_driver_type()
462 err = mmc_io_rw_direct(card, 1, 0, SDIO_CCCR_DRIVE_STRENGTH, sdio_select_driver_type()
467 mmc_set_driver_type(card->host, drive_strength); sdio_select_driver_type()
471 static int sdio_set_bus_speed_mode(struct mmc_card *card) sdio_set_bus_speed_mode() argument
481 if (!mmc_host_uhs(card->host)) sdio_set_bus_speed_mode()
486 if ((card->host->caps & MMC_CAP_UHS_SDR104) && sdio_set_bus_speed_mode()
487 (card->sw_caps.sd3_bus_mode & SD_MODE_UHS_SDR104)) { sdio_set_bus_speed_mode()
490 card->sw_caps.uhs_max_dtr = UHS_SDR104_MAX_DTR; sdio_set_bus_speed_mode()
491 card->sd_bus_speed = UHS_SDR104_BUS_SPEED; sdio_set_bus_speed_mode()
492 } else if ((card->host->caps & MMC_CAP_UHS_DDR50) && sdio_set_bus_speed_mode()
493 (card->sw_caps.sd3_bus_mode & SD_MODE_UHS_DDR50)) { sdio_set_bus_speed_mode()
496 card->sw_caps.uhs_max_dtr = UHS_DDR50_MAX_DTR; sdio_set_bus_speed_mode()
497 card->sd_bus_speed = UHS_DDR50_BUS_SPEED; sdio_set_bus_speed_mode()
498 } else if ((card->host->caps & (MMC_CAP_UHS_SDR104 | sdio_set_bus_speed_mode()
499 MMC_CAP_UHS_SDR50)) && (card->sw_caps.sd3_bus_mode & sdio_set_bus_speed_mode()
503 card->sw_caps.uhs_max_dtr = UHS_SDR50_MAX_DTR; sdio_set_bus_speed_mode()
504 card->sd_bus_speed = UHS_SDR50_BUS_SPEED; sdio_set_bus_speed_mode()
505 } else if ((card->host->caps & (MMC_CAP_UHS_SDR104 | sdio_set_bus_speed_mode()
507 (card->sw_caps.sd3_bus_mode & SD_MODE_UHS_SDR25)) { sdio_set_bus_speed_mode()
510 card->sw_caps.uhs_max_dtr = UHS_SDR25_MAX_DTR; sdio_set_bus_speed_mode()
511 card->sd_bus_speed = UHS_SDR25_BUS_SPEED; sdio_set_bus_speed_mode()
512 } else if ((card->host->caps & (MMC_CAP_UHS_SDR104 | sdio_set_bus_speed_mode()
514 MMC_CAP_UHS_SDR12)) && (card->sw_caps.sd3_bus_mode & sdio_set_bus_speed_mode()
518 card->sw_caps.uhs_max_dtr = UHS_SDR12_MAX_DTR; sdio_set_bus_speed_mode()
519 card->sd_bus_speed = UHS_SDR12_BUS_SPEED; sdio_set_bus_speed_mode()
522 err = mmc_io_rw_direct(card, 0, 0, SDIO_CCCR_SPEED, 0, &speed); sdio_set_bus_speed_mode()
528 err = mmc_io_rw_direct(card, 1, 0, SDIO_CCCR_SPEED, speed, NULL); sdio_set_bus_speed_mode()
533 mmc_set_timing(card->host, timing); sdio_set_bus_speed_mode()
534 mmc_set_clock(card->host, card->sw_caps.uhs_max_dtr); sdio_set_bus_speed_mode()
543 static int mmc_sdio_init_uhs_card(struct mmc_card *card) mmc_sdio_init_uhs_card() argument
547 if (!card->scr.sda_spec3) mmc_sdio_init_uhs_card()
553 if (card->host->caps & MMC_CAP_4_BIT_DATA) mmc_sdio_init_uhs_card()
554 err = sdio_enable_4bit_bus(card); mmc_sdio_init_uhs_card()
556 /* Set the driver strength for the card */ mmc_sdio_init_uhs_card()
557 sdio_select_driver_type(card); mmc_sdio_init_uhs_card()
559 /* Set bus speed mode of the card */ mmc_sdio_init_uhs_card()
560 err = sdio_set_bus_speed_mode(card); mmc_sdio_init_uhs_card()
568 if (!mmc_host_is_spi(card->host) && mmc_sdio_init_uhs_card()
569 ((card->host->ios.timing == MMC_TIMING_UHS_SDR50) || mmc_sdio_init_uhs_card()
570 (card->host->ios.timing == MMC_TIMING_UHS_SDR104))) mmc_sdio_init_uhs_card()
571 err = mmc_execute_tuning(card); mmc_sdio_init_uhs_card()
577 * Handle the detection and initialisation of a card.
579 * In the case of a resume, "oldcard" will contain the card
585 struct mmc_card *card; mmc_sdio_init_card() local
594 /* to query card if 1.8V signalling is supported */ mmc_sdio_init_card()
605 * Inform the card of the voltage mmc_sdio_init_card()
623 * Allocate card structure. mmc_sdio_init_card()
625 card = mmc_alloc_card(host, NULL); mmc_sdio_init_card()
626 if (IS_ERR(card)) { mmc_sdio_init_card()
627 err = PTR_ERR(card); mmc_sdio_init_card()
632 mmc_sd_get_cid(host, ocr & rocr, card->raw_cid, NULL) == 0) { mmc_sdio_init_card()
633 card->type = MMC_TYPE_SD_COMBO; mmc_sdio_init_card()
636 memcmp(card->raw_cid, oldcard->raw_cid, sizeof(card->raw_cid)) != 0)) { mmc_sdio_init_card()
637 mmc_remove_card(card); mmc_sdio_init_card()
641 card->type = MMC_TYPE_SDIO; mmc_sdio_init_card()
644 mmc_remove_card(card); mmc_sdio_init_card()
653 host->ops->init_card(host, card); mmc_sdio_init_card()
656 * If the host and card support UHS-I mode request the card mmc_sdio_init_card()
669 mmc_remove_card(card); mmc_sdio_init_card()
681 * For native busses: set card RCA and quit open drain mode. mmc_sdio_init_card()
684 err = mmc_send_relative_addr(host, &card->rca); mmc_sdio_init_card()
691 * "card" struct when oldcard overwrites that later. mmc_sdio_init_card()
694 oldcard->rca = card->rca; mmc_sdio_init_card()
698 * Read CSD, before selecting the card mmc_sdio_init_card()
700 if (!oldcard && card->type == MMC_TYPE_SD_COMBO) { mmc_sdio_init_card()
701 err = mmc_sd_get_csd(host, card); mmc_sdio_init_card()
705 mmc_decode_cid(card); mmc_sdio_init_card()
709 * Select card, as all following commands rely on that. mmc_sdio_init_card()
712 err = mmc_select_card(card); mmc_sdio_init_card()
717 if (card->quirks & MMC_QUIRK_NONSTD_SDIO) { mmc_sdio_init_card()
724 mmc_set_clock(host, card->cis.max_dtr); mmc_sdio_init_card()
726 if (card->cccr.high_speed) { mmc_sdio_init_card()
727 mmc_set_timing(card->host, MMC_TIMING_SD_HS); mmc_sdio_init_card()
736 err = sdio_read_cccr(card, ocr); mmc_sdio_init_card()
743 err = sdio_read_common_cis(card); mmc_sdio_init_card()
748 int same = (card->cis.vendor == oldcard->cis.vendor && mmc_sdio_init_card()
749 card->cis.device == oldcard->cis.device); mmc_sdio_init_card()
750 mmc_remove_card(card); mmc_sdio_init_card()
754 card = oldcard; mmc_sdio_init_card()
756 card->ocr = ocr_card; mmc_sdio_init_card()
757 mmc_fixup_device(card, NULL); mmc_sdio_init_card()
759 if (card->type == MMC_TYPE_SD_COMBO) { mmc_sdio_init_card()
760 err = mmc_sd_setup_card(host, card, oldcard != NULL); mmc_sdio_init_card()
761 /* handle as SDIO-only card if memory init failed */ mmc_sdio_init_card()
767 card->type = MMC_TYPE_SDIO; mmc_sdio_init_card()
769 card->dev.type = &sd_type; mmc_sdio_init_card()
773 * If needed, disconnect card detection pull-up resistor. mmc_sdio_init_card()
775 err = sdio_disable_cd(card); mmc_sdio_init_card()
780 /* Only if card supports 1.8v and UHS signaling */ mmc_sdio_init_card()
781 if ((ocr & R4_18V_PRESENT) && card->sw_caps.sd3_bus_mode) { mmc_sdio_init_card()
782 err = mmc_sdio_init_uhs_card(card); mmc_sdio_init_card()
789 err = sdio_enable_hs(card); mmc_sdio_init_card()
791 mmc_set_timing(card->host, MMC_TIMING_SD_HS); mmc_sdio_init_card()
796 * Change to the card's maximum speed. mmc_sdio_init_card()
798 mmc_set_clock(host, mmc_sdio_get_max_clock(card)); mmc_sdio_init_card()
803 err = sdio_enable_4bit_bus(card); mmc_sdio_init_card()
809 host->card = card; mmc_sdio_init_card()
814 mmc_remove_card(card); mmc_sdio_init_card()
821 * Host is being removed. Free up the current card.
828 BUG_ON(!host->card); mmc_sdio_remove()
830 for (i = 0;i < host->card->sdio_funcs;i++) { mmc_sdio_remove()
831 if (host->card->sdio_func[i]) { mmc_sdio_remove()
832 sdio_remove_func(host->card->sdio_func[i]); mmc_sdio_remove()
833 host->card->sdio_func[i] = NULL; mmc_sdio_remove()
837 mmc_remove_card(host->card); mmc_sdio_remove()
838 host->card = NULL; mmc_sdio_remove()
842 * Card detection - card is alive.
846 return mmc_select_card(host->card); mmc_sdio_alive()
857 BUG_ON(!host->card); mmc_sdio_detect()
859 /* Make sure card is powered before detecting it */ mmc_sdio_detect()
861 err = pm_runtime_get_sync(&host->card->dev); mmc_sdio_detect()
863 pm_runtime_put_noidle(&host->card->dev); mmc_sdio_detect()
871 * Just check if our card has been removed. mmc_sdio_detect()
878 * Tell PM core it's OK to power off the card now. mmc_sdio_detect()
880 * The _sync variant is used in order to ensure that the card mmc_sdio_detect()
881 * is left powered off in case an error occurred, and the card mmc_sdio_detect()
889 pm_runtime_put_sync(&host->card->dev); mmc_sdio_detect()
905 * and resume methods. Failing that we simply remove the whole card.
911 for (i = 0; i < host->card->sdio_funcs; i++) { mmc_sdio_pre_suspend()
912 struct sdio_func *func = host->card->sdio_func[i]; mmc_sdio_pre_suspend()
916 /* force removal of entire card in that case */ mmc_sdio_pre_suspend()
933 sdio_disable_wide(host->card); mmc_sdio_suspend()
948 BUG_ON(!host->card); mmc_sdio_resume()
950 /* Basic card reinitialization. */ mmc_sdio_resume()
955 mmc_power_up(host, host->card->ocr); mmc_sdio_resume()
957 * Tell runtime PM core we just powered up the card, mmc_sdio_resume()
958 * since it still believes the card is powered off. mmc_sdio_resume()
963 pm_runtime_disable(&host->card->dev); mmc_sdio_resume()
964 pm_runtime_set_active(&host->card->dev); mmc_sdio_resume()
965 pm_runtime_enable(&host->card->dev); mmc_sdio_resume()
973 mmc_send_if_cond(host, host->card->ocr); mmc_sdio_resume()
976 err = mmc_sdio_init_card(host, host->card->ocr, mmc_sdio_resume()
977 host->card, mmc_sdio_resume()
981 err = sdio_enable_4bit_bus(host->card); mmc_sdio_resume()
1005 BUG_ON(!host->card); mmc_sdio_power_restore()
1010 * Reset the card by performing the same steps that are taken by mmc_sdio_power_restore()
1028 mmc_send_if_cond(host, host->card->ocr); mmc_sdio_power_restore()
1034 ret = mmc_sdio_init_card(host, host->card->ocr, host->card, mmc_sdio_power_restore()
1047 /* No references to the card, cut the power to it. */ mmc_sdio_runtime_suspend()
1055 mmc_power_up(host, host->card->ocr); mmc_sdio_runtime_resume()
1073 * Starting point for SDIO card init.
1079 struct mmc_card *card; mmc_attach_sdio() local
1096 * Can we support the voltage(s) of the card(s)? mmc_attach_sdio()
1104 * Detect and init the card. mmc_attach_sdio()
1110 card = host->card; mmc_attach_sdio()
1113 * Enable runtime PM only if supported by host+card+board mmc_attach_sdio()
1117 * Let runtime PM core know our card is active mmc_attach_sdio()
1119 err = pm_runtime_set_active(&card->dev); mmc_attach_sdio()
1124 * Enable runtime PM for this card mmc_attach_sdio()
1126 pm_runtime_enable(&card->dev); mmc_attach_sdio()
1130 * The number of functions on the card is encoded inside mmc_attach_sdio()
1134 card->sdio_funcs = 0; mmc_attach_sdio()
1139 for (i = 0; i < funcs; i++, card->sdio_funcs++) { mmc_attach_sdio()
1140 err = sdio_init_func(host->card, i + 1); mmc_attach_sdio()
1148 pm_runtime_enable(&card->sdio_func[i]->dev); mmc_attach_sdio()
1152 * First add the card to the driver model... mmc_attach_sdio()
1155 err = mmc_add_card(host->card); mmc_attach_sdio()
1163 err = sdio_add_func(host->card->sdio_func[i]); mmc_attach_sdio()
1179 if (host->card) mmc_attach_sdio()
1185 pr_err("%s: error %d whilst initialising SDIO card\n", mmc_attach_sdio()
H A Dquirks.c15 #include <linux/mmc/card.h>
41 static void add_quirk_for_sdio_devices(struct mmc_card *card, int data) add_quirk_for_sdio_devices() argument
43 if (mmc_card_sdio(card)) add_quirk_for_sdio_devices()
44 card->quirks |= data; add_quirk_for_sdio_devices()
72 void mmc_fixup_device(struct mmc_card *card, const struct mmc_fixup *table) mmc_fixup_device() argument
75 u64 rev = cid_rev_card(card); mmc_fixup_device()
83 f->manfid == card->cid.manfid) && mmc_fixup_device()
85 f->oemid == card->cid.oemid) && mmc_fixup_device()
87 !strncmp(f->name, card->cid.prod_name, mmc_fixup_device()
88 sizeof(card->cid.prod_name))) && mmc_fixup_device()
89 (f->cis_vendor == card->cis.vendor || mmc_fixup_device()
91 (f->cis_device == card->cis.device || mmc_fixup_device()
94 dev_dbg(&card->dev, "calling %pf\n", f->vendor_fixup); mmc_fixup_device()
95 f->vendor_fixup(card, f->data); mmc_fixup_device()
H A Dmmc_ops.h15 int mmc_select_card(struct mmc_card *card);
21 int mmc_set_relative_addr(struct mmc_card *card);
22 int mmc_send_csd(struct mmc_card *card, u32 *csd);
23 int mmc_send_status(struct mmc_card *card, u32 *status);
27 int mmc_bus_test(struct mmc_card *card, u8 bus_width);
28 int mmc_send_hpi_cmd(struct mmc_card *card, u32 *status);
29 int mmc_can_ext_csd(struct mmc_card *card);
H A Dsdio_cis.c20 #include <linux/mmc/card.h>
27 static int cistpl_vers_1(struct mmc_card *card, struct sdio_func *func, cistpl_vers_1() argument
67 card->num_info = nr_strings; cistpl_vers_1()
68 card->info = (const char**)buffer; cistpl_vers_1()
74 static int cistpl_manfid(struct mmc_card *card, struct sdio_func *func, cistpl_manfid() argument
89 card->cis.vendor = vendor; cistpl_manfid()
90 card->cis.device = device; cistpl_manfid()
111 static int cis_tpl_parse(struct mmc_card *card, struct sdio_func *func, cis_tpl_parse() argument
127 ret = tpl->parse(card, func, buf, size); cis_tpl_parse()
136 mmc_hostname(card->host), tpl_descr, code, size); cis_tpl_parse()
146 static int cistpl_funce_common(struct mmc_card *card, struct sdio_func *func, cistpl_funce_common() argument
154 card->cis.blksize = buf[1] | (buf[2] << 8); cistpl_funce_common()
157 card->cis.max_dtr = speed_val[(buf[3] >> 3) & 15] * cistpl_funce_common()
163 static int cistpl_funce_func(struct mmc_card *card, struct sdio_func *func, cistpl_funce_func() argument
177 vsn = func->card->cccr.sdio_vsn; cistpl_funce_func()
208 static int cistpl_funce(struct mmc_card *card, struct sdio_func *func, cistpl_funce() argument
214 return cis_tpl_parse(card, func, "CISTPL_FUNCE", cistpl_funce()
228 static int sdio_read_cis(struct mmc_card *card, struct sdio_func *func) sdio_read_cis() argument
247 ret = mmc_io_rw_direct(card, 0, 0, sdio_read_cis()
257 prev = &card->tuples; sdio_read_cis()
264 ret = mmc_io_rw_direct(card, 0, 0, ptr++, 0, &tpl_code); sdio_read_cis()
276 ret = mmc_io_rw_direct(card, 0, 0, ptr++, 0, &tpl_link); sdio_read_cis()
289 ret = mmc_io_rw_direct(card, 0, 0, sdio_read_cis()
300 ret = cis_tpl_parse(card, func, "CIS", sdio_read_cis()
318 mmc_hostname(card->host), sdio_read_cis()
341 *prev = card->tuples; sdio_read_cis()
346 int sdio_read_common_cis(struct mmc_card *card) sdio_read_common_cis() argument
348 return sdio_read_cis(card, NULL); sdio_read_common_cis()
351 void sdio_free_common_cis(struct mmc_card *card) sdio_free_common_cis() argument
355 tuple = card->tuples; sdio_free_common_cis()
363 card->tuples = NULL; sdio_free_common_cis()
370 ret = sdio_read_cis(func->card, func); sdio_read_func_cis()
375 * Since we've linked to tuples in the card structure, sdio_read_func_cis()
378 get_device(&func->card->dev); sdio_read_func_cis()
382 * copy it from the card structure as needed. sdio_read_func_cis()
385 func->vendor = func->card->cis.vendor; sdio_read_func_cis()
386 func->device = func->card->cis.device; sdio_read_func_cis()
398 while (tuple && tuple != func->card->tuples) { sdio_free_func_cis()
408 * card structure, so remove the reference. sdio_free_func_cis()
410 put_device(&func->card->dev); sdio_free_func_cis()
H A Dsd_ops.c18 #include <linux/mmc/card.h>
25 int mmc_app_cmd(struct mmc_host *host, struct mmc_card *card) mmc_app_cmd() argument
31 BUG_ON(card && (card->host != host)); mmc_app_cmd()
35 if (card) { mmc_app_cmd()
36 cmd.arg = card->rca << 16; mmc_app_cmd()
47 /* Check that card supported application commands */ mmc_app_cmd()
59 * @card: Card to send MMC_APP_CMD to
63 * Sends a MMC_APP_CMD, checks the card response, sends the command
68 int mmc_wait_for_app_cmd(struct mmc_host *host, struct mmc_card *card, mmc_wait_for_app_cmd() argument
85 err = mmc_app_cmd(host, card); mmc_wait_for_app_cmd()
121 int mmc_app_set_bus_width(struct mmc_card *card, int width) mmc_app_set_bus_width() argument
126 BUG_ON(!card); mmc_app_set_bus_width()
127 BUG_ON(!card->host); mmc_app_set_bus_width()
143 err = mmc_wait_for_app_cmd(card->host, card, &cmd, MMC_CMD_RETRIES); mmc_app_set_bus_width()
188 pr_err("%s: card never left busy state\n", mmc_hostname(host)); mmc_send_app_op_cond()
248 int mmc_app_send_scr(struct mmc_card *card, u32 *scr) mmc_app_send_scr() argument
257 BUG_ON(!card); mmc_app_send_scr()
258 BUG_ON(!card->host); mmc_app_send_scr()
263 err = mmc_app_cmd(card->host, card); mmc_app_send_scr()
270 data_buf = kmalloc(sizeof(card->raw_scr), GFP_KERNEL); mmc_app_send_scr()
289 mmc_set_data_timeout(&data, card); mmc_app_send_scr()
291 mmc_wait_for_req(card->host, &mrq); mmc_app_send_scr()
293 memcpy(scr, data_buf, sizeof(card->raw_scr)); mmc_app_send_scr()
307 int mmc_sd_switch(struct mmc_card *card, int mode, int group, mmc_sd_switch() argument
315 BUG_ON(!card); mmc_sd_switch()
316 BUG_ON(!card->host); mmc_sd_switch()
340 mmc_set_data_timeout(&data, card); mmc_sd_switch()
342 mmc_wait_for_req(card->host, &mrq); mmc_sd_switch()
352 int mmc_app_sd_status(struct mmc_card *card, void *ssr) mmc_app_sd_status() argument
360 BUG_ON(!card); mmc_app_sd_status()
361 BUG_ON(!card->host); mmc_app_sd_status()
366 err = mmc_app_cmd(card->host, card); mmc_app_sd_status()
385 mmc_set_data_timeout(&data, card); mmc_app_sd_status()
387 mmc_wait_for_req(card->host, &mrq); mmc_app_sd_status()
H A Dsd_ops.h15 int mmc_app_set_bus_width(struct mmc_card *card, int width);
19 int mmc_app_send_scr(struct mmc_card *card, u32 *scr);
20 int mmc_sd_switch(struct mmc_card *card, int mode, int group,
22 int mmc_app_sd_status(struct mmc_card *card, void *ssr);
H A Dsdio_irq.c25 #include <linux/mmc/card.h>
33 struct mmc_card *card = host->card; process_sdio_pending_irqs() local
43 func = card->sdio_single_irq; process_sdio_pending_irqs()
49 ret = mmc_io_rw_direct(card, 0, 0, SDIO_CCCR_INTx, 0, &pending); process_sdio_pending_irqs()
52 mmc_card_id(card), ret); process_sdio_pending_irqs()
56 if (pending && mmc_card_broken_irq_polling(card) && process_sdio_pending_irqs()
61 * register with a Marvell SD8797 card. A dummy CMD52 read to process_sdio_pending_irqs()
64 mmc_io_rw_direct(card, 0, 0, 0xff, 0, &dummy); process_sdio_pending_irqs()
70 func = card->sdio_func[i - 1]; process_sdio_pending_irqs()
73 mmc_card_id(card)); process_sdio_pending_irqs()
113 * asynchronous notification of pending SDIO card interrupts sdio_irq_thread()
193 static int sdio_card_irq_get(struct mmc_card *card) sdio_card_irq_get() argument
195 struct mmc_host *host = card->host; sdio_card_irq_get()
220 static int sdio_card_irq_put(struct mmc_card *card) sdio_card_irq_put() argument
222 struct mmc_host *host = card->host; sdio_card_irq_put()
242 static void sdio_single_irq_set(struct mmc_card *card) sdio_single_irq_set() argument
247 card->sdio_single_irq = NULL; sdio_single_irq_set()
248 if ((card->host->caps & MMC_CAP_SDIO_IRQ) && sdio_single_irq_set()
249 card->host->sdio_irqs == 1) sdio_single_irq_set()
250 for (i = 0; i < card->sdio_funcs; i++) { sdio_single_irq_set()
251 func = card->sdio_func[i]; sdio_single_irq_set()
253 card->sdio_single_irq = func; sdio_single_irq_set()
275 BUG_ON(!func->card); sdio_claim_irq()
284 ret = mmc_io_rw_direct(func->card, 0, 0, SDIO_CCCR_IENx, 0, &reg); sdio_claim_irq()
292 ret = mmc_io_rw_direct(func->card, 1, 0, SDIO_CCCR_IENx, reg, NULL); sdio_claim_irq()
297 ret = sdio_card_irq_get(func->card); sdio_claim_irq()
300 sdio_single_irq_set(func->card); sdio_claim_irq()
318 BUG_ON(!func->card); sdio_release_irq()
324 sdio_card_irq_put(func->card); sdio_release_irq()
325 sdio_single_irq_set(func->card); sdio_release_irq()
328 ret = mmc_io_rw_direct(func->card, 0, 0, SDIO_CCCR_IENx, 0, &reg); sdio_release_irq()
338 ret = mmc_io_rw_direct(func->card, 1, 0, SDIO_CCCR_IENx, reg, NULL); sdio_release_irq()
H A Dbus.h17 struct mmc_card *card = mmc_dev_to_card(dev); \
24 int mmc_add_card(struct mmc_card *card);
25 void mmc_remove_card(struct mmc_card *card);
H A Dcore.c33 #include <linux/mmc/card.h>
54 * operations the card has to perform.
141 if (err && cmd->retries && !mmc_card_removed(host->card)) { mmc_request_done()
195 if (mmc_card_removed(host->card)) mmc_start_request()
262 * @card: MMC card to start BKOPS
264 * called due to an exception raised by the card
270 void mmc_start_bkops(struct mmc_card *card, bool from_exception) mmc_start_bkops() argument
276 BUG_ON(!card); mmc_start_bkops()
278 if (!card->ext_csd.man_bkops_en || mmc_card_doing_bkops(card)) mmc_start_bkops()
281 err = mmc_read_bkops_status(card); mmc_start_bkops()
284 mmc_hostname(card->host), err); mmc_start_bkops()
288 if (!card->ext_csd.raw_bkops_status) mmc_start_bkops()
291 if (card->ext_csd.raw_bkops_status < EXT_CSD_BKOPS_LEVEL_2 && mmc_start_bkops()
295 mmc_claim_host(card->host); mmc_start_bkops()
296 if (card->ext_csd.raw_bkops_status >= EXT_CSD_BKOPS_LEVEL_2) { mmc_start_bkops()
304 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, mmc_start_bkops()
309 mmc_hostname(card->host), err); mmc_start_bkops()
319 mmc_card_set_doing_bkops(card); mmc_start_bkops()
321 mmc_release_host(card->host); mmc_start_bkops()
349 * Sets the done callback to be called when request is completed by the card.
417 mmc_card_removed(host->card)) { mmc_wait_for_data_req_done()
418 err = host->areq->err_check(host->card, mmc_wait_for_data_req_done()
453 * to complete, card might be still in programming state mmc_wait_for_req_done()
454 * so let's try to bring the card out of programming mmc_wait_for_req_done()
458 if (!mmc_interrupt_hpi(host->card)) { mmc_wait_for_req_done()
469 mmc_card_removed(host->card)) mmc_wait_for_req_done()
561 if (host->card && mmc_card_mmc(host->card) && mmc_start_req()
570 mmc_start_bkops(host->card, true); mmc_start_req()
617 * @card: the MMC card associated with the HPI transfer
619 * Issued High Priority Interrupt, and check for card status
622 int mmc_interrupt_hpi(struct mmc_card *card) mmc_interrupt_hpi() argument
628 BUG_ON(!card); mmc_interrupt_hpi()
630 if (!card->ext_csd.hpi_en) { mmc_interrupt_hpi()
631 pr_info("%s: HPI enable bit unset\n", mmc_hostname(card->host)); mmc_interrupt_hpi()
635 mmc_claim_host(card->host); mmc_interrupt_hpi()
636 err = mmc_send_status(card, &status); mmc_interrupt_hpi()
638 pr_err("%s: Get card status fail\n", mmc_hostname(card->host)); mmc_interrupt_hpi()
657 mmc_hostname(card->host), R1_CURRENT_STATE(status)); mmc_interrupt_hpi()
662 err = mmc_send_hpi_cmd(card, &status); mmc_interrupt_hpi()
666 prg_wait = jiffies + msecs_to_jiffies(card->ext_csd.out_of_int_time); mmc_interrupt_hpi()
668 err = mmc_send_status(card, &status); mmc_interrupt_hpi()
677 mmc_release_host(card->host); mmc_interrupt_hpi()
713 * @card: MMC card to check BKOPS
717 * writes. Wait until the card comes out of the programming state
720 int mmc_stop_bkops(struct mmc_card *card) mmc_stop_bkops() argument
724 BUG_ON(!card); mmc_stop_bkops()
725 err = mmc_interrupt_hpi(card); mmc_stop_bkops()
732 mmc_card_clr_doing_bkops(card); mmc_stop_bkops()
740 int mmc_read_bkops_status(struct mmc_card *card) mmc_read_bkops_status() argument
745 mmc_claim_host(card->host); mmc_read_bkops_status()
746 err = mmc_get_ext_csd(card, &ext_csd); mmc_read_bkops_status()
747 mmc_release_host(card->host); mmc_read_bkops_status()
751 card->ext_csd.raw_bkops_status = ext_csd[EXT_CSD_BKOPS_STATUS]; mmc_read_bkops_status()
752 card->ext_csd.raw_exception_status = ext_csd[EXT_CSD_EXP_EVENTS_STATUS]; mmc_read_bkops_status()
761 * @card: the MMC card associated with the data transfer
764 * correct algorithm given the card type.
766 void mmc_set_data_timeout(struct mmc_data *data, const struct mmc_card *card) mmc_set_data_timeout() argument
773 if (mmc_card_sdio(card)) { mmc_set_data_timeout()
782 mult = mmc_card_sd(card) ? 100 : 10; mmc_set_data_timeout()
789 mult <<= card->csd.r2w_factor; mmc_set_data_timeout()
791 data->timeout_ns = card->csd.tacc_ns * mult; mmc_set_data_timeout()
792 data->timeout_clks = card->csd.tacc_clks * mult; mmc_set_data_timeout()
797 if (mmc_card_sd(card)) { mmc_set_data_timeout()
801 if (mmc_host_clk_rate(card->host)) mmc_set_data_timeout()
803 (mmc_host_clk_rate(card->host) / 1000); mmc_set_data_timeout()
809 * timeout value even if the card indicates mmc_set_data_timeout()
821 if (timeout_us > limit_us || mmc_card_blockaddr(card)) { mmc_set_data_timeout()
837 if (mmc_card_long_read_time(card) && data->flags & MMC_DATA_READ) { mmc_set_data_timeout()
848 if (mmc_host_is_spi(card->host)) { mmc_set_data_timeout()
862 * @card: the MMC card associated with the data transfer
874 unsigned int mmc_align_data_size(struct mmc_card *card, unsigned int sz) mmc_align_data_size() argument
966 * card device and also claims the host.
968 void mmc_get_card(struct mmc_card *card) mmc_get_card() argument
970 pm_runtime_get_sync(&card->dev); mmc_get_card()
971 mmc_claim_host(card->host); mmc_get_card()
977 * pm reference for the card device.
979 void mmc_put_card(struct mmc_card *card) mmc_put_card() argument
981 mmc_release_host(card->host); mmc_put_card()
982 pm_runtime_mark_last_busy(&card->dev); mmc_put_card()
983 pm_runtime_put_autosuspend(&card->dev); mmc_put_card()
1094 int mmc_execute_tuning(struct mmc_card *card) mmc_execute_tuning() argument
1096 struct mmc_host *host = card->host; mmc_execute_tuning()
1103 if (mmc_card_mmc(card)) mmc_execute_tuning()
1443 * Sanity check the voltages that the card claims to mmc_select_voltage()
1448 "card claims to support voltages below defined range\n"); mmc_select_voltage()
1454 dev_warn(mmc_dev(host), "no support for card's volts\n"); mmc_select_voltage()
1466 dev_warn(mmc_dev(host), "exceeding card's volts\n"); mmc_select_voltage()
1500 * Send CMD11 only if the request is to switch the card to mmc_set_signal_voltage()
1531 * The card should drive cmd and dat[0:3] low immediately mmc_set_signal_voltage()
1565 * Failure to switch is indicated by the card holding mmc_set_signal_voltage()
1574 "power cycling card\n", mmc_hostname(host)); mmc_set_signal_voltage()
1608 * First, we enable power to the card without the clock running.
1610 * enable the bus drivers and clock to the card.
1678 * Some configurations, such as the 802.11 SDIO card in the OLPC mmc_power_off()
1679 * XO-1.5, require a short delay after poweroff before the card mmc_power_off()
1807 * MMC drivers should call this when they detect a card has been
1809 * present card is still functional, and initialize any newly
1818 void mmc_init_erase(struct mmc_card *card) mmc_init_erase() argument
1822 if (is_power_of_2(card->erase_size)) mmc_init_erase()
1823 card->erase_shift = ffs(card->erase_size) - 1; mmc_init_erase()
1825 card->erase_shift = 0; mmc_init_erase()
1829 * card. That is not desirable because it can take a long time mmc_init_erase()
1842 if (mmc_card_sd(card) && card->ssr.au) { mmc_init_erase()
1843 card->pref_erase = card->ssr.au; mmc_init_erase()
1844 card->erase_shift = ffs(card->ssr.au) - 1; mmc_init_erase()
1845 } else if (card->ext_csd.hc_erase_size) { mmc_init_erase()
1846 card->pref_erase = card->ext_csd.hc_erase_size; mmc_init_erase()
1847 } else if (card->erase_size) { mmc_init_erase()
1848 sz = (card->csd.capacity << (card->csd.read_blkbits - 9)) >> 11; mmc_init_erase()
1850 card->pref_erase = 512 * 1024 / 512; mmc_init_erase()
1852 card->pref_erase = 1024 * 1024 / 512; mmc_init_erase()
1854 card->pref_erase = 2 * 1024 * 1024 / 512; mmc_init_erase()
1856 card->pref_erase = 4 * 1024 * 1024 / 512; mmc_init_erase()
1857 if (card->pref_erase < card->erase_size) mmc_init_erase()
1858 card->pref_erase = card->erase_size; mmc_init_erase()
1860 sz = card->pref_erase % card->erase_size; mmc_init_erase()
1862 card->pref_erase += card->erase_size - sz; mmc_init_erase()
1865 card->pref_erase = 0; mmc_init_erase()
1868 static unsigned int mmc_mmc_erase_timeout(struct mmc_card *card, mmc_mmc_erase_timeout() argument
1874 (arg == MMC_TRIM_ARG && card->ext_csd.rev >= 6)) { mmc_mmc_erase_timeout()
1875 erase_timeout = card->ext_csd.trim_timeout; mmc_mmc_erase_timeout()
1876 } else if (card->ext_csd.erase_group_def & 1) { mmc_mmc_erase_timeout()
1879 erase_timeout = card->ext_csd.trim_timeout; mmc_mmc_erase_timeout()
1881 erase_timeout = card->ext_csd.hc_erase_timeout; mmc_mmc_erase_timeout()
1884 unsigned int mult = (10 << card->csd.r2w_factor); mmc_mmc_erase_timeout()
1885 unsigned int timeout_clks = card->csd.tacc_clks * mult; mmc_mmc_erase_timeout()
1889 if (card->csd.tacc_ns < 1000000) mmc_mmc_erase_timeout()
1890 timeout_us = (card->csd.tacc_ns * mult) / 1000; mmc_mmc_erase_timeout()
1892 timeout_us = (card->csd.tacc_ns / 1000) * mult; mmc_mmc_erase_timeout()
1900 (mmc_host_clk_rate(card->host) / 1000); mmc_mmc_erase_timeout()
1915 erase_timeout *= card->ext_csd.sec_erase_mult; mmc_mmc_erase_timeout()
1917 erase_timeout *= card->ext_csd.sec_trim_mult; mmc_mmc_erase_timeout()
1926 if (mmc_host_is_spi(card->host) && erase_timeout < 1000) mmc_mmc_erase_timeout()
1932 static unsigned int mmc_sd_erase_timeout(struct mmc_card *card, mmc_sd_erase_timeout() argument
1938 if (card->ssr.erase_timeout) { mmc_sd_erase_timeout()
1940 erase_timeout = card->ssr.erase_timeout * qty + mmc_sd_erase_timeout()
1941 card->ssr.erase_offset; mmc_sd_erase_timeout()
1957 static unsigned int mmc_erase_timeout(struct mmc_card *card, mmc_erase_timeout() argument
1961 if (mmc_card_sd(card)) mmc_erase_timeout()
1962 return mmc_sd_erase_timeout(card, arg, qty); mmc_erase_timeout()
1964 return mmc_mmc_erase_timeout(card, arg, qty); mmc_erase_timeout()
1967 static int mmc_do_erase(struct mmc_card *card, unsigned int from, mmc_do_erase() argument
1991 if (card->erase_shift) mmc_do_erase()
1992 qty += ((to >> card->erase_shift) - mmc_do_erase()
1993 (from >> card->erase_shift)) + 1; mmc_do_erase()
1994 else if (mmc_card_sd(card)) mmc_do_erase()
1997 qty += ((to / card->erase_size) - mmc_do_erase()
1998 (from / card->erase_size)) + 1; mmc_do_erase()
2000 if (!mmc_card_blockaddr(card)) { mmc_do_erase()
2005 if (mmc_card_sd(card)) mmc_do_erase()
2011 err = mmc_wait_for_cmd(card->host, &cmd, 0); mmc_do_erase()
2020 if (mmc_card_sd(card)) mmc_do_erase()
2026 err = mmc_wait_for_cmd(card->host, &cmd, 0); mmc_do_erase()
2038 cmd.busy_timeout = mmc_erase_timeout(card, arg, qty); mmc_do_erase()
2039 err = mmc_wait_for_cmd(card->host, &cmd, 0); mmc_do_erase()
2047 if (mmc_host_is_spi(card->host)) mmc_do_erase()
2054 cmd.arg = card->rca << 16; mmc_do_erase()
2057 err = mmc_wait_for_cmd(card->host, &cmd, 0); mmc_do_erase()
2070 mmc_hostname(card->host), __func__); mmc_do_erase()
2083 * @card: card to erase
2090 int mmc_erase(struct mmc_card *card, unsigned int from, unsigned int nr, mmc_erase() argument
2095 if (!(card->host->caps & MMC_CAP_ERASE) || mmc_erase()
2096 !(card->csd.cmdclass & CCC_ERASE)) mmc_erase()
2099 if (!card->erase_size) mmc_erase()
2102 if (mmc_card_sd(card) && arg != MMC_ERASE_ARG) mmc_erase()
2106 !(card->ext_csd.sec_feature_support & EXT_CSD_SEC_ER_EN)) mmc_erase()
2110 !(card->ext_csd.sec_feature_support & EXT_CSD_SEC_GB_CL_EN)) mmc_erase()
2114 if (from % card->erase_size || nr % card->erase_size) mmc_erase()
2119 rem = from % card->erase_size; mmc_erase()
2121 rem = card->erase_size - rem; mmc_erase()
2128 rem = nr % card->erase_size; mmc_erase()
2144 return mmc_do_erase(card, from, to, arg); mmc_erase()
2148 int mmc_can_erase(struct mmc_card *card) mmc_can_erase() argument
2150 if ((card->host->caps & MMC_CAP_ERASE) && mmc_can_erase()
2151 (card->csd.cmdclass & CCC_ERASE) && card->erase_size) mmc_can_erase()
2157 int mmc_can_trim(struct mmc_card *card) mmc_can_trim() argument
2159 if (card->ext_csd.sec_feature_support & EXT_CSD_SEC_GB_CL_EN) mmc_can_trim()
2165 int mmc_can_discard(struct mmc_card *card) mmc_can_discard() argument
2171 if (card->ext_csd.feature_support & MMC_DISCARD_FEATURE) mmc_can_discard()
2177 int mmc_can_sanitize(struct mmc_card *card) mmc_can_sanitize() argument
2179 if (!mmc_can_trim(card) && !mmc_can_erase(card)) mmc_can_sanitize()
2181 if (card->ext_csd.sec_feature_support & EXT_CSD_SEC_SANITIZE) mmc_can_sanitize()
2187 int mmc_can_secure_erase_trim(struct mmc_card *card) mmc_can_secure_erase_trim() argument
2189 if ((card->ext_csd.sec_feature_support & EXT_CSD_SEC_ER_EN) && mmc_can_secure_erase_trim()
2190 !(card->quirks & MMC_QUIRK_SEC_ERASE_TRIM_BROKEN)) mmc_can_secure_erase_trim()
2196 int mmc_erase_group_aligned(struct mmc_card *card, unsigned int from, mmc_erase_group_aligned() argument
2199 if (!card->erase_size) mmc_erase_group_aligned()
2201 if (from % card->erase_size || nr % card->erase_size) mmc_erase_group_aligned()
2207 static unsigned int mmc_do_calc_max_discard(struct mmc_card *card, mmc_do_calc_max_discard() argument
2210 struct mmc_host *host = card->host; mmc_do_calc_max_discard()
2214 if (card->erase_shift) mmc_do_calc_max_discard()
2215 max_qty = UINT_MAX >> card->erase_shift; mmc_do_calc_max_discard()
2216 else if (mmc_card_sd(card)) mmc_do_calc_max_discard()
2219 max_qty = UINT_MAX / card->erase_size; mmc_do_calc_max_discard()
2225 timeout = mmc_erase_timeout(card, arg, qty + x); mmc_do_calc_max_discard()
2243 if (card->erase_shift) mmc_do_calc_max_discard()
2244 max_discard = --qty << card->erase_shift; mmc_do_calc_max_discard()
2245 else if (mmc_card_sd(card)) mmc_do_calc_max_discard()
2248 max_discard = --qty * card->erase_size; mmc_do_calc_max_discard()
2253 unsigned int mmc_calc_max_discard(struct mmc_card *card) mmc_calc_max_discard() argument
2255 struct mmc_host *host = card->host; mmc_calc_max_discard()
2266 if (mmc_card_mmc(card) && !(card->ext_csd.erase_group_def & 1)) mmc_calc_max_discard()
2267 return card->pref_erase; mmc_calc_max_discard()
2269 max_discard = mmc_do_calc_max_discard(card, MMC_ERASE_ARG); mmc_calc_max_discard()
2270 if (mmc_can_trim(card)) { mmc_calc_max_discard()
2271 max_trim = mmc_do_calc_max_discard(card, MMC_TRIM_ARG); mmc_calc_max_discard()
2274 } else if (max_discard < card->erase_size) { mmc_calc_max_discard()
2283 int mmc_set_blocklen(struct mmc_card *card, unsigned int blocklen) mmc_set_blocklen() argument
2287 if (mmc_card_blockaddr(card) || mmc_card_ddr52(card)) mmc_set_blocklen()
2293 return mmc_wait_for_cmd(card->host, &cmd, 5); mmc_set_blocklen()
2297 int mmc_set_blockcount(struct mmc_card *card, unsigned int blockcount, mmc_set_blockcount() argument
2307 return mmc_wait_for_cmd(card->host, &cmd, 5); mmc_set_blockcount()
2324 if (!host->card) mmc_hw_reset()
2336 pr_warn("%s: tried to reset card\n", mmc_hostname(host)); mmc_hw_reset()
2347 pr_info("%s: %s: trying to init card at %u Hz\n", mmc_rescan_try_freq()
2359 * sdio_reset sends CMD52 to reset card. Since we do not know mmc_rescan_try_freq()
2360 * if the card is being re-initialized, just send it. CMD52 mmc_rescan_try_freq()
2387 if (!host->card || mmc_card_removed(host->card)) _mmc_detect_card_removed()
2393 * Card detect status and alive check may be out of sync if card is _mmc_detect_card_removed()
2394 * removed slowly, when card detect switch changes while card/slot _mmc_detect_card_removed()
2401 pr_debug("%s: card removed too slowly\n", mmc_hostname(host)); _mmc_detect_card_removed()
2405 mmc_card_set_removed(host->card); _mmc_detect_card_removed()
2406 pr_debug("%s: card remove detected\n", mmc_hostname(host)); _mmc_detect_card_removed()
2414 struct mmc_card *card = host->card; mmc_detect_card_removed() local
2419 if (!card) mmc_detect_card_removed()
2422 ret = mmc_card_removed(card); mmc_detect_card_removed()
2424 * The card will be considered unchanged unless we have been asked to mmc_detect_card_removed()
2425 * detect a change or host requires polling to provide card detection. mmc_detect_card_removed()
2436 * rescan handle the card removal. mmc_detect_card_removed()
2461 /* If there is a non-removable card registered, only scan once */ mmc_rescan()
2469 * if there is a _removable_ card registered, check whether it is mmc_rescan()
2480 * the card is no longer present. mmc_rescan()
2485 /* if there still is a card present, stop here */ mmc_rescan()
2547 /* clear pm flags now and let card drivers set them as needed */ mmc_stop_host()
2563 BUG_ON(host->card); mmc_stop_host()
2609 mmc_power_up(host, host->card->ocr); mmc_power_restore_host()
2621 int mmc_flush_cache(struct mmc_card *card) mmc_flush_cache() argument
2625 if (mmc_card_mmc(card) && mmc_flush_cache()
2626 (card->ext_csd.cache_size > 0) && mmc_flush_cache()
2627 (card->ext_csd.cache_ctrl & 1)) { mmc_flush_cache()
2628 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, mmc_flush_cache()
2632 mmc_hostname(card->host), err); mmc_flush_cache()
2641 /* Do the card removal on suspend if card is assumed removeable
2643 to sync the card.
H A Dsdio_cis.h17 int sdio_read_common_cis(struct mmc_card *card);
18 void sdio_free_common_cis(struct mmc_card *card);
H A Dmmc_ops.c18 #include <linux/mmc/card.h>
56 static inline int __mmc_send_status(struct mmc_card *card, u32 *status, __mmc_send_status() argument
62 BUG_ON(!card); __mmc_send_status()
63 BUG_ON(!card->host); __mmc_send_status()
66 if (!mmc_host_is_spi(card->host)) __mmc_send_status()
67 cmd.arg = card->rca << 16; __mmc_send_status()
72 err = mmc_wait_for_cmd(card->host, &cmd, MMC_CMD_RETRIES); __mmc_send_status()
85 int mmc_send_status(struct mmc_card *card, u32 *status) mmc_send_status() argument
87 return __mmc_send_status(card, status, false); mmc_send_status()
90 static int _mmc_select_card(struct mmc_host *host, struct mmc_card *card) _mmc_select_card() argument
99 if (card) { _mmc_select_card()
100 cmd.arg = card->rca << 16; _mmc_select_card()
114 int mmc_select_card(struct mmc_card *card) mmc_select_card() argument
116 BUG_ON(!card); mmc_select_card()
118 return _mmc_select_card(card->host, card); mmc_select_card()
244 int mmc_set_relative_addr(struct mmc_card *card) mmc_set_relative_addr() argument
249 BUG_ON(!card); mmc_set_relative_addr()
250 BUG_ON(!card->host); mmc_set_relative_addr()
253 cmd.arg = card->rca << 16; mmc_set_relative_addr()
256 err = mmc_wait_for_cmd(card->host, &cmd, MMC_CMD_RETRIES); mmc_set_relative_addr()
290 mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host, mmc_send_cxd_data() argument
327 mmc_set_data_timeout(&data, card); mmc_send_cxd_data()
339 int mmc_send_csd(struct mmc_card *card, u32 *csd) mmc_send_csd() argument
344 if (!mmc_host_is_spi(card->host)) mmc_send_csd()
345 return mmc_send_cxd_native(card->host, card->rca << 16, mmc_send_csd()
352 ret = mmc_send_cxd_data(card, card->host, MMC_SEND_CSD, csd_tmp, 16); mmc_send_csd()
370 if (!host->card) mmc_send_cid()
372 return mmc_send_cxd_native(host, host->card->rca << 16, mmc_send_cid()
392 int mmc_get_ext_csd(struct mmc_card *card, u8 **new_ext_csd) mmc_get_ext_csd() argument
397 if (!card || !new_ext_csd) mmc_get_ext_csd()
400 if (!mmc_can_ext_csd(card)) mmc_get_ext_csd()
411 err = mmc_send_cxd_data(card, card->host, MMC_SEND_EXT_CSD, ext_csd, mmc_get_ext_csd()
454 * @card: the MMC card associated with the data transfer
464 * Modifies the EXT_CSD register for selected card.
466 int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value, __mmc_switch() argument
470 struct mmc_host *host = card->host; __mmc_switch()
511 /* No need to check card status in case of unblocking command */ __mmc_switch()
530 err = __mmc_send_status(card, &status, ignore_crc); __mmc_switch()
572 int mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value, mmc_switch() argument
575 return __mmc_switch(card, set, index, value, timeout_ms, true, true, mmc_switch()
650 mmc_send_bus_test(struct mmc_card *card, struct mmc_host *host, u8 opcode, mmc_send_bus_test() argument
705 mmc_set_data_timeout(&data, card); mmc_send_bus_test()
726 int mmc_bus_test(struct mmc_card *card, u8 bus_width) mmc_bus_test() argument
743 mmc_send_bus_test(card, card->host, MMC_BUS_TEST_W, width); mmc_bus_test()
744 err = mmc_send_bus_test(card, card->host, MMC_BUS_TEST_R, width); mmc_bus_test()
748 int mmc_send_hpi_cmd(struct mmc_card *card, u32 *status) mmc_send_hpi_cmd() argument
754 if (!card->ext_csd.hpi) { mmc_send_hpi_cmd()
756 mmc_hostname(card->host)); mmc_send_hpi_cmd()
760 opcode = card->ext_csd.hpi_cmd; mmc_send_hpi_cmd()
767 cmd.arg = card->rca << 16 | 1; mmc_send_hpi_cmd()
769 err = mmc_wait_for_cmd(card->host, &cmd, 0); mmc_send_hpi_cmd()
772 "HPI command response %#x\n", mmc_hostname(card->host), mmc_send_hpi_cmd()
782 int mmc_can_ext_csd(struct mmc_card *card) mmc_can_ext_csd() argument
784 return (card && card->csd.mmca_vsn > CSD_SPEC_VER_3); mmc_can_ext_csd()
/linux-4.1.27/drivers/isdn/hardware/avm/
H A Db1dma.c48 static void b1dma_dispatch_tx(avmcard *card);
86 static inline void b1dma_writel(avmcard *card, u32 value, int off) b1dma_writel() argument
88 writel(value, card->mbase + off); b1dma_writel()
91 static inline u32 b1dma_readl(avmcard *card, int off) b1dma_readl() argument
93 return readl(card->mbase + off); b1dma_readl()
108 static int b1dma_tolink(avmcard *card, void *buf, unsigned int len) b1dma_tolink() argument
113 while (!b1dma_tx_empty(card->port) b1dma_tolink()
115 if (!b1dma_tx_empty(card->port)) b1dma_tolink()
117 t1outp(card->port, 0x01, *s++); b1dma_tolink()
122 static int b1dma_fromlink(avmcard *card, void *buf, unsigned int len) b1dma_fromlink() argument
127 while (!b1dma_rx_full(card->port) b1dma_fromlink()
129 if (!b1dma_rx_full(card->port)) b1dma_fromlink()
131 *s++ = t1inp(card->port, 0x00); b1dma_fromlink()
136 static int WriteReg(avmcard *card, u32 reg, u8 val) WriteReg() argument
139 if (b1dma_tolink(card, &cmd, 1) == 0 WriteReg()
140 && b1dma_tolink(card, &reg, 4) == 0) { WriteReg()
142 return b1dma_tolink(card, &tmp, 4); WriteReg()
147 static u8 ReadReg(avmcard *card, u32 reg) ReadReg() argument
150 if (b1dma_tolink(card, &cmd, 1) == 0 ReadReg()
151 && b1dma_tolink(card, &reg, 4) == 0) { ReadReg()
153 if (b1dma_fromlink(card, &tmp, 4) == 0) ReadReg()
218 void b1dma_reset(avmcard *card) b1dma_reset() argument
220 card->csr = 0x0; b1dma_reset()
221 b1dma_writel(card, card->csr, AMCC_INTCSR); b1dma_reset()
222 b1dma_writel(card, 0, AMCC_MCSR); b1dma_reset()
223 b1dma_writel(card, 0, AMCC_RXLEN); b1dma_reset()
224 b1dma_writel(card, 0, AMCC_TXLEN); b1dma_reset()
226 t1outp(card->port, 0x10, 0x00); b1dma_reset()
227 t1outp(card->port, 0x07, 0x00); b1dma_reset()
229 b1dma_writel(card, 0, AMCC_MCSR); b1dma_reset()
231 b1dma_writel(card, 0x0f000000, AMCC_MCSR); /* reset all */ b1dma_reset()
233 b1dma_writel(card, 0, AMCC_MCSR); b1dma_reset()
234 if (card->cardtype == avm_t1pci) b1dma_reset()
242 static int b1dma_detect(avmcard *card) b1dma_detect() argument
244 b1dma_writel(card, 0, AMCC_MCSR); b1dma_detect()
246 b1dma_writel(card, 0x0f000000, AMCC_MCSR); /* reset all */ b1dma_detect()
248 b1dma_writel(card, 0, AMCC_MCSR); b1dma_detect()
251 b1dma_writel(card, 0, AMCC_RXLEN); b1dma_detect()
252 b1dma_writel(card, 0, AMCC_TXLEN); b1dma_detect()
253 card->csr = 0x0; b1dma_detect()
254 b1dma_writel(card, card->csr, AMCC_INTCSR); b1dma_detect()
256 if (b1dma_readl(card, AMCC_MCSR) != 0x000000E6) b1dma_detect()
259 b1dma_writel(card, 0xffffffff, AMCC_RXPTR); b1dma_detect()
260 b1dma_writel(card, 0xffffffff, AMCC_TXPTR); b1dma_detect()
261 if (b1dma_readl(card, AMCC_RXPTR) != 0xfffffffc b1dma_detect()
262 || b1dma_readl(card, AMCC_TXPTR) != 0xfffffffc) b1dma_detect()
265 b1dma_writel(card, 0x0, AMCC_RXPTR); b1dma_detect()
266 b1dma_writel(card, 0x0, AMCC_TXPTR); b1dma_detect()
267 if (b1dma_readl(card, AMCC_RXPTR) != 0x0 b1dma_detect()
268 || b1dma_readl(card, AMCC_TXPTR) != 0x0) b1dma_detect()
271 t1outp(card->port, 0x10, 0x00); b1dma_detect()
272 t1outp(card->port, 0x07, 0x00); b1dma_detect()
274 t1outp(card->port, 0x02, 0x02); b1dma_detect()
275 t1outp(card->port, 0x03, 0x02); b1dma_detect()
277 if ((t1inp(card->port, 0x02) & 0xFE) != 0x02 b1dma_detect()
278 || t1inp(card->port, 0x3) != 0x03) b1dma_detect()
281 t1outp(card->port, 0x02, 0x00); b1dma_detect()
282 t1outp(card->port, 0x03, 0x00); b1dma_detect()
284 if ((t1inp(card->port, 0x02) & 0xFE) != 0x00 b1dma_detect()
285 || t1inp(card->port, 0x3) != 0x01) b1dma_detect()
291 int t1pci_detect(avmcard *card) t1pci_detect() argument
295 if ((ret = b1dma_detect(card)) != 0) t1pci_detect()
300 if (WriteReg(card, 0x80001000, 0x11) != 0 t1pci_detect()
301 || WriteReg(card, 0x80101000, 0x22) != 0 t1pci_detect()
302 || WriteReg(card, 0x80201000, 0x33) != 0 t1pci_detect()
303 || WriteReg(card, 0x80301000, 0x44) != 0) t1pci_detect()
306 if (ReadReg(card, 0x80001000) != 0x11 t1pci_detect()
307 || ReadReg(card, 0x80101000) != 0x22 t1pci_detect()
308 || ReadReg(card, 0x80201000) != 0x33 t1pci_detect()
309 || ReadReg(card, 0x80301000) != 0x44) t1pci_detect()
312 if (WriteReg(card, 0x80001000, 0x55) != 0 t1pci_detect()
313 || WriteReg(card, 0x80101000, 0x66) != 0 t1pci_detect()
314 || WriteReg(card, 0x80201000, 0x77) != 0 t1pci_detect()
315 || WriteReg(card, 0x80301000, 0x88) != 0) t1pci_detect()
318 if (ReadReg(card, 0x80001000) != 0x55 t1pci_detect()
319 || ReadReg(card, 0x80101000) != 0x66 t1pci_detect()
320 || ReadReg(card, 0x80201000) != 0x77 t1pci_detect()
321 || ReadReg(card, 0x80301000) != 0x88) t1pci_detect()
327 int b1pciv4_detect(avmcard *card) b1pciv4_detect() argument
331 if ((ret = b1dma_detect(card)) != 0) b1pciv4_detect()
335 if (WriteReg(card, 0x80A00000, 0x21) != 0) b1pciv4_detect()
337 if ((ReadReg(card, 0x80A00000) & 0x01) != 0x01) b1pciv4_detect()
341 if (WriteReg(card, 0x80A00000, 0x20) != 0) b1pciv4_detect()
343 if ((ReadReg(card, 0x80A00000) & 0x01) != 0x00) b1pciv4_detect()
350 static void b1dma_queue_tx(avmcard *card, struct sk_buff *skb) b1dma_queue_tx() argument
354 spin_lock_irqsave(&card->lock, flags); b1dma_queue_tx()
356 skb_queue_tail(&card->dma->send_queue, skb); b1dma_queue_tx()
358 if (!(card->csr & EN_TX_TC_INT)) { b1dma_queue_tx()
359 b1dma_dispatch_tx(card); b1dma_queue_tx()
360 b1dma_writel(card, card->csr, AMCC_INTCSR); b1dma_queue_tx()
363 spin_unlock_irqrestore(&card->lock, flags); b1dma_queue_tx()
368 static void b1dma_dispatch_tx(avmcard *card) b1dma_dispatch_tx() argument
370 avmcard_dmainfo *dma = card->dma; b1dma_dispatch_tx()
404 printk(KERN_INFO "%s: send ack\n", card->name); b1dma_dispatch_tx()
415 b1dma_writel(card, dma->sendbuf.dmaaddr, AMCC_TXPTR); b1dma_dispatch_tx()
416 b1dma_writel(card, txlen, AMCC_TXLEN); b1dma_dispatch_tx()
418 card->csr |= EN_TX_TC_INT; b1dma_dispatch_tx()
425 static void queue_pollack(avmcard *card) queue_pollack() argument
433 card->name); queue_pollack()
442 b1dma_queue_tx(card, skb); queue_pollack()
447 static void b1dma_handle_rx(avmcard *card) b1dma_handle_rx() argument
449 avmctrl_info *cinfo = &card->ctrlinfo[0]; b1dma_handle_rx()
450 avmcard_dmainfo *dma = card->dma; b1dma_handle_rx()
465 MsgLen = _get_slice(&p, card->msgbuf); b1dma_handle_rx()
466 DataB3Len = _get_slice(&p, card->databuf); b1dma_handle_rx()
469 memset(card->msgbuf + MsgLen, 0, 30 - MsgLen); b1dma_handle_rx()
471 CAPIMSG_SETLEN(card->msgbuf, 30); b1dma_handle_rx()
475 card->name); b1dma_handle_rx()
477 memcpy(skb_put(skb, MsgLen), card->msgbuf, MsgLen); b1dma_handle_rx()
478 memcpy(skb_put(skb, DataB3Len), card->databuf, DataB3Len); b1dma_handle_rx()
486 MsgLen = _get_slice(&p, card->msgbuf); b1dma_handle_rx()
489 card->name); b1dma_handle_rx()
491 memcpy(skb_put(skb, MsgLen), card->msgbuf, MsgLen); b1dma_handle_rx()
493 spin_lock(&card->lock); b1dma_handle_rx()
497 spin_unlock(&card->lock); b1dma_handle_rx()
508 spin_lock(&card->lock); b1dma_handle_rx()
510 spin_unlock(&card->lock); b1dma_handle_rx()
519 spin_lock(&card->lock); b1dma_handle_rx()
521 spin_unlock(&card->lock); b1dma_handle_rx()
527 printk(KERN_INFO "%s: receive poll\n", card->name); b1dma_handle_rx()
530 queue_pollack(card); b1dma_handle_rx()
542 printk(KERN_INFO "%s: %s-card (%s) now active\n", b1dma_handle_rx()
543 card->name, b1dma_handle_rx()
551 MsgLen = _get_slice(&p, card->msgbuf); b1dma_handle_rx()
552 card->msgbuf[MsgLen] = 0; b1dma_handle_rx()
554 && (card->msgbuf[MsgLen - 1] == '\n' b1dma_handle_rx()
555 || card->msgbuf[MsgLen - 1] == '\r')) { b1dma_handle_rx()
556 card->msgbuf[MsgLen - 1] = 0; b1dma_handle_rx()
560 card->name, ApplId, card->msgbuf); b1dma_handle_rx()
564 MsgLen = _get_slice(&p, card->msgbuf); b1dma_handle_rx()
565 card->msgbuf[MsgLen] = 0; b1dma_handle_rx()
567 && (card->msgbuf[MsgLen - 1] == '\n' b1dma_handle_rx()
568 || card->msgbuf[MsgLen - 1] == '\r')) { b1dma_handle_rx()
569 card->msgbuf[MsgLen - 1] = 0; b1dma_handle_rx()
572 printk(KERN_INFO "%s: DEBUG: %s\n", card->name, card->msgbuf); b1dma_handle_rx()
577 card->name, b1cmd); b1dma_handle_rx()
584 static void b1dma_handle_interrupt(avmcard *card) b1dma_handle_interrupt() argument
589 spin_lock(&card->lock); b1dma_handle_interrupt()
591 status = b1dma_readl(card, AMCC_INTCSR); b1dma_handle_interrupt()
593 spin_unlock(&card->lock); b1dma_handle_interrupt()
597 newcsr = card->csr | (status & ALL_INT); b1dma_handle_interrupt()
600 b1dma_writel(card, newcsr, AMCC_INTCSR); b1dma_handle_interrupt()
603 struct avmcard_dmainfo *dma = card->dma; b1dma_handle_interrupt()
605 if (card->dma->recvlen == 0) { b1dma_handle_interrupt()
606 rxlen = b1dma_readl(card, AMCC_RXLEN); b1dma_handle_interrupt()
610 b1dma_writel(card, dma->recvbuf.dmaaddr + 4, AMCC_RXPTR); b1dma_handle_interrupt()
611 b1dma_writel(card, rxlen, AMCC_RXLEN); b1dma_handle_interrupt()
615 card->name, rxlen); b1dma_handle_interrupt()
619 spin_unlock(&card->lock); b1dma_handle_interrupt()
620 b1dma_handle_rx(card); b1dma_handle_interrupt()
622 spin_lock(&card->lock); b1dma_handle_interrupt()
623 b1dma_writel(card, dma->recvbuf.dmaaddr, AMCC_RXPTR); b1dma_handle_interrupt()
624 b1dma_writel(card, 4, AMCC_RXLEN); b1dma_handle_interrupt()
629 if (skb_queue_empty(&card->dma->send_queue)) b1dma_handle_interrupt()
630 card->csr &= ~EN_TX_TC_INT; b1dma_handle_interrupt()
632 b1dma_dispatch_tx(card); b1dma_handle_interrupt()
634 b1dma_writel(card, card->csr, AMCC_INTCSR); b1dma_handle_interrupt()
636 spin_unlock(&card->lock); b1dma_handle_interrupt()
641 avmcard *card = devptr; b1dma_interrupt() local
643 b1dma_handle_interrupt(card); b1dma_interrupt()
649 static int b1dma_loaded(avmcard *card) b1dma_loaded() argument
654 unsigned int base = card->port; b1dma_loaded()
662 card->name); b1dma_loaded()
671 printk(KERN_ERR "%s: b1dma_loaded: got 0x%x, firmware not running in dword mode\n", card->name, ans); b1dma_loaded()
675 printk(KERN_ERR "%s: b1dma_loaded: firmware not running\n", card->name); b1dma_loaded()
681 static void b1dma_send_init(avmcard *card) b1dma_send_init() argument
689 card->name); b1dma_send_init()
698 _put_word(&p, card->cardnr - 1); b1dma_send_init()
701 b1dma_queue_tx(card, skb); b1dma_send_init()
707 avmcard *card = cinfo->card; b1dma_load_firmware() local
710 b1dma_reset(card); b1dma_load_firmware()
712 if ((retval = b1_load_t4file(card, &data->firmware))) { b1dma_load_firmware()
713 b1dma_reset(card); b1dma_load_firmware()
715 card->name); b1dma_load_firmware()
720 if ((retval = b1_load_config(card, &data->configuration))) { b1dma_load_firmware()
721 b1dma_reset(card); b1dma_load_firmware()
723 card->name); b1dma_load_firmware()
728 if (!b1dma_loaded(card)) { b1dma_load_firmware()
729 b1dma_reset(card); b1dma_load_firmware()
730 printk(KERN_ERR "%s: failed to load t4file.\n", card->name); b1dma_load_firmware()
734 card->csr = AVM_FLAG; b1dma_load_firmware()
735 b1dma_writel(card, card->csr, AMCC_INTCSR); b1dma_load_firmware()
736 b1dma_writel(card, EN_A2P_TRANSFERS | EN_P2A_TRANSFERS | A2P_HI_PRIORITY | b1dma_load_firmware()
739 t1outp(card->port, 0x07, 0x30); b1dma_load_firmware()
740 t1outp(card->port, 0x10, 0xF0); b1dma_load_firmware()
742 card->dma->recvlen = 0; b1dma_load_firmware()
743 b1dma_writel(card, card->dma->recvbuf.dmaaddr, AMCC_RXPTR); b1dma_load_firmware()
744 b1dma_writel(card, 4, AMCC_RXLEN); b1dma_load_firmware()
745 card->csr |= EN_RX_TC_INT; b1dma_load_firmware()
746 b1dma_writel(card, card->csr, AMCC_INTCSR); b1dma_load_firmware()
748 b1dma_send_init(card); b1dma_load_firmware()
756 avmcard *card = cinfo->card; b1dma_reset_ctr() local
759 spin_lock_irqsave(&card->lock, flags); b1dma_reset_ctr()
760 b1dma_reset(card); b1dma_reset_ctr()
764 spin_unlock_irqrestore(&card->lock, flags); b1dma_reset_ctr()
775 avmcard *card = cinfo->card; b1dma_register_appl() local
788 card->name); b1dma_register_appl()
802 b1dma_queue_tx(card, skb); b1dma_register_appl()
810 avmcard *card = cinfo->card; b1dma_release_appl() local
815 spin_lock_irqsave(&card->lock, flags); b1dma_release_appl()
817 spin_unlock_irqrestore(&card->lock, flags); b1dma_release_appl()
822 card->name); b1dma_release_appl()
833 b1dma_queue_tx(card, skb); b1dma_release_appl()
841 avmcard *card = cinfo->card; b1dma_send_message() local
846 spin_lock_irqsave(&card->lock, flags); b1dma_send_message()
851 spin_unlock_irqrestore(&card->lock, flags); b1dma_send_message()
854 b1dma_queue_tx(card, skb); b1dma_send_message()
865 avmcard *card = cinfo->card; b1dmactl_proc_show() local
871 seq_printf(m, "%-16s %s\n", "name", card->name); b1dmactl_proc_show()
872 seq_printf(m, "%-16s 0x%x\n", "io", card->port); b1dmactl_proc_show()
873 seq_printf(m, "%-16s %d\n", "irq", card->irq); b1dmactl_proc_show()
874 seq_printf(m, "%-16s 0x%lx\n", "membase", card->membase); b1dmactl_proc_show()
875 switch (card->cardtype) { b1dmactl_proc_show()
895 if (card->cardtype != avm_m1) { b1dmactl_proc_show()
909 if (card->cardtype != avm_m1) { b1dmactl_proc_show()
923 spin_lock_irqsave(&card->lock, flags); b1dmactl_proc_show()
925 txoff = (dma_addr_t)b1dma_readl(card, AMCC_TXPTR)-card->dma->sendbuf.dmaaddr; b1dmactl_proc_show()
926 txlen = b1dma_readl(card, AMCC_TXLEN); b1dmactl_proc_show()
928 rxoff = (dma_addr_t)b1dma_readl(card, AMCC_RXPTR)-card->dma->recvbuf.dmaaddr; b1dmactl_proc_show()
929 rxlen = b1dma_readl(card, AMCC_RXLEN); b1dmactl_proc_show()
931 csr = b1dma_readl(card, AMCC_INTCSR); b1dmactl_proc_show()
933 spin_unlock_irqrestore(&card->lock, flags); b1dmactl_proc_show()
935 seq_printf(m, "%-16s 0x%lx\n", "csr (cached)", (unsigned long)card->csr); b1dmactl_proc_show()
H A Dt1pci.c3 * Module for AVM T1 PCI-card.
41 MODULE_DESCRIPTION("CAPI4Linux: Driver for AVM T1 PCI card");
51 avmcard *card; t1pci_add_card() local
55 card = b1_alloc_card(1); t1pci_add_card()
56 if (!card) { t1pci_add_card()
62 card->dma = avmcard_dma_alloc("t1pci", pdev, 2048 + 128, 2048 + 128); t1pci_add_card()
63 if (!card->dma) { t1pci_add_card()
69 cinfo = card->ctrlinfo; t1pci_add_card()
70 sprintf(card->name, "t1pci-%x", p->port); t1pci_add_card()
71 card->port = p->port; t1pci_add_card()
72 card->irq = p->irq; t1pci_add_card()
73 card->membase = p->membase; t1pci_add_card()
74 card->cardtype = avm_t1pci; t1pci_add_card()
76 if (!request_region(card->port, AVMB1_PORTLEN, card->name)) { t1pci_add_card()
78 card->port, card->port + AVMB1_PORTLEN); t1pci_add_card()
83 card->mbase = ioremap(card->membase, 64); t1pci_add_card()
84 if (!card->mbase) { t1pci_add_card()
86 card->membase); t1pci_add_card()
91 b1dma_reset(card); t1pci_add_card()
93 retval = t1pci_detect(card); t1pci_add_card()
96 printk(KERN_NOTICE "t1pci: NO card at 0x%x (%d)\n", t1pci_add_card()
97 card->port, retval); t1pci_add_card()
99 printk(KERN_NOTICE "t1pci: card at 0x%x, but cable not connected or T1 has no power (%d)\n", t1pci_add_card()
100 card->port, retval); t1pci_add_card()
104 b1dma_reset(card); t1pci_add_card()
106 retval = request_irq(card->irq, b1dma_interrupt, IRQF_SHARED, card->name, card); t1pci_add_card()
108 printk(KERN_ERR "t1pci: unable to get IRQ %d.\n", card->irq); t1pci_add_card()
123 strcpy(cinfo->capi_ctrl.name, card->name); t1pci_add_card()
131 card->cardnr = cinfo->capi_ctrl.cnr; t1pci_add_card()
134 card->port, card->irq, card->membase); t1pci_add_card()
136 pci_set_drvdata(pdev, card); t1pci_add_card()
140 free_irq(card->irq, card); t1pci_add_card()
142 iounmap(card->mbase); t1pci_add_card()
144 release_region(card->port, AVMB1_PORTLEN); t1pci_add_card()
146 avmcard_dma_free(card->dma); t1pci_add_card()
148 b1_free_card(card); t1pci_add_card()
157 avmcard *card = pci_get_drvdata(pdev); t1pci_remove() local
158 avmctrl_info *cinfo = card->ctrlinfo; t1pci_remove()
160 b1dma_reset(card); t1pci_remove()
163 free_irq(card->irq, card); t1pci_remove()
164 iounmap(card->mbase); t1pci_remove()
165 release_region(card->port, AVMB1_PORTLEN); t1pci_remove()
166 avmcard_dma_free(card->dma); t1pci_remove()
167 b1_free_card(card); t1pci_remove()
181 cinfo->card ? cinfo->card->port : 0x0, t1pci_procinfo()
182 cinfo->card ? cinfo->card->irq : 0, t1pci_procinfo()
183 cinfo->card ? cinfo->card->membase : 0 t1pci_procinfo()
H A Db1isa.c3 * Module for AVM B1 ISA-card.
34 MODULE_DESCRIPTION("CAPI4Linux: Driver for AVM B1 ISA card");
43 avmcard *card; b1isa_remove() local
48 card = cinfo->card; b1isa_remove()
50 b1_reset(card->port); b1isa_remove()
51 b1_reset(card->port); b1isa_remove()
54 free_irq(card->irq, card); b1isa_remove()
55 release_region(card->port, AVMB1_PORTLEN); b1isa_remove()
56 b1_free_card(card); b1isa_remove()
66 avmcard *card; b1isa_probe() local
69 card = b1_alloc_card(1); b1isa_probe()
70 if (!card) { b1isa_probe()
76 cinfo = card->ctrlinfo; b1isa_probe()
78 card->port = pci_resource_start(pdev, 0); b1isa_probe()
79 card->irq = pdev->irq; b1isa_probe()
80 card->cardtype = avm_b1isa; b1isa_probe()
81 sprintf(card->name, "b1isa-%x", card->port); b1isa_probe()
83 if (card->port != 0x150 && card->port != 0x250 b1isa_probe()
84 && card->port != 0x300 && card->port != 0x340) { b1isa_probe()
85 printk(KERN_WARNING "b1isa: invalid port 0x%x.\n", card->port); b1isa_probe()
89 if (b1_irq_table[card->irq & 0xf] == 0) { b1isa_probe()
90 printk(KERN_WARNING "b1isa: irq %d not valid.\n", card->irq); b1isa_probe()
94 if (!request_region(card->port, AVMB1_PORTLEN, card->name)) { b1isa_probe()
96 card->port, card->port + AVMB1_PORTLEN); b1isa_probe()
100 retval = request_irq(card->irq, b1_interrupt, 0, card->name, card); b1isa_probe()
102 printk(KERN_ERR "b1isa: unable to get IRQ %d.\n", card->irq); b1isa_probe()
105 b1_reset(card->port); b1isa_probe()
106 if ((retval = b1_detect(card->port, card->cardtype)) != 0) { b1isa_probe()
107 printk(KERN_NOTICE "b1isa: NO card at 0x%x (%d)\n", b1isa_probe()
108 card->port, retval); b1isa_probe()
112 b1_reset(card->port); b1isa_probe()
113 b1_getrevision(card); b1isa_probe()
125 strcpy(cinfo->capi_ctrl.name, card->name); b1isa_probe()
134 card->port, card->irq, card->revision); b1isa_probe()
140 free_irq(card->irq, card); b1isa_probe()
142 release_region(card->port, AVMB1_PORTLEN); b1isa_probe()
144 b1_free_card(card); b1isa_probe()
158 cinfo->card ? cinfo->card->port : 0x0, b1isa_procinfo()
159 cinfo->card ? cinfo->card->irq : 0, b1isa_procinfo()
160 cinfo->card ? cinfo->card->revision : 0 b1isa_procinfo()
H A Db1pci.c3 * Module for AVM B1 PCI-card.
40 MODULE_DESCRIPTION("CAPI4Linux: Driver for AVM B1 PCI card");
55 cinfo->card ? cinfo->card->port : 0x0, b1pci_procinfo()
56 cinfo->card ? cinfo->card->irq : 0, b1pci_procinfo()
57 cinfo->card ? cinfo->card->revision : 0 b1pci_procinfo()
66 avmcard *card; b1pci_probe() local
70 card = b1_alloc_card(1); b1pci_probe()
71 if (!card) { b1pci_probe()
77 cinfo = card->ctrlinfo; b1pci_probe()
78 sprintf(card->name, "b1pci-%x", p->port); b1pci_probe()
79 card->port = p->port; b1pci_probe()
80 card->irq = p->irq; b1pci_probe()
81 card->cardtype = avm_b1pci; b1pci_probe()
83 if (!request_region(card->port, AVMB1_PORTLEN, card->name)) { b1pci_probe()
85 card->port, card->port + AVMB1_PORTLEN); b1pci_probe()
89 b1_reset(card->port); b1pci_probe()
90 retval = b1_detect(card->port, card->cardtype); b1pci_probe()
92 printk(KERN_NOTICE "b1pci: NO card at 0x%x (%d)\n", b1pci_probe()
93 card->port, retval); b1pci_probe()
97 b1_reset(card->port); b1pci_probe()
98 b1_getrevision(card); b1pci_probe()
100 retval = request_irq(card->irq, b1_interrupt, IRQF_SHARED, card->name, card); b1pci_probe()
102 printk(KERN_ERR "b1pci: unable to get IRQ %d.\n", card->irq); b1pci_probe()
116 strcpy(cinfo->capi_ctrl.name, card->name); b1pci_probe()
125 if (card->revision >= 4) { b1pci_probe()
127 card->port, card->irq, card->revision); b1pci_probe()
130 card->port, card->irq, card->revision); b1pci_probe()
133 pci_set_drvdata(pdev, card); b1pci_probe()
137 free_irq(card->irq, card); b1pci_probe()
139 release_region(card->port, AVMB1_PORTLEN); b1pci_probe()
141 b1_free_card(card); b1pci_probe()
148 avmcard *card = pci_get_drvdata(pdev); b1pci_remove() local
149 avmctrl_info *cinfo = card->ctrlinfo; b1pci_remove()
150 unsigned int port = card->port; b1pci_remove()
156 free_irq(card->irq, card); b1pci_remove()
157 release_region(card->port, AVMB1_PORTLEN); b1pci_remove()
158 b1_free_card(card); b1pci_remove()
173 cinfo->card ? cinfo->card->port : 0x0, b1pciv4_procinfo()
174 cinfo->card ? cinfo->card->irq : 0, b1pciv4_procinfo()
175 cinfo->card ? cinfo->card->membase : 0, b1pciv4_procinfo()
176 cinfo->card ? cinfo->card->revision : 0 b1pciv4_procinfo()
185 avmcard *card; b1pciv4_probe() local
189 card = b1_alloc_card(1); b1pciv4_probe()
190 if (!card) { b1pciv4_probe()
196 card->dma = avmcard_dma_alloc("b1pci", pdev, 2048 + 128, 2048 + 128); b1pciv4_probe()
197 if (!card->dma) { b1pciv4_probe()
203 cinfo = card->ctrlinfo; b1pciv4_probe()
204 sprintf(card->name, "b1pciv4-%x", p->port); b1pciv4_probe()
205 card->port = p->port; b1pciv4_probe()
206 card->irq = p->irq; b1pciv4_probe()
207 card->membase = p->membase; b1pciv4_probe()
208 card->cardtype = avm_b1pci; b1pciv4_probe()
210 if (!request_region(card->port, AVMB1_PORTLEN, card->name)) { b1pciv4_probe()
212 card->port, card->port + AVMB1_PORTLEN); b1pciv4_probe()
217 card->mbase = ioremap(card->membase, 64); b1pciv4_probe()
218 if (!card->mbase) { b1pciv4_probe()
220 card->membase); b1pciv4_probe()
225 b1dma_reset(card); b1pciv4_probe()
227 retval = b1pciv4_detect(card); b1pciv4_probe()
229 printk(KERN_NOTICE "b1pci: NO card at 0x%x (%d)\n", b1pciv4_probe()
230 card->port, retval); b1pciv4_probe()
234 b1dma_reset(card); b1pciv4_probe()
235 b1_getrevision(card); b1pciv4_probe()
237 retval = request_irq(card->irq, b1dma_interrupt, IRQF_SHARED, card->name, card); b1pciv4_probe()
240 card->irq); b1pciv4_probe()
255 strcpy(cinfo->capi_ctrl.name, card->name); b1pciv4_probe()
262 card->cardnr = cinfo->capi_ctrl.cnr; b1pciv4_probe()
265 card->port, card->irq, card->membase, card->revision); b1pciv4_probe()
267 pci_set_drvdata(pdev, card); b1pciv4_probe()
271 free_irq(card->irq, card); b1pciv4_probe()
273 iounmap(card->mbase); b1pciv4_probe()
275 release_region(card->port, AVMB1_PORTLEN); b1pciv4_probe()
277 avmcard_dma_free(card->dma); b1pciv4_probe()
279 b1_free_card(card); b1pciv4_probe()
287 avmcard *card = pci_get_drvdata(pdev); b1pciv4_remove() local
288 avmctrl_info *cinfo = card->ctrlinfo; b1pciv4_remove()
290 b1dma_reset(card); b1pciv4_remove()
293 free_irq(card->irq, card); b1pciv4_remove()
294 iounmap(card->mbase); b1pciv4_remove()
295 release_region(card->port, AVMB1_PORTLEN); b1pciv4_remove()
296 avmcard_dma_free(card->dma); b1pciv4_remove()
297 b1_free_card(card); b1pciv4_remove()
350 avmcard *card = pci_get_drvdata(pdev); b1pci_pci_remove() local
352 if (card->dma) b1pci_pci_remove()
H A Dt1isa.c3 * Module for AVM T1 HEMA-card.
37 MODULE_DESCRIPTION("CAPI4Linux: Driver for AVM T1 HEMA ISA card");
137 avmcard *card = devptr; t1isa_interrupt() local
138 avmctrl_info *cinfo = &card->ctrlinfo[0]; t1isa_interrupt()
150 spin_lock_irqsave(&card->lock, flags); t1isa_interrupt()
152 while (b1_rx_full(card->port)) { t1isa_interrupt()
154 b1cmd = b1_get_byte(card->port); t1isa_interrupt()
160 ApplId = (unsigned) b1_get_word(card->port); t1isa_interrupt()
161 MsgLen = t1_get_slice(card->port, card->msgbuf); t1isa_interrupt()
162 DataB3Len = t1_get_slice(card->port, card->databuf); t1isa_interrupt()
163 spin_unlock_irqrestore(&card->lock, flags); t1isa_interrupt()
166 memset(card->msgbuf + MsgLen, 0, 30 - MsgLen); t1isa_interrupt()
168 CAPIMSG_SETLEN(card->msgbuf, 30); t1isa_interrupt()
172 card->name); t1isa_interrupt()
174 memcpy(skb_put(skb, MsgLen), card->msgbuf, MsgLen); t1isa_interrupt()
175 memcpy(skb_put(skb, DataB3Len), card->databuf, DataB3Len); t1isa_interrupt()
182 ApplId = (unsigned) b1_get_word(card->port); t1isa_interrupt()
183 MsgLen = t1_get_slice(card->port, card->msgbuf); t1isa_interrupt()
185 spin_unlock_irqrestore(&card->lock, flags); t1isa_interrupt()
187 card->name); t1isa_interrupt()
189 memcpy(skb_put(skb, MsgLen), card->msgbuf, MsgLen); t1isa_interrupt()
194 spin_unlock_irqrestore(&card->lock, flags); t1isa_interrupt()
201 ApplId = b1_get_word(card->port); t1isa_interrupt()
202 NCCI = b1_get_word(card->port); t1isa_interrupt()
203 WindowSize = b1_get_word(card->port); t1isa_interrupt()
205 spin_unlock_irqrestore(&card->lock, flags); t1isa_interrupt()
210 ApplId = b1_get_word(card->port); t1isa_interrupt()
211 NCCI = b1_get_word(card->port); t1isa_interrupt()
214 spin_unlock_irqrestore(&card->lock, flags); t1isa_interrupt()
218 b1_put_byte(card->port, SEND_POLLACK); t1isa_interrupt()
219 spin_unlock_irqrestore(&card->lock, flags); t1isa_interrupt()
224 spin_unlock_irqrestore(&card->lock, flags); t1isa_interrupt()
230 cinfo->versionlen = t1_get_slice(card->port, cinfo->versionbuf); t1isa_interrupt()
231 spin_unlock_irqrestore(&card->lock, flags); t1isa_interrupt()
233 printk(KERN_INFO "%s: %s-card (%s) now active\n", t1isa_interrupt()
234 card->name, t1isa_interrupt()
241 ApplId = (unsigned) b1_get_word(card->port); t1isa_interrupt()
242 MsgLen = t1_get_slice(card->port, card->msgbuf); t1isa_interrupt()
243 spin_unlock_irqrestore(&card->lock, flags); t1isa_interrupt()
244 card->msgbuf[MsgLen] = 0; t1isa_interrupt()
246 && (card->msgbuf[MsgLen - 1] == '\n' t1isa_interrupt()
247 || card->msgbuf[MsgLen - 1] == '\r')) { t1isa_interrupt()
248 card->msgbuf[MsgLen - 1] = 0; t1isa_interrupt()
252 card->name, ApplId, card->msgbuf); t1isa_interrupt()
256 MsgLen = t1_get_slice(card->port, card->msgbuf); t1isa_interrupt()
257 spin_unlock_irqrestore(&card->lock, flags); t1isa_interrupt()
258 card->msgbuf[MsgLen] = 0; t1isa_interrupt()
260 && (card->msgbuf[MsgLen - 1] == '\n' t1isa_interrupt()
261 || card->msgbuf[MsgLen - 1] == '\r')) { t1isa_interrupt()
262 card->msgbuf[MsgLen - 1] = 0; t1isa_interrupt()
265 printk(KERN_INFO "%s: DEBUG: %s\n", card->name, card->msgbuf); t1isa_interrupt()
270 spin_unlock_irqrestore(&card->lock, flags); t1isa_interrupt()
271 printk(KERN_ERR "%s: card reseted ?\n", card->name); t1isa_interrupt()
274 spin_unlock_irqrestore(&card->lock, flags); t1isa_interrupt()
276 card->name, b1cmd); t1isa_interrupt()
288 avmcard *card = cinfo->card; t1isa_load_firmware() local
289 unsigned int port = card->port; t1isa_load_firmware()
296 if ((retval = b1_load_t4file(card, &data->firmware))) { t1isa_load_firmware()
299 card->name); t1isa_load_firmware()
304 if ((retval = b1_load_config(card, &data->configuration))) { t1isa_load_firmware()
307 card->name); t1isa_load_firmware()
312 if (!b1_loaded(card)) { t1isa_load_firmware()
313 printk(KERN_ERR "%s: failed to load t4file.\n", card->name); t1isa_load_firmware()
317 spin_lock_irqsave(&card->lock, flags); t1isa_load_firmware()
318 b1_setinterrupt(port, card->irq, card->cardtype); t1isa_load_firmware()
323 spin_unlock_irqrestore(&card->lock, flags); t1isa_load_firmware()
331 avmcard *card = cinfo->card; t1isa_reset_ctr() local
332 unsigned int port = card->port; t1isa_reset_ctr()
340 spin_lock_irqsave(&card->lock, flags); t1isa_reset_ctr()
342 spin_unlock_irqrestore(&card->lock, flags); t1isa_reset_ctr()
349 avmcard *card; t1isa_remove() local
354 card = cinfo->card; t1isa_remove()
356 t1_disable_irq(card->port); t1isa_remove()
357 b1_reset(card->port); t1isa_remove()
358 b1_reset(card->port); t1isa_remove()
359 t1_reset(card->port); t1isa_remove()
362 free_irq(card->irq, card); t1isa_remove()
363 release_region(card->port, AVMB1_PORTLEN); t1isa_remove()
364 b1_free_card(card); t1isa_remove()
375 avmcard *card; t1isa_probe() local
378 card = b1_alloc_card(1); t1isa_probe()
379 if (!card) { t1isa_probe()
385 cinfo = card->ctrlinfo; t1isa_probe()
386 card->port = pci_resource_start(pdev, 0); t1isa_probe()
387 card->irq = pdev->irq; t1isa_probe()
388 card->cardtype = avm_t1isa; t1isa_probe()
389 card->cardnr = cardnr; t1isa_probe()
390 sprintf(card->name, "t1isa-%x", card->port); t1isa_probe()
392 if (!(((card->port & 0x7) == 0) && ((card->port & 0x30) != 0x30))) { t1isa_probe()
393 printk(KERN_WARNING "t1isa: invalid port 0x%x.\n", card->port); t1isa_probe()
397 if (hema_irq_table[card->irq & 0xf] == 0) { t1isa_probe()
398 printk(KERN_WARNING "t1isa: irq %d not valid.\n", card->irq); t1isa_probe()
402 if (!request_region(card->port, AVMB1_PORTLEN, card->name)) { t1isa_probe()
404 card->port, card->port + AVMB1_PORTLEN); t1isa_probe()
408 retval = request_irq(card->irq, t1isa_interrupt, 0, card->name, card); t1isa_probe()
410 printk(KERN_INFO "t1isa: unable to get IRQ %d.\n", card->irq); t1isa_probe()
415 if ((retval = t1_detectandinit(card->port, card->irq, card->cardnr)) != 0) { t1isa_probe()
416 printk(KERN_INFO "t1isa: NO card at 0x%x (%d)\n", t1isa_probe()
417 card->port, retval); t1isa_probe()
421 t1_disable_irq(card->port); t1isa_probe()
422 b1_reset(card->port); t1isa_probe()
434 strcpy(cinfo->capi_ctrl.name, card->name); t1isa_probe()
442 printk(KERN_INFO "t1isa: AVM T1 ISA at i/o %#x, irq %d, card %d\n", t1isa_probe()
443 card->port, card->irq, card->cardnr); t1isa_probe()
449 free_irq(card->irq, card); t1isa_probe()
451 release_region(card->port, AVMB1_PORTLEN); t1isa_probe()
453 b1_free_card(card); t1isa_probe()
461 avmcard *card = cinfo->card; t1isa_send_message() local
462 unsigned int port = card->port; t1isa_send_message()
469 spin_lock_irqsave(&card->lock, flags); t1isa_send_message()
476 spin_unlock_irqrestore(&card->lock, flags); t1isa_send_message()
488 spin_unlock_irqrestore(&card->lock, flags); t1isa_send_message()
503 cinfo->card ? cinfo->card->port : 0x0, t1isa_procinfo()
504 cinfo->card ? cinfo->card->irq : 0, t1isa_procinfo()
505 cinfo->card ? cinfo->card->cardnr : 0 t1isa_procinfo()
H A Dc4.c3 * Module for AVM C4 & C2 card.
59 static void c4_dispatch_tx(avmcard *card);
146 static inline int wait_for_doorbell(avmcard *card, unsigned long t) wait_for_doorbell() argument
151 while (c4inmeml(card->mbase + DOORBELL) != 0xffffffff) { wait_for_doorbell()
159 static int c4_poke(avmcard *card, unsigned long off, unsigned long value) c4_poke() argument
162 if (wait_for_doorbell(card, HZ / 10) < 0) c4_poke()
165 c4outmeml(card->mbase + MBOX_PEEK_POKE, off); c4_poke()
166 c4outmeml(card->mbase + DOORBELL, DBELL_ADDR); c4_poke()
168 if (wait_for_doorbell(card, HZ / 10) < 0) c4_poke()
171 c4outmeml(card->mbase + MBOX_PEEK_POKE, value); c4_poke()
172 c4outmeml(card->mbase + DOORBELL, DBELL_DATA | DBELL_ADDR); c4_poke()
177 static int c4_peek(avmcard *card, unsigned long off, unsigned long *valuep) c4_peek() argument
179 if (wait_for_doorbell(card, HZ / 10) < 0) c4_peek()
182 c4outmeml(card->mbase + MBOX_PEEK_POKE, off); c4_peek()
183 c4outmeml(card->mbase + DOORBELL, DBELL_RNWR | DBELL_ADDR); c4_peek()
185 if (wait_for_doorbell(card, HZ / 10) < 0) c4_peek()
188 *valuep = c4inmeml(card->mbase + MBOX_PEEK_POKE); c4_peek()
195 static int c4_load_t4file(avmcard *card, capiloaddatapart *t4file) c4_load_t4file() argument
211 if (c4_poke(card, loadoff, val)) { c4_load_t4file()
213 card->name); c4_load_t4file()
228 if (c4_poke(card, loadoff, val)) { c4_load_t4file()
230 card->name); c4_load_t4file()
296 static void c4_reset(avmcard *card) c4_reset() argument
300 c4outmeml(card->mbase + DOORBELL, DBELL_RESET_ARM); c4_reset()
303 while (c4inmeml(card->mbase + DOORBELL) != 0xffffffff) { c4_reset()
306 c4outmeml(card->mbase + DOORBELL, DBELL_ADDR); c4_reset()
310 c4_poke(card, DC21285_ARMCSR_BASE + CHAN_1_CONTROL, 0); c4_reset()
311 c4_poke(card, DC21285_ARMCSR_BASE + CHAN_2_CONTROL, 0); c4_reset()
316 static int c4_detect(avmcard *card) c4_detect() argument
320 c4outmeml(card->mbase + PCI_OUT_INT_MASK, 0x0c); c4_detect()
321 if (c4inmeml(card->mbase + PCI_OUT_INT_MASK) != 0x0c) c4_detect()
324 c4outmeml(card->mbase + DOORBELL, DBELL_RESET_ARM); c4_detect()
327 while (c4inmeml(card->mbase + DOORBELL) != 0xffffffff) { c4_detect()
330 c4outmeml(card->mbase + DOORBELL, DBELL_ADDR); c4_detect()
334 c4_poke(card, DC21285_ARMCSR_BASE + CHAN_1_CONTROL, 0); c4_detect()
335 c4_poke(card, DC21285_ARMCSR_BASE + CHAN_2_CONTROL, 0); c4_detect()
337 c4outmeml(card->mbase + MAILBOX_0, 0x55aa55aa); c4_detect()
338 if (c4inmeml(card->mbase + MAILBOX_0) != 0x55aa55aa) return 3; c4_detect()
340 c4outmeml(card->mbase + MAILBOX_0, 0xaa55aa55); c4_detect()
341 if (c4inmeml(card->mbase + MAILBOX_0) != 0xaa55aa55) return 4; c4_detect()
343 if (c4_poke(card, DC21285_ARMCSR_BASE + DBELL_SA_MASK, 0)) return 5; c4_detect()
344 if (c4_poke(card, DC21285_ARMCSR_BASE + DBELL_PCI_MASK, 0)) return 6; c4_detect()
345 if (c4_poke(card, DC21285_ARMCSR_BASE + SA_CONTROL, SA_CTL_ALLRIGHT)) c4_detect()
347 if (c4_poke(card, DC21285_ARMCSR_BASE + XBUS_CYCLE, INIT_XBUS_CYCLE)) c4_detect()
349 if (c4_poke(card, DC21285_ARMCSR_BASE + XBUS_STROBE, INIT_XBUS_STROBE)) c4_detect()
351 if (c4_poke(card, DC21285_ARMCSR_BASE + DRAM_TIMING, 0)) return 9; c4_detect()
355 if (c4_peek(card, DC21285_DRAM_A0MR, &dummy)) return 10; c4_detect()
356 if (c4_peek(card, DC21285_DRAM_A1MR, &dummy)) return 11; c4_detect()
357 if (c4_peek(card, DC21285_DRAM_A2MR, &dummy)) return 12; c4_detect()
358 if (c4_peek(card, DC21285_DRAM_A3MR, &dummy)) return 13; c4_detect()
360 if (c4_poke(card, DC21285_DRAM_A0MR + CAS_OFFSET, 0)) return 14; c4_detect()
361 if (c4_poke(card, DC21285_DRAM_A1MR + CAS_OFFSET, 0)) return 15; c4_detect()
362 if (c4_poke(card, DC21285_DRAM_A2MR + CAS_OFFSET, 0)) return 16; c4_detect()
363 if (c4_poke(card, DC21285_DRAM_A3MR + CAS_OFFSET, 0)) return 17; c4_detect()
367 if (c4_poke(card, DC21285_ARMCSR_BASE + DRAM_TIMING, DRAM_TIMING_DEF)) c4_detect()
370 if (c4_poke(card, DC21285_ARMCSR_BASE + DRAM_ADDR_SIZE_0, DRAM_AD_SZ_DEF0)) c4_detect()
372 if (c4_poke(card, DC21285_ARMCSR_BASE + DRAM_ADDR_SIZE_1, DRAM_AD_SZ_NULL)) c4_detect()
374 if (c4_poke(card, DC21285_ARMCSR_BASE + DRAM_ADDR_SIZE_2, DRAM_AD_SZ_NULL)) c4_detect()
376 if (c4_poke(card, DC21285_ARMCSR_BASE + DRAM_ADDR_SIZE_3, DRAM_AD_SZ_NULL)) c4_detect()
381 if (c4_poke(card, 0x000000, 0x11111111) c4_detect()
382 || c4_poke(card, 0x400000, 0x22222222) c4_detect()
383 || c4_poke(card, 0x800000, 0x33333333) c4_detect()
384 || c4_poke(card, 0xC00000, 0x44444444)) c4_detect()
387 if (c4_peek(card, 0x000000, &dummy) || dummy != 0x11111111 c4_detect()
388 || c4_peek(card, 0x400000, &dummy) || dummy != 0x22222222 c4_detect()
389 || c4_peek(card, 0x800000, &dummy) || dummy != 0x33333333 c4_detect()
390 || c4_peek(card, 0xC00000, &dummy) || dummy != 0x44444444) c4_detect()
393 if (c4_poke(card, 0x000000, 0x55555555) c4_detect()
394 || c4_poke(card, 0x400000, 0x66666666) c4_detect()
395 || c4_poke(card, 0x800000, 0x77777777) c4_detect()
396 || c4_poke(card, 0xC00000, 0x88888888)) c4_detect()
399 if (c4_peek(card, 0x000000, &dummy) || dummy != 0x55555555 c4_detect()
400 || c4_peek(card, 0x400000, &dummy) || dummy != 0x66666666 c4_detect()
401 || c4_peek(card, 0x800000, &dummy) || dummy != 0x77777777 c4_detect()
402 || c4_peek(card, 0xC00000, &dummy) || dummy != 0x88888888) c4_detect()
410 static void c4_dispatch_tx(avmcard *card) c4_dispatch_tx() argument
412 avmcard_dmainfo *dma = card->dma; c4_dispatch_tx()
420 if (card->csr & DBELL_DOWN_ARM) { /* tx busy */ c4_dispatch_tx()
427 printk(KERN_DEBUG "%s: tx underrun\n", card->name); c4_dispatch_tx()
451 printk(KERN_DEBUG "%s: tx put msg len=%d\n", card->name, txlen); c4_dispatch_tx()
457 printk(KERN_INFO "%s: ack to c4\n", card->name); c4_dispatch_tx()
461 card->name, skb->data[2], txlen); c4_dispatch_tx()
468 c4outmeml(card->mbase + MBOX_DOWN_ADDR, dma->sendbuf.dmaaddr); c4_dispatch_tx()
469 c4outmeml(card->mbase + MBOX_DOWN_LEN, txlen); c4_dispatch_tx()
471 card->csr |= DBELL_DOWN_ARM; c4_dispatch_tx()
473 c4outmeml(card->mbase + DOORBELL, DBELL_DOWN_ARM); c4_dispatch_tx()
480 static void queue_pollack(avmcard *card) queue_pollack() argument
488 card->name); queue_pollack()
497 skb_queue_tail(&card->dma->send_queue, skb); queue_pollack()
498 c4_dispatch_tx(card); queue_pollack()
503 static void c4_handle_rx(avmcard *card) c4_handle_rx() argument
505 avmcard_dmainfo *dma = card->dma; c4_handle_rx()
516 printk(KERN_DEBUG "%s: rx 0x%x len=%lu\n", card->name, c4_handle_rx()
524 MsgLen = _get_slice(&p, card->msgbuf); c4_handle_rx()
525 DataB3Len = _get_slice(&p, card->databuf); c4_handle_rx()
526 cidx = CAPIMSG_CONTROLLER(card->msgbuf)-card->cardnr; c4_handle_rx()
527 if (cidx >= card->nlogcontr) cidx = 0; c4_handle_rx()
528 ctrl = &card->ctrlinfo[cidx].capi_ctrl; c4_handle_rx()
531 memset(card->msgbuf + MsgLen, 0, 30 - MsgLen); c4_handle_rx()
533 CAPIMSG_SETLEN(card->msgbuf, 30); c4_handle_rx()
537 card->name); c4_handle_rx()
539 memcpy(skb_put(skb, MsgLen), card->msgbuf, MsgLen); c4_handle_rx()
540 memcpy(skb_put(skb, DataB3Len), card->databuf, DataB3Len); c4_handle_rx()
548 MsgLen = _get_slice(&p, card->msgbuf); c4_handle_rx()
549 cidx = CAPIMSG_CONTROLLER(card->msgbuf)-card->cardnr; c4_handle_rx()
550 if (cidx >= card->nlogcontr) cidx = 0; c4_handle_rx()
551 cinfo = &card->ctrlinfo[cidx]; c4_handle_rx()
552 ctrl = &card->ctrlinfo[cidx].capi_ctrl; c4_handle_rx()
556 card->name); c4_handle_rx()
558 memcpy(skb_put(skb, MsgLen), card->msgbuf, MsgLen); c4_handle_rx()
573 cidx = (NCCI & 0x7f) - card->cardnr; c4_handle_rx()
574 if (cidx >= card->nlogcontr) cidx = 0; c4_handle_rx()
576 capilib_new_ncci(&card->ctrlinfo[cidx].ncci_head, ApplId, NCCI, WindowSize); c4_handle_rx()
586 cidx = (NCCI & 0x7f) - card->cardnr; c4_handle_rx()
587 if (cidx >= card->nlogcontr) cidx = 0; c4_handle_rx()
588 capilib_free_ncci(&card->ctrlinfo[cidx].ncci_head, ApplId, NCCI); c4_handle_rx()
594 printk(KERN_INFO "%s: poll from c4\n", card->name); c4_handle_rx()
597 queue_pollack(card); c4_handle_rx()
598 for (cidx = 0; cidx < card->nr_controllers; cidx++) { c4_handle_rx()
599 ctrl = &card->ctrlinfo[cidx].capi_ctrl; c4_handle_rx()
605 for (cidx = 0; cidx < card->nr_controllers; cidx++) { c4_handle_rx()
606 ctrl = &card->ctrlinfo[cidx].capi_ctrl; c4_handle_rx()
613 cidx = card->nlogcontr; c4_handle_rx()
614 if (cidx >= card->nr_controllers) { c4_handle_rx()
615 printk(KERN_ERR "%s: card with %d controllers ??\n", c4_handle_rx()
616 card->name, cidx + 1); c4_handle_rx()
619 card->nlogcontr++; c4_handle_rx()
620 cinfo = &card->ctrlinfo[cidx]; c4_handle_rx()
624 printk(KERN_INFO "%s: %s-card (%s) now active\n", c4_handle_rx()
625 card->name, c4_handle_rx()
633 MsgLen = _get_slice(&p, card->msgbuf); c4_handle_rx()
634 card->msgbuf[MsgLen] = 0; c4_handle_rx()
636 && (card->msgbuf[MsgLen - 1] == '\n' c4_handle_rx()
637 || card->msgbuf[MsgLen - 1] == '\r')) { c4_handle_rx()
638 card->msgbuf[MsgLen - 1] = 0; c4_handle_rx()
642 card->name, ApplId, card->msgbuf); c4_handle_rx()
646 MsgLen = _get_slice(&p, card->msgbuf); c4_handle_rx()
647 card->msgbuf[MsgLen] = 0; c4_handle_rx()
649 && (card->msgbuf[MsgLen - 1] == '\n' c4_handle_rx()
650 || card->msgbuf[MsgLen - 1] == '\r')) { c4_handle_rx()
651 card->msgbuf[MsgLen - 1] = 0; c4_handle_rx()
654 printk(KERN_INFO "%s: DEBUG: %s\n", card->name, card->msgbuf); c4_handle_rx()
659 card->name, b1cmd); c4_handle_rx()
666 static irqreturn_t c4_handle_interrupt(avmcard *card) c4_handle_interrupt() argument
671 spin_lock_irqsave(&card->lock, flags); c4_handle_interrupt()
672 status = c4inmeml(card->mbase + DOORBELL); c4_handle_interrupt()
676 c4outmeml(card->mbase + PCI_OUT_INT_MASK, 0x0c); c4_handle_interrupt()
677 spin_unlock_irqrestore(&card->lock, flags); c4_handle_interrupt()
678 if (card->nlogcontr == 0) c4_handle_interrupt()
680 printk(KERN_ERR "%s: unexpected reset\n", card->name); c4_handle_interrupt()
681 for (i = 0; i < card->nr_controllers; i++) { c4_handle_interrupt()
682 avmctrl_info *cinfo = &card->ctrlinfo[i]; c4_handle_interrupt()
684 spin_lock_irqsave(&card->lock, flags); c4_handle_interrupt()
686 spin_unlock_irqrestore(&card->lock, flags); c4_handle_interrupt()
689 card->nlogcontr = 0; c4_handle_interrupt()
695 spin_unlock_irqrestore(&card->lock, flags); c4_handle_interrupt()
698 c4outmeml(card->mbase + DOORBELL, status); c4_handle_interrupt()
701 card->dma->recvlen = c4inmeml(card->mbase + MBOX_UP_LEN); c4_handle_interrupt()
702 c4outmeml(card->mbase + MBOX_UP_LEN, 0); c4_handle_interrupt()
703 c4_handle_rx(card); c4_handle_interrupt()
704 card->dma->recvlen = 0; c4_handle_interrupt()
705 c4outmeml(card->mbase + MBOX_UP_LEN, card->dma->recvbuf.size); c4_handle_interrupt()
706 c4outmeml(card->mbase + DOORBELL, DBELL_UP_ARM); c4_handle_interrupt()
710 card->csr &= ~DBELL_DOWN_ARM; c4_handle_interrupt()
711 c4_dispatch_tx(card); c4_handle_interrupt()
712 } else if (card->csr & DBELL_DOWN_HOST) { c4_handle_interrupt()
713 if (c4inmeml(card->mbase + MBOX_DOWN_LEN) == 0) { c4_handle_interrupt()
714 card->csr &= ~DBELL_DOWN_ARM; c4_handle_interrupt()
715 c4_dispatch_tx(card); c4_handle_interrupt()
718 spin_unlock_irqrestore(&card->lock, flags); c4_handle_interrupt()
724 avmcard *card = devptr; c4_interrupt() local
726 return c4_handle_interrupt(card); c4_interrupt()
731 static void c4_send_init(avmcard *card) c4_send_init() argument
740 card->name); c4_send_init()
749 _put_word(&p, card->cardnr - 1); c4_send_init()
752 skb_queue_tail(&card->dma->send_queue, skb); c4_send_init()
753 spin_lock_irqsave(&card->lock, flags); c4_send_init()
754 c4_dispatch_tx(card); c4_send_init()
755 spin_unlock_irqrestore(&card->lock, flags); c4_send_init()
758 static int queue_sendconfigword(avmcard *card, u32 val) queue_sendconfigword() argument
767 card->name); queue_sendconfigword()
777 skb_queue_tail(&card->dma->send_queue, skb); queue_sendconfigword()
778 spin_lock_irqsave(&card->lock, flags); queue_sendconfigword()
779 c4_dispatch_tx(card); queue_sendconfigword()
780 spin_unlock_irqrestore(&card->lock, flags); queue_sendconfigword()
784 static int queue_sendconfig(avmcard *card, char cval[4]) queue_sendconfig() argument
793 card->name); queue_sendconfig()
806 skb_queue_tail(&card->dma->send_queue, skb); queue_sendconfig()
808 spin_lock_irqsave(&card->lock, flags); queue_sendconfig()
809 c4_dispatch_tx(card); queue_sendconfig()
810 spin_unlock_irqrestore(&card->lock, flags); queue_sendconfig()
814 static int c4_send_config(avmcard *card, capiloaddatapart *config) c4_send_config() argument
821 if ((retval = queue_sendconfigword(card, 1)) != 0) c4_send_config()
823 if ((retval = queue_sendconfigword(card, config->len)) != 0) c4_send_config()
835 if ((retval = queue_sendconfig(card, val)) != 0) c4_send_config()
848 if ((retval = queue_sendconfig(card, val)) != 0) c4_send_config()
858 avmcard *card = cinfo->card; c4_load_firmware() local
861 if ((retval = c4_load_t4file(card, &data->firmware))) { c4_load_firmware()
863 card->name); c4_load_firmware()
864 c4_reset(card); c4_load_firmware()
868 card->csr = 0; c4_load_firmware()
869 c4outmeml(card->mbase + MBOX_UP_LEN, 0); c4_load_firmware()
870 c4outmeml(card->mbase + MBOX_DOWN_LEN, 0); c4_load_firmware()
871 c4outmeml(card->mbase + DOORBELL, DBELL_INIT); c4_load_firmware()
873 c4outmeml(card->mbase + DOORBELL, c4_load_firmware()
876 c4outmeml(card->mbase + PCI_OUT_INT_MASK, 0x08); c4_load_firmware()
878 card->dma->recvlen = 0; c4_load_firmware()
879 c4outmeml(card->mbase + MBOX_UP_ADDR, card->dma->recvbuf.dmaaddr); c4_load_firmware()
880 c4outmeml(card->mbase + MBOX_UP_LEN, card->dma->recvbuf.size); c4_load_firmware()
881 c4outmeml(card->mbase + DOORBELL, DBELL_UP_ARM); c4_load_firmware()
884 retval = c4_send_config(card, &data->configuration); c4_load_firmware()
887 card->name); c4_load_firmware()
888 c4_reset(card); c4_load_firmware()
893 c4_send_init(card); c4_load_firmware()
901 avmcard *card = ((avmctrl_info *)(ctrl->driverdata))->card; c4_reset_ctr() local
906 spin_lock_irqsave(&card->lock, flags); c4_reset_ctr()
908 c4_reset(card); c4_reset_ctr()
910 spin_unlock_irqrestore(&card->lock, flags); c4_reset_ctr()
912 for (i = 0; i < card->nr_controllers; i++) { c4_reset_ctr()
913 cinfo = &card->ctrlinfo[i]; c4_reset_ctr()
917 card->nlogcontr = 0; c4_reset_ctr()
922 avmcard *card = pci_get_drvdata(pdev); c4_remove() local
926 if (!card) c4_remove()
929 c4_reset(card); c4_remove()
931 for (i = 0; i < card->nr_controllers; i++) { c4_remove()
932 cinfo = &card->ctrlinfo[i]; c4_remove()
936 free_irq(card->irq, card); c4_remove()
937 iounmap(card->mbase); c4_remove()
938 release_region(card->port, AVMB1_PORTLEN); c4_remove()
939 avmcard_dma_free(card->dma); c4_remove()
941 b1_free_card(card); c4_remove()
952 avmcard *card = cinfo->card; c4_register_appl() local
959 if (ctrl->cnr == card->cardnr) { c4_register_appl()
968 card->name); c4_register_appl()
982 skb_queue_tail(&card->dma->send_queue, skb); c4_register_appl()
984 spin_lock_irqsave(&card->lock, flags); c4_register_appl()
985 c4_dispatch_tx(card); c4_register_appl()
986 spin_unlock_irqrestore(&card->lock, flags); c4_register_appl()
995 avmcard *card = cinfo->card; c4_release_appl() local
1000 spin_lock_irqsave(&card->lock, flags); c4_release_appl()
1002 spin_unlock_irqrestore(&card->lock, flags); c4_release_appl()
1004 if (ctrl->cnr == card->cardnr) { c4_release_appl()
1008 card->name); c4_release_appl()
1018 skb_queue_tail(&card->dma->send_queue, skb); c4_release_appl()
1019 spin_lock_irqsave(&card->lock, flags); c4_release_appl()
1020 c4_dispatch_tx(card); c4_release_appl()
1021 spin_unlock_irqrestore(&card->lock, flags); c4_release_appl()
1031 avmcard *card = cinfo->card; c4_send_message() local
1035 spin_lock_irqsave(&card->lock, flags); c4_send_message()
1043 skb_queue_tail(&card->dma->send_queue, skb); c4_send_message()
1044 c4_dispatch_tx(card); c4_send_message()
1046 spin_unlock_irqrestore(&card->lock, flags); c4_send_message()
1061 cinfo->card ? cinfo->card->port : 0x0, c4_procinfo()
1062 cinfo->card ? cinfo->card->irq : 0, c4_procinfo()
1063 cinfo->card ? cinfo->card->membase : 0 c4_procinfo()
1072 avmcard *card = cinfo->card; c4_proc_show() local
1076 seq_printf(m, "%-16s %s\n", "name", card->name); c4_proc_show()
1077 seq_printf(m, "%-16s 0x%x\n", "io", card->port); c4_proc_show()
1078 seq_printf(m, "%-16s %d\n", "irq", card->irq); c4_proc_show()
1079 seq_printf(m, "%-16s 0x%lx\n", "membase", card->membase); c4_proc_show()
1080 switch (card->cardtype) { c4_proc_show()
1100 if (card->cardtype != avm_m1) { c4_proc_show()
1114 if (card->cardtype != avm_m1) { c4_proc_show()
1148 avmcard *card; c4_add_card() local
1153 card = b1_alloc_card(nr_controllers); c4_add_card()
1154 if (!card) { c4_add_card()
1159 card->dma = avmcard_dma_alloc("c4", dev, 2048 + 128, 2048 + 128); c4_add_card()
1160 if (!card->dma) { c4_add_card()
1166 sprintf(card->name, "c%d-%x", nr_controllers, p->port); c4_add_card()
1167 card->port = p->port; c4_add_card()
1168 card->irq = p->irq; c4_add_card()
1169 card->membase = p->membase; c4_add_card()
1170 card->cardtype = (nr_controllers == 4) ? avm_c4 : avm_c2; c4_add_card()
1172 if (!request_region(card->port, AVMB1_PORTLEN, card->name)) { c4_add_card()
1174 card->port, card->port + AVMB1_PORTLEN); c4_add_card()
1179 card->mbase = ioremap(card->membase, 128); c4_add_card()
1180 if (card->mbase == NULL) { c4_add_card()
1182 card->membase); c4_add_card()
1187 retval = c4_detect(card); c4_add_card()
1189 printk(KERN_NOTICE "c4: NO card at 0x%x error(%d)\n", c4_add_card()
1190 card->port, retval); c4_add_card()
1194 c4_reset(card); c4_add_card()
1196 retval = request_irq(card->irq, c4_interrupt, IRQF_SHARED, card->name, card); c4_add_card()
1198 printk(KERN_ERR "c4: unable to get IRQ %d.\n", card->irq); c4_add_card()
1204 cinfo = &card->ctrlinfo[i]; c4_add_card()
1215 strcpy(cinfo->capi_ctrl.name, card->name); c4_add_card()
1221 cinfo = &card->ctrlinfo[i]; c4_add_card()
1227 card->cardnr = cinfo->capi_ctrl.cnr; c4_add_card()
1231 nr_controllers, card->port, card->irq, c4_add_card()
1232 card->membase); c4_add_card()
1233 pci_set_drvdata(dev, card); c4_add_card()
1237 free_irq(card->irq, card); c4_add_card()
1239 iounmap(card->mbase); c4_add_card()
1241 release_region(card->port, AVMB1_PORTLEN); c4_add_card()
1243 avmcard_dma_free(card->dma); c4_add_card()
1245 b1_free_card(card); c4_add_card()
H A Db1pcmcia.c3 * Module for AVM B1/M1/M2 PCMCIA-card.
43 avmcard *card = cinfo->card; b1pcmcia_remove_ctr() local
44 unsigned int port = card->port; b1pcmcia_remove_ctr()
50 free_irq(card->irq, card); b1pcmcia_remove_ctr()
51 b1_free_card(card); b1pcmcia_remove_ctr()
64 avmcard *card; b1pcmcia_add_card() local
68 card = b1_alloc_card(1); b1pcmcia_add_card()
69 if (!card) { b1pcmcia_add_card()
74 cinfo = card->ctrlinfo; b1pcmcia_add_card()
77 case avm_m1: sprintf(card->name, "m1-%x", port); break; b1pcmcia_add_card()
78 case avm_m2: sprintf(card->name, "m2-%x", port); break; b1pcmcia_add_card()
79 default: sprintf(card->name, "b1pcmcia-%x", port); break; b1pcmcia_add_card()
81 card->port = port; b1pcmcia_add_card()
82 card->irq = irq; b1pcmcia_add_card()
83 card->cardtype = cardtype; b1pcmcia_add_card()
85 retval = request_irq(card->irq, b1_interrupt, IRQF_SHARED, card->name, card); b1pcmcia_add_card()
88 card->irq); b1pcmcia_add_card()
92 b1_reset(card->port); b1pcmcia_add_card()
93 if ((retval = b1_detect(card->port, card->cardtype)) != 0) { b1pcmcia_add_card()
94 printk(KERN_NOTICE "b1pcmcia: NO card at 0x%x (%d)\n", b1pcmcia_add_card()
95 card->port, retval); b1pcmcia_add_card()
99 b1_reset(card->port); b1pcmcia_add_card()
100 b1_getrevision(card); b1pcmcia_add_card()
112 strcpy(cinfo->capi_ctrl.name, card->name); b1pcmcia_add_card()
126 cardname, card->port, card->irq, card->revision); b1pcmcia_add_card()
128 list_add(&card->list, &cards); b1pcmcia_add_card()
132 free_irq(card->irq, card); b1pcmcia_add_card()
134 b1_free_card(card); b1pcmcia_add_card()
150 cinfo->card ? cinfo->card->port : 0x0, b1pcmcia_procinfo()
151 cinfo->card ? cinfo->card->irq : 0, b1pcmcia_procinfo()
152 cinfo->card ? cinfo->card->revision : 0 b1pcmcia_procinfo()
177 avmcard *card; b1pcmcia_delcard() local
180 card = list_entry(l, avmcard, list); b1pcmcia_delcard()
181 if (card->port == port && card->irq == irq) { b1pcmcia_delcard()
182 b1pcmcia_remove_ctr(&card->ctrlinfo[0].capi_ctrl); b1pcmcia_delcard()
H A Db1.c67 avmcard *card; b1_alloc_card() local
71 card = kzalloc(sizeof(*card), GFP_KERNEL); b1_alloc_card()
72 if (!card) b1_alloc_card()
77 kfree(card); b1_alloc_card()
81 card->ctrlinfo = cinfo; b1_alloc_card()
84 cinfo[i].card = card; b1_alloc_card()
86 spin_lock_init(&card->lock); b1_alloc_card()
87 card->nr_controllers = nr_controllers; b1_alloc_card()
89 return card; b1_alloc_card()
94 void b1_free_card(avmcard *card) b1_free_card() argument
96 kfree(card->ctrlinfo); b1_free_card()
97 kfree(card); b1_free_card()
145 void b1_getrevision(avmcard *card) b1_getrevision() argument
147 card->class = inb(card->port + B1_ANALYSE); b1_getrevision()
148 card->revision = inb(card->port + B1_REVISION); b1_getrevision()
152 int b1_load_t4file(avmcard *card, capiloaddatapart *t4file) b1_load_t4file() argument
157 unsigned int base = card->port; b1_load_t4file()
171 card->name); b1_load_t4file()
187 card->name); b1_load_t4file()
194 int b1_load_config(avmcard *card, capiloaddatapart *config) b1_load_config() argument
198 unsigned int base = card->port; b1_load_config()
245 int b1_loaded(avmcard *card) b1_loaded() argument
247 unsigned int base = card->port; b1_loaded()
258 card->name); b1_loaded()
268 card->name, ans); b1_loaded()
272 printk(KERN_ERR "%s: b1_loaded: firmware not running\n", card->name); b1_loaded()
281 avmcard *card = cinfo->card; b1_load_firmware() local
282 unsigned int port = card->port; b1_load_firmware()
288 if ((retval = b1_load_t4file(card, &data->firmware))) { b1_load_firmware()
291 card->name); b1_load_firmware()
298 if ((retval = b1_load_config(card, &data->configuration))) { b1_load_firmware()
301 card->name); b1_load_firmware()
306 if (!b1_loaded(card)) { b1_load_firmware()
307 printk(KERN_ERR "%s: failed to load t4file.\n", card->name); b1_load_firmware()
311 spin_lock_irqsave(&card->lock, flags); b1_load_firmware()
312 b1_setinterrupt(port, card->irq, card->cardtype); b1_load_firmware()
317 spin_unlock_irqrestore(&card->lock, flags); b1_load_firmware()
325 avmcard *card = cinfo->card; b1_reset_ctr() local
326 unsigned int port = card->port; b1_reset_ctr()
333 spin_lock_irqsave(&card->lock, flags); b1_reset_ctr()
335 spin_unlock_irqrestore(&card->lock, flags); b1_reset_ctr()
344 avmcard *card = cinfo->card; b1_register_appl() local
345 unsigned int port = card->port; b1_register_appl()
353 spin_lock_irqsave(&card->lock, flags); b1_register_appl()
360 spin_unlock_irqrestore(&card->lock, flags); b1_register_appl()
366 avmcard *card = cinfo->card; b1_release_appl() local
367 unsigned int port = card->port; b1_release_appl()
370 spin_lock_irqsave(&card->lock, flags); b1_release_appl()
374 spin_unlock_irqrestore(&card->lock, flags); b1_release_appl()
380 avmcard *card = cinfo->card; b1_send_message() local
381 unsigned int port = card->port; b1_send_message()
388 spin_lock_irqsave(&card->lock, flags); b1_send_message()
395 spin_unlock_irqrestore(&card->lock, flags); b1_send_message()
408 spin_unlock_irqrestore(&card->lock, flags); b1_send_message()
419 avmcard *card = cinfo->card; b1_parse_version() local
459 printk(KERN_NOTICE "%s: card %d \"%s\" ready.\n", b1_parse_version()
460 card->name, ctrl->cnr, cinfo->cardname); b1_parse_version()
464 printk(KERN_NOTICE "%s: card %d Protocol:%s%s%s%s%s%s%s\n", b1_parse_version()
465 card->name, b1_parse_version()
478 printk(KERN_NOTICE "%s: card %d Linetype:%s%s%s%s\n", b1_parse_version()
479 card->name, b1_parse_version()
492 avmcard *card = devptr; b1_interrupt() local
493 avmctrl_info *cinfo = &card->ctrlinfo[0]; b1_interrupt()
505 spin_lock_irqsave(&card->lock, flags); b1_interrupt()
507 if (!b1_rx_full(card->port)) { b1_interrupt()
508 spin_unlock_irqrestore(&card->lock, flags); b1_interrupt()
512 b1cmd = b1_get_byte(card->port); b1_interrupt()
518 ApplId = (unsigned) b1_get_word(card->port); b1_interrupt()
519 MsgLen = b1_get_slice(card->port, card->msgbuf); b1_interrupt()
520 DataB3Len = b1_get_slice(card->port, card->databuf); b1_interrupt()
521 spin_unlock_irqrestore(&card->lock, flags); b1_interrupt()
524 memset(card->msgbuf + MsgLen, 0, 30-MsgLen); b1_interrupt()
526 CAPIMSG_SETLEN(card->msgbuf, 30); b1_interrupt()
530 card->name); b1_interrupt()
532 memcpy(skb_put(skb, MsgLen), card->msgbuf, MsgLen); b1_interrupt()
533 memcpy(skb_put(skb, DataB3Len), card->databuf, DataB3Len); b1_interrupt()
540 ApplId = (unsigned) b1_get_word(card->port); b1_interrupt()
541 MsgLen = b1_get_slice(card->port, card->msgbuf); b1_interrupt()
544 card->name); b1_interrupt()
545 spin_unlock_irqrestore(&card->lock, flags); b1_interrupt()
547 memcpy(skb_put(skb, MsgLen), card->msgbuf, MsgLen); b1_interrupt()
552 spin_unlock_irqrestore(&card->lock, flags); b1_interrupt()
559 ApplId = b1_get_word(card->port); b1_interrupt()
560 NCCI = b1_get_word(card->port); b1_interrupt()
561 WindowSize = b1_get_word(card->port); b1_interrupt()
563 spin_unlock_irqrestore(&card->lock, flags); b1_interrupt()
568 ApplId = b1_get_word(card->port); b1_interrupt()
569 NCCI = b1_get_word(card->port); b1_interrupt()
572 spin_unlock_irqrestore(&card->lock, flags); b1_interrupt()
576 /* b1_put_byte(card->port, SEND_POLLACK); */ b1_interrupt()
577 spin_unlock_irqrestore(&card->lock, flags); b1_interrupt()
582 spin_unlock_irqrestore(&card->lock, flags); b1_interrupt()
588 cinfo->versionlen = b1_get_slice(card->port, cinfo->versionbuf); b1_interrupt()
589 spin_unlock_irqrestore(&card->lock, flags); b1_interrupt()
591 printk(KERN_INFO "%s: %s-card (%s) now active\n", b1_interrupt()
592 card->name, b1_interrupt()
599 ApplId = (unsigned) b1_get_word(card->port); b1_interrupt()
600 MsgLen = b1_get_slice(card->port, card->msgbuf); b1_interrupt()
601 spin_unlock_irqrestore(&card->lock, flags); b1_interrupt()
602 card->msgbuf[MsgLen] = 0; b1_interrupt()
604 && (card->msgbuf[MsgLen - 1] == '\n' b1_interrupt()
605 || card->msgbuf[MsgLen - 1] == '\r')) { b1_interrupt()
606 card->msgbuf[MsgLen - 1] = 0; b1_interrupt()
610 card->name, ApplId, card->msgbuf); b1_interrupt()
614 MsgLen = b1_get_slice(card->port, card->msgbuf); b1_interrupt()
615 spin_unlock_irqrestore(&card->lock, flags); b1_interrupt()
616 card->msgbuf[MsgLen] = 0; b1_interrupt()
618 && (card->msgbuf[MsgLen - 1] == '\n' b1_interrupt()
619 || card->msgbuf[MsgLen - 1] == '\r')) { b1_interrupt()
620 card->msgbuf[MsgLen - 1] = 0; b1_interrupt()
623 printk(KERN_INFO "%s: DEBUG: %s\n", card->name, card->msgbuf); b1_interrupt()
627 spin_unlock_irqrestore(&card->lock, flags); b1_interrupt()
628 printk(KERN_ERR "%s: card removed ?\n", card->name); b1_interrupt()
631 spin_unlock_irqrestore(&card->lock, flags); b1_interrupt()
633 card->name, b1cmd); b1_interrupt()
644 avmcard *card = cinfo->card; b1ctl_proc_show() local
648 seq_printf(m, "%-16s %s\n", "name", card->name); b1ctl_proc_show()
649 seq_printf(m, "%-16s 0x%x\n", "io", card->port); b1ctl_proc_show()
650 seq_printf(m, "%-16s %d\n", "irq", card->irq); b1ctl_proc_show()
651 switch (card->cardtype) { b1ctl_proc_show()
664 if (card->cardtype == avm_t1isa) b1ctl_proc_show()
665 seq_printf(m, "%-16s %d\n", "cardnr", card->cardnr); b1ctl_proc_show()
673 if (card->cardtype != avm_m1) { b1ctl_proc_show()
687 if (card->cardtype != avm_m1) { b1ctl_proc_show()
/linux-4.1.27/drivers/block/rsxx/
H A Ddev.c73 struct rsxx_cardinfo *card = bdev->bd_disk->private_data; rsxx_blkdev_ioctl() local
77 return rsxx_reg_access(card, (void __user *)arg, 1); rsxx_blkdev_ioctl()
79 return rsxx_reg_access(card, (void __user *)arg, 0); rsxx_blkdev_ioctl()
87 struct rsxx_cardinfo *card = bdev->bd_disk->private_data; rsxx_getgeo() local
88 u64 blocks = card->size8 >> 9; rsxx_getgeo()
94 if (card->size8) { rsxx_getgeo()
113 static void disk_stats_start(struct rsxx_cardinfo *card, struct bio *bio) disk_stats_start() argument
116 &card->gendisk->part0); disk_stats_start()
119 static void disk_stats_complete(struct rsxx_cardinfo *card, disk_stats_complete() argument
123 generic_end_io_acct(bio_data_dir(bio), &card->gendisk->part0, disk_stats_complete()
127 static void bio_dma_done_cb(struct rsxx_cardinfo *card, bio_dma_done_cb() argument
137 if (!card->eeh_state && card->gendisk) bio_dma_done_cb()
138 disk_stats_complete(card, meta->bio, meta->start_time); bio_dma_done_cb()
147 struct rsxx_cardinfo *card = q->queuedata; rsxx_make_request() local
153 if (!card) rsxx_make_request()
156 if (bio_end_sector(bio) > get_capacity(card->gendisk)) rsxx_make_request()
159 if (unlikely(card->halt)) { rsxx_make_request()
164 if (unlikely(card->dma_fault)) { rsxx_make_request()
170 dev_err(CARD_TO_DEV(card), "size zero BIO!\n"); rsxx_make_request()
185 if (!unlikely(card->halt)) rsxx_make_request()
186 disk_stats_start(card, bio); rsxx_make_request()
188 dev_dbg(CARD_TO_DEV(card), "BIO[%c]: meta: %p addr8: x%llx size: %d\n", rsxx_make_request()
192 st = rsxx_dma_queue_bio(card, bio, &bio_meta->pending_dmas, rsxx_make_request()
206 static bool rsxx_discard_supported(struct rsxx_cardinfo *card) rsxx_discard_supported() argument
210 pci_read_config_byte(card->dev, PCI_REVISION_ID, &pci_rev); rsxx_discard_supported()
215 int rsxx_attach_dev(struct rsxx_cardinfo *card) rsxx_attach_dev() argument
217 mutex_lock(&card->dev_lock); rsxx_attach_dev()
221 if (card->config_valid) rsxx_attach_dev()
222 set_capacity(card->gendisk, card->size8 >> 9); rsxx_attach_dev()
224 set_capacity(card->gendisk, 0); rsxx_attach_dev()
225 add_disk(card->gendisk); rsxx_attach_dev()
227 card->bdev_attached = 1; rsxx_attach_dev()
230 mutex_unlock(&card->dev_lock); rsxx_attach_dev()
235 void rsxx_detach_dev(struct rsxx_cardinfo *card) rsxx_detach_dev() argument
237 mutex_lock(&card->dev_lock); rsxx_detach_dev()
239 if (card->bdev_attached) { rsxx_detach_dev()
240 del_gendisk(card->gendisk); rsxx_detach_dev()
241 card->bdev_attached = 0; rsxx_detach_dev()
244 mutex_unlock(&card->dev_lock); rsxx_detach_dev()
247 int rsxx_setup_dev(struct rsxx_cardinfo *card) rsxx_setup_dev() argument
251 mutex_init(&card->dev_lock); rsxx_setup_dev()
256 card->major = register_blkdev(0, DRIVER_NAME); rsxx_setup_dev()
257 if (card->major < 0) { rsxx_setup_dev()
258 dev_err(CARD_TO_DEV(card), "Failed to get major number\n"); rsxx_setup_dev()
262 card->queue = blk_alloc_queue(GFP_KERNEL); rsxx_setup_dev()
263 if (!card->queue) { rsxx_setup_dev()
264 dev_err(CARD_TO_DEV(card), "Failed queue alloc\n"); rsxx_setup_dev()
265 unregister_blkdev(card->major, DRIVER_NAME); rsxx_setup_dev()
269 card->gendisk = alloc_disk(blkdev_minors); rsxx_setup_dev()
270 if (!card->gendisk) { rsxx_setup_dev()
271 dev_err(CARD_TO_DEV(card), "Failed disk alloc\n"); rsxx_setup_dev()
272 blk_cleanup_queue(card->queue); rsxx_setup_dev()
273 unregister_blkdev(card->major, DRIVER_NAME); rsxx_setup_dev()
277 if (card->config_valid) { rsxx_setup_dev()
278 blk_size = card->config.data.block_size; rsxx_setup_dev()
279 blk_queue_dma_alignment(card->queue, blk_size - 1); rsxx_setup_dev()
280 blk_queue_logical_block_size(card->queue, blk_size); rsxx_setup_dev()
283 blk_queue_make_request(card->queue, rsxx_make_request); rsxx_setup_dev()
284 blk_queue_bounce_limit(card->queue, BLK_BOUNCE_ANY); rsxx_setup_dev()
285 blk_queue_max_hw_sectors(card->queue, blkdev_max_hw_sectors); rsxx_setup_dev()
286 blk_queue_physical_block_size(card->queue, RSXX_HW_BLK_SIZE); rsxx_setup_dev()
288 queue_flag_set_unlocked(QUEUE_FLAG_NONROT, card->queue); rsxx_setup_dev()
289 queue_flag_clear_unlocked(QUEUE_FLAG_ADD_RANDOM, card->queue); rsxx_setup_dev()
290 if (rsxx_discard_supported(card)) { rsxx_setup_dev()
291 queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, card->queue); rsxx_setup_dev()
292 blk_queue_max_discard_sectors(card->queue, rsxx_setup_dev()
294 card->queue->limits.discard_granularity = RSXX_HW_BLK_SIZE; rsxx_setup_dev()
295 card->queue->limits.discard_alignment = RSXX_HW_BLK_SIZE; rsxx_setup_dev()
296 card->queue->limits.discard_zeroes_data = 1; rsxx_setup_dev()
299 card->queue->queuedata = card; rsxx_setup_dev()
301 snprintf(card->gendisk->disk_name, sizeof(card->gendisk->disk_name), rsxx_setup_dev()
302 "rsxx%d", card->disk_id); rsxx_setup_dev()
303 card->gendisk->driverfs_dev = &card->dev->dev; rsxx_setup_dev()
304 card->gendisk->major = card->major; rsxx_setup_dev()
305 card->gendisk->first_minor = 0; rsxx_setup_dev()
306 card->gendisk->fops = &rsxx_fops; rsxx_setup_dev()
307 card->gendisk->private_data = card; rsxx_setup_dev()
308 card->gendisk->queue = card->queue; rsxx_setup_dev()
313 void rsxx_destroy_dev(struct rsxx_cardinfo *card) rsxx_destroy_dev() argument
318 put_disk(card->gendisk); rsxx_destroy_dev()
319 card->gendisk = NULL; rsxx_destroy_dev()
321 blk_cleanup_queue(card->queue); rsxx_destroy_dev()
322 card->queue->queuedata = NULL; rsxx_destroy_dev()
323 unregister_blkdev(card->major, DRIVER_NAME); rsxx_destroy_dev()
H A Dcore.c58 "until the card startup has completed.");
67 struct rsxx_cardinfo *card = m->private; rsxx_attr_pci_regs_show() local
70 ioread32(card->regmap + HWID)); rsxx_attr_pci_regs_show()
72 ioread32(card->regmap + SCRATCH)); rsxx_attr_pci_regs_show()
74 ioread32(card->regmap + IER)); rsxx_attr_pci_regs_show()
76 ioread32(card->regmap + IPR)); rsxx_attr_pci_regs_show()
78 ioread32(card->regmap + CREG_CMD)); rsxx_attr_pci_regs_show()
80 ioread32(card->regmap + CREG_ADD)); rsxx_attr_pci_regs_show()
82 ioread32(card->regmap + CREG_CNT)); rsxx_attr_pci_regs_show()
84 ioread32(card->regmap + CREG_STAT)); rsxx_attr_pci_regs_show()
86 ioread32(card->regmap + CREG_DATA0)); rsxx_attr_pci_regs_show()
88 ioread32(card->regmap + CREG_DATA1)); rsxx_attr_pci_regs_show()
90 ioread32(card->regmap + CREG_DATA2)); rsxx_attr_pci_regs_show()
92 ioread32(card->regmap + CREG_DATA3)); rsxx_attr_pci_regs_show()
94 ioread32(card->regmap + CREG_DATA4)); rsxx_attr_pci_regs_show()
96 ioread32(card->regmap + CREG_DATA5)); rsxx_attr_pci_regs_show()
98 ioread32(card->regmap + CREG_DATA6)); rsxx_attr_pci_regs_show()
100 ioread32(card->regmap + CREG_DATA7)); rsxx_attr_pci_regs_show()
102 ioread32(card->regmap + INTR_COAL)); rsxx_attr_pci_regs_show()
104 ioread32(card->regmap + HW_ERROR)); rsxx_attr_pci_regs_show()
106 ioread32(card->regmap + PCI_DEBUG0)); rsxx_attr_pci_regs_show()
108 ioread32(card->regmap + PCI_DEBUG1)); rsxx_attr_pci_regs_show()
110 ioread32(card->regmap + PCI_DEBUG2)); rsxx_attr_pci_regs_show()
112 ioread32(card->regmap + PCI_DEBUG3)); rsxx_attr_pci_regs_show()
114 ioread32(card->regmap + PCI_DEBUG4)); rsxx_attr_pci_regs_show()
116 ioread32(card->regmap + PCI_DEBUG5)); rsxx_attr_pci_regs_show()
118 ioread32(card->regmap + PCI_DEBUG6)); rsxx_attr_pci_regs_show()
120 ioread32(card->regmap + PCI_DEBUG7)); rsxx_attr_pci_regs_show()
122 ioread32(card->regmap + PCI_RECONFIG)); rsxx_attr_pci_regs_show()
129 struct rsxx_cardinfo *card = m->private; rsxx_attr_stats_show() local
132 for (i = 0; i < card->n_targets; i++) { rsxx_attr_stats_show()
134 i, card->ctrl[i].stats.crc_errors); rsxx_attr_stats_show()
136 i, card->ctrl[i].stats.hard_errors); rsxx_attr_stats_show()
138 i, card->ctrl[i].stats.soft_errors); rsxx_attr_stats_show()
140 i, card->ctrl[i].stats.writes_issued); rsxx_attr_stats_show()
142 i, card->ctrl[i].stats.writes_failed); rsxx_attr_stats_show()
144 i, card->ctrl[i].stats.reads_issued); rsxx_attr_stats_show()
146 i, card->ctrl[i].stats.reads_failed); rsxx_attr_stats_show()
148 i, card->ctrl[i].stats.reads_retried); rsxx_attr_stats_show()
150 i, card->ctrl[i].stats.discards_issued); rsxx_attr_stats_show()
152 i, card->ctrl[i].stats.discards_failed); rsxx_attr_stats_show()
154 i, card->ctrl[i].stats.dma_sw_err); rsxx_attr_stats_show()
156 i, card->ctrl[i].stats.dma_hw_fault); rsxx_attr_stats_show()
158 i, card->ctrl[i].stats.dma_cancelled); rsxx_attr_stats_show()
160 i, card->ctrl[i].stats.sw_q_depth); rsxx_attr_stats_show()
162 i, atomic_read(&card->ctrl[i].stats.hw_q_depth)); rsxx_attr_stats_show()
181 struct rsxx_cardinfo *card = file_inode(fp)->i_private; rsxx_cram_read() local
189 st = rsxx_creg_read(card, CREG_ADD_CRAM + (u32)*ppos, cnt, buf, 1); rsxx_cram_read()
202 struct rsxx_cardinfo *card = file_inode(fp)->i_private; rsxx_cram_write() local
212 st = rsxx_creg_write(card, CREG_ADD_CRAM + (u32)*ppos, cnt, rsxx_cram_write()
243 static void rsxx_debugfs_dev_new(struct rsxx_cardinfo *card) rsxx_debugfs_dev_new() argument
249 card->debugfs_dir = debugfs_create_dir(card->gendisk->disk_name, NULL); rsxx_debugfs_dev_new()
250 if (IS_ERR_OR_NULL(card->debugfs_dir)) rsxx_debugfs_dev_new()
254 card->debugfs_dir, card, rsxx_debugfs_dev_new()
260 card->debugfs_dir, card, rsxx_debugfs_dev_new()
266 card->debugfs_dir, card, rsxx_debugfs_dev_new()
277 debugfs_remove(card->debugfs_dir); rsxx_debugfs_dev_new()
279 card->debugfs_dir = NULL; rsxx_debugfs_dev_new()
284 static void rsxx_mask_interrupts(struct rsxx_cardinfo *card) rsxx_mask_interrupts() argument
286 card->isr_mask = 0; rsxx_mask_interrupts()
287 card->ier_mask = 0; rsxx_mask_interrupts()
304 * Enable/Disable interrupt functions assume the card->irq_lock
307 void rsxx_enable_ier(struct rsxx_cardinfo *card, unsigned int intr) rsxx_enable_ier() argument
309 if (unlikely(card->halt) || rsxx_enable_ier()
310 unlikely(card->eeh_state)) rsxx_enable_ier()
313 __enable_intr(&card->ier_mask, intr); rsxx_enable_ier()
314 iowrite32(card->ier_mask, card->regmap + IER); rsxx_enable_ier()
317 void rsxx_disable_ier(struct rsxx_cardinfo *card, unsigned int intr) rsxx_disable_ier() argument
319 if (unlikely(card->eeh_state)) rsxx_disable_ier()
322 __disable_intr(&card->ier_mask, intr); rsxx_disable_ier()
323 iowrite32(card->ier_mask, card->regmap + IER); rsxx_disable_ier()
326 void rsxx_enable_ier_and_isr(struct rsxx_cardinfo *card, rsxx_enable_ier_and_isr() argument
329 if (unlikely(card->halt) || rsxx_enable_ier_and_isr()
330 unlikely(card->eeh_state)) rsxx_enable_ier_and_isr()
333 __enable_intr(&card->isr_mask, intr); rsxx_enable_ier_and_isr()
334 __enable_intr(&card->ier_mask, intr); rsxx_enable_ier_and_isr()
335 iowrite32(card->ier_mask, card->regmap + IER); rsxx_enable_ier_and_isr()
337 void rsxx_disable_ier_and_isr(struct rsxx_cardinfo *card, rsxx_disable_ier_and_isr() argument
340 if (unlikely(card->eeh_state)) rsxx_disable_ier_and_isr()
343 __disable_intr(&card->isr_mask, intr); rsxx_disable_ier_and_isr()
344 __disable_intr(&card->ier_mask, intr); rsxx_disable_ier_and_isr()
345 iowrite32(card->ier_mask, card->regmap + IER); rsxx_disable_ier_and_isr()
350 struct rsxx_cardinfo *card = pdata; rsxx_isr() local
356 spin_lock(&card->irq_lock); rsxx_isr()
361 if (unlikely(card->eeh_state)) rsxx_isr()
364 isr = ioread32(card->regmap + ISR); rsxx_isr()
371 dev_info(CARD_TO_DEV(card), rsxx_isr()
376 isr &= card->isr_mask; rsxx_isr()
380 for (i = 0; i < card->n_targets; i++) { rsxx_isr()
382 if (card->ier_mask & CR_INTR_DMA(i)) { rsxx_isr()
383 rsxx_disable_ier(card, CR_INTR_DMA(i)); rsxx_isr()
386 queue_work(card->ctrl[i].done_wq, rsxx_isr()
387 &card->ctrl[i].dma_done_work); rsxx_isr()
393 queue_work(card->creg_ctrl.creg_wq, rsxx_isr()
394 &card->creg_ctrl.done_work); rsxx_isr()
399 queue_work(card->event_wq, &card->event_work); rsxx_isr()
400 rsxx_disable_ier_and_isr(card, CR_INTR_EVENT); rsxx_isr()
405 spin_unlock(&card->irq_lock); rsxx_isr()
422 static void card_state_change(struct rsxx_cardinfo *card, card_state_change() argument
427 dev_info(CARD_TO_DEV(card), card_state_change()
428 "card state change detected.(%s -> %s)\n", card_state_change()
429 rsxx_card_state_to_str(card->state), card_state_change()
432 card->state = new_state; card_state_change()
434 /* Don't attach DMA interfaces if the card has an invalid config */ card_state_change()
435 if (!card->config_valid) card_state_change()
440 dev_crit(CARD_TO_DEV(card), card_state_change()
447 st = rsxx_get_card_size8(card, &card->size8); card_state_change()
449 dev_err(CARD_TO_DEV(card), card_state_change()
452 if (card->config_valid) card_state_change()
453 set_capacity(card->gendisk, card->size8 >> 9); card_state_change()
457 dev_crit(CARD_TO_DEV(card), card_state_change()
472 set_capacity(card->gendisk, 0); card_state_change()
479 struct rsxx_cardinfo *card; card_event_handler() local
484 card = container_of(work, struct rsxx_cardinfo, event_work); card_event_handler()
486 if (unlikely(card->halt)) card_event_handler()
494 spin_lock_irqsave(&card->irq_lock, flags); card_event_handler()
495 rsxx_enable_ier_and_isr(card, CR_INTR_EVENT); card_event_handler()
496 spin_unlock_irqrestore(&card->irq_lock, flags); card_event_handler()
498 st = rsxx_get_card_state(card, &state); card_event_handler()
500 dev_info(CARD_TO_DEV(card), card_event_handler()
505 if (card->state != state) card_event_handler()
506 card_state_change(card, state); card_event_handler()
508 if (card->creg_ctrl.creg_stats.stat & CREG_STAT_LOG_PENDING) card_event_handler()
509 rsxx_read_hw_log(card); card_event_handler()
513 static int card_shutdown(struct rsxx_cardinfo *card) card_shutdown() argument
520 /* We can't issue a shutdown if the card is in a transition state */ card_shutdown()
523 st = rsxx_get_card_state(card, &state); card_shutdown()
535 st = rsxx_issue_card_cmd(card, CARD_CMD_SHUTDOWN); card_shutdown()
542 st = rsxx_get_card_state(card, &state); card_shutdown()
556 struct rsxx_cardinfo *card = pci_get_drvdata(dev); rsxx_eeh_frozen() local
562 card->eeh_state = 1; rsxx_eeh_frozen()
563 rsxx_mask_interrupts(card); rsxx_eeh_frozen()
574 st = rsxx_eeh_save_issued_dmas(card); rsxx_eeh_frozen()
578 rsxx_eeh_save_issued_creg(card); rsxx_eeh_frozen()
580 for (i = 0; i < card->n_targets; i++) { rsxx_eeh_frozen()
581 if (card->ctrl[i].status.buf) rsxx_eeh_frozen()
582 pci_free_consistent(card->dev, STATUS_BUFFER_SIZE8, rsxx_eeh_frozen()
583 card->ctrl[i].status.buf, rsxx_eeh_frozen()
584 card->ctrl[i].status.dma_addr); rsxx_eeh_frozen()
585 if (card->ctrl[i].cmd.buf) rsxx_eeh_frozen()
586 pci_free_consistent(card->dev, COMMAND_BUFFER_SIZE8, rsxx_eeh_frozen()
587 card->ctrl[i].cmd.buf, rsxx_eeh_frozen()
588 card->ctrl[i].cmd.dma_addr); rsxx_eeh_frozen()
596 struct rsxx_cardinfo *card = pci_get_drvdata(dev); rsxx_eeh_failure() local
600 dev_err(&dev->dev, "IBM Flash Adapter PCI: disabling failed card.\n"); rsxx_eeh_failure()
602 card->eeh_state = 1; rsxx_eeh_failure()
603 card->halt = 1; rsxx_eeh_failure()
605 for (i = 0; i < card->n_targets; i++) { rsxx_eeh_failure()
606 spin_lock_bh(&card->ctrl[i].queue_lock); rsxx_eeh_failure()
607 cnt = rsxx_cleanup_dma_queue(&card->ctrl[i], rsxx_eeh_failure()
608 &card->ctrl[i].queue, rsxx_eeh_failure()
610 spin_unlock_bh(&card->ctrl[i].queue_lock); rsxx_eeh_failure()
612 cnt += rsxx_dma_cancel(&card->ctrl[i]); rsxx_eeh_failure()
615 dev_info(CARD_TO_DEV(card), rsxx_eeh_failure()
617 cnt, card->ctrl[i].id); rsxx_eeh_failure()
621 static int rsxx_eeh_fifo_flush_poll(struct rsxx_cardinfo *card) rsxx_eeh_fifo_flush_poll() argument
628 status = ioread32(card->regmap + PCI_RECONFIG); rsxx_eeh_fifo_flush_poll()
636 dev_warn(CARD_TO_DEV(card), "HW: flash controller timeout\n"); rsxx_eeh_fifo_flush_poll()
669 struct rsxx_cardinfo *card = pci_get_drvdata(dev); rsxx_slot_reset() local
683 st = rsxx_eeh_fifo_flush_poll(card); rsxx_slot_reset()
687 rsxx_dma_queue_reset(card); rsxx_slot_reset()
689 for (i = 0; i < card->n_targets; i++) { rsxx_slot_reset()
690 st = rsxx_hw_buffers_init(dev, &card->ctrl[i]); rsxx_slot_reset()
695 if (card->config_valid) rsxx_slot_reset()
696 rsxx_dma_configure(card); rsxx_slot_reset()
699 st = ioread32(card->regmap + ISR); rsxx_slot_reset()
701 card->eeh_state = 0; rsxx_slot_reset()
703 spin_lock_irqsave(&card->irq_lock, flags); rsxx_slot_reset()
704 if (card->n_targets & RSXX_MAX_TARGETS) rsxx_slot_reset()
705 rsxx_enable_ier_and_isr(card, CR_INTR_ALL_G); rsxx_slot_reset()
707 rsxx_enable_ier_and_isr(card, CR_INTR_ALL_C); rsxx_slot_reset()
708 spin_unlock_irqrestore(&card->irq_lock, flags); rsxx_slot_reset()
710 rsxx_kick_creg_queue(card); rsxx_slot_reset()
712 for (i = 0; i < card->n_targets; i++) { rsxx_slot_reset()
713 spin_lock(&card->ctrl[i].queue_lock); rsxx_slot_reset()
714 if (list_empty(&card->ctrl[i].queue)) { rsxx_slot_reset()
715 spin_unlock(&card->ctrl[i].queue_lock); rsxx_slot_reset()
718 spin_unlock(&card->ctrl[i].queue_lock); rsxx_slot_reset()
720 queue_work(card->ctrl[i].issue_wq, rsxx_slot_reset()
721 &card->ctrl[i].issue_dma_work); rsxx_slot_reset()
729 for (i = 0; i < card->n_targets; i++) { rsxx_slot_reset()
730 if (card->ctrl[i].status.buf) rsxx_slot_reset()
731 pci_free_consistent(card->dev, rsxx_slot_reset()
733 card->ctrl[i].status.buf, rsxx_slot_reset()
734 card->ctrl[i].status.dma_addr); rsxx_slot_reset()
735 if (card->ctrl[i].cmd.buf) rsxx_slot_reset()
736 pci_free_consistent(card->dev, rsxx_slot_reset()
738 card->ctrl[i].cmd.buf, rsxx_slot_reset()
739 card->ctrl[i].cmd.dma_addr); rsxx_slot_reset()
750 static int rsxx_compatibility_check(struct rsxx_cardinfo *card) rsxx_compatibility_check() argument
754 pci_read_config_byte(card->dev, PCI_REVISION_ID, &pci_rev); rsxx_compatibility_check()
764 struct rsxx_cardinfo *card; rsxx_pci_probe() local
770 card = kzalloc(sizeof(*card), GFP_KERNEL); rsxx_pci_probe()
771 if (!card) rsxx_pci_probe()
774 card->dev = dev; rsxx_pci_probe()
775 pci_set_drvdata(dev, card); rsxx_pci_probe()
784 st = ida_get_new(&rsxx_disk_ida, &card->disk_id); rsxx_pci_probe()
800 dev_err(CARD_TO_DEV(card), rsxx_pci_probe()
807 dev_err(CARD_TO_DEV(card), rsxx_pci_probe()
813 dev_err(CARD_TO_DEV(card), "BAR0 has length 0!\n"); rsxx_pci_probe()
818 card->regmap = pci_iomap(dev, 0, 0); rsxx_pci_probe()
819 if (!card->regmap) { rsxx_pci_probe()
820 dev_err(CARD_TO_DEV(card), "Failed to map BAR0\n"); rsxx_pci_probe()
825 spin_lock_init(&card->irq_lock); rsxx_pci_probe()
826 card->halt = 0; rsxx_pci_probe()
827 card->eeh_state = 0; rsxx_pci_probe()
829 spin_lock_irq(&card->irq_lock); rsxx_pci_probe()
830 rsxx_disable_ier_and_isr(card, CR_INTR_ALL); rsxx_pci_probe()
831 spin_unlock_irq(&card->irq_lock); rsxx_pci_probe()
836 dev_warn(CARD_TO_DEV(card), rsxx_pci_probe()
841 DRIVER_NAME, card); rsxx_pci_probe()
843 dev_err(CARD_TO_DEV(card), rsxx_pci_probe()
849 st = rsxx_creg_setup(card); rsxx_pci_probe()
851 dev_err(CARD_TO_DEV(card), "Failed to setup creg interface.\n"); rsxx_pci_probe()
855 spin_lock_irq(&card->irq_lock); rsxx_pci_probe()
856 rsxx_enable_ier_and_isr(card, CR_INTR_CREG); rsxx_pci_probe()
857 spin_unlock_irq(&card->irq_lock); rsxx_pci_probe()
859 st = rsxx_compatibility_check(card); rsxx_pci_probe()
861 dev_warn(CARD_TO_DEV(card), rsxx_pci_probe()
868 st = rsxx_load_config(card); rsxx_pci_probe()
870 dev_err(CARD_TO_DEV(card), rsxx_pci_probe()
871 "Failed loading card config\n"); rsxx_pci_probe()
874 st = rsxx_get_num_targets(card, &card->n_targets); rsxx_pci_probe()
876 dev_info(CARD_TO_DEV(card), rsxx_pci_probe()
879 card->ctrl = kzalloc(card->n_targets * sizeof(*card->ctrl), GFP_KERNEL); rsxx_pci_probe()
880 if (!card->ctrl) { rsxx_pci_probe()
885 st = rsxx_dma_setup(card); rsxx_pci_probe()
887 dev_info(CARD_TO_DEV(card), rsxx_pci_probe()
893 card->event_wq = create_singlethread_workqueue(DRIVER_NAME"_event"); rsxx_pci_probe()
894 if (!card->event_wq) { rsxx_pci_probe()
895 dev_err(CARD_TO_DEV(card), "Failed card event setup.\n"); rsxx_pci_probe()
899 INIT_WORK(&card->event_work, card_event_handler); rsxx_pci_probe()
901 st = rsxx_setup_dev(card); rsxx_pci_probe()
905 rsxx_get_card_state(card, &card->state); rsxx_pci_probe()
907 dev_info(CARD_TO_DEV(card), rsxx_pci_probe()
908 "card state: %s\n", rsxx_pci_probe()
909 rsxx_card_state_to_str(card->state)); rsxx_pci_probe()
916 spin_lock_irq(&card->irq_lock); rsxx_pci_probe()
917 rsxx_enable_ier_and_isr(card, CR_INTR_EVENT); rsxx_pci_probe()
918 spin_unlock_irq(&card->irq_lock); rsxx_pci_probe()
920 if (card->state == CARD_STATE_SHUTDOWN) { rsxx_pci_probe()
921 st = rsxx_issue_card_cmd(card, CARD_CMD_STARTUP); rsxx_pci_probe()
923 dev_crit(CARD_TO_DEV(card), rsxx_pci_probe()
924 "Failed issuing card startup\n"); rsxx_pci_probe()
928 dev_info(CARD_TO_DEV(card), rsxx_pci_probe()
929 "Waiting for card to startup\n"); rsxx_pci_probe()
935 rsxx_get_card_state(card, &card->state); rsxx_pci_probe()
937 (card->state == CARD_STATE_STARTING)); rsxx_pci_probe()
939 if (card->state == CARD_STATE_STARTING) { rsxx_pci_probe()
940 dev_warn(CARD_TO_DEV(card), rsxx_pci_probe()
942 card->size8 = 0; rsxx_pci_probe()
944 dev_info(CARD_TO_DEV(card), rsxx_pci_probe()
945 "card state: %s\n", rsxx_pci_probe()
946 rsxx_card_state_to_str(card->state)); rsxx_pci_probe()
947 st = rsxx_get_card_size8(card, &card->size8); rsxx_pci_probe()
949 card->size8 = 0; rsxx_pci_probe()
952 } else if (card->state == CARD_STATE_GOOD || rsxx_pci_probe()
953 card->state == CARD_STATE_RD_ONLY_FAULT) { rsxx_pci_probe()
954 st = rsxx_get_card_size8(card, &card->size8); rsxx_pci_probe()
956 card->size8 = 0; rsxx_pci_probe()
959 rsxx_attach_dev(card); rsxx_pci_probe()
962 rsxx_debugfs_dev_new(card); rsxx_pci_probe()
967 destroy_workqueue(card->event_wq); rsxx_pci_probe()
968 card->event_wq = NULL; rsxx_pci_probe()
970 rsxx_dma_destroy(card); rsxx_pci_probe()
973 destroy_workqueue(card->creg_ctrl.creg_wq); rsxx_pci_probe()
974 card->creg_ctrl.creg_wq = NULL; rsxx_pci_probe()
976 spin_lock_irq(&card->irq_lock); rsxx_pci_probe()
977 rsxx_disable_ier_and_isr(card, CR_INTR_ALL); rsxx_pci_probe()
978 spin_unlock_irq(&card->irq_lock); rsxx_pci_probe()
979 free_irq(dev->irq, card); rsxx_pci_probe()
983 pci_iounmap(dev, card->regmap); rsxx_pci_probe()
991 ida_remove(&rsxx_disk_ida, card->disk_id); rsxx_pci_probe()
994 kfree(card); rsxx_pci_probe()
1001 struct rsxx_cardinfo *card = pci_get_drvdata(dev); rsxx_pci_remove() local
1006 if (!card) rsxx_pci_remove()
1009 dev_info(CARD_TO_DEV(card), rsxx_pci_remove()
1012 rsxx_detach_dev(card); rsxx_pci_remove()
1014 for (i = 0; i < card->n_targets; i++) { rsxx_pci_remove()
1015 spin_lock_irqsave(&card->irq_lock, flags); rsxx_pci_remove()
1016 rsxx_disable_ier_and_isr(card, CR_INTR_DMA(i)); rsxx_pci_remove()
1017 spin_unlock_irqrestore(&card->irq_lock, flags); rsxx_pci_remove()
1020 st = card_shutdown(card); rsxx_pci_remove()
1022 dev_crit(CARD_TO_DEV(card), "Shutdown failed!\n"); rsxx_pci_remove()
1025 spin_lock_irqsave(&card->irq_lock, flags); rsxx_pci_remove()
1026 rsxx_disable_ier_and_isr(card, CR_INTR_EVENT); rsxx_pci_remove()
1027 spin_unlock_irqrestore(&card->irq_lock, flags); rsxx_pci_remove()
1029 cancel_work_sync(&card->event_work); rsxx_pci_remove()
1031 rsxx_destroy_dev(card); rsxx_pci_remove()
1032 rsxx_dma_destroy(card); rsxx_pci_remove()
1034 spin_lock_irqsave(&card->irq_lock, flags); rsxx_pci_remove()
1035 rsxx_disable_ier_and_isr(card, CR_INTR_ALL); rsxx_pci_remove()
1036 spin_unlock_irqrestore(&card->irq_lock, flags); rsxx_pci_remove()
1039 card->halt = 1; rsxx_pci_remove()
1041 debugfs_remove_recursive(card->debugfs_dir); rsxx_pci_remove()
1043 free_irq(dev->irq, card); rsxx_pci_remove()
1048 rsxx_creg_destroy(card); rsxx_pci_remove()
1050 pci_iounmap(dev, card->regmap); rsxx_pci_remove()
1055 kfree(card); rsxx_pci_remove()
1066 struct rsxx_cardinfo *card = pci_get_drvdata(dev); rsxx_pci_shutdown() local
1070 if (!card) rsxx_pci_shutdown()
1073 dev_info(CARD_TO_DEV(card), "Shutting down PCI-Flash SSD.\n"); rsxx_pci_shutdown()
1075 rsxx_detach_dev(card); rsxx_pci_shutdown()
1077 for (i = 0; i < card->n_targets; i++) { rsxx_pci_shutdown()
1078 spin_lock_irqsave(&card->irq_lock, flags); rsxx_pci_shutdown()
1079 rsxx_disable_ier_and_isr(card, CR_INTR_DMA(i)); rsxx_pci_shutdown()
1080 spin_unlock_irqrestore(&card->irq_lock, flags); rsxx_pci_shutdown()
1083 card_shutdown(card); rsxx_pci_shutdown()
H A Dcregs.c32 typedef void (*creg_cmd_cb)(struct rsxx_cardinfo *card,
61 static int copy_to_creg_data(struct rsxx_cardinfo *card, copy_to_creg_data() argument
69 if (unlikely(card->eeh_state)) copy_to_creg_data()
78 iowrite32be(data[i], card->regmap + CREG_DATA(i)); copy_to_creg_data()
80 iowrite32(data[i], card->regmap + CREG_DATA(i)); copy_to_creg_data()
87 static int copy_from_creg_data(struct rsxx_cardinfo *card, copy_from_creg_data() argument
95 if (unlikely(card->eeh_state)) copy_from_creg_data()
104 data[i] = ioread32be(card->regmap + CREG_DATA(i)); copy_from_creg_data()
106 data[i] = ioread32(card->regmap + CREG_DATA(i)); copy_from_creg_data()
112 static void creg_issue_cmd(struct rsxx_cardinfo *card, struct creg_cmd *cmd) creg_issue_cmd() argument
116 if (unlikely(card->eeh_state)) creg_issue_cmd()
119 iowrite32(cmd->addr, card->regmap + CREG_ADD); creg_issue_cmd()
120 iowrite32(cmd->cnt8, card->regmap + CREG_CNT); creg_issue_cmd()
124 st = copy_to_creg_data(card, cmd->cnt8, creg_issue_cmd()
131 if (unlikely(card->eeh_state)) creg_issue_cmd()
135 iowrite32(cmd->op, card->regmap + CREG_CMD); creg_issue_cmd()
138 static void creg_kick_queue(struct rsxx_cardinfo *card) creg_kick_queue() argument
140 if (card->creg_ctrl.active || list_empty(&card->creg_ctrl.queue)) creg_kick_queue()
143 card->creg_ctrl.active = 1; creg_kick_queue()
144 card->creg_ctrl.active_cmd = list_first_entry(&card->creg_ctrl.queue, creg_kick_queue()
146 list_del(&card->creg_ctrl.active_cmd->list); creg_kick_queue()
147 card->creg_ctrl.q_depth--; creg_kick_queue()
155 mod_timer(&card->creg_ctrl.cmd_timer, creg_kick_queue()
158 creg_issue_cmd(card, card->creg_ctrl.active_cmd); creg_kick_queue()
161 static int creg_queue_cmd(struct rsxx_cardinfo *card, creg_queue_cmd() argument
173 if (unlikely(card->halt)) creg_queue_cmd()
176 if (card->creg_ctrl.reset) creg_queue_cmd()
197 spin_lock_bh(&card->creg_ctrl.lock); creg_queue_cmd()
198 list_add_tail(&cmd->list, &card->creg_ctrl.queue); creg_queue_cmd()
199 card->creg_ctrl.q_depth++; creg_queue_cmd()
200 creg_kick_queue(card); creg_queue_cmd()
201 spin_unlock_bh(&card->creg_ctrl.lock); creg_queue_cmd()
208 struct rsxx_cardinfo *card = (struct rsxx_cardinfo *) data; creg_cmd_timed_out() local
211 spin_lock(&card->creg_ctrl.lock); creg_cmd_timed_out()
212 cmd = card->creg_ctrl.active_cmd; creg_cmd_timed_out()
213 card->creg_ctrl.active_cmd = NULL; creg_cmd_timed_out()
214 spin_unlock(&card->creg_ctrl.lock); creg_cmd_timed_out()
217 card->creg_ctrl.creg_stats.creg_timeout++; creg_cmd_timed_out()
218 dev_warn(CARD_TO_DEV(card), creg_cmd_timed_out()
224 cmd->cb(card, cmd, -ETIMEDOUT); creg_cmd_timed_out()
229 spin_lock(&card->creg_ctrl.lock); creg_cmd_timed_out()
230 card->creg_ctrl.active = 0; creg_cmd_timed_out()
231 creg_kick_queue(card); creg_cmd_timed_out()
232 spin_unlock(&card->creg_ctrl.lock); creg_cmd_timed_out()
238 struct rsxx_cardinfo *card; creg_cmd_done() local
242 card = container_of(work, struct rsxx_cardinfo, creg_cmd_done()
249 if (del_timer_sync(&card->creg_ctrl.cmd_timer) == 0) creg_cmd_done()
250 card->creg_ctrl.creg_stats.failed_cancel_timer++; creg_cmd_done()
252 spin_lock_bh(&card->creg_ctrl.lock); creg_cmd_done()
253 cmd = card->creg_ctrl.active_cmd; creg_cmd_done()
254 card->creg_ctrl.active_cmd = NULL; creg_cmd_done()
255 spin_unlock_bh(&card->creg_ctrl.lock); creg_cmd_done()
258 dev_err(CARD_TO_DEV(card), creg_cmd_done()
263 card->creg_ctrl.creg_stats.stat = ioread32(card->regmap + CREG_STAT); creg_cmd_done()
264 cmd->status = card->creg_ctrl.creg_stats.stat; creg_cmd_done()
266 dev_err(CARD_TO_DEV(card), creg_cmd_done()
280 unsigned int cnt8 = ioread32(card->regmap + CREG_CNT); creg_cmd_done()
284 dev_err(CARD_TO_DEV(card), creg_cmd_done()
290 dev_err(CARD_TO_DEV(card), creg_cmd_done()
296 st = copy_from_creg_data(card, cnt8, cmd->buf, cmd->stream); creg_cmd_done()
301 cmd->cb(card, cmd, st); creg_cmd_done()
305 spin_lock_bh(&card->creg_ctrl.lock); creg_cmd_done()
306 card->creg_ctrl.active = 0; creg_cmd_done()
307 creg_kick_queue(card); creg_cmd_done()
308 spin_unlock_bh(&card->creg_ctrl.lock); creg_cmd_done()
311 static void creg_reset(struct rsxx_cardinfo *card) creg_reset() argument
321 if (!mutex_trylock(&card->creg_ctrl.reset_lock)) creg_reset()
324 card->creg_ctrl.reset = 1; creg_reset()
325 spin_lock_irqsave(&card->irq_lock, flags); creg_reset()
326 rsxx_disable_ier_and_isr(card, CR_INTR_CREG | CR_INTR_EVENT); creg_reset()
327 spin_unlock_irqrestore(&card->irq_lock, flags); creg_reset()
329 dev_warn(CARD_TO_DEV(card), creg_reset()
333 spin_lock_bh(&card->creg_ctrl.lock); creg_reset()
334 list_for_each_entry_safe(cmd, tmp, &card->creg_ctrl.queue, list) { creg_reset()
336 card->creg_ctrl.q_depth--; creg_reset()
338 cmd->cb(card, cmd, -ECANCELED); creg_reset()
342 cmd = card->creg_ctrl.active_cmd; creg_reset()
343 card->creg_ctrl.active_cmd = NULL; creg_reset()
345 if (timer_pending(&card->creg_ctrl.cmd_timer)) creg_reset()
346 del_timer_sync(&card->creg_ctrl.cmd_timer); creg_reset()
349 cmd->cb(card, cmd, -ECANCELED); creg_reset()
352 card->creg_ctrl.active = 0; creg_reset()
354 spin_unlock_bh(&card->creg_ctrl.lock); creg_reset()
356 card->creg_ctrl.reset = 0; creg_reset()
357 spin_lock_irqsave(&card->irq_lock, flags); creg_reset()
358 rsxx_enable_ier_and_isr(card, CR_INTR_CREG | CR_INTR_EVENT); creg_reset()
359 spin_unlock_irqrestore(&card->irq_lock, flags); creg_reset()
361 mutex_unlock(&card->creg_ctrl.reset_lock); creg_reset()
371 static void creg_cmd_done_cb(struct rsxx_cardinfo *card, creg_cmd_done_cb() argument
385 static int __issue_creg_rw(struct rsxx_cardinfo *card, __issue_creg_rw() argument
402 st = creg_queue_cmd(card, op, addr, cnt8, buf, stream, creg_cmd_done_cb, __issue_creg_rw()
413 card->creg_ctrl.q_depth + 20000); __issue_creg_rw()
425 dev_crit(CARD_TO_DEV(card), __issue_creg_rw()
427 creg_reset(card); __issue_creg_rw()
441 ioread32(card->regmap + SCRATCH); __issue_creg_rw()
443 dev_warn(CARD_TO_DEV(card), __issue_creg_rw()
452 static int issue_creg_rw(struct rsxx_cardinfo *card, issue_creg_rw() argument
469 st = __issue_creg_rw(card, op, addr, xfer, issue_creg_rw()
483 int rsxx_creg_write(struct rsxx_cardinfo *card, rsxx_creg_write() argument
489 return issue_creg_rw(card, addr, size8, data, byte_stream, 0); rsxx_creg_write()
492 int rsxx_creg_read(struct rsxx_cardinfo *card, rsxx_creg_read() argument
498 return issue_creg_rw(card, addr, size8, data, byte_stream, 1); rsxx_creg_read()
501 int rsxx_get_card_state(struct rsxx_cardinfo *card, unsigned int *state) rsxx_get_card_state() argument
503 return rsxx_creg_read(card, CREG_ADD_CARD_STATE, rsxx_get_card_state()
507 int rsxx_get_card_size8(struct rsxx_cardinfo *card, u64 *size8) rsxx_get_card_size8() argument
512 st = rsxx_creg_read(card, CREG_ADD_CARD_SIZE, rsxx_get_card_size8()
521 int rsxx_get_num_targets(struct rsxx_cardinfo *card, rsxx_get_num_targets() argument
524 return rsxx_creg_read(card, CREG_ADD_NUM_TARGETS, rsxx_get_num_targets()
528 int rsxx_get_card_capabilities(struct rsxx_cardinfo *card, rsxx_get_card_capabilities() argument
531 return rsxx_creg_read(card, CREG_ADD_CAPABILITIES, rsxx_get_card_capabilities()
535 int rsxx_issue_card_cmd(struct rsxx_cardinfo *card, u32 cmd) rsxx_issue_card_cmd() argument
537 return rsxx_creg_write(card, CREG_ADD_CARD_CMD, rsxx_issue_card_cmd()
543 static void hw_log_msg(struct rsxx_cardinfo *card, const char *str, int len) hw_log_msg() argument
559 dev_emerg(CARD_TO_DEV(card), "HW: %.*s", len, str); hw_log_msg()
562 dev_alert(CARD_TO_DEV(card), "HW: %.*s", len, str); hw_log_msg()
565 dev_crit(CARD_TO_DEV(card), "HW: %.*s", len, str); hw_log_msg()
568 dev_err(CARD_TO_DEV(card), "HW: %.*s", len, str); hw_log_msg()
571 dev_warn(CARD_TO_DEV(card), "HW: %.*s", len, str); hw_log_msg()
574 dev_notice(CARD_TO_DEV(card), "HW: %.*s", len, str); hw_log_msg()
577 dev_info(CARD_TO_DEV(card), "HW: %.*s", len, str); hw_log_msg()
580 dev_dbg(CARD_TO_DEV(card), "HW: %.*s", len, str); hw_log_msg()
583 dev_info(CARD_TO_DEV(card), "HW: %.*s", len, str); hw_log_msg()
609 static void read_hw_log_done(struct rsxx_cardinfo *card, read_hw_log_done() argument
627 log_str = &card->log.buf[card->log.buf_len]; read_hw_log_done()
628 cnt = min(cmd->cnt8 - off, LOG_BUF_SIZE8 - card->log.buf_len); read_hw_log_done()
632 card->log.buf_len += len; read_hw_log_done()
639 (card->log.buf_len == LOG_BUF_SIZE8)) { read_hw_log_done()
640 if (card->log.buf_len != 1) /* Don't log blank lines. */ read_hw_log_done()
641 hw_log_msg(card, card->log.buf, read_hw_log_done()
642 card->log.buf_len); read_hw_log_done()
643 card->log.buf_len = 0; read_hw_log_done()
649 rsxx_read_hw_log(card); read_hw_log_done()
652 int rsxx_read_hw_log(struct rsxx_cardinfo *card) rsxx_read_hw_log() argument
656 st = creg_queue_cmd(card, CREG_OP_READ, CREG_ADD_LOG, rsxx_read_hw_log()
657 sizeof(card->log.tmp), card->log.tmp, rsxx_read_hw_log()
660 dev_err(CARD_TO_DEV(card), rsxx_read_hw_log()
667 static int issue_reg_cmd(struct rsxx_cardinfo *card, issue_reg_cmd() argument
673 return __issue_creg_rw(card, op, cmd->addr, cmd->cnt, cmd->data, issue_reg_cmd()
677 int rsxx_reg_access(struct rsxx_cardinfo *card, rsxx_reg_access() argument
691 st = issue_reg_cmd(card, &cmd, read); rsxx_reg_access()
708 void rsxx_eeh_save_issued_creg(struct rsxx_cardinfo *card) rsxx_eeh_save_issued_creg() argument
712 cmd = card->creg_ctrl.active_cmd; rsxx_eeh_save_issued_creg()
713 card->creg_ctrl.active_cmd = NULL; rsxx_eeh_save_issued_creg()
716 del_timer_sync(&card->creg_ctrl.cmd_timer); rsxx_eeh_save_issued_creg()
718 spin_lock_bh(&card->creg_ctrl.lock); rsxx_eeh_save_issued_creg()
719 list_add(&cmd->list, &card->creg_ctrl.queue); rsxx_eeh_save_issued_creg()
720 card->creg_ctrl.q_depth++; rsxx_eeh_save_issued_creg()
721 card->creg_ctrl.active = 0; rsxx_eeh_save_issued_creg()
722 spin_unlock_bh(&card->creg_ctrl.lock); rsxx_eeh_save_issued_creg()
726 void rsxx_kick_creg_queue(struct rsxx_cardinfo *card) rsxx_kick_creg_queue() argument
728 spin_lock_bh(&card->creg_ctrl.lock); rsxx_kick_creg_queue()
729 if (!list_empty(&card->creg_ctrl.queue)) rsxx_kick_creg_queue()
730 creg_kick_queue(card); rsxx_kick_creg_queue()
731 spin_unlock_bh(&card->creg_ctrl.lock); rsxx_kick_creg_queue()
735 int rsxx_creg_setup(struct rsxx_cardinfo *card) rsxx_creg_setup() argument
737 card->creg_ctrl.active_cmd = NULL; rsxx_creg_setup()
739 card->creg_ctrl.creg_wq = rsxx_creg_setup()
741 if (!card->creg_ctrl.creg_wq) rsxx_creg_setup()
744 INIT_WORK(&card->creg_ctrl.done_work, creg_cmd_done); rsxx_creg_setup()
745 mutex_init(&card->creg_ctrl.reset_lock); rsxx_creg_setup()
746 INIT_LIST_HEAD(&card->creg_ctrl.queue); rsxx_creg_setup()
747 spin_lock_init(&card->creg_ctrl.lock); rsxx_creg_setup()
748 setup_timer(&card->creg_ctrl.cmd_timer, creg_cmd_timed_out, rsxx_creg_setup()
749 (unsigned long) card); rsxx_creg_setup()
754 void rsxx_creg_destroy(struct rsxx_cardinfo *card) rsxx_creg_destroy() argument
761 spin_lock_bh(&card->creg_ctrl.lock); rsxx_creg_destroy()
762 list_for_each_entry_safe(cmd, tmp, &card->creg_ctrl.queue, list) { rsxx_creg_destroy()
765 cmd->cb(card, cmd, -ECANCELED); rsxx_creg_destroy()
771 dev_info(CARD_TO_DEV(card), rsxx_creg_destroy()
774 cmd = card->creg_ctrl.active_cmd; rsxx_creg_destroy()
775 card->creg_ctrl.active_cmd = NULL; rsxx_creg_destroy()
777 if (timer_pending(&card->creg_ctrl.cmd_timer)) rsxx_creg_destroy()
778 del_timer_sync(&card->creg_ctrl.cmd_timer); rsxx_creg_destroy()
781 cmd->cb(card, cmd, -ECANCELED); rsxx_creg_destroy()
782 dev_info(CARD_TO_DEV(card), rsxx_creg_destroy()
786 spin_unlock_bh(&card->creg_ctrl.lock); rsxx_creg_destroy()
788 cancel_work_sync(&card->creg_ctrl.done_work); rsxx_creg_destroy()
H A Dconfig.c98 static int rsxx_save_config(struct rsxx_cardinfo *card) rsxx_save_config() argument
103 memcpy(&cfg, &card->config, sizeof(cfg)); rsxx_save_config()
106 dev_err(CARD_TO_DEV(card), rsxx_save_config()
124 st = rsxx_creg_write(card, CREG_ADD_CONFIG, sizeof(cfg), &cfg, 1); rsxx_save_config()
131 int rsxx_load_config(struct rsxx_cardinfo *card) rsxx_load_config() argument
136 st = rsxx_creg_read(card, CREG_ADD_CONFIG, sizeof(card->config), rsxx_load_config()
137 &card->config, 1); rsxx_load_config()
139 dev_err(CARD_TO_DEV(card), rsxx_load_config()
140 "Failed reading card config.\n"); rsxx_load_config()
144 config_hdr_be_to_cpu(&card->config.hdr); rsxx_load_config()
146 if (card->config.hdr.version == RSXX_CFG_VERSION) { rsxx_load_config()
154 config_data_swab(&card->config); rsxx_load_config()
157 crc = config_data_crc32(&card->config); rsxx_load_config()
158 if (crc != card->config.hdr.crc) { rsxx_load_config()
159 dev_err(CARD_TO_DEV(card), rsxx_load_config()
161 dev_info(CARD_TO_DEV(card), rsxx_load_config()
163 card->config.hdr.crc, crc); rsxx_load_config()
168 config_data_le_to_cpu(&card->config); rsxx_load_config()
170 } else if (card->config.hdr.version != 0) { rsxx_load_config()
171 dev_err(CARD_TO_DEV(card), rsxx_load_config()
173 card->config.hdr.version); rsxx_load_config()
180 dev_info(CARD_TO_DEV(card), rsxx_load_config()
181 "Initializing card configuration.\n"); rsxx_load_config()
182 initialize_config(&card->config); rsxx_load_config()
183 st = rsxx_save_config(card); rsxx_load_config()
188 card->config_valid = 1; rsxx_load_config()
190 dev_dbg(CARD_TO_DEV(card), "version: x%08x\n", rsxx_load_config()
191 card->config.hdr.version); rsxx_load_config()
192 dev_dbg(CARD_TO_DEV(card), "crc: x%08x\n", rsxx_load_config()
193 card->config.hdr.crc); rsxx_load_config()
194 dev_dbg(CARD_TO_DEV(card), "block_size: x%08x\n", rsxx_load_config()
195 card->config.data.block_size); rsxx_load_config()
196 dev_dbg(CARD_TO_DEV(card), "stripe_size: x%08x\n", rsxx_load_config()
197 card->config.data.stripe_size); rsxx_load_config()
198 dev_dbg(CARD_TO_DEV(card), "vendor_id: x%08x\n", rsxx_load_config()
199 card->config.data.vendor_id); rsxx_load_config()
200 dev_dbg(CARD_TO_DEV(card), "cache_order: x%08x\n", rsxx_load_config()
201 card->config.data.cache_order); rsxx_load_config()
202 dev_dbg(CARD_TO_DEV(card), "mode: x%08x\n", rsxx_load_config()
203 card->config.data.intr_coal.mode); rsxx_load_config()
204 dev_dbg(CARD_TO_DEV(card), "count: x%08x\n", rsxx_load_config()
205 card->config.data.intr_coal.count); rsxx_load_config()
206 dev_dbg(CARD_TO_DEV(card), "latency: x%08x\n", rsxx_load_config()
207 card->config.data.intr_coal.latency); rsxx_load_config()
H A Ddma.c102 static unsigned int rsxx_addr8_to_laddr(u64 addr8, struct rsxx_cardinfo *card) rsxx_addr8_to_laddr() argument
106 tgt_addr8 = ((addr8 >> card->_stripe.upper_shift) & rsxx_addr8_to_laddr()
107 card->_stripe.upper_mask) | rsxx_addr8_to_laddr()
108 ((addr8) & card->_stripe.lower_mask); rsxx_addr8_to_laddr()
113 static unsigned int rsxx_get_dma_tgt(struct rsxx_cardinfo *card, u64 addr8) rsxx_get_dma_tgt() argument
117 tgt = (addr8 >> card->_stripe.target_shift) & card->_stripe.target_mask; rsxx_get_dma_tgt()
122 void rsxx_dma_queue_reset(struct rsxx_cardinfo *card) rsxx_dma_queue_reset() argument
125 iowrite32(DMA_QUEUE_RESET, card->regmap + RESET); rsxx_dma_queue_reset()
204 static void dma_intr_coal_auto_tune(struct rsxx_cardinfo *card) dma_intr_coal_auto_tune() argument
210 if (card->config.data.intr_coal.mode != RSXX_INTR_COAL_AUTO_TUNE || dma_intr_coal_auto_tune()
211 unlikely(card->eeh_state)) dma_intr_coal_auto_tune()
214 for (i = 0; i < card->n_targets; i++) dma_intr_coal_auto_tune()
215 q_depth += atomic_read(&card->ctrl[i].stats.hw_q_depth); dma_intr_coal_auto_tune()
217 intr_coal = dma_intr_coal_val(card->config.data.intr_coal.mode, dma_intr_coal_auto_tune()
219 card->config.data.intr_coal.latency); dma_intr_coal_auto_tune()
220 iowrite32(intr_coal, card->regmap + INTR_COAL); dma_intr_coal_auto_tune()
227 if (!pci_dma_mapping_error(ctrl->card->dev, dma->dma_addr)) { rsxx_free_dma()
228 pci_unmap_page(ctrl->card->dev, dma->dma_addr, rsxx_free_dma()
251 dma->cb(ctrl->card, dma->cb_data, status ? 1 : 0); rsxx_complete_dma()
295 dev_dbg(CARD_TO_DEV(ctrl->card), rsxx_handle_dma_error()
309 if (ctrl->card->scrub_hard) { rsxx_handle_dma_error()
342 dev_err(CARD_TO_DEV(ctrl->card), rsxx_handle_dma_error()
363 unlikely(ctrl->card->eeh_state)) dma_engine_stalled()
371 dev_warn(CARD_TO_DEV(ctrl->card), dma_engine_stalled()
377 dev_warn(CARD_TO_DEV(ctrl->card), dma_engine_stalled()
380 ctrl->card->dma_fault = 1; dma_engine_stalled()
390 dev_info(CARD_TO_DEV(ctrl->card), dma_engine_stalled()
406 if (unlikely(ctrl->card->halt) || rsxx_issue_dmas()
407 unlikely(ctrl->card->eeh_state)) rsxx_issue_dmas()
433 if (unlikely(ctrl->card->dma_fault)) { rsxx_issue_dmas()
455 dma->dma_addr = pci_map_page(ctrl->card->dev, dma->page, rsxx_issue_dmas()
457 if (pci_dma_mapping_error(ctrl->card->dev, dma->dma_addr)) { rsxx_issue_dmas()
478 dev_dbg(CARD_TO_DEV(ctrl->card), rsxx_issue_dmas()
499 if (unlikely(ctrl->card->eeh_state)) { rsxx_issue_dmas()
519 if (unlikely(ctrl->card->halt) || rsxx_dma_done()
520 unlikely(ctrl->card->dma_fault) || rsxx_dma_done()
521 unlikely(ctrl->card->eeh_state)) rsxx_dma_done()
541 spin_lock_irqsave(&ctrl->card->irq_lock, flags); rsxx_dma_done()
542 rsxx_disable_ier(ctrl->card, CR_INTR_DMA_ALL); rsxx_dma_done()
543 spin_unlock_irqrestore(&ctrl->card->irq_lock, flags); rsxx_dma_done()
545 dev_err(CARD_TO_DEV(ctrl->card), rsxx_dma_done()
552 dev_dbg(CARD_TO_DEV(ctrl->card), rsxx_dma_done()
577 dma_intr_coal_auto_tune(ctrl->card); rsxx_dma_done()
582 spin_lock_irqsave(&ctrl->card->irq_lock, flags); rsxx_dma_done()
583 rsxx_enable_ier(ctrl->card, CR_INTR_DMA(ctrl->id)); rsxx_dma_done()
584 spin_unlock_irqrestore(&ctrl->card->irq_lock, flags); rsxx_dma_done()
614 static int rsxx_queue_discard(struct rsxx_cardinfo *card, rsxx_queue_discard() argument
636 dev_dbg(CARD_TO_DEV(card), "Queuing[D] laddr %x\n", dma->laddr); rsxx_queue_discard()
643 static int rsxx_queue_dma(struct rsxx_cardinfo *card, rsxx_queue_dma() argument
669 dev_dbg(CARD_TO_DEV(card), rsxx_queue_dma()
680 int rsxx_dma_queue_bio(struct rsxx_cardinfo *card, rsxx_dma_queue_bio() argument
703 for (i = 0; i < card->n_targets; i++) { rsxx_dma_queue_bio()
712 tgt = rsxx_get_dma_tgt(card, addr8); rsxx_dma_queue_bio()
713 laddr = rsxx_addr8_to_laddr(addr8, card); rsxx_dma_queue_bio()
715 st = rsxx_queue_discard(card, &dma_list[tgt], laddr, rsxx_dma_queue_bio()
731 tgt = rsxx_get_dma_tgt(card, addr8); bio_for_each_segment()
732 laddr = rsxx_addr8_to_laddr(addr8, card); bio_for_each_segment()
737 st = rsxx_queue_dma(card, &dma_list[tgt], bio_for_each_segment()
754 for (i = 0; i < card->n_targets; i++) {
756 spin_lock_bh(&card->ctrl[i].queue_lock);
757 card->ctrl[i].stats.sw_q_depth += dma_cnt[i];
758 list_splice_tail(&dma_list[i], &card->ctrl[i].queue);
759 spin_unlock_bh(&card->ctrl[i].queue_lock);
761 queue_work(card->ctrl[i].issue_wq,
762 &card->ctrl[i].issue_dma_work);
769 for (i = 0; i < card->n_targets; i++)
770 rsxx_cleanup_dma_queue(&card->ctrl[i], &dma_list[i],
863 static int rsxx_dma_stripe_setup(struct rsxx_cardinfo *card, rsxx_dma_stripe_setup() argument
867 dev_err(CARD_TO_DEV(card), rsxx_dma_stripe_setup()
872 card->_stripe.lower_mask = stripe_size8 - 1; rsxx_dma_stripe_setup()
874 card->_stripe.upper_mask = ~(card->_stripe.lower_mask); rsxx_dma_stripe_setup()
875 card->_stripe.upper_shift = ffs(card->n_targets) - 1; rsxx_dma_stripe_setup()
877 card->_stripe.target_mask = card->n_targets - 1; rsxx_dma_stripe_setup()
878 card->_stripe.target_shift = ffs(stripe_size8) - 1; rsxx_dma_stripe_setup()
880 dev_dbg(CARD_TO_DEV(card), "_stripe.lower_mask = x%016llx\n", rsxx_dma_stripe_setup()
881 card->_stripe.lower_mask); rsxx_dma_stripe_setup()
882 dev_dbg(CARD_TO_DEV(card), "_stripe.upper_shift = x%016llx\n", rsxx_dma_stripe_setup()
883 card->_stripe.upper_shift); rsxx_dma_stripe_setup()
884 dev_dbg(CARD_TO_DEV(card), "_stripe.upper_mask = x%016llx\n", rsxx_dma_stripe_setup()
885 card->_stripe.upper_mask); rsxx_dma_stripe_setup()
886 dev_dbg(CARD_TO_DEV(card), "_stripe.target_mask = x%016llx\n", rsxx_dma_stripe_setup()
887 card->_stripe.target_mask); rsxx_dma_stripe_setup()
888 dev_dbg(CARD_TO_DEV(card), "_stripe.target_shift = x%016llx\n", rsxx_dma_stripe_setup()
889 card->_stripe.target_shift); rsxx_dma_stripe_setup()
894 int rsxx_dma_configure(struct rsxx_cardinfo *card) rsxx_dma_configure() argument
898 intr_coal = dma_intr_coal_val(card->config.data.intr_coal.mode, rsxx_dma_configure()
899 card->config.data.intr_coal.count, rsxx_dma_configure()
900 card->config.data.intr_coal.latency); rsxx_dma_configure()
901 iowrite32(intr_coal, card->regmap + INTR_COAL); rsxx_dma_configure()
903 return rsxx_dma_stripe_setup(card, card->config.data.stripe_size); rsxx_dma_configure()
906 int rsxx_dma_setup(struct rsxx_cardinfo *card) rsxx_dma_setup() argument
912 dev_info(CARD_TO_DEV(card), rsxx_dma_setup()
914 card->n_targets); rsxx_dma_setup()
917 for (i = 0; i < card->n_targets; i++) rsxx_dma_setup()
918 card->ctrl[i].regmap = card->regmap + (i * 4096); rsxx_dma_setup()
920 card->dma_fault = 0; rsxx_dma_setup()
923 rsxx_dma_queue_reset(card); rsxx_dma_setup()
926 for (i = 0; i < card->n_targets; i++) { rsxx_dma_setup()
927 st = rsxx_dma_ctrl_init(card->dev, &card->ctrl[i]); rsxx_dma_setup()
931 card->ctrl[i].card = card; rsxx_dma_setup()
932 card->ctrl[i].id = i; rsxx_dma_setup()
935 card->scrub_hard = 1; rsxx_dma_setup()
937 if (card->config_valid) rsxx_dma_setup()
938 rsxx_dma_configure(card); rsxx_dma_setup()
941 for (i = 0; i < card->n_targets; i++) { rsxx_dma_setup()
942 spin_lock_irqsave(&card->irq_lock, flags); rsxx_dma_setup()
943 rsxx_enable_ier_and_isr(card, CR_INTR_DMA(i)); rsxx_dma_setup()
944 spin_unlock_irqrestore(&card->irq_lock, flags); rsxx_dma_setup()
950 for (i = 0; i < card->n_targets; i++) { rsxx_dma_setup()
951 struct rsxx_dma_ctrl *ctrl = &card->ctrl[i]; rsxx_dma_setup()
967 pci_free_consistent(card->dev, STATUS_BUFFER_SIZE8, rsxx_dma_setup()
971 pci_free_consistent(card->dev, COMMAND_BUFFER_SIZE8, rsxx_dma_setup()
998 void rsxx_dma_destroy(struct rsxx_cardinfo *card) rsxx_dma_destroy() argument
1003 for (i = 0; i < card->n_targets; i++) { rsxx_dma_destroy()
1004 ctrl = &card->ctrl[i]; rsxx_dma_destroy()
1028 pci_free_consistent(card->dev, STATUS_BUFFER_SIZE8, rsxx_dma_destroy()
1030 pci_free_consistent(card->dev, COMMAND_BUFFER_SIZE8, rsxx_dma_destroy()
1035 int rsxx_eeh_save_issued_dmas(struct rsxx_cardinfo *card) rsxx_eeh_save_issued_dmas() argument
1043 issued_dmas = kzalloc(sizeof(*issued_dmas) * card->n_targets, rsxx_eeh_save_issued_dmas()
1048 for (i = 0; i < card->n_targets; i++) { rsxx_eeh_save_issued_dmas()
1052 dma = get_tracker_dma(card->ctrl[i].trackers, j); rsxx_eeh_save_issued_dmas()
1057 card->ctrl[i].stats.writes_issued--; rsxx_eeh_save_issued_dmas()
1059 card->ctrl[i].stats.discards_issued--; rsxx_eeh_save_issued_dmas()
1061 card->ctrl[i].stats.reads_issued--; rsxx_eeh_save_issued_dmas()
1064 pci_unmap_page(card->dev, dma->dma_addr, rsxx_eeh_save_issued_dmas()
1072 push_tracker(card->ctrl[i].trackers, j); rsxx_eeh_save_issued_dmas()
1076 spin_lock_bh(&card->ctrl[i].queue_lock); rsxx_eeh_save_issued_dmas()
1077 list_splice(&issued_dmas[i], &card->ctrl[i].queue); rsxx_eeh_save_issued_dmas()
1079 atomic_sub(cnt, &card->ctrl[i].stats.hw_q_depth); rsxx_eeh_save_issued_dmas()
1080 card->ctrl[i].stats.sw_q_depth += cnt; rsxx_eeh_save_issued_dmas()
1081 card->ctrl[i].e_cnt = 0; rsxx_eeh_save_issued_dmas()
1082 spin_unlock_bh(&card->ctrl[i].queue_lock); rsxx_eeh_save_issued_dmas()
H A Drsxx_priv.h103 struct rsxx_cardinfo *card; member in struct:rsxx_dma_ctrl
362 int rsxx_load_config(struct rsxx_cardinfo *card);
365 void rsxx_enable_ier(struct rsxx_cardinfo *card, unsigned int intr);
366 void rsxx_disable_ier(struct rsxx_cardinfo *card, unsigned int intr);
367 void rsxx_enable_ier_and_isr(struct rsxx_cardinfo *card,
369 void rsxx_disable_ier_and_isr(struct rsxx_cardinfo *card,
373 int rsxx_attach_dev(struct rsxx_cardinfo *card);
374 void rsxx_detach_dev(struct rsxx_cardinfo *card);
375 int rsxx_setup_dev(struct rsxx_cardinfo *card);
376 void rsxx_destroy_dev(struct rsxx_cardinfo *card);
381 typedef void (*rsxx_dma_cb)(struct rsxx_cardinfo *card,
384 int rsxx_dma_setup(struct rsxx_cardinfo *card);
385 void rsxx_dma_destroy(struct rsxx_cardinfo *card);
392 void rsxx_dma_queue_reset(struct rsxx_cardinfo *card);
393 int rsxx_dma_configure(struct rsxx_cardinfo *card);
394 int rsxx_dma_queue_bio(struct rsxx_cardinfo *card,
400 int rsxx_eeh_save_issued_dmas(struct rsxx_cardinfo *card);
401 int rsxx_eeh_remap_dmas(struct rsxx_cardinfo *card);
404 int rsxx_creg_write(struct rsxx_cardinfo *card, u32 addr,
408 int rsxx_creg_read(struct rsxx_cardinfo *card,
413 int rsxx_read_hw_log(struct rsxx_cardinfo *card);
414 int rsxx_get_card_state(struct rsxx_cardinfo *card,
416 int rsxx_get_card_size8(struct rsxx_cardinfo *card, u64 *size8);
417 int rsxx_get_num_targets(struct rsxx_cardinfo *card,
419 int rsxx_get_card_capabilities(struct rsxx_cardinfo *card,
421 int rsxx_issue_card_cmd(struct rsxx_cardinfo *card, u32 cmd);
422 int rsxx_creg_setup(struct rsxx_cardinfo *card);
423 void rsxx_creg_destroy(struct rsxx_cardinfo *card);
426 int rsxx_reg_access(struct rsxx_cardinfo *card,
429 void rsxx_eeh_save_issued_creg(struct rsxx_cardinfo *card);
430 void rsxx_kick_creg_queue(struct rsxx_cardinfo *card);
/linux-4.1.27/drivers/atm/
H A Didt77252.c161 waitfor_idle(struct idt77252_dev *card) waitfor_idle() argument
171 read_sram(struct idt77252_dev *card, unsigned long addr) read_sram() argument
176 spin_lock_irqsave(&card->cmd_lock, flags); read_sram()
178 waitfor_idle(card); read_sram()
180 spin_unlock_irqrestore(&card->cmd_lock, flags); read_sram()
185 write_sram(struct idt77252_dev *card, unsigned long addr, u32 value) write_sram() argument
190 (((addr > card->tst[0] + card->tst_size - 2) && write_sram()
191 (addr < card->tst[0] + card->tst_size)) || write_sram()
192 ((addr > card->tst[1] + card->tst_size - 2) && write_sram()
193 (addr < card->tst[1] + card->tst_size)))) { write_sram()
195 card->name, addr, value); write_sram()
198 spin_lock_irqsave(&card->cmd_lock, flags); write_sram()
201 waitfor_idle(card); write_sram()
202 spin_unlock_irqrestore(&card->cmd_lock, flags); write_sram()
208 struct idt77252_dev *card = dev; read_utility() local
212 if (!card) { read_utility()
217 spin_lock_irqsave(&card->cmd_lock, flags); read_utility()
219 waitfor_idle(card); read_utility()
221 spin_unlock_irqrestore(&card->cmd_lock, flags); read_utility()
228 struct idt77252_dev *card = dev; write_utility() local
231 if (!card) { write_utility()
236 spin_lock_irqsave(&card->cmd_lock, flags); write_utility()
239 waitfor_idle(card); write_utility()
240 spin_unlock_irqrestore(&card->cmd_lock, flags); write_utility()
350 idt77252_read_gp(struct idt77252_dev *card) idt77252_read_gp() argument
362 idt77252_write_gp(struct idt77252_dev *card, u32 value) idt77252_write_gp() argument
372 spin_lock_irqsave(&card->cmd_lock, flags); idt77252_write_gp()
373 waitfor_idle(card); idt77252_write_gp()
375 spin_unlock_irqrestore(&card->cmd_lock, flags); idt77252_write_gp()
379 idt77252_eeprom_read_status(struct idt77252_dev *card) idt77252_eeprom_read_status() argument
385 gp = idt77252_read_gp(card) & ~(SAR_GP_EESCLK|SAR_GP_EECS|SAR_GP_EEDO); idt77252_eeprom_read_status()
388 idt77252_write_gp(card, gp | rdsrtab[i]); idt77252_eeprom_read_status()
391 idt77252_write_gp(card, gp | SAR_GP_EECS); idt77252_eeprom_read_status()
398 idt77252_write_gp(card, gp | clktab[j++]); idt77252_eeprom_read_status()
401 byte |= idt77252_read_gp(card) & SAR_GP_EEDI ? 1 : 0; idt77252_eeprom_read_status()
403 idt77252_write_gp(card, gp | clktab[j++]); idt77252_eeprom_read_status()
406 idt77252_write_gp(card, gp | SAR_GP_EECS); idt77252_eeprom_read_status()
413 idt77252_eeprom_read_byte(struct idt77252_dev *card, u8 offset) idt77252_eeprom_read_byte() argument
419 gp = idt77252_read_gp(card) & ~(SAR_GP_EESCLK|SAR_GP_EECS|SAR_GP_EEDO); idt77252_eeprom_read_byte()
422 idt77252_write_gp(card, gp | rdtab[i]); idt77252_eeprom_read_byte()
425 idt77252_write_gp(card, gp | SAR_GP_EECS); idt77252_eeprom_read_byte()
429 idt77252_write_gp(card, gp | clktab[j++] | idt77252_eeprom_read_byte()
433 idt77252_write_gp(card, gp | clktab[j++] | idt77252_eeprom_read_byte()
439 idt77252_write_gp(card, gp | SAR_GP_EECS); idt77252_eeprom_read_byte()
446 idt77252_write_gp(card, gp | clktab[j++]); idt77252_eeprom_read_byte()
449 byte |= idt77252_read_gp(card) & SAR_GP_EEDI ? 1 : 0; idt77252_eeprom_read_byte()
451 idt77252_write_gp(card, gp | clktab[j++]); idt77252_eeprom_read_byte()
454 idt77252_write_gp(card, gp | SAR_GP_EECS); idt77252_eeprom_read_byte()
461 idt77252_eeprom_write_byte(struct idt77252_dev *card, u8 offset, u8 data) idt77252_eeprom_write_byte() argument
466 gp = idt77252_read_gp(card) & ~(SAR_GP_EESCLK|SAR_GP_EECS|SAR_GP_EEDO); idt77252_eeprom_write_byte()
469 idt77252_write_gp(card, gp | wrentab[i]); idt77252_eeprom_write_byte()
472 idt77252_write_gp(card, gp | SAR_GP_EECS); idt77252_eeprom_write_byte()
476 idt77252_write_gp(card, gp | wrtab[i]); idt77252_eeprom_write_byte()
479 idt77252_write_gp(card, gp | SAR_GP_EECS); idt77252_eeprom_write_byte()
483 idt77252_write_gp(card, gp | clktab[j++] | idt77252_eeprom_write_byte()
487 idt77252_write_gp(card, gp | clktab[j++] | idt77252_eeprom_write_byte()
493 idt77252_write_gp(card, gp | SAR_GP_EECS); idt77252_eeprom_write_byte()
497 idt77252_write_gp(card, gp | clktab[j++] | idt77252_eeprom_write_byte()
501 idt77252_write_gp(card, gp | clktab[j++] | idt77252_eeprom_write_byte()
507 idt77252_write_gp(card, gp | SAR_GP_EECS); idt77252_eeprom_write_byte()
512 idt77252_eeprom_init(struct idt77252_dev *card) idt77252_eeprom_init() argument
516 gp = idt77252_read_gp(card) & ~(SAR_GP_EESCLK|SAR_GP_EECS|SAR_GP_EEDO); idt77252_eeprom_init()
518 idt77252_write_gp(card, gp | SAR_GP_EECS | SAR_GP_EESCLK); idt77252_eeprom_init()
520 idt77252_write_gp(card, gp | SAR_GP_EECS); idt77252_eeprom_init()
522 idt77252_write_gp(card, gp | SAR_GP_EECS | SAR_GP_EESCLK); idt77252_eeprom_init()
524 idt77252_write_gp(card, gp | SAR_GP_EECS); idt77252_eeprom_init()
532 dump_tct(struct idt77252_dev *card, int index) dump_tct() argument
537 tct = (unsigned long) (card->tct_base + index * SAR_SRAM_TCT_SIZE); dump_tct()
539 printk("%s: TCT %x:", card->name, index); dump_tct()
541 printk(" %08x", read_sram(card, tct + i)); dump_tct()
547 idt77252_tx_dump(struct idt77252_dev *card) idt77252_tx_dump() argument
554 for (i = 0; i < card->tct_size; i++) { idt77252_tx_dump()
555 vc = card->vcs[i]; idt77252_tx_dump()
568 printk("%s: Connection %d:\n", card->name, vc->index); idt77252_tx_dump()
569 dump_tct(card, vc->index); idt77252_tx_dump()
582 sb_pool_add(struct idt77252_dev *card, struct sk_buff *skb, int queue) sb_pool_add() argument
584 struct sb_pool *pool = &card->sbpool[queue]; sb_pool_add()
602 sb_pool_remove(struct idt77252_dev *card, struct sk_buff *skb) sb_pool_remove() argument
617 card->sbpool[queue].skb[index] = NULL; sb_pool_remove()
621 sb_pool_skb(struct idt77252_dev *card, u32 handle) sb_pool_skb() argument
633 return card->sbpool[queue].skb[index]; sb_pool_skb()
637 alloc_scq(struct idt77252_dev *card, int class) alloc_scq() argument
644 scq->base = dma_zalloc_coherent(&card->pcidev->dev, SCQ_SIZE, alloc_scq()
668 free_scq(struct idt77252_dev *card, struct scq_info *scq) free_scq() argument
673 dma_free_coherent(&card->pcidev->dev, SCQ_SIZE, free_scq()
677 dma_unmap_single(&card->pcidev->dev, IDT77252_PRV_PADDR(skb), free_scq()
688 dma_unmap_single(&card->pcidev->dev, IDT77252_PRV_PADDR(skb), free_scq()
703 push_on_scq(struct idt77252_dev *card, struct vc_map *vc, struct sk_buff *skb) push_on_scq() argument
710 TXPRINTK("%s: SCQ: next 0x%p\n", card->name, scq->next); push_on_scq()
756 write_sram(card, scq->scd, push_on_scq()
771 card->name, atomic_read(&scq->used), push_on_scq()
772 read_sram(card, scq->scd + 1), scq->next); push_on_scq()
779 card->name, vc->tx_vcc->vpi, vc->tx_vcc->vci); push_on_scq()
781 idt77252_tx_dump(card); push_on_scq()
791 drain_scq(struct idt77252_dev *card, struct vc_map *vc) drain_scq() argument
798 card->name, atomic_read(&scq->used), scq->next); drain_scq()
802 TXPRINTK("%s: freeing skb at %p.\n", card->name, skb); drain_scq()
804 dma_unmap_single(&card->pcidev->dev, IDT77252_PRV_PADDR(skb), drain_scq()
821 if (push_on_scq(card, vc, skb)) { drain_scq()
830 queue_skb(struct idt77252_dev *card, struct vc_map *vc, queue_skb() argument
840 printk("%s: invalid skb->len (%d)\n", card->name, skb->len); queue_skb()
845 card->name, skb->len); queue_skb()
850 IDT77252_PRV_PADDR(skb) = dma_map_single(&card->pcidev->dev, skb->data, queue_skb()
866 vc = card->vcs[0]; queue_skb()
872 printk("%s: Trying to transmit on reserved VC\n", card->name); queue_skb()
908 printk("%s: Traffic type not supported.\n", card->name); queue_skb()
918 if (push_on_scq(card, vc, skb)) { queue_skb()
928 dma_unmap_single(&card->pcidev->dev, IDT77252_PRV_PADDR(skb), queue_skb()
934 get_free_scd(struct idt77252_dev *card, struct vc_map *vc) get_free_scd() argument
938 for (i = 0; i < card->scd_size; i++) { get_free_scd()
939 if (!card->scd2vc[i]) { get_free_scd()
940 card->scd2vc[i] = vc; get_free_scd()
942 return card->scd_base + i * SAR_SRAM_SCD_SIZE; get_free_scd()
949 fill_scd(struct idt77252_dev *card, struct scq_info *scq, int class) fill_scd() argument
951 write_sram(card, scq->scd, scq->paddr); fill_scd()
952 write_sram(card, scq->scd + 1, 0x00000000); fill_scd()
953 write_sram(card, scq->scd + 2, 0xffffffff); fill_scd()
954 write_sram(card, scq->scd + 3, 0x00000000); fill_scd()
958 clear_scd(struct idt77252_dev *card, struct scq_info *scq, int class) clear_scd() argument
970 init_rsq(struct idt77252_dev *card) init_rsq() argument
974 card->rsq.base = dma_zalloc_coherent(&card->pcidev->dev, RSQSIZE, init_rsq()
975 &card->rsq.paddr, GFP_KERNEL); init_rsq()
976 if (card->rsq.base == NULL) { init_rsq()
977 printk("%s: can't allocate RSQ.\n", card->name); init_rsq()
981 card->rsq.last = card->rsq.base + RSQ_NUM_ENTRIES - 1; init_rsq()
982 card->rsq.next = card->rsq.last; init_rsq()
983 for (rsqe = card->rsq.base; rsqe <= card->rsq.last; rsqe++) init_rsq()
986 writel((unsigned long) card->rsq.last - (unsigned long) card->rsq.base, init_rsq()
988 writel(card->rsq.paddr, SAR_REG_RSQB); init_rsq()
990 IPRINTK("%s: RSQ base at 0x%lx (0x%x).\n", card->name, init_rsq()
991 (unsigned long) card->rsq.base, init_rsq()
994 card->name, init_rsq()
1003 deinit_rsq(struct idt77252_dev *card) deinit_rsq() argument
1005 dma_free_coherent(&card->pcidev->dev, RSQSIZE, deinit_rsq()
1006 card->rsq.base, card->rsq.paddr); deinit_rsq()
1010 dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe) dequeue_rx() argument
1024 card->name); dequeue_rx()
1028 skb = sb_pool_skb(card, le32_to_cpu(rsqe->word_2)); dequeue_rx()
1031 card->name, __func__, dequeue_rx()
1042 card->name, vpi, vci, skb, skb->data); dequeue_rx()
1044 if ((vpi >= (1 << card->vpibits)) || (vci != (vci & card->vcimask))) { dequeue_rx()
1046 card->name, vpi, vci); dequeue_rx()
1047 recycle_rx_skb(card, skb); dequeue_rx()
1051 vc = card->vcs[VPCI2VC(card, vpi, vci)]; dequeue_rx()
1054 card->name, vpi, vci); dequeue_rx()
1055 recycle_rx_skb(card, skb); dequeue_rx()
1061 dma_sync_single_for_cpu(&card->pcidev->dev, IDT77252_PRV_PADDR(skb), dequeue_rx()
1075 card->name); dequeue_rx()
1081 card->name); dequeue_rx()
1104 recycle_rx_skb(card, skb); dequeue_rx()
1109 card->name, vcc->qos.aal); dequeue_rx()
1110 recycle_rx_skb(card, skb); dequeue_rx()
1129 RXPRINTK("%s: PDU has %d bytes.\n", card->name, len); dequeue_rx()
1134 card->name, len, rpp->len, readl(SAR_REG_CDC)); dequeue_rx()
1135 recycle_rx_pool_skb(card, rpp); dequeue_rx()
1140 RXPRINTK("%s: AAL5 CRC error.\n", card->name); dequeue_rx()
1141 recycle_rx_pool_skb(card, rpp); dequeue_rx()
1151 card->name); dequeue_rx()
1152 recycle_rx_pool_skb(card, rpp); dequeue_rx()
1157 recycle_rx_pool_skb(card, rpp); dequeue_rx()
1165 recycle_rx_pool_skb(card, rpp); dequeue_rx()
1177 flush_rx_pool(card, rpp); dequeue_rx()
1180 recycle_rx_skb(card, skb); dequeue_rx()
1184 dma_unmap_single(&card->pcidev->dev, IDT77252_PRV_PADDR(skb), dequeue_rx()
1187 sb_pool_remove(card, skb); dequeue_rx()
1197 add_rx_skb(card, 3, SAR_FB_SIZE_3, 1); dequeue_rx()
1199 add_rx_skb(card, 2, SAR_FB_SIZE_2, 1); dequeue_rx()
1201 add_rx_skb(card, 1, SAR_FB_SIZE_1, 1); dequeue_rx()
1203 add_rx_skb(card, 0, SAR_FB_SIZE_0, 1); dequeue_rx()
1209 idt77252_rx(struct idt77252_dev *card) idt77252_rx() argument
1213 if (card->rsq.next == card->rsq.last) idt77252_rx()
1214 rsqe = card->rsq.base; idt77252_rx()
1216 rsqe = card->rsq.next + 1; idt77252_rx()
1219 RXPRINTK("%s: no entry in RSQ.\n", card->name); idt77252_rx()
1224 dequeue_rx(card, rsqe); idt77252_rx()
1226 card->rsq.next = rsqe; idt77252_rx()
1227 if (card->rsq.next == card->rsq.last) idt77252_rx()
1228 rsqe = card->rsq.base; idt77252_rx()
1230 rsqe = card->rsq.next + 1; idt77252_rx()
1233 writel((unsigned long) card->rsq.next - (unsigned long) card->rsq.base, idt77252_rx()
1238 idt77252_rx_raw(struct idt77252_dev *card) idt77252_rx_raw() argument
1246 if (card->raw_cell_head == NULL) { idt77252_rx_raw()
1247 u32 handle = le32_to_cpu(*(card->raw_cell_hnd + 1)); idt77252_rx_raw()
1248 card->raw_cell_head = sb_pool_skb(card, handle); idt77252_rx_raw()
1251 queue = card->raw_cell_head; idt77252_rx_raw()
1258 dma_sync_single_for_cpu(&card->pcidev->dev, IDT77252_PRV_PADDR(queue), idt77252_rx_raw()
1276 card->name, (header >> 28) & 0x000f, idt77252_rx_raw()
1287 if (vpi >= (1<<card->vpibits) || vci >= (1<<card->vcibits)) { idt77252_rx_raw()
1289 card->name, vpi, vci); idt77252_rx_raw()
1293 vc = card->vcs[VPCI2VC(card, vpi, vci)]; idt77252_rx_raw()
1296 card->name, vpi, vci); idt77252_rx_raw()
1304 card->name, vpi, vci); idt77252_rx_raw()
1311 card->name); idt77252_rx_raw()
1318 card->name); idt77252_rx_raw()
1346 next = sb_pool_skb(card, handle); idt77252_rx_raw()
1347 recycle_rx_skb(card, queue); idt77252_rx_raw()
1350 card->raw_cell_head = next; idt77252_rx_raw()
1351 queue = card->raw_cell_head; idt77252_rx_raw()
1352 dma_sync_single_for_cpu(&card->pcidev->dev, idt77252_rx_raw()
1358 card->raw_cell_head = NULL; idt77252_rx_raw()
1360 card->name); idt77252_rx_raw()
1375 init_tsq(struct idt77252_dev *card) init_tsq() argument
1379 card->tsq.base = dma_alloc_coherent(&card->pcidev->dev, RSQSIZE, init_tsq()
1380 &card->tsq.paddr, GFP_KERNEL); init_tsq()
1381 if (card->tsq.base == NULL) { init_tsq()
1382 printk("%s: can't allocate TSQ.\n", card->name); init_tsq()
1385 memset(card->tsq.base, 0, TSQSIZE); init_tsq()
1387 card->tsq.last = card->tsq.base + TSQ_NUM_ENTRIES - 1; init_tsq()
1388 card->tsq.next = card->tsq.last; init_tsq()
1389 for (tsqe = card->tsq.base; tsqe <= card->tsq.last; tsqe++) init_tsq()
1392 writel(card->tsq.paddr, SAR_REG_TSQB); init_tsq()
1393 writel((unsigned long) card->tsq.next - (unsigned long) card->tsq.base, init_tsq()
1400 deinit_tsq(struct idt77252_dev *card) deinit_tsq() argument
1402 dma_free_coherent(&card->pcidev->dev, TSQSIZE, deinit_tsq()
1403 card->tsq.base, card->tsq.paddr); deinit_tsq()
1407 idt77252_tx(struct idt77252_dev *card) idt77252_tx() argument
1414 if (card->tsq.next == card->tsq.last) idt77252_tx()
1415 tsqe = card->tsq.base; idt77252_tx()
1417 tsqe = card->tsq.next + 1; idt77252_tx()
1420 card->tsq.base, card->tsq.next, card->tsq.last); idt77252_tx()
1438 TXPRINTK("%s: Timer RollOver detected.\n", card->name); idt77252_tx()
1448 card->name, idt77252_tx()
1454 vc = card->vcs[conn & 0x1fff]; idt77252_tx()
1457 card->name, conn & 0x1fff); idt77252_tx()
1462 card->name, vc->index); idt77252_tx()
1471 vc = card->vcs[conn & 0x1fff]; idt77252_tx()
1474 card->name, idt77252_tx()
1479 drain_scq(card, vc); idt77252_tx()
1489 if (vpi >= (1 << card->vpibits) || idt77252_tx()
1490 vci >= (1 << card->vcibits)) { idt77252_tx()
1493 card->name, vpi, vci); idt77252_tx()
1497 vc = card->vcs[VPCI2VC(card, vpi, vci)]; idt77252_tx()
1501 card->name, vpi, vci); idt77252_tx()
1505 drain_scq(card, vc); idt77252_tx()
1511 card->tsq.next = tsqe; idt77252_tx()
1512 if (card->tsq.next == card->tsq.last) idt77252_tx()
1513 tsqe = card->tsq.base; idt77252_tx()
1515 tsqe = card->tsq.next + 1; idt77252_tx()
1518 card->tsq.base, card->tsq.next, card->tsq.last); idt77252_tx()
1524 writel((unsigned long)card->tsq.next - (unsigned long)card->tsq.base, idt77252_tx()
1528 card->index, readl(SAR_REG_TSQH), idt77252_tx()
1529 readl(SAR_REG_TSQT), card->tsq.next); idt77252_tx()
1536 struct idt77252_dev *card = (struct idt77252_dev *)data; tst_timer() local
1542 spin_lock_irqsave(&card->tst_lock, flags); tst_timer()
1544 base = card->tst[card->tst_index]; tst_timer()
1545 idle = card->tst[card->tst_index ^ 1]; tst_timer()
1547 if (test_bit(TST_SWITCH_WAIT, &card->tst_state)) { tst_timer()
1548 jump = base + card->tst_size - 2; tst_timer()
1551 if ((pc ^ idle) & ~(card->tst_size - 1)) { tst_timer()
1552 mod_timer(&card->tst_timer, jiffies + 1); tst_timer()
1556 clear_bit(TST_SWITCH_WAIT, &card->tst_state); tst_timer()
1558 card->tst_index ^= 1; tst_timer()
1559 write_sram(card, jump, TSTE_OPC_JMP | (base << 2)); tst_timer()
1561 base = card->tst[card->tst_index]; tst_timer()
1562 idle = card->tst[card->tst_index ^ 1]; tst_timer()
1564 for (e = 0; e < card->tst_size - 2; e++) { tst_timer()
1565 if (card->soft_tst[e].tste & TSTE_PUSH_IDLE) { tst_timer()
1566 write_sram(card, idle + e, tst_timer()
1567 card->soft_tst[e].tste & TSTE_MASK); tst_timer()
1568 card->soft_tst[e].tste &= ~(TSTE_PUSH_IDLE); tst_timer()
1573 if (test_and_clear_bit(TST_SWITCH_PENDING, &card->tst_state)) { tst_timer()
1575 for (e = 0; e < card->tst_size - 2; e++) { tst_timer()
1576 if (card->soft_tst[e].tste & TSTE_PUSH_ACTIVE) { tst_timer()
1577 write_sram(card, idle + e, tst_timer()
1578 card->soft_tst[e].tste & TSTE_MASK); tst_timer()
1579 card->soft_tst[e].tste &= ~(TSTE_PUSH_ACTIVE); tst_timer()
1580 card->soft_tst[e].tste |= TSTE_PUSH_IDLE; tst_timer()
1584 jump = base + card->tst_size - 2; tst_timer()
1586 write_sram(card, jump, TSTE_OPC_NULL); tst_timer()
1587 set_bit(TST_SWITCH_WAIT, &card->tst_state); tst_timer()
1589 mod_timer(&card->tst_timer, jiffies + 1); tst_timer()
1593 spin_unlock_irqrestore(&card->tst_lock, flags); tst_timer()
1597 __fill_tst(struct idt77252_dev *card, struct vc_map *vc, __fill_tst() argument
1605 avail = card->tst_size - 2; __fill_tst()
1607 if (card->soft_tst[e].vc == NULL) __fill_tst()
1611 printk("%s: No free TST entries found\n", card->name); __fill_tst()
1616 card->name, vc ? vc->index : -1, e); __fill_tst()
1624 idle = card->tst[card->tst_index ^ 1]; __fill_tst()
1630 if ((cl >= avail) && (card->soft_tst[e].vc == NULL)) { __fill_tst()
1632 card->soft_tst[e].vc = vc; __fill_tst()
1634 card->soft_tst[e].vc = (void *)-1; __fill_tst()
1636 card->soft_tst[e].tste = data; __fill_tst()
1637 if (timer_pending(&card->tst_timer)) __fill_tst()
1638 card->soft_tst[e].tste |= TSTE_PUSH_ACTIVE; __fill_tst()
1640 write_sram(card, idle + e, data); __fill_tst()
1641 card->soft_tst[e].tste |= TSTE_PUSH_IDLE; __fill_tst()
1644 cl -= card->tst_size; __fill_tst()
1657 fill_tst(struct idt77252_dev *card, struct vc_map *vc, int n, unsigned int opc) fill_tst() argument
1662 spin_lock_irqsave(&card->tst_lock, flags); fill_tst()
1664 res = __fill_tst(card, vc, n, opc); fill_tst()
1666 set_bit(TST_SWITCH_PENDING, &card->tst_state); fill_tst()
1667 if (!timer_pending(&card->tst_timer)) fill_tst()
1668 mod_timer(&card->tst_timer, jiffies + 1); fill_tst()
1670 spin_unlock_irqrestore(&card->tst_lock, flags); fill_tst()
1675 __clear_tst(struct idt77252_dev *card, struct vc_map *vc) __clear_tst() argument
1680 idle = card->tst[card->tst_index ^ 1]; __clear_tst()
1682 for (e = 0; e < card->tst_size - 2; e++) { __clear_tst()
1683 if (card->soft_tst[e].vc == vc) { __clear_tst()
1684 card->soft_tst[e].vc = NULL; __clear_tst()
1686 card->soft_tst[e].tste = TSTE_OPC_VAR; __clear_tst()
1687 if (timer_pending(&card->tst_timer)) __clear_tst()
1688 card->soft_tst[e].tste |= TSTE_PUSH_ACTIVE; __clear_tst()
1690 write_sram(card, idle + e, TSTE_OPC_VAR); __clear_tst()
1691 card->soft_tst[e].tste |= TSTE_PUSH_IDLE; __clear_tst()
1700 clear_tst(struct idt77252_dev *card, struct vc_map *vc) clear_tst() argument
1705 spin_lock_irqsave(&card->tst_lock, flags); clear_tst()
1707 res = __clear_tst(card, vc); clear_tst()
1709 set_bit(TST_SWITCH_PENDING, &card->tst_state); clear_tst()
1710 if (!timer_pending(&card->tst_timer)) clear_tst()
1711 mod_timer(&card->tst_timer, jiffies + 1); clear_tst()
1713 spin_unlock_irqrestore(&card->tst_lock, flags); clear_tst()
1718 change_tst(struct idt77252_dev *card, struct vc_map *vc, change_tst() argument
1724 spin_lock_irqsave(&card->tst_lock, flags); change_tst()
1726 __clear_tst(card, vc); change_tst()
1727 res = __fill_tst(card, vc, n, opc); change_tst()
1729 set_bit(TST_SWITCH_PENDING, &card->tst_state); change_tst()
1730 if (!timer_pending(&card->tst_timer)) change_tst()
1731 mod_timer(&card->tst_timer, jiffies + 1); change_tst()
1733 spin_unlock_irqrestore(&card->tst_lock, flags); change_tst()
1739 set_tct(struct idt77252_dev *card, struct vc_map *vc) set_tct() argument
1743 tct = (unsigned long) (card->tct_base + vc->index * SAR_SRAM_TCT_SIZE); set_tct()
1748 card->name, tct, vc->scq->scd); set_tct()
1750 write_sram(card, tct + 0, TCT_CBR | vc->scq->scd); set_tct()
1751 write_sram(card, tct + 1, 0); set_tct()
1752 write_sram(card, tct + 2, 0); set_tct()
1753 write_sram(card, tct + 3, 0); set_tct()
1754 write_sram(card, tct + 4, 0); set_tct()
1755 write_sram(card, tct + 5, 0); set_tct()
1756 write_sram(card, tct + 6, 0); set_tct()
1757 write_sram(card, tct + 7, 0); set_tct()
1762 card->name, tct, vc->scq->scd); set_tct()
1764 write_sram(card, tct + 0, TCT_UBR | vc->scq->scd); set_tct()
1765 write_sram(card, tct + 1, 0); set_tct()
1766 write_sram(card, tct + 2, TCT_TSIF); set_tct()
1767 write_sram(card, tct + 3, TCT_HALT | TCT_IDLE); set_tct()
1768 write_sram(card, tct + 4, 0); set_tct()
1769 write_sram(card, tct + 5, vc->init_er); set_tct()
1770 write_sram(card, tct + 6, 0); set_tct()
1771 write_sram(card, tct + 7, TCT_FLAG_UBR); set_tct()
1790 idt77252_fbq_level(struct idt77252_dev *card, int queue) idt77252_fbq_level() argument
1796 idt77252_fbq_full(struct idt77252_dev *card, int queue) idt77252_fbq_full() argument
1802 push_rx_skb(struct idt77252_dev *card, struct sk_buff *skb, int queue) push_rx_skb() argument
1831 if (idt77252_fbq_full(card, queue)) push_rx_skb()
1839 spin_lock_irqsave(&card->cmd_lock, flags); push_rx_skb()
1840 writel(handle, card->fbq[queue]); push_rx_skb()
1841 writel(addr, card->fbq[queue]); push_rx_skb()
1842 spin_unlock_irqrestore(&card->cmd_lock, flags); push_rx_skb()
1848 add_rx_skb(struct idt77252_dev *card, int queue, add_rx_skb() argument
1860 if (sb_pool_add(card, skb, queue)) { add_rx_skb()
1865 paddr = dma_map_single(&card->pcidev->dev, skb->data, add_rx_skb()
1870 if (push_rx_skb(card, skb, queue)) { add_rx_skb()
1879 dma_unmap_single(&card->pcidev->dev, IDT77252_PRV_PADDR(skb), add_rx_skb()
1883 card->sbpool[POOL_QUEUE(handle)].skb[POOL_INDEX(handle)] = NULL; add_rx_skb()
1891 recycle_rx_skb(struct idt77252_dev *card, struct sk_buff *skb) recycle_rx_skb() argument
1896 dma_sync_single_for_device(&card->pcidev->dev, IDT77252_PRV_PADDR(skb), recycle_rx_skb()
1900 err = push_rx_skb(card, skb, POOL_QUEUE(handle)); recycle_rx_skb()
1902 dma_unmap_single(&card->pcidev->dev, IDT77252_PRV_PADDR(skb), recycle_rx_skb()
1905 sb_pool_remove(card, skb); recycle_rx_skb()
1911 flush_rx_pool(struct idt77252_dev *card, struct rx_pool *rpp) flush_rx_pool() argument
1918 recycle_rx_pool_skb(struct idt77252_dev *card, struct rx_pool *rpp) recycle_rx_pool_skb() argument
1923 recycle_rx_skb(card, skb); recycle_rx_pool_skb()
1925 flush_rx_pool(card, rpp); recycle_rx_pool_skb()
1950 struct idt77252_dev *card = dev->dev_data; idt77252_send_skb() local
1955 printk("%s: NULL connection in send().\n", card->name); idt77252_send_skb()
1961 printk("%s: Trying to transmit on a non-tx VC.\n", card->name); idt77252_send_skb()
1973 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal); idt77252_send_skb()
1980 printk("%s: No scatter-gather yet.\n", card->name); idt77252_send_skb()
1987 err = queue_skb(card, vc, skb, oam); idt77252_send_skb()
2006 struct idt77252_dev *card = dev->dev_data; idt77252_send_oam() local
2011 printk("%s: Out of memory in send_oam().\n", card->name); idt77252_send_oam()
2068 idt77252_rate_logindex(struct idt77252_dev *card, int pcr) idt77252_rate_logindex() argument
2082 struct idt77252_dev *card = vc->card; idt77252_est_timer() local
2105 lacr = idt77252_rate_logindex(card, cps); idt77252_est_timer()
2146 idt77252_init_cbr(struct idt77252_dev *card, struct vc_map *vc, idt77252_init_cbr() argument
2156 card->name); idt77252_init_cbr()
2161 tst_free = card->tst_free; idt77252_init_cbr()
2169 TXPRINTK("%s: CBR target cell rate = %d\n", card->name, tcra); idt77252_init_cbr()
2171 tmpl = (unsigned long) tcra * ((unsigned long) card->tst_size - 2); idt77252_init_cbr()
2172 modl = tmpl % (unsigned long)card->utopia_pcr; idt77252_init_cbr()
2174 tst_entries = (int) (tmpl / card->utopia_pcr); idt77252_init_cbr()
2181 printk("%s: no CBR bandwidth free.\n", card->name); idt77252_init_cbr()
2188 card->name); idt77252_init_cbr()
2193 printk("%s: not enough CBR bandwidth free.\n", card->name); idt77252_init_cbr()
2199 card->tst_free = tst_free - tst_entries; idt77252_init_cbr()
2205 card->name, tst_used, tst_entries); idt77252_init_cbr()
2206 change_tst(card, vc, tst_entries, TSTE_OPC_CBR); idt77252_init_cbr()
2210 OPRINTK("%s: setting %d entries in TST.\n", card->name, tst_entries); idt77252_init_cbr()
2211 fill_tst(card, vc, tst_entries, TSTE_OPC_CBR); idt77252_init_cbr()
2216 idt77252_init_ubr(struct idt77252_dev *card, struct vc_map *vc, idt77252_init_ubr() argument
2232 tcr = card->link_pcr; idt77252_init_ubr()
2237 vc->init_er = idt77252_rate_logindex(card, tcr); idt77252_init_ubr()
2248 idt77252_init_tx(struct idt77252_dev *card, struct vc_map *vc, idt77252_init_tx() argument
2271 vc->scq = alloc_scq(card, vc->class); idt77252_init_tx()
2273 printk("%s: can't get SCQ.\n", card->name); idt77252_init_tx()
2277 vc->scq->scd = get_free_scd(card, vc); idt77252_init_tx()
2279 printk("%s: no SCD available.\n", card->name); idt77252_init_tx()
2280 free_scq(card, vc->scq); idt77252_init_tx()
2284 fill_scd(card, vc->scq, vc->class); idt77252_init_tx()
2286 if (set_tct(card, vc)) { idt77252_init_tx()
2288 card->name, qos->txtp.traffic_class); idt77252_init_tx()
2290 card->scd2vc[vc->scd_index] = NULL; idt77252_init_tx()
2291 free_scq(card, vc->scq); idt77252_init_tx()
2297 error = idt77252_init_cbr(card, vc, vcc, qos); idt77252_init_tx()
2299 card->scd2vc[vc->scd_index] = NULL; idt77252_init_tx()
2300 free_scq(card, vc->scq); idt77252_init_tx()
2309 error = idt77252_init_ubr(card, vc, vcc, qos); idt77252_init_tx()
2311 card->scd2vc[vc->scd_index] = NULL; idt77252_init_tx()
2312 free_scq(card, vc->scq); idt77252_init_tx()
2326 idt77252_init_rx(struct idt77252_dev *card, struct vc_map *vc, idt77252_init_rx() argument
2342 flush_rx_pool(card, &vc->rcv.rx_pool); idt77252_init_rx()
2376 addr = card->rct_base + (vc->index << 2); idt77252_init_rx()
2378 OPRINTK("%s: writing RCT at 0x%lx\n", card->name, addr); idt77252_init_rx()
2379 write_sram(card, addr, rcte); idt77252_init_rx()
2381 spin_lock_irqsave(&card->cmd_lock, flags); idt77252_init_rx()
2383 waitfor_idle(card); idt77252_init_rx()
2384 spin_unlock_irqrestore(&card->cmd_lock, flags); idt77252_init_rx()
2393 struct idt77252_dev *card = dev->dev_data; idt77252_open() local
2404 if (vpi >= (1 << card->vpibits)) { idt77252_open()
2405 printk("%s: unsupported VPI: %d\n", card->name, vpi); idt77252_open()
2409 if (vci >= (1 << card->vcibits)) { idt77252_open()
2410 printk("%s: unsupported VCI: %d\n", card->name, vci); idt77252_open()
2416 mutex_lock(&card->mutex); idt77252_open()
2418 OPRINTK("%s: opening vpi.vci: %d.%d\n", card->name, vpi, vci); idt77252_open()
2426 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal); idt77252_open()
2427 mutex_unlock(&card->mutex); idt77252_open()
2431 index = VPCI2VC(card, vpi, vci); idt77252_open()
2432 if (!card->vcs[index]) { idt77252_open()
2433 card->vcs[index] = kzalloc(sizeof(struct vc_map), GFP_KERNEL); idt77252_open()
2434 if (!card->vcs[index]) { idt77252_open()
2435 printk("%s: can't alloc vc in open()\n", card->name); idt77252_open()
2436 mutex_unlock(&card->mutex); idt77252_open()
2439 card->vcs[index]->card = card; idt77252_open()
2440 card->vcs[index]->index = index; idt77252_open()
2442 spin_lock_init(&card->vcs[index]->lock); idt77252_open()
2444 vc = card->vcs[index]; idt77252_open()
2449 card->name, vc->index, vcc->vpi, vcc->vci, idt77252_open()
2463 printk("%s: %s vci already in use.\n", card->name, idt77252_open()
2465 mutex_unlock(&card->mutex); idt77252_open()
2470 error = idt77252_init_tx(card, vc, vcc, &vcc->qos); idt77252_open()
2472 mutex_unlock(&card->mutex); idt77252_open()
2478 error = idt77252_init_rx(card, vc, vcc, &vcc->qos); idt77252_open()
2480 mutex_unlock(&card->mutex); idt77252_open()
2487 mutex_unlock(&card->mutex); idt77252_open()
2495 struct idt77252_dev *card = dev->dev_data; idt77252_close() local
2501 mutex_lock(&card->mutex); idt77252_close()
2504 card->name, vc->index, vcc->vpi, vcc->vci); idt77252_close()
2518 addr = card->rct_base + vc->index * SAR_SRAM_RCT_SIZE; idt77252_close()
2520 spin_lock_irqsave(&card->cmd_lock, flags); idt77252_close()
2522 waitfor_idle(card); idt77252_close()
2523 spin_unlock_irqrestore(&card->cmd_lock, flags); idt77252_close()
2527 card->name); idt77252_close()
2529 recycle_rx_pool_skb(card, &vc->rcv.rx_pool); idt77252_close()
2554 card->name, atomic_read(&vc->scq->used)); idt77252_close()
2560 clear_scd(card, vc->scq, vc->class); idt77252_close()
2563 clear_tst(card, vc); idt77252_close()
2564 card->tst_free += vc->ntste; idt77252_close()
2568 card->scd2vc[vc->scd_index] = NULL; idt77252_close()
2569 free_scq(card, vc->scq); idt77252_close()
2572 mutex_unlock(&card->mutex); idt77252_close()
2579 struct idt77252_dev *card = dev->dev_data; idt77252_change_qos() local
2583 mutex_lock(&card->mutex); idt77252_change_qos()
2587 error = idt77252_init_tx(card, vc, vcc, qos); idt77252_change_qos()
2593 error = idt77252_init_cbr(card, vc, vcc, qos); idt77252_change_qos()
2599 error = idt77252_init_ubr(card, vc, vcc, qos); idt77252_change_qos()
2619 error = idt77252_init_rx(card, vc, vcc, qos); idt77252_change_qos()
2629 mutex_unlock(&card->mutex); idt77252_change_qos()
2636 struct idt77252_dev *card = dev->dev_data; idt77252_proc_read() local
2643 return sprintf(page, "TSIF: %lu\n", card->irqstat[15]); idt77252_proc_read()
2645 return sprintf(page, "TXICP: %lu\n", card->irqstat[14]); idt77252_proc_read()
2647 return sprintf(page, "TSQF: %lu\n", card->irqstat[12]); idt77252_proc_read()
2649 return sprintf(page, "TMROF: %lu\n", card->irqstat[11]); idt77252_proc_read()
2651 return sprintf(page, "PHYI: %lu\n", card->irqstat[10]); idt77252_proc_read()
2653 return sprintf(page, "FBQ3A: %lu\n", card->irqstat[8]); idt77252_proc_read()
2655 return sprintf(page, "FBQ2A: %lu\n", card->irqstat[7]); idt77252_proc_read()
2657 return sprintf(page, "RSQF: %lu\n", card->irqstat[6]); idt77252_proc_read()
2659 return sprintf(page, "EPDU: %lu\n", card->irqstat[5]); idt77252_proc_read()
2661 return sprintf(page, "RAWCF: %lu\n", card->irqstat[4]); idt77252_proc_read()
2663 return sprintf(page, "FBQ1A: %lu\n", card->irqstat[3]); idt77252_proc_read()
2665 return sprintf(page, "FBQ0A: %lu\n", card->irqstat[2]); idt77252_proc_read()
2667 return sprintf(page, "RSQAF: %lu\n", card->irqstat[1]); idt77252_proc_read()
2671 for (i = 0; i < card->tct_size; i++) { idt77252_proc_read()
2677 vc = card->vcs[i]; idt77252_proc_read()
2691 tct = (unsigned long) (card->tct_base + i * SAR_SRAM_TCT_SIZE); idt77252_proc_read()
2694 p += sprintf(p, " %08x", read_sram(card, tct + i)); idt77252_proc_read()
2708 idt77252_collect_stat(struct idt77252_dev *card) idt77252_collect_stat() argument
2719 struct idt77252_dev *card = dev_id; idt77252_interrupt() local
2726 if (test_and_set_bit(IDT77252_BIT_INTERRUPT, &card->flags)) { idt77252_interrupt()
2727 printk("%s: Re-entering irq_handler()\n", card->name); idt77252_interrupt()
2734 INTPRINTK("%s: TSIF\n", card->name); idt77252_interrupt()
2735 card->irqstat[15]++; idt77252_interrupt()
2736 idt77252_tx(card); idt77252_interrupt()
2739 INTPRINTK("%s: TXICP\n", card->name); idt77252_interrupt()
2740 card->irqstat[14]++; idt77252_interrupt()
2742 idt77252_tx_dump(card); idt77252_interrupt()
2746 INTPRINTK("%s: TSQF\n", card->name); idt77252_interrupt()
2747 card->irqstat[12]++; idt77252_interrupt()
2748 idt77252_tx(card); idt77252_interrupt()
2751 INTPRINTK("%s: TMROF\n", card->name); idt77252_interrupt()
2752 card->irqstat[11]++; idt77252_interrupt()
2753 idt77252_collect_stat(card); idt77252_interrupt()
2757 INTPRINTK("%s: EPDU\n", card->name); idt77252_interrupt()
2758 card->irqstat[5]++; idt77252_interrupt()
2759 idt77252_rx(card); idt77252_interrupt()
2762 INTPRINTK("%s: RSQAF\n", card->name); idt77252_interrupt()
2763 card->irqstat[1]++; idt77252_interrupt()
2764 idt77252_rx(card); idt77252_interrupt()
2767 INTPRINTK("%s: RSQF\n", card->name); idt77252_interrupt()
2768 card->irqstat[6]++; idt77252_interrupt()
2769 idt77252_rx(card); idt77252_interrupt()
2772 INTPRINTK("%s: RAWCF\n", card->name); idt77252_interrupt()
2773 card->irqstat[4]++; idt77252_interrupt()
2774 idt77252_rx_raw(card); idt77252_interrupt()
2778 INTPRINTK("%s: PHYI", card->name); idt77252_interrupt()
2779 card->irqstat[10]++; idt77252_interrupt()
2780 if (card->atmdev->phy && card->atmdev->phy->interrupt) idt77252_interrupt()
2781 card->atmdev->phy->interrupt(card->atmdev); idt77252_interrupt()
2789 INTPRINTK("%s: FBQA: %04x\n", card->name, stat); idt77252_interrupt()
2792 card->irqstat[2]++; idt77252_interrupt()
2794 card->irqstat[3]++; idt77252_interrupt()
2796 card->irqstat[7]++; idt77252_interrupt()
2798 card->irqstat[8]++; idt77252_interrupt()
2800 schedule_work(&card->tqueue); idt77252_interrupt()
2804 clear_bit(IDT77252_BIT_INTERRUPT, &card->flags); idt77252_interrupt()
2811 struct idt77252_dev *card = idt77252_softint() local
2820 add_rx_skb(card, 0, SAR_FB_SIZE_0, 32); idt77252_softint()
2826 add_rx_skb(card, 1, SAR_FB_SIZE_1, 32); idt77252_softint()
2832 add_rx_skb(card, 2, SAR_FB_SIZE_2, 32); idt77252_softint()
2838 add_rx_skb(card, 3, SAR_FB_SIZE_3, 32); idt77252_softint()
2851 open_card_oam(struct idt77252_dev *card) open_card_oam() argument
2860 for (vpi = 0; vpi < (1 << card->vpibits); vpi++) { open_card_oam()
2862 index = VPCI2VC(card, vpi, vci); open_card_oam()
2866 printk("%s: can't alloc vc\n", card->name); open_card_oam()
2870 card->vcs[index] = vc; open_card_oam()
2872 flush_rx_pool(card, &vc->rcv.rx_pool); open_card_oam()
2879 addr = card->rct_base + (vc->index << 2); open_card_oam()
2880 write_sram(card, addr, rcte); open_card_oam()
2882 spin_lock_irqsave(&card->cmd_lock, flags); open_card_oam()
2885 waitfor_idle(card); open_card_oam()
2886 spin_unlock_irqrestore(&card->cmd_lock, flags); open_card_oam()
2894 close_card_oam(struct idt77252_dev *card) close_card_oam() argument
2902 for (vpi = 0; vpi < (1 << card->vpibits); vpi++) { close_card_oam()
2904 index = VPCI2VC(card, vpi, vci); close_card_oam()
2905 vc = card->vcs[index]; close_card_oam()
2907 addr = card->rct_base + vc->index * SAR_SRAM_RCT_SIZE; close_card_oam()
2909 spin_lock_irqsave(&card->cmd_lock, flags); close_card_oam()
2912 waitfor_idle(card); close_card_oam()
2913 spin_unlock_irqrestore(&card->cmd_lock, flags); close_card_oam()
2918 card->name); close_card_oam()
2920 recycle_rx_pool_skb(card, &vc->rcv.rx_pool); close_card_oam()
2927 open_card_ubr0(struct idt77252_dev *card) open_card_ubr0() argument
2933 printk("%s: can't alloc vc\n", card->name); open_card_ubr0()
2936 card->vcs[0] = vc; open_card_ubr0()
2939 vc->scq = alloc_scq(card, vc->class); open_card_ubr0()
2941 printk("%s: can't get SCQ.\n", card->name); open_card_ubr0()
2945 card->scd2vc[0] = vc; open_card_ubr0()
2947 vc->scq->scd = card->scd_base; open_card_ubr0()
2949 fill_scd(card, vc->scq, vc->class); open_card_ubr0()
2951 write_sram(card, card->tct_base + 0, TCT_UBR | card->scd_base); open_card_ubr0()
2952 write_sram(card, card->tct_base + 1, 0); open_card_ubr0()
2953 write_sram(card, card->tct_base + 2, 0); open_card_ubr0()
2954 write_sram(card, card->tct_base + 3, 0); open_card_ubr0()
2955 write_sram(card, card->tct_base + 4, 0); open_card_ubr0()
2956 write_sram(card, card->tct_base + 5, 0); open_card_ubr0()
2957 write_sram(card, card->tct_base + 6, 0); open_card_ubr0()
2958 write_sram(card, card->tct_base + 7, TCT_FLAG_UBR); open_card_ubr0()
2966 idt77252_dev_open(struct idt77252_dev *card) idt77252_dev_open() argument
2970 if (!test_bit(IDT77252_BIT_INIT, &card->flags)) { idt77252_dev_open()
2971 printk("%s: SAR not yet initialized.\n", card->name); idt77252_dev_open()
2995 if (open_card_oam(card)) { idt77252_dev_open()
2996 printk("%s: Error initializing OAM.\n", card->name); idt77252_dev_open()
3000 if (open_card_ubr0(card)) { idt77252_dev_open()
3001 printk("%s: Error initializing UBR0.\n", card->name); idt77252_dev_open()
3005 IPRINTK("%s: opened IDT77252 ABR SAR.\n", card->name); idt77252_dev_open()
3011 struct idt77252_dev *card = dev->dev_data; idt77252_dev_close() local
3014 close_card_oam(card); idt77252_dev_close()
3030 DIPRINTK("%s: closed IDT77252 ABR SAR.\n", card->name); idt77252_dev_close()
3042 deinit_card(struct idt77252_dev *card) deinit_card() argument
3047 if (!test_bit(IDT77252_BIT_INIT, &card->flags)) { deinit_card()
3048 printk("%s: SAR not yet initialized.\n", card->name); deinit_card()
3051 DIPRINTK("idt77252: deinitialize card %u\n", card->index); deinit_card()
3055 if (card->atmdev) deinit_card()
3056 atm_dev_deregister(card->atmdev); deinit_card()
3060 skb = card->sbpool[i].skb[j]; deinit_card()
3062 dma_unmap_single(&card->pcidev->dev, deinit_card()
3067 card->sbpool[i].skb[j] = NULL; deinit_card()
3073 vfree(card->soft_tst); deinit_card()
3075 vfree(card->scd2vc); deinit_card()
3077 vfree(card->vcs); deinit_card()
3079 if (card->raw_cell_hnd) { deinit_card()
3080 dma_free_coherent(&card->pcidev->dev, 2 * sizeof(u32), deinit_card()
3081 card->raw_cell_hnd, card->raw_cell_paddr); deinit_card()
3084 if (card->rsq.base) { deinit_card()
3085 DIPRINTK("%s: Release RSQ ...\n", card->name); deinit_card()
3086 deinit_rsq(card); deinit_card()
3089 if (card->tsq.base) { deinit_card()
3090 DIPRINTK("%s: Release TSQ ...\n", card->name); deinit_card()
3091 deinit_tsq(card); deinit_card()
3095 free_irq(card->pcidev->irq, card); deinit_card()
3098 if (card->fbq[i]) deinit_card()
3099 iounmap(card->fbq[i]); deinit_card()
3102 if (card->membase) deinit_card()
3103 iounmap(card->membase); deinit_card()
3105 clear_bit(IDT77252_BIT_INIT, &card->flags); deinit_card()
3106 DIPRINTK("%s: Card deinitialized.\n", card->name); deinit_card()
3110 static void init_sram(struct idt77252_dev *card) init_sram() argument
3114 for (i = 0; i < card->sramsize; i += 4) init_sram()
3115 write_sram(card, (i >> 2), 0); init_sram()
3117 /* set SRAM layout for THIS card */ init_sram()
3118 if (card->sramsize == (512 * 1024)) { init_sram()
3119 card->tct_base = SAR_SRAM_TCT_128_BASE; init_sram()
3120 card->tct_size = (SAR_SRAM_TCT_128_TOP - card->tct_base + 1) init_sram()
3122 card->rct_base = SAR_SRAM_RCT_128_BASE; init_sram()
3123 card->rct_size = (SAR_SRAM_RCT_128_TOP - card->rct_base + 1) init_sram()
3125 card->rt_base = SAR_SRAM_RT_128_BASE; init_sram()
3126 card->scd_base = SAR_SRAM_SCD_128_BASE; init_sram()
3127 card->scd_size = (SAR_SRAM_SCD_128_TOP - card->scd_base + 1) init_sram()
3129 card->tst[0] = SAR_SRAM_TST1_128_BASE; init_sram()
3130 card->tst[1] = SAR_SRAM_TST2_128_BASE; init_sram()
3131 card->tst_size = SAR_SRAM_TST1_128_TOP - card->tst[0] + 1; init_sram()
3132 card->abrst_base = SAR_SRAM_ABRSTD_128_BASE; init_sram()
3133 card->abrst_size = SAR_ABRSTD_SIZE_8K; init_sram()
3134 card->fifo_base = SAR_SRAM_FIFO_128_BASE; init_sram()
3135 card->fifo_size = SAR_RXFD_SIZE_32K; init_sram()
3137 card->tct_base = SAR_SRAM_TCT_32_BASE; init_sram()
3138 card->tct_size = (SAR_SRAM_TCT_32_TOP - card->tct_base + 1) init_sram()
3140 card->rct_base = SAR_SRAM_RCT_32_BASE; init_sram()
3141 card->rct_size = (SAR_SRAM_RCT_32_TOP - card->rct_base + 1) init_sram()
3143 card->rt_base = SAR_SRAM_RT_32_BASE; init_sram()
3144 card->scd_base = SAR_SRAM_SCD_32_BASE; init_sram()
3145 card->scd_size = (SAR_SRAM_SCD_32_TOP - card->scd_base + 1) init_sram()
3147 card->tst[0] = SAR_SRAM_TST1_32_BASE; init_sram()
3148 card->tst[1] = SAR_SRAM_TST2_32_BASE; init_sram()
3149 card->tst_size = (SAR_SRAM_TST1_32_TOP - card->tst[0] + 1); init_sram()
3150 card->abrst_base = SAR_SRAM_ABRSTD_32_BASE; init_sram()
3151 card->abrst_size = SAR_ABRSTD_SIZE_1K; init_sram()
3152 card->fifo_base = SAR_SRAM_FIFO_32_BASE; init_sram()
3153 card->fifo_size = SAR_RXFD_SIZE_4K; init_sram()
3157 for (i = 0; i < card->tct_size; i++) { init_sram()
3158 write_sram(card, i * SAR_SRAM_TCT_SIZE + 0, 0); init_sram()
3159 write_sram(card, i * SAR_SRAM_TCT_SIZE + 1, 0); init_sram()
3160 write_sram(card, i * SAR_SRAM_TCT_SIZE + 2, 0); init_sram()
3161 write_sram(card, i * SAR_SRAM_TCT_SIZE + 3, 0); init_sram()
3162 write_sram(card, i * SAR_SRAM_TCT_SIZE + 4, 0); init_sram()
3163 write_sram(card, i * SAR_SRAM_TCT_SIZE + 5, 0); init_sram()
3164 write_sram(card, i * SAR_SRAM_TCT_SIZE + 6, 0); init_sram()
3165 write_sram(card, i * SAR_SRAM_TCT_SIZE + 7, 0); init_sram()
3169 for (i = 0; i < card->rct_size; i++) { init_sram()
3170 write_sram(card, card->rct_base + i * SAR_SRAM_RCT_SIZE, init_sram()
3172 write_sram(card, card->rct_base + i * SAR_SRAM_RCT_SIZE + 1, init_sram()
3174 write_sram(card, card->rct_base + i * SAR_SRAM_RCT_SIZE + 2, init_sram()
3176 write_sram(card, card->rct_base + i * SAR_SRAM_RCT_SIZE + 3, init_sram()
3191 write_sram(card, card->rt_base + i, log_to_rate[i]); init_sram()
3201 write_sram(card, card->rt_base + 256 + i, tmp); init_sram()
3210 write_sram(card, card->rt_base + 512 + i, tmp); init_sram()
3218 write_sram(card, card->rt_base + 640 + i, tmp); init_sram()
3222 IPRINTK("%s: initialize rate table ...\n", card->name); init_sram()
3223 writel(card->rt_base << 2, SAR_REG_RTBL); init_sram()
3226 IPRINTK("%s: initialize TST ...\n", card->name); init_sram()
3227 card->tst_free = card->tst_size - 2; /* last two are jumps */ init_sram()
3229 for (i = card->tst[0]; i < card->tst[0] + card->tst_size - 2; i++) init_sram()
3230 write_sram(card, i, TSTE_OPC_VAR); init_sram()
3231 write_sram(card, i++, TSTE_OPC_JMP | (card->tst[0] << 2)); init_sram()
3233 write_sram(card, i++, TSTE_OPC_JMP | (card->tst[1] << 2)); init_sram()
3235 for (i = card->tst[1]; i < card->tst[1] + card->tst_size - 2; i++) init_sram()
3236 write_sram(card, i, TSTE_OPC_VAR); init_sram()
3237 write_sram(card, i++, TSTE_OPC_JMP | (card->tst[1] << 2)); init_sram()
3239 write_sram(card, i++, TSTE_OPC_JMP | (card->tst[0] << 2)); init_sram()
3242 card->tst_index = 0; init_sram()
3243 writel(card->tst[0] << 2, SAR_REG_TSTB); init_sram()
3246 IPRINTK("%s: initialize ABRSTD ...\n", card->name); init_sram()
3247 writel(card->abrst_size | (card->abrst_base << 2), init_sram()
3250 IPRINTK("%s: initialize receive fifo ...\n", card->name); init_sram()
3251 writel(card->fifo_size | (card->fifo_base << 2), init_sram()
3254 IPRINTK("%s: SRAM initialization complete.\n", card->name); init_sram()
3259 struct idt77252_dev *card = dev->dev_data; init_card() local
3260 struct pci_dev *pcidev = card->pcidev; init_card()
3272 if (test_bit(IDT77252_BIT_INIT, &card->flags)) { init_card()
3282 IPRINTK("%s: Checking PCI retries.\n", card->name); init_card()
3284 printk("%s: can't read PCI retry timeout.\n", card->name); init_card()
3285 deinit_card(card); init_card()
3290 card->name, pci_byte); init_card()
3293 card->name); init_card()
3294 deinit_card(card); init_card()
3298 IPRINTK("%s: Checking PCI TRDY.\n", card->name); init_card()
3300 printk("%s: can't read PCI TRDY timeout.\n", card->name); init_card()
3301 deinit_card(card); init_card()
3306 card->name, pci_byte); init_card()
3308 printk("%s: can't set PCI TRDY timeout.\n", card->name); init_card()
3309 deinit_card(card); init_card()
3315 printk("%s: resetting timer overflow.\n", card->name); init_card()
3318 IPRINTK("%s: Request IRQ ... ", card->name); init_card()
3320 card->name, card) != 0) { init_card()
3321 printk("%s: can't allocate IRQ.\n", card->name); init_card()
3322 deinit_card(card); init_card()
3331 IPRINTK("%s: Initializing SRAM\n", card->name); init_card()
3342 if (card->sramsize == (512 * 1024)) init_card()
3365 init_sram(card); init_card()
3371 if (0 != init_tsq(card)) { init_card()
3372 deinit_card(card); init_card()
3376 if (0 != init_rsq(card)) { init_card()
3377 deinit_card(card); init_card()
3381 card->vpibits = vpibits; init_card()
3382 if (card->sramsize == (512 * 1024)) { init_card()
3383 card->vcibits = 10 - card->vpibits; init_card()
3385 card->vcibits = 9 - card->vpibits; init_card()
3388 card->vcimask = 0; init_card()
3389 for (k = 0, i = 1; k < card->vcibits; k++) { init_card()
3390 card->vcimask |= i; init_card()
3394 IPRINTK("%s: Setting VPI/VCI mask to zero.\n", card->name); init_card()
3401 card->raw_cell_hnd = dma_zalloc_coherent(&card->pcidev->dev, init_card()
3403 &card->raw_cell_paddr, init_card()
3405 if (!card->raw_cell_hnd) { init_card()
3406 printk("%s: memory allocation failure.\n", card->name); init_card()
3407 deinit_card(card); init_card()
3410 writel(card->raw_cell_paddr, SAR_REG_RAWHND); init_card()
3411 IPRINTK("%s: raw cell handle is at 0x%p.\n", card->name, init_card()
3412 card->raw_cell_hnd); init_card()
3414 size = sizeof(struct vc_map *) * card->tct_size; init_card()
3415 IPRINTK("%s: allocate %d byte for VC map.\n", card->name, size); init_card()
3416 card->vcs = vzalloc(size); init_card()
3417 if (!card->vcs) { init_card()
3418 printk("%s: memory allocation failure.\n", card->name); init_card()
3419 deinit_card(card); init_card()
3423 size = sizeof(struct vc_map *) * card->scd_size; init_card()
3425 card->name, size); init_card()
3426 card->scd2vc = vzalloc(size); init_card()
3427 if (!card->scd2vc) { init_card()
3428 printk("%s: memory allocation failure.\n", card->name); init_card()
3429 deinit_card(card); init_card()
3433 size = sizeof(struct tst_info) * (card->tst_size - 2); init_card()
3435 card->name, size); init_card()
3436 card->soft_tst = vmalloc(size); init_card()
3437 if (!card->soft_tst) { init_card()
3438 printk("%s: memory allocation failure.\n", card->name); init_card()
3439 deinit_card(card); init_card()
3442 for (i = 0; i < card->tst_size - 2; i++) { init_card()
3443 card->soft_tst[i].tste = TSTE_OPC_VAR; init_card()
3444 card->soft_tst[i].vc = NULL; init_card()
3448 printk("%s: No LT device defined.\n", card->name); init_card()
3449 deinit_card(card); init_card()
3453 printk("%s: LT had no IOCTL function defined.\n", card->name); init_card()
3454 deinit_card(card); init_card()
3471 card->link_pcr = (linkrate / 8 / 53); init_card()
3473 card->name, linkrate, card->link_pcr); init_card()
3476 card->utopia_pcr = card->link_pcr; init_card()
3478 card->utopia_pcr = (160000000 / 8 / 54); init_card()
3482 if (card->utopia_pcr > card->link_pcr) init_card()
3483 rsvdcr = card->utopia_pcr - card->link_pcr; init_card()
3485 tmpl = (unsigned long) rsvdcr * ((unsigned long) card->tst_size - 2); init_card()
3486 modl = tmpl % (unsigned long)card->utopia_pcr; init_card()
3487 tst_entries = (int) (tmpl / (unsigned long)card->utopia_pcr); init_card()
3490 card->tst_free -= tst_entries; init_card()
3491 fill_tst(card, NULL, tst_entries, TSTE_OPC_NULL); init_card()
3494 idt77252_eeprom_init(card); init_card()
3495 printk("%s: EEPROM: %02x:", card->name, init_card()
3496 idt77252_eeprom_read_status(card)); init_card()
3500 idt77252_eeprom_read_byte(card, i) init_card()
3509 sprintf(tname, "eth%d", card->index); init_card()
3512 memcpy(card->atmdev->esi, tmp->dev_addr, 6); init_card()
3514 printk("%s: ESI %pM\n", card->name, card->atmdev->esi); init_card()
3523 set_bit(IDT77252_BIT_INIT, &card->flags); init_card()
3525 XPRINTK("%s: IDT77252 ABR SAR initialization complete.\n", card->name); init_card()
3537 static int idt77252_preset(struct idt77252_dev *card) idt77252_preset() argument
3546 card->name); idt77252_preset()
3547 if (pci_read_config_word(card->pcidev, PCI_COMMAND, &pci_command)) { idt77252_preset()
3548 printk("%s: can't read PCI_COMMAND.\n", card->name); idt77252_preset()
3549 deinit_card(card); idt77252_preset()
3554 card->name, pci_command); idt77252_preset()
3555 deinit_card(card); idt77252_preset()
3559 if (pci_write_config_word(card->pcidev, PCI_COMMAND, pci_command)) { idt77252_preset()
3560 printk("%s: can't write PCI_COMMAND.\n", card->name); idt77252_preset()
3561 deinit_card(card); idt77252_preset()
3573 IPRINTK("%s: Software resetted.\n", card->name); idt77252_preset()
3578 static unsigned long probe_sram(struct idt77252_dev *card) probe_sram() argument
3606 struct idt77252_dev *card; idt77252_init_one() local
3621 card = kzalloc(sizeof(struct idt77252_dev), GFP_KERNEL); idt77252_init_one()
3622 if (!card) { idt77252_init_one()
3627 card->revision = pcidev->revision; idt77252_init_one()
3628 card->index = index; idt77252_init_one()
3629 card->pcidev = pcidev; idt77252_init_one()
3630 sprintf(card->name, "idt77252-%d", card->index); idt77252_init_one()
3632 INIT_WORK(&card->tqueue, idt77252_softint); idt77252_init_one()
3637 mutex_init(&card->mutex); idt77252_init_one()
3638 spin_lock_init(&card->cmd_lock); idt77252_init_one()
3639 spin_lock_init(&card->tst_lock); idt77252_init_one()
3641 init_timer(&card->tst_timer); idt77252_init_one()
3642 card->tst_timer.data = (unsigned long)card; idt77252_init_one()
3643 card->tst_timer.function = tst_timer; idt77252_init_one()
3646 card->membase = ioremap(membase, 1024); idt77252_init_one()
3647 if (!card->membase) { idt77252_init_one()
3648 printk("%s: can't ioremap() membase\n", card->name); idt77252_init_one()
3653 if (idt77252_preset(card)) { idt77252_init_one()
3654 printk("%s: preset failed\n", card->name); idt77252_init_one()
3662 printk("%s: can't register atm device\n", card->name); idt77252_init_one()
3666 dev->dev_data = card; idt77252_init_one()
3667 card->atmdev = dev; idt77252_init_one()
3672 printk("%s: can't init SUNI\n", card->name); idt77252_init_one()
3678 card->sramsize = probe_sram(card); idt77252_init_one()
3681 card->fbq[i] = ioremap(srambase | 0x200000 | (i << 18), 4); idt77252_init_one()
3682 if (!card->fbq[i]) { idt77252_init_one()
3683 printk("%s: can't ioremap() FBQ%d\n", card->name, i); idt77252_init_one()
3690 card->name, ((card->revision > 1) && (card->revision < 25)) ? idt77252_init_one()
3691 'A' + card->revision - 1 : '?', membase, srambase, idt77252_init_one()
3692 card->sramsize / 1024); idt77252_init_one()
3695 printk("%s: init_card failed\n", card->name); idt77252_init_one()
3700 dev->ci_range.vpi_bits = card->vpibits; idt77252_init_one()
3701 dev->ci_range.vci_bits = card->vcibits; idt77252_init_one()
3702 dev->link_rate = card->link_pcr; idt77252_init_one()
3707 if (idt77252_dev_open(card)) { idt77252_init_one()
3708 printk("%s: dev_open failed\n", card->name); idt77252_init_one()
3713 *last = card; idt77252_init_one()
3714 last = &card->next; idt77252_init_one()
3724 deinit_card(card); idt77252_init_one()
3727 iounmap(card->membase); idt77252_init_one()
3730 kfree(card); idt77252_init_one()
3771 struct idt77252_dev *card; idt77252_exit() local
3777 card = idt77252_chain; idt77252_exit()
3778 dev = card->atmdev; idt77252_exit()
3779 idt77252_chain = card->next; idt77252_exit()
3783 deinit_card(card); idt77252_exit()
3784 pci_disable_device(card->pcidev); idt77252_exit()
3785 kfree(card); idt77252_exit()
H A Dnicstar.c25 * 1 - Per card interrupt spinlock (to protect structures and such)
27 * 3 - Per card resource spinlock (to access registers, etc.)
104 #define CMD_BUSY(card) (readl((card)->membase + STAT) & NS_STAT_CMDBZ)
119 static u32 ns_read_sram(ns_dev * card, u32 sram_address);
120 static void ns_write_sram(ns_dev * card, u32 sram_address, u32 * value,
123 static void ns_init_card_error(ns_dev * card, int error);
124 static scq_info *get_scq(ns_dev *card, int size, u32 scd);
125 static void free_scq(ns_dev *card, scq_info * scq, struct atm_vcc *vcc);
130 static void fill_tst(ns_dev * card, int n, vc_map * vc);
132 static int push_scqe(ns_dev * card, vc_map * vc, scq_info * scq, ns_scqe * tbd,
134 static void process_tsq(ns_dev * card);
135 static void drain_scq(ns_dev * card, scq_info * scq, int pos);
136 static void process_rsq(ns_dev * card);
137 static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe);
138 static void recycle_rx_buf(ns_dev * card, struct sk_buff *skb);
139 static void recycle_iovec_rx_bufs(ns_dev * card, struct iovec *iov, int count);
140 static void recycle_iov_buf(ns_dev * card, struct sk_buff *iovb);
141 static void dequeue_sm_buf(ns_dev * card, struct sk_buff *sb);
142 static void dequeue_lg_buf(ns_dev * card, struct sk_buff *lb);
146 static void which_list(ns_dev * card, struct sk_buff *skb);
198 ns_dev *card = pci_get_drvdata(pcidev); nicstar_remove_one() local
204 i = card->index; nicstar_remove_one()
209 if (card->atmdev->phy && card->atmdev->phy->stop) nicstar_remove_one()
210 card->atmdev->phy->stop(card->atmdev); nicstar_remove_one()
213 writel(0x00000000, card->membase + CFG); nicstar_remove_one()
216 atm_dev_deregister(card->atmdev); nicstar_remove_one()
223 PRINTK("nicstar%d: freeing %d huge buffers.\n", i, card->hbpool.count); nicstar_remove_one()
224 while ((hb = skb_dequeue(&card->hbpool.queue)) != NULL) { nicstar_remove_one()
231 card->iovpool.count); nicstar_remove_one()
232 while ((iovb = skb_dequeue(&card->iovpool.queue)) != NULL) { nicstar_remove_one()
237 while ((lb = skb_dequeue(&card->lbpool.queue)) != NULL) nicstar_remove_one()
239 while ((sb = skb_dequeue(&card->sbpool.queue)) != NULL) nicstar_remove_one()
241 free_scq(card, card->scq0, NULL); nicstar_remove_one()
243 if (card->scd2vc[j] != NULL) nicstar_remove_one()
244 free_scq(card, card->scd2vc[j]->scq, card->scd2vc[j]->tx_vcc); nicstar_remove_one()
246 idr_destroy(&card->idr); nicstar_remove_one()
247 dma_free_coherent(&card->pcidev->dev, NS_RSQSIZE + NS_RSQ_ALIGNMENT, nicstar_remove_one()
248 card->rsq.org, card->rsq.dma); nicstar_remove_one()
249 dma_free_coherent(&card->pcidev->dev, NS_TSQSIZE + NS_TSQ_ALIGNMENT, nicstar_remove_one()
250 card->tsq.org, card->tsq.dma); nicstar_remove_one()
251 free_irq(card->pcidev->irq, card); nicstar_remove_one()
252 iounmap(card->membase); nicstar_remove_one()
253 kfree(card); nicstar_remove_one()
308 static u32 ns_read_sram(ns_dev * card, u32 sram_address) ns_read_sram() argument
315 spin_lock_irqsave(&card->res_lock, flags); ns_read_sram()
316 while (CMD_BUSY(card)) ; ns_read_sram()
317 writel(sram_address, card->membase + CMD); ns_read_sram()
318 while (CMD_BUSY(card)) ; ns_read_sram()
319 data = readl(card->membase + DR0); ns_read_sram()
320 spin_unlock_irqrestore(&card->res_lock, flags); ns_read_sram()
324 static void ns_write_sram(ns_dev * card, u32 sram_address, u32 * value, ns_write_sram() argument
332 spin_lock_irqsave(&card->res_lock, flags); ns_write_sram()
333 while (CMD_BUSY(card)) ; ns_write_sram()
335 writel(*(value++), card->membase + i); ns_write_sram()
337 so card->membase + DR0 == card->membase */ ns_write_sram()
341 writel(sram_address, card->membase + CMD); ns_write_sram()
342 spin_unlock_irqrestore(&card->res_lock, flags); ns_write_sram()
348 struct ns_dev *card = NULL; ns_init_card() local
362 ns_init_card_error(card, error); ns_init_card()
369 ns_init_card_error(card, error); ns_init_card()
373 if ((card = kmalloc(sizeof(ns_dev), GFP_KERNEL)) == NULL) { ns_init_card()
378 ns_init_card_error(card, error); ns_init_card()
381 cards[i] = card; ns_init_card()
382 spin_lock_init(&card->int_lock); ns_init_card()
383 spin_lock_init(&card->res_lock); ns_init_card()
385 pci_set_drvdata(pcidev, card); ns_init_card()
387 card->index = i; ns_init_card()
388 card->atmdev = NULL; ns_init_card()
389 card->pcidev = pcidev; ns_init_card()
391 card->membase = ioremap(membase, NS_IOREMAP_SIZE); ns_init_card()
392 if (!card->membase) { ns_init_card()
395 ns_init_card_error(card, error); ns_init_card()
398 PRINTK("nicstar%d: membase at 0x%p.\n", i, card->membase); ns_init_card()
405 ns_init_card_error(card, error); ns_init_card()
422 ns_init_card_error(card, error); ns_init_card()
429 data = readl(card->membase + STAT); ns_init_card()
431 writel(NS_STAT_TMROF, card->membase + STAT); ns_init_card()
434 writel(NS_CFG_SWRST, card->membase + CFG); ns_init_card()
436 writel(0x00000000, card->membase + CFG); ns_init_card()
439 writel(0x00000008, card->membase + GP); ns_init_card()
441 writel(0x00000001, card->membase + GP); ns_init_card()
443 while (CMD_BUSY(card)) ; ns_init_card()
444 writel(NS_CMD_WRITE_UTILITY | 0x00000100, card->membase + CMD); /* Sync UTOPIA with SAR clock */ ns_init_card()
448 while (CMD_BUSY(card)) ; ns_init_card()
449 writel(NS_CMD_READ_UTILITY | 0x00000200, card->membase + CMD); ns_init_card()
450 while (CMD_BUSY(card)) ; ns_init_card()
451 data = readl(card->membase + DR0); ns_init_card()
455 card->max_pcr = ATM_25_PCR; ns_init_card()
456 while (CMD_BUSY(card)) ; ns_init_card()
457 writel(0x00000008, card->membase + DR0); ns_init_card()
458 writel(NS_CMD_WRITE_UTILITY | 0x00000200, card->membase + CMD); ns_init_card()
460 writel(NS_STAT_SFBQF, card->membase + STAT); ns_init_card()
462 while (CMD_BUSY(card)) ; ns_init_card()
463 writel(0x00000022, card->membase + DR0); ns_init_card()
464 writel(NS_CMD_WRITE_UTILITY | 0x00000202, card->membase + CMD); ns_init_card()
470 card->max_pcr = ATM_OC3_PCR; ns_init_card()
472 while (CMD_BUSY(card)) ; ns_init_card()
473 writel(0x00000002, card->membase + DR0); ns_init_card()
474 writel(NS_CMD_WRITE_UTILITY | 0x00000205, card->membase + CMD); ns_init_card()
480 ns_init_card_error(card, error); ns_init_card()
483 writel(0x00000000, card->membase + GP); ns_init_card()
487 ns_write_sram(card, 0x1C003, &data, 1); ns_init_card()
489 ns_write_sram(card, 0x14003, &data, 1); ns_init_card()
490 if (ns_read_sram(card, 0x14003) == 0x89ABCDEF && ns_init_card()
491 ns_read_sram(card, 0x1C003) == 0x76543210) ns_init_card()
492 card->sram_size = 128; ns_init_card()
494 card->sram_size = 32; ns_init_card()
495 PRINTK("nicstar%d: %dK x 32bit SRAM size.\n", i, card->sram_size); ns_init_card()
497 card->rct_size = NS_MAX_RCTSIZE; ns_init_card()
500 if (card->sram_size == 128) ns_init_card()
505 if (card->sram_size == 32) { ns_init_card()
509 card->rct_size = 4096; ns_init_card()
515 card->vpibits = NS_VPIBITS; ns_init_card()
516 if (card->rct_size == 4096) ns_init_card()
517 card->vcibits = 12 - NS_VPIBITS; ns_init_card()
518 else /* card->rct_size == 16384 */ ns_init_card()
519 card->vcibits = 14 - NS_VPIBITS; ns_init_card()
523 nicstar_init_eprom(card->membase); ns_init_card()
526 writel(0x00000000, card->membase + VPM); ns_init_card()
529 card->tsq.org = dma_alloc_coherent(&card->pcidev->dev, ns_init_card()
531 &card->tsq.dma, GFP_KERNEL); ns_init_card()
532 if (card->tsq.org == NULL) { ns_init_card()
535 ns_init_card_error(card, error); ns_init_card()
538 card->tsq.base = PTR_ALIGN(card->tsq.org, NS_TSQ_ALIGNMENT); ns_init_card()
539 card->tsq.next = card->tsq.base; ns_init_card()
540 card->tsq.last = card->tsq.base + (NS_TSQ_NUM_ENTRIES - 1); ns_init_card()
542 ns_tsi_init(card->tsq.base + j); ns_init_card()
543 writel(0x00000000, card->membase + TSQH); ns_init_card()
544 writel(ALIGN(card->tsq.dma, NS_TSQ_ALIGNMENT), card->membase + TSQB); ns_init_card()
545 PRINTK("nicstar%d: TSQ base at 0x%p.\n", i, card->tsq.base); ns_init_card()
548 card->rsq.org = dma_alloc_coherent(&card->pcidev->dev, ns_init_card()
550 &card->rsq.dma, GFP_KERNEL); ns_init_card()
551 if (card->rsq.org == NULL) { ns_init_card()
554 ns_init_card_error(card, error); ns_init_card()
557 card->rsq.base = PTR_ALIGN(card->rsq.org, NS_RSQ_ALIGNMENT); ns_init_card()
558 card->rsq.next = card->rsq.base; ns_init_card()
559 card->rsq.last = card->rsq.base + (NS_RSQ_NUM_ENTRIES - 1); ns_init_card()
561 ns_rsqe_init(card->rsq.base + j); ns_init_card()
562 writel(0x00000000, card->membase + RSQH); ns_init_card()
563 writel(ALIGN(card->rsq.dma, NS_RSQ_ALIGNMENT), card->membase + RSQB); ns_init_card()
564 PRINTK("nicstar%d: RSQ base at 0x%p.\n", i, card->rsq.base); ns_init_card()
567 card->scq1 = NULL; ns_init_card()
568 card->scq2 = NULL; ns_init_card()
569 card->scq0 = get_scq(card, VBR_SCQSIZE, NS_VRSCD0); ns_init_card()
570 if (card->scq0 == NULL) { ns_init_card()
573 ns_init_card_error(card, error); ns_init_card()
576 u32d[0] = scq_virt_to_bus(card->scq0, card->scq0->base); ns_init_card()
580 ns_write_sram(card, NS_VRSCD0, u32d, 4); ns_init_card()
581 ns_write_sram(card, NS_VRSCD1, u32d, 4); /* These last two won't be used */ ns_init_card()
582 ns_write_sram(card, NS_VRSCD2, u32d, 4); /* but are initialized, just in case... */ ns_init_card()
583 card->scq0->scd = NS_VRSCD0; ns_init_card()
584 PRINTK("nicstar%d: VBR-SCQ0 base at 0x%p.\n", i, card->scq0->base); ns_init_card()
587 card->tst_addr = NS_TST0; ns_init_card()
588 card->tst_free_entries = NS_TST_NUM_ENTRIES; ns_init_card()
591 ns_write_sram(card, NS_TST0 + j, &data, 1); ns_init_card()
593 ns_write_sram(card, NS_TST0 + NS_TST_NUM_ENTRIES, &data, 1); ns_init_card()
595 ns_write_sram(card, NS_TST1 + j, &data, 1); ns_init_card()
597 ns_write_sram(card, NS_TST1 + NS_TST_NUM_ENTRIES, &data, 1); ns_init_card()
599 card->tste2vc[j] = NULL; ns_init_card()
600 writel(NS_TST0 << 2, card->membase + TSTB); ns_init_card()
611 for (j = 0; j < card->rct_size; j++) ns_init_card()
612 ns_write_sram(card, j * 4, u32d, 4); ns_init_card()
614 memset(card->vcmap, 0, NS_MAX_RCTSIZE * sizeof(vc_map)); ns_init_card()
617 card->scd2vc[j] = NULL; ns_init_card()
620 card->sbnr.min = MIN_SB; ns_init_card()
621 card->sbnr.init = NUM_SB; ns_init_card()
622 card->sbnr.max = MAX_SB; ns_init_card()
623 card->lbnr.min = MIN_LB; ns_init_card()
624 card->lbnr.init = NUM_LB; ns_init_card()
625 card->lbnr.max = MAX_LB; ns_init_card()
626 card->iovnr.min = MIN_IOVB; ns_init_card()
627 card->iovnr.init = NUM_IOVB; ns_init_card()
628 card->iovnr.max = MAX_IOVB; ns_init_card()
629 card->hbnr.min = MIN_HB; ns_init_card()
630 card->hbnr.init = NUM_HB; ns_init_card()
631 card->hbnr.max = MAX_HB; ns_init_card()
633 card->sm_handle = NULL; ns_init_card()
634 card->sm_addr = 0x00000000; ns_init_card()
635 card->lg_handle = NULL; ns_init_card()
636 card->lg_addr = 0x00000000; ns_init_card()
638 card->efbie = 1; /* To prevent push_rxbufs from enabling the interrupt */ ns_init_card()
640 idr_init(&card->idr); ns_init_card()
643 skb_queue_head_init(&card->hbpool.queue); ns_init_card()
644 card->hbpool.count = 0; ns_init_card()
653 ns_init_card_error(card, error); ns_init_card()
657 skb_queue_tail(&card->hbpool.queue, hb); ns_init_card()
658 card->hbpool.count++; ns_init_card()
662 skb_queue_head_init(&card->lbpool.queue); ns_init_card()
663 card->lbpool.count = 0; /* Not used */ ns_init_card()
672 ns_init_card_error(card, error); ns_init_card()
676 skb_queue_tail(&card->lbpool.queue, lb); ns_init_card()
678 push_rxbufs(card, lb); ns_init_card()
681 card->rcbuf = lb; ns_init_card()
682 card->rawcell = (struct ns_rcqe *) lb->data; ns_init_card()
683 card->rawch = NS_PRV_DMA(lb); ns_init_card()
688 ns_stat_lfbqc_get(readl(card->membase + STAT))) < card->lbnr.min) { ns_init_card()
693 ns_init_card_error(card, error); ns_init_card()
698 skb_queue_head_init(&card->sbpool.queue); ns_init_card()
699 card->sbpool.count = 0; /* Not used */ ns_init_card()
708 ns_init_card_error(card, error); ns_init_card()
712 skb_queue_tail(&card->sbpool.queue, sb); ns_init_card()
714 push_rxbufs(card, sb); ns_init_card()
718 ns_stat_sfbqc_get(readl(card->membase + STAT))) < card->sbnr.min) { ns_init_card()
723 ns_init_card_error(card, error); ns_init_card()
728 skb_queue_head_init(&card->iovpool.queue); ns_init_card()
729 card->iovpool.count = 0; ns_init_card()
738 ns_init_card_error(card, error); ns_init_card()
742 skb_queue_tail(&card->iovpool.queue, iovb); ns_init_card()
743 card->iovpool.count++; ns_init_card()
747 if (card->rct_size == 4096) ns_init_card()
749 else /* (card->rct_size == 16384) */ ns_init_card()
752 card->efbie = 1; ns_init_card()
754 card->intcnt = 0; ns_init_card()
756 (pcidev->irq, &ns_irq_handler, IRQF_SHARED, "nicstar", card) != 0) { ns_init_card()
759 ns_init_card_error(card, error); ns_init_card()
764 card->atmdev = atm_dev_register("nicstar", &card->pcidev->dev, &atm_ops, ns_init_card()
766 if (card->atmdev == NULL) { ns_init_card()
769 ns_init_card_error(card, error); ns_init_card()
773 if (mac[i] == NULL || !mac_pton(mac[i], card->atmdev->esi)) { ns_init_card()
774 nicstar_read_eprom(card->membase, NICSTAR_EPROM_MAC_ADDR_OFFSET, ns_init_card()
775 card->atmdev->esi, 6); ns_init_card()
776 if (ether_addr_equal(card->atmdev->esi, "\x00\x00\x00\x00\x00\x00")) { ns_init_card()
777 nicstar_read_eprom(card->membase, ns_init_card()
779 card->atmdev->esi, 6); ns_init_card()
783 printk("nicstar%d: MAC address %pM\n", i, card->atmdev->esi); ns_init_card()
785 card->atmdev->dev_data = card; ns_init_card()
786 card->atmdev->ci_range.vpi_bits = card->vpibits; ns_init_card()
787 card->atmdev->ci_range.vci_bits = card->vcibits; ns_init_card()
788 card->atmdev->link_rate = card->max_pcr; ns_init_card()
789 card->atmdev->phy = NULL; ns_init_card()
792 if (card->max_pcr == ATM_OC3_PCR) ns_init_card()
793 suni_init(card->atmdev); ns_init_card()
797 if (card->max_pcr == ATM_25_PCR) ns_init_card()
798 idt77105_init(card->atmdev); ns_init_card()
801 if (card->atmdev->phy && card->atmdev->phy->start) ns_init_card()
802 card->atmdev->phy->start(card->atmdev); ns_init_card()
806 NS_CFG_PHYIE, card->membase + CFG); ns_init_card()
813 static void ns_init_card_error(ns_dev *card, int error) ns_init_card_error() argument
816 writel(0x00000000, card->membase + CFG); ns_init_card_error()
820 while ((iovb = skb_dequeue(&card->iovpool.queue)) != NULL) ns_init_card_error()
825 while ((sb = skb_dequeue(&card->sbpool.queue)) != NULL) ns_init_card_error()
827 free_scq(card, card->scq0, NULL); ns_init_card_error()
831 while ((lb = skb_dequeue(&card->lbpool.queue)) != NULL) ns_init_card_error()
836 while ((hb = skb_dequeue(&card->hbpool.queue)) != NULL) ns_init_card_error()
840 kfree(card->rsq.org); ns_init_card_error()
843 kfree(card->tsq.org); ns_init_card_error()
846 free_irq(card->pcidev->irq, card); ns_init_card_error()
849 iounmap(card->membase); ns_init_card_error()
852 pci_disable_device(card->pcidev); ns_init_card_error()
853 kfree(card); ns_init_card_error()
857 static scq_info *get_scq(ns_dev *card, int size, u32 scd) get_scq() argument
868 scq->org = dma_alloc_coherent(&card->pcidev->dev, get_scq()
900 static void free_scq(ns_dev *card, scq_info *scq, struct atm_vcc *vcc) free_scq() argument
931 dma_free_coherent(&card->pcidev->dev, free_scq()
940 static void push_rxbufs(ns_dev * card, struct sk_buff *skb) push_rxbufs() argument
952 addr1 = dma_map_single(&card->pcidev->dev, push_rxbufs()
962 card->index); push_rxbufs()
965 stat = readl(card->membase + STAT); push_rxbufs()
966 card->sbfqc = ns_stat_sfbqc_get(stat); push_rxbufs()
967 card->lbfqc = ns_stat_lfbqc_get(stat); push_rxbufs()
970 if (card->sm_addr) { push_rxbufs()
971 addr2 = card->sm_addr; push_rxbufs()
972 handle2 = card->sm_handle; push_rxbufs()
973 card->sm_addr = 0x00000000; push_rxbufs()
974 card->sm_handle = NULL; push_rxbufs()
977 card->sm_addr = addr1; push_rxbufs()
978 card->sm_handle = handle1; push_rxbufs()
984 if (card->lg_addr) { push_rxbufs()
985 addr2 = card->lg_addr; push_rxbufs()
986 handle2 = card->lg_handle; push_rxbufs()
987 card->lg_addr = 0x00000000; push_rxbufs()
988 card->lg_handle = NULL; push_rxbufs()
991 card->lg_addr = addr1; push_rxbufs()
992 card->lg_handle = handle1; push_rxbufs()
999 if (card->sbfqc >= card->sbnr.max) { push_rxbufs()
1000 skb_unlink(handle1, &card->sbpool.queue); push_rxbufs()
1002 skb_unlink(handle2, &card->sbpool.queue); push_rxbufs()
1006 card->sbfqc += 2; push_rxbufs()
1009 if (card->lbfqc >= card->lbnr.max) { push_rxbufs()
1010 skb_unlink(handle1, &card->lbpool.queue); push_rxbufs()
1012 skb_unlink(handle2, &card->lbpool.queue); push_rxbufs()
1016 card->lbfqc += 2; push_rxbufs()
1019 id1 = idr_alloc(&card->idr, handle1, 0, 0, GFP_ATOMIC); push_rxbufs()
1023 id2 = idr_alloc(&card->idr, handle2, 0, 0, GFP_ATOMIC); push_rxbufs()
1027 spin_lock_irqsave(&card->res_lock, flags); push_rxbufs()
1028 while (CMD_BUSY(card)) ; push_rxbufs()
1029 writel(addr2, card->membase + DR3); push_rxbufs()
1030 writel(id2, card->membase + DR2); push_rxbufs()
1031 writel(addr1, card->membase + DR1); push_rxbufs()
1032 writel(id1, card->membase + DR0); push_rxbufs()
1034 card->membase + CMD); push_rxbufs()
1035 spin_unlock_irqrestore(&card->res_lock, flags); push_rxbufs()
1038 card->index, push_rxbufs()
1043 if (!card->efbie && card->sbfqc >= card->sbnr.min && push_rxbufs()
1044 card->lbfqc >= card->lbnr.min) { push_rxbufs()
1045 card->efbie = 1; push_rxbufs()
1046 writel((readl(card->membase + CFG) | NS_CFG_EFBIE), push_rxbufs()
1047 card->membase + CFG); push_rxbufs()
1057 ns_dev *card; ns_irq_handler() local
1061 card = (ns_dev *) dev_id; ns_irq_handler()
1062 dev = card->atmdev; ns_irq_handler()
1063 card->intcnt++; ns_irq_handler()
1065 PRINTK("nicstar%d: NICStAR generated an interrupt\n", card->index); ns_irq_handler()
1067 spin_lock_irqsave(&card->int_lock, flags); ns_irq_handler()
1069 stat_r = readl(card->membase + STAT); ns_irq_handler()
1073 TXPRINTK("nicstar%d: TSI interrupt\n", card->index); ns_irq_handler()
1074 process_tsq(card); ns_irq_handler()
1075 writel(NS_STAT_TSIF, card->membase + STAT); ns_irq_handler()
1080 writel(NS_STAT_TXICP, card->membase + STAT); ns_irq_handler()
1082 card->index); ns_irq_handler()
1087 writel(NS_STAT_TSQF, card->membase + STAT); ns_irq_handler()
1088 PRINTK("nicstar%d: TSQ full.\n", card->index); ns_irq_handler()
1089 process_tsq(card); ns_irq_handler()
1094 writel(NS_STAT_TMROF, card->membase + STAT); ns_irq_handler()
1095 PRINTK("nicstar%d: Timer overflow.\n", card->index); ns_irq_handler()
1100 writel(NS_STAT_PHYI, card->membase + STAT); ns_irq_handler()
1101 PRINTK("nicstar%d: PHY interrupt.\n", card->index); ns_irq_handler()
1109 writel(NS_STAT_SFBQF, card->membase + STAT); ns_irq_handler()
1111 card->index); ns_irq_handler()
1116 writel(NS_STAT_LFBQF, card->membase + STAT); ns_irq_handler()
1118 card->index); ns_irq_handler()
1123 writel(NS_STAT_RSQF, card->membase + STAT); ns_irq_handler()
1124 printk("nicstar%d: RSQ full.\n", card->index); ns_irq_handler()
1125 process_rsq(card); ns_irq_handler()
1130 RXPRINTK("nicstar%d: End of CS-PDU received.\n", card->index); ns_irq_handler()
1131 process_rsq(card); ns_irq_handler()
1132 writel(NS_STAT_EOPDU, card->membase + STAT); ns_irq_handler()
1137 writel(NS_STAT_RAWCF, card->membase + STAT); ns_irq_handler()
1140 card->index); ns_irq_handler()
1145 while (readl(card->membase + RAWCT) != card->rawch) { ns_irq_handler()
1147 if (ns_rcqe_islast(card->rawcell)) { ns_irq_handler()
1150 oldbuf = card->rcbuf; ns_irq_handler()
1151 card->rcbuf = idr_find(&card->idr, ns_irq_handler()
1152 ns_rcqe_nextbufhandle(card->rawcell)); ns_irq_handler()
1153 card->rawch = NS_PRV_DMA(card->rcbuf); ns_irq_handler()
1154 card->rawcell = (struct ns_rcqe *) ns_irq_handler()
1155 card->rcbuf->data; ns_irq_handler()
1156 recycle_rx_buf(card, oldbuf); ns_irq_handler()
1158 card->rawch += NS_RCQE_SIZE; ns_irq_handler()
1159 card->rawcell++; ns_irq_handler()
1169 writel(NS_STAT_SFBQE, card->membase + STAT); ns_irq_handler()
1171 card->index); ns_irq_handler()
1172 for (i = 0; i < card->sbnr.min; i++) { ns_irq_handler()
1175 writel(readl(card->membase + CFG) & ns_irq_handler()
1176 ~NS_CFG_EFBIE, card->membase + CFG); ns_irq_handler()
1177 card->efbie = 0; ns_irq_handler()
1181 skb_queue_tail(&card->sbpool.queue, sb); ns_irq_handler()
1183 push_rxbufs(card, sb); ns_irq_handler()
1185 card->sbfqc = i; ns_irq_handler()
1186 process_rsq(card); ns_irq_handler()
1194 writel(NS_STAT_LFBQE, card->membase + STAT); ns_irq_handler()
1196 card->index); ns_irq_handler()
1197 for (i = 0; i < card->lbnr.min; i++) { ns_irq_handler()
1200 writel(readl(card->membase + CFG) & ns_irq_handler()
1201 ~NS_CFG_EFBIE, card->membase + CFG); ns_irq_handler()
1202 card->efbie = 0; ns_irq_handler()
1206 skb_queue_tail(&card->lbpool.queue, lb); ns_irq_handler()
1208 push_rxbufs(card, lb); ns_irq_handler()
1210 card->lbfqc = i; ns_irq_handler()
1211 process_rsq(card); ns_irq_handler()
1216 writel(NS_STAT_RSQAF, card->membase + STAT); ns_irq_handler()
1217 RXPRINTK("nicstar%d: RSQ almost full.\n", card->index); ns_irq_handler()
1218 process_rsq(card); ns_irq_handler()
1221 spin_unlock_irqrestore(&card->int_lock, flags); ns_irq_handler()
1222 PRINTK("nicstar%d: end of interrupt service\n", card->index); ns_irq_handler()
1228 ns_dev *card; ns_open() local
1243 card = (ns_dev *) vcc->dev->dev_data; ns_open()
1244 PRINTK("nicstar%d: opening vpi.vci %d.%d \n", card->index, (int)vpi, ns_open()
1247 PRINTK("nicstar%d: unsupported AAL.\n", card->index); ns_open()
1251 vc = &(card->vcmap[vpi << card->vcibits | vci]); ns_open()
1260 printk("nicstar%d: %s vci already in use.\n", card->index, ns_open()
1280 card->index); ns_open()
1290 card->index, vcc->qos.txtp.max_pcr); ns_open()
1295 modl = tmpl % card->max_pcr; ns_open()
1297 n = (int)(tmpl / card->max_pcr); ns_open()
1303 (card->tst_free_entries - ns_open()
1307 card->index); ns_open()
1317 card->index); ns_open()
1323 if (n > (card->tst_free_entries - NS_TST_RESERVED)) { ns_open()
1326 card->index); ns_open()
1331 card->tst_free_entries -= n; ns_open()
1334 card->index, n); ns_open()
1336 if (card->scd2vc[frscdi] == NULL) { ns_open()
1337 card->scd2vc[frscdi] = vc; ns_open()
1344 card->index); ns_open()
1345 card->tst_free_entries += n; ns_open()
1353 scq = get_scq(card, CBR_SCQSIZE, vc->cbr_scd); ns_open()
1356 card->index); ns_open()
1357 card->scd2vc[frscdi] = NULL; ns_open()
1358 card->tst_free_entries += n; ns_open()
1368 ns_write_sram(card, vc->cbr_scd, u32d, 4); ns_open()
1370 fill_tst(card, n, vc); ns_open()
1373 vc->scq = card->scq0; ns_open()
1396 ns_write_sram(card, ns_open()
1398 (vpi << card->vcibits | vci) * ns_open()
1411 ns_dev *card; ns_close() local
1416 card = vcc->dev->dev_data; ns_close()
1417 PRINTK("nicstar%d: closing vpi.vci %d.%d \n", card->index, ns_close()
1428 (vcc->vpi << card->vcibits | vcc->vci) * NS_RCT_ENTRY_SIZE; ns_close()
1429 spin_lock_irqsave(&card->res_lock, flags); ns_close()
1430 while (CMD_BUSY(card)) ; ns_close()
1432 card->membase + CMD); ns_close()
1433 spin_unlock_irqrestore(&card->res_lock, flags); ns_close()
1440 stat = readl(card->membase + STAT); ns_close()
1441 card->sbfqc = ns_stat_sfbqc_get(stat); ns_close()
1442 card->lbfqc = ns_stat_lfbqc_get(stat); ns_close()
1446 card->index); ns_close()
1448 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data, ns_close()
1451 spin_lock_irqsave(&card->int_lock, flags); ns_close()
1452 recycle_iov_buf(card, iovb); ns_close()
1453 spin_unlock_irqrestore(&card->int_lock, flags); ns_close()
1502 ns_write_sram(card, scq->scd, &data, 1); ns_close()
1511 if (card->tste2vc[i] == vc) { ns_close()
1512 ns_write_sram(card, card->tst_addr + i, &data, ns_close()
1514 card->tste2vc[i] = NULL; ns_close()
1515 card->tst_free_entries++; ns_close()
1519 card->scd2vc[(vc->cbr_scd - NS_FRSCD) / NS_FRSCD_SIZE] = NULL; ns_close()
1520 free_scq(card, vc->scq, vcc); ns_close()
1526 scq_info *scq = card->scq0; ns_close()
1549 stat = readl(card->membase + STAT); ns_close()
1550 cfg = readl(card->membase + CFG); ns_close()
1554 card->tsq.base, card->tsq.next, ns_close()
1555 card->tsq.last, readl(card->membase + TSQT)); ns_close()
1558 card->rsq.base, card->rsq.next, ns_close()
1559 card->rsq.last, readl(card->membase + RSQT)); ns_close()
1561 card->efbie ? "enabled" : "disabled"); ns_close()
1563 ns_stat_sfbqc_get(stat), card->sbpool.count, ns_close()
1564 ns_stat_lfbqc_get(stat), card->lbpool.count); ns_close()
1566 card->hbpool.count, card->iovpool.count); ns_close()
1571 static void fill_tst(ns_dev * card, int n, vc_map * vc) fill_tst() argument
1582 new_tst = card->tst_addr; fill_tst()
1587 if (card->tste2vc[e] == NULL) fill_tst()
1591 printk("nicstar%d: No free TST entries found. \n", card->index); fill_tst()
1600 if (cl >= NS_TST_NUM_ENTRIES && card->tste2vc[e] == NULL) { fill_tst()
1601 card->tste2vc[e] = vc; fill_tst()
1602 ns_write_sram(card, new_tst + e, &data, 1); fill_tst()
1616 ns_write_sram(card, new_tst + NS_TST_NUM_ENTRIES, &data, 1); fill_tst()
1617 ns_write_sram(card, card->tst_addr + NS_TST_NUM_ENTRIES, &data, 1); fill_tst()
1618 card->tst_addr = new_tst; fill_tst()
1623 ns_dev *card; ns_send() local
1630 card = vcc->dev->dev_data; ns_send()
1631 TXPRINTK("nicstar%d: ns_send() called.\n", card->index); ns_send()
1634 card->index); ns_send()
1642 card->index); ns_send()
1650 card->index); ns_send()
1657 printk("nicstar%d: No scatter-gather yet.\n", card->index); ns_send()
1665 NS_PRV_DMA(skb) = dma_map_single(&card->pcidev->dev, skb->data, ns_send()
1702 scq = card->scq0; ns_send()
1705 if (push_scqe(card, vc, scq, &scqe, skb) != 0) { ns_send()
1715 static int push_scqe(ns_dev * card, vc_map * vc, scq_info * scq, ns_scqe * tbd, push_scqe() argument
1729 printk("nicstar%d: Error pushing TBD.\n", card->index); push_scqe()
1742 card->index); push_scqe()
1750 card->index, skb, index); push_scqe()
1752 card->index, le32_to_cpu(tbd->word_1), le32_to_cpu(tbd->word_2), push_scqe()
1774 ns_write_sram(card, scq->scd, &data, 1); push_scqe()
1777 card->index); push_scqe()
1806 card->index, le32_to_cpu(tsr.word_1), push_scqe()
1817 card->index); push_scqe()
1820 ns_write_sram(card, scq->scd, &data, 1); push_scqe()
1827 static void process_tsq(ns_dev * card) process_tsq() argument
1836 if (card->tsq.next == card->tsq.last) process_tsq()
1837 one_ahead = card->tsq.base; process_tsq()
1839 one_ahead = card->tsq.next + 1; process_tsq()
1841 if (one_ahead == card->tsq.last) process_tsq()
1842 two_ahead = card->tsq.base; process_tsq()
1846 while (!ns_tsi_isempty(card->tsq.next) || !ns_tsi_isempty(one_ahead) || process_tsq()
1853 while (ns_tsi_isempty(card->tsq.next)) { process_tsq()
1854 if (card->tsq.next == card->tsq.last) process_tsq()
1855 card->tsq.next = card->tsq.base; process_tsq()
1857 card->tsq.next++; process_tsq()
1860 if (!ns_tsi_tmrof(card->tsq.next)) { process_tsq()
1861 scdi = ns_tsi_getscdindex(card->tsq.next); process_tsq()
1863 scq = card->scq0; process_tsq()
1865 if (card->scd2vc[scdi] == NULL) { process_tsq()
1868 card->index); process_tsq()
1869 ns_tsi_init(card->tsq.next); process_tsq()
1872 scq = card->scd2vc[scdi]->scq; process_tsq()
1874 drain_scq(card, scq, ns_tsi_getscqpos(card->tsq.next)); process_tsq()
1879 ns_tsi_init(card->tsq.next); process_tsq()
1880 previous = card->tsq.next; process_tsq()
1881 if (card->tsq.next == card->tsq.last) process_tsq()
1882 card->tsq.next = card->tsq.base; process_tsq()
1884 card->tsq.next++; process_tsq()
1886 if (card->tsq.next == card->tsq.last) process_tsq()
1887 one_ahead = card->tsq.base; process_tsq()
1889 one_ahead = card->tsq.next + 1; process_tsq()
1891 if (one_ahead == card->tsq.last) process_tsq()
1892 two_ahead = card->tsq.base; process_tsq()
1898 writel(PTR_DIFF(previous, card->tsq.base), process_tsq()
1899 card->membase + TSQH); process_tsq()
1902 static void drain_scq(ns_dev * card, scq_info * scq, int pos) drain_scq() argument
1910 card->index, scq, pos); drain_scq()
1912 printk("nicstar%d: Bad index on drain_scq().\n", card->index); drain_scq()
1923 card->index, skb, i); drain_scq()
1925 dma_unmap_single(&card->pcidev->dev, drain_scq()
1944 static void process_rsq(ns_dev * card) process_rsq() argument
1948 if (!ns_rsqe_valid(card->rsq.next)) process_rsq()
1951 dequeue_rx(card, card->rsq.next); process_rsq()
1952 ns_rsqe_init(card->rsq.next); process_rsq()
1953 previous = card->rsq.next; process_rsq()
1954 if (card->rsq.next == card->rsq.last) process_rsq()
1955 card->rsq.next = card->rsq.base; process_rsq()
1957 card->rsq.next++; process_rsq()
1958 } while (ns_rsqe_valid(card->rsq.next)); process_rsq()
1959 writel(PTR_DIFF(previous, card->rsq.base), card->membase + RSQH); process_rsq()
1962 static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe) dequeue_rx() argument
1975 stat = readl(card->membase + STAT); dequeue_rx()
1976 card->sbfqc = ns_stat_sfbqc_get(stat); dequeue_rx()
1977 card->lbfqc = ns_stat_lfbqc_get(stat); dequeue_rx()
1980 skb = idr_find(&card->idr, id); dequeue_rx()
1983 "nicstar%d: idr_find() failed!\n", card->index); dequeue_rx()
1986 idr_remove(&card->idr, id); dequeue_rx()
1987 dma_sync_single_for_cpu(&card->pcidev->dev, dequeue_rx()
1992 dma_unmap_single(&card->pcidev->dev, dequeue_rx()
1999 if (vpi >= 1UL << card->vpibits || vci >= 1UL << card->vcibits) { dequeue_rx()
2001 card->index, vpi, vci); dequeue_rx()
2002 recycle_rx_buf(card, skb); dequeue_rx()
2006 vc = &(card->vcmap[vpi << card->vcibits | vci]); dequeue_rx()
2009 card->index, vpi, vci); dequeue_rx()
2010 recycle_rx_buf(card, skb); dequeue_rx()
2026 card->index); dequeue_rx()
2033 card->index); dequeue_rx()
2053 recycle_rx_buf(card, skb); dequeue_rx()
2060 iovb = skb_dequeue(&(card->iovpool.queue)); dequeue_rx()
2065 card->index); dequeue_rx()
2067 recycle_rx_buf(card, skb); dequeue_rx()
2071 } else if (--card->iovpool.count < card->iovnr.min) { dequeue_rx()
2076 skb_queue_tail(&card->iovpool.queue, new_iovb); dequeue_rx()
2077 card->iovpool.count++; dequeue_rx()
2089 printk("nicstar%d: received too big AAL5 SDU.\n", card->index); dequeue_rx()
2091 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data, dequeue_rx()
2108 card->index); dequeue_rx()
2109 which_list(card, skb); dequeue_rx()
2111 recycle_rx_buf(card, skb); dequeue_rx()
2113 recycle_iov_buf(card, iovb); dequeue_rx()
2121 card->index); dequeue_rx()
2122 which_list(card, skb); dequeue_rx()
2124 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data, dequeue_rx()
2127 recycle_iov_buf(card, iovb); dequeue_rx()
2141 printk("nicstar%d: AAL5 CRC error", card->index); dequeue_rx()
2147 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data, dequeue_rx()
2150 recycle_iov_buf(card, iovb); dequeue_rx()
2159 push_rxbufs(card, skb); dequeue_rx()
2163 dequeue_sm_buf(card, skb); dequeue_rx()
2177 push_rxbufs(card, sb); dequeue_rx()
2181 dequeue_sm_buf(card, sb); dequeue_rx()
2188 push_rxbufs(card, skb); dequeue_rx()
2193 push_rxbufs(card, skb); dequeue_rx()
2196 dequeue_lg_buf(card, skb); dequeue_rx()
2207 push_rxbufs(card, sb); dequeue_rx()
2217 hb = skb_dequeue(&(card->hbpool.queue)); dequeue_rx()
2224 card->index); dequeue_rx()
2226 recycle_iovec_rx_bufs(card, dequeue_rx()
2231 recycle_iov_buf(card, iovb); dequeue_rx()
2233 } else if (card->hbpool.count < card->hbnr.min) { dequeue_rx()
2238 skb_queue_tail(&card->hbpool. dequeue_rx()
2240 card->hbpool.count++; dequeue_rx()
2244 } else if (--card->hbpool.count < card->hbnr.min) { dequeue_rx()
2249 skb_queue_tail(&card->hbpool.queue, dequeue_rx()
2251 card->hbpool.count++; dequeue_rx()
2253 if (card->hbpool.count < card->hbnr.min) { dequeue_rx()
2259 skb_queue_tail(&card->hbpool. dequeue_rx()
2261 card->hbpool.count++; dequeue_rx()
2269 recycle_iovec_rx_bufs(card, iov, dequeue_rx()
2271 if (card->hbpool.count < card->hbnr.max) { dequeue_rx()
2272 skb_queue_tail(&card->hbpool.queue, hb); dequeue_rx()
2273 card->hbpool.count++; dequeue_rx()
2286 push_rxbufs(card, sb); dequeue_rx()
2299 push_rxbufs(card, lb); dequeue_rx()
2305 card->index); dequeue_rx()
2315 recycle_iov_buf(card, iovb); dequeue_rx()
2320 static void recycle_rx_buf(ns_dev * card, struct sk_buff *skb) recycle_rx_buf() argument
2324 card->index); recycle_rx_buf()
2327 push_rxbufs(card, skb); recycle_rx_buf()
2330 static void recycle_iovec_rx_bufs(ns_dev * card, struct iovec *iov, int count) recycle_iovec_rx_bufs() argument
2333 recycle_rx_buf(card, (struct sk_buff *)(iov++)->iov_base); recycle_iovec_rx_bufs()
2336 static void recycle_iov_buf(ns_dev * card, struct sk_buff *iovb) recycle_iov_buf() argument
2338 if (card->iovpool.count < card->iovnr.max) { recycle_iov_buf()
2339 skb_queue_tail(&card->iovpool.queue, iovb); recycle_iov_buf()
2340 card->iovpool.count++; recycle_iov_buf()
2345 static void dequeue_sm_buf(ns_dev * card, struct sk_buff *sb) dequeue_sm_buf() argument
2347 skb_unlink(sb, &card->sbpool.queue); dequeue_sm_buf()
2348 if (card->sbfqc < card->sbnr.init) { dequeue_sm_buf()
2352 skb_queue_tail(&card->sbpool.queue, new_sb); dequeue_sm_buf()
2354 push_rxbufs(card, new_sb); dequeue_sm_buf()
2357 if (card->sbfqc < card->sbnr.init) dequeue_sm_buf()
2362 skb_queue_tail(&card->sbpool.queue, new_sb); dequeue_sm_buf()
2364 push_rxbufs(card, new_sb); dequeue_sm_buf()
2369 static void dequeue_lg_buf(ns_dev * card, struct sk_buff *lb) dequeue_lg_buf() argument
2371 skb_unlink(lb, &card->lbpool.queue); dequeue_lg_buf()
2372 if (card->lbfqc < card->lbnr.init) { dequeue_lg_buf()
2376 skb_queue_tail(&card->lbpool.queue, new_lb); dequeue_lg_buf()
2378 push_rxbufs(card, new_lb); dequeue_lg_buf()
2381 if (card->lbfqc < card->lbnr.init) dequeue_lg_buf()
2386 skb_queue_tail(&card->lbpool.queue, new_lb); dequeue_lg_buf()
2388 push_rxbufs(card, new_lb); dequeue_lg_buf()
2396 ns_dev *card; ns_proc_read() local
2400 card = (ns_dev *) dev->dev_data; ns_proc_read()
2401 stat = readl(card->membase + STAT); ns_proc_read()
2406 ns_stat_sfbqc_get(stat), card->sbnr.min, ns_proc_read()
2407 card->sbnr.init, card->sbnr.max); ns_proc_read()
2410 ns_stat_lfbqc_get(stat), card->lbnr.min, ns_proc_read()
2411 card->lbnr.init, card->lbnr.max); ns_proc_read()
2414 card->hbpool.count, card->hbnr.min, ns_proc_read()
2415 card->hbnr.init, card->hbnr.max); ns_proc_read()
2418 card->iovpool.count, card->iovnr.min, ns_proc_read()
2419 card->iovnr.init, card->iovnr.max); ns_proc_read()
2423 sprintf(page, "Interrupt counter: %u \n", card->intcnt); ns_proc_read()
2424 card->intcnt = 0; ns_proc_read()
2431 if (card->max_pcr == ATM_25_PCR && !left--) { ns_proc_read()
2436 while (CMD_BUSY(card)) ; ns_proc_read()
2438 card->membase + CMD); ns_proc_read()
2439 while (CMD_BUSY(card)) ; ns_proc_read()
2440 phy_regs[i] = readl(card->membase + DR0) & 0x000000FF; ns_proc_read()
2451 if (card->tste2vc[left + 1] == NULL) ns_proc_read()
2455 card->tste2vc[left + 1]->tx_vcc->vpi, ns_proc_read()
2456 card->tste2vc[left + 1]->tx_vcc->vci); ns_proc_read()
2464 ns_dev *card; ns_ioctl() local
2469 card = dev->dev_data; ns_ioctl()
2478 ns_stat_sfbqc_get(readl(card->membase + STAT)); ns_ioctl()
2479 pl.level.min = card->sbnr.min; ns_ioctl()
2480 pl.level.init = card->sbnr.init; ns_ioctl()
2481 pl.level.max = card->sbnr.max; ns_ioctl()
2486 ns_stat_lfbqc_get(readl(card->membase + STAT)); ns_ioctl()
2487 pl.level.min = card->lbnr.min; ns_ioctl()
2488 pl.level.init = card->lbnr.init; ns_ioctl()
2489 pl.level.max = card->lbnr.max; ns_ioctl()
2493 pl.count = card->hbpool.count; ns_ioctl()
2494 pl.level.min = card->hbnr.min; ns_ioctl()
2495 pl.level.init = card->hbnr.init; ns_ioctl()
2496 pl.level.max = card->hbnr.max; ns_ioctl()
2500 pl.count = card->iovpool.count; ns_ioctl()
2501 pl.level.min = card->iovnr.min; ns_ioctl()
2502 pl.level.init = card->iovnr.init; ns_ioctl()
2503 pl.level.max = card->iovnr.max; ns_ioctl()
2529 card->sbnr.min = pl.level.min; ns_ioctl()
2530 card->sbnr.init = pl.level.init; ns_ioctl()
2531 card->sbnr.max = pl.level.max; ns_ioctl()
2537 card->lbnr.min = pl.level.min; ns_ioctl()
2538 card->lbnr.init = pl.level.init; ns_ioctl()
2539 card->lbnr.max = pl.level.max; ns_ioctl()
2545 card->hbnr.min = pl.level.min; ns_ioctl()
2546 card->hbnr.init = pl.level.init; ns_ioctl()
2547 card->hbnr.max = pl.level.max; ns_ioctl()
2553 card->iovnr.min = pl.level.min; ns_ioctl()
2554 card->iovnr.init = pl.level.init; ns_ioctl()
2555 card->iovnr.max = pl.level.max; ns_ioctl()
2570 while (card->sbfqc < card->sbnr.init) { ns_ioctl()
2577 skb_queue_tail(&card->sbpool.queue, sb); ns_ioctl()
2579 push_rxbufs(card, sb); ns_ioctl()
2584 while (card->lbfqc < card->lbnr.init) { ns_ioctl()
2591 skb_queue_tail(&card->lbpool.queue, lb); ns_ioctl()
2593 push_rxbufs(card, lb); ns_ioctl()
2598 while (card->hbpool.count > card->hbnr.init) { ns_ioctl()
2601 spin_lock_irqsave(&card->int_lock, flags); ns_ioctl()
2602 hb = skb_dequeue(&card->hbpool.queue); ns_ioctl()
2603 card->hbpool.count--; ns_ioctl()
2604 spin_unlock_irqrestore(&card->int_lock, flags); ns_ioctl()
2608 card->index); ns_ioctl()
2613 while (card->hbpool.count < card->hbnr.init) { ns_ioctl()
2620 spin_lock_irqsave(&card->int_lock, flags); ns_ioctl()
2621 skb_queue_tail(&card->hbpool.queue, hb); ns_ioctl()
2622 card->hbpool.count++; ns_ioctl()
2623 spin_unlock_irqrestore(&card->int_lock, flags); ns_ioctl()
2628 while (card->iovpool.count > card->iovnr.init) { ns_ioctl()
2631 spin_lock_irqsave(&card->int_lock, flags); ns_ioctl()
2632 iovb = skb_dequeue(&card->iovpool.queue); ns_ioctl()
2633 card->iovpool.count--; ns_ioctl()
2634 spin_unlock_irqrestore(&card->int_lock, flags); ns_ioctl()
2638 card->index); ns_ioctl()
2643 while (card->iovpool.count < card->iovnr.init) { ns_ioctl()
2650 spin_lock_irqsave(&card->int_lock, flags); ns_ioctl()
2651 skb_queue_tail(&card->iovpool.queue, iovb); ns_ioctl()
2652 card->iovpool.count++; ns_ioctl()
2653 spin_unlock_irqrestore(&card->int_lock, flags); ns_ioctl()
2667 printk("nicstar%d: %s == NULL \n", card->index, ns_ioctl()
2675 static void which_list(ns_dev * card, struct sk_buff *skb) which_list() argument
2684 ns_dev *card; ns_poll() local
2690 card = cards[i]; ns_poll()
2691 if (spin_is_locked(&card->int_lock)) { ns_poll()
2695 spin_lock_irqsave(&card->int_lock, flags); ns_poll()
2698 stat_r = readl(card->membase + STAT); ns_poll()
2704 process_tsq(card); ns_poll()
2705 process_rsq(card); ns_poll()
2707 writel(stat_w, card->membase + STAT); ns_poll()
2708 spin_unlock_irqrestore(&card->int_lock, flags); ns_poll()
2717 ns_dev *card; ns_phy_put() local
2720 card = dev->dev_data; ns_phy_put()
2721 spin_lock_irqsave(&card->res_lock, flags); ns_phy_put()
2722 while (CMD_BUSY(card)) ; ns_phy_put()
2723 writel((u32) value, card->membase + DR0); ns_phy_put()
2725 card->membase + CMD); ns_phy_put()
2726 spin_unlock_irqrestore(&card->res_lock, flags); ns_phy_put()
2731 ns_dev *card; ns_phy_get() local
2735 card = dev->dev_data; ns_phy_get()
2736 spin_lock_irqsave(&card->res_lock, flags); ns_phy_get()
2737 while (CMD_BUSY(card)) ; ns_phy_get()
2739 card->membase + CMD); ns_phy_get()
2740 while (CMD_BUSY(card)) ; ns_phy_get()
2741 data = readl(card->membase + DR0) & 0x000000FF; ns_phy_get()
2742 spin_unlock_irqrestore(&card->res_lock, flags); ns_phy_get()
H A Dsolos-pci.c2 * Driver for the Solos PCI ADSL2+ card, designed to support Linux by
76 #define RX_BUF(card, nr) ((card->buffers) + (nr)*(card->buffer_size)*2)
77 #define TX_BUF(card, nr) ((card->buffers) + (nr)*(card->buffer_size)*2 + (card->buffer_size))
78 #define FLASH_BUF ((card->buffers) + 4*(card->buffer_size)*2)
171 static void fpga_queue(struct solos_card *card, int port, struct sk_buff *skb,
178 static int send_command(struct solos_card *card, int dev, const char *buf, size_t size);
194 struct solos_card *card = atmdev->dev_data; solos_param_show() local
204 dev_warn(&card->dev->dev, "Failed to allocate sk_buff in solos_param_show()\n"); solos_param_show()
223 spin_lock_irq(&card->param_queue_lock); solos_param_show()
224 list_add(&prm.list, &card->param_queue); solos_param_show()
225 spin_unlock_irq(&card->param_queue_lock); solos_param_show()
227 fpga_queue(card, prm.port, skb, NULL); solos_param_show()
229 wait_event_timeout(card->param_wq, prm.response, 5 * HZ); solos_param_show()
231 spin_lock_irq(&card->param_queue_lock); solos_param_show()
233 spin_unlock_irq(&card->param_queue_lock); solos_param_show()
249 struct solos_card *card = atmdev->dev_data; solos_param_store() local
260 dev_warn(&card->dev->dev, "Failed to allocate sk_buff in solos_param_store()\n"); solos_param_store()
279 spin_lock_irq(&card->param_queue_lock); solos_param_store()
280 list_add(&prm.list, &card->param_queue); solos_param_store()
281 spin_unlock_irq(&card->param_queue_lock); solos_param_store()
283 fpga_queue(card, prm.port, skb, NULL); solos_param_store()
285 wait_event_timeout(card->param_wq, prm.response, 5 * HZ); solos_param_store()
287 spin_lock_irq(&card->param_queue_lock); solos_param_store()
289 spin_unlock_irq(&card->param_queue_lock); solos_param_store()
311 dev_warn(&card->dev->dev, "Unexpected parameter response: '%s'\n", solos_param_store()
348 static int process_status(struct solos_card *card, int port, struct sk_buff *skb) process_status() argument
353 if (!card->atmdev[port]) process_status()
362 dev_warn(&card->dev->dev, "Unexpected status interrupt version %d\n", process_status()
371 dev_dbg(&card->dev->dev, "Status packet indicated Solos error on port %d (starting up?)\n", process_status()
393 atm_dev_signal_change(card->atmdev[port], ATM_PHY_SIG_LOST); process_status()
394 dev_info(&card->dev->dev, "Port %d: %s\n", port, state_str); process_status()
405 dev_info(&card->dev->dev, "Port %d: %s @%d/%d kb/s%s%s%s%s\n", process_status()
409 card->atmdev[port]->link_rate = rate_down / 424; process_status()
410 atm_dev_signal_change(card->atmdev[port], ATM_PHY_SIG_FOUND); process_status()
415 static int process_command(struct solos_card *card, int port, struct sk_buff *skb) process_command() argument
433 spin_lock_irqsave(&card->param_queue_lock, flags); process_command()
434 list_for_each_entry(prm, &card->param_queue, list) { process_command()
438 wake_up(&card->param_wq); process_command()
443 spin_unlock_irqrestore(&card->param_queue_lock, flags); process_command()
451 struct solos_card *card = atmdev->dev_data; console_show() local
455 spin_lock(&card->cli_queue_lock); console_show()
456 skb = skb_dequeue(&card->cli_queue[SOLOS_CHAN(atmdev)]); console_show()
457 spin_unlock(&card->cli_queue_lock); console_show()
468 static int send_command(struct solos_card *card, int dev, const char *buf, size_t size) send_command() argument
474 dev_dbg(&card->dev->dev, "Command is too big. Dropping request\n"); send_command()
479 dev_warn(&card->dev->dev, "Failed to allocate sk_buff in send_command()\n"); send_command()
492 fpga_queue(card, dev, skb, NULL); send_command()
501 struct solos_card *card = atmdev->dev_data; console_store() local
504 err = send_command(card, SOLOS_CHAN(atmdev), buf, count); console_store()
524 struct solos_card *card = pci_get_drvdata(pdev); geos_gpio_store() local
530 spin_lock_irq(&card->param_queue_lock); geos_gpio_store()
531 data32 = ioread32(card->config_regs + GPIO_STATUS); geos_gpio_store()
534 iowrite32(data32, card->config_regs + GPIO_STATUS); geos_gpio_store()
537 iowrite32(data32, card->config_regs + GPIO_STATUS); geos_gpio_store()
541 spin_unlock_irq(&card->param_queue_lock); geos_gpio_store()
550 struct solos_card *card = pci_get_drvdata(pdev); geos_gpio_show() local
553 data32 = ioread32(card->config_regs + GPIO_STATUS); geos_gpio_show()
564 struct solos_card *card = pci_get_drvdata(pdev); hardware_show() local
567 data32 = ioread32(card->config_regs + GPIO_STATUS); hardware_show()
630 static int flash_upgrade(struct solos_card *card, int chip) flash_upgrade() argument
641 if (card->atmel_flash) flash_upgrade()
648 if (card->atmel_flash) flash_upgrade()
654 if (card->fpga_version > LEGACY_BUFFERS){ flash_upgrade()
656 if (card->atmel_flash) flash_upgrade()
661 dev_info(&card->dev->dev, "FPGA version doesn't support" flash_upgrade()
667 if (card->fpga_version > LEGACY_BUFFERS){ flash_upgrade()
669 if (card->atmel_flash) flash_upgrade()
674 dev_info(&card->dev->dev, "FPGA version doesn't support" flash_upgrade()
683 if (request_firmware(&fw, fw_name, &card->dev->dev)) flash_upgrade()
686 dev_info(&card->dev->dev, "Flash upgrade starting\n"); flash_upgrade()
689 iowrite32(DRIVER_VERSION, card->config_regs + DRIVER_VER); flash_upgrade()
692 dev_info(&card->dev->dev, "Firmware size: %zd\n", fw->size); flash_upgrade()
693 dev_info(&card->dev->dev, "Number of blocks: %d\n", numblocks); flash_upgrade()
695 dev_info(&card->dev->dev, "Changing FPGA to Update mode\n"); flash_upgrade()
696 iowrite32(1, card->config_regs + FPGA_MODE); flash_upgrade()
697 (void) ioread32(card->config_regs + FPGA_MODE); flash_upgrade()
701 dev_info(&card->dev->dev, "Set FPGA Flash mode to FPGA Chip Erase\n"); flash_upgrade()
703 dev_info(&card->dev->dev, "Set FPGA Flash mode to Solos Chip Erase\n"); flash_upgrade()
704 iowrite32((chip * 2), card->config_regs + FLASH_MODE); flash_upgrade()
707 iowrite32(1, card->config_regs + WRITE_FLASH); flash_upgrade()
708 wait_event(card->fw_wq, !ioread32(card->config_regs + FLASH_BUSY)); flash_upgrade()
714 iowrite32(0, card->config_regs + WRITE_FLASH); flash_upgrade()
717 /* dev_info(&card->dev->dev, "Set FPGA Flash mode to Block Write\n"); */ flash_upgrade()
718 iowrite32(((chip * 2) + 1), card->config_regs + FLASH_MODE); flash_upgrade()
723 if (card->atmel_flash) flash_upgrade()
727 if(card->fpga_version > LEGACY_BUFFERS) flash_upgrade()
730 iowrite32(word, RX_BUF(card, 3) + i); flash_upgrade()
734 iowrite32(offset / blocksize, card->config_regs + FLASH_BLOCK); flash_upgrade()
735 iowrite32(1, card->config_regs + WRITE_FLASH); flash_upgrade()
736 wait_event(card->fw_wq, !ioread32(card->config_regs + FLASH_BUSY)); flash_upgrade()
740 iowrite32(0, card->config_regs + WRITE_FLASH); flash_upgrade()
741 iowrite32(0, card->config_regs + FPGA_MODE); flash_upgrade()
742 iowrite32(0, card->config_regs + FLASH_MODE); flash_upgrade()
743 dev_info(&card->dev->dev, "Returning FPGA to Data mode\n"); flash_upgrade()
749 struct solos_card *card = dev_id; solos_irq() local
752 iowrite32(0, card->config_regs + IRQ_CLEAR); solos_irq()
755 if (card->atmdev[0]) solos_irq()
756 tasklet_schedule(&card->tlet); solos_irq()
758 wake_up(&card->fw_wq); solos_irq()
765 struct solos_card *card = (void *)card_arg; solos_bh() local
775 card_flags = fpga_tx(card); solos_bh()
777 for (port = 0; port < card->nr_ports; port++) { solos_bh()
784 if (card->using_dma) { solos_bh()
785 skb = card->rx_skb[port]; solos_bh()
786 card->rx_skb[port] = NULL; solos_bh()
788 dma_unmap_single(&card->dev->dev, SKB_CB(skb)->dma_addr, solos_bh()
800 memcpy_fromio(header, RX_BUF(card, port), sizeof(*header)); solos_bh()
803 if (size > (card->buffer_size - sizeof(*header))){ solos_bh()
804 dev_warn(&card->dev->dev, "Invalid buffer size\n"); solos_bh()
811 dev_warn(&card->dev->dev, "Failed to allocate sk_buff for RX\n"); solos_bh()
816 RX_BUF(card, port) + sizeof(*header), solos_bh()
820 dev_info(&card->dev->dev, "Received: port %d\n", port); solos_bh()
821 dev_info(&card->dev->dev, "size: %d VPI: %d VCI: %d\n", solos_bh()
829 vcc = find_vcc(card->atmdev[port], le16_to_cpu(header->vpi), solos_bh()
833 dev_warn(&card->dev->dev, "Received packet for unknown VPI.VCI %d.%d on port %d\n", solos_bh()
845 if (process_status(card, port, skb) && solos_bh()
847 dev_warn(&card->dev->dev, "Bad status packet of %d bytes on port %d:\n", skb->len, port); solos_bh()
855 if (process_command(card, port, skb)) solos_bh()
857 spin_lock(&card->cli_queue_lock); solos_bh()
858 if (skb_queue_len(&card->cli_queue[port]) > 10) { solos_bh()
860 dev_warn(&card->dev->dev, "Dropping console response on port %d\n", solos_bh()
864 skb_queue_tail(&card->cli_queue[port], skb); solos_bh()
865 spin_unlock(&card->cli_queue_lock); solos_bh()
870 if (card->using_dma && card->atmdev[port] && solos_bh()
871 !card->rx_skb[port]) { solos_bh()
875 dma_map_single(&card->dev->dev, skb->data, solos_bh()
878 card->config_regs + RX_DMA_ADDR(port)); solos_bh()
879 card->rx_skb[port] = skb; solos_bh()
882 dev_warn(&card->dev->dev, "Failed to allocate RX skb"); solos_bh()
885 tasklet_schedule(&card->tlet); solos_bh()
890 iowrite32(rx_done, card->config_regs + FLAGS_ADDR); solos_bh()
918 struct solos_card *card = vcc->dev->dev_data; popen() local
923 dev_warn(&card->dev->dev, "Unsupported ATM type %d\n", popen()
931 dev_warn(&card->dev->dev, "Failed to allocate sk_buff in popen()\n"); popen()
941 fpga_queue(card, SOLOS_CHAN(vcc->dev), skb, NULL); popen()
951 struct solos_card *card = vcc->dev->dev_data; pclose() local
957 spin_lock(&card->tx_queue_lock); pclose()
958 skb_queue_walk_safe(&card->tx_queue[port], skb, tmpskb) { pclose()
960 skb_unlink(skb, &card->tx_queue[port]); pclose()
964 spin_unlock(&card->tx_queue_lock); pclose()
968 dev_warn(&card->dev->dev, "Failed to allocate sk_buff in pclose()\n"); pclose()
979 fpga_queue(card, port, skb, NULL); pclose()
981 if (!wait_event_timeout(card->param_wq, !skb_shared(skb), 5 * HZ)) pclose()
982 dev_warn(&card->dev->dev, pclose()
990 tasklet_unlock_wait(&card->tlet); pclose()
1026 static void fpga_queue(struct solos_card *card, int port, struct sk_buff *skb, fpga_queue() argument
1034 spin_lock_irqsave(&card->tx_queue_lock, flags); fpga_queue()
1035 old_len = skb_queue_len(&card->tx_queue[port]); fpga_queue()
1036 skb_queue_tail(&card->tx_queue[port], skb); fpga_queue()
1038 card->tx_mask |= (1 << port); fpga_queue()
1039 spin_unlock_irqrestore(&card->tx_queue_lock, flags); fpga_queue()
1044 fpga_tx(card); fpga_queue()
1047 static uint32_t fpga_tx(struct solos_card *card) fpga_tx() argument
1056 spin_lock_irqsave(&card->tx_lock, flags); fpga_tx()
1058 card_flags = ioread32(card->config_regs + FLAGS_ADDR); fpga_tx()
1066 tx_pending = card->tx_mask & ~card_flags; fpga_tx()
1070 struct sk_buff *oldskb = card->tx_skb[port]; fpga_tx()
1072 dma_unmap_single(&card->dev->dev, SKB_CB(oldskb)->dma_addr, fpga_tx()
1074 card->tx_skb[port] = NULL; fpga_tx()
1076 spin_lock(&card->tx_queue_lock); fpga_tx()
1077 skb = skb_dequeue(&card->tx_queue[port]); fpga_tx()
1079 card->tx_mask &= ~(1 << port); fpga_tx()
1080 spin_unlock(&card->tx_queue_lock); fpga_tx()
1082 if (skb && !card->using_dma) { fpga_tx()
1083 memcpy_toio(TX_BUF(card, port), skb->data, skb->len); fpga_tx()
1086 } else if (skb && card->using_dma) { fpga_tx()
1088 if ((unsigned long)data & card->dma_alignment) { fpga_tx()
1089 data = card->dma_bounce + (BUF_SIZE * port); fpga_tx()
1092 SKB_CB(skb)->dma_addr = dma_map_single(&card->dev->dev, data, fpga_tx()
1094 card->tx_skb[port] = skb; fpga_tx()
1096 card->config_regs + TX_DMA_ADDR(port)); fpga_tx()
1108 dev_info(&card->dev->dev, "Transmitted: port %d\n", fpga_tx()
1110 dev_info(&card->dev->dev, "size: %d VPI: %d VCI: %d\n", fpga_tx()
1123 wake_up(&card->param_wq); fpga_tx()
1129 iowrite32(tx_started, card->config_regs + FLAGS_ADDR); fpga_tx()
1131 spin_unlock_irqrestore(&card->tx_lock, flags); fpga_tx()
1137 struct solos_card *card = vcc->dev->dev_data; psend() local
1143 dev_warn(&card->dev->dev, "Length of PDU is too large. Dropping PDU.\n"); psend()
1157 dev_warn(&card->dev->dev, "pskb_expand_head failed.\n"); psend()
1171 fpga_queue(card, SOLOS_CHAN(vcc->dev), skb, vcc); psend()
1197 struct solos_card *card; fpga_probe() local
1199 card = kzalloc(sizeof(*card), GFP_KERNEL); fpga_probe()
1200 if (!card) fpga_probe()
1203 card->dev = dev; fpga_probe()
1204 init_waitqueue_head(&card->fw_wq); fpga_probe()
1205 init_waitqueue_head(&card->param_wq); fpga_probe()
1225 card->config_regs = pci_iomap(dev, 0, CONFIG_RAM_SIZE); fpga_probe()
1226 if (!card->config_regs) { fpga_probe()
1231 card->buffers = pci_iomap(dev, 1, DATA_RAM_SIZE); fpga_probe()
1232 if (!card->buffers) { fpga_probe()
1239 iowrite32(1, card->config_regs + FPGA_MODE); fpga_probe()
1240 data32 = ioread32(card->config_regs + FPGA_MODE); fpga_probe()
1242 iowrite32(0, card->config_regs + FPGA_MODE); fpga_probe()
1243 data32 = ioread32(card->config_regs + FPGA_MODE); fpga_probe()
1246 data32 = ioread32(card->config_regs + FPGA_VER); fpga_probe()
1250 card->fpga_version = FPGA_VERSION(major_ver,minor_ver); fpga_probe()
1251 if (card->fpga_version > LEGACY_BUFFERS) fpga_probe()
1252 card->buffer_size = BUF_SIZE; fpga_probe()
1254 card->buffer_size = OLD_BUF_SIZE; fpga_probe()
1268 card->atmel_flash = 1; fpga_probe()
1270 card->atmel_flash = 0; fpga_probe()
1272 data32 = ioread32(card->config_regs + PORTS); fpga_probe()
1273 card->nr_ports = (data32 & 0x000000FF); fpga_probe()
1275 if (card->fpga_version >= DMA_SUPPORTED) { fpga_probe()
1277 card->using_dma = 1; fpga_probe()
1279 card->dma_alignment = 3; fpga_probe()
1280 card->dma_bounce = kmalloc(card->nr_ports * BUF_SIZE, GFP_KERNEL); fpga_probe()
1281 if (!card->dma_bounce) { fpga_probe()
1282 dev_warn(&card->dev->dev, "Failed to allocate DMA bounce buffers\n"); fpga_probe()
1289 card->using_dma = 0; fpga_probe()
1291 iowrite32(0xF0, card->config_regs + FLAGS_ADDR); fpga_probe()
1294 pci_set_drvdata(dev, card); fpga_probe()
1296 tasklet_init(&card->tlet, solos_bh, (unsigned long)card); fpga_probe()
1297 spin_lock_init(&card->tx_lock); fpga_probe()
1298 spin_lock_init(&card->tx_queue_lock); fpga_probe()
1299 spin_lock_init(&card->cli_queue_lock); fpga_probe()
1300 spin_lock_init(&card->param_queue_lock); fpga_probe()
1301 INIT_LIST_HEAD(&card->param_queue); fpga_probe()
1304 "solos-pci", card); fpga_probe()
1306 dev_dbg(&card->dev->dev, "Failed to request interrupt IRQ: %d\n", dev->irq); fpga_probe()
1310 iowrite32(1, card->config_regs + IRQ_EN_ADDR); fpga_probe()
1313 flash_upgrade(card, 0); fpga_probe()
1316 flash_upgrade(card, 1); fpga_probe()
1319 flash_upgrade(card, 2); fpga_probe()
1322 flash_upgrade(card, 3); fpga_probe()
1324 err = atm_init(card, &dev->dev); fpga_probe()
1328 if (card->fpga_version >= DMA_SUPPORTED && fpga_probe()
1329 sysfs_create_group(&card->dev->dev.kobj, &gpio_attr_group)) fpga_probe()
1330 dev_err(&card->dev->dev, "Could not register parameter group for GPIOs\n"); fpga_probe()
1335 iowrite32(0, card->config_regs + IRQ_EN_ADDR); fpga_probe()
1336 free_irq(dev->irq, card); fpga_probe()
1337 tasklet_kill(&card->tlet); fpga_probe()
1340 kfree(card->dma_bounce); fpga_probe()
1341 pci_iounmap(dev, card->buffers); fpga_probe()
1343 pci_iounmap(dev, card->config_regs); fpga_probe()
1347 kfree(card); fpga_probe()
1351 static int atm_init(struct solos_card *card, struct device *parent) atm_init() argument
1355 for (i = 0; i < card->nr_ports; i++) { atm_init()
1359 skb_queue_head_init(&card->tx_queue[i]); atm_init()
1360 skb_queue_head_init(&card->cli_queue[i]); atm_init()
1362 card->atmdev[i] = atm_dev_register("solos-pci", parent, &fpga_ops, -1, NULL); atm_init()
1363 if (!card->atmdev[i]) { atm_init()
1364 dev_err(&card->dev->dev, "Could not register ATM device %d\n", i); atm_init()
1365 atm_remove(card); atm_init()
1368 if (device_create_file(&card->atmdev[i]->class_dev, &dev_attr_console)) atm_init()
1369 dev_err(&card->dev->dev, "Could not register console for ATM device %d\n", i); atm_init()
1370 if (sysfs_create_group(&card->atmdev[i]->class_dev.kobj, &solos_attr_group)) atm_init()
1371 dev_err(&card->dev->dev, "Could not register parameter group for ATM device %d\n", i); atm_init()
1373 dev_info(&card->dev->dev, "Registered ATM device %d\n", card->atmdev[i]->number); atm_init()
1375 card->atmdev[i]->ci_range.vpi_bits = 8; atm_init()
1376 card->atmdev[i]->ci_range.vci_bits = 16; atm_init()
1377 card->atmdev[i]->dev_data = card; atm_init()
1378 card->atmdev[i]->phy_data = (void *)(unsigned long)i; atm_init()
1379 atm_dev_signal_change(card->atmdev[i], ATM_PHY_SIG_FOUND); atm_init()
1383 dev_warn(&card->dev->dev, "Failed to allocate sk_buff in atm_init()\n"); atm_init()
1394 fpga_queue(card, i, skb, NULL); atm_init()
1399 static void atm_remove(struct solos_card *card) atm_remove() argument
1403 for (i = 0; i < card->nr_ports; i++) { atm_remove()
1404 if (card->atmdev[i]) { atm_remove()
1407 dev_info(&card->dev->dev, "Unregistering ATM device %d\n", card->atmdev[i]->number); atm_remove()
1409 sysfs_remove_group(&card->atmdev[i]->class_dev.kobj, &solos_attr_group); atm_remove()
1410 atm_dev_deregister(card->atmdev[i]); atm_remove()
1412 skb = card->rx_skb[i]; atm_remove()
1414 dma_unmap_single(&card->dev->dev, SKB_CB(skb)->dma_addr, atm_remove()
1418 skb = card->tx_skb[i]; atm_remove()
1420 dma_unmap_single(&card->dev->dev, SKB_CB(skb)->dma_addr, atm_remove()
1424 while ((skb = skb_dequeue(&card->tx_queue[i]))) atm_remove()
1433 struct solos_card *card = pci_get_drvdata(dev); fpga_remove() local
1436 iowrite32(0, card->config_regs + IRQ_EN_ADDR); fpga_remove()
1439 iowrite32(1, card->config_regs + FPGA_MODE); fpga_remove()
1440 (void)ioread32(card->config_regs + FPGA_MODE); fpga_remove()
1442 if (card->fpga_version >= DMA_SUPPORTED) fpga_remove()
1443 sysfs_remove_group(&card->dev->dev.kobj, &gpio_attr_group); fpga_remove()
1445 atm_remove(card); fpga_remove()
1447 free_irq(dev->irq, card); fpga_remove()
1448 tasklet_kill(&card->tlet); fpga_remove()
1450 kfree(card->dma_bounce); fpga_remove()
1453 iowrite32(0, card->config_regs + FPGA_MODE); fpga_remove()
1454 (void)ioread32(card->config_regs + FPGA_MODE); fpga_remove()
1456 pci_iounmap(dev, card->buffers); fpga_remove()
1457 pci_iounmap(dev, card->config_regs); fpga_remove()
1462 kfree(card); fpga_remove()
/linux-4.1.27/drivers/isdn/act2000/
H A Dact2000_isa.c66 act2000_card *card = dev_id; act2000_isa_interrupt() local
74 act2000_isa_receive(card); act2000_isa_interrupt()
83 printk(KERN_DEBUG "act2000: ?IRQ %d %02x\n", card->irq, istatus); act2000_isa_interrupt()
88 act2000_isa_select_irq(act2000_card *card) act2000_isa_select_irq() argument
93 switch (card->irq) { act2000_isa_select_irq()
120 act2000_isa_enable_irq(act2000_card *card) act2000_isa_enable_irq() argument
122 act2000_isa_select_irq(card); act2000_isa_enable_irq()
128 * Install interrupt handler, enable irq on card.
132 act2000_isa_config_irq(act2000_card *card, short irq) act2000_isa_config_irq() argument
136 if (card->flags & ACT2000_FLAGS_IVALID) { act2000_isa_config_irq()
137 free_irq(card->irq, card); act2000_isa_config_irq()
139 card->flags &= ~ACT2000_FLAGS_IVALID; act2000_isa_config_irq()
144 old_irq = card->irq; act2000_isa_config_irq()
145 card->irq = irq; act2000_isa_config_irq()
146 if (request_irq(irq, &act2000_isa_interrupt, 0, card->regname, card)) { act2000_isa_config_irq()
147 card->irq = old_irq; act2000_isa_config_irq()
148 card->flags |= ACT2000_FLAGS_IVALID; act2000_isa_config_irq()
153 act2000_isa_select_irq(card); act2000_isa_config_irq()
162 act2000_isa_config_port(act2000_card *card, unsigned short portbase) act2000_isa_config_port() argument
164 if (card->flags & ACT2000_FLAGS_PVALID) { act2000_isa_config_port()
165 release_region(card->port, ISA_REGION); act2000_isa_config_port()
166 card->flags &= ~ACT2000_FLAGS_PVALID; act2000_isa_config_port()
168 if (request_region(portbase, ACT2000_PORTLEN, card->regname) == NULL) act2000_isa_config_port()
171 card->port = portbase; act2000_isa_config_port()
172 card->flags |= ACT2000_FLAGS_PVALID; act2000_isa_config_port()
181 act2000_isa_release(act2000_card *card) act2000_isa_release() argument
185 spin_lock_irqsave(&card->lock, flags); act2000_isa_release()
186 if (card->flags & ACT2000_FLAGS_IVALID) act2000_isa_release()
187 free_irq(card->irq, card); act2000_isa_release()
189 card->flags &= ~ACT2000_FLAGS_IVALID; act2000_isa_release()
190 if (card->flags & ACT2000_FLAGS_PVALID) act2000_isa_release()
191 release_region(card->port, ISA_REGION); act2000_isa_release()
192 card->flags &= ~ACT2000_FLAGS_PVALID; act2000_isa_release()
193 spin_unlock_irqrestore(&card->lock, flags); act2000_isa_release()
197 act2000_isa_writeb(act2000_card *card, u_char data) act2000_isa_writeb() argument
214 act2000_isa_readb(act2000_card *card, u_char *data) act2000_isa_readb() argument
231 act2000_isa_receive(act2000_card *card) act2000_isa_receive() argument
235 if (test_and_set_bit(ACT2000_LOCK_RX, (void *) &card->ilock) != 0) act2000_isa_receive()
237 while (!act2000_isa_readb(card, &c)) { act2000_isa_receive()
238 if (card->idat.isa.rcvidx < 8) { act2000_isa_receive()
239 card->idat.isa.rcvhdr[card->idat.isa.rcvidx++] = c; act2000_isa_receive()
240 if (card->idat.isa.rcvidx == 8) { act2000_isa_receive()
241 int valid = actcapi_chkhdr(card, (actcapi_msghdr *)&card->idat.isa.rcvhdr); act2000_isa_receive()
244 card->idat.isa.rcvlen = ((actcapi_msghdr *)&card->idat.isa.rcvhdr)->len; act2000_isa_receive()
245 card->idat.isa.rcvskb = dev_alloc_skb(card->idat.isa.rcvlen); act2000_isa_receive()
246 if (card->idat.isa.rcvskb == NULL) { act2000_isa_receive()
247 card->idat.isa.rcvignore = 1; act2000_isa_receive()
250 test_and_clear_bit(ACT2000_LOCK_RX, (void *) &card->ilock); act2000_isa_receive()
253 memcpy(skb_put(card->idat.isa.rcvskb, 8), card->idat.isa.rcvhdr, 8); act2000_isa_receive()
254 card->idat.isa.rcvptr = skb_put(card->idat.isa.rcvskb, card->idat.isa.rcvlen - 8); act2000_isa_receive()
256 card->idat.isa.rcvidx = 0; act2000_isa_receive()
261 for (i = 0, p = (__u8 *)&card->idat.isa.rcvhdr, t = tmp; i < 8; i++) act2000_isa_receive()
268 if (!card->idat.isa.rcvignore) act2000_isa_receive()
269 *card->idat.isa.rcvptr++ = c; act2000_isa_receive()
270 if (++card->idat.isa.rcvidx >= card->idat.isa.rcvlen) { act2000_isa_receive()
271 if (!card->idat.isa.rcvignore) { act2000_isa_receive()
272 skb_queue_tail(&card->rcvq, card->idat.isa.rcvskb); act2000_isa_receive()
273 act2000_schedule_rx(card); act2000_isa_receive()
275 card->idat.isa.rcvidx = 0; act2000_isa_receive()
276 card->idat.isa.rcvlen = 8; act2000_isa_receive()
277 card->idat.isa.rcvignore = 0; act2000_isa_receive()
278 card->idat.isa.rcvskb = NULL; act2000_isa_receive()
279 card->idat.isa.rcvptr = card->idat.isa.rcvhdr; act2000_isa_receive()
283 if (!(card->flags & ACT2000_FLAGS_IVALID)) { act2000_isa_receive()
285 if ((card->idat.isa.rcvidx) && act2000_isa_receive()
286 (card->idat.isa.rcvignore || act2000_isa_receive()
287 (card->idat.isa.rcvidx < card->idat.isa.rcvlen))) act2000_isa_receive()
288 act2000_schedule_poll(card); act2000_isa_receive()
290 test_and_clear_bit(ACT2000_LOCK_RX, (void *) &card->ilock); act2000_isa_receive()
294 act2000_isa_send(act2000_card *card) act2000_isa_send() argument
301 if (test_and_set_bit(ACT2000_LOCK_TX, (void *) &card->ilock) != 0) act2000_isa_send()
304 spin_lock_irqsave(&card->lock, flags); act2000_isa_send()
305 if (!(card->sbuf)) { act2000_isa_send()
306 if ((card->sbuf = skb_dequeue(&card->sndq))) { act2000_isa_send()
307 card->ack_msg = card->sbuf->data; act2000_isa_send()
308 msg = (actcapi_msg *)card->sbuf->data; act2000_isa_send()
312 card->need_b3ack = msg->msg.data_b3_req.flags; act2000_isa_send()
317 spin_unlock_irqrestore(&card->lock, flags); act2000_isa_send()
318 if (!(card->sbuf)) { act2000_isa_send()
320 test_and_clear_bit(ACT2000_LOCK_TX, (void *) &card->ilock); act2000_isa_send()
323 skb = card->sbuf; act2000_isa_send()
326 if (act2000_isa_writeb(card, *(skb->data))) { act2000_isa_send()
328 test_and_clear_bit(ACT2000_LOCK_TX, (void *) &card->ilock); act2000_isa_send()
330 act2000_schedule_tx(card); act2000_isa_send()
336 msg = (actcapi_msg *)card->ack_msg; act2000_isa_send()
343 skb->data = card->ack_msg; act2000_isa_send()
345 msg->msg.data_b3_req.flags = card->need_b3ack; act2000_isa_send()
346 skb_queue_tail(&card->ackq, skb); act2000_isa_send()
349 card->sbuf = NULL; act2000_isa_send()
357 act2000_isa_getid(act2000_card *card) act2000_isa_getid() argument
367 if (act2000_isa_readb(card, p++)) act2000_isa_getid()
384 if (card->flags & ACT2000_FLAGS_IVALID) { act2000_isa_getid()
386 act2000_isa_enable_irq(card); act2000_isa_getid()
392 * Download microcode into card, check Firmware signature.
395 act2000_isa_download(act2000_card *card, act2000_ddef __user *cb) act2000_isa_download() argument
406 if (!act2000_isa_reset(card->port)) act2000_isa_download()
428 if (act2000_isa_writeb(card, *b++)) { act2000_isa_download()
442 return (act2000_isa_getid(card)); act2000_isa_download()
H A Dmodule.c36 MODULE_DESCRIPTION("ISDN4Linux: Driver for IBM Active 2000 ISDN card");
39 MODULE_PARM_DESC(act_bus, "BusType of first card, 1=ISA, 2=MCA, 3=PCMCIA, currently only ISA");
40 MODULE_PARM_DESC(membase, "Base port address of first card");
41 MODULE_PARM_DESC(act_irq, "IRQ of first card");
42 MODULE_PARM_DESC(act_id, "ID-String of first card");
51 find_channel(act2000_card *card, int channel) find_channel() argument
54 return &(card->bch[channel]); find_channel()
63 act2000_clear_msn(act2000_card *card) act2000_clear_msn() argument
65 struct msn_entry *p = card->msn_list; act2000_clear_msn()
69 spin_lock_irqsave(&card->lock, flags); act2000_clear_msn()
70 card->msn_list = NULL; act2000_clear_msn()
71 spin_unlock_irqrestore(&card->lock, flags); act2000_clear_msn()
85 act2000_find_msn(act2000_card *card, char *msn, int ia5) act2000_find_msn() argument
87 struct msn_entry *p = card->msn_list; act2000_find_msn()
108 act2000_find_eaz(act2000_card *card, char eaz) act2000_find_eaz() argument
110 struct msn_entry *p = card->msn_list; act2000_find_eaz()
127 act2000_set_msn(act2000_card *card, char *eazmsn) act2000_set_msn() argument
129 struct msn_entry *p = card->msn_list; act2000_set_msn()
145 spin_lock_irqsave(&card->lock, flags); act2000_set_msn()
149 card->msn_list = p->next; act2000_set_msn()
150 spin_unlock_irqrestore(&card->lock, flags); act2000_set_msn()
166 spin_lock_irqsave(&card->lock, flags); act2000_set_msn()
168 spin_unlock_irqrestore(&card->lock, flags); act2000_set_msn()
183 p->next = card->msn_list; act2000_set_msn()
184 spin_lock_irqsave(&card->lock, flags); act2000_set_msn()
185 card->msn_list = p; act2000_set_msn()
186 spin_unlock_irqrestore(&card->lock, flags); act2000_set_msn()
197 struct act2000_card *card = act2000_transmit() local
200 switch (card->bus) { act2000_transmit()
202 act2000_isa_send(card); act2000_transmit()
208 "act2000_transmit: Illegal bustype %d\n", card->bus); act2000_transmit()
215 struct act2000_card *card = act2000_receive() local
218 switch (card->bus) { act2000_receive()
220 act2000_isa_receive(card); act2000_receive()
226 "act2000_receive: Illegal bustype %d\n", card->bus); act2000_receive()
233 act2000_card *card = (act2000_card *)data; act2000_poll() local
236 act2000_receive(&card->poll_tq); act2000_poll()
237 spin_lock_irqsave(&card->lock, flags); act2000_poll()
238 mod_timer(&card->ptimer, jiffies + 3); act2000_poll()
239 spin_unlock_irqrestore(&card->lock, flags); act2000_poll()
243 act2000_command(act2000_card *card, isdn_ctrl *c) act2000_command() argument
260 switch (card->bus) { act2000_command()
262 ret = act2000_isa_download(card, act2000_command()
265 card->flags |= ACT2000_FLAGS_LOADED; act2000_command()
266 if (!(card->flags & ACT2000_FLAGS_IVALID)) { act2000_command()
267 card->ptimer.expires = jiffies + 3; act2000_command()
268 card->ptimer.function = act2000_poll; act2000_command()
269 card->ptimer.data = (unsigned long)card; act2000_command()
270 add_timer(&card->ptimer); act2000_command()
272 actcapi_manufacturer_req_errh(card); act2000_command()
278 card->bus); act2000_command()
283 card->ptype = a ? ISDN_PTYPE_EURO : ISDN_PTYPE_1TR6; act2000_command()
284 if (!(card->flags & ACT2000_FLAGS_RUNNING)) act2000_command()
286 actcapi_manufacturer_req_net(card); act2000_command()
292 if ((ret = act2000_set_msn(card, tmp))) act2000_command()
294 if (card->flags & ACT2000_FLAGS_RUNNING) act2000_command()
295 return (actcapi_manufacturer_req_msn(card)); act2000_command()
305 if (!(card->flags & ACT2000_FLAGS_RUNNING)) act2000_command()
313 if (!(card->flags & ACT2000_FLAGS_RUNNING)) act2000_command()
315 if (!(chan = find_channel(card, c->arg & 0x0f))) act2000_command()
317 spin_lock_irqsave(&card->lock, flags); act2000_command()
319 spin_unlock_irqrestore(&card->lock, flags); act2000_command()
324 if (card->ptype == ISDN_PTYPE_EURO) act2000_command()
325 tmp[0] = act2000_find_msn(card, c->parm.setup.eazmsn, 1); act2000_command()
330 spin_unlock_irqrestore(&card->lock, flags); act2000_command()
331 ret = actcapi_connect_req(card, chan, c->parm.setup.phone, act2000_command()
335 cmd.driver = card->myid; act2000_command()
338 card->interface.statcallb(&cmd); act2000_command()
342 if (!(card->flags & ACT2000_FLAGS_RUNNING)) act2000_command()
344 if (!(chan = find_channel(card, c->arg & 0x0f))) act2000_command()
347 actcapi_select_b2_protocol_req(card, chan); act2000_command()
350 if (!(card->flags & ACT2000_FLAGS_RUNNING)) act2000_command()
354 if (!(card->flags & ACT2000_FLAGS_RUNNING)) act2000_command()
356 if (!(chan = find_channel(card, c->arg & 0x0f))) act2000_command()
361 actcapi_connect_resp(card, chan, 0x15); act2000_command()
364 actcapi_disconnect_b3_req(card, chan); act2000_command()
369 if (!(card->flags & ACT2000_FLAGS_RUNNING)) act2000_command()
371 if (!(chan = find_channel(card, c->arg & 0x0f))) act2000_command()
374 if (card->ptype == ISDN_PTYPE_EURO) { act2000_command()
375 chan->eazmask = act2000_find_msn(card, c->parm.num, 0); act2000_command()
377 if (card->ptype == ISDN_PTYPE_1TR6) { act2000_command()
386 actcapi_listen_req(card); act2000_command()
389 if (!(card->flags & ACT2000_FLAGS_RUNNING)) act2000_command()
391 if (!(chan = find_channel(card, c->arg & 0x0f))) act2000_command()
394 actcapi_listen_req(card); act2000_command()
397 if (!(card->flags & ACT2000_FLAGS_RUNNING)) act2000_command()
399 if (!(chan = find_channel(card, c->arg & 0x0f))) act2000_command()
404 if (!(card->flags & ACT2000_FLAGS_RUNNING)) act2000_command()
410 if (!(chan = find_channel(card, c->arg & 0x0f))) act2000_command()
420 act2000_sendbuf(act2000_card *card, int channel, int ack, struct sk_buff *skb) act2000_sendbuf() argument
427 if (!(chan = find_channel(card, channel))) act2000_sendbuf()
459 msg->hdr.msgnum = actcapi_nextsmsg(card); act2000_sendbuf()
466 skb_queue_tail(&card->sndq, xmit_skb); act2000_sendbuf()
467 act2000_schedule_tx(card); act2000_sendbuf()
474 act2000_readstatus(u_char __user *buf, int len, act2000_card *card) act2000_readstatus() argument
480 if (card->status_buf_read == card->status_buf_write) act2000_readstatus()
482 put_user(*card->status_buf_read++, p); act2000_readstatus()
483 if (card->status_buf_read > card->status_buf_end) act2000_readstatus()
484 card->status_buf_read = card->status_buf; act2000_readstatus()
490 * Find card with given driverId
511 act2000_card *card = act2000_findcard(c->driver); if_command() local
513 if (card) if_command()
514 return (act2000_command(card, c)); if_command()
524 act2000_card *card = act2000_findcard(id); if_writecmd() local
526 if (card) { if_writecmd()
527 if (!(card->flags & ACT2000_FLAGS_RUNNING)) if_writecmd()
539 act2000_card *card = act2000_findcard(id); if_readstatus() local
541 if (card) { if_readstatus()
542 if (!(card->flags & ACT2000_FLAGS_RUNNING)) if_readstatus()
544 return (act2000_readstatus(buf, len, card)); if_readstatus()
554 act2000_card *card = act2000_findcard(id); if_sendbuf() local
556 if (card) { if_sendbuf()
557 if (!(card->flags & ACT2000_FLAGS_RUNNING)) if_sendbuf()
559 return (act2000_sendbuf(card, channel, ack, skb)); if_sendbuf()
568 * Allocate a new card-struct, initialize it
575 act2000_card *card; act2000_alloccard() local
576 if (!(card = kzalloc(sizeof(act2000_card), GFP_KERNEL))) { act2000_alloccard()
578 "act2000: (%s) Could not allocate card-struct.\n", id); act2000_alloccard()
581 spin_lock_init(&card->lock); act2000_alloccard()
582 spin_lock_init(&card->mnlock); act2000_alloccard()
583 skb_queue_head_init(&card->sndq); act2000_alloccard()
584 skb_queue_head_init(&card->rcvq); act2000_alloccard()
585 skb_queue_head_init(&card->ackq); act2000_alloccard()
586 INIT_WORK(&card->snd_tq, act2000_transmit); act2000_alloccard()
587 INIT_WORK(&card->rcv_tq, actcapi_dispatch); act2000_alloccard()
588 INIT_WORK(&card->poll_tq, act2000_receive); act2000_alloccard()
589 init_timer(&card->ptimer); act2000_alloccard()
590 card->interface.owner = THIS_MODULE; act2000_alloccard()
591 card->interface.channels = ACT2000_BCH; act2000_alloccard()
592 card->interface.maxbufsize = 4000; act2000_alloccard()
593 card->interface.command = if_command; act2000_alloccard()
594 card->interface.writebuf_skb = if_sendbuf; act2000_alloccard()
595 card->interface.writecmd = if_writecmd; act2000_alloccard()
596 card->interface.readstat = if_readstatus; act2000_alloccard()
597 card->interface.features = act2000_alloccard()
602 card->interface.hl_hdrlen = 20; act2000_alloccard()
603 card->ptype = ISDN_PTYPE_EURO; act2000_alloccard()
604 strlcpy(card->interface.id, id, sizeof(card->interface.id)); act2000_alloccard()
606 card->bch[i].plci = 0x8000; act2000_alloccard()
607 card->bch[i].ncci = 0x8000; act2000_alloccard()
608 card->bch[i].l2prot = ISDN_PROTO_L2_X75I; act2000_alloccard()
609 card->bch[i].l3prot = ISDN_PROTO_L3_TRANS; act2000_alloccard()
611 card->myid = -1; act2000_alloccard()
612 card->bus = bus; act2000_alloccard()
613 card->port = port; act2000_alloccard()
614 card->irq = irq; act2000_alloccard()
615 card->next = cards; act2000_alloccard()
616 cards = card; act2000_alloccard()
620 * register card at linklevel
623 act2000_registercard(act2000_card *card) act2000_registercard() argument
625 switch (card->bus) { act2000_registercard()
633 card->bus); act2000_registercard()
636 if (!register_isdn(&card->interface)) { act2000_registercard()
639 card->interface.id); act2000_registercard()
642 card->myid = card->interface.channels; act2000_registercard()
643 sprintf(card->regname, "act2000-isdn (%s)", card->interface.id); act2000_registercard()
648 unregister_card(act2000_card *card) unregister_card() argument
653 cmd.driver = card->myid; unregister_card()
654 card->interface.statcallb(&cmd); unregister_card()
655 switch (card->bus) { unregister_card()
657 act2000_isa_release(card); unregister_card()
664 card->bus); unregister_card()
686 * This may result in more than one card detected. act2000_addcard()
693 "ISA card at port 0x%x\n", act2000_addcard()
737 "-type card at port " act2000_addcard()
758 /* Init OK, next card ... */ act2000_addcard()
762 /* Init failed, remove card from list, free memory */ act2000_addcard()
795 act2000_card *card = cards; act2000_exit() local
797 while (card) { act2000_exit()
798 unregister_card(card); act2000_exit()
799 del_timer_sync(&card->ptimer); act2000_exit()
800 card = card->next; act2000_exit()
802 card = cards; act2000_exit()
803 while (card) { act2000_exit()
804 last = card; act2000_exit()
805 card = card->next; act2000_exit()
H A Dcapi.c91 actcapi_chkhdr(act2000_card *card, actcapi_msghdr *hdr) actcapi_chkhdr() argument
115 m->hdr.msgnum = actcapi_nextsmsg(card); \
126 skb_queue_tail(&card->sndq, skb); \
127 act2000_schedule_tx(card); \
131 actcapi_listen_req(act2000_card *card) actcapi_listen_req() argument
139 eazmask |= card->bch[i].eazmask; actcapi_listen_req()
154 actcapi_connect_req(act2000_card *card, act2000_chan *chan, char *phone, actcapi_connect_req() argument
181 actcapi_connect_b3_req(act2000_card *card, act2000_chan *chan) actcapi_connect_b3_req() argument
200 actcapi_manufacturer_req_net(act2000_card *card) actcapi_manufacturer_req_net() argument
212 m->msg.manufacturer_req_net.nettype = (card->ptype == ISDN_PTYPE_EURO) ? 1 : 0; actcapi_manufacturer_req_net()
215 card->interface.id, (card->ptype == ISDN_PTYPE_EURO) ? "euro" : "1tr6"); actcapi_manufacturer_req_net()
216 card->interface.features &= actcapi_manufacturer_req_net()
218 card->interface.features |= actcapi_manufacturer_req_net()
219 ((card->ptype == ISDN_PTYPE_EURO) ? ISDN_FEATURE_P_EURO : ISDN_FEATURE_P_1TR6); actcapi_manufacturer_req_net()
228 actcapi_manufacturer_req_v42(act2000_card *card, ulong arg)
251 actcapi_manufacturer_req_errh(act2000_card *card) actcapi_manufacturer_req_errh() argument
272 actcapi_manufacturer_req_msn(act2000_card *card) actcapi_manufacturer_req_msn() argument
274 msn_entry *p = card->msn_list; actcapi_manufacturer_req_msn()
302 actcapi_select_b2_protocol_req(act2000_card *card, act2000_chan *chan) actcapi_select_b2_protocol_req() argument
337 actcapi_select_b3_protocol_req(act2000_card *card, act2000_chan *chan) actcapi_select_b3_protocol_req() argument
358 actcapi_listen_b3_req(act2000_card *card, act2000_chan *chan) actcapi_listen_b3_req() argument
370 actcapi_disconnect_req(act2000_card *card, act2000_chan *chan) actcapi_disconnect_req() argument
383 actcapi_disconnect_b3_req(act2000_card *card, act2000_chan *chan) actcapi_disconnect_b3_req() argument
400 actcapi_connect_resp(act2000_card *card, act2000_chan *chan, __u8 cause) actcapi_connect_resp() argument
418 actcapi_connect_active_resp(act2000_card *card, act2000_chan *chan) actcapi_connect_active_resp() argument
432 actcapi_connect_b3_resp(act2000_card *card, act2000_chan *chan, __u8 rejectcause) actcapi_connect_b3_resp() argument
452 actcapi_connect_b3_active_resp(act2000_card *card, act2000_chan *chan) actcapi_connect_b3_active_resp() argument
465 actcapi_info_resp(act2000_card *card, act2000_chan *chan) actcapi_info_resp() argument
477 actcapi_disconnect_b3_resp(act2000_card *card, act2000_chan *chan) actcapi_disconnect_b3_resp() argument
491 actcapi_disconnect_resp(act2000_card *card, act2000_chan *chan) actcapi_disconnect_resp() argument
504 new_plci(act2000_card *card, __u16 plci) new_plci() argument
508 if (card->bch[i].plci == 0x8000) { new_plci()
509 card->bch[i].plci = plci; new_plci()
516 find_plci(act2000_card *card, __u16 plci) find_plci() argument
520 if (card->bch[i].plci == plci) find_plci()
526 find_ncci(act2000_card *card, __u16 ncci) find_ncci() argument
530 if (card->bch[i].ncci == ncci) find_ncci()
536 find_dialing(act2000_card *card, __u16 callref) find_dialing() argument
540 if ((card->bch[i].callref == callref) && find_dialing()
541 (card->bch[i].fsm_state == ACT2000_STATE_OCALL)) find_dialing()
547 actcapi_data_b3_ind(act2000_card *card, struct sk_buff *skb) { actcapi_data_b3_ind() argument
556 chan = find_ncci(card, ncci); actcapi_data_b3_ind()
559 if (card->bch[chan].fsm_state != ACT2000_STATE_ACTIVE) actcapi_data_b3_ind()
561 if (card->bch[chan].plci != plci) actcapi_data_b3_ind()
565 card->interface.rcvcallb_skb(card->myid, chan, skb); actcapi_data_b3_ind()
575 msg->hdr.msgnum = actcapi_nextsmsg(card); actcapi_data_b3_ind()
588 handle_ack(act2000_card *card, act2000_chan *chan, __u8 blocknr) { handle_ack() argument
595 spin_lock_irqsave(&card->lock, flags); handle_ack()
596 skb = skb_peek(&card->ackq); handle_ack()
597 spin_unlock_irqrestore(&card->lock, flags); handle_ack()
608 skb_unlink(tmp, &card->ackq); handle_ack()
617 spin_lock_irqsave(&card->lock, flags); handle_ack()
619 spin_unlock_irqrestore(&card->lock, flags); handle_ack()
631 struct act2000_card *card = actcapi_dispatch() local
642 while ((skb = skb_dequeue(&card->rcvq))) { actcapi_dispatch()
649 if (actcapi_data_b3_ind(card, skb)) actcapi_dispatch()
654 chan = find_ncci(card, msg->msg.data_b3_conf.ncci); actcapi_dispatch()
655 if ((chan >= 0) && (card->bch[chan].fsm_state == ACT2000_STATE_ACTIVE)) { actcapi_dispatch()
659 len = handle_ack(card, &card->bch[chan], actcapi_dispatch()
662 cmd.driver = card->myid; actcapi_dispatch()
666 card->interface.statcallb(&cmd); actcapi_dispatch()
672 chan = find_dialing(card, msg->hdr.msgnum); actcapi_dispatch()
675 card->bch[chan].fsm_state = ACT2000_STATE_NULL; actcapi_dispatch()
676 cmd.driver = card->myid; actcapi_dispatch()
679 card->interface.statcallb(&cmd); actcapi_dispatch()
681 card->bch[chan].fsm_state = ACT2000_STATE_OWAIT; actcapi_dispatch()
682 card->bch[chan].plci = msg->msg.connect_conf.plci; actcapi_dispatch()
688 chan = new_plci(card, msg->msg.connect_ind.plci); actcapi_dispatch()
692 actcapi_connect_resp(card, ctmp, 0x11); /* All Card-Cannels busy */ actcapi_dispatch()
694 card->bch[chan].fsm_state = ACT2000_STATE_ICALL; actcapi_dispatch()
695 cmd.driver = card->myid; actcapi_dispatch()
700 if (card->ptype == ISDN_PTYPE_EURO) actcapi_dispatch()
702 act2000_find_eaz(card, msg->msg.connect_ind.eaz)); actcapi_dispatch()
712 if (card->interface.statcallb(&cmd) == 2) actcapi_dispatch()
713 actcapi_connect_resp(card, &card->bch[chan], 0x15); /* Reject Call */ actcapi_dispatch()
718 chan = find_plci(card, msg->msg.connect_active_ind.plci); actcapi_dispatch()
720 switch (card->bch[chan].fsm_state) { actcapi_dispatch()
722 actcapi_connect_active_resp(card, &card->bch[chan]); actcapi_dispatch()
725 actcapi_connect_active_resp(card, &card->bch[chan]); actcapi_dispatch()
726 actcapi_select_b2_protocol_req(card, &card->bch[chan]); actcapi_dispatch()
732 chan = find_plci(card, msg->msg.connect_b3_ind.plci); actcapi_dispatch()
733 if ((chan >= 0) && (card->bch[chan].fsm_state == ACT2000_STATE_IBWAIT)) { actcapi_dispatch()
734 card->bch[chan].ncci = msg->msg.connect_b3_ind.ncci; actcapi_dispatch()
735 actcapi_connect_b3_resp(card, &card->bch[chan], 0); actcapi_dispatch()
739 actcapi_connect_b3_resp(card, ctmp, 0x11); /* All Card-Cannels busy */ actcapi_dispatch()
744 chan = find_ncci(card, msg->msg.connect_b3_active_ind.ncci); actcapi_dispatch()
745 if ((chan >= 0) && (card->bch[chan].fsm_state == ACT2000_STATE_BWAIT)) { actcapi_dispatch()
746 actcapi_connect_b3_active_resp(card, &card->bch[chan]); actcapi_dispatch()
747 cmd.driver = card->myid; actcapi_dispatch()
750 card->interface.statcallb(&cmd); actcapi_dispatch()
755 chan = find_ncci(card, msg->msg.disconnect_b3_ind.ncci); actcapi_dispatch()
757 ctmp = &card->bch[chan]; actcapi_dispatch()
758 actcapi_disconnect_b3_resp(card, ctmp); actcapi_dispatch()
762 cmd.driver = card->myid; actcapi_dispatch()
765 card->interface.statcallb(&cmd); actcapi_dispatch()
768 actcapi_disconnect_req(card, ctmp); actcapi_dispatch()
770 cmd.driver = card->myid; actcapi_dispatch()
773 card->interface.statcallb(&cmd); actcapi_dispatch()
780 chan = find_plci(card, msg->msg.disconnect_ind.plci); actcapi_dispatch()
782 ctmp = &card->bch[chan]; actcapi_dispatch()
783 actcapi_disconnect_resp(card, ctmp); actcapi_dispatch()
785 cmd.driver = card->myid; actcapi_dispatch()
788 card->interface.statcallb(&cmd); actcapi_dispatch()
792 actcapi_disconnect_resp(card, ctmp); actcapi_dispatch()
797 chan = find_plci(card, msg->msg.select_b2_protocol_conf.plci); actcapi_dispatch()
799 switch (card->bch[chan].fsm_state) { actcapi_dispatch()
802 ctmp = &card->bch[chan]; actcapi_dispatch()
804 actcapi_select_b3_protocol_req(card, ctmp); actcapi_dispatch()
807 cmd.driver = card->myid; actcapi_dispatch()
810 card->interface.statcallb(&cmd); actcapi_dispatch()
817 chan = find_plci(card, msg->msg.select_b3_protocol_conf.plci); actcapi_dispatch()
819 switch (card->bch[chan].fsm_state) { actcapi_dispatch()
822 ctmp = &card->bch[chan]; actcapi_dispatch()
824 actcapi_listen_b3_req(card, ctmp); actcapi_dispatch()
827 cmd.driver = card->myid; actcapi_dispatch()
830 card->interface.statcallb(&cmd); actcapi_dispatch()
836 chan = find_plci(card, msg->msg.listen_b3_conf.plci); actcapi_dispatch()
838 switch (card->bch[chan].fsm_state) { actcapi_dispatch()
840 ctmp = &card->bch[chan]; actcapi_dispatch()
842 actcapi_connect_resp(card, ctmp, 0); actcapi_dispatch()
845 cmd.driver = card->myid; actcapi_dispatch()
848 card->interface.statcallb(&cmd); actcapi_dispatch()
852 ctmp = &card->bch[chan]; actcapi_dispatch()
854 actcapi_connect_b3_req(card, ctmp); actcapi_dispatch()
856 cmd.driver = card->myid; actcapi_dispatch()
859 card->interface.statcallb(&cmd); actcapi_dispatch()
862 cmd.driver = card->myid; actcapi_dispatch()
865 card->interface.statcallb(&cmd); actcapi_dispatch()
872 chan = find_plci(card, msg->msg.connect_b3_conf.plci); actcapi_dispatch()
873 if ((chan >= 0) && (card->bch[chan].fsm_state == ACT2000_STATE_OBWAIT)) { actcapi_dispatch()
874 ctmp = &card->bch[chan]; actcapi_dispatch()
877 cmd.driver = card->myid; actcapi_dispatch()
880 card->interface.statcallb(&cmd); actcapi_dispatch()
889 chan = find_ncci(card, msg->msg.disconnect_b3_conf.ncci); actcapi_dispatch()
890 if ((chan >= 0) && (card->bch[chan].fsm_state == ACT2000_STATE_BHWAIT)) actcapi_dispatch()
891 card->bch[chan].fsm_state = ACT2000_STATE_BHWAIT2; actcapi_dispatch()
895 chan = find_plci(card, msg->msg.info_ind.plci); actcapi_dispatch()
898 actcapi_info_resp(card, &card->bch[chan]); actcapi_dispatch()
920 card->flags |= ACT2000_FLAGS_RUNNING; actcapi_dispatch()
922 cmd.driver = card->myid; actcapi_dispatch()
924 actcapi_manufacturer_req_net(card); actcapi_dispatch()
925 actcapi_manufacturer_req_msn(card); actcapi_dispatch()
926 actcapi_listen_req(card); actcapi_dispatch()
927 card->interface.statcallb(&cmd); actcapi_dispatch()
/linux-4.1.27/drivers/staging/vme/devices/
H A Dvme_pio2_core.c47 static int pio2_get_led(struct pio2_card *card) pio2_get_led() argument
50 return card->led; pio2_get_led()
53 static int pio2_set_led(struct pio2_card *card, int state) pio2_set_led() argument
58 reg = card->irq_level; pio2_set_led()
67 retval = vme_master_write(card->window, &reg, 1, PIO2_REGS_CTRL); pio2_set_led()
71 card->led = state ? 1 : 0; pio2_set_led()
80 struct pio2_card *card = ptr; pio2_int() local
86 dev_warn(&card->vdev->dev, "Spurious Interrupt\n"); pio2_int()
93 retval = vme_master_read(card->window, &reg, 1, pio2_int()
96 dev_err(&card->vdev->dev, pio2_int()
103 dev_info(&card->vdev->dev, pio2_int()
115 dev_err(&card->vdev->dev, pio2_int()
124 * ensure we have a valid card.
126 static int pio2_reset_card(struct pio2_card *card) pio2_reset_card() argument
132 retval = vme_master_write(card->window, &data, 1, PIO2_REGS_CTRL); pio2_reset_card()
137 retval = vme_master_write(card->window, &data, 1, PIO2_REGS_VME_VECTOR); pio2_reset_card()
142 retval = pio2_gpio_reset(card); pio2_reset_card()
147 retval = pio2_cntr_reset(card); pio2_reset_card()
196 "The IRQ vector used by the card must be specified\n"); pio2_match()
202 "The IRQ level used by the card must be specified\n"); pio2_match()
207 dev_err(&vdev->dev, "The variant of the card must be specified\n"); pio2_match()
216 struct pio2_card *card; pio2_probe() local
222 card = kzalloc(sizeof(struct pio2_card), GFP_KERNEL); pio2_probe()
223 if (card == NULL) { pio2_probe()
228 card->id = vdev->num; pio2_probe()
229 card->bus = bus[card->id]; pio2_probe()
230 card->base = base[card->id]; pio2_probe()
231 card->irq_vector = vector[card->id]; pio2_probe()
232 card->irq_level = level[card->id] & PIO2_VME_INT_MASK; pio2_probe()
233 strncpy(card->variant, variant[card->id], PIO2_VARIANT_LENGTH); pio2_probe()
234 card->vdev = vdev; pio2_probe()
238 if (isdigit(card->variant[i]) == 0) { pio2_probe()
239 dev_err(&card->vdev->dev, "Variant invalid\n"); pio2_probe()
249 if (card->irq_vector & ~PIO2_VME_VECTOR_MASK) { pio2_probe()
250 dev_err(&card->vdev->dev, pio2_probe()
265 switch (card->variant[i]) { pio2_probe()
267 card->bank[i-1].config = NOFIT; pio2_probe()
273 card->bank[i-1].config = INPUT; pio2_probe()
276 card->bank[i-1].config = OUTPUT; pio2_probe()
282 card->bank[i-1].config = BOTH; pio2_probe()
288 card->window = vme_master_request(vdev, VME_A24, VME_SCT, VME_D16); pio2_probe()
289 if (card->window == NULL) { pio2_probe()
290 dev_err(&card->vdev->dev, pio2_probe()
296 retval = vme_master_set(card->window, 1, card->base, 0x10000, VME_A24, pio2_probe()
299 dev_err(&card->vdev->dev, pio2_probe()
310 retval = vme_master_read(card->window, &reg, 1, PIO2_REGS_ID); pio2_probe()
312 dev_err(&card->vdev->dev, "Unable to read from device\n"); pio2_probe()
316 dev_dbg(&card->vdev->dev, "ID Register:%x\n", reg); pio2_probe()
323 retval = pio2_reset_card(card); pio2_probe()
325 dev_err(&card->vdev->dev, pio2_probe()
326 "Failed to reset card, is location valid?\n"); pio2_probe()
332 reg = card->irq_level; pio2_probe()
333 if (pio2_get_led(card)) pio2_probe()
337 retval = vme_master_write(card->window, &reg, 1, PIO2_REGS_CTRL); pio2_probe()
342 retval = vme_master_write(card->window, &card->irq_vector, 1, pio2_probe()
348 vec = card->irq_vector | PIO2_VME_VECTOR_SPUR; pio2_probe()
350 retval = vme_irq_request(vdev, card->irq_level, vec, pio2_probe()
351 &pio2_int, (void *)card); pio2_probe()
353 dev_err(&card->vdev->dev, pio2_probe()
355 vec, card->irq_level); pio2_probe()
361 vec = card->irq_vector | PIO2_VECTOR_BANK[i]; pio2_probe()
363 retval = vme_irq_request(vdev, card->irq_level, vec, pio2_probe()
364 &pio2_int, (void *)card); pio2_probe()
366 dev_err(&card->vdev->dev, pio2_probe()
368 vec, card->irq_level); pio2_probe()
375 vec = card->irq_vector | PIO2_VECTOR_CNTR[i]; pio2_probe()
377 retval = vme_irq_request(vdev, card->irq_level, vec, pio2_probe()
378 &pio2_int, (void *)card); pio2_probe()
380 dev_err(&card->vdev->dev, pio2_probe()
382 vec, card->irq_level); pio2_probe()
388 retval = pio2_gpio_init(card); pio2_probe()
390 dev_err(&card->vdev->dev, pio2_probe()
396 retval = pio2_set_led(card, 0); pio2_probe()
398 dev_err(&card->vdev->dev, "Unable to set LED\n"); pio2_probe()
402 dev_set_drvdata(&card->vdev->dev, card); pio2_probe()
404 dev_info(&card->vdev->dev, pio2_probe()
405 "PIO2 (variant %s) configured at 0x%lx\n", card->variant, pio2_probe()
406 card->base); pio2_probe()
411 pio2_gpio_exit(card); pio2_probe()
417 vec = card->irq_vector | PIO2_VECTOR_CNTR[i]; pio2_probe()
418 vme_irq_free(vdev, card->irq_level, vec); pio2_probe()
425 vec = card->irq_vector | PIO2_VECTOR_BANK[i]; pio2_probe()
426 vme_irq_free(vdev, card->irq_level, vec); pio2_probe()
429 vec = (card->irq_vector & PIO2_VME_VECTOR_MASK) | PIO2_VME_VECTOR_SPUR; pio2_probe()
430 vme_irq_free(vdev, card->irq_level, vec); pio2_probe()
432 pio2_reset_card(card); pio2_probe()
435 vme_master_set(card->window, 0, 0, 0, VME_A16, 0, VME_D16); pio2_probe()
437 vme_master_free(card->window); pio2_probe()
441 kfree(card); pio2_probe()
451 struct pio2_card *card = dev_get_drvdata(&vdev->dev); pio2_remove() local
453 pio2_gpio_exit(card); pio2_remove()
456 vec = card->irq_vector | PIO2_VECTOR_CNTR[i]; pio2_remove()
457 vme_irq_free(vdev, card->irq_level, vec); pio2_remove()
461 vec = card->irq_vector | PIO2_VECTOR_BANK[i]; pio2_remove()
462 vme_irq_free(vdev, card->irq_level, vec); pio2_remove()
465 vec = (card->irq_vector & PIO2_VME_VECTOR_MASK) | PIO2_VME_VECTOR_SPUR; pio2_remove()
466 vme_irq_free(vdev, card->irq_level, vec); pio2_remove()
468 pio2_reset_card(card); pio2_remove()
470 vme_master_set(card->window, 0, 0, 0, VME_A16, 0, VME_D16); pio2_remove()
472 vme_master_free(card->window); pio2_remove()
474 kfree(card); pio2_remove()
H A Dvme_pio2_gpio.c37 struct pio2_card *card = gpio_to_pio2_card(chip); pio2_gpio_get() local
39 if ((card->bank[PIO2_CHANNEL_BANK[offset]].config == OUTPUT) | pio2_gpio_get()
40 (card->bank[PIO2_CHANNEL_BANK[offset]].config == NOFIT)) { pio2_gpio_get()
42 dev_err(&card->vdev->dev, "Channel not available as input\n"); pio2_gpio_get()
46 retval = vme_master_read(card->window, &reg, 1, pio2_gpio_get()
49 dev_err(&card->vdev->dev, "Unable to read from GPIO\n"); pio2_gpio_get()
58 if (card->bank[PIO2_CHANNEL_BANK[offset]].config != BOTH) pio2_gpio_get()
64 if (card->bank[PIO2_CHANNEL_BANK[offset]].config != BOTH) pio2_gpio_get()
75 struct pio2_card *card = gpio_to_pio2_card(chip); pio2_gpio_set() local
77 if ((card->bank[PIO2_CHANNEL_BANK[offset]].config == INPUT) | pio2_gpio_set()
78 (card->bank[PIO2_CHANNEL_BANK[offset]].config == NOFIT)) { pio2_gpio_set()
80 dev_err(&card->vdev->dev, "Channel not available as output\n"); pio2_gpio_set()
85 reg = card->bank[PIO2_CHANNEL_BANK[offset]].value | pio2_gpio_set()
88 reg = card->bank[PIO2_CHANNEL_BANK[offset]].value & pio2_gpio_set()
91 retval = vme_master_write(card->window, &reg, 1, pio2_gpio_set()
94 dev_err(&card->vdev->dev, "Unable to write to GPIO\n"); pio2_gpio_set()
98 card->bank[PIO2_CHANNEL_BANK[offset]].value = reg; pio2_gpio_set()
105 struct pio2_card *card = gpio_to_pio2_card(chip); pio2_gpio_dir_in() local
107 if ((card->bank[PIO2_CHANNEL_BANK[offset]].config == OUTPUT) | pio2_gpio_dir_in()
108 (card->bank[PIO2_CHANNEL_BANK[offset]].config == NOFIT)) { pio2_gpio_dir_in()
109 dev_err(&card->vdev->dev, pio2_gpio_dir_in()
124 struct pio2_card *card = gpio_to_pio2_card(chip); pio2_gpio_dir_out() local
126 if ((card->bank[PIO2_CHANNEL_BANK[offset]].config == INPUT) | pio2_gpio_dir_out()
127 (card->bank[PIO2_CHANNEL_BANK[offset]].config == NOFIT)) { pio2_gpio_dir_out()
128 dev_err(&card->vdev->dev, pio2_gpio_dir_out()
141 * ensure we have a valid card.
143 int pio2_gpio_reset(struct pio2_card *card) pio2_gpio_reset() argument
152 retval = vme_master_write(card->window, &data, 1, pio2_gpio_reset()
156 card->bank[i].value = 0; pio2_gpio_reset()
161 retval = vme_master_write(card->window, &data, 1, pio2_gpio_reset()
166 retval = vme_master_write(card->window, &data, 1, pio2_gpio_reset()
172 card->bank[i].irq[j] = NONE; pio2_gpio_reset()
178 retval = vme_master_read(card->window, &data, 1, pio2_gpio_reset()
188 int pio2_gpio_init(struct pio2_card *card) pio2_gpio_init() argument
194 "%s@%s", driver_name, dev_name(&card->vdev->dev)); pio2_gpio_init()
198 card->gc.label = label; pio2_gpio_init()
200 card->gc.ngpio = PIO2_NUM_CHANNELS; pio2_gpio_init()
202 card->gc.base = -1; pio2_gpio_init()
204 card->gc.direction_input = pio2_gpio_dir_in; pio2_gpio_init()
205 card->gc.direction_output = pio2_gpio_dir_out; pio2_gpio_init()
206 card->gc.get = pio2_gpio_get; pio2_gpio_init()
207 card->gc.set = pio2_gpio_set; pio2_gpio_init()
210 retval = gpiochip_add(&(card->gc)); pio2_gpio_init()
212 dev_err(&card->vdev->dev, "Unable to register GPIO\n"); pio2_gpio_init()
213 kfree(card->gc.label); pio2_gpio_init()
219 void pio2_gpio_exit(struct pio2_card *card) pio2_gpio_exit() argument
221 const char *label = card->gc.label; pio2_gpio_exit()
223 gpiochip_remove(&(card->gc)); pio2_gpio_exit()
H A Dvme_pio2_cntr.c24 static int pio2_cntr_irq_set(struct pio2_card *card, int id) pio2_cntr_irq_set() argument
29 data = PIO2_CNTR_SC_DEV[id] | PIO2_CNTR_RW_BOTH | card->cntr[id].mode; pio2_cntr_irq_set()
30 retval = vme_master_write(card->window, &data, 1, PIO2_CNTR_CTRL[id]); pio2_cntr_irq_set()
34 data = card->cntr[id].count & 0xFF; pio2_cntr_irq_set()
35 retval = vme_master_write(card->window, &data, 1, PIO2_CNTR_DATA[id]); pio2_cntr_irq_set()
39 data = (card->cntr[id].count >> 8) & 0xFF; pio2_cntr_irq_set()
40 retval = vme_master_write(card->window, &data, 1, PIO2_CNTR_DATA[id]); pio2_cntr_irq_set()
47 int pio2_cntr_reset(struct pio2_card *card) pio2_cntr_reset() argument
54 card->cntr[i].mode = PIO2_CNTR_MODE5; pio2_cntr_reset()
55 card->cntr[i].count = 0; pio2_cntr_reset()
56 retval = pio2_cntr_irq_set(card, i); pio2_cntr_reset()
63 retval = vme_master_read(card->window, &reg, 1, pio2_cntr_reset()
/linux-4.1.27/drivers/isdn/icn/
H A Dicn.c23 MODULE_DESCRIPTION("ISDN4Linux: Driver for ICN active ISDN card");
27 MODULE_PARM_DESC(portbase, "Port address of first card");
31 MODULE_PARM_DESC(icn_id, "ID-String of first card");
33 MODULE_PARM_DESC(icn_id2, "ID-String of first card, second S0 (4B only)");
53 * card = pointer to card struct
57 icn_free_queue(icn_card *card, int channel) icn_free_queue() argument
59 struct sk_buff_head *queue = &card->spqueue[channel]; icn_free_queue()
63 card->xlen[channel] = 0; icn_free_queue()
64 card->sndcount[channel] = 0; icn_free_queue()
65 if ((skb = card->xskb[channel])) { icn_free_queue()
66 card->xskb[channel] = NULL; icn_free_queue()
96 icn_disable_ram(icn_card *card) icn_disable_ram() argument
105 icn_enable_ram(icn_card *card) icn_enable_ram() argument
116 icn_map_channel(icn_card *card, int channel) icn_map_channel() argument
121 if ((channel == dev.channel) && (card == dev.mcard)) icn_map_channel()
126 icn_enable_ram(card); icn_map_channel()
127 dev.mcard = card; icn_map_channel()
136 * Return 0 if requested card/channel is unmapped (failure).
142 icn_lock_channel(icn_card *card, int channel) icn_lock_channel() argument
149 if ((dev.channel == channel) && (card == dev.mcard)) { icn_lock_channel()
165 * Release current card/channel lock
180 * Release current card/channel lock
197 icn_trymaplock_channel(icn_card *card, int channel) icn_trymaplock_channel() argument
207 ((dev.channel == channel) && (dev.mcard == card))) { icn_trymaplock_channel()
209 icn_map_channel(card, channel); icn_trymaplock_channel()
224 * Release current card/channel lock,
228 icn_maprelease_channel(icn_card *card, int channel) icn_maprelease_channel() argument
239 icn_map_channel(card, channel); icn_maprelease_channel()
249 icn_pollbchan_receive(int channel, icn_card *card) icn_pollbchan_receive() argument
251 int mch = channel + ((card->secondhalf) ? 2 : 0); icn_pollbchan_receive()
256 if (icn_trymaplock_channel(card, mch)) { icn_pollbchan_receive()
259 if ((card->rcvidx[channel] + cnt) > 4000) { icn_pollbchan_receive()
264 card->rcvidx[channel] = 0; icn_pollbchan_receive()
267 memcpy_fromio(&card->rcvbuf[channel][card->rcvidx[channel]], icn_pollbchan_receive()
269 card->rcvidx[channel] += cnt; icn_pollbchan_receive()
273 icn_maprelease_channel(card, mch & 2); icn_pollbchan_receive()
275 if ((cnt = card->rcvidx[channel])) { icn_pollbchan_receive()
280 memcpy(skb_put(skb, cnt), card->rcvbuf[channel], cnt); icn_pollbchan_receive()
281 card->rcvidx[channel] = 0; icn_pollbchan_receive()
282 card->interface.rcvcallb_skb(card->myid, channel, skb); icn_pollbchan_receive()
285 if (!icn_trymaplock_channel(card, mch)) icn_pollbchan_receive()
288 icn_maprelease_channel(card, mch & 2); icn_pollbchan_receive()
300 icn_pollbchan_send(int channel, icn_card *card) icn_pollbchan_send() argument
302 int mch = channel + ((card->secondhalf) ? 2 : 0); icn_pollbchan_send()
308 if (!(card->sndcount[channel] || card->xskb[channel] || icn_pollbchan_send()
309 !skb_queue_empty(&card->spqueue[channel]))) icn_pollbchan_send()
311 if (icn_trymaplock_channel(card, mch)) { icn_pollbchan_send()
313 (card->sndcount[channel] || icn_pollbchan_send()
314 !skb_queue_empty(&card->spqueue[channel]) || icn_pollbchan_send()
315 card->xskb[channel])) { icn_pollbchan_send()
316 spin_lock_irqsave(&card->lock, flags); icn_pollbchan_send()
317 if (card->xmit_lock[channel]) { icn_pollbchan_send()
318 spin_unlock_irqrestore(&card->lock, flags); icn_pollbchan_send()
321 card->xmit_lock[channel]++; icn_pollbchan_send()
322 spin_unlock_irqrestore(&card->lock, flags); icn_pollbchan_send()
323 skb = card->xskb[channel]; icn_pollbchan_send()
325 skb = skb_dequeue(&card->spqueue[channel]); icn_pollbchan_send()
331 card->xlen[channel] = skb->len; icn_pollbchan_send()
333 card->xlen[channel] = 0; icn_pollbchan_send()
349 icn_maprelease_channel(card, mch & 2); icn_pollbchan_send()
350 spin_lock_irqsave(&card->lock, flags); icn_pollbchan_send()
351 card->sndcount[channel] -= cnt; icn_pollbchan_send()
353 if (card->xskb[channel]) icn_pollbchan_send()
354 card->xskb[channel] = NULL; icn_pollbchan_send()
355 card->xmit_lock[channel] = 0; icn_pollbchan_send()
356 spin_unlock_irqrestore(&card->lock, flags); icn_pollbchan_send()
358 if (card->xlen[channel]) { icn_pollbchan_send()
360 cmd.driver = card->myid; icn_pollbchan_send()
362 cmd.parm.length = card->xlen[channel]; icn_pollbchan_send()
363 card->interface.statcallb(&cmd); icn_pollbchan_send()
366 card->xskb[channel] = skb; icn_pollbchan_send()
367 card->xmit_lock[channel] = 0; icn_pollbchan_send()
368 spin_unlock_irqrestore(&card->lock, flags); icn_pollbchan_send()
370 if (!icn_trymaplock_channel(card, mch)) icn_pollbchan_send()
373 icn_maprelease_channel(card, mch & 2); icn_pollbchan_send()
385 icn_card *card = (icn_card *) data; icn_pollbchan() local
388 if (card->flags & ICN_FLAGS_B1ACTIVE) { icn_pollbchan()
389 icn_pollbchan_receive(0, card); icn_pollbchan()
390 icn_pollbchan_send(0, card); icn_pollbchan()
392 if (card->flags & ICN_FLAGS_B2ACTIVE) { icn_pollbchan()
393 icn_pollbchan_receive(1, card); icn_pollbchan()
394 icn_pollbchan_send(1, card); icn_pollbchan()
396 if (card->flags & (ICN_FLAGS_B1ACTIVE | ICN_FLAGS_B2ACTIVE)) { icn_pollbchan()
398 spin_lock_irqsave(&card->lock, flags); icn_pollbchan()
399 mod_timer(&card->rb_timer, jiffies + ICN_TIMER_BCREAD); icn_pollbchan()
400 card->flags |= ICN_FLAGS_RBTIMER; icn_pollbchan()
401 spin_unlock_irqrestore(&card->lock, flags); icn_pollbchan()
403 card->flags &= ~ICN_FLAGS_RBTIMER; icn_pollbchan()
448 icn_parse_status(u_char *status, int channel, icn_card *card) icn_parse_status() argument
465 cmd.driver = card->myid; icn_parse_status()
469 spin_lock_irqsave(&card->lock, flags); icn_parse_status()
470 icn_free_queue(card, channel); icn_parse_status()
471 card->rcvidx[channel] = 0; icn_parse_status()
473 if (card->flags & icn_parse_status()
478 card->flags &= ~((channel) ? icn_parse_status()
483 ncmd.driver = card->myid; icn_parse_status()
486 spin_unlock_irqrestore(&card->lock, flags); icn_parse_status()
487 card->interface.statcallb(&cmd); icn_parse_status()
489 spin_unlock_irqrestore(&card->lock, flags); icn_parse_status()
492 spin_lock_irqsave(&card->lock, flags); icn_parse_status()
493 icn_free_queue(card, channel); icn_parse_status()
494 card->flags |= (channel) ? icn_parse_status()
496 spin_unlock_irqrestore(&card->lock, flags); icn_parse_status()
499 spin_lock_irqsave(&card->lock, flags); icn_parse_status()
500 card->flags &= ~((channel) ? icn_parse_status()
502 icn_free_queue(card, channel); icn_parse_status()
503 card->rcvidx[channel] = 0; icn_parse_status()
504 spin_unlock_irqrestore(&card->lock, flags); icn_parse_status()
535 sprintf(cmd.parm.setup.phone, "LEASED%d", card->myid); icn_parse_status()
558 spin_lock_irqsave(&card->lock, flags); icn_parse_status()
559 card->flags &= ~ICN_FLAGS_B1ACTIVE; icn_parse_status()
560 icn_free_queue(card, 0); icn_parse_status()
561 card->rcvidx[0] = 0; icn_parse_status()
562 spin_unlock_irqrestore(&card->lock, flags); icn_parse_status()
564 cmd.driver = card->myid; icn_parse_status()
565 card->interface.statcallb(&cmd); icn_parse_status()
568 cmd.driver = card->myid; icn_parse_status()
569 card->interface.statcallb(&cmd); icn_parse_status()
571 spin_lock_irqsave(&card->lock, flags); icn_parse_status()
572 card->flags &= ~ICN_FLAGS_B2ACTIVE; icn_parse_status()
573 icn_free_queue(card, 1); icn_parse_status()
574 card->rcvidx[1] = 0; icn_parse_status()
575 spin_unlock_irqrestore(&card->lock, flags); icn_parse_status()
577 cmd.driver = card->myid; icn_parse_status()
578 card->interface.statcallb(&cmd); icn_parse_status()
581 cmd.driver = card->myid; icn_parse_status()
584 card->interface.statcallb(&cmd); icn_parse_status()
589 icn_putmsg(icn_card *card, unsigned char c) icn_putmsg() argument
593 spin_lock_irqsave(&card->lock, flags); icn_putmsg()
594 *card->msg_buf_write++ = (c == 0xff) ? '\n' : c; icn_putmsg()
595 if (card->msg_buf_write == card->msg_buf_read) { icn_putmsg()
596 if (++card->msg_buf_read > card->msg_buf_end) icn_putmsg()
597 card->msg_buf_read = card->msg_buf; icn_putmsg()
599 if (card->msg_buf_write > card->msg_buf_end) icn_putmsg()
600 card->msg_buf_write = card->msg_buf; icn_putmsg()
601 spin_unlock_irqrestore(&card->lock, flags); icn_putmsg()
607 icn_card *card = (icn_card *) data; icn_polldchan() local
608 int mch = card->secondhalf ? 2 : 0; icn_polldchan()
618 if (icn_trymaplock_channel(card, mch)) { icn_polldchan()
622 icn_putmsg(card, c); icn_polldchan()
624 card->imsg[card->iptr] = 0; icn_polldchan()
625 card->iptr = 0; icn_polldchan()
626 if (card->imsg[0] == '0' && card->imsg[1] >= '0' && icn_polldchan()
627 card->imsg[1] <= '2' && card->imsg[2] == ';') { icn_polldchan()
628 ch = (card->imsg[1] - '0') - 1; icn_polldchan()
629 p = &card->imsg[3]; icn_polldchan()
630 icn_parse_status(p, ch, card); icn_polldchan()
632 p = card->imsg; icn_polldchan()
639 card->ptype = ISDN_PTYPE_1TR6; icn_polldchan()
640 card->interface.features |= ISDN_FEATURE_P_1TR6; icn_polldchan()
645 card->ptype = ISDN_PTYPE_EURO; icn_polldchan()
646 card->interface.features |= ISDN_FEATURE_P_EURO; icn_polldchan()
650 p = strstr(card->imsg, "BRV") + 3; icn_polldchan()
659 card->fw_rev = (int) simple_strtoul(vstr, NULL, 10); icn_polldchan()
665 card->imsg[card->iptr] = c; icn_polldchan()
666 if (card->iptr < 59) icn_polldchan()
667 card->iptr++; icn_polldchan()
675 cmd.driver = card->myid; icn_polldchan()
677 card->interface.statcallb(&cmd); icn_polldchan()
679 spin_lock_irqsave(&card->lock, flags); icn_polldchan()
680 if (card->flags & (ICN_FLAGS_B1ACTIVE | ICN_FLAGS_B2ACTIVE)) icn_polldchan()
681 if (!(card->flags & ICN_FLAGS_RBTIMER)) { icn_polldchan()
683 card->flags |= ICN_FLAGS_RBTIMER; icn_polldchan()
684 del_timer(&card->rb_timer); icn_polldchan()
685 card->rb_timer.function = icn_pollbchan; icn_polldchan()
686 card->rb_timer.data = (unsigned long) card; icn_polldchan()
687 card->rb_timer.expires = jiffies + ICN_TIMER_BCREAD; icn_polldchan()
688 add_timer(&card->rb_timer); icn_polldchan()
691 mod_timer(&card->st_timer, jiffies + ICN_TIMER_DCREAD); icn_polldchan()
692 spin_unlock_irqrestore(&card->lock, flags); icn_polldchan()
699 * card = pointer to card-struct
705 icn_sendbuf(int channel, int ack, struct sk_buff *skb, icn_card *card) icn_sendbuf() argument
717 if (!(card->flags & (channel) ? ICN_FLAGS_B2ACTIVE : ICN_FLAGS_B1ACTIVE)) icn_sendbuf()
719 if (card->sndcount[channel] > ICN_MAX_SQUEUE) icn_sendbuf()
728 skb_queue_tail(&card->spqueue[channel], nskb); icn_sendbuf()
732 spin_lock_irqsave(&card->lock, flags); icn_sendbuf()
733 card->sndcount[channel] += len; icn_sendbuf()
734 spin_unlock_irqrestore(&card->lock, flags); icn_sendbuf()
740 * Check card's status after starting the bootstrap loader.
741 * On entry, the card's shared memory has already to be mapped.
778 /* Load the boot-code into the interface-card's memory and start it.
801 icn_loadboot(u_char __user *buffer, icn_card *card) icn_loadboot() argument
819 if (!card->rvalid) { icn_loadboot()
820 if (!request_region(card->port, ICN_PORTLEN, card->regname)) { icn_loadboot()
824 card->port, icn_loadboot()
825 card->port + ICN_PORTLEN); icn_loadboot()
829 card->rvalid = 1; icn_loadboot()
830 if (card->doubleS0) icn_loadboot()
831 card->other->rvalid = 1; icn_loadboot()
855 icn_map_channel(card, 0); /* Select Bank 0 */ icn_loadboot()
856 icn_lock_channel(card, 0); /* Lock Bank 0 */ icn_loadboot()
863 if (card->doubleS0) { icn_loadboot()
870 icn_map_channel(card, 2); /* Select Bank 8 */ icn_loadboot()
871 icn_lock_channel(card, 2); /* Lock Bank 8 */ icn_loadboot()
881 if ((ret = icn_check_loader(card->doubleS0 ? 2 : 1))) { icn_loadboot()
884 if (!card->doubleS0) { icn_loadboot()
893 icn_map_channel(card, 0); /* Select Bank 0 */ icn_loadboot()
894 icn_lock_channel(card, 0); /* Lock Bank 0 */ icn_loadboot()
906 icn_loadproto(u_char __user *buffer, icn_card *card) icn_loadproto() argument
922 if (card->secondhalf) { icn_loadproto()
923 icn_map_channel(card, 2); icn_loadproto()
924 icn_lock_channel(card, 2); icn_loadproto()
926 icn_map_channel(card, 0); icn_loadproto()
927 icn_lock_channel(card, 0); icn_loadproto()
936 icn_maprelease_channel(card, 0); icn_loadproto()
949 icn_maprelease_channel(card, 0); icn_loadproto()
969 icn_maprelease_channel(card, 0); icn_loadproto()
977 if ((card->secondhalf) || (!card->doubleS0)) { icn_loadproto()
980 card->secondhalf); icn_loadproto()
982 spin_lock_irqsave(&card->lock, flags); icn_loadproto()
983 init_timer(&card->st_timer); icn_loadproto()
984 card->st_timer.expires = jiffies + ICN_TIMER_DCREAD; icn_loadproto()
985 card->st_timer.function = icn_polldchan; icn_loadproto()
986 card->st_timer.data = (unsigned long) card; icn_loadproto()
987 add_timer(&card->st_timer); icn_loadproto()
988 card->flags |= ICN_FLAGS_RUNNING; icn_loadproto()
989 if (card->doubleS0) { icn_loadproto()
990 init_timer(&card->other->st_timer); icn_loadproto()
991 card->other->st_timer.expires = jiffies + ICN_TIMER_DCREAD; icn_loadproto()
992 card->other->st_timer.function = icn_polldchan; icn_loadproto()
993 card->other->st_timer.data = (unsigned long) card->other; icn_loadproto()
994 add_timer(&card->other->st_timer); icn_loadproto()
995 card->other->flags |= ICN_FLAGS_RUNNING; icn_loadproto()
997 spin_unlock_irqrestore(&card->lock, flags); icn_loadproto()
999 icn_maprelease_channel(card, 0); icn_loadproto()
1007 icn_readstatus(u_char __user *buf, int len, icn_card *card) icn_readstatus() argument
1013 if (card->msg_buf_read == card->msg_buf_write) icn_readstatus()
1015 if (put_user(*card->msg_buf_read++, p)) icn_readstatus()
1017 if (card->msg_buf_read > card->msg_buf_end) icn_readstatus()
1018 card->msg_buf_read = card->msg_buf; icn_readstatus()
1025 icn_writecmd(const u_char *buf, int len, int user, icn_card *card) icn_writecmd() argument
1027 int mch = card->secondhalf ? 2 : 0; icn_writecmd()
1056 icn_map_channel(card, mch); icn_writecmd()
1058 icn_putmsg(card, '>'); icn_writecmd()
1065 icn_putmsg(card, *p); icn_writecmd()
1067 icn_putmsg(card, '>'); icn_writecmd()
1086 cmd.driver = card->myid; icn_writecmd()
1088 card->interface.statcallb(&cmd); icn_writecmd()
1093 * Delete card's pending timers, send STOP to linklevel
1096 icn_stopcard(icn_card *card) icn_stopcard() argument
1101 spin_lock_irqsave(&card->lock, flags); icn_stopcard()
1102 if (card->flags & ICN_FLAGS_RUNNING) { icn_stopcard()
1103 card->flags &= ~ICN_FLAGS_RUNNING; icn_stopcard()
1104 del_timer(&card->st_timer); icn_stopcard()
1105 del_timer(&card->rb_timer); icn_stopcard()
1106 spin_unlock_irqrestore(&card->lock, flags); icn_stopcard()
1108 cmd.driver = card->myid; icn_stopcard()
1109 card->interface.statcallb(&cmd); icn_stopcard()
1110 if (card->doubleS0) icn_stopcard()
1111 icn_stopcard(card->other); icn_stopcard()
1113 spin_unlock_irqrestore(&card->lock, flags); icn_stopcard()
1134 icn_card *card = cards; icn_disable_cards() local
1136 while (card) { icn_disable_cards()
1137 if (!request_region(card->port, ICN_PORTLEN, "icn-isdn")) { icn_disable_cards()
1141 card->port, icn_disable_cards()
1142 card->port + ICN_PORTLEN); icn_disable_cards()
1146 release_region(card->port, ICN_PORTLEN); icn_disable_cards()
1148 card = card->next; icn_disable_cards()
1153 icn_command(isdn_ctrl *c, icn_card *card) icn_command() argument
1178 spin_lock_irqsave(&card->lock, flags); icn_command()
1185 spin_unlock_irqrestore(&card->lock, flags); icn_command()
1199 if (card->port != (unsigned short) a) { icn_command()
1207 icn_stopcard(card); icn_command()
1208 spin_lock_irqsave(&card->lock, flags); icn_command()
1209 if (card->rvalid) icn_command()
1210 release_region(card->port, ICN_PORTLEN); icn_command()
1211 card->port = (unsigned short) a; icn_command()
1212 card->rvalid = 0; icn_command()
1213 if (card->doubleS0) { icn_command()
1214 card->other->port = (unsigned short) a; icn_command()
1215 card->other->rvalid = 0; icn_command()
1217 spin_unlock_irqrestore(&card->lock, flags); icn_command()
1220 CID, card->port); icn_command()
1226 return (int) card->port; icn_command()
1228 return (int) card->doubleS0; icn_command()
1231 &card, icn_command()
1248 icn_stopcard(card); icn_command()
1249 return (icn_loadboot(arg, card)); icn_command()
1251 icn_stopcard(card); icn_command()
1252 if ((i = (icn_loadproto(arg, card)))) icn_command()
1254 if (card->doubleS0) icn_command()
1255 i = icn_loadproto(arg + ICN_CODE_STAGE2, card->other); icn_command()
1269 if (!card->leased) { icn_command()
1270 card->leased = 1; icn_command()
1271 while (card->ptype == ISDN_PTYPE_UNKNOWN) { icn_command()
1277 i = icn_writecmd(cbuf, strlen(cbuf), 0, card); icn_command()
1282 cmd.driver = card->myid; icn_command()
1284 card->interface.statcallb(&cmd); icn_command()
1287 if (card->leased) { icn_command()
1288 card->leased = 0; icn_command()
1290 i = icn_writecmd(cbuf, strlen(cbuf), 0, card); icn_command()
1295 cmd.driver = card->myid; icn_command()
1297 card->interface.statcallb(&cmd); icn_command()
1306 if (!(card->flags & ICN_FLAGS_RUNNING)) icn_command()
1308 if (card->leased) icn_command()
1327 i = icn_writecmd(cbuf, strlen(cbuf), 0, card); icn_command()
1331 if (!(card->flags & ICN_FLAGS_RUNNING)) icn_command()
1335 if (card->fw_rev >= 300) { icn_command()
1336 switch (card->l2_proto[a - 1]) { icn_command()
1344 i = icn_writecmd(cbuf, strlen(cbuf), 0, card); icn_command()
1347 i = icn_writecmd(cbuf, strlen(cbuf), 0, card); icn_command()
1351 if (!(card->flags & ICN_FLAGS_RUNNING)) icn_command()
1355 if (card->fw_rev >= 300) icn_command()
1356 switch (card->l2_proto[a - 1]) { icn_command()
1365 i = icn_writecmd(cbuf, strlen(cbuf), 0, card); icn_command()
1369 if (!(card->flags & ICN_FLAGS_RUNNING)) icn_command()
1374 i = icn_writecmd(cbuf, strlen(cbuf), 0, card); icn_command()
1378 if (!(card->flags & ICN_FLAGS_RUNNING)) icn_command()
1380 if (card->leased) icn_command()
1384 if (card->ptype == ISDN_PTYPE_EURO) { icn_command()
1390 i = icn_writecmd(cbuf, strlen(cbuf), 0, card); icn_command()
1394 if (!(card->flags & ICN_FLAGS_RUNNING)) icn_command()
1396 if (card->leased) icn_command()
1400 if (card->ptype == ISDN_PTYPE_EURO) icn_command()
1404 i = icn_writecmd(cbuf, strlen(cbuf), 0, card); icn_command()
1408 if (!(card->flags & ICN_FLAGS_RUNNING)) icn_command()
1422 i = icn_writecmd(cbuf, strlen(cbuf), 0, card); icn_command()
1423 card->l2_proto[a & 255] = (a >> 8); icn_command()
1427 if (!(card->flags & ICN_FLAGS_RUNNING)) icn_command()
1437 * Find card with given driverId
1458 icn_card *card = icn_findcard(c->driver); if_command() local
1460 if (card) if_command()
1461 return (icn_command(c, card)); if_command()
1471 icn_card *card = icn_findcard(id); if_writecmd() local
1473 if (card) { if_writecmd()
1474 if (!(card->flags & ICN_FLAGS_RUNNING)) if_writecmd()
1476 return (icn_writecmd(buf, len, 1, card)); if_writecmd()
1486 icn_card *card = icn_findcard(id); if_readstatus() local
1488 if (card) { if_readstatus()
1489 if (!(card->flags & ICN_FLAGS_RUNNING)) if_readstatus()
1491 return (icn_readstatus(buf, len, card)); if_readstatus()
1501 icn_card *card = icn_findcard(id); if_sendbuf() local
1503 if (card) { if_sendbuf()
1504 if (!(card->flags & ICN_FLAGS_RUNNING)) if_sendbuf()
1506 return (icn_sendbuf(channel, ack, skb, card)); if_sendbuf()
1514 * Allocate a new card-struct, initialize it
1520 icn_card *card; icn_initcard() local
1523 if (!(card = kzalloc(sizeof(icn_card), GFP_KERNEL))) { icn_initcard()
1525 "icn: (%s) Could not allocate card-struct.\n", id); icn_initcard()
1528 spin_lock_init(&card->lock); icn_initcard()
1529 card->port = port; icn_initcard()
1530 card->interface.owner = THIS_MODULE; icn_initcard()
1531 card->interface.hl_hdrlen = 1; icn_initcard()
1532 card->interface.channels = ICN_BCH; icn_initcard()
1533 card->interface.maxbufsize = 4000; icn_initcard()
1534 card->interface.command = if_command; icn_initcard()
1535 card->interface.writebuf_skb = if_sendbuf; icn_initcard()
1536 card->interface.writecmd = if_writecmd; icn_initcard()
1537 card->interface.readstat = if_readstatus; icn_initcard()
1538 card->interface.features = ISDN_FEATURE_L2_X75I | icn_initcard()
1542 card->ptype = ISDN_PTYPE_UNKNOWN; icn_initcard()
1543 strlcpy(card->interface.id, id, sizeof(card->interface.id)); icn_initcard()
1544 card->msg_buf_write = card->msg_buf; icn_initcard()
1545 card->msg_buf_read = card->msg_buf; icn_initcard()
1546 card->msg_buf_end = &card->msg_buf[sizeof(card->msg_buf) - 1]; icn_initcard()
1548 card->l2_proto[i] = ISDN_PROTO_L2_X75I; icn_initcard()
1549 skb_queue_head_init(&card->spqueue[i]); icn_initcard()
1551 card->next = cards; icn_initcard()
1552 cards = card; icn_initcard()
1553 if (!register_isdn(&card->interface)) { icn_initcard()
1557 kfree(card); icn_initcard()
1560 card->myid = card->interface.channels; icn_initcard()
1561 sprintf(card->regname, "icn-isdn (%s)", card->interface.id); icn_initcard()
1562 return card; icn_initcard()
1568 icn_card *card; icn_addcard() local
1571 if (!(card = icn_initcard(port, id1))) { icn_addcard()
1577 card->interface.id, port); icn_addcard()
1585 card->doubleS0 = 1; icn_addcard()
1586 card->secondhalf = 0; icn_addcard()
1587 card->other = card2; icn_addcard()
1590 card2->other = card; icn_addcard()
1593 card->interface.id, card2->interface.id, port); icn_addcard()
1653 icn_card *card = cards; icn_exit() local
1659 while (card) { icn_exit()
1661 cmd.driver = card->myid; icn_exit()
1662 card->interface.statcallb(&cmd); icn_exit()
1663 spin_lock_irqsave(&card->lock, flags); icn_exit()
1664 if (card->rvalid) { icn_exit()
1667 if (card->secondhalf || (!card->doubleS0)) { icn_exit()
1668 release_region(card->port, ICN_PORTLEN); icn_exit()
1669 card->rvalid = 0; icn_exit()
1672 icn_free_queue(card, i); icn_exit()
1674 tmpcard = card->next; icn_exit()
1675 spin_unlock_irqrestore(&card->lock, flags); icn_exit()
1676 card = tmpcard; icn_exit()
1678 card = cards; icn_exit()
1680 while (card) { icn_exit()
1681 last = card; icn_exit()
1682 card = card->next; icn_exit()
/linux-4.1.27/drivers/net/can/softing/
H A Dsofting_main.c41 static inline void softing_set_reset_dpram(struct softing *card) softing_set_reset_dpram() argument
43 if (card->pdat->generation >= 2) { softing_set_reset_dpram()
44 spin_lock_bh(&card->spin); softing_set_reset_dpram()
45 iowrite8(ioread8(&card->dpram[DPRAM_V2_RESET]) & ~1, softing_set_reset_dpram()
46 &card->dpram[DPRAM_V2_RESET]); softing_set_reset_dpram()
47 spin_unlock_bh(&card->spin); softing_set_reset_dpram()
51 static inline void softing_clr_reset_dpram(struct softing *card) softing_clr_reset_dpram() argument
53 if (card->pdat->generation >= 2) { softing_clr_reset_dpram()
54 spin_lock_bh(&card->spin); softing_clr_reset_dpram()
55 iowrite8(ioread8(&card->dpram[DPRAM_V2_RESET]) | 1, softing_clr_reset_dpram()
56 &card->dpram[DPRAM_V2_RESET]); softing_clr_reset_dpram()
57 spin_unlock_bh(&card->spin); softing_clr_reset_dpram()
66 struct softing *card = priv->card; softing_netdev_start_xmit() local
76 spin_lock(&card->spin); softing_netdev_start_xmit()
79 if (!card->fw.up || softing_netdev_start_xmit()
80 (card->tx.pending >= TXMAX) || softing_netdev_start_xmit()
83 fifo_wr = ioread8(&card->dpram[DPRAM_TX_WR]); softing_netdev_start_xmit()
84 fifo_rd = ioread8(&card->dpram[DPRAM_TX_RD]); softing_netdev_start_xmit()
110 memcpy_toio(&card->dpram[DPRAM_TX + DPRAM_TX_SIZE * fifo_wr], softing_netdev_start_xmit()
114 iowrite8(fifo_wr, &card->dpram[DPRAM_TX_WR]); softing_netdev_start_xmit()
115 card->tx.last_bus = priv->index; softing_netdev_start_xmit()
116 ++card->tx.pending; softing_netdev_start_xmit()
125 spin_unlock(&card->spin); softing_netdev_start_xmit()
126 if (card->tx.pending >= TXMAX) { softing_netdev_start_xmit()
128 for (j = 0; j < ARRAY_SIZE(card->net); ++j) { softing_netdev_start_xmit()
129 if (card->net[j]) softing_netdev_start_xmit()
130 netif_stop_queue(card->net[j]); softing_netdev_start_xmit()
160 static int softing_handle_1(struct softing *card) softing_handle_1() argument
174 lost_msg = ioread8(&card->dpram[DPRAM_RX_LOST]); softing_handle_1()
178 iowrite8(0, &card->dpram[DPRAM_RX_LOST]); softing_handle_1()
187 for (j = 0; j < ARRAY_SIZE(card->net); ++j) { softing_handle_1()
188 netdev = card->net[j]; softing_handle_1()
202 fifo_rd = ioread8(&card->dpram[DPRAM_RX_RD]); softing_handle_1()
203 fifo_wr = ioread8(&card->dpram[DPRAM_RX_WR]); softing_handle_1()
210 memcpy_fromio(buf, &card->dpram[DPRAM_RX + DPRAM_RX_SIZE*fifo_rd], softing_handle_1()
214 iowrite8(fifo_rd, &card->dpram[DPRAM_RX_RD]); softing_handle_1()
219 /* not quite useful, probably the card has got out */ softing_handle_1()
221 netdev = card->net[0]; softing_handle_1()
223 netdev = card->net[1]; softing_handle_1()
249 iowrite8(state, &card->dpram[priv->index ? softing_handle_1()
254 ktime = softing_raw2ktime(card, tmp_u32); softing_handle_1()
287 ktime = softing_raw2ktime(card, tmp_u32); softing_handle_1()
304 if (card->tx.pending) softing_handle_1()
305 --card->tx.pending; softing_handle_1()
331 struct softing *card = (struct softing *)dev_id; softing_irq_thread() local
337 spin_lock_bh(&card->spin); softing_irq_thread()
338 while (softing_handle_1(card) > 0) { softing_irq_thread()
339 ++card->irq.svc_count; softing_irq_thread()
342 spin_unlock_bh(&card->spin); softing_irq_thread()
344 offset = card->tx.last_bus; softing_irq_thread()
345 for (j = 0; j < ARRAY_SIZE(card->net); ++j) { softing_irq_thread()
346 if (card->tx.pending >= TXMAX) softing_irq_thread()
348 netdev = card->net[(j + offset + 1) % card->pdat->nbus]; softing_irq_thread()
369 struct softing *card = (struct softing *)dev_id; softing_irq_v2() local
372 ir = ioread8(&card->dpram[DPRAM_V2_IRQ_TOHOST]); softing_irq_v2()
373 iowrite8(0, &card->dpram[DPRAM_V2_IRQ_TOHOST]); softing_irq_v2()
379 struct softing *card = (struct softing *)dev_id; softing_irq_v1() local
382 ir = ioread8(&card->dpram[DPRAM_IRQ_TOHOST]); softing_irq_v1()
383 iowrite8(0, &card->dpram[DPRAM_IRQ_TOHOST]); softing_irq_v1()
431 int softing_enable_irq(struct softing *card, int enable) softing_enable_irq() argument
435 if (!card->irq.nr) { softing_enable_irq()
437 } else if (card->irq.requested && !enable) { softing_enable_irq()
438 free_irq(card->irq.nr, card); softing_enable_irq()
439 card->irq.requested = 0; softing_enable_irq()
440 } else if (!card->irq.requested && enable) { softing_enable_irq()
441 ret = request_threaded_irq(card->irq.nr, softing_enable_irq()
442 (card->pdat->generation >= 2) ? softing_enable_irq()
445 dev_name(&card->pdev->dev), card); softing_enable_irq()
447 dev_alert(&card->pdev->dev, softing_enable_irq()
449 card->irq.nr); softing_enable_irq()
452 card->irq.requested = 1; softing_enable_irq()
457 static void softing_card_shutdown(struct softing *card) softing_card_shutdown() argument
461 if (mutex_lock_interruptible(&card->fw.lock)) softing_card_shutdown()
463 fw_up = card->fw.up; softing_card_shutdown()
464 card->fw.up = 0; softing_card_shutdown()
466 if (card->irq.requested && card->irq.nr) { softing_card_shutdown()
467 free_irq(card->irq.nr, card); softing_card_shutdown()
468 card->irq.requested = 0; softing_card_shutdown()
471 if (card->pdat->enable_irq) softing_card_shutdown()
472 card->pdat->enable_irq(card->pdev, 0); softing_card_shutdown()
473 softing_set_reset_dpram(card); softing_card_shutdown()
474 if (card->pdat->reset) softing_card_shutdown()
475 card->pdat->reset(card->pdev, 1); softing_card_shutdown()
477 mutex_unlock(&card->fw.lock); softing_card_shutdown()
480 static int softing_card_boot(struct softing *card) softing_card_boot() argument
487 if (mutex_lock_interruptible(&card->fw.lock)) softing_card_boot()
489 if (card->fw.up) { softing_card_boot()
490 mutex_unlock(&card->fw.lock); softing_card_boot()
494 if (card->pdat->enable_irq) softing_card_boot()
495 card->pdat->enable_irq(card->pdev, 1); softing_card_boot()
496 /* boot card */ softing_card_boot()
497 softing_set_reset_dpram(card); softing_card_boot()
498 if (card->pdat->reset) softing_card_boot()
499 card->pdat->reset(card->pdev, 1); softing_card_boot()
500 for (j = 0; (j + sizeof(stream)) < card->dpram_size; softing_card_boot()
503 memcpy_toio(&card->dpram[j], stream, sizeof(stream)); softing_card_boot()
506 memcpy_fromio(back, &card->dpram[j], sizeof(stream)); softing_card_boot()
511 dev_alert(&card->pdev->dev, "dpram failed at 0x%04x\n", j); softing_card_boot()
517 ret = softing_load_fw(card->pdat->boot.fw, card, card->dpram, softing_card_boot()
518 card->dpram_size, softing_card_boot()
519 card->pdat->boot.offs - card->pdat->boot.addr); softing_card_boot()
523 ret = softing_load_fw(card->pdat->load.fw, card, card->dpram, softing_card_boot()
524 card->dpram_size, softing_card_boot()
525 card->pdat->load.offs - card->pdat->load.addr); softing_card_boot()
529 if (card->pdat->reset) softing_card_boot()
530 card->pdat->reset(card->pdev, 0); softing_card_boot()
531 softing_clr_reset_dpram(card); softing_card_boot()
532 ret = softing_bootloader_command(card, 0, "card boot"); softing_card_boot()
535 ret = softing_load_app_fw(card->pdat->app.fw, card); softing_card_boot()
539 ret = softing_chip_poweron(card); softing_card_boot()
543 card->fw.up = 1; softing_card_boot()
544 mutex_unlock(&card->fw.lock); softing_card_boot()
547 card->fw.up = 0; softing_card_boot()
548 if (card->pdat->enable_irq) softing_card_boot()
549 card->pdat->enable_irq(card->pdev, 0); softing_card_boot()
550 softing_set_reset_dpram(card); softing_card_boot()
551 if (card->pdat->reset) softing_card_boot()
552 card->pdat->reset(card->pdev, 1); softing_card_boot()
553 mutex_unlock(&card->fw.lock); softing_card_boot()
583 struct softing *card = priv->card; store_output() local
592 ret = mutex_lock_interruptible(&card->fw.lock); store_output()
596 mutex_unlock(&card->fw.lock); store_output()
600 mutex_unlock(&card->fw.lock); store_output()
637 static struct net_device *softing_netdev_create(struct softing *card, softing_netdev_create() argument
645 dev_alert(&card->pdev->dev, "alloc_candev failed\n"); softing_netdev_create()
650 priv->card = card; softing_netdev_create()
652 priv->btr_const.brp_max = card->pdat->max_brp; softing_netdev_create()
653 priv->btr_const.sjw_max = card->pdat->max_sjw; softing_netdev_create()
658 SET_NETDEV_DEV(netdev, &card->pdev->dev); softing_netdev_create()
697 struct softing *card = platform_get_drvdata(to_platform_device(dev)); \
698 return sprintf(buf, "%u\n", card->member); \
706 struct softing *card = platform_get_drvdata(to_platform_device(dev)); \
707 return sprintf(buf, "%s\n", card->member); \
738 struct softing *card = platform_get_drvdata(pdev); softing_pdev_remove() local
741 /* first, disable card*/ softing_pdev_remove()
742 softing_card_shutdown(card); softing_pdev_remove()
744 for (j = 0; j < ARRAY_SIZE(card->net); ++j) { softing_pdev_remove()
745 if (!card->net[j]) softing_pdev_remove()
747 softing_netdev_cleanup(card->net[j]); softing_pdev_remove()
748 card->net[j] = NULL; softing_pdev_remove()
752 iounmap(card->dpram); softing_pdev_remove()
753 kfree(card); softing_pdev_remove()
760 struct softing *card; softing_pdev_probe() local
771 if (pdat->nbus > ARRAY_SIZE(card->net)) { softing_pdev_probe()
776 card = kzalloc(sizeof(*card), GFP_KERNEL); softing_pdev_probe()
777 if (!card) softing_pdev_probe()
779 card->pdat = pdat; softing_pdev_probe()
780 card->pdev = pdev; softing_pdev_probe()
781 platform_set_drvdata(pdev, card); softing_pdev_probe()
782 mutex_init(&card->fw.lock); softing_pdev_probe()
783 spin_lock_init(&card->spin); softing_pdev_probe()
789 card->dpram_phys = pres->start; softing_pdev_probe()
790 card->dpram_size = resource_size(pres); softing_pdev_probe()
791 card->dpram = ioremap_nocache(card->dpram_phys, card->dpram_size); softing_pdev_probe()
792 if (!card->dpram) { softing_pdev_probe()
793 dev_alert(&card->pdev->dev, "dpram ioremap failed\n"); softing_pdev_probe()
799 card->irq.nr = pres->start; softing_pdev_probe()
801 /* reset card */ softing_pdev_probe()
802 ret = softing_card_boot(card); softing_pdev_probe()
809 card->id.freq = card->pdat->freq; softing_pdev_probe()
813 dev_alert(&card->pdev->dev, "sysfs failed\n"); softing_pdev_probe()
817 for (j = 0; j < ARRAY_SIZE(card->net); ++j) { softing_pdev_probe()
818 card->net[j] = netdev = softing_pdev_probe()
819 softing_netdev_create(card, card->id.chip[j]); softing_pdev_probe()
826 priv = netdev_priv(card->net[j]); softing_pdev_probe()
831 card->net[j] = NULL; softing_pdev_probe()
832 dev_alert(&card->pdev->dev, softing_pdev_probe()
837 dev_info(&card->pdev->dev, "%s ready.\n", card->pdat->name); softing_pdev_probe()
841 for (j = 0; j < ARRAY_SIZE(card->net); ++j) { softing_pdev_probe()
842 if (!card->net[j]) softing_pdev_probe()
844 softing_netdev_cleanup(card->net[j]); softing_pdev_probe()
848 softing_card_shutdown(card); softing_pdev_probe()
850 iounmap(card->dpram); softing_pdev_probe()
853 kfree(card); softing_pdev_probe()
H A Dsofting_fw.c28 * Make sure that card->dpram[DPRAM_FCT_HOST] is preset
30 static int _softing_fct_cmd(struct softing *card, int16_t cmd, uint16_t vector, _softing_fct_cmd() argument
36 iowrite16(cmd, &card->dpram[DPRAM_FCT_PARAM]); _softing_fct_cmd()
37 iowrite8(vector >> 8, &card->dpram[DPRAM_FCT_HOST + 1]); _softing_fct_cmd()
38 iowrite8(vector, &card->dpram[DPRAM_FCT_HOST]); _softing_fct_cmd()
39 /* be sure to flush this to the card */ _softing_fct_cmd()
42 /* wait for card */ _softing_fct_cmd()
45 ret = ioread8(&card->dpram[DPRAM_FCT_HOST]) + _softing_fct_cmd()
46 (ioread8(&card->dpram[DPRAM_FCT_HOST + 1]) << 8); _softing_fct_cmd()
51 return ioread16(&card->dpram[DPRAM_FCT_RESULT]); _softing_fct_cmd()
60 dev_alert(&card->pdev->dev, "firmware %s failed (%i)\n", msg, ret); _softing_fct_cmd()
64 static int softing_fct_cmd(struct softing *card, int16_t cmd, const char *msg) softing_fct_cmd() argument
68 ret = _softing_fct_cmd(card, cmd, 0, msg); softing_fct_cmd()
70 dev_alert(&card->pdev->dev, "%s returned %u\n", msg, ret); softing_fct_cmd()
76 int softing_bootloader_command(struct softing *card, int16_t cmd, softing_bootloader_command() argument
82 iowrite16(RES_NONE, &card->dpram[DPRAM_RECEIPT]); softing_bootloader_command()
83 iowrite16(cmd, &card->dpram[DPRAM_COMMAND]); softing_bootloader_command()
84 /* be sure to flush this to the card */ softing_bootloader_command()
87 /* wait for card */ softing_bootloader_command()
89 ret = ioread16(&card->dpram[DPRAM_RECEIPT]); softing_bootloader_command()
101 dev_alert(&card->pdev->dev, "bootloader %s failed (%i)\n", msg, ret); softing_bootloader_command()
144 int softing_load_fw(const char *file, struct softing *card, softing_load_fw() argument
156 ret = request_firmware(&fw, file, &card->pdev->dev); softing_load_fw()
159 dev_dbg(&card->pdev->dev, "%s, firmware(%s) got %u bytes" softing_load_fw()
161 card->pdat->name, file, (unsigned int)fw->size, softing_load_fw()
212 dev_alert(&card->pdev->dev, "DPRAM readback failed\n"); softing_load_fw()
225 dev_info(&card->pdev->dev, "firmware %s failed\n", file); softing_load_fw()
229 int softing_load_app_fw(const char *file, struct softing *card) softing_load_app_fw() argument
239 ret = request_firmware(&fw, file, &card->pdev->dev); softing_load_app_fw()
241 dev_alert(&card->pdev->dev, "request_firmware(%s) got %i\n", softing_load_app_fw()
245 dev_dbg(&card->pdev->dev, "firmware(%s) got %lu bytes\n", softing_load_app_fw()
256 dev_alert(&card->pdev->dev, "firmware starts with type 0x%x\n", softing_load_app_fw()
261 dev_alert(&card->pdev->dev, "firmware string '%.*s' fault\n", softing_load_app_fw()
281 dev_alert(&card->pdev->dev, softing_load_app_fw()
293 memcpy_toio(&card->dpram[card->pdat->app.offs], dat, len); softing_load_app_fw()
294 iowrite32(card->pdat->app.offs + card->pdat->app.addr, softing_load_app_fw()
295 &card->dpram[DPRAM_COMMAND + 2]); softing_load_app_fw()
296 iowrite32(addr, &card->dpram[DPRAM_COMMAND + 6]); softing_load_app_fw()
297 iowrite16(len, &card->dpram[DPRAM_COMMAND + 10]); softing_load_app_fw()
298 iowrite8(1, &card->dpram[DPRAM_COMMAND + 12]); softing_load_app_fw()
299 ret = softing_bootloader_command(card, 1, "loading app."); softing_load_app_fw()
303 rx_sum = ioread16(&card->dpram[DPRAM_RECEIPT + 2]); softing_load_app_fw()
305 dev_alert(&card->pdev->dev, "SRAM seems to be damaged" softing_load_app_fw()
313 /* start application in card */ softing_load_app_fw()
314 iowrite32(start_addr, &card->dpram[DPRAM_COMMAND + 2]); softing_load_app_fw()
315 iowrite8(1, &card->dpram[DPRAM_COMMAND + 6]); softing_load_app_fw()
316 ret = softing_bootloader_command(card, 3, "start app."); softing_load_app_fw()
323 dev_info(&card->pdev->dev, "firmware %s failed\n", file); softing_load_app_fw()
327 static int softing_reset_chip(struct softing *card) softing_reset_chip() argument
333 iowrite8(0, &card->dpram[DPRAM_RESET_RX_FIFO]); softing_reset_chip()
334 iowrite8(0, &card->dpram[DPRAM_RESET_RX_FIFO+1]); softing_reset_chip()
335 iowrite8(1, &card->dpram[DPRAM_RESET]); softing_reset_chip()
336 iowrite8(0, &card->dpram[DPRAM_RESET+1]); softing_reset_chip()
338 ret = softing_fct_cmd(card, 0, "reset_can"); softing_reset_chip()
345 card->tx.pending = 0; softing_reset_chip()
349 int softing_chip_poweron(struct softing *card) softing_chip_poweron() argument
353 ret = _softing_fct_cmd(card, 99, 0x55, "sync-a"); softing_chip_poweron()
357 ret = _softing_fct_cmd(card, 99, 0xaa, "sync-b"); softing_chip_poweron()
361 ret = softing_reset_chip(card); softing_chip_poweron()
365 ret = softing_fct_cmd(card, 43, "get_serial_number"); softing_chip_poweron()
368 card->id.serial = ioread32(&card->dpram[DPRAM_FCT_PARAM]); softing_chip_poweron()
370 ret = softing_fct_cmd(card, 12, "get_version"); softing_chip_poweron()
373 card->id.fw_version = ioread16(&card->dpram[DPRAM_FCT_PARAM + 2]); softing_chip_poweron()
374 card->id.hw_version = ioread16(&card->dpram[DPRAM_FCT_PARAM + 4]); softing_chip_poweron()
375 card->id.license = ioread16(&card->dpram[DPRAM_FCT_PARAM + 6]); softing_chip_poweron()
376 card->id.chip[0] = ioread16(&card->dpram[DPRAM_FCT_PARAM + 8]); softing_chip_poweron()
377 card->id.chip[1] = ioread16(&card->dpram[DPRAM_FCT_PARAM + 10]); softing_chip_poweron()
383 static void softing_initialize_timestamp(struct softing *card) softing_initialize_timestamp() argument
387 card->ts_ref = ktime_get(); softing_initialize_timestamp()
391 do_div(ovf, card->pdat->freq ?: 16); softing_initialize_timestamp()
393 card->ts_overflow = ktime_add_us(ktime_set(0, 0), ovf); softing_initialize_timestamp()
396 ktime_t softing_raw2ktime(struct softing *card, u32 raw) softing_raw2ktime() argument
406 /* find nsec from card */ softing_raw2ktime()
408 do_div(rawl, card->pdat->freq ?: 16); softing_raw2ktime()
409 target = ktime_add_us(card->ts_ref, rawl); softing_raw2ktime()
411 tmp = ktime_add(target, card->ts_overflow); softing_raw2ktime()
413 card->ts_ref = ktime_add(card->ts_ref, card->ts_overflow); softing_raw2ktime()
415 tmp = ktime_add(target, card->ts_overflow); softing_raw2ktime()
431 struct softing *card; softing_startstop() local
440 card = priv->card; softing_startstop()
442 if (!card->fw.up) softing_startstop()
445 ret = mutex_lock_interruptible(&card->fw.lock); softing_startstop()
454 for (j = 0; j < ARRAY_SIZE(card->net); ++j) { softing_startstop()
455 netdev = card->net[j]; softing_startstop()
481 card->tx.pending = 0; softing_startstop()
483 softing_enable_irq(card, 0); softing_startstop()
484 ret = softing_reset_chip(card); softing_startstop()
492 && (softing_error_reporting(card->net[0]) softing_startstop()
493 != softing_error_reporting(card->net[1]))) { softing_startstop()
494 dev_alert(&card->pdev->dev, softing_startstop()
500 netdev = card->net[0]; softing_startstop()
505 iowrite16(bt->brp, &card->dpram[DPRAM_FCT_PARAM + 2]); softing_startstop()
506 iowrite16(bt->sjw, &card->dpram[DPRAM_FCT_PARAM + 4]); softing_startstop()
508 &card->dpram[DPRAM_FCT_PARAM + 6]); softing_startstop()
509 iowrite16(bt->phase_seg2, &card->dpram[DPRAM_FCT_PARAM + 8]); softing_startstop()
511 &card->dpram[DPRAM_FCT_PARAM + 10]); softing_startstop()
512 ret = softing_fct_cmd(card, 1, "initialize_chip[0]"); softing_startstop()
516 iowrite16(0, &card->dpram[DPRAM_FCT_PARAM + 2]); softing_startstop()
517 iowrite16(0, &card->dpram[DPRAM_FCT_PARAM + 4]); softing_startstop()
518 ret = softing_fct_cmd(card, 3, "set_mode[0]"); softing_startstop()
523 iowrite16(0x0000, &card->dpram[DPRAM_FCT_PARAM + 2]); softing_startstop()
524 iowrite16(0x07ff, &card->dpram[DPRAM_FCT_PARAM + 4]); softing_startstop()
526 iowrite16(0x0000, &card->dpram[DPRAM_FCT_PARAM + 6]); softing_startstop()
527 iowrite16(0xffff, &card->dpram[DPRAM_FCT_PARAM + 8]); softing_startstop()
528 iowrite16(0x0000, &card->dpram[DPRAM_FCT_PARAM + 10]); softing_startstop()
529 iowrite16(0x1fff, &card->dpram[DPRAM_FCT_PARAM + 12]); softing_startstop()
530 ret = softing_fct_cmd(card, 7, "set_filter[0]"); softing_startstop()
534 iowrite16(priv->output, &card->dpram[DPRAM_FCT_PARAM + 2]); softing_startstop()
535 ret = softing_fct_cmd(card, 5, "set_output[0]"); softing_startstop()
540 netdev = card->net[1]; softing_startstop()
545 iowrite16(bt->brp, &card->dpram[DPRAM_FCT_PARAM + 2]); softing_startstop()
546 iowrite16(bt->sjw, &card->dpram[DPRAM_FCT_PARAM + 4]); softing_startstop()
548 &card->dpram[DPRAM_FCT_PARAM + 6]); softing_startstop()
549 iowrite16(bt->phase_seg2, &card->dpram[DPRAM_FCT_PARAM + 8]); softing_startstop()
551 &card->dpram[DPRAM_FCT_PARAM + 10]); softing_startstop()
552 ret = softing_fct_cmd(card, 2, "initialize_chip[1]"); softing_startstop()
556 iowrite16(0, &card->dpram[DPRAM_FCT_PARAM + 2]); softing_startstop()
557 iowrite16(0, &card->dpram[DPRAM_FCT_PARAM + 4]); softing_startstop()
558 ret = softing_fct_cmd(card, 4, "set_mode[1]"); softing_startstop()
563 iowrite16(0x0000, &card->dpram[DPRAM_FCT_PARAM + 2]); softing_startstop()
564 iowrite16(0x07ff, &card->dpram[DPRAM_FCT_PARAM + 4]); softing_startstop()
566 iowrite16(0x0000, &card->dpram[DPRAM_FCT_PARAM + 6]); softing_startstop()
567 iowrite16(0xffff, &card->dpram[DPRAM_FCT_PARAM + 8]); softing_startstop()
568 iowrite16(0x0000, &card->dpram[DPRAM_FCT_PARAM + 10]); softing_startstop()
569 iowrite16(0x1fff, &card->dpram[DPRAM_FCT_PARAM + 12]); softing_startstop()
570 ret = softing_fct_cmd(card, 8, "set_filter[1]"); softing_startstop()
574 iowrite16(priv->output, &card->dpram[DPRAM_FCT_PARAM + 2]); softing_startstop()
575 ret = softing_fct_cmd(card, 6, "set_output[1]"); softing_startstop()
586 ret = softing_fct_cmd(card, 51, "enable_error_frame"); softing_startstop()
592 iowrite16(1, &card->dpram[DPRAM_FCT_PARAM + 2]); softing_startstop()
593 iowrite16(1, &card->dpram[DPRAM_FCT_PARAM + 4]); softing_startstop()
594 iowrite16(1, &card->dpram[DPRAM_FCT_PARAM + 6]); softing_startstop()
595 iowrite16(1, &card->dpram[DPRAM_FCT_PARAM + 8]); softing_startstop()
596 iowrite16(1, &card->dpram[DPRAM_FCT_PARAM + 10]); softing_startstop()
597 iowrite16(1, &card->dpram[DPRAM_FCT_PARAM + 12]); softing_startstop()
598 iowrite16(1, &card->dpram[DPRAM_FCT_PARAM + 14]); softing_startstop()
599 iowrite16(1, &card->dpram[DPRAM_FCT_PARAM + 16]); softing_startstop()
600 iowrite16(1, &card->dpram[DPRAM_FCT_PARAM + 18]); softing_startstop()
601 iowrite16(1, &card->dpram[DPRAM_FCT_PARAM + 20]); softing_startstop()
602 ret = softing_fct_cmd(card, 17, "initialize_interface"); softing_startstop()
606 ret = softing_fct_cmd(card, 36, "enable_fifo"); softing_startstop()
610 ret = softing_fct_cmd(card, 13, "fifo_tx_ack[0]"); softing_startstop()
614 ret = softing_fct_cmd(card, 14, "fifo_tx_ack[1]"); softing_startstop()
618 ret = softing_fct_cmd(card, 11, "start_chip"); softing_startstop()
621 iowrite8(0, &card->dpram[DPRAM_INFO_BUSSTATE]); softing_startstop()
622 iowrite8(0, &card->dpram[DPRAM_INFO_BUSSTATE2]); softing_startstop()
623 if (card->pdat->generation < 2) { softing_startstop()
624 iowrite8(0, &card->dpram[DPRAM_V2_IRQ_TOHOST]); softing_startstop()
629 softing_initialize_timestamp(card); softing_startstop()
639 for (j = 0; j < ARRAY_SIZE(card->net); ++j) { softing_startstop()
642 netdev = card->net[j]; softing_startstop()
657 ret = softing_enable_irq(card, 1); softing_startstop()
661 mutex_unlock(&card->fw.lock); softing_startstop()
666 softing_enable_irq(card, 0); softing_startstop()
667 softing_reset_chip(card); softing_startstop()
668 mutex_unlock(&card->fw.lock); softing_startstop()
670 for (j = 0; j < ARRAY_SIZE(card->net); ++j) { softing_startstop()
671 netdev = card->net[j]; softing_startstop()
682 struct softing *card = priv->card; softing_default_output() local
686 return (card->pdat->generation < 2) ? 0xfb : 0xfa; softing_default_output()
/linux-4.1.27/sound/soc/sh/rcar/
H A DMakefile4 snd-soc-rsrc-card-objs := rsrc-card.o
5 obj-$(CONFIG_SND_SOC_RSRC_CARD) += snd-soc-rsrc-card.o
/linux-4.1.27/drivers/pnp/
H A Dcard.c2 * card.c - contains functions for managing groups of PnP devices
19 struct pnp_card *card) match_card()
24 if (compare_pnp_id(card->id, drv_id->id)) { match_card()
35 card_for_each_dev(card, dev) { card_for_each_dev()
61 if (!dev->card || !drv) card_remove_first()
70 static int card_probe(struct pnp_card *card, struct pnp_card_driver *drv) card_probe() argument
78 id = match_card(drv, card); card_probe()
85 clink->card = card; card_probe()
93 card_for_each_dev(card, dev) { card_for_each_dev()
102 * pnp_add_card_id - adds an EISA id to the specified card
104 * @card: pointer to the desired card
106 static struct pnp_id *pnp_add_card_id(struct pnp_card *card, char *id) pnp_add_card_id() argument
124 ptr = card->id; pnp_add_card_id()
130 card->id = dev_id; pnp_add_card_id()
135 static void pnp_free_card_ids(struct pnp_card *card) pnp_free_card_ids() argument
140 id = card->id; pnp_free_card_ids()
150 struct pnp_card *card = to_pnp_card(dmdev); pnp_release_card() local
152 pnp_free_card_ids(card); pnp_release_card()
153 kfree(card); pnp_release_card()
158 struct pnp_card *card; pnp_alloc_card() local
161 card = kzalloc(sizeof(struct pnp_card), GFP_KERNEL); pnp_alloc_card()
162 if (!card) pnp_alloc_card()
165 card->protocol = protocol; pnp_alloc_card()
166 card->number = id; pnp_alloc_card()
168 card->dev.parent = &card->protocol->dev; pnp_alloc_card()
169 dev_set_name(&card->dev, "%02x:%02x", card->protocol->number, card->number); pnp_alloc_card()
171 card->dev.coherent_dma_mask = DMA_BIT_MASK(24); pnp_alloc_card()
172 card->dev.dma_mask = &card->dev.coherent_dma_mask; pnp_alloc_card()
174 dev_id = pnp_add_card_id(card, pnpid); pnp_alloc_card()
176 kfree(card); pnp_alloc_card()
180 return card; pnp_alloc_card()
187 struct pnp_card *card = to_pnp_card(dmdev); pnp_show_card_name() local
189 str += sprintf(str, "%s\n", card->name); pnp_show_card_name()
199 struct pnp_card *card = to_pnp_card(dmdev); pnp_show_card_ids() local
200 struct pnp_id *pos = card->id; pnp_show_card_ids()
211 static int pnp_interface_attach_card(struct pnp_card *card) pnp_interface_attach_card() argument
213 int rc = device_create_file(&card->dev, &dev_attr_name); pnp_interface_attach_card()
218 rc = device_create_file(&card->dev, &dev_attr_card_id); pnp_interface_attach_card()
225 device_remove_file(&card->dev, &dev_attr_name); pnp_interface_attach_card()
230 * pnp_add_card - adds a PnP card to the PnP Layer
231 * @card: pointer to the card to add
233 int pnp_add_card(struct pnp_card *card) pnp_add_card() argument
238 card->dev.bus = NULL; pnp_add_card()
239 card->dev.release = &pnp_release_card; pnp_add_card()
240 error = device_register(&card->dev); pnp_add_card()
242 dev_err(&card->dev, "could not register (err=%d)\n", error); pnp_add_card()
243 put_device(&card->dev); pnp_add_card()
247 pnp_interface_attach_card(card); pnp_add_card()
249 list_add_tail(&card->global_list, &pnp_cards); pnp_add_card()
250 list_add_tail(&card->protocol_list, &card->protocol->cards); pnp_add_card()
254 * will be able to use all of the related devices on the card pnp_add_card()
256 list_for_each(pos, &card->devices) { pnp_add_card()
261 /* match with card drivers */ pnp_add_card()
266 card_probe(card, drv); pnp_add_card()
272 * pnp_remove_card - removes a PnP card from the PnP Layer
273 * @card: pointer to the card to remove
275 void pnp_remove_card(struct pnp_card *card) pnp_remove_card() argument
279 device_unregister(&card->dev); pnp_remove_card()
281 list_del(&card->global_list); pnp_remove_card()
282 list_del(&card->protocol_list); pnp_remove_card()
284 list_for_each_safe(pos, temp, &card->devices) { pnp_remove_card()
291 * pnp_add_card_device - adds a device to the specified card
292 * @card: pointer to the card to add to
295 int pnp_add_card_device(struct pnp_card *card, struct pnp_dev *dev) pnp_add_card_device() argument
297 dev->dev.parent = &card->dev; pnp_add_card_device()
300 dev->protocol->number, card->number, dev->number); pnp_add_card_device()
302 dev->card = card; pnp_add_card_device()
303 list_add_tail(&dev->card_list, &card->devices); pnp_add_card_device()
309 * pnp_remove_card_device- removes a device from the specified card
315 dev->card = NULL; pnp_remove_card_device()
322 * pnp_request_card_device - Searches for a PnP device under the specified card
323 * @clink: pointer to the card link, cannot be NULL
333 struct pnp_card *card; pnp_request_card_device() local
338 card = clink->card; pnp_request_card_device()
341 pos = card->devices.next; pnp_request_card_device()
343 if (from->card != card) pnp_request_card_device()
347 while (pos != &card->devices) { pnp_request_card_device()
410 * pnp_register_card_driver - registers a PnP card driver with the PnP Layer
435 struct pnp_card *card = pnp_register_card_driver() local
437 card_probe(card, drv); pnp_register_card_driver()
443 * pnp_unregister_card_driver - unregisters a PnP card driver from the PnP Layer
18 match_card(struct pnp_card_driver *drv, struct pnp_card *card) match_card() argument
H A DMakefile7 pnp-y := core.o card.o driver.o resource.o manager.o support.o interface.o quirks.o
/linux-4.1.27/drivers/block/
H A Dumem.c33 * - a sequence of writes that cover the card, and
148 static void check_batteries(struct cardinfo *card);
150 static int get_userbit(struct cardinfo *card, int bit) get_userbit() argument
154 led = readb(card->csr_remap + MEMCTRLCMD_LEDCTRL); get_userbit()
158 static int set_userbit(struct cardinfo *card, int bit, unsigned char state) set_userbit() argument
162 led = readb(card->csr_remap + MEMCTRLCMD_LEDCTRL); set_userbit()
167 writeb(led, card->csr_remap + MEMCTRLCMD_LEDCTRL); set_userbit()
175 static void set_led(struct cardinfo *card, int shift, unsigned char state) set_led() argument
179 led = readb(card->csr_remap + MEMCTRLCMD_LEDCTRL); set_led()
186 writeb(led, card->csr_remap + MEMCTRLCMD_LEDCTRL); set_led()
191 static void dump_regs(struct cardinfo *card) dump_regs() argument
196 p = card->csr_remap; dump_regs()
208 static void dump_dmastat(struct cardinfo *card, unsigned int dmastat) dump_dmastat() argument
210 dev_printk(KERN_DEBUG, &card->dev->dev, "DMAstat - "); dump_dmastat()
252 static void mm_start_io(struct cardinfo *card) mm_start_io() argument
255 * no IO active, and we know that card->Active mm_start_io()
263 page = &card->mm_pages[card->Active]; mm_start_io()
265 card->Active, page->headcnt, page->cnt - 1); mm_start_io()
274 set_led(card, LED_REMOVE, LED_ON); mm_start_io()
277 writel(0, card->csr_remap + DMA_PCI_ADDR); mm_start_io()
278 writel(0, card->csr_remap + DMA_PCI_ADDR + 4); mm_start_io()
280 writel(0, card->csr_remap + DMA_LOCAL_ADDR); mm_start_io()
281 writel(0, card->csr_remap + DMA_LOCAL_ADDR + 4); mm_start_io()
283 writel(0, card->csr_remap + DMA_TRANSFER_SIZE); mm_start_io()
284 writel(0, card->csr_remap + DMA_TRANSFER_SIZE + 4); mm_start_io()
286 writel(0, card->csr_remap + DMA_SEMAPHORE_ADDR); mm_start_io()
287 writel(0, card->csr_remap + DMA_SEMAPHORE_ADDR + 4); mm_start_io()
291 card->csr_remap + DMA_DESCRIPTOR_ADDR); mm_start_io()
295 card->csr_remap + DMA_DESCRIPTOR_ADDR + 4); mm_start_io()
299 card->csr_remap + DMA_STATUS_CTRL); mm_start_io()
302 static int add_bio(struct cardinfo *card);
304 static void activate(struct cardinfo *card) activate() argument
313 while (add_bio(card)) activate()
316 if (card->Active == -1 && activate()
317 card->mm_pages[card->Ready].cnt > 0) { activate()
318 card->Active = card->Ready; activate()
319 card->Ready = 1-card->Ready; activate()
320 mm_start_io(card); activate()
323 } while (card->Active == -1 && add_bio(card)); activate()
339 static int add_bio(struct cardinfo *card) add_bio() argument
349 bio = card->currentbio; add_bio()
350 if (!bio && card->bio) { add_bio()
351 card->currentbio = card->bio; add_bio()
352 card->current_iter = card->bio->bi_iter; add_bio()
353 card->bio = card->bio->bi_next; add_bio()
354 if (card->bio == NULL) add_bio()
355 card->biotail = &card->bio; add_bio()
356 card->currentbio->bi_next = NULL; add_bio()
363 if (card->mm_pages[card->Ready].cnt >= DESC_PER_PAGE) add_bio()
366 vec = bio_iter_iovec(bio, card->current_iter); add_bio()
368 dma_handle = pci_map_page(card->dev, add_bio()
375 p = &card->mm_pages[card->Ready]; add_bio()
379 p->iter = card->current_iter; add_bio()
389 desc->local_addr = cpu_to_le64(card->current_iter.bi_sector << 9); add_bio()
406 bio_advance_iter(bio, &card->current_iter, vec.bv_len); add_bio()
407 if (!card->current_iter.bi_size) add_bio()
408 card->currentbio = NULL; add_bio()
423 struct cardinfo *card = (struct cardinfo *)data; process_page() local
424 unsigned int dma_status = card->dma_status; process_page()
426 spin_lock_bh(&card->lock); process_page()
427 if (card->Active < 0) process_page()
429 page = &card->mm_pages[card->Active]; process_page()
453 pci_unmap_page(card->dev, desc->data_dma_handle, process_page()
460 dev_printk(KERN_WARNING, &card->dev->dev, process_page()
464 dump_dmastat(card, control); process_page()
467 card->init_size) { process_page()
468 card->init_size += le32_to_cpu(desc->transfer_size) >> 9; process_page()
469 if (card->init_size >> 1 >= card->mm_size) { process_page()
470 dev_printk(KERN_INFO, &card->dev->dev, process_page()
472 set_userbit(card, MEMORY_INITIALIZED, 1); process_page()
485 set_led(card, LED_REMOVE, LED_OFF); process_page()
487 if (card->check_batteries) { process_page()
488 card->check_batteries = 0; process_page()
489 check_batteries(card); process_page()
493 card->Active = -1; process_page()
494 activate(card); process_page()
498 mm_start_io(card); process_page()
501 spin_unlock_bh(&card->lock); process_page()
514 struct cardinfo *card = cb->data; mm_unplug() local
516 spin_lock_irq(&card->lock); mm_unplug()
517 activate(card); mm_unplug()
518 spin_unlock_irq(&card->lock); mm_unplug()
522 static int mm_check_plugged(struct cardinfo *card) mm_check_plugged() argument
524 return !!blk_check_plugged(mm_unplug, card, sizeof(struct blk_plug_cb)); mm_check_plugged()
529 struct cardinfo *card = q->queuedata; mm_make_request() local
534 spin_lock_irq(&card->lock); mm_make_request()
535 *card->biotail = bio; mm_make_request()
537 card->biotail = &bio->bi_next; mm_make_request()
538 if (bio->bi_rw & REQ_SYNC || !mm_check_plugged(card)) mm_make_request()
539 activate(card); mm_make_request()
540 spin_unlock_irq(&card->lock); mm_make_request()
547 struct cardinfo *card = (struct cardinfo *) __card; mm_interrupt() local
553 dma_status = le32_to_cpu(readl(card->csr_remap + DMA_STATUS_CTRL)); mm_interrupt()
561 if (card->flags & UM_FLAG_NO_BYTE_STATUS) mm_interrupt()
563 card->csr_remap + DMA_STATUS_CTRL); mm_interrupt()
566 card->csr_remap + DMA_STATUS_CTRL + 2); mm_interrupt()
574 stat = readb(card->csr_remap + MEMCTRLCMD_ERRSTATUS); mm_interrupt()
576 data_log1 = le32_to_cpu(readl(card->csr_remap + mm_interrupt()
578 data_log2 = le32_to_cpu(readl(card->csr_remap + mm_interrupt()
580 addr_log1 = le32_to_cpu(readl(card->csr_remap + mm_interrupt()
582 addr_log2 = readb(card->csr_remap + ERROR_ADDR_LOG + 4); mm_interrupt()
584 count = readb(card->csr_remap + ERROR_COUNT); mm_interrupt()
585 syndrome = readb(card->csr_remap + ERROR_SYNDROME); mm_interrupt()
586 check = readb(card->csr_remap + ERROR_CHECK); mm_interrupt()
588 dump_dmastat(card, dma_status); mm_interrupt()
591 dev_printk(KERN_ERR, &card->dev->dev, mm_interrupt()
595 dev_printk(KERN_ERR, &card->dev->dev, mm_interrupt()
598 dev_printk(KERN_ERR, &card->dev->dev, mm_interrupt()
601 dev_printk(KERN_ERR, &card->dev->dev, mm_interrupt()
605 writeb(0, card->csr_remap + ERROR_COUNT); mm_interrupt()
609 dev_printk(KERN_ERR, &card->dev->dev, mm_interrupt()
611 pci_read_config_word(card->dev, PCI_STATUS, &cfg_status); mm_interrupt()
612 pci_write_config_word(card->dev, PCI_STATUS, cfg_status); mm_interrupt()
616 dev_printk(KERN_ERR, &card->dev->dev, mm_interrupt()
618 pci_read_config_word(card->dev, PCI_STATUS, &cfg_status); mm_interrupt()
619 pci_write_config_word(card->dev, PCI_STATUS, cfg_status); mm_interrupt()
623 dev_printk(KERN_ERR, &card->dev->dev, "SYSTEM ERROR\n"); mm_interrupt()
624 pci_read_config_word(card->dev, PCI_STATUS, &cfg_status); mm_interrupt()
625 pci_write_config_word(card->dev, PCI_STATUS, cfg_status); mm_interrupt()
629 dev_printk(KERN_ERR, &card->dev->dev, "TARGET ABORT\n"); mm_interrupt()
630 pci_read_config_word(card->dev, PCI_STATUS, &cfg_status); mm_interrupt()
631 pci_write_config_word(card->dev, PCI_STATUS, cfg_status); mm_interrupt()
635 dev_printk(KERN_ERR, &card->dev->dev, "MASTER ABORT\n"); mm_interrupt()
636 pci_read_config_word(card->dev, PCI_STATUS, &cfg_status); mm_interrupt()
637 pci_write_config_word(card->dev, PCI_STATUS, cfg_status); mm_interrupt()
641 card->dma_status = dma_status; mm_interrupt()
642 tasklet_schedule(&card->tasklet); mm_interrupt()
655 static void set_fault_to_battery_status(struct cardinfo *card) set_fault_to_battery_status() argument
657 if (card->battery[0].good && card->battery[1].good) set_fault_to_battery_status()
658 set_led(card, LED_FAULT, LED_OFF); set_fault_to_battery_status()
659 else if (card->battery[0].warned || card->battery[1].warned) set_fault_to_battery_status()
660 set_led(card, LED_FAULT, LED_ON); set_fault_to_battery_status()
661 else if (!card->battery[0].good && !card->battery[1].good) set_fault_to_battery_status()
662 set_led(card, LED_FAULT, LED_FLASH_7_0); set_fault_to_battery_status()
664 set_led(card, LED_FAULT, LED_FLASH_3_5); set_fault_to_battery_status()
669 static int check_battery(struct cardinfo *card, int battery, int status) check_battery() argument
671 if (status != card->battery[battery].good) { check_battery()
672 card->battery[battery].good = !card->battery[battery].good; check_battery()
673 card->battery[battery].last_change = jiffies; check_battery()
675 if (card->battery[battery].good) { check_battery()
676 dev_printk(KERN_ERR, &card->dev->dev, check_battery()
678 card->battery[battery].warned = 0; check_battery()
680 dev_printk(KERN_ERR, &card->dev->dev, check_battery()
684 } else if (!card->battery[battery].good && check_battery()
685 !card->battery[battery].warned && check_battery()
686 time_after_eq(jiffies, card->battery[battery].last_change + check_battery()
688 dev_printk(KERN_ERR, &card->dev->dev, check_battery()
690 card->battery[battery].warned = 1; check_battery()
698 static void check_batteries(struct cardinfo *card) check_batteries() argument
700 /* NOTE: this must *never* be called while the card check_batteries()
701 * is doing (bus-to-card) DMA, or you will need the check_batteries()
707 status = readb(card->csr_remap + MEMCTRLSTATUS_BATTERY); check_batteries()
709 dev_printk(KERN_DEBUG, &card->dev->dev, check_batteries()
714 ret1 = check_battery(card, 0, !(status & BATTERY_1_FAILURE)); check_batteries()
715 ret2 = check_battery(card, 1, !(status & BATTERY_2_FAILURE)); check_batteries()
718 set_fault_to_battery_status(card); check_batteries()
727 struct cardinfo *card = &cards[i]; check_all_batteries() local
728 spin_lock_bh(&card->lock); check_all_batteries()
729 if (card->Active >= 0) check_all_batteries()
730 card->check_batteries = 1; check_all_batteries()
732 check_batteries(card); check_all_batteries()
733 spin_unlock_bh(&card->lock); check_all_batteries()
762 struct cardinfo *card = disk->private_data; mm_revalidate() local
763 set_capacity(disk, card->mm_size << 1); mm_revalidate()
769 struct cardinfo *card = bdev->bd_disk->private_data; mm_getgeo() local
770 int size = card->mm_size * (1024 / MM_HARDSECT); mm_getgeo()
792 struct cardinfo *card = &cards[num_cards]; mm_pci_probe() local
811 card->dev = dev; mm_pci_probe()
829 dev_printk(KERN_ERR, &card->dev->dev, mm_pci_probe()
834 card->csr_remap = ioremap_nocache(csr_base, csr_len); mm_pci_probe()
835 if (!card->csr_remap) { mm_pci_probe()
836 dev_printk(KERN_ERR, &card->dev->dev, mm_pci_probe()
843 dev_printk(KERN_INFO, &card->dev->dev, mm_pci_probe()
845 csr_base, card->csr_remap, csr_len); mm_pci_probe()
847 switch (card->dev->device) { mm_pci_probe()
849 card->flags |= UM_FLAG_NO_BYTE_STATUS | UM_FLAG_NO_BATTREG; mm_pci_probe()
854 card->flags |= UM_FLAG_NO_BYTE_STATUS; mm_pci_probe()
859 card->flags |= UM_FLAG_NO_BYTE_STATUS | mm_pci_probe()
869 if (readb(card->csr_remap + MEMCTRLSTATUS_MAGIC) != magic_number) { mm_pci_probe()
870 dev_printk(KERN_ERR, &card->dev->dev, "Magic number invalid\n"); mm_pci_probe()
875 card->mm_pages[0].desc = pci_alloc_consistent(card->dev, mm_pci_probe()
877 &card->mm_pages[0].page_dma); mm_pci_probe()
878 card->mm_pages[1].desc = pci_alloc_consistent(card->dev, mm_pci_probe()
880 &card->mm_pages[1].page_dma); mm_pci_probe()
881 if (card->mm_pages[0].desc == NULL || mm_pci_probe()
882 card->mm_pages[1].desc == NULL) { mm_pci_probe()
883 dev_printk(KERN_ERR, &card->dev->dev, "alloc failed\n"); mm_pci_probe()
886 reset_page(&card->mm_pages[0]); mm_pci_probe()
887 reset_page(&card->mm_pages[1]); mm_pci_probe()
888 card->Ready = 0; /* page 0 is ready */ mm_pci_probe()
889 card->Active = -1; /* no page is active */ mm_pci_probe()
890 card->bio = NULL; mm_pci_probe()
891 card->biotail = &card->bio; mm_pci_probe()
893 card->queue = blk_alloc_queue(GFP_KERNEL); mm_pci_probe()
894 if (!card->queue) mm_pci_probe()
897 blk_queue_make_request(card->queue, mm_make_request); mm_pci_probe()
898 card->queue->queue_lock = &card->lock; mm_pci_probe()
899 card->queue->queuedata = card; mm_pci_probe()
901 tasklet_init(&card->tasklet, process_page, (unsigned long)card); mm_pci_probe()
903 card->check_batteries = 0; mm_pci_probe()
905 mem_present = readb(card->csr_remap + MEMCTRLSTATUS_MEMORY); mm_pci_probe()
908 card->mm_size = 1024 * 128; mm_pci_probe()
911 card->mm_size = 1024 * 256; mm_pci_probe()
914 card->mm_size = 1024 * 512; mm_pci_probe()
917 card->mm_size = 1024 * 1024; mm_pci_probe()
920 card->mm_size = 1024 * 2048; mm_pci_probe()
923 card->mm_size = 0; mm_pci_probe()
928 set_led(card, LED_REMOVE, LED_OFF); mm_pci_probe()
929 set_led(card, LED_FAULT, LED_OFF); mm_pci_probe()
931 batt_status = readb(card->csr_remap + MEMCTRLSTATUS_BATTERY); mm_pci_probe()
933 card->battery[0].good = !(batt_status & BATTERY_1_FAILURE); mm_pci_probe()
934 card->battery[1].good = !(batt_status & BATTERY_2_FAILURE); mm_pci_probe()
935 card->battery[0].last_change = card->battery[1].last_change = jiffies; mm_pci_probe()
937 if (card->flags & UM_FLAG_NO_BATT) mm_pci_probe()
938 dev_printk(KERN_INFO, &card->dev->dev, mm_pci_probe()
939 "Size %d KB\n", card->mm_size); mm_pci_probe()
941 dev_printk(KERN_INFO, &card->dev->dev, mm_pci_probe()
943 card->mm_size, mm_pci_probe()
945 card->battery[0].good ? "OK" : "FAILURE", mm_pci_probe()
947 card->battery[1].good ? "OK" : "FAILURE"); mm_pci_probe()
949 set_fault_to_battery_status(card); mm_pci_probe()
962 card)) { mm_pci_probe()
963 dev_printk(KERN_ERR, &card->dev->dev, mm_pci_probe()
969 dev_printk(KERN_INFO, &card->dev->dev, mm_pci_probe()
972 spin_lock_init(&card->lock); mm_pci_probe()
974 pci_set_drvdata(dev, card); mm_pci_probe()
989 if (!get_userbit(card, MEMORY_INITIALIZED)) { mm_pci_probe()
990 dev_printk(KERN_INFO, &card->dev->dev, mm_pci_probe()
992 card->init_size = 0; mm_pci_probe()
994 dev_printk(KERN_INFO, &card->dev->dev, mm_pci_probe()
996 card->init_size = card->mm_size; mm_pci_probe()
1000 writeb(EDC_STORE_CORRECT, card->csr_remap + MEMCTRLCMD_ERRCTRL); mm_pci_probe()
1006 if (card->mm_pages[0].desc) mm_pci_probe()
1007 pci_free_consistent(card->dev, PAGE_SIZE*2, mm_pci_probe()
1008 card->mm_pages[0].desc, mm_pci_probe()
1009 card->mm_pages[0].page_dma); mm_pci_probe()
1010 if (card->mm_pages[1].desc) mm_pci_probe()
1011 pci_free_consistent(card->dev, PAGE_SIZE*2, mm_pci_probe()
1012 card->mm_pages[1].desc, mm_pci_probe()
1013 card->mm_pages[1].page_dma); mm_pci_probe()
1015 iounmap(card->csr_remap); mm_pci_probe()
1025 struct cardinfo *card = pci_get_drvdata(dev); mm_pci_remove() local
1027 tasklet_kill(&card->tasklet); mm_pci_remove()
1028 free_irq(dev->irq, card); mm_pci_remove()
1029 iounmap(card->csr_remap); mm_pci_remove()
1031 if (card->mm_pages[0].desc) mm_pci_remove()
1032 pci_free_consistent(card->dev, PAGE_SIZE*2, mm_pci_remove()
1033 card->mm_pages[0].desc, mm_pci_remove()
1034 card->mm_pages[0].page_dma); mm_pci_remove()
1035 if (card->mm_pages[1].desc) mm_pci_remove()
1036 pci_free_consistent(card->dev, PAGE_SIZE*2, mm_pci_remove()
1037 card->mm_pages[1].desc, mm_pci_remove()
1038 card->mm_pages[1].page_dma); mm_pci_remove()
1039 blk_cleanup_queue(card->queue); mm_pci_remove()
/linux-4.1.27/drivers/net/ethernet/toshiba/
H A Dps3_gelic_net.c62 int gelic_card_set_irq_mask(struct gelic_card *card, u64 mask) gelic_card_set_irq_mask() argument
66 status = lv1_net_set_interrupt_mask(bus_id(card), dev_id(card), gelic_card_set_irq_mask()
69 dev_info(ctodev(card), gelic_card_set_irq_mask()
74 static void gelic_card_rx_irq_on(struct gelic_card *card) gelic_card_rx_irq_on() argument
76 card->irq_mask |= GELIC_CARD_RXINT; gelic_card_rx_irq_on()
77 gelic_card_set_irq_mask(card, card->irq_mask); gelic_card_rx_irq_on()
79 static void gelic_card_rx_irq_off(struct gelic_card *card) gelic_card_rx_irq_off() argument
81 card->irq_mask &= ~GELIC_CARD_RXINT; gelic_card_rx_irq_off()
82 gelic_card_set_irq_mask(card, card->irq_mask); gelic_card_rx_irq_off()
85 static void gelic_card_get_ether_port_status(struct gelic_card *card, gelic_card_get_ether_port_status() argument
91 lv1_net_control(bus_id(card), dev_id(card), gelic_card_get_ether_port_status()
94 &card->ether_port_status, &v2); gelic_card_get_ether_port_status()
97 ether_netdev = card->netdev[GELIC_PORT_ETHERNET_0]; gelic_card_get_ether_port_status()
98 if (card->ether_port_status & GELIC_LV1_ETHER_LINK_UP) gelic_card_get_ether_port_status()
105 static int gelic_card_set_link_mode(struct gelic_card *card, int mode) gelic_card_set_link_mode() argument
110 status = lv1_net_control(bus_id(card), dev_id(card), gelic_card_set_link_mode()
119 card->link_mode = mode; gelic_card_set_link_mode()
125 * @card: card structure
130 static void gelic_card_disable_txdmac(struct gelic_card *card) gelic_card_disable_txdmac() argument
135 status = lv1_net_stop_tx_dma(bus_id(card), dev_id(card)); gelic_card_disable_txdmac()
137 dev_err(ctodev(card), gelic_card_disable_txdmac()
143 * @card: card structure
148 static void gelic_card_enable_rxdmac(struct gelic_card *card) gelic_card_enable_rxdmac() argument
153 if (gelic_descr_get_status(card->rx_chain.head) != gelic_card_enable_rxdmac()
156 be32_to_cpu(card->rx_chain.head->dmac_cmd_status)); gelic_card_enable_rxdmac()
158 be32_to_cpu(card->rx_chain.head->next_descr_addr)); gelic_card_enable_rxdmac()
160 card->rx_chain.head); gelic_card_enable_rxdmac()
163 status = lv1_net_start_rx_dma(bus_id(card), dev_id(card), gelic_card_enable_rxdmac()
164 card->rx_chain.head->bus_addr, 0); gelic_card_enable_rxdmac()
166 dev_info(ctodev(card), gelic_card_enable_rxdmac()
172 * @card: card structure
177 static void gelic_card_disable_rxdmac(struct gelic_card *card) gelic_card_disable_rxdmac() argument
182 status = lv1_net_stop_rx_dma(bus_id(card), dev_id(card)); gelic_card_disable_rxdmac()
184 dev_err(ctodev(card), gelic_card_disable_rxdmac()
213 * @card: card structure
220 static void gelic_card_reset_chain(struct gelic_card *card, gelic_card_reset_chain() argument
237 void gelic_card_up(struct gelic_card *card) gelic_card_up() argument
240 mutex_lock(&card->updown_lock); gelic_card_up()
241 if (atomic_inc_return(&card->users) == 1) { gelic_card_up()
244 gelic_card_set_irq_mask(card, card->irq_mask); gelic_card_up()
246 gelic_card_enable_rxdmac(card); gelic_card_up()
248 napi_enable(&card->napi); gelic_card_up()
250 mutex_unlock(&card->updown_lock); gelic_card_up()
254 void gelic_card_down(struct gelic_card *card) gelic_card_down() argument
258 mutex_lock(&card->updown_lock); gelic_card_down()
259 if (atomic_dec_if_positive(&card->users) == 0) { gelic_card_down()
261 napi_disable(&card->napi); gelic_card_down()
266 mask = card->irq_mask & (GELIC_CARD_WLAN_EVENT_RECEIVED | gelic_card_down()
268 gelic_card_set_irq_mask(card, mask); gelic_card_down()
270 gelic_card_disable_rxdmac(card); gelic_card_down()
271 gelic_card_reset_chain(card, &card->rx_chain, gelic_card_down()
272 card->descr + GELIC_NET_TX_DESCRIPTORS); gelic_card_down()
274 gelic_card_disable_txdmac(card); gelic_card_down()
276 mutex_unlock(&card->updown_lock); gelic_card_down()
294 * @card: card structure
297 static void gelic_card_free_chain(struct gelic_card *card, gelic_card_free_chain() argument
303 dma_unmap_single(ctodev(card), descr->bus_addr, gelic_card_free_chain()
311 * @card: card structure
321 static int gelic_card_init_chain(struct gelic_card *card, gelic_card_init_chain() argument
335 dma_map_single(ctodev(card), descr, gelic_card_init_chain()
366 dma_unmap_single(ctodev(card), descr->bus_addr, gelic_card_init_chain()
374 * @card: card structure
382 static int gelic_descr_prepare_rx(struct gelic_card *card, gelic_descr_prepare_rx() argument
389 dev_info(ctodev(card), "%s: ERROR status\n", __func__); gelic_descr_prepare_rx()
398 dev_info(ctodev(card), gelic_descr_prepare_rx()
413 descr->buf_addr = cpu_to_be32(dma_map_single(ctodev(card), gelic_descr_prepare_rx()
420 dev_info(ctodev(card), gelic_descr_prepare_rx()
432 * @card: card structure
435 static void gelic_card_release_rx_chain(struct gelic_card *card) gelic_card_release_rx_chain() argument
437 struct gelic_descr *descr = card->rx_chain.head; gelic_card_release_rx_chain()
441 dma_unmap_single(ctodev(card), gelic_card_release_rx_chain()
452 } while (descr != card->rx_chain.head); gelic_card_release_rx_chain()
457 * @card: card structure
463 static int gelic_card_fill_rx_chain(struct gelic_card *card) gelic_card_fill_rx_chain() argument
465 struct gelic_descr *descr = card->rx_chain.head; gelic_card_fill_rx_chain()
470 ret = gelic_descr_prepare_rx(card, descr); gelic_card_fill_rx_chain()
475 } while (descr != card->rx_chain.head); gelic_card_fill_rx_chain()
479 gelic_card_release_rx_chain(card); gelic_card_fill_rx_chain()
485 * @card: card structure
489 static int gelic_card_alloc_rx_skbs(struct gelic_card *card) gelic_card_alloc_rx_skbs() argument
493 chain = &card->rx_chain; gelic_card_alloc_rx_skbs()
494 ret = gelic_card_fill_rx_chain(card); gelic_card_alloc_rx_skbs()
495 chain->tail = card->rx_top->prev; /* point to the last */ gelic_card_alloc_rx_skbs()
501 * @card: card structure
506 static void gelic_descr_release_tx(struct gelic_card *card, gelic_descr_release_tx() argument
513 dma_unmap_single(ctodev(card), be32_to_cpu(descr->buf_addr), skb->len, gelic_descr_release_tx()
530 static void gelic_card_stop_queues(struct gelic_card *card) gelic_card_stop_queues() argument
532 netif_stop_queue(card->netdev[GELIC_PORT_ETHERNET_0]); gelic_card_stop_queues()
534 if (card->netdev[GELIC_PORT_WIRELESS]) gelic_card_stop_queues()
535 netif_stop_queue(card->netdev[GELIC_PORT_WIRELESS]); gelic_card_stop_queues()
537 static void gelic_card_wake_queues(struct gelic_card *card) gelic_card_wake_queues() argument
539 netif_wake_queue(card->netdev[GELIC_PORT_ETHERNET_0]); gelic_card_wake_queues()
541 if (card->netdev[GELIC_PORT_WIRELESS]) gelic_card_wake_queues()
542 netif_wake_queue(card->netdev[GELIC_PORT_WIRELESS]); gelic_card_wake_queues()
546 * @card: adapter structure
551 static void gelic_card_release_tx_chain(struct gelic_card *card, int stop) gelic_card_release_tx_chain() argument
558 for (tx_chain = &card->tx_chain; gelic_card_release_tx_chain()
568 dev_info(ctodev(card), gelic_card_release_tx_chain()
590 gelic_descr_release_tx(card, tx_chain->tail); gelic_card_release_tx_chain()
595 gelic_card_wake_queues(card); gelic_card_release_tx_chain()
608 struct gelic_card *card = netdev_card(netdev); gelic_net_set_multi() local
616 status = lv1_net_remove_multicast_address(bus_id(card), dev_id(card), gelic_net_set_multi()
619 dev_err(ctodev(card), gelic_net_set_multi()
623 status = lv1_net_add_multicast_address(bus_id(card), dev_id(card), gelic_net_set_multi()
626 dev_err(ctodev(card), gelic_net_set_multi()
632 status = lv1_net_add_multicast_address(bus_id(card), gelic_net_set_multi()
633 dev_id(card), gelic_net_set_multi()
636 dev_err(ctodev(card), gelic_net_set_multi()
650 status = lv1_net_add_multicast_address(bus_id(card), netdev_for_each_mc_addr()
651 dev_id(card), netdev_for_each_mc_addr()
654 dev_err(ctodev(card), netdev_for_each_mc_addr()
668 struct gelic_card *card; gelic_net_stop() local
675 card = netdev_card(netdev); gelic_net_stop()
676 gelic_card_down(card); gelic_net_stop()
684 * @card: device structure to get descriptor from
689 gelic_card_get_next_tx_descr(struct gelic_card *card) gelic_card_get_next_tx_descr() argument
691 if (!card->tx_chain.head) gelic_card_get_next_tx_descr()
694 if (card->tx_chain.tail != card->tx_chain.head->next && gelic_card_get_next_tx_descr()
695 gelic_descr_get_status(card->tx_chain.head) == gelic_card_get_next_tx_descr()
697 return card->tx_chain.head; gelic_card_get_next_tx_descr()
770 * @card: card structure
777 static int gelic_descr_prepare_tx(struct gelic_card *card, gelic_descr_prepare_tx() argument
783 if (card->vlan_required) { gelic_descr_prepare_tx()
789 card->vlan[type].tx); gelic_descr_prepare_tx()
795 buf = dma_map_single(ctodev(card), skb->data, skb->len, DMA_TO_DEVICE); gelic_descr_prepare_tx()
798 dev_err(ctodev(card), gelic_descr_prepare_tx()
812 card->tx_chain.head = descr->next; gelic_descr_prepare_tx()
818 * @card: card structure
822 static int gelic_card_kick_txdma(struct gelic_card *card, gelic_card_kick_txdma() argument
827 if (card->tx_dma_progress) gelic_card_kick_txdma()
831 card->tx_dma_progress = 1; gelic_card_kick_txdma()
832 status = lv1_net_start_tx_dma(bus_id(card), dev_id(card), gelic_card_kick_txdma()
835 card->tx_dma_progress = 0; gelic_card_kick_txdma()
836 dev_info(ctodev(card), "lv1_net_start_txdma failed," \ gelic_card_kick_txdma()
852 struct gelic_card *card = netdev_card(netdev); gelic_net_xmit() local
857 spin_lock_irqsave(&card->tx_lock, flags); gelic_net_xmit()
859 gelic_card_release_tx_chain(card, 0); gelic_net_xmit()
861 descr = gelic_card_get_next_tx_descr(card); gelic_net_xmit()
866 gelic_card_stop_queues(card); gelic_net_xmit()
867 spin_unlock_irqrestore(&card->tx_lock, flags); gelic_net_xmit()
871 result = gelic_descr_prepare_tx(card, descr, skb); gelic_net_xmit()
879 spin_unlock_irqrestore(&card->tx_lock, flags); gelic_net_xmit()
892 if (gelic_card_kick_txdma(card, descr)) { gelic_net_xmit()
900 gelic_descr_release_tx(card, descr); gelic_net_xmit()
902 card->tx_chain.head = descr; gelic_net_xmit()
905 dev_info(ctodev(card), "%s: kick failure\n", __func__); gelic_net_xmit()
908 spin_unlock_irqrestore(&card->tx_lock, flags); gelic_net_xmit()
915 * @card: card structure
922 struct gelic_card *card, gelic_net_pass_skb_up()
932 dma_unmap_single(ctodev(card), be32_to_cpu(descr->buf_addr), gelic_net_pass_skb_up()
940 dev_info(ctodev(card), "buffer full %x %x %x\n", gelic_net_pass_skb_up()
947 * the card put 2 bytes vlan tag in front gelic_net_pass_skb_up()
973 * @card: card structure
980 static int gelic_card_decode_one_descr(struct gelic_card *card) gelic_card_decode_one_descr() argument
983 struct gelic_descr_chain *chain = &card->rx_chain; gelic_card_decode_one_descr()
994 dev_dbg(ctodev(card), "dormant descr? %p\n", descr); gelic_card_decode_one_descr()
999 if (card->vlan_required) { gelic_card_decode_one_descr()
1004 if (card->vlan[i].rx == vid) { gelic_card_decode_one_descr()
1005 netdev = card->netdev[i]; gelic_card_decode_one_descr()
1014 netdev = card->netdev[GELIC_PORT_ETHERNET_0]; gelic_card_decode_one_descr()
1019 dev_info(ctodev(card), "dropping RX descriptor with state %x\n", gelic_card_decode_one_descr()
1035 dev_info(ctodev(card), "overlength frame\n"); gelic_card_decode_one_descr()
1043 dev_dbg(ctodev(card), "RX descriptor with state %x\n", gelic_card_decode_one_descr()
1049 gelic_net_pass_skb_up(descr, card, netdev); gelic_card_decode_one_descr()
1070 gelic_descr_prepare_rx(card, descr); gelic_card_decode_one_descr()
1086 gelic_card_enable_rxdmac(card); gelic_card_decode_one_descr()
1101 struct gelic_card *card = container_of(napi, struct gelic_card, napi); gelic_net_poll() local
1105 if (!gelic_card_decode_one_descr(card)) gelic_net_poll()
1113 gelic_card_rx_irq_on(card); gelic_net_poll()
1142 struct gelic_card *card = ptr; gelic_card_interrupt() local
1145 status = card->irq_status; gelic_card_interrupt()
1150 status &= card->irq_mask; gelic_card_interrupt()
1153 gelic_card_rx_irq_off(card); gelic_card_interrupt()
1154 napi_schedule(&card->napi); gelic_card_interrupt()
1158 spin_lock_irqsave(&card->tx_lock, flags); gelic_card_interrupt()
1159 card->tx_dma_progress = 0; gelic_card_interrupt()
1160 gelic_card_release_tx_chain(card, 0); gelic_card_interrupt()
1162 gelic_card_kick_txdma(card, card->tx_chain.tail); gelic_card_interrupt()
1163 spin_unlock_irqrestore(&card->tx_lock, flags); gelic_card_interrupt()
1168 gelic_card_get_ether_port_status(card, 1); gelic_card_interrupt()
1173 gelic_wl_interrupt(card->netdev[GELIC_PORT_WIRELESS], status); gelic_card_interrupt()
1188 struct gelic_card *card = netdev_card(netdev); gelic_net_poll_controller() local
1190 gelic_card_set_irq_mask(card, 0); gelic_net_poll_controller()
1192 gelic_card_set_irq_mask(card, card->irq_mask); gelic_net_poll_controller()
1207 struct gelic_card *card = netdev_card(netdev); gelic_net_open() local
1209 dev_dbg(ctodev(card), " -> %s %p\n", __func__, netdev); gelic_net_open()
1211 gelic_card_up(card); gelic_net_open()
1214 gelic_card_get_ether_port_status(card, 1); gelic_net_open()
1216 dev_dbg(ctodev(card), " <- %s\n", __func__); gelic_net_open()
1230 struct gelic_card *card = netdev_card(netdev); gelic_ether_get_settings() local
1232 gelic_card_get_ether_port_status(card, 0); gelic_ether_get_settings()
1234 if (card->ether_port_status & GELIC_LV1_ETHER_FULL_DUPLEX) gelic_ether_get_settings()
1239 switch (card->ether_port_status & GELIC_LV1_ETHER_SPEED_MASK) { gelic_ether_get_settings()
1260 if (card->link_mode & GELIC_LV1_ETHER_AUTO_NEG) { gelic_ether_get_settings()
1274 struct gelic_card *card = netdev_card(netdev); gelic_ether_set_settings() local
1302 ret = gelic_card_set_link_mode(card, mode); gelic_ether_set_settings()
1325 struct gelic_card *card; gelic_net_set_wol() local
1335 card = netdev_card(netdev); gelic_net_set_wol()
1337 status = lv1_net_control(bus_id(card), dev_id(card), gelic_net_set_wol()
1348 status = lv1_net_control(bus_id(card), dev_id(card), gelic_net_set_wol()
1361 status = lv1_net_control(bus_id(card), dev_id(card), gelic_net_set_wol()
1372 status = lv1_net_control(bus_id(card), dev_id(card), gelic_net_set_wol()
1407 struct gelic_card *card = gelic_net_tx_timeout_task() local
1409 struct net_device *netdev = card->netdev[GELIC_PORT_ETHERNET_0]; gelic_net_tx_timeout_task()
1411 dev_info(ctodev(card), "%s:Timed out. Restarting...\n", __func__); gelic_net_tx_timeout_task()
1423 atomic_dec(&card->tx_timeout_task_counter); gelic_net_tx_timeout_task()
1434 struct gelic_card *card; gelic_net_tx_timeout() local
1436 card = netdev_card(netdev); gelic_net_tx_timeout()
1437 atomic_inc(&card->tx_timeout_task_counter); gelic_net_tx_timeout()
1439 schedule_work(&card->tx_timeout_task); gelic_net_tx_timeout()
1441 atomic_dec(&card->tx_timeout_task_counter); gelic_net_tx_timeout()
1477 * @card: card structure
1484 int gelic_net_setup_netdev(struct net_device *netdev, struct gelic_card *card) gelic_net_setup_netdev() argument
1495 status = lv1_net_control(bus_id(card), dev_id(card), gelic_net_setup_netdev()
1500 dev_info(ctodev(card), gelic_net_setup_netdev()
1507 if (card->vlan_required) { gelic_net_setup_netdev()
1518 dev_err(ctodev(card), "%s:Couldn't register %s %d\n", gelic_net_setup_netdev()
1522 dev_info(ctodev(card), "%s: MAC addr %pM\n", gelic_net_setup_netdev()
1529 * gelic_alloc_card_net - allocates net_device and card structure
1531 * returns the card structure or NULL in case of errors
1533 * the card and net_device structures are linked to each other
1538 struct gelic_card *card; gelic_alloc_card_net() local
1557 card = PTR_ALIGN(p, GELIC_ALIGN); gelic_alloc_card_net()
1558 card->unalign = p; gelic_alloc_card_net()
1565 kfree(card->unalign); gelic_alloc_card_net()
1572 port->card = card; gelic_alloc_card_net()
1576 card->netdev[GELIC_PORT_ETHERNET_0] = *netdev; gelic_alloc_card_net()
1578 INIT_WORK(&card->tx_timeout_task, gelic_net_tx_timeout_task); gelic_alloc_card_net()
1579 init_waitqueue_head(&card->waitq); gelic_alloc_card_net()
1580 atomic_set(&card->tx_timeout_task_counter, 0); gelic_alloc_card_net()
1581 mutex_init(&card->updown_lock); gelic_alloc_card_net()
1582 atomic_set(&card->users, 0); gelic_alloc_card_net()
1584 return card; gelic_alloc_card_net()
1587 static void gelic_card_get_vlan_info(struct gelic_card *card) gelic_card_get_vlan_info() argument
1608 status = lv1_net_control(bus_id(card), dev_id(card), gelic_card_get_vlan_info()
1614 dev_dbg(ctodev(card), gelic_card_get_vlan_info()
1617 card->vlan[i].tx = 0; gelic_card_get_vlan_info()
1618 card->vlan[i].rx = 0; gelic_card_get_vlan_info()
1621 card->vlan[i].tx = (u16)v1; gelic_card_get_vlan_info()
1624 status = lv1_net_control(bus_id(card), dev_id(card), gelic_card_get_vlan_info()
1630 dev_info(ctodev(card), gelic_card_get_vlan_info()
1633 card->vlan[i].tx = 0; gelic_card_get_vlan_info()
1634 card->vlan[i].rx = 0; gelic_card_get_vlan_info()
1637 card->vlan[i].rx = (u16)v1; gelic_card_get_vlan_info()
1639 dev_dbg(ctodev(card), "vlan_id[%d] tx=%02x rx=%02x\n", gelic_card_get_vlan_info()
1640 i, card->vlan[i].tx, card->vlan[i].rx); gelic_card_get_vlan_info()
1643 if (card->vlan[GELIC_PORT_ETHERNET_0].tx) { gelic_card_get_vlan_info()
1644 BUG_ON(!card->vlan[GELIC_PORT_WIRELESS].tx); gelic_card_get_vlan_info()
1645 card->vlan_required = 1; gelic_card_get_vlan_info()
1647 card->vlan_required = 0; gelic_card_get_vlan_info()
1651 card->vlan[GELIC_PORT_WIRELESS].tx = 0; gelic_card_get_vlan_info()
1652 card->vlan[GELIC_PORT_WIRELESS].rx = 0; gelic_card_get_vlan_info()
1655 dev_info(ctodev(card), "internal vlan %s\n", gelic_card_get_vlan_info()
1656 card->vlan_required? "enabled" : "disabled"); gelic_card_get_vlan_info()
1663 struct gelic_card *card; ps3_gelic_driver_probe() local
1688 /* alloc card/netdevice */ ps3_gelic_driver_probe()
1689 card = gelic_alloc_card_net(&netdev); ps3_gelic_driver_probe()
1690 if (!card) { ps3_gelic_driver_probe()
1696 ps3_system_bus_set_drvdata(dev, card); ps3_gelic_driver_probe()
1697 card->dev = dev; ps3_gelic_driver_probe()
1700 gelic_card_get_vlan_info(card); ps3_gelic_driver_probe()
1702 card->link_mode = GELIC_LV1_ETHER_AUTO_NEG; ps3_gelic_driver_probe()
1705 result = lv1_net_set_interrupt_status_indicator(bus_id(card), ps3_gelic_driver_probe()
1706 dev_id(card), ps3_gelic_driver_probe()
1707 ps3_mm_phys_to_lpar(__pa(&card->irq_status)), ps3_gelic_driver_probe()
1719 &card->irq); ps3_gelic_driver_probe()
1722 dev_info(ctodev(card), ps3_gelic_driver_probe()
1728 result = request_irq(card->irq, gelic_card_interrupt, ps3_gelic_driver_probe()
1729 0, netdev->name, card); ps3_gelic_driver_probe()
1732 dev_info(ctodev(card), "%s:request_irq failed (%d)\n", ps3_gelic_driver_probe()
1737 /* setup card structure */ ps3_gelic_driver_probe()
1738 card->irq_mask = GELIC_CARD_RXINT | GELIC_CARD_TXINT | ps3_gelic_driver_probe()
1742 result = gelic_card_init_chain(card, &card->tx_chain, ps3_gelic_driver_probe()
1743 card->descr, GELIC_NET_TX_DESCRIPTORS); ps3_gelic_driver_probe()
1746 result = gelic_card_init_chain(card, &card->rx_chain, ps3_gelic_driver_probe()
1747 card->descr + GELIC_NET_TX_DESCRIPTORS, ps3_gelic_driver_probe()
1753 card->tx_top = card->tx_chain.head; ps3_gelic_driver_probe()
1754 card->rx_top = card->rx_chain.head; ps3_gelic_driver_probe()
1755 dev_dbg(ctodev(card), "descr rx %p, tx %p, size %#lx, num %#x\n", ps3_gelic_driver_probe()
1756 card->rx_top, card->tx_top, sizeof(struct gelic_descr), ps3_gelic_driver_probe()
1759 result = gelic_card_alloc_rx_skbs(card); ps3_gelic_driver_probe()
1763 spin_lock_init(&card->tx_lock); ps3_gelic_driver_probe()
1764 card->tx_dma_progress = 0; ps3_gelic_driver_probe()
1767 netdev->irq = card->irq; ps3_gelic_driver_probe()
1768 SET_NETDEV_DEV(netdev, &card->dev->core); ps3_gelic_driver_probe()
1769 gelic_ether_setup_netdev_ops(netdev, &card->napi); ps3_gelic_driver_probe()
1770 result = gelic_net_setup_netdev(netdev, card); ps3_gelic_driver_probe()
1778 result = gelic_wl_driver_probe(card); ps3_gelic_driver_probe()
1789 gelic_card_free_chain(card, card->rx_chain.head); ps3_gelic_driver_probe()
1791 gelic_card_free_chain(card, card->tx_chain.head); ps3_gelic_driver_probe()
1793 free_irq(card->irq, card); ps3_gelic_driver_probe()
1796 ps3_sb_event_receive_port_destroy(dev, card->irq); ps3_gelic_driver_probe()
1798 lv1_net_set_interrupt_status_indicator(bus_id(card), ps3_gelic_driver_probe()
1799 bus_id(card), ps3_gelic_driver_probe()
1819 struct gelic_card *card = ps3_system_bus_get_drvdata(dev); ps3_gelic_driver_remove() local
1824 gelic_card_set_link_mode(card, GELIC_LV1_ETHER_AUTO_NEG); ps3_gelic_driver_remove()
1827 gelic_wl_driver_remove(card); ps3_gelic_driver_remove()
1830 gelic_card_set_irq_mask(card, 0); ps3_gelic_driver_remove()
1833 gelic_card_disable_rxdmac(card); ps3_gelic_driver_remove()
1834 gelic_card_disable_txdmac(card); ps3_gelic_driver_remove()
1837 gelic_card_release_tx_chain(card, 1); ps3_gelic_driver_remove()
1838 gelic_card_release_rx_chain(card); ps3_gelic_driver_remove()
1840 gelic_card_free_chain(card, card->tx_top); ps3_gelic_driver_remove()
1841 gelic_card_free_chain(card, card->rx_top); ps3_gelic_driver_remove()
1843 netdev0 = card->netdev[GELIC_PORT_ETHERNET_0]; ps3_gelic_driver_remove()
1845 free_irq(card->irq, card); ps3_gelic_driver_remove()
1847 ps3_sb_event_receive_port_destroy(card->dev, card->irq); ps3_gelic_driver_remove()
1849 wait_event(card->waitq, ps3_gelic_driver_remove()
1850 atomic_read(&card->tx_timeout_task_counter) == 0); ps3_gelic_driver_remove()
1852 lv1_net_set_interrupt_status_indicator(bus_id(card), dev_id(card), ps3_gelic_driver_remove()
921 gelic_net_pass_skb_up(struct gelic_descr *descr, struct gelic_card *card, struct net_device *netdev) gelic_net_pass_skb_up() argument
H A Dspider_net.c85 * spider_net_read_reg - reads an SMMIO register of a card
86 * @card: device structure
92 spider_net_read_reg(struct spider_net_card *card, u32 reg) spider_net_read_reg() argument
98 return in_be32(card->regs + reg); spider_net_read_reg()
102 * spider_net_write_reg - writes to an SMMIO register of a card
103 * @card: device structure
108 spider_net_write_reg(struct spider_net_card *card, u32 reg, u32 value) spider_net_write_reg() argument
114 out_be32(card->regs + reg, value); spider_net_write_reg()
132 struct spider_net_card *card = netdev_priv(netdev); spider_net_write_phy() local
138 spider_net_write_reg(card, SPIDER_NET_GPCWOPCMD, writevalue); spider_net_write_phy()
155 struct spider_net_card *card = netdev_priv(netdev); spider_net_read_phy() local
159 spider_net_write_reg(card, SPIDER_NET_GPCROPCMD, readvalue); spider_net_read_phy()
165 readvalue = spider_net_read_reg(card, SPIDER_NET_GPCROPCMD); spider_net_read_phy()
175 * @card: device structure
178 spider_net_setup_aneg(struct spider_net_card *card) spider_net_setup_aneg() argument
180 struct mii_phy *phy = &card->phy; spider_net_setup_aneg()
184 bmsr = spider_net_read_phy(card->netdev, phy->mii_id, MII_BMSR); spider_net_setup_aneg()
185 estat = spider_net_read_phy(card->netdev, phy->mii_id, MII_ESTATUS); spider_net_setup_aneg()
207 * spider_net_rx_irq_off - switch off rx irq on this spider card
208 * @card: device structure
213 spider_net_rx_irq_off(struct spider_net_card *card) spider_net_rx_irq_off() argument
218 spider_net_write_reg(card, SPIDER_NET_GHIINT0MSK, regvalue); spider_net_rx_irq_off()
222 * spider_net_rx_irq_on - switch on rx irq on this spider card
223 * @card: device structure
228 spider_net_rx_irq_on(struct spider_net_card *card) spider_net_rx_irq_on() argument
233 spider_net_write_reg(card, SPIDER_NET_GHIINT0MSK, regvalue); spider_net_rx_irq_on()
238 * @card: card structure
244 spider_net_set_promisc(struct spider_net_card *card) spider_net_set_promisc() argument
247 struct net_device *netdev = card->netdev; spider_net_set_promisc()
251 spider_net_write_reg(card, SPIDER_NET_GMRUAFILnR, 0); spider_net_set_promisc()
252 spider_net_write_reg(card, SPIDER_NET_GMRUAFILnR + 0x04, 0); spider_net_set_promisc()
253 spider_net_write_reg(card, SPIDER_NET_GMRUA0FIL15R, spider_net_set_promisc()
262 spider_net_write_reg(card, SPIDER_NET_GMRUAFILnR, macu); spider_net_set_promisc()
263 spider_net_write_reg(card, SPIDER_NET_GMRUAFILnR + 0x04, macl); spider_net_set_promisc()
264 spider_net_write_reg(card, SPIDER_NET_GMRUA0FIL15R, spider_net_set_promisc()
283 * @card: card structure
288 spider_net_free_chain(struct spider_net_card *card, spider_net_free_chain() argument
300 dma_free_coherent(&card->pdev->dev, chain->num_desc, spider_net_free_chain()
306 * @card: card structure
315 spider_net_init_chain(struct spider_net_card *card, spider_net_init_chain() argument
326 chain->hwring = dma_alloc_coherent(&card->pdev->dev, alloc_size, spider_net_init_chain()
360 * @card: card structure
365 spider_net_free_rx_chain_contents(struct spider_net_card *card) spider_net_free_rx_chain_contents() argument
369 descr = card->rx_chain.head; spider_net_free_rx_chain_contents()
372 pci_unmap_single(card->pdev, descr->hwdescr->buf_addr, spider_net_free_rx_chain_contents()
379 } while (descr != card->rx_chain.head); spider_net_free_rx_chain_contents()
384 * @card: card structure
393 spider_net_prepare_rx_descr(struct spider_net_card *card, spider_net_prepare_rx_descr() argument
408 descr->skb = netdev_alloc_skb(card->netdev, spider_net_prepare_rx_descr()
411 if (netif_msg_rx_err(card) && net_ratelimit()) spider_net_prepare_rx_descr()
412 dev_err(&card->netdev->dev, spider_net_prepare_rx_descr()
414 card->spider_stats.alloc_rx_skb_error++; spider_net_prepare_rx_descr()
428 buf = pci_map_single(card->pdev, descr->skb->data, spider_net_prepare_rx_descr()
430 if (pci_dma_mapping_error(card->pdev, buf)) { spider_net_prepare_rx_descr()
433 if (netif_msg_rx_err(card) && net_ratelimit()) spider_net_prepare_rx_descr()
434 dev_err(&card->netdev->dev, "Could not iommu-map rx buffer\n"); spider_net_prepare_rx_descr()
435 card->spider_stats.rx_iommu_map_error++; spider_net_prepare_rx_descr()
449 * @card: card structure
456 spider_net_enable_rxchtails(struct spider_net_card *card) spider_net_enable_rxchtails() argument
459 spider_net_write_reg(card, SPIDER_NET_GDADCHA , spider_net_enable_rxchtails()
460 card->rx_chain.tail->bus_addr); spider_net_enable_rxchtails()
465 * @card: card structure
471 spider_net_enable_rxdmac(struct spider_net_card *card) spider_net_enable_rxdmac() argument
474 spider_net_write_reg(card, SPIDER_NET_GDADMACCNTR, spider_net_enable_rxdmac()
480 * @card: card structure
486 spider_net_disable_rxdmac(struct spider_net_card *card) spider_net_disable_rxdmac() argument
488 spider_net_write_reg(card, SPIDER_NET_GDADMACCNTR, spider_net_disable_rxdmac()
494 * @card: card structure
499 spider_net_refill_rx_chain(struct spider_net_card *card) spider_net_refill_rx_chain() argument
501 struct spider_net_descr_chain *chain = &card->rx_chain; spider_net_refill_rx_chain()
513 if (spider_net_prepare_rx_descr(card, chain->head)) spider_net_refill_rx_chain()
523 * @card: card structure
528 spider_net_alloc_rx_skbs(struct spider_net_card *card) spider_net_alloc_rx_skbs() argument
530 struct spider_net_descr_chain *chain = &card->rx_chain; spider_net_alloc_rx_skbs()
543 if (spider_net_prepare_rx_descr(card, chain->head)) spider_net_alloc_rx_skbs()
550 spider_net_refill_rx_chain(card); spider_net_alloc_rx_skbs()
551 spider_net_enable_rxdmac(card); spider_net_alloc_rx_skbs()
555 spider_net_free_rx_chain_contents(card); spider_net_alloc_rx_skbs()
606 struct spider_net_card *card = netdev_priv(netdev); spider_net_set_multi() local
610 spider_net_set_promisc(card); spider_net_set_multi()
643 spider_net_write_reg(card, SPIDER_NET_GMRMHFILnR + i * 4, reg);
649 * @card: card structure
658 spider_net_prepare_tx_descr(struct spider_net_card *card, spider_net_prepare_tx_descr() argument
661 struct spider_net_descr_chain *chain = &card->tx_chain; spider_net_prepare_tx_descr()
667 buf = pci_map_single(card->pdev, skb->data, skb->len, PCI_DMA_TODEVICE); spider_net_prepare_tx_descr()
668 if (pci_dma_mapping_error(card->pdev, buf)) { spider_net_prepare_tx_descr()
669 if (netif_msg_tx_err(card) && net_ratelimit()) spider_net_prepare_tx_descr()
670 dev_err(&card->netdev->dev, "could not iommu-map packet (%p, %i). " spider_net_prepare_tx_descr()
672 card->spider_stats.tx_iommu_map_error++; spider_net_prepare_tx_descr()
677 descr = card->tx_chain.head; spider_net_prepare_tx_descr()
680 pci_unmap_single(card->pdev, buf, skb->len, PCI_DMA_TODEVICE); spider_net_prepare_tx_descr()
710 card->netdev->trans_start = jiffies; /* set netdev watchdog timer */ spider_net_prepare_tx_descr()
715 spider_net_set_low_watermark(struct spider_net_card *card) spider_net_set_low_watermark() argument
717 struct spider_net_descr *descr = card->tx_chain.tail; spider_net_set_low_watermark()
726 while (descr != card->tx_chain.head) { spider_net_set_low_watermark()
735 if (cnt < card->tx_chain.num_desc/4) spider_net_set_low_watermark()
739 descr = card->tx_chain.tail; spider_net_set_low_watermark()
745 spin_lock_irqsave(&card->tx_chain.lock, flags); spider_net_set_low_watermark()
747 if (card->low_watermark && card->low_watermark != descr) { spider_net_set_low_watermark()
748 hwdescr = card->low_watermark->hwdescr; spider_net_set_low_watermark()
752 card->low_watermark = descr; spider_net_set_low_watermark()
753 spin_unlock_irqrestore(&card->tx_chain.lock, flags); spider_net_set_low_watermark()
759 * @card: adapter structure
770 spider_net_release_tx_chain(struct spider_net_card *card, int brutal) spider_net_release_tx_chain() argument
772 struct net_device *dev = card->netdev; spider_net_release_tx_chain()
773 struct spider_net_descr_chain *chain = &card->tx_chain; spider_net_release_tx_chain()
810 if (netif_msg_tx_err(card)) spider_net_release_tx_chain()
811 dev_err(&card->netdev->dev, "forcing end of tx descriptor " spider_net_release_tx_chain()
833 pci_unmap_single(card->pdev, buf_addr, skb->len, spider_net_release_tx_chain()
843 * @card: card structure
853 spider_net_kick_tx_dma(struct spider_net_card *card) spider_net_kick_tx_dma() argument
857 if (spider_net_read_reg(card, SPIDER_NET_GDTDMACCNTR) & spider_net_kick_tx_dma()
861 descr = card->tx_chain.tail; spider_net_kick_tx_dma()
865 spider_net_write_reg(card, SPIDER_NET_GDTDCHA, spider_net_kick_tx_dma()
867 spider_net_write_reg(card, SPIDER_NET_GDTDMACCNTR, spider_net_kick_tx_dma()
871 if (descr == card->tx_chain.head) spider_net_kick_tx_dma()
877 mod_timer(&card->tx_timer, jiffies + SPIDER_NET_TX_TIMER); spider_net_kick_tx_dma()
891 struct spider_net_card *card = netdev_priv(netdev); spider_net_xmit() local
893 spider_net_release_tx_chain(card, 0); spider_net_xmit()
895 if (spider_net_prepare_tx_descr(card, skb) != 0) { spider_net_xmit()
901 cnt = spider_net_set_low_watermark(card); spider_net_xmit()
903 spider_net_kick_tx_dma(card); spider_net_xmit()
909 * @card: card structure
917 spider_net_cleanup_tx_ring(struct spider_net_card *card) spider_net_cleanup_tx_ring() argument
919 if ((spider_net_release_tx_chain(card, 0) != 0) && spider_net_cleanup_tx_ring()
920 (card->netdev->flags & IFF_UP)) { spider_net_cleanup_tx_ring()
921 spider_net_kick_tx_dma(card); spider_net_cleanup_tx_ring()
922 netif_wake_queue(card->netdev); spider_net_cleanup_tx_ring()
947 * @card: card structure
954 struct spider_net_card *card) spider_net_pass_skb_up()
958 struct net_device *netdev = card->netdev; spider_net_pass_skb_up()
964 /* the card seems to add 2 bytes of junk in front spider_net_pass_skb_up()
991 static void show_rx_chain(struct spider_net_card *card) show_rx_chain() argument
993 struct spider_net_descr_chain *chain = &card->rx_chain; show_rx_chain()
997 struct device *dev = &card->netdev->dev; show_rx_chain()
1011 curr_desc = spider_net_read_reg(card, SPIDER_NET_GDACTDPA); show_rx_chain()
1012 next_desc = spider_net_read_reg(card, SPIDER_NET_GDACNEXTDA); show_rx_chain()
1088 static void spider_net_resync_head_ptr(struct spider_net_card *card) spider_net_resync_head_ptr() argument
1091 struct spider_net_descr_chain *chain = &card->rx_chain; spider_net_resync_head_ptr()
1116 static int spider_net_resync_tail_ptr(struct spider_net_card *card) spider_net_resync_tail_ptr() argument
1118 struct spider_net_descr_chain *chain = &card->rx_chain; spider_net_resync_tail_ptr()
1141 * @card: card structure
1151 spider_net_decode_one_descr(struct spider_net_card *card) spider_net_decode_one_descr() argument
1153 struct net_device *dev = card->netdev; spider_net_decode_one_descr()
1154 struct spider_net_descr_chain *chain = &card->rx_chain; spider_net_decode_one_descr()
1173 pci_unmap_single(card->pdev, hw_buf_addr, spider_net_decode_one_descr()
1179 if (netif_msg_rx_err(card)) spider_net_decode_one_descr()
1188 if (netif_msg_rx_err(card)) spider_net_decode_one_descr()
1189 dev_err(&card->netdev->dev, spider_net_decode_one_descr()
1191 card->spider_stats.rx_desc_unk_state++; spider_net_decode_one_descr()
1197 if (netif_msg_rx_err(card)) spider_net_decode_one_descr()
1198 dev_err(&card->netdev->dev, spider_net_decode_one_descr()
1206 dev_err(&card->netdev->dev, "bad status, cmd_status=x%08x\n", spider_net_decode_one_descr()
1215 pr_err("which=%ld\n", descr - card->rx_chain.ring); spider_net_decode_one_descr()
1217 card->spider_stats.rx_desc_error++; spider_net_decode_one_descr()
1222 spider_net_pass_skb_up(descr, card); spider_net_decode_one_descr()
1228 if (netif_msg_rx_err(card)) spider_net_decode_one_descr()
1229 show_rx_chain(card); spider_net_decode_one_descr()
1250 struct spider_net_card *card = container_of(napi, struct spider_net_card, napi); spider_net_poll() local
1254 if (!spider_net_decode_one_descr(card)) spider_net_poll()
1260 if ((packets_done == 0) && (card->num_rx_ints != 0)) { spider_net_poll()
1261 if (!spider_net_resync_tail_ptr(card)) spider_net_poll()
1263 spider_net_resync_head_ptr(card); spider_net_poll()
1265 card->num_rx_ints = 0; spider_net_poll()
1267 spider_net_refill_rx_chain(card); spider_net_poll()
1268 spider_net_enable_rxdmac(card); spider_net_poll()
1270 spider_net_cleanup_tx_ring(card); spider_net_poll()
1276 spider_net_rx_irq_on(card); spider_net_poll()
1277 card->ignore_rx_ramfull = 0; spider_net_poll()
1313 struct spider_net_card *card = netdev_priv(netdev); spider_net_set_mac() local
1323 regvalue = spider_net_read_reg(card, SPIDER_NET_GMACOPEMD); spider_net_set_mac()
1325 spider_net_write_reg(card, SPIDER_NET_GMACOPEMD, regvalue); spider_net_set_mac()
1331 spider_net_write_reg(card, SPIDER_NET_GMACUNIMACU, macu); spider_net_set_mac()
1332 spider_net_write_reg(card, SPIDER_NET_GMACUNIMACL, macl); spider_net_set_mac()
1335 regvalue = spider_net_read_reg(card, SPIDER_NET_GMACOPEMD); spider_net_set_mac()
1337 spider_net_write_reg(card, SPIDER_NET_GMACOPEMD, regvalue); spider_net_set_mac()
1339 spider_net_set_promisc(card); spider_net_set_mac()
1356 struct spider_net_card *card = netdev_priv(netdev); spider_net_link_reset() local
1358 del_timer_sync(&card->aneg_timer); spider_net_link_reset()
1361 spider_net_write_reg(card, SPIDER_NET_GMACST, spider_net_link_reset()
1362 spider_net_read_reg(card, SPIDER_NET_GMACST)); spider_net_link_reset()
1363 spider_net_write_reg(card, SPIDER_NET_GMACINTEN, 0); spider_net_link_reset()
1366 card->aneg_count = 0; spider_net_link_reset()
1367 card->medium = BCM54XX_COPPER; spider_net_link_reset()
1368 spider_net_setup_aneg(card); spider_net_link_reset()
1369 mod_timer(&card->aneg_timer, jiffies + SPIDER_NET_ANEG_TIMER); spider_net_link_reset()
1375 * @card: card structure
1382 spider_net_handle_error_irq(struct spider_net_card *card, u32 status_reg, spider_net_handle_error_irq() argument
1420 if (netif_msg_intr(card)) spider_net_handle_error_irq()
1421 dev_err(&card->netdev->dev, "PHY write queue full\n"); spider_net_handle_error_irq()
1465 if (card->tx_chain.tail != card->tx_chain.head) spider_net_handle_error_irq()
1466 spider_net_kick_tx_dma(card); spider_net_handle_error_irq()
1492 if (card->ignore_rx_ramfull == 0) { spider_net_handle_error_irq()
1493 card->ignore_rx_ramfull = 1; spider_net_handle_error_irq()
1494 spider_net_resync_head_ptr(card); spider_net_handle_error_irq()
1495 spider_net_refill_rx_chain(card); spider_net_handle_error_irq()
1496 spider_net_enable_rxdmac(card); spider_net_handle_error_irq()
1497 card->num_rx_ints ++; spider_net_handle_error_irq()
1498 napi_schedule(&card->napi); spider_net_handle_error_irq()
1514 spider_net_resync_head_ptr(card); spider_net_handle_error_irq()
1515 spider_net_refill_rx_chain(card); spider_net_handle_error_irq()
1516 spider_net_enable_rxdmac(card); spider_net_handle_error_irq()
1517 card->num_rx_ints ++; spider_net_handle_error_irq()
1518 napi_schedule(&card->napi); spider_net_handle_error_irq()
1528 spider_net_resync_head_ptr(card); spider_net_handle_error_irq()
1529 spider_net_refill_rx_chain(card); spider_net_handle_error_irq()
1530 spider_net_enable_rxdmac(card); spider_net_handle_error_irq()
1531 card->num_rx_ints ++; spider_net_handle_error_irq()
1532 napi_schedule(&card->napi); spider_net_handle_error_irq()
1587 if ((show_error) && (netif_msg_intr(card)) && net_ratelimit()) spider_net_handle_error_irq()
1588 dev_err(&card->netdev->dev, "Error interrupt, GHIINT0STS = 0x%08x, " spider_net_handle_error_irq()
1593 spider_net_write_reg(card, SPIDER_NET_GHIINT1STS, error_reg1); spider_net_handle_error_irq()
1594 spider_net_write_reg(card, SPIDER_NET_GHIINT2STS, error_reg2); spider_net_handle_error_irq()
1603 * interrupt found raised by card.
1612 struct spider_net_card *card = netdev_priv(netdev); spider_net_interrupt() local
1615 status_reg = spider_net_read_reg(card, SPIDER_NET_GHIINT0STS); spider_net_interrupt()
1616 error_reg1 = spider_net_read_reg(card, SPIDER_NET_GHIINT1STS); spider_net_interrupt()
1617 error_reg2 = spider_net_read_reg(card, SPIDER_NET_GHIINT2STS); spider_net_interrupt()
1625 spider_net_rx_irq_off(card); spider_net_interrupt()
1626 napi_schedule(&card->napi); spider_net_interrupt()
1627 card->num_rx_ints ++; spider_net_interrupt()
1630 napi_schedule(&card->napi); spider_net_interrupt()
1636 spider_net_handle_error_irq(card, status_reg, spider_net_interrupt()
1640 spider_net_write_reg(card, SPIDER_NET_GHIINT0STS, status_reg); spider_net_interrupt()
1663 * @card: card structure
1668 spider_net_enable_interrupts(struct spider_net_card *card) spider_net_enable_interrupts() argument
1670 spider_net_write_reg(card, SPIDER_NET_GHIINT0MSK, spider_net_enable_interrupts()
1672 spider_net_write_reg(card, SPIDER_NET_GHIINT1MSK, spider_net_enable_interrupts()
1674 spider_net_write_reg(card, SPIDER_NET_GHIINT2MSK, spider_net_enable_interrupts()
1680 * @card: card structure
1685 spider_net_disable_interrupts(struct spider_net_card *card) spider_net_disable_interrupts() argument
1687 spider_net_write_reg(card, SPIDER_NET_GHIINT0MSK, 0); spider_net_disable_interrupts()
1688 spider_net_write_reg(card, SPIDER_NET_GHIINT1MSK, 0); spider_net_disable_interrupts()
1689 spider_net_write_reg(card, SPIDER_NET_GHIINT2MSK, 0); spider_net_disable_interrupts()
1690 spider_net_write_reg(card, SPIDER_NET_GMACINTEN, 0); spider_net_disable_interrupts()
1694 * spider_net_init_card - initializes the card
1695 * @card: card structure
1697 * spider_net_init_card initializes the card so that other registers can
1701 spider_net_init_card(struct spider_net_card *card) spider_net_init_card() argument
1703 spider_net_write_reg(card, SPIDER_NET_CKRCTRL, spider_net_init_card()
1706 spider_net_write_reg(card, SPIDER_NET_CKRCTRL, spider_net_init_card()
1710 spider_net_write_reg(card, SPIDER_NET_GMACOPEMD, spider_net_init_card()
1711 spider_net_read_reg(card, SPIDER_NET_GMACOPEMD) | 0x4); spider_net_init_card()
1713 spider_net_disable_interrupts(card); spider_net_init_card()
1717 * spider_net_enable_card - enables the card by setting all kinds of regs
1718 * @card: card structure
1723 spider_net_enable_card(struct spider_net_card *card) spider_net_enable_card() argument
1771 spider_net_write_reg(card, regs[i][0], regs[i][1]); spider_net_enable_card()
1777 spider_net_write_reg(card, spider_net_enable_card()
1780 spider_net_write_reg(card, spider_net_enable_card()
1785 spider_net_write_reg(card, SPIDER_NET_GMRUA0FIL15R, 0x08080000); spider_net_enable_card()
1787 spider_net_write_reg(card, SPIDER_NET_ECMODE, SPIDER_NET_ECMODE_VALUE); spider_net_enable_card()
1791 spider_net_enable_rxchtails(card); spider_net_enable_card()
1792 spider_net_enable_rxdmac(card); spider_net_enable_card()
1794 spider_net_write_reg(card, SPIDER_NET_GRXDMAEN, SPIDER_NET_WOL_VALUE); spider_net_enable_card()
1796 spider_net_write_reg(card, SPIDER_NET_GMACLENLMT, spider_net_enable_card()
1798 spider_net_write_reg(card, SPIDER_NET_GMACOPEMD, spider_net_enable_card()
1801 spider_net_write_reg(card, SPIDER_NET_GDTDMACCNTR, spider_net_enable_card()
1807 * @card: card structure
1814 spider_net_download_firmware(struct spider_net_card *card, spider_net_download_firmware() argument
1821 spider_net_write_reg(card, SPIDER_NET_GSINIT, spider_net_download_firmware()
1826 spider_net_write_reg(card, spider_net_download_firmware()
1829 spider_net_write_reg(card, SPIDER_NET_GSnPRGDAT + spider_net_download_firmware()
1835 if (spider_net_read_reg(card, SPIDER_NET_GSINIT)) spider_net_download_firmware()
1838 spider_net_write_reg(card, SPIDER_NET_GSINIT, spider_net_download_firmware()
1846 * @card: card structure
1871 spider_net_init_firmware(struct spider_net_card *card) spider_net_init_firmware() argument
1880 SPIDER_NET_FIRMWARE_NAME, &card->pdev->dev) == 0) { spider_net_init_firmware()
1882 netif_msg_probe(card) ) { spider_net_init_firmware()
1883 dev_err(&card->netdev->dev, spider_net_init_firmware()
1888 err = spider_net_download_firmware(card, firmware->data); spider_net_init_firmware()
1898 dn = pci_device_to_OF_node(card->pdev); spider_net_init_firmware()
1907 netif_msg_probe(card) ) { spider_net_init_firmware()
1908 dev_err(&card->netdev->dev, spider_net_init_firmware()
1913 err = spider_net_download_firmware(card, fw_prop); spider_net_init_firmware()
1918 if (netif_msg_probe(card)) spider_net_init_firmware()
1919 dev_err(&card->netdev->dev, spider_net_init_firmware()
1937 struct spider_net_card *card = netdev_priv(netdev); spider_net_open() local
1940 result = spider_net_init_firmware(card); spider_net_open()
1945 card->aneg_count = 0; spider_net_open()
1946 card->medium = BCM54XX_COPPER; spider_net_open()
1947 spider_net_setup_aneg(card); spider_net_open()
1948 if (card->phy.def->phy_id) spider_net_open()
1949 mod_timer(&card->aneg_timer, jiffies + SPIDER_NET_ANEG_TIMER); spider_net_open()
1951 result = spider_net_init_chain(card, &card->tx_chain); spider_net_open()
1954 card->low_watermark = NULL; spider_net_open()
1956 result = spider_net_init_chain(card, &card->rx_chain); spider_net_open()
1961 result = spider_net_alloc_rx_skbs(card); spider_net_open()
1974 spider_net_enable_card(card); spider_net_open()
1978 napi_enable(&card->napi); spider_net_open()
1980 spider_net_enable_interrupts(card); spider_net_open()
1985 spider_net_free_rx_chain_contents(card); spider_net_open()
1987 spider_net_free_chain(card, &card->rx_chain); spider_net_open()
1989 spider_net_free_chain(card, &card->tx_chain); spider_net_open()
1991 del_timer_sync(&card->aneg_timer); spider_net_open()
1998 * @data: used for pointer to card structure
2003 struct spider_net_card *card = (struct spider_net_card *)data; spider_net_link_phy() local
2004 struct mii_phy *phy = &card->phy; spider_net_link_phy()
2007 if (card->aneg_count > SPIDER_NET_ANEG_TIMEOUT) { spider_net_link_phy()
2010 card->netdev->name); spider_net_link_phy()
2012 switch (card->medium) { spider_net_link_phy()
2017 card->medium = BCM54XX_FIBER; spider_net_link_phy()
2024 card->medium = BCM54XX_UNKNOWN; spider_net_link_phy()
2030 spider_net_setup_aneg(card); spider_net_link_phy()
2031 card->medium = BCM54XX_COPPER; spider_net_link_phy()
2035 card->aneg_count = 0; spider_net_link_phy()
2036 mod_timer(&card->aneg_timer, jiffies + SPIDER_NET_ANEG_TIMER); spider_net_link_phy()
2042 card->aneg_count++; spider_net_link_phy()
2043 mod_timer(&card->aneg_timer, jiffies + SPIDER_NET_ANEG_TIMER); spider_net_link_phy()
2050 spider_net_write_reg(card, SPIDER_NET_GMACST, spider_net_link_phy()
2051 spider_net_read_reg(card, SPIDER_NET_GMACST)); spider_net_link_phy()
2052 spider_net_write_reg(card, SPIDER_NET_GMACINTEN, 0x4); spider_net_link_phy()
2055 spider_net_write_reg(card, SPIDER_NET_GMACMODE, 0x00000001); spider_net_link_phy()
2057 spider_net_write_reg(card, SPIDER_NET_GMACMODE, 0); spider_net_link_phy()
2059 card->aneg_count = 0; spider_net_link_phy()
2062 card->netdev->name, phy->speed, spider_net_link_phy()
2069 * @card: card structure
2076 spider_net_setup_phy(struct spider_net_card *card) spider_net_setup_phy() argument
2078 struct mii_phy *phy = &card->phy; spider_net_setup_phy()
2080 spider_net_write_reg(card, SPIDER_NET_GDTDMASEL, spider_net_setup_phy()
2082 spider_net_write_reg(card, SPIDER_NET_GPCCTRL, spider_net_setup_phy()
2085 phy->dev = card->netdev; spider_net_setup_phy()
2091 id = spider_net_read_phy(card->netdev, phy->mii_id, MII_BMSR); spider_net_setup_phy()
2105 * @card: card structure
2110 spider_net_workaround_rxramfull(struct spider_net_card *card) spider_net_workaround_rxramfull() argument
2115 spider_net_write_reg(card, SPIDER_NET_CKRCTRL, spider_net_workaround_rxramfull()
2121 spider_net_write_reg(card, SPIDER_NET_GSnPRGADR + spider_net_workaround_rxramfull()
2124 spider_net_write_reg(card, SPIDER_NET_GSnPRGDAT + spider_net_workaround_rxramfull()
2130 spider_net_write_reg(card, SPIDER_NET_GSINIT, 0x000000fe); spider_net_workaround_rxramfull()
2133 spider_net_write_reg(card, SPIDER_NET_CKRCTRL, spider_net_workaround_rxramfull()
2146 struct spider_net_card *card = netdev_priv(netdev); spider_net_stop() local
2148 napi_disable(&card->napi); spider_net_stop()
2151 del_timer_sync(&card->tx_timer); spider_net_stop()
2152 del_timer_sync(&card->aneg_timer); spider_net_stop()
2154 spider_net_disable_interrupts(card); spider_net_stop()
2158 spider_net_write_reg(card, SPIDER_NET_GDTDMACCNTR, spider_net_stop()
2162 spider_net_disable_rxdmac(card); spider_net_stop()
2165 spider_net_release_tx_chain(card, 1); spider_net_stop()
2166 spider_net_free_rx_chain_contents(card); spider_net_stop()
2168 spider_net_free_chain(card, &card->tx_chain); spider_net_stop()
2169 spider_net_free_chain(card, &card->rx_chain); spider_net_stop()
2184 struct spider_net_card *card = spider_net_tx_timeout_task() local
2186 struct net_device *netdev = card->netdev; spider_net_tx_timeout_task()
2194 spider_net_workaround_rxramfull(card); spider_net_tx_timeout_task()
2195 spider_net_init_card(card); spider_net_tx_timeout_task()
2197 if (spider_net_setup_phy(card)) spider_net_tx_timeout_task()
2201 spider_net_kick_tx_dma(card); spider_net_tx_timeout_task()
2205 atomic_dec(&card->tx_timeout_task_counter); spider_net_tx_timeout_task()
2217 struct spider_net_card *card; spider_net_tx_timeout() local
2219 card = netdev_priv(netdev); spider_net_tx_timeout()
2220 atomic_inc(&card->tx_timeout_task_counter); spider_net_tx_timeout()
2222 schedule_work(&card->tx_timeout_task); spider_net_tx_timeout()
2224 atomic_dec(&card->tx_timeout_task_counter); spider_net_tx_timeout()
2225 card->spider_stats.tx_timeouts++; spider_net_tx_timeout()
2262 * @card: card structure
2269 spider_net_setup_netdev(struct spider_net_card *card) spider_net_setup_netdev() argument
2272 struct net_device *netdev = card->netdev; spider_net_setup_netdev()
2277 SET_NETDEV_DEV(netdev, &card->pdev->dev); spider_net_setup_netdev()
2279 pci_set_drvdata(card->pdev, netdev); spider_net_setup_netdev()
2281 init_timer(&card->tx_timer); spider_net_setup_netdev()
2282 card->tx_timer.function = spider_net_setup_netdev()
2284 card->tx_timer.data = (unsigned long) card; spider_net_setup_netdev()
2285 netdev->irq = card->pdev->irq; spider_net_setup_netdev()
2287 card->aneg_count = 0; spider_net_setup_netdev()
2288 init_timer(&card->aneg_timer); spider_net_setup_netdev()
2289 card->aneg_timer.function = spider_net_link_phy; spider_net_setup_netdev()
2290 card->aneg_timer.data = (unsigned long) card; spider_net_setup_netdev()
2292 netif_napi_add(netdev, &card->napi, spider_net_setup_netdev()
2304 netdev->irq = card->pdev->irq; spider_net_setup_netdev()
2305 card->num_rx_ints = 0; spider_net_setup_netdev()
2306 card->ignore_rx_ramfull = 0; spider_net_setup_netdev()
2308 dn = pci_device_to_OF_node(card->pdev); spider_net_setup_netdev()
2318 if ((result) && (netif_msg_probe(card))) spider_net_setup_netdev()
2319 dev_err(&card->netdev->dev, spider_net_setup_netdev()
2324 if (netif_msg_probe(card)) spider_net_setup_netdev()
2325 dev_err(&card->netdev->dev, spider_net_setup_netdev()
2330 if (netif_msg_probe(card)) spider_net_setup_netdev()
2337 * spider_net_alloc_card - allocates net_device and card structure
2339 * returns the card structure or NULL in case of errors
2341 * the card and net_device structures are linked to each other
2347 struct spider_net_card *card; spider_net_alloc_card() local
2356 card = netdev_priv(netdev); spider_net_alloc_card()
2357 card->netdev = netdev; spider_net_alloc_card()
2358 card->msg_enable = SPIDER_NET_DEFAULT_MSG; spider_net_alloc_card()
2359 INIT_WORK(&card->tx_timeout_task, spider_net_tx_timeout_task); spider_net_alloc_card()
2360 init_waitqueue_head(&card->waitq); spider_net_alloc_card()
2361 atomic_set(&card->tx_timeout_task_counter, 0); spider_net_alloc_card()
2363 card->rx_chain.num_desc = rx_descriptors; spider_net_alloc_card()
2364 card->rx_chain.ring = card->darray; spider_net_alloc_card()
2365 card->tx_chain.num_desc = tx_descriptors; spider_net_alloc_card()
2366 card->tx_chain.ring = card->darray + rx_descriptors; spider_net_alloc_card()
2368 return card; spider_net_alloc_card()
2373 * @card: card structure
2378 spider_net_undo_pci_setup(struct spider_net_card *card) spider_net_undo_pci_setup() argument
2380 iounmap(card->regs); spider_net_undo_pci_setup()
2381 pci_release_regions(card->pdev); spider_net_undo_pci_setup()
2388 * Returns the card structure or NULL if any errors occur
2393 * The net_device structure is attached to the card structure, if the
2399 struct spider_net_card *card; spider_net_setup_pci_dev() local
2421 card = spider_net_alloc_card(); spider_net_setup_pci_dev()
2422 if (!card) { spider_net_setup_pci_dev()
2427 card->pdev = pdev; spider_net_setup_pci_dev()
2433 card->netdev->mem_start = mmio_start; spider_net_setup_pci_dev()
2434 card->netdev->mem_end = mmio_start + mmio_len; spider_net_setup_pci_dev()
2435 card->regs = ioremap(mmio_start, mmio_len); spider_net_setup_pci_dev()
2437 if (!card->regs) { spider_net_setup_pci_dev()
2443 return card; spider_net_setup_pci_dev()
2466 struct spider_net_card *card; spider_net_probe() local
2468 card = spider_net_setup_pci_dev(pdev); spider_net_probe()
2469 if (!card) spider_net_probe()
2472 spider_net_workaround_rxramfull(card); spider_net_probe()
2473 spider_net_init_card(card); spider_net_probe()
2475 err = spider_net_setup_phy(card); spider_net_probe()
2479 err = spider_net_setup_netdev(card); spider_net_probe()
2486 spider_net_undo_pci_setup(card); spider_net_probe()
2487 free_netdev(card->netdev); spider_net_probe()
2505 struct spider_net_card *card; spider_net_remove() local
2508 card = netdev_priv(netdev); spider_net_remove()
2510 wait_event(card->waitq, spider_net_remove()
2511 atomic_read(&card->tx_timeout_task_counter) == 0); spider_net_remove()
2515 /* switch off card */ spider_net_remove()
2516 spider_net_write_reg(card, SPIDER_NET_CKRCTRL, spider_net_remove()
2518 spider_net_write_reg(card, SPIDER_NET_CKRCTRL, spider_net_remove()
2521 spider_net_undo_pci_setup(card); spider_net_remove()
953 spider_net_pass_skb_up(struct spider_net_descr *descr, struct spider_net_card *card) spider_net_pass_skb_up() argument
H A Dspider_net_ethtool.c53 struct spider_net_card *card; spider_net_ethtool_get_settings() local
54 card = netdev_priv(netdev); spider_net_ethtool_get_settings()
61 ethtool_cmd_speed_set(cmd, card->phy.speed); spider_net_ethtool_get_settings()
71 struct spider_net_card *card; spider_net_ethtool_get_drvinfo() local
72 card = netdev_priv(netdev); spider_net_ethtool_get_drvinfo()
80 strlcpy(drvinfo->bus_info, pci_name(card->pdev), spider_net_ethtool_get_drvinfo()
96 struct spider_net_card *card; spider_net_ethtool_get_msglevel() local
97 card = netdev_priv(netdev); spider_net_ethtool_get_msglevel()
98 return card->msg_enable; spider_net_ethtool_get_msglevel()
105 struct spider_net_card *card; spider_net_ethtool_set_msglevel() local
106 card = netdev_priv(netdev); spider_net_ethtool_set_msglevel()
107 card->msg_enable = level; spider_net_ethtool_set_msglevel()
124 struct spider_net_card *card = netdev_priv(netdev); spider_net_ethtool_get_ringparam() local
127 ering->tx_pending = card->tx_chain.num_desc; spider_net_ethtool_get_ringparam()
129 ering->rx_pending = card->rx_chain.num_desc; spider_net_ethtool_get_ringparam()
145 struct spider_net_card *card = netdev_priv(netdev); spider_net_get_ethtool_stats() local
154 data[7] = card->spider_stats.rx_desc_error; spider_net_get_ethtool_stats()
155 data[8] = card->spider_stats.tx_timeouts; spider_net_get_ethtool_stats()
156 data[9] = card->spider_stats.alloc_rx_skb_error; spider_net_get_ethtool_stats()
157 data[10] = card->spider_stats.rx_iommu_map_error; spider_net_get_ethtool_stats()
158 data[11] = card->spider_stats.tx_iommu_map_error; spider_net_get_ethtool_stats()
159 data[12] = card->spider_stats.rx_desc_unk_state; spider_net_get_ethtool_stats()
/linux-4.1.27/drivers/isdn/hysdn/
H A Dboardergo.c37 hysdn_card *card = dev_id; /* parameter from irq */ ergo_interrupt() local
42 if (!card) ergo_interrupt()
44 if (!card->irq_enabled) ergo_interrupt()
47 spin_lock_irqsave(&card->hysdn_lock, flags); /* no further irqs allowed */ ergo_interrupt()
49 if (!(bytein(card->iobase + PCI9050_INTR_REG) & PCI9050_INTR_REG_STAT1)) { ergo_interrupt()
50 spin_unlock_irqrestore(&card->hysdn_lock, flags); /* restore old state */ ergo_interrupt()
54 dpr = card->dpram; ergo_interrupt()
60 if (!card->hw_lock) ergo_interrupt()
61 schedule_work(&card->irq_queue); ergo_interrupt()
62 spin_unlock_irqrestore(&card->hysdn_lock, flags); ergo_interrupt()
70 /* the card after booting. The task may be queued from everywhere */
76 hysdn_card *card = container_of(ugli_api, hysdn_card, irq_queue); ergo_irq_bh() local
81 if (card->state != CARD_STATE_RUN) ergo_irq_bh()
84 dpr = card->dpram; /* point to DPRAM */ ergo_irq_bh()
86 spin_lock_irqsave(&card->hysdn_lock, flags); ergo_irq_bh()
87 if (card->hw_lock) { ergo_irq_bh()
88 spin_unlock_irqrestore(&card->hysdn_lock, flags); /* hardware currently unavailable */ ergo_irq_bh()
91 card->hw_lock = 1; /* we now lock the hardware */ ergo_irq_bh()
99 if (hysdn_sched_tx(card, dpr->ToHyBuf, &dpr->ToHySize, &dpr->ToHyChannel, ergo_irq_bh()
108 if (hysdn_sched_rx(card, dpr->ToPcBuf, dpr->ToPcSize, dpr->ToPcChannel)) { ergo_irq_bh()
117 card->hw_lock = 0; /* free hardware again */ ergo_irq_bh()
120 spin_unlock_irqrestore(&card->hysdn_lock, flags); ergo_irq_bh()
125 /* stop the card (hardware reset) and disable interrupts */
128 ergo_stopcard(hysdn_card *card) ergo_stopcard() argument
133 hysdn_net_release(card); /* first release the net device if existing */ ergo_stopcard()
135 hycapi_capi_stop(card); ergo_stopcard()
137 spin_lock_irqsave(&card->hysdn_lock, flags); ergo_stopcard()
138 val = bytein(card->iobase + PCI9050_INTR_REG); /* get actual value */ ergo_stopcard()
140 byteout(card->iobase + PCI9050_INTR_REG, val); ergo_stopcard()
141 card->irq_enabled = 0; ergo_stopcard()
142 byteout(card->iobase + PCI9050_USER_IO, PCI9050_E1_RESET); /* reset E1 processor */ ergo_stopcard()
143 card->state = CARD_STATE_UNUSED; ergo_stopcard()
144 card->err_log_state = ERRLOG_STATE_OFF; /* currently no log active */ ergo_stopcard()
146 spin_unlock_irqrestore(&card->hysdn_lock, flags); ergo_stopcard()
153 ergo_set_errlog_state(hysdn_card *card, int on) ergo_set_errlog_state() argument
157 if (card->state != CARD_STATE_RUN) { ergo_set_errlog_state()
158 card->err_log_state = ERRLOG_STATE_OFF; /* must be off */ ergo_set_errlog_state()
161 spin_lock_irqsave(&card->hysdn_lock, flags); ergo_set_errlog_state()
163 if (((card->err_log_state == ERRLOG_STATE_OFF) && !on) || ergo_set_errlog_state()
164 ((card->err_log_state == ERRLOG_STATE_ON) && on)) { ergo_set_errlog_state()
165 spin_unlock_irqrestore(&card->hysdn_lock, flags); ergo_set_errlog_state()
169 card->err_log_state = ERRLOG_STATE_START; /* request start */ ergo_set_errlog_state()
171 card->err_log_state = ERRLOG_STATE_STOP; /* request stop */ ergo_set_errlog_state()
173 spin_unlock_irqrestore(&card->hysdn_lock, flags); ergo_set_errlog_state()
174 schedule_work(&card->irq_queue); ergo_set_errlog_state()
183 ergo_testram(hysdn_card *card) ergo_testram() argument
185 tErgDpram *dpr = card->dpram; ergo_testram()
209 /* PCI-write-buffers flushed and the card is taken out of reset. */
214 ergo_writebootimg(struct HYSDN_CARD *card, unsigned char *buf, ergo_writebootimg() argument
221 if (card->debug_flags & LOG_POF_CARD) ergo_writebootimg()
222 hysdn_addlog(card, "ERGO: write bootldr offs=0x%lx ", offs); ergo_writebootimg()
224 dst = card->dpram; /* pointer to start of DPRAM */ ergo_writebootimg()
236 memset(card->dpram, 0, ERG_DPRAM_FILL_SIZE); /* fill the DPRAM still not cleared */ ergo_writebootimg()
237 dpram = card->dpram; /* get pointer to dpram structure */ ergo_writebootimg()
241 byteout(card->iobase + PCI9050_USER_IO, PCI9050_E1_RUN); /* start E1 processor */ ergo_writebootimg()
246 if (((tDpramBootSpooler *) card->dpram)->Len != DPRAM_SPOOLER_DATA_SIZE) { ergo_writebootimg()
247 if (card->debug_flags & LOG_POF_CARD) ergo_writebootimg()
248 hysdn_addlog(card, "ERGO: write bootldr no answer"); ergo_writebootimg()
261 ergo_writebootseq(struct HYSDN_CARD *card, unsigned char *buf, int len) ergo_writebootseq() argument
263 tDpramBootSpooler *sp = (tDpramBootSpooler *) card->dpram; ergo_writebootseq()
271 if (card->debug_flags & LOG_POF_CARD) ergo_writebootseq()
272 hysdn_addlog(card, "ERGO: write boot seq len=%d ", len); ergo_writebootseq()
289 if (card->debug_flags & LOG_POF_CARD) ergo_writebootseq()
290 hysdn_addlog(card, "ERGO: write boot seq timeout"); ergo_writebootseq()
322 ergo_waitpofready(struct HYSDN_CARD *card) ergo_waitpofready() argument
324 tErgDpram *dpr = card->dpram; /* pointer to DPRAM structure */ ergo_waitpofready()
330 if (card->debug_flags & LOG_POF_CARD) ergo_waitpofready()
331 hysdn_addlog(card, "ERGO: waiting for pof ready"); ergo_waitpofready()
347 if (EvalSysrTokData(card, dpr->ToPcBuf + RDY_MAGIC_SIZE, msg_size)) ergo_waitpofready()
350 if (card->debug_flags & LOG_POF_RECORD) ergo_waitpofready()
351 hysdn_addlog(card, "ERGO: pof boot success"); ergo_waitpofready()
352 spin_lock_irqsave(&card->hysdn_lock, flags); ergo_waitpofready()
354 card->state = CARD_STATE_RUN; /* now card is running */ ergo_waitpofready()
356 byteout(card->iobase + PCI9050_INTR_REG, ergo_waitpofready()
357 bytein(card->iobase + PCI9050_INTR_REG) | ergo_waitpofready()
359 card->irq_enabled = 1; /* we are ready to receive interrupts */ ergo_waitpofready()
365 spin_unlock_irqrestore(&card->hysdn_lock, flags); ergo_waitpofready()
366 if ((hynet_enable & (1 << card->myid)) ergo_waitpofready()
367 && (i = hysdn_net_create(card))) ergo_waitpofready()
369 ergo_stopcard(card); ergo_waitpofready()
370 card->state = CARD_STATE_BOOTERR; ergo_waitpofready()
374 if ((i = hycapi_capi_create(card))) { ergo_waitpofready()
383 if (card->debug_flags & LOG_POF_CARD) ergo_waitpofready()
384 hysdn_addlog(card, "ERGO: pof boot ready timeout"); ergo_waitpofready()
396 ergo_releasehardware(hysdn_card *card) ergo_releasehardware() argument
398 ergo_stopcard(card); /* first stop the card if not already done */ ergo_releasehardware()
399 free_irq(card->irq, card); /* release interrupt */ ergo_releasehardware()
400 release_region(card->iobase + PCI9050_INTR_REG, 1); /* release all io ports */ ergo_releasehardware()
401 release_region(card->iobase + PCI9050_USER_IO, 1); ergo_releasehardware()
402 iounmap(card->dpram); ergo_releasehardware()
403 card->dpram = NULL; /* release shared mem */ ergo_releasehardware()
413 ergo_inithardware(hysdn_card *card) ergo_inithardware() argument
415 if (!request_region(card->iobase + PCI9050_INTR_REG, 1, "HYSDN")) ergo_inithardware()
417 if (!request_region(card->iobase + PCI9050_USER_IO, 1, "HYSDN")) { ergo_inithardware()
418 release_region(card->iobase + PCI9050_INTR_REG, 1); ergo_inithardware()
421 card->memend = card->membase + ERG_DPRAM_PAGE_SIZE - 1; ergo_inithardware()
422 if (!(card->dpram = ioremap(card->membase, ERG_DPRAM_PAGE_SIZE))) { ergo_inithardware()
423 release_region(card->iobase + PCI9050_INTR_REG, 1); ergo_inithardware()
424 release_region(card->iobase + PCI9050_USER_IO, 1); ergo_inithardware()
428 ergo_stopcard(card); /* disable interrupts */ ergo_inithardware()
429 if (request_irq(card->irq, ergo_interrupt, IRQF_SHARED, "HYSDN", card)) { ergo_inithardware()
430 ergo_releasehardware(card); /* return the acquired hardware */ ergo_inithardware()
434 card->stopcard = ergo_stopcard; ergo_inithardware()
435 card->releasehardware = ergo_releasehardware; ergo_inithardware()
436 card->testram = ergo_testram; ergo_inithardware()
437 card->writebootimg = ergo_writebootimg; ergo_inithardware()
438 card->writebootseq = ergo_writebootseq; ergo_inithardware()
439 card->waitpofready = ergo_waitpofready; ergo_inithardware()
440 card->set_errlog_state = ergo_set_errlog_state; ergo_inithardware()
441 INIT_WORK(&card->irq_queue, ergo_irq_bh); ergo_inithardware()
442 spin_lock_init(&card->hysdn_lock); ergo_inithardware()
H A Dhysdn_init.c40 hysdn_card *card_root = NULL; /* pointer to first card */
41 static hysdn_card *card_last = NULL; /* pointer to first card */
62 hysdn_card *card; hysdn_pci_init_one() local
69 if (!(card = kzalloc(sizeof(hysdn_card), GFP_KERNEL))) { hysdn_pci_init_one()
74 card->myid = cardmax; /* set own id */ hysdn_pci_init_one()
75 card->bus = akt_pcidev->bus->number; hysdn_pci_init_one()
76 card->devfn = akt_pcidev->devfn; /* slot + function */ hysdn_pci_init_one()
77 card->subsysid = akt_pcidev->subsystem_device; hysdn_pci_init_one()
78 card->irq = akt_pcidev->irq; hysdn_pci_init_one()
79 card->iobase = pci_resource_start(akt_pcidev, PCI_REG_PLX_IO_BASE); hysdn_pci_init_one()
80 card->plxbase = pci_resource_start(akt_pcidev, PCI_REG_PLX_MEM_BASE); hysdn_pci_init_one()
81 card->membase = pci_resource_start(akt_pcidev, PCI_REG_MEMORY_BASE); hysdn_pci_init_one()
82 card->brdtype = BD_NONE; /* unknown */ hysdn_pci_init_one()
83 card->debug_flags = DEF_DEB_FLAGS; /* set default debug */ hysdn_pci_init_one()
84 card->faxchans = 0; /* default no fax channels */ hysdn_pci_init_one()
85 card->bchans = 2; /* and 2 b-channels */ hysdn_pci_init_one()
86 card->brdtype = ent->driver_data; hysdn_pci_init_one()
88 if (ergo_inithardware(card)) { hysdn_pci_init_one()
89 printk(KERN_WARNING "HYSDN: card at io 0x%04x already in use\n", card->iobase); hysdn_pci_init_one()
95 card->next = NULL; /*end of chain */ hysdn_pci_init_one()
97 card_last->next = card; /* pointer to next card */ hysdn_pci_init_one()
99 card_root = card; hysdn_pci_init_one()
100 card_last = card; /* new chain end */ hysdn_pci_init_one()
102 pci_set_drvdata(akt_pcidev, card); hysdn_pci_init_one()
106 kfree(card); hysdn_pci_init_one()
114 hysdn_card *card = pci_get_drvdata(akt_pcidev); hysdn_pci_remove_one() local
118 if (card->stopcard) hysdn_pci_remove_one()
119 card->stopcard(card); hysdn_pci_remove_one()
122 hycapi_capi_release(card); hysdn_pci_remove_one()
125 if (card->releasehardware) hysdn_pci_remove_one()
126 card->releasehardware(card); /* free all hardware resources */ hysdn_pci_remove_one()
128 if (card == card_root) { hysdn_pci_remove_one()
135 if (tmp->next == card) hysdn_pci_remove_one()
136 tmp->next = card->next; hysdn_pci_remove_one()
142 kfree(card); hysdn_pci_remove_one()
166 printk(KERN_INFO "HYSDN: %d card(s) found.\n", cardmax); hysdn_init()
H A Dhysdn_sched.c4 * scheduler routines for handling exchange card <-> pc.
25 /* available from the card. The routine has to handle the data and return */
27 /* no room to buffer the data is available a zero return tells the card */
31 hysdn_sched_rx(hysdn_card *card, unsigned char *buf, unsigned short len, hysdn_sched_rx() argument
37 if (hynet_enable & (1 << card->myid)) { hysdn_sched_rx()
39 hysdn_rx_netpkt(card, buf, len); hysdn_sched_rx()
44 hysdn_card_errlog(card, (tErrLogEntry *) buf, len); hysdn_sched_rx()
45 if (card->err_log_state == ERRLOG_STATE_ON) hysdn_sched_rx()
46 card->err_log_state = ERRLOG_STATE_START; /* start new fetch */ hysdn_sched_rx()
51 if (hycapi_enable & (1 << card->myid)) { hysdn_sched_rx()
52 hycapi_rx_capipkt(card, buf, len); hysdn_sched_rx()
67 /* room in the tx-buffer to the card and data may be sent if needed. */
74 hysdn_sched_tx(hysdn_card *card, unsigned char *buf, hysdn_sched_tx() argument
80 if (card->net_tx_busy) { hysdn_sched_tx()
81 card->net_tx_busy = 0; /* reset flag */ hysdn_sched_tx()
82 hysdn_tx_netack(card); /* acknowledge packet send */ hysdn_sched_tx()
85 if (card->async_busy) { hysdn_sched_tx()
86 if (card->async_len <= maxlen) { hysdn_sched_tx()
87 memcpy(buf, card->async_data, card->async_len); hysdn_sched_tx()
88 *len = card->async_len; hysdn_sched_tx()
89 *chan = card->async_channel; hysdn_sched_tx()
90 card->async_busy = 0; /* reset request */ hysdn_sched_tx()
93 card->async_busy = 0; /* in case of length error */ hysdn_sched_tx()
95 if ((card->err_log_state == ERRLOG_STATE_START) && hysdn_sched_tx()
100 card->err_log_state = ERRLOG_STATE_ON; /* new state is on */ hysdn_sched_tx()
103 if ((card->err_log_state == ERRLOG_STATE_STOP) && hysdn_sched_tx()
108 card->err_log_state = ERRLOG_STATE_OFF; /* new state is off */ hysdn_sched_tx()
112 if ((hynet_enable & (1 << card->myid)) && hysdn_sched_tx()
113 (skb = hysdn_tx_netget(card)) != NULL) hysdn_sched_tx()
120 card->net_tx_busy = 1; /* we are busy sending network data */ hysdn_sched_tx()
123 hysdn_tx_netack(card); /* aknowledge packet -> throw away */ hysdn_sched_tx()
126 if (((hycapi_enable & (1 << card->myid))) && hysdn_sched_tx()
127 ((skb = hycapi_tx_capiget(card)) != NULL)) hysdn_sched_tx()
133 hycapi_tx_capiack(card); hysdn_sched_tx()
143 /* send one config line to the card and return 0 if successful, otherwise a */
150 hysdn_tx_cfgline(hysdn_card *card, unsigned char *line, unsigned short chan) hysdn_tx_cfgline() argument
155 if (card->debug_flags & LOG_SCHED_ASYN) hysdn_tx_cfgline()
156 hysdn_addlog(card, "async tx-cfg chan=%d len=%d", chan, strlen(line) + 1); hysdn_tx_cfgline()
158 while (card->async_busy) { hysdn_tx_cfgline()
160 if (card->debug_flags & LOG_SCHED_ASYN) hysdn_tx_cfgline()
161 hysdn_addlog(card, "async tx-cfg delayed"); hysdn_tx_cfgline()
168 spin_lock_irqsave(&card->hysdn_lock, flags); hysdn_tx_cfgline()
169 strcpy(card->async_data, line); hysdn_tx_cfgline()
170 card->async_len = strlen(line) + 1; hysdn_tx_cfgline()
171 card->async_channel = chan; hysdn_tx_cfgline()
172 card->async_busy = 1; /* request transfer */ hysdn_tx_cfgline()
175 schedule_work(&card->irq_queue); hysdn_tx_cfgline()
176 spin_unlock_irqrestore(&card->hysdn_lock, flags); hysdn_tx_cfgline()
178 if (card->debug_flags & LOG_SCHED_ASYN) hysdn_tx_cfgline()
179 hysdn_addlog(card, "async tx-cfg data queued"); hysdn_tx_cfgline()
183 while (card->async_busy) { hysdn_tx_cfgline()
185 if (card->debug_flags & LOG_SCHED_ASYN) hysdn_tx_cfgline()
186 hysdn_addlog(card, "async tx-cfg waiting for tx-ready"); hysdn_tx_cfgline()
193 if (card->debug_flags & LOG_SCHED_ASYN) hysdn_tx_cfgline()
194 hysdn_addlog(card, "async tx-cfg data send"); hysdn_tx_cfgline()
H A Dhysdn_procconf.c38 hysdn_card *card; /* card the device is connected to */ member in struct:conf_writedata
48 /* process_line parses one config line and transfers it to the card if */
58 if (cnf->card->debug_flags & LOG_CNF_LINE) process_line()
59 hysdn_addlog(cnf->card, "conf line: %s", cp); process_line()
70 if (cnf->card->debug_flags & LOG_CNF_MISC) process_line()
71 hysdn_addlog(cnf->card, "conf channel invalid %d", i); process_line()
78 if (cnf->card->debug_flags & LOG_CNF_DATA) process_line()
79 hysdn_addlog(cnf->card, "conf chan=%d %s", cnf->channel, cp); process_line()
80 return (hysdn_tx_cfgline(cnf->card, cnf->conf_line + 1, process_line()
91 /* write conf file -> boot or send cfg line to card */
112 if ((cnf->needed_size = pof_write_open(cnf->card, &cnf->pof_buffer)) <= 0) hysdn_conf_write()
120 if (cnf->card->state != CARD_STATE_RUN) hysdn_conf_write()
138 cnf->needed_size = pof_write_buffer(cnf->card, cnf->buf_size); /* write data */ hysdn_conf_write()
140 cnf->card->state = CARD_STATE_BOOTERR; /* show boot error */ hysdn_conf_write()
149 if (cnf->card->state != CARD_STATE_RUN) { hysdn_conf_write()
150 if (cnf->card->debug_flags & LOG_CNF_MISC) hysdn_conf_write()
151 hysdn_addlog(cnf->card, "cnf write denied -> not booted"); hysdn_conf_write()
190 if (cnf->card->debug_flags & LOG_CNF_MISC) hysdn_conf_write()
191 hysdn_addlog(cnf->card, "cnf line too long %d chars pos %d", cnf->buf_size, count); hysdn_conf_write()
199 if (cnf->card->debug_flags & LOG_CNF_MISC) hysdn_conf_write()
200 hysdn_addlog(cnf->card, "cnf line too long"); hysdn_conf_write()
209 /* read conf file -> output card info data */
231 hysdn_card *card; hysdn_conf_open() local
235 /* now search the addressed card */ hysdn_conf_open()
237 card = PDE_DATA(ino); hysdn_conf_open()
238 if (card->debug_flags & (LOG_PROC_OPEN | LOG_PROC_ALL)) hysdn_conf_open()
239 hysdn_addlog(card, "config open for uid=%d gid=%d mode=0x%x", hysdn_conf_open()
250 cnf->card = card; hysdn_conf_open()
256 /* read access -> output card info data */ hysdn_conf_open()
275 card->myid, hysdn_conf_open()
276 card->bus, hysdn_conf_open()
277 PCI_SLOT(card->devfn), hysdn_conf_open()
278 card->brdtype, hysdn_conf_open()
279 card->irq, hysdn_conf_open()
280 card->iobase, hysdn_conf_open()
281 card->membase, hysdn_conf_open()
282 card->bchans, hysdn_conf_open()
283 card->faxchans, hysdn_conf_open()
284 card->state, hysdn_conf_open()
285 hysdn_net_getname(card)); hysdn_conf_open()
306 hysdn_card *card; hysdn_conf_close() local
311 card = PDE_DATA(ino); hysdn_conf_close()
312 if (card->debug_flags & (LOG_PROC_OPEN | LOG_PROC_ALL)) hysdn_conf_close()
313 hysdn_addlog(card, "config close for uid=%d gid=%d mode=0x%x", hysdn_conf_close()
323 retval = pof_write_close(cnf->card); /* close the pof write */ hysdn_conf_close()
328 /* read access -> output card info data */ hysdn_conf_close()
356 /* have been detected. The needed proc dir and card config files are created. */
362 hysdn_card *card; hysdn_procconf_init() local
370 card = card_root; /* point to first card */ hysdn_procconf_init()
371 while (card) { hysdn_procconf_init()
373 sprintf(conf_name, "%s%d", PROC_CONF_BASENAME, card->myid); hysdn_procconf_init()
374 if ((card->procconf = (void *) proc_create_data(conf_name, hysdn_procconf_init()
378 card)) != NULL) { hysdn_procconf_init()
379 hysdn_proclog_init(card); /* init the log file entry */ hysdn_procconf_init()
381 card = card->next; /* next entry */ hysdn_procconf_init()
395 hysdn_card *card; hysdn_procconf_release() local
398 card = card_root; /* start with first card */ hysdn_procconf_release()
399 while (card) { hysdn_procconf_release()
401 sprintf(conf_name, "%s%d", PROC_CONF_BASENAME, card->myid); hysdn_procconf_release()
402 if (card->procconf) hysdn_procconf_release()
405 hysdn_proclog_release(card); /* init the log file entry */ hysdn_procconf_release()
407 card = card->next; /* point to next card */ hysdn_procconf_release()
H A Dhysdn_boot.c36 unsigned char is_crypted;/* card data is crypted */
85 pof_handle_data(hysdn_card *card, int datlen) pof_handle_data() argument
87 struct boot_data *boot = card->boot; /* pointer to boot specific data */ pof_handle_data()
96 if (card->debug_flags & LOG_POF_RECORD) pof_handle_data()
97 hysdn_addlog(card, "POF created %s", boot->buf.PofTime.DateTimeText); pof_handle_data()
103 if (card->debug_flags & LOG_POF_RECORD) pof_handle_data()
104 hysdn_addlog(card, "POF got %s len=%d offs=0x%lx", pof_handle_data()
125 /* The buffer for the boot image on the card is filled in 2 cycles */ pof_handle_data()
132 card->writebootimg(card, imgp, pof_handle_data()
141 if (card->debug_flags & LOG_POF_RECORD) pof_handle_data()
142 hysdn_addlog(card, "POF got %s len=%d offs=0x%lx", pof_handle_data()
146 if ((boot->last_error = card->writebootseq(card, boot->buf.BootBuf, datlen)) < 0) pof_handle_data()
150 return (card->waitpofready(card)); /* data completely spooled, wait for ready */ pof_handle_data()
155 if (card->debug_flags & LOG_POF_RECORD) pof_handle_data()
156 hysdn_addlog(card, "POF got data(id=0x%lx) len=%d offs=0x%lx", boot->pof_recid, pof_handle_data()
174 pof_write_buffer(hysdn_card *card, int datlen) pof_write_buffer() argument
176 struct boot_data *boot = card->boot; /* pointer to boot specific data */ pof_write_buffer()
183 if (card->debug_flags & LOG_POF_WRITE) pof_write_buffer()
184 hysdn_addlog(card, "POF write: got %d bytes ", datlen); pof_write_buffer()
188 if (card->debug_flags & LOG_POF_WRITE) pof_write_buffer()
189 hysdn_addlog(card, "POF write: checking file header"); pof_write_buffer()
206 if (card->debug_flags & LOG_POF_WRITE) pof_write_buffer()
207 hysdn_addlog(card, "POF write: checking tag header"); pof_write_buffer()
217 if (card->debug_flags & LOG_POF_RECORD) pof_write_buffer()
218 hysdn_addlog(card, "POF: got record id=0x%lx length=%ld ", pof_write_buffer()
234 if (card->debug_flags & LOG_POF_WRITE) pof_write_buffer()
235 hysdn_addlog(card, "POF write: getting tag data"); pof_write_buffer()
241 if ((boot->last_error = pof_handle_data(card, datlen)) < 0) pof_write_buffer()
271 pof_write_open(hysdn_card *card, unsigned char **bufp) pof_write_open() argument
275 if (card->boot) { pof_write_open()
276 if (card->debug_flags & LOG_POF_OPEN) pof_write_open()
277 hysdn_addlog(card, "POF open: already opened for boot"); pof_write_open()
282 if (card->debug_flags & LOG_MEM_ERR) pof_write_open()
283 hysdn_addlog(card, "POF open: unable to allocate mem"); pof_write_open()
286 card->boot = boot; pof_write_open()
287 card->state = CARD_STATE_BOOTING; pof_write_open()
289 card->stopcard(card); /* first stop the card */ pof_write_open()
290 if (card->testram(card)) { pof_write_open()
291 if (card->debug_flags & LOG_POF_OPEN) pof_write_open()
292 hysdn_addlog(card, "POF open: DPRAM test failure"); pof_write_open()
294 card->state = CARD_STATE_BOOTERR; /* show boot error */ pof_write_open()
301 if (card->debug_flags & LOG_POF_OPEN) pof_write_open()
302 hysdn_addlog(card, "POF open: success"); pof_write_open()
313 pof_write_close(hysdn_card *card) pof_write_close() argument
315 struct boot_data *boot = card->boot; /* pointer to boot specific data */ pof_write_close()
320 card->boot = NULL; /* no boot active */ pof_write_close()
323 if (card->state == CARD_STATE_RUN) pof_write_close()
324 card->set_errlog_state(card, 1); /* activate error log */ pof_write_close()
326 if (card->debug_flags & LOG_POF_OPEN) pof_write_close()
327 hysdn_addlog(card, "POF close: success"); pof_write_close()
337 EvalSysrTokData(hysdn_card *card, unsigned char *cp, int len) EvalSysrTokData() argument
342 if (card->debug_flags & LOG_POF_RECORD) EvalSysrTokData()
343 hysdn_addlog(card, "SysReady Token data length %d", len); EvalSysrTokData()
346 hysdn_addlog(card, "SysReady Token Data to short"); EvalSysrTokData()
356 hysdn_addlog(card, "SysReady Token Data invalid CRC"); EvalSysrTokData()
366 hysdn_addlog(card, "token 0x%x invalid length %d", *cp, *(cp + 1)); EvalSysrTokData()
373 card->bchans = *(cp + 2); EvalSysrTokData()
379 card->faxchans = *(cp + 2); EvalSysrTokData()
385 memcpy(card->mac_addr, cp + 2, 6); EvalSysrTokData()
389 hysdn_addlog(card, "unknown token 0x%02x length %d", *cp, *(cp + 1)); EvalSysrTokData()
396 hysdn_addlog(card, "no end token found"); EvalSysrTokData()
H A Dhysdn_proclog.c27 static void put_log_buffer(hysdn_card *card, char *cp);
40 /* structure holding proc entrys for one card */
57 hysdn_card_errlog(hysdn_card *card, tErrLogEntry *logp, int maxsize) hysdn_card_errlog() argument
62 put_log_buffer(card, buf); /* output the string */ hysdn_card_errlog()
69 hysdn_addlog(hysdn_card *card, char *fmt, ...) hysdn_addlog() argument
71 struct procdata *pd = card->proclog; hysdn_addlog()
79 cp += sprintf(cp, "HYSDN: card %d ", card->myid); hysdn_addlog()
87 if (card->debug_flags & DEB_OUT_SYSLOG) hysdn_addlog()
90 put_log_buffer(card, pd->logtmp); hysdn_addlog()
101 put_log_buffer(hysdn_card *card, char *cp) put_log_buffer() argument
104 struct procdata *pd = card->proclog; put_log_buffer()
122 spin_lock_irqsave(&card->hysdn_lock, flags); put_log_buffer()
130 spin_unlock_irqrestore(&card->hysdn_lock, flags); put_log_buffer()
159 hysdn_card *card = file->private_data; hysdn_log_write() local
161 rc = kstrtoul_from_user(buf, count, 0, &card->debug_flags); hysdn_log_write()
164 hysdn_addlog(card, "debug set to 0x%lx", card->debug_flags); hysdn_log_write()
176 hysdn_card *card = PDE_DATA(file_inode(file)); hysdn_log_read() local
179 struct procdata *pd = card->proclog; hysdn_log_read()
206 hysdn_card *card = PDE_DATA(ino); hysdn_log_open() local
211 filep->private_data = card; /* remember our own card */ hysdn_log_open()
213 struct procdata *pd = card->proclog; hysdn_log_open()
217 spin_lock_irqsave(&card->hysdn_lock, flags); hysdn_log_open()
223 spin_unlock_irqrestore(&card->hysdn_lock, flags); hysdn_log_open()
244 hysdn_card *card; hysdn_log_close() local
258 /* no info available -> search card */ hysdn_log_close()
259 card = PDE_DATA(file_inode(filep)); hysdn_log_close()
260 pd = card->proclog; /* pointer to procfs log */ hysdn_log_close()
290 hysdn_card *card = PDE_DATA(file_inode(file)); hysdn_log_poll() local
291 struct procdata *pd = card->proclog; hysdn_log_poll()
324 hysdn_proclog_init(hysdn_card *card) hysdn_proclog_init() argument
331 sprintf(pd->log_name, "%s%d", PROC_LOG_BASENAME, card->myid); hysdn_proclog_init()
334 &log_fops, card); hysdn_proclog_init()
338 card->proclog = (void *) pd; /* remember procfs structure */ hysdn_proclog_init()
349 hysdn_proclog_release(hysdn_card *card) hysdn_proclog_release() argument
353 if ((pd = (struct procdata *) card->proclog) != NULL) { hysdn_proclog_release()
357 card->proclog = NULL; hysdn_proclog_release()
H A Dhysdn_net.c63 hysdn_card *card = dev->ml_priv; net_open() local
69 if (!card->mac_addr[0]) { net_open()
78 memcpy(dev->dev_addr, card->mac_addr, ETH_ALEN); net_open()
158 hysdn_tx_netack(hysdn_card *card) hysdn_tx_netack() argument
160 struct net_local *lp = card->netif; hysdn_tx_netack()
184 hysdn_rx_netpkt(hysdn_card *card, unsigned char *buf, unsigned short len) hysdn_rx_netpkt() argument
186 struct net_local *lp = card->netif; hysdn_rx_netpkt()
218 hysdn_tx_netget(hysdn_card *card) hysdn_tx_netget() argument
220 struct net_local *lp = card->netif; hysdn_tx_netget()
242 /* hysdn_net_create creates a new net device for the given card. If a device */
247 hysdn_net_create(hysdn_card *card) hysdn_net_create() argument
253 if (!card) { hysdn_net_create()
254 printk(KERN_WARNING "No card-pt in hysdn_net_create!\n"); hysdn_net_create()
257 hysdn_net_release(card); /* release an existing net device */ hysdn_net_create()
272 dev->base_addr = card->iobase; /* IO address */ hysdn_net_create()
273 dev->irq = card->irq; /* irq */ hysdn_net_create()
281 dev->ml_priv = card; /* remember pointer to own data structure */ hysdn_net_create()
282 card->netif = dev; /* setup the local pointer */ hysdn_net_create()
284 if (card->debug_flags & LOG_NET_INIT) hysdn_net_create()
285 hysdn_addlog(card, "network device created"); hysdn_net_create()
290 /* hysdn_net_release deletes the net device for the given card. The return */
294 hysdn_net_release(hysdn_card *card) hysdn_net_release() argument
296 struct net_device *dev = card->netif; hysdn_net_release()
301 card->netif = NULL; /* clear out pointer */ hysdn_net_release()
308 if (card->debug_flags & LOG_NET_INIT) hysdn_net_release()
309 hysdn_addlog(card, "network device deleted"); hysdn_net_release()
319 hysdn_net_getname(hysdn_card *card) hysdn_net_getname() argument
321 struct net_device *dev = card->netif; hysdn_net_getname()
H A Dhycapi.c85 hysdn_card *card = NULL; hycapi_remove_ctr() local
94 card = cinfo->card; hycapi_remove_ctr()
104 kfree(card->hyctrlinfo); hycapi_remove_ctr()
107 card->hyctrlinfo = NULL; hycapi_remove_ctr()
120 hysdn_card *card = cinfo->card; hycapi_sendmsg_internal() local
133 card->myid); hycapi_sendmsg_internal()
138 schedule_work(&card->irq_queue); hycapi_sendmsg_internal()
156 hysdn_card *card = cinfo->card; hycapi_register_internal() local
170 printk(KERN_ERR "HYSDN card%d: memory squeeze in hycapi_register_appl\n", hycapi_register_internal()
171 card->myid); hycapi_register_internal()
228 hysdn_card *card = cinfo->card; hycapi_register_appl() local
244 MaxLogicalConnections = card->bchans * -MaxLogicalConnections; hycapi_register_appl()
247 MaxLogicalConnections = card->bchans; hycapi_register_appl()
265 hysdn_card *card = cinfo->card; hycapi_release_internal() local
278 printk(KERN_ERR "HYSDN card%d: memory squeeze in hycapi_register_appl\n", hycapi_release_internal()
279 card->myid); hycapi_release_internal()
323 int hycapi_capi_release(hysdn_card *card) hycapi_capi_release() argument
325 hycapictrl_info *cinfo = card->hyctrlinfo; hycapi_capi_release()
340 Stop CAPI-Output on a card. (e.g. during reboot)
343 int hycapi_capi_stop(hysdn_card *card) hycapi_capi_stop() argument
345 hycapictrl_info *cinfo = card->hyctrlinfo; hycapi_capi_stop()
442 hysdn_card *card = cinfo->card; hycapi_proc_show() local
446 seq_printf(m, "%-16s 0x%x\n", "io", card->iobase); hycapi_proc_show()
447 seq_printf(m, "%-16s %d\n", "irq", card->irq); hycapi_proc_show()
449 switch (card->brdtype) { hycapi_proc_show()
511 cinfo->card ? cinfo->card->iobase : 0x0, hycapi_procinfo()
512 cinfo->card ? cinfo->card->irq : 0, hycapi_procinfo()
528 hycapi_rx_capipkt(hysdn_card *card, unsigned char *buf, unsigned short len) hycapi_rx_capipkt() argument
531 hycapictrl_info *cinfo = card->hyctrlinfo; hycapi_rx_capipkt()
546 card->myid, len); hycapi_rx_capipkt()
557 card->myid); hycapi_rx_capipkt()
568 card->myid); hycapi_rx_capipkt()
587 "protocol. NCPI ignored.\n", card->myid); hycapi_rx_capipkt()
591 " current state\n", card->myid); hycapi_rx_capipkt()
594 printk(KERN_ERR "HYSDN Card%d: invalid PLCI\n", card->myid); hycapi_rx_capipkt()
597 printk(KERN_ERR "HYSDN Card%d: out of NCCI\n", card->myid); hycapi_rx_capipkt()
601 card->myid); hycapi_rx_capipkt()
605 card->myid, info); hycapi_rx_capipkt()
633 void hycapi_tx_capiack(hysdn_card *card) hycapi_tx_capiack() argument
635 hycapictrl_info *cinfo = card->hyctrlinfo; hycapi_tx_capiack()
654 hycapi_tx_capiget(hysdn_card *card)
661 hycapi_tx_capiget(hysdn_card *card) hycapi_tx_capiget() argument
663 hycapictrl_info *cinfo = card->hyctrlinfo; hycapi_tx_capiget()
703 hycapi_capi_create(hysdn_card *card)
705 Attach the card with its capi-ctrl.
708 static void hycapi_fill_profile(hysdn_card *card) hycapi_fill_profile() argument
712 cinfo = card->hyctrlinfo; hycapi_fill_profile()
720 ctrl->profile.ncontroller = card->myid; hycapi_fill_profile()
721 ctrl->profile.nbchannel = card->bchans; hycapi_fill_profile()
725 (card->faxchans ? B1_PROT_T30 : 0) | hycapi_fill_profile()
728 (card->faxchans ? B2_PROT_T30 : 0) | hycapi_fill_profile()
732 (card->faxchans ? B3_PROT_T30 : 0) | hycapi_fill_profile()
733 (card->faxchans ? B3_PROT_T30EXT : 0) | hycapi_fill_profile()
738 hycapi_capi_create(hysdn_card *card) hycapi_capi_create() argument
746 if ((hycapi_enable & (1 << card->myid)) == 0) { hycapi_capi_create()
749 if (!card->hyctrlinfo) { hycapi_capi_create()
755 card->hyctrlinfo = cinfo; hycapi_capi_create()
756 cinfo->card = card; hycapi_capi_create()
760 switch (card->brdtype) { hycapi_capi_create()
788 hycapi_fill_profile(card); hycapi_capi_create()
792 ctrl = &card->hyctrlinfo->capi_ctrl; hycapi_capi_create()
793 hycapi_fill_profile(card); hycapi_capi_create()
/linux-4.1.27/arch/x86/boot/
H A Dvideo-mode.c33 struct card_info *card; probe_cards() local
41 for (card = video_cards; card < video_cards_end; card++) { probe_cards()
42 if (card->unsafe == unsafe) { probe_cards()
43 if (card->probe) probe_cards()
44 card->nmodes = card->probe(); probe_cards()
46 card->nmodes = 0; probe_cards()
54 struct card_info *card; mode_defined() local
58 for (card = video_cards; card < video_cards_end; card++) { mode_defined()
59 mi = card->modes; mode_defined()
60 for (i = 0; i < card->nmodes; i++, mi++) { mode_defined()
73 struct card_info *card; raw_set_mode() local
81 for (card = video_cards; card < video_cards_end; card++) { raw_set_mode()
82 mi = card->modes; raw_set_mode()
83 for (i = 0; i < card->nmodes; i++, mi++) { raw_set_mode()
90 return card->set_mode(mi); raw_set_mode()
99 for (card = video_cards; card < video_cards_end; card++) { raw_set_mode()
100 if (mode >= card->xmode_first && raw_set_mode()
101 mode < card->xmode_first+card->xmode_n) { raw_set_mode()
105 return card->set_mode(&mix); raw_set_mode()
/linux-4.1.27/sound/usb/usx2y/
H A DusX2Yhwdep.h4 int usX2Y_hwdep_new(struct snd_card *card, struct usb_device* device);
H A Dus122l.c38 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* Id for this card */
39 /* Enable this card */
52 static int us122l_create_usbmidi(struct snd_card *card) us122l_create_usbmidi() argument
67 struct usb_device *dev = US122L(card)->dev; us122l_create_usbmidi()
70 return snd_usbmidi_create(card, iface, us122l_create_usbmidi()
71 &US122L(card)->midi_list, &quirk); us122l_create_usbmidi()
74 static int us144_create_usbmidi(struct snd_card *card) us144_create_usbmidi() argument
89 struct usb_device *dev = US122L(card)->dev; us144_create_usbmidi()
92 return snd_usbmidi_create(card, iface, us144_create_usbmidi()
93 &US122L(card)->midi_list, &quirk); us144_create_usbmidi()
427 snd_power_wait(hw->card, SNDRV_CTL_POWER_D0); usb_stream_hwdep_ioctl()
457 static int usb_stream_hwdep_new(struct snd_card *card) usb_stream_hwdep_new() argument
461 struct usb_device *dev = US122L(card)->dev; usb_stream_hwdep_new()
463 err = snd_hwdep_new(card, SND_USB_STREAM_ID, 0, &hw); usb_stream_hwdep_new()
468 hw->private_data = US122L(card); usb_stream_hwdep_new()
482 static bool us122l_create_card(struct snd_card *card) us122l_create_card() argument
485 struct us122l *us122l = US122L(card); us122l_create_card()
509 err = us144_create_usbmidi(card); us122l_create_card()
511 err = us122l_create_usbmidi(card); us122l_create_card()
517 err = usb_stream_hwdep_new(card); us122l_create_card()
530 static void snd_us122l_free(struct snd_card *card) snd_us122l_free() argument
532 struct us122l *us122l = US122L(card); snd_us122l_free()
543 struct snd_card *card; usx2y_create_card() local
552 sizeof(struct us122l), &card); usx2y_create_card()
555 snd_us122l_card_used[US122L(card)->card_index = dev] = 1; usx2y_create_card()
556 card->private_free = snd_us122l_free; usx2y_create_card()
557 US122L(card)->dev = device; usx2y_create_card()
558 mutex_init(&US122L(card)->mutex); usx2y_create_card()
559 init_waitqueue_head(&US122L(card)->sk.sleep); usx2y_create_card()
560 INIT_LIST_HEAD(&US122L(card)->midi_list); usx2y_create_card()
561 strcpy(card->driver, "USB "NAME_ALLCAPS""); usx2y_create_card()
562 sprintf(card->shortname, "TASCAM "NAME_ALLCAPS""); usx2y_create_card()
563 sprintf(card->longname, "%s (%x:%x if %d at %03d/%03d)", usx2y_create_card()
564 card->shortname, usx2y_create_card()
568 US122L(card)->dev->bus->busnum, usx2y_create_card()
569 US122L(card)->dev->devnum usx2y_create_card()
571 *cardp = card; usx2y_create_card()
580 struct snd_card *card; us122l_usb_probe() local
583 err = usx2y_create_card(device, intf, &card); us122l_usb_probe()
587 if (!us122l_create_card(card)) { us122l_usb_probe()
588 snd_card_free(card); us122l_usb_probe()
592 err = snd_card_register(card); us122l_usb_probe()
594 snd_card_free(card); us122l_usb_probe()
600 *cardp = card; us122l_usb_probe()
608 struct snd_card *card; snd_us122l_probe() local
623 err = us122l_usb_probe(usb_get_intf(intf), id, &card); snd_us122l_probe()
629 usb_set_intfdata(intf, card); snd_us122l_probe()
635 struct snd_card *card; snd_us122l_disconnect() local
639 card = usb_get_intfdata(intf); snd_us122l_disconnect()
640 if (!card) snd_us122l_disconnect()
643 snd_card_disconnect(card); snd_us122l_disconnect()
645 us122l = US122L(card); snd_us122l_disconnect()
662 snd_card_free(card); snd_us122l_disconnect()
667 struct snd_card *card; snd_us122l_suspend() local
671 card = usb_get_intfdata(intf); snd_us122l_suspend()
672 if (!card) snd_us122l_suspend()
674 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); snd_us122l_suspend()
676 us122l = US122L(card); snd_us122l_suspend()
692 struct snd_card *card; snd_us122l_resume() local
697 card = usb_get_intfdata(intf); snd_us122l_resume()
698 if (!card) snd_us122l_resume()
701 us122l = US122L(card); snd_us122l_resume()
738 snd_power_change_state(card, SNDRV_CTL_POWER_D0); snd_us122l_resume()
H A Dusbusx2y.c156 static char* id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* Id for this card */
157 static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
170 static void snd_usX2Y_card_private_free(struct snd_card *card);
340 struct snd_card * card; usX2Y_create_card() local
349 sizeof(struct usX2Ydev), &card); usX2Y_create_card()
352 snd_usX2Y_card_used[usX2Y(card)->card_index = dev] = 1; usX2Y_create_card()
353 card->private_free = snd_usX2Y_card_private_free; usX2Y_create_card()
354 usX2Y(card)->dev = device; usX2Y_create_card()
355 init_waitqueue_head(&usX2Y(card)->prepare_wait_queue); usX2Y_create_card()
356 mutex_init(&usX2Y(card)->pcm_mutex); usX2Y_create_card()
357 INIT_LIST_HEAD(&usX2Y(card)->midi_list); usX2Y_create_card()
358 strcpy(card->driver, "USB "NAME_ALLCAPS""); usX2Y_create_card()
359 sprintf(card->shortname, "TASCAM "NAME_ALLCAPS""); usX2Y_create_card()
360 sprintf(card->longname, "%s (%x:%x if %d at %03d/%03d)", usX2Y_create_card()
361 card->shortname, usX2Y_create_card()
364 0,//us428(card)->usbmidi.ifnum, usX2Y_create_card()
365 usX2Y(card)->dev->bus->busnum, usX2Y(card)->dev->devnum usX2Y_create_card()
367 *cardp = card; usX2Y_create_card()
378 struct snd_card * card; usX2Y_usb_probe() local
387 err = usX2Y_create_card(device, intf, &card); usX2Y_usb_probe()
390 if ((err = usX2Y_hwdep_new(card, device)) < 0 || usX2Y_usb_probe()
391 (err = snd_card_register(card)) < 0) { usX2Y_usb_probe()
392 snd_card_free(card); usX2Y_usb_probe()
395 *cardp = card; usX2Y_usb_probe()
404 struct snd_card *card; snd_usX2Y_probe() local
407 err = usX2Y_usb_probe(interface_to_usbdev(intf), intf, id, &card); snd_usX2Y_probe()
410 dev_set_drvdata(&intf->dev, card); snd_usX2Y_probe()
428 static void snd_usX2Y_card_private_free(struct snd_card *card) snd_usX2Y_card_private_free() argument
430 kfree(usX2Y(card)->In04Buf); snd_usX2Y_card_private_free()
431 usb_free_urb(usX2Y(card)->In04urb); snd_usX2Y_card_private_free()
432 if (usX2Y(card)->us428ctls_sharedmem) snd_usX2Y_card_private_free()
433 snd_free_pages(usX2Y(card)->us428ctls_sharedmem, sizeof(*usX2Y(card)->us428ctls_sharedmem)); snd_usX2Y_card_private_free()
434 if (usX2Y(card)->card_index >= 0 && usX2Y(card)->card_index < SNDRV_CARDS) snd_usX2Y_card_private_free()
435 snd_usX2Y_card_used[usX2Y(card)->card_index] = 0; snd_usX2Y_card_private_free()
444 struct snd_card *card = ptr; usX2Y_usb_disconnect() local
445 struct usX2Ydev *usX2Y = usX2Y(card); usX2Y_usb_disconnect()
450 snd_card_disconnect(card); usX2Y_usb_disconnect()
457 snd_card_free(card); usX2Y_usb_disconnect()
/linux-4.1.27/drivers/memstick/core/
H A Dmemstick.c31 static int memstick_dev_match(struct memstick_dev *card, memstick_dev_match() argument
35 if ((id->type == card->id.type) memstick_dev_match()
36 && (id->category == card->id.category) memstick_dev_match()
37 && (id->class == card->id.class)) memstick_dev_match()
46 struct memstick_dev *card = container_of(dev, struct memstick_dev, memstick_bus_match() local
55 if (memstick_dev_match(card, ids)) memstick_bus_match()
65 struct memstick_dev *card = container_of(dev, struct memstick_dev, memstick_uevent() local
68 if (add_uevent_var(env, "MEMSTICK_TYPE=%02X", card->id.type)) memstick_uevent()
71 if (add_uevent_var(env, "MEMSTICK_CATEGORY=%02X", card->id.category)) memstick_uevent()
74 if (add_uevent_var(env, "MEMSTICK_CLASS=%02X", card->id.class)) memstick_uevent()
82 struct memstick_dev *card = container_of(dev, struct memstick_dev, memstick_device_probe() local
90 rc = drv->probe(card); memstick_device_probe()
99 struct memstick_dev *card = container_of(dev, struct memstick_dev, memstick_device_remove() local
106 drv->remove(card); memstick_device_remove()
107 card->dev.driver = NULL; memstick_device_remove()
118 struct memstick_dev *card = container_of(dev, struct memstick_dev, memstick_device_suspend() local
125 return drv->suspend(card, state); memstick_device_suspend()
131 struct memstick_dev *card = container_of(dev, struct memstick_dev, memstick_device_resume() local
138 return drv->resume(card); memstick_device_resume()
153 struct memstick_dev *card = container_of(dev, struct memstick_dev, \
155 return sprintf(buf, format, card->id.name); \
196 struct memstick_dev *card = container_of(dev, struct memstick_dev, memstick_free_card() local
198 kfree(card); memstick_free_card()
201 static int memstick_dummy_check(struct memstick_dev *card) memstick_dummy_check() argument
236 if (host->card && host->card->next_request) memstick_next_req()
237 rc = host->card->next_request(host->card, mrq); memstick_next_req()
254 if (host->card) { memstick_new_req()
256 reinit_completion(&host->card->mrq_complete); memstick_new_req()
327 static int h_memstick_read_dev_id(struct memstick_dev *card, h_memstick_read_dev_id() argument
333 memstick_init_req(&card->current_mrq, MS_TPC_READ_REG, NULL, h_memstick_read_dev_id()
335 *mrq = &card->current_mrq; h_memstick_read_dev_id()
340 card->id.match_flags = MEMSTICK_MATCH_ALL; h_memstick_read_dev_id()
341 card->id.type = id_reg.type; h_memstick_read_dev_id()
342 card->id.category = id_reg.category; h_memstick_read_dev_id()
343 card->id.class = id_reg.class; h_memstick_read_dev_id()
344 dev_dbg(&card->dev, "if_mode = %02x\n", id_reg.if_mode); h_memstick_read_dev_id()
346 complete(&card->mrq_complete); h_memstick_read_dev_id()
351 static int h_memstick_set_rw_addr(struct memstick_dev *card, h_memstick_set_rw_addr() argument
355 memstick_init_req(&card->current_mrq, MS_TPC_SET_RW_REG_ADRS, h_memstick_set_rw_addr()
356 (char *)&card->reg_addr, h_memstick_set_rw_addr()
357 sizeof(card->reg_addr)); h_memstick_set_rw_addr()
358 *mrq = &card->current_mrq; h_memstick_set_rw_addr()
361 complete(&card->mrq_complete); h_memstick_set_rw_addr()
369 * @card - media device to use
371 int memstick_set_rw_addr(struct memstick_dev *card) memstick_set_rw_addr() argument
373 card->next_request = h_memstick_set_rw_addr; memstick_set_rw_addr()
374 memstick_new_req(card->host); memstick_set_rw_addr()
375 wait_for_completion(&card->mrq_complete); memstick_set_rw_addr()
377 return card->current_mrq.error; memstick_set_rw_addr()
383 struct memstick_dev *card = kzalloc(sizeof(struct memstick_dev), memstick_alloc_card() local
385 struct memstick_dev *old_card = host->card; memstick_alloc_card()
388 if (card) { memstick_alloc_card()
389 card->host = host; memstick_alloc_card()
390 dev_set_name(&card->dev, "%s", dev_name(&host->dev)); memstick_alloc_card()
391 card->dev.parent = &host->dev; memstick_alloc_card()
392 card->dev.bus = &memstick_bus_type; memstick_alloc_card()
393 card->dev.release = memstick_free_card; memstick_alloc_card()
394 card->check = memstick_dummy_check; memstick_alloc_card()
396 card->reg_addr.r_offset = offsetof(struct ms_register, id); memstick_alloc_card()
397 card->reg_addr.r_length = sizeof(id_reg); memstick_alloc_card()
398 card->reg_addr.w_offset = offsetof(struct ms_register, id); memstick_alloc_card()
399 card->reg_addr.w_length = sizeof(id_reg); memstick_alloc_card()
401 init_completion(&card->mrq_complete); memstick_alloc_card()
403 host->card = card; memstick_alloc_card()
404 if (memstick_set_rw_addr(card)) memstick_alloc_card()
407 card->next_request = h_memstick_read_dev_id; memstick_alloc_card()
409 wait_for_completion(&card->mrq_complete); memstick_alloc_card()
411 if (card->current_mrq.error) memstick_alloc_card()
414 host->card = old_card; memstick_alloc_card()
415 return card; memstick_alloc_card()
417 host->card = old_card; memstick_alloc_card()
418 kfree(card); memstick_alloc_card()
436 struct memstick_dev *card; memstick_check() local
440 if (!host->card) { memstick_check()
443 } else if (host->card->stop) memstick_check()
444 host->card->stop(host->card); memstick_check()
446 card = memstick_alloc_card(host); memstick_check()
448 if (!card) { memstick_check()
449 if (host->card) { memstick_check()
450 device_unregister(&host->card->dev); memstick_check()
451 host->card = NULL; memstick_check()
454 dev_dbg(&host->dev, "new card %02x, %02x, %02x\n", memstick_check()
455 card->id.type, card->id.category, card->id.class); memstick_check()
456 if (host->card) { memstick_check()
457 if (memstick_set_rw_addr(host->card) memstick_check()
458 || !memstick_dev_match(host->card, &card->id) memstick_check()
459 || !(host->card->check(host->card))) { memstick_check()
460 device_unregister(&host->card->dev); memstick_check()
461 host->card = NULL; memstick_check()
462 } else if (host->card->start) memstick_check()
463 host->card->start(host->card); memstick_check()
466 if (!host->card) { memstick_check()
467 host->card = card; memstick_check()
468 if (device_register(&card->dev)) { memstick_check()
469 put_device(&card->dev); memstick_check()
470 kfree(host->card); memstick_check()
471 host->card = NULL; memstick_check()
474 kfree(card); memstick_check()
478 if (!host->card) memstick_check()
551 if (host->card) memstick_remove_host()
552 device_unregister(&host->card->dev); memstick_remove_host()
553 host->card = NULL; memstick_remove_host()
596 if (host->card) memstick_resume_host()
H A Dmspro_block.c139 struct memstick_dev *card; member in struct:mspro_block_data
160 int (*mrq_handler)(struct memstick_dev *card,
167 void (*setup_transfer)(struct memstick_dev *card,
181 static int mspro_block_complete_req(struct memstick_dev *card, int error);
193 if (msb && msb->card) { mspro_block_bd_open()
525 static int h_mspro_block_req_init(struct memstick_dev *card, h_mspro_block_req_init() argument
528 struct mspro_block_data *msb = memstick_get_drvdata(card); h_mspro_block_req_init()
530 *mrq = &card->current_mrq; h_mspro_block_req_init()
531 card->next_request = msb->mrq_handler; h_mspro_block_req_init()
535 static int h_mspro_block_default(struct memstick_dev *card, h_mspro_block_default() argument
538 return mspro_block_complete_req(card, (*mrq)->error); h_mspro_block_default()
541 static int h_mspro_block_default_bad(struct memstick_dev *card, h_mspro_block_default_bad() argument
547 static int h_mspro_block_get_ro(struct memstick_dev *card, h_mspro_block_get_ro() argument
550 struct mspro_block_data *msb = memstick_get_drvdata(card); h_mspro_block_get_ro()
560 return mspro_block_complete_req(card, (*mrq)->error); h_mspro_block_get_ro()
563 static int h_mspro_block_wait_for_ced(struct memstick_dev *card, h_mspro_block_wait_for_ced() argument
566 dev_dbg(&card->dev, "wait for ced: value %x\n", (*mrq)->data[0]); h_mspro_block_wait_for_ced()
575 return mspro_block_complete_req(card, (*mrq)->error); h_mspro_block_wait_for_ced()
578 static int h_mspro_block_transfer_data(struct memstick_dev *card, h_mspro_block_transfer_data() argument
581 struct mspro_block_data *msb = memstick_get_drvdata(card); h_mspro_block_transfer_data()
587 return mspro_block_complete_req(card, (*mrq)->error); h_mspro_block_transfer_data()
606 card->next_request = h_mspro_block_default; h_mspro_block_transfer_data()
618 return mspro_block_complete_req(card, h_mspro_block_transfer_data()
621 card->next_request h_mspro_block_transfer_data()
667 /** Setup data transfer request for SET_CMD TPC with arguments in card
670 * @card Current media instance
674 static void h_mspro_block_setup_cmd(struct memstick_dev *card, u64 offset, h_mspro_block_setup_cmd() argument
677 struct mspro_block_data *msb = memstick_get_drvdata(card); h_mspro_block_setup_cmd()
689 card->next_request = h_mspro_block_req_init; h_mspro_block_setup_cmd()
691 memstick_init_req(&card->current_mrq, MS_TPC_WRITE_REG, h_mspro_block_setup_cmd()
697 static int mspro_block_issue_req(struct memstick_dev *card, int chunk) mspro_block_issue_req() argument
699 struct mspro_block_data *msb = memstick_get_drvdata(card); mspro_block_issue_req()
720 msb->setup_transfer(card, t_off, count); mspro_block_issue_req()
727 memstick_new_req(card->host); mspro_block_issue_req()
731 dev_dbg(&card->dev, "blk_fetch\n"); mspro_block_issue_req()
734 dev_dbg(&card->dev, "issue end\n"); mspro_block_issue_req()
738 dev_dbg(&card->dev, "trying again\n"); mspro_block_issue_req()
743 static int mspro_block_complete_req(struct memstick_dev *card, int error) mspro_block_complete_req() argument
745 struct mspro_block_data *msb = memstick_get_drvdata(card); mspro_block_complete_req()
751 dev_dbg(&card->dev, "complete %d, %d\n", msb->has_request ? 1 : 0, mspro_block_complete_req()
759 if (error || (card->current_mrq.tpc == MSPRO_CMD_STOP)) { mspro_block_complete_req()
774 dev_dbg(&card->dev, "transferred %x (%d)\n", t_len, error); mspro_block_complete_req()
781 error = mspro_block_issue_req(card, chunk); mspro_block_complete_req()
792 card->next_request = h_mspro_block_default_bad; mspro_block_complete_req()
793 complete_all(&card->mrq_complete); mspro_block_complete_req()
799 static void mspro_block_stop(struct memstick_dev *card) mspro_block_stop() argument
801 struct mspro_block_data *msb = memstick_get_drvdata(card); mspro_block_stop()
816 wait_for_completion(&card->mrq_complete); mspro_block_stop()
820 static void mspro_block_start(struct memstick_dev *card) mspro_block_start() argument
822 struct mspro_block_data *msb = memstick_get_drvdata(card); mspro_block_start()
845 struct memstick_dev *card = q->queuedata; mspro_block_submit_req() local
846 struct mspro_block_data *msb = memstick_get_drvdata(card); mspro_block_submit_req()
860 if (mspro_block_issue_req(card, 0)) mspro_block_submit_req()
866 static int mspro_block_wait_for_ced(struct memstick_dev *card) mspro_block_wait_for_ced() argument
868 struct mspro_block_data *msb = memstick_get_drvdata(card); mspro_block_wait_for_ced()
870 card->next_request = h_mspro_block_req_init; mspro_block_wait_for_ced()
872 memstick_init_req(&card->current_mrq, MS_TPC_GET_INT, NULL, 1); mspro_block_wait_for_ced()
873 memstick_new_req(card->host); mspro_block_wait_for_ced()
874 wait_for_completion(&card->mrq_complete); mspro_block_wait_for_ced()
875 return card->current_mrq.error; mspro_block_wait_for_ced()
878 static int mspro_block_set_interface(struct memstick_dev *card, mspro_block_set_interface() argument
881 struct memstick_host *host = card->host; mspro_block_set_interface()
882 struct mspro_block_data *msb = memstick_get_drvdata(card); mspro_block_set_interface()
890 card->next_request = h_mspro_block_req_init; mspro_block_set_interface()
892 memstick_init_req(&card->current_mrq, MS_TPC_WRITE_REG, &param, mspro_block_set_interface()
895 wait_for_completion(&card->mrq_complete); mspro_block_set_interface()
896 return card->current_mrq.error; mspro_block_set_interface()
899 static int mspro_block_switch_interface(struct memstick_dev *card) mspro_block_switch_interface() argument
901 struct memstick_host *host = card->host; mspro_block_switch_interface()
902 struct mspro_block_data *msb = memstick_get_drvdata(card); mspro_block_switch_interface()
907 rc = mspro_block_set_interface(card, MEMSTICK_SYS_PAR4); mspro_block_switch_interface()
914 dev_name(&card->dev), rc); mspro_block_switch_interface()
921 dev_name(&card->dev)); mspro_block_switch_interface()
924 rc = mspro_block_set_interface(card, MEMSTICK_SYS_PAR8); mspro_block_switch_interface()
932 dev_name(&card->dev)); mspro_block_switch_interface()
936 dev_name(&card->dev), rc); mspro_block_switch_interface()
939 card->next_request = h_mspro_block_req_init; mspro_block_switch_interface()
941 memstick_init_req(&card->current_mrq, MS_TPC_GET_INT, NULL, 1); mspro_block_switch_interface()
942 memstick_new_req(card->host); mspro_block_switch_interface()
943 wait_for_completion(&card->mrq_complete); mspro_block_switch_interface()
944 rc = card->current_mrq.error; mspro_block_switch_interface()
949 dev_name(&card->dev)); mspro_block_switch_interface()
956 rc = memstick_set_rw_addr(card); mspro_block_switch_interface()
958 rc = mspro_block_set_interface(card, msb->system); mspro_block_switch_interface()
962 rc = mspro_block_wait_for_ced(card); mspro_block_switch_interface()
979 static int mspro_block_read_attributes(struct memstick_dev *card) mspro_block_read_attributes() argument
981 struct mspro_block_data *msb = memstick_get_drvdata(card); mspro_block_read_attributes()
1004 msb->setup_transfer(card, attr_offset, attr_len); mspro_block_read_attributes()
1006 memstick_new_req(card->host); mspro_block_read_attributes()
1007 wait_for_completion(&card->mrq_complete); mspro_block_read_attributes()
1008 if (card->current_mrq.error) { mspro_block_read_attributes()
1009 rc = card->current_mrq.error; mspro_block_read_attributes()
1015 dev_name(&card->dev), be16_to_cpu(attr->signature)); mspro_block_read_attributes()
1022 dev_name(&card->dev)); mspro_block_read_attributes()
1053 dev_dbg(&card->dev, "adding attribute %d: id %x, address %x, " mspro_block_read_attributes()
1106 dev_dbg(&card->dev, "reading attribute range %x, %x\n", mspro_block_read_attributes()
1109 msb->setup_transfer(card, attr_offset, attr_len); mspro_block_read_attributes()
1110 memstick_new_req(card->host); mspro_block_read_attributes()
1111 wait_for_completion(&card->mrq_complete); mspro_block_read_attributes()
1112 if (card->current_mrq.error) { mspro_block_read_attributes()
1113 rc = card->current_mrq.error; mspro_block_read_attributes()
1129 static int mspro_block_init_card(struct memstick_dev *card) mspro_block_init_card() argument
1131 struct mspro_block_data *msb = memstick_get_drvdata(card); mspro_block_init_card()
1132 struct memstick_host *host = card->host; mspro_block_init_card()
1138 card->reg_addr.r_offset = offsetof(struct mspro_register, status); mspro_block_init_card()
1139 card->reg_addr.r_length = sizeof(struct ms_status_register); mspro_block_init_card()
1140 card->reg_addr.w_offset = offsetof(struct mspro_register, param); mspro_block_init_card()
1141 card->reg_addr.w_length = sizeof(struct mspro_param_register); mspro_block_init_card()
1143 if (memstick_set_rw_addr(card)) mspro_block_init_card()
1149 rc = mspro_block_wait_for_ced(card); mspro_block_init_card()
1153 rc = mspro_block_switch_interface(card); mspro_block_init_card()
1157 dev_dbg(&card->dev, "card activated\n"); mspro_block_init_card()
1161 card->next_request = h_mspro_block_req_init; mspro_block_init_card()
1163 memstick_init_req(&card->current_mrq, MS_TPC_READ_REG, NULL, mspro_block_init_card()
1165 memstick_new_req(card->host); mspro_block_init_card()
1166 wait_for_completion(&card->mrq_complete); mspro_block_init_card()
1167 if (card->current_mrq.error) mspro_block_init_card()
1168 return card->current_mrq.error; mspro_block_init_card()
1170 dev_dbg(&card->dev, "card r/w status %d\n", msb->read_only ? 0 : 1); mspro_block_init_card()
1173 rc = mspro_block_read_attributes(card); mspro_block_init_card()
1177 dev_dbg(&card->dev, "attributes loaded\n"); mspro_block_init_card()
1182 static int mspro_block_init_disk(struct memstick_dev *card) mspro_block_init_disk() argument
1184 struct mspro_block_data *msb = memstick_get_drvdata(card); mspro_block_init_disk()
1185 struct memstick_host *host = card->host; mspro_block_init_disk()
1215 disk_id = idr_alloc(&mspro_block_disk_idr, card, 0, 256, GFP_KERNEL); mspro_block_init_disk()
1232 msb->queue->queuedata = card; mspro_block_init_disk()
1247 msb->disk->driverfs_dev = &card->dev; mspro_block_init_disk()
1257 dev_dbg(&card->dev, "capacity set %ld\n", capacity); mspro_block_init_disk()
1287 msb->card = NULL; mspro_block_data_clear()
1290 static int mspro_block_check_card(struct memstick_dev *card) mspro_block_check_card() argument
1292 struct mspro_block_data *msb = memstick_get_drvdata(card); mspro_block_check_card()
1297 static int mspro_block_probe(struct memstick_dev *card) mspro_block_probe() argument
1305 memstick_set_drvdata(card, msb); mspro_block_probe()
1306 msb->card = card; mspro_block_probe()
1309 rc = mspro_block_init_card(card); mspro_block_probe()
1314 rc = sysfs_create_group(&card->dev.kobj, &msb->attr_group); mspro_block_probe()
1318 rc = mspro_block_init_disk(card); mspro_block_probe()
1320 card->check = mspro_block_check_card; mspro_block_probe()
1321 card->stop = mspro_block_stop; mspro_block_probe()
1322 card->start = mspro_block_start; mspro_block_probe()
1326 sysfs_remove_group(&card->dev.kobj, &msb->attr_group); mspro_block_probe()
1328 memstick_set_drvdata(card, NULL); mspro_block_probe()
1334 static void mspro_block_remove(struct memstick_dev *card) mspro_block_remove() argument
1336 struct mspro_block_data *msb = memstick_get_drvdata(card); mspro_block_remove()
1345 dev_dbg(&card->dev, "mspro block remove\n"); mspro_block_remove()
1350 sysfs_remove_group(&card->dev.kobj, &msb->attr_group); mspro_block_remove()
1357 memstick_set_drvdata(card, NULL); mspro_block_remove()
1362 static int mspro_block_suspend(struct memstick_dev *card, pm_message_t state) mspro_block_suspend() argument
1364 struct mspro_block_data *msb = memstick_get_drvdata(card); mspro_block_suspend()
1375 static int mspro_block_resume(struct memstick_dev *card) mspro_block_resume() argument
1377 struct mspro_block_data *msb = memstick_get_drvdata(card); mspro_block_resume()
1384 struct memstick_host *host = card->host; mspro_block_resume()
1395 new_msb->card = card; mspro_block_resume()
1396 memstick_set_drvdata(card, new_msb); mspro_block_resume()
1397 if (mspro_block_init_card(card)) mspro_block_resume()
1416 memstick_set_drvdata(card, msb); mspro_block_resume()
/linux-4.1.27/drivers/net/wireless/mwifiex/
H A Dpcie.c55 struct pcie_service_card *card = adapter->card; mwifiex_map_pci_memory() local
58 mapping.addr = pci_map_single(card->dev, skb->data, size, flags); mwifiex_map_pci_memory()
59 if (pci_dma_mapping_error(card->dev, mapping.addr)) { mwifiex_map_pci_memory()
71 struct pcie_service_card *card = adapter->card; mwifiex_unmap_pci_memory() local
75 pci_unmap_single(card->dev, mapping.addr, mapping.len, flags); mwifiex_unmap_pci_memory()
84 struct pcie_service_card *card = adapter->card; mwifiex_pcie_ok_to_access_hw() local
85 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; mwifiex_pcie_ok_to_access_hw()
90 if (card->sleep_cookie_vbase) { mwifiex_pcie_ok_to_access_hw()
91 cookie_addr = (u32 *)card->sleep_cookie_vbase; mwifiex_pcie_ok_to_access_hw()
105 * methods. Failing that the kernel simply removes the whole card.
113 struct pcie_service_card *card; mwifiex_pcie_suspend() local
118 card = pci_get_drvdata(pdev); mwifiex_pcie_suspend()
119 if (!card || !card->adapter) { mwifiex_pcie_suspend()
128 adapter = card->adapter; mwifiex_pcie_suspend()
142 * methods. Failing that the kernel simply removes the whole card.
150 struct pcie_service_card *card; mwifiex_pcie_resume() local
154 card = pci_get_drvdata(pdev); mwifiex_pcie_resume()
155 if (!card || !card->adapter) { mwifiex_pcie_resume()
164 adapter = card->adapter; mwifiex_pcie_resume()
182 * the card structure, enables PCIE function number and initiates the
189 struct pcie_service_card *card; mwifiex_pcie_probe() local
194 card = kzalloc(sizeof(struct pcie_service_card), GFP_KERNEL); mwifiex_pcie_probe()
195 if (!card) mwifiex_pcie_probe()
198 card->dev = pdev; mwifiex_pcie_probe()
202 card->pcie.firmware = data->firmware; mwifiex_pcie_probe()
203 card->pcie.reg = data->reg; mwifiex_pcie_probe()
204 card->pcie.blksz_fw_dl = data->blksz_fw_dl; mwifiex_pcie_probe()
205 card->pcie.tx_buf_size = data->tx_buf_size; mwifiex_pcie_probe()
206 card->pcie.can_dump_fw = data->can_dump_fw; mwifiex_pcie_probe()
207 card->pcie.can_ext_scan = data->can_ext_scan; mwifiex_pcie_probe()
210 if (mwifiex_add_card(card, &add_remove_card_sem, &pcie_ops, mwifiex_pcie_probe()
213 kfree(card); mwifiex_pcie_probe()
221 * This function removes the interface and frees up the card structure.
225 struct pcie_service_card *card; mwifiex_pcie_remove() local
229 card = pci_get_drvdata(pdev); mwifiex_pcie_remove()
230 if (!card) mwifiex_pcie_remove()
233 adapter = card->adapter; mwifiex_pcie_remove()
252 mwifiex_remove_card(card->adapter, &add_remove_card_sem); mwifiex_pcie_remove()
300 * This function writes data into PCIE card register.
304 struct pcie_service_card *card = adapter->card; mwifiex_write_reg() local
306 iowrite32(data, card->pci_mmap1 + reg); mwifiex_write_reg()
312 * This function reads data from PCIE card register.
316 struct pcie_service_card *card = adapter->card; mwifiex_read_reg() local
318 *data = ioread32(card->pci_mmap1 + reg); mwifiex_read_reg()
323 /* This function reads u8 data from PCIE card register. */ mwifiex_read_reg_byte()
327 struct pcie_service_card *card = adapter->card; mwifiex_read_reg_byte() local
329 *data = ioread8(card->pci_mmap1 + reg); mwifiex_read_reg_byte()
355 struct pcie_service_card *card = adapter->card; mwifiex_delay_for_sleep_cookie() local
360 buffer = card->cmdrsp_buf->data - INTF_HEADER_LEN; mwifiex_delay_for_sleep_cookie()
376 /* This function wakes up the card by reading fw_status register. */ mwifiex_pm_wakeup_card()
380 struct pcie_service_card *card = adapter->card; mwifiex_pm_wakeup_card() local
381 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; mwifiex_pm_wakeup_card()
404 * This function is called after the card has woken up.
406 * The card configuration register is reset.
419 * written back to the card host interrupt mask register.
437 * The host interrupt enable mask is written to the card
459 struct pcie_service_card *card = adapter->card; mwifiex_init_txq_ring() local
460 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; mwifiex_init_txq_ring()
466 card->tx_buf_list[i] = NULL; mwifiex_init_txq_ring()
468 card->txbd_ring[i] = (void *)card->txbd_ring_vbase + mwifiex_init_txq_ring()
470 desc2 = card->txbd_ring[i]; mwifiex_init_txq_ring()
473 card->txbd_ring[i] = (void *)card->txbd_ring_vbase + mwifiex_init_txq_ring()
475 desc = card->txbd_ring[i]; mwifiex_init_txq_ring()
489 struct pcie_service_card *card = adapter->card; mwifiex_init_rxq_ring() local
490 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; mwifiex_init_rxq_ring()
504 kfree(card->rxbd_ring_vbase); mwifiex_init_rxq_ring()
520 card->rx_buf_list[i] = skb; mwifiex_init_rxq_ring()
522 card->rxbd_ring[i] = (void *)card->rxbd_ring_vbase + mwifiex_init_rxq_ring()
524 desc2 = card->rxbd_ring[i]; mwifiex_init_rxq_ring()
531 card->rxbd_ring[i] = (void *)(card->rxbd_ring_vbase + mwifiex_init_rxq_ring()
533 desc = card->rxbd_ring[i]; mwifiex_init_rxq_ring()
549 struct pcie_service_card *card = adapter->card; mwifiex_pcie_init_evt_ring() local
561 kfree(card->evtbd_ring_vbase); mwifiex_pcie_init_evt_ring()
577 card->evt_buf_list[i] = skb; mwifiex_pcie_init_evt_ring()
578 card->evtbd_ring[i] = (void *)(card->evtbd_ring_vbase + mwifiex_pcie_init_evt_ring()
580 desc = card->evtbd_ring[i]; mwifiex_pcie_init_evt_ring()
594 struct pcie_service_card *card = adapter->card; mwifiex_cleanup_txq_ring() local
595 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; mwifiex_cleanup_txq_ring()
603 desc2 = card->txbd_ring[i]; mwifiex_cleanup_txq_ring()
604 if (card->tx_buf_list[i]) { mwifiex_cleanup_txq_ring()
605 skb = card->tx_buf_list[i]; mwifiex_cleanup_txq_ring()
612 desc = card->txbd_ring[i]; mwifiex_cleanup_txq_ring()
613 if (card->tx_buf_list[i]) { mwifiex_cleanup_txq_ring()
614 skb = card->tx_buf_list[i]; mwifiex_cleanup_txq_ring()
621 card->tx_buf_list[i] = NULL; mwifiex_cleanup_txq_ring()
632 struct pcie_service_card *card = adapter->card; mwifiex_cleanup_rxq_ring() local
633 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; mwifiex_cleanup_rxq_ring()
641 desc2 = card->rxbd_ring[i]; mwifiex_cleanup_rxq_ring()
642 if (card->rx_buf_list[i]) { mwifiex_cleanup_rxq_ring()
643 skb = card->rx_buf_list[i]; mwifiex_cleanup_rxq_ring()
650 desc = card->rxbd_ring[i]; mwifiex_cleanup_rxq_ring()
651 if (card->rx_buf_list[i]) { mwifiex_cleanup_rxq_ring()
652 skb = card->rx_buf_list[i]; mwifiex_cleanup_rxq_ring()
659 card->rx_buf_list[i] = NULL; mwifiex_cleanup_rxq_ring()
670 struct pcie_service_card *card = adapter->card; mwifiex_cleanup_evt_ring() local
676 desc = card->evtbd_ring[i]; mwifiex_cleanup_evt_ring()
677 if (card->evt_buf_list[i]) { mwifiex_cleanup_evt_ring()
678 skb = card->evt_buf_list[i]; mwifiex_cleanup_evt_ring()
683 card->evt_buf_list[i] = NULL; mwifiex_cleanup_evt_ring()
694 struct pcie_service_card *card = adapter->card; mwifiex_pcie_create_txbd_ring() local
695 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; mwifiex_pcie_create_txbd_ring()
702 card->txbd_wrptr = 0; mwifiex_pcie_create_txbd_ring()
705 card->txbd_rdptr = 0; mwifiex_pcie_create_txbd_ring()
707 card->txbd_rdptr |= reg->tx_rollover_ind; mwifiex_pcie_create_txbd_ring()
712 card->txbd_ring_size = sizeof(struct mwifiex_pfu_buf_desc) * mwifiex_pcie_create_txbd_ring()
715 card->txbd_ring_size = sizeof(struct mwifiex_pcie_buf_desc) * mwifiex_pcie_create_txbd_ring()
719 card->txbd_ring_size); mwifiex_pcie_create_txbd_ring()
720 card->txbd_ring_vbase = pci_alloc_consistent(card->dev, mwifiex_pcie_create_txbd_ring()
721 card->txbd_ring_size, mwifiex_pcie_create_txbd_ring()
722 &card->txbd_ring_pbase); mwifiex_pcie_create_txbd_ring()
723 if (!card->txbd_ring_vbase) { mwifiex_pcie_create_txbd_ring()
726 card->txbd_ring_size); mwifiex_pcie_create_txbd_ring()
731 card->txbd_ring_vbase, (unsigned int)card->txbd_ring_pbase, mwifiex_pcie_create_txbd_ring()
732 (u32)((u64)card->txbd_ring_pbase >> 32), card->txbd_ring_size); mwifiex_pcie_create_txbd_ring()
739 struct pcie_service_card *card = adapter->card; mwifiex_pcie_delete_txbd_ring() local
740 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; mwifiex_pcie_delete_txbd_ring()
744 if (card->txbd_ring_vbase) mwifiex_pcie_delete_txbd_ring()
745 pci_free_consistent(card->dev, card->txbd_ring_size, mwifiex_pcie_delete_txbd_ring()
746 card->txbd_ring_vbase, mwifiex_pcie_delete_txbd_ring()
747 card->txbd_ring_pbase); mwifiex_pcie_delete_txbd_ring()
748 card->txbd_ring_size = 0; mwifiex_pcie_delete_txbd_ring()
749 card->txbd_wrptr = 0; mwifiex_pcie_delete_txbd_ring()
750 card->txbd_rdptr = 0 | reg->tx_rollover_ind; mwifiex_pcie_delete_txbd_ring()
751 card->txbd_ring_vbase = NULL; mwifiex_pcie_delete_txbd_ring()
752 card->txbd_ring_pbase = 0; mwifiex_pcie_delete_txbd_ring()
762 struct pcie_service_card *card = adapter->card; mwifiex_pcie_create_rxbd_ring() local
763 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; mwifiex_pcie_create_rxbd_ring()
770 card->rxbd_wrptr = 0; mwifiex_pcie_create_rxbd_ring()
771 card->rxbd_rdptr = reg->rx_rollover_ind; mwifiex_pcie_create_rxbd_ring()
774 card->rxbd_ring_size = sizeof(struct mwifiex_pfu_buf_desc) * mwifiex_pcie_create_rxbd_ring()
777 card->rxbd_ring_size = sizeof(struct mwifiex_pcie_buf_desc) * mwifiex_pcie_create_rxbd_ring()
781 card->rxbd_ring_size); mwifiex_pcie_create_rxbd_ring()
782 card->rxbd_ring_vbase = pci_alloc_consistent(card->dev, mwifiex_pcie_create_rxbd_ring()
783 card->rxbd_ring_size, mwifiex_pcie_create_rxbd_ring()
784 &card->rxbd_ring_pbase); mwifiex_pcie_create_rxbd_ring()
785 if (!card->rxbd_ring_vbase) { mwifiex_pcie_create_rxbd_ring()
788 card->rxbd_ring_size); mwifiex_pcie_create_rxbd_ring()
794 card->rxbd_ring_vbase, (u32)card->rxbd_ring_pbase, mwifiex_pcie_create_rxbd_ring()
795 (u32)((u64)card->rxbd_ring_pbase >> 32), mwifiex_pcie_create_rxbd_ring()
796 card->rxbd_ring_size); mwifiex_pcie_create_rxbd_ring()
806 struct pcie_service_card *card = adapter->card; mwifiex_pcie_delete_rxbd_ring() local
807 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; mwifiex_pcie_delete_rxbd_ring()
811 if (card->rxbd_ring_vbase) mwifiex_pcie_delete_rxbd_ring()
812 pci_free_consistent(card->dev, card->rxbd_ring_size, mwifiex_pcie_delete_rxbd_ring()
813 card->rxbd_ring_vbase, mwifiex_pcie_delete_rxbd_ring()
814 card->rxbd_ring_pbase); mwifiex_pcie_delete_rxbd_ring()
815 card->rxbd_ring_size = 0; mwifiex_pcie_delete_rxbd_ring()
816 card->rxbd_wrptr = 0; mwifiex_pcie_delete_rxbd_ring()
817 card->rxbd_rdptr = 0 | reg->rx_rollover_ind; mwifiex_pcie_delete_rxbd_ring()
818 card->rxbd_ring_vbase = NULL; mwifiex_pcie_delete_rxbd_ring()
819 card->rxbd_ring_pbase = 0; mwifiex_pcie_delete_rxbd_ring()
829 struct pcie_service_card *card = adapter->card; mwifiex_pcie_create_evtbd_ring() local
830 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; mwifiex_pcie_create_evtbd_ring()
837 card->evtbd_wrptr = 0; mwifiex_pcie_create_evtbd_ring()
838 card->evtbd_rdptr = reg->evt_rollover_ind; mwifiex_pcie_create_evtbd_ring()
840 card->evtbd_ring_size = sizeof(struct mwifiex_evt_buf_desc) * mwifiex_pcie_create_evtbd_ring()
844 card->evtbd_ring_size); mwifiex_pcie_create_evtbd_ring()
845 card->evtbd_ring_vbase = pci_alloc_consistent(card->dev, mwifiex_pcie_create_evtbd_ring()
846 card->evtbd_ring_size, mwifiex_pcie_create_evtbd_ring()
847 &card->evtbd_ring_pbase); mwifiex_pcie_create_evtbd_ring()
848 if (!card->evtbd_ring_vbase) { mwifiex_pcie_create_evtbd_ring()
851 card->evtbd_ring_size); mwifiex_pcie_create_evtbd_ring()
857 card->evtbd_ring_vbase, (u32)card->evtbd_ring_pbase, mwifiex_pcie_create_evtbd_ring()
858 (u32)((u64)card->evtbd_ring_pbase >> 32), mwifiex_pcie_create_evtbd_ring()
859 card->evtbd_ring_size); mwifiex_pcie_create_evtbd_ring()
869 struct pcie_service_card *card = adapter->card; mwifiex_pcie_delete_evtbd_ring() local
870 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; mwifiex_pcie_delete_evtbd_ring()
874 if (card->evtbd_ring_vbase) mwifiex_pcie_delete_evtbd_ring()
875 pci_free_consistent(card->dev, card->evtbd_ring_size, mwifiex_pcie_delete_evtbd_ring()
876 card->evtbd_ring_vbase, mwifiex_pcie_delete_evtbd_ring()
877 card->evtbd_ring_pbase); mwifiex_pcie_delete_evtbd_ring()
878 card->evtbd_wrptr = 0; mwifiex_pcie_delete_evtbd_ring()
879 card->evtbd_rdptr = 0 | reg->evt_rollover_ind; mwifiex_pcie_delete_evtbd_ring()
880 card->evtbd_ring_size = 0; mwifiex_pcie_delete_evtbd_ring()
881 card->evtbd_ring_vbase = NULL; mwifiex_pcie_delete_evtbd_ring()
882 card->evtbd_ring_pbase = 0; mwifiex_pcie_delete_evtbd_ring()
892 struct pcie_service_card *card = adapter->card; mwifiex_pcie_alloc_cmdrsp_buf() local
907 card->cmdrsp_buf = skb; mwifiex_pcie_alloc_cmdrsp_buf()
917 struct pcie_service_card *card; mwifiex_pcie_delete_cmdrsp_buf() local
922 card = adapter->card; mwifiex_pcie_delete_cmdrsp_buf()
924 if (card && card->cmdrsp_buf) { mwifiex_pcie_delete_cmdrsp_buf()
925 mwifiex_unmap_pci_memory(adapter, card->cmdrsp_buf, mwifiex_pcie_delete_cmdrsp_buf()
927 dev_kfree_skb_any(card->cmdrsp_buf); mwifiex_pcie_delete_cmdrsp_buf()
930 if (card && card->cmd_buf) { mwifiex_pcie_delete_cmdrsp_buf()
931 mwifiex_unmap_pci_memory(adapter, card->cmd_buf, mwifiex_pcie_delete_cmdrsp_buf()
942 struct pcie_service_card *card = adapter->card; mwifiex_pcie_alloc_sleep_cookie_buf() local
944 card->sleep_cookie_vbase = pci_alloc_consistent(card->dev, sizeof(u32), mwifiex_pcie_alloc_sleep_cookie_buf()
945 &card->sleep_cookie_pbase); mwifiex_pcie_alloc_sleep_cookie_buf()
946 if (!card->sleep_cookie_vbase) { mwifiex_pcie_alloc_sleep_cookie_buf()
951 *(u32 *)card->sleep_cookie_vbase = FW_AWAKE_COOKIE; mwifiex_pcie_alloc_sleep_cookie_buf()
954 *((u32 *)card->sleep_cookie_vbase)); mwifiex_pcie_alloc_sleep_cookie_buf()
964 struct pcie_service_card *card; mwifiex_pcie_delete_sleep_cookie_buf() local
969 card = adapter->card; mwifiex_pcie_delete_sleep_cookie_buf()
971 if (card && card->sleep_cookie_vbase) { mwifiex_pcie_delete_sleep_cookie_buf()
972 pci_free_consistent(card->dev, sizeof(u32), mwifiex_pcie_delete_sleep_cookie_buf()
973 card->sleep_cookie_vbase, mwifiex_pcie_delete_sleep_cookie_buf()
974 card->sleep_cookie_pbase); mwifiex_pcie_delete_sleep_cookie_buf()
975 card->sleep_cookie_vbase = NULL; mwifiex_pcie_delete_sleep_cookie_buf()
987 struct pcie_service_card *card = adapter->card; mwifiex_clean_pcie_ring_buf() local
989 if (!mwifiex_pcie_txbd_empty(card, card->txbd_rdptr)) { mwifiex_clean_pcie_ring_buf()
990 card->txbd_flush = 1; mwifiex_clean_pcie_ring_buf()
1013 struct pcie_service_card *card = adapter->card; mwifiex_pcie_send_data_complete() local
1014 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; mwifiex_pcie_send_data_complete()
1027 card->txbd_rdptr, rdptr); mwifiex_pcie_send_data_complete()
1031 while (((card->txbd_rdptr & reg->tx_mask) != mwifiex_pcie_send_data_complete()
1033 ((card->txbd_rdptr & reg->tx_rollover_ind) != mwifiex_pcie_send_data_complete()
1035 wrdoneidx = (card->txbd_rdptr & reg->tx_mask) >> mwifiex_pcie_send_data_complete()
1038 skb = card->tx_buf_list[wrdoneidx]; mwifiex_pcie_send_data_complete()
1049 if (card->txbd_flush) mwifiex_pcie_send_data_complete()
1056 card->tx_buf_list[wrdoneidx] = NULL; mwifiex_pcie_send_data_complete()
1059 desc2 = card->txbd_ring[wrdoneidx]; mwifiex_pcie_send_data_complete()
1062 desc = card->txbd_ring[wrdoneidx]; mwifiex_pcie_send_data_complete()
1065 switch (card->dev->device) { mwifiex_pcie_send_data_complete()
1067 card->txbd_rdptr++; mwifiex_pcie_send_data_complete()
1070 card->txbd_rdptr += reg->ring_tx_start_ptr; mwifiex_pcie_send_data_complete()
1075 if ((card->txbd_rdptr & reg->tx_mask) == num_tx_buffs) mwifiex_pcie_send_data_complete()
1076 card->txbd_rdptr = ((card->txbd_rdptr & mwifiex_pcie_send_data_complete()
1084 if (card->txbd_flush) { mwifiex_pcie_send_data_complete()
1085 if (mwifiex_pcie_txbd_empty(card, card->txbd_rdptr)) mwifiex_pcie_send_data_complete()
1086 card->txbd_flush = 0; mwifiex_pcie_send_data_complete()
1105 struct pcie_service_card *card = adapter->card; mwifiex_pcie_send_data() local
1106 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; mwifiex_pcie_send_data()
1125 card->txbd_rdptr, card->txbd_wrptr); mwifiex_pcie_send_data()
1126 if (mwifiex_pcie_txbd_not_full(card)) { mwifiex_pcie_send_data()
1140 wrindx = (card->txbd_wrptr & reg->tx_mask) >> reg->tx_start_ptr; mwifiex_pcie_send_data()
1142 card->tx_buf_list[wrindx] = skb; mwifiex_pcie_send_data()
1145 desc2 = card->txbd_ring[wrindx]; mwifiex_pcie_send_data()
1153 desc = card->txbd_ring[wrindx]; mwifiex_pcie_send_data()
1160 switch (card->dev->device) { mwifiex_pcie_send_data()
1162 card->txbd_wrptr++; mwifiex_pcie_send_data()
1165 card->txbd_wrptr += reg->ring_tx_start_ptr; mwifiex_pcie_send_data()
1169 if ((card->txbd_wrptr & reg->tx_mask) == num_tx_buffs) mwifiex_pcie_send_data()
1170 card->txbd_wrptr = ((card->txbd_wrptr & mwifiex_pcie_send_data()
1174 rx_val = card->rxbd_rdptr & reg->rx_wrap_mask; mwifiex_pcie_send_data()
1177 card->txbd_wrptr | rx_val)) { mwifiex_pcie_send_data()
1183 if ((mwifiex_pcie_txbd_not_full(card)) && mwifiex_pcie_send_data()
1201 card->txbd_rdptr, card->txbd_wrptr); mwifiex_pcie_send_data()
1217 card->tx_buf_list[wrindx] = NULL; mwifiex_pcie_send_data()
1232 struct pcie_service_card *card = adapter->card; mwifiex_pcie_process_recv_data() local
1233 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; mwifiex_pcie_process_recv_data()
1251 card->rxbd_wrptr = wrptr; mwifiex_pcie_process_recv_data()
1254 (card->rxbd_rdptr & reg->rx_mask)) || mwifiex_pcie_process_recv_data()
1256 (card->rxbd_rdptr & reg->rx_rollover_ind))) { mwifiex_pcie_process_recv_data()
1261 rd_index = card->rxbd_rdptr & reg->rx_mask; mwifiex_pcie_process_recv_data()
1262 skb_data = card->rx_buf_list[rd_index]; mwifiex_pcie_process_recv_data()
1271 card->rx_buf_list[rd_index] = NULL; mwifiex_pcie_process_recv_data()
1282 rx_len, card->rxbd_rdptr, wrptr); mwifiex_pcie_process_recv_data()
1288 card->rxbd_rdptr, wrptr, rx_len); mwifiex_pcie_process_recv_data()
1317 card->rx_buf_list[rd_index] = skb_tmp; mwifiex_pcie_process_recv_data()
1320 desc2 = card->rxbd_ring[rd_index]; mwifiex_pcie_process_recv_data()
1327 desc = card->rxbd_ring[rd_index]; mwifiex_pcie_process_recv_data()
1333 if ((++card->rxbd_rdptr & reg->rx_mask) == mwifiex_pcie_process_recv_data()
1335 card->rxbd_rdptr = ((card->rxbd_rdptr & mwifiex_pcie_process_recv_data()
1340 card->rxbd_rdptr, wrptr); mwifiex_pcie_process_recv_data()
1342 tx_val = card->txbd_wrptr & reg->tx_wrap_mask; mwifiex_pcie_process_recv_data()
1345 card->rxbd_rdptr | tx_val)) { mwifiex_pcie_process_recv_data()
1361 card->rxbd_wrptr = wrptr; mwifiex_pcie_process_recv_data()
1375 struct pcie_service_card *card = adapter->card; mwifiex_pcie_send_boot_cmd() local
1376 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; mwifiex_pcie_send_boot_cmd()
1439 struct pcie_service_card *card = adapter->card; mwifiex_pcie_init_fw_port() local
1440 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; mwifiex_pcie_init_fw_port()
1441 int tx_wrap = card->txbd_wrptr & reg->tx_wrap_mask; mwifiex_pcie_init_fw_port()
1444 if (mwifiex_write_reg(adapter, reg->rx_rdptr, card->rxbd_rdptr | mwifiex_pcie_init_fw_port()
1458 struct pcie_service_card *card = adapter->card; mwifiex_pcie_send_cmd() local
1459 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; mwifiex_pcie_send_cmd()
1471 if (!card->cmdrsp_buf) { mwifiex_pcie_send_cmd()
1488 card->cmd_buf = skb; mwifiex_pcie_send_cmd()
1500 if (card->cmdrsp_buf) { mwifiex_pcie_send_cmd()
1501 cmdrsp_buf_pa = MWIFIEX_SKB_DMA_ADDR(card->cmdrsp_buf); mwifiex_pcie_send_cmd()
1522 cmd_buf_pa = MWIFIEX_SKB_DMA_ADDR(card->cmd_buf); mwifiex_pcie_send_cmd()
1542 card->cmd_buf->len)) { mwifiex_pcie_send_cmd()
1570 struct pcie_service_card *card = adapter->card; mwifiex_pcie_process_cmd_complete() local
1571 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; mwifiex_pcie_process_cmd_complete()
1572 struct sk_buff *skb = card->cmdrsp_buf; mwifiex_pcie_process_cmd_complete()
1582 if (card->cmd_buf) { mwifiex_pcie_process_cmd_complete()
1583 mwifiex_unmap_pci_memory(adapter, card->cmd_buf, mwifiex_pcie_process_cmd_complete()
1585 card->cmd_buf = NULL; mwifiex_pcie_process_cmd_complete()
1625 card->cmdrsp_buf = NULL; mwifiex_pcie_process_cmd_complete()
1653 struct pcie_service_card *card = adapter->card; mwifiex_pcie_cmdrsp_complete() local
1656 card->cmdrsp_buf = skb; mwifiex_pcie_cmdrsp_complete()
1657 skb_push(card->cmdrsp_buf, INTF_HEADER_LEN); mwifiex_pcie_cmdrsp_complete()
1671 struct pcie_service_card *card = adapter->card; mwifiex_pcie_process_event_ready() local
1672 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; mwifiex_pcie_process_event_ready()
1673 u32 rdptr = card->evtbd_rdptr & MWIFIEX_EVTBD_MASK; mwifiex_pcie_process_event_ready()
1699 card->evtbd_rdptr, wrptr); mwifiex_pcie_process_event_ready()
1700 if (((wrptr & MWIFIEX_EVTBD_MASK) != (card->evtbd_rdptr mwifiex_pcie_process_event_ready()
1703 (card->evtbd_rdptr & reg->evt_rollover_ind))) { mwifiex_pcie_process_event_ready()
1709 skb_cmd = card->evt_buf_list[rdptr]; mwifiex_pcie_process_event_ready()
1714 card->evt_buf_list[rdptr] = NULL; mwifiex_pcie_process_event_ready()
1715 desc = card->evtbd_ring[rdptr]; mwifiex_pcie_process_event_ready()
1758 struct pcie_service_card *card = adapter->card; mwifiex_pcie_event_complete() local
1759 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; mwifiex_pcie_event_complete()
1761 u32 rdptr = card->evtbd_rdptr & MWIFIEX_EVTBD_MASK; mwifiex_pcie_event_complete()
1781 if (!card->evt_buf_list[rdptr]) { mwifiex_pcie_event_complete()
1787 card->evt_buf_list[rdptr] = skb; mwifiex_pcie_event_complete()
1788 desc = card->evtbd_ring[rdptr]; mwifiex_pcie_event_complete()
1796 rdptr, card->evt_buf_list[rdptr], skb); mwifiex_pcie_event_complete()
1799 if ((++card->evtbd_rdptr & MWIFIEX_EVTBD_MASK) == MWIFIEX_MAX_EVT_BD) { mwifiex_pcie_event_complete()
1800 card->evtbd_rdptr = ((card->evtbd_rdptr & mwifiex_pcie_event_complete()
1806 card->evtbd_rdptr, wrptr); mwifiex_pcie_event_complete()
1810 card->evtbd_rdptr)) { mwifiex_pcie_event_complete()
1823 * This function downloads the firmware to the card.
1825 * Firmware is downloaded to the card in blocks. Every block download
1839 struct pcie_service_card *card = adapter->card; mwifiex_prog_fw_w_helper() local
1840 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; mwifiex_prog_fw_w_helper()
1918 tx_blocks = (txlen + card->pcie.blksz_fw_dl - 1) / mwifiex_prog_fw_w_helper()
1919 card->pcie.blksz_fw_dl; mwifiex_prog_fw_w_helper()
1926 skb_trim(skb, tx_blocks * card->pcie.blksz_fw_dl); mwifiex_prog_fw_w_helper()
1967 * This function checks the firmware status in card.
1976 struct pcie_service_card *card = adapter->card; mwifiex_check_fw_status() local
1977 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; mwifiex_check_fw_status()
2031 * This function reads the interrupt status from card.
2082 struct pcie_service_card *card; mwifiex_pcie_interrupt() local
2090 card = pci_get_drvdata(pdev); mwifiex_pcie_interrupt()
2091 if (!card || !card->adapter) { mwifiex_pcie_interrupt()
2092 pr_debug("info: %s: card=%p adapter=%p\n", __func__, card, mwifiex_pcie_interrupt()
2093 card ? card->adapter : NULL); mwifiex_pcie_interrupt()
2096 adapter = card->adapter; mwifiex_pcie_interrupt()
2118 * In case of Rx packets received, the packets are uploaded from card to
2198 * This function downloads data from driver to card.
2200 * Both commands and data packets are transferred to the card by this
2230 struct pcie_service_card *card = adapter->card; mwifiex_pcie_rdwr_firmware() local
2231 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; mwifiex_pcie_rdwr_firmware()
2265 struct pcie_service_card *card = adapter->card; mwifiex_pcie_fw_dump_work() local
2266 const struct mwifiex_pcie_card_reg *creg = card->pcie.reg; mwifiex_pcie_fw_dump_work()
2274 if (!card->pcie.can_dump_fw) mwifiex_pcie_fw_dump_work()
2408 struct pcie_service_card *card = adapter->card; mwifiex_pcie_init() local
2410 struct pci_dev *pdev = card->dev; mwifiex_pcie_init()
2411 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; mwifiex_pcie_init()
2413 pci_set_drvdata(pdev, card); mwifiex_pcie_init()
2439 card->pci_mmap = pci_iomap(pdev, 0, 0); mwifiex_pcie_init()
2440 if (!card->pci_mmap) { mwifiex_pcie_init()
2450 card->pci_mmap1 = pci_iomap(pdev, 2, 0); mwifiex_pcie_init()
2451 if (!card->pci_mmap1) { mwifiex_pcie_init()
2459 card->pci_mmap, card->pci_mmap1); mwifiex_pcie_init()
2461 card->cmdrsp_buf = NULL; mwifiex_pcie_init()
2479 card->sleep_cookie_vbase = NULL; mwifiex_pcie_init()
2492 pci_iounmap(pdev, card->pci_mmap1); mwifiex_pcie_init()
2496 pci_iounmap(pdev, card->pci_mmap); mwifiex_pcie_init()
2508 * This function cleans up the allocated card buffers.
2519 struct pcie_service_card *card = adapter->card; mwifiex_pcie_cleanup() local
2520 struct pci_dev *pdev = card->dev; mwifiex_pcie_cleanup()
2521 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; mwifiex_pcie_cleanup()
2531 pci_iounmap(pdev, card->pci_mmap); mwifiex_pcie_cleanup()
2532 pci_iounmap(pdev, card->pci_mmap1); mwifiex_pcie_cleanup()
2538 kfree(card); mwifiex_pcie_cleanup()
2549 struct pcie_service_card *card = adapter->card; mwifiex_register_dev() local
2550 struct pci_dev *pdev = card->dev; mwifiex_register_dev()
2552 /* save adapter pointer in card */ mwifiex_register_dev()
2553 card->adapter = adapter; mwifiex_register_dev()
2559 adapter->card = NULL; mwifiex_register_dev()
2564 adapter->tx_buf_size = card->pcie.tx_buf_size; mwifiex_register_dev()
2567 strcpy(adapter->fw_name, card->pcie.firmware); mwifiex_register_dev()
2568 adapter->ext_scan = card->pcie.can_ext_scan; mwifiex_register_dev()
2581 struct pcie_service_card *card = adapter->card; mwifiex_unregister_dev() local
2584 if (card) { mwifiex_unregister_dev()
2586 free_irq(card->dev->irq, card->dev); mwifiex_unregister_dev()
2588 reg = card->pcie.reg; mwifiex_unregister_dev()
2596 card->cmdrsp_buf = NULL; mwifiex_unregister_dev()
2637 /* Clear the flag in case user removes the card. */ mwifiex_pcie_init_module()
H A Dsdio.c36 * the card from the slot. The driver handles these 2 cases
40 * If the card is removed, there is no need to send these command.
43 * scenarios. This flag is initialized as FALSE in case the card
76 * the card structure, enables SDIO function number and initiates the
84 struct sdio_mmc_card *card = NULL; mwifiex_sdio_probe() local
89 card = kzalloc(sizeof(struct sdio_mmc_card), GFP_KERNEL); mwifiex_sdio_probe()
90 if (!card) mwifiex_sdio_probe()
93 card->func = func; mwifiex_sdio_probe()
95 func->card->quirks |= MMC_QUIRK_BLKSZ_FOR_BYTE_MODE; mwifiex_sdio_probe()
100 card->firmware = data->firmware; mwifiex_sdio_probe()
101 card->reg = data->reg; mwifiex_sdio_probe()
102 card->max_ports = data->max_ports; mwifiex_sdio_probe()
103 card->mp_agg_pkt_limit = data->mp_agg_pkt_limit; mwifiex_sdio_probe()
104 card->supports_sdio_new_mode = data->supports_sdio_new_mode; mwifiex_sdio_probe()
105 card->has_control_mask = data->has_control_mask; mwifiex_sdio_probe()
106 card->tx_buf_size = data->tx_buf_size; mwifiex_sdio_probe()
107 card->mp_tx_agg_buf_size = data->mp_tx_agg_buf_size; mwifiex_sdio_probe()
108 card->mp_rx_agg_buf_size = data->mp_rx_agg_buf_size; mwifiex_sdio_probe()
109 card->can_dump_fw = data->can_dump_fw; mwifiex_sdio_probe()
110 card->can_auto_tdls = data->can_auto_tdls; mwifiex_sdio_probe()
111 card->can_ext_scan = data->can_ext_scan; mwifiex_sdio_probe()
120 kfree(card); mwifiex_sdio_probe()
124 if (mwifiex_add_card(card, &add_remove_card_sem, &sdio_ops, mwifiex_sdio_probe()
126 pr_err("%s: add card failed\n", __func__); mwifiex_sdio_probe()
127 kfree(card); mwifiex_sdio_probe()
142 * methods. Failing that the kernel simply removes the whole card.
150 struct sdio_mmc_card *card; mwifiex_sdio_resume() local
156 card = sdio_get_drvdata(func); mwifiex_sdio_resume()
157 if (!card || !card->adapter) { mwifiex_sdio_resume()
158 pr_err("resume: invalid card or adapter\n"); mwifiex_sdio_resume()
166 adapter = card->adapter; mwifiex_sdio_resume()
185 * This function removes the interface and frees up the card structure.
190 struct sdio_mmc_card *card; mwifiex_sdio_remove() local
196 card = sdio_get_drvdata(func); mwifiex_sdio_remove()
197 if (!card) mwifiex_sdio_remove()
200 adapter = card->adapter; mwifiex_sdio_remove()
215 mwifiex_remove_card(card->adapter, &add_remove_card_sem); mwifiex_sdio_remove()
223 * methods. Failing that the kernel simply removes the whole card.
231 struct sdio_mmc_card *card; mwifiex_sdio_suspend() local
246 card = sdio_get_drvdata(func); mwifiex_sdio_suspend()
247 if (!card || !card->adapter) { mwifiex_sdio_suspend()
248 pr_err("suspend: invalid card or adapter\n"); mwifiex_sdio_suspend()
256 adapter = card->adapter; mwifiex_sdio_suspend()
324 /* Write data into SDIO card register. Caller claims SDIO device. */
334 * This function writes data into SDIO card register.
339 struct sdio_mmc_card *card = adapter->card; mwifiex_write_reg() local
342 sdio_claim_host(card->func); mwifiex_write_reg()
343 ret = mwifiex_write_reg_locked(card->func, reg, data); mwifiex_write_reg()
344 sdio_release_host(card->func); mwifiex_write_reg()
350 * This function reads data from SDIO card register.
355 struct sdio_mmc_card *card = adapter->card; mwifiex_read_reg() local
359 sdio_claim_host(card->func); mwifiex_read_reg()
360 val = sdio_readb(card->func, reg, &ret); mwifiex_read_reg()
361 sdio_release_host(card->func); mwifiex_read_reg()
369 * This function writes multiple data into SDIO card memory.
377 struct sdio_mmc_card *card = adapter->card; mwifiex_write_data_sync() local
394 sdio_claim_host(card->func); mwifiex_write_data_sync()
396 ret = sdio_writesb(card->func, ioport, buffer, blk_cnt * blk_size); mwifiex_write_data_sync()
398 sdio_release_host(card->func); mwifiex_write_data_sync()
404 * This function reads multiple data from SDIO card memory.
409 struct sdio_mmc_card *card = adapter->card; mwifiex_read_data_sync() local
419 sdio_claim_host(card->func); mwifiex_read_data_sync()
421 ret = sdio_readsb(card->func, buffer, ioport, blk_cnt * blk_size); mwifiex_read_data_sync()
424 sdio_release_host(card->func); mwifiex_read_data_sync()
430 * This function wakes up the card.
432 * A host power up command is written to the card configuration
433 * register to wake up the card.
443 * This function is called after the card has woken up.
445 * The card configuration register is reset.
461 struct sdio_mmc_card *card = adapter->card; mwifiex_init_sdio_new_mode() local
466 if (mwifiex_read_reg(adapter, card->reg->card_cfg_2_1_reg, &reg)) mwifiex_init_sdio_new_mode()
468 if (mwifiex_write_reg(adapter, card->reg->card_cfg_2_1_reg, mwifiex_init_sdio_new_mode()
473 if (mwifiex_read_reg(adapter, card->reg->cmd_cfg_0, &reg)) mwifiex_init_sdio_new_mode()
475 if (mwifiex_write_reg(adapter, card->reg->cmd_cfg_0, mwifiex_init_sdio_new_mode()
482 if (mwifiex_read_reg(adapter, card->reg->cmd_cfg_1, &reg)) mwifiex_init_sdio_new_mode()
484 if (mwifiex_write_reg(adapter, card->reg->cmd_cfg_1, mwifiex_init_sdio_new_mode()
501 struct sdio_mmc_card *card = adapter->card; mwifiex_init_sdio_ioport() local
505 if (card->supports_sdio_new_mode) { mwifiex_init_sdio_ioport()
512 if (!mwifiex_read_reg(adapter, card->reg->io_port_0_reg, &reg)) mwifiex_init_sdio_ioport()
517 if (!mwifiex_read_reg(adapter, card->reg->io_port_1_reg, &reg)) mwifiex_init_sdio_ioport()
522 if (!mwifiex_read_reg(adapter, card->reg->io_port_2_reg, &reg)) mwifiex_init_sdio_ioport()
530 if (!mwifiex_read_reg(adapter, card->reg->host_int_rsr_reg, &reg)) mwifiex_init_sdio_ioport()
531 mwifiex_write_reg(adapter, card->reg->host_int_rsr_reg, mwifiex_init_sdio_ioport()
532 reg | card->reg->sdio_int_mask); mwifiex_init_sdio_ioport()
537 if (!mwifiex_read_reg(adapter, card->reg->card_misc_cfg_reg, &reg)) mwifiex_init_sdio_ioport()
538 mwifiex_write_reg(adapter, card->reg->card_misc_cfg_reg, mwifiex_init_sdio_ioport()
547 * This function sends data to the card.
583 struct sdio_mmc_card *card = adapter->card; mwifiex_get_rd_port() local
584 const struct mwifiex_sdio_card_reg *reg = card->reg; mwifiex_get_rd_port()
585 u32 rd_bitmap = card->mp_rd_bitmap; mwifiex_get_rd_port()
589 if (card->supports_sdio_new_mode) { mwifiex_get_rd_port()
597 if ((card->has_control_mask) && mwifiex_get_rd_port()
598 (card->mp_rd_bitmap & CTRL_PORT_MASK)) { mwifiex_get_rd_port()
599 card->mp_rd_bitmap &= (u32) (~CTRL_PORT_MASK); mwifiex_get_rd_port()
602 *port, card->mp_rd_bitmap); mwifiex_get_rd_port()
606 if (!(card->mp_rd_bitmap & (1 << card->curr_rd_port))) mwifiex_get_rd_port()
610 card->mp_rd_bitmap &= (u32)(~(1 << card->curr_rd_port)); mwifiex_get_rd_port()
611 *port = card->curr_rd_port; mwifiex_get_rd_port()
613 if (++card->curr_rd_port == card->max_ports) mwifiex_get_rd_port()
614 card->curr_rd_port = reg->start_rd_port; mwifiex_get_rd_port()
618 *port, rd_bitmap, card->mp_rd_bitmap); mwifiex_get_rd_port()
632 struct sdio_mmc_card *card = adapter->card; mwifiex_get_wr_port_data() local
633 const struct mwifiex_sdio_card_reg *reg = card->reg; mwifiex_get_wr_port_data()
634 u32 wr_bitmap = card->mp_wr_bitmap; mwifiex_get_wr_port_data()
638 if (!(wr_bitmap & card->mp_data_port_mask)) { mwifiex_get_wr_port_data()
643 if (card->mp_wr_bitmap & (1 << card->curr_wr_port)) { mwifiex_get_wr_port_data()
644 card->mp_wr_bitmap &= (u32) (~(1 << card->curr_wr_port)); mwifiex_get_wr_port_data()
645 *port = card->curr_wr_port; mwifiex_get_wr_port_data()
646 if (++card->curr_wr_port == card->mp_end_port) mwifiex_get_wr_port_data()
647 card->curr_wr_port = reg->start_wr_port; mwifiex_get_wr_port_data()
653 if ((card->has_control_mask) && (*port == CTRL_PORT)) { mwifiex_get_wr_port_data()
656 *port, card->curr_wr_port, wr_bitmap, mwifiex_get_wr_port_data()
657 card->mp_wr_bitmap); mwifiex_get_wr_port_data()
662 *port, wr_bitmap, card->mp_wr_bitmap); mwifiex_get_wr_port_data()
668 * This function polls the card status.
673 struct sdio_mmc_card *card = adapter->card; mwifiex_sdio_poll_card_status() local
678 if (mwifiex_read_reg(adapter, card->reg->poll_reg, &cs)) mwifiex_sdio_poll_card_status()
686 dev_err(adapter->dev, "poll card status failed, tries = %d\n", tries); mwifiex_sdio_poll_card_status()
697 struct sdio_mmc_card *card = adapter->card; mwifiex_sdio_read_fw_status() local
698 const struct mwifiex_sdio_card_reg *reg = card->reg; mwifiex_sdio_read_fw_status()
716 * written back to the card host interrupt mask register.
720 struct sdio_mmc_card *card = adapter->card; mwifiex_sdio_disable_host_int() local
721 struct sdio_func *func = card->func; mwifiex_sdio_disable_host_int()
724 mwifiex_write_reg_locked(func, card->reg->host_int_mask_reg, 0); mwifiex_sdio_disable_host_int()
730 * This function reads the interrupt status from card.
734 struct sdio_mmc_card *card = adapter->card; mwifiex_interrupt_status() local
738 if (mwifiex_read_data_sync(adapter, card->mp_regs, mwifiex_interrupt_status()
739 card->reg->max_mp_regs, mwifiex_interrupt_status()
745 sdio_ireg = card->mp_regs[card->reg->host_int_status_reg]; mwifiex_interrupt_status()
771 struct sdio_mmc_card *card; mwifiex_sdio_interrupt() local
773 card = sdio_get_drvdata(func); mwifiex_sdio_interrupt()
774 if (!card || !card->adapter) { mwifiex_sdio_interrupt()
775 pr_debug("int: func=%p card=%p adapter=%p\n", mwifiex_sdio_interrupt()
776 func, card, card ? card->adapter : NULL); mwifiex_sdio_interrupt()
779 adapter = card->adapter; mwifiex_sdio_interrupt()
791 * The host interrupt enable mask is written to the card
796 struct sdio_mmc_card *card = adapter->card; mwifiex_sdio_enable_host_int() local
797 struct sdio_func *func = card->func; mwifiex_sdio_enable_host_int()
810 ret = mwifiex_write_reg_locked(func, card->reg->host_int_mask_reg, mwifiex_sdio_enable_host_int()
811 card->reg->host_int_enable); mwifiex_sdio_enable_host_int()
823 * This function sends a data buffer to the card.
858 * This function downloads the firmware to the card.
860 * Firmware is downloaded to the card in blocks. Every block download
867 struct sdio_mmc_card *card = adapter->card; mwifiex_prog_fw_w_helper() local
868 const struct mwifiex_sdio_card_reg *reg = card->reg; mwifiex_prog_fw_w_helper()
1004 * This function checks the firmware status in card.
1011 struct sdio_mmc_card *card = adapter->card; mwifiex_check_fw_status() local
1033 (adapter, card->reg->status_reg_0, &winner_status)) mwifiex_check_fw_status()
1190 * This function transfers received packets from card to driver, performing
1201 struct sdio_mmc_card *card = adapter->card; mwifiex_sdio_card_to_host_mp_aggr() local
1211 if ((card->has_control_mask) && (port == CTRL_PORT)) { mwifiex_sdio_card_to_host_mp_aggr()
1220 if (!card->mpa_rx.enabled) { mwifiex_sdio_card_to_host_mp_aggr()
1228 if ((!card->has_control_mask && (card->mp_rd_bitmap & mwifiex_sdio_card_to_host_mp_aggr()
1229 card->reg->data_port_mask)) || mwifiex_sdio_card_to_host_mp_aggr()
1230 (card->has_control_mask && (card->mp_rd_bitmap & mwifiex_sdio_card_to_host_mp_aggr()
1235 if (MP_RX_AGGR_IN_PROGRESS(card)) { mwifiex_sdio_card_to_host_mp_aggr()
1236 if (MP_RX_AGGR_BUF_HAS_ROOM(card, rx_len)) { mwifiex_sdio_card_to_host_mp_aggr()
1252 if (MP_RX_AGGR_IN_PROGRESS(card)) { mwifiex_sdio_card_to_host_mp_aggr()
1254 if (MP_RX_AGGR_BUF_HAS_ROOM(card, rx_len)) mwifiex_sdio_card_to_host_mp_aggr()
1267 mp_rx_aggr_setup(card, rx_len, port); mwifiex_sdio_card_to_host_mp_aggr()
1269 if (MP_RX_AGGR_PKT_LIMIT_REACHED(card) || mwifiex_sdio_card_to_host_mp_aggr()
1270 mp_rx_aggr_port_limit_reached(card)) { mwifiex_sdio_card_to_host_mp_aggr()
1281 card->mpa_rx.pkt_cnt); mwifiex_sdio_card_to_host_mp_aggr()
1283 if (card->supports_sdio_new_mode) { mwifiex_sdio_card_to_host_mp_aggr()
1287 for (i = 0, port_count = 0; i < card->max_ports; i++) mwifiex_sdio_card_to_host_mp_aggr()
1288 if (card->mpa_rx.ports & BIT(i)) mwifiex_sdio_card_to_host_mp_aggr()
1296 (port_count << 8)) + card->mpa_rx.start_port; mwifiex_sdio_card_to_host_mp_aggr()
1299 (card->mpa_rx.ports << 4)) + mwifiex_sdio_card_to_host_mp_aggr()
1300 card->mpa_rx.start_port; mwifiex_sdio_card_to_host_mp_aggr()
1303 if (mwifiex_read_data_sync(adapter, card->mpa_rx.buf, mwifiex_sdio_card_to_host_mp_aggr()
1304 card->mpa_rx.buf_len, mport, 1)) mwifiex_sdio_card_to_host_mp_aggr()
1307 curr_ptr = card->mpa_rx.buf; mwifiex_sdio_card_to_host_mp_aggr()
1309 for (pind = 0; pind < card->mpa_rx.pkt_cnt; pind++) { mwifiex_sdio_card_to_host_mp_aggr()
1310 u32 *len_arr = card->mpa_rx.len_arr; mwifiex_sdio_card_to_host_mp_aggr()
1352 MP_RX_AGGR_BUF_RESET(card); mwifiex_sdio_card_to_host_mp_aggr()
1365 card->mpa_rx.buf, rx_len, mwifiex_sdio_card_to_host_mp_aggr()
1391 mp_rx_aggr_setup(card, rx_len, port); mwifiex_sdio_card_to_host_mp_aggr()
1396 if (MP_RX_AGGR_IN_PROGRESS(card)) mwifiex_sdio_card_to_host_mp_aggr()
1397 MP_RX_AGGR_BUF_RESET(card); mwifiex_sdio_card_to_host_mp_aggr()
1418 * In case of Rx packets received, the packets are uploaded from card to
1423 struct sdio_mmc_card *card = adapter->card; mwifiex_process_int_status() local
1424 const struct mwifiex_sdio_card_reg *reg = card->reg; mwifiex_process_int_status()
1453 rx_len = card->mp_regs[reg->cmd_rd_len_1] << 8; mwifiex_process_int_status()
1454 rx_len |= (u16)card->mp_regs[reg->cmd_rd_len_0]; mwifiex_process_int_status()
1488 bitmap = (u32) card->mp_regs[reg->wr_bitmap_l]; mwifiex_process_int_status()
1489 bitmap |= ((u32) card->mp_regs[reg->wr_bitmap_u]) << 8; mwifiex_process_int_status()
1490 if (card->supports_sdio_new_mode) { mwifiex_process_int_status()
1492 ((u32) card->mp_regs[reg->wr_bitmap_1l]) << 16; mwifiex_process_int_status()
1494 ((u32) card->mp_regs[reg->wr_bitmap_1u]) << 24; mwifiex_process_int_status()
1496 card->mp_wr_bitmap = bitmap; mwifiex_process_int_status()
1499 card->mp_wr_bitmap); mwifiex_process_int_status()
1501 (card->mp_wr_bitmap & card->mp_data_port_mask)) { mwifiex_process_int_status()
1511 if (card->has_control_mask && adapter->cmd_sent) { mwifiex_process_int_status()
1514 card->mp_wr_bitmap |= mwifiex_process_int_status()
1515 (u32) card->mp_regs[reg->wr_bitmap_l] & CTRL_PORT_MASK; mwifiex_process_int_status()
1516 if (card->mp_wr_bitmap & CTRL_PORT_MASK) mwifiex_process_int_status()
1523 bitmap = (u32) card->mp_regs[reg->rd_bitmap_l]; mwifiex_process_int_status()
1524 bitmap |= ((u32) card->mp_regs[reg->rd_bitmap_u]) << 8; mwifiex_process_int_status()
1525 if (card->supports_sdio_new_mode) { mwifiex_process_int_status()
1527 ((u32) card->mp_regs[reg->rd_bitmap_1l]) << 16; mwifiex_process_int_status()
1529 ((u32) card->mp_regs[reg->rd_bitmap_1u]) << 24; mwifiex_process_int_status()
1531 card->mp_rd_bitmap = bitmap; mwifiex_process_int_status()
1533 card->mp_rd_bitmap); mwifiex_process_int_status()
1544 rx_len = ((u16) card->mp_regs[len_reg_u]) << 8; mwifiex_process_int_status()
1545 rx_len |= (u16) card->mp_regs[len_reg_l]; mwifiex_process_int_status()
1553 card->mpa_rx.buf_size) { mwifiex_process_int_status()
1595 * the aggregated packet to card.
1598 * buffer and then downloaded to the card. Previous unsent packets in the
1603 * The function will only download the packet to the card when aggregation
1611 struct sdio_mmc_card *card = adapter->card; mwifiex_host_to_card_mp_aggr() local
1619 if (!card->mpa_tx.enabled || mwifiex_host_to_card_mp_aggr()
1620 (card->has_control_mask && (port == CTRL_PORT)) || mwifiex_host_to_card_mp_aggr()
1621 (card->supports_sdio_new_mode && (port == CMD_PORT_SLCT))) { mwifiex_host_to_card_mp_aggr()
1634 if (MP_TX_AGGR_IN_PROGRESS(card)) { mwifiex_host_to_card_mp_aggr()
1635 if (MP_TX_AGGR_BUF_HAS_ROOM(card, pkt_len)) { mwifiex_host_to_card_mp_aggr()
1638 if (!(card->mp_wr_bitmap & mwifiex_host_to_card_mp_aggr()
1639 (1 << card->curr_wr_port)) || mwifiex_host_to_card_mp_aggr()
1641 card, pkt_len + next_pkt_len)) mwifiex_host_to_card_mp_aggr()
1647 if (!(card->mp_wr_bitmap & mwifiex_host_to_card_mp_aggr()
1648 (1 << card->curr_wr_port))) mwifiex_host_to_card_mp_aggr()
1654 if (MP_TX_AGGR_BUF_HAS_ROOM(card, pkt_len) && mwifiex_host_to_card_mp_aggr()
1655 (card->mp_wr_bitmap & (1 << card->curr_wr_port))) mwifiex_host_to_card_mp_aggr()
1665 if (MP_TX_AGGR_IN_PROGRESS(card)) { mwifiex_host_to_card_mp_aggr()
1669 if (MP_TX_AGGR_BUF_HAS_ROOM(card, pkt_len)) mwifiex_host_to_card_mp_aggr()
1682 MP_TX_AGGR_BUF_PUT(card, payload, pkt_len, port); mwifiex_host_to_card_mp_aggr()
1684 if (MP_TX_AGGR_PKT_LIMIT_REACHED(card) || mwifiex_host_to_card_mp_aggr()
1685 mp_tx_aggr_port_limit_reached(card)) mwifiex_host_to_card_mp_aggr()
1693 card->mpa_tx.start_port, card->mpa_tx.ports); mwifiex_host_to_card_mp_aggr()
1694 if (card->supports_sdio_new_mode) { mwifiex_host_to_card_mp_aggr()
1698 for (i = 0, port_count = 0; i < card->max_ports; i++) mwifiex_host_to_card_mp_aggr()
1699 if (card->mpa_tx.ports & BIT(i)) mwifiex_host_to_card_mp_aggr()
1707 (port_count << 8)) + card->mpa_tx.start_port; mwifiex_host_to_card_mp_aggr()
1710 (card->mpa_tx.ports << 4)) + mwifiex_host_to_card_mp_aggr()
1711 card->mpa_tx.start_port; mwifiex_host_to_card_mp_aggr()
1714 ret = mwifiex_write_data_to_card(adapter, card->mpa_tx.buf, mwifiex_host_to_card_mp_aggr()
1715 card->mpa_tx.buf_len, mport); mwifiex_host_to_card_mp_aggr()
1717 MP_TX_AGGR_BUF_RESET(card); mwifiex_host_to_card_mp_aggr()
1731 MP_TX_AGGR_BUF_PUT(card, payload, pkt_len, port); mwifiex_host_to_card_mp_aggr()
1738 * This function downloads data from driver to card.
1740 * Both commands and data packets are transferred to the card by this
1751 struct sdio_mmc_card *card = adapter->card; mwifiex_sdio_host_to_card() local
1787 if (card->supports_sdio_new_mode) mwifiex_sdio_host_to_card()
1791 /* Transfer data to card */ mwifiex_sdio_host_to_card()
1808 card->curr_wr_port = port; mwifiex_sdio_host_to_card()
1809 card->mp_wr_bitmap |= (u32)(1 << card->curr_wr_port); mwifiex_sdio_host_to_card()
1813 if (!(card->mp_wr_bitmap & (1 << card->curr_wr_port))) mwifiex_sdio_host_to_card()
1829 struct sdio_mmc_card *card = adapter->card; mwifiex_alloc_sdio_mpa_buffers() local
1833 card->mpa_tx.buf = kzalloc(mpa_tx_buf_size, GFP_KERNEL); mwifiex_alloc_sdio_mpa_buffers()
1834 if (!card->mpa_tx.buf) { mwifiex_alloc_sdio_mpa_buffers()
1839 card->mpa_tx.buf_size = mpa_tx_buf_size; mwifiex_alloc_sdio_mpa_buffers()
1843 card->mpa_rx.buf = kzalloc(rx_buf_size, GFP_KERNEL); mwifiex_alloc_sdio_mpa_buffers()
1844 if (!card->mpa_rx.buf) { mwifiex_alloc_sdio_mpa_buffers()
1849 card->mpa_rx.buf_size = rx_buf_size; mwifiex_alloc_sdio_mpa_buffers()
1853 kfree(card->mpa_tx.buf); mwifiex_alloc_sdio_mpa_buffers()
1854 kfree(card->mpa_rx.buf); mwifiex_alloc_sdio_mpa_buffers()
1869 struct sdio_mmc_card *card = adapter->card; mwifiex_unregister_dev() local
1871 if (adapter->card) { mwifiex_unregister_dev()
1872 sdio_claim_host(card->func); mwifiex_unregister_dev()
1873 sdio_disable_func(card->func); mwifiex_unregister_dev()
1874 sdio_release_host(card->func); mwifiex_unregister_dev()
1886 struct sdio_mmc_card *card = adapter->card; mwifiex_register_dev() local
1887 struct sdio_func *func = card->func; mwifiex_register_dev()
1889 /* save adapter pointer in card */ mwifiex_register_dev()
1890 card->adapter = adapter; mwifiex_register_dev()
1891 adapter->tx_buf_size = card->tx_buf_size; mwifiex_register_dev()
1896 ret = sdio_set_block_size(card->func, MWIFIEX_SDIO_BLOCK_SIZE); mwifiex_register_dev()
1906 strcpy(adapter->fw_name, card->firmware); mwifiex_register_dev()
1921 * - Initialize SDIO variables in card
1927 struct sdio_mmc_card *card = adapter->card; mwifiex_init_sdio() local
1928 const struct mwifiex_sdio_card_reg *reg = card->reg; mwifiex_init_sdio()
1932 sdio_set_drvdata(card->func, card); mwifiex_init_sdio()
1939 mwifiex_read_reg(adapter, card->reg->host_int_status_reg, &sdio_ireg); mwifiex_init_sdio()
1944 /* Initialize SDIO variables in card */ mwifiex_init_sdio()
1945 card->mp_rd_bitmap = 0; mwifiex_init_sdio()
1946 card->mp_wr_bitmap = 0; mwifiex_init_sdio()
1947 card->curr_rd_port = reg->start_rd_port; mwifiex_init_sdio()
1948 card->curr_wr_port = reg->start_wr_port; mwifiex_init_sdio()
1950 card->mp_data_port_mask = reg->data_port_mask; mwifiex_init_sdio()
1952 card->mpa_tx.buf_len = 0; mwifiex_init_sdio()
1953 card->mpa_tx.pkt_cnt = 0; mwifiex_init_sdio()
1954 card->mpa_tx.start_port = 0; mwifiex_init_sdio()
1956 card->mpa_tx.enabled = 1; mwifiex_init_sdio()
1957 card->mpa_tx.pkt_aggr_limit = card->mp_agg_pkt_limit; mwifiex_init_sdio()
1959 card->mpa_rx.buf_len = 0; mwifiex_init_sdio()
1960 card->mpa_rx.pkt_cnt = 0; mwifiex_init_sdio()
1961 card->mpa_rx.start_port = 0; mwifiex_init_sdio()
1963 card->mpa_rx.enabled = 1; mwifiex_init_sdio()
1964 card->mpa_rx.pkt_aggr_limit = card->mp_agg_pkt_limit; mwifiex_init_sdio()
1967 card->mp_regs = kzalloc(reg->max_mp_regs, GFP_KERNEL); mwifiex_init_sdio()
1968 if (!card->mp_regs) mwifiex_init_sdio()
1972 card->mpa_rx.skb_arr = kzalloc((sizeof(void *)) * mwifiex_init_sdio()
1973 card->mp_agg_pkt_limit, GFP_KERNEL); mwifiex_init_sdio()
1974 card->mpa_rx.len_arr = kzalloc(sizeof(*card->mpa_rx.len_arr) * mwifiex_init_sdio()
1975 card->mp_agg_pkt_limit, GFP_KERNEL); mwifiex_init_sdio()
1977 card->mp_tx_agg_buf_size, mwifiex_init_sdio()
1978 card->mp_rx_agg_buf_size); mwifiex_init_sdio()
1981 kfree(card->mp_regs); mwifiex_init_sdio()
1985 adapter->auto_tdls = card->can_auto_tdls; mwifiex_init_sdio()
1986 adapter->ext_scan = card->can_ext_scan; mwifiex_init_sdio()
1995 struct sdio_mmc_card *card = adapter->card; mwifiex_cleanup_mpa_buf() local
1997 MP_TX_AGGR_BUF_RESET(card); mwifiex_cleanup_mpa_buf()
1998 MP_RX_AGGR_BUF_RESET(card); mwifiex_cleanup_mpa_buf()
2002 * This function cleans up the allocated card buffers.
2011 struct sdio_mmc_card *card = adapter->card; mwifiex_cleanup_sdio() local
2013 kfree(card->mp_regs); mwifiex_cleanup_sdio()
2014 kfree(card->mpa_rx.skb_arr); mwifiex_cleanup_sdio()
2015 kfree(card->mpa_rx.len_arr); mwifiex_cleanup_sdio()
2016 kfree(card->mpa_tx.buf); mwifiex_cleanup_sdio()
2017 kfree(card->mpa_rx.buf); mwifiex_cleanup_sdio()
2018 sdio_set_drvdata(card->func, NULL); mwifiex_cleanup_sdio()
2019 kfree(card); mwifiex_cleanup_sdio()
2023 * This function updates the MP end port in card.
2028 struct sdio_mmc_card *card = adapter->card; mwifiex_update_mp_end_port() local
2029 const struct mwifiex_sdio_card_reg *reg = card->reg; mwifiex_update_mp_end_port()
2032 card->mp_end_port = port; mwifiex_update_mp_end_port()
2034 card->mp_data_port_mask = reg->data_port_mask; mwifiex_update_mp_end_port()
2037 for (i = 1; i <= card->max_ports - card->mp_end_port; i++) mwifiex_update_mp_end_port()
2038 card->mp_data_port_mask &= mwifiex_update_mp_end_port()
2039 ~(1 << (card->max_ports - i)); mwifiex_update_mp_end_port()
2042 card->curr_wr_port = reg->start_wr_port; mwifiex_update_mp_end_port()
2045 port, card->mp_data_port_mask); mwifiex_update_mp_end_port()
2051 struct sdio_mmc_card *card = adapter->card; mwifiex_sdio_card_reset_work() local
2052 struct mmc_host *target = card->func->card->host; mwifiex_sdio_card_reset_work()
2062 pr_err("Resetting card...\n"); mwifiex_sdio_card_reset_work()
2075 struct sdio_mmc_card *card = adapter->card; mwifiex_sdio_rdwr_firmware() local
2079 sdio_writeb(card->func, FW_DUMP_HOST_READY, card->reg->fw_dump_ctrl, mwifiex_sdio_rdwr_firmware()
2086 ctrl_data = sdio_readb(card->func, card->reg->fw_dump_ctrl, mwifiex_sdio_rdwr_firmware()
2099 sdio_writeb(card->func, FW_DUMP_HOST_READY, mwifiex_sdio_rdwr_firmware()
2100 card->reg->fw_dump_ctrl, &ret); mwifiex_sdio_rdwr_firmware()
2119 struct sdio_mmc_card *card = adapter->card; mwifiex_sdio_fw_dump_work() local
2129 if (!card->can_dump_fw) mwifiex_sdio_fw_dump_work()
2143 sdio_claim_host(card->func); mwifiex_sdio_fw_dump_work()
2151 reg = card->reg->fw_dump_start; mwifiex_sdio_fw_dump_work()
2153 dump_num = sdio_readb(card->func, reg, &ret); mwifiex_sdio_fw_dump_work()
2168 reg = card->reg->fw_dump_start; mwifiex_sdio_fw_dump_work()
2170 read_reg = sdio_readb(card->func, reg, &ret); mwifiex_sdio_fw_dump_work()
2205 reg_start = card->reg->fw_dump_start; mwifiex_sdio_fw_dump_work()
2206 reg_end = card->reg->fw_dump_end; mwifiex_sdio_fw_dump_work()
2208 *dbg_ptr = sdio_readb(card->func, reg, &ret); mwifiex_sdio_fw_dump_work()
2234 sdio_release_host(card->func); mwifiex_sdio_fw_dump_work()
2249 /* This function resets the card */ mwifiex_sdio_card_reset()
2279 struct sdio_mmc_card *cardp = adapter->card; mwifiex_sdio_reg_dump()
2401 /* Clear the flag in case user removes the card. */ mwifiex_sdio_init_module()
H A Dusb.c162 struct usb_card_rec *card; mwifiex_usb_rx_complete() local
166 if (!adapter || !adapter->card) { mwifiex_usb_rx_complete()
167 pr_err("mwifiex adapter or card structure is not valid\n"); mwifiex_usb_rx_complete()
171 card = (struct usb_card_rec *)adapter->card; mwifiex_usb_rx_complete()
172 if (card->rx_cmd_ep == context->ep) mwifiex_usb_rx_complete()
173 atomic_dec(&card->rx_cmd_urb_pending); mwifiex_usb_rx_complete()
175 atomic_dec(&card->rx_data_urb_pending); mwifiex_usb_rx_complete()
182 if (card->rx_cmd_ep != context->ep) mwifiex_usb_rx_complete()
202 if (card->rx_cmd_ep == context->ep) mwifiex_usb_rx_complete()
210 if (card->rx_cmd_ep != context->ep) mwifiex_usb_rx_complete()
223 if (card->rx_cmd_ep != context->ep) mwifiex_usb_rx_complete()
230 if (card->rx_cmd_ep == context->ep) mwifiex_usb_rx_complete()
235 if (card->rx_cmd_ep == context->ep) { mwifiex_usb_rx_complete()
250 struct usb_card_rec *card = adapter->card; mwifiex_usb_tx_complete() local
254 if (context->ep == card->tx_cmd_ep) { mwifiex_usb_tx_complete()
256 atomic_dec(&card->tx_cmd_urb_pending); mwifiex_usb_tx_complete()
260 atomic_dec(&card->tx_data_urb_pending); mwifiex_usb_tx_complete()
273 struct usb_card_rec *card = (struct usb_card_rec *)adapter->card; mwifiex_usb_submit_rx_urb() local
275 if (card->rx_cmd_ep != ctx->ep) { mwifiex_usb_submit_rx_urb()
284 usb_fill_bulk_urb(ctx->urb, card->udev, mwifiex_usb_submit_rx_urb()
285 usb_rcvbulkpipe(card->udev, ctx->ep), ctx->skb->data, mwifiex_usb_submit_rx_urb()
288 if (card->rx_cmd_ep == ctx->ep) mwifiex_usb_submit_rx_urb()
289 atomic_inc(&card->rx_cmd_urb_pending); mwifiex_usb_submit_rx_urb()
291 atomic_inc(&card->rx_data_urb_pending); mwifiex_usb_submit_rx_urb()
298 if (card->rx_cmd_ep == ctx->ep) mwifiex_usb_submit_rx_urb()
299 atomic_dec(&card->rx_cmd_urb_pending); mwifiex_usb_submit_rx_urb()
301 atomic_dec(&card->rx_data_urb_pending); mwifiex_usb_submit_rx_urb()
309 static void mwifiex_usb_free(struct usb_card_rec *card) mwifiex_usb_free() argument
313 if (atomic_read(&card->rx_cmd_urb_pending) && card->rx_cmd.urb) mwifiex_usb_free()
314 usb_kill_urb(card->rx_cmd.urb); mwifiex_usb_free()
316 usb_free_urb(card->rx_cmd.urb); mwifiex_usb_free()
317 card->rx_cmd.urb = NULL; mwifiex_usb_free()
319 if (atomic_read(&card->rx_data_urb_pending)) mwifiex_usb_free()
321 if (card->rx_data_list[i].urb) mwifiex_usb_free()
322 usb_kill_urb(card->rx_data_list[i].urb); mwifiex_usb_free()
325 usb_free_urb(card->rx_data_list[i].urb); mwifiex_usb_free()
326 card->rx_data_list[i].urb = NULL; mwifiex_usb_free()
330 usb_free_urb(card->tx_data_list[i].urb); mwifiex_usb_free()
331 card->tx_data_list[i].urb = NULL; mwifiex_usb_free()
334 usb_free_urb(card->tx_cmd.urb); mwifiex_usb_free()
335 card->tx_cmd.urb = NULL; mwifiex_usb_free()
341 * the card structure, initiates the device registration and initialization
351 struct usb_card_rec *card; mwifiex_usb_probe() local
354 card = kzalloc(sizeof(struct usb_card_rec), GFP_KERNEL); mwifiex_usb_probe()
355 if (!card) mwifiex_usb_probe()
371 card->usb_boot_state = USB8XXX_FW_DNLD; mwifiex_usb_probe()
377 card->usb_boot_state = USB8XXX_FW_READY; mwifiex_usb_probe()
381 card->usb_boot_state = USB8XXX_FW_DNLD; mwifiex_usb_probe()
385 card->udev = udev; mwifiex_usb_probe()
386 card->intf = intf; mwifiex_usb_probe()
401 card->rx_cmd_ep = usb_endpoint_num(epd); mwifiex_usb_probe()
402 atomic_set(&card->rx_cmd_urb_pending, 0); mwifiex_usb_probe()
410 card->rx_data_ep = usb_endpoint_num(epd); mwifiex_usb_probe()
411 atomic_set(&card->rx_data_urb_pending, 0); mwifiex_usb_probe()
419 card->tx_data_ep = usb_endpoint_num(epd); mwifiex_usb_probe()
420 atomic_set(&card->tx_data_urb_pending, 0); mwifiex_usb_probe()
428 card->tx_cmd_ep = usb_endpoint_num(epd); mwifiex_usb_probe()
429 atomic_set(&card->tx_cmd_urb_pending, 0); mwifiex_usb_probe()
430 card->bulk_out_maxpktsize = mwifiex_usb_probe()
435 usb_set_intfdata(intf, card); mwifiex_usb_probe()
437 ret = mwifiex_add_card(card, &add_remove_card_sem, &usb_ops, mwifiex_usb_probe()
442 kfree(card); mwifiex_usb_probe()
453 * methods. Failing that the kernel simply removes the whole card.
460 struct usb_card_rec *card = usb_get_intfdata(intf); mwifiex_usb_suspend() local
464 if (!card || !card->adapter) { mwifiex_usb_suspend()
465 pr_err("%s: card or card->adapter is NULL\n", __func__); mwifiex_usb_suspend()
468 adapter = card->adapter; mwifiex_usb_suspend()
484 if (atomic_read(&card->rx_cmd_urb_pending) && card->rx_cmd.urb) mwifiex_usb_suspend()
485 usb_kill_urb(card->rx_cmd.urb); mwifiex_usb_suspend()
487 if (atomic_read(&card->rx_data_urb_pending)) mwifiex_usb_suspend()
489 if (card->rx_data_list[i].urb) mwifiex_usb_suspend()
490 usb_kill_urb(card->rx_data_list[i].urb); mwifiex_usb_suspend()
493 if (card->tx_data_list[i].urb) mwifiex_usb_suspend()
494 usb_kill_urb(card->tx_data_list[i].urb); mwifiex_usb_suspend()
496 if (card->tx_cmd.urb) mwifiex_usb_suspend()
497 usb_kill_urb(card->tx_cmd.urb); mwifiex_usb_suspend()
504 * methods. Failing that the kernel simply removes the whole card.
511 struct usb_card_rec *card = usb_get_intfdata(intf); mwifiex_usb_resume() local
515 if (!card || !card->adapter) { mwifiex_usb_resume()
516 pr_err("%s: card or card->adapter is NULL\n", __func__); mwifiex_usb_resume()
519 adapter = card->adapter; mwifiex_usb_resume()
531 if (!atomic_read(&card->rx_data_urb_pending)) mwifiex_usb_resume()
533 mwifiex_usb_submit_rx_urb(&card->rx_data_list[i], mwifiex_usb_resume()
536 if (!atomic_read(&card->rx_cmd_urb_pending)) { mwifiex_usb_resume()
537 card->rx_cmd.skb = dev_alloc_skb(MWIFIEX_RX_CMD_BUF_SIZE); mwifiex_usb_resume()
538 if (card->rx_cmd.skb) mwifiex_usb_resume()
539 mwifiex_usb_submit_rx_urb(&card->rx_cmd, mwifiex_usb_resume()
554 struct usb_card_rec *card = usb_get_intfdata(intf); mwifiex_usb_disconnect() local
557 if (!card || !card->adapter) { mwifiex_usb_disconnect()
558 pr_err("%s: card or card->adapter is NULL\n", __func__); mwifiex_usb_disconnect()
562 adapter = card->adapter; mwifiex_usb_disconnect()
579 mwifiex_usb_free(card); mwifiex_usb_disconnect()
581 dev_dbg(adapter->dev, "%s: removing card\n", __func__); mwifiex_usb_disconnect()
586 kfree(card); mwifiex_usb_disconnect()
603 struct usb_card_rec *card = (struct usb_card_rec *)adapter->card; mwifiex_usb_tx_init() local
606 card->tx_cmd.adapter = adapter; mwifiex_usb_tx_init()
607 card->tx_cmd.ep = card->tx_cmd_ep; mwifiex_usb_tx_init()
609 card->tx_cmd.urb = usb_alloc_urb(0, GFP_KERNEL); mwifiex_usb_tx_init()
610 if (!card->tx_cmd.urb) { mwifiex_usb_tx_init()
615 card->tx_data_ix = 0; mwifiex_usb_tx_init()
618 card->tx_data_list[i].adapter = adapter; mwifiex_usb_tx_init()
619 card->tx_data_list[i].ep = card->tx_data_ep; mwifiex_usb_tx_init()
621 card->tx_data_list[i].urb = usb_alloc_urb(0, GFP_KERNEL); mwifiex_usb_tx_init()
622 if (!card->tx_data_list[i].urb) { mwifiex_usb_tx_init()
634 struct usb_card_rec *card = (struct usb_card_rec *)adapter->card; mwifiex_usb_rx_init() local
637 card->rx_cmd.adapter = adapter; mwifiex_usb_rx_init()
638 card->rx_cmd.ep = card->rx_cmd_ep; mwifiex_usb_rx_init()
640 card->rx_cmd.urb = usb_alloc_urb(0, GFP_KERNEL); mwifiex_usb_rx_init()
641 if (!card->rx_cmd.urb) { mwifiex_usb_rx_init()
646 card->rx_cmd.skb = dev_alloc_skb(MWIFIEX_RX_CMD_BUF_SIZE); mwifiex_usb_rx_init()
647 if (!card->rx_cmd.skb) { mwifiex_usb_rx_init()
652 if (mwifiex_usb_submit_rx_urb(&card->rx_cmd, MWIFIEX_RX_CMD_BUF_SIZE)) mwifiex_usb_rx_init()
656 card->rx_data_list[i].adapter = adapter; mwifiex_usb_rx_init()
657 card->rx_data_list[i].ep = card->rx_data_ep; mwifiex_usb_rx_init()
659 card->rx_data_list[i].urb = usb_alloc_urb(0, GFP_KERNEL); mwifiex_usb_rx_init()
660 if (!card->rx_data_list[i].urb) { mwifiex_usb_rx_init()
665 if (mwifiex_usb_submit_rx_urb(&card->rx_data_list[i], mwifiex_usb_rx_init()
676 struct usb_card_rec *card = adapter->card; mwifiex_write_data_sync() local
679 if (!(*len % card->bulk_out_maxpktsize)) mwifiex_write_data_sync()
683 ret = usb_bulk_msg(card->udev, usb_sndbulkpipe(card->udev, ep), pbuf, mwifiex_write_data_sync()
698 struct usb_card_rec *card = adapter->card; mwifiex_read_data_sync() local
702 ret = usb_bulk_msg(card->udev, usb_rcvbulkpipe(card->udev, ep), pbuf, mwifiex_read_data_sync()
714 /* This function write a command/data packet to card. */ mwifiex_usb_host_to_card()
719 struct usb_card_rec *card = adapter->card; mwifiex_usb_host_to_card() local
735 if (ep == card->tx_data_ep && mwifiex_usb_host_to_card()
736 atomic_read(&card->tx_data_urb_pending) >= MWIFIEX_TX_DATA_URB) { mwifiex_usb_host_to_card()
742 if (ep == card->tx_cmd_ep) { mwifiex_usb_host_to_card()
743 context = &card->tx_cmd; mwifiex_usb_host_to_card()
745 if (card->tx_data_ix >= MWIFIEX_TX_DATA_URB) mwifiex_usb_host_to_card()
746 card->tx_data_ix = 0; mwifiex_usb_host_to_card()
747 context = &card->tx_data_list[card->tx_data_ix++]; mwifiex_usb_host_to_card()
755 usb_fill_bulk_urb(tx_urb, card->udev, usb_sndbulkpipe(card->udev, ep), mwifiex_usb_host_to_card()
761 if (ep == card->tx_cmd_ep) mwifiex_usb_host_to_card()
762 atomic_inc(&card->tx_cmd_urb_pending); mwifiex_usb_host_to_card()
764 atomic_inc(&card->tx_data_urb_pending); mwifiex_usb_host_to_card()
768 if (ep == card->tx_cmd_ep) { mwifiex_usb_host_to_card()
769 atomic_dec(&card->tx_cmd_urb_pending); mwifiex_usb_host_to_card()
771 atomic_dec(&card->tx_data_urb_pending); mwifiex_usb_host_to_card()
772 if (card->tx_data_ix) mwifiex_usb_host_to_card()
773 card->tx_data_ix--; mwifiex_usb_host_to_card()
775 card->tx_data_ix = MWIFIEX_TX_DATA_URB; mwifiex_usb_host_to_card()
780 if (ep == card->tx_data_ep && mwifiex_usb_host_to_card()
781 atomic_read(&card->tx_data_urb_pending) == mwifiex_usb_host_to_card()
792 struct usb_card_rec *card = (struct usb_card_rec *)adapter->card; mwifiex_register_dev() local
794 card->adapter = adapter; mwifiex_register_dev()
795 adapter->dev = &card->udev->dev; mwifiex_register_dev()
797 switch (le16_to_cpu(card->udev->descriptor.idProduct)) { mwifiex_register_dev()
829 struct usb_card_rec *card = (struct usb_card_rec *)adapter->card; mwifiex_unregister_dev() local
831 card->adapter = NULL; mwifiex_unregister_dev()
964 struct usb_card_rec *card = (struct usb_card_rec *)adapter->card; mwifiex_usb_dnld_fw() local
966 if (card->usb_boot_state == USB8XXX_FW_DNLD) { mwifiex_usb_dnld_fw()
972 if (card->usb_boot_state == USB8XXX_FW_DNLD) mwifiex_usb_dnld_fw()
985 struct usb_card_rec *card = (struct usb_card_rec *)adapter->card; mwifiex_submit_rx_urb() local
987 skb_push(card->rx_cmd.skb, INTF_HEADER_LEN); mwifiex_submit_rx_urb()
988 if ((ep == card->rx_cmd_ep) && mwifiex_submit_rx_urb()
989 (!atomic_read(&card->rx_cmd_urb_pending))) mwifiex_submit_rx_urb()
990 mwifiex_usb_submit_rx_urb(&card->rx_cmd, mwifiex_submit_rx_urb()
1004 /* This function wakes up the card. */ mwifiex_pm_wakeup_card()
1018 struct usb_card_rec *card = (struct usb_card_rec *)adapter->card; mwifiex_usb_submit_rem_rx_urbs() local
1023 if (card->rx_data_list[i].skb) mwifiex_usb_submit_rem_rx_urbs()
1025 ctx = &card->rx_data_list[i]; mwifiex_usb_submit_rem_rx_urbs()
1030 /* This function is called after the card has woken up. */
H A Dsdio.h27 #include <linux/mmc/card.h>
96 /* Card Control Registers : Download card ready */
523 mp_rx_aggr_port_limit_reached(struct sdio_mmc_card *card) mp_rx_aggr_port_limit_reached() argument
527 if (card->curr_rd_port < card->mpa_rx.start_port) { mp_rx_aggr_port_limit_reached()
528 if (card->supports_sdio_new_mode) mp_rx_aggr_port_limit_reached()
529 tmp = card->mp_end_port >> 1; mp_rx_aggr_port_limit_reached()
531 tmp = card->mp_agg_pkt_limit; mp_rx_aggr_port_limit_reached()
533 if (((card->max_ports - card->mpa_rx.start_port) + mp_rx_aggr_port_limit_reached()
534 card->curr_rd_port) >= tmp) mp_rx_aggr_port_limit_reached()
538 if (!card->supports_sdio_new_mode) mp_rx_aggr_port_limit_reached()
541 if ((card->curr_rd_port - card->mpa_rx.start_port) >= mp_rx_aggr_port_limit_reached()
542 (card->mp_end_port >> 1)) mp_rx_aggr_port_limit_reached()
549 mp_tx_aggr_port_limit_reached(struct sdio_mmc_card *card) mp_tx_aggr_port_limit_reached() argument
553 if (card->curr_wr_port < card->mpa_tx.start_port) { mp_tx_aggr_port_limit_reached()
554 if (card->supports_sdio_new_mode) mp_tx_aggr_port_limit_reached()
555 tmp = card->mp_end_port >> 1; mp_tx_aggr_port_limit_reached()
557 tmp = card->mp_agg_pkt_limit; mp_tx_aggr_port_limit_reached()
559 if (((card->max_ports - card->mpa_tx.start_port) + mp_tx_aggr_port_limit_reached()
560 card->curr_wr_port) >= tmp) mp_tx_aggr_port_limit_reached()
564 if (!card->supports_sdio_new_mode) mp_tx_aggr_port_limit_reached()
567 if ((card->curr_wr_port - card->mpa_tx.start_port) >= mp_tx_aggr_port_limit_reached()
568 (card->mp_end_port >> 1)) mp_tx_aggr_port_limit_reached()
574 /* Prepare to copy current packet from card to SDIO Rx aggregation buffer */ mp_rx_aggr_setup()
575 static inline void mp_rx_aggr_setup(struct sdio_mmc_card *card, mp_rx_aggr_setup() argument
578 card->mpa_rx.buf_len += rx_len; mp_rx_aggr_setup()
580 if (!card->mpa_rx.pkt_cnt) mp_rx_aggr_setup()
581 card->mpa_rx.start_port = port; mp_rx_aggr_setup()
583 if (card->supports_sdio_new_mode) { mp_rx_aggr_setup()
584 card->mpa_rx.ports |= (1 << port); mp_rx_aggr_setup()
586 if (card->mpa_rx.start_port <= port) mp_rx_aggr_setup()
587 card->mpa_rx.ports |= 1 << (card->mpa_rx.pkt_cnt); mp_rx_aggr_setup()
589 card->mpa_rx.ports |= 1 << (card->mpa_rx.pkt_cnt + 1); mp_rx_aggr_setup()
591 card->mpa_rx.skb_arr[card->mpa_rx.pkt_cnt] = NULL; mp_rx_aggr_setup()
592 card->mpa_rx.len_arr[card->mpa_rx.pkt_cnt] = rx_len; mp_rx_aggr_setup()
593 card->mpa_rx.pkt_cnt++; mp_rx_aggr_setup()
/linux-4.1.27/drivers/net/wireless/libertas/
H A Dif_sdio.c37 #include <linux/mmc/card.h>
55 * the card from the slot. The driver handles these 2 cases
59 * If the card is removed, there is no need to send this command.
62 * scenarios. This flag is initialized as FALSE in case the card
134 static void if_sdio_finish_power_on(struct if_sdio_card *card);
135 static int if_sdio_power_off(struct if_sdio_card *card);
147 static u16 if_sdio_read_scratch(struct if_sdio_card *card, int *err) if_sdio_read_scratch() argument
152 scratch = sdio_readb(card->func, card->scratch_reg, &ret); if_sdio_read_scratch()
154 scratch |= sdio_readb(card->func, card->scratch_reg + 1, if_sdio_read_scratch()
166 static u8 if_sdio_read_rx_unit(struct if_sdio_card *card) if_sdio_read_rx_unit() argument
171 rx_unit = sdio_readb(card->func, IF_SDIO_RX_UNIT, &ret); if_sdio_read_rx_unit()
179 static u16 if_sdio_read_rx_len(struct if_sdio_card *card, int *err) if_sdio_read_rx_len() argument
184 switch (card->model) { if_sdio_read_rx_len()
187 rx_len = if_sdio_read_scratch(card, &ret); if_sdio_read_rx_len()
191 rx_len = sdio_readb(card->func, IF_SDIO_RX_LEN, &ret); if_sdio_read_rx_len()
193 rx_len <<= card->rx_unit; if_sdio_read_rx_len()
206 static int if_sdio_handle_cmd(struct if_sdio_card *card, if_sdio_handle_cmd() argument
209 struct lbs_private *priv = card->priv; if_sdio_handle_cmd()
231 spin_unlock_irqrestore(&card->priv->driver_lock, flags); if_sdio_handle_cmd()
240 static int if_sdio_handle_data(struct if_sdio_card *card, if_sdio_handle_data() argument
268 lbs_process_rxed_packet(card->priv, skb); if_sdio_handle_data()
278 static int if_sdio_handle_event(struct if_sdio_card *card, if_sdio_handle_event() argument
286 if (card->model == MODEL_8385) { if_sdio_handle_event()
287 event = sdio_readb(card->func, IF_SDIO_EVENT, &ret); if_sdio_handle_event()
306 lbs_queue_event(card->priv, event & 0xFF); if_sdio_handle_event()
315 static int if_sdio_wait_status(struct if_sdio_card *card, const u8 condition) if_sdio_wait_status() argument
323 status = sdio_readb(card->func, IF_SDIO_STATUS, &ret); if_sdio_wait_status()
335 static int if_sdio_card_to_host(struct if_sdio_card *card) if_sdio_card_to_host() argument
342 size = if_sdio_read_rx_len(card, &ret); if_sdio_card_to_host()
353 ret = if_sdio_wait_status(card, IF_SDIO_IO_RDY); if_sdio_card_to_host()
362 chunk = sdio_align_size(card->func, size); if_sdio_card_to_host()
364 ret = sdio_readsb(card->func, card->buffer, card->ioport, chunk); if_sdio_card_to_host()
368 chunk = card->buffer[0] | (card->buffer[1] << 8); if_sdio_card_to_host()
369 type = card->buffer[2] | (card->buffer[3] << 8); if_sdio_card_to_host()
388 ret = if_sdio_handle_cmd(card, card->buffer + 4, chunk - 4); if_sdio_card_to_host()
393 ret = if_sdio_handle_data(card, card->buffer + 4, chunk - 4); if_sdio_card_to_host()
398 ret = if_sdio_handle_event(card, card->buffer + 4, chunk - 4); if_sdio_card_to_host()
420 struct if_sdio_card *card; if_sdio_host_to_card_worker() local
427 card = container_of(work, struct if_sdio_card, packet_worker); if_sdio_host_to_card_worker()
430 spin_lock_irqsave(&card->lock, flags); if_sdio_host_to_card_worker()
431 packet = card->packets; if_sdio_host_to_card_worker()
433 card->packets = packet->next; if_sdio_host_to_card_worker()
434 spin_unlock_irqrestore(&card->lock, flags); if_sdio_host_to_card_worker()
439 sdio_claim_host(card->func); if_sdio_host_to_card_worker()
441 ret = if_sdio_wait_status(card, IF_SDIO_IO_RDY); if_sdio_host_to_card_worker()
443 ret = sdio_writesb(card->func, card->ioport, if_sdio_host_to_card_worker()
450 sdio_release_host(card->func); if_sdio_host_to_card_worker()
464 static int if_sdio_prog_helper(struct if_sdio_card *card, if_sdio_prog_helper() argument
482 sdio_claim_host(card->func); if_sdio_prog_helper()
484 ret = sdio_set_block_size(card->func, 32); if_sdio_prog_helper()
492 ret = if_sdio_wait_status(card, FW_DL_READY_STATUS); if_sdio_prog_helper()
508 ret = sdio_writesb(card->func, card->ioport, if_sdio_prog_helper()
519 ret = sdio_writesb(card->func, card->ioport, chunk_buffer, 64); if_sdio_prog_helper()
530 req_size = sdio_readb(card->func, IF_SDIO_RD_BASE, &ret); if_sdio_prog_helper()
534 req_size |= sdio_readb(card->func, IF_SDIO_RD_BASE + 1, &ret) << 8; if_sdio_prog_helper()
552 sdio_release_host(card->func); if_sdio_prog_helper()
563 static int if_sdio_prog_real(struct if_sdio_card *card, if_sdio_prog_real() argument
581 sdio_claim_host(card->func); if_sdio_prog_real()
583 ret = sdio_set_block_size(card->func, 32); if_sdio_prog_real()
593 ret = if_sdio_wait_status(card, FW_DL_READY_STATUS); if_sdio_prog_real()
597 req_size = sdio_readb(card->func, IF_SDIO_RD_BASE, if_sdio_prog_real()
602 req_size |= sdio_readb(card->func, IF_SDIO_RD_BASE + 1, if_sdio_prog_real()
649 ret = sdio_writesb(card->func, card->ioport, if_sdio_prog_real()
669 scratch = if_sdio_read_scratch(card, &ret); if_sdio_prog_real()
687 sdio_release_host(card->func); if_sdio_prog_real()
702 struct if_sdio_card *card = priv->card; if_sdio_do_prog_firmware() local
709 ret = if_sdio_prog_helper(card, helper); if_sdio_do_prog_firmware()
715 ret = if_sdio_prog_real(card, mainfw); if_sdio_do_prog_firmware()
720 if_sdio_finish_power_on(card); if_sdio_do_prog_firmware()
723 static int if_sdio_prog_firmware(struct if_sdio_card *card) if_sdio_prog_firmware() argument
733 sdio_claim_host(card->func); if_sdio_prog_firmware()
734 sdio_writeb(card->func, 0x00, IF_SDIO_H_INT_MASK, &ret); if_sdio_prog_firmware()
735 sdio_release_host(card->func); if_sdio_prog_firmware()
737 sdio_claim_host(card->func); if_sdio_prog_firmware()
738 scratch = if_sdio_read_scratch(card, &ret); if_sdio_prog_firmware()
739 sdio_release_host(card->func); if_sdio_prog_firmware()
760 if_sdio_finish_power_on(card); if_sdio_prog_firmware()
762 } else if ((card->model == MODEL_8686) && (scratch & 0x7fff)) { if_sdio_prog_firmware()
764 if_sdio_finish_power_on(card); if_sdio_prog_firmware()
768 ret = lbs_get_firmware_async(card->priv, &card->func->dev, card->model, if_sdio_prog_firmware()
781 static void if_sdio_finish_power_on(struct if_sdio_card *card) if_sdio_finish_power_on() argument
783 struct sdio_func *func = card->func; if_sdio_finish_power_on()
784 struct lbs_private *priv = card->priv; if_sdio_finish_power_on()
788 sdio_set_block_size(card->func, IF_SDIO_BLOCK_SIZE); if_sdio_finish_power_on()
794 if ((card->model != MODEL_8385) if_sdio_finish_power_on()
795 && (card->model != MODEL_8686)) if_sdio_finish_power_on()
796 card->rx_unit = if_sdio_read_rx_unit(card); if_sdio_finish_power_on()
798 card->rx_unit = 0; if_sdio_finish_power_on()
832 if (card->model == MODEL_8688) { if_sdio_finish_power_on()
843 wake_up(&card->pwron_waitq); if_sdio_finish_power_on()
845 if (!card->started) { if_sdio_finish_power_on()
847 if_sdio_power_off(card); if_sdio_finish_power_on()
849 card->started = true; if_sdio_finish_power_on()
850 /* Tell PM core that we don't need the card to be if_sdio_finish_power_on()
864 static int if_sdio_power_on(struct if_sdio_card *card) if_sdio_power_on() argument
866 struct sdio_func *func = card->func; if_sdio_power_on()
867 struct mmc_host *host = func->card->host; if_sdio_power_on()
879 if ((card->model == MODEL_8686) && if_sdio_power_on()
884 func->card->quirks |= MMC_QUIRK_LENIENT_FN0; if_sdio_power_on()
895 card->ioport = sdio_readb(func, IF_SDIO_IOPORT, &ret); if_sdio_power_on()
899 card->ioport |= sdio_readb(func, IF_SDIO_IOPORT + 1, &ret) << 8; if_sdio_power_on()
903 card->ioport |= sdio_readb(func, IF_SDIO_IOPORT + 2, &ret) << 16; if_sdio_power_on()
908 ret = if_sdio_prog_firmware(card); if_sdio_power_on()
923 static int if_sdio_power_off(struct if_sdio_card *card) if_sdio_power_off() argument
925 struct sdio_func *func = card->func; if_sdio_power_off()
926 struct lbs_private *priv = card->priv; if_sdio_power_off()
946 struct if_sdio_card *card; if_sdio_host_to_card() local
953 card = priv->card; if_sdio_host_to_card()
965 size = sdio_align_size(card->func, nb + 4); if_sdio_host_to_card()
987 spin_lock_irqsave(&card->lock, flags); if_sdio_host_to_card()
989 if (!card->packets) if_sdio_host_to_card()
990 card->packets = packet; if_sdio_host_to_card()
992 cur = card->packets; if_sdio_host_to_card()
1009 spin_unlock_irqrestore(&card->lock, flags); if_sdio_host_to_card()
1011 queue_work(card->workqueue, &card->packet_worker); if_sdio_host_to_card()
1040 struct if_sdio_card *card = priv->card; if_sdio_exit_deep_sleep() local
1044 sdio_claim_host(card->func); if_sdio_exit_deep_sleep()
1046 sdio_writeb(card->func, HOST_POWER_UP, CONFIGURATION_REG, &ret); if_sdio_exit_deep_sleep()
1050 sdio_release_host(card->func); if_sdio_exit_deep_sleep()
1057 struct if_sdio_card *card = priv->card; if_sdio_reset_deep_sleep_wakeup() local
1061 sdio_claim_host(card->func); if_sdio_reset_deep_sleep_wakeup()
1063 sdio_writeb(card->func, 0, CONFIGURATION_REG, &ret); if_sdio_reset_deep_sleep_wakeup()
1067 sdio_release_host(card->func); if_sdio_reset_deep_sleep_wakeup()
1087 pr_info("Resetting card..."); if_sdio_reset_card_worker()
1095 struct if_sdio_card *card = priv->card; if_sdio_reset_card() local
1100 reset_host = card->func->card->host; if_sdio_reset_card()
1106 struct if_sdio_card *card = priv->card; if_sdio_power_save() local
1109 flush_workqueue(card->workqueue); if_sdio_power_save()
1111 ret = if_sdio_power_off(card); if_sdio_power_save()
1113 /* Let runtime PM know the card is powered off */ if_sdio_power_save()
1114 pm_runtime_put_sync(&card->func->dev); if_sdio_power_save()
1121 struct if_sdio_card *card = priv->card; if_sdio_power_restore() local
1124 /* Make sure the card will not be powered off by runtime PM */ if_sdio_power_restore()
1125 pm_runtime_get_sync(&card->func->dev); if_sdio_power_restore()
1127 r = if_sdio_power_on(card); if_sdio_power_restore()
1131 wait_event(card->pwron_waitq, priv->fw_ready); if_sdio_power_restore()
1143 struct if_sdio_card *card; if_sdio_interrupt() local
1148 card = sdio_get_drvdata(func); if_sdio_interrupt()
1150 cause = sdio_readb(card->func, IF_SDIO_H_INT_STATUS, &ret); if_sdio_interrupt()
1156 sdio_writeb(card->func, ~cause, IF_SDIO_H_INT_STATUS, &ret); if_sdio_interrupt()
1161 * Ignore the define name, this really means the card has if_sdio_interrupt()
1164 card->priv->is_activity_detected = 1; if_sdio_interrupt()
1166 lbs_host_to_card_done(card->priv); if_sdio_interrupt()
1170 ret = if_sdio_card_to_host(card); if_sdio_interrupt()
1184 struct if_sdio_card *card; if_sdio_probe() local
1192 for (i = 0;i < func->card->num_info;i++) { if_sdio_probe()
1193 if (sscanf(func->card->info[i], if_sdio_probe()
1196 if (sscanf(func->card->info[i], if_sdio_probe()
1199 if (!strcmp(func->card->info[i], "IBIS Wireless SDIO Card")) { if_sdio_probe()
1205 if (i == func->card->num_info) { if_sdio_probe()
1206 pr_err("unable to identify card model\n"); if_sdio_probe()
1210 card = kzalloc(sizeof(struct if_sdio_card), GFP_KERNEL); if_sdio_probe()
1211 if (!card) if_sdio_probe()
1214 card->func = func; if_sdio_probe()
1215 card->model = model; if_sdio_probe()
1217 switch (card->model) { if_sdio_probe()
1219 card->scratch_reg = IF_SDIO_SCRATCH_OLD; if_sdio_probe()
1222 card->scratch_reg = IF_SDIO_SCRATCH; if_sdio_probe()
1226 card->scratch_reg = IF_SDIO_FW_STATUS; if_sdio_probe()
1230 spin_lock_init(&card->lock); if_sdio_probe()
1231 card->workqueue = create_workqueue("libertas_sdio"); if_sdio_probe()
1232 INIT_WORK(&card->packet_worker, if_sdio_host_to_card_worker); if_sdio_probe()
1233 init_waitqueue_head(&card->pwron_waitq); if_sdio_probe()
1235 /* Check if we support this card */ if_sdio_probe()
1237 if (card->model == fw_table[i].model) if_sdio_probe()
1241 pr_err("unknown card model 0x%x\n", card->model); if_sdio_probe()
1246 sdio_set_drvdata(func, card); if_sdio_probe()
1251 model, (unsigned)card->ioport); if_sdio_probe()
1254 priv = lbs_add_card(card, &func->dev); if_sdio_probe()
1260 card->priv = priv; if_sdio_probe()
1262 priv->card = card; if_sdio_probe()
1271 ret = if_sdio_power_on(card); if_sdio_probe()
1281 flush_workqueue(card->workqueue); if_sdio_probe()
1284 destroy_workqueue(card->workqueue); if_sdio_probe()
1285 while (card->packets) { if_sdio_probe()
1286 packet = card->packets; if_sdio_probe()
1287 card->packets = card->packets->next; if_sdio_probe()
1291 kfree(card); if_sdio_probe()
1298 struct if_sdio_card *card; if_sdio_remove() local
1303 card = sdio_get_drvdata(func); if_sdio_remove()
1308 if (user_rmmod && (card->model == MODEL_8688)) { if_sdio_remove()
1318 if (__lbs_cmd(card->priv, CMD_FUNC_SHUTDOWN, if_sdio_remove()
1325 lbs_deb_sdio("call remove card\n"); if_sdio_remove()
1326 lbs_stop_card(card->priv); if_sdio_remove()
1327 lbs_remove_card(card->priv); if_sdio_remove()
1329 flush_workqueue(card->workqueue); if_sdio_remove()
1330 destroy_workqueue(card->workqueue); if_sdio_remove()
1332 while (card->packets) { if_sdio_remove()
1333 packet = card->packets; if_sdio_remove()
1334 card->packets = card->packets->next; if_sdio_remove()
1338 kfree(card); if_sdio_remove()
1346 struct if_sdio_card *card = sdio_get_drvdata(func); if_sdio_suspend() local
1351 * card. */ if_sdio_suspend()
1352 if (!lbs_iface_active(card->priv)) if_sdio_suspend()
1359 * and let the SD stack power down the card. if_sdio_suspend()
1361 if (card->priv->wol_criteria == EHS_REMOVE_WAKEUP) { if_sdio_suspend()
1362 dev_info(dev, "Suspend without wake params -- powering down card\n"); if_sdio_suspend()
1376 ret = lbs_suspend(card->priv); if_sdio_suspend()
1386 struct if_sdio_card *card = sdio_get_drvdata(func); if_sdio_resume() local
1391 ret = lbs_resume(card->priv); if_sdio_resume()
1426 /* Clear the flag in case user removes the card. */ if_sdio_init_module()
H A Dif_spi.c50 /* The card ID and card revision, as reported by the hardware. */
77 /* True is card suspended */
81 static void free_if_spi_card(struct if_spi_card *card) free_if_spi_card() argument
86 list_for_each_safe(cursor, next, &card->cmd_packet_list) { free_if_spi_card()
91 list_for_each_safe(cursor, next, &card->data_packet_list) { free_if_spi_card()
96 kfree(card); free_if_spi_card()
133 static void spu_transaction_init(struct if_spi_card *card) spu_transaction_init() argument
135 if (!time_after(jiffies, card->prev_xfer_time + 1)) { spu_transaction_init()
144 static void spu_transaction_finish(struct if_spi_card *card) spu_transaction_finish() argument
146 card->prev_xfer_time = jiffies; spu_transaction_finish()
153 static int spu_write(struct if_spi_card *card, u16 reg, const u8 *buf, int len) spu_write() argument
169 spu_transaction_init(card); spu_write()
181 err = spi_sync(card->spi, &m); spu_write()
182 spu_transaction_finish(card); spu_write()
186 static inline int spu_write_u16(struct if_spi_card *card, u16 reg, u16 val) spu_write_u16() argument
191 return spu_write(card, reg, (u8 *)&buff, sizeof(u16)); spu_write_u16()
206 static int spu_read(struct if_spi_card *card, u16 reg, u8 *buf, int len) spu_read() argument
222 spu_transaction_init(card); spu_read()
234 delay = spu_reg_is_port_reg(reg) ? card->spu_port_delay : spu_read()
235 card->spu_reg_delay; spu_read()
236 if (card->use_dummy_writes) { spu_read()
251 err = spi_sync(card->spi, &m); spu_read()
252 spu_transaction_finish(card); spu_read()
257 static inline int spu_read_u16(struct if_spi_card *card, u16 reg, u16 *val) spu_read_u16() argument
262 ret = spu_read(card, reg, (u8 *)&buf, sizeof(buf)); spu_read_u16()
272 static int spu_read_u32(struct if_spi_card *card, u16 reg, u32 *val) spu_read_u32() argument
277 err = spu_read(card, reg, (u8 *)&buf, sizeof(buf)); spu_read_u32()
292 static int spu_wait_for_u16(struct if_spi_card *card, u16 reg, spu_wait_for_u16() argument
299 err = spu_read_u16(card, reg, &val); spu_wait_for_u16()
322 static int spu_wait_for_u32(struct if_spi_card *card, u32 reg, u32 target) spu_wait_for_u32() argument
327 err = spu_read_u32(card, reg, &val); spu_wait_for_u32()
337 static int spu_set_interrupt_mode(struct if_spi_card *card, spu_set_interrupt_mode() argument
348 err = spu_write_u16(card, IF_SPI_HOST_INT_STATUS_MASK_REG, 0); spu_set_interrupt_mode()
352 err = spu_write_u16(card, IF_SPI_HOST_INT_STATUS_MASK_REG, spu_set_interrupt_mode()
366 * trigger a card interrupt. spu_set_interrupt_mode()
369 err = spu_write_u16(card, IF_SPI_HOST_INT_CTRL_REG, spu_set_interrupt_mode()
377 err = spu_write_u16(card, IF_SPI_HOST_INT_STATUS_MASK_REG, 0); spu_set_interrupt_mode()
384 static int spu_get_chip_revision(struct if_spi_card *card, spu_get_chip_revision() argument
389 err = spu_read_u32(card, IF_SPI_DEVICEID_CTRL_REG, &dev_ctrl); spu_get_chip_revision()
397 static int spu_set_bus_mode(struct if_spi_card *card, u16 mode) spu_set_bus_mode() argument
402 err = spu_write_u16(card, IF_SPI_SPU_BUS_MODE_REG, mode); spu_set_bus_mode()
406 err = spu_read_u16(card, IF_SPI_SPU_BUS_MODE_REG, &rval); spu_set_bus_mode()
416 static int spu_init(struct if_spi_card *card, int use_dummy_writes) spu_init() argument
425 card->use_dummy_writes = 0; spu_init()
426 err = spu_set_bus_mode(card, spu_init()
432 card->spu_port_delay = 1000; spu_init()
433 card->spu_reg_delay = 1000; spu_init()
434 err = spu_read_u32(card, IF_SPI_DELAY_READ_REG, &delay); spu_init()
437 card->spu_port_delay = delay & 0x0000ffff; spu_init()
438 card->spu_reg_delay = (delay & 0xffff0000) >> 16; spu_init()
442 card->use_dummy_writes = 1; spu_init()
443 err = spu_set_bus_mode(card, spu_init()
453 card->spu_port_delay, card->spu_reg_delay); spu_init()
461 static int if_spi_prog_helper_firmware(struct if_spi_card *card, if_spi_prog_helper_firmware() argument
471 err = spu_set_interrupt_mode(card, 1, 0); if_spi_prog_helper_firmware()
484 err = spu_write_u16(card, IF_SPI_SCRATCH_1_REG, if_spi_prog_helper_firmware()
489 err = spu_wait_for_u16(card, IF_SPI_HOST_INT_STATUS_REG, if_spi_prog_helper_firmware()
503 err = spu_write(card, IF_SPI_CMD_RDWRPORT_REG, if_spi_prog_helper_firmware()
509 err = spu_write_u16(card, IF_SPI_HOST_INT_STATUS_REG, 0); if_spi_prog_helper_firmware()
512 err = spu_write_u16(card, IF_SPI_CARD_INT_CAUSE_REG, if_spi_prog_helper_firmware()
525 err = spu_write_u16(card, IF_SPI_SCRATCH_1_REG, FIRMWARE_DNLD_OK); if_spi_prog_helper_firmware()
528 err = spu_write_u16(card, IF_SPI_HOST_INT_STATUS_REG, 0); if_spi_prog_helper_firmware()
531 err = spu_write_u16(card, IF_SPI_CARD_INT_CAUSE_REG, if_spi_prog_helper_firmware()
544 static int if_spi_prog_main_firmware_check_len(struct if_spi_card *card, if_spi_prog_main_firmware_check_len() argument
554 err = spu_wait_for_u16(card, IF_SPI_HOST_INT_STATUS_REG, if_spi_prog_main_firmware_check_len()
563 err = spu_read_u16(card, IF_SPI_SCRATCH_1_REG, &len); if_spi_prog_main_firmware_check_len()
582 static int if_spi_prog_main_firmware(struct if_spi_card *card, if_spi_prog_main_firmware() argument
585 struct lbs_private *priv = card->priv; if_spi_prog_main_firmware()
593 err = spu_set_interrupt_mode(card, 1, 0); if_spi_prog_main_firmware()
597 err = spu_wait_for_u16(card, IF_SPI_SCRATCH_1_REG, 0, 0); if_spi_prog_main_firmware()
609 while ((len = if_spi_prog_main_firmware_check_len(card, &crc_err))) { if_spi_prog_main_firmware()
636 memset(card->cmd_buffer, 0, len); if_spi_prog_main_firmware()
637 memcpy(card->cmd_buffer, fw, bytes); if_spi_prog_main_firmware()
639 memcpy(card->cmd_buffer, fw, len); if_spi_prog_main_firmware()
641 err = spu_write_u16(card, IF_SPI_HOST_INT_STATUS_REG, 0); if_spi_prog_main_firmware()
644 err = spu_write(card, IF_SPI_CMD_RDWRPORT_REG, if_spi_prog_main_firmware()
645 card->cmd_buffer, len); if_spi_prog_main_firmware()
648 err = spu_write_u16(card, IF_SPI_CARD_INT_CAUSE_REG , if_spi_prog_main_firmware()
659 err = spu_wait_for_u32(card, IF_SPI_SCRATCH_4_REG, if_spi_prog_main_firmware()
679 /* Move a command from the card to the host */ if_spi_c2h_cmd()
680 static int if_spi_c2h_cmd(struct if_spi_card *card) if_spi_c2h_cmd() argument
682 struct lbs_private *priv = card->priv; if_spi_c2h_cmd()
705 err = spu_read_u16(card, IF_SPI_SCRATCH_2_REG, &len); if_spi_c2h_cmd()
709 netdev_err(priv->dev, "%s: error: card has no data for host\n", if_spi_c2h_cmd()
722 err = spu_read(card, IF_SPI_CMD_RDWRPORT_REG, if_spi_c2h_cmd()
723 card->cmd_buffer, ALIGN(len, 4)); if_spi_c2h_cmd()
731 memcpy(priv->resp_buf[i], card->cmd_buffer, len); if_spi_c2h_cmd()
742 /* Move data from the card to the host */ if_spi_c2h_data()
743 static int if_spi_c2h_data(struct if_spi_card *card) if_spi_c2h_data() argument
745 struct lbs_private *priv = card->priv; if_spi_c2h_data()
754 err = spu_read_u16(card, IF_SPI_SCRATCH_1_REG, &len); if_spi_c2h_data()
758 netdev_err(priv->dev, "%s: error: card has no data for host\n", if_spi_c2h_data()
764 "%s: error: card has %d bytes of data, but our maximum skb size is %zu\n", if_spi_c2h_data()
780 err = spu_read(card, IF_SPI_DATA_RDWRPORT_REG, data, ALIGN(len, 4)); if_spi_c2h_data()
785 err = lbs_process_rxed_packet(card->priv, skb); if_spi_c2h_data()
801 /* Move data or a command from the host to the card. */ if_spi_h2c()
802 static void if_spi_h2c(struct if_spi_card *card, if_spi_h2c() argument
805 struct lbs_private *priv = card->priv; if_spi_h2c()
825 /* Write the data to the card */ if_spi_h2c()
826 err = spu_write(card, port_reg, packet->buffer, packet->blen); if_spi_h2c()
837 /* Inform the host about a card event */ if_spi_e2h()
838 static void if_spi_e2h(struct if_spi_card *card) if_spi_e2h() argument
842 struct lbs_private *priv = card->priv; if_spi_e2h()
844 err = spu_read_u32(card, IF_SPI_SCRATCH_3_REG, &cause); if_spi_e2h()
848 /* re-enable the card event interrupt */ if_spi_e2h()
849 spu_write_u16(card, IF_SPI_HOST_INT_STATUS_REG, if_spi_e2h()
852 /* generate a card interrupt */ if_spi_e2h()
853 spu_write_u16(card, IF_SPI_CARD_INT_CAUSE_REG, IF_SPI_CIC_HOST_EVENT); if_spi_e2h()
864 struct if_spi_card *card; if_spi_host_to_card_worker() local
870 card = container_of(work, struct if_spi_card, packet_work); if_spi_host_to_card_worker()
871 priv = card->priv; if_spi_host_to_card_worker()
879 err = spu_read_u16(card, IF_SPI_HOST_INT_STATUS_REG, if_spi_host_to_card_worker()
887 err = if_spi_c2h_cmd(card); if_spi_host_to_card_worker()
892 err = if_spi_c2h_data(card); if_spi_host_to_card_worker()
898 * workaround: in PS mode, the card does not set the Command if_spi_host_to_card_worker()
902 (card->priv->psstate != PS_STATE_FULL_POWER && if_spi_host_to_card_worker()
906 * if there was a previous command sent, the card has if_spi_host_to_card_worker()
911 lbs_host_to_card_done(card->priv); if_spi_host_to_card_worker()
915 spin_lock_irqsave(&card->buffer_lock, flags); if_spi_host_to_card_worker()
916 if (!list_empty(&card->cmd_packet_list)) { if_spi_host_to_card_worker()
917 packet = (struct if_spi_packet *)(card-> if_spi_host_to_card_worker()
921 spin_unlock_irqrestore(&card->buffer_lock, flags); if_spi_host_to_card_worker()
924 if_spi_h2c(card, packet, MVMS_CMD); if_spi_host_to_card_worker()
929 spin_lock_irqsave(&card->buffer_lock, flags); if_spi_host_to_card_worker()
930 if (!list_empty(&card->data_packet_list)) { if_spi_host_to_card_worker()
931 packet = (struct if_spi_packet *)(card-> if_spi_host_to_card_worker()
935 spin_unlock_irqrestore(&card->buffer_lock, flags); if_spi_host_to_card_worker()
938 if_spi_h2c(card, packet, MVMS_DAT); if_spi_host_to_card_worker()
941 if_spi_e2h(card); if_spi_host_to_card_worker()
961 struct if_spi_card *card = priv->card; if_spi_host_to_card() local
986 spin_lock_irqsave(&card->buffer_lock, flags); if_spi_host_to_card()
987 list_add_tail(&packet->list, &card->cmd_packet_list); if_spi_host_to_card()
988 spin_unlock_irqrestore(&card->buffer_lock, flags); if_spi_host_to_card()
992 spin_lock_irqsave(&card->buffer_lock, flags); if_spi_host_to_card()
993 list_add_tail(&packet->list, &card->data_packet_list); if_spi_host_to_card()
994 spin_unlock_irqrestore(&card->buffer_lock, flags); if_spi_host_to_card()
1005 queue_work(card->workqueue, &card->packet_work); if_spi_host_to_card()
1019 struct if_spi_card *card = dev_id; if_spi_host_interrupt() local
1021 queue_work(card->workqueue, &card->packet_work); if_spi_host_interrupt()
1030 static int if_spi_init_card(struct if_spi_card *card) if_spi_init_card() argument
1032 struct lbs_private *priv = card->priv; if_spi_init_card()
1040 err = spu_init(card, card->pdata->use_dummy_writes); if_spi_init_card()
1043 err = spu_get_chip_revision(card, &card->card_id, &card->card_rev); if_spi_init_card()
1047 err = spu_read_u32(card, IF_SPI_SCRATCH_4_REG, &scratch); if_spi_init_card()
1054 /* Check if we support this card */ if_spi_init_card()
1056 if (card->card_id == fw_table[i].model) if_spi_init_card()
1061 card->card_id); if_spi_init_card()
1066 err = lbs_get_firmware(&card->spi->dev, card->card_id, if_spi_init_card()
1078 card->card_id, card->card_rev, if_spi_init_card()
1079 card->spi->master->bus_num, if_spi_init_card()
1080 card->spi->chip_select, if_spi_init_card()
1081 card->spi->max_speed_hz); if_spi_init_card()
1082 err = if_spi_prog_helper_firmware(card, helper); if_spi_init_card()
1085 err = if_spi_prog_main_firmware(card, mainfw); if_spi_init_card()
1091 err = spu_set_interrupt_mode(card, 0, 1); if_spi_init_card()
1102 struct if_spi_card *card; if_spi_resume_worker() local
1104 card = container_of(work, struct if_spi_card, resume_work); if_spi_resume_worker()
1106 if (card->suspended) { if_spi_resume_worker()
1107 if (card->pdata->setup) if_spi_resume_worker()
1108 card->pdata->setup(card->spi); if_spi_resume_worker()
1110 /* Init card ... */ if_spi_resume_worker()
1111 if_spi_init_card(card); if_spi_resume_worker()
1113 enable_irq(card->spi->irq); if_spi_resume_worker()
1116 lbs_resume(card->priv); if_spi_resume_worker()
1118 card->suspended = 0; if_spi_resume_worker()
1124 struct if_spi_card *card; if_spi_probe() local
1142 /* Allocate card structure to represent this specific device */ if_spi_probe()
1143 card = kzalloc(sizeof(struct if_spi_card), GFP_KERNEL); if_spi_probe()
1144 if (!card) { if_spi_probe()
1148 spi_set_drvdata(spi, card); if_spi_probe()
1149 card->pdata = pdata; if_spi_probe()
1150 card->spi = spi; if_spi_probe()
1151 card->prev_xfer_time = jiffies; if_spi_probe()
1153 INIT_LIST_HEAD(&card->cmd_packet_list); if_spi_probe()
1154 INIT_LIST_HEAD(&card->data_packet_list); if_spi_probe()
1155 spin_lock_init(&card->buffer_lock); if_spi_probe()
1160 err = if_spi_init_card(card); if_spi_probe()
1165 * Register our card with libertas. if_spi_probe()
1168 priv = lbs_add_card(card, &spi->dev); if_spi_probe()
1173 card->priv = priv; if_spi_probe()
1175 priv->card = card; if_spi_probe()
1183 card->workqueue = create_workqueue("libertas_spi"); if_spi_probe()
1184 INIT_WORK(&card->packet_work, if_spi_host_to_card_worker); if_spi_probe()
1185 INIT_WORK(&card->resume_work, if_spi_resume_worker); if_spi_probe()
1188 IRQF_TRIGGER_FALLING, "libertas_spi", card); if_spi_probe()
1195 * Start the card. if_spi_probe()
1209 free_irq(spi->irq, card); if_spi_probe()
1211 flush_workqueue(card->workqueue); if_spi_probe()
1212 destroy_workqueue(card->workqueue); if_spi_probe()
1215 free_if_spi_card(card); if_spi_probe()
1226 struct if_spi_card *card = spi_get_drvdata(spi); libertas_spi_remove() local
1227 struct lbs_private *priv = card->priv; libertas_spi_remove()
1232 cancel_work_sync(&card->resume_work); libertas_spi_remove()
1237 free_irq(spi->irq, card); libertas_spi_remove()
1238 flush_workqueue(card->workqueue); libertas_spi_remove()
1239 destroy_workqueue(card->workqueue); libertas_spi_remove()
1240 if (card->pdata->teardown) libertas_spi_remove()
1241 card->pdata->teardown(spi); libertas_spi_remove()
1242 free_if_spi_card(card); libertas_spi_remove()
1250 struct if_spi_card *card = spi_get_drvdata(spi); if_spi_suspend() local
1252 if (!card->suspended) { if_spi_suspend()
1253 lbs_suspend(card->priv); if_spi_suspend()
1254 flush_workqueue(card->workqueue); if_spi_suspend()
1257 if (card->pdata->teardown) if_spi_suspend()
1258 card->pdata->teardown(spi); if_spi_suspend()
1259 card->suspended = 1; if_spi_suspend()
1268 struct if_spi_card *card = spi_get_drvdata(spi); if_spi_resume() local
1271 schedule_work(&card->resume_work); if_spi_resume()
H A Dif_cs.c109 static inline unsigned int if_cs_read8(struct if_cs_card *card, uint reg) if_cs_read8() argument
111 unsigned int val = ioread8(card->iobase + reg); if_cs_read8()
116 static inline unsigned int if_cs_read16(struct if_cs_card *card, uint reg) if_cs_read16() argument
118 unsigned int val = ioread16(card->iobase + reg); if_cs_read16()
124 struct if_cs_card *card, if_cs_read16_rep()
132 ioread16_rep(card->iobase + reg, buf, count); if_cs_read16_rep()
135 static inline void if_cs_write8(struct if_cs_card *card, uint reg, u8 val) if_cs_write8() argument
139 iowrite8(val, card->iobase + reg); if_cs_write8()
142 static inline void if_cs_write16(struct if_cs_card *card, uint reg, u16 val) if_cs_write16() argument
146 iowrite16(val, card->iobase + reg); if_cs_write16()
150 struct if_cs_card *card, if_cs_write16_rep()
158 iowrite16_rep(card->iobase + reg, buf, count); if_cs_write16_rep()
168 * the card. :-)
174 static int if_cs_poll_while_fw_download(struct if_cs_card *card, uint addr, u8 reg) if_cs_poll_while_fw_download() argument
179 u8 val = if_cs_read8(card, addr); if_cs_poll_while_fw_download()
190 * First the bitmasks for the host/card interrupt/status registers:
250 * The card status registers shows what the card/firmware actually
257 * IF_CS_BIT_EVENT the card has a event for use (link lost, snr low etc)
264 * we handle this via the card int cause register.
270 * The card int cause register is used by the card/firmware to notify us
277 * IF_CS_BIT_EVENT the card has a event for use (link lost, snr low etc)
282 * This is used to for handshaking with the card's bootloader/helper image
337 static inline void if_cs_enable_ints(struct if_cs_card *card) if_cs_enable_ints() argument
340 if_cs_write16(card, IF_CS_HOST_INT_MASK, 0); if_cs_enable_ints()
343 static inline void if_cs_disable_ints(struct if_cs_card *card) if_cs_disable_ints() argument
346 if_cs_write16(card, IF_CS_HOST_INT_MASK, IF_CS_BIT_MASK); if_cs_disable_ints()
354 struct if_cs_card *card = (struct if_cs_card *)priv->card; if_cs_send_cmd() local
359 if_cs_disable_ints(card); if_cs_send_cmd()
363 u16 status = if_cs_read16(card, IF_CS_CARD_STATUS); if_cs_send_cmd()
367 netdev_err(priv->dev, "card not ready for commands\n"); if_cs_send_cmd()
373 if_cs_write16(card, IF_CS_CMD_LEN, nb); if_cs_send_cmd()
375 if_cs_write16_rep(card, IF_CS_CMD, buf, nb / 2); if_cs_send_cmd()
378 if_cs_write8(card, IF_CS_CMD, buf[nb-1]); if_cs_send_cmd()
382 if_cs_write16(card, IF_CS_HOST_STATUS, IF_CS_BIT_COMMAND); if_cs_send_cmd()
386 if_cs_write16(card, IF_CS_HOST_INT_CAUSE, IF_CS_BIT_COMMAND); if_cs_send_cmd()
390 if_cs_enable_ints(card); if_cs_send_cmd()
400 struct if_cs_card *card = (struct if_cs_card *)priv->card; if_cs_send_data() local
404 if_cs_disable_ints(card); if_cs_send_data()
406 status = if_cs_read16(card, IF_CS_CARD_STATUS); if_cs_send_data()
409 if_cs_write16(card, IF_CS_WRITE_LEN, nb); if_cs_send_data()
412 if_cs_write16_rep(card, IF_CS_WRITE, buf, nb / 2); if_cs_send_data()
414 if_cs_write8(card, IF_CS_WRITE, buf[nb-1]); if_cs_send_data()
416 if_cs_write16(card, IF_CS_HOST_STATUS, IF_CS_BIT_TX); if_cs_send_data()
417 if_cs_write16(card, IF_CS_HOST_INT_CAUSE, IF_CS_BIT_TX); if_cs_send_data()
418 if_cs_enable_ints(card); if_cs_send_data()
424 * Get the command result out of the card.
435 status = if_cs_read16(priv->card, IF_CS_CARD_STATUS); if_cs_receive_cmdres()
437 netdev_err(priv->dev, "no cmd response in card\n"); if_cs_receive_cmdres()
442 *len = if_cs_read16(priv->card, IF_CS_RESP_LEN); if_cs_receive_cmdres()
445 "card cmd buffer has invalid # of bytes (%d)\n", if_cs_receive_cmdres()
451 if_cs_read16_rep(priv->card, IF_CS_RESP, data, *len/sizeof(u16)); if_cs_receive_cmdres()
453 data[*len-1] = if_cs_read8(priv->card, IF_CS_RESP); if_cs_receive_cmdres()
478 len = if_cs_read16(priv->card, IF_CS_READ_LEN); if_cs_receive_data()
481 "card data buffer has invalid # of bytes (%d)\n", if_cs_receive_data()
495 if_cs_read16_rep(priv->card, IF_CS_READ, data, len/sizeof(u16)); if_cs_receive_data()
497 data[len-1] = if_cs_read8(priv->card, IF_CS_READ); if_cs_receive_data()
500 if_cs_write16(priv->card, IF_CS_HOST_STATUS, IF_CS_BIT_RX); if_cs_receive_data()
501 if_cs_write16(priv->card, IF_CS_HOST_INT_CAUSE, IF_CS_BIT_RX); if_cs_receive_data()
510 struct if_cs_card *card = data; if_cs_interrupt() local
511 struct lbs_private *priv = card->priv; if_cs_interrupt()
516 /* Ask card interrupt cause register if there is something for us */ if_cs_interrupt()
517 cause = if_cs_read16(card, IF_CS_CARD_INT_CAUSE); if_cs_interrupt()
526 /* Read in junk, the card has probably been removed */ if_cs_interrupt()
527 card->priv->surpriseremoved = 1; if_cs_interrupt()
563 u16 status = if_cs_read16(priv->card, IF_CS_CARD_STATUS); if_cs_interrupt()
564 if_cs_write16(priv->card, IF_CS_HOST_INT_CAUSE, if_cs_interrupt()
570 if_cs_write16(card, IF_CS_CARD_INT_CAUSE, cause & IF_CS_BIT_MASK); if_cs_interrupt()
588 static int if_cs_prog_helper(struct if_cs_card *card, const struct firmware *fw) if_cs_prog_helper() argument
598 * the CF8305 card, therefore for the sake of speed of the driver, we do if_cs_prog_helper()
601 if (card->align_regs) if_cs_prog_helper()
602 scratch = if_cs_read16(card, IF_CS_SCRATCH) >> 8; if_cs_prog_helper()
604 scratch = if_cs_read8(card, IF_CS_SCRATCH); if_cs_prog_helper()
635 if_cs_write16(card, IF_CS_CMD_LEN, count); if_cs_prog_helper()
639 if_cs_write16_rep(card, IF_CS_CMD, if_cs_prog_helper()
647 if_cs_write8(card, IF_CS_HOST_STATUS, IF_CS_BIT_COMMAND); if_cs_prog_helper()
653 if_cs_write16(card, IF_CS_HOST_INT_CAUSE, IF_CS_BIT_COMMAND); if_cs_prog_helper()
659 ret = if_cs_poll_while_fw_download(card, IF_CS_CARD_STATUS, if_cs_prog_helper()
679 static int if_cs_prog_real(struct if_cs_card *card, const struct firmware *fw) if_cs_prog_real() argument
690 ret = if_cs_poll_while_fw_download(card, IF_CS_SQ_READ_LOW, if_cs_prog_real()
698 len = if_cs_read16(card, IF_CS_SQ_READ_LOW); if_cs_prog_real()
716 if_cs_write16(card, IF_CS_CMD_LEN, len); if_cs_prog_real()
718 if_cs_write16_rep(card, IF_CS_CMD, if_cs_prog_real()
721 if_cs_write8(card, IF_CS_HOST_STATUS, IF_CS_BIT_COMMAND); if_cs_prog_real()
722 if_cs_write16(card, IF_CS_HOST_INT_CAUSE, IF_CS_BIT_COMMAND); if_cs_prog_real()
724 ret = if_cs_poll_while_fw_download(card, IF_CS_CARD_STATUS, if_cs_prog_real()
732 ret = if_cs_poll_while_fw_download(card, IF_CS_SCRATCH, 0x5a); if_cs_prog_real()
745 struct if_cs_card *card = priv->card; if_cs_prog_firmware() local
753 ret = if_cs_prog_helper(card, helper); if_cs_prog_firmware()
754 if (ret == 0 && (card->model != MODEL_8305)) if_cs_prog_firmware()
755 ret = if_cs_prog_real(card, mainfw); if_cs_prog_firmware()
760 ret = request_irq(card->p_dev->irq, if_cs_interrupt, if_cs_prog_firmware()
761 IRQF_SHARED, DRV_NAME, card); if_cs_prog_firmware()
769 * firmware/initializing card if_cs_prog_firmware()
771 if_cs_write16(card, IF_CS_CARD_INT_CAUSE, IF_CS_BIT_MASK); if_cs_prog_firmware()
772 if_cs_enable_ints(card); if_cs_prog_firmware()
774 /* And finally bring the card up */ if_cs_prog_firmware()
777 pr_err("could not activate card\n"); if_cs_prog_firmware()
778 free_irq(card->p_dev->irq, card); if_cs_prog_firmware()
787 /* Send commands or data packets to the card */ if_cs_host_to_card()
819 struct if_cs_card *card = p_dev->priv; if_cs_release() local
823 free_irq(p_dev->irq, card); if_cs_release()
825 if (card->iobase) if_cs_release()
826 ioport_unmap(card->iobase); if_cs_release()
851 struct if_cs_card *card; if_cs_probe() local
855 card = kzalloc(sizeof(struct if_cs_card), GFP_KERNEL); if_cs_probe()
856 if (!card) if_cs_probe()
859 card->p_dev = p_dev; if_cs_probe()
860 p_dev->priv = card; if_cs_probe()
878 card->iobase = ioport_map(p_dev->resource[0]->start, if_cs_probe()
880 if (!card->iobase) { if_cs_probe()
897 * weird ones cannot. That's especially true for the CF8305 card. if_cs_probe()
899 card->align_regs = false; if_cs_probe()
901 card->model = get_model(p_dev->manf_id, p_dev->card_id); if_cs_probe()
902 if (card->model == MODEL_UNKNOWN) { if_cs_probe()
910 prod_id = if_cs_read8(card, IF_CS_PRODUCT_ID); if_cs_probe()
911 if (card->model == MODEL_8305) { if_cs_probe()
912 card->align_regs = true; if_cs_probe()
920 if ((card->model == MODEL_8381) && prod_id < IF_CS_CF8381_B3_REV) { if_cs_probe()
926 if ((card->model == MODEL_8385) && prod_id < IF_CS_CF8385_B1_REV) { if_cs_probe()
932 /* Make this card known to the libertas driver */ if_cs_probe()
933 priv = lbs_add_card(card, &p_dev->dev); if_cs_probe()
940 card->priv = priv; if_cs_probe()
941 priv->card = card; if_cs_probe()
948 ret = lbs_get_firmware_async(priv, &p_dev->dev, card->model, fw_table, if_cs_probe()
960 ioport_unmap(card->iobase); if_cs_probe()
971 struct if_cs_card *card = p_dev->priv; if_cs_detach() local
975 lbs_stop_card(card->priv); if_cs_detach()
976 lbs_remove_card(card->priv); if_cs_detach()
977 if_cs_disable_ints(card); if_cs_detach()
979 kfree(card); if_cs_detach()
123 if_cs_read16_rep( struct if_cs_card *card, uint reg, void *buf, unsigned long count) if_cs_read16_rep() argument
149 if_cs_write16_rep( struct if_cs_card *card, uint reg, const void *buf, unsigned long count) if_cs_write16_rep() argument
/linux-4.1.27/drivers/bluetooth/
H A Dbtmrvl_sdio.c57 * the card from the slot. The driver handles these 2 cases
61 * If the card is removed, there is no need to send command
65 * scenarios. This flag is initialized as FALSE in case the card
219 static int btmrvl_sdio_get_rx_unit(struct btmrvl_sdio_card *card) btmrvl_sdio_get_rx_unit() argument
224 reg = sdio_readb(card->func, card->reg->card_rx_unit, &ret); btmrvl_sdio_get_rx_unit()
226 card->rx_unit = reg; btmrvl_sdio_get_rx_unit()
231 static int btmrvl_sdio_read_fw_status(struct btmrvl_sdio_card *card, u16 *dat) btmrvl_sdio_read_fw_status() argument
238 fws0 = sdio_readb(card->func, card->reg->card_fw_status0, &ret); btmrvl_sdio_read_fw_status()
242 fws1 = sdio_readb(card->func, card->reg->card_fw_status1, &ret); btmrvl_sdio_read_fw_status()
251 static int btmrvl_sdio_read_rx_len(struct btmrvl_sdio_card *card, u16 *dat) btmrvl_sdio_read_rx_len() argument
256 reg = sdio_readb(card->func, card->reg->card_rx_len, &ret); btmrvl_sdio_read_rx_len()
258 *dat = (u16) reg << card->rx_unit; btmrvl_sdio_read_rx_len()
263 static int btmrvl_sdio_enable_host_int_mask(struct btmrvl_sdio_card *card, btmrvl_sdio_enable_host_int_mask() argument
268 sdio_writeb(card->func, mask, card->reg->host_int_mask, &ret); btmrvl_sdio_enable_host_int_mask()
277 static int btmrvl_sdio_disable_host_int_mask(struct btmrvl_sdio_card *card, btmrvl_sdio_disable_host_int_mask() argument
283 host_int_mask = sdio_readb(card->func, card->reg->host_int_mask, &ret); btmrvl_sdio_disable_host_int_mask()
289 sdio_writeb(card->func, host_int_mask, card->reg->host_int_mask, &ret); btmrvl_sdio_disable_host_int_mask()
298 static int btmrvl_sdio_poll_card_status(struct btmrvl_sdio_card *card, u8 bits) btmrvl_sdio_poll_card_status() argument
305 status = sdio_readb(card->func, card->reg->card_status, &ret); btmrvl_sdio_poll_card_status()
322 static int btmrvl_sdio_verify_fw_download(struct btmrvl_sdio_card *card, btmrvl_sdio_verify_fw_download() argument
330 sdio_claim_host(card->func); btmrvl_sdio_verify_fw_download()
331 ret = btmrvl_sdio_read_fw_status(card, &firmwarestat); btmrvl_sdio_verify_fw_download()
332 sdio_release_host(card->func); btmrvl_sdio_verify_fw_download()
345 static int btmrvl_sdio_download_helper(struct btmrvl_sdio_card *card) btmrvl_sdio_download_helper() argument
355 ret = request_firmware(&fw_helper, card->helper, btmrvl_sdio_download_helper()
356 &card->func->dev); btmrvl_sdio_download_helper()
388 ret = btmrvl_sdio_poll_card_status(card, btmrvl_sdio_download_helper()
413 ret = sdio_writesb(card->func, card->ioport, helperbuf, btmrvl_sdio_download_helper()
428 ret = sdio_writesb(card->func, card->ioport, helperbuf, btmrvl_sdio_download_helper()
443 static int btmrvl_sdio_download_fw_w_helper(struct btmrvl_sdio_card *card) btmrvl_sdio_download_fw_w_helper() argument
452 u16 len, blksz_dl = card->sd_blksz_fw_dl; btmrvl_sdio_download_fw_w_helper()
455 ret = request_firmware(&fw_firmware, card->firmware, btmrvl_sdio_download_fw_w_helper()
456 &card->func->dev); btmrvl_sdio_download_fw_w_helper()
484 ret = btmrvl_sdio_poll_card_status(card, btmrvl_sdio_download_fw_w_helper()
497 base0 = sdio_readb(card->func, btmrvl_sdio_download_fw_w_helper()
498 card->reg->sq_read_base_addr_a0, &ret); btmrvl_sdio_download_fw_w_helper()
507 base1 = sdio_readb(card->func, btmrvl_sdio_download_fw_w_helper()
508 card->reg->sq_read_base_addr_a1, &ret); btmrvl_sdio_download_fw_w_helper()
561 ret = sdio_writesb(card->func, card->ioport, fwbuf, btmrvl_sdio_download_fw_w_helper()
567 sdio_writeb(card->func, HOST_CMD53_FIN, btmrvl_sdio_download_fw_w_helper()
568 card->reg->cfg, &ret); btmrvl_sdio_download_fw_w_helper()
594 struct btmrvl_sdio_card *card = priv->btmrvl_dev.card; btmrvl_sdio_card_to_host() local
596 if (!card || !card->func) { btmrvl_sdio_card_to_host()
597 BT_ERR("card or function is NULL!"); btmrvl_sdio_card_to_host()
603 ret = btmrvl_sdio_read_rx_len(card, &buf_len); btmrvl_sdio_card_to_host()
637 ret = sdio_readsb(card->func, payload, card->ioport, btmrvl_sdio_card_to_host()
713 struct btmrvl_sdio_card *card = priv->btmrvl_dev.card; btmrvl_sdio_process_int_status() local
720 sdio_claim_host(card->func); btmrvl_sdio_process_int_status()
732 sdio_release_host(card->func); btmrvl_sdio_process_int_status()
737 static int btmrvl_sdio_read_to_clear(struct btmrvl_sdio_card *card, u8 *ireg) btmrvl_sdio_read_to_clear() argument
739 struct btmrvl_adapter *adapter = card->priv->adapter; btmrvl_sdio_read_to_clear()
742 ret = sdio_readsb(card->func, adapter->hw_regs, 0, SDIO_BLOCK_SIZE); btmrvl_sdio_read_to_clear()
748 *ireg = adapter->hw_regs[card->reg->host_intstatus]; btmrvl_sdio_read_to_clear()
749 BT_DBG("hw_regs[%#x]=%#x", card->reg->host_intstatus, *ireg); btmrvl_sdio_read_to_clear()
754 static int btmrvl_sdio_write_to_clear(struct btmrvl_sdio_card *card, u8 *ireg) btmrvl_sdio_write_to_clear() argument
758 *ireg = sdio_readb(card->func, card->reg->host_intstatus, &ret); btmrvl_sdio_write_to_clear()
772 sdio_writeb(card->func, ~(*ireg) & (DN_LD_HOST_INT_STATUS | btmrvl_sdio_write_to_clear()
774 card->reg->host_intstatus, &ret); btmrvl_sdio_write_to_clear()
787 struct btmrvl_sdio_card *card; btmrvl_sdio_interrupt() local
792 card = sdio_get_drvdata(func); btmrvl_sdio_interrupt()
793 if (!card || !card->priv) { btmrvl_sdio_interrupt()
794 BT_ERR("sbi_interrupt(%p) card or priv is NULL, card=%p", btmrvl_sdio_interrupt()
795 func, card); btmrvl_sdio_interrupt()
799 priv = card->priv; btmrvl_sdio_interrupt()
804 if (card->reg->int_read_to_clear) btmrvl_sdio_interrupt()
805 ret = btmrvl_sdio_read_to_clear(card, &ireg); btmrvl_sdio_interrupt()
807 ret = btmrvl_sdio_write_to_clear(card, &ireg); btmrvl_sdio_interrupt()
819 static int btmrvl_sdio_register_dev(struct btmrvl_sdio_card *card) btmrvl_sdio_register_dev() argument
825 if (!card || !card->func) { btmrvl_sdio_register_dev()
826 BT_ERR("Error: card or function is NULL!"); btmrvl_sdio_register_dev()
831 func = card->func; btmrvl_sdio_register_dev()
849 ret = sdio_set_block_size(card->func, SDIO_BLOCK_SIZE); btmrvl_sdio_register_dev()
856 reg = sdio_readb(func, card->reg->io_port_0, &ret); btmrvl_sdio_register_dev()
862 card->ioport = reg; btmrvl_sdio_register_dev()
864 reg = sdio_readb(func, card->reg->io_port_1, &ret); btmrvl_sdio_register_dev()
870 card->ioport |= (reg << 8); btmrvl_sdio_register_dev()
872 reg = sdio_readb(func, card->reg->io_port_2, &ret); btmrvl_sdio_register_dev()
878 card->ioport |= (reg << 16); btmrvl_sdio_register_dev()
880 BT_DBG("SDIO FUNC%d IO port: 0x%x", func->num, card->ioport); btmrvl_sdio_register_dev()
882 if (card->reg->int_read_to_clear) { btmrvl_sdio_register_dev()
883 reg = sdio_readb(func, card->reg->host_int_rsr, &ret); btmrvl_sdio_register_dev()
888 sdio_writeb(func, reg | 0x3f, card->reg->host_int_rsr, &ret); btmrvl_sdio_register_dev()
894 reg = sdio_readb(func, card->reg->card_misc_cfg, &ret); btmrvl_sdio_register_dev()
899 sdio_writeb(func, reg | 0x10, card->reg->card_misc_cfg, &ret); btmrvl_sdio_register_dev()
906 sdio_set_drvdata(func, card); btmrvl_sdio_register_dev()
925 static int btmrvl_sdio_unregister_dev(struct btmrvl_sdio_card *card) btmrvl_sdio_unregister_dev() argument
927 if (card && card->func) { btmrvl_sdio_unregister_dev()
928 sdio_claim_host(card->func); btmrvl_sdio_unregister_dev()
929 sdio_release_irq(card->func); btmrvl_sdio_unregister_dev()
930 sdio_disable_func(card->func); btmrvl_sdio_unregister_dev()
931 sdio_release_host(card->func); btmrvl_sdio_unregister_dev()
932 sdio_set_drvdata(card->func, NULL); btmrvl_sdio_unregister_dev()
938 static int btmrvl_sdio_enable_host_int(struct btmrvl_sdio_card *card) btmrvl_sdio_enable_host_int() argument
942 if (!card || !card->func) btmrvl_sdio_enable_host_int()
945 sdio_claim_host(card->func); btmrvl_sdio_enable_host_int()
947 ret = btmrvl_sdio_enable_host_int_mask(card, HIM_ENABLE); btmrvl_sdio_enable_host_int()
949 btmrvl_sdio_get_rx_unit(card); btmrvl_sdio_enable_host_int()
951 sdio_release_host(card->func); btmrvl_sdio_enable_host_int()
956 static int btmrvl_sdio_disable_host_int(struct btmrvl_sdio_card *card) btmrvl_sdio_disable_host_int() argument
960 if (!card || !card->func) btmrvl_sdio_disable_host_int()
963 sdio_claim_host(card->func); btmrvl_sdio_disable_host_int()
965 ret = btmrvl_sdio_disable_host_int_mask(card, HIM_DISABLE); btmrvl_sdio_disable_host_int()
967 sdio_release_host(card->func); btmrvl_sdio_disable_host_int()
975 struct btmrvl_sdio_card *card = priv->btmrvl_dev.card; btmrvl_sdio_host_to_card() local
984 if (!card || !card->func) { btmrvl_sdio_host_to_card()
985 BT_ERR("card or function is NULL!"); btmrvl_sdio_host_to_card()
1002 sdio_claim_host(card->func); btmrvl_sdio_host_to_card()
1005 /* Transfer data to card */ btmrvl_sdio_host_to_card()
1006 ret = sdio_writesb(card->func, card->ioport, buf, btmrvl_sdio_host_to_card()
1021 sdio_release_host(card->func); btmrvl_sdio_host_to_card()
1027 static int btmrvl_sdio_download_fw(struct btmrvl_sdio_card *card) btmrvl_sdio_download_fw() argument
1033 if (!card || !card->func) { btmrvl_sdio_download_fw()
1034 BT_ERR("card or function is NULL!"); btmrvl_sdio_download_fw()
1038 if (!btmrvl_sdio_verify_fw_download(card, 1)) { btmrvl_sdio_download_fw()
1043 sdio_claim_host(card->func); btmrvl_sdio_download_fw()
1046 fws0 = sdio_readb(card->func, card->reg->card_fw_status0, &ret); btmrvl_sdio_download_fw()
1058 if (card->helper) { btmrvl_sdio_download_fw()
1059 ret = btmrvl_sdio_download_helper(card); btmrvl_sdio_download_fw()
1067 if (btmrvl_sdio_download_fw_w_helper(card)) { btmrvl_sdio_download_fw()
1074 sdio_release_host(card->func); btmrvl_sdio_download_fw()
1080 if (btmrvl_sdio_verify_fw_download(card, pollnum)) { btmrvl_sdio_download_fw()
1088 sdio_release_host(card->func); btmrvl_sdio_download_fw()
1094 struct btmrvl_sdio_card *card = priv->btmrvl_dev.card; btmrvl_sdio_wakeup_fw() local
1097 if (!card || !card->func) { btmrvl_sdio_wakeup_fw()
1098 BT_ERR("card or function is NULL!"); btmrvl_sdio_wakeup_fw()
1102 sdio_claim_host(card->func); btmrvl_sdio_wakeup_fw()
1104 sdio_writeb(card->func, HOST_POWER_UP, card->reg->cfg, &ret); btmrvl_sdio_wakeup_fw()
1106 sdio_release_host(card->func); btmrvl_sdio_wakeup_fw()
1115 struct btmrvl_sdio_card *card = priv->btmrvl_dev.card; btmrvl_sdio_dump_regs() local
1123 sdio_claim_host(card->func); btmrvl_sdio_dump_regs()
1144 data = sdio_f0_readb(card->func, reg, &ret); btmrvl_sdio_dump_regs()
1146 data = sdio_readb(card->func, reg, &ret); btmrvl_sdio_dump_regs()
1159 sdio_release_host(card->func); btmrvl_sdio_dump_regs()
1167 struct btmrvl_sdio_card *card = priv->btmrvl_dev.card; btmrvl_sdio_rdwr_firmware() local
1171 sdio_writeb(card->func, FW_DUMP_HOST_READY, card->reg->fw_dump_ctrl, btmrvl_sdio_rdwr_firmware()
1180 ctrl_data = sdio_readb(card->func, card->reg->fw_dump_ctrl, btmrvl_sdio_rdwr_firmware()
1194 sdio_writeb(card->func, FW_DUMP_HOST_READY, btmrvl_sdio_rdwr_firmware()
1195 card->reg->fw_dump_ctrl, &ret); btmrvl_sdio_rdwr_firmware()
1215 struct btmrvl_sdio_card *card = priv->btmrvl_dev.card; btmrvl_sdio_dump_firmware() local
1226 if (!card->supports_fw_dump) { btmrvl_sdio_dump_firmware()
1227 BT_ERR("Firmware dump not supported for this card!"); btmrvl_sdio_dump_firmware()
1242 sdio_claim_host(card->func); btmrvl_sdio_dump_firmware()
1250 reg = card->reg->fw_dump_start; btmrvl_sdio_dump_firmware()
1252 dump_num = sdio_readb(card->func, reg, &ret); btmrvl_sdio_dump_firmware()
1268 reg = card->reg->fw_dump_start; btmrvl_sdio_dump_firmware()
1270 read_reg = sdio_readb(card->func, reg, &ret); btmrvl_sdio_dump_firmware()
1310 reg_start = card->reg->fw_dump_start; btmrvl_sdio_dump_firmware()
1311 reg_end = card->reg->fw_dump_end; btmrvl_sdio_dump_firmware()
1313 *dbg_ptr = sdio_readb(card->func, reg, &ret); btmrvl_sdio_dump_firmware()
1338 sdio_release_host(card->func); btmrvl_sdio_dump_firmware()
1389 struct btmrvl_sdio_card *card = NULL; btmrvl_sdio_probe() local
1394 card = devm_kzalloc(&func->dev, sizeof(*card), GFP_KERNEL); btmrvl_sdio_probe()
1395 if (!card) btmrvl_sdio_probe()
1398 card->func = func; btmrvl_sdio_probe()
1402 card->helper = data->helper; btmrvl_sdio_probe()
1403 card->firmware = data->firmware; btmrvl_sdio_probe()
1404 card->reg = data->reg; btmrvl_sdio_probe()
1405 card->sd_blksz_fw_dl = data->sd_blksz_fw_dl; btmrvl_sdio_probe()
1406 card->support_pscan_win_report = data->support_pscan_win_report; btmrvl_sdio_probe()
1407 card->supports_fw_dump = data->supports_fw_dump; btmrvl_sdio_probe()
1410 if (btmrvl_sdio_register_dev(card) < 0) { btmrvl_sdio_probe()
1415 /* Disable the interrupts on the card */ btmrvl_sdio_probe()
1416 btmrvl_sdio_disable_host_int(card); btmrvl_sdio_probe()
1418 if (btmrvl_sdio_download_fw(card)) { btmrvl_sdio_probe()
1424 btmrvl_sdio_enable_host_int(card); btmrvl_sdio_probe()
1426 priv = btmrvl_add_card(card); btmrvl_sdio_probe()
1428 BT_ERR("Initializing card failed!"); btmrvl_sdio_probe()
1433 card->priv = priv; btmrvl_sdio_probe()
1450 btmrvl_sdio_disable_host_int(card); btmrvl_sdio_probe()
1452 btmrvl_sdio_unregister_dev(card); btmrvl_sdio_probe()
1458 struct btmrvl_sdio_card *card; btmrvl_sdio_remove() local
1461 card = sdio_get_drvdata(func); btmrvl_sdio_remove()
1462 if (card) { btmrvl_sdio_remove()
1467 btmrvl_send_module_cfg_cmd(card->priv, btmrvl_sdio_remove()
1469 btmrvl_sdio_disable_host_int(card); btmrvl_sdio_remove()
1472 card->priv->surprise_removed = true; btmrvl_sdio_remove()
1473 btmrvl_sdio_unregister_dev(card); btmrvl_sdio_remove()
1474 btmrvl_remove_card(card->priv); btmrvl_sdio_remove()
1482 struct btmrvl_sdio_card *card; btmrvl_sdio_suspend() local
1496 card = sdio_get_drvdata(func); btmrvl_sdio_suspend()
1497 if (!card || !card->priv) { btmrvl_sdio_suspend()
1498 BT_ERR("card or priv structure is not valid"); btmrvl_sdio_suspend()
1506 priv = card->priv; btmrvl_sdio_suspend()
1534 struct btmrvl_sdio_card *card; btmrvl_sdio_resume() local
1543 card = sdio_get_drvdata(func); btmrvl_sdio_resume()
1544 if (!card || !card->priv) { btmrvl_sdio_resume()
1545 BT_ERR("card or priv structure is not valid"); btmrvl_sdio_resume()
1552 priv = card->priv; btmrvl_sdio_resume()
1593 /* Clear the flag in case user removes the card. */ btmrvl_sdio_init_module()
/linux-4.1.27/drivers/isdn/capi/
H A Dcapidrv.c144 static void handle_dtrace_data(capidrv_contr *card,
332 static capidrv_plci *new_plci(capidrv_contr *card, int chan) new_plci() argument
345 plcip->next = card->plci_list; new_plci()
346 card->plci_list = plcip; new_plci()
347 card->bchans[chan].plcip = plcip; new_plci()
352 static capidrv_plci *find_plci_by_plci(capidrv_contr *card, u32 plci) find_plci_by_plci() argument
355 for (p = card->plci_list; p; p = p->next) find_plci_by_plci()
361 static capidrv_plci *find_plci_by_msgid(capidrv_contr *card, u16 msgid) find_plci_by_msgid() argument
364 for (p = card->plci_list; p; p = p->next) find_plci_by_msgid()
370 static capidrv_plci *find_plci_by_ncci(capidrv_contr *card, u32 ncci) find_plci_by_ncci() argument
373 for (p = card->plci_list; p; p = p->next) find_plci_by_ncci()
379 static void free_plci(capidrv_contr *card, capidrv_plci *plcip) free_plci() argument
383 for (pp = &card->plci_list; *pp; pp = &(*pp)->next) { free_plci()
386 card->bchans[plcip->chan].plcip = NULL; free_plci()
387 card->bchans[plcip->chan].disconnecting = 0; free_plci()
388 card->bchans[plcip->chan].incoming = 0; free_plci()
394 card->contrnr, plcip, plcip->plci); free_plci()
399 static inline capidrv_ncci *new_ncci(capidrv_contr *card, new_ncci() argument
419 card->bchans[plcip->chan].nccip = nccip; new_ncci()
424 static inline capidrv_ncci *find_ncci(capidrv_contr *card, u32 ncci) find_ncci() argument
429 if ((plcip = find_plci_by_ncci(card, ncci)) == NULL) find_ncci()
438 static inline capidrv_ncci *find_ncci_by_msgid(capidrv_contr *card, find_ncci_by_msgid() argument
444 if ((plcip = find_plci_by_ncci(card, ncci)) == NULL) find_ncci_by_msgid()
453 static void free_ncci(capidrv_contr *card, struct capidrv_ncci *nccip) free_ncci() argument
463 card->bchans[nccip->chan].nccip = NULL; free_ncci()
504 static void send_message(capidrv_contr *card, _cmsg *cmsg) send_message() argument
545 static void listen_change_state(capidrv_contr *card, int event) listen_change_state() argument
549 if (card->state == p->actstate && p->event == event) { listen_change_state()
552 card->contrnr, card->state, p->nextstate); listen_change_state()
553 card->state = p->nextstate; listen_change_state()
559 card->contrnr, card->state, event); listen_change_state()
565 static void p0(capidrv_contr *card, capidrv_plci *plci) p0() argument
569 card->bchans[plci->chan].contr = NULL; p0()
571 cmd.driver = card->myid; p0()
573 card->interface.statcallb(&cmd); p0()
574 free_plci(card, plci); p0()
583 void (*changefunc)(capidrv_contr *card, capidrv_plci *plci);
640 static void plci_change_state(capidrv_contr *card, capidrv_plci *plci, int event) plci_change_state() argument
647 card->contrnr, plci->plci, plci->state, p->nextstate); plci_change_state()
650 p->changefunc(card, plci); plci_change_state()
656 card->contrnr, plci->plci, plci->state, event); plci_change_state()
663 static void n0(capidrv_contr *card, capidrv_ncci *ncci) n0() argument
669 card->msgid++, n0()
676 plci_change_state(card, ncci->plcip, EV_PLCI_DISCONNECT_REQ); n0()
677 send_message(card, &cmsg); n0()
680 cmd.driver = card->myid; n0()
682 card->interface.statcallb(&cmd); n0()
683 free_ncci(card, ncci); n0()
692 void (*changefunc)(capidrv_contr *card, capidrv_ncci *ncci);
729 static void ncci_change_state(capidrv_contr *card, capidrv_ncci *ncci, int event) ncci_change_state() argument
736 card->contrnr, ncci->ncci, ncci->state, p->nextstate); ncci_change_state()
745 p->changefunc(card, ncci); ncci_change_state()
751 card->contrnr, ncci->ncci, ncci->state, event); ncci_change_state()
756 static inline int new_bchan(capidrv_contr *card) new_bchan() argument
759 for (i = 0; i < card->nbchan; i++) { new_bchan()
760 if (card->bchans[i].plcip == NULL) { new_bchan()
761 card->bchans[i].disconnecting = 0; new_bchan()
967 capidrv_contr *card = findcontrbynumber(cmsg->adr.adrController & 0x7f); handle_controller() local
969 if (!card) { handle_controller()
980 card->contrnr, cmsg->Info, capi_info2str(cmsg->Info), card->cipmask); handle_controller()
982 listen_change_state(card, EV_LISTEN_CONF_ERROR); handle_controller()
983 } else if (card->cipmask == 0) { handle_controller()
984 listen_change_state(card, EV_LISTEN_CONF_EMPTY); handle_controller()
986 listen_change_state(card, EV_LISTEN_CONF_OK); handle_controller()
1009 handle_dtrace_data(card, direction, 1, data, len); handle_controller()
1013 handle_dtrace_data(card, direction, 0, data, len); handle_controller()
1017 card->contrnr, handle_controller()
1034 card->contrnr, handle_controller()
1052 card->contrnr, handle_controller()
1060 card->contrnr, handle_controller()
1065 static void handle_incoming_call(capidrv_contr *card, _cmsg *cmsg) handle_incoming_call() argument
1072 if ((chan = new_bchan(card)) == -1) { handle_incoming_call()
1073 printk(KERN_ERR "capidrv-%d: incoming call on not existing bchan ?\n", card->contrnr); handle_incoming_call()
1076 bchan = &card->bchans[chan]; handle_incoming_call()
1077 if ((plcip = new_plci(card, chan)) == NULL) { handle_incoming_call()
1078 printk(KERN_ERR "capidrv-%d: incoming call: no memory, sorry.\n", card->contrnr); handle_incoming_call()
1083 plci_change_state(card, plcip, EV_PLCI_CONNECT_IND); handle_incoming_call()
1086 cmd.driver = card->myid; handle_incoming_call()
1101 card->contrnr, handle_incoming_call()
1109 card->contrnr, handle_incoming_call()
1114 switch (card->interface.statcallb(&cmd)) { handle_incoming_call()
1124 plci_change_state(card, plcip, EV_PLCI_CONNECT_REJECT); handle_incoming_call()
1125 send_message(card, cmsg); handle_incoming_call()
1127 card->contrnr, handle_incoming_call()
1145 card->contrnr, handle_incoming_call()
1152 card->msgid++, handle_incoming_call()
1160 send_message(card, cmsg); handle_incoming_call()
1163 card->contrnr, handle_incoming_call()
1174 plci_change_state(card, plcip, EV_PLCI_CONNECT_REJECT); handle_incoming_call()
1175 send_message(card, cmsg); handle_incoming_call()
1183 plci_change_state(card, plcip, EV_PLCI_CONNECT_REJECT); handle_incoming_call()
1184 send_message(card, cmsg); handle_incoming_call()
1192 capidrv_contr *card = findcontrbynumber(cmsg->adr.adrController & 0x7f); handle_plci() local
1197 if (!card) { handle_plci()
1208 card->contrnr, handle_plci()
1212 if (!(plcip = find_plci_by_plci(card, cmsg->adr.adrPLCI))) { handle_plci()
1214 send_message(card, cmsg); handle_plci()
1217 card->bchans[plcip->chan].disconnecting = 1; handle_plci()
1218 plci_change_state(card, plcip, EV_PLCI_DISCONNECT_IND); handle_plci()
1220 plci_change_state(card, plcip, EV_PLCI_DISCONNECT_RESP); handle_plci()
1221 send_message(card, cmsg); handle_plci()
1227 card->contrnr, handle_plci()
1232 if (!(plcip = find_plci_by_plci(card, cmsg->adr.adrPLCI))) handle_plci()
1235 card->bchans[plcip->chan].disconnecting = 1; handle_plci()
1241 card->contrnr, handle_plci()
1249 handle_incoming_call(card, cmsg); handle_plci()
1255 card->contrnr, handle_plci()
1260 if (!(plcip = find_plci_by_msgid(card, cmsg->Messagenumber))) handle_plci()
1265 plci_change_state(card, plcip, EV_PLCI_CONNECT_CONF_ERROR); handle_plci()
1267 plci_change_state(card, plcip, EV_PLCI_CONNECT_CONF_OK); handle_plci()
1273 if (!(plcip = find_plci_by_plci(card, cmsg->adr.adrPLCI))) handle_plci()
1276 if (card->bchans[plcip->chan].incoming) { handle_plci()
1278 plci_change_state(card, plcip, EV_PLCI_CONNECT_ACTIVE_IND); handle_plci()
1279 send_message(card, cmsg); handle_plci()
1283 send_message(card, cmsg); handle_plci()
1285 nccip = new_ncci(card, plcip, cmsg->adr.adrPLCI); handle_plci()
1288 printk(KERN_ERR "capidrv-%d: no mem for ncci, sorry\n", card->contrnr); handle_plci()
1293 card->msgid++, handle_plci()
1298 plci_change_state(card, plcip, handle_plci()
1300 ncci_change_state(card, nccip, EV_NCCI_CONNECT_B3_REQ); handle_plci()
1301 send_message(card, cmsg); handle_plci()
1303 cmd.driver = card->myid; handle_plci()
1305 card->interface.statcallb(&cmd); handle_plci()
1311 if (!(plcip = find_plci_by_plci(card, cmsg->adr.adrPLCI))) handle_plci()
1317 cmd.driver = card->myid; handle_plci()
1325 card->interface.statcallb(&cmd); handle_plci()
1332 card->contrnr, cdb->buf); handle_plci()
1336 card->contrnr, cmsg->InfoNumber); handle_plci()
1354 card->contrnr, handle_plci()
1361 card->contrnr, handle_plci()
1367 card->contrnr, handle_plci()
1375 capidrv_contr *card = findcontrbynumber(cmsg->adr.adrController & 0x7f); handle_ncci() local
1381 if (!card) { handle_ncci()
1390 if (!(nccip = find_ncci(card, cmsg->adr.adrNCCI))) handle_ncci()
1394 ncci_change_state(card, nccip, EV_NCCI_CONNECT_B3_ACTIVE_IND); handle_ncci()
1395 send_message(card, cmsg); handle_ncci()
1398 cmd.driver = card->myid; handle_ncci()
1400 card->interface.statcallb(&cmd); handle_ncci()
1403 card->contrnr, nccip->chan, nccip->ncci); handle_ncci()
1411 plcip = find_plci_by_ncci(card, cmsg->adr.adrNCCI); handle_ncci()
1413 nccip = new_ncci(card, plcip, cmsg->adr.adrNCCI); handle_ncci()
1415 ncci_change_state(card, nccip, EV_NCCI_CONNECT_B3_IND); handle_ncci()
1418 card->msgid++, handle_ncci()
1423 ncci_change_state(card, nccip, EV_NCCI_CONNECT_B3_RESP); handle_ncci()
1424 send_message(card, cmsg); handle_ncci()
1427 printk(KERN_ERR "capidrv-%d: no mem for ncci, sorry\n", card->contrnr); handle_ncci()
1430 card->contrnr, handle_ncci()
1436 card->msgid++, handle_ncci()
1441 send_message(card, cmsg); handle_ncci()
1446 if (!(nccip = find_ncci_by_msgid(card, handle_ncci()
1454 card->contrnr, handle_ncci()
1461 ncci_change_state(card, nccip, EV_NCCI_CONNECT_B3_CONF_ERROR); handle_ncci()
1463 ncci_change_state(card, nccip, EV_NCCI_CONNECT_B3_CONF_OK); handle_ncci()
1468 send_message(card, cmsg); handle_ncci()
1480 if (!(nccip = find_ncci(card, cmsg->adr.adrNCCI))) handle_ncci()
1487 cmd.driver = card->myid; handle_ncci()
1490 card->interface.statcallb(&cmd); handle_ncci()
1494 if (!(nccip = find_ncci(card, cmsg->adr.adrNCCI))) handle_ncci()
1497 card->bchans[nccip->chan].disconnecting = 1; handle_ncci()
1498 ncci_change_state(card, nccip, EV_NCCI_DISCONNECT_B3_IND); handle_ncci()
1500 ncci_change_state(card, nccip, EV_NCCI_DISCONNECT_B3_RESP); handle_ncci()
1501 send_message(card, cmsg); handle_ncci()
1505 if (!(nccip = find_ncci(card, cmsg->adr.adrNCCI))) handle_ncci()
1509 card->contrnr, handle_ncci()
1513 ncci_change_state(card, nccip, EV_NCCI_DISCONNECT_B3_CONF_ERROR); handle_ncci()
1518 if (!(nccip = find_ncci(card, cmsg->adr.adrNCCI))) handle_ncci()
1520 ncci_change_state(card, nccip, EV_NCCI_RESET_B3_IND); handle_ncci()
1522 send_message(card, cmsg); handle_ncci()
1535 card->contrnr, handle_ncci()
1542 card->contrnr, handle_ncci()
1548 card->contrnr, handle_ncci()
1556 capidrv_contr *card = findcontrbynumber(cmsg->adr.adrController & 0x7f); handle_data() local
1559 if (!card) { handle_data()
1566 if (!(nccip = find_ncci(card, cmsg->adr.adrNCCI))) { handle_data()
1568 card->contrnr, handle_data()
1575 card->interface.rcvcallb_skb(card->myid, nccip->chan, skb); handle_data()
1577 send_message(card, cmsg); handle_data()
1623 #define PUTBYTE_TO_STATUS(card, byte) \
1625 *(card)->q931_write++ = (byte); \
1626 if ((card)->q931_write > (card)->q931_end) \
1627 (card)->q931_write = (card)->q931_buf; \
1630 static void handle_dtrace_data(capidrv_contr *card, handle_dtrace_data() argument
1638 card->contrnr, len); handle_dtrace_data()
1643 PUTBYTE_TO_STATUS(card, 'D'); handle_dtrace_data()
1644 PUTBYTE_TO_STATUS(card, '2'); handle_dtrace_data()
1645 PUTBYTE_TO_STATUS(card, send ? '>' : '<'); handle_dtrace_data()
1646 PUTBYTE_TO_STATUS(card, ':'); handle_dtrace_data()
1648 PUTBYTE_TO_STATUS(card, 'D'); handle_dtrace_data()
1649 PUTBYTE_TO_STATUS(card, '3'); handle_dtrace_data()
1650 PUTBYTE_TO_STATUS(card, send ? '>' : '<'); handle_dtrace_data()
1651 PUTBYTE_TO_STATUS(card, ':'); handle_dtrace_data()
1655 PUTBYTE_TO_STATUS(card, ' '); handle_dtrace_data()
1656 PUTBYTE_TO_STATUS(card, hex_asc_hi(*p)); handle_dtrace_data()
1657 PUTBYTE_TO_STATUS(card, hex_asc_lo(*p)); handle_dtrace_data()
1659 PUTBYTE_TO_STATUS(card, '\n'); handle_dtrace_data()
1662 cmd.driver = card->myid; handle_dtrace_data()
1664 card->interface.statcallb(&cmd); handle_dtrace_data()
1671 static int capidrv_ioctl(isdn_ctrl *c, capidrv_contr *card) capidrv_ioctl() argument
1677 card->contrnr, debugmode); capidrv_ioctl()
1681 card->contrnr, c->arg); capidrv_ioctl()
1786 static int capidrv_command(isdn_ctrl *c, capidrv_contr *card) capidrv_command() argument
1795 return capidrv_ioctl(c, card); capidrv_command()
1804 card->contrnr, capidrv_command()
1811 bchan = &card->bchans[c->arg % card->nbchan]; capidrv_command()
1815 card->contrnr, capidrv_command()
1832 printk(KERN_ERR "capidrv-%d: WARNING: invalid leased linedefinition \"%s\"\n", card->contrnr, bchan->num); capidrv_command()
1838 printk(KERN_DEBUG "capidrv-%d: connecting leased line\n", card->contrnr); capidrv_command()
1851 card->msgid++, capidrv_command()
1852 card->contrnr, /* adr */ capidrv_command()
1873 if ((plcip = new_plci(card, (c->arg % card->nbchan))) == NULL) { capidrv_command()
1875 cmd.driver = card->myid; capidrv_command()
1876 cmd.arg = (c->arg % card->nbchan); capidrv_command()
1877 card->interface.statcallb(&cmd); capidrv_command()
1882 plci_change_state(card, plcip, EV_PLCI_CONNECT_REQ); capidrv_command()
1883 send_message(card, &cmdcmsg); capidrv_command()
1889 bchan = &card->bchans[c->arg % card->nbchan]; capidrv_command()
1892 card->contrnr, capidrv_command()
1897 card->msgid++, capidrv_command()
1916 card->contrnr); capidrv_command()
1919 plci_change_state(card, bchan->plcip, EV_PLCI_CONNECT_RESP); capidrv_command()
1920 send_message(card, &cmdcmsg); capidrv_command()
1926 card->contrnr, capidrv_command()
1933 card->contrnr, capidrv_command()
1935 bchan = &card->bchans[c->arg % card->nbchan]; capidrv_command()
1940 card->contrnr, capidrv_command()
1948 card->msgid++, capidrv_command()
1952 ncci_change_state(card, bchan->nccip, EV_NCCI_DISCONNECT_B3_REQ); capidrv_command()
1953 send_message(card, &cmdcmsg); capidrv_command()
1969 card->msgid++, capidrv_command()
1976 plci_change_state(card, bchan->plcip, EV_PLCI_DISCONNECT_REQ); capidrv_command()
1977 send_message(card, &cmdcmsg); capidrv_command()
1981 card->contrnr, capidrv_command()
1987 card->contrnr, capidrv_command()
1995 card->contrnr, capidrv_command()
1997 bchan = &card->bchans[(c->arg & 0xff) % card->nbchan]; capidrv_command()
2004 card->contrnr, capidrv_command()
2006 bchan = &card->bchans[(c->arg & 0xff) % card->nbchan]; capidrv_command()
2013 card->contrnr, capidrv_command()
2015 bchan = &card->bchans[c->arg % card->nbchan]; capidrv_command()
2022 card->contrnr, c->arg); capidrv_command()
2023 bchan = &card->bchans[c->arg % card->nbchan]; capidrv_command()
2029 card->contrnr, c->command); capidrv_command()
2037 capidrv_contr *card = findcontrbydriverid(c->driver); if_command() local
2039 if (card) if_command()
2040 return capidrv_command(c, card); if_command()
2052 capidrv_contr *card = findcontrbydriverid(id); if_sendbuf() local
2061 if (!card) { if_sendbuf()
2068 card->contrnr, len, skb, doack); if_sendbuf()
2069 bchan = &card->bchans[channel % card->nbchan]; if_sendbuf()
2073 card->contrnr, card->name, channel); if_sendbuf()
2094 capi_fill_DATA_B3_REQ(&sendcmsg, global.ap.applid, card->msgid++, if_sendbuf()
2107 card->contrnr); if_sendbuf()
2115 card->contrnr); if_sendbuf()
2120 card->contrnr, skb_headroom(skb), msglen); if_sendbuf()
2130 card->contrnr, errcode, capi_info2str(errcode)); if_sendbuf()
2143 card->contrnr, errcode, capi_info2str(errcode)); if_sendbuf()
2152 capidrv_contr *card = findcontrbydriverid(id); if_readstat() local
2156 if (!card) { if_readstat()
2163 if (put_user(*card->q931_read++, p)) if_readstat()
2165 if (card->q931_read > card->q931_end) if_readstat()
2166 card->q931_read = card->q931_buf; if_readstat()
2172 static void enable_dchannel_trace(capidrv_contr *card) enable_dchannel_trace() argument
2176 u16 contr = card->contrnr; enable_dchannel_trace()
2183 card->name, errcode); enable_dchannel_trace()
2188 card->name, manufacturer); enable_dchannel_trace()
2194 card->name, errcode); enable_dchannel_trace()
2203 printk(KERN_INFO "%s: D2 trace enabled\n", card->name); enable_dchannel_trace()
2205 card->msgid++, enable_dchannel_trace()
2212 printk(KERN_INFO "%s: D3 trace enabled\n", card->name); enable_dchannel_trace()
2214 card->msgid++, enable_dchannel_trace()
2221 send_message(card, &cmdcmsg); enable_dchannel_trace()
2225 static void send_listen(capidrv_contr *card) send_listen() argument
2228 card->msgid++, send_listen()
2229 card->contrnr, /* controller */ send_listen()
2231 card->cipmask, send_listen()
2232 card->cipmask2, send_listen()
2234 listen_change_state(card, EV_LISTEN_REQ); send_listen()
2235 send_message(card, &cmdcmsg); send_listen()
2240 capidrv_contr *card = (capidrv_contr *)x; listentimerfunc() local
2241 if (card->state != ST_LISTEN_NONE && card->state != ST_LISTEN_ACTIVE) listentimerfunc()
2242 printk(KERN_ERR "%s: controller dead ??\n", card->name); listentimerfunc()
2243 send_listen(card); listentimerfunc()
2244 mod_timer(&card->listentimer, jiffies + 60 * HZ); listentimerfunc()
2250 capidrv_contr *card; capidrv_addcontr() local
2261 if (!(card = kzalloc(sizeof(capidrv_contr), GFP_ATOMIC))) { capidrv_addcontr()
2266 card->owner = THIS_MODULE; capidrv_addcontr()
2267 init_timer(&card->listentimer); capidrv_addcontr()
2268 strcpy(card->name, id); capidrv_addcontr()
2269 card->contrnr = contr; capidrv_addcontr()
2270 card->nbchan = profp->nbchannel; capidrv_addcontr()
2271 card->bchans = kmalloc(sizeof(capidrv_bchan) * card->nbchan, GFP_ATOMIC); capidrv_addcontr()
2272 if (!card->bchans) { capidrv_addcontr()
2275 module_put(card->owner); capidrv_addcontr()
2276 kfree(card); capidrv_addcontr()
2279 card->interface.channels = profp->nbchannel; capidrv_addcontr()
2280 card->interface.maxbufsize = 2048; capidrv_addcontr()
2281 card->interface.command = if_command; capidrv_addcontr()
2282 card->interface.writebuf_skb = if_sendbuf; capidrv_addcontr()
2283 card->interface.writecmd = NULL; capidrv_addcontr()
2284 card->interface.readstat = if_readstat; capidrv_addcontr()
2285 card->interface.features = capidrv_addcontr()
2294 card->interface.features |= capidrv_addcontr()
2299 card->interface.features |= ISDN_FEATURE_L2_MODEM; capidrv_addcontr()
2300 card->interface.hl_hdrlen = 22; /* len of DATA_B3_REQ */ capidrv_addcontr()
2301 strncpy(card->interface.id, id, sizeof(card->interface.id) - 1); capidrv_addcontr()
2304 card->q931_read = card->q931_buf; capidrv_addcontr()
2305 card->q931_write = card->q931_buf; capidrv_addcontr()
2306 card->q931_end = card->q931_buf + sizeof(card->q931_buf) - 1; capidrv_addcontr()
2308 if (!register_isdn(&card->interface)) { capidrv_addcontr()
2310 kfree(card->bchans); capidrv_addcontr()
2311 module_put(card->owner); capidrv_addcontr()
2312 kfree(card); capidrv_addcontr()
2315 card->myid = card->interface.channels; capidrv_addcontr()
2316 memset(card->bchans, 0, sizeof(capidrv_bchan) * card->nbchan); capidrv_addcontr()
2317 for (i = 0; i < card->nbchan; i++) { capidrv_addcontr()
2318 card->bchans[i].contr = card; capidrv_addcontr()
2322 card->next = global.contr_list; capidrv_addcontr()
2323 global.contr_list = card; capidrv_addcontr()
2328 cmd.driver = card->myid; capidrv_addcontr()
2329 card->interface.statcallb(&cmd); capidrv_addcontr()
2331 card->cipmask = 0x1FFF03FF; /* any */ capidrv_addcontr()
2332 card->cipmask2 = 0; capidrv_addcontr()
2334 card->listentimer.data = (unsigned long)card; capidrv_addcontr()
2335 card->listentimer.function = listentimerfunc; capidrv_addcontr()
2336 send_listen(card); capidrv_addcontr()
2337 mod_timer(&card->listentimer, jiffies + 60 * HZ); capidrv_addcontr()
2340 card->name, card->nbchan); capidrv_addcontr()
2342 enable_dchannel_trace(card); capidrv_addcontr()
2349 capidrv_contr **pp, *card; capidrv_delcontr() local
2354 for (card = global.contr_list; card; card = card->next) { capidrv_delcontr()
2355 if (card->contrnr == contr) capidrv_delcontr()
2358 if (!card) { capidrv_delcontr()
2364 /* FIXME: maybe a race condition the card should be removed capidrv_delcontr()
2369 del_timer(&card->listentimer); capidrv_delcontr()
2373 card->contrnr, card->myid); capidrv_delcontr()
2376 cmd.driver = card->myid; capidrv_delcontr()
2377 card->interface.statcallb(&cmd); capidrv_delcontr()
2379 while (card->nbchan) { capidrv_delcontr()
2382 cmd.driver = card->myid; capidrv_delcontr()
2383 cmd.arg = card->nbchan - 1; capidrv_delcontr()
2387 card->contrnr, card->myid, cmd.arg); capidrv_delcontr()
2388 card->interface.statcallb(&cmd); capidrv_delcontr()
2390 if (card->bchans[card->nbchan - 1].nccip) capidrv_delcontr()
2391 free_ncci(card, card->bchans[card->nbchan - 1].nccip); capidrv_delcontr()
2392 if (card->bchans[card->nbchan - 1].plcip) capidrv_delcontr()
2393 free_plci(card, card->bchans[card->nbchan - 1].plcip); capidrv_delcontr()
2394 if (card->plci_list) capidrv_delcontr()
2396 card->nbchan--; capidrv_delcontr()
2398 kfree(card->bchans); capidrv_delcontr()
2399 card->bchans = NULL; capidrv_delcontr()
2403 card->contrnr, card->myid); capidrv_delcontr()
2406 cmd.driver = card->myid; capidrv_delcontr()
2407 card->interface.statcallb(&cmd); capidrv_delcontr()
2411 card->contrnr, card->myid); capidrv_delcontr()
2415 if (*pp == card) { capidrv_delcontr()
2417 card->next = NULL; capidrv_delcontr()
2424 module_put(card->owner); capidrv_delcontr()
2425 printk(KERN_INFO "%s: now down.\n", card->name); capidrv_delcontr()
2426 kfree(card); capidrv_delcontr()
/linux-4.1.27/drivers/isdn/hardware/eicon/
H A Didifunc.c59 * find card in list
63 udiva_card *card; find_card_in_list() local
67 diva_os_enter_spin_lock(&ll_lock, &old_irql, "find card"); find_card_in_list()
69 card = list_entry(tmp, udiva_card, list); find_card_in_list()
70 if (card->d.request == d->request) { find_card_in_list()
72 "find card"); find_card_in_list()
73 return (card); find_card_in_list()
76 diva_os_leave_spin_lock(&ll_lock, &old_irql, "find card"); find_card_in_list()
81 * new card
86 udiva_card *card = NULL; um_new_card() local
90 if (!(card = diva_os_malloc(0, sizeof(udiva_card)))) { um_new_card()
91 DBG_ERR(("cannot get buffer for card")); um_new_card()
94 memcpy(&card->d, d, sizeof(DESCRIPTOR)); um_new_card()
98 card->d.request((ENTITY *)&sync_req); um_new_card()
101 card->Id = adapter_nr; um_new_card()
103 diva_os_enter_spin_lock(&ll_lock, &old_irql, "add card"); um_new_card()
104 list_add_tail(&card->list, &cards); um_new_card()
105 diva_os_leave_spin_lock(&ll_lock, &old_irql, "add card"); um_new_card()
107 DBG_ERR(("could not create user mode idi card %d", um_new_card()
109 diva_os_free(0, card); um_new_card()
114 * remove card
119 udiva_card *card = NULL; um_remove_card() local
121 if (!(card = find_card_in_list(d))) { um_remove_card()
122 DBG_ERR(("cannot find card to remove")); um_remove_card()
125 diva_user_mode_idi_remove_adapter(card->Id); um_remove_card()
126 diva_os_enter_spin_lock(&ll_lock, &old_irql, "remove card"); um_remove_card()
127 list_del(&card->list); um_remove_card()
128 diva_os_leave_spin_lock(&ll_lock, &old_irql, "remove card"); um_remove_card()
129 DBG_LOG(("idi proc entry removed for card %d", card->Id)); um_remove_card()
130 diva_os_free(0, card); um_remove_card()
138 udiva_card *card; remove_all_idi_proc() local
144 card = list_entry(cards.next, udiva_card, list); remove_all_idi_proc()
145 list_del(&card->list); remove_all_idi_proc()
147 diva_user_mode_idi_remove_adapter(card->Id); remove_all_idi_proc()
148 diva_os_free(0, card); remove_all_idi_proc()
H A Ddivasfunc.c64 void diva_xdi_didd_register_adapter(int card) diva_xdi_didd_register_adapter() argument
69 if (card && ((card - 1) < MAX_ADAPTER) && diva_xdi_didd_register_adapter()
70 IoAdapters[card - 1] && Requests[card - 1]) { diva_xdi_didd_register_adapter()
71 d.type = IoAdapters[card - 1]->Properties.DescType; diva_xdi_didd_register_adapter()
72 d.request = Requests[card - 1]; diva_xdi_didd_register_adapter()
73 d.channels = IoAdapters[card - 1]->Properties.Channels; diva_xdi_didd_register_adapter()
74 d.features = IoAdapters[card - 1]->Properties.Features; diva_xdi_didd_register_adapter()
75 DBG_TRC(("DIDD register A(%d) channels=%d", card, diva_xdi_didd_register_adapter()
78 strlcpy(IoAdapters[card - 1]->Name, diva_xdi_didd_register_adapter()
79 IoAdapters[card - 1]->Properties.Name, diva_xdi_didd_register_adapter()
80 sizeof(IoAdapters[card - 1]->Name)); diva_xdi_didd_register_adapter()
86 DBG_ERR(("DIDD register A(%d) failed !", card)) diva_xdi_didd_register_adapter()
88 IoAdapters[card - 1]->os_trap_nfy_Fnc = NULL; diva_xdi_didd_register_adapter()
95 void diva_xdi_didd_remove_adapter(int card) diva_xdi_didd_remove_adapter() argument
98 ADAPTER *a = &IoAdapters[card - 1]->a; diva_xdi_didd_remove_adapter()
100 IoAdapters[card - 1]->os_trap_nfy_Fnc = NULL; diva_xdi_didd_remove_adapter()
101 DBG_TRC(("DIDD de-register A(%d)", card)) diva_xdi_didd_remove_adapter()
105 (IDI_CALL) Requests[card - 1]; diva_xdi_didd_remove_adapter()
/linux-4.1.27/sound/core/
H A Dinit.c99 int (*snd_mixer_oss_notify_callback)(struct snd_card *card, int free_flag);
107 snd_iprintf(buffer, "%s\n", entry->card->id); snd_card_id_read()
110 static inline int init_info_for_card(struct snd_card *card) init_info_for_card() argument
115 if ((err = snd_info_card_register(card)) < 0) { init_info_for_card()
116 dev_dbg(card->dev, "unable to create card info\n"); init_info_for_card()
119 if ((entry = snd_info_create_card_entry(card, "id", card->proc_root)) == NULL) { init_info_for_card()
120 dev_dbg(card->dev, "unable to create card entry\n"); init_info_for_card()
128 card->proc_id = entry; init_info_for_card()
132 #define init_info_for_card(card)
171 * @card: card to assign, optional
173 void snd_device_initialize(struct device *dev, struct snd_card *card) snd_device_initialize() argument
176 if (card) snd_device_initialize()
177 dev->parent = &card->card_dev; snd_device_initialize()
183 static int snd_card_do_free(struct snd_card *card);
194 * @idx: card index (address) [0 ... (SNDRV_CARDS-1)]
195 * @xid: card identification (ASCII string)
198 * @card_ret: the pointer to store the created card instance
212 struct snd_card *card; snd_card_new() local
221 card = kzalloc(sizeof(*card) + extra_size, GFP_KERNEL); snd_card_new()
222 if (!card) snd_card_new()
225 card->private_data = (char *)card + sizeof(struct snd_card); snd_card_new()
227 strlcpy(card->id, xid, sizeof(card->id)); snd_card_new()
245 kfree(card); snd_card_new()
252 card->dev = parent; snd_card_new()
253 card->number = idx; snd_card_new()
254 card->module = module; snd_card_new()
255 INIT_LIST_HEAD(&card->devices); snd_card_new()
256 init_rwsem(&card->controls_rwsem); snd_card_new()
257 rwlock_init(&card->ctl_files_rwlock); snd_card_new()
258 mutex_init(&card->user_ctl_lock); snd_card_new()
259 INIT_LIST_HEAD(&card->controls); snd_card_new()
260 INIT_LIST_HEAD(&card->ctl_files); snd_card_new()
261 spin_lock_init(&card->files_lock); snd_card_new()
262 INIT_LIST_HEAD(&card->files_list); snd_card_new()
264 mutex_init(&card->power_lock); snd_card_new()
265 init_waitqueue_head(&card->power_sleep); snd_card_new()
268 device_initialize(&card->card_dev); snd_card_new()
269 card->card_dev.parent = parent; snd_card_new()
270 card->card_dev.class = sound_class; snd_card_new()
271 card->card_dev.release = release_card_device; snd_card_new()
272 card->card_dev.groups = card->dev_groups; snd_card_new()
273 card->dev_groups[0] = &card_dev_attr_group; snd_card_new()
274 err = kobject_set_name(&card->card_dev.kobj, "card%d", idx); snd_card_new()
280 err = snd_ctl_create(card); snd_card_new()
285 err = snd_info_card_create(card); snd_card_new()
287 dev_err(parent, "unable to create card info\n"); snd_card_new()
290 *card_ret = card; snd_card_new()
294 snd_device_free_all(card); snd_card_new()
296 put_device(&card->card_dev); snd_card_new()
301 /* return non-zero if a card is already locked */ snd_card_locked()
302 int snd_card_locked(int card) snd_card_locked() argument
307 locked = test_bit(card, snd_cards_lock); snd_card_locked()
391 * @card: soundcard structure
400 int snd_card_disconnect(struct snd_card *card) snd_card_disconnect() argument
404 if (!card) snd_card_disconnect()
407 spin_lock(&card->files_lock); snd_card_disconnect()
408 if (card->shutdown) { snd_card_disconnect()
409 spin_unlock(&card->files_lock); snd_card_disconnect()
412 card->shutdown = 1; snd_card_disconnect()
413 spin_unlock(&card->files_lock); snd_card_disconnect()
417 snd_cards[card->number] = NULL; snd_card_disconnect()
418 clear_bit(card->number, snd_cards_lock); snd_card_disconnect()
423 spin_lock(&card->files_lock); snd_card_disconnect()
424 list_for_each_entry(mfile, &card->files_list, list) { snd_card_disconnect()
436 spin_unlock(&card->files_lock); snd_card_disconnect()
443 snd_mixer_oss_notify_callback(card, SND_MIXER_OSS_NOTIFY_DISCONNECT); snd_card_disconnect()
447 snd_device_disconnect_all(card); snd_card_disconnect()
449 snd_info_card_disconnect(card); snd_card_disconnect()
450 if (card->registered) { snd_card_disconnect()
451 device_del(&card->card_dev); snd_card_disconnect()
452 card->registered = false; snd_card_disconnect()
455 wake_up(&card->power_sleep); snd_card_disconnect()
462 static int snd_card_do_free(struct snd_card *card) snd_card_do_free() argument
466 snd_mixer_oss_notify_callback(card, SND_MIXER_OSS_NOTIFY_FREE); snd_card_do_free()
468 snd_device_free_all(card); snd_card_do_free()
469 if (card->private_free) snd_card_do_free()
470 card->private_free(card); snd_card_do_free()
471 snd_info_free_entry(card->proc_id); snd_card_do_free()
472 if (snd_info_card_free(card) < 0) { snd_card_do_free()
473 dev_warn(card->dev, "unable to free card info\n"); snd_card_do_free()
476 if (card->release_completion) snd_card_do_free()
477 complete(card->release_completion); snd_card_do_free()
478 kfree(card); snd_card_do_free()
483 * snd_card_free_when_closed - Disconnect the card, free it later eventually
484 * @card: soundcard structure
486 * Unlike snd_card_free(), this function doesn't try to release the card
487 * resource immediately, but tries to disconnect at first. When the card
489 * The card resources will be freed when the refcount gets to zero.
491 int snd_card_free_when_closed(struct snd_card *card) snd_card_free_when_closed() argument
493 int ret = snd_card_disconnect(card); snd_card_free_when_closed()
496 put_device(&card->card_dev); snd_card_free_when_closed()
503 * @card: soundcard structure
514 int snd_card_free(struct snd_card *card) snd_card_free() argument
520 card->release_completion = &released; snd_card_free()
521 ret = snd_card_free_when_closed(card); snd_card_free()
543 /* return true if the given id string doesn't conflict any other card ids */ card_id_ok()
544 static bool card_id_ok(struct snd_card *card, const char *id) card_id_ok() argument
550 if (snd_cards[i] && snd_cards[i] != card && card_id_ok()
557 /* copy to card->id only with valid letters from nid */ copy_valid_id_string()
558 static void copy_valid_id_string(struct snd_card *card, const char *src, copy_valid_id_string() argument
561 char *id = card->id; copy_valid_id_string()
567 while (*nid && (size_t)(id - card->id) < sizeof(card->id) - 1) { copy_valid_id_string()
575 /* Set card->id from the given string
578 static void snd_card_set_id_no_lock(struct snd_card *card, const char *src, snd_card_set_id_no_lock() argument
585 copy_valid_id_string(card, src, nid); snd_card_set_id_no_lock()
586 id = card->id; snd_card_set_id_no_lock()
590 * ("card" conflicts with proc directories) snd_card_set_id_no_lock()
592 if (!*id || !strncmp(id, "card", 4)) { snd_card_set_id_no_lock()
603 if (card_id_ok(card, id)) snd_card_set_id_no_lock()
609 if (len + sfxlen >= sizeof(card->id)) snd_card_set_id_no_lock()
610 spos = id + sizeof(card->id) - sfxlen - 1; snd_card_set_id_no_lock()
621 dev_err(card->dev, "unable to set card id (%s)\n", id); snd_card_set_id_no_lock()
622 if (card->proc_root->name) snd_card_set_id_no_lock()
623 strlcpy(card->id, card->proc_root->name, sizeof(card->id)); snd_card_set_id_no_lock()
627 * snd_card_set_id - set card identification name
628 * @card: soundcard structure
631 * This function sets the card identification and checks for name
634 void snd_card_set_id(struct snd_card *card, const char *nid) snd_card_set_id() argument
636 /* check if user specified own card->id */ snd_card_set_id()
637 if (card->id[0] != '\0') snd_card_set_id()
640 snd_card_set_id_no_lock(card, nid, nid); snd_card_set_id()
649 struct snd_card *card = container_of(dev, struct snd_card, card_dev); card_id_show_attr() local
650 return snprintf(buf, PAGE_SIZE, "%s\n", card->id); card_id_show_attr()
657 struct snd_card *card = container_of(dev, struct snd_card, card_dev); card_id_store_attr() local
658 char buf1[sizeof(card->id)]; card_id_store_attr()
659 size_t copy = count > sizeof(card->id) - 1 ? card_id_store_attr()
660 sizeof(card->id) - 1 : count; card_id_store_attr()
676 strcpy(card->id, buf1); card_id_store_attr()
677 snd_info_card_id_change(card); card_id_store_attr()
689 struct snd_card *card = container_of(dev, struct snd_card, card_dev); card_number_show_attr() local
690 return snprintf(buf, PAGE_SIZE, "%i\n", card->number); card_number_show_attr()
706 * snd_card_add_dev_attr - Append a new sysfs attribute group to card
707 * @card: card instance
710 int snd_card_add_dev_attr(struct snd_card *card, snd_card_add_dev_attr() argument
716 for (i = 0; i < ARRAY_SIZE(card->dev_groups) - 1; i++) { snd_card_add_dev_attr()
717 if (!card->dev_groups[i]) { snd_card_add_dev_attr()
718 card->dev_groups[i] = group; snd_card_add_dev_attr()
723 dev_err(card->dev, "Too many groups assigned\n"); snd_card_add_dev_attr()
730 * @card: soundcard structure
735 * of the initialization of the card.
739 int snd_card_register(struct snd_card *card) snd_card_register() argument
743 if (snd_BUG_ON(!card)) snd_card_register()
746 if (!card->registered) { snd_card_register()
747 err = device_add(&card->card_dev); snd_card_register()
750 card->registered = true; snd_card_register()
753 if ((err = snd_device_register_all(card)) < 0) snd_card_register()
756 if (snd_cards[card->number]) { snd_card_register()
761 if (*card->id) { snd_card_register()
763 char tmpid[sizeof(card->id)]; snd_card_register()
764 memcpy(tmpid, card->id, sizeof(card->id)); snd_card_register()
765 snd_card_set_id_no_lock(card, tmpid, tmpid); snd_card_register()
769 src = *card->shortname ? card->shortname : card->longname; snd_card_register()
770 snd_card_set_id_no_lock(card, src, snd_card_register()
773 snd_cards[card->number] = card; snd_card_register()
775 init_info_for_card(card); snd_card_register()
778 snd_mixer_oss_notify_callback(card, SND_MIXER_OSS_NOTIFY_REGISTER); snd_card_register()
792 struct snd_card *card; snd_card_info_read() local
796 if ((card = snd_cards[idx]) != NULL) { snd_card_info_read()
800 card->id, snd_card_info_read()
801 card->driver, snd_card_info_read()
802 card->shortname); snd_card_info_read()
804 card->longname); snd_card_info_read()
817 struct snd_card *card; snd_card_info_read_oss() local
821 if ((card = snd_cards[idx]) != NULL) { snd_card_info_read_oss()
823 snd_iprintf(buffer, "%s\n", card->longname); snd_card_info_read_oss()
840 struct snd_card *card; snd_card_module_info_read() local
844 if ((card = snd_cards[idx]) != NULL) snd_card_module_info_read()
846 idx, card->module->name); snd_card_module_info_read()
893 * @card: soundcard structure
902 int snd_component_add(struct snd_card *card, const char *component) snd_component_add() argument
907 ptr = strstr(card->components, component); snd_component_add()
912 if (strlen(card->components) + 1 + len + 1 > sizeof(card->components)) { snd_component_add()
916 if (card->components[0] != '\0') snd_component_add()
917 strcat(card->components, " "); snd_component_add()
918 strcat(card->components, component); snd_component_add()
925 * snd_card_file_add - add the file to the file list of the card
926 * @card: soundcard structure
929 * This function adds the file to the file linked-list of the card.
935 int snd_card_file_add(struct snd_card *card, struct file *file) snd_card_file_add() argument
945 spin_lock(&card->files_lock); snd_card_file_add()
946 if (card->shutdown) { snd_card_file_add()
947 spin_unlock(&card->files_lock); snd_card_file_add()
951 list_add(&mfile->list, &card->files_list); snd_card_file_add()
952 get_device(&card->card_dev); snd_card_file_add()
953 spin_unlock(&card->files_lock); snd_card_file_add()
961 * @card: soundcard structure
964 * This function removes the file formerly added to the card via
972 int snd_card_file_remove(struct snd_card *card, struct file *file) snd_card_file_remove() argument
976 spin_lock(&card->files_lock); snd_card_file_remove()
977 list_for_each_entry(mfile, &card->files_list, list) { snd_card_file_remove()
989 spin_unlock(&card->files_lock); snd_card_file_remove()
991 dev_err(card->dev, "card file remove problem (%p)\n", file); snd_card_file_remove()
995 put_device(&card->card_dev); snd_card_file_remove()
1004 * @card: soundcard structure
1013 int snd_power_wait(struct snd_card *card, unsigned int power_state) snd_power_wait() argument
1019 if (snd_power_get_state(card) == power_state) snd_power_wait()
1022 add_wait_queue(&card->power_sleep, &wait); snd_power_wait()
1024 if (card->shutdown) { snd_power_wait()
1028 if (snd_power_get_state(card) == power_state) snd_power_wait()
1031 snd_power_unlock(card); snd_power_wait()
1033 snd_power_lock(card); snd_power_wait()
1035 remove_wait_queue(&card->power_sleep, &wait); snd_power_wait()
H A Ddevice.c30 * @card: the card instance
36 * The device will be assigned to the card and managed together
37 * by the card.
44 int snd_device_new(struct snd_card *card, enum snd_device_type type, snd_device_new() argument
50 if (snd_BUG_ON(!card || !device_data || !ops)) snd_device_new()
56 dev->card = card; snd_device_new()
63 list_for_each_prev(p, &card->devices) { snd_device_new()
79 dev_err(dev->card->dev, "device disconnect failure\n"); __snd_device_disconnect()
92 dev_err(dev->card->dev, "device free failure\n"); __snd_device_free()
97 static struct snd_device *look_for_dev(struct snd_card *card, void *device_data) look_for_dev() argument
101 list_for_each_entry(dev, &card->devices, list) look_for_dev()
110 * @card: the card instance
121 void snd_device_disconnect(struct snd_card *card, void *device_data) snd_device_disconnect() argument
125 if (snd_BUG_ON(!card || !device_data)) snd_device_disconnect()
127 dev = look_for_dev(card, device_data); snd_device_disconnect()
131 dev_dbg(card->dev, "device disconnect %p (from %pF), not found\n", snd_device_disconnect()
137 * snd_device_free - release the device from the card
138 * @card: the card instance
141 * Removes the device from the list on the card and invokes the
145 void snd_device_free(struct snd_card *card, void *device_data) snd_device_free() argument
149 if (snd_BUG_ON(!card || !device_data)) snd_device_free()
151 dev = look_for_dev(card, device_data); snd_device_free()
155 dev_dbg(card->dev, "device free %p (from %pF), not found\n", snd_device_free()
175 * @card: the card instance
186 int snd_device_register(struct snd_card *card, void *device_data) snd_device_register() argument
190 if (snd_BUG_ON(!card || !device_data)) snd_device_register()
192 dev = look_for_dev(card, device_data); snd_device_register()
201 * register all the devices on the card.
204 int snd_device_register_all(struct snd_card *card) snd_device_register_all() argument
209 if (snd_BUG_ON(!card)) snd_device_register_all()
211 list_for_each_entry(dev, &card->devices, list) { snd_device_register_all()
220 * disconnect all the devices on the card.
223 void snd_device_disconnect_all(struct snd_card *card) snd_device_disconnect_all() argument
227 if (snd_BUG_ON(!card)) snd_device_disconnect_all()
229 list_for_each_entry_reverse(dev, &card->devices, list) snd_device_disconnect_all()
234 * release all the devices on the card.
237 void snd_device_free_all(struct snd_card *card) snd_device_free_all() argument
241 if (snd_BUG_ON(!card)) snd_device_free_all()
243 list_for_each_entry_safe_reverse(dev, next, &card->devices, list) snd_device_free_all()
H A Dcontrol.c51 struct snd_card *card; snd_ctl_open() local
59 card = snd_lookup_minor_data(iminor(inode), SNDRV_DEVICE_TYPE_CONTROL); snd_ctl_open()
60 if (!card) { snd_ctl_open()
64 err = snd_card_file_add(card, file); snd_ctl_open()
69 if (!try_module_get(card->module)) { snd_ctl_open()
81 ctl->card = card; snd_ctl_open()
86 write_lock_irqsave(&card->ctl_files_rwlock, flags); snd_ctl_open()
87 list_add_tail(&ctl->list, &card->ctl_files); snd_ctl_open()
88 write_unlock_irqrestore(&card->ctl_files_rwlock, flags); snd_ctl_open()
89 snd_card_unref(card); snd_ctl_open()
93 module_put(card->module); snd_ctl_open()
95 snd_card_file_remove(card, file); snd_ctl_open()
97 if (card) snd_ctl_open()
98 snd_card_unref(card); snd_ctl_open()
119 struct snd_card *card; snd_ctl_release() local
126 card = ctl->card; snd_ctl_release()
127 write_lock_irqsave(&card->ctl_files_rwlock, flags); snd_ctl_release()
129 write_unlock_irqrestore(&card->ctl_files_rwlock, flags); snd_ctl_release()
130 down_write(&card->controls_rwsem); snd_ctl_release()
131 list_for_each_entry(control, &card->controls, list) snd_ctl_release()
135 up_write(&card->controls_rwsem); snd_ctl_release()
139 module_put(card->module); snd_ctl_release()
140 snd_card_file_remove(card, file); snd_ctl_release()
146 * @card: the card to send notification
154 void snd_ctl_notify(struct snd_card *card, unsigned int mask, snd_ctl_notify() argument
161 if (snd_BUG_ON(!card || !id)) snd_ctl_notify()
163 read_lock(&card->ctl_files_rwlock); snd_ctl_notify()
165 card->mixer_oss_change_count++; snd_ctl_notify()
167 list_for_each_entry(ctl, &card->ctl_files, list) { snd_ctl_notify()
183 dev_err(card->dev, "No memory available to allocate event\n"); snd_ctl_notify()
190 read_unlock(&card->ctl_files_rwlock); snd_ctl_notify()
302 * Don't call this after the control was added to the card.
314 static bool snd_ctl_remove_numid_conflict(struct snd_card *card, snd_ctl_remove_numid_conflict() argument
320 if (card->last_numid >= UINT_MAX - count) snd_ctl_remove_numid_conflict()
321 card->last_numid = 0; snd_ctl_remove_numid_conflict()
323 list_for_each_entry(kctl, &card->controls, list) { snd_ctl_remove_numid_conflict()
324 if (kctl->id.numid < card->last_numid + 1 + count && snd_ctl_remove_numid_conflict()
325 kctl->id.numid + kctl->count > card->last_numid + 1) { snd_ctl_remove_numid_conflict()
326 card->last_numid = kctl->id.numid + kctl->count - 1; snd_ctl_remove_numid_conflict()
333 static int snd_ctl_find_hole(struct snd_card *card, unsigned int count) snd_ctl_find_hole() argument
337 while (snd_ctl_remove_numid_conflict(card, count)) { snd_ctl_find_hole()
340 dev_err(card->dev, "unable to allocate new control numid\n"); snd_ctl_find_hole()
348 * snd_ctl_add - add the control instance to the card
349 * @card: the card instance
353 * snd_ctl_new1() to the given card. Assigns also an unique
361 int snd_ctl_add(struct snd_card *card, struct snd_kcontrol *kcontrol) snd_ctl_add() argument
370 if (snd_BUG_ON(!card || !kcontrol->info)) snd_ctl_add()
376 down_write(&card->controls_rwsem); snd_ctl_add()
377 if (snd_ctl_find_id(card, &id)) { snd_ctl_add()
378 up_write(&card->controls_rwsem); snd_ctl_add()
379 dev_err(card->dev, "control %i:%i:%i:%s:%i is already present\n", snd_ctl_add()
388 if (snd_ctl_find_hole(card, kcontrol->count) < 0) { snd_ctl_add()
389 up_write(&card->controls_rwsem); snd_ctl_add()
393 list_add_tail(&kcontrol->list, &card->controls); snd_ctl_add()
394 card->controls_count += kcontrol->count; snd_ctl_add()
395 kcontrol->id.numid = card->last_numid + 1; snd_ctl_add()
396 card->last_numid += kcontrol->count; snd_ctl_add()
399 up_write(&card->controls_rwsem); snd_ctl_add()
401 snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_ADD, &id); snd_ctl_add()
411 * snd_ctl_replace - replace the control instance of the card
412 * @card: the card instance
424 int snd_ctl_replace(struct snd_card *card, struct snd_kcontrol *kcontrol, snd_ctl_replace() argument
435 if (snd_BUG_ON(!card || !kcontrol->info)) { snd_ctl_replace()
440 down_write(&card->controls_rwsem); snd_ctl_replace()
441 old = snd_ctl_find_id(card, &id); snd_ctl_replace()
445 up_write(&card->controls_rwsem); snd_ctl_replace()
449 ret = snd_ctl_remove(card, old); snd_ctl_replace()
451 up_write(&card->controls_rwsem); snd_ctl_replace()
455 if (snd_ctl_find_hole(card, kcontrol->count) < 0) { snd_ctl_replace()
456 up_write(&card->controls_rwsem); snd_ctl_replace()
460 list_add_tail(&kcontrol->list, &card->controls); snd_ctl_replace()
461 card->controls_count += kcontrol->count; snd_ctl_replace()
462 kcontrol->id.numid = card->last_numid + 1; snd_ctl_replace()
463 card->last_numid += kcontrol->count; snd_ctl_replace()
466 up_write(&card->controls_rwsem); snd_ctl_replace()
468 snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_ADD, &id); snd_ctl_replace()
478 * snd_ctl_remove - remove the control from the card and release it
479 * @card: the card instance
482 * Removes the control from the card and then releases the instance.
484 * the write lock - down_write(&card->controls_rwsem).
488 int snd_ctl_remove(struct snd_card *card, struct snd_kcontrol *kcontrol) snd_ctl_remove() argument
493 if (snd_BUG_ON(!card || !kcontrol)) snd_ctl_remove()
496 card->controls_count -= kcontrol->count; snd_ctl_remove()
499 snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_REMOVE, &id); snd_ctl_remove()
507 * @card: the card instance
511 * card list and releases it.
515 int snd_ctl_remove_id(struct snd_card *card, struct snd_ctl_elem_id *id) snd_ctl_remove_id() argument
520 down_write(&card->controls_rwsem); snd_ctl_remove_id()
521 kctl = snd_ctl_find_id(card, id); snd_ctl_remove_id()
523 up_write(&card->controls_rwsem); snd_ctl_remove_id()
526 ret = snd_ctl_remove(card, kctl); snd_ctl_remove_id()
527 up_write(&card->controls_rwsem); snd_ctl_remove_id()
538 * card list and releases it.
545 struct snd_card *card = file->card; snd_ctl_remove_user_ctl() local
549 down_write(&card->controls_rwsem); snd_ctl_remove_user_ctl()
550 kctl = snd_ctl_find_id(card, id); snd_ctl_remove_user_ctl()
564 ret = snd_ctl_remove(card, kctl); snd_ctl_remove_user_ctl()
567 card->user_ctl_count--; snd_ctl_remove_user_ctl()
569 up_write(&card->controls_rwsem); snd_ctl_remove_user_ctl()
575 * @card: the card instance
585 int snd_ctl_activate_id(struct snd_card *card, struct snd_ctl_elem_id *id, snd_ctl_activate_id() argument
593 down_write(&card->controls_rwsem); snd_ctl_activate_id()
594 kctl = snd_ctl_find_id(card, id); snd_ctl_activate_id()
614 up_write(&card->controls_rwsem); snd_ctl_activate_id()
616 snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_INFO, id); snd_ctl_activate_id()
622 * snd_ctl_rename_id - replace the id of a control on the card
623 * @card: the card instance
627 * Finds the control with the old id from the card, and replaces the
632 int snd_ctl_rename_id(struct snd_card *card, struct snd_ctl_elem_id *src_id, snd_ctl_rename_id() argument
637 down_write(&card->controls_rwsem); snd_ctl_rename_id()
638 kctl = snd_ctl_find_id(card, src_id); snd_ctl_rename_id()
640 up_write(&card->controls_rwsem); snd_ctl_rename_id()
644 kctl->id.numid = card->last_numid + 1; snd_ctl_rename_id()
645 card->last_numid += kctl->count; snd_ctl_rename_id()
646 up_write(&card->controls_rwsem); snd_ctl_rename_id()
653 * @card: the card instance
656 * Finds the control instance with the given number-id from the card.
658 * The caller must down card->controls_rwsem before calling this function
664 struct snd_kcontrol *snd_ctl_find_numid(struct snd_card *card, unsigned int numid) snd_ctl_find_numid() argument
668 if (snd_BUG_ON(!card || !numid)) snd_ctl_find_numid()
670 list_for_each_entry(kctl, &card->controls, list) { snd_ctl_find_numid()
680 * @card: the card instance
683 * Finds the control instance with the given id from the card.
685 * The caller must down card->controls_rwsem before calling this function
691 struct snd_kcontrol *snd_ctl_find_id(struct snd_card *card, snd_ctl_find_id() argument
696 if (snd_BUG_ON(!card || !id)) snd_ctl_find_id()
699 return snd_ctl_find_numid(card, id->numid); snd_ctl_find_id()
700 list_for_each_entry(kctl, &card->controls, list) { snd_ctl_find_id()
719 static int snd_ctl_card_info(struct snd_card *card, struct snd_ctl_file * ctl, snd_ctl_card_info() argument
728 info->card = card->number; snd_ctl_card_info()
729 strlcpy(info->id, card->id, sizeof(info->id)); snd_ctl_card_info()
730 strlcpy(info->driver, card->driver, sizeof(info->driver)); snd_ctl_card_info()
731 strlcpy(info->name, card->shortname, sizeof(info->name)); snd_ctl_card_info()
732 strlcpy(info->longname, card->longname, sizeof(info->longname)); snd_ctl_card_info()
733 strlcpy(info->mixername, card->mixername, sizeof(info->mixername)); snd_ctl_card_info()
734 strlcpy(info->components, card->components, sizeof(info->components)); snd_ctl_card_info()
744 static int snd_ctl_elem_list(struct snd_card *card, snd_ctl_elem_list() argument
765 down_read(&card->controls_rwsem); snd_ctl_elem_list()
766 list.count = card->controls_count; snd_ctl_elem_list()
767 plist = card->controls.next; snd_ctl_elem_list()
768 while (plist != &card->controls) { snd_ctl_elem_list()
779 while (space > 0 && plist != &card->controls) { snd_ctl_elem_list()
790 up_read(&card->controls_rwsem); snd_ctl_elem_list()
799 down_read(&card->controls_rwsem); snd_ctl_elem_list()
800 list.count = card->controls_count; snd_ctl_elem_list()
801 up_read(&card->controls_rwsem); snd_ctl_elem_list()
811 struct snd_card *card = ctl->card; snd_ctl_elem_info() local
817 down_read(&card->controls_rwsem); snd_ctl_elem_info()
818 kctl = snd_ctl_find_id(card, &info->id); snd_ctl_elem_info()
820 up_read(&card->controls_rwsem); snd_ctl_elem_info()
842 up_read(&card->controls_rwsem); snd_ctl_elem_info()
854 snd_power_lock(ctl->card); snd_ctl_elem_info_user()
855 result = snd_power_wait(ctl->card, SNDRV_CTL_POWER_D0); snd_ctl_elem_info_user()
858 snd_power_unlock(ctl->card); snd_ctl_elem_info_user()
865 static int snd_ctl_elem_read(struct snd_card *card, snd_ctl_elem_read() argument
873 down_read(&card->controls_rwsem); snd_ctl_elem_read()
874 kctl = snd_ctl_find_id(card, &control->id); snd_ctl_elem_read()
887 up_read(&card->controls_rwsem); snd_ctl_elem_read()
891 static int snd_ctl_elem_read_user(struct snd_card *card, snd_ctl_elem_read_user() argument
901 snd_power_lock(card); snd_ctl_elem_read_user()
902 result = snd_power_wait(card, SNDRV_CTL_POWER_D0); snd_ctl_elem_read_user()
904 result = snd_ctl_elem_read(card, control); snd_ctl_elem_read_user()
905 snd_power_unlock(card); snd_ctl_elem_read_user()
913 static int snd_ctl_elem_write(struct snd_card *card, struct snd_ctl_file *file, snd_ctl_elem_write() argument
921 down_read(&card->controls_rwsem); snd_ctl_elem_write()
922 kctl = snd_ctl_find_id(card, &control->id); snd_ctl_elem_write()
938 up_read(&card->controls_rwsem); snd_ctl_elem_write()
939 snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE, &id); snd_ctl_elem_write()
943 up_read(&card->controls_rwsem); snd_ctl_elem_write()
951 struct snd_card *card; snd_ctl_elem_write_user() local
958 card = file->card; snd_ctl_elem_write_user()
959 snd_power_lock(card); snd_ctl_elem_write_user()
960 result = snd_power_wait(card, SNDRV_CTL_POWER_D0); snd_ctl_elem_write_user()
962 result = snd_ctl_elem_write(card, file, control); snd_ctl_elem_write_user()
963 snd_power_unlock(card); snd_ctl_elem_write_user()
974 struct snd_card *card = file->card; snd_ctl_elem_lock() local
982 down_write(&card->controls_rwsem); snd_ctl_elem_lock()
983 kctl = snd_ctl_find_id(card, &id); snd_ctl_elem_lock()
995 up_write(&card->controls_rwsem); snd_ctl_elem_lock()
1002 struct snd_card *card = file->card; snd_ctl_elem_unlock() local
1010 down_write(&card->controls_rwsem); snd_ctl_elem_unlock()
1011 kctl = snd_ctl_find_id(card, &id); snd_ctl_elem_unlock()
1025 up_write(&card->controls_rwsem); snd_ctl_elem_unlock()
1031 struct snd_card *card; member in struct:user_element
1085 mutex_lock(&ue->card->user_ctl_lock); snd_ctl_elem_user_get()
1087 mutex_unlock(&ue->card->user_ctl_lock); snd_ctl_elem_user_get()
1100 mutex_lock(&ue->card->user_ctl_lock); snd_ctl_elem_user_put()
1104 mutex_unlock(&ue->card->user_ctl_lock); snd_ctl_elem_user_put()
1124 mutex_lock(&ue->card->user_ctl_lock); snd_ctl_elem_user_tlv()
1131 mutex_unlock(&ue->card->user_ctl_lock); snd_ctl_elem_user_tlv()
1135 mutex_lock(&ue->card->user_ctl_lock); snd_ctl_elem_user_tlv()
1147 mutex_unlock(&ue->card->user_ctl_lock); snd_ctl_elem_user_tlv()
1217 struct snd_card *card = file->card; snd_ctl_elem_add() local
1243 if (card->user_ctl_count + 1 > MAX_USER_CONTROLS) snd_ctl_elem_add()
1297 ue->card = card; snd_ctl_elem_add()
1323 err = snd_ctl_add(card, kctl); snd_ctl_elem_add()
1336 down_write(&card->controls_rwsem); snd_ctl_elem_add()
1337 card->user_ctl_count++; snd_ctl_elem_add()
1338 up_write(&card->controls_rwsem); snd_ctl_elem_add()
1397 struct snd_card *card = file->card; snd_ctl_tlv_ioctl() local
1410 down_read(&card->controls_rwsem); snd_ctl_tlv_ioctl()
1411 kctl = snd_ctl_find_numid(card, tlv.numid); snd_ctl_tlv_ioctl()
1438 up_read(&card->controls_rwsem); snd_ctl_tlv_ioctl()
1439 snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_TLV, &id); snd_ctl_tlv_ioctl()
1456 up_read(&card->controls_rwsem); snd_ctl_tlv_ioctl()
1463 struct snd_card *card; snd_ctl_ioctl() local
1470 card = ctl->card; snd_ctl_ioctl()
1471 if (snd_BUG_ON(!card)) snd_ctl_ioctl()
1477 return snd_ctl_card_info(card, ctl, cmd, argp); snd_ctl_ioctl()
1479 return snd_ctl_elem_list(card, argp); snd_ctl_ioctl()
1483 return snd_ctl_elem_read_user(card, argp); snd_ctl_ioctl()
1508 return put_user(card->power_state, ip) ? -EFAULT : 0; snd_ctl_ioctl()
1515 err = p->fioctl(card, ctl, cmd, arg); snd_ctl_ioctl()
1522 dev_dbg(card->dev, "unknown ioctl = 0x%x\n", cmd); snd_ctl_ioctl()
1534 if (snd_BUG_ON(!ctl || !ctl->card)) snd_ctl_read()
1556 if (ctl->card->shutdown) snd_ctl_read()
1702 int snd_ctl_get_preferred_subdevice(struct snd_card *card, int type) snd_ctl_get_preferred_subdevice() argument
1707 read_lock(&card->ctl_files_rwlock); snd_ctl_get_preferred_subdevice()
1708 list_for_each_entry(kctl, &card->ctl_files, list) { snd_ctl_get_preferred_subdevice()
1715 read_unlock(&card->ctl_files_rwlock); snd_ctl_get_preferred_subdevice()
1751 struct snd_card *card = device->device_data; snd_ctl_dev_register() local
1753 return snd_register_device(SNDRV_DEVICE_TYPE_CONTROL, card, -1, snd_ctl_dev_register()
1754 &snd_ctl_f_ops, card, &card->ctl_dev); snd_ctl_dev_register()
1762 struct snd_card *card = device->device_data; snd_ctl_dev_disconnect() local
1765 read_lock(&card->ctl_files_rwlock); snd_ctl_dev_disconnect()
1766 list_for_each_entry(ctl, &card->ctl_files, list) { snd_ctl_dev_disconnect()
1770 read_unlock(&card->ctl_files_rwlock); snd_ctl_dev_disconnect()
1772 return snd_unregister_device(&card->ctl_dev); snd_ctl_dev_disconnect()
1780 struct snd_card *card = device->device_data; snd_ctl_dev_free() local
1783 down_write(&card->controls_rwsem); snd_ctl_dev_free()
1784 while (!list_empty(&card->controls)) { snd_ctl_dev_free()
1785 control = snd_kcontrol(card->controls.next); snd_ctl_dev_free()
1786 snd_ctl_remove(card, control); snd_ctl_dev_free()
1788 up_write(&card->controls_rwsem); snd_ctl_dev_free()
1789 put_device(&card->ctl_dev); snd_ctl_dev_free()
1797 int snd_ctl_create(struct snd_card *card) snd_ctl_create() argument
1806 if (snd_BUG_ON(!card)) snd_ctl_create()
1808 if (snd_BUG_ON(card->number < 0 || card->number >= SNDRV_CARDS)) snd_ctl_create()
1811 snd_device_initialize(&card->ctl_dev, card); snd_ctl_create()
1812 dev_set_name(&card->ctl_dev, "controlC%d", card->number); snd_ctl_create()
1814 err = snd_device_new(card, SNDRV_DEV_CONTROL, card, &ops); snd_ctl_create()
1816 put_device(&card->ctl_dev); snd_ctl_create()
H A Dsound.c50 /* this one holds the actual max. card number currently available.
63 * snd_request_card - try to load the card module
64 * @card: the card number
66 * Tries to load the module "snd-card-X" for the given card number
69 void snd_request_card(int card) snd_request_card() argument
71 if (snd_card_locked(card)) snd_request_card()
73 if (card < 0 || card >= cards_limit) snd_request_card()
75 request_module("snd-card-%i", card); snd_request_card()
102 * This function increments the reference counter of the card instance
138 int card = SNDRV_MINOR_CARD(minor); autoload_device() local
139 if (snd_cards[card] == NULL) autoload_device()
140 snd_request_card(card); autoload_device()
189 static int snd_find_free_minor(int type, struct snd_card *card, int dev) snd_find_free_minor() argument
212 static int snd_find_free_minor(int type, struct snd_card *card, int dev) snd_find_free_minor() argument
222 if (snd_BUG_ON(!card)) snd_find_free_minor()
224 minor = SNDRV_MINOR(card->number, type); snd_find_free_minor()
231 if (snd_BUG_ON(!card)) snd_find_free_minor()
233 minor = SNDRV_MINOR(card->number, type + dev); snd_find_free_minor()
247 * snd_register_device - Register the ALSA device file for the card
249 * @card: the card instance
255 * Registers an ALSA device file for the given card.
260 int snd_register_device(int type, struct snd_card *card, int dev, snd_register_device() argument
275 preg->card = card ? card->number : -1; snd_register_device()
279 preg->card_ptr = card; snd_register_device()
281 minor = snd_find_free_minor(type, card, dev); snd_register_device()
303 * snd_unregister_device - unregister the device on the given card
371 if (mptr->card >= 0) { snd_minor_info_read()
374 minor, mptr->card, mptr->device, snd_minor_info_read()
378 minor, mptr->card, snd_minor_info_read()
H A Dpcm_trace.h15 __field( unsigned int, card )
27 __entry->card = (substream)->pcm->card->number;
38 __entry->card, __entry->device,
53 __field( unsigned int, card )
63 __entry->card = (substream)->pcm->card->number;
73 __entry->card, __entry->device,
86 __field( unsigned int, card )
93 __entry->card = (substream)->pcm->card->number;
100 __entry->card, __entry->device,
H A Dsound_oss.c43 /* NOTE: This function increments the refcount of the associated card like
67 static int snd_oss_kernel_minor(int type, struct snd_card *card, int dev) snd_oss_kernel_minor() argument
73 if (snd_BUG_ON(!card || dev < 0 || dev > 1)) snd_oss_kernel_minor()
75 minor = SNDRV_MINOR_OSS(card->number, (dev ? SNDRV_MINOR_OSS_MIXER1 : SNDRV_MINOR_OSS_MIXER)); snd_oss_kernel_minor()
84 if (snd_BUG_ON(!card || dev < 0 || dev > 1)) snd_oss_kernel_minor()
86 minor = SNDRV_MINOR_OSS(card->number, (dev ? SNDRV_MINOR_OSS_PCM1 : SNDRV_MINOR_OSS_PCM)); snd_oss_kernel_minor()
89 if (snd_BUG_ON(!card || dev < 0 || dev > 1)) snd_oss_kernel_minor()
91 minor = SNDRV_MINOR_OSS(card->number, (dev ? SNDRV_MINOR_OSS_MIDI1 : SNDRV_MINOR_OSS_MIDI)); snd_oss_kernel_minor()
94 minor = SNDRV_MINOR_OSS(card->number, SNDRV_MINOR_OSS_DMFM); snd_oss_kernel_minor()
107 int snd_register_oss_device(int type, struct snd_card *card, int dev, snd_register_oss_device() argument
110 int minor = snd_oss_kernel_minor(type, card, dev); snd_register_oss_device()
116 struct device *carddev = snd_card_get_device_link(card); snd_register_oss_device()
118 if (card && card->number >= SNDRV_MINOR_OSS_DEVICES) snd_register_oss_device()
126 preg->card = card ? card->number : -1; snd_register_oss_device()
130 preg->card_ptr = card; snd_register_oss_device()
171 int snd_unregister_oss_device(int type, struct snd_card *card, int dev) snd_unregister_oss_device() argument
173 int minor = snd_oss_kernel_minor(type, card, dev); snd_unregister_oss_device()
178 if (card && card->number >= SNDRV_MINOR_OSS_DEVICES) snd_unregister_oss_device()
249 if (mptr->card >= 0) snd_minor_info_oss_read()
251 mptr->card, mptr->device, snd_minor_info_oss_read()
/linux-4.1.27/drivers/net/wan/
H A Dn2.c2 * SDL Inc. RISCom/N2 synchronous serial card driver for Linux
99 struct card_s *card; member in struct:port_s
135 #define sca_reg(reg, card) (0x8000 | (card)->io | \
137 #define sca_in(reg, card) inb(sca_reg(reg, card))
138 #define sca_out(value, reg, card) outb(value, sca_reg(reg, card))
139 #define sca_inw(reg, card) inw(sca_reg(reg, card))
140 #define sca_outw(value, reg, card) outw(value, sca_reg(reg, card))
142 #define port_to_card(port) ((port)->card)
145 #define winsize(card) (USE_WINDOWSIZE)
146 #define winbase(card) ((card)->winbase)
147 #define get_port(card, port) ((card)->ports[port].valid ? \
148 &(card)->ports[port] : NULL)
151 static __inline__ u8 sca_get_page(card_t *card) sca_get_page() argument
153 return inb(card->io + N2_PSR) & PSR_PAGEBITS; sca_get_page()
157 static __inline__ void openwin(card_t *card, u8 page) openwin() argument
159 u8 psr = inb(card->io + N2_PSR); openwin()
160 outb((psr & ~PSR_PAGEBITS) | page, card->io + N2_PSR); openwin()
169 card_t *card = port->card; n2_set_iface() local
170 int io = card->io; n2_set_iface()
204 sca_out(rxs, msci + RXS, card); n2_set_iface()
205 sca_out(txs, msci + TXS, card); n2_set_iface()
214 int io = port->card->io; n2_open()
237 int io = port->card->io; n2_close()
303 static void n2_destroy_card(card_t *card) n2_destroy_card() argument
308 if (card->ports[cnt].card) { n2_destroy_card()
309 struct net_device *dev = port_to_dev(&card->ports[cnt]); n2_destroy_card()
313 if (card->irq) n2_destroy_card()
314 free_irq(card->irq, card); n2_destroy_card()
316 if (card->winbase) { n2_destroy_card()
317 iounmap(card->winbase); n2_destroy_card()
318 release_mem_region(card->phy_winbase, USE_WINDOWSIZE); n2_destroy_card()
321 if (card->io) n2_destroy_card()
322 release_region(card->io, N2_IOPORTS); n2_destroy_card()
323 if (card->ports[0].dev) n2_destroy_card()
324 free_netdev(card->ports[0].dev); n2_destroy_card()
325 if (card->ports[1].dev) n2_destroy_card()
326 free_netdev(card->ports[1].dev); n2_destroy_card()
327 kfree(card); n2_destroy_card()
341 card_t *card; n2_run() local
360 card = kzalloc(sizeof(card_t), GFP_KERNEL); n2_run()
361 if (card == NULL) n2_run()
364 card->ports[0].dev = alloc_hdlcdev(&card->ports[0]); n2_run()
365 card->ports[1].dev = alloc_hdlcdev(&card->ports[1]); n2_run()
366 if (!card->ports[0].dev || !card->ports[1].dev) { n2_run()
368 n2_destroy_card(card); n2_run()
374 n2_destroy_card(card); n2_run()
377 card->io = io; n2_run()
379 if (request_irq(irq, sca_intr, 0, devname, card)) { n2_run()
381 n2_destroy_card(card); n2_run()
384 card->irq = irq; n2_run()
388 n2_destroy_card(card); n2_run()
391 card->phy_winbase = winbase; n2_run()
392 card->winbase = ioremap(winbase, USE_WINDOWSIZE); n2_run()
393 if (!card->winbase) { n2_run()
395 n2_destroy_card(card); n2_run()
417 n2_destroy_card(card); n2_run()
424 card->ram_size = sca_detect_ram(card, card->winbase, MAX_RAM_SIZE); n2_run()
427 i = card->ram_size / ((valid0 + valid1) * (sizeof(pkt_desc) + n2_run()
430 card->tx_ring_buffers = min(i / 2, MAX_TX_BUFFERS); n2_run()
431 card->rx_ring_buffers = i - card->tx_ring_buffers; n2_run()
433 card->buff_offset = (valid0 + valid1) * sizeof(pkt_desc) * n2_run()
434 (card->tx_ring_buffers + card->rx_ring_buffers); n2_run()
437 card->ram_size / 1024, card->irq, n2_run()
438 card->tx_ring_buffers, card->rx_ring_buffers); n2_run()
440 if (card->tx_ring_buffers < 1) { n2_run()
442 n2_destroy_card(card); n2_run()
450 sca_init(card, 0); n2_run()
452 port_t *port = &card->ports[cnt]; n2_run()
474 port->card = card; n2_run()
478 port->card = NULL; n2_run()
479 n2_destroy_card(card); n2_run()
487 *new_card = card; n2_run()
488 new_card = &card->next_card; n2_run()
499 pr_info("no card initialized\n"); n2_init()
549 card_t *card = first_card; n2_cleanup() local
551 while (card) { n2_cleanup()
552 card_t *ptr = card; n2_cleanup()
553 card = card->next_card; n2_cleanup()
H A Dpci200syn.c2 * Goramo PCI200SYN synchronous serial card driver for Linux
70 struct card_s *card; member in struct:port_s
98 #define get_port(card, port) (&card->ports[port])
99 #define sca_flush(card) (sca_in(IER0, card));
122 card_t *card = port->card; pci200_set_iface() local
128 port->card); pci200_set_iface()
153 sca_out(rxs, msci + RXS, card); pci200_set_iface()
154 sca_out(txs, msci + TXS, card); pci200_set_iface()
170 sca_flush(port->card); pci200_open()
179 sca_flush(dev_to_port(dev)->card); pci200_close()
232 sca_flush(port->card); pci200_ioctl()
245 card_t *card = pci_get_drvdata(pdev); pci200_pci_remove_one() local
248 if (card->ports[i].card) pci200_pci_remove_one()
249 unregister_hdlc_device(card->ports[i].netdev); pci200_pci_remove_one()
251 if (card->irq) pci200_pci_remove_one()
252 free_irq(card->irq, card); pci200_pci_remove_one()
254 if (card->rambase) pci200_pci_remove_one()
255 iounmap(card->rambase); pci200_pci_remove_one()
256 if (card->scabase) pci200_pci_remove_one()
257 iounmap(card->scabase); pci200_pci_remove_one()
258 if (card->plxbase) pci200_pci_remove_one()
259 iounmap(card->plxbase); pci200_pci_remove_one()
263 if (card->ports[0].netdev) pci200_pci_remove_one()
264 free_netdev(card->ports[0].netdev); pci200_pci_remove_one()
265 if (card->ports[1].netdev) pci200_pci_remove_one()
266 free_netdev(card->ports[1].netdev); pci200_pci_remove_one()
267 kfree(card); pci200_pci_remove_one()
281 card_t *card; pci200_pci_init_one() local
299 card = kzalloc(sizeof(card_t), GFP_KERNEL); pci200_pci_init_one()
300 if (card == NULL) { pci200_pci_init_one()
305 pci_set_drvdata(pdev, card); pci200_pci_init_one()
306 card->ports[0].netdev = alloc_hdlcdev(&card->ports[0]); pci200_pci_init_one()
307 card->ports[1].netdev = alloc_hdlcdev(&card->ports[1]); pci200_pci_init_one()
308 if (!card->ports[0].netdev || !card->ports[1].netdev) { pci200_pci_init_one()
317 pr_err("invalid card EEPROM parameters\n"); pci200_pci_init_one()
323 card->plxbase = ioremap(plxphys, PCI200SYN_PLX_SIZE); pci200_pci_init_one()
326 card->scabase = ioremap(scaphys, PCI200SYN_SCA_SIZE); pci200_pci_init_one()
329 card->rambase = pci_ioremap_bar(pdev, 3); pci200_pci_init_one()
331 if (card->plxbase == NULL || pci200_pci_init_one()
332 card->scabase == NULL || pci200_pci_init_one()
333 card->rambase == NULL) { pci200_pci_init_one()
340 p = &card->plxbase->init_ctrl; pci200_pci_init_one()
349 ramsize = sca_detect_ram(card, card->rambase, pci200_pci_init_one()
352 /* number of TX + RX buffers for one port - this is dual port card */ pci200_pci_init_one()
354 card->tx_ring_buffers = min(i / 2, MAX_TX_BUFFERS); pci200_pci_init_one()
355 card->rx_ring_buffers = i - card->tx_ring_buffers; pci200_pci_init_one()
357 card->buff_offset = 2 * sizeof(pkt_desc) * (card->tx_ring_buffers + pci200_pci_init_one()
358 card->rx_ring_buffers); pci200_pci_init_one()
362 pdev->irq, card->tx_ring_buffers, card->rx_ring_buffers); pci200_pci_init_one()
364 if (card->tx_ring_buffers < 1) { pci200_pci_init_one()
371 p = &card->plxbase->intr_ctrl_stat; pci200_pci_init_one()
375 if (request_irq(pdev->irq, sca_intr, IRQF_SHARED, "pci200syn", card)) { pci200_pci_init_one()
380 card->irq = pdev->irq; pci200_pci_init_one()
382 sca_init(card, 0); pci200_pci_init_one()
385 port_t *port = &card->ports[i]; pci200_pci_init_one()
391 dev->irq = card->irq; pci200_pci_init_one()
399 port->card = card; pci200_pci_init_one()
403 port->card = NULL; pci200_pci_init_one()
411 sca_flush(card); pci200_pci_init_one()
H A Dhd64572.c14 * Packet buffer descriptor rings - starting from card->rambase:
20 * Packet data buffers - starting from card->rambase + buff_offset:
51 #define sca_in(reg, card) readb(card->scabase + (reg))
52 #define sca_out(value, reg, card) writeb(value, card->scabase + (reg))
53 #define sca_inw(reg, card) readw(card->scabase + (reg))
54 #define sca_outw(value, reg, card) writew(value, card->scabase + (reg))
55 #define sca_inl(reg, card) readl(card->scabase + (reg))
56 #define sca_outl(value, reg, card) writel(value, card->scabase + (reg))
68 sca_outl(sca_inl(IER0, port->card) | enable_intr()
69 (port->chan ? 0x08002200 : 0x00080022), IER0, port->card); enable_intr()
74 sca_outl(sca_inl(IER0, port->card) & disable_intr()
75 (port->chan ? 0x00FF00FF : 0xFF00FF00), IER0, port->card); disable_intr()
80 u16 rx_buffs = port->card->rx_ring_buffers; desc_abs_number()
81 u16 tx_buffs = port->card->tx_ring_buffers; desc_abs_number()
98 return (pkt_desc __iomem *)(port->card->rambase + desc_address()
105 return port->card->buff_offset + buffer_offset()
112 if (!(sca_in(get_msci(port) + ST3, port->card) & ST3_DCD)) { sca_set_carrier()
130 card_t *card = port->card; sca_init_port() local
139 u16 buffs = transmit ? card->tx_ring_buffers sca_init_port()
140 : card->rx_ring_buffers; sca_init_port()
155 sca_out(0, DSR_RX(port->chan), card); sca_init_port()
156 sca_out(0, DSR_TX(port->chan), card); sca_init_port()
159 sca_out(DCR_ABORT, DCR_RX(port->chan), card); sca_init_port()
160 sca_out(DCR_ABORT, DCR_TX(port->chan), card); sca_init_port()
163 sca_outl(desc_offset(port, 0, 0), dmac_rx + CDAL, card); sca_init_port() local
164 sca_outl(desc_offset(port, card->tx_ring_buffers - 1, 0), sca_init_port()
165 dmac_rx + EDAL, card); sca_init_port() local
166 sca_outl(desc_offset(port, 0, 1), dmac_tx + CDAL, card); sca_init_port() local
167 sca_outl(desc_offset(port, 0, 1), dmac_tx + EDAL, card); sca_init_port() local
170 sca_out(DCR_CLEAR_EOF, DCR_RX(port->chan), card); sca_init_port()
171 sca_out(DCR_CLEAR_EOF, DCR_TX(port->chan), card); sca_init_port()
174 sca_outw(HDLC_MAX_MRU, dmac_rx + BFLL, card); /* set buffer length */ sca_init_port()
175 sca_out(0x14, DMR_RX(port->chan), card); /* Chain mode, Multi-frame */ sca_init_port()
176 sca_out(DIR_EOME, DIR_RX(port->chan), card); /* enable interrupts */ sca_init_port()
177 sca_out(DSR_DE, DSR_RX(port->chan), card); /* DMA enable */ sca_init_port()
180 sca_out(0x14, DMR_TX(port->chan), card); /* Chain mode, Multi-frame */ sca_init_port()
181 sca_out(DIR_EOME, DIR_TX(port->chan), card); /* enable interrupts */ sca_init_port()
192 card_t* card = port->card; sca_msci_intr() local
194 if (sca_in(msci + ST1, card) & ST1_CDCD) { sca_msci_intr()
196 sca_out(ST1_CDCD, msci + ST1, card); sca_msci_intr()
202 static inline void sca_rx(card_t *card, port_t *port, pkt_desc __iomem *desc, sca_rx() argument
218 memcpy_fromio(skb->data, card->rambase + buff, len); sca_rx()
237 card_t *card = port->card; sca_rx_done() local
238 u8 stat = sca_in(DSR_RX(port->chan), card); /* read DMA Status */ sca_rx_done()
243 DSR_RX(port->chan), card); sca_rx_done()
252 u32 cda = sca_inl(dmac + CDAL, card); sca_rx_done()
273 sca_rx(card, port, desc, port->rxin); sca_rx_done()
278 sca_outl(desc_off, dmac + EDAL, card); sca_rx_done()
279 port->rxin = (port->rxin + 1) % card->rx_ring_buffers; sca_rx_done()
283 sca_out(DSR_DE, DSR_RX(port->chan), card); sca_rx_done()
292 card_t* card = port->card; sca_tx_done() local
298 stat = sca_in(DSR_TX(port->chan), card); /* read DMA Status */ sca_tx_done()
302 DSR_TX(port->chan), card); sca_tx_done()
319 port->txlast = (port->txlast + 1) % card->tx_ring_buffers; sca_tx_done()
331 u32 isr0 = sca_inl(ISR0, port->card); sca_poll()
353 card_t *card = dev_id; sca_intr() local
354 u32 isr0 = sca_inl(ISR0, card); sca_intr()
358 port_t *port = get_port(card, i); sca_intr()
372 card_t* card = port->card; sca_set_port() local
374 u8 md2 = sca_in(msci + MD2, card); sca_set_port()
407 sca_out(port->tmc, msci + TMCR, card); sca_set_port()
408 sca_out(port->tmc, msci + TMCT, card); sca_set_port()
411 sca_out(port->rxs, msci + RXS, card); sca_set_port()
412 sca_out(port->txs, msci + TXS, card); sca_set_port()
419 sca_out(md2, msci + MD2, card); sca_set_port()
427 card_t* card = port->card; sca_open() local
450 sca_out(CMD_RESET, msci + CMD, card); sca_open()
451 sca_out(md0, msci + MD0, card); sca_open()
452 sca_out(0x00, msci + MD1, card); /* no address field check */ sca_open()
453 sca_out(md2, msci + MD2, card); sca_open()
454 sca_out(0x7E, msci + IDL, card); /* flag character 0x7E */ sca_open()
456 sca_out(CTL_IDLE | CTL_URCT | CTL_URSKP, msci + CTL, card); sca_open()
457 sca_out(0x0F, msci + RNR, card); /* +1=RX DMA activation condition */ sca_open()
458 sca_out(0x3C, msci + TFS, card); /* +1 = TX start */ sca_open()
459 sca_out(0x38, msci + TCR, card); /* =Critical TX DMA activ condition */ sca_open()
460 sca_out(0x38, msci + TNR0, card); /* =TX DMA activation condition */ sca_open()
461 sca_out(0x3F, msci + TNR1, card); /* +1=TX DMA deactivation condition*/ sca_open()
467 sca_outl(IE0_RXINTA | IE0_CDCD, msci + IE0, card); sca_open()
469 sca_out(port->tmc, msci + TMCR, card); sca_open()
470 sca_out(port->tmc, msci + TMCT, card); sca_open()
471 sca_out(port->rxs, msci + RXS, card); sca_open()
472 sca_out(port->txs, msci + TXS, card); sca_open()
473 sca_out(CMD_TX_ENABLE, msci + CMD, card); sca_open()
474 sca_out(CMD_RX_ENABLE, msci + CMD, card); sca_open()
488 sca_out(CMD_RESET, get_msci(port) + CMD, port->card); sca_close()
522 card_t *card = port->card; sca_dump_rings() local
526 sca_inl(get_dmac_rx(port) + CDAL, card), sca_dump_rings()
527 sca_inl(get_dmac_rx(port) + EDAL, card), sca_dump_rings()
528 sca_in(DSR_RX(port->chan), card), port->rxin, sca_dump_rings()
529 sca_in(DSR_RX(port->chan), card) & DSR_DE ? "" : "in"); sca_dump_rings()
530 for (cnt = 0; cnt < port->card->rx_ring_buffers; cnt++) sca_dump_rings()
536 sca_inl(get_dmac_tx(port) + CDAL, card), sca_dump_rings()
537 sca_inl(get_dmac_tx(port) + EDAL, card), sca_dump_rings()
538 sca_in(DSR_TX(port->chan), card), port->txin, port->txlast, sca_dump_rings()
539 sca_in(DSR_TX(port->chan), card) & DSR_DE ? "" : "in"); sca_dump_rings()
541 for (cnt = 0; cnt < port->card->tx_ring_buffers; cnt++) sca_dump_rings()
547 sca_in(get_msci(port) + MD0, card), sca_dump_rings()
548 sca_in(get_msci(port) + MD1, card), sca_dump_rings()
549 sca_in(get_msci(port) + MD2, card), sca_dump_rings()
550 sca_in(get_msci(port) + ST0, card), sca_dump_rings()
551 sca_in(get_msci(port) + ST1, card), sca_dump_rings()
552 sca_in(get_msci(port) + ST2, card), sca_dump_rings()
553 sca_in(get_msci(port) + ST3, card), sca_dump_rings()
554 sca_in(get_msci(port) + ST4, card), sca_dump_rings()
555 sca_in(get_msci(port) + FST, card), sca_dump_rings()
556 sca_in(get_msci(port) + CST0, card), sca_dump_rings()
557 sca_in(get_msci(port) + CST1, card)); sca_dump_rings()
559 printk(KERN_DEBUG "ILAR: %02x ISR: %08x %08x\n", sca_in(ILAR, card), sca_dump_rings()
560 sca_inl(ISR0, card), sca_inl(ISR1, card)); sca_dump_rings()
568 card_t *card = port->card; sca_xmit() local
585 memcpy_toio(card->rambase + buff, skb->data, len); sca_xmit()
590 port->txin = (port->txin + 1) % card->tx_ring_buffers; sca_xmit()
592 get_dmac_tx(port) + EDAL, card); sca_xmit()
594 sca_out(DSR_DE, DSR_TX(port->chan), card); /* Enable TX DMA */ sca_xmit()
607 static u32 sca_detect_ram(card_t *card, u8 __iomem *rambase, u32 ramsize) sca_detect_ram() argument
626 static void sca_init(card_t *card, int wait_states) sca_init() argument
628 sca_out(wait_states, WCRL, card); /* Wait Control */ sca_init()
629 sca_out(wait_states, WCRM, card); sca_init()
630 sca_out(wait_states, WCRH, card); sca_init()
632 sca_out(0, DMER, card); /* DMA Master disable */ sca_init()
633 sca_out(0x03, PCR, card); /* DMA priority */ sca_init()
634 sca_out(0, DSR_RX(0), card); /* DMA disable - to halt state */ sca_init()
635 sca_out(0, DSR_TX(0), card); sca_init()
636 sca_out(0, DSR_RX(1), card); sca_init()
637 sca_out(0, DSR_TX(1), card); sca_init()
638 sca_out(DMER_DME, DMER, card); /* DMA Master enable */ sca_init()
H A Dc101.c2 * Moxa C101 synchronous serial card driver for Linux
87 #define sca_in(reg, card) readb((card)->win0base + C101_SCA + (reg))
88 #define sca_out(value, reg, card) writeb(value, (card)->win0base + C101_SCA + (reg))
89 #define sca_inw(reg, card) readw((card)->win0base + C101_SCA + (reg))
92 #define sca_outw(value, reg, card) do { \
93 writeb(value & 0xFF, (card)->win0base + C101_SCA + (reg)); \
94 writeb((value >> 8 ) & 0xFF, (card)->win0base + C101_SCA + (reg + 1));\
100 #define winsize(card) (C101_WINDOW_SIZE)
101 #define win0base(card) ((card)->win0base)
102 #define winbase(card) ((card)->win0base + 0x2000)
103 #define get_port(card, port) (card)
107 static inline u8 sca_get_page(card_t *card) sca_get_page() argument
109 return card->page; sca_get_page()
112 static inline void openwin(card_t *card, u8 page) openwin() argument
114 card->page = page; openwin()
115 writeb(page, card->win0base + C101_PAGE); openwin()
285 static void c101_destroy_card(card_t *card) c101_destroy_card() argument
287 readb(card->win0base + C101_PAGE); /* Resets SCA? */ c101_destroy_card()
289 if (card->irq) c101_destroy_card()
290 free_irq(card->irq, card); c101_destroy_card()
292 if (card->win0base) { c101_destroy_card()
293 iounmap(card->win0base); c101_destroy_card()
294 release_mem_region(card->phy_winbase, C101_MAPPED_RAM_SIZE); c101_destroy_card()
297 free_netdev(card->dev); c101_destroy_card()
299 kfree(card); c101_destroy_card()
314 card_t *card; c101_run() local
327 card = kzalloc(sizeof(card_t), GFP_KERNEL); c101_run()
328 if (card == NULL) c101_run()
331 card->dev = alloc_hdlcdev(card); c101_run()
332 if (!card->dev) { c101_run()
334 kfree(card); c101_run()
338 if (request_irq(irq, sca_intr, 0, devname, card)) { c101_run()
340 c101_destroy_card(card); c101_run()
343 card->irq = irq; c101_run()
347 c101_destroy_card(card); c101_run()
350 card->phy_winbase = winbase; c101_run()
351 card->win0base = ioremap(winbase, C101_MAPPED_RAM_SIZE); c101_run()
352 if (!card->win0base) { c101_run()
354 c101_destroy_card(card); c101_run()
358 card->tx_ring_buffers = TX_RING_BUFFERS; c101_run()
359 card->rx_ring_buffers = RX_RING_BUFFERS; c101_run()
360 card->buff_offset = C101_WINDOW_SIZE; /* Bytes 1D00-1FFF reserved */ c101_run()
362 readb(card->win0base + C101_PAGE); /* Resets SCA? */ c101_run()
364 writeb(0, card->win0base + C101_PAGE); c101_run()
365 writeb(0, card->win0base + C101_DTR); /* Power-up for RAM? */ c101_run()
367 sca_init(card, 0); c101_run()
369 dev = port_to_dev(card); c101_run()
372 spin_lock_init(&card->lock); c101_run()
380 card->settings.clock_type = CLOCK_EXT; c101_run()
385 c101_destroy_card(card); c101_run()
389 sca_init_port(card); /* Set up C101 memory */ c101_run()
390 set_carrier(card); c101_run()
393 card->irq, card->tx_ring_buffers, card->rx_ring_buffers); c101_run()
395 *new_card = card; c101_run()
396 new_card = &card->next_card; c101_run()
406 pr_info("no card initialized\n"); c101_init()
436 card_t *card = first_card; c101_cleanup() local
438 while (card) { c101_cleanup()
439 card_t *ptr = card; c101_cleanup()
440 card = card->next_card; c101_cleanup()
H A Dpc300too.c2 * Cyclades PC300 synchronous serial card driver for Linux
59 enum { PC300_RSV = 1, PC300_X21, PC300_TE }; /* card types */
82 struct card_s *card; member in struct:port_s
114 #define get_port(card, port) ((port) < (card)->n_ports ? \
115 (&(card)->ports[port]) : (NULL))
122 card_t *card = port->card; pc300_set_iface() local
123 u32 __iomem * init_ctrl = &card->plxbase->init_ctrl; pc300_set_iface()
129 port->card); pc300_set_iface()
154 sca_out(rxs, msci + RXS, card); pc300_set_iface()
155 sca_out(txs, msci + TXS, card); pc300_set_iface()
158 if (port->card->type == PC300_RSV) { pc300_set_iface()
160 writel(card->init_ctrl_value | pc300_set_iface()
163 writel(card->init_ctrl_value & pc300_set_iface()
223 if (port->card->type == PC300_X21 && pc300_ioctl()
228 else if (port->card->type == PC300_RSV && pc300_ioctl()
233 else if (port->card->type == PC300_RSV && pc300_ioctl()
266 card_t *card = pci_get_drvdata(pdev); pc300_pci_remove_one() local
269 if (card->ports[i].card) pc300_pci_remove_one()
270 unregister_hdlc_device(card->ports[i].netdev); pc300_pci_remove_one()
272 if (card->irq) pc300_pci_remove_one()
273 free_irq(card->irq, card); pc300_pci_remove_one()
275 if (card->rambase) pc300_pci_remove_one()
276 iounmap(card->rambase); pc300_pci_remove_one()
277 if (card->scabase) pc300_pci_remove_one()
278 iounmap(card->scabase); pc300_pci_remove_one()
279 if (card->plxbase) pc300_pci_remove_one()
280 iounmap(card->plxbase); pc300_pci_remove_one()
284 if (card->ports[0].netdev) pc300_pci_remove_one()
285 free_netdev(card->ports[0].netdev); pc300_pci_remove_one()
286 if (card->ports[1].netdev) pc300_pci_remove_one()
287 free_netdev(card->ports[1].netdev); pc300_pci_remove_one()
288 kfree(card); pc300_pci_remove_one()
302 card_t *card; pc300_pci_init_one() local
320 card = kzalloc(sizeof(card_t), GFP_KERNEL); pc300_pci_init_one()
321 if (card == NULL) { pc300_pci_init_one()
326 pci_set_drvdata(pdev, card); pc300_pci_init_one()
331 pr_err("invalid card EEPROM parameters\n"); pc300_pci_init_one()
337 card->plxbase = ioremap(plxphys, PC300_PLX_SIZE); pc300_pci_init_one()
340 card->scabase = ioremap(scaphys, PC300_SCA_SIZE); pc300_pci_init_one()
343 card->rambase = pci_ioremap_bar(pdev, 3); pc300_pci_init_one()
345 if (card->plxbase == NULL || pc300_pci_init_one()
346 card->scabase == NULL || pc300_pci_init_one()
347 card->rambase == NULL) { pc300_pci_init_one()
354 card->init_ctrl_value = readl(&((plx9050 __iomem *)card->scabase)->init_ctrl); pc300_pci_init_one()
359 card->type = PC300_TE; /* not fully supported */ pc300_pci_init_one()
360 else if (card->init_ctrl_value & PC300_CTYPE_MASK) pc300_pci_init_one()
361 card->type = PC300_X21; pc300_pci_init_one()
363 card->type = PC300_RSV; pc300_pci_init_one()
367 card->n_ports = 1; pc300_pci_init_one()
369 card->n_ports = 2; pc300_pci_init_one()
371 for (i = 0; i < card->n_ports; i++) pc300_pci_init_one()
372 if (!(card->ports[i].netdev = alloc_hdlcdev(&card->ports[i]))) { pc300_pci_init_one()
379 p = &card->plxbase->init_ctrl; pc300_pci_init_one()
380 writel(card->init_ctrl_value | 0x40000000, p); pc300_pci_init_one()
384 writel(card->init_ctrl_value, p); pc300_pci_init_one()
389 writel(card->init_ctrl_value | 0x20000000, p); pc300_pci_init_one()
393 writel(card->init_ctrl_value, p); pc300_pci_init_one()
397 ramsize = sca_detect_ram(card, card->rambase, pc300_pci_init_one()
401 card->init_ctrl_value &= ~PC300_CLKSEL_MASK; pc300_pci_init_one()
403 card->init_ctrl_value |= PC300_CLKSEL_MASK; pc300_pci_init_one()
405 writel(card->init_ctrl_value, &card->plxbase->init_ctrl); pc300_pci_init_one()
407 i = ramsize / (card->n_ports * (sizeof(pkt_desc) + HDLC_MAX_MRU)); pc300_pci_init_one()
408 card->tx_ring_buffers = min(i / 2, MAX_TX_BUFFERS); pc300_pci_init_one()
409 card->rx_ring_buffers = i - card->tx_ring_buffers; pc300_pci_init_one()
411 card->buff_offset = card->n_ports * sizeof(pkt_desc) * pc300_pci_init_one()
412 (card->tx_ring_buffers + card->rx_ring_buffers); pc300_pci_init_one()
415 card->type == PC300_X21 ? "X21" : pc300_pci_init_one()
416 card->type == PC300_TE ? "TE" : "RSV", pc300_pci_init_one()
418 card->tx_ring_buffers, card->rx_ring_buffers); pc300_pci_init_one()
420 if (card->tx_ring_buffers < 1) { pc300_pci_init_one()
427 writew(0x0041, &card->plxbase->intr_ctrl_stat); pc300_pci_init_one()
430 if (request_irq(pdev->irq, sca_intr, IRQF_SHARED, "pc300", card)) { pc300_pci_init_one()
435 card->irq = pdev->irq; pc300_pci_init_one()
437 sca_init(card, 0); pc300_pci_init_one()
440 // sca_out(sca_in(PCR, card) | PCR_COTE, PCR, card); pc300_pci_init_one()
442 sca_out(0x10, BTCR, card); pc300_pci_init_one()
444 for (i = 0; i < card->n_ports; i++) { pc300_pci_init_one()
445 port_t *port = &card->ports[i]; pc300_pci_init_one()
451 dev->irq = card->irq; pc300_pci_init_one()
459 port->card = card; pc300_pci_init_one()
460 if (card->type == PC300_X21) pc300_pci_init_one()
468 port->card = NULL; pc300_pci_init_one()
H A Dhd64570.c59 static inline int sca_intr_status(card_t *card) sca_intr_status() argument
62 u8 isr0 = sca_in(ISR0, card); sca_intr_status()
63 u8 isr1 = sca_in(ISR1, card); sca_intr_status()
73 if (sca_in(DSR_TX(0), card) & DSR_EOM) sca_intr_status()
76 if (sca_in(DSR_TX(1), card) & DSR_EOM) sca_intr_status()
152 card_t *card = port_to_card(port); sca_init_port() local
160 openwin(card, 0); sca_init_port()
165 u16 buffs = transmit ? card->tx_ring_buffers sca_init_port()
166 : card->rx_ring_buffers; sca_init_port()
181 DSR_RX(phy_node(port)), card); sca_init_port()
184 DCR_RX(phy_node(port)), card); sca_init_port()
187 sca_out(0, dmac + CPB, card); /* pointer base */ sca_init_port()
188 sca_outw(desc_offset(port, 0, transmit), dmac + CDAL, card); sca_init_port() local
191 dmac + EDAL, card); sca_init_port() local
194 card); sca_init_port() local
198 DCR_RX(phy_node(port)), card); sca_init_port()
202 sca_outw(HDLC_MAX_MRU, dmac + BFLL, card); sca_init_port()
204 sca_out(0x14, DMR_RX(phy_node(port)), card); sca_init_port()
206 card); sca_init_port()
208 sca_out(DSR_DE, DSR_RX(phy_node(port)), card); sca_init_port()
211 sca_out(0x14, DMR_TX(phy_node(port)), card); sca_init_port()
213 sca_out(DIR_BOFE, DIR_TX(phy_node(port)), card); sca_init_port()
225 card_t* card = port_to_card(port); sca_msci_intr() local
226 u8 stat = sca_in(msci + ST1, card); /* read MSCI ST1 status */ sca_msci_intr()
229 sca_out(stat & (ST1_UDRN | ST1_CDCD), msci + ST1, card); sca_msci_intr()
243 static inline void sca_rx(card_t *card, port_t *port, pkt_desc __iomem *desc, sca_rx() argument
261 page = buff / winsize(card); sca_rx()
262 buff = buff % winsize(card); sca_rx()
263 maxlen = winsize(card) - buff; sca_rx()
265 openwin(card, page); sca_rx()
268 memcpy_fromio(skb->data, winbase(card) + buff, maxlen); sca_rx()
269 openwin(card, page + 1); sca_rx()
270 memcpy_fromio(skb->data + maxlen, winbase(card), len - maxlen); sca_rx()
272 memcpy_fromio(skb->data, winbase(card) + buff, len); sca_rx()
275 openwin(card, 0); /* select pkt_desc table page back */ sca_rx()
294 card_t *card = port_to_card(port); sca_rx_intr() local
295 u8 stat = sca_in(DSR_RX(phy_node(port)), card); /* read DMA Status */ sca_rx_intr()
299 DSR_RX(phy_node(port)), card); sca_rx_intr()
308 u32 cda = sca_inw(dmac + CDAL, card); sca_rx_intr()
329 sca_rx(card, port, desc, port->rxin); sca_rx_intr()
332 sca_outw(desc_off, dmac + EDAL, card); sca_rx_intr()
337 sca_out(DSR_DE, DSR_RX(phy_node(port)), card); sca_rx_intr()
346 card_t* card = port_to_card(port); sca_tx_intr() local
351 stat = sca_in(DSR_TX(phy_node(port)), card); /* read DMA Status */ sca_tx_intr()
355 DSR_TX(phy_node(port)), card); sca_tx_intr()
361 u32 cda = sca_inw(dmac + CDAL, card); sca_tx_intr()
379 card_t *card = dev_id; sca_intr() local
383 u8 page = sca_get_page(card); sca_intr()
385 while((stat = sca_intr_status(card)) != 0) { sca_intr()
388 port_t *port = get_port(card, i); sca_intr()
402 openwin(card, page); /* Restore original page */ sca_intr()
409 card_t* card = port_to_card(port); sca_set_port() local
411 u8 md2 = sca_in(msci + MD2, card); sca_set_port()
444 sca_out(port->tmc, msci + TMC, card); sca_set_port()
447 sca_out(port->rxs, msci + RXS, card); sca_set_port()
448 sca_out(port->txs, msci + TXS, card); sca_set_port()
455 sca_out(md2, msci + MD2, card); sca_set_port()
463 card_t* card = port_to_card(port); sca_open() local
486 sca_out(CMD_RESET, msci + CMD, card); sca_open()
487 sca_out(md0, msci + MD0, card); sca_open()
488 sca_out(0x00, msci + MD1, card); /* no address field check */ sca_open()
489 sca_out(md2, msci + MD2, card); sca_open()
490 sca_out(0x7E, msci + IDL, card); /* flag character 0x7E */ sca_open()
491 sca_out(CTL_IDLE, msci + CTL, card); sca_open()
495 sca_out(0x07, msci + RRC, card); /* +1=RXRDY/DMA activation condition*/ sca_open()
496 sca_out(0x10, msci + TRC0, card); /* = TXRDY/DMA activation condition*/ sca_open()
497 sca_out(0x14, msci + TRC1, card); /* +1=TXRDY/DMA deactiv condition */ sca_open()
506 sca_out(IE0_TXINT | IE0_RXINTA, msci + IE0, card); sca_open()
507 sca_out(IE1_UDRN | IE1_CDCD, msci + IE1, card); sca_open()
508 sca_out(sca_in(IER0, card) | (phy_node(port) ? 0xC0 : 0x0C), sca_open()
509 IER0, card); /* TXINT and RXINT */ sca_open()
511 sca_out(sca_in(IER1, card) | (phy_node(port) ? 0xF0 : 0x0F), sca_open()
512 IER1, card); sca_open()
514 sca_out(port->tmc, msci + TMC, card); /* Restore registers */ sca_open()
515 sca_out(port->rxs, msci + RXS, card); sca_open()
516 sca_out(port->txs, msci + TXS, card); sca_open()
517 sca_out(CMD_TX_ENABLE, msci + CMD, card); sca_open()
518 sca_out(CMD_RX_ENABLE, msci + CMD, card); sca_open()
527 card_t* card = port_to_card(port); sca_close() local
532 sca_out(sca_in(IER0, card) & (phy_node(port) ? 0x0F : 0xF0), sca_close()
533 IER0, card); sca_close()
535 sca_out(sca_in(IER1, card) & (phy_node(port) ? 0x0F : 0xF0), sca_close()
536 IER1, card); sca_close()
569 card_t *card = port_to_card(port); sca_dump_rings() local
572 u8 page = sca_get_page(card); sca_dump_rings()
574 openwin(card, 0); sca_dump_rings()
578 sca_inw(get_dmac_rx(port) + CDAL, card), sca_dump_rings()
579 sca_inw(get_dmac_rx(port) + EDAL, card), sca_dump_rings()
580 sca_in(DSR_RX(phy_node(port)), card), port->rxin, sca_dump_rings()
581 sca_in(DSR_RX(phy_node(port)), card) & DSR_DE ? "" : "in"); sca_dump_rings()
588 sca_inw(get_dmac_tx(port) + CDAL, card), sca_dump_rings()
589 sca_inw(get_dmac_tx(port) + EDAL, card), sca_dump_rings()
590 sca_in(DSR_TX(phy_node(port)), card), port->txin, port->txlast, sca_dump_rings()
591 sca_in(DSR_TX(phy_node(port)), card) & DSR_DE ? "" : "in"); sca_dump_rings()
599 sca_in(get_msci(port) + MD0, card), sca_dump_rings()
600 sca_in(get_msci(port) + MD1, card), sca_dump_rings()
601 sca_in(get_msci(port) + MD2, card), sca_dump_rings()
602 sca_in(get_msci(port) + ST0, card), sca_dump_rings()
603 sca_in(get_msci(port) + ST1, card), sca_dump_rings()
604 sca_in(get_msci(port) + ST2, card), sca_dump_rings()
605 sca_in(get_msci(port) + ST3, card), sca_dump_rings()
606 sca_in(get_msci(port) + FST, card), sca_dump_rings()
607 sca_in(get_msci(port) + CST0, card), sca_dump_rings()
608 sca_in(get_msci(port) + CST1, card)); sca_dump_rings()
610 printk(KERN_DEBUG "ISR: %02x %02x %02x\n", sca_in(ISR0, card), sca_dump_rings()
611 sca_in(ISR1, card), sca_in(ISR2, card)); sca_dump_rings()
614 openwin(card, page); /* Restore original page */ sca_dump_rings()
623 card_t *card = port_to_card(port); sca_xmit() local
642 page = buff / winsize(card); sca_xmit()
643 buff = buff % winsize(card); sca_xmit()
644 maxlen = winsize(card) - buff; sca_xmit()
646 openwin(card, page); sca_xmit()
648 memcpy_toio(winbase(card) + buff, skb->data, maxlen); sca_xmit()
649 openwin(card, page + 1); sca_xmit()
650 memcpy_toio(winbase(card), skb->data + maxlen, len - maxlen); sca_xmit()
652 memcpy_toio(winbase(card) + buff, skb->data, len); sca_xmit()
655 openwin(card, 0); /* select pkt_desc table page back */ sca_xmit()
662 get_dmac_tx(port) + EDAL, card); sca_xmit()
664 sca_out(DSR_DE, DSR_TX(phy_node(port)), card); /* Enable TX DMA */ sca_xmit()
678 static u32 sca_detect_ram(card_t *card, u8 __iomem *rambase, u32 ramsize) sca_detect_ram() argument
682 u32 size = winsize(card); sca_detect_ram()
684 openwin(card, (i - 4) / size); /* select last window */ sca_detect_ram()
689 openwin(card, i / size); sca_detect_ram()
695 openwin(card, i / size); sca_detect_ram()
706 static void sca_init(card_t *card, int wait_states) sca_init() argument
708 sca_out(wait_states, WCRL, card); /* Wait Control */ sca_init()
709 sca_out(wait_states, WCRM, card); sca_init()
710 sca_out(wait_states, WCRH, card); sca_init()
712 sca_out(0, DMER, card); /* DMA Master disable */ sca_init()
713 sca_out(0x03, PCR, card); /* DMA priority */ sca_init()
714 sca_out(0, DSR_RX(0), card); /* DMA disable - to halt state */ sca_init()
715 sca_out(0, DSR_TX(0), card); sca_init()
716 sca_out(0, DSR_RX(1), card); sca_init()
717 sca_out(0, DSR_TX(1), card); sca_init()
718 sca_out(DMER_DME, DMER, card); /* DMA Master enable */ sca_init()
H A Dfarsync.c48 /* Number of ports (per card) and cards supported
58 * of frames on the way down to the card
59 * so that we can keep the card busy
109 #define FST_MEMSIZE 0x100000 /* Size of card memory (1Mb) */
179 /* Interrupts from the card are caused by various events which are presented
320 /* Number of times the card thinks the host has
429 struct fst_card_info *card; /* Card we're associated with */ member in struct:fst_port_info
430 int index; /* Port index on the card */
447 /* Per card information
456 unsigned int type; /* Type index of card */
457 unsigned int state; /* State of card */
459 unsigned short pci_conf; /* PCI card config in I/O space */
463 int card_no; /* Inst of the card on the system */
571 static void do_bottom_half_tx(struct fst_card_info *card);
572 static void do_bottom_half_rx(struct fst_card_info *card);
597 * a bit for the card indicating that there is work to do in the fst_q_work_item()
598 * bottom half for the card. Note the limitation of 64 cards. fst_q_work_item()
623 * Call the bottom half for each card with work waiting fst_process_tx_work_q()
628 dbg(DBG_TX, "Calling tx bh for card %d\n", i); fst_process_tx_work_q()
653 * Call the bottom half for each card with work waiting fst_process_int_work_q()
659 "Calling rx & tx bh for card %d\n", i); fst_process_int_work_q()
673 * Used to be a simple write to card control space but a glitch in the latest
679 fst_cpureset(struct fst_card_info *card) fst_cpureset() argument
684 if (card->family == FST_FAMILY_TXU) { fst_cpureset()
686 (card->device, PCI_INTERRUPT_LINE, &interrupt_line_register)) { fst_cpureset()
694 outw(0x440f, card->pci_conf + CNTRL_9054 + 2); fst_cpureset()
695 outw(0x040f, card->pci_conf + CNTRL_9054 + 2); fst_cpureset()
700 outw(0x240f, card->pci_conf + CNTRL_9054 + 2); fst_cpureset()
705 outw(0x040f, card->pci_conf + CNTRL_9054 + 2); fst_cpureset()
708 (card->device, PCI_INTERRUPT_LINE, interrupt_line_register)) { fst_cpureset()
714 regval = inl(card->pci_conf + CNTRL_9052); fst_cpureset()
716 outl(regval | 0x40000000, card->pci_conf + CNTRL_9052); fst_cpureset()
717 outl(regval & ~0x40000000, card->pci_conf + CNTRL_9052); fst_cpureset()
724 fst_cpurelease(struct fst_card_info *card) fst_cpurelease() argument
726 if (card->family == FST_FAMILY_TXU) { fst_cpurelease()
730 (void) readb(card->mem); fst_cpurelease()
736 outw(0x040e, card->pci_conf + CNTRL_9054 + 2); fst_cpurelease()
737 outw(0x040f, card->pci_conf + CNTRL_9054 + 2); fst_cpurelease()
739 (void) readb(card->ctlmem); fst_cpurelease()
746 fst_clear_intr(struct fst_card_info *card) fst_clear_intr() argument
748 if (card->family == FST_FAMILY_TXU) { fst_clear_intr()
749 (void) readb(card->ctlmem); fst_clear_intr()
753 outw(0x0543, card->pci_conf + INTCSR_9052); fst_clear_intr()
757 /* Enable card interrupts
760 fst_enable_intr(struct fst_card_info *card) fst_enable_intr() argument
762 if (card->family == FST_FAMILY_TXU) { fst_enable_intr()
763 outl(0x0f0c0900, card->pci_conf + INTCSR_9054); fst_enable_intr()
765 outw(0x0543, card->pci_conf + INTCSR_9052); fst_enable_intr()
769 /* Disable card interrupts
772 fst_disable_intr(struct fst_card_info *card) fst_disable_intr() argument
774 if (card->family == FST_FAMILY_TXU) { fst_disable_intr()
775 outl(0x00000000, card->pci_conf + INTCSR_9054); fst_disable_intr()
777 outw(0x0000, card->pci_conf + INTCSR_9052); fst_disable_intr()
805 fst_init_dma(struct fst_card_info *card) fst_init_dma() argument
810 if (card->family == FST_FAMILY_TXU) { fst_init_dma()
811 pci_set_master(card->device); fst_init_dma()
812 outl(0x00020441, card->pci_conf + DMAMODE0); fst_init_dma()
813 outl(0x00020441, card->pci_conf + DMAMODE1); fst_init_dma()
814 outl(0x0, card->pci_conf + DMATHR); fst_init_dma()
821 fst_tx_dma_complete(struct fst_card_info *card, struct fst_port_info *port, fst_tx_dma_complete() argument
827 * Everything is now set, just tell the card to go fst_tx_dma_complete()
830 FST_WRB(card, txDescrRing[port->index][txpos].bits, fst_tx_dma_complete()
851 fst_rx_dma_complete(struct fst_card_info *card, struct fst_port_info *port, fst_rx_dma_complete() argument
860 memcpy(skb_put(skb, len), card->rx_dma_handle_host, len); fst_rx_dma_complete()
863 FST_WRB(card, rxDescrRing[pi][rxp].bits, DMA_OWN); fst_rx_dma_complete()
885 fst_rx_dma(struct fst_card_info *card, dma_addr_t dma, u32 mem, int len) fst_rx_dma() argument
892 if (card->dmarx_in_progress) { fst_rx_dma()
896 outl(dma, card->pci_conf + DMAPADR0); /* Copy to here */ fst_rx_dma()
897 outl(mem, card->pci_conf + DMALADR0); /* from here */ fst_rx_dma()
898 outl(len, card->pci_conf + DMASIZ0); /* for this length */ fst_rx_dma()
899 outl(0x00000000c, card->pci_conf + DMADPR0); /* In this direction */ fst_rx_dma()
904 card->dmarx_in_progress = 1; fst_rx_dma()
905 outb(0x03, card->pci_conf + DMACSR0); /* Start the transfer */ fst_rx_dma()
912 fst_tx_dma(struct fst_card_info *card, dma_addr_t dma, u32 mem, int len) fst_tx_dma() argument
919 if (card->dmatx_in_progress) { fst_tx_dma()
923 outl(dma, card->pci_conf + DMAPADR1); /* Copy from here */ fst_tx_dma()
924 outl(mem, card->pci_conf + DMALADR1); /* to here */ fst_tx_dma()
925 outl(len, card->pci_conf + DMASIZ1); /* for this length */ fst_tx_dma()
926 outl(0x000000004, card->pci_conf + DMADPR1); /* In this direction */ fst_tx_dma()
931 card->dmatx_in_progress = 1; fst_tx_dma()
932 outb(0x03, card->pci_conf + DMACSR1); /* Start the transfer */ fst_tx_dma()
942 struct fst_card_info *card; fst_issue_cmd() local
947 card = port->card; fst_issue_cmd()
948 spin_lock_irqsave(&card->card_lock, flags); fst_issue_cmd()
949 mbval = FST_RDW(card, portMailbox[port->index][0]); fst_issue_cmd()
954 spin_unlock_irqrestore(&card->card_lock, flags); fst_issue_cmd()
956 spin_lock_irqsave(&card->card_lock, flags); fst_issue_cmd()
963 mbval = FST_RDW(card, portMailbox[port->index][0]); fst_issue_cmd()
972 FST_WRW(card, portMailbox[port->index][0], cmd); fst_issue_cmd()
980 spin_unlock_irqrestore(&card->card_lock, flags); fst_issue_cmd()
988 outputs |= FST_RDL(port->card, v24OpSts[port->index]); fst_op_raise()
989 FST_WRL(port->card, v24OpSts[port->index], outputs); fst_op_raise()
998 outputs = ~outputs & FST_RDL(port->card, v24OpSts[port->index]); fst_op_lower()
999 FST_WRL(port->card, v24OpSts[port->index], outputs); fst_op_lower()
1015 struct fst_card_info *card; fst_rx_config() local
1018 card = port->card; fst_rx_config()
1019 spin_lock_irqsave(&card->card_lock, flags); fst_rx_config()
1023 FST_WRW(card, rxDescrRing[pi][i].ladr, (u16) offset); fst_rx_config()
1024 FST_WRB(card, rxDescrRing[pi][i].hadr, (u8) (offset >> 16)); fst_rx_config()
1025 FST_WRW(card, rxDescrRing[pi][i].bcnt, cnv_bcnt(LEN_RX_BUFFER)); fst_rx_config()
1026 FST_WRW(card, rxDescrRing[pi][i].mcnt, LEN_RX_BUFFER); fst_rx_config()
1027 FST_WRB(card, rxDescrRing[pi][i].bits, DMA_OWN); fst_rx_config()
1030 spin_unlock_irqrestore(&card->card_lock, flags); fst_rx_config()
1043 struct fst_card_info *card; fst_tx_config() local
1046 card = port->card; fst_tx_config()
1047 spin_lock_irqsave(&card->card_lock, flags); fst_tx_config()
1051 FST_WRW(card, txDescrRing[pi][i].ladr, (u16) offset); fst_tx_config()
1052 FST_WRB(card, txDescrRing[pi][i].hadr, (u8) (offset >> 16)); fst_tx_config()
1053 FST_WRW(card, txDescrRing[pi][i].bcnt, 0); fst_tx_config()
1054 FST_WRB(card, txDescrRing[pi][i].bits, 0); fst_tx_config()
1059 spin_unlock_irqrestore(&card->card_lock, flags); fst_tx_config()
1065 fst_intr_te1_alarm(struct fst_card_info *card, struct fst_port_info *port) fst_intr_te1_alarm() argument
1071 los = FST_RDB(card, suStatus.lossOfSignal); fst_intr_te1_alarm()
1072 rra = FST_RDB(card, suStatus.receiveRemoteAlarm); fst_intr_te1_alarm()
1073 ais = FST_RDB(card, suStatus.alarmIndicationSignal); fst_intr_te1_alarm()
1111 fst_intr_ctlchg(struct fst_card_info *card, struct fst_port_info *port) fst_intr_ctlchg() argument
1115 signals = FST_RDL(card, v24DebouncedSts[port->index]); fst_intr_ctlchg()
1134 fst_log_rx_error(struct fst_card_info *card, struct fst_port_info *port, fst_log_rx_error() argument
1145 dbg(DBG_ASS, "Rx fifo error on card %d port %d buffer %d\n", fst_log_rx_error()
1146 card->card_no, port->index, rxp); fst_log_rx_error()
1150 dbg(DBG_ASS, "Rx crc error on card %d port %d\n", fst_log_rx_error()
1151 card->card_no, port->index); fst_log_rx_error()
1155 dbg(DBG_ASS, "Rx frame error on card %d port %d\n", fst_log_rx_error()
1156 card->card_no, port->index); fst_log_rx_error()
1160 dbg(DBG_ASS, "Rx length error (%d) on card %d port %d\n", fst_log_rx_error()
1161 len, card->card_no, port->index); fst_log_rx_error()
1168 fst_recover_rx_error(struct fst_card_info *card, struct fst_port_info *port, fst_recover_rx_error() argument
1182 FST_WRB(card, rxDescrRing[pi][rxp].bits, DMA_OWN); fst_recover_rx_error()
1189 dmabits = FST_RDB(card, rxDescrRing[pi][rxp].bits); fst_recover_rx_error()
1196 FST_WRB(card, rxDescrRing[pi][rxp].bits, DMA_OWN); fst_recover_rx_error()
1207 fst_intr_rx(struct fst_card_info *card, struct fst_port_info *port) fst_intr_rx() argument
1220 dmabits = FST_RDB(card, rxDescrRing[pi][rxp].bits); fst_intr_rx()
1226 if (card->dmarx_in_progress) { fst_intr_rx()
1231 len = FST_RDW(card, rxDescrRing[pi][rxp].mcnt); fst_intr_rx()
1240 card->card_no, port->index); fst_intr_rx()
1241 /* Return descriptor to card */ fst_intr_rx()
1242 FST_WRB(card, rxDescrRing[pi][rxp].bits, DMA_OWN); fst_intr_rx()
1255 fst_log_rx_error(card, port, dmabits, rxp, len); fst_intr_rx()
1256 fst_recover_rx_error(card, port, dmabits, rxp, len); fst_intr_rx()
1266 /* Return descriptor to card */ fst_intr_rx()
1267 FST_WRB(card, rxDescrRing[pi][rxp].bits, DMA_OWN); fst_intr_rx()
1280 if ((len < FST_MIN_DMA_LEN) || (card->family == FST_FAMILY_TXP)) { fst_intr_rx()
1282 card->mem + BUF_OFFSET(rxBuffer[pi][rxp][0]), fst_intr_rx()
1286 FST_WRB(card, rxDescrRing[pi][rxp].bits, DMA_OWN); fst_intr_rx()
1303 card->dma_skb_rx = skb; fst_intr_rx()
1304 card->dma_port_rx = port; fst_intr_rx()
1305 card->dma_len_rx = len; fst_intr_rx()
1306 card->dma_rxpos = rxp; fst_intr_rx()
1307 fst_rx_dma(card, card->rx_dma_handle_card, fst_intr_rx()
1324 do_bottom_half_tx(struct fst_card_info *card) do_bottom_half_tx() argument
1335 * Step through each port on this card do_bottom_half_tx()
1339 for (pi = 0, port = card->ports; pi < card->nports; pi++, port++) { do_bottom_half_tx()
1344 while (!(FST_RDB(card, txDescrRing[pi][port->txpos].bits) & do_bottom_half_tx()
1346 !(card->dmatx_in_progress)) { do_bottom_half_tx()
1352 spin_lock_irqsave(&card->card_lock, flags); do_bottom_half_tx()
1360 spin_unlock_irqrestore(&card->card_lock, flags); do_bottom_half_tx()
1365 spin_lock_irqsave(&card->card_lock, flags); do_bottom_half_tx()
1371 spin_unlock_irqrestore(&card->card_lock, flags); do_bottom_half_tx()
1374 * card. do_bottom_half_tx()
1376 FST_WRW(card, txDescrRing[pi][port->txpos].bcnt, do_bottom_half_tx()
1379 (card->family == FST_FAMILY_TXP)) { do_bottom_half_tx()
1381 memcpy_toio(card->mem + do_bottom_half_tx()
1386 FST_WRB(card, do_bottom_half_tx()
1395 memcpy(card->tx_dma_handle_host, do_bottom_half_tx()
1397 card->dma_port_tx = port; do_bottom_half_tx()
1398 card->dma_len_tx = skb->len; do_bottom_half_tx()
1399 card->dma_txpos = port->txpos; do_bottom_half_tx()
1400 fst_tx_dma(card, do_bottom_half_tx()
1401 card->tx_dma_handle_card, do_bottom_half_tx()
1430 do_bottom_half_rx(struct fst_card_info *card) do_bottom_half_rx() argument
1436 /* Check for rx completions on all ports on this card */ do_bottom_half_rx()
1438 for (pi = 0, port = card->ports; pi < card->nports; pi++, port++) { do_bottom_half_rx()
1442 while (!(FST_RDB(card, rxDescrRing[pi][port->rxpos].bits) do_bottom_half_rx()
1443 & DMA_OWN) && !(card->dmarx_in_progress)) { do_bottom_half_rx()
1449 fst_q_work_item(&fst_work_intq, card->card_no); do_bottom_half_rx()
1453 fst_intr_rx(card, port); do_bottom_half_rx()
1466 struct fst_card_info *card = dev_id; fst_intr() local
1476 * Check to see if the interrupt was for this card fst_intr()
1480 dbg(DBG_INTR, "intr: %d %p\n", card->irq, card); fst_intr()
1481 if (card->state != FST_RUNNING) { fst_intr()
1482 pr_err("Interrupt received for card %d in a non running state (%d)\n", fst_intr()
1483 card->card_no, card->state); fst_intr()
1487 * a running card fst_intr()
1490 fst_clear_intr(card); fst_intr()
1495 fst_clear_intr(card); fst_intr()
1498 * Is the interrupt for this card (handshake == 1) fst_intr()
1501 if (FST_RDB(card, interruptHandshake) == 1) { fst_intr()
1504 FST_WRB(card, interruptHandshake, 0xEE); fst_intr()
1506 if (card->family == FST_FAMILY_TXU) { fst_intr()
1510 dma_intcsr = inl(card->pci_conf + INTCSR_9054); fst_intr()
1516 outb(0x8, card->pci_conf + DMACSR0); fst_intr()
1517 fst_rx_dma_complete(card, card->dma_port_rx, fst_intr()
1518 card->dma_len_rx, card->dma_skb_rx, fst_intr()
1519 card->dma_rxpos); fst_intr()
1520 card->dmarx_in_progress = 0; fst_intr()
1528 outb(0x8, card->pci_conf + DMACSR1); fst_intr()
1529 fst_tx_dma_complete(card, card->dma_port_tx, fst_intr()
1530 card->dma_len_tx, card->dma_txpos); fst_intr()
1531 card->dmatx_in_progress = 0; fst_intr()
1539 int_retry_count = FST_RDL(card, interruptRetryCount); fst_intr()
1542 card->card_no, int_retry_count); fst_intr()
1543 FST_WRL(card, interruptRetryCount, 0); fst_intr()
1551 fst_q_work_item(&fst_work_intq, card->card_no); fst_intr()
1555 rdidx = FST_RDB(card, interruptEvent.rdindex) & 0x1f; fst_intr()
1556 wridx = FST_RDB(card, interruptEvent.wrindex) & 0x1f; fst_intr()
1558 event = FST_RDB(card, interruptEvent.evntbuff[rdidx]); fst_intr()
1559 port = &card->ports[event & 0x03]; fst_intr()
1567 fst_intr_te1_alarm(card, port); fst_intr()
1575 fst_intr_ctlchg(card, port); fst_intr()
1595 dbg(DBG_ASS, "Tx underflow on card %d port %d\n", fst_intr()
1596 card->card_no, port->index); fst_intr()
1605 card->state = FST_IFAILED; fst_intr()
1609 pr_err("intr: unknown card event %d. ignored\n", event); fst_intr()
1617 FST_WRB(card, interruptEvent.rdindex, rdidx); fst_intr()
1625 check_started_ok(struct fst_card_info *card) check_started_ok() argument
1630 if (FST_RDW(card, smcVersion) != SMC_VERSION) { check_started_ok()
1632 FST_RDW(card, smcVersion), SMC_VERSION); check_started_ok()
1633 card->state = FST_BADVERSION; check_started_ok()
1636 if (FST_RDL(card, endOfSmcSignature) != END_SIG) { check_started_ok()
1638 card->state = FST_BADVERSION; check_started_ok()
1642 if ((i = FST_RDB(card, taskStatus)) == 0x01) { check_started_ok()
1643 card->state = FST_RUNNING; check_started_ok()
1646 card->state = FST_HALTED; check_started_ok()
1650 card->state = FST_HALTED; check_started_ok()
1655 * number we assumed at card detection. Should never happen with check_started_ok()
1658 if (FST_RDL(card, numberOfPorts) != card->nports) { check_started_ok()
1659 pr_warn("Port count mismatch on card %d. Firmware thinks %d we say %d\n", check_started_ok()
1660 card->card_no, check_started_ok()
1661 FST_RDL(card, numberOfPorts), card->nports); check_started_ok()
1666 set_conf_from_info(struct fst_card_info *card, struct fst_port_info *port, set_conf_from_info() argument
1691 FST_WRB(card, portConfig[port->index].invertClock, set_conf_from_info()
1694 FST_WRW(card, cardMode, info->cardMode); set_conf_from_info()
1696 FST_WRL(card, suConfig.dataRate, info->lineSpeed); set_conf_from_info()
1697 FST_WRB(card, suConfig.clocking, info->clockSource); set_conf_from_info()
1705 FST_WRB(card, suConfig.framing, my_framing); set_conf_from_info()
1706 FST_WRB(card, suConfig.structure, info->structure); set_conf_from_info()
1707 FST_WRB(card, suConfig.interface, info->interface); set_conf_from_info()
1708 FST_WRB(card, suConfig.coding, info->coding); set_conf_from_info()
1709 FST_WRB(card, suConfig.lineBuildOut, info->lineBuildOut); set_conf_from_info()
1710 FST_WRB(card, suConfig.equalizer, info->equalizer); set_conf_from_info()
1711 FST_WRB(card, suConfig.transparentMode, info->transparentMode); set_conf_from_info()
1712 FST_WRB(card, suConfig.loopMode, info->loopMode); set_conf_from_info()
1713 FST_WRB(card, suConfig.range, info->range); set_conf_from_info()
1714 FST_WRB(card, suConfig.txBufferMode, info->txBufferMode); set_conf_from_info()
1715 FST_WRB(card, suConfig.rxBufferMode, info->rxBufferMode); set_conf_from_info()
1716 FST_WRB(card, suConfig.startingSlot, info->startingSlot); set_conf_from_info()
1717 FST_WRB(card, suConfig.losThreshold, info->losThreshold); set_conf_from_info()
1719 FST_WRB(card, suConfig.enableIdleCode, 1); set_conf_from_info()
1721 FST_WRB(card, suConfig.enableIdleCode, 0); set_conf_from_info()
1722 FST_WRB(card, suConfig.idleCode, info->idleCode); set_conf_from_info()
1756 gather_conf_info(struct fst_card_info *card, struct fst_port_info *port, gather_conf_info() argument
1765 info->nports = card->nports; gather_conf_info()
1766 info->type = card->type; gather_conf_info()
1767 info->state = card->state; gather_conf_info()
1774 /* Only mark information as valid if card is running. gather_conf_info()
1777 info->valid = ((card->state == FST_RUNNING) ? FSTVAL_ALL : FSTVAL_CARD) gather_conf_info()
1783 info->lineInterface = FST_RDW(card, portConfig[i].lineInterface); gather_conf_info()
1784 info->internalClock = FST_RDB(card, portConfig[i].internalClock); gather_conf_info()
1785 info->lineSpeed = FST_RDL(card, portConfig[i].lineSpeed); gather_conf_info()
1786 info->invertClock = FST_RDB(card, portConfig[i].invertClock); gather_conf_info()
1787 info->v24IpSts = FST_RDL(card, v24IpSts[i]); gather_conf_info()
1788 info->v24OpSts = FST_RDL(card, v24OpSts[i]); gather_conf_info()
1789 info->clockStatus = FST_RDW(card, clockStatus[i]); gather_conf_info()
1790 info->cableStatus = FST_RDW(card, cableStatus); gather_conf_info()
1791 info->cardMode = FST_RDW(card, cardMode); gather_conf_info()
1792 info->smcFirmwareVersion = FST_RDL(card, smcFirmwareVersion); gather_conf_info()
1799 if (card->family == FST_FAMILY_TXU) { gather_conf_info()
1816 if (card->type == FST_TYPE_TE1) { gather_conf_info()
1817 info->lineSpeed = FST_RDL(card, suConfig.dataRate); gather_conf_info()
1818 info->clockSource = FST_RDB(card, suConfig.clocking); gather_conf_info()
1819 info->framing = FST_RDB(card, suConfig.framing); gather_conf_info()
1820 info->structure = FST_RDB(card, suConfig.structure); gather_conf_info()
1821 info->interface = FST_RDB(card, suConfig.interface); gather_conf_info()
1822 info->coding = FST_RDB(card, suConfig.coding); gather_conf_info()
1823 info->lineBuildOut = FST_RDB(card, suConfig.lineBuildOut); gather_conf_info()
1824 info->equalizer = FST_RDB(card, suConfig.equalizer); gather_conf_info()
1825 info->loopMode = FST_RDB(card, suConfig.loopMode); gather_conf_info()
1826 info->range = FST_RDB(card, suConfig.range); gather_conf_info()
1827 info->txBufferMode = FST_RDB(card, suConfig.txBufferMode); gather_conf_info()
1828 info->rxBufferMode = FST_RDB(card, suConfig.rxBufferMode); gather_conf_info()
1829 info->startingSlot = FST_RDB(card, suConfig.startingSlot); gather_conf_info()
1830 info->losThreshold = FST_RDB(card, suConfig.losThreshold); gather_conf_info()
1831 if (FST_RDB(card, suConfig.enableIdleCode)) gather_conf_info()
1832 info->idleCode = FST_RDB(card, suConfig.idleCode); gather_conf_info()
1836 FST_RDL(card, suStatus.receiveBufferDelay); gather_conf_info()
1838 FST_RDL(card, suStatus.framingErrorCount); gather_conf_info()
1840 FST_RDL(card, suStatus.codeViolationCount); gather_conf_info()
1841 info->crcErrorCount = FST_RDL(card, suStatus.crcErrorCount); gather_conf_info()
1842 info->lineAttenuation = FST_RDL(card, suStatus.lineAttenuation); gather_conf_info()
1843 info->lossOfSignal = FST_RDB(card, suStatus.lossOfSignal); gather_conf_info()
1845 FST_RDB(card, suStatus.receiveRemoteAlarm); gather_conf_info()
1847 FST_RDB(card, suStatus.alarmIndicationSignal); gather_conf_info()
1852 fst_set_iface(struct fst_card_info *card, struct fst_port_info *port, fst_set_iface() argument
1874 FST_WRW(card, portConfig[i].lineInterface, V35); fst_set_iface()
1879 FST_WRW(card, portConfig[i].lineInterface, V24); fst_set_iface()
1884 FST_WRW(card, portConfig[i].lineInterface, X21); fst_set_iface()
1889 FST_WRW(card, portConfig[i].lineInterface, X21D); fst_set_iface()
1894 FST_WRW(card, portConfig[i].lineInterface, T1); fst_set_iface()
1899 FST_WRW(card, portConfig[i].lineInterface, E1); fst_set_iface()
1912 FST_WRB(card, portConfig[i].internalClock, EXTCLK); fst_set_iface()
1916 FST_WRB(card, portConfig[i].internalClock, INTCLK); fst_set_iface()
1922 FST_WRL(card, portConfig[i].lineSpeed, sync.clock_rate); fst_set_iface()
1927 fst_get_iface(struct fst_card_info *card, struct fst_port_info *port, fst_get_iface() argument
1967 sync.clock_rate = FST_RDL(card, portConfig[i].lineSpeed); fst_get_iface()
1968 /* Lucky card and linux use same encoding here */ fst_get_iface()
1969 sync.clock_type = FST_RDB(card, portConfig[i].internalClock) == fst_get_iface()
1984 struct fst_card_info *card; fst_ioctl() local
1994 card = port->card; fst_ioctl()
2001 fst_cpureset(card); fst_ioctl()
2002 card->state = FST_RESET; fst_ioctl()
2006 fst_cpurelease(card); fst_ioctl()
2007 card->state = FST_STARTING; fst_ioctl()
2031 /* Now copy the data to the card. */ fst_ioctl()
2038 memcpy_toio(card->mem + wrthdr.offset, buf, wrthdr.size); fst_ioctl()
2041 /* Writes to the memory of a card in the reset state constitute fst_ioctl()
2044 if (card->state == FST_RESET) { fst_ioctl()
2045 card->state = FST_DOWNLOAD; fst_ioctl()
2051 /* If card has just been started check the shared memory config fst_ioctl()
2054 if (card->state == FST_STARTING) { fst_ioctl()
2055 check_started_ok(card); fst_ioctl()
2057 /* If everything checked out enable card interrupts */ fst_ioctl()
2058 if (card->state == FST_RUNNING) { fst_ioctl()
2059 spin_lock_irqsave(&card->card_lock, flags); fst_ioctl()
2060 fst_enable_intr(card); fst_ioctl()
2061 FST_WRB(card, interruptHandshake, 0xEE); fst_ioctl()
2062 spin_unlock_irqrestore(&card->card_lock, flags); fst_ioctl()
2070 gather_conf_info(card, port, &info); fst_ioctl()
2084 if (card->state != FST_RUNNING) { fst_ioctl()
2085 pr_err("Attempt to configure card %d in non-running state (%d)\n", fst_ioctl()
2086 card->card_no, card->state); fst_ioctl()
2093 return set_conf_from_info(card, port, &info); fst_ioctl()
2098 return fst_get_iface(card, port, ifr); fst_ioctl()
2107 return fst_set_iface(card, port, ifr); fst_ioctl()
2139 /* Only init things if card is actually running. This allows open to fst_openport()
2142 if (port->card->state == FST_RUNNING) { fst_openport()
2157 signals = FST_RDL(port->card, v24DebouncedSts[port->index]); fst_openport()
2174 if (port->card->state == FST_RUNNING) { fst_closeport()
2213 struct fst_card_info *card; fst_close() local
2218 card = port->card; fst_close()
2220 tx_dma_done = inb(card->pci_conf + DMACSR1); fst_close()
2221 rx_dma_done = inb(card->pci_conf + DMACSR0); fst_close()
2224 card->dmatx_in_progress, tx_dma_done, card->dmarx_in_progress, fst_close()
2240 * Setting currently fixed in FarSync card so we check and forget fst_attach()
2251 struct fst_card_info *card; fst_tx_timeout() local
2254 card = port->card; fst_tx_timeout()
2257 dbg(DBG_ASS, "Tx timeout card %d port %d\n", fst_tx_timeout()
2258 card->card_no, port->index); fst_tx_timeout()
2269 struct fst_card_info *card; fst_start_xmit() local
2275 card = port->card; fst_start_xmit()
2284 "Tried to transmit but no carrier on card %d port %d\n", fst_start_xmit()
2285 card->card_no, port->index); fst_start_xmit()
2303 spin_lock_irqsave(&card->card_lock, flags); fst_start_xmit()
2311 spin_unlock_irqrestore(&card->card_lock, flags); fst_start_xmit()
2327 dbg(DBG_ASS, "Tx queue overflow card %d port %d\n", fst_start_xmit()
2328 card->card_no, port->index); fst_start_xmit()
2335 spin_lock_irqsave(&card->card_lock, flags); fst_start_xmit()
2340 spin_unlock_irqrestore(&card->card_lock, flags); fst_start_xmit()
2343 fst_q_work_item(&fst_work_txq, card->card_no); fst_start_xmit()
2367 fst_init_card(struct fst_card_info *card) fst_init_card() argument
2372 /* We're working on a number of ports based on the card ID. If the fst_init_card()
2376 for (i = 0; i < card->nports; i++) { fst_init_card()
2377 err = register_hdlc_device(card->ports[i].dev); fst_init_card()
2382 unregister_hdlc_device(card->ports[i].dev); fst_init_card()
2388 port_to_dev(&card->ports[0])->name, fst_init_card()
2389 port_to_dev(&card->ports[card->nports - 1])->name, fst_init_card()
2390 type_strings[card->type], card->irq, card->nports); fst_init_card()
2404 * Initialise card when detected.
2411 struct fst_card_info *card; fst_add_one() local
2440 card = kzalloc(sizeof(struct fst_card_info), GFP_KERNEL); fst_add_one()
2441 if (card == NULL) fst_add_one()
2446 pr_err("Failed to enable card. Err %d\n", -err); fst_add_one()
2456 card->pci_conf = pci_resource_start(pdev, 1); fst_add_one()
2457 card->phys_mem = pci_resource_start(pdev, 2); fst_add_one()
2458 card->phys_ctlmem = pci_resource_start(pdev, 3); fst_add_one()
2459 if ((card->mem = ioremap(card->phys_mem, FST_MEMSIZE)) == NULL) { fst_add_one()
2464 if ((card->ctlmem = ioremap(card->phys_ctlmem, 0x10)) == NULL) { fst_add_one()
2469 dbg(DBG_PCI, "kernel mem %p, ctlmem %p\n", card->mem, card->ctlmem); fst_add_one()
2472 if (request_irq(pdev->irq, fst_intr, IRQF_SHARED, FST_DEV_NAME, card)) { fst_add_one()
2473 pr_err("Unable to register interrupt %d\n", card->irq); fst_add_one()
2479 card->irq = pdev->irq; fst_add_one()
2480 card->type = ent->driver_data; fst_add_one()
2481 card->family = ((ent->driver_data == FST_TYPE_T2P) || fst_add_one()
2486 card->nports = 1; fst_add_one()
2488 card->nports = ((ent->driver_data == FST_TYPE_T2P) || fst_add_one()
2491 card->state = FST_UNINIT; fst_add_one()
2492 spin_lock_init ( &card->card_lock ); fst_add_one()
2494 for ( i = 0 ; i < card->nports ; i++ ) { fst_add_one()
2495 struct net_device *dev = alloc_hdlcdev(&card->ports[i]); fst_add_one()
2499 free_netdev(card->ports[i].dev); fst_add_one()
2504 card->ports[i].dev = dev; fst_add_one()
2505 card->ports[i].card = card; fst_add_one()
2506 card->ports[i].index = i; fst_add_one()
2507 card->ports[i].run = 0; fst_add_one()
2514 * and basic card I/O. fst_add_one()
2516 dev->mem_start = card->phys_mem fst_add_one()
2518 dev->mem_end = card->phys_mem fst_add_one()
2520 dev->base_addr = card->pci_conf; fst_add_one()
2521 dev->irq = card->irq; fst_add_one()
2530 card->device = pdev; fst_add_one()
2532 dbg(DBG_PCI, "type %d nports %d irq %d\n", card->type, fst_add_one()
2533 card->nports, card->irq); fst_add_one()
2535 card->pci_conf, card->phys_mem, card->phys_ctlmem); fst_add_one()
2537 /* Reset the card's processor */ fst_add_one()
2538 fst_cpureset(card); fst_add_one()
2539 card->state = FST_RESET; fst_add_one()
2542 fst_init_dma(card); fst_add_one()
2545 pci_set_drvdata(pdev, card); fst_add_one()
2547 /* Remainder of card setup */ fst_add_one()
2553 fst_card_array[no_of_cards_added] = card; fst_add_one()
2554 card->card_no = no_of_cards_added++; /* Record instance and bump it */ fst_add_one()
2555 err = fst_init_card(card); fst_add_one()
2558 if (card->family == FST_FAMILY_TXU) { fst_add_one()
2562 card->rx_dma_handle_host = fst_add_one()
2563 pci_alloc_consistent(card->device, FST_MAX_MTU, fst_add_one()
2564 &card->rx_dma_handle_card); fst_add_one()
2565 if (card->rx_dma_handle_host == NULL) { fst_add_one()
2570 card->tx_dma_handle_host = fst_add_one()
2571 pci_alloc_consistent(card->device, FST_MAX_MTU, fst_add_one()
2572 &card->tx_dma_handle_card); fst_add_one()
2573 if (card->tx_dma_handle_host == NULL) { fst_add_one()
2582 pci_free_consistent(card->device, FST_MAX_MTU, fst_add_one()
2583 card->rx_dma_handle_host, fst_add_one()
2584 card->rx_dma_handle_card); fst_add_one()
2586 fst_disable_intr(card); fst_add_one()
2587 for (i = 0 ; i < card->nports ; i++) fst_add_one()
2588 unregister_hdlc_device(card->ports[i].dev); fst_add_one()
2590 fst_card_array[card->card_no] = NULL; fst_add_one()
2592 for (i = 0 ; i < card->nports ; i++) fst_add_one()
2593 free_netdev(card->ports[i].dev); fst_add_one()
2595 free_irq(card->irq, card); fst_add_one()
2597 iounmap(card->ctlmem); fst_add_one()
2599 iounmap(card->mem); fst_add_one()
2605 kfree(card); fst_add_one()
2610 * Cleanup and close down a card
2615 struct fst_card_info *card; fst_remove_one() local
2618 card = pci_get_drvdata(pdev); fst_remove_one()
2620 for (i = 0; i < card->nports; i++) { fst_remove_one()
2621 struct net_device *dev = port_to_dev(&card->ports[i]); fst_remove_one()
2625 fst_disable_intr(card); fst_remove_one()
2626 free_irq(card->irq, card); fst_remove_one()
2628 iounmap(card->ctlmem); fst_remove_one()
2629 iounmap(card->mem); fst_remove_one()
2631 if (card->family == FST_FAMILY_TXU) { fst_remove_one()
2635 pci_free_consistent(card->device, FST_MAX_MTU, fst_remove_one()
2636 card->rx_dma_handle_host, fst_remove_one()
2637 card->rx_dma_handle_card); fst_remove_one()
2638 pci_free_consistent(card->device, FST_MAX_MTU, fst_remove_one()
2639 card->tx_dma_handle_host, fst_remove_one()
2640 card->tx_dma_handle_card); fst_remove_one()
2642 fst_card_array[card->card_no] = NULL; fst_remove_one()
H A Dwanxl.c2 * wanXL serial card driver for Linux
38 static const char* version = "wanXL serial card driver version: 0.48";
59 struct card *card; member in struct:port
74 struct card { struct
82 struct card_status *status; /* shared between host and card */
97 return &port->card->status->port_status[port->node]; get_status()
186 pci_unmap_single(port->card->pdev, desc->address, skb->len, wanxl_tx_intr()
196 static inline void wanxl_rx_intr(struct card *card) wanxl_rx_intr() argument
199 while (desc = &card->status->rx_descs[card->rx_in], wanxl_rx_intr()
201 if ((desc->stat & PACKET_PORT_MASK) > card->n_ports) wanxl_rx_intr()
203 pci_name(card->pdev)); wanxl_rx_intr()
205 struct sk_buff *skb = card->rx_skbs[card->rx_in]; wanxl_rx_intr()
206 struct port *port = &card->ports[desc->stat & wanxl_rx_intr()
213 pci_unmap_single(card->pdev, desc->address, wanxl_rx_intr()
233 pci_map_single(card->pdev, skb->data, wanxl_rx_intr()
236 card->rx_skbs[card->rx_in] = skb; wanxl_rx_intr()
240 card->rx_in = (card->rx_in + 1) % RX_QUEUE_LENGTH; wanxl_rx_intr()
248 struct card *card = dev_id; wanxl_intr() local
254 while((stat = readl(card->plx + PLX_DOORBELL_FROM_CARD)) != 0) { wanxl_intr()
256 writel(stat, card->plx + PLX_DOORBELL_FROM_CARD); wanxl_intr()
258 for (i = 0; i < card->n_ports; i++) { wanxl_intr()
260 wanxl_tx_intr(&card->ports[i]); wanxl_intr()
262 wanxl_cable_intr(&card->ports[i]); wanxl_intr()
265 wanxl_rx_intr(card); wanxl_intr()
297 desc->address = pci_map_single(port->card->pdev, skb->data, skb->len, wanxl_xmit()
302 port->card->plx + PLX_DOORBELL_TO_CARD); wanxl_xmit()
397 u8 __iomem *dbr = port->card->plx + PLX_DOORBELL_TO_CARD; wanxl_open()
411 /* signal the card */ wanxl_open()
423 /* ask the card to close the port, should it be still alive */ wanxl_open()
437 /* signal the card */ wanxl_close()
439 port->card->plx + PLX_DOORBELL_TO_CARD); wanxl_close()
457 pci_unmap_single(port->card->pdev, desc->address, wanxl_close()
481 static int wanxl_puts_command(struct card *card, u32 cmd) wanxl_puts_command() argument
485 writel(cmd, card->plx + PLX_MAILBOX_1); wanxl_puts_command()
487 if (readl(card->plx + PLX_MAILBOX_1) == 0) wanxl_puts_command()
498 static void wanxl_reset(struct card *card) wanxl_reset() argument
500 u32 old_value = readl(card->plx + PLX_CONTROL) & ~PLX_CTL_RESET; wanxl_reset()
502 writel(0x80, card->plx + PLX_MAILBOX_0); wanxl_reset()
503 writel(old_value | PLX_CTL_RESET, card->plx + PLX_CONTROL); wanxl_reset()
504 readl(card->plx + PLX_CONTROL); /* wait for posted write */ wanxl_reset()
506 writel(old_value, card->plx + PLX_CONTROL); wanxl_reset()
507 readl(card->plx + PLX_CONTROL); /* wait for posted write */ wanxl_reset()
514 struct card *card = pci_get_drvdata(pdev); wanxl_pci_remove_one() local
517 for (i = 0; i < card->n_ports; i++) { wanxl_pci_remove_one()
518 unregister_hdlc_device(card->ports[i].dev); wanxl_pci_remove_one()
519 free_netdev(card->ports[i].dev); wanxl_pci_remove_one()
523 if (card->irq) wanxl_pci_remove_one()
524 free_irq(card->irq, card); wanxl_pci_remove_one()
526 wanxl_reset(card); wanxl_pci_remove_one()
529 if (card->rx_skbs[i]) { wanxl_pci_remove_one()
530 pci_unmap_single(card->pdev, wanxl_pci_remove_one()
531 card->status->rx_descs[i].address, wanxl_pci_remove_one()
533 dev_kfree_skb(card->rx_skbs[i]); wanxl_pci_remove_one()
536 if (card->plx) wanxl_pci_remove_one()
537 iounmap(card->plx); wanxl_pci_remove_one()
539 if (card->status) wanxl_pci_remove_one()
541 card->status, card->status_address); wanxl_pci_remove_one()
545 kfree(card); wanxl_pci_remove_one()
563 struct card *card; wanxl_pci_init_one() local
604 alloc_size = sizeof(struct card) + ports * sizeof(struct port); wanxl_pci_init_one()
605 card = kzalloc(alloc_size, GFP_KERNEL); wanxl_pci_init_one()
606 if (card == NULL) { wanxl_pci_init_one()
612 pci_set_drvdata(pdev, card); wanxl_pci_init_one()
613 card->pdev = pdev; wanxl_pci_init_one()
615 card->status = pci_alloc_consistent(pdev, wanxl_pci_init_one()
617 &card->status_address); wanxl_pci_init_one()
618 if (card->status == NULL) { wanxl_pci_init_one()
626 (unsigned long long)card->status_address); wanxl_pci_init_one()
631 to indicate the card can do 32-bit DMA addressing */ wanxl_pci_init_one()
642 card->plx = ioremap_nocache(plx_phy, 0x70); wanxl_pci_init_one()
643 if (!card->plx) { wanxl_pci_init_one()
650 wanxl_reset(card); wanxl_pci_init_one()
654 while ((stat = readl(card->plx + PLX_MAILBOX_0)) != 0) { wanxl_pci_init_one()
678 ramsize = readl(card->plx + PLX_MAILBOX_2) & MBX2_MEMSZ_MASK; wanxl_pci_init_one()
695 if (wanxl_puts_command(card, MBX1_CMD_BSWAP)) { wanxl_pci_init_one()
703 card->rx_skbs[i] = skb; wanxl_pci_init_one()
705 card->status->rx_descs[i].address = wanxl_pci_init_one()
706 pci_map_single(card->pdev, skb->data, wanxl_pci_init_one()
722 writel(card->status_address + wanxl_pci_init_one()
723 (void *)&card->status->port_status[i] - wanxl_pci_init_one()
724 (void *)card->status, mem + PDM_OFFSET + 4 + i * 4); wanxl_pci_init_one()
725 writel(card->status_address, mem + PDM_OFFSET + 20); wanxl_pci_init_one()
729 writel(0, card->plx + PLX_MAILBOX_5); wanxl_pci_init_one()
731 if (wanxl_puts_command(card, MBX1_CMD_ABORTJ)) { wanxl_pci_init_one()
740 if ((stat = readl(card->plx + PLX_MAILBOX_5)) != 0) wanxl_pci_init_one()
746 pr_warn("%s: timeout while initializing card firmware\n", wanxl_pci_init_one()
760 if (request_irq(pdev->irq, wanxl_intr, IRQF_SHARED, "wanXL", card)) { wanxl_pci_init_one()
766 card->irq = pdev->irq; wanxl_pci_init_one()
770 struct port *port = &card->ports[i]; wanxl_pci_init_one()
786 port->card = card; wanxl_pci_init_one()
796 card->n_ports++; wanxl_pci_init_one()
802 i ? "," : "", i, card->ports[i].dev->name); wanxl_pci_init_one()
806 wanxl_cable_intr(&card->ports[i]); /* get carrier status etc.*/ wanxl_pci_init_one()
/linux-4.1.27/drivers/media/pci/bt8xx/
H A Ddvb-bt8xx.c56 struct dvb_bt8xx_card *card = (struct dvb_bt8xx_card *)data; dvb_bt8xx_task() local
58 //printk("%d ", card->bt->finished_block); dvb_bt8xx_task()
60 while (card->bt->last_block != card->bt->finished_block) { dvb_bt8xx_task()
61 (card->bt->TS_Size ? dvb_dmx_swfilter_204 : dvb_dmx_swfilter) dvb_bt8xx_task()
62 (&card->demux, dvb_bt8xx_task()
63 &card->bt->buf_cpu[card->bt->last_block * dvb_bt8xx_task()
64 card->bt->block_bytes], dvb_bt8xx_task()
65 card->bt->block_bytes); dvb_bt8xx_task()
66 card->bt->last_block = (card->bt->last_block + 1) % dvb_bt8xx_task()
67 card->bt->block_count; dvb_bt8xx_task()
74 struct dvb_bt8xx_card *card = dvbdmx->priv; dvb_bt8xx_start_feed() local
82 mutex_lock(&card->lock); dvb_bt8xx_start_feed()
83 card->nfeeds++; dvb_bt8xx_start_feed()
84 rc = card->nfeeds; dvb_bt8xx_start_feed()
85 if (card->nfeeds == 1) dvb_bt8xx_start_feed()
86 bt878_start(card->bt, card->gpio_mode, dvb_bt8xx_start_feed()
87 card->op_sync_orin, card->irq_err_ignore); dvb_bt8xx_start_feed()
88 mutex_unlock(&card->lock); dvb_bt8xx_start_feed()
95 struct dvb_bt8xx_card *card = dvbdmx->priv; dvb_bt8xx_stop_feed() local
102 mutex_lock(&card->lock); dvb_bt8xx_stop_feed()
103 card->nfeeds--; dvb_bt8xx_stop_feed()
104 if (card->nfeeds == 0) dvb_bt8xx_stop_feed()
105 bt878_stop(card->bt); dvb_bt8xx_stop_feed()
106 mutex_unlock(&card->lock); dvb_bt8xx_stop_feed()
252 struct dvb_bt8xx_card *card = fe->dvb->priv; pinnsat_tuner_init() local
254 bttv_gpio_enable(card->bttv_nr, 1, 1); /* output */ pinnsat_tuner_init()
255 bttv_write_gpio(card->bttv_nr, 1, 1); /* relay on */ pinnsat_tuner_init()
262 struct dvb_bt8xx_card *card = fe->dvb->priv; pinnsat_tuner_sleep() local
264 bttv_write_gpio(card->bttv_nr, 1, 0); /* relay off */ pinnsat_tuner_sleep()
276 struct dvb_bt8xx_card *card = (struct dvb_bt8xx_card *) fe->dvb->priv; microtune_mt7202dtf_tuner_set_params() local
310 i2c_transfer(card->i2c_adapter, &msg, 1); microtune_mt7202dtf_tuner_set_params()
472 struct dvb_bt8xx_card *card = (struct dvb_bt8xx_card *) fe->dvb->priv; vp3021_alps_tded4_tuner_set_params() local
495 i2c_transfer(card->i2c_adapter, &msg, 1); vp3021_alps_tded4_tuner_set_params()
597 static void frontend_init(struct dvb_bt8xx_card *card, u32 type) frontend_init() argument
603 card->fe = dvb_attach(mt352_attach, &thomson_dtt7579_config, card->i2c_adapter); frontend_init()
605 if (card->fe == NULL) frontend_init()
606 card->fe = dvb_attach(zl10353_attach, &thomson_dtt7579_zl10353_config, frontend_init()
607 card->i2c_adapter); frontend_init()
609 if (card->fe != NULL) { frontend_init()
610 card->fe->ops.tuner_ops.calc_regs = thomson_dtt7579_tuner_calc_regs; frontend_init()
611 card->fe->ops.info.frequency_min = 174000000; frontend_init()
612 card->fe->ops.info.frequency_max = 862000000; frontend_init()
617 lgdt330x_reset(card); frontend_init()
618 card->fe = dvb_attach(lgdt330x_attach, &tdvs_tua6034_config, card->i2c_adapter); frontend_init()
619 if (card->fe != NULL) { frontend_init()
620 dvb_attach(simple_tuner_attach, card->fe, frontend_init()
621 card->i2c_adapter, 0x61, frontend_init()
633 /* Old Nebula (marked (c)2003 on high profile pci card) has nxt6000 demod */ frontend_init()
634 digitv_alps_tded4_reset(card); frontend_init()
635 card->fe = dvb_attach(nxt6000_attach, &vp3021_alps_tded4_config, card->i2c_adapter); frontend_init()
636 if (card->fe != NULL) { frontend_init()
637 card->fe->ops.tuner_ops.set_params = vp3021_alps_tded4_tuner_set_params; frontend_init()
638 dprintk ("dvb_bt8xx: an nxt6000 was detected on your digitv card\n"); frontend_init()
642 /* New Nebula (marked (c)2005 on low profile pci card) has mt352 demod */ frontend_init()
643 digitv_alps_tded4_reset(card); frontend_init()
644 card->fe = dvb_attach(mt352_attach, &digitv_alps_tded4_config, card->i2c_adapter); frontend_init()
646 if (card->fe != NULL) { frontend_init()
647 card->fe->ops.tuner_ops.calc_regs = digitv_alps_tded4_tuner_calc_regs; frontend_init()
648 dprintk ("dvb_bt8xx: an mt352 was detected on your digitv card\n"); frontend_init()
653 card->fe = dvb_attach(sp887x_attach, &microtune_mt7202dtf_config, card->i2c_adapter); frontend_init()
654 if (card->fe) { frontend_init()
655 card->fe->ops.tuner_ops.set_params = microtune_mt7202dtf_tuner_set_params; frontend_init()
660 card->fe = dvb_attach(mt352_attach, &advbt771_samsung_tdtc9251dh0_config, card->i2c_adapter); frontend_init()
661 if (card->fe != NULL) { frontend_init()
662 card->fe->ops.tuner_ops.calc_regs = advbt771_samsung_tdtc9251dh0_tuner_calc_regs; frontend_init()
663 card->fe->ops.info.frequency_min = 174000000; frontend_init()
664 card->fe->ops.info.frequency_max = 862000000; frontend_init()
677 state->i2c = card->i2c_adapter; frontend_init()
678 state->bt = card->bt; frontend_init()
681 if (dvb_attach(dst_attach, state, &card->dvb_adapter) == NULL) { frontend_init()
687 card->fe = &state->frontend; frontend_init()
689 dvb_attach(dst_ca_attach, state, &card->dvb_adapter); frontend_init()
693 card->fe = dvb_attach(cx24110_attach, &pctvsat_config, card->i2c_adapter); frontend_init()
694 if (card->fe) { frontend_init()
695 card->fe->ops.tuner_ops.init = pinnsat_tuner_init; frontend_init()
696 card->fe->ops.tuner_ops.sleep = pinnsat_tuner_sleep; frontend_init()
697 card->fe->ops.tuner_ops.set_params = cx24108_tuner_set_params; frontend_init()
702 card->fe = dvb_attach(or51211_attach, &or51211_config, card->i2c_adapter); frontend_init()
703 if (card->fe != NULL) frontend_init()
704 dvb_attach(simple_tuner_attach, card->fe, frontend_init()
705 card->i2c_adapter, 0x61, frontend_init()
710 if (card->fe == NULL) frontend_init()
712 card->bt->dev->vendor, frontend_init()
713 card->bt->dev->device, frontend_init()
714 card->bt->dev->subsystem_vendor, frontend_init()
715 card->bt->dev->subsystem_device); frontend_init()
717 if (dvb_register_frontend(&card->dvb_adapter, card->fe)) { frontend_init()
719 dvb_frontend_detach(card->fe); frontend_init()
720 card->fe = NULL; frontend_init()
724 static int dvb_bt8xx_load_card(struct dvb_bt8xx_card *card, u32 type) dvb_bt8xx_load_card() argument
728 result = dvb_register_adapter(&card->dvb_adapter, card->card_name, dvb_bt8xx_load_card()
729 THIS_MODULE, &card->bt->dev->dev, dvb_bt8xx_load_card()
735 card->dvb_adapter.priv = card; dvb_bt8xx_load_card()
737 card->bt->adapter = card->i2c_adapter; dvb_bt8xx_load_card()
739 memset(&card->demux, 0, sizeof(struct dvb_demux)); dvb_bt8xx_load_card()
741 card->demux.dmx.capabilities = DMX_TS_FILTERING | DMX_SECTION_FILTERING | DMX_MEMORY_BASED_FILTERING; dvb_bt8xx_load_card()
743 card->demux.priv = card; dvb_bt8xx_load_card()
744 card->demux.filternum = 256; dvb_bt8xx_load_card()
745 card->demux.feednum = 256; dvb_bt8xx_load_card()
746 card->demux.start_feed = dvb_bt8xx_start_feed; dvb_bt8xx_load_card()
747 card->demux.stop_feed = dvb_bt8xx_stop_feed; dvb_bt8xx_load_card()
748 card->demux.write_to_decoder = NULL; dvb_bt8xx_load_card()
750 result = dvb_dmx_init(&card->demux); dvb_bt8xx_load_card()
756 card->dmxdev.filternum = 256; dvb_bt8xx_load_card()
757 card->dmxdev.demux = &card->demux.dmx; dvb_bt8xx_load_card()
758 card->dmxdev.capabilities = 0; dvb_bt8xx_load_card()
760 result = dvb_dmxdev_init(&card->dmxdev, &card->dvb_adapter); dvb_bt8xx_load_card()
766 card->fe_hw.source = DMX_FRONTEND_0; dvb_bt8xx_load_card()
768 result = card->demux.dmx.add_frontend(&card->demux.dmx, &card->fe_hw); dvb_bt8xx_load_card()
774 card->fe_mem.source = DMX_MEMORY_FE; dvb_bt8xx_load_card()
776 result = card->demux.dmx.add_frontend(&card->demux.dmx, &card->fe_mem); dvb_bt8xx_load_card()
782 result = card->demux.dmx.connect_frontend(&card->demux.dmx, &card->fe_hw); dvb_bt8xx_load_card()
788 result = dvb_net_init(&card->dvb_adapter, &card->dvbnet, &card->demux.dmx); dvb_bt8xx_load_card()
794 tasklet_init(&card->bt->tasklet, dvb_bt8xx_task, (unsigned long) card); dvb_bt8xx_load_card()
796 frontend_init(card, type); dvb_bt8xx_load_card()
801 card->demux.dmx.disconnect_frontend(&card->demux.dmx); dvb_bt8xx_load_card()
803 card->demux.dmx.remove_frontend(&card->demux.dmx, &card->fe_mem); dvb_bt8xx_load_card()
805 card->demux.dmx.remove_frontend(&card->demux.dmx, &card->fe_hw); dvb_bt8xx_load_card()
807 dvb_dmxdev_release(&card->dmxdev); dvb_bt8xx_load_card()
809 dvb_dmx_release(&card->demux); dvb_bt8xx_load_card()
811 dvb_unregister_adapter(&card->dvb_adapter); dvb_bt8xx_load_card()
817 struct dvb_bt8xx_card *card; dvb_bt8xx_probe() local
821 if (!(card = kzalloc(sizeof(struct dvb_bt8xx_card), GFP_KERNEL))) dvb_bt8xx_probe()
824 mutex_init(&card->lock); dvb_bt8xx_probe()
825 card->bttv_nr = sub->core->nr; dvb_bt8xx_probe()
826 strlcpy(card->card_name, sub->core->v4l2_dev.name, sizeof(card->card_name)); dvb_bt8xx_probe()
827 card->i2c_adapter = &sub->core->i2c_adap; dvb_bt8xx_probe()
831 card->gpio_mode = 0x0400c060; dvb_bt8xx_probe()
834 card->op_sync_orin = BT878_RISC_SYNC_MASK; dvb_bt8xx_probe()
835 card->irq_err_ignore = BT878_AFBUS | BT878_AFDSR; dvb_bt8xx_probe()
839 card->gpio_mode = 0x0400C060; dvb_bt8xx_probe()
840 card->op_sync_orin = BT878_RISC_SYNC_MASK; dvb_bt8xx_probe()
841 card->irq_err_ignore = BT878_AFBUS | BT878_AFDSR; dvb_bt8xx_probe()
848 card->gpio_mode = 0x0400c060; dvb_bt8xx_probe()
849 card->op_sync_orin = BT878_RISC_SYNC_MASK; dvb_bt8xx_probe()
850 card->irq_err_ignore = BT878_AFBUS | BT878_AFDSR; dvb_bt8xx_probe()
855 card->gpio_mode = (1 << 26) | (1 << 14) | (1 << 5); dvb_bt8xx_probe()
856 card->op_sync_orin = BT878_RISC_SYNC_MASK; dvb_bt8xx_probe()
857 card->irq_err_ignore = BT878_AFBUS | BT878_AFDSR; dvb_bt8xx_probe()
862 card->gpio_mode = 0x0400402B; dvb_bt8xx_probe()
863 card->op_sync_orin = BT878_RISC_SYNC_MASK; dvb_bt8xx_probe()
864 card->irq_err_ignore = BT878_AFBUS | BT878_AFDSR; dvb_bt8xx_probe()
869 card->gpio_mode = 0x2204f2c; dvb_bt8xx_probe()
870 card->op_sync_orin = BT878_RISC_SYNC_MASK; dvb_bt8xx_probe()
871 card->irq_err_ignore = BT878_APABORT | BT878_ARIPERR | dvb_bt8xx_probe()
887 card->gpio_mode = 0x0100EC7B; dvb_bt8xx_probe()
888 card->op_sync_orin = BT878_RISC_SYNC_MASK; dvb_bt8xx_probe()
889 card->irq_err_ignore = BT878_AFBUS | BT878_AFDSR; dvb_bt8xx_probe()
893 pr_err("Unknown bttv card type: %d\n", sub->core->type); dvb_bt8xx_probe()
894 kfree(card); dvb_bt8xx_probe()
898 dprintk("dvb_bt8xx: identified card%d as %s\n", card->bttv_nr, card->card_name); dvb_bt8xx_probe()
900 if (!(bttv_pci_dev = bttv_get_pcidev(card->bttv_nr))) { dvb_bt8xx_probe()
901 pr_err("no pci device for card %d\n", card->bttv_nr); dvb_bt8xx_probe()
902 kfree(card); dvb_bt8xx_probe()
906 if (!(card->bt = dvb_bt8xx_878_match(card->bttv_nr, bttv_pci_dev))) { dvb_bt8xx_probe()
907 pr_err("unable to determine DMA core of card %d,\n", card->bttv_nr); dvb_bt8xx_probe()
910 kfree(card); dvb_bt8xx_probe()
914 mutex_init(&card->bt->gpio_lock); dvb_bt8xx_probe()
915 card->bt->bttv_nr = sub->core->nr; dvb_bt8xx_probe()
917 if ( (ret = dvb_bt8xx_load_card(card, sub->core->type)) ) { dvb_bt8xx_probe()
918 kfree(card); dvb_bt8xx_probe()
922 dev_set_drvdata(&sub->dev, card); dvb_bt8xx_probe()
928 struct dvb_bt8xx_card *card = dev_get_drvdata(&sub->dev); dvb_bt8xx_remove() local
930 dprintk("dvb_bt8xx: unloading card%d\n", card->bttv_nr); dvb_bt8xx_remove()
932 bt878_stop(card->bt); dvb_bt8xx_remove()
933 tasklet_kill(&card->bt->tasklet); dvb_bt8xx_remove()
934 dvb_net_release(&card->dvbnet); dvb_bt8xx_remove()
935 card->demux.dmx.remove_frontend(&card->demux.dmx, &card->fe_mem); dvb_bt8xx_remove()
936 card->demux.dmx.remove_frontend(&card->demux.dmx, &card->fe_hw); dvb_bt8xx_remove()
937 dvb_dmxdev_release(&card->dmxdev); dvb_bt8xx_remove()
938 dvb_dmx_release(&card->demux); dvb_bt8xx_remove()
939 if (card->fe) { dvb_bt8xx_remove()
940 dvb_unregister_frontend(card->fe); dvb_bt8xx_remove()
941 dvb_frontend_detach(card->fe); dvb_bt8xx_remove()
943 dvb_unregister_adapter(&card->dvb_adapter); dvb_bt8xx_remove()
945 kfree(card); dvb_bt8xx_remove()
H A Dbttv-if.c46 struct pci_dev* bttv_get_pcidev(unsigned int card) bttv_get_pcidev() argument
48 if (card >= bttv_num) bttv_get_pcidev()
50 if (!bttvs[card]) bttv_get_pcidev()
53 return bttvs[card]->c.pci; bttv_get_pcidev()
57 int bttv_gpio_enable(unsigned int card, unsigned long mask, unsigned long data) bttv_gpio_enable() argument
61 if (card >= bttv_num) { bttv_gpio_enable()
65 btv = bttvs[card]; bttv_gpio_enable()
75 int bttv_read_gpio(unsigned int card, unsigned long *data) bttv_read_gpio() argument
79 if (card >= bttv_num) { bttv_read_gpio()
83 btv = bttvs[card]; bttv_read_gpio()
97 int bttv_write_gpio(unsigned int card, unsigned long mask, unsigned long data) bttv_write_gpio() argument
101 if (card >= bttv_num) { bttv_write_gpio()
105 btv = bttvs[card]; bttv_write_gpio()
/linux-4.1.27/drivers/firewire/
H A Dcore-card.c41 void func(const struct fw_card *card, const char *fmt, ...) \
50 dev_name(card->device), &vaf); \
103 static void generate_config_rom(struct fw_card *card, __be32 *config_rom) generate_config_rom() argument
121 BIB_LINK_SPEED(card->link_speed) | generate_config_rom()
122 BIB_GENERATION(card->config_rom_generation++ % 14 + 2) | generate_config_rom()
124 BIB_MAX_RECEIVE(card->max_receive) | generate_config_rom()
126 config_rom[3] = cpu_to_be32(card->guid >> 32); generate_config_rom()
127 config_rom[4] = cpu_to_be32(card->guid); generate_config_rom()
165 struct fw_card *card; update_config_roms() local
167 list_for_each_entry (card, &card_list, link) { update_config_roms()
168 generate_config_rom(card, tmp_config_rom); update_config_roms()
169 card->driver->set_config_rom(card, tmp_config_rom, update_config_roms()
232 static int reset_bus(struct fw_card *card, bool short_reset) reset_bus() argument
237 return card->driver->update_phy_reg(card, reg, 0, bit); reset_bus()
240 void fw_schedule_bus_reset(struct fw_card *card, bool delayed, bool short_reset) fw_schedule_bus_reset() argument
243 card->br_short = short_reset; fw_schedule_bus_reset()
246 fw_card_get(card); fw_schedule_bus_reset()
247 if (!queue_delayed_work(fw_workqueue, &card->br_work, fw_schedule_bus_reset()
249 fw_card_put(card); fw_schedule_bus_reset()
255 struct fw_card *card = container_of(work, struct fw_card, br_work.work); br_work() local
258 if (card->reset_jiffies != 0 && br_work()
259 time_before64(get_jiffies_64(), card->reset_jiffies + 2 * HZ)) { br_work()
260 if (!queue_delayed_work(fw_workqueue, &card->br_work, 2 * HZ)) br_work()
261 fw_card_put(card); br_work()
265 fw_send_phy_config(card, FW_PHY_CONFIG_NO_NODE_ID, card->generation, br_work()
267 reset_bus(card, card->br_short); br_work()
268 fw_card_put(card); br_work()
271 static void allocate_broadcast_channel(struct fw_card *card, int generation) allocate_broadcast_channel() argument
275 if (!card->broadcast_channel_allocated) { allocate_broadcast_channel()
276 fw_iso_resource_manage(card, generation, 1ULL << 31, allocate_broadcast_channel()
279 fw_notice(card, "failed to allocate broadcast channel\n"); allocate_broadcast_channel()
282 card->broadcast_channel_allocated = true; allocate_broadcast_channel()
285 device_for_each_child(card->device, (void *)(long)generation, allocate_broadcast_channel()
293 void fw_schedule_bm_work(struct fw_card *card, unsigned long delay) fw_schedule_bm_work() argument
295 fw_card_get(card); fw_schedule_bm_work()
296 if (!schedule_delayed_work(&card->bm_work, delay)) fw_schedule_bm_work()
297 fw_card_put(card); fw_schedule_bm_work()
302 struct fw_card *card = container_of(work, struct fw_card, bm_work.work); bm_work() local
314 spin_lock_irq(&card->lock); bm_work()
316 if (card->local_node == NULL) { bm_work()
317 spin_unlock_irq(&card->lock); bm_work()
321 generation = card->generation; bm_work()
323 root_node = card->root_node; bm_work()
330 irm_device = card->irm_node->data; bm_work()
339 irm_id = card->irm_node->node_id; bm_work()
340 local_id = card->local_node->node_id; bm_work()
343 card->reset_jiffies + DIV_ROUND_UP(HZ, 8)); bm_work()
345 if ((is_next_generation(generation, card->bm_generation) && bm_work()
346 !card->bm_abdicate) || bm_work()
347 (card->bm_generation != generation && grace)) { bm_work()
360 if (!card->irm_node->link_on) { bm_work()
362 fw_notice(card, "%s, making local node (%02x) root\n", bm_work()
369 fw_notice(card, "%s, making local node (%02x) root\n", bm_work()
377 spin_unlock_irq(&card->lock); bm_work()
379 rcode = fw_run_transaction(card, TCODE_LOCK_COMPARE_SWAP, bm_work()
390 spin_lock_irq(&card->lock); bm_work()
391 if (rcode == RCODE_COMPLETE && generation == card->generation) bm_work()
392 card->bm_node_id = bm_work()
394 spin_unlock_irq(&card->lock); bm_work()
399 allocate_broadcast_channel(card, generation); bm_work()
410 fw_schedule_bm_work(card, DIV_ROUND_UP(HZ, 8)); bm_work()
414 spin_lock_irq(&card->lock); bm_work()
424 fw_notice(card, "BM lock failed (%s), making local node (%02x) root\n", bm_work()
428 } else if (card->bm_generation != generation) { bm_work()
433 spin_unlock_irq(&card->lock); bm_work()
434 fw_schedule_bm_work(card, DIV_ROUND_UP(HZ, 8)); bm_work()
443 card->bm_generation = generation; bm_work()
456 spin_unlock_irq(&card->lock); bm_work()
478 if (!card->beta_repeaters_present && bm_work()
490 if (card->bm_retries++ < 5 && bm_work()
491 (card->gap_count != gap_count || new_root_id != root_id)) bm_work()
494 spin_unlock_irq(&card->lock); bm_work()
497 fw_notice(card, "phy config: new root=%x, gap_count=%d\n", bm_work()
499 fw_send_phy_config(card, new_root_id, generation, gap_count); bm_work()
500 reset_bus(card, true); bm_work()
510 rcode = fw_run_transaction(card, TCODE_WRITE_QUADLET_REQUEST, bm_work()
519 allocate_broadcast_channel(card, generation); bm_work()
524 fw_card_put(card); bm_work()
527 void fw_card_initialize(struct fw_card *card, fw_card_initialize() argument
533 card->index = atomic_inc_return(&index); fw_card_initialize()
534 card->driver = driver; fw_card_initialize()
535 card->device = device; fw_card_initialize()
536 card->current_tlabel = 0; fw_card_initialize()
537 card->tlabel_mask = 0; fw_card_initialize()
538 card->split_timeout_hi = DEFAULT_SPLIT_TIMEOUT / 8000; fw_card_initialize()
539 card->split_timeout_lo = (DEFAULT_SPLIT_TIMEOUT % 8000) << 19; fw_card_initialize()
540 card->split_timeout_cycles = DEFAULT_SPLIT_TIMEOUT; fw_card_initialize()
541 card->split_timeout_jiffies = fw_card_initialize()
543 card->color = 0; fw_card_initialize()
544 card->broadcast_channel = BROADCAST_CHANNEL_INITIAL; fw_card_initialize()
546 kref_init(&card->kref); fw_card_initialize()
547 init_completion(&card->done); fw_card_initialize()
548 INIT_LIST_HEAD(&card->transaction_list); fw_card_initialize()
549 INIT_LIST_HEAD(&card->phy_receiver_list); fw_card_initialize()
550 spin_lock_init(&card->lock); fw_card_initialize()
552 card->local_node = NULL; fw_card_initialize()
554 INIT_DELAYED_WORK(&card->br_work, br_work); fw_card_initialize()
555 INIT_DELAYED_WORK(&card->bm_work, bm_work); fw_card_initialize()
559 int fw_card_add(struct fw_card *card, fw_card_add() argument
564 card->max_receive = max_receive; fw_card_add()
565 card->link_speed = link_speed; fw_card_add()
566 card->guid = guid; fw_card_add()
570 generate_config_rom(card, tmp_config_rom); fw_card_add()
571 ret = card->driver->enable(card, tmp_config_rom, config_rom_length); fw_card_add()
573 list_add_tail(&card->link, &card_list); fw_card_add()
582 * The next few functions implement a dummy driver that is used once a card
584 * as all IO to the card will be handled (and failed) by the dummy driver
586 * shutdown still need to be provided by the card driver.
590 * .set_config_rom() is never called since the card is taken out of card_list
594 static int dummy_read_phy_reg(struct fw_card *card, int address) dummy_read_phy_reg() argument
599 static int dummy_update_phy_reg(struct fw_card *card, int address, dummy_update_phy_reg() argument
605 static void dummy_send_request(struct fw_card *card, struct fw_packet *packet) dummy_send_request() argument
607 packet->callback(packet, card, RCODE_CANCELLED); dummy_send_request()
610 static void dummy_send_response(struct fw_card *card, struct fw_packet *packet) dummy_send_response() argument
612 packet->callback(packet, card, RCODE_CANCELLED); dummy_send_response()
615 static int dummy_cancel_packet(struct fw_card *card, struct fw_packet *packet) dummy_cancel_packet() argument
620 static int dummy_enable_phys_dma(struct fw_card *card, dummy_enable_phys_dma() argument
626 static struct fw_iso_context *dummy_allocate_iso_context(struct fw_card *card, dummy_allocate_iso_context() argument
675 struct fw_card *card = container_of(kref, struct fw_card, kref); fw_card_release() local
677 complete(&card->done); fw_card_release()
681 void fw_core_remove_card(struct fw_card *card) fw_core_remove_card() argument
685 card->driver->update_phy_reg(card, 4, fw_core_remove_card()
687 fw_schedule_bus_reset(card, false, true); fw_core_remove_card()
690 list_del_init(&card->link); fw_core_remove_card()
693 /* Switch off most of the card driver interface. */ fw_core_remove_card()
694 dummy_driver.free_iso_context = card->driver->free_iso_context; fw_core_remove_card()
695 dummy_driver.stop_iso = card->driver->stop_iso; fw_core_remove_card()
696 card->driver = &dummy_driver; fw_core_remove_card()
698 fw_destroy_nodes(card); fw_core_remove_card()
701 fw_card_put(card); fw_core_remove_card()
702 wait_for_completion(&card->done); fw_core_remove_card()
704 WARN_ON(!list_empty(&card->transaction_list)); fw_core_remove_card()
H A Dcore-topology.c181 * fw_node corresponding to the local card otherwise NULL.
183 static struct fw_node *build_tree(struct fw_card *card, build_tree() argument
207 fw_err(card, "inconsistent extended self IDs\n"); build_tree()
213 fw_err(card, "PHY ID mismatch in self ID: %d != %d\n", build_tree()
219 fw_err(card, "topology stack underflow\n"); build_tree()
235 node = fw_node_create(q, port_count, card->color); build_tree()
237 fw_err(card, "out of memory while building topology\n"); build_tree()
241 if (phy_id == (card->node_id & 0x3f)) build_tree()
273 child->color = card->color; build_tree()
286 fw_err(card, "parent port inconsistency for node %d: " build_tree()
313 card->root_node = node; build_tree()
314 card->irm_node = irm_node; build_tree()
315 card->gap_count = gap_count; build_tree()
316 card->beta_repeaters_present = beta_repeaters_present; build_tree()
321 typedef void (*fw_node_callback_t)(struct fw_card * card,
325 static void for_each_fw_node(struct fw_card *card, struct fw_node *root, for_each_fw_node() argument
338 node->color = card->color; for_each_fw_node()
344 if (child->color == card->color) for_each_fw_node()
352 callback(card, node, parent); for_each_fw_node()
359 static void report_lost_node(struct fw_card *card, report_lost_node() argument
362 fw_node_event(card, node, FW_NODE_DESTROYED); report_lost_node()
366 card->bm_retries = 0; report_lost_node()
369 static void report_found_node(struct fw_card *card, report_found_node() argument
384 fw_node_event(card, node, FW_NODE_CREATED); report_found_node()
387 card->bm_retries = 0; report_found_node()
390 void fw_destroy_nodes(struct fw_card *card) fw_destroy_nodes() argument
394 spin_lock_irqsave(&card->lock, flags); fw_destroy_nodes()
395 card->color++; fw_destroy_nodes()
396 if (card->local_node != NULL) fw_destroy_nodes()
397 for_each_fw_node(card, card->local_node, report_lost_node); fw_destroy_nodes()
398 card->local_node = NULL; fw_destroy_nodes()
399 spin_unlock_irqrestore(&card->lock, flags); fw_destroy_nodes()
418 * Compare the old topology tree for card with the new one specified by root.
420 * Update the nodes in the card topology tree as we go.
422 static void update_tree(struct fw_card *card, struct fw_node *root) update_tree() argument
429 list_add_tail(&card->local_node->link, &list0); update_tree()
449 node0->color = card->color; update_tree()
453 node1->color = card->color; update_tree()
454 fw_node_event(card, node0, event); update_tree()
456 if (card->root_node == node1) update_tree()
457 card->root_node = node0; update_tree()
458 if (card->irm_node == node1) update_tree()
459 card->irm_node = node0; update_tree()
468 if (node0->ports[i]->color == card->color) update_tree()
480 for_each_fw_node(card, node0->ports[i], update_tree()
491 for_each_fw_node(card, node0->ports[i], update_tree()
503 static void update_topology_map(struct fw_card *card, update_topology_map() argument
506 int node_count = (card->root_node->node_id & 0x3f) + 1; update_topology_map()
507 __be32 *map = card->topology_map; update_topology_map()
510 *map++ = cpu_to_be32(be32_to_cpu(card->topology_map[1]) + 1); update_topology_map()
516 fw_compute_block_crc(card->topology_map); update_topology_map()
519 void fw_core_handle_bus_reset(struct fw_card *card, int node_id, int generation, fw_core_handle_bus_reset() argument
530 if (!is_next_generation(generation, card->generation) && fw_core_handle_bus_reset()
531 card->local_node != NULL) { fw_core_handle_bus_reset()
532 fw_destroy_nodes(card); fw_core_handle_bus_reset()
533 card->bm_retries = 0; fw_core_handle_bus_reset()
536 spin_lock_irqsave(&card->lock, flags); fw_core_handle_bus_reset()
538 card->broadcast_channel_allocated = card->broadcast_channel_auto_allocated; fw_core_handle_bus_reset()
539 card->node_id = node_id; fw_core_handle_bus_reset()
545 card->generation = generation; fw_core_handle_bus_reset()
546 card->reset_jiffies = get_jiffies_64(); fw_core_handle_bus_reset()
547 card->bm_node_id = 0xffff; fw_core_handle_bus_reset()
548 card->bm_abdicate = bm_abdicate; fw_core_handle_bus_reset()
549 fw_schedule_bm_work(card, 0); fw_core_handle_bus_reset()
551 local_node = build_tree(card, self_ids, self_id_count); fw_core_handle_bus_reset()
553 update_topology_map(card, self_ids, self_id_count); fw_core_handle_bus_reset()
555 card->color++; fw_core_handle_bus_reset()
558 fw_err(card, "topology build failed\n"); fw_core_handle_bus_reset()
560 } else if (card->local_node == NULL) { fw_core_handle_bus_reset()
561 card->local_node = local_node; fw_core_handle_bus_reset()
562 for_each_fw_node(card, local_node, report_found_node); fw_core_handle_bus_reset()
564 update_tree(card, local_node); fw_core_handle_bus_reset()
567 spin_unlock_irqrestore(&card->lock, flags); fw_core_handle_bus_reset()
H A Dcore-transaction.c87 struct fw_card *card, int rcode) close_transaction()
92 spin_lock_irqsave(&card->lock, flags); close_transaction()
93 list_for_each_entry(t, &card->transaction_list, link) { close_transaction()
96 spin_unlock_irqrestore(&card->lock, flags); close_transaction()
100 card->tlabel_mask &= ~(1ULL << t->tlabel); close_transaction()
104 spin_unlock_irqrestore(&card->lock, flags); close_transaction()
106 if (&t->link != &card->transaction_list) { close_transaction()
107 t->callback(card, rcode, NULL, 0, t->callback_data); close_transaction()
119 int fw_cancel_transaction(struct fw_card *card, fw_cancel_transaction() argument
128 if (card->driver->cancel_packet(card, &transaction->packet) == 0) fw_cancel_transaction()
136 return close_transaction(transaction, card, RCODE_CANCELLED); fw_cancel_transaction()
143 struct fw_card *card = t->card; split_transaction_timeout_callback() local
146 spin_lock_irqsave(&card->lock, flags); split_transaction_timeout_callback()
148 spin_unlock_irqrestore(&card->lock, flags); split_transaction_timeout_callback()
152 card->tlabel_mask &= ~(1ULL << t->tlabel); split_transaction_timeout_callback()
153 spin_unlock_irqrestore(&card->lock, flags); split_transaction_timeout_callback()
155 t->callback(card, RCODE_CANCELLED, NULL, 0, t->callback_data); split_transaction_timeout_callback()
159 struct fw_card *card) start_split_transaction_timeout()
163 spin_lock_irqsave(&card->lock, flags); start_split_transaction_timeout()
166 spin_unlock_irqrestore(&card->lock, flags); start_split_transaction_timeout()
172 jiffies + card->split_timeout_jiffies); start_split_transaction_timeout()
174 spin_unlock_irqrestore(&card->lock, flags); start_split_transaction_timeout()
178 struct fw_card *card, int status) transmit_complete_callback()
185 close_transaction(t, card, RCODE_COMPLETE); transmit_complete_callback()
188 start_split_transaction_timeout(t, card); transmit_complete_callback()
193 close_transaction(t, card, RCODE_BUSY); transmit_complete_callback()
196 close_transaction(t, card, RCODE_DATA_ERROR); transmit_complete_callback()
199 close_transaction(t, card, RCODE_TYPE_ERROR); transmit_complete_callback()
206 close_transaction(t, card, status); transmit_complete_callback()
285 static int allocate_tlabel(struct fw_card *card) allocate_tlabel() argument
289 tlabel = card->current_tlabel; allocate_tlabel()
290 while (card->tlabel_mask & (1ULL << tlabel)) { allocate_tlabel()
292 if (tlabel == card->current_tlabel) allocate_tlabel()
296 card->current_tlabel = (tlabel + 1) & 0x3f; allocate_tlabel()
297 card->tlabel_mask |= 1ULL << tlabel; allocate_tlabel()
304 * @card: interface to send the request at
350 void fw_send_request(struct fw_card *card, struct fw_transaction *t, int tcode, fw_send_request() argument
360 * the list while holding the card spinlock. fw_send_request()
363 spin_lock_irqsave(&card->lock, flags); fw_send_request()
365 tlabel = allocate_tlabel(card); fw_send_request()
367 spin_unlock_irqrestore(&card->lock, flags); fw_send_request()
368 callback(card, RCODE_SEND_ERROR, NULL, 0, callback_data); fw_send_request()
374 t->card = card; fw_send_request()
382 destination_id, card->node_id, generation, fw_send_request()
386 list_add_tail(&t->link, &card->transaction_list); fw_send_request()
388 spin_unlock_irqrestore(&card->lock, flags); fw_send_request()
390 card->driver->send_request(card, &t->packet); fw_send_request()
400 static void transaction_callback(struct fw_card *card, int rcode, transaction_callback() argument
419 int fw_run_transaction(struct fw_card *card, int tcode, int destination_id, fw_run_transaction() argument
429 fw_send_request(card, &t, tcode, destination_id, generation, speed, fw_run_transaction()
442 struct fw_card *card, int status) transmit_phy_packet_callback()
455 void fw_send_phy_config(struct fw_card *card, fw_send_phy_config() argument
465 gap_count = card->driver->read_phy_reg(card, 1); fw_send_phy_config()
482 card->driver->send_request(card, &phy_config_packet); fw_send_phy_config()
631 struct fw_card *card, int status) free_response_callback()
732 static u32 compute_split_timeout_timestamp(struct fw_card *card, compute_split_timeout_timestamp() argument
738 cycles = card->split_timeout_cycles; compute_split_timeout_timestamp()
748 static struct fw_request *allocate_request(struct fw_card *card, allocate_request() argument
779 fw_notice(card, "ERROR - corrupt request received - %08x %08x %08x\n", allocate_request()
790 compute_split_timeout_timestamp(card, p->timestamp); allocate_request()
804 void fw_send_response(struct fw_card *card, fw_send_response() argument
825 card->driver->send_response(card, &request->response); fw_send_response()
838 static void handle_exclusive_region_request(struct fw_card *card, handle_exclusive_region_request() argument
856 handler->address_callback(card, request, handle_exclusive_region_request()
864 fw_send_response(card, request, RCODE_ADDRESS_ERROR); handle_exclusive_region_request()
867 static void handle_fcp_region_request(struct fw_card *card, handle_fcp_region_request() argument
878 fw_send_response(card, request, RCODE_ADDRESS_ERROR); handle_fcp_region_request()
889 fw_send_response(card, request, RCODE_TYPE_ERROR); handle_fcp_region_request()
897 handler->address_callback(card, NULL, tcode, handle_fcp_region_request()
906 fw_send_response(card, request, RCODE_COMPLETE); handle_fcp_region_request()
909 void fw_core_handle_request(struct fw_card *card, struct fw_packet *p) fw_core_handle_request() argument
918 fw_cdev_handle_phy_packet(card, p); fw_core_handle_request()
922 request = allocate_request(card, p); fw_core_handle_request()
932 handle_exclusive_region_request(card, p, request, offset); fw_core_handle_request()
934 handle_fcp_region_request(card, p, request, offset); fw_core_handle_request()
939 void fw_core_handle_response(struct fw_card *card, struct fw_packet *p) fw_core_handle_response() argument
952 spin_lock_irqsave(&card->lock, flags); fw_core_handle_response()
953 list_for_each_entry(t, &card->transaction_list, link) { fw_core_handle_response()
956 spin_unlock_irqrestore(&card->lock, flags); fw_core_handle_response()
960 card->tlabel_mask &= ~(1ULL << t->tlabel); fw_core_handle_response()
964 spin_unlock_irqrestore(&card->lock, flags); fw_core_handle_response()
966 if (&t->link == &card->transaction_list) { fw_core_handle_response()
968 fw_notice(card, "unsolicited response (source %x, tlabel %x)\n", fw_core_handle_response()
1006 card->driver->cancel_packet(card, &t->packet); fw_core_handle_response()
1008 t->callback(card, rcode, data, data_length, t->callback_data); fw_core_handle_response()
1042 static void handle_topology_map(struct fw_card *card, struct fw_request *request, handle_topology_map() argument
1050 fw_send_response(card, request, RCODE_TYPE_ERROR); handle_topology_map()
1055 fw_send_response(card, request, RCODE_ADDRESS_ERROR); handle_topology_map()
1060 memcpy(payload, &card->topology_map[start], length); handle_topology_map()
1062 fw_send_response(card, request, RCODE_COMPLETE); handle_topology_map()
1074 static void update_split_timeout(struct fw_card *card) update_split_timeout() argument
1078 cycles = card->split_timeout_hi * 8000 + (card->split_timeout_lo >> 19); update_split_timeout()
1083 card->split_timeout_cycles = cycles; update_split_timeout()
1084 card->split_timeout_jiffies = DIV_ROUND_UP(cycles * HZ, 8000); update_split_timeout()
1087 static void handle_registers(struct fw_card *card, struct fw_request *request, handle_registers() argument
1099 if (!card->priority_budget_implemented) { handle_registers()
1118 *data = cpu_to_be32(card->driver->read_csr(card, reg)); handle_registers()
1120 card->driver->write_csr(card, reg, be32_to_cpu(*data)); handle_registers()
1127 card->driver->write_csr(card, CSR_STATE_CLEAR, handle_registers()
1135 *data = cpu_to_be32(card->split_timeout_hi); handle_registers()
1137 spin_lock_irqsave(&card->lock, flags); handle_registers()
1138 card->split_timeout_hi = be32_to_cpu(*data) & 7; handle_registers()
1139 update_split_timeout(card); handle_registers()
1140 spin_unlock_irqrestore(&card->lock, flags); handle_registers()
1148 *data = cpu_to_be32(card->split_timeout_lo); handle_registers()
1150 spin_lock_irqsave(&card->lock, flags); handle_registers()
1151 card->split_timeout_lo = handle_registers()
1153 update_split_timeout(card); handle_registers()
1154 spin_unlock_irqrestore(&card->lock, flags); handle_registers()
1162 *data = card->maint_utility_register; handle_registers()
1164 card->maint_utility_register = *data; handle_registers()
1171 *data = cpu_to_be32(card->broadcast_channel); handle_registers()
1173 card->broadcast_channel = handle_registers()
1199 fw_send_response(card, request, rcode); handle_registers()
1207 static void handle_low_memory(struct fw_card *card, struct fw_request *request, handle_low_memory() argument
1216 fw_send_response(card, request, RCODE_TYPE_ERROR); handle_low_memory()
86 close_transaction(struct fw_transaction *transaction, struct fw_card *card, int rcode) close_transaction() argument
158 start_split_transaction_timeout(struct fw_transaction *t, struct fw_card *card) start_split_transaction_timeout() argument
177 transmit_complete_callback(struct fw_packet *packet, struct fw_card *card, int status) transmit_complete_callback() argument
441 transmit_phy_packet_callback(struct fw_packet *packet, struct fw_card *card, int status) transmit_phy_packet_callback() argument
630 free_response_callback(struct fw_packet *packet, struct fw_card *card, int status) free_response_callback() argument
H A Dcore.h27 /* -card */
30 void fw_err(const struct fw_card *card, const char *fmt, ...);
32 void fw_notice(const struct fw_card *card, const char *fmt, ...);
54 * Enable the given card with the given initial config rom.
55 * This function is expected to activate the card, and either
59 int (*enable)(struct fw_card *card,
62 int (*read_phy_reg)(struct fw_card *card, int address);
63 int (*update_phy_reg)(struct fw_card *card, int address,
67 * Update the config rom for an enabled card. This function
71 int (*set_config_rom)(struct fw_card *card,
74 void (*send_request)(struct fw_card *card, struct fw_packet *packet);
75 void (*send_response)(struct fw_card *card, struct fw_packet *packet);
77 int (*cancel_packet)(struct fw_card *card, struct fw_packet *packet);
81 * host memory. The card will disable this for all node when
83 * bus reset. Returns 0 on success, -ENODEV if the card
87 int (*enable_phys_dma)(struct fw_card *card,
90 u32 (*read_csr)(struct fw_card *card, int csr_offset);
91 void (*write_csr)(struct fw_card *card, int csr_offset, u32 value);
94 (*allocate_iso_context)(struct fw_card *card,
115 void fw_card_initialize(struct fw_card *card,
117 int fw_card_add(struct fw_card *card,
119 void fw_core_remove_card(struct fw_card *card);
121 void fw_schedule_bm_work(struct fw_card *card, unsigned long delay);
129 void fw_cdev_handle_phy_packet(struct fw_card *card, struct fw_packet *p);
152 void fw_node_event(struct fw_card *card, struct fw_node *node, int event);
158 int fw_iso_buffer_map_dma(struct fw_iso_buffer *buffer, struct fw_card *card,
211 void fw_core_handle_bus_reset(struct fw_card *card, int node_id,
213 void fw_destroy_nodes(struct fw_card *card);
242 void fw_core_handle_request(struct fw_card *card, struct fw_packet *request);
243 void fw_core_handle_response(struct fw_card *card, struct fw_packet *packet);
250 void fw_send_phy_config(struct fw_card *card,
H A Dcore-iso.c67 int fw_iso_buffer_map_dma(struct fw_iso_buffer *buffer, struct fw_card *card, fw_iso_buffer_map_dma() argument
76 address = dma_map_page(card->device, buffer->pages[i], fw_iso_buffer_map_dma()
78 if (dma_mapping_error(card->device, address)) fw_iso_buffer_map_dma()
90 int fw_iso_buffer_init(struct fw_iso_buffer *buffer, struct fw_card *card, fw_iso_buffer_init() argument
99 ret = fw_iso_buffer_map_dma(buffer, card, direction); fw_iso_buffer_init()
101 fw_iso_buffer_destroy(buffer, card); fw_iso_buffer_init()
126 struct fw_card *card) fw_iso_buffer_destroy()
133 dma_unmap_page(card->device, address, fw_iso_buffer_destroy()
163 struct fw_iso_context *fw_iso_context_create(struct fw_card *card, fw_iso_context_create() argument
169 ctx = card->driver->allocate_iso_context(card, fw_iso_context_create()
174 ctx->card = card; fw_iso_context_create()
188 ctx->card->driver->free_iso_context(ctx); fw_iso_context_destroy()
195 return ctx->card->driver->start_iso(ctx, cycle, sync, tags); fw_iso_context_start()
201 return ctx->card->driver->set_iso_channels(ctx, channels); fw_iso_context_set_channels()
209 return ctx->card->driver->queue_iso(ctx, packet, buffer, payload); fw_iso_context_queue()
215 ctx->card->driver->flush_queue_iso(ctx); fw_iso_context_queue_flush()
221 return ctx->card->driver->flush_iso_completions(ctx); fw_iso_context_flush_completions()
227 return ctx->card->driver->stop_iso(ctx); fw_iso_context_stop()
235 static int manage_bandwidth(struct fw_card *card, int irm_id, int generation, manage_bandwidth() argument
253 switch (fw_run_transaction(card, TCODE_LOCK_COMPARE_SWAP, manage_bandwidth()
273 static int manage_channel(struct fw_card *card, int irm_id, int generation, manage_channel() argument
294 switch (fw_run_transaction(card, TCODE_LOCK_COMPARE_SWAP, manage_channel()
325 static void deallocate_channel(struct fw_card *card, int irm_id, deallocate_channel() argument
335 manage_channel(card, irm_id, generation, mask, offset, false); deallocate_channel()
341 * In parameters: card, generation, channels_mask, bandwidth, allocate
362 void fw_iso_resource_manage(struct fw_card *card, int generation, fw_iso_resource_manage() argument
370 spin_lock_irq(&card->lock); fw_iso_resource_manage()
371 irm_id = card->irm_node->node_id; fw_iso_resource_manage()
372 spin_unlock_irq(&card->lock); fw_iso_resource_manage()
375 c = manage_channel(card, irm_id, generation, channels_hi, fw_iso_resource_manage()
379 c = manage_channel(card, irm_id, generation, channels_lo, fw_iso_resource_manage()
393 ret = manage_bandwidth(card, irm_id, generation, *bandwidth, allocate); fw_iso_resource_manage()
399 deallocate_channel(card, irm_id, generation, c); fw_iso_resource_manage()
125 fw_iso_buffer_destroy(struct fw_iso_buffer *buffer, struct fw_card *card) fw_iso_buffer_destroy() argument
/linux-4.1.27/drivers/net/ethernet/dec/tulip/
H A Dxircom_cb.c47 /* IO registers on the card, offsets */
113 static void xircom_up(struct xircom_private *card);
118 static void investigate_read_descriptor(struct net_device *dev,struct xircom_private *card, int descnr, unsigned int bufferoffset);
119 static void investigate_write_descriptor(struct net_device *dev, struct xircom_private *card, int descnr, unsigned int bufferoffset);
120 static void read_mac_address(struct xircom_private *card);
121 static void transceiver_voodoo(struct xircom_private *card);
122 static void initialize_card(struct xircom_private *card);
123 static void trigger_transmit(struct xircom_private *card);
124 static void trigger_receive(struct xircom_private *card);
125 static void setup_descriptors(struct xircom_private *card);
126 static void remove_descriptors(struct xircom_private *card);
127 static int link_status_changed(struct xircom_private *card);
128 static void activate_receiver(struct xircom_private *card);
129 static void deactivate_receiver(struct xircom_private *card);
130 static void activate_transmitter(struct xircom_private *card);
131 static void deactivate_transmitter(struct xircom_private *card);
132 static void enable_transmit_interrupt(struct xircom_private *card);
133 static void enable_receive_interrupt(struct xircom_private *card);
134 static void enable_link_interrupt(struct xircom_private *card);
135 static void disable_all_interrupts(struct xircom_private *card);
136 static int link_status(struct xircom_private *card);
188 TODO: Send 1 or 2 "dummy" packets here as the card seems to discard the
313 struct xircom_private *card = netdev_priv(dev); xircom_remove() local
317 pci_iounmap(pdev, card->ioaddr); xircom_remove()
318 dma_free_coherent(d, 8192, card->tx_buffer, card->tx_dma_handle); xircom_remove()
319 dma_free_coherent(d, 8192, card->rx_buffer, card->rx_dma_handle); xircom_remove()
328 struct xircom_private *card = netdev_priv(dev); xircom_interrupt() local
329 void __iomem *ioaddr = card->ioaddr; xircom_interrupt()
333 spin_lock(&card->lock); xircom_interrupt()
339 card->tx_buffer[0], card->tx_buffer[4]); xircom_interrupt()
341 card->rx_buffer[0], card->rx_buffer[4]); xircom_interrupt()
345 spin_unlock(&card->lock); xircom_interrupt()
349 if (link_status_changed(card)) { xircom_interrupt()
352 newlink = link_status(card); xircom_interrupt()
368 investigate_write_descriptor(dev,card,i,bufferoffsets[i]); xircom_interrupt()
370 investigate_read_descriptor(dev,card,i,bufferoffsets[i]); xircom_interrupt()
372 spin_unlock(&card->lock); xircom_interrupt()
379 struct xircom_private *card; xircom_start_xmit() local
384 card = netdev_priv(dev); xircom_start_xmit()
385 spin_lock_irqsave(&card->lock,flags); xircom_start_xmit()
389 investigate_write_descriptor(dev,card,desc,bufferoffsets[desc]); xircom_start_xmit()
392 nextdescriptor = (card->transmit_used +1) % (NUMDESCRIPTORS); xircom_start_xmit()
393 desc = card->transmit_used; xircom_start_xmit()
396 if (card->tx_buffer[4*desc]==0) { xircom_start_xmit()
397 /* Copy the packet data; zero the memory first as the card xircom_start_xmit()
400 memset(&card->tx_buffer[bufferoffsets[desc]/4],0,1536); xircom_start_xmit()
402 &(card->tx_buffer[bufferoffsets[desc] / 4]), xircom_start_xmit()
407 card->tx_buffer[4*desc+1] = cpu_to_le32(skb->len); xircom_start_xmit()
409 card->tx_buffer[4*desc+1] |= cpu_to_le32(1<<25); xircom_start_xmit()
411 card->tx_buffer[4*desc+1] |= cpu_to_le32(0xF0000000); xircom_start_xmit()
413 card->tx_skb[desc] = skb; xircom_start_xmit()
416 /* This gives the descriptor to the card */ xircom_start_xmit()
417 card->tx_buffer[4*desc] = cpu_to_le32(0x80000000); xircom_start_xmit()
418 trigger_transmit(card); xircom_start_xmit()
419 if (card->tx_buffer[nextdescriptor*4] & cpu_to_le32(0x8000000)) { xircom_start_xmit()
423 card->transmit_used = nextdescriptor; xircom_start_xmit()
424 spin_unlock_irqrestore(&card->lock,flags); xircom_start_xmit()
430 spin_unlock_irqrestore(&card->lock,flags); xircom_start_xmit()
431 trigger_transmit(card); xircom_start_xmit()
458 struct xircom_private *card; xircom_close() local
461 card = netdev_priv(dev); xircom_close()
465 spin_lock_irqsave(&card->lock,flags); xircom_close()
467 disable_all_interrupts(card); xircom_close()
470 deactivate_receiver(card); xircom_close()
471 deactivate_transmitter(card); xircom_close()
473 remove_descriptors(card); xircom_close()
475 spin_unlock_irqrestore(&card->lock,flags); xircom_close()
477 card->open = 0; xircom_close()
478 free_irq(card->pdev->irq, dev); xircom_close()
498 static void initialize_card(struct xircom_private *card) initialize_card() argument
500 void __iomem *ioaddr = card->ioaddr; initialize_card()
504 spin_lock_irqsave(&card->lock, flags); initialize_card()
506 /* First: reset the card */ initialize_card()
511 udelay(100); /* give the card some time to reset */ initialize_card()
523 disable_all_interrupts(card); initialize_card()
524 deactivate_receiver(card); initialize_card()
525 deactivate_transmitter(card); initialize_card()
527 spin_unlock_irqrestore(&card->lock, flags); initialize_card()
531 trigger_transmit causes the card to check for frames to be transmitted.
536 static void trigger_transmit(struct xircom_private *card) trigger_transmit() argument
538 void __iomem *ioaddr = card->ioaddr; trigger_transmit()
544 trigger_receive causes the card to check for empty frames in the
550 static void trigger_receive(struct xircom_private *card) trigger_receive() argument
552 void __iomem *ioaddr = card->ioaddr; trigger_receive()
559 descriptors and programs the addresses into the card.
561 static void setup_descriptors(struct xircom_private *card) setup_descriptors() argument
563 void __iomem *ioaddr = card->ioaddr; setup_descriptors()
567 BUG_ON(card->rx_buffer == NULL); setup_descriptors()
568 BUG_ON(card->tx_buffer == NULL); setup_descriptors()
571 memset(card->rx_buffer, 0, 128); /* clear the descriptors */ setup_descriptors()
574 /* Rx Descr0: It's empty, let the card own it, no errors -> 0x80000000 */ setup_descriptors()
575 card->rx_buffer[i*4 + 0] = cpu_to_le32(0x80000000); setup_descriptors()
577 card->rx_buffer[i*4 + 1] = cpu_to_le32(1536); setup_descriptors()
579 card->rx_buffer[i*4 + 1] |= cpu_to_le32(1 << 25); setup_descriptors()
584 address = card->rx_dma_handle; setup_descriptors()
585 card->rx_buffer[i*4 + 2] = cpu_to_le32(address + bufferoffsets[i]); setup_descriptors()
587 card->rx_buffer[i*4 + 3] = 0; setup_descriptors()
591 /* Write the receive descriptor ring address to the card */ setup_descriptors()
592 address = card->rx_dma_handle; setup_descriptors()
597 memset(card->tx_buffer, 0, 128); /* clear the descriptors */ setup_descriptors()
601 card->tx_buffer[i*4 + 0] = 0x00000000; setup_descriptors()
603 card->tx_buffer[i*4 + 1] = cpu_to_le32(1536); setup_descriptors()
605 card->tx_buffer[i*4 + 1] |= cpu_to_le32(1 << 25); setup_descriptors()
609 address = card->tx_dma_handle; setup_descriptors()
610 card->tx_buffer[i*4 + 2] = cpu_to_le32(address + bufferoffsets[i]); setup_descriptors()
612 card->tx_buffer[i*4 + 3] = 0; setup_descriptors()
616 /* wite the transmit descriptor ring to the card */ setup_descriptors()
617 address = card->tx_dma_handle; setup_descriptors()
622 remove_descriptors informs the card the descriptors are no longer
623 valid by setting the address in the card to 0x00.
625 static void remove_descriptors(struct xircom_private *card) remove_descriptors() argument
627 void __iomem *ioaddr = card->ioaddr; remove_descriptors()
636 link_status_changed returns 1 if the card has indicated that
641 static int link_status_changed(struct xircom_private *card) link_status_changed() argument
643 void __iomem *ioaddr = card->ioaddr; link_status_changed()
660 transmit_active returns 1 if the transmitter on the card is
663 static int transmit_active(struct xircom_private *card) transmit_active() argument
665 void __iomem *ioaddr = card->ioaddr; transmit_active()
674 receive_active returns 1 if the receiver on the card is
677 static int receive_active(struct xircom_private *card) receive_active() argument
679 void __iomem *ioaddr = card->ioaddr; receive_active()
688 activate_receiver enables the receiver on the card.
697 static void activate_receiver(struct xircom_private *card) activate_receiver() argument
699 void __iomem *ioaddr = card->ioaddr; activate_receiver()
707 if ((val&2) && (receive_active(card))) activate_receiver()
716 if (!receive_active(card)) activate_receiver()
722 netdev_err(card->dev, "Receiver failed to deactivate\n"); activate_receiver()
730 /* now wait for the card to activate again */ activate_receiver()
733 if (receive_active(card)) activate_receiver()
739 netdev_err(card->dev, activate_receiver()
745 deactivate_receiver disables the receiver on the card.
751 static void deactivate_receiver(struct xircom_private *card) deactivate_receiver() argument
753 void __iomem *ioaddr = card->ioaddr; deactivate_receiver()
763 if (!receive_active(card)) deactivate_receiver()
769 netdev_err(card->dev, "Receiver failed to deactivate\n"); deactivate_receiver()
775 activate_transmitter enables the transmitter on the card.
784 static void activate_transmitter(struct xircom_private *card) activate_transmitter() argument
786 void __iomem *ioaddr = card->ioaddr; activate_transmitter()
794 if ((val&(1<<13)) && (transmit_active(card))) activate_transmitter()
802 if (!transmit_active(card)) activate_transmitter()
808 netdev_err(card->dev, activate_transmitter()
817 /* now wait for the card to activate again */ activate_transmitter()
820 if (transmit_active(card)) activate_transmitter()
826 netdev_err(card->dev, activate_transmitter()
832 deactivate_transmitter disables the transmitter on the card.
838 static void deactivate_transmitter(struct xircom_private *card) deactivate_transmitter() argument
840 void __iomem *ioaddr = card->ioaddr; deactivate_transmitter()
850 if (!transmit_active(card)) deactivate_transmitter()
856 netdev_err(card->dev, deactivate_transmitter()
867 static void enable_transmit_interrupt(struct xircom_private *card) enable_transmit_interrupt() argument
869 void __iomem *ioaddr = card->ioaddr; enable_transmit_interrupt()
883 static void enable_receive_interrupt(struct xircom_private *card) enable_receive_interrupt() argument
885 void __iomem *ioaddr = card->ioaddr; enable_receive_interrupt()
898 static void enable_link_interrupt(struct xircom_private *card) enable_link_interrupt() argument
900 void __iomem *ioaddr = card->ioaddr; enable_link_interrupt()
915 static void disable_all_interrupts(struct xircom_private *card) disable_all_interrupts() argument
917 void __iomem *ioaddr = card->ioaddr; disable_all_interrupts()
927 static void enable_common_interrupts(struct xircom_private *card) enable_common_interrupts() argument
929 void __iomem *ioaddr = card->ioaddr; enable_common_interrupts()
949 static int enable_promisc(struct xircom_private *card) enable_promisc() argument
951 void __iomem *ioaddr = card->ioaddr; enable_promisc()
969 static int link_status(struct xircom_private *card) link_status() argument
971 void __iomem *ioaddr = card->ioaddr; link_status()
997 static void read_mac_address(struct xircom_private *card) read_mac_address() argument
999 void __iomem *ioaddr = card->ioaddr; read_mac_address()
1004 spin_lock_irqsave(&card->lock, flags); read_mac_address()
1023 card->dev->dev_addr[j] = xr32(CSR9) & 0xff; read_mac_address()
1030 spin_unlock_irqrestore(&card->lock, flags); read_mac_address()
1031 pr_debug(" %pM\n", card->dev->dev_addr); read_mac_address()
1040 static void transceiver_voodoo(struct xircom_private *card) transceiver_voodoo() argument
1042 void __iomem *ioaddr = card->ioaddr; transceiver_voodoo()
1046 pci_write_config_dword(card->pdev, PCI_POWERMGMT, 0x0000); transceiver_voodoo()
1048 setup_descriptors(card); transceiver_voodoo()
1050 spin_lock_irqsave(&card->lock, flags); transceiver_voodoo()
1059 spin_unlock_irqrestore(&card->lock, flags); transceiver_voodoo()
1061 netif_start_queue(card->dev); transceiver_voodoo()
1065 static void xircom_up(struct xircom_private *card) xircom_up() argument
1071 pci_write_config_dword(card->pdev, PCI_POWERMGMT, 0x0000); xircom_up()
1073 setup_descriptors(card); xircom_up()
1075 spin_lock_irqsave(&card->lock, flags); xircom_up()
1078 enable_link_interrupt(card); xircom_up()
1079 enable_transmit_interrupt(card); xircom_up()
1080 enable_receive_interrupt(card); xircom_up()
1081 enable_common_interrupts(card); xircom_up()
1082 enable_promisc(card); xircom_up()
1084 /* The card can have received packets already, read them away now */ xircom_up()
1086 investigate_read_descriptor(card->dev,card,i,bufferoffsets[i]); xircom_up()
1089 spin_unlock_irqrestore(&card->lock, flags); xircom_up()
1090 trigger_receive(card); xircom_up()
1091 trigger_transmit(card); xircom_up()
1092 netif_start_queue(card->dev); xircom_up()
1097 investigate_read_descriptor(struct net_device *dev, struct xircom_private *card, investigate_read_descriptor() argument
1102 status = le32_to_cpu(card->rx_buffer[4*descnr]); investigate_read_descriptor()
1124 &card->rx_buffer[bufferoffset / 4], investigate_read_descriptor()
1133 /* give the buffer back to the card */ investigate_read_descriptor()
1134 card->rx_buffer[4*descnr] = cpu_to_le32(0x80000000); investigate_read_descriptor()
1135 trigger_receive(card); investigate_read_descriptor()
1143 struct xircom_private *card, investigate_write_descriptor()
1148 status = le32_to_cpu(card->tx_buffer[4*descnr]); investigate_write_descriptor()
1152 card->tx_buffer[4*descnr] = 0; investigate_write_descriptor()
1157 if (card->tx_skb[descnr]!=NULL) { investigate_write_descriptor()
1158 dev->stats.tx_bytes += card->tx_skb[descnr]->len; investigate_write_descriptor()
1159 dev_kfree_skb_irq(card->tx_skb[descnr]); investigate_write_descriptor()
1161 card->tx_skb[descnr] = NULL; investigate_write_descriptor()
1165 card->tx_buffer[4*descnr] = 0; /* descriptor is free again */ investigate_write_descriptor()
1142 investigate_write_descriptor(struct net_device *dev, struct xircom_private *card, int descnr, unsigned int bufferoffset) investigate_write_descriptor() argument
/linux-4.1.27/sound/isa/
H A Dadlib.c2 * AdLib FM card driver.
45 static void snd_adlib_free(struct snd_card *card) snd_adlib_free() argument
47 release_and_free_resource(card->private_data); snd_adlib_free()
52 struct snd_card *card; snd_adlib_probe() local
56 error = snd_card_new(dev, index[n], id[n], THIS_MODULE, 0, &card); snd_adlib_probe()
58 dev_err(dev, "could not create card\n"); snd_adlib_probe()
62 card->private_data = request_region(port[n], 4, CRD_NAME); snd_adlib_probe()
63 if (!card->private_data) { snd_adlib_probe()
68 card->private_free = snd_adlib_free; snd_adlib_probe()
70 strcpy(card->driver, DEV_NAME); snd_adlib_probe()
71 strcpy(card->shortname, CRD_NAME); snd_adlib_probe()
72 sprintf(card->longname, CRD_NAME " at %#lx", port[n]); snd_adlib_probe()
74 error = snd_opl3_create(card, port[n], port[n] + 2, OPL3_HW_AUTO, 1, &opl3); snd_adlib_probe()
86 error = snd_card_register(card); snd_adlib_probe()
88 dev_err(dev, "could not register card\n"); snd_adlib_probe()
92 dev_set_drvdata(dev, card); snd_adlib_probe()
95 out: snd_card_free(card); snd_adlib_probe()
H A Dazt2320.c2 card-azt2320.c - driver for Aztech Systems AZT2320 based soundcards.
57 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
58 static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */
100 #define DRIVER_NAME "snd-card-azt2320"
103 struct pnp_card_link *card, snd_card_azt2320_pnp()
109 acard->dev = pnp_request_card_device(card, id->devs[0].id, NULL); snd_card_azt2320_pnp()
113 acard->devmpu = pnp_request_card_device(card, id->devs[1].id, NULL); snd_card_azt2320_pnp()
182 struct snd_card *card; snd_card_azt2320_probe() local
187 error = snd_card_new(&pcard->card->dev, snd_card_azt2320_probe()
189 sizeof(struct snd_card_azt2320), &card); snd_card_azt2320_probe()
192 acard = card->private_data; snd_card_azt2320_probe()
195 snd_card_free(card); snd_card_azt2320_probe()
200 snd_card_free(card); snd_card_azt2320_probe()
204 error = snd_wss_create(card, wss_port[dev], -1, snd_card_azt2320_probe()
209 snd_card_free(card); snd_card_azt2320_probe()
213 strcpy(card->driver, "AZT2320"); snd_card_azt2320_probe()
214 strcpy(card->shortname, "Aztech AZT2320"); snd_card_azt2320_probe()
215 sprintf(card->longname, "%s, WSS at 0x%lx, irq %i, dma %i&%i", snd_card_azt2320_probe()
216 card->shortname, chip->port, irq[dev], dma1[dev], dma2[dev]); snd_card_azt2320_probe()
220 snd_card_free(card); snd_card_azt2320_probe()
225 snd_card_free(card); snd_card_azt2320_probe()
230 snd_card_free(card); snd_card_azt2320_probe()
235 if (snd_mpu401_uart_new(card, 0, MPU401_HW_AZT2320, snd_card_azt2320_probe()
242 if (snd_opl3_create(card, snd_card_azt2320_probe()
249 snd_card_free(card); snd_card_azt2320_probe()
253 snd_card_free(card); snd_card_azt2320_probe()
259 if ((error = snd_card_register(card)) < 0) { snd_card_azt2320_probe()
260 snd_card_free(card); snd_card_azt2320_probe()
263 pnp_set_card_drvdata(pcard, card); snd_card_azt2320_probe()
269 static int snd_azt2320_pnp_detect(struct pnp_card_link *card, snd_azt2320_pnp_detect() argument
278 res = snd_card_azt2320_probe(dev, card, id); snd_azt2320_pnp_detect()
297 struct snd_card *card = pnp_get_card_drvdata(pcard); snd_azt2320_pnp_suspend() local
298 struct snd_card_azt2320 *acard = card->private_data; snd_azt2320_pnp_suspend()
301 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); snd_azt2320_pnp_suspend()
308 struct snd_card *card = pnp_get_card_drvdata(pcard); snd_azt2320_pnp_resume() local
309 struct snd_card_azt2320 *acard = card->private_data; snd_azt2320_pnp_resume()
313 snd_power_change_state(card, SNDRV_CTL_POWER_D0); snd_azt2320_pnp_resume()
102 snd_card_azt2320_pnp(int dev, struct snd_card_azt2320 *acard, struct pnp_card_link *card, const struct pnp_card_device_id *id) snd_card_azt2320_pnp() argument
H A Dals100.c3 card-als100.c - driver for Avance Logic ALS100 based soundcards.
56 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
57 static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */
121 struct pnp_card_link *card, snd_card_als100_pnp()
127 acard->dev = pnp_request_card_device(card, id->devs[0].id, NULL); snd_card_als100_pnp()
131 acard->devmpu = pnp_request_card_device(card, id->devs[1].id, acard->dev); snd_card_als100_pnp()
132 acard->devopl = pnp_request_card_device(card, id->devs[2].id, acard->dev); snd_card_als100_pnp()
192 struct snd_card *card; snd_card_als100_probe() local
196 error = snd_card_new(&pcard->card->dev, snd_card_als100_probe()
198 sizeof(struct snd_card_als100), &card); snd_card_als100_probe()
201 acard = card->private_data; snd_card_als100_probe()
204 snd_card_free(card); snd_card_als100_probe()
211 error = snd_sbdsp_create(card, port[dev], irq[dev], snd_card_als100_probe()
217 snd_card_free(card); snd_card_als100_probe()
223 strcpy(card->driver, "DT-019X"); snd_card_als100_probe()
224 strcpy(card->shortname, "Diamond Tech. DT-019X"); snd_card_als100_probe()
225 sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d", snd_card_als100_probe()
226 card->shortname, chip->name, chip->port, snd_card_als100_probe()
229 strcpy(card->driver, "ALS100"); snd_card_als100_probe()
230 strcpy(card->shortname, "Avance Logic ALS100"); snd_card_als100_probe()
231 sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d&%d", snd_card_als100_probe()
232 card->shortname, chip->name, chip->port, snd_card_als100_probe()
237 snd_card_free(card); snd_card_als100_probe()
242 snd_card_free(card); snd_card_als100_probe()
255 if (snd_mpu401_uart_new(card, 0, snd_card_als100_probe()
264 if (snd_opl3_create(card, snd_card_als100_probe()
271 snd_card_free(card); snd_card_als100_probe()
275 snd_card_free(card); snd_card_als100_probe()
281 if ((error = snd_card_register(card)) < 0) { snd_card_als100_probe()
282 snd_card_free(card); snd_card_als100_probe()
285 pnp_set_card_drvdata(pcard, card); snd_card_als100_probe()
291 static int snd_als100_pnp_detect(struct pnp_card_link *card, snd_als100_pnp_detect() argument
300 res = snd_card_als100_probe(dev, card, id); snd_als100_pnp_detect()
319 struct snd_card *card = pnp_get_card_drvdata(pcard); snd_als100_pnp_suspend() local
320 struct snd_card_als100 *acard = card->private_data; snd_als100_pnp_suspend()
323 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); snd_als100_pnp_suspend()
331 struct snd_card *card = pnp_get_card_drvdata(pcard); snd_als100_pnp_resume() local
332 struct snd_card_als100 *acard = card->private_data; snd_als100_pnp_resume()
337 snd_power_change_state(card, SNDRV_CTL_POWER_D0); snd_als100_pnp_resume()
120 snd_card_als100_pnp(int dev, struct snd_card_als100 *acard, struct pnp_card_link *card, const struct pnp_card_device_id *id) snd_card_als100_pnp() argument
/linux-4.1.27/sound/arm/
H A Dpxa2xx-ac97.c79 platform_ops = substream->pcm->card->dev->platform_data; pxa2xx_ac97_pcm_startup()
90 platform_ops = substream->pcm->card->dev->platform_data; pxa2xx_ac97_pcm_shutdown()
113 static int pxa2xx_ac97_do_suspend(struct snd_card *card) pxa2xx_ac97_do_suspend() argument
115 pxa2xx_audio_ops_t *platform_ops = card->dev->platform_data; pxa2xx_ac97_do_suspend()
117 snd_power_change_state(card, SNDRV_CTL_POWER_D3cold); pxa2xx_ac97_do_suspend()
126 static int pxa2xx_ac97_do_resume(struct snd_card *card) pxa2xx_ac97_do_resume() argument
128 pxa2xx_audio_ops_t *platform_ops = card->dev->platform_data; pxa2xx_ac97_do_resume()
138 snd_power_change_state(card, SNDRV_CTL_POWER_D0); pxa2xx_ac97_do_resume()
145 struct snd_card *card = dev_get_drvdata(dev); pxa2xx_ac97_suspend() local
148 if (card) pxa2xx_ac97_suspend()
149 ret = pxa2xx_ac97_do_suspend(card); pxa2xx_ac97_suspend()
156 struct snd_card *card = dev_get_drvdata(dev); pxa2xx_ac97_resume() local
159 if (card) pxa2xx_ac97_resume()
160 ret = pxa2xx_ac97_do_resume(card); pxa2xx_ac97_resume()
170 struct snd_card *card; pxa2xx_ac97_probe() local
183 THIS_MODULE, 0, &card); pxa2xx_ac97_probe()
187 strlcpy(card->driver, dev->dev.driver->name, sizeof(card->driver)); pxa2xx_ac97_probe()
189 ret = pxa2xx_pcm_new(card, &pxa2xx_ac97_pcm_client, &pxa2xx_ac97_pcm); pxa2xx_ac97_probe()
197 ret = snd_ac97_bus(card, 0, &pxa2xx_ac97_ops, NULL, &ac97_bus); pxa2xx_ac97_probe()
205 snprintf(card->shortname, sizeof(card->shortname), pxa2xx_ac97_probe()
207 snprintf(card->longname, sizeof(card->longname), pxa2xx_ac97_probe()
208 "%s (%s)", dev->dev.driver->name, card->mixername); pxa2xx_ac97_probe()
212 ret = snd_card_register(card); pxa2xx_ac97_probe()
214 platform_set_drvdata(dev, card); pxa2xx_ac97_probe()
221 if (card) pxa2xx_ac97_probe()
222 snd_card_free(card); pxa2xx_ac97_probe()
229 struct snd_card *card = platform_get_drvdata(dev); pxa2xx_ac97_remove() local
231 if (card) { pxa2xx_ac97_remove()
232 snd_card_free(card); pxa2xx_ac97_remove()
/linux-4.1.27/sound/pci/hda/
H A Dhda_intel_trace.h20 __field( int, card )
26 __entry->card = (chip)->card->number;
31 TP_printk("[%d:%d] cmd=%d", __entry->card, __entry->idx, __entry->cmd)
41 __field( int, card )
48 __entry->card = (chip)->card->number;
54 TP_printk("[%d:%d] pos=%u, delay=%u", __entry->card, __entry->idx, __entry->pos, __entry->delay)
H A Dhda_tegra.c93 return snd_dma_alloc_pages(type, chip->card->dev, size, buf); dma_alloc_pages()
250 struct snd_card *card = dev_get_drvdata(dev); hda_tegra_suspend() local
251 struct azx *chip = card->private_data; hda_tegra_suspend()
254 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); hda_tegra_suspend()
265 struct snd_card *card = dev_get_drvdata(dev); hda_tegra_resume() local
266 struct azx *chip = card->private_data; hda_tegra_resume()
275 snd_power_change_state(card, SNDRV_CTL_POWER_D0); hda_tegra_resume()
340 struct snd_card *card = chip->card; hda_tegra_first_init() local
349 err = devm_request_irq(chip->card->dev, irq_id, azx_interrupt, hda_tegra_first_init()
352 dev_err(chip->card->dev, hda_tegra_first_init()
362 dev_dbg(card->dev, "chipset global capabilities = 0x%x\n", gcap); hda_tegra_first_init()
377 chip->azx_dev = devm_kcalloc(card->dev, chip->num_streams, hda_tegra_first_init()
394 dev_err(card->dev, "no codecs found!\n"); hda_tegra_first_init()
398 strcpy(card->driver, "tegra-hda"); hda_tegra_first_init()
399 strcpy(card->shortname, "tegra-hda"); hda_tegra_first_init()
400 snprintf(card->longname, sizeof(card->longname), hda_tegra_first_init()
402 card->shortname, chip->addr, chip->irq); hda_tegra_first_init()
410 static int hda_tegra_create(struct snd_card *card, hda_tegra_create() argument
425 chip->card = card; hda_tegra_create()
438 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops); hda_tegra_create()
440 dev_err(card->dev, "Error creating device\n"); hda_tegra_create()
455 struct snd_card *card; hda_tegra_probe() local
468 THIS_MODULE, 0, &card); hda_tegra_probe()
470 dev_err(&pdev->dev, "Error creating card!\n"); hda_tegra_probe()
474 err = hda_tegra_create(card, driver_flags, &hda_tegra_ops, hda); hda_tegra_probe()
477 card->private_data = chip; hda_tegra_probe()
479 dev_set_drvdata(&pdev->dev, card); hda_tegra_probe()
498 err = snd_card_register(chip->card); hda_tegra_probe()
508 snd_card_free(card); hda_tegra_probe()
519 struct snd_card *card = dev_get_drvdata(&pdev->dev); hda_tegra_shutdown() local
522 if (!card) hda_tegra_shutdown()
524 chip = card->private_data; hda_tegra_shutdown()
/linux-4.1.27/drivers/mmc/card/
H A DMakefile2 # Makefile for MMC/SD card drivers
H A Dblock.c40 #include <linux/mmc/card.h>
138 static inline int mmc_blk_part_switch(struct mmc_card *card,
140 static int get_card_status(struct mmc_card *card, u32 *status, int retries);
201 struct mmc_card *card = md->queue.card; power_ro_lock_show() local
204 if (card->ext_csd.boot_ro_lock & EXT_CSD_BOOT_WP_B_PERM_WP_EN) power_ro_lock_show()
206 else if (card->ext_csd.boot_ro_lock & EXT_CSD_BOOT_WP_B_PWR_WP_EN) power_ro_lock_show()
221 struct mmc_card *card; power_ro_lock_store() local
231 card = md->queue.card; power_ro_lock_store()
233 mmc_get_card(card); power_ro_lock_store()
235 ret = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_BOOT_WP, power_ro_lock_store()
236 card->ext_csd.boot_ro_lock | power_ro_lock_store()
238 card->ext_csd.part_time); power_ro_lock_store()
242 card->ext_csd.boot_ro_lock |= EXT_CSD_BOOT_WP_B_PWR_WP_EN; power_ro_lock_store()
244 mmc_put_card(card); power_ro_lock_store()
387 static int ioctl_rpmb_card_status_poll(struct mmc_card *card, u32 *status, ioctl_rpmb_card_status_poll() argument
397 err = get_card_status(card, status, 5); ioctl_rpmb_card_status_poll()
419 static int ioctl_do_sanitize(struct mmc_card *card) ioctl_do_sanitize() argument
423 if (!mmc_can_sanitize(card)) { ioctl_do_sanitize()
425 mmc_hostname(card->host), __func__); ioctl_do_sanitize()
431 mmc_hostname(card->host), __func__); ioctl_do_sanitize()
433 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, ioctl_do_sanitize()
439 mmc_hostname(card->host), __func__, err); ioctl_do_sanitize()
441 pr_debug("%s: %s - SANITIZE COMPLETED\n", mmc_hostname(card->host), ioctl_do_sanitize()
452 struct mmc_card *card; mmc_blk_ioctl_cmd() local
482 card = md->queue.card; mmc_blk_ioctl_cmd()
483 if (IS_ERR(card)) { mmc_blk_ioctl_cmd()
484 err = PTR_ERR(card); mmc_blk_ioctl_cmd()
506 mmc_set_data_timeout(&data, card); mmc_blk_ioctl_cmd()
530 mmc_get_card(card); mmc_blk_ioctl_cmd()
532 err = mmc_blk_part_switch(card, md); mmc_blk_ioctl_cmd()
537 err = mmc_app_cmd(card->host, card); mmc_blk_ioctl_cmd()
543 err = mmc_set_blockcount(card, data.blocks, mmc_blk_ioctl_cmd()
551 err = ioctl_do_sanitize(card); mmc_blk_ioctl_cmd()
560 mmc_wait_for_req(card->host, &mrq); mmc_blk_ioctl_cmd()
563 dev_err(mmc_dev(card->host), "%s: cmd error %d\n", mmc_blk_ioctl_cmd()
569 dev_err(mmc_dev(card->host), "%s: data error %d\n", mmc_blk_ioctl_cmd()
600 err = ioctl_rpmb_card_status_poll(card, &status, 5); mmc_blk_ioctl_cmd()
602 dev_err(mmc_dev(card->host), mmc_blk_ioctl_cmd()
608 mmc_put_card(card); mmc_blk_ioctl_cmd()
646 static inline int mmc_blk_part_switch(struct mmc_card *card, mmc_blk_part_switch() argument
650 struct mmc_blk_data *main_md = dev_get_drvdata(&card->dev); mmc_blk_part_switch()
655 if (mmc_card_mmc(card)) { mmc_blk_part_switch()
656 u8 part_config = card->ext_csd.part_config; mmc_blk_part_switch()
661 ret = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, mmc_blk_part_switch()
663 card->ext_csd.part_time); mmc_blk_part_switch()
667 card->ext_csd.part_config = part_config; mmc_blk_part_switch()
674 static u32 mmc_sd_num_wr_blocks(struct mmc_card *card) mmc_sd_num_wr_blocks() argument
687 cmd.arg = card->rca << 16; mmc_sd_num_wr_blocks()
690 err = mmc_wait_for_cmd(card->host, &cmd, 0); mmc_sd_num_wr_blocks()
693 if (!mmc_host_is_spi(card->host) && !(cmd.resp[0] & R1_APP_CMD)) mmc_sd_num_wr_blocks()
707 mmc_set_data_timeout(&data, card); mmc_sd_num_wr_blocks()
718 mmc_wait_for_req(card->host, &mrq); mmc_sd_num_wr_blocks()
729 static int get_card_status(struct mmc_card *card, u32 *status, int retries) get_card_status() argument
735 if (!mmc_host_is_spi(card->host)) get_card_status()
736 cmd.arg = card->rca << 16; get_card_status()
738 err = mmc_wait_for_cmd(card->host, &cmd, retries); get_card_status()
744 static int card_busy_detect(struct mmc_card *card, unsigned int timeout_ms, card_busy_detect() argument
752 err = get_card_status(card, &status, 5); card_busy_detect()
766 if ((card->host->caps & MMC_CAP_WAIT_WHILE_BUSY) && card_busy_detect()
776 mmc_hostname(card->host), card_busy_detect()
784 * indication and the card state. card_busy_detect()
792 static int send_stop(struct mmc_card *card, unsigned int timeout_ms, send_stop() argument
795 struct mmc_host *host = card->host; send_stop()
823 /* No need to check card status in case of READ. */ send_stop()
834 return card_busy_detect(card, timeout_ms, use_r1b_resp, req, gen_err); send_stop()
848 pr_err("%s: %s sending %s command, card status %#x\n", mmc_blk_cmd_error()
854 pr_err("%s: %s sending %s command, card status %#x\n", mmc_blk_cmd_error()
874 pr_err("%s: unknown error %d sending read/write command, card status %#x\n", mmc_blk_cmd_error()
882 * We don't know whether the card received the r/w cmd or not, so try to
884 * - Obtain card status. If the first attempt to obtain card status fails,
886 * r/w cmd. If we fail to obtain card status, it suggests we can no
887 * longer communicate with the card.
888 * - Check the card state. If the card received the cmd but there was a
898 static int mmc_blk_cmd_recovery(struct mmc_card *card, struct request *req, mmc_blk_cmd_recovery() argument
905 if (mmc_card_removed(card)) mmc_blk_cmd_recovery()
909 * Try to get card status which indicates both the card state mmc_blk_cmd_recovery()
914 err = get_card_status(card, &status, 0); mmc_blk_cmd_recovery()
923 /* We couldn't get a response from the card. Give up. */ mmc_blk_cmd_recovery()
925 /* Check if the card is removed */ mmc_blk_cmd_recovery()
926 if (mmc_detect_card_removed(card->host)) mmc_blk_cmd_recovery()
938 if (!mmc_host_is_spi(card->host) && rq_data_dir(req) != READ) mmc_blk_cmd_recovery()
941 pr_err("%s: %s: general error sending stop or status command, stop cmd response %#x, card status %#x\n", mmc_blk_cmd_recovery()
948 * Check the current card state. If it is in some data transfer mmc_blk_cmd_recovery()
953 err = send_stop(card, mmc_blk_cmd_recovery()
960 * If the stop cmd also timed out, the card is probably mmc_blk_cmd_recovery()
985 pr_info("%s: error %d sending stop command, original cmd response %#x, card status %#x\n", mmc_blk_cmd_recovery()
1013 dev_get_drvdata(&host->card->dev); mmc_blk_reset()
1017 part_err = mmc_blk_part_switch(host->card, md); mmc_blk_reset()
1049 struct mmc_card *card = md->queue.card; mmc_blk_issue_discard_rq() local
1053 if (!mmc_can_erase(card)) { mmc_blk_issue_discard_rq()
1061 if (mmc_can_discard(card)) mmc_blk_issue_discard_rq()
1063 else if (mmc_can_trim(card)) mmc_blk_issue_discard_rq()
1068 if (card->quirks & MMC_QUIRK_INAND_CMD38) { mmc_blk_issue_discard_rq()
1069 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, mmc_blk_issue_discard_rq()
1078 err = mmc_erase(card, from, nr, arg); mmc_blk_issue_discard_rq()
1080 if (err == -EIO && !mmc_blk_reset(md, card->host, type)) mmc_blk_issue_discard_rq()
1093 struct mmc_card *card = md->queue.card; mmc_blk_issue_secdiscard_rq() local
1097 if (!(mmc_can_secure_erase_trim(card))) { mmc_blk_issue_secdiscard_rq()
1105 if (mmc_can_trim(card) && !mmc_erase_group_aligned(card, from, nr)) mmc_blk_issue_secdiscard_rq()
1111 if (card->quirks & MMC_QUIRK_INAND_CMD38) { mmc_blk_issue_secdiscard_rq()
1112 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, mmc_blk_issue_secdiscard_rq()
1122 err = mmc_erase(card, from, nr, arg); mmc_blk_issue_secdiscard_rq()
1129 if (card->quirks & MMC_QUIRK_INAND_CMD38) { mmc_blk_issue_secdiscard_rq()
1130 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, mmc_blk_issue_secdiscard_rq()
1138 err = mmc_erase(card, from, nr, MMC_SECURE_TRIM2_ARG); mmc_blk_issue_secdiscard_rq()
1146 if (err && !mmc_blk_reset(md, card->host, type)) mmc_blk_issue_secdiscard_rq()
1159 struct mmc_card *card = md->queue.card; mmc_blk_issue_flush() local
1162 ret = mmc_flush_cache(card); mmc_blk_issue_flush()
1179 struct mmc_card *card, mmc_apply_rel_rw()
1182 if (!(card->ext_csd.rel_param & EXT_CSD_WR_REL_PARAM_EN)) { mmc_apply_rel_rw()
1184 if (!IS_ALIGNED(brq->cmd.arg, card->ext_csd.rel_sectors)) mmc_apply_rel_rw()
1187 if (brq->data.blocks > card->ext_csd.rel_sectors) mmc_apply_rel_rw()
1188 brq->data.blocks = card->ext_csd.rel_sectors; mmc_apply_rel_rw()
1189 else if (brq->data.blocks < card->ext_csd.rel_sectors) mmc_apply_rel_rw()
1202 static int mmc_blk_err_check(struct mmc_card *card, mmc_blk_err_check() argument
1223 switch (mmc_blk_cmd_recovery(card, req, brq, &ecc_err, &gen_err)) { mmc_blk_err_check()
1251 if (!mmc_host_is_spi(card->host) && rq_data_dir(req) != READ) { mmc_blk_err_check()
1262 err = card_busy_detect(card, MMC_BLK_TIMEOUT_MS, false, req, mmc_blk_err_check()
1276 pr_err("%s: error %d transferring data, sector %u, nr %u, cmd response %#x, card status %#x\n", mmc_blk_err_check()
1307 static int mmc_blk_packed_err_check(struct mmc_card *card, mmc_blk_packed_err_check() argument
1320 check = mmc_blk_err_check(card, areq); mmc_blk_packed_err_check()
1321 err = get_card_status(card, &status, 0); mmc_blk_packed_err_check()
1329 err = mmc_get_ext_csd(card, &ext_csd); mmc_blk_packed_err_check()
1358 struct mmc_card *card, mmc_blk_rw_rq_prep()
1385 if (!mmc_card_blockaddr(card)) mmc_blk_rw_rq_prep()
1398 if (brq->data.blocks > card->host->max_blk_count) mmc_blk_rw_rq_prep()
1399 brq->data.blocks = card->host->max_blk_count; mmc_blk_rw_rq_prep()
1414 if (card->host->ops->multi_io_quirk) mmc_blk_rw_rq_prep()
1415 brq->data.blocks = card->host->ops->multi_io_quirk(card, mmc_blk_rw_rq_prep()
1425 if (!mmc_host_is_spi(card->host) || mmc_blk_rw_rq_prep()
1450 mmc_apply_rel_rw(brq, card, req); mmc_blk_rw_rq_prep()
1456 do_data_tag = (card->ext_csd.data_tag_unit_size) && mmc_blk_rw_rq_prep()
1460 card->ext_csd.data_tag_unit_size); mmc_blk_rw_rq_prep()
1471 * supported by card and host, we'll fill sbc in and let mmc_blk_rw_rq_prep()
1481 (do_rel_wr || !(card->quirks & MMC_QUIRK_BLK_NO_CMD23) || mmc_blk_rw_rq_prep()
1491 mmc_set_data_timeout(&brq->data, card); mmc_blk_rw_rq_prep()
1522 struct mmc_card *card) mmc_calc_packed_hdr_segs()
1524 unsigned int hdr_sz = mmc_large_sector(card) ? 4096 : 512; mmc_calc_packed_hdr_segs()
1540 struct mmc_card *card = mq->card; mmc_blk_prep_packed_list() local
1544 bool en_rel_wr = card->ext_csd.rel_param & EXT_CSD_WR_REL_PARAM_EN; mmc_blk_prep_packed_list()
1555 mmc_host_packed_wr(card->host)) mmc_blk_prep_packed_list()
1556 max_packed_rw = card->ext_csd.max_packed_writes; mmc_blk_prep_packed_list()
1565 if (mmc_large_sector(card) && mmc_blk_prep_packed_list()
1571 max_blk_count = min(card->host->max_blk_count, mmc_blk_prep_packed_list()
1572 card->host->max_req_size >> 9); mmc_blk_prep_packed_list()
1581 req_sectors += mmc_large_sector(card) ? 8 : 1; mmc_blk_prep_packed_list()
1582 phys_segments += mmc_calc_packed_hdr_segs(q, card); mmc_blk_prep_packed_list()
1599 if (mmc_large_sector(card) && mmc_blk_prep_packed_list()
1646 struct mmc_card *card, mmc_blk_packed_hdr_wrq_prep()
1669 hdr_blocks = mmc_large_sector(card) ? 8 : 1; mmc_blk_packed_hdr_wrq_prep()
1676 do_data_tag = (card->ext_csd.data_tag_unit_size) && mmc_blk_packed_hdr_wrq_prep()
1680 card->ext_csd.data_tag_unit_size); mmc_blk_packed_hdr_wrq_prep()
1688 mmc_card_blockaddr(card) ? mmc_blk_packed_hdr_wrq_prep()
1706 if (!mmc_card_blockaddr(card)) mmc_blk_packed_hdr_wrq_prep()
1718 mmc_set_data_timeout(&brq->data, card); mmc_blk_packed_hdr_wrq_prep()
1729 static int mmc_blk_cmd_err(struct mmc_blk_data *md, struct mmc_card *card, mmc_blk_cmd_err() argument
1737 * If this is an SD card and we're writing, we can first mmc_blk_cmd_err()
1740 * If the card is not SD, we can still ok written sectors mmc_blk_cmd_err()
1744 if (mmc_card_sd(card)) { mmc_blk_cmd_err()
1747 blocks = mmc_sd_num_wr_blocks(card); mmc_blk_cmd_err()
1833 struct mmc_card *card = md->queue.card; mmc_blk_issue_rw_rq() local
1856 (card->ext_csd.data_sector_size == 4096)) { mmc_blk_issue_rw_rq()
1865 card, mq); mmc_blk_issue_rw_rq()
1867 mmc_blk_rw_rq_prep(mq->mqrq_cur, card, 0, mq); mmc_blk_issue_rw_rq()
1871 areq = mmc_start_req(card->host, areq, (int *) &status); mmc_blk_issue_rw_rq()
1914 ret = mmc_blk_cmd_err(md, card, brq, req, ret); mmc_blk_issue_rw_rq()
1915 if (mmc_blk_reset(md, card->host, type)) mmc_blk_issue_rw_rq()
1925 if (!mmc_blk_reset(md, card->host, type)) mmc_blk_issue_rw_rq()
1931 err = mmc_blk_reset(md, card->host, type); mmc_blk_issue_rw_rq()
1969 mmc_blk_packed_hdr_wrq_prep(mq_rq, card, mq); mmc_blk_issue_rw_rq()
1970 mmc_start_req(card->host, mmc_blk_issue_rw_rq()
1978 mmc_blk_rw_rq_prep(mq_rq, card, mmc_blk_issue_rw_rq()
1980 mmc_start_req(card->host, mmc_blk_issue_rw_rq()
1992 if (mmc_card_removed(card)) mmc_blk_issue_rw_rq()
2001 if (mmc_card_removed(card)) { mmc_blk_issue_rw_rq()
2011 mmc_blk_rw_rq_prep(mq->mqrq_cur, card, 0, mq); mmc_blk_issue_rw_rq()
2012 mmc_start_req(card->host, mmc_blk_issue_rw_rq()
2024 struct mmc_card *card = md->queue.card; mmc_blk_issue_rq() local
2025 struct mmc_host *host = card->host; mmc_blk_issue_rq()
2031 mmc_get_card(card); mmc_blk_issue_rq()
2033 ret = mmc_blk_part_switch(card, md); mmc_blk_issue_rq()
2045 if (card->host->areq) mmc_blk_issue_rq()
2053 if (card->host->areq) mmc_blk_issue_rq()
2074 mmc_put_card(card); mmc_blk_issue_rq()
2078 static inline int mmc_blk_readonly(struct mmc_card *card) mmc_blk_readonly() argument
2080 return mmc_card_readonly(card) || mmc_blk_readonly()
2081 !(card->csd.cmdclass & CCC_BLOCK_WRITE); mmc_blk_readonly()
2084 static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card, mmc_blk_alloc_req() argument
2108 * partitions, devidx will not coincide with a per-physical card mmc_blk_alloc_req()
2124 md->read_only = mmc_blk_readonly(card); mmc_blk_alloc_req()
2136 ret = mmc_init_queue(&md->queue, card, &md->lock, subname); mmc_blk_alloc_req()
2162 * messages to tell when the card is present. mmc_blk_alloc_req()
2168 if (mmc_card_mmc(card)) mmc_blk_alloc_req()
2170 card->ext_csd.data_sector_size); mmc_blk_alloc_req()
2176 if (mmc_host_cmd23(card->host)) { mmc_blk_alloc_req()
2177 if (mmc_card_mmc(card) || mmc_blk_alloc_req()
2178 (mmc_card_sd(card) && mmc_blk_alloc_req()
2179 card->scr.cmds & SD_SCR_CMD23_SUPPORT)) mmc_blk_alloc_req()
2183 if (mmc_card_mmc(card) && mmc_blk_alloc_req()
2185 ((card->ext_csd.rel_param & EXT_CSD_WR_REL_PARAM_EN) || mmc_blk_alloc_req()
2186 card->ext_csd.rel_sectors)) { mmc_blk_alloc_req()
2191 if (mmc_card_mmc(card) && mmc_blk_alloc_req()
2194 card->ext_csd.packed_event_en) { mmc_blk_alloc_req()
2195 if (!mmc_packed_init(&md->queue, card)) mmc_blk_alloc_req()
2209 static struct mmc_blk_data *mmc_blk_alloc(struct mmc_card *card) mmc_blk_alloc() argument
2213 if (!mmc_card_sd(card) && mmc_card_blockaddr(card)) { mmc_blk_alloc()
2218 size = card->ext_csd.sectors; mmc_blk_alloc()
2224 size = card->csd.capacity << (card->csd.read_blkbits - 9); mmc_blk_alloc()
2227 return mmc_blk_alloc_req(card, &card->dev, size, false, NULL, mmc_blk_alloc()
2231 static int mmc_blk_alloc_part(struct mmc_card *card, mmc_blk_alloc_part() argument
2242 part_md = mmc_blk_alloc_req(card, disk_to_dev(md->disk), size, default_ro, mmc_blk_alloc_part()
2252 part_md->disk->disk_name, mmc_card_id(card), mmc_blk_alloc_part()
2253 mmc_card_name(card), part_md->part_type, cap_str); mmc_blk_alloc_part()
2263 static int mmc_blk_alloc_parts(struct mmc_card *card, struct mmc_blk_data *md) mmc_blk_alloc_parts() argument
2267 if (!mmc_card_mmc(card)) mmc_blk_alloc_parts()
2270 for (idx = 0; idx < card->nr_parts; idx++) { mmc_blk_alloc_parts()
2271 if (card->part[idx].size) { mmc_blk_alloc_parts()
2272 ret = mmc_blk_alloc_part(card, md, mmc_blk_alloc_parts()
2273 card->part[idx].part_cfg, mmc_blk_alloc_parts()
2274 card->part[idx].size >> 9, mmc_blk_alloc_parts()
2275 card->part[idx].force_ro, mmc_blk_alloc_parts()
2276 card->part[idx].name, mmc_blk_alloc_parts()
2277 card->part[idx].area_type); mmc_blk_alloc_parts()
2288 struct mmc_card *card; mmc_blk_remove_req() local
2296 card = md->queue.card; mmc_blk_remove_req()
2303 card->ext_csd.boot_ro_lockable) mmc_blk_remove_req()
2313 static void mmc_blk_remove_parts(struct mmc_card *card, mmc_blk_remove_parts() argument
2330 struct mmc_card *card = md->queue.card; mmc_add_disk() local
2343 card->ext_csd.boot_ro_lockable) { mmc_add_disk()
2346 if (card->ext_csd.boot_ro_lock & EXT_CSD_BOOT_WP_B_PWR_WP_DIS) mmc_add_disk()
2438 static int mmc_blk_probe(struct mmc_card *card) mmc_blk_probe() argument
2444 * Check that the card supports the command class(es) we need. mmc_blk_probe()
2446 if (!(card->csd.cmdclass & CCC_BLOCK_READ)) mmc_blk_probe()
2449 mmc_fixup_device(card, blk_fixups); mmc_blk_probe()
2451 md = mmc_blk_alloc(card); mmc_blk_probe()
2458 md->disk->disk_name, mmc_card_id(card), mmc_card_name(card), mmc_blk_probe()
2461 if (mmc_blk_alloc_parts(card, md)) mmc_blk_probe()
2464 dev_set_drvdata(&card->dev, md); mmc_blk_probe()
2474 pm_runtime_set_autosuspend_delay(&card->dev, 3000); mmc_blk_probe()
2475 pm_runtime_use_autosuspend(&card->dev); mmc_blk_probe()
2481 if (card->type != MMC_TYPE_SD_COMBO) { mmc_blk_probe()
2482 pm_runtime_set_active(&card->dev); mmc_blk_probe()
2483 pm_runtime_enable(&card->dev); mmc_blk_probe()
2489 mmc_blk_remove_parts(card, md); mmc_blk_probe()
2494 static void mmc_blk_remove(struct mmc_card *card) mmc_blk_remove() argument
2496 struct mmc_blk_data *md = dev_get_drvdata(&card->dev); mmc_blk_remove()
2498 mmc_blk_remove_parts(card, md); mmc_blk_remove()
2499 pm_runtime_get_sync(&card->dev); mmc_blk_remove()
2500 mmc_claim_host(card->host); mmc_blk_remove()
2501 mmc_blk_part_switch(card, md); mmc_blk_remove()
2502 mmc_release_host(card->host); mmc_blk_remove()
2503 if (card->type != MMC_TYPE_SD_COMBO) mmc_blk_remove()
2504 pm_runtime_disable(&card->dev); mmc_blk_remove()
2505 pm_runtime_put_noidle(&card->dev); mmc_blk_remove()
2507 dev_set_drvdata(&card->dev, NULL); mmc_blk_remove()
2510 static int _mmc_blk_suspend(struct mmc_card *card) _mmc_blk_suspend() argument
2513 struct mmc_blk_data *md = dev_get_drvdata(&card->dev); _mmc_blk_suspend()
2524 static void mmc_blk_shutdown(struct mmc_card *card) mmc_blk_shutdown() argument
2526 _mmc_blk_suspend(card); mmc_blk_shutdown()
2532 struct mmc_card *card = mmc_dev_to_card(dev); mmc_blk_suspend() local
2534 return _mmc_blk_suspend(card); mmc_blk_suspend()
2544 * Resume involves the card going into idle state, mmc_blk_resume()
1178 mmc_apply_rel_rw(struct mmc_blk_request *brq, struct mmc_card *card, struct request *req) mmc_apply_rel_rw() argument
1357 mmc_blk_rw_rq_prep(struct mmc_queue_req *mqrq, struct mmc_card *card, int disable_multi, struct mmc_queue *mq) mmc_blk_rw_rq_prep() argument
1521 mmc_calc_packed_hdr_segs(struct request_queue *q, struct mmc_card *card) mmc_calc_packed_hdr_segs() argument
1645 mmc_blk_packed_hdr_wrq_prep(struct mmc_queue_req *mqrq, struct mmc_card *card, struct mmc_queue *mq) mmc_blk_packed_hdr_wrq_prep() argument
/linux-4.1.27/drivers/parisc/
H A Dhppb.c51 struct hppb_card *card = &hppb_card_head; hppb_probe() local
53 while(card->next) { hppb_probe()
54 card = card->next; hppb_probe()
57 if(card->hpa) { hppb_probe()
58 card->next = kzalloc(sizeof(struct hppb_card), GFP_KERNEL); hppb_probe()
59 if(!card->next) { hppb_probe()
63 card = card->next; hppb_probe()
68 card->hpa = dev->hpa.start; hppb_probe()
69 card->mmio_region.name = "HP-PB Bus"; hppb_probe()
70 card->mmio_region.flags = IORESOURCE_MEM; hppb_probe()
72 card->mmio_region.start = gsc_readl(dev->hpa.start + IO_IO_LOW); hppb_probe()
73 card->mmio_region.end = gsc_readl(dev->hpa.start + IO_IO_HIGH) - 1; hppb_probe()
75 status = ccio_request_resource(dev, &card->mmio_region); hppb_probe()
78 __FILE__, &card->mmio_region); hppb_probe()
/linux-4.1.27/sound/pci/ctxfi/
H A Dxfi.c63 struct snd_card *card; ct_card_probe() local
75 0, &card); ct_card_probe()
79 dev_err(card->dev, ct_card_probe()
82 dev_err(card->dev, ct_card_probe()
87 dev_err(card->dev, "Invalid multiple value %u!!!\n", ct_card_probe()
89 dev_err(card->dev, ct_card_probe()
93 err = ct_atc_create(card, pci, reference_rate, multiple, ct_card_probe()
98 card->private_data = atc; ct_card_probe()
100 /* Create alsa devices supported by this card */ ct_card_probe()
105 strcpy(card->driver, "SB-XFi"); ct_card_probe()
106 strcpy(card->shortname, "Creative X-Fi"); ct_card_probe()
107 snprintf(card->longname, sizeof(card->longname), "%s %s %s", ct_card_probe()
108 card->shortname, atc->chip_name, atc->model_name); ct_card_probe()
110 err = snd_card_register(card); ct_card_probe()
114 pci_set_drvdata(pci, card); ct_card_probe()
120 snd_card_free(card); ct_card_probe()
132 struct snd_card *card = dev_get_drvdata(dev); ct_card_suspend() local
133 struct ct_atc *atc = card->private_data; ct_card_suspend()
140 struct snd_card *card = dev_get_drvdata(dev); ct_card_resume() local
141 struct ct_atc *atc = card->private_data; ct_card_resume()
/linux-4.1.27/drivers/mtd/maps/
H A Dvmu-flash.c63 struct memcard *card; ofs_to_block() local
69 card = maple_get_drvdata(mdev); ofs_to_block()
71 if (src_ofs >= card->parts[partition].numblocks * card->blocklen) ofs_to_block()
74 num = src_ofs / card->blocklen; ofs_to_block()
75 if (num > card->parts[partition].numblocks) ofs_to_block()
83 vblock->ofs = src_ofs % card->blocklen; ofs_to_block()
94 struct memcard *card; vmu_blockread() local
97 card = maple_get_drvdata(mdev); vmu_blockread()
100 if (unlikely(!card->blockread)) vmu_blockread()
103 memcpy(card->blockread, mq->recvbuf->buf + 12, vmu_blockread()
104 card->blocklen/card->readcnt); vmu_blockread()
114 struct memcard *card; maple_vmu_read_block() local
125 card = maple_get_drvdata(mdev); maple_vmu_read_block()
126 pcache = card->parts[partition].pcache; maple_vmu_read_block()
131 pcache->buffer = kmalloc(card->blocklen, GFP_KERNEL); maple_vmu_read_block()
146 for (x = 0; x < card->readcnt; x++) { maple_vmu_read_block()
161 blockread = kmalloc(card->blocklen/card->readcnt, GFP_KERNEL); maple_vmu_read_block()
167 card->blockread = blockread; maple_vmu_read_block()
186 card->blockread = NULL; maple_vmu_read_block()
190 card->blockread = NULL; maple_vmu_read_block()
207 memcpy(buf + (card->blocklen/card->readcnt) * x, blockread, maple_vmu_read_block()
208 card->blocklen/card->readcnt); maple_vmu_read_block()
210 memcpy(pcache->buffer + (card->blocklen/card->readcnt) * x, maple_vmu_read_block()
211 card->blockread, card->blocklen/card->readcnt); maple_vmu_read_block()
212 card->blockread = NULL; maple_vmu_read_block()
231 struct memcard *card; maple_vmu_write_block() local
240 card = maple_get_drvdata(mdev); maple_vmu_write_block()
242 phaselen = card->blocklen/card->writecnt; maple_vmu_write_block()
249 for (x = 0; x < card->writecnt; x++) { maple_vmu_write_block()
293 return card->blocklen; maple_vmu_write_block()
308 struct memcard *card; vmu_flash_read_char() local
317 card = maple_get_drvdata(mdev); vmu_flash_read_char()
320 buf = kmalloc(card->blocklen, GFP_KERNEL); vmu_flash_read_char()
356 struct memcard *card; vmu_flash_read() local
366 card = maple_get_drvdata(mdev); vmu_flash_read()
368 numblocks = card->parts[partition].numblocks; vmu_flash_read()
369 if (from + len > numblocks * card->blocklen) vmu_flash_read()
370 len = numblocks * card->blocklen - from; vmu_flash_read()
374 pcache = card->parts[partition].pcache; vmu_flash_read()
384 leftover = card->blocklen - vblock->ofs; vmu_flash_read()
385 if (vblock->ofs + len - index < card->blocklen) { vmu_flash_read()
422 struct memcard *card; vmu_flash_write() local
432 card = maple_get_drvdata(mdev); vmu_flash_write()
434 numblocks = card->parts[partition].numblocks; vmu_flash_write()
435 if (to + len > numblocks * card->blocklen) vmu_flash_write()
436 len = numblocks * card->blocklen - to; vmu_flash_write()
448 buffer = kmalloc(card->blocklen, GFP_KERNEL); vmu_flash_write()
466 } while (vblock->ofs < card->blocklen); vmu_flash_write()
471 pcache = card->parts[partition].pcache; vmu_flash_write()
474 if (error != card->blocklen) vmu_flash_write()
505 struct memcard *card; vmu_queryblocks() local
514 card = maple_get_drvdata(mdev); vmu_queryblocks()
516 card->tempA = res[12]; vmu_queryblocks()
517 card->tempB = res[6]; vmu_queryblocks()
520 "blocks with a root block at %d\n", card->partition, vmu_queryblocks()
521 card->tempA, card->tempB); vmu_queryblocks()
523 part_cur = &card->parts[card->partition]; vmu_queryblocks()
524 part_cur->user_blocks = card->tempA; vmu_queryblocks()
525 part_cur->root_block = card->tempB; vmu_queryblocks()
526 part_cur->numblocks = card->tempB + 1; vmu_queryblocks()
532 mdev->port, mdev->unit, card->partition); vmu_queryblocks()
533 mtd_cur = &card->mtd[card->partition]; vmu_queryblocks()
537 mtd_cur->size = part_cur->numblocks * card->blocklen; vmu_queryblocks()
538 mtd_cur->erasesize = card->blocklen; vmu_queryblocks()
542 mtd_cur->writesize = card->blocklen; vmu_queryblocks()
549 mpart->partition = card->partition; vmu_queryblocks()
569 if (++card->partition < card->partitions) { vmu_queryblocks()
570 partnum = cpu_to_be32(card->partition << 24); vmu_queryblocks()
581 for (error = 0; error <= card->partition; error++) { vmu_queryblocks()
582 kfree(((card->parts)[error]).pcache); vmu_queryblocks()
583 ((card->parts)[error]).pcache = NULL; vmu_queryblocks()
587 for (error = 0; error <= card->partition; error++) { vmu_queryblocks()
588 kfree(((card->mtd)[error]).priv); vmu_queryblocks()
589 ((card->mtd)[error]).priv = NULL; vmu_queryblocks()
603 struct memcard *card; vmu_connect() local
608 * function_data element has details of the memory card vmu_connect()
614 card = kmalloc(sizeof(struct memcard), GFP_KERNEL); vmu_connect()
615 if (!card) { vmu_connect()
620 card->partitions = (basic_flash_data >> 24 & 0xFF) + 1; vmu_connect()
621 card->blocklen = ((basic_flash_data >> 16 & 0xFF) + 1) << 5; vmu_connect()
622 card->writecnt = basic_flash_data >> 12 & 0xF; vmu_connect()
623 card->readcnt = basic_flash_data >> 8 & 0xF; vmu_connect()
624 card->removeable = basic_flash_data >> 7 & 1; vmu_connect()
626 card->partition = 0; vmu_connect()
632 card->parts = kmalloc(sizeof(struct vmupart) * card->partitions, vmu_connect()
634 if (!card->parts) { vmu_connect()
639 card->mtd = kmalloc(sizeof(struct mtd_info) * card->partitions, vmu_connect()
641 if (!card->mtd) { vmu_connect()
646 maple_set_drvdata(mdev, card); vmu_connect()
684 kfree(card->mtd); vmu_connect()
686 kfree(card->parts); vmu_connect()
688 kfree(card); vmu_connect()
695 struct memcard *card; vmu_disconnect() local
700 card = maple_get_drvdata(mdev); vmu_disconnect()
701 for (x = 0; x < card->partitions; x++) { vmu_disconnect()
702 mpart = ((card->mtd)[x]).priv; vmu_disconnect()
704 mtd_device_unregister(&((card->mtd)[x])); vmu_disconnect()
705 kfree(((card->parts)[x]).name); vmu_disconnect()
707 kfree(card->parts); vmu_disconnect()
708 kfree(card->mtd); vmu_disconnect()
709 kfree(card); vmu_disconnect()
717 struct memcard *card; vmu_can_unload() local
721 card = maple_get_drvdata(mdev); vmu_can_unload()
722 for (x = 0; x < card->partitions; x++) { vmu_can_unload()
723 mtd = &((card->mtd)[x]); vmu_can_unload()
/linux-4.1.27/drivers/net/can/sja1000/
H A Dpeak_pcmcia.c163 static void pcan_set_leds(struct pcan_pccard *card, u8 mask, u8 state);
168 static void pcan_start_led_timer(struct pcan_pccard *card) pcan_start_led_timer() argument
170 if (!timer_pending(&card->led_timer)) pcan_start_led_timer()
171 mod_timer(&card->led_timer, jiffies + HZ); pcan_start_led_timer()
177 static void pcan_stop_led_timer(struct pcan_pccard *card) pcan_stop_led_timer() argument
179 del_timer_sync(&card->led_timer); pcan_stop_led_timer()
195 struct pcan_pccard *card = priv->priv; pcan_write_canreg() local
196 int c = (priv->reg_base - card->ioport_addr) / PCC_CHAN_SIZE; pcan_write_canreg()
203 pcan_set_leds(card, PCC_LED(c), PCC_LED_ON); pcan_write_canreg()
207 pcan_set_leds(card, PCC_LED(c), PCC_LED_SLOW); pcan_write_canreg()
208 pcan_start_led_timer(card); pcan_write_canreg()
220 static u8 pcan_read_reg(struct pcan_pccard *card, int port) pcan_read_reg() argument
222 return ioread8(card->ioport_addr + PCC_COMN_OFF + port); pcan_read_reg()
228 static void pcan_write_reg(struct pcan_pccard *card, int port, u8 v) pcan_write_reg() argument
232 if (card->ccr == v) pcan_write_reg()
234 card->ccr = v; pcan_write_reg()
237 iowrite8(v, card->ioport_addr + PCC_COMN_OFF + port); pcan_write_reg()
241 * check whether the card is present by checking its fw version numbers
244 static inline int pcan_pccard_present(struct pcan_pccard *card) pcan_pccard_present() argument
246 return ((pcan_read_reg(card, PCC_FW_MAJOR) == card->fw_major) && pcan_pccard_present()
247 (pcan_read_reg(card, PCC_FW_MINOR) == card->fw_minor)); pcan_pccard_present()
253 static int pcan_wait_spi_busy(struct pcan_pccard *card) pcan_wait_spi_busy() argument
259 while (pcan_read_reg(card, PCC_CSR) & PCC_CSR_SPI_BUSY) { pcan_wait_spi_busy()
271 static int pcan_write_eeprom(struct pcan_pccard *card, u16 addr, u8 v) pcan_write_eeprom() argument
277 pcan_write_reg(card, PCC_SPI_IR, PCC_EEP_WREN); pcan_write_eeprom()
278 err = pcan_wait_spi_busy(card); pcan_write_eeprom()
285 pcan_write_reg(card, PCC_SPI_IR, PCC_EEP_RDSR); pcan_write_eeprom()
286 err = pcan_wait_spi_busy(card); pcan_write_eeprom()
291 status = pcan_read_reg(card, PCC_SPI_DIR); pcan_write_eeprom()
297 dev_err(&card->pdev->dev, pcan_write_eeprom()
303 pcan_write_reg(card, PCC_SPI_ADR, addr & 0xff); pcan_write_eeprom()
304 pcan_write_reg(card, PCC_SPI_DOR, v); pcan_write_eeprom()
310 pcan_write_reg(card, PCC_SPI_IR, PCC_EEP_WRITE(addr)); pcan_write_eeprom()
311 err = pcan_wait_spi_busy(card); pcan_write_eeprom()
318 pcan_write_reg(card, PCC_SPI_IR, PCC_EEP_RDSR); pcan_write_eeprom()
319 err = pcan_wait_spi_busy(card); pcan_write_eeprom()
324 status = pcan_read_reg(card, PCC_SPI_DIR); pcan_write_eeprom()
330 dev_err(&card->pdev->dev, pcan_write_eeprom()
336 pcan_write_reg(card, PCC_SPI_IR, PCC_EEP_WRDI); pcan_write_eeprom()
337 err = pcan_wait_spi_busy(card); pcan_write_eeprom()
344 dev_err(&card->pdev->dev, pcan_write_eeprom()
350 static void pcan_set_leds(struct pcan_pccard *card, u8 led_mask, u8 state) pcan_set_leds() argument
352 u8 ccr = card->ccr; pcan_set_leds()
355 for (i = 0; i < card->chan_count; i++) pcan_set_leds()
364 pcan_write_reg(card, PCC_CCR, ccr); pcan_set_leds()
370 static inline void pcan_set_can_power(struct pcan_pccard *card, int onoff) pcan_set_can_power() argument
374 err = pcan_write_eeprom(card, 0, !!onoff); pcan_set_can_power()
376 dev_err(&card->pdev->dev, pcan_set_can_power()
386 struct pcan_pccard *card = (struct pcan_pccard *)arg; pcan_led_timer() local
391 ccr = card->ccr; pcan_led_timer()
392 for (i = 0; i < card->chan_count; i++) { pcan_led_timer()
397 netdev = card->channel[i].netdev; pcan_led_timer()
408 if (netdev->stats.rx_bytes != card->channel[i].prev_rx_bytes) { pcan_led_timer()
409 card->channel[i].prev_rx_bytes = netdev->stats.rx_bytes; pcan_led_timer()
413 if (netdev->stats.tx_bytes != card->channel[i].prev_tx_bytes) { pcan_led_timer()
414 card->channel[i].prev_tx_bytes = netdev->stats.tx_bytes; pcan_led_timer()
421 pcan_write_reg(card, PCC_CCR, ccr); pcan_led_timer()
425 mod_timer(&card->led_timer, jiffies + HZ); pcan_led_timer()
433 struct pcan_pccard *card = dev_id; pcan_isr() local
443 for (i = 0; i < card->chan_count; i++) { pcan_isr()
447 * check whether the card is present before calling pcan_isr()
450 if (!pcan_pccard_present(card)) { pcan_isr()
451 /* card unplugged during isr */ pcan_isr()
459 netdev = card->channel[i].netdev; pcan_isr()
475 static void pcan_free_channels(struct pcan_pccard *card) pcan_free_channels() argument
480 for (i = 0; i < card->chan_count; i++) { pcan_free_channels()
486 netdev = card->channel[i].netdev; pcan_free_channels()
496 dev_info(&card->pdev->dev, "%s removed\n", name); pcan_free_channels()
500 if (pcan_pccard_present(card)) { pcan_free_channels()
501 pcan_set_leds(card, led_mask, PCC_LED_OFF); pcan_free_channels()
502 pcan_set_can_power(card, 0); pcan_free_channels()
522 static int pcan_add_channels(struct pcan_pccard *card) pcan_add_channels() argument
524 struct pcmcia_device *pdev = card->pdev; pcan_add_channels()
529 card->ccr = ~ccr; pcan_add_channels()
530 pcan_write_reg(card, PCC_CCR, ccr); pcan_add_channels()
536 pcan_write_reg(card, PCC_CCR, ccr); pcan_add_channels()
539 for (i = 0; i < ARRAY_SIZE(card->channel); i++) { pcan_add_channels()
551 priv->priv = card; pcan_add_channels()
557 priv->reg_base = card->ioport_addr + PCC_CHAN_OFF(i); pcan_add_channels()
585 card->channel[i].netdev = netdev; pcan_add_channels()
586 card->chan_count++; pcan_add_channels()
597 pcan_write_reg(card, PCC_CCR, ccr); pcan_add_channels()
617 struct pcan_pccard *card = pdev->priv; pcan_free() local
619 if (!card) pcan_free()
622 free_irq(pdev->irq, card); pcan_free()
623 pcan_stop_led_timer(card); pcan_free()
625 pcan_free_channels(card); pcan_free()
627 ioport_unmap(card->ioport_addr); pcan_free()
629 kfree(card); pcan_free()
638 struct pcan_pccard *card; pcan_probe() local
662 card = kzalloc(sizeof(struct pcan_pccard), GFP_KERNEL); pcan_probe()
663 if (!card) { pcan_probe()
668 card->pdev = pdev; pcan_probe()
669 pdev->priv = card; pcan_probe()
672 card->ioport_addr = ioport_map(pdev->resource[0]->start, pcan_probe()
674 if (!card->ioport_addr) { pcan_probe()
679 card->fw_major = pcan_read_reg(card, PCC_FW_MAJOR); pcan_probe()
680 card->fw_minor = pcan_read_reg(card, PCC_FW_MINOR); pcan_probe()
683 dev_info(&pdev->dev, "PEAK-System pcmcia card %s fw %d.%d\n", pcan_probe()
685 card->fw_major, card->fw_minor); pcan_probe()
688 pcan_add_channels(card); pcan_probe()
689 if (!card->chan_count) { pcan_probe()
695 init_timer(&card->led_timer); pcan_probe()
696 card->led_timer.function = pcan_led_timer; pcan_probe()
697 card->led_timer.data = (unsigned long)card; pcan_probe()
700 err = request_irq(pdev->irq, &pcan_isr, IRQF_SHARED, PCC_NAME, card); pcan_probe()
707 pcan_set_can_power(card, 1); pcan_probe()
713 pcan_free_channels(card); pcan_probe()
716 ioport_unmap(card->ioport_addr); pcan_probe()
719 kfree(card); pcan_probe()
H A Dems_pci.c35 MODULE_SUPPORTED_DEVICE("EMS CPC-PCI/PCIe/104P CAN card");
116 * Helper to read internal registers from card logic (not CAN)
118 static u8 ems_pci_v1_readb(struct ems_pci_card *card, unsigned int port) ems_pci_v1_readb() argument
120 return readb(card->base_addr + (port * 4)); ems_pci_v1_readb()
136 struct ems_pci_card *card = (struct ems_pci_card *)priv->priv; ems_pci_v1_post_irq() local
140 card->conf_addr + PITA2_ICR); ems_pci_v1_post_irq()
156 struct ems_pci_card *card = (struct ems_pci_card *)priv->priv; ems_pci_v2_post_irq() local
158 writel(PLX_ICSR_ENA_CLR, card->conf_addr + PLX_ICSR); ems_pci_v2_post_irq()
185 struct ems_pci_card *card = pci_get_drvdata(pdev); ems_pci_del_card() local
189 for (i = 0; i < card->channels; i++) { ems_pci_del_card()
190 dev = card->net_dev[i]; ems_pci_del_card()
200 if (card->base_addr != NULL) ems_pci_del_card()
201 pci_iounmap(card->pci_dev, card->base_addr); ems_pci_del_card()
203 if (card->conf_addr != NULL) ems_pci_del_card()
204 pci_iounmap(card->pci_dev, card->conf_addr); ems_pci_del_card()
206 kfree(card); ems_pci_del_card()
211 static void ems_pci_card_reset(struct ems_pci_card *card) ems_pci_card_reset() argument
214 writeb(0, card->base_addr); ems_pci_card_reset()
226 struct ems_pci_card *card; ems_pci_add_card() local
236 /* Allocating card structures to hold addresses, ... */ ems_pci_add_card()
237 card = kzalloc(sizeof(struct ems_pci_card), GFP_KERNEL); ems_pci_add_card()
238 if (card == NULL) { ems_pci_add_card()
243 pci_set_drvdata(pdev, card); ems_pci_add_card()
245 card->pci_dev = pdev; ems_pci_add_card()
247 card->channels = 0; ems_pci_add_card()
250 card->version = 2; /* CPC-PCI v2 */ ems_pci_add_card()
255 card->version = 1; /* CPC-PCI v1 */ ems_pci_add_card()
262 card->conf_addr = pci_iomap(pdev, 0, conf_size); ems_pci_add_card()
263 if (card->conf_addr == NULL) { ems_pci_add_card()
268 card->base_addr = pci_iomap(pdev, base_bar, EMS_PCI_BASE_SIZE); ems_pci_add_card()
269 if (card->base_addr == NULL) { ems_pci_add_card()
274 if (card->version == 1) { ems_pci_add_card()
276 writel(PITA2_MISC_CONFIG, card->conf_addr + PITA2_MISC); ems_pci_add_card()
279 if (ems_pci_v1_readb(card, 0) != 0x55 || ems_pci_add_card()
280 ems_pci_v1_readb(card, 1) != 0xAA || ems_pci_add_card()
281 ems_pci_v1_readb(card, 2) != 0x01 || ems_pci_add_card()
282 ems_pci_v1_readb(card, 3) != 0xCB || ems_pci_add_card()
283 ems_pci_v1_readb(card, 4) != 0x11) { ems_pci_add_card()
291 ems_pci_card_reset(card); ems_pci_add_card()
301 card->net_dev[i] = dev; ems_pci_add_card()
303 priv->priv = card; ems_pci_add_card()
307 priv->reg_base = card->base_addr + EMS_PCI_CAN_BASE_OFFSET ems_pci_add_card()
309 if (card->version == 1) { ems_pci_add_card()
328 if (card->version == 1) ems_pci_add_card()
331 card->conf_addr + PITA2_ICR); ems_pci_add_card()
335 card->conf_addr + PLX_ICSR); ems_pci_add_card()
346 card->channels++; ems_pci_add_card()
H A Dpeak_pci.c165 static inline void pita_set_scl_highz(struct peak_pciec_card *card) pita_set_scl_highz() argument
167 u8 gp_outen = readb(card->cfg_base + PITA_GPOEN) & ~PITA_GPIN_SCL; pita_set_scl_highz()
168 writeb(gp_outen, card->cfg_base + PITA_GPOEN); pita_set_scl_highz()
171 static inline void pita_set_sda_highz(struct peak_pciec_card *card) pita_set_sda_highz() argument
173 u8 gp_outen = readb(card->cfg_base + PITA_GPOEN) & ~PITA_GPIN_SDA; pita_set_sda_highz()
174 writeb(gp_outen, card->cfg_base + PITA_GPOEN); pita_set_sda_highz()
177 static void peak_pciec_init_pita_gpio(struct peak_pciec_card *card) peak_pciec_init_pita_gpio() argument
180 pita_set_scl_highz(card); peak_pciec_init_pita_gpio()
181 pita_set_sda_highz(card); peak_pciec_init_pita_gpio()
186 struct peak_pciec_card *card = (struct peak_pciec_card *)data; pita_setsda() local
190 gp_out = readb(card->cfg_base + PITA_GPOUT) & ~PITA_GPIN_SDA; pita_setsda()
191 writeb(gp_out, card->cfg_base + PITA_GPOUT); pita_setsda()
194 gp_outen = readb(card->cfg_base + PITA_GPOEN); pita_setsda()
200 writeb(gp_outen, card->cfg_base + PITA_GPOEN); pita_setsda()
205 struct peak_pciec_card *card = (struct peak_pciec_card *)data; pita_setscl() local
209 gp_out = readb(card->cfg_base + PITA_GPOUT) & ~PITA_GPIN_SCL; pita_setscl()
210 writeb(gp_out, card->cfg_base + PITA_GPOUT); pita_setscl()
213 gp_outen = readb(card->cfg_base + PITA_GPOEN); pita_setscl()
219 writeb(gp_outen, card->cfg_base + PITA_GPOEN); pita_setscl()
224 struct peak_pciec_card *card = (struct peak_pciec_card *)data; pita_getsda() local
227 pita_set_sda_highz(card); pita_getsda()
229 return (readb(card->cfg_base + PITA_GPIN) & PITA_GPIN_SDA) ? 1 : 0; pita_getsda()
234 struct peak_pciec_card *card = (struct peak_pciec_card *)data; pita_getscl() local
237 pita_set_scl_highz(card); pita_getscl()
239 return (readb(card->cfg_base + PITA_GPIN) & PITA_GPIN_SCL) ? 1 : 0; pita_getscl()
245 static int peak_pciec_write_pca9553(struct peak_pciec_card *card, peak_pciec_write_pca9553() argument
260 if ((offset == 5) && (data == card->led_cache)) peak_pciec_write_pca9553()
263 ret = i2c_transfer(&card->led_chip, &msg, 1); peak_pciec_write_pca9553()
268 card->led_cache = data; peak_pciec_write_pca9553()
278 struct peak_pciec_card *card = peak_pciec_led_work() local
281 u8 new_led = card->led_cache; peak_pciec_led_work()
285 for (i = 0; i < card->chan_count; i++) { peak_pciec_led_work()
290 netdev = card->channel[i].netdev; peak_pciec_led_work()
301 if (netdev->stats.rx_bytes != card->channel[i].prev_rx_bytes) { peak_pciec_led_work()
302 card->channel[i].prev_rx_bytes = netdev->stats.rx_bytes; peak_pciec_led_work()
306 if (netdev->stats.tx_bytes != card->channel[i].prev_tx_bytes) { peak_pciec_led_work()
307 card->channel[i].prev_tx_bytes = netdev->stats.tx_bytes; peak_pciec_led_work()
314 peak_pciec_write_pca9553(card, 5, new_led); peak_pciec_led_work()
318 schedule_delayed_work(&card->led_work, HZ); peak_pciec_led_work()
324 static void peak_pciec_set_leds(struct peak_pciec_card *card, u8 led_mask, u8 s) peak_pciec_set_leds() argument
326 u8 new_led = card->led_cache; peak_pciec_set_leds()
330 for (i = 0; i < card->chan_count; i++) peak_pciec_set_leds()
337 peak_pciec_write_pca9553(card, 5, new_led); peak_pciec_set_leds()
343 static void peak_pciec_start_led_work(struct peak_pciec_card *card) peak_pciec_start_led_work() argument
345 schedule_delayed_work(&card->led_work, HZ); peak_pciec_start_led_work()
351 static void peak_pciec_stop_led_work(struct peak_pciec_card *card) peak_pciec_stop_led_work() argument
353 cancel_delayed_work_sync(&card->led_work); peak_pciec_stop_led_work()
359 static int peak_pciec_init_leds(struct peak_pciec_card *card) peak_pciec_init_leds() argument
364 err = peak_pciec_write_pca9553(card, 1, 44 / 1); peak_pciec_init_leds()
369 err = peak_pciec_write_pca9553(card, 2, 0x80); peak_pciec_init_leds()
374 err = peak_pciec_write_pca9553(card, 3, 44 / 5); peak_pciec_init_leds()
379 err = peak_pciec_write_pca9553(card, 4, 0x80); peak_pciec_init_leds()
384 return peak_pciec_write_pca9553(card, 5, PCA9553_LS0_INIT); peak_pciec_init_leds()
390 static void peak_pciec_leds_exit(struct peak_pciec_card *card) peak_pciec_leds_exit() argument
393 peak_pciec_write_pca9553(card, 5, PCA9553_LED_OFF_ALL); peak_pciec_leds_exit()
404 struct peak_pciec_card *card = chan->pciec_card; peak_pciec_write_reg() local
405 int c = (priv->reg_base - card->reg_base) / PEAK_PCI_CHAN_SIZE; peak_pciec_write_reg()
412 peak_pciec_set_leds(card, PCA9553_LED(c), PCA9553_ON); peak_pciec_write_reg()
416 peak_pciec_set_leds(card, PCA9553_LED(c), PCA9553_SLOW); peak_pciec_write_reg()
417 peak_pciec_start_led_work(card); peak_pciec_write_reg()
440 struct peak_pciec_card *card; peak_pciec_probe() local
448 card = prev_chan->pciec_card; peak_pciec_probe()
449 if (!card) peak_pciec_probe()
455 card = kzalloc(sizeof(struct peak_pciec_card), GFP_KERNEL); peak_pciec_probe()
456 if (!card) peak_pciec_probe()
459 card->cfg_base = chan->cfg_base; peak_pciec_probe()
460 card->reg_base = priv->reg_base; peak_pciec_probe()
462 card->led_chip.owner = THIS_MODULE; peak_pciec_probe()
463 card->led_chip.dev.parent = &pdev->dev; peak_pciec_probe()
464 card->led_chip.algo_data = &card->i2c_bit; peak_pciec_probe()
465 strncpy(card->led_chip.name, "peak_i2c", peak_pciec_probe()
466 sizeof(card->led_chip.name)); peak_pciec_probe()
468 card->i2c_bit = peak_pciec_i2c_bit_ops; peak_pciec_probe()
469 card->i2c_bit.udelay = 10; peak_pciec_probe()
470 card->i2c_bit.timeout = HZ; peak_pciec_probe()
471 card->i2c_bit.data = card; peak_pciec_probe()
473 peak_pciec_init_pita_gpio(card); peak_pciec_probe()
475 err = i2c_bit_add_bus(&card->led_chip); peak_pciec_probe()
481 err = peak_pciec_init_leds(card); peak_pciec_probe()
487 INIT_DELAYED_WORK(&card->led_work, peak_pciec_led_work); peak_pciec_probe()
492 chan->pciec_card = card; peak_pciec_probe()
493 card->channel[card->chan_count++].netdev = dev; peak_pciec_probe()
498 i2c_del_adapter(&card->led_chip); peak_pciec_probe()
501 peak_pciec_init_pita_gpio(card); peak_pciec_probe()
502 kfree(card); peak_pciec_probe()
507 static void peak_pciec_remove(struct peak_pciec_card *card) peak_pciec_remove() argument
509 peak_pciec_stop_led_work(card); peak_pciec_remove()
510 peak_pciec_leds_exit(card); peak_pciec_remove()
511 i2c_del_adapter(&card->led_chip); peak_pciec_remove()
512 peak_pciec_init_pita_gpio(card); peak_pciec_remove()
513 kfree(card); peak_pciec_remove()
526 static inline void peak_pciec_remove(struct peak_pciec_card *card) peak_pciec_remove() argument
606 /* Enable all channels of this card */ peak_pci_probe()
H A Dems_pcmcia.c32 MODULE_SUPPORTED_DEVICE("EMS CPC-CARD CAN card");
67 #define EMS_CMD_RESET 0x00 /* Perform a reset of the card */
68 #define EMS_CMD_MAP 0x03 /* Map CAN controllers into card' memory */
69 #define EMS_CMD_UMAP 0x02 /* Unmap CAN controllers from card' memory */
92 struct ems_pcmcia_card *card = dev_id; ems_pcmcia_interrupt() local
98 if (readw(card->base_addr) != 0xAA55) ems_pcmcia_interrupt()
105 for (i = 0; i < card->channels; i++) { ems_pcmcia_interrupt()
106 dev = card->net_dev[i]; ems_pcmcia_interrupt()
141 struct ems_pcmcia_card *card = pdev->priv; ems_pcmcia_del_card() local
145 free_irq(pdev->irq, card); ems_pcmcia_del_card()
147 for (i = 0; i < card->channels; i++) { ems_pcmcia_del_card()
148 dev = card->net_dev[i]; ems_pcmcia_del_card()
158 writeb(EMS_CMD_UMAP, card->base_addr); ems_pcmcia_del_card()
159 iounmap(card->base_addr); ems_pcmcia_del_card()
160 kfree(card); ems_pcmcia_del_card()
173 struct ems_pcmcia_card *card; ems_pcmcia_add_card() local
176 /* Allocating card structures to hold addresses, ... */ ems_pcmcia_add_card()
177 card = kzalloc(sizeof(struct ems_pcmcia_card), GFP_KERNEL); ems_pcmcia_add_card()
178 if (!card) ems_pcmcia_add_card()
181 pdev->priv = card; ems_pcmcia_add_card()
182 card->channels = 0; ems_pcmcia_add_card()
184 card->base_addr = ioremap(base, EMS_PCMCIA_MEM_SIZE); ems_pcmcia_add_card()
185 if (!card->base_addr) { ems_pcmcia_add_card()
191 if (readw(card->base_addr) != 0xAA55) { ems_pcmcia_add_card()
197 writeb(EMS_CMD_RESET, card->base_addr); ems_pcmcia_add_card()
199 /* Make sure CAN controllers are mapped into card's memory space */ ems_pcmcia_add_card()
200 writeb(EMS_CMD_MAP, card->base_addr); ems_pcmcia_add_card()
210 card->net_dev[i] = dev; ems_pcmcia_add_card()
212 priv->priv = card; ems_pcmcia_add_card()
218 priv->reg_base = card->base_addr + EMS_PCMCIA_CAN_BASE_OFFSET + ems_pcmcia_add_card()
237 card->channels++; ems_pcmcia_add_card()
247 DRV_NAME, card); ems_pcmcia_add_card()
H A Dplx_pci.c308 /* IXXAT PC-I 04/PCI card */
315 /* Marathon CAN-bus-PCI card */
322 /* TEWS TECHNOLOGIES TPMC810 card */
329 /* Connect Tech Inc. CANpro/104-Plus Opto (CRG001) card */
397 struct plx_pci_card *card = pci_get_drvdata(pdev); plx_pci_reset_common() local
400 cntrl = ioread32(card->conf_addr + PLX_CNTRL); plx_pci_reset_common()
402 iowrite32(cntrl, card->conf_addr + PLX_CNTRL); plx_pci_reset_common()
405 iowrite32(cntrl, card->conf_addr + PLX_CNTRL); plx_pci_reset_common()
414 struct plx_pci_card *card = pci_get_drvdata(pdev); plx9056_pci_reset_common() local
418 cntrl = ioread32(card->conf_addr + PLX9056_CNTRL); plx9056_pci_reset_common()
420 iowrite32(cntrl, card->conf_addr + PLX9056_CNTRL); plx9056_pci_reset_common()
423 iowrite32(cntrl, card->conf_addr + PLX9056_CNTRL); plx9056_pci_reset_common()
427 iowrite32(cntrl, card->conf_addr + PLX9056_CNTRL); plx9056_pci_reset_common()
437 iowrite32(cntrl, card->conf_addr + PLX9056_CNTRL); plx9056_pci_reset_common()
440 /* Special reset function for Marathon card */ plx_pci_reset_marathon()
465 struct plx_pci_card *card = pci_get_drvdata(pdev); plx_pci_del_card() local
471 dev = card->net_dev[i]; plx_pci_del_card()
483 card->reset_func(pdev); plx_pci_del_card()
486 * Disable interrupts from PCI-card and disable local plx_pci_del_card()
490 iowrite32(0x0, card->conf_addr + PLX_INTCSR); plx_pci_del_card()
492 iowrite32(0x0, card->conf_addr + PLX9056_INTCSR); plx_pci_del_card()
494 if (card->conf_addr) plx_pci_del_card()
495 pci_iounmap(pdev, card->conf_addr); plx_pci_del_card()
497 kfree(card); plx_pci_del_card()
511 struct plx_pci_card *card; plx_pci_add_card() local
524 dev_info(&pdev->dev, "Detected \"%s\" card at slot #%i\n", plx_pci_add_card()
527 /* Allocate card structures to hold addresses, ... */ plx_pci_add_card()
528 card = kzalloc(sizeof(*card), GFP_KERNEL); plx_pci_add_card()
529 if (!card) { plx_pci_add_card()
534 pci_set_drvdata(pdev, card); plx_pci_add_card()
536 card->channels = 0; plx_pci_add_card()
546 card->conf_addr = addr + ci->conf_map.offset; plx_pci_add_card()
549 card->reset_func = ci->reset_func; plx_pci_add_card()
561 card->net_dev[i] = dev; plx_pci_add_card()
563 priv->priv = card; plx_pci_add_card()
600 card->channels++; plx_pci_add_card()
609 card->net_dev[i] = NULL; plx_pci_add_card()
613 if (!card->channels) { plx_pci_add_card()
619 * Enable interrupts from PCI-card (PLX90xx) and enable Local_1, plx_pci_add_card()
623 val = ioread32(card->conf_addr + PLX_INTCSR); plx_pci_add_card()
628 iowrite32(val, card->conf_addr + PLX_INTCSR); plx_pci_add_card()
631 card->conf_addr + PLX9056_INTCSR); plx_pci_add_card()
/linux-4.1.27/drivers/net/ethernet/brocade/bna/
H A Dbfa_defs_mfg_comm.h40 /* Manufacturing card type */
42 BFA_MFG_TYPE_CB_MAX = 825, /*!< Crossbow card type max */
43 BFA_MFG_TYPE_FC8P2 = 825, /*!< 8G 2port FC card */
44 BFA_MFG_TYPE_FC8P1 = 815, /*!< 8G 1port FC card */
45 BFA_MFG_TYPE_FC4P2 = 425, /*!< 4G 2port FC card */
46 BFA_MFG_TYPE_FC4P1 = 415, /*!< 4G 1port FC card */
47 BFA_MFG_TYPE_CNA10P2 = 1020, /*!< 10G 2port CNA card */
48 BFA_MFG_TYPE_CNA10P1 = 1010, /*!< 10G 1port CNA card */
49 BFA_MFG_TYPE_JAYHAWK = 804, /*!< Jayhawk mezz card */
50 BFA_MFG_TYPE_WANCHESE = 1007, /*!< Wanchese mezz card */
51 BFA_MFG_TYPE_ASTRA = 807, /*!< Astra mezz card */
52 BFA_MFG_TYPE_LIGHTNING_P0 = 902, /*!< Lightning mezz card - old */
53 BFA_MFG_TYPE_LIGHTNING = 1741, /*!< Lightning mezz card */
59 BFA_MFG_TYPE_INVALID = 0, /*!< Invalid card type */
64 /* Check if Mezz card */
75 CB_GPIO_FC8P2 = (2), /*!< 8G 2port FC card */
76 CB_GPIO_FC8P1 = (3), /*!< 8G 1port FC card */
77 CB_GPIO_FC4P2 = (4), /*!< 4G 2port FC card */
78 CB_GPIO_FC4P1 = (5), /*!< 4G 1port FC card */
79 CB_GPIO_DFLY = (6), /*!< 8G 2port FC mezzanine card */
/linux-4.1.27/sound/soc/qcom/
H A Dstorm.c31 struct snd_soc_card *card = soc_runtime->card; storm_ops_hw_params() local
39 dev_err(card->dev, "%s() invalid bit width given: %d\n", storm_ops_hw_params()
53 dev_err(card->dev, "%s() error setting sysclk to %u: %d\n", storm_ops_hw_params()
77 static int storm_parse_of(struct snd_soc_card *card) storm_parse_of() argument
79 struct snd_soc_dai_link *dai_link = card->dai_link; storm_parse_of()
80 struct device_node *np = card->dev->of_node; storm_parse_of()
84 dev_err(card->dev, "%s() error getting cpu phandle\n", storm_parse_of()
92 dev_err(card->dev, "%s() error getting codec phandle\n", storm_parse_of()
102 struct snd_soc_card *card = &storm_soc_card; storm_platform_probe() local
105 if (card->dev) { storm_platform_probe()
110 card->dev = &pdev->dev; storm_platform_probe()
111 platform_set_drvdata(pdev, card); storm_platform_probe()
113 ret = snd_soc_of_parse_card_name(card, "qcom,model"); storm_platform_probe()
115 dev_err(&pdev->dev, "%s() error parsing card name: %d\n", storm_platform_probe()
120 card->dai_link = &storm_dai_link; storm_platform_probe()
121 card->num_links = 1; storm_platform_probe()
123 ret = storm_parse_of(card); storm_platform_probe()
130 ret = devm_snd_soc_register_card(&pdev->dev, card); storm_platform_probe()
132 card->dev = NULL; storm_platform_probe()
/linux-4.1.27/sound/ppc/
H A Dsnd_ps3.c119 static int snd_ps3_verify_dma_stop(struct snd_ps3_card_info *card, snd_ps3_verify_dma_stop() argument
157 * NOTE: caller should reset card->running before call.
161 static void snd_ps3_wait_for_dma_stop(struct snd_ps3_card_info *card) snd_ps3_wait_for_dma_stop() argument
173 stop_forced = snd_ps3_verify_dma_stop(card, 700, 1); snd_ps3_wait_for_dma_stop()
190 static void snd_ps3_kick_dma(struct snd_ps3_card_info *card) snd_ps3_kick_dma() argument
201 static dma_addr_t v_to_bus(struct snd_ps3_card_info *card, void *paddr, int ch) v_to_bus() argument
203 return card->dma_start_bus_addr[ch] + v_to_bus()
204 (paddr - card->dma_start_vaddr[ch]); v_to_bus()
212 static void snd_ps3_bump_buffer(struct snd_ps3_card_info *card, snd_ps3_bump_buffer() argument
217 card->dma_last_transfer_vaddr[ch] = snd_ps3_bump_buffer()
218 card->dma_next_transfer_vaddr[ch]; snd_ps3_bump_buffer()
219 card->dma_next_transfer_vaddr[ch] += byte_count; snd_ps3_bump_buffer()
220 if ((card->dma_start_vaddr[ch] + (card->dma_buffer_size / 2)) <= snd_ps3_bump_buffer()
221 card->dma_next_transfer_vaddr[ch]) { snd_ps3_bump_buffer()
222 card->dma_next_transfer_vaddr[ch] = card->dma_start_vaddr[ch]; snd_ps3_bump_buffer()
228 static int snd_ps3_program_dma(struct snd_ps3_card_info *card, snd_ps3_program_dma() argument
256 snd_ps3_verify_dma_stop(card, 700, 0); snd_ps3_program_dma()
258 spin_lock_irqsave(&card->dma_lock, irqsave); snd_ps3_program_dma()
260 start_vaddr = card->dma_next_transfer_vaddr[0]; snd_ps3_program_dma()
264 dma_addr = card->null_buffer_start_dma_addr; snd_ps3_program_dma()
267 v_to_bus(card, snd_ps3_program_dma()
268 card->dma_next_transfer_vaddr[ch], snd_ps3_program_dma()
289 snd_ps3_bump_buffer(card, ch, snd_ps3_program_dma()
306 spin_unlock_irqrestore(&card->dma_lock, irqsave); snd_ps3_program_dma()
319 struct snd_ps3_card_info *card = dev_id; snd_ps3_interrupt() local
321 if (!card->running) { snd_ps3_interrupt()
338 if (card->silent) { snd_ps3_interrupt()
340 snd_ps3_program_dma(card, snd_ps3_interrupt()
344 snd_ps3_kick_dma(card); snd_ps3_interrupt()
345 card->silent--; snd_ps3_interrupt()
347 snd_ps3_program_dma(card, snd_ps3_interrupt()
351 snd_ps3_kick_dma(card); snd_ps3_interrupt()
352 snd_pcm_period_elapsed(card->substream); snd_ps3_interrupt()
365 snd_ps3_program_dma(card, snd_ps3_interrupt()
367 snd_ps3_kick_dma(card); snd_ps3_interrupt()
368 snd_ps3_program_dma(card, snd_ps3_interrupt()
370 snd_ps3_kick_dma(card); snd_ps3_interrupt()
390 static int snd_ps3_change_avsetting(struct snd_ps3_card_info *card) snd_ps3_change_avsetting() argument
395 ret = ps3av_set_audio_mode(card->avs.avs_audio_ch, snd_ps3_change_avsetting()
396 card->avs.avs_audio_rate, snd_ps3_change_avsetting()
397 card->avs.avs_audio_width, snd_ps3_change_avsetting()
398 card->avs.avs_audio_format, snd_ps3_change_avsetting()
399 card->avs.avs_audio_source); snd_ps3_change_avsetting()
454 struct snd_ps3_card_info *card = snd_pcm_substream_chip(substream); snd_ps3_set_avsetting() local
458 avs = card->avs; snd_ps3_set_avsetting()
465 card->avs.avs_audio_rate, card->avs.avs_audio_width); snd_ps3_set_avsetting()
503 if (memcmp(&card->avs, &avs, sizeof(avs))) { snd_ps3_set_avsetting()
505 card->avs.avs_audio_rate, card->avs.avs_audio_width); snd_ps3_set_avsetting()
507 card->avs = avs; snd_ps3_set_avsetting()
508 snd_ps3_change_avsetting(card); snd_ps3_set_avsetting()
528 struct snd_ps3_card_info *card = snd_pcm_substream_chip(substream); snd_ps3_pcm_open() local
533 card->substream = substream; snd_ps3_pcm_open()
537 card->start_delay = snd_ps3_start_delay; snd_ps3_pcm_open()
597 struct snd_ps3_card_info *card = snd_pcm_substream_chip(substream); snd_ps3_pcm_prepare() local
609 card->silent = snd_ps3_delay_to_bytes(substream, snd_ps3_pcm_prepare()
610 card->start_delay) / snd_ps3_pcm_prepare()
615 spin_lock_irqsave(&card->dma_lock, irqsave); snd_ps3_pcm_prepare()
617 card->dma_buffer_size = runtime->dma_bytes; snd_ps3_pcm_prepare()
619 card->dma_last_transfer_vaddr[SND_PS3_CH_L] = snd_ps3_pcm_prepare()
620 card->dma_next_transfer_vaddr[SND_PS3_CH_L] = snd_ps3_pcm_prepare()
621 card->dma_start_vaddr[SND_PS3_CH_L] = snd_ps3_pcm_prepare()
623 card->dma_start_bus_addr[SND_PS3_CH_L] = runtime->dma_addr; snd_ps3_pcm_prepare()
625 card->dma_last_transfer_vaddr[SND_PS3_CH_R] = snd_ps3_pcm_prepare()
626 card->dma_next_transfer_vaddr[SND_PS3_CH_R] = snd_ps3_pcm_prepare()
627 card->dma_start_vaddr[SND_PS3_CH_R] = snd_ps3_pcm_prepare()
629 card->dma_start_bus_addr[SND_PS3_CH_R] = snd_ps3_pcm_prepare()
633 card->dma_start_vaddr[SND_PS3_CH_L], snd_ps3_pcm_prepare()
634 card->dma_start_bus_addr[SND_PS3_CH_L]); snd_ps3_pcm_prepare()
637 spin_unlock_irqrestore(&card->dma_lock, irqsave); snd_ps3_pcm_prepare()
648 struct snd_ps3_card_info *card = snd_pcm_substream_chip(substream); snd_ps3_pcm_trigger() local
656 spin_lock(&card->dma_lock); snd_ps3_pcm_trigger()
658 card->running = 1; snd_ps3_pcm_trigger()
660 spin_unlock(&card->dma_lock); snd_ps3_pcm_trigger()
662 snd_ps3_program_dma(card, snd_ps3_pcm_trigger()
664 snd_ps3_kick_dma(card); snd_ps3_pcm_trigger()
669 snd_ps3_program_dma(card, SND_PS3_DMA_FILLTYPE_SILENT_RUNNING); snd_ps3_pcm_trigger()
670 snd_ps3_kick_dma(card); snd_ps3_pcm_trigger()
674 spin_lock(&card->dma_lock); snd_ps3_pcm_trigger()
676 card->running = 0; snd_ps3_pcm_trigger()
678 spin_unlock(&card->dma_lock); snd_ps3_pcm_trigger()
679 snd_ps3_wait_for_dma_stop(card); snd_ps3_pcm_trigger()
695 struct snd_ps3_card_info *card = snd_pcm_substream_chip(substream); snd_ps3_pcm_pointer() local
699 spin_lock(&card->dma_lock); snd_ps3_pcm_pointer()
701 bytes = (size_t)(card->dma_last_transfer_vaddr[SND_PS3_CH_L] - snd_ps3_pcm_pointer()
702 card->dma_start_vaddr[SND_PS3_CH_L]); snd_ps3_pcm_pointer()
704 spin_unlock(&card->dma_lock); snd_ps3_pcm_pointer()
885 static void snd_ps3_audio_fixup(struct snd_ps3_card_info *card) snd_ps3_audio_fixup() argument
909 static int snd_ps3_init_avsetting(struct snd_ps3_card_info *card) snd_ps3_init_avsetting() argument
913 card->avs.avs_audio_ch = PS3AV_CMD_AUDIO_NUM_OF_CH_2; snd_ps3_init_avsetting()
914 card->avs.avs_audio_rate = PS3AV_CMD_AUDIO_FS_48K; snd_ps3_init_avsetting()
915 card->avs.avs_audio_width = PS3AV_CMD_AUDIO_WORD_BITS_16; snd_ps3_init_avsetting()
916 card->avs.avs_audio_format = PS3AV_CMD_AUDIO_FORMAT_PCM; snd_ps3_init_avsetting()
917 card->avs.avs_audio_source = PS3AV_CMD_AUDIO_SOURCE_SERIAL; snd_ps3_init_avsetting()
918 memcpy(card->avs.avs_cs_info, ps3av_mode_cs_info, 8); snd_ps3_init_avsetting()
920 ret = snd_ps3_change_avsetting(card); snd_ps3_init_avsetting()
922 snd_ps3_audio_fixup(card); snd_ps3_init_avsetting()
925 snd_ps3_program_dma(card, SND_PS3_DMA_FILLTYPE_SILENT_FIRSTFILL); snd_ps3_init_avsetting()
926 snd_ps3_kick_dma(card); snd_ps3_init_avsetting()
986 /* create card instance */ snd_ps3_driver_probe()
988 0, &the_card.card); snd_ps3_driver_probe()
992 strcpy(the_card.card->driver, "PS3"); snd_ps3_driver_probe()
993 strcpy(the_card.card->shortname, "PS3"); snd_ps3_driver_probe()
994 strcpy(the_card.card->longname, "PS3 sound"); snd_ps3_driver_probe()
998 ret = snd_ctl_add(the_card.card, snd_ps3_driver_probe()
1006 ret = snd_pcm_new(the_card.card, snd_ps3_driver_probe()
1055 /* register the card */ snd_ps3_driver_probe()
1056 ret = snd_card_register(the_card.card); snd_ps3_driver_probe()
1061 the_card.card->longname, the_card.start_delay); snd_ps3_driver_probe()
1070 snd_card_free(the_card.card); snd_ps3_driver_probe()
1083 * midlayer automatically releases if the card removed snd_ps3_driver_probe()
1100 ret = snd_card_free(the_card.card); snd_ps3_driver_remove()
H A Dpowermac.c38 static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */
56 struct snd_card *card; snd_pmac_probe() local
61 err = snd_card_new(&devptr->dev, index, id, THIS_MODULE, 0, &card); snd_pmac_probe()
65 if ((err = snd_pmac_new(card, &chip)) < 0) snd_pmac_probe()
67 card->private_data = chip; snd_pmac_probe()
71 strcpy(card->driver, "PMac Burgundy"); snd_pmac_probe()
72 strcpy(card->shortname, "PowerMac Burgundy"); snd_pmac_probe()
73 sprintf(card->longname, "%s (Dev %d) Sub-frame %d", snd_pmac_probe()
74 card->shortname, chip->device_id, chip->subframe); snd_pmac_probe()
79 strcpy(card->driver, "PMac DACA"); snd_pmac_probe()
80 strcpy(card->shortname, "PowerMac DACA"); snd_pmac_probe()
81 sprintf(card->longname, "%s (Dev %d) Sub-frame %d", snd_pmac_probe()
82 card->shortname, chip->device_id, chip->subframe); snd_pmac_probe()
89 sprintf(card->driver, "PMac %s", name_ext); snd_pmac_probe()
90 sprintf(card->shortname, "PowerMac %s", name_ext); snd_pmac_probe()
91 sprintf(card->longname, "%s (Dev %d) Sub-frame %d", snd_pmac_probe()
92 card->shortname, chip->device_id, chip->subframe); snd_pmac_probe()
99 sprintf(card->driver, "PMac %s", name_ext); snd_pmac_probe()
100 sprintf(card->shortname, "PowerMac %s", name_ext); snd_pmac_probe()
107 sprintf(card->longname, "%s%s Rev %d", snd_pmac_probe()
108 card->shortname, name_ext, chip->revision); snd_pmac_probe()
125 if ((err = snd_card_register(card)) < 0) snd_pmac_probe()
128 platform_set_drvdata(devptr, card); snd_pmac_probe()
132 snd_card_free(card); snd_pmac_probe()
146 struct snd_card *card = dev_get_drvdata(dev); snd_pmac_driver_suspend() local
147 snd_pmac_suspend(card->private_data); snd_pmac_driver_suspend()
153 struct snd_card *card = dev_get_drvdata(dev); snd_pmac_driver_resume() local
154 snd_pmac_resume(card->private_data); snd_pmac_driver_resume()
/linux-4.1.27/sound/isa/es1688/
H A Des1688.c52 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
56 static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */
98 static int snd_es1688_legacy_create(struct snd_card *card, snd_es1688_legacy_create() argument
101 struct snd_es1688 *chip = card->private_data; snd_es1688_legacy_create()
124 return snd_es1688_create(card, chip, port[n], mpu_port[n], snd_es1688_legacy_create()
130 error = snd_es1688_create(card, chip, port[n], mpu_port[n], snd_es1688_legacy_create()
137 static int snd_es1688_probe(struct snd_card *card, unsigned int n) snd_es1688_probe() argument
139 struct snd_es1688 *chip = card->private_data; snd_es1688_probe()
143 error = snd_es1688_pcm(card, chip, 0); snd_es1688_probe()
147 error = snd_es1688_mixer(card, chip); snd_es1688_probe()
151 strlcpy(card->driver, "ES1688", sizeof(card->driver)); snd_es1688_probe()
152 strlcpy(card->shortname, chip->pcm->name, sizeof(card->shortname)); snd_es1688_probe()
153 snprintf(card->longname, sizeof(card->longname), snd_es1688_probe()
161 if (snd_opl3_create(card, fm_port[n], fm_port[n] + 2, snd_es1688_probe()
163 dev_warn(card->dev, snd_es1688_probe()
174 error = snd_mpu401_uart_new(card, 0, MPU401_HW_ES1688, snd_es1688_probe()
181 return snd_card_register(card); snd_es1688_probe()
186 struct snd_card *card; snd_es1688_isa_probe() local
190 sizeof(struct snd_es1688), &card); snd_es1688_isa_probe()
194 error = snd_es1688_legacy_create(card, dev, n); snd_es1688_isa_probe()
198 error = snd_es1688_probe(card, n); snd_es1688_isa_probe()
202 dev_set_drvdata(dev, card); snd_es1688_isa_probe()
206 snd_card_free(card); snd_es1688_isa_probe()
232 static int snd_card_es968_pnp(struct snd_card *card, unsigned int n, snd_card_es968_pnp() argument
236 struct snd_es1688 *chip = card->private_data; snd_card_es968_pnp()
253 return snd_es1688_create(card, chip, port[n], mpu_port[n], irq[n], snd_card_es968_pnp()
260 struct snd_card *card; snd_es968_pnp_detect() local
274 error = snd_card_new(&pcard->card->dev, snd_es968_pnp_detect()
276 sizeof(struct snd_es1688), &card); snd_es968_pnp_detect()
279 chip = card->private_data; snd_es968_pnp_detect()
281 error = snd_card_es968_pnp(card, dev, pcard, pid); snd_es968_pnp_detect()
283 snd_card_free(card); snd_es968_pnp_detect()
286 error = snd_es1688_probe(card, dev); snd_es968_pnp_detect()
289 pnp_set_card_drvdata(pcard, card); snd_es968_pnp_detect()
305 struct snd_card *card = pnp_get_card_drvdata(pcard); snd_es968_pnp_suspend() local
306 struct snd_es1688 *chip = card->private_data; snd_es968_pnp_suspend()
308 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); snd_es968_pnp_suspend()
315 struct snd_card *card = pnp_get_card_drvdata(pcard); snd_es968_pnp_resume() local
316 struct snd_es1688 *chip = card->private_data; snd_es968_pnp_resume()
319 snd_power_change_state(card, SNDRV_CTL_POWER_D0); snd_es968_pnp_resume()
/linux-4.1.27/include/trace/events/
H A Dasoc.h20 TP_PROTO(struct snd_soc_card *card, int val),
22 TP_ARGS(card, val),
25 __string( name, card->name )
30 __assign_str(name, card->name);
34 TP_printk("card=%s val=%d", __get_str(name), (int)__entry->val)
39 TP_PROTO(struct snd_soc_card *card, int val),
41 TP_ARGS(card, val)
47 TP_PROTO(struct snd_soc_card *card, int val),
49 TP_ARGS(card, val)
55 TP_PROTO(struct snd_soc_card *card),
57 TP_ARGS(card),
60 __string( name, card->name )
64 __assign_str(name, card->name);
67 TP_printk("card=%s", __get_str(name))
72 TP_PROTO(struct snd_soc_card *card),
74 TP_ARGS(card)
80 TP_PROTO(struct snd_soc_card *card),
82 TP_ARGS(card)
132 TP_PROTO(struct snd_soc_card *card),
134 TP_ARGS(card),
137 __string( name, card->name )
144 __assign_str(name, card->name);
145 __entry->power_checks = card->dapm_stats.power_checks;
146 __entry->path_checks = card->dapm_stats.path_checks;
147 __entry->neighbour_checks = card->dapm_stats.neighbour_checks;
/linux-4.1.27/sound/soc/
H A Dsoc-core.c295 if (!component->card->debugfs_card_root) soc_init_component_debugfs()
305 component->card->debugfs_card_root); soc_init_component_debugfs()
310 component->card->debugfs_card_root); soc_init_component_debugfs()
459 static void soc_init_card_debugfs(struct snd_soc_card *card) soc_init_card_debugfs() argument
464 card->debugfs_card_root = debugfs_create_dir(card->name, soc_init_card_debugfs()
466 if (!card->debugfs_card_root) { soc_init_card_debugfs()
467 dev_warn(card->dev, soc_init_card_debugfs()
468 "ASoC: Failed to create card debugfs directory\n"); soc_init_card_debugfs()
472 card->debugfs_pop_time = debugfs_create_u32("dapm_pop_time", 0644, soc_init_card_debugfs()
473 card->debugfs_card_root, soc_init_card_debugfs()
474 &card->pop_time); soc_init_card_debugfs()
475 if (!card->debugfs_pop_time) soc_init_card_debugfs()
476 dev_warn(card->dev, soc_init_card_debugfs()
480 static void soc_cleanup_card_debugfs(struct snd_soc_card *card) soc_cleanup_card_debugfs() argument
482 debugfs_remove_recursive(card->debugfs_card_root); soc_cleanup_card_debugfs()
527 static inline void soc_init_card_debugfs(struct snd_soc_card *card) soc_init_card_debugfs() argument
531 static inline void soc_cleanup_card_debugfs(struct snd_soc_card *card) soc_cleanup_card_debugfs() argument
545 struct snd_pcm_substream *snd_soc_get_dai_substream(struct snd_soc_card *card, snd_soc_get_dai_substream() argument
550 for (i = 0; i < card->num_links; i++) { snd_soc_get_dai_substream()
551 if (card->rtd[i].dai_link->no_pcm && snd_soc_get_dai_substream()
552 !strcmp(card->rtd[i].dai_link->name, dai_link)) snd_soc_get_dai_substream()
553 return card->rtd[i].pcm->streams[stream].substream; snd_soc_get_dai_substream()
555 dev_dbg(card->dev, "ASoC: failed to find dai link %s\n", dai_link); snd_soc_get_dai_substream()
560 struct snd_soc_pcm_runtime *snd_soc_get_pcm_runtime(struct snd_soc_card *card, snd_soc_get_pcm_runtime() argument
565 for (i = 0; i < card->num_links; i++) { snd_soc_get_pcm_runtime()
566 if (!strcmp(card->rtd[i].dai_link->name, dai_link)) snd_soc_get_pcm_runtime()
567 return &card->rtd[i]; snd_soc_get_pcm_runtime()
569 dev_dbg(card->dev, "ASoC: failed to find rtd %s\n", dai_link); snd_soc_get_pcm_runtime()
587 struct snd_soc_card *card = dev_get_drvdata(dev); snd_soc_suspend() local
591 /* If the card is not initialized yet there is nothing to do */ snd_soc_suspend()
592 if (!card->instantiated) snd_soc_suspend()
598 snd_power_lock(card->snd_card); snd_soc_suspend()
599 snd_power_wait(card->snd_card, SNDRV_CTL_POWER_D0); snd_soc_suspend()
600 snd_power_unlock(card->snd_card); snd_soc_suspend()
603 snd_power_change_state(card->snd_card, SNDRV_CTL_POWER_D3hot); snd_soc_suspend()
606 for (i = 0; i < card->num_rtd; i++) { snd_soc_suspend()
608 if (card->rtd[i].dai_link->ignore_suspend) snd_soc_suspend()
611 for (j = 0; j < card->rtd[i].num_codecs; j++) { snd_soc_suspend()
612 struct snd_soc_dai *dai = card->rtd[i].codec_dais[j]; snd_soc_suspend()
621 for (i = 0; i < card->num_rtd; i++) { snd_soc_suspend()
622 if (card->rtd[i].dai_link->ignore_suspend) snd_soc_suspend()
625 snd_pcm_suspend_all(card->rtd[i].pcm); snd_soc_suspend()
628 if (card->suspend_pre) snd_soc_suspend()
629 card->suspend_pre(card); snd_soc_suspend()
631 for (i = 0; i < card->num_rtd; i++) { snd_soc_suspend()
632 struct snd_soc_dai *cpu_dai = card->rtd[i].cpu_dai; snd_soc_suspend()
634 if (card->rtd[i].dai_link->ignore_suspend) snd_soc_suspend()
642 for (i = 0; i < card->num_rtd; i++) snd_soc_suspend()
643 flush_delayed_work(&card->rtd[i].delayed_work); snd_soc_suspend()
645 for (i = 0; i < card->num_rtd; i++) { snd_soc_suspend()
647 if (card->rtd[i].dai_link->ignore_suspend) snd_soc_suspend()
650 snd_soc_dapm_stream_event(&card->rtd[i], snd_soc_suspend()
654 snd_soc_dapm_stream_event(&card->rtd[i], snd_soc_suspend()
660 dapm_mark_endpoints_dirty(card); snd_soc_suspend()
661 snd_soc_dapm_sync(&card->dapm); snd_soc_suspend()
664 list_for_each_entry(codec, &card->codec_dev_list, card_list) { snd_soc_suspend()
699 for (i = 0; i < card->num_rtd; i++) { snd_soc_suspend()
700 struct snd_soc_dai *cpu_dai = card->rtd[i].cpu_dai; snd_soc_suspend()
702 if (card->rtd[i].dai_link->ignore_suspend) snd_soc_suspend()
712 if (card->suspend_post) snd_soc_suspend()
713 card->suspend_post(card); snd_soc_suspend()
724 struct snd_soc_card *card = soc_resume_deferred() local
733 dev_dbg(card->dev, "ASoC: starting resume work\n"); soc_resume_deferred()
736 snd_power_change_state(card->snd_card, SNDRV_CTL_POWER_D2); soc_resume_deferred()
738 if (card->resume_pre) soc_resume_deferred()
739 card->resume_pre(card); soc_resume_deferred()
742 for (i = 0; i < card->num_rtd; i++) { soc_resume_deferred()
743 struct snd_soc_dai *cpu_dai = card->rtd[i].cpu_dai; soc_resume_deferred()
745 if (card->rtd[i].dai_link->ignore_suspend) soc_resume_deferred()
752 list_for_each_entry(codec, &card->codec_dev_list, card_list) { soc_resume_deferred()
773 for (i = 0; i < card->num_rtd; i++) { soc_resume_deferred()
775 if (card->rtd[i].dai_link->ignore_suspend) soc_resume_deferred()
778 snd_soc_dapm_stream_event(&card->rtd[i], soc_resume_deferred()
782 snd_soc_dapm_stream_event(&card->rtd[i], soc_resume_deferred()
788 for (i = 0; i < card->num_rtd; i++) { soc_resume_deferred()
790 if (card->rtd[i].dai_link->ignore_suspend) soc_resume_deferred()
793 for (j = 0; j < card->rtd[i].num_codecs; j++) { soc_resume_deferred()
794 struct snd_soc_dai *dai = card->rtd[i].codec_dais[j]; soc_resume_deferred()
802 for (i = 0; i < card->num_rtd; i++) { soc_resume_deferred()
803 struct snd_soc_dai *cpu_dai = card->rtd[i].cpu_dai; soc_resume_deferred()
805 if (card->rtd[i].dai_link->ignore_suspend) soc_resume_deferred()
812 if (card->resume_post) soc_resume_deferred()
813 card->resume_post(card); soc_resume_deferred()
815 dev_dbg(card->dev, "ASoC: resume work completed\n"); soc_resume_deferred()
818 snd_power_change_state(card->snd_card, SNDRV_CTL_POWER_D0); soc_resume_deferred()
821 dapm_mark_endpoints_dirty(card); soc_resume_deferred()
822 snd_soc_dapm_sync(&card->dapm); soc_resume_deferred()
828 struct snd_soc_card *card = dev_get_drvdata(dev); snd_soc_resume() local
832 /* If the card is not initialized yet there is nothing to do */ snd_soc_resume()
833 if (!card->instantiated) snd_soc_resume()
837 for (i = 0; i < card->num_rtd; i++) { snd_soc_resume()
838 struct snd_soc_pcm_runtime *rtd = &card->rtd[i]; snd_soc_resume()
859 for (i = 0; i < card->num_rtd; i++) { snd_soc_resume()
860 struct snd_soc_dai *cpu_dai = card->rtd[i].cpu_dai; snd_soc_resume()
865 soc_resume_deferred(&card->deferred_resume_work); snd_soc_resume()
868 if (!schedule_work(&card->deferred_resume_work)) snd_soc_resume()
927 static int soc_bind_dai_link(struct snd_soc_card *card, int num) soc_bind_dai_link() argument
929 struct snd_soc_dai_link *dai_link = &card->dai_link[num]; soc_bind_dai_link()
930 struct snd_soc_pcm_runtime *rtd = &card->rtd[num]; soc_bind_dai_link()
938 dev_dbg(card->dev, "ASoC: binding %s at idx %d\n", dai_link->name, num); soc_bind_dai_link()
945 dev_err(card->dev, "ASoC: CPU DAI %s not registered\n", soc_bind_dai_link()
956 dev_err(card->dev, "ASoC: CODEC DAI %s not registered\n", soc_bind_dai_link()
985 dev_err(card->dev, "ASoC: platform %s not registered\n", soc_bind_dai_link()
990 card->num_rtd++; soc_bind_dai_link()
1031 static void soc_remove_link_dais(struct snd_soc_card *card, int num, int order) soc_remove_link_dais() argument
1033 struct snd_soc_pcm_runtime *rtd = &card->rtd[num]; soc_remove_link_dais()
1049 static void soc_remove_link_components(struct snd_soc_card *card, int num, soc_remove_link_components() argument
1052 struct snd_soc_pcm_runtime *rtd = &card->rtd[num]; soc_remove_link_components()
1076 static void soc_remove_dai_links(struct snd_soc_card *card) soc_remove_dai_links() argument
1082 for (dai = 0; dai < card->num_rtd; dai++) soc_remove_dai_links()
1083 soc_remove_link_dais(card, dai, order); soc_remove_dai_links()
1088 for (dai = 0; dai < card->num_rtd; dai++) soc_remove_dai_links()
1089 soc_remove_link_components(card, dai, order); soc_remove_dai_links()
1092 card->num_rtd = 0; soc_remove_dai_links()
1095 static void soc_set_name_prefix(struct snd_soc_card *card, soc_set_name_prefix() argument
1100 if (card->codec_conf == NULL) soc_set_name_prefix()
1103 for (i = 0; i < card->num_configs; i++) { soc_set_name_prefix()
1104 struct snd_soc_codec_conf *map = &card->codec_conf[i]; soc_set_name_prefix()
1114 static int soc_probe_component(struct snd_soc_card *card, soc_probe_component() argument
1124 component->card = card; soc_probe_component()
1125 dapm->card = card; soc_probe_component()
1126 soc_set_name_prefix(card, component); soc_probe_component()
1175 list_add(&dapm->list, &card->dapm_list); soc_probe_component()
1179 list_add(&component->codec->card_list, &card->codec_dev_list); soc_probe_component()
1205 rtd->dev->parent = rtd->card->dev; soc_post_component_init()
1219 dev_err(rtd->card->dev, soc_post_component_init()
1227 static int soc_probe_link_components(struct snd_soc_card *card, int num, soc_probe_link_components() argument
1230 struct snd_soc_pcm_runtime *rtd = &card->rtd[num]; soc_probe_link_components()
1238 ret = soc_probe_component(card, component); soc_probe_link_components()
1247 ret = soc_probe_component(card, component); soc_probe_link_components()
1255 ret = soc_probe_component(card, &platform->component); soc_probe_link_components()
1284 static int soc_link_dai_widgets(struct snd_soc_card *card, soc_link_dai_widgets() argument
1294 dev_warn(card->dev, "ASoC: Multiple codecs not supported yet\n"); soc_link_dai_widgets()
1300 ret = snd_soc_dapm_new_pcm(card, dai_link->params, soc_link_dai_widgets()
1304 dev_err(card->dev, "ASoC: Can't link %s to %s: %d\n", soc_link_dai_widgets()
1313 ret = snd_soc_dapm_new_pcm(card, dai_link->params, soc_link_dai_widgets()
1317 dev_err(card->dev, "ASoC: Can't link %s to %s: %d\n", soc_link_dai_widgets()
1326 static int soc_probe_link_dais(struct snd_soc_card *card, int num, int order) soc_probe_link_dais() argument
1328 struct snd_soc_dai_link *dai_link = &card->dai_link[num]; soc_probe_link_dais()
1329 struct snd_soc_pcm_runtime *rtd = &card->rtd[num]; soc_probe_link_dais()
1333 dev_dbg(card->dev, "ASoC: probe %s dai link %d late %d\n", soc_probe_link_dais()
1334 card->name, num, order); soc_probe_link_dais()
1358 dev_err(card->dev, "ASoC: failed to init %s: %d\n", soc_probe_link_dais()
1381 dev_err(card->dev, "ASoC: can't create compress %s\n", soc_probe_link_dais()
1391 dev_err(card->dev, "ASoC: can't create pcm %s :%d\n", soc_probe_link_dais()
1400 ret = soc_link_dai_widgets(card, dai_link, rtd); soc_probe_link_dais()
1409 static int soc_bind_aux_dev(struct snd_soc_card *card, int num) soc_bind_aux_dev() argument
1411 struct snd_soc_pcm_runtime *rtd = &card->rtd_aux[num]; soc_bind_aux_dev()
1412 struct snd_soc_aux_dev *aux_dev = &card->aux_dev[num]; soc_bind_aux_dev()
1420 dev_err(card->dev, "ASoC: %s not registered\n", name); soc_bind_aux_dev()
1434 static int soc_probe_aux_dev(struct snd_soc_card *card, int num) soc_probe_aux_dev() argument
1436 struct snd_soc_pcm_runtime *rtd = &card->rtd_aux[num]; soc_probe_aux_dev()
1437 struct snd_soc_aux_dev *aux_dev = &card->aux_dev[num]; soc_probe_aux_dev()
1440 ret = soc_probe_component(card, rtd->component); soc_probe_aux_dev()
1448 dev_err(card->dev, "ASoC: failed to init %s: %d\n", soc_probe_aux_dev()
1457 static void soc_remove_aux_dev(struct snd_soc_card *card, int num) soc_remove_aux_dev() argument
1459 struct snd_soc_pcm_runtime *rtd = &card->rtd_aux[num]; soc_remove_aux_dev()
1556 static int snd_soc_instantiate_card(struct snd_soc_card *card) snd_soc_instantiate_card() argument
1562 mutex_lock_nested(&card->mutex, SND_SOC_CARD_CLASS_INIT); snd_soc_instantiate_card()
1565 for (i = 0; i < card->num_links; i++) { snd_soc_instantiate_card()
1566 ret = soc_bind_dai_link(card, i); snd_soc_instantiate_card()
1572 for (i = 0; i < card->num_aux_devs; i++) { snd_soc_instantiate_card()
1573 ret = soc_bind_aux_dev(card, i); snd_soc_instantiate_card()
1587 /* card bind complete so register a sound card */ snd_soc_instantiate_card()
1588 ret = snd_card_new(card->dev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1, snd_soc_instantiate_card()
1589 card->owner, 0, &card->snd_card); snd_soc_instantiate_card()
1591 dev_err(card->dev, snd_soc_instantiate_card()
1592 "ASoC: can't create sound card for card %s: %d\n", snd_soc_instantiate_card()
1593 card->name, ret); snd_soc_instantiate_card()
1597 soc_init_card_debugfs(card); snd_soc_instantiate_card()
1599 card->dapm.bias_level = SND_SOC_BIAS_OFF; snd_soc_instantiate_card()
1600 card->dapm.dev = card->dev; snd_soc_instantiate_card()
1601 card->dapm.card = card; snd_soc_instantiate_card()
1602 list_add(&card->dapm.list, &card->dapm_list); snd_soc_instantiate_card()
1605 snd_soc_dapm_debugfs_init(&card->dapm, card->debugfs_card_root); snd_soc_instantiate_card()
1610 INIT_WORK(&card->deferred_resume_work, soc_resume_deferred); snd_soc_instantiate_card()
1613 if (card->dapm_widgets) snd_soc_instantiate_card()
1614 snd_soc_dapm_new_controls(&card->dapm, card->dapm_widgets, snd_soc_instantiate_card()
1615 card->num_dapm_widgets); snd_soc_instantiate_card()
1617 if (card->of_dapm_widgets) snd_soc_instantiate_card()
1618 snd_soc_dapm_new_controls(&card->dapm, card->of_dapm_widgets, snd_soc_instantiate_card()
1619 card->num_of_dapm_widgets); snd_soc_instantiate_card()
1621 /* initialise the sound card only once */ snd_soc_instantiate_card()
1622 if (card->probe) { snd_soc_instantiate_card()
1623 ret = card->probe(card); snd_soc_instantiate_card()
1628 /* probe all components used by DAI links on this card */ snd_soc_instantiate_card()
1631 for (i = 0; i < card->num_links; i++) { snd_soc_instantiate_card()
1632 ret = soc_probe_link_components(card, i, order); snd_soc_instantiate_card()
1634 dev_err(card->dev, snd_soc_instantiate_card()
1635 "ASoC: failed to instantiate card %d\n", snd_soc_instantiate_card()
1642 /* probe all DAI links on this card */ snd_soc_instantiate_card()
1645 for (i = 0; i < card->num_links; i++) { snd_soc_instantiate_card()
1646 ret = soc_probe_link_dais(card, i, order); snd_soc_instantiate_card()
1648 dev_err(card->dev, snd_soc_instantiate_card()
1649 "ASoC: failed to instantiate card %d\n", snd_soc_instantiate_card()
1656 for (i = 0; i < card->num_aux_devs; i++) { snd_soc_instantiate_card()
1657 ret = soc_probe_aux_dev(card, i); snd_soc_instantiate_card()
1659 dev_err(card->dev, snd_soc_instantiate_card()
1666 snd_soc_dapm_link_dai_widgets(card); snd_soc_instantiate_card()
1667 snd_soc_dapm_connect_dai_link_widgets(card); snd_soc_instantiate_card()
1669 if (card->controls) snd_soc_instantiate_card()
1670 snd_soc_add_card_controls(card, card->controls, card->num_controls); snd_soc_instantiate_card()
1672 if (card->dapm_routes) snd_soc_instantiate_card()
1673 snd_soc_dapm_add_routes(&card->dapm, card->dapm_routes, snd_soc_instantiate_card()
1674 card->num_dapm_routes); snd_soc_instantiate_card()
1676 if (card->of_dapm_routes) snd_soc_instantiate_card()
1677 snd_soc_dapm_add_routes(&card->dapm, card->of_dapm_routes, snd_soc_instantiate_card()
1678 card->num_of_dapm_routes); snd_soc_instantiate_card()
1680 snprintf(card->snd_card->shortname, sizeof(card->snd_card->shortname), snd_soc_instantiate_card()
1681 "%s", card->name); snd_soc_instantiate_card()
1682 snprintf(card->snd_card->longname, sizeof(card->snd_card->longname), snd_soc_instantiate_card()
1683 "%s", card->long_name ? card->long_name : card->name); snd_soc_instantiate_card()
1684 snprintf(card->snd_card->driver, sizeof(card->snd_card->driver), snd_soc_instantiate_card()
1685 "%s", card->driver_name ? card->driver_name : card->name); snd_soc_instantiate_card()
1686 for (i = 0; i < ARRAY_SIZE(card->snd_card->driver); i++) { snd_soc_instantiate_card()
1687 switch (card->snd_card->driver[i]) { snd_soc_instantiate_card()
1693 if (!isalnum(card->snd_card->driver[i])) snd_soc_instantiate_card()
1694 card->snd_card->driver[i] = '_'; snd_soc_instantiate_card()
1699 if (card->late_probe) { snd_soc_instantiate_card()
1700 ret = card->late_probe(card); snd_soc_instantiate_card()
1702 dev_err(card->dev, "ASoC: %s late_probe() failed: %d\n", snd_soc_instantiate_card()
1703 card->name, ret); snd_soc_instantiate_card()
1708 snd_soc_dapm_new_widgets(card); snd_soc_instantiate_card()
1710 ret = snd_card_register(card->snd_card); snd_soc_instantiate_card()
1712 dev_err(card->dev, "ASoC: failed to register soundcard %d\n", snd_soc_instantiate_card()
1717 card->instantiated = 1; snd_soc_instantiate_card()
1718 snd_soc_dapm_sync(&card->dapm); snd_soc_instantiate_card()
1719 mutex_unlock(&card->mutex); snd_soc_instantiate_card()
1725 for (i = 0; i < card->num_aux_devs; i++) snd_soc_instantiate_card()
1726 soc_remove_aux_dev(card, i); snd_soc_instantiate_card()
1729 soc_remove_dai_links(card); snd_soc_instantiate_card()
1732 if (card->remove) snd_soc_instantiate_card()
1733 card->remove(card); snd_soc_instantiate_card()
1735 soc_cleanup_card_debugfs(card); snd_soc_instantiate_card()
1736 snd_card_free(card->snd_card); snd_soc_instantiate_card()
1739 mutex_unlock(&card->mutex); snd_soc_instantiate_card()
1748 struct snd_soc_card *card = platform_get_drvdata(pdev); soc_probe() local
1751 * no card, so machine driver should be registering card soc_probe()
1754 if (!card) soc_probe()
1759 card->name); soc_probe()
1762 card->dev = &pdev->dev; soc_probe()
1764 return snd_soc_register_card(card); soc_probe()
1767 static int soc_cleanup_card_resources(struct snd_soc_card *card) soc_cleanup_card_resources() argument
1772 for (i = 0; i < card->num_rtd; i++) { soc_cleanup_card_resources()
1773 struct snd_soc_pcm_runtime *rtd = &card->rtd[i]; soc_cleanup_card_resources()
1778 for (i = 0; i < card->num_aux_devs; i++) soc_cleanup_card_resources()
1779 soc_remove_aux_dev(card, i); soc_cleanup_card_resources()
1782 soc_remove_dai_links(card); soc_cleanup_card_resources()
1784 soc_cleanup_card_debugfs(card); soc_cleanup_card_resources()
1786 /* remove the card */ soc_cleanup_card_resources()
1787 if (card->remove) soc_cleanup_card_resources()
1788 card->remove(card); soc_cleanup_card_resources()
1790 snd_soc_dapm_free(&card->dapm); soc_cleanup_card_resources()
1792 snd_card_free(card->snd_card); soc_cleanup_card_resources()
1800 struct snd_soc_card *card = platform_get_drvdata(pdev); soc_remove() local
1802 snd_soc_unregister_card(card); soc_remove()
1808 struct snd_soc_card *card = dev_get_drvdata(dev); snd_soc_poweroff() local
1811 if (!card->instantiated) snd_soc_poweroff()
1816 for (i = 0; i < card->num_rtd; i++) { snd_soc_poweroff()
1817 struct snd_soc_pcm_runtime *rtd = &card->rtd[i]; snd_soc_poweroff()
1821 snd_soc_dapm_shutdown(card); snd_soc_poweroff()
1824 for (i = 0; i < card->num_rtd; i++) { snd_soc_poweroff()
1825 struct snd_soc_pcm_runtime *rtd = &card->rtd[i]; snd_soc_poweroff()
1903 static int snd_soc_add_controls(struct snd_card *card, struct device *dev, snd_soc_add_controls() argument
1911 err = snd_ctl_add(card, snd_soc_cnew(control, data, snd_soc_add_controls()
1926 struct snd_card *card = soc_card->snd_card; snd_soc_card_get_kcontrol() local
1932 list_for_each_entry(kctl, &card->controls, list) snd_soc_card_get_kcontrol()
1951 struct snd_card *card = component->card->snd_card; snd_soc_add_component_controls() local
1953 return snd_soc_add_controls(card, component->dev, controls, snd_soc_add_component_controls()
1996 * snd_soc_add_card_controls - add an array of controls to a SoC card.
1999 * @soc_card: SoC card to add controls to
2008 struct snd_card *card = soc_card->snd_card; snd_soc_add_card_controls() local
2010 return snd_soc_add_controls(card, soc_card->dev, controls, num_controls, snd_soc_add_card_controls()
2028 struct snd_card *card = dai->component->card->snd_card; snd_soc_add_dai_controls() local
2030 return snd_soc_add_controls(card, dai->dev, controls, num_controls, snd_soc_add_dai_controls()
2307 static int snd_soc_init_multicodec(struct snd_soc_card *card, snd_soc_init_multicodec() argument
2315 dai_link->codecs = devm_kzalloc(card->dev, snd_soc_init_multicodec()
2327 dev_err(card->dev, "ASoC: DAI link has no CODECs\n"); snd_soc_init_multicodec()
2335 * snd_soc_register_card - Register a card with the ASoC core
2337 * @card: Card to register
2340 int snd_soc_register_card(struct snd_soc_card *card) snd_soc_register_card() argument
2344 if (!card->name || !card->dev) snd_soc_register_card()
2347 for (i = 0; i < card->num_links; i++) { snd_soc_register_card()
2348 struct snd_soc_dai_link *link = &card->dai_link[i]; snd_soc_register_card()
2350 ret = snd_soc_init_multicodec(card, link); snd_soc_register_card()
2352 dev_err(card->dev, "ASoC: failed to init multicodec\n"); snd_soc_register_card()
2363 dev_err(card->dev, "ASoC: Neither/both codec name/of_node are set for %s\n", snd_soc_register_card()
2369 dev_err(card->dev, "ASoC: codec_dai_name not set for %s\n", snd_soc_register_card()
2380 dev_err(card->dev, snd_soc_register_card()
2392 dev_err(card->dev, snd_soc_register_card()
2403 dev_err(card->dev, snd_soc_register_card()
2410 dev_set_drvdata(card->dev, card); snd_soc_register_card()
2412 snd_soc_initialize_card_lists(card); snd_soc_register_card()
2414 card->rtd = devm_kzalloc(card->dev, snd_soc_register_card()
2416 (card->num_links + card->num_aux_devs), snd_soc_register_card()
2418 if (card->rtd == NULL) snd_soc_register_card()
2420 card->num_rtd = 0; snd_soc_register_card()
2421 card->rtd_aux = &card->rtd[card->num_links]; snd_soc_register_card()
2423 for (i = 0; i < card->num_links; i++) { snd_soc_register_card()
2424 card->rtd[i].card = card; snd_soc_register_card()
2425 card->rtd[i].dai_link = &card->dai_link[i]; snd_soc_register_card()
2426 card->rtd[i].codec_dais = devm_kzalloc(card->dev, snd_soc_register_card()
2428 (card->rtd[i].dai_link->num_codecs), snd_soc_register_card()
2430 if (card->rtd[i].codec_dais == NULL) snd_soc_register_card()
2434 for (i = 0; i < card->num_aux_devs; i++) snd_soc_register_card()
2435 card->rtd_aux[i].card = card; snd_soc_register_card()
2437 INIT_LIST_HEAD(&card->dapm_dirty); snd_soc_register_card()
2438 card->instantiated = 0; snd_soc_register_card()
2439 mutex_init(&card->mutex); snd_soc_register_card()
2440 mutex_init(&card->dapm_mutex); snd_soc_register_card()
2442 ret = snd_soc_instantiate_card(card); snd_soc_register_card()
2447 for (i = 0; i < card->num_rtd; i++) { snd_soc_register_card()
2448 struct snd_soc_pcm_runtime *rtd = &card->rtd[i]; snd_soc_register_card()
2467 * snd_soc_unregister_card - Unregister a card with the ASoC core
2469 * @card: Card to unregister
2472 int snd_soc_unregister_card(struct snd_soc_card *card) snd_soc_unregister_card() argument
2474 if (card->instantiated) { snd_soc_unregister_card()
2475 card->instantiated = false; snd_soc_unregister_card()
2476 snd_soc_dapm_shutdown(card); snd_soc_unregister_card()
2477 soc_cleanup_card_resources(card); snd_soc_unregister_card()
2478 dev_dbg(card->dev, "ASoC: Unregistered card '%s'\n", card->name); snd_soc_unregister_card()
3171 /* Retrieve a card's name from device tree */ snd_soc_of_parse_card_name()
3172 int snd_soc_of_parse_card_name(struct snd_soc_card *card, snd_soc_of_parse_card_name() argument
3178 if (!card->dev) { snd_soc_of_parse_card_name()
3179 pr_err("card->dev is not set before calling %s\n", __func__); snd_soc_of_parse_card_name()
3183 np = card->dev->of_node; snd_soc_of_parse_card_name()
3185 ret = of_property_read_string_index(np, propname, 0, &card->name); snd_soc_of_parse_card_name()
3188 * card->name was previously set, which is checked later in snd_soc_of_parse_card_name()
3192 dev_err(card->dev, snd_soc_of_parse_card_name()
3209 int snd_soc_of_parse_audio_simple_widgets(struct snd_soc_card *card, snd_soc_of_parse_audio_simple_widgets() argument
3212 struct device_node *np = card->dev->of_node; snd_soc_of_parse_audio_simple_widgets()
3219 dev_err(card->dev, snd_soc_of_parse_audio_simple_widgets()
3224 dev_err(card->dev, snd_soc_of_parse_audio_simple_widgets()
3231 dev_err(card->dev, "ASoC: Property '%s's length is zero\n", snd_soc_of_parse_audio_simple_widgets()
3236 widgets = devm_kcalloc(card->dev, num_widgets, sizeof(*widgets), snd_soc_of_parse_audio_simple_widgets()
3239 dev_err(card->dev, snd_soc_of_parse_audio_simple_widgets()
3248 dev_err(card->dev, snd_soc_of_parse_audio_simple_widgets()
3263 dev_err(card->dev, snd_soc_of_parse_audio_simple_widgets()
3273 dev_err(card->dev, snd_soc_of_parse_audio_simple_widgets()
3282 card->of_dapm_widgets = widgets; snd_soc_of_parse_audio_simple_widgets()
3283 card->num_of_dapm_widgets = num_widgets; snd_soc_of_parse_audio_simple_widgets()
3318 int snd_soc_of_parse_audio_routing(struct snd_soc_card *card, snd_soc_of_parse_audio_routing() argument
3321 struct device_node *np = card->dev->of_node; snd_soc_of_parse_audio_routing()
3328 dev_err(card->dev, snd_soc_of_parse_audio_routing()
3335 dev_err(card->dev, "ASoC: Property '%s's length is zero\n", snd_soc_of_parse_audio_routing()
3340 routes = devm_kzalloc(card->dev, num_routes * sizeof(*routes), snd_soc_of_parse_audio_routing()
3343 dev_err(card->dev, snd_soc_of_parse_audio_routing()
3352 dev_err(card->dev, snd_soc_of_parse_audio_routing()
3360 dev_err(card->dev, snd_soc_of_parse_audio_routing()
3367 card->num_of_dapm_routes = num_routes; snd_soc_of_parse_audio_routing()
3368 card->of_dapm_routes = routes; snd_soc_of_parse_audio_routing()
H A Dsoc-dapm.c48 #define DAPM_UPDATE_STAT(widget, val) widget->dapm->card->dapm_stats.val++;
116 if (dapm->card && dapm->card->instantiated) dapm_assert_locked()
117 lockdep_assert_held(&dapm->card->dapm_mutex); dapm_assert_locked()
158 list_add_tail(&w->dirty, &w->dapm->card->dapm_dirty); dapm_mark_dirty()
272 void dapm_mark_endpoints_dirty(struct snd_soc_card *card) dapm_mark_endpoints_dirty() argument
276 mutex_lock(&card->dapm_mutex); dapm_mark_endpoints_dirty()
278 list_for_each_entry(w, &card->widgets, list) { dapm_mark_endpoints_dirty()
288 mutex_unlock(&card->dapm_mutex); dapm_mark_endpoints_dirty()
476 static void dapm_reset(struct snd_soc_card *card) dapm_reset() argument
480 lockdep_assert_held(&card->dapm_mutex); dapm_reset()
482 memset(&card->dapm_stats, 0, sizeof(card->dapm_stats)); dapm_reset()
484 list_for_each_entry(w, &card->widgets, list) { dapm_reset()
540 struct snd_soc_card *card = dapm->card; snd_soc_dapm_set_bias_level() local
543 trace_snd_soc_bias_level_start(card, level); snd_soc_dapm_set_bias_level()
545 if (card && card->set_bias_level) snd_soc_dapm_set_bias_level()
546 ret = card->set_bias_level(card, dapm, level); snd_soc_dapm_set_bias_level()
552 else if (!card || dapm != &card->dapm) snd_soc_dapm_set_bias_level()
558 if (card && card->set_bias_level_post) snd_soc_dapm_set_bias_level()
559 ret = card->set_bias_level_post(card, dapm, level); snd_soc_dapm_set_bias_level()
561 trace_snd_soc_bias_level_done(card, level); snd_soc_dapm_set_bias_level()
653 list_for_each_entry(w, &dapm->card->widgets, list) { dapm_is_shared_kcontrol()
676 struct snd_card *card = dapm->card->snd_card; dapm_create_or_share_mixmux_kcontrol() local
756 ret = snd_ctl_add(card, kcontrol); dapm_create_or_share_mixmux_kcontrol()
852 struct snd_card *card = dapm->card->snd_card; dapm_new_dai_link() local
862 ret = snd_ctl_add(card, kcontrol); dapm_new_dai_link()
877 * the ALSA card - when we are suspending the ALSA state for the card
882 int level = snd_power_get_state(widget->dapm->card->snd_card); snd_soc_dapm_suspend_check()
1066 struct snd_soc_card *card = dai->component->card; snd_soc_dapm_dai_get_connected_widgets() local
1070 mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); snd_soc_dapm_dai_get_connected_widgets()
1076 list_for_each_entry(w, &card->widgets, list) { snd_soc_dapm_dai_get_connected_widgets()
1087 mutex_unlock(&card->dapm_mutex); snd_soc_dapm_dai_get_connected_widgets()
1250 static void dapm_seq_check_event(struct snd_soc_card *card, dapm_seq_check_event() argument
1290 pop_dbg(w->dapm->dev, card->pop_time, "pop test : %s %s\n", dapm_seq_check_event()
1303 static void dapm_seq_run_coalesced(struct snd_soc_card *card, dapm_seq_run_coalesced() argument
1326 pop_dbg(dapm->dev, card->pop_time, list_for_each_entry()
1331 dapm_seq_check_event(card, w, SND_SOC_DAPM_PRE_PMU); list_for_each_entry()
1332 dapm_seq_check_event(card, w, SND_SOC_DAPM_PRE_PMD); list_for_each_entry()
1340 pop_dbg(dapm->dev, card->pop_time,
1342 value, mask, reg, card->pop_time);
1343 pop_wait(card->pop_time);
1348 dapm_seq_check_event(card, w, SND_SOC_DAPM_POST_PMU); list_for_each_entry()
1349 dapm_seq_check_event(card, w, SND_SOC_DAPM_POST_PMD); list_for_each_entry()
1361 static void dapm_seq_run(struct snd_soc_card *card, dapm_seq_run() argument
1386 dapm_seq_run_coalesced(card, &pending); list_for_each_entry_safe()
1449 dapm_seq_run_coalesced(card, &pending);
1458 list_for_each_entry(d, &card->dapm_list, list) {
1463 static void dapm_widget_update(struct snd_soc_card *card) dapm_widget_update() argument
1465 struct snd_soc_dapm_update *update = card->update; dapm_widget_update()
1652 switch (snd_power_get_state(dapm->card->snd_card)) { dapm_idle_bias_off()
1672 static int dapm_power_widgets(struct snd_soc_card *card, int event) dapm_power_widgets() argument
1681 lockdep_assert_held(&card->dapm_mutex); dapm_power_widgets()
1683 trace_snd_soc_dapm_start(card); dapm_power_widgets()
1685 list_for_each_entry(d, &card->dapm_list, list) { dapm_power_widgets()
1692 dapm_reset(card); dapm_power_widgets()
1700 list_for_each_entry(w, &card->dapm_dirty, dirty) { dapm_power_widgets()
1704 list_for_each_entry(w, &card->widgets, list) { dapm_power_widgets()
1744 /* Force all contexts in the card to the same bias state if dapm_power_widgets()
1748 list_for_each_entry(d, &card->dapm_list, list) dapm_power_widgets()
1751 list_for_each_entry(d, &card->dapm_list, list) dapm_power_widgets()
1755 trace_snd_soc_dapm_walk_done(card); dapm_power_widgets()
1757 /* Run card bias changes at first */ dapm_power_widgets()
1758 dapm_pre_sequence_async(&card->dapm, 0); dapm_power_widgets()
1760 list_for_each_entry(d, &card->dapm_list, list) { dapm_power_widgets()
1761 if (d != &card->dapm) dapm_power_widgets()
1768 dapm_seq_check_event(card, w, SND_SOC_DAPM_WILL_PMD); dapm_power_widgets()
1772 dapm_seq_check_event(card, w, SND_SOC_DAPM_WILL_PMU); dapm_power_widgets()
1776 dapm_seq_run(card, &down_list, event, false); dapm_power_widgets()
1778 dapm_widget_update(card); dapm_power_widgets()
1781 dapm_seq_run(card, &up_list, event, true); dapm_power_widgets()
1784 list_for_each_entry(d, &card->dapm_list, list) { dapm_power_widgets()
1785 if (d != &card->dapm) dapm_power_widgets()
1790 /* Run card bias changes at last */ dapm_power_widgets()
1791 dapm_post_sequence_async(&card->dapm, 0); dapm_power_widgets()
1794 list_for_each_entry(d, &card->dapm_list, list) { dapm_power_widgets()
1799 pop_dbg(card->dev, card->pop_time, dapm_power_widgets()
1800 "DAPM sequencing finished, waiting %dms\n", card->pop_time); dapm_power_widgets()
1801 pop_wait(card->pop_time); dapm_power_widgets()
1803 trace_snd_soc_dapm_done(card); dapm_power_widgets()
1814 struct snd_soc_card *card = w->dapm->card; dapm_widget_power_read_file() local
1824 mutex_lock(&card->dapm_mutex); dapm_widget_power_read_file()
1872 mutex_unlock(&card->dapm_mutex); dapm_widget_power_read_file()
2003 static int soc_dapm_mux_update_power(struct snd_soc_card *card, soc_dapm_mux_update_power() argument
2010 lockdep_assert_held(&card->dapm_mutex); soc_dapm_mux_update_power()
2025 dapm_power_widgets(card, SND_SOC_DAPM_STREAM_NOP);
2034 struct snd_soc_card *card = dapm->card; snd_soc_dapm_mux_update_power() local
2037 mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); snd_soc_dapm_mux_update_power()
2038 card->update = update; snd_soc_dapm_mux_update_power()
2039 ret = soc_dapm_mux_update_power(card, kcontrol, mux, e); snd_soc_dapm_mux_update_power()
2040 card->update = NULL; snd_soc_dapm_mux_update_power()
2041 mutex_unlock(&card->dapm_mutex); snd_soc_dapm_mux_update_power()
2043 soc_dpcm_runtime_update(card); snd_soc_dapm_mux_update_power()
2049 static int soc_dapm_mixer_update_power(struct snd_soc_card *card, soc_dapm_mixer_update_power() argument
2055 lockdep_assert_held(&card->dapm_mutex); soc_dapm_mixer_update_power()
2064 dapm_power_widgets(card, SND_SOC_DAPM_STREAM_NOP);
2073 struct snd_soc_card *card = dapm->card; snd_soc_dapm_mixer_update_power() local
2076 mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); snd_soc_dapm_mixer_update_power()
2077 card->update = update; snd_soc_dapm_mixer_update_power()
2078 ret = soc_dapm_mixer_update_power(card, kcontrol, connect); snd_soc_dapm_mixer_update_power()
2079 card->update = NULL; snd_soc_dapm_mixer_update_power()
2080 mutex_unlock(&card->dapm_mutex); snd_soc_dapm_mixer_update_power()
2082 soc_dpcm_runtime_update(card); snd_soc_dapm_mixer_update_power()
2093 list_for_each_entry(w, &codec->component.card->widgets, list) { dapm_widget_show_codec()
2148 mutex_lock(&rtd->card->dapm_mutex); dapm_widget_show()
2155 mutex_unlock(&rtd->card->dapm_mutex); dapm_widget_show()
2182 list_for_each_entry_safe(w, next_w, &dapm->card->widgets, list) { dapm_free_widgets()
2210 list_for_each_entry(w, &dapm->card->widgets, list) { dapm_find_widget()
2265 * silly DAPM runs during card startup. snd_soc_dapm_sync_unlocked()
2267 if (!dapm->card || !dapm->card->instantiated) snd_soc_dapm_sync_unlocked()
2270 return dapm_power_widgets(dapm->card, SND_SOC_DAPM_STREAM_NOP); snd_soc_dapm_sync_unlocked()
2287 mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); snd_soc_dapm_sync()
2289 mutex_unlock(&dapm->card->dapm_mutex); snd_soc_dapm_sync()
2309 /* On a fully routed card a input is never a source */ dapm_update_widget_flags()
2310 if (w->dapm->card->fully_routed) dapm_update_widget_flags()
2324 /* On a fully routed card a output is never a sink */ dapm_update_widget_flags()
2325 if (w->dapm->card->fully_routed) dapm_update_widget_flags()
2419 list_add(&path->list, &dapm->card->paths); snd_soc_dapm_add_path()
2429 if (dapm->card->instantiated && path->connect) snd_soc_dapm_add_path()
2467 list_for_each_entry(w, &dapm->card->widgets, list) { snd_soc_dapm_add_route()
2540 list_for_each_entry(p, &dapm->card->paths, list) { snd_soc_dapm_del_route()
2589 mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_INIT); snd_soc_dapm_add_routes()
2601 mutex_unlock(&dapm->card->dapm_mutex); snd_soc_dapm_add_routes()
2620 mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_INIT); snd_soc_dapm_del_routes()
2625 mutex_unlock(&dapm->card->dapm_mutex); snd_soc_dapm_del_routes()
2698 mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_INIT); snd_soc_dapm_weak_routes()
2705 mutex_unlock(&dapm->card->dapm_mutex); snd_soc_dapm_weak_routes()
2719 int snd_soc_dapm_new_widgets(struct snd_soc_card *card) snd_soc_dapm_new_widgets() argument
2724 mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_INIT); snd_soc_dapm_new_widgets()
2726 list_for_each_entry(w, &card->widgets, list) snd_soc_dapm_new_widgets()
2736 mutex_unlock(&card->dapm_mutex); snd_soc_dapm_new_widgets()
2776 dapm_power_widgets(card, SND_SOC_DAPM_STREAM_NOP); snd_soc_dapm_new_widgets()
2777 mutex_unlock(&card->dapm_mutex); snd_soc_dapm_new_widgets()
2795 struct snd_soc_card *card = dapm->card; snd_soc_dapm_get_volsw() local
2811 mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); snd_soc_dapm_get_volsw()
2818 mutex_unlock(&card->dapm_mutex); snd_soc_dapm_get_volsw()
2842 struct snd_soc_card *card = dapm->card; snd_soc_dapm_put_volsw() local
2866 mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); snd_soc_dapm_put_volsw()
2883 card->update = &update; snd_soc_dapm_put_volsw()
2887 ret = soc_dapm_mixer_update_power(card, kcontrol, connect); snd_soc_dapm_put_volsw()
2889 card->update = NULL; snd_soc_dapm_put_volsw()
2892 mutex_unlock(&card->dapm_mutex); snd_soc_dapm_put_volsw()
2895 soc_dpcm_runtime_update(card); snd_soc_dapm_put_volsw()
2950 struct snd_soc_card *card = dapm->card; snd_soc_dapm_put_enum_double() local
2970 mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); snd_soc_dapm_put_enum_double()
2983 card->update = &update; snd_soc_dapm_put_enum_double()
2986 ret = soc_dapm_mux_update_power(card, kcontrol, item[0], e); snd_soc_dapm_put_enum_double()
2988 card->update = NULL; snd_soc_dapm_put_enum_double()
2991 mutex_unlock(&card->dapm_mutex); snd_soc_dapm_put_enum_double()
2994 soc_dpcm_runtime_update(card); snd_soc_dapm_put_enum_double()
3029 struct snd_soc_card *card = snd_kcontrol_chip(kcontrol); snd_soc_dapm_get_pin_switch() local
3032 mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); snd_soc_dapm_get_pin_switch()
3035 snd_soc_dapm_get_pin_status(&card->dapm, pin); snd_soc_dapm_get_pin_switch()
3037 mutex_unlock(&card->dapm_mutex); snd_soc_dapm_get_pin_switch()
3052 struct snd_soc_card *card = snd_kcontrol_chip(kcontrol); snd_soc_dapm_put_pin_switch() local
3056 snd_soc_dapm_enable_pin(&card->dapm, pin); snd_soc_dapm_put_pin_switch()
3058 snd_soc_dapm_disable_pin(&card->dapm, pin); snd_soc_dapm_put_pin_switch()
3060 snd_soc_dapm_sync(&card->dapm); snd_soc_dapm_put_pin_switch()
3127 if (!dapm->card->fully_routed) snd_soc_dapm_new_control()
3137 if (!dapm->card->fully_routed) snd_soc_dapm_new_control()
3180 list_add(&w->list, &dapm->card->widgets); snd_soc_dapm_new_control()
3208 mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_INIT); snd_soc_dapm_new_controls()
3220 mutex_unlock(&dapm->card->dapm_mutex); snd_soc_dapm_new_controls()
3352 int snd_soc_dapm_new_pcm(struct snd_soc_card *card, snd_soc_dapm_new_pcm() argument
3374 w_param_text = devm_kcalloc(card->dev, num_params, snd_soc_dapm_new_pcm()
3379 link_name = devm_kasprintf(card->dev, GFP_KERNEL, "%s-%s", snd_soc_dapm_new_pcm()
3388 dev_warn(card->dapm.dev, snd_soc_dapm_new_pcm()
3392 devm_kasprintf(card->dev, GFP_KERNEL, snd_soc_dapm_new_pcm()
3400 w_param_text[count] = devm_kmemdup(card->dev, snd_soc_dapm_new_pcm()
3424 (unsigned long) devm_kmemdup(card->dev, snd_soc_dapm_new_pcm()
3428 dev_err(card->dev, "ASoC: Failed to create control for %s widget\n", snd_soc_dapm_new_pcm()
3436 devm_kmemdup(card->dev, &kcontrol_dai_link[0], snd_soc_dapm_new_pcm()
3440 dev_err(card->dev, "ASoC: Failed to create control for %s widget\n", snd_soc_dapm_new_pcm()
3446 dev_dbg(card->dev, "ASoC: adding %s widget\n", link_name); snd_soc_dapm_new_pcm()
3448 w = snd_soc_dapm_new_control(&card->dapm, &template); snd_soc_dapm_new_pcm()
3450 dev_err(card->dev, "ASoC: Failed to create %s widget\n", snd_soc_dapm_new_pcm()
3459 ret = snd_soc_dapm_add_path(&card->dapm, source, w, NULL, NULL); snd_soc_dapm_new_pcm()
3462 return snd_soc_dapm_add_path(&card->dapm, w, sink, NULL, NULL); snd_soc_dapm_new_pcm()
3465 devm_kfree(card->dev, w); snd_soc_dapm_new_pcm()
3467 devm_kfree(card->dev, (void *)template.kcontrol_news); snd_soc_dapm_new_pcm()
3469 devm_kfree(card->dev, (void *)private_value); snd_soc_dapm_new_pcm()
3471 devm_kfree(card->dev, link_name); snd_soc_dapm_new_pcm()
3474 devm_kfree(card->dev, (void *)w_param_text[count]); snd_soc_dapm_new_pcm()
3475 devm_kfree(card->dev, w_param_text); snd_soc_dapm_new_pcm()
3532 int snd_soc_dapm_link_dai_widgets(struct snd_soc_card *card) snd_soc_dapm_link_dai_widgets() argument
3539 list_for_each_entry(dai_w, &card->widgets, list) { snd_soc_dapm_link_dai_widgets()
3551 list_for_each_entry(w, &card->widgets, list) { snd_soc_dapm_link_dai_widgets()
3581 static void dapm_connect_dai_link_widgets(struct snd_soc_card *card, dapm_connect_dai_link_widgets() argument
3604 snd_soc_dapm_add_path(&card->dapm, source, sink, dapm_connect_dai_link_widgets()
3616 snd_soc_dapm_add_path(&card->dapm, source, sink, dapm_connect_dai_link_widgets()
3659 void snd_soc_dapm_connect_dai_link_widgets(struct snd_soc_card *card) snd_soc_dapm_connect_dai_link_widgets() argument
3661 struct snd_soc_pcm_runtime *rtd = card->rtd; snd_soc_dapm_connect_dai_link_widgets()
3665 for (i = 0; i < card->num_rtd; i++) { snd_soc_dapm_connect_dai_link_widgets()
3666 rtd = &card->rtd[i]; snd_soc_dapm_connect_dai_link_widgets()
3675 dapm_connect_dai_link_widgets(card, rtd); snd_soc_dapm_connect_dai_link_widgets()
3688 dapm_power_widgets(rtd->card, event); soc_dapm_stream_event()
3705 struct snd_soc_card *card = rtd->card; snd_soc_dapm_stream_event() local
3707 mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); snd_soc_dapm_stream_event()
3709 mutex_unlock(&card->dapm_mutex); snd_soc_dapm_stream_event()
3747 mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); snd_soc_dapm_enable_pin()
3751 mutex_unlock(&dapm->card->dapm_mutex); snd_soc_dapm_enable_pin()
3815 mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); snd_soc_dapm_force_enable_pin()
3819 mutex_unlock(&dapm->card->dapm_mutex); snd_soc_dapm_force_enable_pin()
3859 mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); snd_soc_dapm_disable_pin()
3863 mutex_unlock(&dapm->card->dapm_mutex); snd_soc_dapm_disable_pin()
3910 mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); snd_soc_dapm_nc_pin()
3914 mutex_unlock(&dapm->card->dapm_mutex); snd_soc_dapm_nc_pin()
3984 struct snd_soc_card *card = dapm->card; soc_dapm_shutdown_dapm() local
3989 mutex_lock(&card->dapm_mutex); soc_dapm_shutdown_dapm()
3991 list_for_each_entry(w, &dapm->card->widgets, list) { soc_dapm_shutdown_dapm()
4008 dapm_seq_run(card, &down_list, 0, false); soc_dapm_shutdown_dapm()
4014 mutex_unlock(&card->dapm_mutex); soc_dapm_shutdown_dapm()
4020 void snd_soc_dapm_shutdown(struct snd_soc_card *card) snd_soc_dapm_shutdown() argument
4024 list_for_each_entry(dapm, &card->dapm_list, list) { snd_soc_dapm_shutdown()
4025 if (dapm != &card->dapm) { snd_soc_dapm_shutdown()
4033 soc_dapm_shutdown_dapm(&card->dapm); snd_soc_dapm_shutdown()
4034 if (card->dapm.bias_level == SND_SOC_BIAS_STANDBY) snd_soc_dapm_shutdown()
4035 snd_soc_dapm_set_bias_level(&card->dapm, snd_soc_dapm_shutdown()
/linux-4.1.27/sound/usb/6fire/
H A Dchip.c36 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* Id for card */
37 static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable card */
61 if (chip->card) { usb6fire_chip_abort()
62 snd_card_disconnect(chip->card); usb6fire_chip_abort()
63 snd_card_free_when_closed(chip->card); usb6fire_chip_abort()
64 chip->card = NULL; usb6fire_chip_abort()
80 if (chip->card) usb6fire_chip_destroy()
81 snd_card_free(chip->card); usb6fire_chip_destroy()
93 struct snd_card *card = NULL; usb6fire_chip_probe() local
95 /* look if we already serve this card and return if so */ usb6fire_chip_probe()
122 /* if we are here, card can be registered in alsa. */ usb6fire_chip_probe()
128 THIS_MODULE, sizeof(struct sfire_chip), &card); usb6fire_chip_probe()
130 dev_err(&intf->dev, "cannot create alsa card.\n"); usb6fire_chip_probe()
133 strcpy(card->driver, "6FireUSB"); usb6fire_chip_probe()
134 strcpy(card->shortname, "TerraTec DMX6FireUSB"); usb6fire_chip_probe()
135 sprintf(card->longname, "%s at %d:%d", card->shortname, usb6fire_chip_probe()
138 chip = card->private_data; usb6fire_chip_probe()
143 chip->card = card; usb6fire_chip_probe()
169 ret = snd_card_register(card); usb6fire_chip_probe()
171 dev_err(&intf->dev, "cannot register card."); usb6fire_chip_probe()
182 struct snd_card *card; usb6fire_chip_disconnect() local
186 card = chip->card; usb6fire_chip_disconnect()
/linux-4.1.27/drivers/net/wireless/orinoco/
H A Dairport.c4 * card.
40 struct airport *card = priv->card; airport_suspend() local
56 disable_irq(card->irq); airport_suspend()
68 struct airport *card = priv->card; airport_resume() local
78 enable_irq(card->irq); airport_resume()
91 struct airport *card = priv->card; airport_detach() local
93 if (card->ndev_registered) airport_detach()
95 card->ndev_registered = 0; airport_detach()
97 if (card->irq_requested) airport_detach()
98 free_irq(card->irq, priv); airport_detach()
99 card->irq_requested = 0; airport_detach()
101 if (card->vaddr) airport_detach()
102 iounmap(card->vaddr); airport_detach()
103 card->vaddr = NULL; airport_detach()
124 struct airport *card = priv->card; airport_hard_reset()
131 disable_irq(card->irq); airport_hard_reset()
134 macio_get_of_node(card->mdev), 0, 0); airport_hard_reset()
137 macio_get_of_node(card->mdev), 0, 1); airport_hard_reset()
140 enable_irq(card->irq); airport_hard_reset()
151 struct airport *card; airport_attach() local
161 priv = alloc_orinocodev(sizeof(*card), &mdev->ofdev.dev, airport_attach()
167 card = priv->card; airport_attach()
170 card->mdev = mdev; airport_attach()
181 card->irq = macio_irq(mdev, 0); airport_attach()
184 card->vaddr = ioremap(phys_addr, AIRPORT_IO_LEN); airport_attach()
185 if (!card->vaddr) { airport_attach()
190 hermes_struct_init(hw, card->vaddr, HERMES_16BIT_REGSPACING); airport_attach()
192 /* Power up card */ airport_attach()
200 if (request_irq(card->irq, orinoco_interrupt, 0, DRIVER_NAME, priv)) { airport_attach()
201 printk(KERN_ERR PFX "Couldn't get IRQ %d\n", card->irq); airport_attach()
204 card->irq_requested = 1; airport_attach()
213 if (orinoco_if_add(priv, phys_addr, card->irq, NULL) != 0) { airport_attach()
217 card->ndev_registered = 1; airport_attach()
228 MODULE_DESCRIPTION("Driver for the Apple Airport wireless card.");
H A Dorinoco_nortel.c53 #define COR_OFFSET (0xe0) /* COR attribute offset of Prism2 PC card */
54 #define COR_VALUE (COR_LEVEL_REQ | COR_FUNC_ENA) /* Enable PC card with interrupt in level trigger */
58 * Do a soft reset of the card using the Configuration Option Register
67 struct orinoco_pci_card *card = priv->card; orinoco_nortel_cor_reset() local
69 /* Assert the reset until the card notices */ orinoco_nortel_cor_reset()
70 iowrite16(8, card->bridge_io + 2); orinoco_nortel_cor_reset()
71 ioread16(card->attr_io + COR_OFFSET); orinoco_nortel_cor_reset()
72 iowrite16(0x80, card->attr_io + COR_OFFSET); orinoco_nortel_cor_reset()
75 /* Give time for the card to recover from this hard effort */ orinoco_nortel_cor_reset()
76 iowrite16(0, card->attr_io + COR_OFFSET); orinoco_nortel_cor_reset()
77 iowrite16(0, card->attr_io + COR_OFFSET); orinoco_nortel_cor_reset()
81 iowrite16(COR_VALUE, card->attr_io + COR_OFFSET); orinoco_nortel_cor_reset()
82 iowrite16(COR_VALUE, card->attr_io + COR_OFFSET); orinoco_nortel_cor_reset()
85 iowrite16(0x228, card->bridge_io + 2); orinoco_nortel_cor_reset()
90 static int orinoco_nortel_hw_init(struct orinoco_pci_card *card) orinoco_nortel_hw_init() argument
96 if (ioread16(card->bridge_io) & 1) { orinoco_nortel_hw_init()
100 iowrite16(0x118, card->bridge_io + 2); orinoco_nortel_hw_init()
101 iowrite16(0x108, card->bridge_io + 2); orinoco_nortel_hw_init()
103 iowrite16(0x8, card->bridge_io + 2); orinoco_nortel_hw_init()
106 if (ioread16(card->bridge_io) & 0x10) orinoco_nortel_hw_init()
113 if (ioread16(card->attr_io + COR_OFFSET) & 1) { orinoco_nortel_hw_init()
117 if (ioread16(card->attr_io + COR_OFFSET + 2) & 1) { orinoco_nortel_hw_init()
121 if (ioread16(card->attr_io + COR_OFFSET + 4) & 1) { orinoco_nortel_hw_init()
127 iowrite16(COR_VALUE, card->attr_io + COR_OFFSET); orinoco_nortel_hw_init()
129 reg = ioread16(card->attr_io + COR_OFFSET); orinoco_nortel_hw_init()
137 iowrite16(1, card->bridge_io + 10); orinoco_nortel_hw_init()
146 struct orinoco_pci_card *card; orinoco_nortel_init_one() local
183 priv = alloc_orinocodev(sizeof(*card), &pdev->dev, orinoco_nortel_init_one()
191 card = priv->card; orinoco_nortel_init_one()
192 card->bridge_io = bridge_io; orinoco_nortel_init_one()
193 card->attr_io = attr_io; orinoco_nortel_init_one()
205 err = orinoco_nortel_hw_init(card); orinoco_nortel_init_one()
260 struct orinoco_pci_card *card = priv->card; orinoco_nortel_remove_one() local
263 iowrite16(0, card->bridge_io + 10); orinoco_nortel_remove_one()
269 pci_iounmap(pdev, card->attr_io); orinoco_nortel_remove_one()
270 pci_iounmap(pdev, card->bridge_io); orinoco_nortel_remove_one()
/linux-4.1.27/drivers/misc/cxl/
H A Dtrace.h64 __field(u8, card)
70 __entry->card = ctx->afu->adapter->adapter_num;
76 __entry->card,
89 __field(u8, card)
99 __entry->card = ctx->afu->adapter->adapter_num;
109 __entry->card,
130 __field(u8, card)
139 __entry->card = ctx->afu->adapter->adapter_num;
148 __entry->card,
163 __field(u8, card)
172 __entry->card = ctx->afu->adapter->adapter_num;
181 __entry->card,
196 __field(u8, card)
203 __entry->card = ctx->afu->adapter->adapter_num;
210 __entry->card,
223 __field(u8, card)
230 __entry->card = ctx->afu->adapter->adapter_num;
237 __entry->card,
250 __field(u8, card)
259 __entry->card = ctx->afu->adapter->adapter_num;
268 __entry->card,
283 __field(u8, card)
291 __entry->card = ctx->afu->adapter->adapter_num;
299 __entry->card,
313 __field(u8, card)
320 __entry->card = ctx->afu->adapter->adapter_num;
327 __entry->card,
340 __field(u8, card)
348 __entry->card = ctx->afu->adapter->adapter_num;
356 __entry->card,
370 __field(u8, card)
376 __entry->card = afu->adapter->adapter_num;
382 __entry->card,
394 __field(u8, card)
401 __entry->card = afu->adapter->adapter_num;
408 __entry->card,
430 __entry->card,
441 __entry->card,
/linux-4.1.27/include/linux/mmc/
H A Dcard.h2 * linux/include/linux/mmc/card.h
251 unsigned int rca; /* relative card address of device */
252 unsigned int type; /* card type */
253 #define MMC_TYPE_MMC 0 /* MMC card */
254 #define MMC_TYPE_SD 1 /* SD card */
255 #define MMC_TYPE_SDIO 2 /* SDIO card */
256 #define MMC_TYPE_SD_COMBO 3 /* SD combo (IO+mem) card */
257 unsigned int state; /* (our) card state */
259 #define MMC_STATE_READONLY (1<<1) /* card is read-only */
260 #define MMC_STATE_BLOCKADDR (1<<2) /* card uses block-addressing */
261 #define MMC_CARD_SDXC (1<<3) /* card is SDXC */
262 #define MMC_CARD_REMOVED (1<<4) /* card has been removed */
263 #define MMC_STATE_DOING_BKOPS (1<<5) /* card is doing BKOPS */
264 #define MMC_STATE_SUSPENDED (1<<6) /* card is suspended */
265 unsigned int quirks; /* card quirks */
269 #define MMC_QUIRK_NONSTD_SDIO (1<<2) /* non-standard SDIO card attached */
271 #define MMC_QUIRK_BROKEN_CLK_GATING (1<<3) /* clock gating the sdio bus will make card fail */
272 #define MMC_QUIRK_NONSTD_FUNC_IF (1<<4) /* SDIO card has nonstd function interfaces */
287 u32 raw_cid[4]; /* raw card CID */
288 u32 raw_csd[4]; /* raw card CSD */
289 u32 raw_scr[2]; /* raw card SCR */
290 struct mmc_cid cid; /* card identification */
291 struct mmc_csd csd; /* card specific */
292 struct mmc_ext_csd ext_csd; /* mmc v4 extended card specific */
298 struct sdio_cccr cccr; /* common card info */
306 unsigned int sd_bus_speed; /* Bus Speed Mode set for the card */
307 unsigned int mmc_avail_type; /* supported device type by both host and card */
317 static inline void mmc_part_add(struct mmc_card *card, unsigned int size, mmc_part_add() argument
321 card->part[card->nr_parts].size = size; mmc_part_add()
322 card->part[card->nr_parts].part_cfg = part_cfg; mmc_part_add()
323 sprintf(card->part[card->nr_parts].name, name, idx); mmc_part_add()
324 card->part[card->nr_parts].force_ro = ro; mmc_part_add()
325 card->part[card->nr_parts].area_type = area_type; mmc_part_add()
326 card->nr_parts++; mmc_part_add()
329 static inline bool mmc_large_sector(struct mmc_card *card) mmc_large_sector() argument
331 return card->ext_csd.data_sector_size == 4096; mmc_large_sector()
352 void (*vendor_fixup)(struct mmc_card *card, int data);
399 #define cid_rev_card(card) \
400 cid_rev(card->cid.hwrev, \
401 card->cid.fwrev, \
402 card->cid.year, \
403 card->cid.month)
409 static inline void __maybe_unused add_quirk(struct mmc_card *card, int data) add_quirk() argument
411 card->quirks |= data; add_quirk()
414 static inline void __maybe_unused remove_quirk(struct mmc_card *card, int data) remove_quirk() argument
416 card->quirks &= ~data; remove_quirk()
445 static inline void __maybe_unused add_quirk_mmc(struct mmc_card *card, int data) add_quirk_mmc() argument
447 if (mmc_card_mmc(card)) add_quirk_mmc()
448 card->quirks |= data; add_quirk_mmc()
451 static inline void __maybe_unused remove_quirk_mmc(struct mmc_card *card, remove_quirk_mmc() argument
454 if (mmc_card_mmc(card)) remove_quirk_mmc()
455 card->quirks &= ~data; remove_quirk_mmc()
462 static inline void __maybe_unused add_quirk_sd(struct mmc_card *card, int data) add_quirk_sd() argument
464 if (mmc_card_sd(card)) add_quirk_sd()
465 card->quirks |= data; add_quirk_sd()
468 static inline void __maybe_unused remove_quirk_sd(struct mmc_card *card, remove_quirk_sd() argument
471 if (mmc_card_sd(card)) remove_quirk_sd()
472 card->quirks &= ~data; remove_quirk_sd()
516 * MMC device driver (e.g., Flash card, I/O card...)
528 extern void mmc_fixup_device(struct mmc_card *card,
/linux-4.1.27/drivers/media/usb/stk1160/
H A Dstk1160-ac97.c92 struct snd_card *card = NULL; stk1160_ac97_register() local
98 * Just want a card to access ac96 controls, stk1160_ac97_register()
102 THIS_MODULE, 0, &card); stk1160_ac97_register()
107 snprintf(card->shortname, sizeof(card->shortname), stk1160_ac97_register()
109 snprintf(card->longname, sizeof(card->longname), stk1160_ac97_register()
111 strlcpy(card->driver, dev->dev->driver->name, sizeof(card->driver)); stk1160_ac97_register()
113 rc = snd_ac97_bus(card, 0, &stk1160_ac97_ops, NULL, &ac97_bus); stk1160_ac97_register()
125 dev->snd_card = card; stk1160_ac97_register()
126 rc = snd_card_register(card); stk1160_ac97_register()
134 snd_card_free(card); stk1160_ac97_register()
140 struct snd_card *card = dev->snd_card; stk1160_ac97_unregister() local
146 if (card && dev->udev) stk1160_ac97_unregister()
147 snd_card_free(card); stk1160_ac97_unregister()
/linux-4.1.27/drivers/pnp/isapnp/
H A Dcompat.c36 struct pnp_card *card = global_to_pnp_card(list); pnp_find_card() local
38 if (compare_pnp_id(card->id, id) || (memcmp(id, any, 7) == 0)) pnp_find_card()
39 return card; pnp_find_card()
45 struct pnp_dev *pnp_find_dev(struct pnp_card *card, unsigned short vendor, pnp_find_dev() argument
53 if (card == NULL) { /* look for a logical device from all cards */ pnp_find_dev()
71 list = card->devices.next; pnp_find_dev()
74 if (from->card != card) /* something is wrong */ pnp_find_dev()
77 while (list != &card->devices) { pnp_find_dev()
/linux-4.1.27/sound/soc/sirf/
H A Dsirf-audio.c2 * SiRF audio card driver
27 struct snd_soc_card *card = dapm->card; sirf_audio_hp_event() local
28 struct sirf_audio_card *sirf_audio_card = snd_soc_card_get_drvdata(card); sirf_audio_hp_event()
39 struct snd_soc_card *card = dapm->card; sirf_audio_spk_event() local
40 struct sirf_audio_card *sirf_audio_card = snd_soc_card_get_drvdata(card); sirf_audio_spk_event()
65 .name = "SiRF audio card",
73 .name = "SiRF audio card",
85 struct snd_soc_card *card = &snd_soc_sirf_audio_card; sirf_audio_probe() local
127 card->dev = &pdev->dev; sirf_audio_probe()
128 snd_soc_card_set_drvdata(card, sirf_audio_card); sirf_audio_probe()
130 ret = devm_snd_soc_register_card(&pdev->dev, card); sirf_audio_probe()
138 {.compatible = "sirf,sirf-audio-card", },
145 .name = "sirf-audio-card",
154 MODULE_DESCRIPTION("ALSA SoC SIRF audio card driver");
/linux-4.1.27/include/sound/
H A Dcore.h83 struct snd_card *card; /* card which holds this device */ member in struct:snd_device
98 char id[16]; /* id string of this card */
103 char components[128]; /* card components delimited with
108 void (*private_free) (struct snd_card *card); /* callback for freeing of
118 struct list_head controls; /* all controls for this card */
124 struct snd_info_entry *proc_id; /* the card id */
127 struct list_head files_list; /* all files associated to this card */
130 spinlock_t files_lock; /* lock the files for this card */
131 int shutdown; /* this card is going down */
133 struct device *dev; /* device assigned to this card */
153 static inline void snd_power_lock(struct snd_card *card) snd_power_lock() argument
155 mutex_lock(&card->power_lock); snd_power_lock()
158 static inline void snd_power_unlock(struct snd_card *card) snd_power_unlock() argument
160 mutex_unlock(&card->power_lock); snd_power_unlock()
163 static inline unsigned int snd_power_get_state(struct snd_card *card) snd_power_get_state() argument
165 return card->power_state; snd_power_get_state()
168 static inline void snd_power_change_state(struct snd_card *card, unsigned int state) snd_power_change_state() argument
170 card->power_state = state; snd_power_change_state()
171 wake_up(&card->power_sleep); snd_power_change_state()
175 int snd_power_wait(struct snd_card *card, unsigned int power_state);
179 #define snd_power_lock(card) do { (void)(card); } while (0)
180 #define snd_power_unlock(card) do { (void)(card); } while (0) snd_power_wait()
181 static inline int snd_power_wait(struct snd_card *card, unsigned int state) { return 0; } snd_power_wait() argument
182 #define snd_power_get_state(card) ({ (void)(card); SNDRV_CTL_POWER_D0; })
183 #define snd_power_change_state(card, state) do { (void)(card); } while (0)
189 int card; /* card number */ member in struct:snd_minor
194 struct snd_card *card_ptr; /* assigned card instance */
198 static inline struct device *snd_card_get_device_link(struct snd_card *card) snd_card_get_device_link() argument
200 return card ? &card->card_dev : NULL; snd_card_get_device_link()
209 void snd_request_card(int card);
211 void snd_device_initialize(struct device *dev, struct snd_card *card);
213 int snd_register_device(int type, struct snd_card *card, int dev,
220 int snd_register_oss_device(int type, struct snd_card *card, int dev,
222 int snd_unregister_oss_device(int type, struct snd_card *card, int dev);
247 int snd_card_locked(int card); snd_minor_info_oss_done()
252 extern int (*snd_mixer_oss_notify_callback)(struct snd_card *card, int cmd); snd_minor_info_oss_done()
259 int snd_card_disconnect(struct snd_card *card); snd_minor_info_oss_done()
260 int snd_card_free(struct snd_card *card); snd_minor_info_oss_done()
261 int snd_card_free_when_closed(struct snd_card *card); snd_minor_info_oss_done()
262 void snd_card_set_id(struct snd_card *card, const char *id); snd_minor_info_oss_done()
263 int snd_card_register(struct snd_card *card); snd_minor_info_oss_done()
266 int snd_card_add_dev_attr(struct snd_card *card, snd_minor_info_oss_done()
268 int snd_component_add(struct snd_card *card, const char *component); snd_minor_info_oss_done()
269 int snd_card_file_add(struct snd_card *card, struct file *file); snd_minor_info_oss_done()
270 int snd_card_file_remove(struct snd_card *card, struct file *file); snd_minor_info_oss_done()
271 #define snd_card_unref(card) put_device(&(card)->card_dev) snd_minor_info_oss_done()
273 #define snd_card_set_dev(card, devptr) ((card)->dev = (devptr)) snd_minor_info_oss_done()
277 int snd_device_new(struct snd_card *card, enum snd_device_type type, snd_minor_info_oss_done()
279 int snd_device_register(struct snd_card *card, void *device_data); snd_minor_info_oss_done()
280 int snd_device_register_all(struct snd_card *card); snd_minor_info_oss_done()
281 void snd_device_disconnect(struct snd_card *card, void *device_data); snd_minor_info_oss_done()
282 void snd_device_disconnect_all(struct snd_card *card); snd_minor_info_oss_done()
283 void snd_device_free(struct snd_card *card, void *device_data); snd_minor_info_oss_done()
284 void snd_device_free_all(struct snd_card *card); snd_minor_info_oss_done()
/linux-4.1.27/sound/isa/ad1816a/
H A Dad1816a.c3 card-ad1816a.c - driver for ADI SoundPort AD1816A based soundcards.
46 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
47 static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */
94 #define DRIVER_NAME "snd-card-ad1816a"
97 static int snd_card_ad1816a_pnp(int dev, struct pnp_card_link *card, snd_card_ad1816a_pnp() argument
103 pdev = pnp_request_card_device(card, id->devs[0].id, NULL); snd_card_ad1816a_pnp()
119 pdev = pnp_request_card_device(card, id->devs[1].id, NULL); snd_card_ad1816a_pnp()
142 struct snd_card *card; snd_card_ad1816a_probe() local
146 error = snd_card_new(&pcard->card->dev, snd_card_ad1816a_probe()
148 sizeof(struct snd_ad1816a), &card); snd_card_ad1816a_probe()
151 chip = card->private_data; snd_card_ad1816a_probe()
154 snd_card_free(card); snd_card_ad1816a_probe()
158 if ((error = snd_ad1816a_create(card, port[dev], snd_card_ad1816a_probe()
163 snd_card_free(card); snd_card_ad1816a_probe()
169 strcpy(card->driver, "AD1816A"); snd_card_ad1816a_probe()
170 strcpy(card->shortname, "ADI SoundPort AD1816A"); snd_card_ad1816a_probe()
171 sprintf(card->longname, "%s, SS at 0x%lx, irq %d, dma %d&%d", snd_card_ad1816a_probe()
172 card->shortname, chip->port, irq[dev], dma1[dev], dma2[dev]); snd_card_ad1816a_probe()
175 snd_card_free(card); snd_card_ad1816a_probe()
180 snd_card_free(card); snd_card_ad1816a_probe()
186 snd_card_free(card); snd_card_ad1816a_probe()
191 if (snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401, snd_card_ad1816a_probe()
198 if (snd_opl3_create(card, snd_card_ad1816a_probe()
205 snd_card_free(card); snd_card_ad1816a_probe()
211 if ((error = snd_card_register(card)) < 0) { snd_card_ad1816a_probe()
212 snd_card_free(card); snd_card_ad1816a_probe()
215 pnp_set_card_drvdata(pcard, card); snd_card_ad1816a_probe()
221 static int snd_ad1816a_pnp_detect(struct pnp_card_link *card, snd_ad1816a_pnp_detect() argument
230 res = snd_card_ad1816a_probe(dev, card, id); snd_ad1816a_pnp_detect()
250 struct snd_card *card = pnp_get_card_drvdata(pcard); snd_ad1816a_pnp_suspend() local
252 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); snd_ad1816a_pnp_suspend()
253 snd_ad1816a_suspend(card->private_data); snd_ad1816a_pnp_suspend()
259 struct snd_card *card = pnp_get_card_drvdata(pcard); snd_ad1816a_pnp_resume() local
261 snd_ad1816a_resume(card->private_data); snd_ad1816a_pnp_resume()
262 snd_power_change_state(card, SNDRV_CTL_POWER_D0); snd_ad1816a_pnp_resume()
/linux-4.1.27/sound/pci/trident/
H A Dtrident.c49 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
50 static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
80 struct snd_card *card; snd_trident_probe() local
93 0, &card); snd_trident_probe()
97 if ((err = snd_trident_create(card, pci, snd_trident_probe()
102 snd_card_free(card); snd_trident_probe()
105 card->private_data = trident; snd_trident_probe()
120 strcpy(card->driver, str); snd_trident_probe()
122 strcpy(card->shortname, "SiS "); snd_trident_probe()
124 strcpy(card->shortname, "Trident "); snd_trident_probe()
126 strcat(card->shortname, card->driver); snd_trident_probe()
127 sprintf(card->longname, "%s PCI Audio at 0x%lx, irq %d", snd_trident_probe()
128 card->shortname, trident->port, trident->irq); snd_trident_probe()
131 snd_card_free(card); snd_trident_probe()
138 snd_card_free(card); snd_trident_probe()
145 snd_card_free(card); snd_trident_probe()
150 (err = snd_mpu401_uart_new(card, 0, MPU401_HW_TRID4DWAVE, snd_trident_probe()
155 snd_card_free(card); snd_trident_probe()
161 if ((err = snd_card_register(card)) < 0) { snd_trident_probe()
162 snd_card_free(card); snd_trident_probe()
165 pci_set_drvdata(pci, card); snd_trident_probe()
/linux-4.1.27/drivers/uwb/
H A Dwhci.c27 u64 whci_capdata_quirks(struct whci_card *card, u64 capdata) whci_capdata_quirks() argument
30 struct pci_dev *pci_dev = card->pci; whci_capdata_quirks()
92 static int whci_add_cap(struct whci_card *card, int n) whci_add_cap() argument
98 umc = umc_device_create(&card->pci->dev, n); whci_add_cap()
102 capdata = le_readq(card->uwbbase + UWBCAPDATA(n)); whci_add_cap()
106 capdata = whci_capdata_quirks(card, capdata); whci_add_cap()
112 umc->resource.start = pci_resource_start(card->pci, bar) whci_add_cap()
117 umc->resource.flags = card->pci->resource[bar].flags; whci_add_cap()
118 umc->resource.parent = &card->pci->resource[bar]; whci_add_cap()
119 umc->irq = card->pci->irq; whci_add_cap()
124 card->devs[n] = umc; whci_add_cap()
132 static void whci_del_cap(struct whci_card *card, int n) whci_del_cap() argument
134 struct umc_dev *umc = card->devs[n]; whci_del_cap()
155 struct whci_card *card; whci_probe() local
176 card = kzalloc(sizeof(struct whci_card) whci_probe()
179 if (card == NULL) whci_probe()
181 card->pci = pci; whci_probe()
182 card->n_caps = n_caps; whci_probe()
186 UWBCAPDATA_SIZE(card->n_caps), whci_probe()
190 card->uwbbase = pci_iomap(pci, 0, UWBCAPDATA_SIZE(card->n_caps)); whci_probe()
191 if (!card->uwbbase) whci_probe()
195 for (n = 0; n <= card->n_caps; n++) { whci_probe()
196 err = whci_add_cap(card, n); whci_probe()
206 pci_set_drvdata(pci, card); whci_probe()
210 pci_iounmap(pci, card->uwbbase); whci_probe()
212 release_mem_region(pci_resource_start(pci, 0), UWBCAPDATA_SIZE(card->n_caps)); whci_probe()
214 kfree(card); whci_probe()
226 struct whci_card *card = pci_get_drvdata(pci); whci_remove() local
232 for (n = card->n_caps; n >= 0 ; n--) whci_remove()
233 whci_del_cap(card, n); whci_remove()
234 pci_iounmap(pci, card->uwbbase); whci_remove()
235 release_mem_region(pci_resource_start(pci, 0), UWBCAPDATA_SIZE(card->n_caps)); whci_remove()
236 kfree(card); whci_remove()
/linux-4.1.27/sound/soc/tegra/
H A Dtegra_wm8903.c63 struct snd_soc_card *card = rtd->card; tegra_wm8903_hw_params() local
64 struct tegra_wm8903 *machine = snd_soc_card_get_drvdata(card); tegra_wm8903_hw_params()
85 dev_err(card->dev, "Can't configure clocks\n"); tegra_wm8903_hw_params()
92 dev_err(card->dev, "codec_dai clock not set\n"); tegra_wm8903_hw_params()
132 struct snd_soc_card *card = dapm->card; tegra_wm8903_event_int_spk() local
133 struct tegra_wm8903 *machine = snd_soc_card_get_drvdata(card); tegra_wm8903_event_int_spk()
148 struct snd_soc_card *card = dapm->card; tegra_wm8903_event_hp() local
149 struct tegra_wm8903 *machine = snd_soc_card_get_drvdata(card); tegra_wm8903_event_hp()
174 struct snd_soc_card *card = rtd->card; tegra_wm8903_init() local
175 struct tegra_wm8903 *machine = snd_soc_card_get_drvdata(card); tegra_wm8903_init()
179 snd_soc_card_jack_new(rtd->card, "Headphone Jack", tegra_wm8903_init()
188 snd_soc_card_jack_new(rtd->card, "Mic Jack", SND_JACK_MICROPHONE, tegra_wm8903_init()
195 snd_soc_dapm_force_enable_pin(&card->dapm, "MICBIAS"); tegra_wm8903_init()
200 static int tegra_wm8903_remove(struct snd_soc_card *card) tegra_wm8903_remove() argument
202 struct snd_soc_pcm_runtime *rtd = &(card->rtd[0]); tegra_wm8903_remove()
205 struct tegra_wm8903 *machine = snd_soc_card_get_drvdata(card); tegra_wm8903_remove()
244 struct snd_soc_card *card = &snd_soc_tegra_wm8903; tegra_wm8903_driver_probe() local
255 card->dev = &pdev->dev; tegra_wm8903_driver_probe()
256 platform_set_drvdata(pdev, card); tegra_wm8903_driver_probe()
257 snd_soc_card_set_drvdata(card, machine); tegra_wm8903_driver_probe()
267 dev_err(card->dev, "cannot get spkr_en gpio\n"); tegra_wm8903_driver_probe()
280 dev_err(card->dev, "cannot get hp_mute gpio\n"); tegra_wm8903_driver_probe()
299 dev_err(card->dev, "cannot get int_mic_en gpio\n"); tegra_wm8903_driver_probe()
314 dev_err(card->dev, "cannot get ext_mic_en gpio\n"); tegra_wm8903_driver_probe()
319 ret = snd_soc_of_parse_card_name(card, "nvidia,model"); tegra_wm8903_driver_probe()
323 ret = snd_soc_of_parse_audio_routing(card, "nvidia,audio-routing"); tegra_wm8903_driver_probe()
351 ret = snd_soc_register_card(card); tegra_wm8903_driver_probe()
368 struct snd_soc_card *card = platform_get_drvdata(pdev); tegra_wm8903_driver_remove() local
369 struct tegra_wm8903 *machine = snd_soc_card_get_drvdata(card); tegra_wm8903_driver_remove()
371 snd_soc_unregister_card(card); tegra_wm8903_driver_remove()
H A Dtegra_alc5632.c44 struct snd_soc_card *card = rtd->card; tegra_alc5632_asoc_hw_params() local
45 struct tegra_alc5632 *alc5632 = snd_soc_card_get_drvdata(card); tegra_alc5632_asoc_hw_params()
54 dev_err(card->dev, "Can't configure clocks\n"); tegra_alc5632_asoc_hw_params()
61 dev_err(card->dev, "codec_dai clock not set\n"); tegra_alc5632_asoc_hw_params()
104 struct tegra_alc5632 *machine = snd_soc_card_get_drvdata(rtd->card); tegra_alc5632_asoc_init()
106 snd_soc_card_jack_new(rtd->card, "Headset Jack", SND_JACK_HEADSET, tegra_alc5632_asoc_init()
118 snd_soc_dapm_force_enable_pin(&rtd->card->dapm, "MICBIAS1"); tegra_alc5632_asoc_init()
123 static int tegra_alc5632_card_remove(struct snd_soc_card *card) tegra_alc5632_card_remove() argument
125 struct tegra_alc5632 *machine = snd_soc_card_get_drvdata(card); tegra_alc5632_card_remove()
162 struct snd_soc_card *card = &snd_soc_tegra_alc5632; tegra_alc5632_probe() local
173 card->dev = &pdev->dev; tegra_alc5632_probe()
174 platform_set_drvdata(pdev, card); tegra_alc5632_probe()
175 snd_soc_card_set_drvdata(card, alc5632); tegra_alc5632_probe()
181 ret = snd_soc_of_parse_card_name(card, "nvidia,model"); tegra_alc5632_probe()
185 ret = snd_soc_of_parse_audio_routing(card, "nvidia,audio-routing"); tegra_alc5632_probe()
214 ret = snd_soc_register_card(card); tegra_alc5632_probe()
231 struct snd_soc_card *card = platform_get_drvdata(pdev); tegra_alc5632_remove() local
232 struct tegra_alc5632 *machine = snd_soc_card_get_drvdata(card); tegra_alc5632_remove()
234 snd_soc_unregister_card(card); tegra_alc5632_remove()
H A Dtegra_rt5640.c55 struct snd_soc_card *card = rtd->card; tegra_rt5640_asoc_hw_params() local
56 struct tegra_rt5640 *machine = snd_soc_card_get_drvdata(card); tegra_rt5640_asoc_hw_params()
65 dev_err(card->dev, "Can't configure clocks\n"); tegra_rt5640_asoc_hw_params()
72 dev_err(card->dev, "codec_dai clock not set\n"); tegra_rt5640_asoc_hw_params()
111 struct tegra_rt5640 *machine = snd_soc_card_get_drvdata(rtd->card); tegra_rt5640_asoc_init()
113 snd_soc_card_jack_new(rtd->card, "Headphones", SND_JACK_HEADPHONE, tegra_rt5640_asoc_init()
129 static int tegra_rt5640_card_remove(struct snd_soc_card *card) tegra_rt5640_card_remove() argument
131 struct tegra_rt5640 *machine = snd_soc_card_get_drvdata(card); tegra_rt5640_card_remove()
167 struct snd_soc_card *card = &snd_soc_tegra_rt5640; tegra_rt5640_probe() local
178 card->dev = &pdev->dev; tegra_rt5640_probe()
179 platform_set_drvdata(pdev, card); tegra_rt5640_probe()
180 snd_soc_card_set_drvdata(card, machine); tegra_rt5640_probe()
187 ret = snd_soc_of_parse_card_name(card, "nvidia,model"); tegra_rt5640_probe()
191 ret = snd_soc_of_parse_audio_routing(card, "nvidia,audio-routing"); tegra_rt5640_probe()
219 ret = snd_soc_register_card(card); tegra_rt5640_probe()
236 struct snd_soc_card *card = platform_get_drvdata(pdev); tegra_rt5640_remove() local
237 struct tegra_rt5640 *machine = snd_soc_card_get_drvdata(card); tegra_rt5640_remove()
239 snd_soc_unregister_card(card); tegra_rt5640_remove()
H A Dtegra_rt5677.c57 struct snd_soc_card *card = rtd->card; tegra_rt5677_asoc_hw_params() local
58 struct tegra_rt5677 *machine = snd_soc_card_get_drvdata(card); tegra_rt5677_asoc_hw_params()
66 dev_err(card->dev, "Can't configure clocks\n"); tegra_rt5677_asoc_hw_params()
73 dev_err(card->dev, "codec_dai clock not set\n"); tegra_rt5677_asoc_hw_params()
84 struct snd_soc_card *card = dapm->card; tegra_rt5677_event_hp() local
85 struct tegra_rt5677 *machine = snd_soc_card_get_drvdata(card); tegra_rt5677_event_hp()
144 struct tegra_rt5677 *machine = snd_soc_card_get_drvdata(rtd->card); tegra_rt5677_asoc_init()
146 snd_soc_card_jack_new(rtd->card, "Headphone Jack", SND_JACK_HEADPHONE, tegra_rt5677_asoc_init()
157 snd_soc_card_jack_new(rtd->card, "Mic Jack", SND_JACK_MICROPHONE, tegra_rt5677_asoc_init()
167 snd_soc_dapm_force_enable_pin(&rtd->card->dapm, "MICBIAS1"); tegra_rt5677_asoc_init()
172 static int tegra_rt5677_card_remove(struct snd_soc_card *card) tegra_rt5677_card_remove() argument
174 struct tegra_rt5677 *machine = snd_soc_card_get_drvdata(card); tegra_rt5677_card_remove()
215 struct snd_soc_card *card = &snd_soc_tegra_rt5677; tegra_rt5677_probe() local
224 card->dev = &pdev->dev; tegra_rt5677_probe()
225 platform_set_drvdata(pdev, card); tegra_rt5677_probe()
226 snd_soc_card_set_drvdata(card, machine); tegra_rt5677_probe()
244 dev_err(card->dev, "cannot get hp_en gpio\n"); tegra_rt5677_probe()
258 dev_err(card->dev, "cannot get dmic_clk_en gpio\n"); tegra_rt5677_probe()
263 ret = snd_soc_of_parse_card_name(card, "nvidia,model"); tegra_rt5677_probe()
267 ret = snd_soc_of_parse_audio_routing(card, "nvidia,audio-routing"); tegra_rt5677_probe()
294 ret = snd_soc_register_card(card); tegra_rt5677_probe()
311 struct snd_soc_card *card = platform_get_drvdata(pdev); tegra_rt5677_remove() local
312 struct tegra_rt5677 *machine = snd_soc_card_get_drvdata(card); tegra_rt5677_remove()
314 snd_soc_unregister_card(card); tegra_rt5677_remove()
H A Dtegra_wm9712.c49 return snd_soc_dapm_force_enable_pin(&rtd->card->dapm, "Mic Bias"); tegra_wm9712_init()
74 struct snd_soc_card *card = &snd_soc_tegra_wm9712; tegra_wm9712_driver_probe() local
85 card->dev = &pdev->dev; tegra_wm9712_driver_probe()
86 platform_set_drvdata(pdev, card); tegra_wm9712_driver_probe()
87 snd_soc_card_set_drvdata(card, machine); tegra_wm9712_driver_probe()
99 ret = snd_soc_of_parse_card_name(card, "nvidia,model"); tegra_wm9712_driver_probe()
103 ret = snd_soc_of_parse_audio_routing(card, "nvidia,audio-routing"); tegra_wm9712_driver_probe()
126 ret = snd_soc_register_card(card); tegra_wm9712_driver_probe()
146 struct snd_soc_card *card = platform_get_drvdata(pdev); tegra_wm9712_driver_remove() local
147 struct tegra_wm9712 *machine = snd_soc_card_get_drvdata(card); tegra_wm9712_driver_remove()
149 snd_soc_unregister_card(card); tegra_wm9712_driver_remove()
H A Dtegra_wm8753.c58 struct snd_soc_card *card = rtd->card; tegra_wm8753_hw_params() local
59 struct tegra_wm8753 *machine = snd_soc_card_get_drvdata(card); tegra_wm8753_hw_params()
78 dev_err(card->dev, "Can't configure clocks\n"); tegra_wm8753_hw_params()
85 dev_err(card->dev, "codec_dai clock not set\n"); tegra_wm8753_hw_params()
125 struct snd_soc_card *card = &snd_soc_tegra_wm8753; tegra_wm8753_driver_probe() local
136 card->dev = &pdev->dev; tegra_wm8753_driver_probe()
137 platform_set_drvdata(pdev, card); tegra_wm8753_driver_probe()
138 snd_soc_card_set_drvdata(card, machine); tegra_wm8753_driver_probe()
140 ret = snd_soc_of_parse_card_name(card, "nvidia,model"); tegra_wm8753_driver_probe()
144 ret = snd_soc_of_parse_audio_routing(card, "nvidia,audio-routing"); tegra_wm8753_driver_probe()
172 ret = snd_soc_register_card(card); tegra_wm8753_driver_probe()
189 struct snd_soc_card *card = platform_get_drvdata(pdev); tegra_wm8753_driver_remove() local
190 struct tegra_wm8753 *machine = snd_soc_card_get_drvdata(card); tegra_wm8753_driver_remove()
192 snd_soc_unregister_card(card); tegra_wm8753_driver_remove()
/linux-4.1.27/sound/isa/cs423x/
H A Dcs4231.c43 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
44 static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */
93 struct snd_card *card; snd_cs4231_probe() local
97 error = snd_card_new(dev, index[n], id[n], THIS_MODULE, 0, &card); snd_cs4231_probe()
101 error = snd_wss_create(card, port[n], -1, irq[n], dma1[n], dma2[n], snd_cs4231_probe()
106 card->private_data = chip; snd_cs4231_probe()
112 strcpy(card->driver, "CS4231"); snd_cs4231_probe()
113 strcpy(card->shortname, chip->pcm->name); snd_cs4231_probe()
115 sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d", snd_cs4231_probe()
118 sprintf(card->longname + strlen(card->longname), "&%d", dma2[n]); snd_cs4231_probe()
131 if (snd_mpu401_uart_new(card, 0, MPU401_HW_CS4232, snd_cs4231_probe()
137 error = snd_card_register(card); snd_cs4231_probe()
141 dev_set_drvdata(dev, card); snd_cs4231_probe()
144 out: snd_card_free(card); snd_cs4231_probe()
157 struct snd_card *card = dev_get_drvdata(dev); snd_cs4231_suspend() local
158 struct snd_wss *chip = card->private_data; snd_cs4231_suspend()
160 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); snd_cs4231_suspend()
167 struct snd_card *card = dev_get_drvdata(dev); snd_cs4231_resume() local
168 struct snd_wss *chip = card->private_data; snd_cs4231_resume()
171 snd_power_change_state(card, SNDRV_CTL_POWER_D0); snd_cs4231_resume()
/linux-4.1.27/sound/pci/cs46xx/
H A Dcs46xx.c48 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
49 static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
80 struct snd_card *card; snd_card_cs46xx_probe() local
92 0, &card); snd_card_cs46xx_probe()
95 if ((err = snd_cs46xx_create(card, pci, snd_card_cs46xx_probe()
98 snd_card_free(card); snd_card_cs46xx_probe()
101 card->private_data = chip; snd_card_cs46xx_probe()
104 snd_card_free(card); snd_card_cs46xx_probe()
109 snd_card_free(card); snd_card_cs46xx_probe()
113 snd_card_free(card); snd_card_cs46xx_probe()
118 snd_card_free(card); snd_card_cs46xx_probe()
124 snd_card_free(card); snd_card_cs46xx_probe()
130 snd_card_free(card); snd_card_cs46xx_probe()
134 snd_card_free(card); snd_card_cs46xx_probe()
141 strcpy(card->driver, "CS46xx"); snd_card_cs46xx_probe()
142 strcpy(card->shortname, "Sound Fusion CS46xx"); snd_card_cs46xx_probe()
143 sprintf(card->longname, "%s at 0x%lx/0x%lx, irq %i", snd_card_cs46xx_probe()
144 card->shortname, snd_card_cs46xx_probe()
149 if ((err = snd_card_register(card)) < 0) { snd_card_cs46xx_probe()
150 snd_card_free(card); snd_card_cs46xx_probe()
154 pci_set_drvdata(pci, card); snd_card_cs46xx_probe()
/linux-4.1.27/sound/usb/hiface/
H A Dchip.c47 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* Id for card */
48 static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
72 struct snd_card *card = NULL; hiface_chip_create() local
79 /* if we are here, card can be registered in alsa. */ hiface_chip_create()
81 sizeof(*chip), &card); hiface_chip_create()
83 dev_err(&device->dev, "cannot create alsa card.\n"); hiface_chip_create()
87 strlcpy(card->driver, DRIVER_NAME, sizeof(card->driver)); hiface_chip_create()
90 strlcpy(card->shortname, quirk->device_name, sizeof(card->shortname)); hiface_chip_create()
92 strlcpy(card->shortname, "M2Tech generic audio", sizeof(card->shortname)); hiface_chip_create()
94 strlcat(card->longname, card->shortname, sizeof(card->longname)); hiface_chip_create()
95 len = strlcat(card->longname, " at ", sizeof(card->longname)); hiface_chip_create()
96 if (len < sizeof(card->longname)) hiface_chip_create()
97 usb_make_path(device, card->longname + len, hiface_chip_create()
98 sizeof(card->longname) - len); hiface_chip_create()
100 chip = card->private_data; hiface_chip_create()
102 chip->card = card; hiface_chip_create()
123 /* check whether the card is already registered */ hiface_chip_probe()
145 ret = snd_card_register(chip->card); hiface_chip_probe()
147 dev_err(&device->dev, "cannot register " CARD_NAME " card\n"); hiface_chip_probe()
157 snd_card_free(chip->card); hiface_chip_probe()
166 struct snd_card *card; hiface_chip_disconnect() local
172 card = chip->card; hiface_chip_disconnect()
175 snd_card_disconnect(card); hiface_chip_disconnect()
178 snd_card_free_when_closed(card); hiface_chip_disconnect()
/linux-4.1.27/drivers/tty/
H A Disicom.c36 * when the last port on the card is
56 * ISIHP-4X card
207 struct isi_board *card; member in struct:isi_port
218 * Locking functions for card level locking. We need to own both
219 * the kernel lock for the card and have the card in a position that
237 static int lock_card(struct isi_board *card) lock_card() argument
239 unsigned long base = card->base; lock_card()
243 spin_lock_irqsave(&card->card_lock, card->flags); lock_card()
249 spin_unlock_irqrestore(&card->card_lock, card->flags); lock_card()
252 pr_warn("Failed to lock Card (0x%lx)\n", card->base); lock_card()
254 return 0; /* Failed to acquire the card! */ lock_card()
257 static void unlock_card(struct isi_board *card) unlock_card() argument
259 spin_unlock_irqrestore(&card->card_lock, card->flags); unlock_card()
266 /* card->lock HAS to be held */ raise_dtr()
269 struct isi_board *card = port->card; raise_dtr() local
270 unsigned long base = card->base; raise_dtr()
276 outw(0x8000 | (channel << card->shift_count) | 0x02, base); raise_dtr()
282 /* card->lock HAS to be held */ drop_dtr()
285 struct isi_board *card = port->card; drop_dtr() local
286 unsigned long base = card->base; drop_dtr()
292 outw(0x8000 | (channel << card->shift_count) | 0x02, base); drop_dtr()
298 /* card->lock HAS to be held */ raise_rts()
301 struct isi_board *card = port->card; raise_rts() local
302 unsigned long base = card->base; raise_rts()
308 outw(0x8000 | (channel << card->shift_count) | 0x02, base); raise_rts()
314 /* card->lock HAS to be held */ drop_rts()
317 struct isi_board *card = port->card; drop_rts() local
318 unsigned long base = card->base; drop_rts()
324 outw(0x8000 | (channel << card->shift_count) | 0x02, base); drop_rts()
330 /* card->lock MUST NOT be held */
335 struct isi_board *card = ip->card; isicom_dtr_rts() local
336 unsigned long base = card->base; isicom_dtr_rts()
339 if (!lock_card(card)) isicom_dtr_rts()
343 outw(0x8000 | (channel << card->shift_count) | 0x02, base); isicom_dtr_rts()
348 outw(0x8000 | (channel << card->shift_count) | 0x02, base); isicom_dtr_rts()
353 unlock_card(card); isicom_dtr_rts()
356 /* card->lock HAS to be held */ drop_dtr_rts()
359 struct isi_board *card = port->card; drop_dtr_rts() local
360 unsigned long base = card->base; drop_dtr_rts()
366 outw(0x8000 | (channel << card->shift_count) | 0x02, base); drop_dtr_rts()
397 * We shovel data into the card buffers on a regular basis. The card
405 short count = (BOARD_COUNT-1), card; isicom_tx() local
411 card = (prev_card + 1) & 0x0003; isicom_tx()
413 if (isi_card[card].status & BOARD_ACTIVE) isicom_tx()
415 card = (card + 1) & 0x0003; isicom_tx()
417 if (!(isi_card[card].status & BOARD_ACTIVE)) isicom_tx()
420 prev_card = card; isicom_tx()
422 count = isi_card[card].port_count; isicom_tx()
423 port = isi_card[card].ports; isicom_tx()
424 base = isi_card[card].base; isicom_tx()
426 spin_lock_irqsave(&isi_card[card].card_lock, flags); isicom_tx()
454 outw((port->channel << isi_card[card].shift_count) | txcount, isicom_tx()
505 spin_unlock_irqrestore(&isi_card[card].card_lock, flags); isicom_tx()
517 struct isi_board *card = dev_id; isicom_interrupt() local
525 if (!card || !(card->status & FIRMWARE_LOADED)) isicom_interrupt()
528 base = card->base; isicom_interrupt()
530 /* did the card interrupt us? */ isicom_interrupt()
534 spin_lock(&card->card_lock); isicom_interrupt()
537 * disable any interrupts from the PCI card and lower the isicom_interrupt()
545 channel = (header & 0x7800) >> card->shift_count; isicom_interrupt()
548 if (channel + 1 > card->port_count) { isicom_interrupt()
552 spin_unlock(&card->card_lock); isicom_interrupt()
555 port = card->ports + channel; isicom_interrupt()
558 spin_unlock(&card->card_lock); isicom_interrupt()
572 spin_unlock(&card->card_lock); isicom_interrupt()
677 spin_unlock(&card->card_lock); isicom_interrupt()
686 struct isi_board *card = port->card; isicom_config_port() local
688 unsigned long base = card->base; isicom_config_port()
690 shift_count = card->shift_count; isicom_config_port()
699 * then the card is programmed for 57.6Kbps or 115Kbps isicom_config_port()
785 /* rx enabled -> enable port for rx on the card */ isicom_config_port()
787 card->port_status |= (1 << channel); isicom_config_port()
788 outw(card->port_status, base + 0x02); isicom_config_port()
814 struct isi_board *card = port->card; isicom_activate() local
820 spin_lock_irqsave(&card->card_lock, flags); isicom_activate()
821 isicom_setup_board(card); isicom_activate()
826 if (WaitTillCardIsFree(card->base) == 0) { isicom_activate()
827 outw(0x8000 | (port->channel << card->shift_count) | 0x02, isicom_activate()
828 card->base); isicom_activate()
829 outw(((ISICOM_KILLTX | ISICOM_KILLRX) << 8) | 0x06, card->base); isicom_activate()
830 InterruptTheCard(card->base); isicom_activate()
833 spin_unlock_irqrestore(&card->card_lock, flags); isicom_activate()
847 struct isi_board *card; isicom_find_port() local
852 card = &isi_card[board]; isicom_find_port()
854 if (!(card->status & FIRMWARE_LOADED)) isicom_find_port()
857 /* open on a port greater than the port count for the card !!! */ isicom_find_port()
858 if (line > ((board * 16) + card->port_count - 1)) isicom_find_port()
884 /* card->lock HAS to be held */ isicom_shutdown_port()
887 struct isi_board *card = port->card; isicom_shutdown_port() local
889 if (--card->count < 0) { isicom_shutdown_port()
891 __func__, card->base, card->count); isicom_shutdown_port()
892 card->count = 0; isicom_shutdown_port()
895 if (!card->count) isicom_shutdown_port()
896 card->status &= BOARD_ACTIVE; isicom_shutdown_port()
902 struct isi_board *card = port->card; isicom_flush_buffer() local
908 spin_lock_irqsave(&card->card_lock, flags); isicom_flush_buffer()
910 spin_unlock_irqrestore(&card->card_lock, flags); isicom_flush_buffer()
918 struct isi_board *card = ip->card; isicom_shutdown() local
921 /* indicate to the card that no more data can be received isicom_shutdown()
923 spin_lock_irqsave(&card->card_lock, flags); isicom_shutdown()
924 card->port_status &= ~(1 << ip->channel); isicom_shutdown()
925 outw(card->port_status, card->base + 0x02); isicom_shutdown()
927 spin_unlock_irqrestore(&card->card_lock, flags); isicom_shutdown()
950 struct isi_board *card = port->card; isicom_write() local
957 spin_lock_irqsave(&card->card_lock, flags); isicom_write()
975 spin_unlock_irqrestore(&card->card_lock, flags); isicom_write()
983 struct isi_board *card = port->card; isicom_put_char() local
989 spin_lock_irqsave(&card->card_lock, flags); isicom_put_char()
991 spin_unlock_irqrestore(&card->card_lock, flags); isicom_put_char()
998 spin_unlock_irqrestore(&card->card_lock, flags); isicom_put_char()
1015 data output to the card ... that's the best we can do. */ isicom_flush_chars()
1047 struct isi_board *card = port->card; isicom_send_break() local
1048 unsigned long base = card->base; isicom_send_break()
1053 if (!lock_card(card)) isicom_send_break()
1056 outw(0x8000 | ((port->channel) << (card->shift_count)) | 0x3, base); isicom_send_break()
1061 unlock_card(card); isicom_send_break()
1091 spin_lock_irqsave(&port->card->card_lock, flags); isicom_tiocmset()
1101 spin_unlock_irqrestore(&port->card->card_lock, flags); isicom_tiocmset()
1138 spin_lock_irqsave(&port->card->card_lock, flags); isicom_set_serial_info()
1140 spin_unlock_irqrestore(&port->card->card_lock, flags); isicom_set_serial_info()
1155 out_info.port = port->card->base; isicom_get_serial_info()
1156 out_info.irq = port->card->irq; isicom_get_serial_info()
1203 spin_lock_irqsave(&port->card->card_lock, flags); isicom_set_termios()
1205 spin_unlock_irqrestore(&port->card->card_lock, flags); isicom_set_termios()
1218 struct isi_board *card = port->card; isicom_throttle() local
1223 /* tell the card that this port cannot handle any more data for now */ isicom_throttle()
1224 card->port_status &= ~(1 << port->channel); isicom_throttle()
1225 outw(card->port_status, card->base + 0x02); isicom_throttle()
1232 struct isi_board *card = port->card; isicom_unthrottle() local
1237 /* tell the card that this port is ready to accept more data */ isicom_unthrottle()
1238 card->port_status |= (1 << port->channel); isicom_unthrottle()
1239 outw(card->port_status, card->base + 0x02); isicom_unthrottle()
1251 data output to the card. */ isicom_stop()
1264 data output to the card. */ isicom_start()
1311 const unsigned int card, unsigned int *signature) reset_card()
1318 dev_dbg(&pdev->dev, "ISILoad:Resetting Card%d at 0x%lx\n", card + 1, reset_card()
1334 "bad I/O Port Address 0x%lx).\n", card + 1, base); reset_card()
1346 card + 1); reset_card()
1666 port->card = &isi_card[idx]; isicom_init()
1310 reset_card(struct pci_dev *pdev, const unsigned int card, unsigned int *signature) reset_card() argument
/linux-4.1.27/include/linux/platform_data/
H A Dmmc-mxcmmc.h9 * If not present, a writable card with 3,3V is assumed.
13 * 0 for a read/write card
14 * 1 for a read-only card
21 * The board code can call 'handler' on a card detection
35 /* enable card detect using DAT3 */
H A Dmmc-sdhci-s3c.h10 S3C_SDHCI_CD_NONE, /* no CD line, use polling to detect card */
11 S3C_SDHCI_CD_PERMANENT, /* no CD line, card permanently wired to host */
20 * @ext_cd_init: Initialize external card detect subsystem. Called on
23 * that triggers the card detection event. Callback arguments:
25 * state is new state of the card (0 - removed, 1 - inserted).
26 * @ext_cd_cleanup: Cleanup external card detect subsystem. Called on
32 * @cfg_gpio: Configure the GPIO for a specific card bit-width
36 * card speed information.
/linux-4.1.27/sound/isa/ad1848/
H A Dad1848.c5 * Based on card-4232.c by Jaroslav Kysela <perex@perex.cz>
45 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
46 static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */
89 struct snd_card *card; snd_ad1848_probe() local
93 error = snd_card_new(dev, index[n], id[n], THIS_MODULE, 0, &card); snd_ad1848_probe()
97 error = snd_wss_create(card, port[n], -1, irq[n], dma1[n], -1, snd_ad1848_probe()
103 card->private_data = chip; snd_ad1848_probe()
113 strcpy(card->driver, "AD1848"); snd_ad1848_probe()
114 strcpy(card->shortname, chip->pcm->name); snd_ad1848_probe()
116 sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d", snd_ad1848_probe()
119 strcat(card->longname, " [Thinkpad]"); snd_ad1848_probe()
121 error = snd_card_register(card); snd_ad1848_probe()
125 dev_set_drvdata(dev, card); snd_ad1848_probe()
128 out: snd_card_free(card); snd_ad1848_probe()
141 struct snd_card *card = dev_get_drvdata(dev); snd_ad1848_suspend() local
142 struct snd_wss *chip = card->private_data; snd_ad1848_suspend()
144 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); snd_ad1848_suspend()
151 struct snd_card *card = dev_get_drvdata(dev); snd_ad1848_resume() local
152 struct snd_wss *chip = card->private_data; snd_ad1848_resume()
155 snd_power_change_state(card, SNDRV_CTL_POWER_D0); snd_ad1848_resume()
/linux-4.1.27/sound/pci/au88x0/
H A Dau88x0_mixer.c13 static int remove_ctl(struct snd_card *card, const char *name) remove_ctl() argument
19 return snd_ctl_remove_id(card, &id); remove_ctl()
32 if ((err = snd_ac97_bus(vortex->card, 0, &ops, NULL, &pbus)) < 0) snd_vortex_mixer()
40 remove_ctl(vortex->card, "Master Mono Playback Volume"); snd_vortex_mixer()
41 remove_ctl(vortex->card, "Master Mono Playback Switch"); snd_vortex_mixer()
H A Dau88x0.c140 snd_vortex_create(struct snd_card *card, struct pci_dev *pci, vortex_t ** rchip) snd_vortex_create() argument
155 dev_err(card->dev, "error to set DMA mask\n"); snd_vortex_create()
166 chip->card = card; snd_vortex_create()
173 chip->card = card; snd_vortex_create()
184 dev_err(card->dev, "MMIO area remap failed.\n"); snd_vortex_create()
193 dev_err(card->dev, "hw core init failed\n"); snd_vortex_create()
200 dev_err(card->dev, "cannot grab irq\n"); snd_vortex_create()
209 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { snd_vortex_create()
238 struct snd_card *card; snd_vortex_probe() local
251 0, &card); snd_vortex_probe()
256 if ((err = snd_vortex_create(card, pci, &chip)) < 0) { snd_vortex_probe()
257 snd_card_free(card); snd_vortex_probe()
263 strcpy(card->driver, CARD_NAME_SHORT); snd_vortex_probe()
264 sprintf(card->shortname, "Aureal Vortex %s", CARD_NAME_SHORT); snd_vortex_probe()
265 sprintf(card->longname, "%s at 0x%lx irq %i", snd_vortex_probe()
266 card->shortname, chip->io, chip->irq); snd_vortex_probe()
271 snd_card_free(card); snd_vortex_probe()
277 snd_card_free(card); snd_vortex_probe()
283 snd_card_free(card); snd_vortex_probe()
288 snd_card_free(card); snd_vortex_probe()
295 snd_card_free(card); snd_vortex_probe()
302 snd_card_free(card); snd_vortex_probe()
307 snd_card_free(card); snd_vortex_probe()
314 if (snd_seq_device_new(card, 1, SNDRV_SEQ_DEV_ID_VORTEX_SYNTH, snd_vortex_probe()
317 dev_err(card->dev, "Can't initialize Aureal wavetable synth\n"); snd_vortex_probe()
333 snd_card_free(card); snd_vortex_probe()
338 snd_card_free(card); snd_vortex_probe()
344 dev_alert(card->dev, snd_vortex_probe()
345 "The revision (%x) of your card has not been seen before.\n", snd_vortex_probe()
347 dev_alert(card->dev, snd_vortex_probe()
349 snd_card_free(card); snd_vortex_probe()
356 if ((err = snd_card_register(card)) < 0) { snd_vortex_probe()
357 snd_card_free(card); snd_vortex_probe()
361 pci_set_drvdata(pci, card); snd_vortex_probe()
/linux-4.1.27/sound/soc/au1x/
H A Ddb1000.c39 struct snd_soc_card *card = &db1000_ac97; db1000_audio_probe() local
40 card->dev = &pdev->dev; db1000_audio_probe()
41 return snd_soc_register_card(card); db1000_audio_probe()
46 struct snd_soc_card *card = platform_get_drvdata(pdev); db1000_audio_remove() local
47 snd_soc_unregister_card(card); db1000_audio_remove()
/linux-4.1.27/drivers/usb/gadget/function/
H A Du_uac1.c131 ERROR(snd->card, playback_default_hw_params()
132 "Preparing sound card failed: %d\n", (int)result); playback_default_hw_params()
145 INFO(snd->card, playback_default_hw_params()
155 size_t u_audio_playback(struct gaudio *card, void *buf, size_t count) u_audio_playback() argument
157 struct gaudio_snd_dev *snd = &card->playback; u_audio_playback()
170 ERROR(card, "Preparing sound card failed: %d\n", u_audio_playback()
181 ERROR(card, "Playback error: %d\n", (int)result); u_audio_playback()
190 int u_audio_get_playback_channels(struct gaudio *card) u_audio_get_playback_channels() argument
192 return card->playback.channels; u_audio_get_playback_channels()
195 int u_audio_get_playback_rate(struct gaudio *card) u_audio_get_playback_rate() argument
197 return card->playback.rate; u_audio_get_playback_rate()
204 static int gaudio_open_snd_dev(struct gaudio *card) gaudio_open_snd_dev() argument
211 opts = container_of(card->func.fi, struct f_uac1_opts, func_inst); gaudio_open_snd_dev()
217 snd = &card->control; gaudio_open_snd_dev()
221 ERROR(card, "unable to open sound control device file: %s\n", gaudio_open_snd_dev()
226 snd->card = card; gaudio_open_snd_dev()
229 snd = &card->playback; gaudio_open_snd_dev()
234 ERROR(card, "No such PCM playback device: %s\n", fn_play); gaudio_open_snd_dev()
240 snd->card = card; gaudio_open_snd_dev()
244 snd = &card->capture; gaudio_open_snd_dev()
247 ERROR(card, "No such PCM capture device: %s\n", fn_cap); gaudio_open_snd_dev()
249 snd->card = NULL; gaudio_open_snd_dev()
254 snd->card = card; gaudio_open_snd_dev()
292 int gaudio_setup(struct gaudio *card) gaudio_setup() argument
296 ret = gaudio_open_snd_dev(card); gaudio_setup()
298 ERROR(card, "we need at least one control device\n"); gaudio_setup()
H A Du_uac1.h35 * This represents the USB side of an audio card device, managed by a USB
40 struct gaudio *card; member in struct:gaudio_snd_dev
77 int gaudio_setup(struct gaudio *card);
80 size_t u_audio_playback(struct gaudio *card, void *buf, size_t count);
81 int u_audio_get_playback_channels(struct gaudio *card);
82 int u_audio_get_playback_rate(struct gaudio *card);
/linux-4.1.27/drivers/media/pci/ivtv/
H A Divtv-routing.c41 in = &itv->card->radio_input; ivtv_audio_set_io()
43 in = &itv->card->audio_inputs[itv->audio_input]; ivtv_audio_set_io()
47 if (itv->card->hw_muxer & IVTV_HW_M52790) ivtv_audio_set_io()
54 if (itv->card->hw_audio & IVTV_HW_MSP34XX) ivtv_audio_set_io()
56 ivtv_call_hw(itv, itv->card->hw_audio, audio, s_routing, ivtv_audio_set_io()
69 itv->card->video_inputs[inp].video_input, 0, 0); ivtv_video_set_io()
71 type = itv->card->video_inputs[inp].video_type; ivtv_video_set_io()
81 if (itv->card->hw_video & IVTV_HW_GPIO) ivtv_video_set_io()
85 if (itv->card->hw_video & IVTV_HW_UPD64031A) { ivtv_video_set_io()
94 input |= itv->card->gr_config; ivtv_video_set_io()
100 if (itv->card->hw_video & IVTV_HW_UPD6408X) { ivtv_video_set_io()
108 else if (itv->card->hw_video & IVTV_HW_UPD64031A) { ivtv_video_set_io()
112 itv->card->type == IVTV_CARD_CX23416GYC) { ivtv_video_set_io()
/linux-4.1.27/sound/drivers/mpu401/
H A Dmpu401.c36 static int index[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = -2}; /* exclude the first card */
37 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
38 static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */
70 struct snd_card *card; snd_mpu401_create() local
78 0, &card); snd_mpu401_create()
81 strcpy(card->driver, "MPU-401 UART"); snd_mpu401_create()
82 strcpy(card->shortname, card->driver); snd_mpu401_create()
83 sprintf(card->longname, "%s at %#lx, ", card->shortname, port[dev]); snd_mpu401_create()
85 sprintf(card->longname + strlen(card->longname), "irq %d", irq[dev]); snd_mpu401_create()
87 strcat(card->longname, "polled"); snd_mpu401_create()
90 err = snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401, port[dev], 0, snd_mpu401_create()
97 *rcard = card; snd_mpu401_create()
101 snd_card_free(card); snd_mpu401_create()
109 struct snd_card *card; snd_mpu401_probe() local
119 err = snd_mpu401_create(&devptr->dev, dev, &card); snd_mpu401_probe()
122 if ((err = snd_card_register(card)) < 0) { snd_mpu401_probe()
123 snd_card_free(card); snd_mpu401_probe()
126 platform_set_drvdata(devptr, card); snd_mpu401_probe()
188 struct snd_card *card; snd_mpu401_pnp_probe() local
197 err = snd_mpu401_create(&pnp_dev->dev, dev, &card); snd_mpu401_pnp_probe()
200 if ((err = snd_card_register(card)) < 0) { snd_mpu401_pnp_probe()
201 snd_card_free(card); snd_mpu401_pnp_probe()
204 pnp_set_drvdata(pnp_dev, card); snd_mpu401_pnp_probe()
214 struct snd_card *card = (struct snd_card *) pnp_get_drvdata(dev); snd_mpu401_pnp_remove() local
216 snd_card_disconnect(card); snd_mpu401_pnp_remove()
217 snd_card_free_when_closed(card); snd_mpu401_pnp_remove()
/linux-4.1.27/sound/drivers/pcsp/
H A Dpcsp.c27 static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */
28 static bool enable = SNDRV_DEFAULT_ENABLE1; /* Enable this card */
42 static int snd_pcsp_create(struct snd_card *card) snd_pcsp_create() argument
84 pcsp_chip.card = card; snd_pcsp_create()
90 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, &pcsp_chip, &ops); snd_pcsp_create()
99 struct snd_card *card; snd_card_pcsp_probe() local
108 err = snd_card_new(dev, index, id, THIS_MODULE, 0, &card); snd_card_pcsp_probe()
112 err = snd_pcsp_create(card); snd_card_pcsp_probe()
114 snd_card_free(card); snd_card_pcsp_probe()
120 snd_card_free(card); snd_card_pcsp_probe()
126 snd_card_free(card); snd_card_pcsp_probe()
130 strcpy(card->driver, "PC-Speaker"); snd_card_pcsp_probe()
131 strcpy(card->shortname, "pcsp"); snd_card_pcsp_probe()
132 sprintf(card->longname, "Internal PC-Speaker at port 0x%x", snd_card_pcsp_probe()
135 err = snd_card_register(card); snd_card_pcsp_probe()
137 snd_card_free(card); snd_card_pcsp_probe()
165 snd_card_free(chip->card); alsa_card_pcsp_exit()
/linux-4.1.27/include/uapi/linux/
H A Db1lli.h3 * ISDN lowlevel-module for AVM B1-card.
63 #define AVMB1_LOAD 0 /* load image to card */
64 #define AVMB1_ADDCARD 1 /* add a new card - OBSOLETE */
65 #define AVMB1_RESETCARD 2 /* reset a card */
66 #define AVMB1_LOAD_AND_CONFIG 3 /* load image and config to card */
67 #define AVMB1_ADDCARD_WITH_TYPE 4 /* add a new card, with cardtype */
69 #define AVMB1_REMOVECARD 6 /* remove a card - OBSOLETE */
/linux-4.1.27/sound/pci/
H A Dcs5530.c63 struct snd_card *card; member in struct:snd_cs5530
105 static int snd_cs5530_create(struct snd_card *card, snd_cs5530_create() argument
131 chip->card = card; snd_cs5530_create()
163 dev_info(card->dev, "XpressAudio at 0x%lx\n", sb_base); snd_cs5530_create()
165 dev_err(card->dev, "Could not find XpressAudio!\n"); snd_cs5530_create()
171 dev_info(card->dev, "MPU at 0x300\n"); snd_cs5530_create()
173 dev_info(card->dev, "MPU at 0x330\n"); snd_cs5530_create()
185 dev_err(card->dev, "No 16bit DMA enabled\n"); snd_cs5530_create()
197 dev_err(card->dev, "No 8bit DMA enabled\n"); snd_cs5530_create()
211 dev_err(card->dev, "SoundBlaster IRQ not set\n"); snd_cs5530_create()
216 dev_info(card->dev, "IRQ: %d DMA8: %d DMA16: %d\n", irq, dma8, dma16); snd_cs5530_create()
218 err = snd_sbdsp_create(card, sb_base, irq, snd_sb16dsp_interrupt, dma8, snd_cs5530_create()
221 dev_err(card->dev, "Could not create SoundBlaster\n"); snd_cs5530_create()
228 dev_err(card->dev, "Could not create PCM\n"); snd_cs5530_create()
235 dev_err(card->dev, "Could not create Mixer\n"); snd_cs5530_create()
240 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops); snd_cs5530_create()
254 struct snd_card *card; snd_cs5530_probe() local
266 0, &card); snd_cs5530_probe()
271 err = snd_cs5530_create(card, pci, &chip); snd_cs5530_probe()
273 snd_card_free(card); snd_cs5530_probe()
277 strcpy(card->driver, "CS5530"); snd_cs5530_probe()
278 strcpy(card->shortname, "CS5530 Audio"); snd_cs5530_probe()
279 sprintf(card->longname, "%s at 0x%lx", card->shortname, chip->pci_base); snd_cs5530_probe()
281 err = snd_card_register(card); snd_cs5530_probe()
283 snd_card_free(card); snd_cs5530_probe()
286 pci_set_drvdata(pci, card); snd_cs5530_probe()
/linux-4.1.27/sound/soc/fsl/
H A Dpcm030-audio-fabric.c26 struct snd_soc_card *card; member in struct:pcm030_audio_data
58 struct snd_soc_card *card = &pcm030_card; pcm030_fabric_probe() local
71 card->dev = &op->dev; pcm030_fabric_probe()
73 pdata->card = card; pcm030_fabric_probe()
81 for (i = 0; i < card->num_links; i++) pcm030_fabric_probe()
82 card->dai_link[i].platform_of_node = platform_np; pcm030_fabric_probe()
96 ret = snd_soc_register_card(card); pcm030_fabric_probe()
110 ret = snd_soc_unregister_card(pdata->card); pcm030_fabric_remove()
H A Dimx-sgtl5000.c27 struct snd_soc_card card; member in struct:imx_sgtl5000_data
36 struct imx_sgtl5000_data *data = snd_soc_card_get_drvdata(rtd->card); imx_sgtl5000_dai_init()
37 struct device *dev = rtd->card->dev; imx_sgtl5000_dai_init()
148 data->card.dev = &pdev->dev; imx_sgtl5000_probe()
149 ret = snd_soc_of_parse_card_name(&data->card, "model"); imx_sgtl5000_probe()
152 ret = snd_soc_of_parse_audio_routing(&data->card, "audio-routing"); imx_sgtl5000_probe()
155 data->card.num_links = 1; imx_sgtl5000_probe()
156 data->card.owner = THIS_MODULE; imx_sgtl5000_probe()
157 data->card.dai_link = &data->dai; imx_sgtl5000_probe()
158 data->card.dapm_widgets = imx_sgtl5000_dapm_widgets; imx_sgtl5000_probe()
159 data->card.num_dapm_widgets = ARRAY_SIZE(imx_sgtl5000_dapm_widgets); imx_sgtl5000_probe()
161 platform_set_drvdata(pdev, &data->card); imx_sgtl5000_probe()
162 snd_soc_card_set_drvdata(&data->card, data); imx_sgtl5000_probe()
164 ret = devm_snd_soc_register_card(&pdev->dev, &data->card); imx_sgtl5000_probe()
186 struct snd_soc_card *card = platform_get_drvdata(pdev); imx_sgtl5000_remove() local
187 struct imx_sgtl5000_data *data = snd_soc_card_get_drvdata(card); imx_sgtl5000_remove()
H A Dimx-es8328.c30 struct snd_soc_card card; member in struct:imx_es8328_data
50 struct imx_es8328_data *data = container_of(rtd->card, imx_es8328_dai_init()
51 struct imx_es8328_data, card); imx_es8328_dai_init()
56 ret = snd_soc_card_jack_new(rtd->card, "Headphone", imx_es8328_dai_init()
171 data->card.dev = dev; imx_es8328_probe()
172 data->card.dapm_widgets = imx_es8328_dapm_widgets; imx_es8328_probe()
173 data->card.num_dapm_widgets = ARRAY_SIZE(imx_es8328_dapm_widgets); imx_es8328_probe()
174 ret = snd_soc_of_parse_card_name(&data->card, "model"); imx_es8328_probe()
176 dev_err(dev, "Unable to parse card name\n"); imx_es8328_probe()
179 ret = snd_soc_of_parse_audio_routing(&data->card, "audio-routing"); imx_es8328_probe()
184 data->card.num_links = 1; imx_es8328_probe()
185 data->card.owner = THIS_MODULE; imx_es8328_probe()
186 data->card.dai_link = &data->dai; imx_es8328_probe()
188 ret = snd_soc_register_card(&data->card); imx_es8328_probe()
209 snd_soc_unregister_card(&data->card); imx_es8328_remove()
/linux-4.1.27/sound/core/oss/
H A Dmixer_oss.c43 struct snd_card *card; snd_mixer_oss_open() local
51 card = snd_lookup_oss_minor_data(iminor(inode), snd_mixer_oss_open()
53 if (card == NULL) snd_mixer_oss_open()
55 if (card->mixer_oss == NULL) { snd_mixer_oss_open()
56 snd_card_unref(card); snd_mixer_oss_open()
59 err = snd_card_file_add(card, file); snd_mixer_oss_open()
61 snd_card_unref(card); snd_mixer_oss_open()
66 snd_card_file_remove(card, file); snd_mixer_oss_open()
67 snd_card_unref(card); snd_mixer_oss_open()
70 fmixer->card = card; snd_mixer_oss_open()
71 fmixer->mixer = card->mixer_oss; snd_mixer_oss_open()
73 if (!try_module_get(card->module)) { snd_mixer_oss_open()
75 snd_card_file_remove(card, file); snd_mixer_oss_open()
76 snd_card_unref(card); snd_mixer_oss_open()
79 snd_card_unref(card); snd_mixer_oss_open()
89 module_put(fmixer->card->module); snd_mixer_oss_release()
90 snd_card_file_remove(fmixer->card, file); snd_mixer_oss_release()
99 struct snd_card *card = fmixer->card; snd_mixer_oss_info() local
104 strlcpy(info.id, mixer && mixer->id[0] ? mixer->id : card->driver, sizeof(info.id)); snd_mixer_oss_info()
105 strlcpy(info.name, mixer && mixer->name[0] ? mixer->name : card->mixername, sizeof(info.name)); snd_mixer_oss_info()
106 info.modify_counter = card->mixer_oss_change_count; snd_mixer_oss_info()
115 struct snd_card *card = fmixer->card; snd_mixer_oss_info_obsolete() local
120 strlcpy(info.id, mixer && mixer->id[0] ? mixer->id : card->driver, sizeof(info.id)); snd_mixer_oss_info_obsolete()
121 strlcpy(info.name, mixer && mixer->name[0] ? mixer->name : card->mixername, sizeof(info.name)); snd_mixer_oss_info_obsolete()
384 int snd_mixer_oss_ioctl_card(struct snd_card *card, unsigned int cmd, unsigned long arg) snd_mixer_oss_ioctl_card() argument
388 if (snd_BUG_ON(!card)) snd_mixer_oss_ioctl_card()
390 if (card->mixer_oss == NULL) snd_mixer_oss_ioctl_card()
393 fmixer.card = card; snd_mixer_oss_ioctl_card()
394 fmixer.mixer = card->mixer_oss; snd_mixer_oss_ioctl_card()
447 static void snd_mixer_oss_recsrce_set(struct snd_card *card, int slot)
449 struct snd_mixer_oss *mixer = card->mixer_oss;
454 static int snd_mixer_oss_recsrce_get(struct snd_card *card, int slot)
456 struct snd_mixer_oss *mixer = card->mixer_oss;
505 struct snd_card *card = mixer->card; snd_mixer_oss_test_id() local
512 return snd_ctl_find_id(card, &id); snd_mixer_oss_test_id()
523 struct snd_card *card = fmixer->card; snd_mixer_oss_get_volume1_vol() local
527 down_read(&card->controls_rwsem); snd_mixer_oss_get_volume1_vol()
528 if ((kctl = snd_ctl_find_numid(card, numid)) == NULL) { snd_mixer_oss_get_volume1_vol()
529 up_read(&card->controls_rwsem); snd_mixer_oss_get_volume1_vol()
547 up_read(&card->controls_rwsem); snd_mixer_oss_get_volume1_vol()
561 struct snd_card *card = fmixer->card; snd_mixer_oss_get_volume1_sw() local
565 down_read(&card->controls_rwsem); snd_mixer_oss_get_volume1_sw()
566 if ((kctl = snd_ctl_find_numid(card, numid)) == NULL) { snd_mixer_oss_get_volume1_sw()
567 up_read(&card->controls_rwsem); snd_mixer_oss_get_volume1_sw()
586 up_read(&card->controls_rwsem); snd_mixer_oss_get_volume1_sw()
625 struct snd_card *card = fmixer->card; snd_mixer_oss_put_volume1_vol() local
630 down_read(&card->controls_rwsem); snd_mixer_oss_put_volume1_vol()
631 if ((kctl = snd_ctl_find_numid(card, numid)) == NULL) { snd_mixer_oss_put_volume1_vol()
632 up_read(&card->controls_rwsem); snd_mixer_oss_put_volume1_vol()
650 snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE, &kctl->id); snd_mixer_oss_put_volume1_vol()
652 up_read(&card->controls_rwsem); snd_mixer_oss_put_volume1_vol()
666 struct snd_card *card = fmixer->card; snd_mixer_oss_put_volume1_sw() local
671 down_read(&card->controls_rwsem); snd_mixer_oss_put_volume1_sw()
672 if ((kctl = snd_ctl_find_numid(card, numid)) == NULL) { snd_mixer_oss_put_volume1_sw()
673 up_read(&card->controls_rwsem); snd_mixer_oss_put_volume1_sw()
695 snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE, &kctl->id); snd_mixer_oss_put_volume1_sw()
697 up_read(&card->controls_rwsem); snd_mixer_oss_put_volume1_sw()
799 struct snd_card *card = fmixer->card; snd_mixer_oss_get_recsrc2() local
814 down_read(&card->controls_rwsem); snd_mixer_oss_get_recsrc2()
840 up_read(&card->controls_rwsem); snd_mixer_oss_get_recsrc2()
849 struct snd_card *card = fmixer->card; snd_mixer_oss_put_recsrc2() local
865 down_read(&card->controls_rwsem); snd_mixer_oss_put_recsrc2()
892 snd_ctl_notify(fmixer->card, SNDRV_CTL_EVENT_MASK_VALUE, &kctl->id); snd_mixer_oss_put_recsrc2()
895 up_read(&card->controls_rwsem); snd_mixer_oss_put_recsrc2()
912 struct snd_card *card = mixer->card; snd_mixer_oss_build_test() local
915 down_read(&card->controls_rwsem); snd_mixer_oss_build_test()
918 up_read(&card->controls_rwsem); snd_mixer_oss_build_test()
923 up_read(&card->controls_rwsem); snd_mixer_oss_build_test()
927 up_read(&card->controls_rwsem); snd_mixer_oss_build_test()
932 up_read(&card->controls_rwsem); snd_mixer_oss_build_test()
1044 down_read(&mixer->card->controls_rwsem); snd_mixer_oss_build_input()
1050 up_read(&mixer->card->controls_rwsem); snd_mixer_oss_build_input()
1055 up_read(&mixer->card->controls_rwsem); snd_mixer_oss_build_input()
1071 up_read(&mixer->card->controls_rwsem); snd_mixer_oss_build_input()
1083 up_read(&mixer->card->controls_rwsem); snd_mixer_oss_build_input()
1237 entry = snd_info_create_card_entry(mixer->card, "oss_mixer", snd_mixer_oss_proc_init()
1238 mixer->card->proc_root); snd_mixer_oss_proc_init()
1322 struct snd_card *card; snd_mixer_oss_free1() local
1327 card = mixer->card; snd_mixer_oss_free1()
1328 if (snd_BUG_ON(mixer != card->mixer_oss)) snd_mixer_oss_free1()
1330 card->mixer_oss = NULL; snd_mixer_oss_free1()
1340 static int snd_mixer_oss_notify_handler(struct snd_card *card, int cmd) snd_mixer_oss_notify_handler() argument
1352 card, 0, snd_mixer_oss_notify_handler()
1353 &snd_mixer_oss_f_ops, card)) < 0) { snd_mixer_oss_notify_handler()
1354 dev_err(card->dev, snd_mixer_oss_notify_handler()
1356 card->number, 0); snd_mixer_oss_notify_handler()
1361 mixer->card = card; snd_mixer_oss_notify_handler()
1362 if (*card->mixername) snd_mixer_oss_notify_handler()
1363 strlcpy(mixer->name, card->mixername, sizeof(mixer->name)); snd_mixer_oss_notify_handler()
1366 "mixer%i", card->number); snd_mixer_oss_notify_handler()
1369 card->number, snd_mixer_oss_notify_handler()
1374 card->mixer_oss = mixer; snd_mixer_oss_notify_handler()
1378 mixer = card->mixer_oss; snd_mixer_oss_notify_handler()
1383 snd_oss_info_unregister(SNDRV_OSS_INFO_DEV_MIXERS, mixer->card->number); snd_mixer_oss_notify_handler()
1385 snd_unregister_oss_device(SNDRV_OSS_DEVICE_TYPE_MIXER, mixer->card, 0); snd_mixer_oss_notify_handler()
/linux-4.1.27/sound/soc/samsung/
H A Dodroidx2_max98090.c26 static int odroidx2_late_probe(struct snd_soc_card *card) odroidx2_late_probe() argument
28 struct snd_soc_dai *codec_dai = card->rtd[0].codec_dai; odroidx2_late_probe()
29 struct snd_soc_dai *cpu_dai = card->rtd[0].cpu_dai; odroidx2_late_probe()
98 struct snd_soc_card *card = &odroidx2; odroidx2_audio_probe() local
107 card->num_dapm_widgets = dd->num_dapm_widgets; odroidx2_audio_probe()
108 card->dapm_widgets = dd->dapm_widgets; odroidx2_audio_probe()
110 card->dev = &pdev->dev; odroidx2_audio_probe()
112 ret = snd_soc_of_parse_card_name(card, "samsung,model"); odroidx2_audio_probe()
116 ret = snd_soc_of_parse_audio_routing(card, "samsung,audio-routing"); odroidx2_audio_probe()
139 ret = snd_soc_register_card(card); odroidx2_audio_probe()
156 struct snd_soc_card *card = platform_get_drvdata(pdev); odroidx2_audio_remove() local
158 snd_soc_unregister_card(card); odroidx2_audio_remove()
H A Dsnow.c36 static int snow_late_probe(struct snd_soc_card *card) snow_late_probe() argument
38 struct snd_soc_dai *codec_dai = card->rtd[0].codec_dai; snow_late_probe()
39 struct snd_soc_dai *cpu_dai = card->rtd[0].cpu_dai; snow_late_probe()
67 struct snd_soc_card *card = &snow_snd; snow_probe() local
93 card->dev = &pdev->dev; snow_probe()
95 /* Update card-name if provided through DT, else use default name */ snow_probe()
96 snd_soc_of_parse_card_name(card, "samsung,model"); snow_probe()
98 ret = devm_snd_soc_register_card(&pdev->dev, card); snow_probe()
/linux-4.1.27/sound/firewire/dice/
H A Ddice.c196 struct snd_card *card = dice->card; dice_card_strings() local
202 strcpy(card->driver, "DICE"); dice_card_strings()
204 strcpy(card->shortname, "DICE"); dice_card_strings()
205 BUILD_BUG_ON(NICK_NAME_SIZE < sizeof(card->shortname)); dice_card_strings()
207 card->shortname, dice_card_strings()
208 sizeof(card->shortname)); dice_card_strings()
211 BUILD_BUG_ON(sizeof(card->shortname) % 4 != 0); dice_card_strings()
212 for (i = 0; i < sizeof(card->shortname); i += 4) dice_card_strings()
213 swab32s((u32 *)&card->shortname[i]); dice_card_strings()
214 card->shortname[sizeof(card->shortname) - 1] = '\0'; dice_card_strings()
221 snprintf(card->longname, sizeof(card->longname), dice_card_strings()
226 strcpy(card->mixername, "DICE"); dice_card_strings()
235 static void dice_card_free(struct snd_card *card) dice_card_free() argument
237 struct snd_dice *dice = card->private_data; dice_card_free()
248 struct snd_card *card; dice_probe() local
257 sizeof(*dice), &card); dice_probe()
261 dice = card->private_data; dice_probe()
262 dice->card = card; dice_probe()
264 card->private_free = dice_card_free; dice_probe()
299 err = snd_card_register(card); dice_probe()
309 snd_card_free(card); dice_probe()
317 /* No need to wait for releasing card object in this context. */ dice_remove()
318 snd_card_free_when_closed(dice->card); dice_remove()
/linux-4.1.27/sound/soc/atmel/
H A Dsam9x5_wm8731.c82 struct snd_soc_card *card; sam9x5_wm8731_driver_probe() local
92 card = devm_kzalloc(&pdev->dev, sizeof(*card), GFP_KERNEL); sam9x5_wm8731_driver_probe()
95 if (!dai || !card || !priv) { sam9x5_wm8731_driver_probe()
100 snd_soc_card_set_drvdata(card, priv); sam9x5_wm8731_driver_probe()
102 card->dev = &pdev->dev; sam9x5_wm8731_driver_probe()
103 card->owner = THIS_MODULE; sam9x5_wm8731_driver_probe()
104 card->dai_link = dai; sam9x5_wm8731_driver_probe()
105 card->num_links = 1; sam9x5_wm8731_driver_probe()
106 card->dapm_widgets = sam9x5_dapm_widgets; sam9x5_wm8731_driver_probe()
107 card->num_dapm_widgets = ARRAY_SIZE(sam9x5_dapm_widgets); sam9x5_wm8731_driver_probe()
115 ret = snd_soc_of_parse_card_name(card, "atmel,model"); sam9x5_wm8731_driver_probe()
121 ret = snd_soc_of_parse_audio_routing(card, "atmel,audio-routing"); sam9x5_wm8731_driver_probe()
158 ret = snd_soc_register_card(card); sam9x5_wm8731_driver_probe()
177 struct snd_soc_card *card = platform_get_drvdata(pdev); sam9x5_wm8731_driver_remove() local
178 struct sam9x5_drvdata *priv = card->drvdata; sam9x5_wm8731_driver_remove()
180 snd_soc_unregister_card(card); sam9x5_wm8731_driver_remove()
/linux-4.1.27/sound/pci/emu10k1/
H A Demu10k1.c46 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
47 static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
54 static uint subsystem[SNDRV_CARDS]; /* Force card subsystem model */
76 MODULE_PARM_DESC(subsystem, "Force card subsystem model.");
106 struct snd_card *card; snd_card_emu10k1_probe() local
121 0, &card); snd_card_emu10k1_probe()
128 if ((err = snd_emu10k1_create(card, pci, extin[dev], extout[dev], snd_card_emu10k1_probe()
133 card->private_data = emu; snd_card_emu10k1_probe()
170 if (snd_seq_device_new(card, 1, SNDRV_SEQ_DEV_ID_EMU10K1_SYNTH, snd_card_emu10k1_probe()
173 dev_warn(emu->card->dev, snd_card_emu10k1_probe()
186 strlcpy(card->driver, emu->card_capabilities->driver, snd_card_emu10k1_probe()
187 sizeof(card->driver)); snd_card_emu10k1_probe()
188 strlcpy(card->shortname, emu->card_capabilities->name, snd_card_emu10k1_probe()
189 sizeof(card->shortname)); snd_card_emu10k1_probe()
190 snprintf(card->longname, sizeof(card->longname), snd_card_emu10k1_probe()
192 card->shortname, emu->revision, emu->serial, emu->port, emu->irq); snd_card_emu10k1_probe()
194 if ((err = snd_card_register(card)) < 0) snd_card_emu10k1_probe()
197 pci_set_drvdata(pci, card); snd_card_emu10k1_probe()
202 snd_card_free(card); snd_card_emu10k1_probe()
215 struct snd_card *card = dev_get_drvdata(dev); snd_emu10k1_suspend() local
216 struct snd_emu10k1 *emu = card->private_data; snd_emu10k1_suspend()
218 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); snd_emu10k1_suspend()
241 struct snd_card *card = dev_get_drvdata(dev); snd_emu10k1_resume() local
242 struct snd_emu10k1 *emu = card->private_data; snd_emu10k1_resume()
254 snd_power_change_state(card, SNDRV_CTL_POWER_D0); snd_emu10k1_resume()
/linux-4.1.27/sound/pcmcia/pdaudiocf/
H A Dpdaudiocf.c41 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
78 pdacf->card = NULL; snd_pdacf_free()
97 struct snd_card *card; snd_pdacf_probe() local
103 /* find an empty slot from the card list */ snd_pdacf_probe()
115 /* ok, create a card instance */ snd_pdacf_probe()
117 0, &card); snd_pdacf_probe()
119 snd_printk(KERN_ERR "pdacf: cannot create a card instance\n"); snd_pdacf_probe()
123 pdacf = snd_pdacf_create(card); snd_pdacf_probe()
125 snd_card_free(card); snd_pdacf_probe()
129 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, pdacf, &ops); snd_pdacf_probe()
132 snd_card_free(card); snd_pdacf_probe()
137 card_list[i] = card; snd_pdacf_probe()
154 * snd_pdacf_assign_resources - initialize the hardware and card instance.
155 * @port: i/o port for the card
156 * @irq: irq number for the card
158 * this function assigns the specified port and irq, boot the card,
166 struct snd_card *card = pdacf->card; snd_pdacf_assign_resources() local
177 strcpy(card->driver, "PDAudio-CF"); snd_pdacf_assign_resources()
178 sprintf(card->shortname, "Core Sound %s", card->driver); snd_pdacf_assign_resources()
179 sprintf(card->longname, "%s at 0x%x, irq %i", snd_pdacf_assign_resources()
180 card->shortname, port, irq); snd_pdacf_assign_resources()
186 if ((err = snd_card_register(card)) < 0) snd_pdacf_assign_resources()
205 snd_card_disconnect(chip->card); snd_pdacf_detach()
206 snd_card_free_when_closed(chip->card); snd_pdacf_detach()
/linux-4.1.27/drivers/tty/serial/
H A Drp2.c185 struct rp2_card *card; member in struct:rp2_uart_port
261 spin_lock_irqsave(&up->card->card_lock, flags); rp2_mask_ch_irq()
270 spin_unlock_irqrestore(&up->card->card_lock, flags); rp2_mask_ch_irq()
488 static int rp2_asic_interrupt(struct rp2_card *card, unsigned int asic_id) rp2_asic_interrupt() argument
490 void __iomem *base = card->bar1 + RP2_ASIC_OFFSET(asic_id); rp2_asic_interrupt()
496 rp2_ch_interrupt(&card->ports[ch]); rp2_asic_interrupt()
504 struct rp2_card *card = dev_id; rp2_uart_interrupt() local
507 handled = rp2_asic_interrupt(card, 0); rp2_uart_interrupt()
508 if (card->n_ports >= PORTS_PER_ASIC) rp2_uart_interrupt()
509 handled += rp2_asic_interrupt(card, 1); rp2_uart_interrupt()
601 static void rp2_reset_asic(struct rp2_card *card, unsigned int asic_id) rp2_reset_asic() argument
603 void __iomem *base = card->bar1 + RP2_ASIC_OFFSET(asic_id); rp2_reset_asic()
621 static void rp2_init_card(struct rp2_card *card) rp2_init_card() argument
623 writel(4, card->bar0 + RP2_FPGA_CTL0); rp2_init_card()
624 writel(0, card->bar0 + RP2_FPGA_CTL1); rp2_init_card()
626 rp2_reset_asic(card, 0); rp2_init_card()
627 if (card->n_ports >= PORTS_PER_ASIC) rp2_init_card()
628 rp2_reset_asic(card, 1); rp2_init_card()
630 writel(RP2_IRQ_MASK_EN_m, card->bar0 + RP2_IRQ_MASK); rp2_init_card()
661 static void rp2_remove_ports(struct rp2_card *card) rp2_remove_ports() argument
665 for (i = 0; i < card->initialized_ports; i++) rp2_remove_ports()
666 uart_remove_one_port(&rp2_uart_driver, &card->ports[i].port); rp2_remove_ports()
667 card->initialized_ports = 0; rp2_remove_ports()
672 struct rp2_card *card = context; rp2_fw_cb() local
677 dev_err(&card->pdev->dev, "cannot find '%s' firmware image\n", rp2_fw_cb()
682 phys_base = pci_resource_start(card->pdev, 1); rp2_fw_cb()
684 for (i = 0; i < card->n_ports; i++) { rp2_fw_cb()
685 struct rp2_uart_port *rp = &card->ports[i]; rp2_fw_cb()
689 rp->asic_base = card->bar1; rp2_fw_cb()
690 rp->base = card->bar1 + RP2_PORT_BASE + j*RP2_PORT_SPACING; rp2_fw_cb()
691 rp->ucode = card->bar1 + RP2_UCODE_BASE + j*RP2_UCODE_SPACING; rp2_fw_cb()
692 rp->card = card; rp2_fw_cb()
696 p->line = card->minor_start + i; rp2_fw_cb()
697 p->dev = &card->pdev->dev; rp2_fw_cb()
704 p->irq = card->pdev->irq; rp2_fw_cb()
718 dev_err(&card->pdev->dev, rp2_fw_cb()
720 rp2_remove_ports(card); rp2_fw_cb()
723 card->initialized_ports++; rp2_fw_cb()
735 dev_warn(&card->pdev->dev, "driver initialization failed\n"); rp2_fw_cb()
737 complete(&card->fw_loaded); rp2_fw_cb()
743 struct rp2_card *card; rp2_probe() local
748 card = devm_kzalloc(&pdev->dev, sizeof(*card), GFP_KERNEL); rp2_probe()
749 if (!card) rp2_probe()
751 pci_set_drvdata(pdev, card); rp2_probe()
752 spin_lock_init(&card->card_lock); rp2_probe()
753 init_completion(&card->fw_loaded); rp2_probe()
764 card->bar0 = bars[0]; rp2_probe()
765 card->bar1 = bars[1]; rp2_probe()
766 card->pdev = pdev; rp2_probe()
768 rp2_decode_cap(id, &card->n_ports, &card->smpte); rp2_probe()
769 dev_info(&pdev->dev, "found new card with %d ports\n", card->n_ports); rp2_probe()
771 card->minor_start = rp2_alloc_ports(card->n_ports); rp2_probe()
772 if (card->minor_start < 0) { rp2_probe()
778 rp2_init_card(card); rp2_probe()
780 ports = devm_kzalloc(&pdev->dev, sizeof(*ports) * card->n_ports, rp2_probe()
784 card->ports = ports; rp2_probe()
787 IRQF_SHARED, DRV_NAME, card); rp2_probe()
797 GFP_KERNEL, card, rp2_fw_cb); rp2_probe()
807 struct rp2_card *card = pci_get_drvdata(pdev); rp2_remove() local
809 wait_for_completion(&card->fw_loaded); rp2_remove()
810 rp2_remove_ports(card); rp2_remove()
/linux-4.1.27/drivers/mtd/nand/
H A Dr852.h38 /* card detection status */
42 #define R852_CARD_STA_RO 0x02 /* card is readonly */
43 #define R852_CARD_STA_PRESENT 0x04 /* card is present (#CD) */
44 #define R852_CARD_STA_ABSENT 0x08 /* card is absent */
45 #define R852_CARD_STA_BUSY 0x80 /* card is busy - (#R/B) */
47 /* card detection irq status & enable*/
52 #define R852_CARD_IRQ_REMOVE 0x04 /* detect card removal */
53 #define R852_CARD_IRQ_INSERT 0x08 /* detect card insert */
82 #define R852_DMA_INTERNAL 0x04 /* (internal hw buffer <-> card) */
92 #define R852_DMA_IRQ_INTERNAL 0x04 /* (internal hw buffer <-> card) */
130 /* card status area */
133 int card_registred; /* card registered with mtd */
134 int card_detected; /* card detected in slot */
135 int card_unstable; /* whenever the card is inserted,
137 int readonly; /* card is readonly */
138 int sm; /* Is card smartmedia */
/linux-4.1.27/drivers/staging/vt6655/
H A DMakefile6 card.o \
/linux-4.1.27/drivers/staging/vt6656/
H A DMakefile6 card.o \
/linux-4.1.27/arch/arm/mach-omap2/
H A Dmmc.h11 /* called from board-specific card detection service routine */
/linux-4.1.27/sound/pcmcia/vx/
H A Dvxpocket.c41 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
135 static int snd_vxpocket_new(struct snd_card *card, int ibl, snd_vxpocket_new() argument
146 chip = snd_vx_create(card, &vxpocket_hw, &snd_vxpocket_ops, snd_vxpocket_new()
151 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops); snd_vxpocket_new()
176 * snd_vxpocket_assign_resources - initialize the hardware and card instance.
178 * @port: i/o port for the card
179 * @irq: irq number for the card
181 * this function assigns the specified port and irq, boot the card,
189 struct snd_card *card = chip->card; snd_vxpocket_assign_resources() local
195 sprintf(card->shortname, "Digigram %s", card->driver); snd_vxpocket_assign_resources()
196 sprintf(card->longname, "%s at 0x%x, irq %i", snd_vxpocket_assign_resources()
197 card->shortname, port, irq); snd_vxpocket_assign_resources()
227 strcpy(chip->card->driver, vxp440_hw.name); vxpocket_config()
298 struct snd_card *card; vxpocket_probe() local
302 /* find an empty slot from the card list */ vxpocket_probe()
314 /* ok, create a card instance */ vxpocket_probe()
316 0, &card); vxpocket_probe()
318 snd_printk(KERN_ERR "vxpocket: cannot create a card instance\n"); vxpocket_probe()
322 err = snd_vxpocket_new(card, ibl[i], p_dev, &vxp); vxpocket_probe()
324 snd_card_free(card); vxpocket_probe()
327 card->private_data = vxp; vxpocket_probe()
350 snd_card_disconnect(chip->card); vxpocket_detach()
352 snd_card_free_when_closed(chip->card); vxpocket_detach()
/linux-4.1.27/sound/soc/omap/
H A Domap-hdmi-audio.c36 struct snd_soc_card *card; member in struct:hdmi_audio_data
54 return snd_soc_card_get_drvdata(rtd->card); card_drvdata_substream()
313 struct snd_soc_card *card; omap_hdmi_audio_probe() local
352 card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL); omap_hdmi_audio_probe()
353 if (!card) omap_hdmi_audio_probe()
356 card->name = devm_kasprintf(dev, GFP_KERNEL, omap_hdmi_audio_probe()
358 card->owner = THIS_MODULE; omap_hdmi_audio_probe()
359 card->dai_link = omap_hdmi_audio_probe()
360 devm_kzalloc(dev, sizeof(*(card->dai_link)), GFP_KERNEL); omap_hdmi_audio_probe()
361 card->dai_link->name = card->name; omap_hdmi_audio_probe()
362 card->dai_link->stream_name = card->name; omap_hdmi_audio_probe()
363 card->dai_link->cpu_dai_name = dev_name(ad->dssdev); omap_hdmi_audio_probe()
364 card->dai_link->platform_name = dev_name(ad->dssdev); omap_hdmi_audio_probe()
365 card->dai_link->codec_name = "snd-soc-dummy"; omap_hdmi_audio_probe()
366 card->dai_link->codec_dai_name = "snd-soc-dummy-dai"; omap_hdmi_audio_probe()
367 card->num_links = 1; omap_hdmi_audio_probe()
368 card->dev = dev; omap_hdmi_audio_probe()
370 ret = snd_soc_register_card(card); omap_hdmi_audio_probe()
377 ad->card = card; omap_hdmi_audio_probe()
378 snd_soc_card_set_drvdata(card, ad); omap_hdmi_audio_probe()
389 snd_soc_unregister_card(ad->card); omap_hdmi_audio_remove()
H A Drx51.c62 struct snd_soc_card *card = dapm->card; rx51_ext_control() local
63 struct rx51_audio_pdata *pdata = snd_soc_card_get_drvdata(card); rx51_ext_control()
108 struct snd_soc_card *card = rtd->card; rx51_startup() local
112 rx51_ext_control(&card->dapm); rx51_startup()
144 struct snd_soc_card *card = snd_kcontrol_chip(kcontrol); rx51_set_spk() local
150 rx51_ext_control(&card->dapm); rx51_set_spk()
159 struct snd_soc_card *card = dapm->card; rx51_spk_event() local
160 struct rx51_audio_pdata *pdata = snd_soc_card_get_drvdata(card); rx51_spk_event()
192 struct snd_soc_card *card = snd_kcontrol_chip(kcontrol); rx51_set_input() local
198 rx51_ext_control(&card->dapm); rx51_set_input()
214 struct snd_soc_card *card = snd_kcontrol_chip(kcontrol); rx51_set_jack() local
220 rx51_ext_control(&card->dapm); rx51_set_jack()
289 struct snd_soc_card *card = rtd->card; rx51_aic34_init() local
290 struct rx51_audio_pdata *pdata = snd_soc_card_get_drvdata(card); rx51_aic34_init()
302 dev_err(card->dev, "Failed to add TPA6130A2 controls\n"); rx51_aic34_init()
309 dev_err(card->dev, "Failed to add MCBSP controls\n"); rx51_aic34_init()
314 err = snd_soc_card_jack_new(rtd->card, "AV Jack", rx51_aic34_init()
318 dev_err(card->dev, "Failed to add AV Jack\n"); rx51_aic34_init()
324 devm_gpiod_put(card->dev, pdata->jack_detection_gpio); rx51_aic34_init()
330 dev_err(card->dev, "Failed to add GPIOs\n"); rx51_aic34_init()
337 static int rx51_card_remove(struct snd_soc_card *card) rx51_card_remove() argument
375 /* Audio card */
399 struct snd_soc_card *card = &rx51_sound_card; rx51_soc_probe() local
405 card->dev = &pdev->dev; rx51_soc_probe()
452 dev_err(card->dev, "failed to create private data\n"); rx51_soc_probe()
455 snd_soc_card_set_drvdata(card, pdata); rx51_soc_probe()
457 pdata->tvout_selection_gpio = devm_gpiod_get(card->dev, rx51_soc_probe()
460 dev_err(card->dev, "could not get tvout selection gpio\n"); rx51_soc_probe()
466 dev_err(card->dev, "could not setup tvout selection gpio\n"); rx51_soc_probe()
470 pdata->jack_detection_gpio = devm_gpiod_get(card->dev, rx51_soc_probe()
473 dev_err(card->dev, "could not get jack detection gpio\n"); rx51_soc_probe()
477 pdata->eci_sw_gpio = devm_gpiod_get(card->dev, "eci-switch"); rx51_soc_probe()
479 dev_err(card->dev, "could not get eci switch gpio\n"); rx51_soc_probe()
485 dev_err(card->dev, "could not setup eci switch gpio\n"); rx51_soc_probe()
489 pdata->speaker_amp_gpio = devm_gpiod_get(card->dev, rx51_soc_probe()
492 dev_err(card->dev, "could not get speaker enable gpio\n"); rx51_soc_probe()
498 dev_err(card->dev, "could not setup speaker enable gpio\n"); rx51_soc_probe()
502 err = devm_snd_soc_register_card(card->dev, card); rx51_soc_probe()
/linux-4.1.27/include/linux/
H A DmISDNdsp.h27 int hfc_dtmf; /* set if HFCmulti card supports dtmf */
28 int hfc_conf; /* set if HFCmulti card supports conferences */
29 int hfc_loops; /* set if card supports tone loops */
30 int hfc_echocanhw; /* set if card supports echocancelation*/
/linux-4.1.27/Documentation/watchdog/src/
H A Dwatchdog-test.c19 * the PC Watchdog card to reset its internal timer so it doesn't trigger
30 * The main program. Run the program with "-d" to disable the card,
31 * or "-e" to enable the card.
57 fprintf(stderr, "Watchdog card disabled.\n"); main()
63 fprintf(stderr, "Watchdog card enabled.\n"); main()
68 fprintf(stderr, "run by itself to tick the card.\n"); main()
/linux-4.1.27/sound/isa/sb/
H A Dsb8.c38 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
39 static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; /* Enable this card */
73 static void snd_sb8_free(struct snd_card *card) snd_sb8_free() argument
75 struct snd_sb8 *acard = card->private_data; snd_sb8_free()
100 struct snd_card *card; snd_sb8_probe() local
106 sizeof(struct snd_sb8), &card); snd_sb8_probe()
109 acard = card->private_data; snd_sb8_probe()
110 card->private_free = snd_sb8_free; snd_sb8_probe()
116 if ((err = snd_sbdsp_create(card, port[dev], irq[dev], snd_sb8_probe()
130 err = snd_sbdsp_create(card, possible_ports[i], snd_sb8_probe()
167 if ((err = snd_opl3_create(card, chip->port + 8, 0, snd_sb8_probe()
173 if ((err = snd_opl3_create(card, chip->port, chip->port + 2, snd_sb8_probe()
188 strcpy(card->driver, chip->hardware == SB_HW_PRO ? "SB Pro" : "SB8"); snd_sb8_probe()
189 strcpy(card->shortname, chip->name); snd_sb8_probe()
190 sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d", snd_sb8_probe()
195 if ((err = snd_card_register(card)) < 0) snd_sb8_probe()
198 dev_set_drvdata(pdev, card); snd_sb8_probe()
202 snd_card_free(card); snd_sb8_probe()
216 struct snd_card *card = dev_get_drvdata(dev); snd_sb8_suspend() local
217 struct snd_sb8 *acard = card->private_data; snd_sb8_suspend()
220 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); snd_sb8_suspend()
228 struct snd_card *card = dev_get_drvdata(dev); snd_sb8_resume() local
229 struct snd_sb8 *acard = card->private_data; snd_sb8_resume()
234 snd_power_change_state(card, SNDRV_CTL_POWER_D0); snd_sb8_resume()
/linux-4.1.27/sound/pci/lx6464es/
H A Dlx6464es.c115 dev_dbg(chip->card->dev, "allocating pipe for %d channels\n", channels); lx_hardware_open()
118 dev_err(chip->card->dev, LXP "allocating pipe failed\n"); lx_hardware_open()
124 dev_err(chip->card->dev, "setting granularity to %ld failed\n", lx_hardware_open()
139 dev_dbg(chip->card->dev, "setting stream format\n"); lx_hardware_start()
142 dev_err(chip->card->dev, "setting stream format failed\n"); lx_hardware_start()
146 dev_dbg(chip->card->dev, "starting pipe\n"); lx_hardware_start()
149 dev_err(chip->card->dev, "starting pipe failed\n"); lx_hardware_start()
153 dev_dbg(chip->card->dev, "waiting for pipe to start\n"); lx_hardware_start()
156 dev_err(chip->card->dev, "waiting for pipe failed\n"); lx_hardware_start()
170 dev_dbg(chip->card->dev, "pausing pipe\n"); lx_hardware_stop()
173 dev_err(chip->card->dev, "pausing pipe failed\n"); lx_hardware_stop()
177 dev_dbg(chip->card->dev, "waiting for pipe to become idle\n"); lx_hardware_stop()
180 dev_err(chip->card->dev, "waiting for pipe failed\n"); lx_hardware_stop()
184 dev_dbg(chip->card->dev, "stopping pipe\n"); lx_hardware_stop()
187 dev_err(chip->card->dev, "stopping pipe failed\n"); lx_hardware_stop()
201 dev_dbg(chip->card->dev, "releasing pipe\n"); lx_hardware_close()
204 dev_err(chip->card->dev, "releasing pipe failed\n"); lx_hardware_close()
219 dev_dbg(chip->card->dev, "->lx_pcm_open\n"); lx_pcm_open()
230 dev_warn(chip->card->dev, "could not constrain periods\n"); lx_pcm_open()
241 dev_warn(chip->card->dev, "could not constrain periods\n"); lx_pcm_open()
251 dev_warn(chip->card->dev, lx_pcm_open()
266 dev_dbg(chip->card->dev, "<-lx_pcm_open, %d\n", err); lx_pcm_open()
273 dev_dbg(substream->pcm->card->dev, "->lx_pcm_close\n"); lx_pcm_close()
287 dev_dbg(chip->card->dev, "->lx_pcm_stream_pointer\n"); lx_pcm_stream_pointer()
293 dev_dbg(chip->card->dev, "stream_pointer at %ld\n", pos); lx_pcm_stream_pointer()
303 dev_dbg(chip->card->dev, "->lx_pcm_prepare\n"); lx_pcm_prepare()
310 dev_err(chip->card->dev, "failed to stop hardware. " lx_pcm_prepare()
317 dev_err(chip->card->dev, "failed to close hardware. " lx_pcm_prepare()
323 dev_dbg(chip->card->dev, "opening hardware\n"); lx_pcm_prepare()
326 dev_err(chip->card->dev, "failed to open hardware. " lx_pcm_prepare()
333 dev_err(chip->card->dev, "failed to start hardware. " lx_pcm_prepare()
356 dev_dbg(chip->card->dev, "->lx_pcm_hw_params\n"); lx_pcm_hw_params()
391 dev_dbg(chip->card->dev, "->lx_pcm_hw_free\n"); lx_pcm_hw_free()
397 dev_err(chip->card->dev, "failed to stop hardware. " lx_pcm_hw_free()
404 dev_err(chip->card->dev, "failed to close hardware. " lx_pcm_hw_free()
448 dev_dbg(chip->card->dev, "starting: needed %d, freed %d\n", lx_trigger_start()
455 dev_dbg(chip->card->dev, "starting: buffer index %x on 0x%lx (%d bytes)\n", lx_trigger_start()
461 dev_dbg(chip->card->dev, "starting: needed %d, freed %d\n", needed, freed); lx_trigger_start()
463 dev_dbg(chip->card->dev, "starting: starting stream\n"); lx_trigger_start()
466 dev_err(chip->card->dev, "couldn't start stream\n"); lx_trigger_start()
478 dev_dbg(chip->card->dev, "stopping: stopping stream\n"); lx_trigger_stop()
481 dev_err(chip->card->dev, "couldn't stop stream\n"); lx_trigger_stop()
540 dev_dbg(chip->card->dev, "->lx_pcm_trigger\n"); lx_pcm_trigger()
547 dev_dbg(chip->card->dev, "->snd_lx6464es_free\n"); snd_lx6464es_free()
576 dev_dbg(chip->card->dev, "->lx_init_xilinx_reset\n"); lx_init_xilinx_reset()
596 dev_dbg(chip->card->dev, "xilinx reset done\n"); lx_init_xilinx_reset()
597 dev_dbg(chip->card->dev, "xilinx took %d loops\n", i); lx_init_xilinx_reset()
617 dev_dbg(chip->card->dev, "->lx_init_xilinx_test\n"); lx_init_xilinx_test()
625 dev_err(chip->card->dev, "Problem: Reg_CSM %x.\n", reg); lx_init_xilinx_test()
632 dev_err(chip->card->dev, "Error: Reg_CSM %x.\n", reg); lx_init_xilinx_test()
637 dev_dbg(chip->card->dev, "Xilinx/MicroBlaze access test successful\n"); lx_init_xilinx_test()
654 dev_dbg(chip->card->dev, "->lx_init_ethersound\n"); lx_init_ethersound_config()
659 * write it to the card ! lx_init_ethersound_config()
668 dev_dbg(chip->card->dev, "ethersound initialized after %dms\n", lx_init_ethersound_config()
674 dev_warn(chip->card->dev, lx_init_ethersound_config()
679 dev_dbg(chip->card->dev, "ethersound initialized\n"); lx_init_ethersound_config()
689 dev_dbg(chip->card->dev, "->lx_init_get_version_features\n"); lx_init_get_version_features()
696 dev_info(chip->card->dev, "DSP version: V%02d.%02d #%d\n", lx_init_get_version_features()
711 dev_dbg(chip->card->dev, "actual clock frequency %d\n", freq); lx_init_get_version_features()
713 dev_err(chip->card->dev, "DSP corrupted \n"); lx_init_get_version_features()
725 dev_dbg(chip->card->dev, "->lx_set_granularity\n"); lx_set_granularity()
738 dev_warn(chip->card->dev, "could not set granularity\n"); lx_set_granularity()
743 dev_err(chip->card->dev, "snapped blocksize to %d\n", snapped_gran); lx_set_granularity()
745 dev_dbg(chip->card->dev, "set blocksize on board %d\n", snapped_gran); lx_set_granularity()
757 dev_dbg(chip->card->dev, "->lx_init_dsp\n"); lx_init_dsp()
759 dev_dbg(chip->card->dev, "initialize board\n"); lx_init_dsp()
764 dev_dbg(chip->card->dev, "testing board\n"); lx_init_dsp()
769 dev_dbg(chip->card->dev, "initialize ethersound configuration\n"); lx_init_dsp()
790 dev_dbg(chip->card->dev, "mac address ready read after: %dms\n", i); lx_init_dsp()
791 dev_info(chip->card->dev, lx_init_dsp()
843 err = snd_pcm_new(chip->card, (char *)card_name, 0, lx_pcm_create()
949 static int lx_proc_create(struct snd_card *card, struct lx6464es *chip) lx_proc_create() argument
952 int err = snd_card_proc_new(card, "levels", &entry); lx_proc_create()
961 static int snd_lx6464es_create(struct snd_card *card, snd_lx6464es_create() argument
972 dev_dbg(card->dev, "->snd_lx6464es_create\n"); snd_lx6464es_create()
986 dev_err(card->dev, snd_lx6464es_create()
998 chip->card = card; snd_lx6464es_create()
1023 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq); snd_lx6464es_create()
1028 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops); snd_lx6464es_create()
1034 dev_err(card->dev, "error during DSP initialization\n"); snd_lx6464es_create()
1042 err = lx_proc_create(card, chip); snd_lx6464es_create()
1046 err = snd_ctl_add(card, snd_ctl_new1(&lx_control_playback_switch, snd_lx6464es_create()
1073 struct snd_card *card; snd_lx6464es_probe() local
1087 0, &card); snd_lx6464es_probe()
1091 err = snd_lx6464es_create(card, pci, &chip); snd_lx6464es_probe()
1093 dev_err(card->dev, "error during snd_lx6464es_create\n"); snd_lx6464es_probe()
1097 strcpy(card->driver, "LX6464ES"); snd_lx6464es_probe()
1098 sprintf(card->id, "LX6464ES_%02X%02X%02X", snd_lx6464es_probe()
1101 sprintf(card->shortname, "LX6464ES %02X.%02X.%02X.%02X.%02X.%02X", snd_lx6464es_probe()
1105 sprintf(card->longname, "%s at 0x%lx, 0x%p, irq %i", snd_lx6464es_probe()
1106 card->shortname, chip->port_plx, snd_lx6464es_probe()
1109 err = snd_card_register(card); snd_lx6464es_probe()
1113 dev_dbg(chip->card->dev, "initialization successful\n"); snd_lx6464es_probe()
1114 pci_set_drvdata(pci, card); snd_lx6464es_probe()
1119 snd_card_free(card); snd_lx6464es_probe()
/linux-4.1.27/sound/drivers/
H A Dvirmidi.c25 * This dummy card contains up to 4 virtual rawmidi devices.
65 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
79 struct snd_card *card; member in struct:snd_card_virmidi
88 struct snd_card *card; snd_virmidi_probe() local
94 sizeof(struct snd_card_virmidi), &card); snd_virmidi_probe()
97 vmidi = card->private_data; snd_virmidi_probe()
98 vmidi->card = card; snd_virmidi_probe()
110 err = snd_virmidi_new(card, idx, &rmidi); snd_virmidi_probe()
119 strcpy(card->driver, "VirMIDI"); snd_virmidi_probe()
120 strcpy(card->shortname, "VirMIDI"); snd_virmidi_probe()
121 sprintf(card->longname, "Virtual MIDI Card %i", dev + 1); snd_virmidi_probe()
123 err = snd_card_register(card); snd_virmidi_probe()
125 platform_set_drvdata(devptr, card); snd_virmidi_probe()
129 snd_card_free(card); snd_virmidi_probe()
/linux-4.1.27/sound/usb/
H A Dcard.c57 #include "card.h"
77 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
78 static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;/* Enable this card */
79 /* Vendor/product IDs for this card */
82 static int device_setup[SNDRV_CARDS]; /* device parameter for this card */
106 * the all interfaces on the same card as one sound device.
174 int err = snd_usbmidi_create(chip->card, iface, snd_usb_create_stream()
332 struct snd_card *card; snd_usb_audio_create() local
355 0, &card); snd_usb_audio_create()
357 dev_err(&dev->dev, "cannot create card instance %d\n", idx); snd_usb_audio_create()
363 snd_card_free(card); snd_usb_audio_create()
371 chip->card = card; snd_usb_audio_create()
385 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { snd_usb_audio_create()
387 snd_card_free(card); snd_usb_audio_create()
391 strcpy(card->driver, "USB-Audio"); snd_usb_audio_create()
394 snd_component_add(card, component); snd_usb_audio_create()
398 strlcpy(card->shortname, quirk->product_name, sizeof(card->shortname)); snd_usb_audio_create()
402 card->shortname, sizeof(card->shortname)) <= 0) { snd_usb_audio_create()
404 sprintf(card->shortname, "USB Device %#04x:%#04x", snd_usb_audio_create()
409 strim(card->shortname); snd_usb_audio_create()
413 len = strlcpy(card->longname, quirk->vendor_name, sizeof(card->longname)); snd_usb_audio_create()
417 card->longname, sizeof(card->longname)); snd_usb_audio_create()
423 strim(card->longname); snd_usb_audio_create()
424 if (*card->longname) snd_usb_audio_create()
425 strlcat(card->longname, " ", sizeof(card->longname)); snd_usb_audio_create()
428 strlcat(card->longname, card->shortname, sizeof(card->longname)); snd_usb_audio_create()
430 len = strlcat(card->longname, " at ", sizeof(card->longname)); snd_usb_audio_create()
432 if (len < sizeof(card->longname)) snd_usb_audio_create()
433 usb_make_path(dev, card->longname + len, sizeof(card->longname) - len); snd_usb_audio_create()
437 strlcat(card->longname, ", low speed", sizeof(card->longname)); snd_usb_audio_create()
440 strlcat(card->longname, ", full speed", sizeof(card->longname)); snd_usb_audio_create()
443 strlcat(card->longname, ", high speed", sizeof(card->longname)); snd_usb_audio_create()
446 strlcat(card->longname, ", super speed", sizeof(card->longname)); snd_usb_audio_create()
464 * thus we check the usb device pointer and creates the card instance
466 * append the pcm interface to the corresponding card.
501 dev_err(&dev->dev, "USB device is in the shutdown state, cannot create a card instance\n"); usb_audio_probe()
512 * now look for an empty slot and create a new card instance usb_audio_probe()
560 err = snd_card_register(chip->card); usb_audio_probe()
574 snd_card_free(chip->card); usb_audio_probe()
588 struct snd_card *card; usb_audio_disconnect() local
594 card = chip->card; usb_audio_disconnect()
607 snd_card_disconnect(card); usb_audio_disconnect()
630 snd_card_free_when_closed(card); usb_audio_disconnect()
699 snd_power_change_state(chip->card, SNDRV_CTL_POWER_D3hot); usb_audio_suspend()
754 snd_power_change_state(chip->card, SNDRV_CTL_POWER_D0); __usb_audio_resume()

Completed in 4685 milliseconds

1234567891011>>