sedlbauer.c 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879
  1. /* $Id: sedlbauer.c,v 1.34.2.6 2004/01/24 20:47:24 keil Exp $
  2. *
  3. * low level stuff for Sedlbauer cards
  4. * includes support for the Sedlbauer speed star (speed star II),
  5. * support for the Sedlbauer speed fax+,
  6. * support for the Sedlbauer ISDN-Controller PC/104 and
  7. * support for the Sedlbauer speed pci
  8. * derived from the original file asuscom.c from Karsten Keil
  9. *
  10. * Author Marcus Niemann
  11. * Copyright by Marcus Niemann <niemann@www-bib.fh-bielefeld.de>
  12. *
  13. * This software may be used and distributed according to the terms
  14. * of the GNU General Public License, incorporated herein by reference.
  15. *
  16. * Thanks to Karsten Keil
  17. * Sedlbauer AG for informations
  18. * Edgar Toernig
  19. *
  20. */
  21. /* Supported cards:
  22. * Card: Chip: Configuration: Comment:
  23. * ---------------------------------------------------------------------
  24. * Speed Card ISAC_HSCX DIP-SWITCH
  25. * Speed Win ISAC_HSCX ISAPNP
  26. * Speed Fax+ ISAC_ISAR ISAPNP Full analog support
  27. * Speed Star ISAC_HSCX CARDMGR
  28. * Speed Win2 IPAC ISAPNP
  29. * ISDN PC/104 IPAC DIP-SWITCH
  30. * Speed Star2 IPAC CARDMGR
  31. * Speed PCI IPAC PCI PNP
  32. * Speed Fax+ ISAC_ISAR PCI PNP Full analog support
  33. *
  34. * Important:
  35. * For the sedlbauer speed fax+ to work properly you have to download
  36. * the firmware onto the card.
  37. * For example: hisaxctrl <DriverID> 9 ISAR.BIN
  38. */
  39. #include <linux/init.h>
  40. #include "hisax.h"
  41. #include "isac.h"
  42. #include "ipac.h"
  43. #include "hscx.h"
  44. #include "isar.h"
  45. #include "isdnl1.h"
  46. #include <linux/pci.h>
  47. #include <linux/isapnp.h>
  48. static const char *Sedlbauer_revision = "$Revision: 1.34.2.6 $";
  49. static const char *Sedlbauer_Types[] =
  50. {"None", "speed card/win", "speed star", "speed fax+",
  51. "speed win II / ISDN PC/104", "speed star II", "speed pci",
  52. "speed fax+ pyramid", "speed fax+ pci", "HST Saphir III"};
  53. #define PCI_SUBVENDOR_SPEEDFAX_PYRAMID 0x51
  54. #define PCI_SUBVENDOR_HST_SAPHIR3 0x52
  55. #define PCI_SUBVENDOR_SEDLBAUER_PCI 0x53
  56. #define PCI_SUBVENDOR_SPEEDFAX_PCI 0x54
  57. #define PCI_SUB_ID_SEDLBAUER 0x01
  58. #define SEDL_SPEED_CARD_WIN 1
  59. #define SEDL_SPEED_STAR 2
  60. #define SEDL_SPEED_FAX 3
  61. #define SEDL_SPEED_WIN2_PC104 4
  62. #define SEDL_SPEED_STAR2 5
  63. #define SEDL_SPEED_PCI 6
  64. #define SEDL_SPEEDFAX_PYRAMID 7
  65. #define SEDL_SPEEDFAX_PCI 8
  66. #define HST_SAPHIR3 9
  67. #define SEDL_CHIP_TEST 0
  68. #define SEDL_CHIP_ISAC_HSCX 1
  69. #define SEDL_CHIP_ISAC_ISAR 2
  70. #define SEDL_CHIP_IPAC 3
  71. #define SEDL_BUS_ISA 1
  72. #define SEDL_BUS_PCI 2
  73. #define SEDL_BUS_PCMCIA 3
  74. #define byteout(addr,val) outb(val,addr)
  75. #define bytein(addr) inb(addr)
  76. #define SEDL_HSCX_ISA_RESET_ON 0
  77. #define SEDL_HSCX_ISA_RESET_OFF 1
  78. #define SEDL_HSCX_ISA_ISAC 2
  79. #define SEDL_HSCX_ISA_HSCX 3
  80. #define SEDL_HSCX_ISA_ADR 4
  81. #define SEDL_HSCX_PCMCIA_RESET 0
  82. #define SEDL_HSCX_PCMCIA_ISAC 1
  83. #define SEDL_HSCX_PCMCIA_HSCX 2
  84. #define SEDL_HSCX_PCMCIA_ADR 4
  85. #define SEDL_ISAR_ISA_ISAC 4
  86. #define SEDL_ISAR_ISA_ISAR 6
  87. #define SEDL_ISAR_ISA_ADR 8
  88. #define SEDL_ISAR_ISA_ISAR_RESET_ON 10
  89. #define SEDL_ISAR_ISA_ISAR_RESET_OFF 12
  90. #define SEDL_IPAC_ANY_ADR 0
  91. #define SEDL_IPAC_ANY_IPAC 2
  92. #define SEDL_IPAC_PCI_BASE 0
  93. #define SEDL_IPAC_PCI_ADR 0xc0
  94. #define SEDL_IPAC_PCI_IPAC 0xc8
  95. #define SEDL_ISAR_PCI_ADR 0xc8
  96. #define SEDL_ISAR_PCI_ISAC 0xd0
  97. #define SEDL_ISAR_PCI_ISAR 0xe0
  98. #define SEDL_ISAR_PCI_ISAR_RESET_ON 0x01
  99. #define SEDL_ISAR_PCI_ISAR_RESET_OFF 0x18
  100. #define SEDL_ISAR_PCI_LED1 0x08
  101. #define SEDL_ISAR_PCI_LED2 0x10
  102. #define SEDL_RESET 0x3 /* same as DOS driver */
  103. static inline u_char
  104. readreg(unsigned int ale, unsigned int adr, u_char off)
  105. {
  106. register u_char ret;
  107. byteout(ale, off);
  108. ret = bytein(adr);
  109. return (ret);
  110. }
  111. static inline void
  112. readfifo(unsigned int ale, unsigned int adr, u_char off, u_char * data, int size)
  113. {
  114. byteout(ale, off);
  115. insb(adr, data, size);
  116. }
  117. static inline void
  118. writereg(unsigned int ale, unsigned int adr, u_char off, u_char data)
  119. {
  120. byteout(ale, off);
  121. byteout(adr, data);
  122. }
  123. static inline void
  124. writefifo(unsigned int ale, unsigned int adr, u_char off, u_char * data, int size)
  125. {
  126. byteout(ale, off);
  127. outsb(adr, data, size);
  128. }
  129. /* Interface functions */
  130. static u_char
  131. ReadISAC(struct IsdnCardState *cs, u_char offset)
  132. {
  133. return (readreg(cs->hw.sedl.adr, cs->hw.sedl.isac, offset));
  134. }
  135. static void
  136. WriteISAC(struct IsdnCardState *cs, u_char offset, u_char value)
  137. {
  138. writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, offset, value);
  139. }
  140. static void
  141. ReadISACfifo(struct IsdnCardState *cs, u_char * data, int size)
  142. {
  143. readfifo(cs->hw.sedl.adr, cs->hw.sedl.isac, 0, data, size);
  144. }
  145. static void
  146. WriteISACfifo(struct IsdnCardState *cs, u_char * data, int size)
  147. {
  148. writefifo(cs->hw.sedl.adr, cs->hw.sedl.isac, 0, data, size);
  149. }
  150. static u_char
  151. ReadISAC_IPAC(struct IsdnCardState *cs, u_char offset)
  152. {
  153. return (readreg(cs->hw.sedl.adr, cs->hw.sedl.isac, offset|0x80));
  154. }
  155. static void
  156. WriteISAC_IPAC(struct IsdnCardState *cs, u_char offset, u_char value)
  157. {
  158. writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, offset|0x80, value);
  159. }
  160. static void
  161. ReadISACfifo_IPAC(struct IsdnCardState *cs, u_char * data, int size)
  162. {
  163. readfifo(cs->hw.sedl.adr, cs->hw.sedl.isac, 0x80, data, size);
  164. }
  165. static void
  166. WriteISACfifo_IPAC(struct IsdnCardState *cs, u_char * data, int size)
  167. {
  168. writefifo(cs->hw.sedl.adr, cs->hw.sedl.isac, 0x80, data, size);
  169. }
  170. static u_char
  171. ReadHSCX(struct IsdnCardState *cs, int hscx, u_char offset)
  172. {
  173. return (readreg(cs->hw.sedl.adr,
  174. cs->hw.sedl.hscx, offset + (hscx ? 0x40 : 0)));
  175. }
  176. static void
  177. WriteHSCX(struct IsdnCardState *cs, int hscx, u_char offset, u_char value)
  178. {
  179. writereg(cs->hw.sedl.adr,
  180. cs->hw.sedl.hscx, offset + (hscx ? 0x40 : 0), value);
  181. }
  182. /* ISAR access routines
  183. * mode = 0 access with IRQ on
  184. * mode = 1 access with IRQ off
  185. * mode = 2 access with IRQ off and using last offset
  186. */
  187. static u_char
  188. ReadISAR(struct IsdnCardState *cs, int mode, u_char offset)
  189. {
  190. if (mode == 0)
  191. return (readreg(cs->hw.sedl.adr, cs->hw.sedl.hscx, offset));
  192. else if (mode == 1)
  193. byteout(cs->hw.sedl.adr, offset);
  194. return(bytein(cs->hw.sedl.hscx));
  195. }
  196. static void
  197. WriteISAR(struct IsdnCardState *cs, int mode, u_char offset, u_char value)
  198. {
  199. if (mode == 0)
  200. writereg(cs->hw.sedl.adr, cs->hw.sedl.hscx, offset, value);
  201. else {
  202. if (mode == 1)
  203. byteout(cs->hw.sedl.adr, offset);
  204. byteout(cs->hw.sedl.hscx, value);
  205. }
  206. }
  207. /*
  208. * fast interrupt HSCX stuff goes here
  209. */
  210. #define READHSCX(cs, nr, reg) readreg(cs->hw.sedl.adr, \
  211. cs->hw.sedl.hscx, reg + (nr ? 0x40 : 0))
  212. #define WRITEHSCX(cs, nr, reg, data) writereg(cs->hw.sedl.adr, \
  213. cs->hw.sedl.hscx, reg + (nr ? 0x40 : 0), data)
  214. #define READHSCXFIFO(cs, nr, ptr, cnt) readfifo(cs->hw.sedl.adr, \
  215. cs->hw.sedl.hscx, (nr ? 0x40 : 0), ptr, cnt)
  216. #define WRITEHSCXFIFO(cs, nr, ptr, cnt) writefifo(cs->hw.sedl.adr, \
  217. cs->hw.sedl.hscx, (nr ? 0x40 : 0), ptr, cnt)
  218. #include "hscx_irq.c"
  219. static irqreturn_t
  220. sedlbauer_interrupt(int intno, void *dev_id)
  221. {
  222. struct IsdnCardState *cs = dev_id;
  223. u_char val;
  224. u_long flags;
  225. spin_lock_irqsave(&cs->lock, flags);
  226. if ((cs->hw.sedl.bus == SEDL_BUS_PCMCIA) && (*cs->busy_flag == 1)) {
  227. /* The card tends to generate interrupts while being removed
  228. causing us to just crash the kernel. bad. */
  229. spin_unlock_irqrestore(&cs->lock, flags);
  230. printk(KERN_WARNING "Sedlbauer: card not available!\n");
  231. return IRQ_NONE;
  232. }
  233. val = readreg(cs->hw.sedl.adr, cs->hw.sedl.hscx, HSCX_ISTA + 0x40);
  234. Start_HSCX:
  235. if (val)
  236. hscx_int_main(cs, val);
  237. val = readreg(cs->hw.sedl.adr, cs->hw.sedl.isac, ISAC_ISTA);
  238. Start_ISAC:
  239. if (val)
  240. isac_interrupt(cs, val);
  241. val = readreg(cs->hw.sedl.adr, cs->hw.sedl.hscx, HSCX_ISTA + 0x40);
  242. if (val) {
  243. if (cs->debug & L1_DEB_HSCX)
  244. debugl1(cs, "HSCX IntStat after IntRoutine");
  245. goto Start_HSCX;
  246. }
  247. val = readreg(cs->hw.sedl.adr, cs->hw.sedl.isac, ISAC_ISTA);
  248. if (val) {
  249. if (cs->debug & L1_DEB_ISAC)
  250. debugl1(cs, "ISAC IntStat after IntRoutine");
  251. goto Start_ISAC;
  252. }
  253. writereg(cs->hw.sedl.adr, cs->hw.sedl.hscx, HSCX_MASK, 0xFF);
  254. writereg(cs->hw.sedl.adr, cs->hw.sedl.hscx, HSCX_MASK + 0x40, 0xFF);
  255. writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, ISAC_MASK, 0xFF);
  256. writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, ISAC_MASK, 0x0);
  257. writereg(cs->hw.sedl.adr, cs->hw.sedl.hscx, HSCX_MASK, 0x0);
  258. writereg(cs->hw.sedl.adr, cs->hw.sedl.hscx, HSCX_MASK + 0x40, 0x0);
  259. spin_unlock_irqrestore(&cs->lock, flags);
  260. return IRQ_HANDLED;
  261. }
  262. static irqreturn_t
  263. sedlbauer_interrupt_ipac(int intno, void *dev_id)
  264. {
  265. struct IsdnCardState *cs = dev_id;
  266. u_char ista, val, icnt = 5;
  267. u_long flags;
  268. spin_lock_irqsave(&cs->lock, flags);
  269. ista = readreg(cs->hw.sedl.adr, cs->hw.sedl.isac, IPAC_ISTA);
  270. Start_IPAC:
  271. if (cs->debug & L1_DEB_IPAC)
  272. debugl1(cs, "IPAC ISTA %02X", ista);
  273. if (ista & 0x0f) {
  274. val = readreg(cs->hw.sedl.adr, cs->hw.sedl.hscx, HSCX_ISTA + 0x40);
  275. if (ista & 0x01)
  276. val |= 0x01;
  277. if (ista & 0x04)
  278. val |= 0x02;
  279. if (ista & 0x08)
  280. val |= 0x04;
  281. if (val)
  282. hscx_int_main(cs, val);
  283. }
  284. if (ista & 0x20) {
  285. val = 0xfe & readreg(cs->hw.sedl.adr, cs->hw.sedl.isac, ISAC_ISTA | 0x80);
  286. if (val) {
  287. isac_interrupt(cs, val);
  288. }
  289. }
  290. if (ista & 0x10) {
  291. val = 0x01;
  292. isac_interrupt(cs, val);
  293. }
  294. ista = readreg(cs->hw.sedl.adr, cs->hw.sedl.isac, IPAC_ISTA);
  295. if ((ista & 0x3f) && icnt) {
  296. icnt--;
  297. goto Start_IPAC;
  298. }
  299. if (!icnt)
  300. if (cs->debug & L1_DEB_ISAC)
  301. debugl1(cs, "Sedlbauer IRQ LOOP");
  302. writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, IPAC_MASK, 0xFF);
  303. writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, IPAC_MASK, 0xC0);
  304. spin_unlock_irqrestore(&cs->lock, flags);
  305. return IRQ_HANDLED;
  306. }
  307. static irqreturn_t
  308. sedlbauer_interrupt_isar(int intno, void *dev_id)
  309. {
  310. struct IsdnCardState *cs = dev_id;
  311. u_char val;
  312. int cnt = 5;
  313. u_long flags;
  314. spin_lock_irqsave(&cs->lock, flags);
  315. val = readreg(cs->hw.sedl.adr, cs->hw.sedl.hscx, ISAR_IRQBIT);
  316. Start_ISAR:
  317. if (val & ISAR_IRQSTA)
  318. isar_int_main(cs);
  319. val = readreg(cs->hw.sedl.adr, cs->hw.sedl.isac, ISAC_ISTA);
  320. Start_ISAC:
  321. if (val)
  322. isac_interrupt(cs, val);
  323. val = readreg(cs->hw.sedl.adr, cs->hw.sedl.hscx, ISAR_IRQBIT);
  324. if ((val & ISAR_IRQSTA) && --cnt) {
  325. if (cs->debug & L1_DEB_HSCX)
  326. debugl1(cs, "ISAR IntStat after IntRoutine");
  327. goto Start_ISAR;
  328. }
  329. val = readreg(cs->hw.sedl.adr, cs->hw.sedl.isac, ISAC_ISTA);
  330. if (val && --cnt) {
  331. if (cs->debug & L1_DEB_ISAC)
  332. debugl1(cs, "ISAC IntStat after IntRoutine");
  333. goto Start_ISAC;
  334. }
  335. if (!cnt)
  336. if (cs->debug & L1_DEB_ISAC)
  337. debugl1(cs, "Sedlbauer IRQ LOOP");
  338. writereg(cs->hw.sedl.adr, cs->hw.sedl.hscx, ISAR_IRQBIT, 0);
  339. writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, ISAC_MASK, 0xFF);
  340. writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, ISAC_MASK, 0x0);
  341. writereg(cs->hw.sedl.adr, cs->hw.sedl.hscx, ISAR_IRQBIT, ISAR_IRQMSK);
  342. spin_unlock_irqrestore(&cs->lock, flags);
  343. return IRQ_HANDLED;
  344. }
  345. static void
  346. release_io_sedlbauer(struct IsdnCardState *cs)
  347. {
  348. int bytecnt = 8;
  349. if (cs->subtyp == SEDL_SPEED_FAX) {
  350. bytecnt = 16;
  351. } else if (cs->hw.sedl.bus == SEDL_BUS_PCI) {
  352. bytecnt = 256;
  353. }
  354. if (cs->hw.sedl.cfg_reg)
  355. release_region(cs->hw.sedl.cfg_reg, bytecnt);
  356. }
  357. static void
  358. reset_sedlbauer(struct IsdnCardState *cs)
  359. {
  360. printk(KERN_INFO "Sedlbauer: resetting card\n");
  361. if (!((cs->hw.sedl.bus == SEDL_BUS_PCMCIA) &&
  362. (cs->hw.sedl.chip == SEDL_CHIP_ISAC_HSCX))) {
  363. if (cs->hw.sedl.chip == SEDL_CHIP_IPAC) {
  364. writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, IPAC_POTA2, 0x20);
  365. mdelay(2);
  366. writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, IPAC_POTA2, 0x0);
  367. mdelay(10);
  368. writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, IPAC_CONF, 0x0);
  369. writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, IPAC_ACFG, 0xff);
  370. writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, IPAC_AOE, 0x0);
  371. writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, IPAC_MASK, 0xc0);
  372. writereg(cs->hw.sedl.adr, cs->hw.sedl.isac, IPAC_PCFG, 0x12);
  373. } else if ((cs->hw.sedl.chip == SEDL_CHIP_ISAC_ISAR) &&
  374. (cs->hw.sedl.bus == SEDL_BUS_PCI)) {
  375. byteout(cs->hw.sedl.cfg_reg +3, cs->hw.sedl.reset_on);
  376. mdelay(2);
  377. byteout(cs->hw.sedl.cfg_reg +3, cs->hw.sedl.reset_off);
  378. mdelay(10);
  379. } else {
  380. byteout(cs->hw.sedl.reset_on, SEDL_RESET); /* Reset On */
  381. mdelay(2);
  382. byteout(cs->hw.sedl.reset_off, 0); /* Reset Off */
  383. mdelay(10);
  384. }
  385. }
  386. }
  387. static int
  388. Sedl_card_msg(struct IsdnCardState *cs, int mt, void *arg)
  389. {
  390. u_long flags;
  391. switch (mt) {
  392. case CARD_RESET:
  393. spin_lock_irqsave(&cs->lock, flags);
  394. reset_sedlbauer(cs);
  395. spin_unlock_irqrestore(&cs->lock, flags);
  396. return(0);
  397. case CARD_RELEASE:
  398. if (cs->hw.sedl.bus == SEDL_BUS_PCI)
  399. /* disable all IRQ */
  400. byteout(cs->hw.sedl.cfg_reg+ 5, 0);
  401. if (cs->hw.sedl.chip == SEDL_CHIP_ISAC_ISAR) {
  402. spin_lock_irqsave(&cs->lock, flags);
  403. writereg(cs->hw.sedl.adr, cs->hw.sedl.hscx,
  404. ISAR_IRQBIT, 0);
  405. writereg(cs->hw.sedl.adr, cs->hw.sedl.isac,
  406. ISAC_MASK, 0xFF);
  407. reset_sedlbauer(cs);
  408. writereg(cs->hw.sedl.adr, cs->hw.sedl.hscx,
  409. ISAR_IRQBIT, 0);
  410. writereg(cs->hw.sedl.adr, cs->hw.sedl.isac,
  411. ISAC_MASK, 0xFF);
  412. spin_unlock_irqrestore(&cs->lock, flags);
  413. }
  414. release_io_sedlbauer(cs);
  415. return(0);
  416. case CARD_INIT:
  417. spin_lock_irqsave(&cs->lock, flags);
  418. if (cs->hw.sedl.bus == SEDL_BUS_PCI)
  419. /* enable all IRQ */
  420. byteout(cs->hw.sedl.cfg_reg+ 5, 0x02);
  421. reset_sedlbauer(cs);
  422. if (cs->hw.sedl.chip == SEDL_CHIP_ISAC_ISAR) {
  423. clear_pending_isac_ints(cs);
  424. writereg(cs->hw.sedl.adr, cs->hw.sedl.hscx,
  425. ISAR_IRQBIT, 0);
  426. initisac(cs);
  427. initisar(cs);
  428. /* Reenable all IRQ */
  429. cs->writeisac(cs, ISAC_MASK, 0);
  430. /* RESET Receiver and Transmitter */
  431. cs->writeisac(cs, ISAC_CMDR, 0x41);
  432. } else {
  433. inithscxisac(cs, 3);
  434. }
  435. spin_unlock_irqrestore(&cs->lock, flags);
  436. return(0);
  437. case CARD_TEST:
  438. return(0);
  439. case MDL_INFO_CONN:
  440. if (cs->subtyp != SEDL_SPEEDFAX_PYRAMID)
  441. return(0);
  442. spin_lock_irqsave(&cs->lock, flags);
  443. if ((long) arg)
  444. cs->hw.sedl.reset_off &= ~SEDL_ISAR_PCI_LED2;
  445. else
  446. cs->hw.sedl.reset_off &= ~SEDL_ISAR_PCI_LED1;
  447. byteout(cs->hw.sedl.cfg_reg +3, cs->hw.sedl.reset_off);
  448. spin_unlock_irqrestore(&cs->lock, flags);
  449. break;
  450. case MDL_INFO_REL:
  451. if (cs->subtyp != SEDL_SPEEDFAX_PYRAMID)
  452. return(0);
  453. spin_lock_irqsave(&cs->lock, flags);
  454. if ((long) arg)
  455. cs->hw.sedl.reset_off |= SEDL_ISAR_PCI_LED2;
  456. else
  457. cs->hw.sedl.reset_off |= SEDL_ISAR_PCI_LED1;
  458. byteout(cs->hw.sedl.cfg_reg +3, cs->hw.sedl.reset_off);
  459. spin_unlock_irqrestore(&cs->lock, flags);
  460. break;
  461. }
  462. return(0);
  463. }
  464. #ifdef __ISAPNP__
  465. static struct isapnp_device_id sedl_ids[] __devinitdata = {
  466. { ISAPNP_VENDOR('S', 'A', 'G'), ISAPNP_FUNCTION(0x01),
  467. ISAPNP_VENDOR('S', 'A', 'G'), ISAPNP_FUNCTION(0x01),
  468. (unsigned long) "Speed win" },
  469. { ISAPNP_VENDOR('S', 'A', 'G'), ISAPNP_FUNCTION(0x02),
  470. ISAPNP_VENDOR('S', 'A', 'G'), ISAPNP_FUNCTION(0x02),
  471. (unsigned long) "Speed Fax+" },
  472. { 0, }
  473. };
  474. static struct isapnp_device_id *ipid __devinitdata = &sedl_ids[0];
  475. static struct pnp_card *pnp_c __devinitdata = NULL;
  476. static int __devinit
  477. setup_sedlbauer_isapnp(struct IsdnCard *card, int *bytecnt)
  478. {
  479. struct IsdnCardState *cs = card->cs;
  480. struct pnp_dev *pnp_d;
  481. if (!isapnp_present())
  482. return -1;
  483. while(ipid->card_vendor) {
  484. if ((pnp_c = pnp_find_card(ipid->card_vendor,
  485. ipid->card_device, pnp_c))) {
  486. pnp_d = NULL;
  487. if ((pnp_d = pnp_find_dev(pnp_c,
  488. ipid->vendor, ipid->function, pnp_d))) {
  489. int err;
  490. printk(KERN_INFO "HiSax: %s detected\n",
  491. (char *)ipid->driver_data);
  492. pnp_disable_dev(pnp_d);
  493. err = pnp_activate_dev(pnp_d);
  494. if (err<0) {
  495. printk(KERN_WARNING "%s: pnp_activate_dev ret(%d)\n",
  496. __func__, err);
  497. return(0);
  498. }
  499. card->para[1] = pnp_port_start(pnp_d, 0);
  500. card->para[0] = pnp_irq(pnp_d, 0);
  501. if (!card->para[0] || !card->para[1]) {
  502. printk(KERN_ERR "Sedlbauer PnP:some resources are missing %ld/%lx\n",
  503. card->para[0], card->para[1]);
  504. pnp_disable_dev(pnp_d);
  505. return(0);
  506. }
  507. cs->hw.sedl.cfg_reg = card->para[1];
  508. cs->irq = card->para[0];
  509. if (ipid->function == ISAPNP_FUNCTION(0x2)) {
  510. cs->subtyp = SEDL_SPEED_FAX;
  511. cs->hw.sedl.chip = SEDL_CHIP_ISAC_ISAR;
  512. *bytecnt = 16;
  513. } else {
  514. cs->subtyp = SEDL_SPEED_CARD_WIN;
  515. cs->hw.sedl.chip = SEDL_CHIP_TEST;
  516. }
  517. return (1);
  518. } else {
  519. printk(KERN_ERR "Sedlbauer PnP: PnP error card found, no device\n");
  520. return(0);
  521. }
  522. }
  523. ipid++;
  524. pnp_c = NULL;
  525. }
  526. printk(KERN_INFO "Sedlbauer PnP: no ISAPnP card found\n");
  527. return -1;
  528. }
  529. #else
  530. static int __devinit
  531. setup_sedlbauer_isapnp(struct IsdnCard *card, int *bytecnt)
  532. {
  533. return -1;
  534. }
  535. #endif /* __ISAPNP__ */
  536. #ifdef CONFIG_PCI
  537. static struct pci_dev *dev_sedl __devinitdata = NULL;
  538. static int __devinit
  539. setup_sedlbauer_pci(struct IsdnCard *card)
  540. {
  541. struct IsdnCardState *cs = card->cs;
  542. u16 sub_vendor_id, sub_id;
  543. if ((dev_sedl = hisax_find_pci_device(PCI_VENDOR_ID_TIGERJET,
  544. PCI_DEVICE_ID_TIGERJET_100, dev_sedl))) {
  545. if (pci_enable_device(dev_sedl))
  546. return(0);
  547. cs->irq = dev_sedl->irq;
  548. if (!cs->irq) {
  549. printk(KERN_WARNING "Sedlbauer: No IRQ for PCI card found\n");
  550. return(0);
  551. }
  552. cs->hw.sedl.cfg_reg = pci_resource_start(dev_sedl, 0);
  553. } else {
  554. printk(KERN_WARNING "Sedlbauer: No PCI card found\n");
  555. return(0);
  556. }
  557. cs->irq_flags |= IRQF_SHARED;
  558. cs->hw.sedl.bus = SEDL_BUS_PCI;
  559. sub_vendor_id = dev_sedl->subsystem_vendor;
  560. sub_id = dev_sedl->subsystem_device;
  561. printk(KERN_INFO "Sedlbauer: PCI subvendor:%x subid %x\n",
  562. sub_vendor_id, sub_id);
  563. printk(KERN_INFO "Sedlbauer: PCI base adr %#x\n",
  564. cs->hw.sedl.cfg_reg);
  565. if (sub_id != PCI_SUB_ID_SEDLBAUER) {
  566. printk(KERN_ERR "Sedlbauer: unknown sub id %#x\n", sub_id);
  567. return(0);
  568. }
  569. if (sub_vendor_id == PCI_SUBVENDOR_SPEEDFAX_PYRAMID) {
  570. cs->hw.sedl.chip = SEDL_CHIP_ISAC_ISAR;
  571. cs->subtyp = SEDL_SPEEDFAX_PYRAMID;
  572. } else if (sub_vendor_id == PCI_SUBVENDOR_SPEEDFAX_PCI) {
  573. cs->hw.sedl.chip = SEDL_CHIP_ISAC_ISAR;
  574. cs->subtyp = SEDL_SPEEDFAX_PCI;
  575. } else if (sub_vendor_id == PCI_SUBVENDOR_HST_SAPHIR3) {
  576. cs->hw.sedl.chip = SEDL_CHIP_IPAC;
  577. cs->subtyp = HST_SAPHIR3;
  578. } else if (sub_vendor_id == PCI_SUBVENDOR_SEDLBAUER_PCI) {
  579. cs->hw.sedl.chip = SEDL_CHIP_IPAC;
  580. cs->subtyp = SEDL_SPEED_PCI;
  581. } else {
  582. printk(KERN_ERR "Sedlbauer: unknown sub vendor id %#x\n",
  583. sub_vendor_id);
  584. return(0);
  585. }
  586. cs->hw.sedl.reset_on = SEDL_ISAR_PCI_ISAR_RESET_ON;
  587. cs->hw.sedl.reset_off = SEDL_ISAR_PCI_ISAR_RESET_OFF;
  588. byteout(cs->hw.sedl.cfg_reg, 0xff);
  589. byteout(cs->hw.sedl.cfg_reg, 0x00);
  590. byteout(cs->hw.sedl.cfg_reg+ 2, 0xdd);
  591. byteout(cs->hw.sedl.cfg_reg+ 5, 0); /* disable all IRQ */
  592. byteout(cs->hw.sedl.cfg_reg +3, cs->hw.sedl.reset_on);
  593. mdelay(2);
  594. byteout(cs->hw.sedl.cfg_reg +3, cs->hw.sedl.reset_off);
  595. mdelay(10);
  596. return (1);
  597. }
  598. #else
  599. static int __devinit
  600. setup_sedlbauer_pci(struct IsdnCard *card)
  601. {
  602. return (1);
  603. }
  604. #endif /* CONFIG_PCI */
  605. int __devinit
  606. setup_sedlbauer(struct IsdnCard *card)
  607. {
  608. int bytecnt = 8, ver, val, rc;
  609. struct IsdnCardState *cs = card->cs;
  610. char tmp[64];
  611. strcpy(tmp, Sedlbauer_revision);
  612. printk(KERN_INFO "HiSax: Sedlbauer driver Rev. %s\n", HiSax_getrev(tmp));
  613. if (cs->typ == ISDN_CTYPE_SEDLBAUER) {
  614. cs->subtyp = SEDL_SPEED_CARD_WIN;
  615. cs->hw.sedl.bus = SEDL_BUS_ISA;
  616. cs->hw.sedl.chip = SEDL_CHIP_TEST;
  617. } else if (cs->typ == ISDN_CTYPE_SEDLBAUER_PCMCIA) {
  618. cs->subtyp = SEDL_SPEED_STAR;
  619. cs->hw.sedl.bus = SEDL_BUS_PCMCIA;
  620. cs->hw.sedl.chip = SEDL_CHIP_TEST;
  621. } else if (cs->typ == ISDN_CTYPE_SEDLBAUER_FAX) {
  622. cs->subtyp = SEDL_SPEED_FAX;
  623. cs->hw.sedl.bus = SEDL_BUS_ISA;
  624. cs->hw.sedl.chip = SEDL_CHIP_ISAC_ISAR;
  625. } else
  626. return (0);
  627. bytecnt = 8;
  628. if (card->para[1]) {
  629. cs->hw.sedl.cfg_reg = card->para[1];
  630. cs->irq = card->para[0];
  631. if (cs->hw.sedl.chip == SEDL_CHIP_ISAC_ISAR) {
  632. bytecnt = 16;
  633. }
  634. } else {
  635. rc = setup_sedlbauer_isapnp(card, &bytecnt);
  636. if (!rc)
  637. return (0);
  638. if (rc > 0)
  639. goto ready;
  640. /* Probe for Sedlbauer speed pci */
  641. rc = setup_sedlbauer_pci(card);
  642. if (!rc)
  643. return (0);
  644. bytecnt = 256;
  645. }
  646. ready:
  647. /* In case of the sedlbauer pcmcia card, this region is in use,
  648. * reserved for us by the card manager. So we do not check it
  649. * here, it would fail.
  650. */
  651. if (cs->hw.sedl.bus != SEDL_BUS_PCMCIA &&
  652. !request_region(cs->hw.sedl.cfg_reg, bytecnt, "sedlbauer isdn")) {
  653. printk(KERN_WARNING
  654. "HiSax: %s config port %x-%x already in use\n",
  655. CardType[card->typ],
  656. cs->hw.sedl.cfg_reg,
  657. cs->hw.sedl.cfg_reg + bytecnt);
  658. return (0);
  659. }
  660. printk(KERN_INFO
  661. "Sedlbauer: defined at 0x%x-0x%x IRQ %d\n",
  662. cs->hw.sedl.cfg_reg,
  663. cs->hw.sedl.cfg_reg + bytecnt,
  664. cs->irq);
  665. cs->BC_Read_Reg = &ReadHSCX;
  666. cs->BC_Write_Reg = &WriteHSCX;
  667. cs->BC_Send_Data = &hscx_fill_fifo;
  668. cs->cardmsg = &Sedl_card_msg;
  669. /*
  670. * testing ISA and PCMCIA Cards for IPAC, default is ISAC
  671. * do not test for PCI card, because ports are different
  672. * and PCI card uses only IPAC (for the moment)
  673. */
  674. if (cs->hw.sedl.bus != SEDL_BUS_PCI) {
  675. val = readreg(cs->hw.sedl.cfg_reg + SEDL_IPAC_ANY_ADR,
  676. cs->hw.sedl.cfg_reg + SEDL_IPAC_ANY_IPAC, IPAC_ID);
  677. printk(KERN_DEBUG "Sedlbauer: testing IPAC version %x\n", val);
  678. if ((val == 1) || (val == 2)) {
  679. /* IPAC */
  680. cs->subtyp = SEDL_SPEED_WIN2_PC104;
  681. if (cs->hw.sedl.bus == SEDL_BUS_PCMCIA) {
  682. cs->subtyp = SEDL_SPEED_STAR2;
  683. }
  684. cs->hw.sedl.chip = SEDL_CHIP_IPAC;
  685. } else {
  686. /* ISAC_HSCX oder ISAC_ISAR */
  687. if (cs->hw.sedl.chip == SEDL_CHIP_TEST) {
  688. cs->hw.sedl.chip = SEDL_CHIP_ISAC_HSCX;
  689. }
  690. }
  691. }
  692. /*
  693. * hw.sedl.chip is now properly set
  694. */
  695. printk(KERN_INFO "Sedlbauer: %s detected\n",
  696. Sedlbauer_Types[cs->subtyp]);
  697. setup_isac(cs);
  698. if (cs->hw.sedl.chip == SEDL_CHIP_IPAC) {
  699. if (cs->hw.sedl.bus == SEDL_BUS_PCI) {
  700. cs->hw.sedl.adr = cs->hw.sedl.cfg_reg + SEDL_IPAC_PCI_ADR;
  701. cs->hw.sedl.isac = cs->hw.sedl.cfg_reg + SEDL_IPAC_PCI_IPAC;
  702. cs->hw.sedl.hscx = cs->hw.sedl.cfg_reg + SEDL_IPAC_PCI_IPAC;
  703. } else {
  704. cs->hw.sedl.adr = cs->hw.sedl.cfg_reg + SEDL_IPAC_ANY_ADR;
  705. cs->hw.sedl.isac = cs->hw.sedl.cfg_reg + SEDL_IPAC_ANY_IPAC;
  706. cs->hw.sedl.hscx = cs->hw.sedl.cfg_reg + SEDL_IPAC_ANY_IPAC;
  707. }
  708. test_and_set_bit(HW_IPAC, &cs->HW_Flags);
  709. cs->readisac = &ReadISAC_IPAC;
  710. cs->writeisac = &WriteISAC_IPAC;
  711. cs->readisacfifo = &ReadISACfifo_IPAC;
  712. cs->writeisacfifo = &WriteISACfifo_IPAC;
  713. cs->irq_func = &sedlbauer_interrupt_ipac;
  714. val = readreg(cs->hw.sedl.adr, cs->hw.sedl.isac, IPAC_ID);
  715. printk(KERN_INFO "Sedlbauer: IPAC version %x\n", val);
  716. } else {
  717. /* ISAC_HSCX oder ISAC_ISAR */
  718. cs->readisac = &ReadISAC;
  719. cs->writeisac = &WriteISAC;
  720. cs->readisacfifo = &ReadISACfifo;
  721. cs->writeisacfifo = &WriteISACfifo;
  722. if (cs->hw.sedl.chip == SEDL_CHIP_ISAC_ISAR) {
  723. if (cs->hw.sedl.bus == SEDL_BUS_PCI) {
  724. cs->hw.sedl.adr = cs->hw.sedl.cfg_reg +
  725. SEDL_ISAR_PCI_ADR;
  726. cs->hw.sedl.isac = cs->hw.sedl.cfg_reg +
  727. SEDL_ISAR_PCI_ISAC;
  728. cs->hw.sedl.hscx = cs->hw.sedl.cfg_reg +
  729. SEDL_ISAR_PCI_ISAR;
  730. } else {
  731. cs->hw.sedl.adr = cs->hw.sedl.cfg_reg +
  732. SEDL_ISAR_ISA_ADR;
  733. cs->hw.sedl.isac = cs->hw.sedl.cfg_reg +
  734. SEDL_ISAR_ISA_ISAC;
  735. cs->hw.sedl.hscx = cs->hw.sedl.cfg_reg +
  736. SEDL_ISAR_ISA_ISAR;
  737. cs->hw.sedl.reset_on = cs->hw.sedl.cfg_reg +
  738. SEDL_ISAR_ISA_ISAR_RESET_ON;
  739. cs->hw.sedl.reset_off = cs->hw.sedl.cfg_reg +
  740. SEDL_ISAR_ISA_ISAR_RESET_OFF;
  741. }
  742. cs->bcs[0].hw.isar.reg = &cs->hw.sedl.isar;
  743. cs->bcs[1].hw.isar.reg = &cs->hw.sedl.isar;
  744. test_and_set_bit(HW_ISAR, &cs->HW_Flags);
  745. cs->irq_func = &sedlbauer_interrupt_isar;
  746. cs->auxcmd = &isar_auxcmd;
  747. ISACVersion(cs, "Sedlbauer:");
  748. cs->BC_Read_Reg = &ReadISAR;
  749. cs->BC_Write_Reg = &WriteISAR;
  750. cs->BC_Send_Data = &isar_fill_fifo;
  751. bytecnt = 3;
  752. while (bytecnt) {
  753. ver = ISARVersion(cs, "Sedlbauer:");
  754. if (ver < 0)
  755. printk(KERN_WARNING
  756. "Sedlbauer: wrong ISAR version (ret = %d)\n", ver);
  757. else
  758. break;
  759. reset_sedlbauer(cs);
  760. bytecnt--;
  761. }
  762. if (!bytecnt) {
  763. release_io_sedlbauer(cs);
  764. return (0);
  765. }
  766. } else {
  767. if (cs->hw.sedl.bus == SEDL_BUS_PCMCIA) {
  768. cs->hw.sedl.adr = cs->hw.sedl.cfg_reg + SEDL_HSCX_PCMCIA_ADR;
  769. cs->hw.sedl.isac = cs->hw.sedl.cfg_reg + SEDL_HSCX_PCMCIA_ISAC;
  770. cs->hw.sedl.hscx = cs->hw.sedl.cfg_reg + SEDL_HSCX_PCMCIA_HSCX;
  771. cs->hw.sedl.reset_on = cs->hw.sedl.cfg_reg + SEDL_HSCX_PCMCIA_RESET;
  772. cs->hw.sedl.reset_off = cs->hw.sedl.cfg_reg + SEDL_HSCX_PCMCIA_RESET;
  773. cs->irq_flags |= IRQF_SHARED;
  774. } else {
  775. cs->hw.sedl.adr = cs->hw.sedl.cfg_reg + SEDL_HSCX_ISA_ADR;
  776. cs->hw.sedl.isac = cs->hw.sedl.cfg_reg + SEDL_HSCX_ISA_ISAC;
  777. cs->hw.sedl.hscx = cs->hw.sedl.cfg_reg + SEDL_HSCX_ISA_HSCX;
  778. cs->hw.sedl.reset_on = cs->hw.sedl.cfg_reg + SEDL_HSCX_ISA_RESET_ON;
  779. cs->hw.sedl.reset_off = cs->hw.sedl.cfg_reg + SEDL_HSCX_ISA_RESET_OFF;
  780. }
  781. cs->irq_func = &sedlbauer_interrupt;
  782. ISACVersion(cs, "Sedlbauer:");
  783. if (HscxVersion(cs, "Sedlbauer:")) {
  784. printk(KERN_WARNING
  785. "Sedlbauer: wrong HSCX versions check IO address\n");
  786. release_io_sedlbauer(cs);
  787. return (0);
  788. }
  789. }
  790. }
  791. return (1);
  792. }