config.c 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001
  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] __devinitdata = { 0, };
  307. static int io1[HISAX_MAX_CARDS] __devinitdata = { 0, };
  308. #endif
  309. static int irq[HISAX_MAX_CARDS] __devinitdata = { 0, };
  310. static int mem[HISAX_MAX_CARDS] __devinitdata = { 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 __devinit 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. /* Used from an exported function but calls __devinit functions.
  1058. * Tell modpost not to warn (__ref)
  1059. */
  1060. static int __ref checkcard(int cardnr, char *id, int *busy_flag,
  1061. struct module *lockowner,
  1062. hisax_setup_func_t card_setup)
  1063. {
  1064. int ret;
  1065. struct IsdnCard *card = cards + cardnr;
  1066. struct IsdnCardState *cs;
  1067. ret = hisax_cs_new(cardnr, id, card, &cs, busy_flag, lockowner);
  1068. if (!ret)
  1069. return 0;
  1070. printk(KERN_INFO
  1071. "HiSax: Card %d Protocol %s Id=%s (%d)\n", cardnr + 1,
  1072. (card->protocol == ISDN_PTYPE_1TR6) ? "1TR6" :
  1073. (card->protocol == ISDN_PTYPE_EURO) ? "EDSS1" :
  1074. (card->protocol == ISDN_PTYPE_LEASED) ? "LEASED" :
  1075. (card->protocol == ISDN_PTYPE_NI1) ? "NI1" :
  1076. "NONE", cs->iif.id, cs->myid);
  1077. ret = card_setup(card);
  1078. if (!ret) {
  1079. ll_unload(cs);
  1080. goto outf_cs;
  1081. }
  1082. ret = hisax_cs_setup(cardnr, card, cs);
  1083. goto out;
  1084. outf_cs:
  1085. kfree(cs);
  1086. card->cs = NULL;
  1087. out:
  1088. return ret;
  1089. }
  1090. static void HiSax_shiftcards(int idx)
  1091. {
  1092. int i;
  1093. for (i = idx; i < (HISAX_MAX_CARDS - 1); i++)
  1094. memcpy(&cards[i], &cards[i + 1], sizeof(cards[i]));
  1095. }
  1096. static int __init HiSax_inithardware(int *busy_flag)
  1097. {
  1098. int foundcards = 0;
  1099. int i = 0;
  1100. int t = ',';
  1101. int flg = 0;
  1102. char *id;
  1103. char *next_id = HiSax_id;
  1104. char ids[20];
  1105. if (strchr(HiSax_id, ','))
  1106. t = ',';
  1107. else if (strchr(HiSax_id, '%'))
  1108. t = '%';
  1109. while (i < nrcards) {
  1110. if (cards[i].typ < 1)
  1111. break;
  1112. id = next_id;
  1113. if ((next_id = strchr(id, t))) {
  1114. *next_id++ = 0;
  1115. strcpy(ids, id);
  1116. flg = i + 1;
  1117. } else {
  1118. next_id = id;
  1119. if (flg >= i)
  1120. strcpy(ids, id);
  1121. else
  1122. sprintf(ids, "%s%d", id, i);
  1123. }
  1124. if (checkcard(i, ids, busy_flag, THIS_MODULE,
  1125. hisax_cs_setup_card)) {
  1126. foundcards++;
  1127. i++;
  1128. } else {
  1129. /* make sure we don't oops the module */
  1130. if (cards[i].typ > 0 && cards[i].typ <= ISDN_CTYPE_COUNT) {
  1131. printk(KERN_WARNING
  1132. "HiSax: Card %s not installed !\n",
  1133. CardType[cards[i].typ]);
  1134. }
  1135. HiSax_shiftcards(i);
  1136. nrcards--;
  1137. }
  1138. }
  1139. return foundcards;
  1140. }
  1141. void HiSax_closecard(int cardnr)
  1142. {
  1143. int i, last = nrcards - 1;
  1144. if (cardnr > last || cardnr < 0)
  1145. return;
  1146. if (cards[cardnr].cs) {
  1147. ll_stop(cards[cardnr].cs);
  1148. release_tei(cards[cardnr].cs);
  1149. CallcFreeChan(cards[cardnr].cs);
  1150. closecard(cardnr);
  1151. if (cards[cardnr].cs->irq)
  1152. free_irq(cards[cardnr].cs->irq, cards[cardnr].cs);
  1153. kfree((void *) cards[cardnr].cs);
  1154. cards[cardnr].cs = NULL;
  1155. }
  1156. i = cardnr;
  1157. while (i <= last) {
  1158. cards[i] = cards[i + 1];
  1159. i++;
  1160. }
  1161. nrcards--;
  1162. }
  1163. void HiSax_reportcard(int cardnr, int sel)
  1164. {
  1165. struct IsdnCardState *cs = cards[cardnr].cs;
  1166. printk(KERN_DEBUG "HiSax: reportcard No %d\n", cardnr + 1);
  1167. printk(KERN_DEBUG "HiSax: Type %s\n", CardType[cs->typ]);
  1168. printk(KERN_DEBUG "HiSax: debuglevel %x\n", cs->debug);
  1169. printk(KERN_DEBUG "HiSax: HiSax_reportcard address 0x%lX\n",
  1170. (ulong) & HiSax_reportcard);
  1171. printk(KERN_DEBUG "HiSax: cs 0x%lX\n", (ulong) cs);
  1172. printk(KERN_DEBUG "HiSax: HW_Flags %lx bc0 flg %lx bc1 flg %lx\n",
  1173. cs->HW_Flags, cs->bcs[0].Flag, cs->bcs[1].Flag);
  1174. printk(KERN_DEBUG "HiSax: bcs 0 mode %d ch%d\n",
  1175. cs->bcs[0].mode, cs->bcs[0].channel);
  1176. printk(KERN_DEBUG "HiSax: bcs 1 mode %d ch%d\n",
  1177. cs->bcs[1].mode, cs->bcs[1].channel);
  1178. #ifdef ERROR_STATISTIC
  1179. printk(KERN_DEBUG "HiSax: dc errors(rx,crc,tx) %d,%d,%d\n",
  1180. cs->err_rx, cs->err_crc, cs->err_tx);
  1181. printk(KERN_DEBUG
  1182. "HiSax: bc0 errors(inv,rdo,crc,tx) %d,%d,%d,%d\n",
  1183. cs->bcs[0].err_inv, cs->bcs[0].err_rdo, cs->bcs[0].err_crc,
  1184. cs->bcs[0].err_tx);
  1185. printk(KERN_DEBUG
  1186. "HiSax: bc1 errors(inv,rdo,crc,tx) %d,%d,%d,%d\n",
  1187. cs->bcs[1].err_inv, cs->bcs[1].err_rdo, cs->bcs[1].err_crc,
  1188. cs->bcs[1].err_tx);
  1189. if (sel == 99) {
  1190. cs->err_rx = 0;
  1191. cs->err_crc = 0;
  1192. cs->err_tx = 0;
  1193. cs->bcs[0].err_inv = 0;
  1194. cs->bcs[0].err_rdo = 0;
  1195. cs->bcs[0].err_crc = 0;
  1196. cs->bcs[0].err_tx = 0;
  1197. cs->bcs[1].err_inv = 0;
  1198. cs->bcs[1].err_rdo = 0;
  1199. cs->bcs[1].err_crc = 0;
  1200. cs->bcs[1].err_tx = 0;
  1201. }
  1202. #endif
  1203. }
  1204. static int __init HiSax_init(void)
  1205. {
  1206. int i, retval;
  1207. #ifdef MODULE
  1208. int j;
  1209. int nzproto = 0;
  1210. #endif
  1211. HiSaxVersion();
  1212. retval = CallcNew();
  1213. if (retval)
  1214. goto out;
  1215. retval = Isdnl3New();
  1216. if (retval)
  1217. goto out_callc;
  1218. retval = Isdnl2New();
  1219. if (retval)
  1220. goto out_isdnl3;
  1221. retval = TeiNew();
  1222. if (retval)
  1223. goto out_isdnl2;
  1224. retval = Isdnl1New();
  1225. if (retval)
  1226. goto out_tei;
  1227. #ifdef MODULE
  1228. if (!type[0]) {
  1229. /* We 'll register drivers later, but init basic functions */
  1230. for (i = 0; i < HISAX_MAX_CARDS; i++)
  1231. cards[i].typ = 0;
  1232. return 0;
  1233. }
  1234. #ifdef CONFIG_HISAX_ELSA
  1235. if (type[0] == ISDN_CTYPE_ELSA_PCMCIA) {
  1236. /* we have exported and return in this case */
  1237. return 0;
  1238. }
  1239. #endif
  1240. #ifdef CONFIG_HISAX_SEDLBAUER
  1241. if (type[0] == ISDN_CTYPE_SEDLBAUER_PCMCIA) {
  1242. /* we have to export and return in this case */
  1243. return 0;
  1244. }
  1245. #endif
  1246. #ifdef CONFIG_HISAX_AVM_A1_PCMCIA
  1247. if (type[0] == ISDN_CTYPE_A1_PCMCIA) {
  1248. /* we have to export and return in this case */
  1249. return 0;
  1250. }
  1251. #endif
  1252. #ifdef CONFIG_HISAX_HFC_SX
  1253. if (type[0] == ISDN_CTYPE_HFC_SP_PCMCIA) {
  1254. /* we have to export and return in this case */
  1255. return 0;
  1256. }
  1257. #endif
  1258. #endif
  1259. nrcards = 0;
  1260. #ifdef MODULE
  1261. if (id) /* If id= string used */
  1262. HiSax_id = id;
  1263. for (i = j = 0; j < HISAX_MAX_CARDS; i++) {
  1264. cards[j].typ = type[i];
  1265. if (protocol[i]) {
  1266. cards[j].protocol = protocol[i];
  1267. nzproto++;
  1268. } else {
  1269. cards[j].protocol = DEFAULT_PROTO;
  1270. }
  1271. switch (type[i]) {
  1272. case ISDN_CTYPE_16_0:
  1273. cards[j].para[0] = irq[i];
  1274. cards[j].para[1] = mem[i];
  1275. cards[j].para[2] = io[i];
  1276. break;
  1277. case ISDN_CTYPE_8_0:
  1278. cards[j].para[0] = irq[i];
  1279. cards[j].para[1] = mem[i];
  1280. break;
  1281. #ifdef IO0_IO1
  1282. case ISDN_CTYPE_PNP:
  1283. case ISDN_CTYPE_NICCY:
  1284. cards[j].para[0] = irq[i];
  1285. cards[j].para[1] = io0[i];
  1286. cards[j].para[2] = io1[i];
  1287. break;
  1288. case ISDN_CTYPE_COMPAQ_ISA:
  1289. cards[j].para[0] = irq[i];
  1290. cards[j].para[1] = io0[i];
  1291. cards[j].para[2] = io1[i];
  1292. cards[j].para[3] = io[i];
  1293. break;
  1294. #endif
  1295. case ISDN_CTYPE_ELSA:
  1296. case ISDN_CTYPE_HFC_PCI:
  1297. cards[j].para[0] = io[i];
  1298. break;
  1299. case ISDN_CTYPE_16_3:
  1300. case ISDN_CTYPE_TELESPCMCIA:
  1301. case ISDN_CTYPE_A1:
  1302. case ISDN_CTYPE_A1_PCMCIA:
  1303. case ISDN_CTYPE_ELSA_PNP:
  1304. case ISDN_CTYPE_ELSA_PCMCIA:
  1305. case ISDN_CTYPE_IX1MICROR2:
  1306. case ISDN_CTYPE_DIEHLDIVA:
  1307. case ISDN_CTYPE_ASUSCOM:
  1308. case ISDN_CTYPE_TELEINT:
  1309. case ISDN_CTYPE_SEDLBAUER:
  1310. case ISDN_CTYPE_SEDLBAUER_PCMCIA:
  1311. case ISDN_CTYPE_SEDLBAUER_FAX:
  1312. case ISDN_CTYPE_SPORTSTER:
  1313. case ISDN_CTYPE_MIC:
  1314. case ISDN_CTYPE_TELES3C:
  1315. case ISDN_CTYPE_ACERP10:
  1316. case ISDN_CTYPE_S0BOX:
  1317. case ISDN_CTYPE_FRITZPCI:
  1318. case ISDN_CTYPE_HSTSAPHIR:
  1319. case ISDN_CTYPE_GAZEL:
  1320. case ISDN_CTYPE_HFC_SX:
  1321. case ISDN_CTYPE_HFC_SP_PCMCIA:
  1322. cards[j].para[0] = irq[i];
  1323. cards[j].para[1] = io[i];
  1324. break;
  1325. case ISDN_CTYPE_ISURF:
  1326. cards[j].para[0] = irq[i];
  1327. cards[j].para[1] = io[i];
  1328. cards[j].para[2] = mem[i];
  1329. break;
  1330. case ISDN_CTYPE_ELSA_PCI:
  1331. case ISDN_CTYPE_NETJET_S:
  1332. case ISDN_CTYPE_TELESPCI:
  1333. case ISDN_CTYPE_W6692:
  1334. case ISDN_CTYPE_NETJET_U:
  1335. break;
  1336. case ISDN_CTYPE_BKM_A4T:
  1337. break;
  1338. case ISDN_CTYPE_SCT_QUADRO:
  1339. if (irq[i]) {
  1340. cards[j].para[0] = irq[i];
  1341. } else {
  1342. /* QUADRO is a 4 BRI card */
  1343. cards[j++].para[0] = 1;
  1344. /* we need to check if further cards can be added */
  1345. if (j < HISAX_MAX_CARDS) {
  1346. cards[j].typ = ISDN_CTYPE_SCT_QUADRO;
  1347. cards[j].protocol = protocol[i];
  1348. cards[j++].para[0] = 2;
  1349. }
  1350. if (j < HISAX_MAX_CARDS) {
  1351. cards[j].typ = ISDN_CTYPE_SCT_QUADRO;
  1352. cards[j].protocol = protocol[i];
  1353. cards[j++].para[0] = 3;
  1354. }
  1355. if (j < HISAX_MAX_CARDS) {
  1356. cards[j].typ = ISDN_CTYPE_SCT_QUADRO;
  1357. cards[j].protocol = protocol[i];
  1358. cards[j].para[0] = 4;
  1359. }
  1360. }
  1361. break;
  1362. }
  1363. j++;
  1364. }
  1365. if (!nzproto) {
  1366. printk(KERN_WARNING
  1367. "HiSax: Warning - no protocol specified\n");
  1368. printk(KERN_WARNING "HiSax: using protocol %s\n",
  1369. DEFAULT_PROTO_NAME);
  1370. }
  1371. #endif
  1372. if (!HiSax_id)
  1373. HiSax_id = HiSaxID;
  1374. if (!HiSaxID[0])
  1375. strcpy(HiSaxID, "HiSax");
  1376. for (i = 0; i < HISAX_MAX_CARDS; i++)
  1377. if (cards[i].typ > 0)
  1378. nrcards++;
  1379. printk(KERN_DEBUG "HiSax: Total %d card%s defined\n",
  1380. nrcards, (nrcards > 1) ? "s" : "");
  1381. /* Install only, if at least one card found */
  1382. if (!HiSax_inithardware(NULL))
  1383. return -ENODEV;
  1384. return 0;
  1385. out_tei:
  1386. TeiFree();
  1387. out_isdnl2:
  1388. Isdnl2Free();
  1389. out_isdnl3:
  1390. Isdnl3Free();
  1391. out_callc:
  1392. CallcFree();
  1393. out:
  1394. return retval;
  1395. }
  1396. static void __exit HiSax_exit(void)
  1397. {
  1398. int cardnr = nrcards - 1;
  1399. while (cardnr >= 0)
  1400. HiSax_closecard(cardnr--);
  1401. Isdnl1Free();
  1402. TeiFree();
  1403. Isdnl2Free();
  1404. Isdnl3Free();
  1405. CallcFree();
  1406. printk(KERN_INFO "HiSax module removed\n");
  1407. }
  1408. #ifdef CONFIG_HOTPLUG
  1409. int __devinit hisax_init_pcmcia(void *pcm_iob, int *busy_flag, struct IsdnCard *card)
  1410. {
  1411. u_char ids[16];
  1412. int ret = -1;
  1413. cards[nrcards] = *card;
  1414. if (nrcards)
  1415. sprintf(ids, "HiSax%d", nrcards);
  1416. else
  1417. sprintf(ids, "HiSax");
  1418. if (!checkcard(nrcards, ids, busy_flag, THIS_MODULE,
  1419. hisax_cs_setup_card))
  1420. goto error;
  1421. ret = nrcards;
  1422. nrcards++;
  1423. error:
  1424. return ret;
  1425. }
  1426. EXPORT_SYMBOL(hisax_init_pcmcia);
  1427. #endif
  1428. EXPORT_SYMBOL(HiSax_closecard);
  1429. #include "hisax_if.h"
  1430. EXPORT_SYMBOL(hisax_register);
  1431. EXPORT_SYMBOL(hisax_unregister);
  1432. static void hisax_d_l1l2(struct hisax_if *ifc, int pr, void *arg);
  1433. static void hisax_b_l1l2(struct hisax_if *ifc, int pr, void *arg);
  1434. static void hisax_d_l2l1(struct PStack *st, int pr, void *arg);
  1435. static void hisax_b_l2l1(struct PStack *st, int pr, void *arg);
  1436. static int hisax_cardmsg(struct IsdnCardState *cs, int mt, void *arg);
  1437. static int hisax_bc_setstack(struct PStack *st, struct BCState *bcs);
  1438. static void hisax_bc_close(struct BCState *bcs);
  1439. static void hisax_bh(struct work_struct *work);
  1440. static void EChannel_proc_rcv(struct hisax_d_if *d_if);
  1441. static int hisax_setup_card_dynamic(struct IsdnCard *card)
  1442. {
  1443. return 2;
  1444. }
  1445. int hisax_register(struct hisax_d_if *hisax_d_if, struct hisax_b_if *b_if[],
  1446. char *name, int protocol)
  1447. {
  1448. int i, retval;
  1449. char id[20];
  1450. struct IsdnCardState *cs;
  1451. for (i = 0; i < HISAX_MAX_CARDS; i++) {
  1452. if (!cards[i].typ)
  1453. break;
  1454. }
  1455. if (i >= HISAX_MAX_CARDS)
  1456. return -EBUSY;
  1457. cards[i].typ = ISDN_CTYPE_DYNAMIC;
  1458. cards[i].protocol = protocol;
  1459. sprintf(id, "%s%d", name, i);
  1460. nrcards++;
  1461. retval = checkcard(i, id, NULL, hisax_d_if->owner,
  1462. hisax_setup_card_dynamic);
  1463. if (retval == 0) { // yuck
  1464. cards[i].typ = 0;
  1465. nrcards--;
  1466. return -EINVAL;
  1467. }
  1468. cs = cards[i].cs;
  1469. hisax_d_if->cs = cs;
  1470. cs->hw.hisax_d_if = hisax_d_if;
  1471. cs->cardmsg = hisax_cardmsg;
  1472. INIT_WORK(&cs->tqueue, hisax_bh);
  1473. cs->channel[0].d_st->l2.l2l1 = hisax_d_l2l1;
  1474. for (i = 0; i < 2; i++) {
  1475. cs->bcs[i].BC_SetStack = hisax_bc_setstack;
  1476. cs->bcs[i].BC_Close = hisax_bc_close;
  1477. b_if[i]->ifc.l1l2 = hisax_b_l1l2;
  1478. hisax_d_if->b_if[i] = b_if[i];
  1479. }
  1480. hisax_d_if->ifc.l1l2 = hisax_d_l1l2;
  1481. skb_queue_head_init(&hisax_d_if->erq);
  1482. clear_bit(0, &hisax_d_if->ph_state);
  1483. return 0;
  1484. }
  1485. void hisax_unregister(struct hisax_d_if *hisax_d_if)
  1486. {
  1487. cards[hisax_d_if->cs->cardnr].typ = 0;
  1488. HiSax_closecard(hisax_d_if->cs->cardnr);
  1489. skb_queue_purge(&hisax_d_if->erq);
  1490. }
  1491. #include "isdnl1.h"
  1492. static void hisax_sched_event(struct IsdnCardState *cs, int event)
  1493. {
  1494. test_and_set_bit(event, &cs->event);
  1495. schedule_work(&cs->tqueue);
  1496. }
  1497. static void hisax_bh(struct work_struct *work)
  1498. {
  1499. struct IsdnCardState *cs =
  1500. container_of(work, struct IsdnCardState, tqueue);
  1501. struct PStack *st;
  1502. int pr;
  1503. if (test_and_clear_bit(D_RCVBUFREADY, &cs->event))
  1504. DChannel_proc_rcv(cs);
  1505. if (test_and_clear_bit(E_RCVBUFREADY, &cs->event))
  1506. EChannel_proc_rcv(cs->hw.hisax_d_if);
  1507. if (test_and_clear_bit(D_L1STATECHANGE, &cs->event)) {
  1508. if (test_bit(0, &cs->hw.hisax_d_if->ph_state))
  1509. pr = PH_ACTIVATE | INDICATION;
  1510. else
  1511. pr = PH_DEACTIVATE | INDICATION;
  1512. for (st = cs->stlist; st; st = st->next)
  1513. st->l1.l1l2(st, pr, NULL);
  1514. }
  1515. }
  1516. static void hisax_b_sched_event(struct BCState *bcs, int event)
  1517. {
  1518. test_and_set_bit(event, &bcs->event);
  1519. schedule_work(&bcs->tqueue);
  1520. }
  1521. static inline void D_L2L1(struct hisax_d_if *d_if, int pr, void *arg)
  1522. {
  1523. struct hisax_if *ifc = (struct hisax_if *) d_if;
  1524. ifc->l2l1(ifc, pr, arg);
  1525. }
  1526. static inline void B_L2L1(struct hisax_b_if *b_if, int pr, void *arg)
  1527. {
  1528. struct hisax_if *ifc = (struct hisax_if *) b_if;
  1529. ifc->l2l1(ifc, pr, arg);
  1530. }
  1531. static void hisax_d_l1l2(struct hisax_if *ifc, int pr, void *arg)
  1532. {
  1533. struct hisax_d_if *d_if = (struct hisax_d_if *) ifc;
  1534. struct IsdnCardState *cs = d_if->cs;
  1535. struct PStack *st;
  1536. struct sk_buff *skb;
  1537. switch (pr) {
  1538. case PH_ACTIVATE | INDICATION:
  1539. set_bit(0, &d_if->ph_state);
  1540. hisax_sched_event(cs, D_L1STATECHANGE);
  1541. break;
  1542. case PH_DEACTIVATE | INDICATION:
  1543. clear_bit(0, &d_if->ph_state);
  1544. hisax_sched_event(cs, D_L1STATECHANGE);
  1545. break;
  1546. case PH_DATA | INDICATION:
  1547. skb_queue_tail(&cs->rq, arg);
  1548. hisax_sched_event(cs, D_RCVBUFREADY);
  1549. break;
  1550. case PH_DATA | CONFIRM:
  1551. skb = skb_dequeue(&cs->sq);
  1552. if (skb) {
  1553. D_L2L1(d_if, PH_DATA | REQUEST, skb);
  1554. break;
  1555. }
  1556. clear_bit(FLG_L1_DBUSY, &cs->HW_Flags);
  1557. for (st = cs->stlist; st; st = st->next) {
  1558. if (test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags)) {
  1559. st->l1.l1l2(st, PH_PULL | CONFIRM, NULL);
  1560. break;
  1561. }
  1562. }
  1563. break;
  1564. case PH_DATA_E | INDICATION:
  1565. skb_queue_tail(&d_if->erq, arg);
  1566. hisax_sched_event(cs, E_RCVBUFREADY);
  1567. break;
  1568. default:
  1569. printk("pr %#x\n", pr);
  1570. break;
  1571. }
  1572. }
  1573. static void hisax_b_l1l2(struct hisax_if *ifc, int pr, void *arg)
  1574. {
  1575. struct hisax_b_if *b_if = (struct hisax_b_if *) ifc;
  1576. struct BCState *bcs = b_if->bcs;
  1577. struct PStack *st = bcs->st;
  1578. struct sk_buff *skb;
  1579. // FIXME use isdnl1?
  1580. switch (pr) {
  1581. case PH_ACTIVATE | INDICATION:
  1582. st->l1.l1l2(st, pr, NULL);
  1583. break;
  1584. case PH_DEACTIVATE | INDICATION:
  1585. st->l1.l1l2(st, pr, NULL);
  1586. clear_bit(BC_FLG_BUSY, &bcs->Flag);
  1587. skb_queue_purge(&bcs->squeue);
  1588. bcs->hw.b_if = NULL;
  1589. break;
  1590. case PH_DATA | INDICATION:
  1591. skb_queue_tail(&bcs->rqueue, arg);
  1592. hisax_b_sched_event(bcs, B_RCVBUFREADY);
  1593. break;
  1594. case PH_DATA | CONFIRM:
  1595. bcs->tx_cnt -= (long)arg;
  1596. if (test_bit(FLG_LLI_L1WAKEUP,&bcs->st->lli.flag)) {
  1597. u_long flags;
  1598. spin_lock_irqsave(&bcs->aclock, flags);
  1599. bcs->ackcnt += (long)arg;
  1600. spin_unlock_irqrestore(&bcs->aclock, flags);
  1601. schedule_event(bcs, B_ACKPENDING);
  1602. }
  1603. skb = skb_dequeue(&bcs->squeue);
  1604. if (skb) {
  1605. B_L2L1(b_if, PH_DATA | REQUEST, skb);
  1606. break;
  1607. }
  1608. clear_bit(BC_FLG_BUSY, &bcs->Flag);
  1609. if (test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags)) {
  1610. st->l1.l1l2(st, PH_PULL | CONFIRM, NULL);
  1611. }
  1612. break;
  1613. default:
  1614. printk("hisax_b_l1l2 pr %#x\n", pr);
  1615. break;
  1616. }
  1617. }
  1618. static void hisax_d_l2l1(struct PStack *st, int pr, void *arg)
  1619. {
  1620. struct IsdnCardState *cs = st->l1.hardware;
  1621. struct hisax_d_if *hisax_d_if = cs->hw.hisax_d_if;
  1622. struct sk_buff *skb = arg;
  1623. switch (pr) {
  1624. case PH_DATA | REQUEST:
  1625. case PH_PULL | INDICATION:
  1626. if (cs->debug & DEB_DLOG_HEX)
  1627. LogFrame(cs, skb->data, skb->len);
  1628. if (cs->debug & DEB_DLOG_VERBOSE)
  1629. dlogframe(cs, skb, 0);
  1630. Logl2Frame(cs, skb, "PH_DATA_REQ", 0);
  1631. // FIXME lock?
  1632. if (!test_and_set_bit(FLG_L1_DBUSY, &cs->HW_Flags))
  1633. D_L2L1(hisax_d_if, PH_DATA | REQUEST, skb);
  1634. else
  1635. skb_queue_tail(&cs->sq, skb);
  1636. break;
  1637. case PH_PULL | REQUEST:
  1638. if (!test_bit(FLG_L1_DBUSY, &cs->HW_Flags))
  1639. st->l1.l1l2(st, PH_PULL | CONFIRM, NULL);
  1640. else
  1641. set_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
  1642. break;
  1643. default:
  1644. D_L2L1(hisax_d_if, pr, arg);
  1645. break;
  1646. }
  1647. }
  1648. static int hisax_cardmsg(struct IsdnCardState *cs, int mt, void *arg)
  1649. {
  1650. return 0;
  1651. }
  1652. static void hisax_b_l2l1(struct PStack *st, int pr, void *arg)
  1653. {
  1654. struct BCState *bcs = st->l1.bcs;
  1655. struct hisax_b_if *b_if = bcs->hw.b_if;
  1656. switch (pr) {
  1657. case PH_ACTIVATE | REQUEST:
  1658. B_L2L1(b_if, pr, (void *)(unsigned long)st->l1.mode);
  1659. break;
  1660. case PH_DATA | REQUEST:
  1661. case PH_PULL | INDICATION:
  1662. // FIXME lock?
  1663. if (!test_and_set_bit(BC_FLG_BUSY, &bcs->Flag)) {
  1664. B_L2L1(b_if, PH_DATA | REQUEST, arg);
  1665. } else {
  1666. skb_queue_tail(&bcs->squeue, arg);
  1667. }
  1668. break;
  1669. case PH_PULL | REQUEST:
  1670. if (!test_bit(BC_FLG_BUSY, &bcs->Flag))
  1671. st->l1.l1l2(st, PH_PULL | CONFIRM, NULL);
  1672. else
  1673. set_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
  1674. break;
  1675. case PH_DEACTIVATE | REQUEST:
  1676. test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag);
  1677. skb_queue_purge(&bcs->squeue);
  1678. default:
  1679. B_L2L1(b_if, pr, arg);
  1680. break;
  1681. }
  1682. }
  1683. static int hisax_bc_setstack(struct PStack *st, struct BCState *bcs)
  1684. {
  1685. struct IsdnCardState *cs = st->l1.hardware;
  1686. struct hisax_d_if *hisax_d_if = cs->hw.hisax_d_if;
  1687. bcs->channel = st->l1.bc;
  1688. bcs->hw.b_if = hisax_d_if->b_if[st->l1.bc];
  1689. hisax_d_if->b_if[st->l1.bc]->bcs = bcs;
  1690. st->l1.bcs = bcs;
  1691. st->l2.l2l1 = hisax_b_l2l1;
  1692. setstack_manager(st);
  1693. bcs->st = st;
  1694. setstack_l1_B(st);
  1695. skb_queue_head_init(&bcs->rqueue);
  1696. skb_queue_head_init(&bcs->squeue);
  1697. return 0;
  1698. }
  1699. static void hisax_bc_close(struct BCState *bcs)
  1700. {
  1701. struct hisax_b_if *b_if = bcs->hw.b_if;
  1702. if (b_if)
  1703. B_L2L1(b_if, PH_DEACTIVATE | REQUEST, NULL);
  1704. }
  1705. static void EChannel_proc_rcv(struct hisax_d_if *d_if)
  1706. {
  1707. struct IsdnCardState *cs = d_if->cs;
  1708. u_char *ptr;
  1709. struct sk_buff *skb;
  1710. while ((skb = skb_dequeue(&d_if->erq)) != NULL) {
  1711. if (cs->debug & DEB_DLOG_HEX) {
  1712. ptr = cs->dlog;
  1713. if ((skb->len) < MAX_DLOG_SPACE / 3 - 10) {
  1714. *ptr++ = 'E';
  1715. *ptr++ = 'C';
  1716. *ptr++ = 'H';
  1717. *ptr++ = 'O';
  1718. *ptr++ = ':';
  1719. ptr += QuickHex(ptr, skb->data, skb->len);
  1720. ptr--;
  1721. *ptr++ = '\n';
  1722. *ptr = 0;
  1723. HiSax_putstatus(cs, NULL, cs->dlog);
  1724. } else
  1725. HiSax_putstatus(cs, "LogEcho: ",
  1726. "warning Frame too big (%d)",
  1727. skb->len);
  1728. }
  1729. dev_kfree_skb_any(skb);
  1730. }
  1731. }
  1732. #ifdef CONFIG_PCI
  1733. #include <linux/pci.h>
  1734. static struct pci_device_id hisax_pci_tbl[] __devinitdata __used = {
  1735. #ifdef CONFIG_HISAX_FRITZPCI
  1736. {PCI_VDEVICE(AVM, PCI_DEVICE_ID_AVM_A1) },
  1737. #endif
  1738. #ifdef CONFIG_HISAX_DIEHLDIVA
  1739. {PCI_VDEVICE(EICON, PCI_DEVICE_ID_EICON_DIVA20) },
  1740. {PCI_VDEVICE(EICON, PCI_DEVICE_ID_EICON_DIVA20_U) },
  1741. {PCI_VDEVICE(EICON, PCI_DEVICE_ID_EICON_DIVA201) },
  1742. /*##########################################################################*/
  1743. {PCI_VDEVICE(EICON, PCI_DEVICE_ID_EICON_DIVA202) },
  1744. /*##########################################################################*/
  1745. #endif
  1746. #ifdef CONFIG_HISAX_ELSA
  1747. {PCI_VDEVICE(ELSA, PCI_DEVICE_ID_ELSA_MICROLINK) },
  1748. {PCI_VDEVICE(ELSA, PCI_DEVICE_ID_ELSA_QS3000) },
  1749. #endif
  1750. #ifdef CONFIG_HISAX_GAZEL
  1751. {PCI_VDEVICE(PLX, PCI_DEVICE_ID_PLX_R685) },
  1752. {PCI_VDEVICE(PLX, PCI_DEVICE_ID_PLX_R753) },
  1753. {PCI_VDEVICE(PLX, PCI_DEVICE_ID_PLX_DJINN_ITOO) },
  1754. {PCI_VDEVICE(PLX, PCI_DEVICE_ID_PLX_OLITEC) },
  1755. #endif
  1756. #ifdef CONFIG_HISAX_SCT_QUADRO
  1757. {PCI_VDEVICE(PLX, PCI_DEVICE_ID_PLX_9050) },
  1758. #endif
  1759. #ifdef CONFIG_HISAX_NICCY
  1760. {PCI_VDEVICE(SATSAGEM, PCI_DEVICE_ID_SATSAGEM_NICCY) },
  1761. #endif
  1762. #ifdef CONFIG_HISAX_SEDLBAUER
  1763. {PCI_VDEVICE(TIGERJET, PCI_DEVICE_ID_TIGERJET_100) },
  1764. #endif
  1765. #if defined(CONFIG_HISAX_NETJET) || defined(CONFIG_HISAX_NETJET_U)
  1766. {PCI_VDEVICE(TIGERJET, PCI_DEVICE_ID_TIGERJET_300) },
  1767. #endif
  1768. #if defined(CONFIG_HISAX_TELESPCI) || defined(CONFIG_HISAX_SCT_QUADRO)
  1769. {PCI_VDEVICE(ZORAN, PCI_DEVICE_ID_ZORAN_36120) },
  1770. #endif
  1771. #ifdef CONFIG_HISAX_W6692
  1772. {PCI_VDEVICE(DYNALINK, PCI_DEVICE_ID_DYNALINK_IS64PH) },
  1773. {PCI_VDEVICE(WINBOND2, PCI_DEVICE_ID_WINBOND2_6692) },
  1774. #endif
  1775. #ifdef CONFIG_HISAX_HFC_PCI
  1776. {PCI_VDEVICE(CCD, PCI_DEVICE_ID_CCD_2BD0) },
  1777. {PCI_VDEVICE(CCD, PCI_DEVICE_ID_CCD_B000) },
  1778. {PCI_VDEVICE(CCD, PCI_DEVICE_ID_CCD_B006) },
  1779. {PCI_VDEVICE(CCD, PCI_DEVICE_ID_CCD_B007) },
  1780. {PCI_VDEVICE(CCD, PCI_DEVICE_ID_CCD_B008) },
  1781. {PCI_VDEVICE(CCD, PCI_DEVICE_ID_CCD_B009) },
  1782. {PCI_VDEVICE(CCD, PCI_DEVICE_ID_CCD_B00A) },
  1783. {PCI_VDEVICE(CCD, PCI_DEVICE_ID_CCD_B00B) },
  1784. {PCI_VDEVICE(CCD, PCI_DEVICE_ID_CCD_B00C) },
  1785. {PCI_VDEVICE(CCD, PCI_DEVICE_ID_CCD_B100) },
  1786. {PCI_VDEVICE(CCD, PCI_DEVICE_ID_CCD_B700) },
  1787. {PCI_VDEVICE(CCD, PCI_DEVICE_ID_CCD_B701) },
  1788. {PCI_VDEVICE(ABOCOM, PCI_DEVICE_ID_ABOCOM_2BD1) },
  1789. {PCI_VDEVICE(ASUSTEK, PCI_DEVICE_ID_ASUSTEK_0675) },
  1790. {PCI_VDEVICE(BERKOM, PCI_DEVICE_ID_BERKOM_T_CONCEPT) },
  1791. {PCI_VDEVICE(BERKOM, PCI_DEVICE_ID_BERKOM_A1T) },
  1792. {PCI_VDEVICE(ANIGMA, PCI_DEVICE_ID_ANIGMA_MC145575) },
  1793. {PCI_VDEVICE(ZOLTRIX, PCI_DEVICE_ID_ZOLTRIX_2BD0) },
  1794. {PCI_VDEVICE(DIGI, PCI_DEVICE_ID_DIGI_DF_M_IOM2_E) },
  1795. {PCI_VDEVICE(DIGI, PCI_DEVICE_ID_DIGI_DF_M_E) },
  1796. {PCI_VDEVICE(DIGI, PCI_DEVICE_ID_DIGI_DF_M_IOM2_A) },
  1797. {PCI_VDEVICE(DIGI, PCI_DEVICE_ID_DIGI_DF_M_A) },
  1798. #endif
  1799. { } /* Terminating entry */
  1800. };
  1801. MODULE_DEVICE_TABLE(pci, hisax_pci_tbl);
  1802. #endif /* CONFIG_PCI */
  1803. module_init(HiSax_init);
  1804. module_exit(HiSax_exit);
  1805. EXPORT_SYMBOL(FsmNew);
  1806. EXPORT_SYMBOL(FsmFree);
  1807. EXPORT_SYMBOL(FsmEvent);
  1808. EXPORT_SYMBOL(FsmChangeState);
  1809. EXPORT_SYMBOL(FsmInitTimer);
  1810. EXPORT_SYMBOL(FsmDelTimer);
  1811. EXPORT_SYMBOL(FsmRestartTimer);