hisax.h 27 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316
  1. /* $Id: hisax.h,v 2.64.2.4 2004/02/11 13:21:33 keil Exp $
  2. *
  3. * Basic declarations, defines and prototypes
  4. *
  5. * This software may be used and distributed according to the terms
  6. * of the GNU General Public License, incorporated herein by reference.
  7. *
  8. */
  9. #include <linux/errno.h>
  10. #include <linux/fs.h>
  11. #include <linux/major.h>
  12. #include <asm/io.h>
  13. #include <linux/delay.h>
  14. #include <linux/kernel.h>
  15. #include <linux/signal.h>
  16. #include <linux/slab.h>
  17. #include <linux/mm.h>
  18. #include <linux/mman.h>
  19. #include <linux/ioport.h>
  20. #include <linux/timer.h>
  21. #include <linux/wait.h>
  22. #include <linux/isdnif.h>
  23. #include <linux/tty.h>
  24. #include <linux/serial_reg.h>
  25. #include <linux/netdevice.h>
  26. #define ERROR_STATISTIC
  27. #define REQUEST 0
  28. #define CONFIRM 1
  29. #define INDICATION 2
  30. #define RESPONSE 3
  31. #define HW_ENABLE 0x0000
  32. #define HW_RESET 0x0004
  33. #define HW_POWERUP 0x0008
  34. #define HW_ACTIVATE 0x0010
  35. #define HW_DEACTIVATE 0x0018
  36. #define HW_INFO1 0x0010
  37. #define HW_INFO2 0x0020
  38. #define HW_INFO3 0x0030
  39. #define HW_INFO4 0x0040
  40. #define HW_INFO4_P8 0x0040
  41. #define HW_INFO4_P10 0x0048
  42. #define HW_RSYNC 0x0060
  43. #define HW_TESTLOOP 0x0070
  44. #define CARD_RESET 0x00F0
  45. #define CARD_INIT 0x00F2
  46. #define CARD_RELEASE 0x00F3
  47. #define CARD_TEST 0x00F4
  48. #define CARD_AUX_IND 0x00F5
  49. #define PH_ACTIVATE 0x0100
  50. #define PH_DEACTIVATE 0x0110
  51. #define PH_DATA 0x0120
  52. #define PH_PULL 0x0130
  53. #define PH_TESTLOOP 0x0140
  54. #define PH_PAUSE 0x0150
  55. #define MPH_ACTIVATE 0x0180
  56. #define MPH_DEACTIVATE 0x0190
  57. #define MPH_INFORMATION 0x01A0
  58. #define DL_ESTABLISH 0x0200
  59. #define DL_RELEASE 0x0210
  60. #define DL_DATA 0x0220
  61. #define DL_FLUSH 0x0224
  62. #define DL_UNIT_DATA 0x0230
  63. #define MDL_BC_RELEASE 0x0278 // Formula-n enter:now
  64. #define MDL_BC_ASSIGN 0x027C // Formula-n enter:now
  65. #define MDL_ASSIGN 0x0280
  66. #define MDL_REMOVE 0x0284
  67. #define MDL_ERROR 0x0288
  68. #define MDL_INFO_SETUP 0x02E0
  69. #define MDL_INFO_CONN 0x02E4
  70. #define MDL_INFO_REL 0x02E8
  71. #define CC_SETUP 0x0300
  72. #define CC_RESUME 0x0304
  73. #define CC_MORE_INFO 0x0310
  74. #define CC_IGNORE 0x0320
  75. #define CC_REJECT 0x0324
  76. #define CC_SETUP_COMPL 0x0330
  77. #define CC_PROCEEDING 0x0340
  78. #define CC_ALERTING 0x0344
  79. #define CC_PROGRESS 0x0348
  80. #define CC_CONNECT 0x0350
  81. #define CC_CHARGE 0x0354
  82. #define CC_NOTIFY 0x0358
  83. #define CC_DISCONNECT 0x0360
  84. #define CC_RELEASE 0x0368
  85. #define CC_SUSPEND 0x0370
  86. #define CC_PROCEED_SEND 0x0374
  87. #define CC_REDIR 0x0378
  88. #define CC_T302 0x0382
  89. #define CC_T303 0x0383
  90. #define CC_T304 0x0384
  91. #define CC_T305 0x0385
  92. #define CC_T308_1 0x0388
  93. #define CC_T308_2 0x038A
  94. #define CC_T309 0x0309
  95. #define CC_T310 0x0390
  96. #define CC_T313 0x0393
  97. #define CC_T318 0x0398
  98. #define CC_T319 0x0399
  99. #define CC_TSPID 0x03A0
  100. #define CC_NOSETUP_RSP 0x03E0
  101. #define CC_SETUP_ERR 0x03E1
  102. #define CC_SUSPEND_ERR 0x03E2
  103. #define CC_RESUME_ERR 0x03E3
  104. #define CC_CONNECT_ERR 0x03E4
  105. #define CC_RELEASE_ERR 0x03E5
  106. #define CC_RESTART 0x03F4
  107. #define CC_TDSS1_IO 0x13F4 /* DSS1 IO user timer */
  108. #define CC_TNI1_IO 0x13F5 /* NI1 IO user timer */
  109. /* define maximum number of possible waiting incoming calls */
  110. #define MAX_WAITING_CALLS 2
  111. #ifdef __KERNEL__
  112. /* include l3dss1 & ni1 specific process structures, but no other defines */
  113. #ifdef CONFIG_HISAX_EURO
  114. #define l3dss1_process
  115. #include "l3dss1.h"
  116. #undef l3dss1_process
  117. #endif /* CONFIG_HISAX_EURO */
  118. #ifdef CONFIG_HISAX_NI1
  119. #define l3ni1_process
  120. #include "l3ni1.h"
  121. #undef l3ni1_process
  122. #endif /* CONFIG_HISAX_NI1 */
  123. #define MAX_DFRAME_LEN 260
  124. #define MAX_DFRAME_LEN_L1 300
  125. #define HSCX_BUFMAX 4096
  126. #define MAX_DATA_SIZE (HSCX_BUFMAX - 4)
  127. #define MAX_DATA_MEM (HSCX_BUFMAX + 64)
  128. #define RAW_BUFMAX (((HSCX_BUFMAX*6)/5) + 5)
  129. #define MAX_HEADER_LEN 4
  130. #define MAX_WINDOW 8
  131. #define MAX_MON_FRAME 32
  132. #define MAX_DLOG_SPACE 2048
  133. #define MAX_BLOG_SPACE 256
  134. /* #define I4L_IRQ_FLAG SA_INTERRUPT */
  135. #define I4L_IRQ_FLAG 0
  136. /*
  137. * Statemachine
  138. */
  139. struct FsmInst;
  140. typedef void (* FSMFNPTR)(struct FsmInst *, int, void *);
  141. struct Fsm {
  142. FSMFNPTR *jumpmatrix;
  143. int state_count, event_count;
  144. char **strEvent, **strState;
  145. };
  146. struct FsmInst {
  147. struct Fsm *fsm;
  148. int state;
  149. int debug;
  150. void *userdata;
  151. int userint;
  152. void (*printdebug) (struct FsmInst *, char *, ...);
  153. };
  154. struct FsmNode {
  155. int state, event;
  156. void (*routine) (struct FsmInst *, int, void *);
  157. };
  158. struct FsmTimer {
  159. struct FsmInst *fi;
  160. struct timer_list tl;
  161. int event;
  162. void *arg;
  163. };
  164. struct L3Timer {
  165. struct l3_process *pc;
  166. struct timer_list tl;
  167. int event;
  168. };
  169. #define FLG_L1_ACTIVATING 1
  170. #define FLG_L1_ACTIVATED 2
  171. #define FLG_L1_DEACTTIMER 3
  172. #define FLG_L1_ACTTIMER 4
  173. #define FLG_L1_T3RUN 5
  174. #define FLG_L1_PULL_REQ 6
  175. #define FLG_L1_UINT 7
  176. struct Layer1 {
  177. void *hardware;
  178. struct BCState *bcs;
  179. struct PStack **stlistp;
  180. unsigned long Flags;
  181. struct FsmInst l1m;
  182. struct FsmTimer timer;
  183. void (*l1l2) (struct PStack *, int, void *);
  184. void (*l1hw) (struct PStack *, int, void *);
  185. void (*l1tei) (struct PStack *, int, void *);
  186. int mode, bc;
  187. int delay;
  188. };
  189. #define GROUP_TEI 127
  190. #define TEI_SAPI 63
  191. #define CTRL_SAPI 0
  192. #define PACKET_NOACK 7
  193. /* Layer2 Flags */
  194. #define FLG_LAPB 0
  195. #define FLG_LAPD 1
  196. #define FLG_ORIG 2
  197. #define FLG_MOD128 3
  198. #define FLG_PEND_REL 4
  199. #define FLG_L3_INIT 5
  200. #define FLG_T200_RUN 6
  201. #define FLG_ACK_PEND 7
  202. #define FLG_REJEXC 8
  203. #define FLG_OWN_BUSY 9
  204. #define FLG_PEER_BUSY 10
  205. #define FLG_DCHAN_BUSY 11
  206. #define FLG_L1_ACTIV 12
  207. #define FLG_ESTAB_PEND 13
  208. #define FLG_PTP 14
  209. #define FLG_FIXED_TEI 15
  210. #define FLG_L2BLOCK 16
  211. struct Layer2 {
  212. int tei;
  213. int sap;
  214. int maxlen;
  215. u_long flag;
  216. spinlock_t lock;
  217. u_int vs, va, vr;
  218. int rc;
  219. unsigned int window;
  220. unsigned int sow;
  221. struct sk_buff *windowar[MAX_WINDOW];
  222. struct sk_buff_head i_queue;
  223. struct sk_buff_head ui_queue;
  224. void (*l2l1) (struct PStack *, int, void *);
  225. void (*l2l3) (struct PStack *, int, void *);
  226. void (*l2tei) (struct PStack *, int, void *);
  227. struct FsmInst l2m;
  228. struct FsmTimer t200, t203;
  229. int T200, N200, T203;
  230. int debug;
  231. char debug_id[16];
  232. };
  233. struct Layer3 {
  234. void (*l3l4) (struct PStack *, int, void *);
  235. void (*l3ml3) (struct PStack *, int, void *);
  236. void (*l3l2) (struct PStack *, int, void *);
  237. struct FsmInst l3m;
  238. struct FsmTimer l3m_timer;
  239. struct sk_buff_head squeue;
  240. struct l3_process *proc;
  241. struct l3_process *global;
  242. int N303;
  243. int debug;
  244. char debug_id[8];
  245. };
  246. struct LLInterface {
  247. void (*l4l3) (struct PStack *, int, void *);
  248. int (*l4l3_proto) (struct PStack *, isdn_ctrl *);
  249. void *userdata;
  250. u_long flag;
  251. };
  252. #define FLG_LLI_L1WAKEUP 1
  253. #define FLG_LLI_L2WAKEUP 2
  254. struct Management {
  255. int ri;
  256. struct FsmInst tei_m;
  257. struct FsmTimer t202;
  258. int T202, N202, debug;
  259. void (*layer) (struct PStack *, int, void *);
  260. };
  261. #define NO_CAUSE 254
  262. struct Param {
  263. u_char cause;
  264. u_char loc;
  265. u_char diag[6];
  266. int bchannel;
  267. int chargeinfo;
  268. int spv; /* SPV Flag */
  269. setup_parm setup; /* from isdnif.h numbers and Serviceindicator */
  270. u_char moderate; /* transfer mode and rate (bearer octet 4) */
  271. };
  272. struct PStack {
  273. struct PStack *next;
  274. struct Layer1 l1;
  275. struct Layer2 l2;
  276. struct Layer3 l3;
  277. struct LLInterface lli;
  278. struct Management ma;
  279. int protocol; /* EDSS1, 1TR6 or NI1 */
  280. /* protocol specific data fields */
  281. union
  282. { u_char uuuu; /* only as dummy */
  283. #ifdef CONFIG_HISAX_EURO
  284. dss1_stk_priv dss1; /* private dss1 data */
  285. #endif /* CONFIG_HISAX_EURO */
  286. #ifdef CONFIG_HISAX_NI1
  287. ni1_stk_priv ni1; /* private ni1 data */
  288. #endif /* CONFIG_HISAX_NI1 */
  289. } prot;
  290. };
  291. struct l3_process {
  292. int callref;
  293. int state;
  294. struct L3Timer timer;
  295. int N303;
  296. int debug;
  297. struct Param para;
  298. struct Channel *chan;
  299. struct PStack *st;
  300. struct l3_process *next;
  301. ulong redir_result;
  302. /* protocol specific data fields */
  303. union
  304. { u_char uuuu; /* only when euro not defined, avoiding empty union */
  305. #ifdef CONFIG_HISAX_EURO
  306. dss1_proc_priv dss1; /* private dss1 data */
  307. #endif /* CONFIG_HISAX_EURO */
  308. #ifdef CONFIG_HISAX_NI1
  309. ni1_proc_priv ni1; /* private ni1 data */
  310. #endif /* CONFIG_HISAX_NI1 */
  311. } prot;
  312. };
  313. struct hscx_hw {
  314. int hscx;
  315. int rcvidx;
  316. int count; /* Current skb sent count */
  317. u_char *rcvbuf; /* B-Channel receive Buffer */
  318. u_char tsaxr0;
  319. u_char tsaxr1;
  320. };
  321. struct w6692B_hw {
  322. int bchan;
  323. int rcvidx;
  324. int count; /* Current skb sent count */
  325. u_char *rcvbuf; /* B-Channel receive Buffer */
  326. };
  327. struct isar_reg {
  328. unsigned long Flags;
  329. volatile u_char bstat;
  330. volatile u_char iis;
  331. volatile u_char cmsb;
  332. volatile u_char clsb;
  333. volatile u_char par[8];
  334. };
  335. struct isar_hw {
  336. int dpath;
  337. int rcvidx;
  338. int txcnt;
  339. int mml;
  340. u_char state;
  341. u_char cmd;
  342. u_char mod;
  343. u_char newcmd;
  344. u_char newmod;
  345. char try_mod;
  346. struct timer_list ftimer;
  347. u_char *rcvbuf; /* B-Channel receive Buffer */
  348. u_char conmsg[16];
  349. struct isar_reg *reg;
  350. };
  351. struct hdlc_stat_reg {
  352. #ifdef __BIG_ENDIAN
  353. u_char fill;
  354. u_char mode;
  355. u_char xml;
  356. u_char cmd;
  357. #else
  358. u_char cmd;
  359. u_char xml;
  360. u_char mode;
  361. u_char fill;
  362. #endif
  363. } __attribute__((packed));
  364. struct hdlc_hw {
  365. union {
  366. u_int ctrl;
  367. struct hdlc_stat_reg sr;
  368. } ctrl;
  369. u_int stat;
  370. int rcvidx;
  371. int count; /* Current skb sent count */
  372. u_char *rcvbuf; /* B-Channel receive Buffer */
  373. };
  374. struct hfcB_hw {
  375. unsigned int *send;
  376. int f1;
  377. int f2;
  378. };
  379. struct tiger_hw {
  380. u_int *send;
  381. u_int *s_irq;
  382. u_int *s_end;
  383. u_int *sendp;
  384. u_int *rec;
  385. int free;
  386. u_char *rcvbuf;
  387. u_char *sendbuf;
  388. u_char *sp;
  389. int sendcnt;
  390. u_int s_tot;
  391. u_int r_bitcnt;
  392. u_int r_tot;
  393. u_int r_err;
  394. u_int r_fcs;
  395. u_char r_state;
  396. u_char r_one;
  397. u_char r_val;
  398. u_char s_state;
  399. };
  400. struct amd7930_hw {
  401. u_char *tx_buff;
  402. u_char *rv_buff;
  403. int rv_buff_in;
  404. int rv_buff_out;
  405. struct sk_buff *rv_skb;
  406. struct hdlc_state *hdlc_state;
  407. struct work_struct tq_rcv;
  408. struct work_struct tq_xmt;
  409. };
  410. #define BC_FLG_INIT 1
  411. #define BC_FLG_ACTIV 2
  412. #define BC_FLG_BUSY 3
  413. #define BC_FLG_NOFRAME 4
  414. #define BC_FLG_HALF 5
  415. #define BC_FLG_EMPTY 6
  416. #define BC_FLG_ORIG 7
  417. #define BC_FLG_DLEETX 8
  418. #define BC_FLG_LASTDLE 9
  419. #define BC_FLG_FIRST 10
  420. #define BC_FLG_LASTDATA 11
  421. #define BC_FLG_NMD_DATA 12
  422. #define BC_FLG_FTI_RUN 13
  423. #define BC_FLG_LL_OK 14
  424. #define BC_FLG_LL_CONN 15
  425. #define BC_FLG_FTI_FTS 16
  426. #define BC_FLG_FRH_WAIT 17
  427. #define L1_MODE_NULL 0
  428. #define L1_MODE_TRANS 1
  429. #define L1_MODE_HDLC 2
  430. #define L1_MODE_EXTRN 3
  431. #define L1_MODE_HDLC_56K 4
  432. #define L1_MODE_MODEM 7
  433. #define L1_MODE_V32 8
  434. #define L1_MODE_FAX 9
  435. struct BCState {
  436. int channel;
  437. int mode;
  438. u_long Flag;
  439. struct IsdnCardState *cs;
  440. int tx_cnt; /* B-Channel transmit counter */
  441. struct sk_buff *tx_skb; /* B-Channel transmit Buffer */
  442. struct sk_buff_head rqueue; /* B-Channel receive Queue */
  443. struct sk_buff_head squeue; /* B-Channel send Queue */
  444. int ackcnt;
  445. spinlock_t aclock;
  446. struct PStack *st;
  447. u_char *blog;
  448. u_char *conmsg;
  449. struct timer_list transbusy;
  450. struct work_struct tqueue;
  451. u_long event;
  452. int (*BC_SetStack) (struct PStack *, struct BCState *);
  453. void (*BC_Close) (struct BCState *);
  454. #ifdef ERROR_STATISTIC
  455. int err_crc;
  456. int err_tx;
  457. int err_rdo;
  458. int err_inv;
  459. #endif
  460. union {
  461. struct hscx_hw hscx;
  462. struct hdlc_hw hdlc;
  463. struct isar_hw isar;
  464. struct hfcB_hw hfc;
  465. struct tiger_hw tiger;
  466. struct amd7930_hw amd7930;
  467. struct w6692B_hw w6692;
  468. struct hisax_b_if *b_if;
  469. } hw;
  470. };
  471. struct Channel {
  472. struct PStack *b_st, *d_st;
  473. struct IsdnCardState *cs;
  474. struct BCState *bcs;
  475. int chan;
  476. int incoming;
  477. struct FsmInst fi;
  478. struct FsmTimer drel_timer, dial_timer;
  479. int debug;
  480. int l2_protocol, l2_active_protocol;
  481. int l3_protocol;
  482. int data_open;
  483. struct l3_process *proc;
  484. setup_parm setup; /* from isdnif.h numbers and Serviceindicator */
  485. u_long Flags; /* for remembering action done in l4 */
  486. int leased;
  487. };
  488. struct elsa_hw {
  489. struct pci_dev *dev;
  490. unsigned long base;
  491. unsigned int cfg;
  492. unsigned int ctrl;
  493. unsigned int ale;
  494. unsigned int isac;
  495. unsigned int itac;
  496. unsigned int hscx;
  497. unsigned int trig;
  498. unsigned int timer;
  499. unsigned int counter;
  500. unsigned int status;
  501. struct timer_list tl;
  502. unsigned int MFlag;
  503. struct BCState *bcs;
  504. u_char *transbuf;
  505. u_char *rcvbuf;
  506. unsigned int transp;
  507. unsigned int rcvp;
  508. unsigned int transcnt;
  509. unsigned int rcvcnt;
  510. u_char IER;
  511. u_char FCR;
  512. u_char LCR;
  513. u_char MCR;
  514. u_char ctrl_reg;
  515. };
  516. struct teles3_hw {
  517. unsigned int cfg_reg;
  518. signed int isac;
  519. signed int hscx[2];
  520. signed int isacfifo;
  521. signed int hscxfifo[2];
  522. };
  523. struct teles0_hw {
  524. unsigned int cfg_reg;
  525. void __iomem *membase;
  526. unsigned long phymem;
  527. };
  528. struct avm_hw {
  529. unsigned int cfg_reg;
  530. unsigned int isac;
  531. unsigned int hscx[2];
  532. unsigned int isacfifo;
  533. unsigned int hscxfifo[2];
  534. unsigned int counter;
  535. struct pci_dev *dev;
  536. };
  537. struct ix1_hw {
  538. unsigned int cfg_reg;
  539. unsigned int isac_ale;
  540. unsigned int isac;
  541. unsigned int hscx_ale;
  542. unsigned int hscx;
  543. };
  544. struct diva_hw {
  545. unsigned long cfg_reg;
  546. unsigned long pci_cfg;
  547. unsigned int ctrl;
  548. unsigned long isac_adr;
  549. unsigned int isac;
  550. unsigned long hscx_adr;
  551. unsigned int hscx;
  552. unsigned int status;
  553. struct timer_list tl;
  554. u_char ctrl_reg;
  555. struct pci_dev *dev;
  556. };
  557. struct asus_hw {
  558. unsigned int cfg_reg;
  559. unsigned int adr;
  560. unsigned int isac;
  561. unsigned int hscx;
  562. unsigned int u7;
  563. unsigned int pots;
  564. };
  565. struct hfc_hw {
  566. unsigned int addr;
  567. unsigned int fifosize;
  568. unsigned char cirm;
  569. unsigned char ctmt;
  570. unsigned char cip;
  571. u_char isac_spcr;
  572. struct timer_list timer;
  573. };
  574. struct sedl_hw {
  575. unsigned int cfg_reg;
  576. unsigned int adr;
  577. unsigned int isac;
  578. unsigned int hscx;
  579. unsigned int reset_on;
  580. unsigned int reset_off;
  581. struct isar_reg isar;
  582. unsigned int chip;
  583. unsigned int bus;
  584. struct pci_dev *dev;
  585. };
  586. struct spt_hw {
  587. unsigned int cfg_reg;
  588. unsigned int isac;
  589. unsigned int hscx[2];
  590. unsigned char res_irq;
  591. };
  592. struct mic_hw {
  593. unsigned int cfg_reg;
  594. unsigned int adr;
  595. unsigned int isac;
  596. unsigned int hscx;
  597. };
  598. struct njet_hw {
  599. unsigned long base;
  600. unsigned int isac;
  601. unsigned int auxa;
  602. unsigned char auxd;
  603. unsigned char dmactrl;
  604. unsigned char ctrl_reg;
  605. unsigned char irqmask0;
  606. unsigned char irqstat0;
  607. unsigned char last_is0;
  608. struct pci_dev *dev;
  609. };
  610. struct hfcPCI_hw {
  611. unsigned char cirm;
  612. unsigned char ctmt;
  613. unsigned char conn;
  614. unsigned char mst_m;
  615. unsigned char int_m1;
  616. unsigned char int_m2;
  617. unsigned char int_s1;
  618. unsigned char sctrl;
  619. unsigned char sctrl_r;
  620. unsigned char sctrl_e;
  621. unsigned char trm;
  622. unsigned char stat;
  623. unsigned char fifo;
  624. unsigned char fifo_en;
  625. unsigned char bswapped;
  626. unsigned char nt_mode;
  627. int nt_timer;
  628. struct pci_dev *dev;
  629. unsigned char *pci_io; /* start of PCI IO memory */
  630. void *share_start; /* shared memory for Fifos start */
  631. void *fifos; /* FIFO memory */
  632. int last_bfifo_cnt[2]; /* marker saving last b-fifo frame count */
  633. struct timer_list timer;
  634. };
  635. struct hfcSX_hw {
  636. unsigned long base;
  637. unsigned char cirm;
  638. unsigned char ctmt;
  639. unsigned char conn;
  640. unsigned char mst_m;
  641. unsigned char int_m1;
  642. unsigned char int_m2;
  643. unsigned char int_s1;
  644. unsigned char sctrl;
  645. unsigned char sctrl_r;
  646. unsigned char sctrl_e;
  647. unsigned char trm;
  648. unsigned char stat;
  649. unsigned char fifo;
  650. unsigned char bswapped;
  651. unsigned char nt_mode;
  652. unsigned char chip;
  653. int b_fifo_size;
  654. unsigned char last_fifo;
  655. void *extra;
  656. int nt_timer;
  657. struct timer_list timer;
  658. };
  659. struct hfcD_hw {
  660. unsigned int addr;
  661. unsigned int bfifosize;
  662. unsigned int dfifosize;
  663. unsigned char cirm;
  664. unsigned char ctmt;
  665. unsigned char cip;
  666. unsigned char conn;
  667. unsigned char mst_m;
  668. unsigned char int_m1;
  669. unsigned char int_m2;
  670. unsigned char int_s1;
  671. unsigned char sctrl;
  672. unsigned char stat;
  673. unsigned char fifo;
  674. unsigned char f1;
  675. unsigned char f2;
  676. unsigned int *send;
  677. struct timer_list timer;
  678. };
  679. struct isurf_hw {
  680. unsigned int reset;
  681. unsigned long phymem;
  682. void __iomem *isac;
  683. void __iomem *isar;
  684. struct isar_reg isar_r;
  685. };
  686. struct saphir_hw {
  687. struct pci_dev *dev;
  688. unsigned int cfg_reg;
  689. unsigned int ale;
  690. unsigned int isac;
  691. unsigned int hscx;
  692. struct timer_list timer;
  693. };
  694. struct bkm_hw {
  695. struct pci_dev *dev;
  696. unsigned long base;
  697. /* A4T stuff */
  698. unsigned long isac_adr;
  699. unsigned int isac_ale;
  700. unsigned long jade_adr;
  701. unsigned int jade_ale;
  702. /* Scitel Quadro stuff */
  703. unsigned long plx_adr;
  704. unsigned long data_adr;
  705. };
  706. struct gazel_hw {
  707. struct pci_dev *dev;
  708. unsigned int cfg_reg;
  709. unsigned int pciaddr[2];
  710. signed int ipac;
  711. signed int isac;
  712. signed int hscx[2];
  713. signed int isacfifo;
  714. signed int hscxfifo[2];
  715. unsigned char timeslot;
  716. unsigned char iom2;
  717. };
  718. struct w6692_hw {
  719. struct pci_dev *dev;
  720. unsigned int iobase;
  721. struct timer_list timer;
  722. };
  723. struct arcofi_msg {
  724. struct arcofi_msg *next;
  725. u_char receive;
  726. u_char len;
  727. u_char msg[10];
  728. };
  729. struct isac_chip {
  730. int ph_state;
  731. u_char *mon_tx;
  732. u_char *mon_rx;
  733. int mon_txp;
  734. int mon_txc;
  735. int mon_rxp;
  736. struct arcofi_msg *arcofi_list;
  737. struct timer_list arcofitimer;
  738. wait_queue_head_t arcofi_wait;
  739. u_char arcofi_bc;
  740. u_char arcofi_state;
  741. u_char mocr;
  742. u_char adf2;
  743. };
  744. struct hfcd_chip {
  745. int ph_state;
  746. };
  747. struct hfcpci_chip {
  748. int ph_state;
  749. };
  750. struct hfcsx_chip {
  751. int ph_state;
  752. };
  753. struct w6692_chip {
  754. int ph_state;
  755. };
  756. struct amd7930_chip {
  757. u_char lmr1;
  758. u_char ph_state;
  759. u_char old_state;
  760. u_char flg_t3;
  761. unsigned int tx_xmtlen;
  762. struct timer_list timer3;
  763. void (*ph_command) (struct IsdnCardState *, u_char, char *);
  764. void (*setIrqMask) (struct IsdnCardState *, u_char);
  765. };
  766. struct icc_chip {
  767. int ph_state;
  768. u_char *mon_tx;
  769. u_char *mon_rx;
  770. int mon_txp;
  771. int mon_txc;
  772. int mon_rxp;
  773. struct arcofi_msg *arcofi_list;
  774. struct timer_list arcofitimer;
  775. wait_queue_head_t arcofi_wait;
  776. u_char arcofi_bc;
  777. u_char arcofi_state;
  778. u_char mocr;
  779. u_char adf2;
  780. };
  781. #define HW_IOM1 0
  782. #define HW_IPAC 1
  783. #define HW_ISAR 2
  784. #define HW_ARCOFI 3
  785. #define FLG_TWO_DCHAN 4
  786. #define FLG_L1_DBUSY 5
  787. #define FLG_DBUSY_TIMER 6
  788. #define FLG_LOCK_ATOMIC 7
  789. #define FLG_ARCOFI_TIMER 8
  790. #define FLG_ARCOFI_ERROR 9
  791. #define FLG_HW_L1_UINT 10
  792. struct IsdnCardState {
  793. spinlock_t lock;
  794. u_char typ;
  795. u_char subtyp;
  796. int protocol;
  797. u_int irq;
  798. u_long irq_flags;
  799. u_long HW_Flags;
  800. int *busy_flag;
  801. int chanlimit; /* limited number of B-chans to use */
  802. int logecho; /* log echo if supported by card */
  803. union {
  804. struct elsa_hw elsa;
  805. struct teles0_hw teles0;
  806. struct teles3_hw teles3;
  807. struct avm_hw avm;
  808. struct ix1_hw ix1;
  809. struct diva_hw diva;
  810. struct asus_hw asus;
  811. struct hfc_hw hfc;
  812. struct sedl_hw sedl;
  813. struct spt_hw spt;
  814. struct mic_hw mic;
  815. struct njet_hw njet;
  816. struct hfcD_hw hfcD;
  817. struct hfcPCI_hw hfcpci;
  818. struct hfcSX_hw hfcsx;
  819. struct ix1_hw niccy;
  820. struct isurf_hw isurf;
  821. struct saphir_hw saphir;
  822. struct bkm_hw ax;
  823. struct gazel_hw gazel;
  824. struct w6692_hw w6692;
  825. struct hisax_d_if *hisax_d_if;
  826. } hw;
  827. int myid;
  828. isdn_if iif;
  829. spinlock_t statlock;
  830. u_char *status_buf;
  831. u_char *status_read;
  832. u_char *status_write;
  833. u_char *status_end;
  834. u_char (*readisac) (struct IsdnCardState *, u_char);
  835. void (*writeisac) (struct IsdnCardState *, u_char, u_char);
  836. void (*readisacfifo) (struct IsdnCardState *, u_char *, int);
  837. void (*writeisacfifo) (struct IsdnCardState *, u_char *, int);
  838. u_char (*BC_Read_Reg) (struct IsdnCardState *, int, u_char);
  839. void (*BC_Write_Reg) (struct IsdnCardState *, int, u_char, u_char);
  840. void (*BC_Send_Data) (struct BCState *);
  841. int (*cardmsg) (struct IsdnCardState *, int, void *);
  842. void (*setstack_d) (struct PStack *, struct IsdnCardState *);
  843. void (*DC_Close) (struct IsdnCardState *);
  844. irq_handler_t irq_func;
  845. int (*auxcmd) (struct IsdnCardState *, isdn_ctrl *);
  846. struct Channel channel[2+MAX_WAITING_CALLS];
  847. struct BCState bcs[2+MAX_WAITING_CALLS];
  848. struct PStack *stlist;
  849. struct sk_buff_head rq, sq; /* D-channel queues */
  850. int cardnr;
  851. char *dlog;
  852. int debug;
  853. union {
  854. struct isac_chip isac;
  855. struct hfcd_chip hfcd;
  856. struct hfcpci_chip hfcpci;
  857. struct hfcsx_chip hfcsx;
  858. struct w6692_chip w6692;
  859. struct amd7930_chip amd7930;
  860. struct icc_chip icc;
  861. } dc;
  862. u_char *rcvbuf;
  863. int rcvidx;
  864. struct sk_buff *tx_skb;
  865. int tx_cnt;
  866. u_long event;
  867. struct work_struct tqueue;
  868. struct timer_list dbusytimer;
  869. #ifdef ERROR_STATISTIC
  870. int err_crc;
  871. int err_tx;
  872. int err_rx;
  873. #endif
  874. };
  875. #define schedule_event(s, ev) do {test_and_set_bit(ev, &s->event);schedule_work(&s->tqueue); } while(0)
  876. #define MON0_RX 1
  877. #define MON1_RX 2
  878. #define MON0_TX 4
  879. #define MON1_TX 8
  880. #ifdef ISDN_CHIP_ISAC
  881. #undef ISDN_CHIP_ISAC
  882. #endif
  883. #ifdef CONFIG_HISAX_16_0
  884. #define CARD_TELES0 1
  885. #ifndef ISDN_CHIP_ISAC
  886. #define ISDN_CHIP_ISAC 1
  887. #endif
  888. #else
  889. #define CARD_TELES0 0
  890. #endif
  891. #ifdef CONFIG_HISAX_16_3
  892. #define CARD_TELES3 1
  893. #ifndef ISDN_CHIP_ISAC
  894. #define ISDN_CHIP_ISAC 1
  895. #endif
  896. #else
  897. #define CARD_TELES3 0
  898. #endif
  899. #ifdef CONFIG_HISAX_TELESPCI
  900. #define CARD_TELESPCI 1
  901. #ifndef ISDN_CHIP_ISAC
  902. #define ISDN_CHIP_ISAC 1
  903. #endif
  904. #else
  905. #define CARD_TELESPCI 0
  906. #endif
  907. #ifdef CONFIG_HISAX_AVM_A1
  908. #define CARD_AVM_A1 1
  909. #ifndef ISDN_CHIP_ISAC
  910. #define ISDN_CHIP_ISAC 1
  911. #endif
  912. #else
  913. #define CARD_AVM_A1 0
  914. #endif
  915. #ifdef CONFIG_HISAX_AVM_A1_PCMCIA
  916. #define CARD_AVM_A1_PCMCIA 1
  917. #ifndef ISDN_CHIP_ISAC
  918. #define ISDN_CHIP_ISAC 1
  919. #endif
  920. #else
  921. #define CARD_AVM_A1_PCMCIA 0
  922. #endif
  923. #ifdef CONFIG_HISAX_FRITZPCI
  924. #define CARD_FRITZPCI 1
  925. #ifndef ISDN_CHIP_ISAC
  926. #define ISDN_CHIP_ISAC 1
  927. #endif
  928. #else
  929. #define CARD_FRITZPCI 0
  930. #endif
  931. #ifdef CONFIG_HISAX_ELSA
  932. #define CARD_ELSA 1
  933. #ifndef ISDN_CHIP_ISAC
  934. #define ISDN_CHIP_ISAC 1
  935. #endif
  936. #else
  937. #define CARD_ELSA 0
  938. #endif
  939. #ifdef CONFIG_HISAX_IX1MICROR2
  940. #define CARD_IX1MICROR2 1
  941. #ifndef ISDN_CHIP_ISAC
  942. #define ISDN_CHIP_ISAC 1
  943. #endif
  944. #else
  945. #define CARD_IX1MICROR2 0
  946. #endif
  947. #ifdef CONFIG_HISAX_DIEHLDIVA
  948. #define CARD_DIEHLDIVA 1
  949. #ifndef ISDN_CHIP_ISAC
  950. #define ISDN_CHIP_ISAC 1
  951. #endif
  952. #else
  953. #define CARD_DIEHLDIVA 0
  954. #endif
  955. #ifdef CONFIG_HISAX_ASUSCOM
  956. #define CARD_ASUSCOM 1
  957. #ifndef ISDN_CHIP_ISAC
  958. #define ISDN_CHIP_ISAC 1
  959. #endif
  960. #else
  961. #define CARD_ASUSCOM 0
  962. #endif
  963. #ifdef CONFIG_HISAX_TELEINT
  964. #define CARD_TELEINT 1
  965. #ifndef ISDN_CHIP_ISAC
  966. #define ISDN_CHIP_ISAC 1
  967. #endif
  968. #else
  969. #define CARD_TELEINT 0
  970. #endif
  971. #ifdef CONFIG_HISAX_SEDLBAUER
  972. #define CARD_SEDLBAUER 1
  973. #ifndef ISDN_CHIP_ISAC
  974. #define ISDN_CHIP_ISAC 1
  975. #endif
  976. #else
  977. #define CARD_SEDLBAUER 0
  978. #endif
  979. #ifdef CONFIG_HISAX_SPORTSTER
  980. #define CARD_SPORTSTER 1
  981. #ifndef ISDN_CHIP_ISAC
  982. #define ISDN_CHIP_ISAC 1
  983. #endif
  984. #else
  985. #define CARD_SPORTSTER 0
  986. #endif
  987. #ifdef CONFIG_HISAX_MIC
  988. #define CARD_MIC 1
  989. #ifndef ISDN_CHIP_ISAC
  990. #define ISDN_CHIP_ISAC 1
  991. #endif
  992. #else
  993. #define CARD_MIC 0
  994. #endif
  995. #ifdef CONFIG_HISAX_NETJET
  996. #define CARD_NETJET_S 1
  997. #ifndef ISDN_CHIP_ISAC
  998. #define ISDN_CHIP_ISAC 1
  999. #endif
  1000. #else
  1001. #define CARD_NETJET_S 0
  1002. #endif
  1003. #ifdef CONFIG_HISAX_HFCS
  1004. #define CARD_HFCS 1
  1005. #else
  1006. #define CARD_HFCS 0
  1007. #endif
  1008. #ifdef CONFIG_HISAX_HFC_PCI
  1009. #define CARD_HFC_PCI 1
  1010. #else
  1011. #define CARD_HFC_PCI 0
  1012. #endif
  1013. #ifdef CONFIG_HISAX_HFC_SX
  1014. #define CARD_HFC_SX 1
  1015. #else
  1016. #define CARD_HFC_SX 0
  1017. #endif
  1018. #ifdef CONFIG_HISAX_NICCY
  1019. #define CARD_NICCY 1
  1020. #ifndef ISDN_CHIP_ISAC
  1021. #define ISDN_CHIP_ISAC 1
  1022. #endif
  1023. #else
  1024. #define CARD_NICCY 0
  1025. #endif
  1026. #ifdef CONFIG_HISAX_ISURF
  1027. #define CARD_ISURF 1
  1028. #ifndef ISDN_CHIP_ISAC
  1029. #define ISDN_CHIP_ISAC 1
  1030. #endif
  1031. #else
  1032. #define CARD_ISURF 0
  1033. #endif
  1034. #ifdef CONFIG_HISAX_S0BOX
  1035. #define CARD_S0BOX 1
  1036. #ifndef ISDN_CHIP_ISAC
  1037. #define ISDN_CHIP_ISAC 1
  1038. #endif
  1039. #else
  1040. #define CARD_S0BOX 0
  1041. #endif
  1042. #ifdef CONFIG_HISAX_HSTSAPHIR
  1043. #define CARD_HSTSAPHIR 1
  1044. #ifndef ISDN_CHIP_ISAC
  1045. #define ISDN_CHIP_ISAC 1
  1046. #endif
  1047. #else
  1048. #define CARD_HSTSAPHIR 0
  1049. #endif
  1050. #ifdef CONFIG_HISAX_BKM_A4T
  1051. #define CARD_BKM_A4T 1
  1052. #ifndef ISDN_CHIP_ISAC
  1053. #define ISDN_CHIP_ISAC 1
  1054. #endif
  1055. #else
  1056. #define CARD_BKM_A4T 0
  1057. #endif
  1058. #ifdef CONFIG_HISAX_SCT_QUADRO
  1059. #define CARD_SCT_QUADRO 1
  1060. #ifndef ISDN_CHIP_ISAC
  1061. #define ISDN_CHIP_ISAC 1
  1062. #endif
  1063. #else
  1064. #define CARD_SCT_QUADRO 0
  1065. #endif
  1066. #ifdef CONFIG_HISAX_GAZEL
  1067. #define CARD_GAZEL 1
  1068. #ifndef ISDN_CHIP_ISAC
  1069. #define ISDN_CHIP_ISAC 1
  1070. #endif
  1071. #else
  1072. #define CARD_GAZEL 0
  1073. #endif
  1074. #ifdef CONFIG_HISAX_W6692
  1075. #define CARD_W6692 1
  1076. #ifndef ISDN_CHIP_W6692
  1077. #define ISDN_CHIP_W6692 1
  1078. #endif
  1079. #else
  1080. #define CARD_W6692 0
  1081. #endif
  1082. #ifdef CONFIG_HISAX_NETJET_U
  1083. #define CARD_NETJET_U 1
  1084. #ifndef ISDN_CHIP_ICC
  1085. #define ISDN_CHIP_ICC 1
  1086. #endif
  1087. #ifndef HISAX_UINTERFACE
  1088. #define HISAX_UINTERFACE 1
  1089. #endif
  1090. #else
  1091. #define CARD_NETJET_U 0
  1092. #endif
  1093. #ifdef CONFIG_HISAX_ENTERNOW_PCI
  1094. #define CARD_FN_ENTERNOW_PCI 1
  1095. #else
  1096. #define CARD_FN_ENTERNOW_PCI 0
  1097. #endif
  1098. #define TEI_PER_CARD 1
  1099. /* L1 Debug */
  1100. #define L1_DEB_WARN 0x01
  1101. #define L1_DEB_INTSTAT 0x02
  1102. #define L1_DEB_ISAC 0x04
  1103. #define L1_DEB_ISAC_FIFO 0x08
  1104. #define L1_DEB_HSCX 0x10
  1105. #define L1_DEB_HSCX_FIFO 0x20
  1106. #define L1_DEB_LAPD 0x40
  1107. #define L1_DEB_IPAC 0x80
  1108. #define L1_DEB_RECEIVE_FRAME 0x100
  1109. #define L1_DEB_MONITOR 0x200
  1110. #define DEB_DLOG_HEX 0x400
  1111. #define DEB_DLOG_VERBOSE 0x800
  1112. #define L2FRAME_DEBUG
  1113. #ifdef L2FRAME_DEBUG
  1114. extern void Logl2Frame(struct IsdnCardState *cs, struct sk_buff *skb, char *buf, int dir);
  1115. #endif
  1116. #include "hisax_cfg.h"
  1117. void init_bcstate(struct IsdnCardState *cs, int bc);
  1118. void setstack_HiSax(struct PStack *st, struct IsdnCardState *cs);
  1119. void HiSax_addlist(struct IsdnCardState *sp, struct PStack *st);
  1120. void HiSax_rmlist(struct IsdnCardState *sp, struct PStack *st);
  1121. void setstack_l1_B(struct PStack *st);
  1122. void setstack_tei(struct PStack *st);
  1123. void setstack_manager(struct PStack *st);
  1124. void setstack_isdnl2(struct PStack *st, char *debug_id);
  1125. void releasestack_isdnl2(struct PStack *st);
  1126. void setstack_transl2(struct PStack *st);
  1127. void releasestack_transl2(struct PStack *st);
  1128. void lli_writewakeup(struct PStack *st, int len);
  1129. void setstack_l3dc(struct PStack *st, struct Channel *chanp);
  1130. void setstack_l3bc(struct PStack *st, struct Channel *chanp);
  1131. void releasestack_isdnl3(struct PStack *st);
  1132. u_char *findie(u_char * p, int size, u_char ie, int wanted_set);
  1133. int getcallref(u_char * p);
  1134. int newcallref(void);
  1135. int FsmNew(struct Fsm *fsm, struct FsmNode *fnlist, int fncount);
  1136. void FsmFree(struct Fsm *fsm);
  1137. int FsmEvent(struct FsmInst *fi, int event, void *arg);
  1138. void FsmChangeState(struct FsmInst *fi, int newstate);
  1139. void FsmInitTimer(struct FsmInst *fi, struct FsmTimer *ft);
  1140. int FsmAddTimer(struct FsmTimer *ft, int millisec, int event,
  1141. void *arg, int where);
  1142. void FsmRestartTimer(struct FsmTimer *ft, int millisec, int event,
  1143. void *arg, int where);
  1144. void FsmDelTimer(struct FsmTimer *ft, int where);
  1145. int jiftime(char *s, long mark);
  1146. int HiSax_command(isdn_ctrl * ic);
  1147. int HiSax_writebuf_skb(int id, int chan, int ack, struct sk_buff *skb);
  1148. void HiSax_putstatus(struct IsdnCardState *cs, char *head, char *fmt, ...);
  1149. void VHiSax_putstatus(struct IsdnCardState *cs, char *head, char *fmt, va_list args);
  1150. void HiSax_reportcard(int cardnr, int sel);
  1151. int QuickHex(char *txt, u_char * p, int cnt);
  1152. void LogFrame(struct IsdnCardState *cs, u_char * p, int size);
  1153. void dlogframe(struct IsdnCardState *cs, struct sk_buff *skb, int dir);
  1154. void iecpy(u_char * dest, u_char * iestart, int ieoffset);
  1155. #endif /* __KERNEL__ */
  1156. /*
  1157. * Busywait delay for `jiffs' jiffies
  1158. */
  1159. #define HZDELAY(jiffs) do { \
  1160. int tout = jiffs; \
  1161. \
  1162. while (tout--) { \
  1163. int loops = USEC_PER_SEC / HZ; \
  1164. while (loops--) \
  1165. udelay(1); \
  1166. } \
  1167. } while (0)
  1168. int ll_run(struct IsdnCardState *cs, int addfeatures);
  1169. int CallcNew(void);
  1170. void CallcFree(void);
  1171. int CallcNewChan(struct IsdnCardState *cs);
  1172. void CallcFreeChan(struct IsdnCardState *cs);
  1173. int Isdnl1New(void);
  1174. void Isdnl1Free(void);
  1175. int Isdnl2New(void);
  1176. void Isdnl2Free(void);
  1177. int Isdnl3New(void);
  1178. void Isdnl3Free(void);
  1179. void init_tei(struct IsdnCardState *cs, int protocol);
  1180. void release_tei(struct IsdnCardState *cs);
  1181. char *HiSax_getrev(const char *revision);
  1182. int TeiNew(void);
  1183. void TeiFree(void);