sedlbauer.c 24 KB

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