w6692.c 29 KB

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