config.c 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959
  1. /* $Id: config.c,v 2.84.2.5 2004/02/11 13:21:33 keil Exp $
  2. *
  3. * Author Karsten Keil
  4. * Copyright by Karsten Keil <keil@isdn4linux.de>
  5. * by Kai Germaschewski <kai.germaschewski@gmx.de>
  6. *
  7. * This software may be used and distributed according to the terms
  8. * of the GNU General Public License, incorporated herein by reference.
  9. *
  10. * For changes and modifications please read
  11. * Documentation/isdn/HiSax.cert
  12. *
  13. * based on the teles driver from Jan den Ouden
  14. *
  15. */
  16. #include <linux/types.h>
  17. #include <linux/stddef.h>
  18. #include <linux/timer.h>
  19. #include <linux/config.h>
  20. #include <linux/init.h>
  21. #include "hisax.h"
  22. #include <linux/module.h>
  23. #include <linux/kernel_stat.h>
  24. #include <linux/workqueue.h>
  25. #include <linux/interrupt.h>
  26. #define HISAX_STATUS_BUFSIZE 4096
  27. /*
  28. * This structure array contains one entry per card. An entry looks
  29. * like this:
  30. *
  31. * { type, protocol, p0, p1, p2, NULL }
  32. *
  33. * type
  34. * 1 Teles 16.0 p0=irq p1=membase p2=iobase
  35. * 2 Teles 8.0 p0=irq p1=membase
  36. * 3 Teles 16.3 p0=irq p1=iobase
  37. * 4 Creatix PNP p0=irq p1=IO0 (ISAC) p2=IO1 (HSCX)
  38. * 5 AVM A1 (Fritz) p0=irq p1=iobase
  39. * 6 ELSA PC [p0=iobase] or nothing (autodetect)
  40. * 7 ELSA Quickstep p0=irq p1=iobase
  41. * 8 Teles PCMCIA p0=irq p1=iobase
  42. * 9 ITK ix1-micro p0=irq p1=iobase
  43. * 10 ELSA PCMCIA p0=irq p1=iobase
  44. * 11 Eicon.Diehl Diva p0=irq p1=iobase
  45. * 12 Asuscom ISDNLink p0=irq p1=iobase
  46. * 13 Teleint p0=irq p1=iobase
  47. * 14 Teles 16.3c p0=irq p1=iobase
  48. * 15 Sedlbauer speed p0=irq p1=iobase
  49. * 15 Sedlbauer PC/104 p0=irq p1=iobase
  50. * 15 Sedlbauer speed pci no parameter
  51. * 16 USR Sportster internal p0=irq p1=iobase
  52. * 17 MIC card p0=irq p1=iobase
  53. * 18 ELSA Quickstep 1000PCI no parameter
  54. * 19 Compaq ISDN S0 ISA card p0=irq p1=IO0 (HSCX) p2=IO1 (ISAC) p3=IO2
  55. * 20 Travers Technologies NETjet-S PCI card
  56. * 21 TELES PCI no parameter
  57. * 22 Sedlbauer Speed Star p0=irq p1=iobase
  58. * 23 reserved
  59. * 24 Dr Neuhaus Niccy PnP/PCI card p0=irq p1=IO0 p2=IO1 (PnP only)
  60. * 25 Teles S0Box p0=irq p1=iobase (from isapnp setup)
  61. * 26 AVM A1 PCMCIA (Fritz) p0=irq p1=iobase
  62. * 27 AVM PnP/PCI p0=irq p1=iobase (PCI no parameter)
  63. * 28 Sedlbauer Speed Fax+ p0=irq p1=iobase (from isapnp setup)
  64. * 29 Siemens I-Surf p0=irq p1=iobase p2=memory (from isapnp setup)
  65. * 30 ACER P10 p0=irq p1=iobase (from isapnp setup)
  66. * 31 HST Saphir p0=irq p1=iobase
  67. * 32 Telekom A4T none
  68. * 33 Scitel Quadro p0=subcontroller (4*S0, subctrl 1...4)
  69. * 34 Gazel ISDN cards
  70. * 35 HFC 2BDS0 PCI none
  71. * 36 Winbond 6692 PCI none
  72. * 37 HFC 2BDS0 S+/SP p0=irq p1=iobase
  73. * 38 Travers Technologies NETspider-U PCI card
  74. * 39 HFC 2BDS0-SP PCMCIA p0=irq p1=iobase
  75. * 40 hotplug interface
  76. * 41 Formula-n enter:now ISDN PCI a/b none
  77. *
  78. * protocol can be either ISDN_PTYPE_EURO or ISDN_PTYPE_1TR6 or ISDN_PTYPE_NI1
  79. *
  80. *
  81. */
  82. const char *CardType[] = {
  83. "No Card", "Teles 16.0", "Teles 8.0", "Teles 16.3",
  84. "Creatix/Teles PnP", "AVM A1", "Elsa ML", "Elsa Quickstep",
  85. "Teles PCMCIA", "ITK ix1-micro Rev.2", "Elsa PCMCIA",
  86. "Eicon.Diehl Diva", "ISDNLink", "TeleInt", "Teles 16.3c",
  87. "Sedlbauer Speed Card", "USR Sportster", "ith mic Linux",
  88. "Elsa PCI", "Compaq ISA", "NETjet-S", "Teles PCI",
  89. "Sedlbauer Speed Star (PCMCIA)", "AMD 7930", "NICCY", "S0Box",
  90. "AVM A1 (PCMCIA)", "AVM Fritz PnP/PCI", "Sedlbauer Speed Fax +",
  91. "Siemens I-Surf", "Acer P10", "HST Saphir", "Telekom A4T",
  92. "Scitel Quadro", "Gazel", "HFC 2BDS0 PCI", "Winbond 6692",
  93. "HFC 2BDS0 SX", "NETspider-U", "HFC-2BDS0-SP PCMCIA",
  94. "Hotplug", "Formula-n enter:now PCI a/b",
  95. };
  96. #ifdef CONFIG_HISAX_ELSA
  97. #define DEFAULT_CARD ISDN_CTYPE_ELSA
  98. #define DEFAULT_CFG {0,0,0,0}
  99. #endif
  100. #ifdef CONFIG_HISAX_AVM_A1
  101. #undef DEFAULT_CARD
  102. #undef DEFAULT_CFG
  103. #define DEFAULT_CARD ISDN_CTYPE_A1
  104. #define DEFAULT_CFG {10,0x340,0,0}
  105. #endif
  106. #ifdef CONFIG_HISAX_AVM_A1_PCMCIA
  107. #undef DEFAULT_CARD
  108. #undef DEFAULT_CFG
  109. #define DEFAULT_CARD ISDN_CTYPE_A1_PCMCIA
  110. #define DEFAULT_CFG {11,0x170,0,0}
  111. #endif
  112. #ifdef CONFIG_HISAX_FRITZPCI
  113. #undef DEFAULT_CARD
  114. #undef DEFAULT_CFG
  115. #define DEFAULT_CARD ISDN_CTYPE_FRITZPCI
  116. #define DEFAULT_CFG {0,0,0,0}
  117. #endif
  118. #ifdef CONFIG_HISAX_16_3
  119. #undef DEFAULT_CARD
  120. #undef DEFAULT_CFG
  121. #define DEFAULT_CARD ISDN_CTYPE_16_3
  122. #define DEFAULT_CFG {15,0x180,0,0}
  123. #endif
  124. #ifdef CONFIG_HISAX_S0BOX
  125. #undef DEFAULT_CARD
  126. #undef DEFAULT_CFG
  127. #define DEFAULT_CARD ISDN_CTYPE_S0BOX
  128. #define DEFAULT_CFG {7,0x378,0,0}
  129. #endif
  130. #ifdef CONFIG_HISAX_16_0
  131. #undef DEFAULT_CARD
  132. #undef DEFAULT_CFG
  133. #define DEFAULT_CARD ISDN_CTYPE_16_0
  134. #define DEFAULT_CFG {15,0xd0000,0xd80,0}
  135. #endif
  136. #ifdef CONFIG_HISAX_TELESPCI
  137. #undef DEFAULT_CARD
  138. #undef DEFAULT_CFG
  139. #define DEFAULT_CARD ISDN_CTYPE_TELESPCI
  140. #define DEFAULT_CFG {0,0,0,0}
  141. #endif
  142. #ifdef CONFIG_HISAX_IX1MICROR2
  143. #undef DEFAULT_CARD
  144. #undef DEFAULT_CFG
  145. #define DEFAULT_CARD ISDN_CTYPE_IX1MICROR2
  146. #define DEFAULT_CFG {5,0x390,0,0}
  147. #endif
  148. #ifdef CONFIG_HISAX_DIEHLDIVA
  149. #undef DEFAULT_CARD
  150. #undef DEFAULT_CFG
  151. #define DEFAULT_CARD ISDN_CTYPE_DIEHLDIVA
  152. #define DEFAULT_CFG {0,0x0,0,0}
  153. #endif
  154. #ifdef CONFIG_HISAX_ASUSCOM
  155. #undef DEFAULT_CARD
  156. #undef DEFAULT_CFG
  157. #define DEFAULT_CARD ISDN_CTYPE_ASUSCOM
  158. #define DEFAULT_CFG {5,0x200,0,0}
  159. #endif
  160. #ifdef CONFIG_HISAX_TELEINT
  161. #undef DEFAULT_CARD
  162. #undef DEFAULT_CFG
  163. #define DEFAULT_CARD ISDN_CTYPE_TELEINT
  164. #define DEFAULT_CFG {5,0x300,0,0}
  165. #endif
  166. #ifdef CONFIG_HISAX_SEDLBAUER
  167. #undef DEFAULT_CARD
  168. #undef DEFAULT_CFG
  169. #define DEFAULT_CARD ISDN_CTYPE_SEDLBAUER
  170. #define DEFAULT_CFG {11,0x270,0,0}
  171. #endif
  172. #ifdef CONFIG_HISAX_SPORTSTER
  173. #undef DEFAULT_CARD
  174. #undef DEFAULT_CFG
  175. #define DEFAULT_CARD ISDN_CTYPE_SPORTSTER
  176. #define DEFAULT_CFG {7,0x268,0,0}
  177. #endif
  178. #ifdef CONFIG_HISAX_MIC
  179. #undef DEFAULT_CARD
  180. #undef DEFAULT_CFG
  181. #define DEFAULT_CARD ISDN_CTYPE_MIC
  182. #define DEFAULT_CFG {12,0x3e0,0,0}
  183. #endif
  184. #ifdef CONFIG_HISAX_NETJET
  185. #undef DEFAULT_CARD
  186. #undef DEFAULT_CFG
  187. #define DEFAULT_CARD ISDN_CTYPE_NETJET_S
  188. #define DEFAULT_CFG {0,0,0,0}
  189. #endif
  190. #ifdef CONFIG_HISAX_HFCS
  191. #undef DEFAULT_CARD
  192. #undef DEFAULT_CFG
  193. #define DEFAULT_CARD ISDN_CTYPE_TELES3C
  194. #define DEFAULT_CFG {5,0x500,0,0}
  195. #endif
  196. #ifdef CONFIG_HISAX_HFC_PCI
  197. #undef DEFAULT_CARD
  198. #undef DEFAULT_CFG
  199. #define DEFAULT_CARD ISDN_CTYPE_HFC_PCI
  200. #define DEFAULT_CFG {0,0,0,0}
  201. #endif
  202. #ifdef CONFIG_HISAX_HFC_SX
  203. #undef DEFAULT_CARD
  204. #undef DEFAULT_CFG
  205. #define DEFAULT_CARD ISDN_CTYPE_HFC_SX
  206. #define DEFAULT_CFG {5,0x2E0,0,0}
  207. #endif
  208. #ifdef CONFIG_HISAX_AMD7930
  209. #undef DEFAULT_CARD
  210. #undef DEFAULT_CFG
  211. #define DEFAULT_CARD ISDN_CTYPE_AMD7930
  212. #define DEFAULT_CFG {12,0x3e0,0,0}
  213. #endif
  214. #ifdef CONFIG_HISAX_NICCY
  215. #undef DEFAULT_CARD
  216. #undef DEFAULT_CFG
  217. #define DEFAULT_CARD ISDN_CTYPE_NICCY
  218. #define DEFAULT_CFG {0,0x0,0,0}
  219. #endif
  220. #ifdef CONFIG_HISAX_ISURF
  221. #undef DEFAULT_CARD
  222. #undef DEFAULT_CFG
  223. #define DEFAULT_CARD ISDN_CTYPE_ISURF
  224. #define DEFAULT_CFG {5,0x100,0xc8000,0}
  225. #endif
  226. #ifdef CONFIG_HISAX_HSTSAPHIR
  227. #undef DEFAULT_CARD
  228. #undef DEFAULT_CFG
  229. #define DEFAULT_CARD ISDN_CTYPE_HSTSAPHIR
  230. #define DEFAULT_CFG {5,0x250,0,0}
  231. #endif
  232. #ifdef CONFIG_HISAX_BKM_A4T
  233. #undef DEFAULT_CARD
  234. #undef DEFAULT_CFG
  235. #define DEFAULT_CARD ISDN_CTYPE_BKM_A4T
  236. #define DEFAULT_CFG {0,0x0,0,0}
  237. #endif
  238. #ifdef CONFIG_HISAX_SCT_QUADRO
  239. #undef DEFAULT_CARD
  240. #undef DEFAULT_CFG
  241. #define DEFAULT_CARD ISDN_CTYPE_SCT_QUADRO
  242. #define DEFAULT_CFG {1,0x0,0,0}
  243. #endif
  244. #ifdef CONFIG_HISAX_GAZEL
  245. #undef DEFAULT_CARD
  246. #undef DEFAULT_CFG
  247. #define DEFAULT_CARD ISDN_CTYPE_GAZEL
  248. #define DEFAULT_CFG {15,0x180,0,0}
  249. #endif
  250. #ifdef CONFIG_HISAX_W6692
  251. #undef DEFAULT_CARD
  252. #undef DEFAULT_CFG
  253. #define DEFAULT_CARD ISDN_CTYPE_W6692
  254. #define DEFAULT_CFG {0,0,0,0}
  255. #endif
  256. #ifdef CONFIG_HISAX_NETJET_U
  257. #undef DEFAULT_CARD
  258. #undef DEFAULT_CFG
  259. #define DEFAULT_CARD ISDN_CTYPE_NETJET_U
  260. #define DEFAULT_CFG {0,0,0,0}
  261. #endif
  262. #ifdef CONFIG_HISAX_1TR6
  263. #define DEFAULT_PROTO ISDN_PTYPE_1TR6
  264. #define DEFAULT_PROTO_NAME "1TR6"
  265. #endif
  266. #ifdef CONFIG_HISAX_NI1
  267. #undef DEFAULT_PROTO
  268. #define DEFAULT_PROTO ISDN_PTYPE_NI1
  269. #undef DEFAULT_PROTO_NAME
  270. #define DEFAULT_PROTO_NAME "NI1"
  271. #endif
  272. #ifdef CONFIG_HISAX_EURO
  273. #undef DEFAULT_PROTO
  274. #define DEFAULT_PROTO ISDN_PTYPE_EURO
  275. #undef DEFAULT_PROTO_NAME
  276. #define DEFAULT_PROTO_NAME "EURO"
  277. #endif
  278. #ifndef DEFAULT_PROTO
  279. #define DEFAULT_PROTO ISDN_PTYPE_UNKNOWN
  280. #define DEFAULT_PROTO_NAME "UNKNOWN"
  281. #endif
  282. #ifndef DEFAULT_CARD
  283. #define DEFAULT_CARD 0
  284. #define DEFAULT_CFG {0,0,0,0}
  285. #endif
  286. #define FIRST_CARD { \
  287. DEFAULT_CARD, \
  288. DEFAULT_PROTO, \
  289. DEFAULT_CFG, \
  290. NULL, \
  291. }
  292. struct IsdnCard cards[HISAX_MAX_CARDS] = {
  293. FIRST_CARD,
  294. };
  295. #define HISAX_IDSIZE (HISAX_MAX_CARDS*8)
  296. static char HiSaxID[HISAX_IDSIZE] = { 0, };
  297. static char *HiSax_id = HiSaxID;
  298. #ifdef MODULE
  299. /* Variables for insmod */
  300. static int type[HISAX_MAX_CARDS] = { 0, };
  301. static int protocol[HISAX_MAX_CARDS] = { 0, };
  302. static int io[HISAX_MAX_CARDS] = { 0, };
  303. #undef IO0_IO1
  304. #ifdef CONFIG_HISAX_16_3
  305. #define IO0_IO1
  306. #endif
  307. #ifdef CONFIG_HISAX_NICCY
  308. #undef IO0_IO1
  309. #define IO0_IO1
  310. #endif
  311. #ifdef IO0_IO1
  312. static int io0[HISAX_MAX_CARDS] __devinitdata = { 0, };
  313. static int io1[HISAX_MAX_CARDS] __devinitdata = { 0, };
  314. #endif
  315. static int irq[HISAX_MAX_CARDS] __devinitdata = { 0, };
  316. static int mem[HISAX_MAX_CARDS] __devinitdata = { 0, };
  317. static char *id = HiSaxID;
  318. MODULE_DESCRIPTION("ISDN4Linux: Driver for passive ISDN cards");
  319. MODULE_AUTHOR("Karsten Keil");
  320. MODULE_LICENSE("GPL");
  321. module_param_array(type, int, NULL, 0);
  322. module_param_array(protocol, int, NULL, 0);
  323. module_param_array(io, int, NULL, 0);
  324. module_param_array(irq, int, NULL, 0);
  325. module_param_array(mem, int, NULL, 0);
  326. module_param(id, charp, 0);
  327. #ifdef IO0_IO1
  328. module_param_array(io0, int, NULL, 0);
  329. module_param_array(io1, int, NULL, 0);
  330. #endif
  331. #endif /* MODULE */
  332. int nrcards;
  333. extern char *l1_revision;
  334. extern char *l2_revision;
  335. extern char *l3_revision;
  336. extern char *lli_revision;
  337. extern char *tei_revision;
  338. char *HiSax_getrev(const char *revision)
  339. {
  340. char *rev;
  341. char *p;
  342. if ((p = strchr(revision, ':'))) {
  343. rev = p + 2;
  344. p = strchr(rev, '$');
  345. *--p = 0;
  346. } else
  347. rev = "???";
  348. return rev;
  349. }
  350. static void __init HiSaxVersion(void)
  351. {
  352. char tmp[64];
  353. printk(KERN_INFO "HiSax: Linux Driver for passive ISDN cards\n");
  354. #ifdef MODULE
  355. printk(KERN_INFO "HiSax: Version 3.5 (module)\n");
  356. #else
  357. printk(KERN_INFO "HiSax: Version 3.5 (kernel)\n");
  358. #endif
  359. strcpy(tmp, l1_revision);
  360. printk(KERN_INFO "HiSax: Layer1 Revision %s\n", HiSax_getrev(tmp));
  361. strcpy(tmp, l2_revision);
  362. printk(KERN_INFO "HiSax: Layer2 Revision %s\n", HiSax_getrev(tmp));
  363. strcpy(tmp, tei_revision);
  364. printk(KERN_INFO "HiSax: TeiMgr Revision %s\n", HiSax_getrev(tmp));
  365. strcpy(tmp, l3_revision);
  366. printk(KERN_INFO "HiSax: Layer3 Revision %s\n", HiSax_getrev(tmp));
  367. strcpy(tmp, lli_revision);
  368. printk(KERN_INFO "HiSax: LinkLayer Revision %s\n",
  369. HiSax_getrev(tmp));
  370. }
  371. #ifndef MODULE
  372. #define MAX_ARG (HISAX_MAX_CARDS*5)
  373. static int __init HiSax_setup(char *line)
  374. {
  375. int i, j, argc;
  376. int ints[MAX_ARG + 1];
  377. char *str;
  378. str = get_options(line, MAX_ARG, ints);
  379. argc = ints[0];
  380. printk(KERN_DEBUG "HiSax_setup: argc(%d) str(%s)\n", argc, str);
  381. i = 0;
  382. j = 1;
  383. while (argc && (i < HISAX_MAX_CARDS)) {
  384. cards[i].protocol = DEFAULT_PROTO;
  385. if (argc) {
  386. cards[i].typ = ints[j];
  387. j++;
  388. argc--;
  389. }
  390. if (argc) {
  391. cards[i].protocol = ints[j];
  392. j++;
  393. argc--;
  394. }
  395. if (argc) {
  396. cards[i].para[0] = ints[j];
  397. j++;
  398. argc--;
  399. }
  400. if (argc) {
  401. cards[i].para[1] = ints[j];
  402. j++;
  403. argc--;
  404. }
  405. if (argc) {
  406. cards[i].para[2] = ints[j];
  407. j++;
  408. argc--;
  409. }
  410. i++;
  411. }
  412. if (str && *str) {
  413. if (strlen(str) < HISAX_IDSIZE)
  414. strcpy(HiSaxID, str);
  415. else
  416. printk(KERN_WARNING "HiSax: ID too long!");
  417. } else
  418. strcpy(HiSaxID, "HiSax");
  419. HiSax_id = HiSaxID;
  420. return 1;
  421. }
  422. __setup("hisax=", HiSax_setup);
  423. #endif /* MODULES */
  424. #if CARD_TELES0
  425. extern int setup_teles0(struct IsdnCard *card);
  426. #endif
  427. #if CARD_TELES3
  428. extern int setup_teles3(struct IsdnCard *card);
  429. #endif
  430. #if CARD_S0BOX
  431. extern int setup_s0box(struct IsdnCard *card);
  432. #endif
  433. #if CARD_TELESPCI
  434. extern int setup_telespci(struct IsdnCard *card);
  435. #endif
  436. #if CARD_AVM_A1
  437. extern int setup_avm_a1(struct IsdnCard *card);
  438. #endif
  439. #if CARD_AVM_A1_PCMCIA
  440. extern int setup_avm_a1_pcmcia(struct IsdnCard *card);
  441. #endif
  442. #if CARD_FRITZPCI
  443. extern int setup_avm_pcipnp(struct IsdnCard *card);
  444. #endif
  445. #if CARD_ELSA
  446. extern int setup_elsa(struct IsdnCard *card);
  447. #endif
  448. #if CARD_IX1MICROR2
  449. extern int setup_ix1micro(struct IsdnCard *card);
  450. #endif
  451. #if CARD_DIEHLDIVA
  452. extern int setup_diva(struct IsdnCard *card);
  453. #endif
  454. #if CARD_ASUSCOM
  455. extern int setup_asuscom(struct IsdnCard *card);
  456. #endif
  457. #if CARD_TELEINT
  458. extern int setup_TeleInt(struct IsdnCard *card);
  459. #endif
  460. #if CARD_SEDLBAUER
  461. extern int setup_sedlbauer(struct IsdnCard *card);
  462. #endif
  463. #if CARD_SPORTSTER
  464. extern int setup_sportster(struct IsdnCard *card);
  465. #endif
  466. #if CARD_MIC
  467. extern int setup_mic(struct IsdnCard *card);
  468. #endif
  469. #if CARD_NETJET_S
  470. extern int setup_netjet_s(struct IsdnCard *card);
  471. #endif
  472. #if CARD_HFCS
  473. extern int setup_hfcs(struct IsdnCard *card);
  474. #endif
  475. #if CARD_HFC_PCI
  476. extern int setup_hfcpci(struct IsdnCard *card);
  477. #endif
  478. #if CARD_HFC_SX
  479. extern int setup_hfcsx(struct IsdnCard *card);
  480. #endif
  481. #if CARD_AMD7930
  482. extern int setup_amd7930(struct IsdnCard *card);
  483. #endif
  484. #if CARD_NICCY
  485. extern int setup_niccy(struct IsdnCard *card);
  486. #endif
  487. #if CARD_ISURF
  488. extern int setup_isurf(struct IsdnCard *card);
  489. #endif
  490. #if CARD_HSTSAPHIR
  491. extern int setup_saphir(struct IsdnCard *card);
  492. #endif
  493. #if CARD_TESTEMU
  494. extern int setup_testemu(struct IsdnCard *card);
  495. #endif
  496. #if CARD_BKM_A4T
  497. extern int setup_bkm_a4t(struct IsdnCard *card);
  498. #endif
  499. #if CARD_SCT_QUADRO
  500. extern int setup_sct_quadro(struct IsdnCard *card);
  501. #endif
  502. #if CARD_GAZEL
  503. extern int setup_gazel(struct IsdnCard *card);
  504. #endif
  505. #if CARD_W6692
  506. extern int setup_w6692(struct IsdnCard *card);
  507. #endif
  508. #if CARD_NETJET_U
  509. extern int setup_netjet_u(struct IsdnCard *card);
  510. #endif
  511. #if CARD_FN_ENTERNOW_PCI
  512. extern int setup_enternow_pci(struct IsdnCard *card);
  513. #endif
  514. /*
  515. * Find card with given driverId
  516. */
  517. static inline struct IsdnCardState *hisax_findcard(int driverid)
  518. {
  519. int i;
  520. for (i = 0; i < nrcards; i++)
  521. if (cards[i].cs)
  522. if (cards[i].cs->myid == driverid)
  523. return cards[i].cs;
  524. return NULL;
  525. }
  526. /*
  527. * Find card with given card number
  528. */
  529. #if 0
  530. struct IsdnCardState *hisax_get_card(int cardnr)
  531. {
  532. if ((cardnr <= nrcards) && (cardnr > 0))
  533. if (cards[cardnr - 1].cs)
  534. return cards[cardnr - 1].cs;
  535. return NULL;
  536. }
  537. #endif /* 0 */
  538. static int HiSax_readstatus(u_char __user *buf, int len, int id, int channel)
  539. {
  540. int count, cnt;
  541. u_char __user *p = buf;
  542. struct IsdnCardState *cs = hisax_findcard(id);
  543. if (cs) {
  544. if (len > HISAX_STATUS_BUFSIZE) {
  545. printk(KERN_WARNING
  546. "HiSax: status overflow readstat %d/%d\n",
  547. len, HISAX_STATUS_BUFSIZE);
  548. }
  549. count = cs->status_end - cs->status_read + 1;
  550. if (count >= len)
  551. count = len;
  552. copy_to_user(p, cs->status_read, count);
  553. cs->status_read += count;
  554. if (cs->status_read > cs->status_end)
  555. cs->status_read = cs->status_buf;
  556. p += count;
  557. count = len - count;
  558. while (count) {
  559. if (count > HISAX_STATUS_BUFSIZE)
  560. cnt = HISAX_STATUS_BUFSIZE;
  561. else
  562. cnt = count;
  563. copy_to_user(p, cs->status_read, cnt);
  564. p += cnt;
  565. cs->status_read += cnt % HISAX_STATUS_BUFSIZE;
  566. count -= cnt;
  567. }
  568. return len;
  569. } else {
  570. printk(KERN_ERR
  571. "HiSax: if_readstatus called with invalid driverId!\n");
  572. return -ENODEV;
  573. }
  574. }
  575. int jiftime(char *s, long mark)
  576. {
  577. s += 8;
  578. *s-- = '\0';
  579. *s-- = mark % 10 + '0';
  580. mark /= 10;
  581. *s-- = mark % 10 + '0';
  582. mark /= 10;
  583. *s-- = '.';
  584. *s-- = mark % 10 + '0';
  585. mark /= 10;
  586. *s-- = mark % 6 + '0';
  587. mark /= 6;
  588. *s-- = ':';
  589. *s-- = mark % 10 + '0';
  590. mark /= 10;
  591. *s-- = mark % 10 + '0';
  592. return 8;
  593. }
  594. static u_char tmpbuf[HISAX_STATUS_BUFSIZE];
  595. void VHiSax_putstatus(struct IsdnCardState *cs, char *head, char *fmt,
  596. va_list args)
  597. {
  598. /* if head == NULL the fmt contains the full info */
  599. u_long flags;
  600. int count, i;
  601. u_char *p;
  602. isdn_ctrl ic;
  603. int len;
  604. if (!cs) {
  605. printk(KERN_WARNING "HiSax: No CardStatus for message");
  606. return;
  607. }
  608. spin_lock_irqsave(&cs->statlock, flags);
  609. p = tmpbuf;
  610. if (head) {
  611. p += jiftime(p, jiffies);
  612. p += sprintf(p, " %s", head);
  613. p += vsprintf(p, fmt, args);
  614. *p++ = '\n';
  615. *p = 0;
  616. len = p - tmpbuf;
  617. p = tmpbuf;
  618. } else {
  619. p = fmt;
  620. len = strlen(fmt);
  621. }
  622. if (len > HISAX_STATUS_BUFSIZE) {
  623. spin_unlock_irqrestore(&cs->statlock, flags);
  624. printk(KERN_WARNING "HiSax: status overflow %d/%d\n",
  625. len, HISAX_STATUS_BUFSIZE);
  626. return;
  627. }
  628. count = len;
  629. i = cs->status_end - cs->status_write + 1;
  630. if (i >= len)
  631. i = len;
  632. len -= i;
  633. memcpy(cs->status_write, p, i);
  634. cs->status_write += i;
  635. if (cs->status_write > cs->status_end)
  636. cs->status_write = cs->status_buf;
  637. p += i;
  638. if (len) {
  639. memcpy(cs->status_write, p, len);
  640. cs->status_write += len;
  641. }
  642. #ifdef KERNELSTACK_DEBUG
  643. i = (ulong) & len - current->kernel_stack_page;
  644. sprintf(tmpbuf, "kstack %s %lx use %ld\n", current->comm,
  645. current->kernel_stack_page, i);
  646. len = strlen(tmpbuf);
  647. for (p = tmpbuf, i = len; i > 0; i--, p++) {
  648. *cs->status_write++ = *p;
  649. if (cs->status_write > cs->status_end)
  650. cs->status_write = cs->status_buf;
  651. count++;
  652. }
  653. #endif
  654. spin_unlock_irqrestore(&cs->statlock, flags);
  655. if (count) {
  656. ic.command = ISDN_STAT_STAVAIL;
  657. ic.driver = cs->myid;
  658. ic.arg = count;
  659. cs->iif.statcallb(&ic);
  660. }
  661. }
  662. void HiSax_putstatus(struct IsdnCardState *cs, char *head, char *fmt, ...)
  663. {
  664. va_list args;
  665. va_start(args, fmt);
  666. VHiSax_putstatus(cs, head, fmt, args);
  667. va_end(args);
  668. }
  669. int ll_run(struct IsdnCardState *cs, int addfeatures)
  670. {
  671. isdn_ctrl ic;
  672. ic.driver = cs->myid;
  673. ic.command = ISDN_STAT_RUN;
  674. cs->iif.features |= addfeatures;
  675. cs->iif.statcallb(&ic);
  676. return 0;
  677. }
  678. static void ll_stop(struct IsdnCardState *cs)
  679. {
  680. isdn_ctrl ic;
  681. ic.command = ISDN_STAT_STOP;
  682. ic.driver = cs->myid;
  683. cs->iif.statcallb(&ic);
  684. // CallcFreeChan(cs);
  685. }
  686. static void ll_unload(struct IsdnCardState *cs)
  687. {
  688. isdn_ctrl ic;
  689. ic.command = ISDN_STAT_UNLOAD;
  690. ic.driver = cs->myid;
  691. cs->iif.statcallb(&ic);
  692. kfree(cs->status_buf);
  693. cs->status_read = NULL;
  694. cs->status_write = NULL;
  695. cs->status_end = NULL;
  696. kfree(cs->dlog);
  697. cs->dlog = NULL;
  698. }
  699. static void closecard(int cardnr)
  700. {
  701. struct IsdnCardState *csta = cards[cardnr].cs;
  702. if (csta->bcs->BC_Close != NULL) {
  703. csta->bcs->BC_Close(csta->bcs + 1);
  704. csta->bcs->BC_Close(csta->bcs);
  705. }
  706. skb_queue_purge(&csta->rq);
  707. skb_queue_purge(&csta->sq);
  708. kfree(csta->rcvbuf);
  709. csta->rcvbuf = NULL;
  710. if (csta->tx_skb) {
  711. dev_kfree_skb(csta->tx_skb);
  712. csta->tx_skb = NULL;
  713. }
  714. if (csta->DC_Close != NULL) {
  715. csta->DC_Close(csta);
  716. }
  717. if (csta->cardmsg)
  718. csta->cardmsg(csta, CARD_RELEASE, NULL);
  719. if (csta->dbusytimer.function != NULL) // FIXME?
  720. del_timer(&csta->dbusytimer);
  721. ll_unload(csta);
  722. }
  723. static int init_card(struct IsdnCardState *cs)
  724. {
  725. int irq_cnt, cnt = 3, ret;
  726. if (!cs->irq) {
  727. ret = cs->cardmsg(cs, CARD_INIT, NULL);
  728. return(ret);
  729. }
  730. irq_cnt = kstat_irqs(cs->irq);
  731. printk(KERN_INFO "%s: IRQ %d count %d\n", CardType[cs->typ],
  732. cs->irq, irq_cnt);
  733. if (request_irq(cs->irq, cs->irq_func, cs->irq_flags, "HiSax", cs)) {
  734. printk(KERN_WARNING "HiSax: couldn't get interrupt %d\n",
  735. cs->irq);
  736. return 1;
  737. }
  738. while (cnt) {
  739. cs->cardmsg(cs, CARD_INIT, NULL);
  740. /* Timeout 10ms */
  741. msleep(10);
  742. printk(KERN_INFO "%s: IRQ %d count %d\n",
  743. CardType[cs->typ], cs->irq, kstat_irqs(cs->irq));
  744. if (kstat_irqs(cs->irq) == irq_cnt) {
  745. printk(KERN_WARNING
  746. "%s: IRQ(%d) getting no interrupts during init %d\n",
  747. CardType[cs->typ], cs->irq, 4 - cnt);
  748. if (cnt == 1) {
  749. free_irq(cs->irq, cs);
  750. return 2;
  751. } else {
  752. cs->cardmsg(cs, CARD_RESET, NULL);
  753. cnt--;
  754. }
  755. } else {
  756. cs->cardmsg(cs, CARD_TEST, NULL);
  757. return 0;
  758. }
  759. }
  760. return 3;
  761. }
  762. static int checkcard(int cardnr, char *id, int *busy_flag, struct module *lockowner)
  763. {
  764. int ret = 0;
  765. struct IsdnCard *card = cards + cardnr;
  766. struct IsdnCardState *cs;
  767. cs = kmalloc(sizeof(struct IsdnCardState), GFP_ATOMIC);
  768. if (!cs) {
  769. printk(KERN_WARNING
  770. "HiSax: No memory for IsdnCardState(card %d)\n",
  771. cardnr + 1);
  772. goto out;
  773. }
  774. memset(cs, 0, sizeof(struct IsdnCardState));
  775. card->cs = cs;
  776. spin_lock_init(&cs->statlock);
  777. spin_lock_init(&cs->lock);
  778. cs->chanlimit = 2; /* maximum B-channel number */
  779. cs->logecho = 0; /* No echo logging */
  780. cs->cardnr = cardnr;
  781. cs->debug = L1_DEB_WARN;
  782. cs->HW_Flags = 0;
  783. cs->busy_flag = busy_flag;
  784. cs->irq_flags = I4L_IRQ_FLAG;
  785. #if TEI_PER_CARD
  786. if (card->protocol == ISDN_PTYPE_NI1)
  787. test_and_set_bit(FLG_TWO_DCHAN, &cs->HW_Flags);
  788. #else
  789. test_and_set_bit(FLG_TWO_DCHAN, &cs->HW_Flags);
  790. #endif
  791. cs->protocol = card->protocol;
  792. if (card->typ <= 0 || card->typ > ISDN_CTYPE_COUNT) {
  793. printk(KERN_WARNING
  794. "HiSax: Card Type %d out of range\n", card->typ);
  795. goto outf_cs;
  796. }
  797. if (!(cs->dlog = kmalloc(MAX_DLOG_SPACE, GFP_ATOMIC))) {
  798. printk(KERN_WARNING
  799. "HiSax: No memory for dlog(card %d)\n", cardnr + 1);
  800. goto outf_cs;
  801. }
  802. if (!(cs->status_buf = kmalloc(HISAX_STATUS_BUFSIZE, GFP_ATOMIC))) {
  803. printk(KERN_WARNING
  804. "HiSax: No memory for status_buf(card %d)\n",
  805. cardnr + 1);
  806. goto outf_dlog;
  807. }
  808. cs->stlist = NULL;
  809. cs->status_read = cs->status_buf;
  810. cs->status_write = cs->status_buf;
  811. cs->status_end = cs->status_buf + HISAX_STATUS_BUFSIZE - 1;
  812. cs->typ = card->typ;
  813. #ifdef MODULE
  814. cs->iif.owner = lockowner;
  815. #endif
  816. strcpy(cs->iif.id, id);
  817. cs->iif.channels = 2;
  818. cs->iif.maxbufsize = MAX_DATA_SIZE;
  819. cs->iif.hl_hdrlen = MAX_HEADER_LEN;
  820. cs->iif.features =
  821. ISDN_FEATURE_L2_X75I |
  822. ISDN_FEATURE_L2_HDLC |
  823. ISDN_FEATURE_L2_HDLC_56K |
  824. ISDN_FEATURE_L2_TRANS |
  825. ISDN_FEATURE_L3_TRANS |
  826. #ifdef CONFIG_HISAX_1TR6
  827. ISDN_FEATURE_P_1TR6 |
  828. #endif
  829. #ifdef CONFIG_HISAX_EURO
  830. ISDN_FEATURE_P_EURO |
  831. #endif
  832. #ifdef CONFIG_HISAX_NI1
  833. ISDN_FEATURE_P_NI1 |
  834. #endif
  835. 0;
  836. cs->iif.command = HiSax_command;
  837. cs->iif.writecmd = NULL;
  838. cs->iif.writebuf_skb = HiSax_writebuf_skb;
  839. cs->iif.readstat = HiSax_readstatus;
  840. register_isdn(&cs->iif);
  841. cs->myid = cs->iif.channels;
  842. printk(KERN_INFO
  843. "HiSax: Card %d Protocol %s Id=%s (%d)\n", cardnr + 1,
  844. (card->protocol == ISDN_PTYPE_1TR6) ? "1TR6" :
  845. (card->protocol == ISDN_PTYPE_EURO) ? "EDSS1" :
  846. (card->protocol == ISDN_PTYPE_LEASED) ? "LEASED" :
  847. (card->protocol == ISDN_PTYPE_NI1) ? "NI1" :
  848. "NONE", cs->iif.id, cs->myid);
  849. switch (card->typ) {
  850. #if CARD_TELES0
  851. case ISDN_CTYPE_16_0:
  852. case ISDN_CTYPE_8_0:
  853. ret = setup_teles0(card);
  854. break;
  855. #endif
  856. #if CARD_TELES3
  857. case ISDN_CTYPE_16_3:
  858. case ISDN_CTYPE_PNP:
  859. case ISDN_CTYPE_TELESPCMCIA:
  860. case ISDN_CTYPE_COMPAQ_ISA:
  861. ret = setup_teles3(card);
  862. break;
  863. #endif
  864. #if CARD_S0BOX
  865. case ISDN_CTYPE_S0BOX:
  866. ret = setup_s0box(card);
  867. break;
  868. #endif
  869. #if CARD_TELESPCI
  870. case ISDN_CTYPE_TELESPCI:
  871. ret = setup_telespci(card);
  872. break;
  873. #endif
  874. #if CARD_AVM_A1
  875. case ISDN_CTYPE_A1:
  876. ret = setup_avm_a1(card);
  877. break;
  878. #endif
  879. #if CARD_AVM_A1_PCMCIA
  880. case ISDN_CTYPE_A1_PCMCIA:
  881. ret = setup_avm_a1_pcmcia(card);
  882. break;
  883. #endif
  884. #if CARD_FRITZPCI
  885. case ISDN_CTYPE_FRITZPCI:
  886. ret = setup_avm_pcipnp(card);
  887. break;
  888. #endif
  889. #if CARD_ELSA
  890. case ISDN_CTYPE_ELSA:
  891. case ISDN_CTYPE_ELSA_PNP:
  892. case ISDN_CTYPE_ELSA_PCMCIA:
  893. case ISDN_CTYPE_ELSA_PCI:
  894. ret = setup_elsa(card);
  895. break;
  896. #endif
  897. #if CARD_IX1MICROR2
  898. case ISDN_CTYPE_IX1MICROR2:
  899. ret = setup_ix1micro(card);
  900. break;
  901. #endif
  902. #if CARD_DIEHLDIVA
  903. case ISDN_CTYPE_DIEHLDIVA:
  904. ret = setup_diva(card);
  905. break;
  906. #endif
  907. #if CARD_ASUSCOM
  908. case ISDN_CTYPE_ASUSCOM:
  909. ret = setup_asuscom(card);
  910. break;
  911. #endif
  912. #if CARD_TELEINT
  913. case ISDN_CTYPE_TELEINT:
  914. ret = setup_TeleInt(card);
  915. break;
  916. #endif
  917. #if CARD_SEDLBAUER
  918. case ISDN_CTYPE_SEDLBAUER:
  919. case ISDN_CTYPE_SEDLBAUER_PCMCIA:
  920. case ISDN_CTYPE_SEDLBAUER_FAX:
  921. ret = setup_sedlbauer(card);
  922. break;
  923. #endif
  924. #if CARD_SPORTSTER
  925. case ISDN_CTYPE_SPORTSTER:
  926. ret = setup_sportster(card);
  927. break;
  928. #endif
  929. #if CARD_MIC
  930. case ISDN_CTYPE_MIC:
  931. ret = setup_mic(card);
  932. break;
  933. #endif
  934. #if CARD_NETJET_S
  935. case ISDN_CTYPE_NETJET_S:
  936. ret = setup_netjet_s(card);
  937. break;
  938. #endif
  939. #if CARD_HFCS
  940. case ISDN_CTYPE_TELES3C:
  941. case ISDN_CTYPE_ACERP10:
  942. ret = setup_hfcs(card);
  943. break;
  944. #endif
  945. #if CARD_HFC_PCI
  946. case ISDN_CTYPE_HFC_PCI:
  947. ret = setup_hfcpci(card);
  948. break;
  949. #endif
  950. #if CARD_HFC_SX
  951. case ISDN_CTYPE_HFC_SX:
  952. ret = setup_hfcsx(card);
  953. break;
  954. #endif
  955. #if CARD_NICCY
  956. case ISDN_CTYPE_NICCY:
  957. ret = setup_niccy(card);
  958. break;
  959. #endif
  960. #if CARD_AMD7930
  961. case ISDN_CTYPE_AMD7930:
  962. ret = setup_amd7930(card);
  963. break;
  964. #endif
  965. #if CARD_ISURF
  966. case ISDN_CTYPE_ISURF:
  967. ret = setup_isurf(card);
  968. break;
  969. #endif
  970. #if CARD_HSTSAPHIR
  971. case ISDN_CTYPE_HSTSAPHIR:
  972. ret = setup_saphir(card);
  973. break;
  974. #endif
  975. #if CARD_TESTEMU
  976. case ISDN_CTYPE_TESTEMU:
  977. ret = setup_testemu(card);
  978. break;
  979. #endif
  980. #if CARD_BKM_A4T
  981. case ISDN_CTYPE_BKM_A4T:
  982. ret = setup_bkm_a4t(card);
  983. break;
  984. #endif
  985. #if CARD_SCT_QUADRO
  986. case ISDN_CTYPE_SCT_QUADRO:
  987. ret = setup_sct_quadro(card);
  988. break;
  989. #endif
  990. #if CARD_GAZEL
  991. case ISDN_CTYPE_GAZEL:
  992. ret = setup_gazel(card);
  993. break;
  994. #endif
  995. #if CARD_W6692
  996. case ISDN_CTYPE_W6692:
  997. ret = setup_w6692(card);
  998. break;
  999. #endif
  1000. #if CARD_NETJET_U
  1001. case ISDN_CTYPE_NETJET_U:
  1002. ret = setup_netjet_u(card);
  1003. break;
  1004. #endif
  1005. #if CARD_FN_ENTERNOW_PCI
  1006. case ISDN_CTYPE_ENTERNOW:
  1007. ret = setup_enternow_pci(card);
  1008. break;
  1009. #endif
  1010. case ISDN_CTYPE_DYNAMIC:
  1011. ret = 2;
  1012. break;
  1013. default:
  1014. printk(KERN_WARNING
  1015. "HiSax: Support for %s Card not selected\n",
  1016. CardType[card->typ]);
  1017. ll_unload(cs);
  1018. goto outf_cs;
  1019. }
  1020. if (!ret) {
  1021. ll_unload(cs);
  1022. goto outf_cs;
  1023. }
  1024. if (!(cs->rcvbuf = kmalloc(MAX_DFRAME_LEN_L1, GFP_ATOMIC))) {
  1025. printk(KERN_WARNING "HiSax: No memory for isac rcvbuf\n");
  1026. ll_unload(cs);
  1027. goto outf_cs;
  1028. }
  1029. cs->rcvidx = 0;
  1030. cs->tx_skb = NULL;
  1031. cs->tx_cnt = 0;
  1032. cs->event = 0;
  1033. cs->tqueue.data = cs;
  1034. skb_queue_head_init(&cs->rq);
  1035. skb_queue_head_init(&cs->sq);
  1036. init_bcstate(cs, 0);
  1037. init_bcstate(cs, 1);
  1038. /* init_card only handles interrupts which are not */
  1039. /* used here for the loadable driver */
  1040. switch (card->typ) {
  1041. case ISDN_CTYPE_DYNAMIC:
  1042. ret = 0;
  1043. break;
  1044. default:
  1045. ret = init_card(cs);
  1046. break;
  1047. }
  1048. if (ret) {
  1049. closecard(cardnr);
  1050. ret = 0;
  1051. goto outf_cs;
  1052. }
  1053. init_tei(cs, cs->protocol);
  1054. ret = CallcNewChan(cs);
  1055. if (ret) {
  1056. closecard(cardnr);
  1057. ret = 0;
  1058. goto outf_cs;
  1059. }
  1060. /* ISAR needs firmware download first */
  1061. if (!test_bit(HW_ISAR, &cs->HW_Flags))
  1062. ll_run(cs, 0);
  1063. ret = 1;
  1064. goto out;
  1065. outf_dlog:
  1066. kfree(cs->dlog);
  1067. outf_cs:
  1068. kfree(cs);
  1069. card->cs = NULL;
  1070. out:
  1071. return ret;
  1072. }
  1073. static void HiSax_shiftcards(int idx)
  1074. {
  1075. int i;
  1076. for (i = idx; i < (HISAX_MAX_CARDS - 1); i++)
  1077. memcpy(&cards[i], &cards[i + 1], sizeof(cards[i]));
  1078. }
  1079. static int HiSax_inithardware(int *busy_flag)
  1080. {
  1081. int foundcards = 0;
  1082. int i = 0;
  1083. int t = ',';
  1084. int flg = 0;
  1085. char *id;
  1086. char *next_id = HiSax_id;
  1087. char ids[20];
  1088. if (strchr(HiSax_id, ','))
  1089. t = ',';
  1090. else if (strchr(HiSax_id, '%'))
  1091. t = '%';
  1092. while (i < nrcards) {
  1093. if (cards[i].typ < 1)
  1094. break;
  1095. id = next_id;
  1096. if ((next_id = strchr(id, t))) {
  1097. *next_id++ = 0;
  1098. strcpy(ids, id);
  1099. flg = i + 1;
  1100. } else {
  1101. next_id = id;
  1102. if (flg >= i)
  1103. strcpy(ids, id);
  1104. else
  1105. sprintf(ids, "%s%d", id, i);
  1106. }
  1107. if (checkcard(i, ids, busy_flag, THIS_MODULE)) {
  1108. foundcards++;
  1109. i++;
  1110. } else {
  1111. /* make sure we don't oops the module */
  1112. if (cards[i].typ > 0 && cards[i].typ <= ISDN_CTYPE_COUNT) {
  1113. printk(KERN_WARNING
  1114. "HiSax: Card %s not installed !\n",
  1115. CardType[cards[i].typ]);
  1116. }
  1117. HiSax_shiftcards(i);
  1118. nrcards--;
  1119. }
  1120. }
  1121. return foundcards;
  1122. }
  1123. void HiSax_closecard(int cardnr)
  1124. {
  1125. int i, last = nrcards - 1;
  1126. if (cardnr > last || cardnr < 0)
  1127. return;
  1128. if (cards[cardnr].cs) {
  1129. ll_stop(cards[cardnr].cs);
  1130. release_tei(cards[cardnr].cs);
  1131. CallcFreeChan(cards[cardnr].cs);
  1132. closecard(cardnr);
  1133. if (cards[cardnr].cs->irq)
  1134. free_irq(cards[cardnr].cs->irq, cards[cardnr].cs);
  1135. kfree((void *) cards[cardnr].cs);
  1136. cards[cardnr].cs = NULL;
  1137. }
  1138. i = cardnr;
  1139. while (i <= last) {
  1140. cards[i] = cards[i + 1];
  1141. i++;
  1142. }
  1143. nrcards--;
  1144. }
  1145. void HiSax_reportcard(int cardnr, int sel)
  1146. {
  1147. struct IsdnCardState *cs = cards[cardnr].cs;
  1148. printk(KERN_DEBUG "HiSax: reportcard No %d\n", cardnr + 1);
  1149. printk(KERN_DEBUG "HiSax: Type %s\n", CardType[cs->typ]);
  1150. printk(KERN_DEBUG "HiSax: debuglevel %x\n", cs->debug);
  1151. printk(KERN_DEBUG "HiSax: HiSax_reportcard address 0x%lX\n",
  1152. (ulong) & HiSax_reportcard);
  1153. printk(KERN_DEBUG "HiSax: cs 0x%lX\n", (ulong) cs);
  1154. printk(KERN_DEBUG "HiSax: HW_Flags %lx bc0 flg %lx bc1 flg %lx\n",
  1155. cs->HW_Flags, cs->bcs[0].Flag, cs->bcs[1].Flag);
  1156. printk(KERN_DEBUG "HiSax: bcs 0 mode %d ch%d\n",
  1157. cs->bcs[0].mode, cs->bcs[0].channel);
  1158. printk(KERN_DEBUG "HiSax: bcs 1 mode %d ch%d\n",
  1159. cs->bcs[1].mode, cs->bcs[1].channel);
  1160. #ifdef ERROR_STATISTIC
  1161. printk(KERN_DEBUG "HiSax: dc errors(rx,crc,tx) %d,%d,%d\n",
  1162. cs->err_rx, cs->err_crc, cs->err_tx);
  1163. printk(KERN_DEBUG
  1164. "HiSax: bc0 errors(inv,rdo,crc,tx) %d,%d,%d,%d\n",
  1165. cs->bcs[0].err_inv, cs->bcs[0].err_rdo, cs->bcs[0].err_crc,
  1166. cs->bcs[0].err_tx);
  1167. printk(KERN_DEBUG
  1168. "HiSax: bc1 errors(inv,rdo,crc,tx) %d,%d,%d,%d\n",
  1169. cs->bcs[1].err_inv, cs->bcs[1].err_rdo, cs->bcs[1].err_crc,
  1170. cs->bcs[1].err_tx);
  1171. if (sel == 99) {
  1172. cs->err_rx = 0;
  1173. cs->err_crc = 0;
  1174. cs->err_tx = 0;
  1175. cs->bcs[0].err_inv = 0;
  1176. cs->bcs[0].err_rdo = 0;
  1177. cs->bcs[0].err_crc = 0;
  1178. cs->bcs[0].err_tx = 0;
  1179. cs->bcs[1].err_inv = 0;
  1180. cs->bcs[1].err_rdo = 0;
  1181. cs->bcs[1].err_crc = 0;
  1182. cs->bcs[1].err_tx = 0;
  1183. }
  1184. #endif
  1185. }
  1186. static int __init HiSax_init(void)
  1187. {
  1188. int i, retval;
  1189. #ifdef MODULE
  1190. int j;
  1191. int nzproto = 0;
  1192. #endif
  1193. HiSaxVersion();
  1194. retval = CallcNew();
  1195. if (retval)
  1196. goto out;
  1197. retval = Isdnl3New();
  1198. if (retval)
  1199. goto out_callc;
  1200. retval = Isdnl2New();
  1201. if (retval)
  1202. goto out_isdnl3;
  1203. retval = TeiNew();
  1204. if (retval)
  1205. goto out_isdnl2;
  1206. retval = Isdnl1New();
  1207. if (retval)
  1208. goto out_tei;
  1209. #ifdef MODULE
  1210. if (!type[0]) {
  1211. /* We 'll register drivers later, but init basic functions */
  1212. for (i = 0; i < HISAX_MAX_CARDS; i++)
  1213. cards[i].typ = 0;
  1214. return 0;
  1215. }
  1216. #ifdef CONFIG_HISAX_ELSA
  1217. if (type[0] == ISDN_CTYPE_ELSA_PCMCIA) {
  1218. /* we have exported and return in this case */
  1219. return 0;
  1220. }
  1221. #endif
  1222. #ifdef CONFIG_HISAX_SEDLBAUER
  1223. if (type[0] == ISDN_CTYPE_SEDLBAUER_PCMCIA) {
  1224. /* we have to export and return in this case */
  1225. return 0;
  1226. }
  1227. #endif
  1228. #ifdef CONFIG_HISAX_AVM_A1_PCMCIA
  1229. if (type[0] == ISDN_CTYPE_A1_PCMCIA) {
  1230. /* we have to export and return in this case */
  1231. return 0;
  1232. }
  1233. #endif
  1234. #ifdef CONFIG_HISAX_HFC_SX
  1235. if (type[0] == ISDN_CTYPE_HFC_SP_PCMCIA) {
  1236. /* we have to export and return in this case */
  1237. return 0;
  1238. }
  1239. #endif
  1240. #endif
  1241. nrcards = 0;
  1242. #ifdef MODULE
  1243. if (id) /* If id= string used */
  1244. HiSax_id = id;
  1245. for (i = j = 0; j < HISAX_MAX_CARDS; i++) {
  1246. cards[j].typ = type[i];
  1247. if (protocol[i]) {
  1248. cards[j].protocol = protocol[i];
  1249. nzproto++;
  1250. } else {
  1251. cards[j].protocol = DEFAULT_PROTO;
  1252. }
  1253. switch (type[i]) {
  1254. case ISDN_CTYPE_16_0:
  1255. cards[j].para[0] = irq[i];
  1256. cards[j].para[1] = mem[i];
  1257. cards[j].para[2] = io[i];
  1258. break;
  1259. case ISDN_CTYPE_8_0:
  1260. cards[j].para[0] = irq[i];
  1261. cards[j].para[1] = mem[i];
  1262. break;
  1263. #ifdef IO0_IO1
  1264. case ISDN_CTYPE_PNP:
  1265. case ISDN_CTYPE_NICCY:
  1266. cards[j].para[0] = irq[i];
  1267. cards[j].para[1] = io0[i];
  1268. cards[j].para[2] = io1[i];
  1269. break;
  1270. case ISDN_CTYPE_COMPAQ_ISA:
  1271. cards[j].para[0] = irq[i];
  1272. cards[j].para[1] = io0[i];
  1273. cards[j].para[2] = io1[i];
  1274. cards[j].para[3] = io[i];
  1275. break;
  1276. #endif
  1277. case ISDN_CTYPE_ELSA:
  1278. case ISDN_CTYPE_HFC_PCI:
  1279. cards[j].para[0] = io[i];
  1280. break;
  1281. case ISDN_CTYPE_16_3:
  1282. case ISDN_CTYPE_TELESPCMCIA:
  1283. case ISDN_CTYPE_A1:
  1284. case ISDN_CTYPE_A1_PCMCIA:
  1285. case ISDN_CTYPE_ELSA_PNP:
  1286. case ISDN_CTYPE_ELSA_PCMCIA:
  1287. case ISDN_CTYPE_IX1MICROR2:
  1288. case ISDN_CTYPE_DIEHLDIVA:
  1289. case ISDN_CTYPE_ASUSCOM:
  1290. case ISDN_CTYPE_TELEINT:
  1291. case ISDN_CTYPE_SEDLBAUER:
  1292. case ISDN_CTYPE_SEDLBAUER_PCMCIA:
  1293. case ISDN_CTYPE_SEDLBAUER_FAX:
  1294. case ISDN_CTYPE_SPORTSTER:
  1295. case ISDN_CTYPE_MIC:
  1296. case ISDN_CTYPE_TELES3C:
  1297. case ISDN_CTYPE_ACERP10:
  1298. case ISDN_CTYPE_S0BOX:
  1299. case ISDN_CTYPE_FRITZPCI:
  1300. case ISDN_CTYPE_HSTSAPHIR:
  1301. case ISDN_CTYPE_GAZEL:
  1302. case ISDN_CTYPE_HFC_SX:
  1303. case ISDN_CTYPE_HFC_SP_PCMCIA:
  1304. cards[j].para[0] = irq[i];
  1305. cards[j].para[1] = io[i];
  1306. break;
  1307. case ISDN_CTYPE_ISURF:
  1308. cards[j].para[0] = irq[i];
  1309. cards[j].para[1] = io[i];
  1310. cards[j].para[2] = mem[i];
  1311. break;
  1312. case ISDN_CTYPE_ELSA_PCI:
  1313. case ISDN_CTYPE_NETJET_S:
  1314. case ISDN_CTYPE_AMD7930:
  1315. case ISDN_CTYPE_TELESPCI:
  1316. case ISDN_CTYPE_W6692:
  1317. case ISDN_CTYPE_NETJET_U:
  1318. break;
  1319. case ISDN_CTYPE_BKM_A4T:
  1320. break;
  1321. case ISDN_CTYPE_SCT_QUADRO:
  1322. if (irq[i]) {
  1323. cards[j].para[0] = irq[i];
  1324. } else {
  1325. /* QUADRO is a 4 BRI card */
  1326. cards[j++].para[0] = 1;
  1327. /* we need to check if further cards can be added */
  1328. if (j < HISAX_MAX_CARDS) {
  1329. cards[j].typ = ISDN_CTYPE_SCT_QUADRO;
  1330. cards[j].protocol = protocol[i];
  1331. cards[j++].para[0] = 2;
  1332. }
  1333. if (j < HISAX_MAX_CARDS) {
  1334. cards[j].typ = ISDN_CTYPE_SCT_QUADRO;
  1335. cards[j].protocol = protocol[i];
  1336. cards[j++].para[0] = 3;
  1337. }
  1338. if (j < HISAX_MAX_CARDS) {
  1339. cards[j].typ = ISDN_CTYPE_SCT_QUADRO;
  1340. cards[j].protocol = protocol[i];
  1341. cards[j].para[0] = 4;
  1342. }
  1343. }
  1344. break;
  1345. }
  1346. j++;
  1347. }
  1348. if (!nzproto) {
  1349. printk(KERN_WARNING
  1350. "HiSax: Warning - no protocol specified\n");
  1351. printk(KERN_WARNING "HiSax: using protocol %s\n",
  1352. DEFAULT_PROTO_NAME);
  1353. }
  1354. #endif
  1355. if (!HiSax_id)
  1356. HiSax_id = HiSaxID;
  1357. if (!HiSaxID[0])
  1358. strcpy(HiSaxID, "HiSax");
  1359. for (i = 0; i < HISAX_MAX_CARDS; i++)
  1360. if (cards[i].typ > 0)
  1361. nrcards++;
  1362. printk(KERN_DEBUG "HiSax: Total %d card%s defined\n",
  1363. nrcards, (nrcards > 1) ? "s" : "");
  1364. /* Install only, if at least one card found */
  1365. if (!HiSax_inithardware(NULL))
  1366. return -ENODEV;
  1367. return 0;
  1368. out_tei:
  1369. TeiFree();
  1370. out_isdnl2:
  1371. Isdnl2Free();
  1372. out_isdnl3:
  1373. Isdnl3Free();
  1374. out_callc:
  1375. CallcFree();
  1376. out:
  1377. return retval;
  1378. }
  1379. static void __exit HiSax_exit(void)
  1380. {
  1381. int cardnr = nrcards - 1;
  1382. while (cardnr >= 0)
  1383. HiSax_closecard(cardnr--);
  1384. Isdnl1Free();
  1385. TeiFree();
  1386. Isdnl2Free();
  1387. Isdnl3Free();
  1388. CallcFree();
  1389. printk(KERN_INFO "HiSax module removed\n");
  1390. }
  1391. int hisax_init_pcmcia(void *pcm_iob, int *busy_flag, struct IsdnCard *card)
  1392. {
  1393. u_char ids[16];
  1394. int ret = -1;
  1395. cards[nrcards] = *card;
  1396. if (nrcards)
  1397. sprintf(ids, "HiSax%d", nrcards);
  1398. else
  1399. sprintf(ids, "HiSax");
  1400. if (!checkcard(nrcards, ids, busy_flag, THIS_MODULE))
  1401. goto error;
  1402. ret = nrcards;
  1403. nrcards++;
  1404. error:
  1405. return ret;
  1406. }
  1407. EXPORT_SYMBOL(hisax_init_pcmcia);
  1408. EXPORT_SYMBOL(HiSax_closecard);
  1409. #include "hisax_if.h"
  1410. EXPORT_SYMBOL(hisax_register);
  1411. EXPORT_SYMBOL(hisax_unregister);
  1412. static void hisax_d_l1l2(struct hisax_if *ifc, int pr, void *arg);
  1413. static void hisax_b_l1l2(struct hisax_if *ifc, int pr, void *arg);
  1414. static void hisax_d_l2l1(struct PStack *st, int pr, void *arg);
  1415. static void hisax_b_l2l1(struct PStack *st, int pr, void *arg);
  1416. static int hisax_cardmsg(struct IsdnCardState *cs, int mt, void *arg);
  1417. static int hisax_bc_setstack(struct PStack *st, struct BCState *bcs);
  1418. static void hisax_bc_close(struct BCState *bcs);
  1419. static void hisax_bh(struct IsdnCardState *cs);
  1420. static void EChannel_proc_rcv(struct hisax_d_if *d_if);
  1421. int hisax_register(struct hisax_d_if *hisax_d_if, struct hisax_b_if *b_if[],
  1422. char *name, int protocol)
  1423. {
  1424. int i, retval;
  1425. char id[20];
  1426. struct IsdnCardState *cs;
  1427. for (i = 0; i < HISAX_MAX_CARDS; i++) {
  1428. if (!cards[i].typ)
  1429. break;
  1430. }
  1431. if (i >= HISAX_MAX_CARDS)
  1432. return -EBUSY;
  1433. cards[i].typ = ISDN_CTYPE_DYNAMIC;
  1434. cards[i].protocol = protocol;
  1435. sprintf(id, "%s%d", name, i);
  1436. nrcards++;
  1437. retval = checkcard(i, id, NULL, hisax_d_if->owner);
  1438. if (retval == 0) { // yuck
  1439. cards[i].typ = 0;
  1440. nrcards--;
  1441. return retval;
  1442. }
  1443. cs = cards[i].cs;
  1444. hisax_d_if->cs = cs;
  1445. cs->hw.hisax_d_if = hisax_d_if;
  1446. cs->cardmsg = hisax_cardmsg;
  1447. INIT_WORK(&cs->tqueue, (void *)(void *)hisax_bh, cs);
  1448. cs->channel[0].d_st->l2.l2l1 = hisax_d_l2l1;
  1449. for (i = 0; i < 2; i++) {
  1450. cs->bcs[i].BC_SetStack = hisax_bc_setstack;
  1451. cs->bcs[i].BC_Close = hisax_bc_close;
  1452. b_if[i]->ifc.l1l2 = hisax_b_l1l2;
  1453. hisax_d_if->b_if[i] = b_if[i];
  1454. }
  1455. hisax_d_if->ifc.l1l2 = hisax_d_l1l2;
  1456. skb_queue_head_init(&hisax_d_if->erq);
  1457. clear_bit(0, &hisax_d_if->ph_state);
  1458. return 0;
  1459. }
  1460. void hisax_unregister(struct hisax_d_if *hisax_d_if)
  1461. {
  1462. cards[hisax_d_if->cs->cardnr].typ = 0;
  1463. HiSax_closecard(hisax_d_if->cs->cardnr);
  1464. skb_queue_purge(&hisax_d_if->erq);
  1465. }
  1466. #include "isdnl1.h"
  1467. static void hisax_sched_event(struct IsdnCardState *cs, int event)
  1468. {
  1469. test_and_set_bit(event, &cs->event);
  1470. schedule_work(&cs->tqueue);
  1471. }
  1472. static void hisax_bh(struct IsdnCardState *cs)
  1473. {
  1474. struct PStack *st;
  1475. int pr;
  1476. if (test_and_clear_bit(D_RCVBUFREADY, &cs->event))
  1477. DChannel_proc_rcv(cs);
  1478. if (test_and_clear_bit(E_RCVBUFREADY, &cs->event))
  1479. EChannel_proc_rcv(cs->hw.hisax_d_if);
  1480. if (test_and_clear_bit(D_L1STATECHANGE, &cs->event)) {
  1481. if (test_bit(0, &cs->hw.hisax_d_if->ph_state))
  1482. pr = PH_ACTIVATE | INDICATION;
  1483. else
  1484. pr = PH_DEACTIVATE | INDICATION;
  1485. for (st = cs->stlist; st; st = st->next)
  1486. st->l1.l1l2(st, pr, NULL);
  1487. }
  1488. }
  1489. static void hisax_b_sched_event(struct BCState *bcs, int event)
  1490. {
  1491. test_and_set_bit(event, &bcs->event);
  1492. schedule_work(&bcs->tqueue);
  1493. }
  1494. static inline void D_L2L1(struct hisax_d_if *d_if, int pr, void *arg)
  1495. {
  1496. struct hisax_if *ifc = (struct hisax_if *) d_if;
  1497. ifc->l2l1(ifc, pr, arg);
  1498. }
  1499. static inline void B_L2L1(struct hisax_b_if *b_if, int pr, void *arg)
  1500. {
  1501. struct hisax_if *ifc = (struct hisax_if *) b_if;
  1502. ifc->l2l1(ifc, pr, arg);
  1503. }
  1504. static void hisax_d_l1l2(struct hisax_if *ifc, int pr, void *arg)
  1505. {
  1506. struct hisax_d_if *d_if = (struct hisax_d_if *) ifc;
  1507. struct IsdnCardState *cs = d_if->cs;
  1508. struct PStack *st;
  1509. struct sk_buff *skb;
  1510. switch (pr) {
  1511. case PH_ACTIVATE | INDICATION:
  1512. set_bit(0, &d_if->ph_state);
  1513. hisax_sched_event(cs, D_L1STATECHANGE);
  1514. break;
  1515. case PH_DEACTIVATE | INDICATION:
  1516. clear_bit(0, &d_if->ph_state);
  1517. hisax_sched_event(cs, D_L1STATECHANGE);
  1518. break;
  1519. case PH_DATA | INDICATION:
  1520. skb_queue_tail(&cs->rq, arg);
  1521. hisax_sched_event(cs, D_RCVBUFREADY);
  1522. break;
  1523. case PH_DATA | CONFIRM:
  1524. skb = skb_dequeue(&cs->sq);
  1525. if (skb) {
  1526. D_L2L1(d_if, PH_DATA | REQUEST, skb);
  1527. break;
  1528. }
  1529. clear_bit(FLG_L1_DBUSY, &cs->HW_Flags);
  1530. for (st = cs->stlist; st; st = st->next) {
  1531. if (test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags)) {
  1532. st->l1.l1l2(st, PH_PULL | CONFIRM, NULL);
  1533. break;
  1534. }
  1535. }
  1536. break;
  1537. case PH_DATA_E | INDICATION:
  1538. skb_queue_tail(&d_if->erq, arg);
  1539. hisax_sched_event(cs, E_RCVBUFREADY);
  1540. break;
  1541. default:
  1542. printk("pr %#x\n", pr);
  1543. break;
  1544. }
  1545. }
  1546. static void hisax_b_l1l2(struct hisax_if *ifc, int pr, void *arg)
  1547. {
  1548. struct hisax_b_if *b_if = (struct hisax_b_if *) ifc;
  1549. struct BCState *bcs = b_if->bcs;
  1550. struct PStack *st = bcs->st;
  1551. struct sk_buff *skb;
  1552. // FIXME use isdnl1?
  1553. switch (pr) {
  1554. case PH_ACTIVATE | INDICATION:
  1555. st->l1.l1l2(st, pr, NULL);
  1556. break;
  1557. case PH_DEACTIVATE | INDICATION:
  1558. st->l1.l1l2(st, pr, NULL);
  1559. clear_bit(BC_FLG_BUSY, &bcs->Flag);
  1560. skb_queue_purge(&bcs->squeue);
  1561. bcs->hw.b_if = NULL;
  1562. break;
  1563. case PH_DATA | INDICATION:
  1564. skb_queue_tail(&bcs->rqueue, arg);
  1565. hisax_b_sched_event(bcs, B_RCVBUFREADY);
  1566. break;
  1567. case PH_DATA | CONFIRM:
  1568. bcs->tx_cnt -= (int) arg;
  1569. if (test_bit(FLG_LLI_L1WAKEUP,&bcs->st->lli.flag)) {
  1570. u_long flags;
  1571. spin_lock_irqsave(&bcs->aclock, flags);
  1572. bcs->ackcnt += (int) arg;
  1573. spin_unlock_irqrestore(&bcs->aclock, flags);
  1574. schedule_event(bcs, B_ACKPENDING);
  1575. }
  1576. skb = skb_dequeue(&bcs->squeue);
  1577. if (skb) {
  1578. B_L2L1(b_if, PH_DATA | REQUEST, skb);
  1579. break;
  1580. }
  1581. clear_bit(BC_FLG_BUSY, &bcs->Flag);
  1582. if (test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags)) {
  1583. st->l1.l1l2(st, PH_PULL | CONFIRM, NULL);
  1584. }
  1585. break;
  1586. default:
  1587. printk("hisax_b_l1l2 pr %#x\n", pr);
  1588. break;
  1589. }
  1590. }
  1591. static void hisax_d_l2l1(struct PStack *st, int pr, void *arg)
  1592. {
  1593. struct IsdnCardState *cs = st->l1.hardware;
  1594. struct hisax_d_if *hisax_d_if = cs->hw.hisax_d_if;
  1595. struct sk_buff *skb = arg;
  1596. switch (pr) {
  1597. case PH_DATA | REQUEST:
  1598. case PH_PULL | INDICATION:
  1599. if (cs->debug & DEB_DLOG_HEX)
  1600. LogFrame(cs, skb->data, skb->len);
  1601. if (cs->debug & DEB_DLOG_VERBOSE)
  1602. dlogframe(cs, skb, 0);
  1603. Logl2Frame(cs, skb, "PH_DATA_REQ", 0);
  1604. // FIXME lock?
  1605. if (!test_and_set_bit(FLG_L1_DBUSY, &cs->HW_Flags))
  1606. D_L2L1(hisax_d_if, PH_DATA | REQUEST, skb);
  1607. else
  1608. skb_queue_tail(&cs->sq, skb);
  1609. break;
  1610. case PH_PULL | REQUEST:
  1611. if (!test_bit(FLG_L1_DBUSY, &cs->HW_Flags))
  1612. st->l1.l1l2(st, PH_PULL | CONFIRM, NULL);
  1613. else
  1614. set_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
  1615. break;
  1616. default:
  1617. D_L2L1(hisax_d_if, pr, arg);
  1618. break;
  1619. }
  1620. }
  1621. static int hisax_cardmsg(struct IsdnCardState *cs, int mt, void *arg)
  1622. {
  1623. return 0;
  1624. }
  1625. static void hisax_b_l2l1(struct PStack *st, int pr, void *arg)
  1626. {
  1627. struct BCState *bcs = st->l1.bcs;
  1628. struct hisax_b_if *b_if = bcs->hw.b_if;
  1629. switch (pr) {
  1630. case PH_ACTIVATE | REQUEST:
  1631. B_L2L1(b_if, pr, (void *) st->l1.mode);
  1632. break;
  1633. case PH_DATA | REQUEST:
  1634. case PH_PULL | INDICATION:
  1635. // FIXME lock?
  1636. if (!test_and_set_bit(BC_FLG_BUSY, &bcs->Flag)) {
  1637. B_L2L1(b_if, PH_DATA | REQUEST, arg);
  1638. } else {
  1639. skb_queue_tail(&bcs->squeue, arg);
  1640. }
  1641. break;
  1642. case PH_PULL | REQUEST:
  1643. if (!test_bit(BC_FLG_BUSY, &bcs->Flag))
  1644. st->l1.l1l2(st, PH_PULL | CONFIRM, NULL);
  1645. else
  1646. set_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
  1647. break;
  1648. case PH_DEACTIVATE | REQUEST:
  1649. test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag);
  1650. skb_queue_purge(&bcs->squeue);
  1651. default:
  1652. B_L2L1(b_if, pr, arg);
  1653. break;
  1654. }
  1655. }
  1656. static int hisax_bc_setstack(struct PStack *st, struct BCState *bcs)
  1657. {
  1658. struct IsdnCardState *cs = st->l1.hardware;
  1659. struct hisax_d_if *hisax_d_if = cs->hw.hisax_d_if;
  1660. bcs->channel = st->l1.bc;
  1661. bcs->hw.b_if = hisax_d_if->b_if[st->l1.bc];
  1662. hisax_d_if->b_if[st->l1.bc]->bcs = bcs;
  1663. st->l1.bcs = bcs;
  1664. st->l2.l2l1 = hisax_b_l2l1;
  1665. setstack_manager(st);
  1666. bcs->st = st;
  1667. setstack_l1_B(st);
  1668. skb_queue_head_init(&bcs->rqueue);
  1669. skb_queue_head_init(&bcs->squeue);
  1670. return 0;
  1671. }
  1672. static void hisax_bc_close(struct BCState *bcs)
  1673. {
  1674. struct hisax_b_if *b_if = bcs->hw.b_if;
  1675. if (b_if)
  1676. B_L2L1(b_if, PH_DEACTIVATE | REQUEST, NULL);
  1677. }
  1678. static void EChannel_proc_rcv(struct hisax_d_if *d_if)
  1679. {
  1680. struct IsdnCardState *cs = d_if->cs;
  1681. u_char *ptr;
  1682. struct sk_buff *skb;
  1683. while ((skb = skb_dequeue(&d_if->erq)) != NULL) {
  1684. if (cs->debug & DEB_DLOG_HEX) {
  1685. ptr = cs->dlog;
  1686. if ((skb->len) < MAX_DLOG_SPACE / 3 - 10) {
  1687. *ptr++ = 'E';
  1688. *ptr++ = 'C';
  1689. *ptr++ = 'H';
  1690. *ptr++ = 'O';
  1691. *ptr++ = ':';
  1692. ptr += QuickHex(ptr, skb->data, skb->len);
  1693. ptr--;
  1694. *ptr++ = '\n';
  1695. *ptr = 0;
  1696. HiSax_putstatus(cs, NULL, cs->dlog);
  1697. } else
  1698. HiSax_putstatus(cs, "LogEcho: ",
  1699. "warning Frame too big (%d)",
  1700. skb->len);
  1701. }
  1702. dev_kfree_skb_any(skb);
  1703. }
  1704. }
  1705. #ifdef CONFIG_PCI
  1706. #include <linux/pci.h>
  1707. static struct pci_device_id hisax_pci_tbl[] __initdata = {
  1708. #ifdef CONFIG_HISAX_FRITZPCI
  1709. {PCI_VENDOR_ID_AVM, PCI_DEVICE_ID_AVM_A1, PCI_ANY_ID, PCI_ANY_ID},
  1710. #endif
  1711. #ifdef CONFIG_HISAX_DIEHLDIVA
  1712. {PCI_VENDOR_ID_EICON, PCI_DEVICE_ID_EICON_DIVA20, PCI_ANY_ID, PCI_ANY_ID},
  1713. {PCI_VENDOR_ID_EICON, PCI_DEVICE_ID_EICON_DIVA20_U, PCI_ANY_ID, PCI_ANY_ID},
  1714. {PCI_VENDOR_ID_EICON, PCI_DEVICE_ID_EICON_DIVA201, PCI_ANY_ID, PCI_ANY_ID},
  1715. //#########################################################################################
  1716. {PCI_VENDOR_ID_EICON, PCI_DEVICE_ID_EICON_DIVA202, PCI_ANY_ID, PCI_ANY_ID},
  1717. //#########################################################################################
  1718. #endif
  1719. #ifdef CONFIG_HISAX_ELSA
  1720. {PCI_VENDOR_ID_ELSA, PCI_DEVICE_ID_ELSA_MICROLINK, PCI_ANY_ID, PCI_ANY_ID},
  1721. {PCI_VENDOR_ID_ELSA, PCI_DEVICE_ID_ELSA_QS3000, PCI_ANY_ID, PCI_ANY_ID},
  1722. #endif
  1723. #ifdef CONFIG_HISAX_GAZEL
  1724. {PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_R685, PCI_ANY_ID, PCI_ANY_ID},
  1725. {PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_R753, PCI_ANY_ID, PCI_ANY_ID},
  1726. {PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_DJINN_ITOO, PCI_ANY_ID, PCI_ANY_ID},
  1727. {PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_OLITEC, PCI_ANY_ID, PCI_ANY_ID},
  1728. #endif
  1729. #ifdef CONFIG_HISAX_QUADRO
  1730. {PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9050, PCI_ANY_ID, PCI_ANY_ID},
  1731. #endif
  1732. #ifdef CONFIG_HISAX_NICCY
  1733. {PCI_VENDOR_ID_SATSAGEM, PCI_DEVICE_ID_SATSAGEM_NICCY, PCI_ANY_ID,PCI_ANY_ID},
  1734. #endif
  1735. #ifdef CONFIG_HISAX_SEDLBAUER
  1736. {PCI_VENDOR_ID_TIGERJET, PCI_DEVICE_ID_TIGERJET_100, PCI_ANY_ID,PCI_ANY_ID},
  1737. #endif
  1738. #if defined(CONFIG_HISAX_NETJET) || defined(CONFIG_HISAX_NETJET_U)
  1739. {PCI_VENDOR_ID_TIGERJET, PCI_DEVICE_ID_TIGERJET_300, PCI_ANY_ID,PCI_ANY_ID},
  1740. #endif
  1741. #if defined(CONFIG_HISAX_TELESPCI) || defined(CONFIG_HISAX_SCT_QUADRO)
  1742. {PCI_VENDOR_ID_ZORAN, PCI_DEVICE_ID_ZORAN_36120, PCI_ANY_ID,PCI_ANY_ID},
  1743. #endif
  1744. #ifdef CONFIG_HISAX_W6692
  1745. {PCI_VENDOR_ID_DYNALINK, PCI_DEVICE_ID_DYNALINK_IS64PH, PCI_ANY_ID,PCI_ANY_ID},
  1746. {PCI_VENDOR_ID_WINBOND2, PCI_DEVICE_ID_WINBOND2_6692, PCI_ANY_ID,PCI_ANY_ID},
  1747. #endif
  1748. #ifdef CONFIG_HISAX_HFC_PCI
  1749. {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_2BD0, PCI_ANY_ID, PCI_ANY_ID},
  1750. {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B000, PCI_ANY_ID, PCI_ANY_ID},
  1751. {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B006, PCI_ANY_ID, PCI_ANY_ID},
  1752. {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B007, PCI_ANY_ID, PCI_ANY_ID},
  1753. {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B008, PCI_ANY_ID, PCI_ANY_ID},
  1754. {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B009, PCI_ANY_ID, PCI_ANY_ID},
  1755. {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B00A, PCI_ANY_ID, PCI_ANY_ID},
  1756. {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B00B, PCI_ANY_ID, PCI_ANY_ID},
  1757. {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B00C, PCI_ANY_ID, PCI_ANY_ID},
  1758. {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B100, PCI_ANY_ID, PCI_ANY_ID},
  1759. {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B700, PCI_ANY_ID, PCI_ANY_ID},
  1760. {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B701, PCI_ANY_ID, PCI_ANY_ID},
  1761. {PCI_VENDOR_ID_ABOCOM, PCI_DEVICE_ID_ABOCOM_2BD1, PCI_ANY_ID, PCI_ANY_ID},
  1762. {PCI_VENDOR_ID_ASUSTEK, PCI_DEVICE_ID_ASUSTEK_0675, PCI_ANY_ID, PCI_ANY_ID},
  1763. {PCI_VENDOR_ID_BERKOM, PCI_DEVICE_ID_BERKOM_T_CONCEPT, PCI_ANY_ID, PCI_ANY_ID},
  1764. {PCI_VENDOR_ID_BERKOM, PCI_DEVICE_ID_BERKOM_A1T, PCI_ANY_ID, PCI_ANY_ID},
  1765. {PCI_VENDOR_ID_ANIGMA, PCI_DEVICE_ID_ANIGMA_MC145575, PCI_ANY_ID, PCI_ANY_ID},
  1766. {PCI_VENDOR_ID_ZOLTRIX, PCI_DEVICE_ID_ZOLTRIX_2BD0, PCI_ANY_ID, PCI_ANY_ID},
  1767. {PCI_VENDOR_ID_DIGI, PCI_DEVICE_ID_DIGI_DF_M_IOM2_E, PCI_ANY_ID, PCI_ANY_ID},
  1768. {PCI_VENDOR_ID_DIGI, PCI_DEVICE_ID_DIGI_DF_M_E, PCI_ANY_ID, PCI_ANY_ID},
  1769. {PCI_VENDOR_ID_DIGI, PCI_DEVICE_ID_DIGI_DF_M_IOM2_A, PCI_ANY_ID, PCI_ANY_ID},
  1770. {PCI_VENDOR_ID_DIGI, PCI_DEVICE_ID_DIGI_DF_M_A, PCI_ANY_ID, PCI_ANY_ID},
  1771. #endif
  1772. { } /* Terminating entry */
  1773. };
  1774. MODULE_DEVICE_TABLE(pci, hisax_pci_tbl);
  1775. #endif /* CONFIG_PCI */
  1776. module_init(HiSax_init);
  1777. module_exit(HiSax_exit);
  1778. EXPORT_SYMBOL(FsmNew);
  1779. EXPORT_SYMBOL(FsmFree);
  1780. EXPORT_SYMBOL(FsmEvent);
  1781. EXPORT_SYMBOL(FsmChangeState);
  1782. EXPORT_SYMBOL(FsmInitTimer);
  1783. EXPORT_SYMBOL(FsmDelTimer);
  1784. EXPORT_SYMBOL(FsmRestartTimer);