config.c 46 KB

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