w6692.c 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085
  1. /* $Id: w6692.c,v 1.18.2.4 2004/02/11 13:21:34 keil Exp $
  2. *
  3. * Winbond W6692 specific routines
  4. *
  5. * Author Petr Novak
  6. * Copyright by Petr Novak <petr.novak@i.cz>
  7. *
  8. * This software may be used and distributed according to the terms
  9. * of the GNU General Public License, incorporated herein by reference.
  10. *
  11. */
  12. #include <linux/init.h>
  13. #include "hisax.h"
  14. #include "w6692.h"
  15. #include "isdnl1.h"
  16. #include <linux/interrupt.h>
  17. #include <linux/pci.h>
  18. #include <linux/slab.h>
  19. /* table entry in the PCI devices list */
  20. typedef struct {
  21. int vendor_id;
  22. int device_id;
  23. char *vendor_name;
  24. char *card_name;
  25. } PCI_ENTRY;
  26. static const PCI_ENTRY id_list[] =
  27. {
  28. {PCI_VENDOR_ID_WINBOND2, PCI_DEVICE_ID_WINBOND2_6692, "Winbond", "W6692"},
  29. {PCI_VENDOR_ID_DYNALINK, PCI_DEVICE_ID_DYNALINK_IS64PH, "Dynalink/AsusCom", "IS64PH"},
  30. {0, 0, "U.S.Robotics", "ISDN PCI Card TA"}
  31. };
  32. #define W6692_SV_USR 0x16ec
  33. #define W6692_SD_USR 0x3409
  34. #define W6692_WINBOND 0
  35. #define W6692_DYNALINK 1
  36. #define W6692_USR 2
  37. static const char *w6692_revision = "$Revision: 1.18.2.4 $";
  38. #define DBUSY_TIMER_VALUE 80
  39. static char *W6692Ver[] =
  40. {"W6692 V00", "W6692 V01", "W6692 V10",
  41. "W6692 V11"};
  42. static void
  43. W6692Version(struct IsdnCardState *cs, char *s)
  44. {
  45. int val;
  46. val = cs->readW6692(cs, W_D_RBCH);
  47. printk(KERN_INFO "%s Winbond W6692 version (%x): %s\n", s, val, W6692Ver[(val >> 6) & 3]);
  48. }
  49. static void
  50. ph_command(struct IsdnCardState *cs, unsigned int command)
  51. {
  52. if (cs->debug & L1_DEB_ISAC)
  53. debugl1(cs, "ph_command %x", command);
  54. cs->writeisac(cs, W_CIX, command);
  55. }
  56. static void
  57. W6692_new_ph(struct IsdnCardState *cs)
  58. {
  59. switch (cs->dc.w6692.ph_state) {
  60. case (W_L1CMD_RST):
  61. ph_command(cs, W_L1CMD_DRC);
  62. l1_msg(cs, HW_RESET | INDICATION, NULL);
  63. /* fallthru */
  64. case (W_L1IND_CD):
  65. l1_msg(cs, HW_DEACTIVATE | CONFIRM, NULL);
  66. break;
  67. case (W_L1IND_DRD):
  68. l1_msg(cs, HW_DEACTIVATE | INDICATION, NULL);
  69. break;
  70. case (W_L1IND_CE):
  71. l1_msg(cs, HW_POWERUP | CONFIRM, NULL);
  72. break;
  73. case (W_L1IND_LD):
  74. l1_msg(cs, HW_RSYNC | INDICATION, NULL);
  75. break;
  76. case (W_L1IND_ARD):
  77. l1_msg(cs, HW_INFO2 | INDICATION, NULL);
  78. break;
  79. case (W_L1IND_AI8):
  80. l1_msg(cs, HW_INFO4_P8 | INDICATION, NULL);
  81. break;
  82. case (W_L1IND_AI10):
  83. l1_msg(cs, HW_INFO4_P10 | INDICATION, NULL);
  84. break;
  85. default:
  86. break;
  87. }
  88. }
  89. static void
  90. W6692_bh(struct work_struct *work)
  91. {
  92. struct IsdnCardState *cs =
  93. container_of(work, struct IsdnCardState, tqueue);
  94. struct PStack *stptr;
  95. if (test_and_clear_bit(D_CLEARBUSY, &cs->event)) {
  96. if (cs->debug)
  97. debugl1(cs, "D-Channel Busy cleared");
  98. stptr = cs->stlist;
  99. while (stptr != NULL) {
  100. stptr->l1.l1l2(stptr, PH_PAUSE | CONFIRM, NULL);
  101. stptr = stptr->next;
  102. }
  103. }
  104. if (test_and_clear_bit(D_L1STATECHANGE, &cs->event))
  105. W6692_new_ph(cs);
  106. if (test_and_clear_bit(D_RCVBUFREADY, &cs->event))
  107. DChannel_proc_rcv(cs);
  108. if (test_and_clear_bit(D_XMTBUFREADY, &cs->event))
  109. DChannel_proc_xmt(cs);
  110. /*
  111. if (test_and_clear_bit(D_RX_MON1, &cs->event))
  112. arcofi_fsm(cs, ARCOFI_RX_END, NULL);
  113. if (test_and_clear_bit(D_TX_MON1, &cs->event))
  114. arcofi_fsm(cs, ARCOFI_TX_END, NULL);
  115. */
  116. }
  117. static void
  118. W6692_empty_fifo(struct IsdnCardState *cs, int count)
  119. {
  120. u_char *ptr;
  121. if ((cs->debug & L1_DEB_ISAC) && !(cs->debug & L1_DEB_ISAC_FIFO))
  122. debugl1(cs, "W6692_empty_fifo");
  123. if ((cs->rcvidx + count) >= MAX_DFRAME_LEN_L1) {
  124. if (cs->debug & L1_DEB_WARN)
  125. debugl1(cs, "W6692_empty_fifo overrun %d",
  126. cs->rcvidx + count);
  127. cs->writeW6692(cs, W_D_CMDR, W_D_CMDR_RACK);
  128. cs->rcvidx = 0;
  129. return;
  130. }
  131. ptr = cs->rcvbuf + cs->rcvidx;
  132. cs->rcvidx += count;
  133. cs->readW6692fifo(cs, ptr, count);
  134. cs->writeW6692(cs, W_D_CMDR, W_D_CMDR_RACK);
  135. if (cs->debug & L1_DEB_ISAC_FIFO) {
  136. char *t = cs->dlog;
  137. t += sprintf(t, "W6692_empty_fifo cnt %d", count);
  138. QuickHex(t, ptr, count);
  139. debugl1(cs, "%s", cs->dlog);
  140. }
  141. }
  142. static void
  143. W6692_fill_fifo(struct IsdnCardState *cs)
  144. {
  145. int count, more;
  146. u_char *ptr;
  147. if ((cs->debug & L1_DEB_ISAC) && !(cs->debug & L1_DEB_ISAC_FIFO))
  148. debugl1(cs, "W6692_fill_fifo");
  149. if (!cs->tx_skb)
  150. return;
  151. count = cs->tx_skb->len;
  152. if (count <= 0)
  153. return;
  154. more = 0;
  155. if (count > W_D_FIFO_THRESH) {
  156. more = !0;
  157. count = W_D_FIFO_THRESH;
  158. }
  159. ptr = cs->tx_skb->data;
  160. skb_pull(cs->tx_skb, count);
  161. cs->tx_cnt += count;
  162. cs->writeW6692fifo(cs, ptr, count);
  163. cs->writeW6692(cs, W_D_CMDR, more ? W_D_CMDR_XMS : (W_D_CMDR_XMS | W_D_CMDR_XME));
  164. if (test_and_set_bit(FLG_DBUSY_TIMER, &cs->HW_Flags)) {
  165. debugl1(cs, "W6692_fill_fifo dbusytimer running");
  166. del_timer(&cs->dbusytimer);
  167. }
  168. cs->dbusytimer.expires = jiffies + ((DBUSY_TIMER_VALUE * HZ) / 1000);
  169. add_timer(&cs->dbusytimer);
  170. if (cs->debug & L1_DEB_ISAC_FIFO) {
  171. char *t = cs->dlog;
  172. t += sprintf(t, "W6692_fill_fifo cnt %d", count);
  173. QuickHex(t, ptr, count);
  174. debugl1(cs, "%s", cs->dlog);
  175. }
  176. }
  177. static void
  178. W6692B_empty_fifo(struct BCState *bcs, int count)
  179. {
  180. u_char *ptr;
  181. struct IsdnCardState *cs = bcs->cs;
  182. if ((cs->debug & L1_DEB_HSCX) && !(cs->debug & L1_DEB_HSCX_FIFO))
  183. debugl1(cs, "W6692B_empty_fifo");
  184. if (bcs->hw.w6692.rcvidx + count > HSCX_BUFMAX) {
  185. if (cs->debug & L1_DEB_WARN)
  186. debugl1(cs, "W6692B_empty_fifo: incoming packet too large");
  187. cs->BC_Write_Reg(cs, bcs->channel, W_B_CMDR, W_B_CMDR_RACK | W_B_CMDR_RACT);
  188. bcs->hw.w6692.rcvidx = 0;
  189. return;
  190. }
  191. ptr = bcs->hw.w6692.rcvbuf + bcs->hw.w6692.rcvidx;
  192. bcs->hw.w6692.rcvidx += count;
  193. READW6692BFIFO(cs, bcs->channel, ptr, count);
  194. cs->BC_Write_Reg(cs, bcs->channel, W_B_CMDR, W_B_CMDR_RACK | W_B_CMDR_RACT);
  195. if (cs->debug & L1_DEB_HSCX_FIFO) {
  196. char *t = bcs->blog;
  197. t += sprintf(t, "W6692B_empty_fifo %c cnt %d",
  198. bcs->channel + '1', count);
  199. QuickHex(t, ptr, count);
  200. debugl1(cs, "%s", bcs->blog);
  201. }
  202. }
  203. static void
  204. W6692B_fill_fifo(struct BCState *bcs)
  205. {
  206. struct IsdnCardState *cs = bcs->cs;
  207. int more, count;
  208. u_char *ptr;
  209. if (!bcs->tx_skb)
  210. return;
  211. if (bcs->tx_skb->len <= 0)
  212. return;
  213. more = (bcs->mode == L1_MODE_TRANS) ? 1 : 0;
  214. if (bcs->tx_skb->len > W_B_FIFO_THRESH) {
  215. more = 1;
  216. count = W_B_FIFO_THRESH;
  217. } else
  218. count = bcs->tx_skb->len;
  219. if ((cs->debug & L1_DEB_HSCX) && !(cs->debug & L1_DEB_HSCX_FIFO))
  220. debugl1(cs, "W6692B_fill_fifo%s%d", (more ? " " : " last "), count);
  221. ptr = bcs->tx_skb->data;
  222. skb_pull(bcs->tx_skb, count);
  223. bcs->tx_cnt -= count;
  224. bcs->hw.w6692.count += count;
  225. WRITEW6692BFIFO(cs, bcs->channel, ptr, count);
  226. cs->BC_Write_Reg(cs, bcs->channel, W_B_CMDR, W_B_CMDR_RACT | W_B_CMDR_XMS | (more ? 0 : W_B_CMDR_XME));
  227. if (cs->debug & L1_DEB_HSCX_FIFO) {
  228. char *t = bcs->blog;
  229. t += sprintf(t, "W6692B_fill_fifo %c cnt %d",
  230. bcs->channel + '1', count);
  231. QuickHex(t, ptr, count);
  232. debugl1(cs, "%s", bcs->blog);
  233. }
  234. }
  235. static void
  236. W6692B_interrupt(struct IsdnCardState *cs, u_char bchan)
  237. {
  238. u_char val;
  239. u_char r;
  240. struct BCState *bcs;
  241. struct sk_buff *skb;
  242. int count;
  243. bcs = (cs->bcs->channel == bchan) ? cs->bcs : (cs->bcs + 1);
  244. val = cs->BC_Read_Reg(cs, bchan, W_B_EXIR);
  245. debugl1(cs, "W6692B chan %d B_EXIR 0x%02X", bchan, val);
  246. if (!test_bit(BC_FLG_INIT, &bcs->Flag)) {
  247. debugl1(cs, "W6692B not INIT yet");
  248. return;
  249. }
  250. if (val & W_B_EXI_RME) { /* RME */
  251. r = cs->BC_Read_Reg(cs, bchan, W_B_STAR);
  252. if (r & (W_B_STAR_RDOV | W_B_STAR_CRCE | W_B_STAR_RMB)) {
  253. if (cs->debug & L1_DEB_WARN)
  254. debugl1(cs, "W6692 B STAR %x", r);
  255. if ((r & W_B_STAR_RDOV) && bcs->mode)
  256. if (cs->debug & L1_DEB_WARN)
  257. debugl1(cs, "W6692 B RDOV mode=%d",
  258. bcs->mode);
  259. if (r & W_B_STAR_CRCE)
  260. if (cs->debug & L1_DEB_WARN)
  261. debugl1(cs, "W6692 B CRC error");
  262. cs->BC_Write_Reg(cs, bchan, W_B_CMDR, W_B_CMDR_RACK | W_B_CMDR_RRST | W_B_CMDR_RACT);
  263. } else {
  264. count = cs->BC_Read_Reg(cs, bchan, W_B_RBCL) & (W_B_FIFO_THRESH - 1);
  265. if (count == 0)
  266. count = W_B_FIFO_THRESH;
  267. W6692B_empty_fifo(bcs, count);
  268. if ((count = bcs->hw.w6692.rcvidx) > 0) {
  269. if (cs->debug & L1_DEB_HSCX_FIFO)
  270. debugl1(cs, "W6692 Bchan Frame %d", count);
  271. if (!(skb = dev_alloc_skb(count)))
  272. printk(KERN_WARNING "W6692: Bchan receive out of memory\n");
  273. else {
  274. skb_put_data(skb,
  275. bcs->hw.w6692.rcvbuf,
  276. 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. skb_put_data(skb, bcs->hw.w6692.rcvbuf,
  300. 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. skb_put_data(skb, 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 timer_list *t)
  642. {
  643. struct IsdnCardState *cs = from_timer(cs, t, dbusytimer);
  644. struct PStack *stptr;
  645. int rbch, star;
  646. u_long flags;
  647. spin_lock_irqsave(&cs->lock, flags);
  648. if (test_bit(FLG_DBUSY_TIMER, &cs->HW_Flags)) {
  649. rbch = cs->readW6692(cs, W_D_RBCH);
  650. star = cs->readW6692(cs, W_D_STAR);
  651. if (cs->debug)
  652. debugl1(cs, "D-Channel Busy D_RBCH %02x D_STAR %02x",
  653. rbch, star);
  654. if (star & W_D_STAR_XBZ) { /* D-Channel Busy */
  655. test_and_set_bit(FLG_L1_DBUSY, &cs->HW_Flags);
  656. stptr = cs->stlist;
  657. while (stptr != NULL) {
  658. stptr->l1.l1l2(stptr, PH_PAUSE | INDICATION, NULL);
  659. stptr = stptr->next;
  660. }
  661. } else {
  662. /* discard frame; reset transceiver */
  663. test_and_clear_bit(FLG_DBUSY_TIMER, &cs->HW_Flags);
  664. if (cs->tx_skb) {
  665. dev_kfree_skb_any(cs->tx_skb);
  666. cs->tx_cnt = 0;
  667. cs->tx_skb = NULL;
  668. } else {
  669. printk(KERN_WARNING "HiSax: W6692 D-Channel Busy no skb\n");
  670. debugl1(cs, "D-Channel Busy no skb");
  671. }
  672. cs->writeW6692(cs, W_D_CMDR, W_D_CMDR_XRST); /* Transmitter reset */
  673. spin_unlock_irqrestore(&cs->lock, flags);
  674. cs->irq_func(cs->irq, cs);
  675. return;
  676. }
  677. }
  678. spin_unlock_irqrestore(&cs->lock, flags);
  679. }
  680. static void
  681. W6692Bmode(struct BCState *bcs, int mode, int bchan)
  682. {
  683. struct IsdnCardState *cs = bcs->cs;
  684. if (cs->debug & L1_DEB_HSCX)
  685. debugl1(cs, "w6692 %c mode %d ichan %d",
  686. '1' + bchan, mode, bchan);
  687. bcs->mode = mode;
  688. bcs->channel = bchan;
  689. bcs->hw.w6692.bchan = bchan;
  690. switch (mode) {
  691. case (L1_MODE_NULL):
  692. cs->BC_Write_Reg(cs, bchan, W_B_MODE, 0);
  693. break;
  694. case (L1_MODE_TRANS):
  695. cs->BC_Write_Reg(cs, bchan, W_B_MODE, W_B_MODE_MMS);
  696. break;
  697. case (L1_MODE_HDLC):
  698. cs->BC_Write_Reg(cs, bchan, W_B_MODE, W_B_MODE_ITF);
  699. cs->BC_Write_Reg(cs, bchan, W_B_ADM1, 0xff);
  700. cs->BC_Write_Reg(cs, bchan, W_B_ADM2, 0xff);
  701. break;
  702. }
  703. if (mode)
  704. cs->BC_Write_Reg(cs, bchan, W_B_CMDR, W_B_CMDR_RRST |
  705. W_B_CMDR_RACT | W_B_CMDR_XRST);
  706. cs->BC_Write_Reg(cs, bchan, W_B_EXIM, 0x00);
  707. }
  708. static void
  709. W6692_l2l1(struct PStack *st, int pr, void *arg)
  710. {
  711. struct sk_buff *skb = arg;
  712. struct BCState *bcs = st->l1.bcs;
  713. u_long flags;
  714. switch (pr) {
  715. case (PH_DATA | REQUEST):
  716. spin_lock_irqsave(&bcs->cs->lock, flags);
  717. if (bcs->tx_skb) {
  718. skb_queue_tail(&bcs->squeue, skb);
  719. } else {
  720. bcs->tx_skb = skb;
  721. test_and_set_bit(BC_FLG_BUSY, &bcs->Flag);
  722. bcs->hw.w6692.count = 0;
  723. bcs->cs->BC_Send_Data(bcs);
  724. }
  725. spin_unlock_irqrestore(&bcs->cs->lock, flags);
  726. break;
  727. case (PH_PULL | INDICATION):
  728. if (bcs->tx_skb) {
  729. printk(KERN_WARNING "W6692_l2l1: this shouldn't happen\n");
  730. break;
  731. }
  732. spin_lock_irqsave(&bcs->cs->lock, flags);
  733. test_and_set_bit(BC_FLG_BUSY, &bcs->Flag);
  734. bcs->tx_skb = skb;
  735. bcs->hw.w6692.count = 0;
  736. bcs->cs->BC_Send_Data(bcs);
  737. spin_unlock_irqrestore(&bcs->cs->lock, flags);
  738. break;
  739. case (PH_PULL | REQUEST):
  740. if (!bcs->tx_skb) {
  741. test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
  742. st->l1.l1l2(st, PH_PULL | CONFIRM, NULL);
  743. } else
  744. test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
  745. break;
  746. case (PH_ACTIVATE | REQUEST):
  747. spin_lock_irqsave(&bcs->cs->lock, flags);
  748. test_and_set_bit(BC_FLG_ACTIV, &bcs->Flag);
  749. W6692Bmode(bcs, st->l1.mode, st->l1.bc);
  750. spin_unlock_irqrestore(&bcs->cs->lock, flags);
  751. l1_msg_b(st, pr, arg);
  752. break;
  753. case (PH_DEACTIVATE | REQUEST):
  754. l1_msg_b(st, pr, arg);
  755. break;
  756. case (PH_DEACTIVATE | CONFIRM):
  757. spin_lock_irqsave(&bcs->cs->lock, flags);
  758. test_and_clear_bit(BC_FLG_ACTIV, &bcs->Flag);
  759. test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag);
  760. W6692Bmode(bcs, 0, st->l1.bc);
  761. spin_unlock_irqrestore(&bcs->cs->lock, flags);
  762. st->l1.l1l2(st, PH_DEACTIVATE | CONFIRM, NULL);
  763. break;
  764. }
  765. }
  766. static void
  767. close_w6692state(struct BCState *bcs)
  768. {
  769. W6692Bmode(bcs, 0, bcs->channel);
  770. if (test_and_clear_bit(BC_FLG_INIT, &bcs->Flag)) {
  771. kfree(bcs->hw.w6692.rcvbuf);
  772. bcs->hw.w6692.rcvbuf = NULL;
  773. kfree(bcs->blog);
  774. bcs->blog = NULL;
  775. skb_queue_purge(&bcs->rqueue);
  776. skb_queue_purge(&bcs->squeue);
  777. if (bcs->tx_skb) {
  778. dev_kfree_skb_any(bcs->tx_skb);
  779. bcs->tx_skb = NULL;
  780. test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag);
  781. }
  782. }
  783. }
  784. static int
  785. open_w6692state(struct IsdnCardState *cs, struct BCState *bcs)
  786. {
  787. if (!test_and_set_bit(BC_FLG_INIT, &bcs->Flag)) {
  788. if (!(bcs->hw.w6692.rcvbuf = kmalloc(HSCX_BUFMAX, GFP_ATOMIC))) {
  789. printk(KERN_WARNING
  790. "HiSax: No memory for w6692.rcvbuf\n");
  791. test_and_clear_bit(BC_FLG_INIT, &bcs->Flag);
  792. return (1);
  793. }
  794. if (!(bcs->blog = kmalloc(MAX_BLOG_SPACE, GFP_ATOMIC))) {
  795. printk(KERN_WARNING
  796. "HiSax: No memory for bcs->blog\n");
  797. test_and_clear_bit(BC_FLG_INIT, &bcs->Flag);
  798. kfree(bcs->hw.w6692.rcvbuf);
  799. bcs->hw.w6692.rcvbuf = NULL;
  800. return (2);
  801. }
  802. skb_queue_head_init(&bcs->rqueue);
  803. skb_queue_head_init(&bcs->squeue);
  804. }
  805. bcs->tx_skb = NULL;
  806. test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag);
  807. bcs->event = 0;
  808. bcs->hw.w6692.rcvidx = 0;
  809. bcs->tx_cnt = 0;
  810. return (0);
  811. }
  812. static int
  813. setstack_w6692(struct PStack *st, struct BCState *bcs)
  814. {
  815. bcs->channel = st->l1.bc;
  816. if (open_w6692state(st->l1.hardware, bcs))
  817. return (-1);
  818. st->l1.bcs = bcs;
  819. st->l2.l2l1 = W6692_l2l1;
  820. setstack_manager(st);
  821. bcs->st = st;
  822. setstack_l1_B(st);
  823. return (0);
  824. }
  825. static void resetW6692(struct IsdnCardState *cs)
  826. {
  827. cs->writeW6692(cs, W_D_CTL, W_D_CTL_SRST);
  828. mdelay(10);
  829. cs->writeW6692(cs, W_D_CTL, 0x00);
  830. mdelay(10);
  831. cs->writeW6692(cs, W_IMASK, 0xff);
  832. cs->writeW6692(cs, W_D_SAM, 0xff);
  833. cs->writeW6692(cs, W_D_TAM, 0xff);
  834. cs->writeW6692(cs, W_D_EXIM, 0x00);
  835. cs->writeW6692(cs, W_D_MODE, W_D_MODE_RACT);
  836. cs->writeW6692(cs, W_IMASK, 0x18);
  837. if (cs->subtyp == W6692_USR) {
  838. /* seems that USR implemented some power control features
  839. * Pin 79 is connected to the oscilator circuit so we
  840. * have to handle it here
  841. */
  842. cs->writeW6692(cs, W_PCTL, 0x80);
  843. cs->writeW6692(cs, W_XDATA, 0x00);
  844. }
  845. }
  846. static void initW6692(struct IsdnCardState *cs, int part)
  847. {
  848. if (part & 1) {
  849. cs->setstack_d = setstack_W6692;
  850. cs->DC_Close = DC_Close_W6692;
  851. timer_setup(&cs->dbusytimer, dbusy_timer_handler, 0);
  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 = NULL;
  929. int 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. }