w6692.c 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087
  1. /* $Id: w6692.c,v 1.18.2.4 2004/02/11 13:21:34 keil Exp $
  2. *
  3. * Winbond W6692 specific routines
  4. *
  5. * Author Petr Novak
  6. * Copyright by Petr Novak <petr.novak@i.cz>
  7. *
  8. * This software may be used and distributed according to the terms
  9. * of the GNU General Public License, incorporated herein by reference.
  10. *
  11. */
  12. #include <linux/init.h>
  13. #include "hisax.h"
  14. #include "w6692.h"
  15. #include "isdnl1.h"
  16. #include <linux/interrupt.h>
  17. #include <linux/pci.h>
  18. #include <linux/slab.h>
  19. /* table entry in the PCI devices list */
  20. typedef struct {
  21. int vendor_id;
  22. int device_id;
  23. char *vendor_name;
  24. char *card_name;
  25. } PCI_ENTRY;
  26. static const PCI_ENTRY id_list[] =
  27. {
  28. {PCI_VENDOR_ID_WINBOND2, PCI_DEVICE_ID_WINBOND2_6692, "Winbond", "W6692"},
  29. {PCI_VENDOR_ID_DYNALINK, PCI_DEVICE_ID_DYNALINK_IS64PH, "Dynalink/AsusCom", "IS64PH"},
  30. {0, 0, "U.S.Robotics", "ISDN PCI Card TA"}
  31. };
  32. #define W6692_SV_USR 0x16ec
  33. #define W6692_SD_USR 0x3409
  34. #define W6692_WINBOND 0
  35. #define W6692_DYNALINK 1
  36. #define W6692_USR 2
  37. static const char *w6692_revision = "$Revision: 1.18.2.4 $";
  38. #define DBUSY_TIMER_VALUE 80
  39. static char *W6692Ver[] =
  40. {"W6692 V00", "W6692 V01", "W6692 V10",
  41. "W6692 V11"};
  42. static void
  43. W6692Version(struct IsdnCardState *cs, char *s)
  44. {
  45. int val;
  46. val = cs->readW6692(cs, W_D_RBCH);
  47. printk(KERN_INFO "%s Winbond W6692 version (%x): %s\n", s, val, W6692Ver[(val >> 6) & 3]);
  48. }
  49. static void
  50. ph_command(struct IsdnCardState *cs, unsigned int command)
  51. {
  52. if (cs->debug & L1_DEB_ISAC)
  53. debugl1(cs, "ph_command %x", command);
  54. cs->writeisac(cs, W_CIX, command);
  55. }
  56. static void
  57. W6692_new_ph(struct IsdnCardState *cs)
  58. {
  59. switch (cs->dc.w6692.ph_state) {
  60. case (W_L1CMD_RST):
  61. ph_command(cs, W_L1CMD_DRC);
  62. l1_msg(cs, HW_RESET | INDICATION, NULL);
  63. /* fallthru */
  64. case (W_L1IND_CD):
  65. l1_msg(cs, HW_DEACTIVATE | CONFIRM, NULL);
  66. break;
  67. case (W_L1IND_DRD):
  68. l1_msg(cs, HW_DEACTIVATE | INDICATION, NULL);
  69. break;
  70. case (W_L1IND_CE):
  71. l1_msg(cs, HW_POWERUP | CONFIRM, NULL);
  72. break;
  73. case (W_L1IND_LD):
  74. l1_msg(cs, HW_RSYNC | INDICATION, NULL);
  75. break;
  76. case (W_L1IND_ARD):
  77. l1_msg(cs, HW_INFO2 | INDICATION, NULL);
  78. break;
  79. case (W_L1IND_AI8):
  80. l1_msg(cs, HW_INFO4_P8 | INDICATION, NULL);
  81. break;
  82. case (W_L1IND_AI10):
  83. l1_msg(cs, HW_INFO4_P10 | INDICATION, NULL);
  84. break;
  85. default:
  86. break;
  87. }
  88. }
  89. static void
  90. W6692_bh(struct work_struct *work)
  91. {
  92. struct IsdnCardState *cs =
  93. container_of(work, struct IsdnCardState, tqueue);
  94. struct PStack *stptr;
  95. if (test_and_clear_bit(D_CLEARBUSY, &cs->event)) {
  96. if (cs->debug)
  97. debugl1(cs, "D-Channel Busy cleared");
  98. stptr = cs->stlist;
  99. while (stptr != NULL) {
  100. stptr->l1.l1l2(stptr, PH_PAUSE | CONFIRM, NULL);
  101. stptr = stptr->next;
  102. }
  103. }
  104. if (test_and_clear_bit(D_L1STATECHANGE, &cs->event))
  105. W6692_new_ph(cs);
  106. if (test_and_clear_bit(D_RCVBUFREADY, &cs->event))
  107. DChannel_proc_rcv(cs);
  108. if (test_and_clear_bit(D_XMTBUFREADY, &cs->event))
  109. DChannel_proc_xmt(cs);
  110. /*
  111. if (test_and_clear_bit(D_RX_MON1, &cs->event))
  112. arcofi_fsm(cs, ARCOFI_RX_END, NULL);
  113. if (test_and_clear_bit(D_TX_MON1, &cs->event))
  114. arcofi_fsm(cs, ARCOFI_TX_END, NULL);
  115. */
  116. }
  117. static void
  118. W6692_empty_fifo(struct IsdnCardState *cs, int count)
  119. {
  120. u_char *ptr;
  121. if ((cs->debug & L1_DEB_ISAC) && !(cs->debug & L1_DEB_ISAC_FIFO))
  122. debugl1(cs, "W6692_empty_fifo");
  123. if ((cs->rcvidx + count) >= MAX_DFRAME_LEN_L1) {
  124. if (cs->debug & L1_DEB_WARN)
  125. debugl1(cs, "W6692_empty_fifo overrun %d",
  126. cs->rcvidx + count);
  127. cs->writeW6692(cs, W_D_CMDR, W_D_CMDR_RACK);
  128. cs->rcvidx = 0;
  129. return;
  130. }
  131. ptr = cs->rcvbuf + cs->rcvidx;
  132. cs->rcvidx += count;
  133. cs->readW6692fifo(cs, ptr, count);
  134. cs->writeW6692(cs, W_D_CMDR, W_D_CMDR_RACK);
  135. if (cs->debug & L1_DEB_ISAC_FIFO) {
  136. char *t = cs->dlog;
  137. t += sprintf(t, "W6692_empty_fifo cnt %d", count);
  138. QuickHex(t, ptr, count);
  139. debugl1(cs, "%s", cs->dlog);
  140. }
  141. }
  142. static void
  143. W6692_fill_fifo(struct IsdnCardState *cs)
  144. {
  145. int count, more;
  146. u_char *ptr;
  147. if ((cs->debug & L1_DEB_ISAC) && !(cs->debug & L1_DEB_ISAC_FIFO))
  148. debugl1(cs, "W6692_fill_fifo");
  149. if (!cs->tx_skb)
  150. return;
  151. count = cs->tx_skb->len;
  152. if (count <= 0)
  153. return;
  154. more = 0;
  155. if (count > W_D_FIFO_THRESH) {
  156. more = !0;
  157. count = W_D_FIFO_THRESH;
  158. }
  159. ptr = cs->tx_skb->data;
  160. skb_pull(cs->tx_skb, count);
  161. cs->tx_cnt += count;
  162. cs->writeW6692fifo(cs, ptr, count);
  163. cs->writeW6692(cs, W_D_CMDR, more ? W_D_CMDR_XMS : (W_D_CMDR_XMS | W_D_CMDR_XME));
  164. if (test_and_set_bit(FLG_DBUSY_TIMER, &cs->HW_Flags)) {
  165. debugl1(cs, "W6692_fill_fifo dbusytimer running");
  166. del_timer(&cs->dbusytimer);
  167. }
  168. init_timer(&cs->dbusytimer);
  169. cs->dbusytimer.expires = jiffies + ((DBUSY_TIMER_VALUE * HZ) / 1000);
  170. add_timer(&cs->dbusytimer);
  171. if (cs->debug & L1_DEB_ISAC_FIFO) {
  172. char *t = cs->dlog;
  173. t += sprintf(t, "W6692_fill_fifo cnt %d", count);
  174. QuickHex(t, ptr, count);
  175. debugl1(cs, "%s", cs->dlog);
  176. }
  177. }
  178. static void
  179. W6692B_empty_fifo(struct BCState *bcs, int count)
  180. {
  181. u_char *ptr;
  182. struct IsdnCardState *cs = bcs->cs;
  183. if ((cs->debug & L1_DEB_HSCX) && !(cs->debug & L1_DEB_HSCX_FIFO))
  184. debugl1(cs, "W6692B_empty_fifo");
  185. if (bcs->hw.w6692.rcvidx + count > HSCX_BUFMAX) {
  186. if (cs->debug & L1_DEB_WARN)
  187. debugl1(cs, "W6692B_empty_fifo: incoming packet too large");
  188. cs->BC_Write_Reg(cs, bcs->channel, W_B_CMDR, W_B_CMDR_RACK | W_B_CMDR_RACT);
  189. bcs->hw.w6692.rcvidx = 0;
  190. return;
  191. }
  192. ptr = bcs->hw.w6692.rcvbuf + bcs->hw.w6692.rcvidx;
  193. bcs->hw.w6692.rcvidx += count;
  194. READW6692BFIFO(cs, bcs->channel, ptr, count);
  195. cs->BC_Write_Reg(cs, bcs->channel, W_B_CMDR, W_B_CMDR_RACK | W_B_CMDR_RACT);
  196. if (cs->debug & L1_DEB_HSCX_FIFO) {
  197. char *t = bcs->blog;
  198. t += sprintf(t, "W6692B_empty_fifo %c cnt %d",
  199. bcs->channel + '1', count);
  200. QuickHex(t, ptr, count);
  201. debugl1(cs, "%s", bcs->blog);
  202. }
  203. }
  204. static void
  205. W6692B_fill_fifo(struct BCState *bcs)
  206. {
  207. struct IsdnCardState *cs = bcs->cs;
  208. int more, count;
  209. u_char *ptr;
  210. if (!bcs->tx_skb)
  211. return;
  212. if (bcs->tx_skb->len <= 0)
  213. return;
  214. more = (bcs->mode == L1_MODE_TRANS) ? 1 : 0;
  215. if (bcs->tx_skb->len > W_B_FIFO_THRESH) {
  216. more = 1;
  217. count = W_B_FIFO_THRESH;
  218. } else
  219. count = bcs->tx_skb->len;
  220. if ((cs->debug & L1_DEB_HSCX) && !(cs->debug & L1_DEB_HSCX_FIFO))
  221. debugl1(cs, "W6692B_fill_fifo%s%d", (more ? " " : " last "), count);
  222. ptr = bcs->tx_skb->data;
  223. skb_pull(bcs->tx_skb, count);
  224. bcs->tx_cnt -= count;
  225. bcs->hw.w6692.count += count;
  226. WRITEW6692BFIFO(cs, bcs->channel, ptr, count);
  227. cs->BC_Write_Reg(cs, bcs->channel, W_B_CMDR, W_B_CMDR_RACT | W_B_CMDR_XMS | (more ? 0 : W_B_CMDR_XME));
  228. if (cs->debug & L1_DEB_HSCX_FIFO) {
  229. char *t = bcs->blog;
  230. t += sprintf(t, "W6692B_fill_fifo %c cnt %d",
  231. bcs->channel + '1', count);
  232. QuickHex(t, ptr, count);
  233. debugl1(cs, "%s", bcs->blog);
  234. }
  235. }
  236. static void
  237. W6692B_interrupt(struct IsdnCardState *cs, u_char bchan)
  238. {
  239. u_char val;
  240. u_char r;
  241. struct BCState *bcs;
  242. struct sk_buff *skb;
  243. int count;
  244. bcs = (cs->bcs->channel == bchan) ? cs->bcs : (cs->bcs + 1);
  245. val = cs->BC_Read_Reg(cs, bchan, W_B_EXIR);
  246. debugl1(cs, "W6692B chan %d B_EXIR 0x%02X", bchan, val);
  247. if (!test_bit(BC_FLG_INIT, &bcs->Flag)) {
  248. debugl1(cs, "W6692B not INIT yet");
  249. return;
  250. }
  251. if (val & W_B_EXI_RME) { /* RME */
  252. r = cs->BC_Read_Reg(cs, bchan, W_B_STAR);
  253. if (r & (W_B_STAR_RDOV | W_B_STAR_CRCE | W_B_STAR_RMB)) {
  254. if (cs->debug & L1_DEB_WARN)
  255. debugl1(cs, "W6692 B STAR %x", r);
  256. if ((r & W_B_STAR_RDOV) && bcs->mode)
  257. if (cs->debug & L1_DEB_WARN)
  258. debugl1(cs, "W6692 B RDOV mode=%d",
  259. bcs->mode);
  260. if (r & W_B_STAR_CRCE)
  261. if (cs->debug & L1_DEB_WARN)
  262. debugl1(cs, "W6692 B CRC error");
  263. cs->BC_Write_Reg(cs, bchan, W_B_CMDR, W_B_CMDR_RACK | W_B_CMDR_RRST | W_B_CMDR_RACT);
  264. } else {
  265. count = cs->BC_Read_Reg(cs, bchan, W_B_RBCL) & (W_B_FIFO_THRESH - 1);
  266. if (count == 0)
  267. count = W_B_FIFO_THRESH;
  268. W6692B_empty_fifo(bcs, count);
  269. if ((count = bcs->hw.w6692.rcvidx) > 0) {
  270. if (cs->debug & L1_DEB_HSCX_FIFO)
  271. debugl1(cs, "W6692 Bchan Frame %d", count);
  272. if (!(skb = dev_alloc_skb(count)))
  273. printk(KERN_WARNING "W6692: Bchan receive out of memory\n");
  274. else {
  275. skb_put_data(skb,
  276. bcs->hw.w6692.rcvbuf,
  277. count);
  278. skb_queue_tail(&bcs->rqueue, skb);
  279. }
  280. }
  281. }
  282. bcs->hw.w6692.rcvidx = 0;
  283. schedule_event(bcs, B_RCVBUFREADY);
  284. }
  285. if (val & W_B_EXI_RMR) { /* RMR */
  286. W6692B_empty_fifo(bcs, W_B_FIFO_THRESH);
  287. r = cs->BC_Read_Reg(cs, bchan, W_B_STAR);
  288. if (r & W_B_STAR_RDOV) {
  289. if (cs->debug & L1_DEB_WARN)
  290. debugl1(cs, "W6692 B RDOV(RMR) mode=%d", bcs->mode);
  291. cs->BC_Write_Reg(cs, bchan, W_B_CMDR, W_B_CMDR_RACK | W_B_CMDR_RRST | W_B_CMDR_RACT);
  292. if (bcs->mode != L1_MODE_TRANS)
  293. bcs->hw.w6692.rcvidx = 0;
  294. }
  295. if (bcs->mode == L1_MODE_TRANS) {
  296. /* receive audio data */
  297. if (!(skb = dev_alloc_skb(W_B_FIFO_THRESH)))
  298. printk(KERN_WARNING "HiSax: receive out of memory\n");
  299. else {
  300. skb_put_data(skb, bcs->hw.w6692.rcvbuf,
  301. W_B_FIFO_THRESH);
  302. skb_queue_tail(&bcs->rqueue, skb);
  303. }
  304. bcs->hw.w6692.rcvidx = 0;
  305. schedule_event(bcs, B_RCVBUFREADY);
  306. }
  307. }
  308. if (val & W_B_EXI_XDUN) { /* XDUN */
  309. cs->BC_Write_Reg(cs, bchan, W_B_CMDR, W_B_CMDR_XRST | W_B_CMDR_RACT);
  310. if (cs->debug & L1_DEB_WARN)
  311. debugl1(cs, "W6692 B EXIR %x Lost TX", val);
  312. if (bcs->mode == 1)
  313. W6692B_fill_fifo(bcs);
  314. else {
  315. /* Here we lost an TX interrupt, so
  316. * restart transmitting the whole frame.
  317. */
  318. if (bcs->tx_skb) {
  319. skb_push(bcs->tx_skb, bcs->hw.w6692.count);
  320. bcs->tx_cnt += bcs->hw.w6692.count;
  321. bcs->hw.w6692.count = 0;
  322. }
  323. }
  324. return;
  325. }
  326. if (val & W_B_EXI_XFR) { /* XFR */
  327. r = cs->BC_Read_Reg(cs, bchan, W_B_STAR);
  328. if (r & W_B_STAR_XDOW) {
  329. if (cs->debug & L1_DEB_WARN)
  330. debugl1(cs, "W6692 B STAR %x XDOW", r);
  331. cs->BC_Write_Reg(cs, bchan, W_B_CMDR, W_B_CMDR_XRST | W_B_CMDR_RACT);
  332. if (bcs->tx_skb && (bcs->mode != 1)) {
  333. skb_push(bcs->tx_skb, bcs->hw.w6692.count);
  334. bcs->tx_cnt += bcs->hw.w6692.count;
  335. bcs->hw.w6692.count = 0;
  336. }
  337. }
  338. if (bcs->tx_skb) {
  339. if (bcs->tx_skb->len) {
  340. W6692B_fill_fifo(bcs);
  341. return;
  342. } else {
  343. if (test_bit(FLG_LLI_L1WAKEUP, &bcs->st->lli.flag) &&
  344. (PACKET_NOACK != bcs->tx_skb->pkt_type)) {
  345. u_long flags;
  346. spin_lock_irqsave(&bcs->aclock, flags);
  347. bcs->ackcnt += bcs->hw.w6692.count;
  348. spin_unlock_irqrestore(&bcs->aclock, flags);
  349. schedule_event(bcs, B_ACKPENDING);
  350. }
  351. dev_kfree_skb_irq(bcs->tx_skb);
  352. bcs->hw.w6692.count = 0;
  353. bcs->tx_skb = NULL;
  354. }
  355. }
  356. if ((bcs->tx_skb = skb_dequeue(&bcs->squeue))) {
  357. bcs->hw.w6692.count = 0;
  358. test_and_set_bit(BC_FLG_BUSY, &bcs->Flag);
  359. W6692B_fill_fifo(bcs);
  360. } else {
  361. test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag);
  362. schedule_event(bcs, B_XMTBUFREADY);
  363. }
  364. }
  365. }
  366. static irqreturn_t
  367. W6692_interrupt(int intno, void *dev_id)
  368. {
  369. struct IsdnCardState *cs = dev_id;
  370. u_char val, exval, v1;
  371. struct sk_buff *skb;
  372. u_int count;
  373. u_long flags;
  374. int icnt = 5;
  375. spin_lock_irqsave(&cs->lock, flags);
  376. val = cs->readW6692(cs, W_ISTA);
  377. if (!val) {
  378. spin_unlock_irqrestore(&cs->lock, flags);
  379. return IRQ_NONE;
  380. }
  381. StartW6692:
  382. if (cs->debug & L1_DEB_ISAC)
  383. debugl1(cs, "W6692 ISTA %x", val);
  384. if (val & W_INT_D_RME) { /* RME */
  385. exval = cs->readW6692(cs, W_D_RSTA);
  386. if (exval & (W_D_RSTA_RDOV | W_D_RSTA_CRCE | W_D_RSTA_RMB)) {
  387. if (exval & W_D_RSTA_RDOV)
  388. if (cs->debug & L1_DEB_WARN)
  389. debugl1(cs, "W6692 RDOV");
  390. if (exval & W_D_RSTA_CRCE)
  391. if (cs->debug & L1_DEB_WARN)
  392. debugl1(cs, "W6692 D-channel CRC error");
  393. if (exval & W_D_RSTA_RMB)
  394. if (cs->debug & L1_DEB_WARN)
  395. debugl1(cs, "W6692 D-channel ABORT");
  396. cs->writeW6692(cs, W_D_CMDR, W_D_CMDR_RACK | W_D_CMDR_RRST);
  397. } else {
  398. count = cs->readW6692(cs, W_D_RBCL) & (W_D_FIFO_THRESH - 1);
  399. if (count == 0)
  400. count = W_D_FIFO_THRESH;
  401. W6692_empty_fifo(cs, count);
  402. if ((count = cs->rcvidx) > 0) {
  403. cs->rcvidx = 0;
  404. if (!(skb = alloc_skb(count, GFP_ATOMIC)))
  405. printk(KERN_WARNING "HiSax: D receive out of memory\n");
  406. else {
  407. skb_put_data(skb, cs->rcvbuf, count);
  408. skb_queue_tail(&cs->rq, skb);
  409. }
  410. }
  411. }
  412. cs->rcvidx = 0;
  413. schedule_event(cs, D_RCVBUFREADY);
  414. }
  415. if (val & W_INT_D_RMR) { /* RMR */
  416. W6692_empty_fifo(cs, W_D_FIFO_THRESH);
  417. }
  418. if (val & W_INT_D_XFR) { /* XFR */
  419. if (test_and_clear_bit(FLG_DBUSY_TIMER, &cs->HW_Flags))
  420. del_timer(&cs->dbusytimer);
  421. if (test_and_clear_bit(FLG_L1_DBUSY, &cs->HW_Flags))
  422. schedule_event(cs, D_CLEARBUSY);
  423. if (cs->tx_skb) {
  424. if (cs->tx_skb->len) {
  425. W6692_fill_fifo(cs);
  426. goto afterXFR;
  427. } else {
  428. dev_kfree_skb_irq(cs->tx_skb);
  429. cs->tx_cnt = 0;
  430. cs->tx_skb = NULL;
  431. }
  432. }
  433. if ((cs->tx_skb = skb_dequeue(&cs->sq))) {
  434. cs->tx_cnt = 0;
  435. W6692_fill_fifo(cs);
  436. } else
  437. schedule_event(cs, D_XMTBUFREADY);
  438. }
  439. afterXFR:
  440. if (val & (W_INT_XINT0 | W_INT_XINT1)) { /* XINT0/1 - never */
  441. if (cs->debug & L1_DEB_ISAC)
  442. debugl1(cs, "W6692 spurious XINT!");
  443. }
  444. if (val & W_INT_D_EXI) { /* EXI */
  445. exval = cs->readW6692(cs, W_D_EXIR);
  446. if (cs->debug & L1_DEB_WARN)
  447. debugl1(cs, "W6692 D_EXIR %02x", exval);
  448. if (exval & (W_D_EXI_XDUN | W_D_EXI_XCOL)) { /* Transmit underrun/collision */
  449. debugl1(cs, "W6692 D-chan underrun/collision");
  450. printk(KERN_WARNING "HiSax: W6692 XDUN/XCOL\n");
  451. if (test_and_clear_bit(FLG_DBUSY_TIMER, &cs->HW_Flags))
  452. del_timer(&cs->dbusytimer);
  453. if (test_and_clear_bit(FLG_L1_DBUSY, &cs->HW_Flags))
  454. schedule_event(cs, D_CLEARBUSY);
  455. if (cs->tx_skb) { /* Restart frame */
  456. skb_push(cs->tx_skb, cs->tx_cnt);
  457. cs->tx_cnt = 0;
  458. W6692_fill_fifo(cs);
  459. } else {
  460. printk(KERN_WARNING "HiSax: W6692 XDUN/XCOL no skb\n");
  461. debugl1(cs, "W6692 XDUN/XCOL no skb");
  462. cs->writeW6692(cs, W_D_CMDR, W_D_CMDR_XRST);
  463. }
  464. }
  465. if (exval & W_D_EXI_RDOV) { /* RDOV */
  466. debugl1(cs, "W6692 D-channel RDOV");
  467. printk(KERN_WARNING "HiSax: W6692 D-RDOV\n");
  468. cs->writeW6692(cs, W_D_CMDR, W_D_CMDR_RRST);
  469. }
  470. if (exval & W_D_EXI_TIN2) { /* TIN2 - never */
  471. debugl1(cs, "W6692 spurious TIN2 interrupt");
  472. }
  473. if (exval & W_D_EXI_MOC) { /* MOC - not supported */
  474. debugl1(cs, "W6692 spurious MOC interrupt");
  475. v1 = cs->readW6692(cs, W_MOSR);
  476. debugl1(cs, "W6692 MOSR %02x", v1);
  477. }
  478. if (exval & W_D_EXI_ISC) { /* ISC - Level1 change */
  479. v1 = cs->readW6692(cs, W_CIR);
  480. if (cs->debug & L1_DEB_ISAC)
  481. debugl1(cs, "W6692 ISC CIR=0x%02X", v1);
  482. if (v1 & W_CIR_ICC) {
  483. cs->dc.w6692.ph_state = v1 & W_CIR_COD_MASK;
  484. if (cs->debug & L1_DEB_ISAC)
  485. debugl1(cs, "ph_state_change %x", cs->dc.w6692.ph_state);
  486. schedule_event(cs, D_L1STATECHANGE);
  487. }
  488. if (v1 & W_CIR_SCC) {
  489. v1 = cs->readW6692(cs, W_SQR);
  490. debugl1(cs, "W6692 SCC SQR=0x%02X", v1);
  491. }
  492. }
  493. if (exval & W_D_EXI_WEXP) {
  494. debugl1(cs, "W6692 spurious WEXP interrupt!");
  495. }
  496. if (exval & W_D_EXI_TEXP) {
  497. debugl1(cs, "W6692 spurious TEXP interrupt!");
  498. }
  499. }
  500. if (val & W_INT_B1_EXI) {
  501. debugl1(cs, "W6692 B channel 1 interrupt");
  502. W6692B_interrupt(cs, 0);
  503. }
  504. if (val & W_INT_B2_EXI) {
  505. debugl1(cs, "W6692 B channel 2 interrupt");
  506. W6692B_interrupt(cs, 1);
  507. }
  508. val = cs->readW6692(cs, W_ISTA);
  509. if (val && icnt) {
  510. icnt--;
  511. goto StartW6692;
  512. }
  513. if (!icnt) {
  514. printk(KERN_WARNING "W6692 IRQ LOOP\n");
  515. cs->writeW6692(cs, W_IMASK, 0xff);
  516. }
  517. spin_unlock_irqrestore(&cs->lock, flags);
  518. return IRQ_HANDLED;
  519. }
  520. static void
  521. W6692_l1hw(struct PStack *st, int pr, void *arg)
  522. {
  523. struct IsdnCardState *cs = (struct IsdnCardState *) st->l1.hardware;
  524. struct sk_buff *skb = arg;
  525. u_long flags;
  526. int val;
  527. switch (pr) {
  528. case (PH_DATA | REQUEST):
  529. if (cs->debug & DEB_DLOG_HEX)
  530. LogFrame(cs, skb->data, skb->len);
  531. if (cs->debug & DEB_DLOG_VERBOSE)
  532. dlogframe(cs, skb, 0);
  533. spin_lock_irqsave(&cs->lock, flags);
  534. if (cs->tx_skb) {
  535. skb_queue_tail(&cs->sq, skb);
  536. #ifdef L2FRAME_DEBUG /* psa */
  537. if (cs->debug & L1_DEB_LAPD)
  538. Logl2Frame(cs, skb, "PH_DATA Queued", 0);
  539. #endif
  540. } else {
  541. cs->tx_skb = skb;
  542. cs->tx_cnt = 0;
  543. #ifdef L2FRAME_DEBUG /* psa */
  544. if (cs->debug & L1_DEB_LAPD)
  545. Logl2Frame(cs, skb, "PH_DATA", 0);
  546. #endif
  547. W6692_fill_fifo(cs);
  548. }
  549. spin_unlock_irqrestore(&cs->lock, flags);
  550. break;
  551. case (PH_PULL | INDICATION):
  552. spin_lock_irqsave(&cs->lock, flags);
  553. if (cs->tx_skb) {
  554. if (cs->debug & L1_DEB_WARN)
  555. debugl1(cs, " l2l1 tx_skb exist this shouldn't happen");
  556. skb_queue_tail(&cs->sq, skb);
  557. spin_unlock_irqrestore(&cs->lock, flags);
  558. break;
  559. }
  560. if (cs->debug & DEB_DLOG_HEX)
  561. LogFrame(cs, skb->data, skb->len);
  562. if (cs->debug & DEB_DLOG_VERBOSE)
  563. dlogframe(cs, skb, 0);
  564. cs->tx_skb = skb;
  565. cs->tx_cnt = 0;
  566. #ifdef L2FRAME_DEBUG /* psa */
  567. if (cs->debug & L1_DEB_LAPD)
  568. Logl2Frame(cs, skb, "PH_DATA_PULLED", 0);
  569. #endif
  570. W6692_fill_fifo(cs);
  571. spin_unlock_irqrestore(&cs->lock, flags);
  572. break;
  573. case (PH_PULL | REQUEST):
  574. #ifdef L2FRAME_DEBUG /* psa */
  575. if (cs->debug & L1_DEB_LAPD)
  576. debugl1(cs, "-> PH_REQUEST_PULL");
  577. #endif
  578. if (!cs->tx_skb) {
  579. test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
  580. st->l1.l1l2(st, PH_PULL | CONFIRM, NULL);
  581. } else
  582. test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
  583. break;
  584. case (HW_RESET | REQUEST):
  585. spin_lock_irqsave(&cs->lock, flags);
  586. if ((cs->dc.w6692.ph_state == W_L1IND_DRD)) {
  587. ph_command(cs, W_L1CMD_ECK);
  588. spin_unlock_irqrestore(&cs->lock, flags);
  589. } else {
  590. ph_command(cs, W_L1CMD_RST);
  591. cs->dc.w6692.ph_state = W_L1CMD_RST;
  592. spin_unlock_irqrestore(&cs->lock, flags);
  593. W6692_new_ph(cs);
  594. }
  595. break;
  596. case (HW_ENABLE | REQUEST):
  597. spin_lock_irqsave(&cs->lock, flags);
  598. ph_command(cs, W_L1CMD_ECK);
  599. spin_unlock_irqrestore(&cs->lock, flags);
  600. break;
  601. case (HW_INFO3 | REQUEST):
  602. spin_lock_irqsave(&cs->lock, flags);
  603. ph_command(cs, W_L1CMD_AR8);
  604. spin_unlock_irqrestore(&cs->lock, flags);
  605. break;
  606. case (HW_TESTLOOP | REQUEST):
  607. val = 0;
  608. if (1 & (long) arg)
  609. val |= 0x0c;
  610. if (2 & (long) arg)
  611. val |= 0x3;
  612. /* !!! not implemented yet */
  613. break;
  614. case (HW_DEACTIVATE | RESPONSE):
  615. skb_queue_purge(&cs->rq);
  616. skb_queue_purge(&cs->sq);
  617. if (cs->tx_skb) {
  618. dev_kfree_skb_any(cs->tx_skb);
  619. cs->tx_skb = NULL;
  620. }
  621. if (test_and_clear_bit(FLG_DBUSY_TIMER, &cs->HW_Flags))
  622. del_timer(&cs->dbusytimer);
  623. if (test_and_clear_bit(FLG_L1_DBUSY, &cs->HW_Flags))
  624. schedule_event(cs, D_CLEARBUSY);
  625. break;
  626. default:
  627. if (cs->debug & L1_DEB_WARN)
  628. debugl1(cs, "W6692_l1hw unknown %04x", pr);
  629. break;
  630. }
  631. }
  632. static void
  633. setstack_W6692(struct PStack *st, struct IsdnCardState *cs)
  634. {
  635. st->l1.l1hw = W6692_l1hw;
  636. }
  637. static void
  638. DC_Close_W6692(struct IsdnCardState *cs)
  639. {
  640. }
  641. static void
  642. dbusy_timer_handler(struct IsdnCardState *cs)
  643. {
  644. struct PStack *stptr;
  645. int rbch, star;
  646. u_long flags;
  647. spin_lock_irqsave(&cs->lock, flags);
  648. if (test_bit(FLG_DBUSY_TIMER, &cs->HW_Flags)) {
  649. rbch = cs->readW6692(cs, W_D_RBCH);
  650. star = cs->readW6692(cs, W_D_STAR);
  651. if (cs->debug)
  652. debugl1(cs, "D-Channel Busy D_RBCH %02x D_STAR %02x",
  653. rbch, star);
  654. if (star & W_D_STAR_XBZ) { /* D-Channel Busy */
  655. test_and_set_bit(FLG_L1_DBUSY, &cs->HW_Flags);
  656. stptr = cs->stlist;
  657. while (stptr != NULL) {
  658. stptr->l1.l1l2(stptr, PH_PAUSE | INDICATION, NULL);
  659. stptr = stptr->next;
  660. }
  661. } else {
  662. /* discard frame; reset transceiver */
  663. test_and_clear_bit(FLG_DBUSY_TIMER, &cs->HW_Flags);
  664. if (cs->tx_skb) {
  665. dev_kfree_skb_any(cs->tx_skb);
  666. cs->tx_cnt = 0;
  667. cs->tx_skb = NULL;
  668. } else {
  669. printk(KERN_WARNING "HiSax: W6692 D-Channel Busy no skb\n");
  670. debugl1(cs, "D-Channel Busy no skb");
  671. }
  672. cs->writeW6692(cs, W_D_CMDR, W_D_CMDR_XRST); /* Transmitter reset */
  673. spin_unlock_irqrestore(&cs->lock, flags);
  674. cs->irq_func(cs->irq, cs);
  675. return;
  676. }
  677. }
  678. spin_unlock_irqrestore(&cs->lock, flags);
  679. }
  680. static void
  681. W6692Bmode(struct BCState *bcs, int mode, int bchan)
  682. {
  683. struct IsdnCardState *cs = bcs->cs;
  684. if (cs->debug & L1_DEB_HSCX)
  685. debugl1(cs, "w6692 %c mode %d ichan %d",
  686. '1' + bchan, mode, bchan);
  687. bcs->mode = mode;
  688. bcs->channel = bchan;
  689. bcs->hw.w6692.bchan = bchan;
  690. switch (mode) {
  691. case (L1_MODE_NULL):
  692. cs->BC_Write_Reg(cs, bchan, W_B_MODE, 0);
  693. break;
  694. case (L1_MODE_TRANS):
  695. cs->BC_Write_Reg(cs, bchan, W_B_MODE, W_B_MODE_MMS);
  696. break;
  697. case (L1_MODE_HDLC):
  698. cs->BC_Write_Reg(cs, bchan, W_B_MODE, W_B_MODE_ITF);
  699. cs->BC_Write_Reg(cs, bchan, W_B_ADM1, 0xff);
  700. cs->BC_Write_Reg(cs, bchan, W_B_ADM2, 0xff);
  701. break;
  702. }
  703. if (mode)
  704. cs->BC_Write_Reg(cs, bchan, W_B_CMDR, W_B_CMDR_RRST |
  705. W_B_CMDR_RACT | W_B_CMDR_XRST);
  706. cs->BC_Write_Reg(cs, bchan, W_B_EXIM, 0x00);
  707. }
  708. static void
  709. W6692_l2l1(struct PStack *st, int pr, void *arg)
  710. {
  711. struct sk_buff *skb = arg;
  712. struct BCState *bcs = st->l1.bcs;
  713. u_long flags;
  714. switch (pr) {
  715. case (PH_DATA | REQUEST):
  716. spin_lock_irqsave(&bcs->cs->lock, flags);
  717. if (bcs->tx_skb) {
  718. skb_queue_tail(&bcs->squeue, skb);
  719. } else {
  720. bcs->tx_skb = skb;
  721. test_and_set_bit(BC_FLG_BUSY, &bcs->Flag);
  722. bcs->hw.w6692.count = 0;
  723. bcs->cs->BC_Send_Data(bcs);
  724. }
  725. spin_unlock_irqrestore(&bcs->cs->lock, flags);
  726. break;
  727. case (PH_PULL | INDICATION):
  728. if (bcs->tx_skb) {
  729. printk(KERN_WARNING "W6692_l2l1: this shouldn't happen\n");
  730. break;
  731. }
  732. spin_lock_irqsave(&bcs->cs->lock, flags);
  733. test_and_set_bit(BC_FLG_BUSY, &bcs->Flag);
  734. bcs->tx_skb = skb;
  735. bcs->hw.w6692.count = 0;
  736. bcs->cs->BC_Send_Data(bcs);
  737. spin_unlock_irqrestore(&bcs->cs->lock, flags);
  738. break;
  739. case (PH_PULL | REQUEST):
  740. if (!bcs->tx_skb) {
  741. test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
  742. st->l1.l1l2(st, PH_PULL | CONFIRM, NULL);
  743. } else
  744. test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
  745. break;
  746. case (PH_ACTIVATE | REQUEST):
  747. spin_lock_irqsave(&bcs->cs->lock, flags);
  748. test_and_set_bit(BC_FLG_ACTIV, &bcs->Flag);
  749. W6692Bmode(bcs, st->l1.mode, st->l1.bc);
  750. spin_unlock_irqrestore(&bcs->cs->lock, flags);
  751. l1_msg_b(st, pr, arg);
  752. break;
  753. case (PH_DEACTIVATE | REQUEST):
  754. l1_msg_b(st, pr, arg);
  755. break;
  756. case (PH_DEACTIVATE | CONFIRM):
  757. spin_lock_irqsave(&bcs->cs->lock, flags);
  758. test_and_clear_bit(BC_FLG_ACTIV, &bcs->Flag);
  759. test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag);
  760. W6692Bmode(bcs, 0, st->l1.bc);
  761. spin_unlock_irqrestore(&bcs->cs->lock, flags);
  762. st->l1.l1l2(st, PH_DEACTIVATE | CONFIRM, NULL);
  763. break;
  764. }
  765. }
  766. static void
  767. close_w6692state(struct BCState *bcs)
  768. {
  769. W6692Bmode(bcs, 0, bcs->channel);
  770. if (test_and_clear_bit(BC_FLG_INIT, &bcs->Flag)) {
  771. kfree(bcs->hw.w6692.rcvbuf);
  772. bcs->hw.w6692.rcvbuf = NULL;
  773. kfree(bcs->blog);
  774. bcs->blog = NULL;
  775. skb_queue_purge(&bcs->rqueue);
  776. skb_queue_purge(&bcs->squeue);
  777. if (bcs->tx_skb) {
  778. dev_kfree_skb_any(bcs->tx_skb);
  779. bcs->tx_skb = NULL;
  780. test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag);
  781. }
  782. }
  783. }
  784. static int
  785. open_w6692state(struct IsdnCardState *cs, struct BCState *bcs)
  786. {
  787. if (!test_and_set_bit(BC_FLG_INIT, &bcs->Flag)) {
  788. if (!(bcs->hw.w6692.rcvbuf = kmalloc(HSCX_BUFMAX, GFP_ATOMIC))) {
  789. printk(KERN_WARNING
  790. "HiSax: No memory for w6692.rcvbuf\n");
  791. test_and_clear_bit(BC_FLG_INIT, &bcs->Flag);
  792. return (1);
  793. }
  794. if (!(bcs->blog = kmalloc(MAX_BLOG_SPACE, GFP_ATOMIC))) {
  795. printk(KERN_WARNING
  796. "HiSax: No memory for bcs->blog\n");
  797. test_and_clear_bit(BC_FLG_INIT, &bcs->Flag);
  798. kfree(bcs->hw.w6692.rcvbuf);
  799. bcs->hw.w6692.rcvbuf = NULL;
  800. return (2);
  801. }
  802. skb_queue_head_init(&bcs->rqueue);
  803. skb_queue_head_init(&bcs->squeue);
  804. }
  805. bcs->tx_skb = NULL;
  806. test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag);
  807. bcs->event = 0;
  808. bcs->hw.w6692.rcvidx = 0;
  809. bcs->tx_cnt = 0;
  810. return (0);
  811. }
  812. static int
  813. setstack_w6692(struct PStack *st, struct BCState *bcs)
  814. {
  815. bcs->channel = st->l1.bc;
  816. if (open_w6692state(st->l1.hardware, bcs))
  817. return (-1);
  818. st->l1.bcs = bcs;
  819. st->l2.l2l1 = W6692_l2l1;
  820. setstack_manager(st);
  821. bcs->st = st;
  822. setstack_l1_B(st);
  823. return (0);
  824. }
  825. static void resetW6692(struct IsdnCardState *cs)
  826. {
  827. cs->writeW6692(cs, W_D_CTL, W_D_CTL_SRST);
  828. mdelay(10);
  829. cs->writeW6692(cs, W_D_CTL, 0x00);
  830. mdelay(10);
  831. cs->writeW6692(cs, W_IMASK, 0xff);
  832. cs->writeW6692(cs, W_D_SAM, 0xff);
  833. cs->writeW6692(cs, W_D_TAM, 0xff);
  834. cs->writeW6692(cs, W_D_EXIM, 0x00);
  835. cs->writeW6692(cs, W_D_MODE, W_D_MODE_RACT);
  836. cs->writeW6692(cs, W_IMASK, 0x18);
  837. if (cs->subtyp == W6692_USR) {
  838. /* seems that USR implemented some power control features
  839. * Pin 79 is connected to the oscilator circuit so we
  840. * have to handle it here
  841. */
  842. cs->writeW6692(cs, W_PCTL, 0x80);
  843. cs->writeW6692(cs, W_XDATA, 0x00);
  844. }
  845. }
  846. static void initW6692(struct IsdnCardState *cs, int part)
  847. {
  848. if (part & 1) {
  849. cs->setstack_d = setstack_W6692;
  850. cs->DC_Close = DC_Close_W6692;
  851. setup_timer(&cs->dbusytimer, (void *)dbusy_timer_handler,
  852. (long)cs);
  853. resetW6692(cs);
  854. ph_command(cs, W_L1CMD_RST);
  855. cs->dc.w6692.ph_state = W_L1CMD_RST;
  856. W6692_new_ph(cs);
  857. ph_command(cs, W_L1CMD_ECK);
  858. cs->bcs[0].BC_SetStack = setstack_w6692;
  859. cs->bcs[1].BC_SetStack = setstack_w6692;
  860. cs->bcs[0].BC_Close = close_w6692state;
  861. cs->bcs[1].BC_Close = close_w6692state;
  862. W6692Bmode(cs->bcs, 0, 0);
  863. W6692Bmode(cs->bcs + 1, 0, 0);
  864. }
  865. if (part & 2) {
  866. /* Reenable all IRQ */
  867. cs->writeW6692(cs, W_IMASK, 0x18);
  868. cs->writeW6692(cs, W_D_EXIM, 0x00);
  869. cs->BC_Write_Reg(cs, 0, W_B_EXIM, 0x00);
  870. cs->BC_Write_Reg(cs, 1, W_B_EXIM, 0x00);
  871. /* Reset D-chan receiver and transmitter */
  872. cs->writeW6692(cs, W_D_CMDR, W_D_CMDR_RRST | W_D_CMDR_XRST);
  873. }
  874. }
  875. /* Interface functions */
  876. static u_char
  877. ReadW6692(struct IsdnCardState *cs, u_char offset)
  878. {
  879. return (inb(cs->hw.w6692.iobase + offset));
  880. }
  881. static void
  882. WriteW6692(struct IsdnCardState *cs, u_char offset, u_char value)
  883. {
  884. outb(value, cs->hw.w6692.iobase + offset);
  885. }
  886. static void
  887. ReadISACfifo(struct IsdnCardState *cs, u_char *data, int size)
  888. {
  889. insb(cs->hw.w6692.iobase + W_D_RFIFO, data, size);
  890. }
  891. static void
  892. WriteISACfifo(struct IsdnCardState *cs, u_char *data, int size)
  893. {
  894. outsb(cs->hw.w6692.iobase + W_D_XFIFO, data, size);
  895. }
  896. static u_char
  897. ReadW6692B(struct IsdnCardState *cs, int bchan, u_char offset)
  898. {
  899. return (inb(cs->hw.w6692.iobase + (bchan ? 0x40 : 0) + offset));
  900. }
  901. static void
  902. WriteW6692B(struct IsdnCardState *cs, int bchan, u_char offset, u_char value)
  903. {
  904. outb(value, cs->hw.w6692.iobase + (bchan ? 0x40 : 0) + offset);
  905. }
  906. static int
  907. w6692_card_msg(struct IsdnCardState *cs, int mt, void *arg)
  908. {
  909. switch (mt) {
  910. case CARD_RESET:
  911. resetW6692(cs);
  912. return (0);
  913. case CARD_RELEASE:
  914. cs->writeW6692(cs, W_IMASK, 0xff);
  915. release_region(cs->hw.w6692.iobase, 256);
  916. if (cs->subtyp == W6692_USR) {
  917. cs->writeW6692(cs, W_XDATA, 0x04);
  918. }
  919. return (0);
  920. case CARD_INIT:
  921. initW6692(cs, 3);
  922. return (0);
  923. case CARD_TEST:
  924. return (0);
  925. }
  926. return (0);
  927. }
  928. static int id_idx;
  929. static struct pci_dev *dev_w6692 = NULL;
  930. int setup_w6692(struct IsdnCard *card)
  931. {
  932. struct IsdnCardState *cs = card->cs;
  933. char tmp[64];
  934. u_char found = 0;
  935. u_char pci_irq = 0;
  936. u_int pci_ioaddr = 0;
  937. strcpy(tmp, w6692_revision);
  938. printk(KERN_INFO "HiSax: W6692 driver Rev. %s\n", HiSax_getrev(tmp));
  939. if (cs->typ != ISDN_CTYPE_W6692)
  940. return (0);
  941. while (id_list[id_idx].vendor_id) {
  942. dev_w6692 = hisax_find_pci_device(id_list[id_idx].vendor_id,
  943. id_list[id_idx].device_id,
  944. dev_w6692);
  945. if (dev_w6692) {
  946. if (pci_enable_device(dev_w6692))
  947. continue;
  948. cs->subtyp = id_idx;
  949. break;
  950. }
  951. id_idx++;
  952. }
  953. if (dev_w6692) {
  954. found = 1;
  955. pci_irq = dev_w6692->irq;
  956. /* I think address 0 is allways the configuration area */
  957. /* and address 1 is the real IO space KKe 03.09.99 */
  958. pci_ioaddr = pci_resource_start(dev_w6692, 1);
  959. /* USR ISDN PCI card TA need some special handling */
  960. if (cs->subtyp == W6692_WINBOND) {
  961. if ((W6692_SV_USR == dev_w6692->subsystem_vendor) &&
  962. (W6692_SD_USR == dev_w6692->subsystem_device)) {
  963. cs->subtyp = W6692_USR;
  964. }
  965. }
  966. }
  967. if (!found) {
  968. printk(KERN_WARNING "W6692: No PCI card found\n");
  969. return (0);
  970. }
  971. cs->irq = pci_irq;
  972. if (!cs->irq) {
  973. printk(KERN_WARNING "W6692: No IRQ for PCI card found\n");
  974. return (0);
  975. }
  976. if (!pci_ioaddr) {
  977. printk(KERN_WARNING "W6692: NO I/O Base Address found\n");
  978. return (0);
  979. }
  980. cs->hw.w6692.iobase = pci_ioaddr;
  981. printk(KERN_INFO "Found: %s %s, I/O base: 0x%x, irq: %d\n",
  982. id_list[cs->subtyp].vendor_name, id_list[cs->subtyp].card_name,
  983. pci_ioaddr, pci_irq);
  984. if (!request_region(cs->hw.w6692.iobase, 256, id_list[cs->subtyp].card_name)) {
  985. printk(KERN_WARNING
  986. "HiSax: %s I/O ports %x-%x already in use\n",
  987. id_list[cs->subtyp].card_name,
  988. cs->hw.w6692.iobase,
  989. cs->hw.w6692.iobase + 255);
  990. return (0);
  991. }
  992. printk(KERN_INFO
  993. "HiSax: %s config irq:%d I/O:%x\n",
  994. id_list[cs->subtyp].card_name, cs->irq,
  995. cs->hw.w6692.iobase);
  996. INIT_WORK(&cs->tqueue, W6692_bh);
  997. cs->readW6692 = &ReadW6692;
  998. cs->writeW6692 = &WriteW6692;
  999. cs->readisacfifo = &ReadISACfifo;
  1000. cs->writeisacfifo = &WriteISACfifo;
  1001. cs->BC_Read_Reg = &ReadW6692B;
  1002. cs->BC_Write_Reg = &WriteW6692B;
  1003. cs->BC_Send_Data = &W6692B_fill_fifo;
  1004. cs->cardmsg = &w6692_card_msg;
  1005. cs->irq_func = &W6692_interrupt;
  1006. cs->irq_flags |= IRQF_SHARED;
  1007. W6692Version(cs, "W6692:");
  1008. printk(KERN_INFO "W6692 ISTA=0x%X\n", ReadW6692(cs, W_ISTA));
  1009. printk(KERN_INFO "W6692 IMASK=0x%X\n", ReadW6692(cs, W_IMASK));
  1010. printk(KERN_INFO "W6692 D_EXIR=0x%X\n", ReadW6692(cs, W_D_EXIR));
  1011. printk(KERN_INFO "W6692 D_EXIM=0x%X\n", ReadW6692(cs, W_D_EXIM));
  1012. printk(KERN_INFO "W6692 D_RSTA=0x%X\n", ReadW6692(cs, W_D_RSTA));
  1013. return (1);
  1014. }