config.c 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993
  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);