w6692.c 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086
  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, 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, 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, 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, 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. memcpy(skb_put(skb, count), bcs->hw.w6692.rcvbuf, count);
  276. skb_queue_tail(&bcs->rqueue, skb);
  277. }
  278. }
  279. }
  280. bcs->hw.w6692.rcvidx = 0;
  281. schedule_event(bcs, B_RCVBUFREADY);
  282. }
  283. if (val & W_B_EXI_RMR) { /* RMR */
  284. W6692B_empty_fifo(bcs, W_B_FIFO_THRESH);
  285. r = cs->BC_Read_Reg(cs, bchan, W_B_STAR);
  286. if (r & W_B_STAR_RDOV) {
  287. if (cs->debug & L1_DEB_WARN)
  288. debugl1(cs, "W6692 B RDOV(RMR) mode=%d",bcs->mode);
  289. cs->BC_Write_Reg(cs, bchan, W_B_CMDR, W_B_CMDR_RACK | W_B_CMDR_RRST | W_B_CMDR_RACT);
  290. if (bcs->mode != L1_MODE_TRANS)
  291. bcs->hw.w6692.rcvidx = 0;
  292. }
  293. if (bcs->mode == L1_MODE_TRANS) {
  294. /* receive audio data */
  295. if (!(skb = dev_alloc_skb(W_B_FIFO_THRESH)))
  296. printk(KERN_WARNING "HiSax: receive out of memory\n");
  297. else {
  298. memcpy(skb_put(skb, W_B_FIFO_THRESH), bcs->hw.w6692.rcvbuf, W_B_FIFO_THRESH);
  299. skb_queue_tail(&bcs->rqueue, skb);
  300. }
  301. bcs->hw.w6692.rcvidx = 0;
  302. schedule_event(bcs, B_RCVBUFREADY);
  303. }
  304. }
  305. if (val & W_B_EXI_XDUN) { /* XDUN */
  306. cs->BC_Write_Reg(cs, bchan, W_B_CMDR, W_B_CMDR_XRST | W_B_CMDR_RACT);
  307. if (cs->debug & L1_DEB_WARN)
  308. debugl1(cs, "W6692 B EXIR %x Lost TX", val);
  309. if (bcs->mode == 1)
  310. W6692B_fill_fifo(bcs);
  311. else {
  312. /* Here we lost an TX interrupt, so
  313. * restart transmitting the whole frame.
  314. */
  315. if (bcs->tx_skb) {
  316. skb_push(bcs->tx_skb, bcs->hw.w6692.count);
  317. bcs->tx_cnt += bcs->hw.w6692.count;
  318. bcs->hw.w6692.count = 0;
  319. }
  320. }
  321. return;
  322. }
  323. if (val & W_B_EXI_XFR) { /* XFR */
  324. r = cs->BC_Read_Reg(cs, bchan, W_B_STAR);
  325. if (r & W_B_STAR_XDOW) {
  326. if (cs->debug & L1_DEB_WARN)
  327. debugl1(cs, "W6692 B STAR %x XDOW", r);
  328. cs->BC_Write_Reg(cs, bchan, W_B_CMDR, W_B_CMDR_XRST | W_B_CMDR_RACT);
  329. if (bcs->tx_skb && (bcs->mode != 1)) {
  330. skb_push(bcs->tx_skb, bcs->hw.w6692.count);
  331. bcs->tx_cnt += bcs->hw.w6692.count;
  332. bcs->hw.w6692.count = 0;
  333. }
  334. }
  335. if (bcs->tx_skb) {
  336. if (bcs->tx_skb->len) {
  337. W6692B_fill_fifo(bcs);
  338. return;
  339. } else {
  340. if (test_bit(FLG_LLI_L1WAKEUP,&bcs->st->lli.flag) &&
  341. (PACKET_NOACK != bcs->tx_skb->pkt_type)) {
  342. u_long flags;
  343. spin_lock_irqsave(&bcs->aclock, flags);
  344. bcs->ackcnt += bcs->hw.w6692.count;
  345. spin_unlock_irqrestore(&bcs->aclock, flags);
  346. schedule_event(bcs, B_ACKPENDING);
  347. }
  348. dev_kfree_skb_irq(bcs->tx_skb);
  349. bcs->hw.w6692.count = 0;
  350. bcs->tx_skb = NULL;
  351. }
  352. }
  353. if ((bcs->tx_skb = skb_dequeue(&bcs->squeue))) {
  354. bcs->hw.w6692.count = 0;
  355. test_and_set_bit(BC_FLG_BUSY, &bcs->Flag);
  356. W6692B_fill_fifo(bcs);
  357. } else {
  358. test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag);
  359. schedule_event(bcs, B_XMTBUFREADY);
  360. }
  361. }
  362. }
  363. static irqreturn_t
  364. W6692_interrupt(int intno, void *dev_id)
  365. {
  366. struct IsdnCardState *cs = dev_id;
  367. u_char val, exval, v1;
  368. struct sk_buff *skb;
  369. u_int count;
  370. u_long flags;
  371. int icnt = 5;
  372. spin_lock_irqsave(&cs->lock, flags);
  373. val = cs->readW6692(cs, W_ISTA);
  374. if (!val) {
  375. spin_unlock_irqrestore(&cs->lock, flags);
  376. return IRQ_NONE;
  377. }
  378. StartW6692:
  379. if (cs->debug & L1_DEB_ISAC)
  380. debugl1(cs, "W6692 ISTA %x", val);
  381. if (val & W_INT_D_RME) { /* RME */
  382. exval = cs->readW6692(cs, W_D_RSTA);
  383. if (exval & (W_D_RSTA_RDOV | W_D_RSTA_CRCE | W_D_RSTA_RMB)) {
  384. if (exval & W_D_RSTA_RDOV)
  385. if (cs->debug & L1_DEB_WARN)
  386. debugl1(cs, "W6692 RDOV");
  387. if (exval & W_D_RSTA_CRCE)
  388. if (cs->debug & L1_DEB_WARN)
  389. debugl1(cs, "W6692 D-channel CRC error");
  390. if (exval & W_D_RSTA_RMB)
  391. if (cs->debug & L1_DEB_WARN)
  392. debugl1(cs, "W6692 D-channel ABORT");
  393. cs->writeW6692(cs, W_D_CMDR, W_D_CMDR_RACK | W_D_CMDR_RRST);
  394. } else {
  395. count = cs->readW6692(cs, W_D_RBCL) & (W_D_FIFO_THRESH - 1);
  396. if (count == 0)
  397. count = W_D_FIFO_THRESH;
  398. W6692_empty_fifo(cs, count);
  399. if ((count = cs->rcvidx) > 0) {
  400. cs->rcvidx = 0;
  401. if (!(skb = alloc_skb(count, GFP_ATOMIC)))
  402. printk(KERN_WARNING "HiSax: D receive out of memory\n");
  403. else {
  404. memcpy(skb_put(skb, count), cs->rcvbuf, count);
  405. skb_queue_tail(&cs->rq, skb);
  406. }
  407. }
  408. }
  409. cs->rcvidx = 0;
  410. schedule_event(cs, D_RCVBUFREADY);
  411. }
  412. if (val & W_INT_D_RMR) { /* RMR */
  413. W6692_empty_fifo(cs, W_D_FIFO_THRESH);
  414. }
  415. if (val & W_INT_D_XFR) { /* XFR */
  416. if (test_and_clear_bit(FLG_DBUSY_TIMER, &cs->HW_Flags))
  417. del_timer(&cs->dbusytimer);
  418. if (test_and_clear_bit(FLG_L1_DBUSY, &cs->HW_Flags))
  419. schedule_event(cs, D_CLEARBUSY);
  420. if (cs->tx_skb) {
  421. if (cs->tx_skb->len) {
  422. W6692_fill_fifo(cs);
  423. goto afterXFR;
  424. } else {
  425. dev_kfree_skb_irq(cs->tx_skb);
  426. cs->tx_cnt = 0;
  427. cs->tx_skb = NULL;
  428. }
  429. }
  430. if ((cs->tx_skb = skb_dequeue(&cs->sq))) {
  431. cs->tx_cnt = 0;
  432. W6692_fill_fifo(cs);
  433. } else
  434. schedule_event(cs, D_XMTBUFREADY);
  435. }
  436. afterXFR:
  437. if (val & (W_INT_XINT0 | W_INT_XINT1)) { /* XINT0/1 - never */
  438. if (cs->debug & L1_DEB_ISAC)
  439. debugl1(cs, "W6692 spurious XINT!");
  440. }
  441. if (val & W_INT_D_EXI) { /* EXI */
  442. exval = cs->readW6692(cs, W_D_EXIR);
  443. if (cs->debug & L1_DEB_WARN)
  444. debugl1(cs, "W6692 D_EXIR %02x", exval);
  445. if (exval & (W_D_EXI_XDUN | W_D_EXI_XCOL)) { /* Transmit underrun/collision */
  446. debugl1(cs, "W6692 D-chan underrun/collision");
  447. printk(KERN_WARNING "HiSax: W6692 XDUN/XCOL\n");
  448. if (test_and_clear_bit(FLG_DBUSY_TIMER, &cs->HW_Flags))
  449. del_timer(&cs->dbusytimer);
  450. if (test_and_clear_bit(FLG_L1_DBUSY, &cs->HW_Flags))
  451. schedule_event(cs, D_CLEARBUSY);
  452. if (cs->tx_skb) { /* Restart frame */
  453. skb_push(cs->tx_skb, cs->tx_cnt);
  454. cs->tx_cnt = 0;
  455. W6692_fill_fifo(cs);
  456. } else {
  457. printk(KERN_WARNING "HiSax: W6692 XDUN/XCOL no skb\n");
  458. debugl1(cs, "W6692 XDUN/XCOL no skb");
  459. cs->writeW6692(cs, W_D_CMDR, W_D_CMDR_XRST);
  460. }
  461. }
  462. if (exval & W_D_EXI_RDOV) { /* RDOV */
  463. debugl1(cs, "W6692 D-channel RDOV");
  464. printk(KERN_WARNING "HiSax: W6692 D-RDOV\n");
  465. cs->writeW6692(cs, W_D_CMDR, W_D_CMDR_RRST);
  466. }
  467. if (exval & W_D_EXI_TIN2) { /* TIN2 - never */
  468. debugl1(cs, "W6692 spurious TIN2 interrupt");
  469. }
  470. if (exval & W_D_EXI_MOC) { /* MOC - not supported */
  471. debugl1(cs, "W6692 spurious MOC interrupt");
  472. v1 = cs->readW6692(cs, W_MOSR);
  473. debugl1(cs, "W6692 MOSR %02x", v1);
  474. }
  475. if (exval & W_D_EXI_ISC) { /* ISC - Level1 change */
  476. v1 = cs->readW6692(cs, W_CIR);
  477. if (cs->debug & L1_DEB_ISAC)
  478. debugl1(cs, "W6692 ISC CIR=0x%02X", v1);
  479. if (v1 & W_CIR_ICC) {
  480. cs->dc.w6692.ph_state = v1 & W_CIR_COD_MASK;
  481. if (cs->debug & L1_DEB_ISAC)
  482. debugl1(cs, "ph_state_change %x", cs->dc.w6692.ph_state);
  483. schedule_event(cs, D_L1STATECHANGE);
  484. }
  485. if (v1 & W_CIR_SCC) {
  486. v1 = cs->readW6692(cs, W_SQR);
  487. debugl1(cs, "W6692 SCC SQR=0x%02X", v1);
  488. }
  489. }
  490. if (exval & W_D_EXI_WEXP) {
  491. debugl1(cs, "W6692 spurious WEXP interrupt!");
  492. }
  493. if (exval & W_D_EXI_TEXP) {
  494. debugl1(cs, "W6692 spurious TEXP interrupt!");
  495. }
  496. }
  497. if (val & W_INT_B1_EXI) {
  498. debugl1(cs, "W6692 B channel 1 interrupt");
  499. W6692B_interrupt(cs, 0);
  500. }
  501. if (val & W_INT_B2_EXI) {
  502. debugl1(cs, "W6692 B channel 2 interrupt");
  503. W6692B_interrupt(cs, 1);
  504. }
  505. val = cs->readW6692(cs, W_ISTA);
  506. if (val && icnt) {
  507. icnt--;
  508. goto StartW6692;
  509. }
  510. if (!icnt) {
  511. printk(KERN_WARNING "W6692 IRQ LOOP\n");
  512. cs->writeW6692(cs, W_IMASK, 0xff);
  513. }
  514. spin_unlock_irqrestore(&cs->lock, flags);
  515. return IRQ_HANDLED;
  516. }
  517. static void
  518. W6692_l1hw(struct PStack *st, int pr, void *arg)
  519. {
  520. struct IsdnCardState *cs = (struct IsdnCardState *) st->l1.hardware;
  521. struct sk_buff *skb = arg;
  522. u_long flags;
  523. int val;
  524. switch (pr) {
  525. case (PH_DATA | REQUEST):
  526. if (cs->debug & DEB_DLOG_HEX)
  527. LogFrame(cs, skb->data, skb->len);
  528. if (cs->debug & DEB_DLOG_VERBOSE)
  529. dlogframe(cs, skb, 0);
  530. spin_lock_irqsave(&cs->lock, flags);
  531. if (cs->tx_skb) {
  532. skb_queue_tail(&cs->sq, skb);
  533. #ifdef L2FRAME_DEBUG /* psa */
  534. if (cs->debug & L1_DEB_LAPD)
  535. Logl2Frame(cs, skb, "PH_DATA Queued", 0);
  536. #endif
  537. } else {
  538. cs->tx_skb = skb;
  539. cs->tx_cnt = 0;
  540. #ifdef L2FRAME_DEBUG /* psa */
  541. if (cs->debug & L1_DEB_LAPD)
  542. Logl2Frame(cs, skb, "PH_DATA", 0);
  543. #endif
  544. W6692_fill_fifo(cs);
  545. }
  546. spin_unlock_irqrestore(&cs->lock, flags);
  547. break;
  548. case (PH_PULL | INDICATION):
  549. spin_lock_irqsave(&cs->lock, flags);
  550. if (cs->tx_skb) {
  551. if (cs->debug & L1_DEB_WARN)
  552. debugl1(cs, " l2l1 tx_skb exist this shouldn't happen");
  553. skb_queue_tail(&cs->sq, skb);
  554. spin_unlock_irqrestore(&cs->lock, flags);
  555. break;
  556. }
  557. if (cs->debug & DEB_DLOG_HEX)
  558. LogFrame(cs, skb->data, skb->len);
  559. if (cs->debug & DEB_DLOG_VERBOSE)
  560. dlogframe(cs, skb, 0);
  561. cs->tx_skb = skb;
  562. cs->tx_cnt = 0;
  563. #ifdef L2FRAME_DEBUG /* psa */
  564. if (cs->debug & L1_DEB_LAPD)
  565. Logl2Frame(cs, skb, "PH_DATA_PULLED", 0);
  566. #endif
  567. W6692_fill_fifo(cs);
  568. spin_unlock_irqrestore(&cs->lock, flags);
  569. break;
  570. case (PH_PULL | REQUEST):
  571. #ifdef L2FRAME_DEBUG /* psa */
  572. if (cs->debug & L1_DEB_LAPD)
  573. debugl1(cs, "-> PH_REQUEST_PULL");
  574. #endif
  575. if (!cs->tx_skb) {
  576. test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
  577. st->l1.l1l2(st, PH_PULL | CONFIRM, NULL);
  578. } else
  579. test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
  580. break;
  581. case (HW_RESET | REQUEST):
  582. spin_lock_irqsave(&cs->lock, flags);
  583. if ((cs->dc.w6692.ph_state == W_L1IND_DRD)) {
  584. ph_command(cs, W_L1CMD_ECK);
  585. spin_unlock_irqrestore(&cs->lock, flags);
  586. } else {
  587. ph_command(cs, W_L1CMD_RST);
  588. cs->dc.w6692.ph_state = W_L1CMD_RST;
  589. spin_unlock_irqrestore(&cs->lock, flags);
  590. W6692_new_ph(cs);
  591. }
  592. break;
  593. case (HW_ENABLE | REQUEST):
  594. spin_lock_irqsave(&cs->lock, flags);
  595. ph_command(cs, W_L1CMD_ECK);
  596. spin_unlock_irqrestore(&cs->lock, flags);
  597. break;
  598. case (HW_INFO3 | REQUEST):
  599. spin_lock_irqsave(&cs->lock, flags);
  600. ph_command(cs, W_L1CMD_AR8);
  601. spin_unlock_irqrestore(&cs->lock, flags);
  602. break;
  603. case (HW_TESTLOOP | REQUEST):
  604. val = 0;
  605. if (1 & (long) arg)
  606. val |= 0x0c;
  607. if (2 & (long) arg)
  608. val |= 0x3;
  609. /* !!! not implemented yet */
  610. break;
  611. case (HW_DEACTIVATE | RESPONSE):
  612. skb_queue_purge(&cs->rq);
  613. skb_queue_purge(&cs->sq);
  614. if (cs->tx_skb) {
  615. dev_kfree_skb_any(cs->tx_skb);
  616. cs->tx_skb = NULL;
  617. }
  618. if (test_and_clear_bit(FLG_DBUSY_TIMER, &cs->HW_Flags))
  619. del_timer(&cs->dbusytimer);
  620. if (test_and_clear_bit(FLG_L1_DBUSY, &cs->HW_Flags))
  621. schedule_event(cs, D_CLEARBUSY);
  622. break;
  623. default:
  624. if (cs->debug & L1_DEB_WARN)
  625. debugl1(cs, "W6692_l1hw unknown %04x", pr);
  626. break;
  627. }
  628. }
  629. static void
  630. setstack_W6692(struct PStack *st, struct IsdnCardState *cs)
  631. {
  632. st->l1.l1hw = W6692_l1hw;
  633. }
  634. static void
  635. DC_Close_W6692(struct IsdnCardState *cs)
  636. {
  637. }
  638. static void
  639. dbusy_timer_handler(struct IsdnCardState *cs)
  640. {
  641. struct PStack *stptr;
  642. int rbch, star;
  643. u_long flags;
  644. spin_lock_irqsave(&cs->lock, flags);
  645. if (test_bit(FLG_DBUSY_TIMER, &cs->HW_Flags)) {
  646. rbch = cs->readW6692(cs, W_D_RBCH);
  647. star = cs->readW6692(cs, W_D_STAR);
  648. if (cs->debug)
  649. debugl1(cs, "D-Channel Busy D_RBCH %02x D_STAR %02x",
  650. rbch, star);
  651. if (star & W_D_STAR_XBZ) { /* D-Channel Busy */
  652. test_and_set_bit(FLG_L1_DBUSY, &cs->HW_Flags);
  653. stptr = cs->stlist;
  654. while (stptr != NULL) {
  655. stptr->l1.l1l2(stptr, PH_PAUSE | INDICATION, NULL);
  656. stptr = stptr->next;
  657. }
  658. } else {
  659. /* discard frame; reset transceiver */
  660. test_and_clear_bit(FLG_DBUSY_TIMER, &cs->HW_Flags);
  661. if (cs->tx_skb) {
  662. dev_kfree_skb_any(cs->tx_skb);
  663. cs->tx_cnt = 0;
  664. cs->tx_skb = NULL;
  665. } else {
  666. printk(KERN_WARNING "HiSax: W6692 D-Channel Busy no skb\n");
  667. debugl1(cs, "D-Channel Busy no skb");
  668. }
  669. cs->writeW6692(cs, W_D_CMDR, W_D_CMDR_XRST); /* Transmitter reset */
  670. spin_unlock_irqrestore(&cs->lock, flags);
  671. cs->irq_func(cs->irq, cs);
  672. return;
  673. }
  674. }
  675. spin_unlock_irqrestore(&cs->lock, flags);
  676. }
  677. static void
  678. W6692Bmode(struct BCState *bcs, int mode, int bchan)
  679. {
  680. struct IsdnCardState *cs = bcs->cs;
  681. if (cs->debug & L1_DEB_HSCX)
  682. debugl1(cs, "w6692 %c mode %d ichan %d",
  683. '1' + bchan, mode, bchan);
  684. bcs->mode = mode;
  685. bcs->channel = bchan;
  686. bcs->hw.w6692.bchan = bchan;
  687. switch (mode) {
  688. case (L1_MODE_NULL):
  689. cs->BC_Write_Reg(cs, bchan, W_B_MODE, 0);
  690. break;
  691. case (L1_MODE_TRANS):
  692. cs->BC_Write_Reg(cs, bchan, W_B_MODE, W_B_MODE_MMS);
  693. break;
  694. case (L1_MODE_HDLC):
  695. cs->BC_Write_Reg(cs, bchan, W_B_MODE, W_B_MODE_ITF);
  696. cs->BC_Write_Reg(cs, bchan, W_B_ADM1, 0xff);
  697. cs->BC_Write_Reg(cs, bchan, W_B_ADM2, 0xff);
  698. break;
  699. }
  700. if (mode)
  701. cs->BC_Write_Reg(cs, bchan, W_B_CMDR, W_B_CMDR_RRST |
  702. W_B_CMDR_RACT | W_B_CMDR_XRST);
  703. cs->BC_Write_Reg(cs, bchan, W_B_EXIM, 0x00);
  704. }
  705. static void
  706. W6692_l2l1(struct PStack *st, int pr, void *arg)
  707. {
  708. struct sk_buff *skb = arg;
  709. struct BCState *bcs = st->l1.bcs;
  710. u_long flags;
  711. switch (pr) {
  712. case (PH_DATA | REQUEST):
  713. spin_lock_irqsave(&bcs->cs->lock, flags);
  714. if (bcs->tx_skb) {
  715. skb_queue_tail(&bcs->squeue, skb);
  716. } else {
  717. bcs->tx_skb = skb;
  718. test_and_set_bit(BC_FLG_BUSY, &bcs->Flag);
  719. bcs->hw.w6692.count = 0;
  720. bcs->cs->BC_Send_Data(bcs);
  721. }
  722. spin_unlock_irqrestore(&bcs->cs->lock, flags);
  723. break;
  724. case (PH_PULL | INDICATION):
  725. if (bcs->tx_skb) {
  726. printk(KERN_WARNING "W6692_l2l1: this shouldn't happen\n");
  727. break;
  728. }
  729. spin_lock_irqsave(&bcs->cs->lock, flags);
  730. test_and_set_bit(BC_FLG_BUSY, &bcs->Flag);
  731. bcs->tx_skb = skb;
  732. bcs->hw.w6692.count = 0;
  733. bcs->cs->BC_Send_Data(bcs);
  734. spin_unlock_irqrestore(&bcs->cs->lock, flags);
  735. break;
  736. case (PH_PULL | REQUEST):
  737. if (!bcs->tx_skb) {
  738. test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
  739. st->l1.l1l2(st, PH_PULL | CONFIRM, NULL);
  740. } else
  741. test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
  742. break;
  743. case (PH_ACTIVATE | REQUEST):
  744. spin_lock_irqsave(&bcs->cs->lock, flags);
  745. test_and_set_bit(BC_FLG_ACTIV, &bcs->Flag);
  746. W6692Bmode(bcs, st->l1.mode, st->l1.bc);
  747. spin_unlock_irqrestore(&bcs->cs->lock, flags);
  748. l1_msg_b(st, pr, arg);
  749. break;
  750. case (PH_DEACTIVATE | REQUEST):
  751. l1_msg_b(st, pr, arg);
  752. break;
  753. case (PH_DEACTIVATE | CONFIRM):
  754. spin_lock_irqsave(&bcs->cs->lock, flags);
  755. test_and_clear_bit(BC_FLG_ACTIV, &bcs->Flag);
  756. test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag);
  757. W6692Bmode(bcs, 0, st->l1.bc);
  758. spin_unlock_irqrestore(&bcs->cs->lock, flags);
  759. st->l1.l1l2(st, PH_DEACTIVATE | CONFIRM, NULL);
  760. break;
  761. }
  762. }
  763. static void
  764. close_w6692state(struct BCState *bcs)
  765. {
  766. W6692Bmode(bcs, 0, bcs->channel);
  767. if (test_and_clear_bit(BC_FLG_INIT, &bcs->Flag)) {
  768. kfree(bcs->hw.w6692.rcvbuf);
  769. bcs->hw.w6692.rcvbuf = NULL;
  770. kfree(bcs->blog);
  771. bcs->blog = NULL;
  772. skb_queue_purge(&bcs->rqueue);
  773. skb_queue_purge(&bcs->squeue);
  774. if (bcs->tx_skb) {
  775. dev_kfree_skb_any(bcs->tx_skb);
  776. bcs->tx_skb = NULL;
  777. test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag);
  778. }
  779. }
  780. }
  781. static int
  782. open_w6692state(struct IsdnCardState *cs, struct BCState *bcs)
  783. {
  784. if (!test_and_set_bit(BC_FLG_INIT, &bcs->Flag)) {
  785. if (!(bcs->hw.w6692.rcvbuf = kmalloc(HSCX_BUFMAX, GFP_ATOMIC))) {
  786. printk(KERN_WARNING
  787. "HiSax: No memory for w6692.rcvbuf\n");
  788. test_and_clear_bit(BC_FLG_INIT, &bcs->Flag);
  789. return (1);
  790. }
  791. if (!(bcs->blog = kmalloc(MAX_BLOG_SPACE, GFP_ATOMIC))) {
  792. printk(KERN_WARNING
  793. "HiSax: No memory for bcs->blog\n");
  794. test_and_clear_bit(BC_FLG_INIT, &bcs->Flag);
  795. kfree(bcs->hw.w6692.rcvbuf);
  796. bcs->hw.w6692.rcvbuf = NULL;
  797. return (2);
  798. }
  799. skb_queue_head_init(&bcs->rqueue);
  800. skb_queue_head_init(&bcs->squeue);
  801. }
  802. bcs->tx_skb = NULL;
  803. test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag);
  804. bcs->event = 0;
  805. bcs->hw.w6692.rcvidx = 0;
  806. bcs->tx_cnt = 0;
  807. return (0);
  808. }
  809. static int
  810. setstack_w6692(struct PStack *st, struct BCState *bcs)
  811. {
  812. bcs->channel = st->l1.bc;
  813. if (open_w6692state(st->l1.hardware, bcs))
  814. return (-1);
  815. st->l1.bcs = bcs;
  816. st->l2.l2l1 = W6692_l2l1;
  817. setstack_manager(st);
  818. bcs->st = st;
  819. setstack_l1_B(st);
  820. return (0);
  821. }
  822. static void resetW6692(struct IsdnCardState *cs)
  823. {
  824. cs->writeW6692(cs, W_D_CTL, W_D_CTL_SRST);
  825. mdelay(10);
  826. cs->writeW6692(cs, W_D_CTL, 0x00);
  827. mdelay(10);
  828. cs->writeW6692(cs, W_IMASK, 0xff);
  829. cs->writeW6692(cs, W_D_SAM, 0xff);
  830. cs->writeW6692(cs, W_D_TAM, 0xff);
  831. cs->writeW6692(cs, W_D_EXIM, 0x00);
  832. cs->writeW6692(cs, W_D_MODE, W_D_MODE_RACT);
  833. cs->writeW6692(cs, W_IMASK, 0x18);
  834. if (cs->subtyp == W6692_USR) {
  835. /* seems that USR implemented some power control features
  836. * Pin 79 is connected to the oscilator circuit so we
  837. * have to handle it here
  838. */
  839. cs->writeW6692(cs, W_PCTL, 0x80);
  840. cs->writeW6692(cs, W_XDATA, 0x00);
  841. }
  842. }
  843. static void initW6692(struct IsdnCardState *cs, int part)
  844. {
  845. if (part & 1) {
  846. cs->setstack_d = setstack_W6692;
  847. cs->DC_Close = DC_Close_W6692;
  848. cs->dbusytimer.function = (void *) dbusy_timer_handler;
  849. cs->dbusytimer.data = (long) cs;
  850. init_timer(&cs->dbusytimer);
  851. resetW6692(cs);
  852. ph_command(cs, W_L1CMD_RST);
  853. cs->dc.w6692.ph_state = W_L1CMD_RST;
  854. W6692_new_ph(cs);
  855. ph_command(cs, W_L1CMD_ECK);
  856. cs->bcs[0].BC_SetStack = setstack_w6692;
  857. cs->bcs[1].BC_SetStack = setstack_w6692;
  858. cs->bcs[0].BC_Close = close_w6692state;
  859. cs->bcs[1].BC_Close = close_w6692state;
  860. W6692Bmode(cs->bcs, 0, 0);
  861. W6692Bmode(cs->bcs + 1, 0, 0);
  862. }
  863. if (part & 2) {
  864. /* Reenable all IRQ */
  865. cs->writeW6692(cs, W_IMASK, 0x18);
  866. cs->writeW6692(cs, W_D_EXIM, 0x00);
  867. cs->BC_Write_Reg(cs, 0, W_B_EXIM, 0x00);
  868. cs->BC_Write_Reg(cs, 1, W_B_EXIM, 0x00);
  869. /* Reset D-chan receiver and transmitter */
  870. cs->writeW6692(cs, W_D_CMDR, W_D_CMDR_RRST | W_D_CMDR_XRST);
  871. }
  872. }
  873. /* Interface functions */
  874. static u_char
  875. ReadW6692(struct IsdnCardState *cs, u_char offset)
  876. {
  877. return (inb(cs->hw.w6692.iobase + offset));
  878. }
  879. static void
  880. WriteW6692(struct IsdnCardState *cs, u_char offset, u_char value)
  881. {
  882. outb(value, cs->hw.w6692.iobase + offset);
  883. }
  884. static void
  885. ReadISACfifo(struct IsdnCardState *cs, u_char * data, int size)
  886. {
  887. insb(cs->hw.w6692.iobase + W_D_RFIFO, data, size);
  888. }
  889. static void
  890. WriteISACfifo(struct IsdnCardState *cs, u_char * data, int size)
  891. {
  892. outsb(cs->hw.w6692.iobase + W_D_XFIFO, data, size);
  893. }
  894. static u_char
  895. ReadW6692B(struct IsdnCardState *cs, int bchan, u_char offset)
  896. {
  897. return (inb(cs->hw.w6692.iobase + (bchan ? 0x40 : 0) + offset));
  898. }
  899. static void
  900. WriteW6692B(struct IsdnCardState *cs, int bchan, u_char offset, u_char value)
  901. {
  902. outb(value, cs->hw.w6692.iobase + (bchan ? 0x40 : 0) + offset);
  903. }
  904. static int
  905. w6692_card_msg(struct IsdnCardState *cs, int mt, void *arg)
  906. {
  907. switch (mt) {
  908. case CARD_RESET:
  909. resetW6692(cs);
  910. return (0);
  911. case CARD_RELEASE:
  912. cs->writeW6692(cs, W_IMASK, 0xff);
  913. release_region(cs->hw.w6692.iobase, 256);
  914. if (cs->subtyp == W6692_USR) {
  915. cs->writeW6692(cs, W_XDATA, 0x04);
  916. }
  917. return (0);
  918. case CARD_INIT:
  919. initW6692(cs, 3);
  920. return (0);
  921. case CARD_TEST:
  922. return (0);
  923. }
  924. return (0);
  925. }
  926. static int id_idx ;
  927. static struct pci_dev *dev_w6692 __devinitdata = NULL;
  928. int __devinit
  929. setup_w6692(struct IsdnCard *card)
  930. {
  931. struct IsdnCardState *cs = card->cs;
  932. char tmp[64];
  933. u_char found = 0;
  934. u_char pci_irq = 0;
  935. u_int pci_ioaddr = 0;
  936. strcpy(tmp, w6692_revision);
  937. printk(KERN_INFO "HiSax: W6692 driver Rev. %s\n", HiSax_getrev(tmp));
  938. if (cs->typ != ISDN_CTYPE_W6692)
  939. return (0);
  940. while (id_list[id_idx].vendor_id) {
  941. dev_w6692 = hisax_find_pci_device(id_list[id_idx].vendor_id,
  942. id_list[id_idx].device_id,
  943. dev_w6692);
  944. if (dev_w6692) {
  945. if (pci_enable_device(dev_w6692))
  946. continue;
  947. cs->subtyp = id_idx;
  948. break;
  949. }
  950. id_idx++;
  951. }
  952. if (dev_w6692) {
  953. found = 1;
  954. pci_irq = dev_w6692->irq;
  955. /* I think address 0 is allways the configuration area */
  956. /* and address 1 is the real IO space KKe 03.09.99 */
  957. pci_ioaddr = pci_resource_start(dev_w6692, 1);
  958. /* USR ISDN PCI card TA need some special handling */
  959. if (cs->subtyp == W6692_WINBOND) {
  960. if ((W6692_SV_USR == dev_w6692->subsystem_vendor) &&
  961. (W6692_SD_USR == dev_w6692->subsystem_device)) {
  962. cs->subtyp = W6692_USR;
  963. }
  964. }
  965. }
  966. if (!found) {
  967. printk(KERN_WARNING "W6692: No PCI card found\n");
  968. return (0);
  969. }
  970. cs->irq = pci_irq;
  971. if (!cs->irq) {
  972. printk(KERN_WARNING "W6692: No IRQ for PCI card found\n");
  973. return (0);
  974. }
  975. if (!pci_ioaddr) {
  976. printk(KERN_WARNING "W6692: NO I/O Base Address found\n");
  977. return (0);
  978. }
  979. cs->hw.w6692.iobase = pci_ioaddr;
  980. printk(KERN_INFO "Found: %s %s, I/O base: 0x%x, irq: %d\n",
  981. id_list[cs->subtyp].vendor_name, id_list[cs->subtyp].card_name,
  982. pci_ioaddr, pci_irq);
  983. if (!request_region(cs->hw.w6692.iobase, 256, id_list[cs->subtyp].card_name)) {
  984. printk(KERN_WARNING
  985. "HiSax: %s I/O ports %x-%x already in use\n",
  986. id_list[cs->subtyp].card_name,
  987. cs->hw.w6692.iobase,
  988. cs->hw.w6692.iobase + 255);
  989. return (0);
  990. }
  991. printk(KERN_INFO
  992. "HiSax: %s config irq:%d I/O:%x\n",
  993. id_list[cs->subtyp].card_name, cs->irq,
  994. cs->hw.w6692.iobase);
  995. INIT_WORK(&cs->tqueue, W6692_bh);
  996. cs->readW6692 = &ReadW6692;
  997. cs->writeW6692 = &WriteW6692;
  998. cs->readisacfifo = &ReadISACfifo;
  999. cs->writeisacfifo = &WriteISACfifo;
  1000. cs->BC_Read_Reg = &ReadW6692B;
  1001. cs->BC_Write_Reg = &WriteW6692B;
  1002. cs->BC_Send_Data = &W6692B_fill_fifo;
  1003. cs->cardmsg = &w6692_card_msg;
  1004. cs->irq_func = &W6692_interrupt;
  1005. cs->irq_flags |= IRQF_SHARED;
  1006. W6692Version(cs, "W6692:");
  1007. printk(KERN_INFO "W6692 ISTA=0x%X\n", ReadW6692(cs, W_ISTA));
  1008. printk(KERN_INFO "W6692 IMASK=0x%X\n", ReadW6692(cs, W_IMASK));
  1009. printk(KERN_INFO "W6692 D_EXIR=0x%X\n", ReadW6692(cs, W_D_EXIR));
  1010. printk(KERN_INFO "W6692 D_EXIM=0x%X\n", ReadW6692(cs, W_D_EXIM));
  1011. printk(KERN_INFO "W6692 D_RSTA=0x%X\n", ReadW6692(cs, W_D_RSTA));
  1012. return (1);
  1013. }