16 #include <linux/slab.h>
18 #define DBG_LOADFIRM 0
19 #define DUMP_MBOXFRAME 2
25 static const u_char faxmodulation[] = {3, 24, 48, 72, 73, 74, 96, 97, 98, 121, 122, 145, 146};
26 static u_int modmask = 0x1fff;
27 static int frm_extra_delay = 2;
28 static int para_TOA = 6;
29 static const u_char *FC1_CMD[] = {
"FAE",
"FTS",
"FRS",
"FTM",
"FRM",
"FTH",
"FRH",
"CTRL"};
31 static void isar_setup(
struct IsdnCardState *
cs);
32 static void isar_pump_cmd(
struct BCState *bcs,
u_char cmd,
u_char para);
33 static void ll_deliver_faxstat(
struct BCState *bcs,
u_char status);
36 waitforHIA(
struct IsdnCardState *
cs,
int timeout)
39 while ((cs->BC_Read_Reg(cs, 0,
ISAR_HIA) & 1) && timeout) {
55 if (!waitforHIA(cs, 4000))
58 if (cs->debug & L1_DEB_HSCX)
59 debugl1(cs,
"sendmsg(%02x,%02x,%d)", his, creg, len);
65 cs->BC_Write_Reg(cs, 1,
ISAR_MBOX, msg[0]);
66 for (i = 1; i < len; i++)
67 cs->BC_Write_Reg(cs, 2,
ISAR_MBOX, msg[i]);
68 #if DUMP_MBOXFRAME > 1
69 if (cs->debug & L1_DEB_HSCX_FIFO) {
75 t +=
sprintf(t,
"sendmbox cnt %d", len);
76 QuickHex(t, &msg[len-i], (i > 64) ? 64 : i);
83 cs->BC_Write_Reg(cs, 1,
ISAR_HIS, his);
84 waitforHIA(cs, 10000);
90 rcv_mbox(
struct IsdnCardState *cs,
struct isar_reg *ireg,
u_char *msg)
95 if (msg && ireg->clsb) {
96 msg[0] = cs->BC_Read_Reg(cs, 1,
ISAR_MBOX);
97 for (i = 1; i < ireg->clsb; i++)
98 msg[i] = cs->BC_Read_Reg(cs, 2,
ISAR_MBOX);
99 #if DUMP_MBOXFRAME > 1
100 if (cs->debug & L1_DEB_HSCX_FIFO) {
106 t +=
sprintf(t,
"rcv_mbox cnt %d", ireg->clsb);
107 QuickHex(t, &msg[ireg->clsb - i], (i > 64) ? 64 : i);
114 cs->BC_Write_Reg(cs, 1,
ISAR_IIA, 0);
119 get_irq_infos(
struct IsdnCardState *cs,
struct isar_reg *ireg)
121 ireg->iis = cs->BC_Read_Reg(cs, 1,
ISAR_IIS);
125 if (cs->debug & L1_DEB_HSCX)
126 debugl1(cs,
"irq_stat(%02x,%02x,%d)", ireg->iis, ireg->cmsb,
132 waitrecmsg(
struct IsdnCardState *cs,
u_char *len,
133 u_char *msg,
int maxdelay)
136 struct isar_reg *
ir = cs->bcs[0].hw.isar.reg;
140 (timeout++ < maxdelay))
142 if (timeout > maxdelay) {
146 get_irq_infos(cs, ir);
147 rcv_mbox(cs, ir, msg);
167 cs->debug &= ~(L1_DEB_HSCX | L1_DEB_HSCX_FIFO);
169 spin_unlock_irqrestore(&cs->lock, flags);
172 if (!waitrecmsg(cs, &len, tmp, 100000)) {
173 spin_unlock_irqrestore(&cs->lock, flags);
185 spin_unlock_irqrestore(&cs->lock, flags);
190 isar_load_firmware(
struct IsdnCardState *cs,
u_char __user *
buf)
198 struct isar_reg *ireg = cs->bcs[0].hw.isar.reg;
205 #define BLK_HEAD_SIZE 6
207 printk(
KERN_ERR"isar_load_firmware wrong isar version %d\n", ret);
212 cs->debug &= ~(L1_DEB_HSCX | L1_DEB_HSCX_FIFO);
217 printk(
KERN_ERR "isar_load_firmware copy_from_user ret %d\n", cfu_ret);
237 spin_unlock_irqrestore(&cs->lock, flags);
240 printk(
KERN_ERR"isar_load_firmware copy_from_user ret %d\n", ret);
244 sadr = (blk_head.sadr & 0xff) * 256 + blk_head.sadr / 256;
245 blk_head.sadr = sadr;
246 sadr = (blk_head.len & 0xff) * 256 + blk_head.len / 256;
248 sadr = (blk_head.d_key & 0xff) * 256 + blk_head.d_key / 256;
249 blk_head.d_key = sadr;
251 cnt += BLK_HEAD_SIZE;
254 blk_head.sadr, blk_head.len, blk_head.d_key & 0xff);
255 sadr = blk_head.sadr;
260 ret = 1;
goto reterr_unlock;
262 if (!waitrecmsg(cs, &len, tmp, 100000)) {
264 ret = 1;
goto reterr_unlock;
268 ireg->iis, ireg->cmsb, len);
269 ret = 1;
goto reterr_unlock;
271 spin_unlock_irqrestore(&cs->lock, flags);
284 printk(
KERN_ERR"isar_load_firmware copy_from_user ret %d\n", ret);
310 ret = 1;
goto reterr_unlock;
312 if (!waitrecmsg(cs, &len, tmp, 100000)) {
314 ret = 1;
goto reterr_unlock;
318 ireg->iis, ireg->cmsb, len);
319 ret = 1;
goto reterr_unlock;
321 spin_unlock_irqrestore(&cs->lock, flags);
336 ret = 1;
goto reterr_unlock;
338 if (!waitrecmsg(cs, &len, tmp, 100000)) {
340 ret = 1;
goto reterr_unlock;
344 ireg->iis, ireg->cmsb, len);
345 ret = 1;
goto reterr_unlock;
351 spin_unlock_irqrestore(&cs->lock, flags);
353 while ((!ireg->bstat) && cnt) {
359 ret = 1;
goto reterror;
372 ret = 1;
goto reterr_unlock;
375 spin_unlock_irqrestore(&cs->lock, flags);
383 ret = 1;
goto reterror;
386 && (ireg->par[0] == 0)) {
390 ireg->cmsb, ireg->clsb, ireg->par[0]);
391 ret = 1;
goto reterror;
397 ret = 1;
goto reterr_unlock;
399 spin_unlock_irqrestore(&cs->lock, flags);
408 ret = 1;
goto reterror;
415 ireg->cmsb, ireg->clsb, cnt);
416 ret = 1;
goto reterror;
425 spin_unlock_irqrestore(&cs->lock, flags);
436 #define B_LL_NOCARRIER 8
437 #define B_LL_CONNECT 9
443 struct BCState *bcs =
container_of(work,
struct BCState, tqueue);
455 send_DLE_ETX(
struct BCState *bcs)
460 if ((skb = dev_alloc_skb(2))) {
470 dle_count(
unsigned char *buf,
int len)
481 insert_dle(
unsigned char *
dest,
unsigned char *
src,
int count) {
491 isar_rcv_frame(
struct IsdnCardState *cs,
struct BCState *bcs)
495 struct isar_reg *ireg = bcs->hw.isar.reg;
498 debugl1(cs,
"isar zero len frame");
499 cs->BC_Write_Reg(cs, 1,
ISAR_IIA, 0);
504 debugl1(cs,
"isar mode 0 spurious IIS_RDATA %x/%x/%x",
505 ireg->iis, ireg->cmsb, ireg->clsb);
507 ireg->iis, ireg->cmsb, ireg->clsb);
508 cs->BC_Write_Reg(cs, 1,
ISAR_IIA, 0);
512 if ((skb = dev_alloc_skb(ireg->clsb))) {
518 cs->BC_Write_Reg(cs, 1,
ISAR_IIA, 0);
522 if ((bcs->hw.isar.rcvidx + ireg->clsb) >
HSCX_BUFMAX) {
523 if (cs->debug & L1_DEB_WARN)
524 debugl1(cs,
"isar_rcv_frame: incoming packet too large");
525 cs->BC_Write_Reg(cs, 1,
ISAR_IIA, 0);
526 bcs->hw.isar.rcvidx = 0;
528 if (cs->debug & L1_DEB_WARN)
529 debugl1(cs,
"isar frame error %x len %d",
530 ireg->cmsb, ireg->clsb);
531 #ifdef ERROR_STATISTIC
537 bcs->hw.isar.rcvidx = 0;
538 cs->BC_Write_Reg(cs, 1,
ISAR_IIA, 0);
541 bcs->hw.isar.rcvidx = 0;
542 ptr = bcs->hw.isar.rcvbuf + bcs->hw.isar.rcvidx;
543 bcs->hw.isar.rcvidx += ireg->clsb;
544 rcv_mbox(cs, ireg, ptr);
546 if (bcs->hw.isar.rcvidx < 3) {
547 if (cs->debug & L1_DEB_WARN)
548 debugl1(cs,
"isar frame to short %d",
549 bcs->hw.isar.rcvidx);
550 }
else if (!(skb = dev_alloc_skb(bcs->hw.isar.rcvidx - 2))) {
554 bcs->hw.isar.rcvbuf, bcs->hw.isar.rcvidx - 2);
558 bcs->hw.isar.rcvidx = 0;
564 if (cs->debug & L1_DEB_WARN)
565 debugl1(cs,
"isar_rcv_frame: not ACTIV");
566 cs->BC_Write_Reg(cs, 1,
ISAR_IIA, 0);
567 bcs->hw.isar.rcvidx = 0;
571 rcv_mbox(cs, ireg, bcs->hw.isar.rcvbuf);
572 bcs->hw.isar.rcvidx = ireg->clsb +
573 dle_count(bcs->hw.isar.rcvbuf, ireg->clsb);
574 if (cs->debug & L1_DEB_HSCX)
575 debugl1(cs,
"isar_rcv_frame: raw(%d) dle(%d)",
576 ireg->clsb, bcs->hw.isar.rcvidx);
577 if ((skb = dev_alloc_skb(bcs->hw.isar.rcvidx))) {
579 bcs->hw.isar.rcvbuf, ireg->clsb);
583 if (cs->debug & L1_DEB_WARN)
584 debugl1(cs,
"isar_rcv_frame: no more data");
585 bcs->hw.isar.rcvidx = 0;
587 sendmsg(cs,
SET_DPS(bcs->hw.isar.dpath) |
599 if (cs->debug & L1_DEB_WARN)
600 debugl1(cs,
"isar_rcv_frame: unknown fax mode %x",
602 cs->BC_Write_Reg(cs, 1,
ISAR_IIA, 0);
603 bcs->hw.isar.rcvidx = 0;
607 if ((bcs->hw.isar.rcvidx + ireg->clsb) >
HSCX_BUFMAX) {
608 if (cs->debug & L1_DEB_WARN)
609 debugl1(cs,
"isar_rcv_frame: incoming packet too large");
610 cs->BC_Write_Reg(cs, 1,
ISAR_IIA, 0);
611 bcs->hw.isar.rcvidx = 0;
613 if (cs->debug & L1_DEB_WARN)
614 debugl1(cs,
"isar frame error %x len %d",
615 ireg->cmsb, ireg->clsb);
616 bcs->hw.isar.rcvidx = 0;
617 cs->BC_Write_Reg(cs, 1,
ISAR_IIA, 0);
620 bcs->hw.isar.rcvidx = 0;
622 ptr = bcs->hw.isar.rcvbuf + bcs->hw.isar.rcvidx;
623 bcs->hw.isar.rcvidx += ireg->clsb;
624 rcv_mbox(cs, ireg, ptr);
626 int len = bcs->hw.isar.rcvidx +
627 dle_count(bcs->hw.isar.rcvbuf, bcs->hw.isar.rcvidx);
628 if (bcs->hw.isar.rcvidx < 3) {
629 if (cs->debug & L1_DEB_WARN)
630 debugl1(cs,
"isar frame to short %d",
631 bcs->hw.isar.rcvidx);
633 bcs->hw.isar.rcvidx);
634 }
else if (!(skb = dev_alloc_skb(len))) {
639 bcs->hw.isar.rcvidx);
646 bcs->hw.isar.rcvidx = 0;
650 if (cs->debug & L1_DEB_WARN)
651 debugl1(cs,
"isar_rcv_frame: no more data");
652 bcs->hw.isar.rcvidx = 0;
653 sendmsg(cs,
SET_DPS(bcs->hw.isar.dpath) |
664 cs->BC_Write_Reg(cs, 1,
ISAR_IIA, 0);
672 struct IsdnCardState *cs = bcs->cs;
677 if ((cs->debug & L1_DEB_HSCX) && !(cs->debug & L1_DEB_HSCX_FIFO))
681 if (bcs->tx_skb->len <= 0)
683 if (!(bcs->hw.isar.reg->bstat &
686 if (bcs->tx_skb->len > bcs->hw.isar.mml) {
688 count = bcs->hw.isar.mml;
690 count = bcs->tx_skb->len;
693 ptr = bcs->tx_skb->data;
694 if (!bcs->hw.isar.txcnt) {
698 if (bcs->tx_skb->len > 1) {
699 if ((ptr[0] == 0xff) && (ptr[1] == 0x13))
707 bcs->tx_cnt -=
count;
708 bcs->hw.isar.txcnt +=
count;
724 if (cs->debug & L1_DEB_WARN)
725 debugl1(cs,
"isar_fill_fifo: not ACTIV");
733 if (cs->debug & L1_DEB_WARN)
734 debugl1(cs,
"isar_fill_fifo: not FTH/FTM");
739 debugl1(cs,
"isar_fill_fifo mode(%x) error", bcs->mode);
746 struct BCState *sel_bcs_isar(
struct IsdnCardState *cs,
u_char dpath)
748 if ((!dpath) || (dpath == 3))
750 if (cs->bcs[0].hw.isar.dpath == dpath)
751 return (&cs->bcs[0]);
752 if (cs->bcs[1].hw.isar.dpath == dpath)
753 return (&cs->bcs[1]);
758 send_frames(
struct BCState *bcs)
761 if (bcs->tx_skb->len) {
765 if (
test_bit(FLG_LLI_L1WAKEUP, &bcs->st->lli.flag) &&
766 (PACKET_NOACK != bcs->tx_skb->pkt_type)) {
769 bcs->ackcnt += bcs->hw.isar.txcnt;
770 spin_unlock_irqrestore(&bcs->aclock, flags);
775 if (
test_bit(BC_FLG_LASTDATA, &bcs->Flag)) {
779 if (
test_bit(BC_FLG_DLEETX, &bcs->Flag)) {
786 bcs->hw.isar.txcnt = 0;
791 bcs->hw.isar.txcnt = 0;
799 sendmsg(bcs->cs,
SET_DPS(bcs->hw.isar.dpath) |
813 check_send(
struct IsdnCardState *cs,
u_char rdm)
818 if ((bcs = sel_bcs_isar(cs, 1))) {
825 if ((bcs = sel_bcs_isar(cs, 2))) {
834 static const char *
dmril[] = {
"NO SPEED",
"1200/75",
"NODEF2",
"75/1200",
835 "NODEF4",
"300",
"600",
"1200",
"2400",
836 "4800",
"7200",
"9600nt",
"9600t",
"12000",
838 static const char *
dmrim[] = {
"NO MOD",
"NO DEF",
"V32/V32b",
"V22",
"V21",
839 "Bell103",
"V23",
"Bell202",
"V17",
"V29",
843 isar_pump_status_rsp(
struct BCState *bcs,
struct isar_reg *ireg) {
844 struct IsdnCardState *cs = bcs->cs;
845 u_char ril = ireg->par[0];
851 if (cs->debug & L1_DEB_WARN)
852 debugl1(cs,
"wrong pstrsp ril=%d", ril);
855 switch (ireg->par[1]) {
890 sprintf(bcs->hw.isar.conmsg,
"%s %s", dmril[ril], dmrim[rim]);
891 bcs->conmsg = bcs->hw.isar.conmsg;
892 if (cs->debug & L1_DEB_HSCX)
893 debugl1(cs,
"pump strsp %s", bcs->conmsg);
897 isar_pump_statev_modem(
struct BCState *bcs,
u_char devt) {
898 struct IsdnCardState *cs = bcs->cs;
903 if (cs->debug & L1_DEB_HSCX)
904 debugl1(cs,
"pump stev TIMER");
907 if (cs->debug & L1_DEB_HSCX)
908 debugl1(cs,
"pump stev CONNECT");
912 if (cs->debug & L1_DEB_HSCX)
913 debugl1(cs,
"pump stev NO CONNECT");
918 if (cs->debug & L1_DEB_HSCX)
919 debugl1(cs,
"pump stev V24 OFF");
922 if (cs->debug & L1_DEB_HSCX)
923 debugl1(cs,
"pump stev CTS ON");
926 if (cs->debug & L1_DEB_HSCX)
927 debugl1(cs,
"pump stev CTS OFF");
930 if (cs->debug & L1_DEB_HSCX)
931 debugl1(cs,
"pump stev CARRIER ON");
936 if (cs->debug & L1_DEB_HSCX)
937 debugl1(cs,
"pump stev CARRIER OFF");
940 if (cs->debug & L1_DEB_HSCX)
941 debugl1(cs,
"pump stev DSR ON");
944 if (cs->debug & L1_DEB_HSCX)
945 debugl1(cs,
"pump stev DSR_OFF");
948 if (cs->debug & L1_DEB_HSCX)
949 debugl1(cs,
"pump stev REMOTE RETRAIN");
952 if (cs->debug & L1_DEB_HSCX)
953 debugl1(cs,
"pump stev REMOTE RENEGOTIATE");
956 if (cs->debug & L1_DEB_HSCX)
957 debugl1(cs,
"pump stev GSTN CLEAR");
960 if (cs->debug & L1_DEB_HSCX)
961 debugl1(cs,
"unknown pump stev %x", devt);
972 if (bcs->cs->debug & L1_DEB_HSCX)
973 debugl1(bcs->cs,
"HL->LL FAXIND %x", status);
974 ic.
driver = bcs->cs->myid;
976 ic.
arg = chanp->chan;
978 bcs->cs->iif.statcallb(&ic);
982 isar_pump_statev_fax(
struct BCState *bcs,
u_char devt) {
983 struct IsdnCardState *cs = bcs->cs;
989 if (cs->debug & L1_DEB_HSCX)
990 debugl1(cs,
"pump stev TIMER");
993 if (cs->debug & L1_DEB_HSCX)
994 debugl1(cs,
"pump stev RSP_READY");
997 if (
test_bit(BC_FLG_ORIG, &bcs->Flag)) {
1005 if (cs->debug & L1_DEB_HSCX)
1006 debugl1(cs,
"pump stev LINE_TX_H");
1010 if (cs->debug & L1_DEB_WARN)
1011 debugl1(cs,
"pump stev LINE_TX_H wrong st %x",
1012 bcs->hw.isar.state);
1017 if (cs->debug & L1_DEB_HSCX)
1018 debugl1(cs,
"pump stev LINE_RX_H");
1022 if (cs->debug & L1_DEB_WARN)
1023 debugl1(cs,
"pump stev LINE_RX_H wrong st %x",
1024 bcs->hw.isar.state);
1029 if (cs->debug & L1_DEB_HSCX)
1030 debugl1(cs,
"pump stev LINE_TX_B");
1034 if (cs->debug & L1_DEB_WARN)
1035 debugl1(cs,
"pump stev LINE_TX_B wrong st %x",
1036 bcs->hw.isar.state);
1041 if (cs->debug & L1_DEB_HSCX)
1042 debugl1(cs,
"pump stev LINE_RX_B");
1046 if (cs->debug & L1_DEB_WARN)
1047 debugl1(cs,
"pump stev LINE_RX_B wrong st %x",
1048 bcs->hw.isar.state);
1053 if (cs->debug & L1_DEB_HSCX)
1054 debugl1(cs,
"pump stev RSP_CONN");
1063 bcs->hw.isar.ftimer.expires =
1072 if (cs->debug & L1_DEB_WARN)
1073 debugl1(cs,
"pump stev RSP_CONN wrong st %x",
1074 bcs->hw.isar.state);
1078 if (cs->debug & L1_DEB_HSCX)
1079 debugl1(cs,
"pump stev FLAGS_DET");
1082 if (cs->debug & L1_DEB_HSCX)
1083 debugl1(cs,
"pump stev RSP_DISC");
1086 switch (bcs->hw.isar.newcmd) {
1098 if (frm_extra_delay)
1101 p1 = bcs->hw.isar.mod = bcs->hw.isar.newmod;
1102 bcs->hw.isar.newmod = 0;
1103 bcs->hw.isar.cmd = bcs->hw.isar.newcmd;
1104 bcs->hw.isar.newcmd = 0;
1106 bcs->hw.isar.cmd, 1, &p1);
1108 bcs->hw.isar.try_mod = 3;
1111 if (cs->debug & L1_DEB_HSCX)
1112 debugl1(cs,
"RSP_DISC unknown newcmd %x", bcs->hw.isar.newcmd);
1131 if (cs->debug & L1_DEB_HSCX)
1132 debugl1(cs,
"pump stev RSP_SILDET");
1134 p1 = bcs->hw.isar.mod = bcs->hw.isar.newmod;
1135 bcs->hw.isar.newmod = 0;
1136 bcs->hw.isar.cmd = bcs->hw.isar.newcmd;
1137 bcs->hw.isar.newcmd = 0;
1139 bcs->hw.isar.cmd, 1, &p1);
1141 bcs->hw.isar.try_mod = 3;
1145 if (cs->debug & L1_DEB_HSCX)
1146 debugl1(cs,
"pump stev RSP_SILOFF");
1150 if (cs->debug & L1_DEB_HSCX)
1151 debugl1(cs,
"pump stev RSP_FCERR try %d",
1152 bcs->hw.isar.try_mod);
1153 if (bcs->hw.isar.try_mod--) {
1155 bcs->hw.isar.cmd, 1,
1160 if (cs->debug & L1_DEB_HSCX)
1161 debugl1(cs,
"pump stev RSP_FCERR");
1171 static char debbuf[128];
1176 struct isar_reg *ireg = cs->bcs[0].hw.isar.reg;
1177 struct BCState *bcs;
1179 get_irq_infos(cs, ireg);
1182 if ((bcs = sel_bcs_isar(cs, ireg->iis >> 6))) {
1183 isar_rcv_frame(cs, bcs);
1185 debugl1(cs,
"isar spurious IIS_RDATA %x/%x/%x",
1186 ireg->iis, ireg->cmsb, ireg->clsb);
1187 cs->BC_Write_Reg(cs, 1,
ISAR_IIA, 0);
1191 cs->BC_Write_Reg(cs, 1,
ISAR_IIA, 0);
1192 ireg->bstat |= ireg->cmsb;
1193 check_send(cs, ireg->cmsb);
1196 #ifdef ERROR_STATISTIC
1197 if ((bcs = sel_bcs_isar(cs, ireg->iis >> 6))) {
1204 if (cs->debug & L1_DEB_WARN)
1205 debugl1(cs,
"Buffer STEV dpath%d msb(%x)",
1206 ireg->iis >> 6, ireg->cmsb);
1207 cs->BC_Write_Reg(cs, 1,
ISAR_IIA, 0);
1210 if ((bcs = sel_bcs_isar(cs, ireg->iis >> 6))) {
1211 rcv_mbox(cs, ireg, (
u_char *)ireg->par);
1213 isar_pump_statev_modem(bcs, ireg->cmsb);
1215 isar_pump_statev_fax(bcs, ireg->cmsb);
1217 if (cs->debug & L1_DEB_HSCX)
1218 debugl1(cs,
"pump stev TIMER");
1220 if (cs->debug & L1_DEB_WARN)
1221 debugl1(cs,
"isar IIS_PSTEV pmode %d stat %x",
1222 bcs->mode, ireg->cmsb);
1225 debugl1(cs,
"isar spurious IIS_PSTEV %x/%x/%x",
1226 ireg->iis, ireg->cmsb, ireg->clsb);
1227 cs->BC_Write_Reg(cs, 1,
ISAR_IIA, 0);
1231 if ((bcs = sel_bcs_isar(cs, ireg->iis >> 6))) {
1232 rcv_mbox(cs, ireg, (
u_char *)ireg->par);
1233 isar_pump_status_rsp(bcs, ireg);
1235 debugl1(cs,
"isar spurious IIS_PSTRSP %x/%x/%x",
1236 ireg->iis, ireg->cmsb, ireg->clsb);
1237 cs->BC_Write_Reg(cs, 1,
ISAR_IIA, 0);
1243 rcv_mbox(cs, ireg, (
u_char *)ireg->par);
1244 if ((cs->debug & (L1_DEB_HSCX | L1_DEB_HSCX_FIFO))
1248 tp +=
sprintf(debbuf,
"msg iis(%x) msb(%x)",
1249 ireg->iis, ireg->cmsb);
1255 rcv_mbox(cs, ireg, debbuf);
1256 if (cs->debug & L1_DEB_WARN)
1257 debugl1(cs,
"invalid msg his:%x",
1261 rcv_mbox(cs, ireg, debbuf);
1262 if (cs->debug & L1_DEB_WARN)
1263 debugl1(cs,
"unhandled msg iis(%x) ctrl(%x/%x)",
1264 ireg->iis, ireg->cmsb, ireg->clsb);
1270 ftimer_handler(
struct BCState *bcs) {
1272 debugl1(bcs->cs,
"ftimer flags %04lx",
1284 setup_pump(
struct BCState *bcs) {
1285 struct IsdnCardState *cs = bcs->cs;
1289 switch (bcs->mode) {
1297 if (
test_bit(BC_FLG_ORIG, &bcs->Flag)) {
1303 param[0] = para_TOA;
1313 if (
test_bit(BC_FLG_ORIG, &bcs->Flag)) {
1319 param[0] = para_TOA;
1322 bcs->hw.isar.newcmd = 0;
1323 bcs->hw.isar.newmod = 0;
1333 setup_sart(
struct BCState *bcs) {
1334 struct IsdnCardState *cs = bcs->cs;
1338 switch (bcs->mode) {
1369 setup_iom2(
struct BCState *bcs) {
1370 struct IsdnCardState *cs = bcs->cs;
1375 msg[1] = msg[3] = 1;
1376 switch (bcs->mode) {
1380 msg[1] = msg[3] = bcs->hw.isar.dpath + 2;
1397 modeisar(
struct BCState *bcs,
int mode,
int bc)
1399 struct IsdnCardState *cs = bcs->cs;
1406 if (!bcs->hw.isar.dpath)
1414 &bcs->hw.isar.reg->Flags))
1415 bcs->hw.isar.dpath = 2;
1417 &bcs->hw.isar.reg->Flags))
1418 bcs->hw.isar.dpath = 1;
1428 &bcs->hw.isar.reg->Flags))
1429 bcs->hw.isar.dpath = 1;
1432 debugl1(cs,
"isar modeisar analog functions only with DP1");
1438 if (cs->debug & L1_DEB_HSCX)
1439 debugl1(cs,
"isar dp%d mode %d->%d ichan %d",
1440 bcs->hw.isar.dpath, bcs->mode, mode, bc);
1447 if (bcs->hw.isar.dpath == 1)
1449 else if (bcs->hw.isar.dpath == 2)
1451 bcs->hw.isar.dpath = 0;
1459 struct IsdnCardState *cs = bcs->cs;
1461 u_char ctrl = 0, nom = 0, p1 = 0;
1471 bcs->hw.isar.cmd =
ctrl;
1472 bcs->hw.isar.mod = para;
1473 bcs->hw.isar.newmod = 0;
1474 bcs->hw.isar.newcmd = 0;
1475 bcs->hw.isar.try_mod = 3;
1478 (bcs->hw.isar.mod == para)) {
1481 bcs->hw.isar.newmod = para;
1495 bcs->hw.isar.cmd =
ctrl;
1496 bcs->hw.isar.mod = para;
1497 bcs->hw.isar.newmod = 0;
1498 bcs->hw.isar.newcmd = 0;
1499 bcs->hw.isar.try_mod = 3;
1502 (bcs->hw.isar.mod == para)) {
1505 bcs->hw.isar.newmod = para;
1519 bcs->hw.isar.cmd =
ctrl;
1520 bcs->hw.isar.mod = para;
1521 bcs->hw.isar.newmod = 0;
1522 bcs->hw.isar.newcmd = 0;
1523 bcs->hw.isar.try_mod = 3;
1526 (bcs->hw.isar.mod == para)) {
1529 bcs->hw.isar.newmod = para;
1543 bcs->hw.isar.cmd =
ctrl;
1544 bcs->hw.isar.mod = para;
1545 bcs->hw.isar.newmod = 0;
1546 bcs->hw.isar.newcmd = 0;
1547 bcs->hw.isar.try_mod = 3;
1550 (bcs->hw.isar.mod == para)) {
1553 bcs->hw.isar.newmod = para;
1571 isar_setup(
struct IsdnCardState *cs)
1578 for (i = 0; i < 2; i++) {
1582 cs->bcs[
i].hw.isar.mml =
msg;
1583 cs->bcs[
i].mode = 0;
1584 cs->bcs[
i].hw.isar.dpath = i + 1;
1585 modeisar(&cs->bcs[i], 0, 0);
1591 isar_l2l1(
struct PStack *
st,
int pr,
void *
arg)
1593 struct BCState *bcs = st->l1.bcs;
1606 if (bcs->cs->debug & L1_DEB_HSCX)
1607 debugl1(bcs->cs,
"DRQ set BC_FLG_BUSY");
1608 bcs->hw.isar.txcnt = 0;
1609 bcs->cs->BC_Send_Data(bcs);
1611 spin_unlock_irqrestore(&bcs->cs->lock, flags);
1619 if (bcs->cs->debug & L1_DEB_HSCX)
1620 debugl1(bcs->cs,
"PUI set BC_FLG_BUSY");
1622 bcs->hw.isar.txcnt = 0;
1623 bcs->cs->BC_Send_Data(bcs);
1625 spin_unlock_irqrestore(&bcs->cs->lock, flags);
1637 bcs->hw.isar.conmsg[0] = 0;
1642 switch (st->l1.mode) {
1645 ret = modeisar(bcs, st->l1.mode, st->l1.bc);
1646 spin_unlock_irqrestore(&bcs->cs->lock, flags);
1654 ret = modeisar(bcs, st->l1.mode, st->l1.bc);
1655 spin_unlock_irqrestore(&bcs->cs->lock, flags);
1660 spin_unlock_irqrestore(&bcs->cs->lock, flags);
1669 switch (st->l1.mode) {
1680 if (bcs->cs->debug & L1_DEB_HSCX)
1681 debugl1(bcs->cs,
"PDAC clear BC_FLG_BUSY");
1682 modeisar(bcs, 0, st->l1.bc);
1683 spin_unlock_irqrestore(&bcs->cs->lock, flags);
1690 close_isarstate(
struct BCState *bcs)
1692 modeisar(bcs, 0, bcs->channel);
1694 kfree(bcs->hw.isar.rcvbuf);
1695 bcs->hw.isar.rcvbuf =
NULL;
1702 if (bcs->cs->debug & L1_DEB_HSCX)
1703 debugl1(bcs->cs,
"closeisar clear BC_FLG_BUSY");
1710 open_isarstate(
struct IsdnCardState *cs,
struct BCState *bcs)
1715 "HiSax: No memory for isar.rcvbuf\n");
1718 skb_queue_head_init(&bcs->rqueue);
1719 skb_queue_head_init(&bcs->squeue);
1723 if (cs->debug & L1_DEB_HSCX)
1724 debugl1(cs,
"openisar clear BC_FLG_BUSY");
1726 bcs->hw.isar.rcvidx = 0;
1732 setstack_isar(
struct PStack *st,
struct BCState *bcs)
1734 bcs->channel = st->l1.bc;
1735 if (open_isarstate(st->l1.hardware, bcs))
1738 st->l2.l2l1 = isar_l2l1;
1749 struct BCState *bcs;
1751 if (cs->debug & L1_DEB_HSCX)
1755 bcs = cs->channel[ic->
arg].bcs;
1756 if (cs->debug & L1_DEB_HSCX)
1757 debugl1(cs,
"isar_auxcmd cmd/subcmd %d/%d",
1769 cs->iif.statcallb(ic);
1775 cs->iif.statcallb(ic);
1778 if (cs->debug & L1_DEB_HSCX)
1779 debugl1(cs,
"isar_auxcmd %s=%d",
1785 cs->iif.statcallb(ic);
1790 bcs->hw.isar.ftimer.expires =
1797 debugl1(cs,
"isar FTS=%d and FTI busy",
1802 debugl1(cs,
"isar FTS=%d and isar.state not ready(%x)",
1807 cs->iif.statcallb(ic);
1816 "%d", bcs->hw.isar.mod);
1819 cs->iif.statcallb(ic);
1824 if ((1 << i) & modmask)
1825 p +=
sprintf(p,
"%d,", faxmodulation[i]);
1830 cs->iif.statcallb(ic);
1833 if (cs->debug & L1_DEB_HSCX)
1834 debugl1(cs,
"isar_auxcmd %s=%d",
1839 if ((i < FAXMODCNT) && ((1 << i) & modmask) &&
1840 test_bit(BC_FLG_INIT, &bcs->Flag)) {
1852 cs->iif.statcallb(ic);
1868 features = *(
unsigned int *) ic->
parm.
num;
1874 features = *(
unsigned int *) ic->
parm.
num;
1876 frm_extra_delay, features);
1881 features = *(
unsigned int *) ic->
parm.
num;
1883 para_TOA, features);
1884 if (features >= 0 && features < 32)
1901 cs->bcs[0].BC_SetStack = setstack_isar;
1902 cs->bcs[1].BC_SetStack = setstack_isar;
1903 cs->bcs[0].BC_Close = close_isarstate;
1904 cs->bcs[1].BC_Close = close_isarstate;
1905 cs->bcs[0].hw.isar.ftimer.function = (
void *) ftimer_handler;
1906 cs->bcs[0].hw.isar.ftimer.data = (
long) &cs->bcs[0];
1908 cs->bcs[1].hw.isar.ftimer.function = (
void *) ftimer_handler;
1909 cs->bcs[1].hw.isar.ftimer.data = (
long) &cs->bcs[1];