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