config.c 46 KB

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