w6692.c 29 KB

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