config.c 46 KB

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