mISDNinfineon.c 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173
  1. /*
  2. * mISDNinfineon.c
  3. * Support for cards based on following Infineon ISDN chipsets
  4. * - ISAC + HSCX
  5. * - IPAC and IPAC-X
  6. * - ISAC-SX + HSCX
  7. *
  8. * Supported cards:
  9. * - Dialogic Diva 2.0
  10. * - Dialogic Diva 2.0U
  11. * - Dialogic Diva 2.01
  12. * - Dialogic Diva 2.02
  13. * - Sedlbauer Speedwin
  14. * - HST Saphir3
  15. * - Develo (former ELSA) Microlink PCI (Quickstep 1000)
  16. * - Develo (former ELSA) Quickstep 3000
  17. * - Berkom Scitel BRIX Quadro
  18. * - Dr.Neuhaus (Sagem) Niccy
  19. *
  20. *
  21. *
  22. * Author Karsten Keil <keil@isdn4linux.de>
  23. *
  24. * Copyright 2009 by Karsten Keil <keil@isdn4linux.de>
  25. *
  26. * This program is free software; you can redistribute it and/or modify
  27. * it under the terms of the GNU General Public License version 2 as
  28. * published by the Free Software Foundation.
  29. *
  30. * This program is distributed in the hope that it will be useful,
  31. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  32. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  33. * GNU General Public License for more details.
  34. *
  35. * You should have received a copy of the GNU General Public License
  36. * along with this program; if not, write to the Free Software
  37. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  38. *
  39. */
  40. #include <linux/module.h>
  41. #include <linux/pci.h>
  42. #include <linux/delay.h>
  43. #include <linux/mISDNhw.h>
  44. #include <linux/slab.h>
  45. #include "ipac.h"
  46. #define INFINEON_REV "1.0"
  47. static int inf_cnt;
  48. static u32 debug;
  49. static u32 irqloops = 4;
  50. enum inf_types {
  51. INF_NONE,
  52. INF_DIVA20,
  53. INF_DIVA20U,
  54. INF_DIVA201,
  55. INF_DIVA202,
  56. INF_SPEEDWIN,
  57. INF_SAPHIR3,
  58. INF_QS1000,
  59. INF_QS3000,
  60. INF_NICCY,
  61. INF_SCT_1,
  62. INF_SCT_2,
  63. INF_SCT_3,
  64. INF_SCT_4,
  65. INF_GAZEL_R685,
  66. INF_GAZEL_R753
  67. };
  68. enum addr_mode {
  69. AM_NONE = 0,
  70. AM_IO,
  71. AM_MEMIO,
  72. AM_IND_IO,
  73. };
  74. struct inf_cinfo {
  75. enum inf_types typ;
  76. const char *full;
  77. const char *name;
  78. enum addr_mode cfg_mode;
  79. enum addr_mode addr_mode;
  80. u8 cfg_bar;
  81. u8 addr_bar;
  82. void *irqfunc;
  83. };
  84. struct _ioaddr {
  85. enum addr_mode mode;
  86. union {
  87. void __iomem *p;
  88. struct _ioport io;
  89. } a;
  90. };
  91. struct _iohandle {
  92. enum addr_mode mode;
  93. resource_size_t size;
  94. resource_size_t start;
  95. void __iomem *p;
  96. };
  97. struct inf_hw {
  98. struct list_head list;
  99. struct pci_dev *pdev;
  100. const struct inf_cinfo *ci;
  101. char name[MISDN_MAX_IDLEN];
  102. u32 irq;
  103. u32 irqcnt;
  104. struct _iohandle cfg;
  105. struct _iohandle addr;
  106. struct _ioaddr isac;
  107. struct _ioaddr hscx;
  108. spinlock_t lock; /* HW access lock */
  109. struct ipac_hw ipac;
  110. struct inf_hw *sc[3]; /* slave cards */
  111. };
  112. #define PCI_SUBVENDOR_HST_SAPHIR3 0x52
  113. #define PCI_SUBVENDOR_SEDLBAUER_PCI 0x53
  114. #define PCI_SUB_ID_SEDLBAUER 0x01
  115. static struct pci_device_id infineon_ids[] __devinitdata = {
  116. { PCI_VDEVICE(EICON, PCI_DEVICE_ID_EICON_DIVA20), INF_DIVA20 },
  117. { PCI_VDEVICE(EICON, PCI_DEVICE_ID_EICON_DIVA20_U), INF_DIVA20U },
  118. { PCI_VDEVICE(EICON, PCI_DEVICE_ID_EICON_DIVA201), INF_DIVA201 },
  119. { PCI_VDEVICE(EICON, PCI_DEVICE_ID_EICON_DIVA202), INF_DIVA202 },
  120. { PCI_VENDOR_ID_TIGERJET, PCI_DEVICE_ID_TIGERJET_100,
  121. PCI_SUBVENDOR_SEDLBAUER_PCI, PCI_SUB_ID_SEDLBAUER, 0, 0,
  122. INF_SPEEDWIN },
  123. { PCI_VENDOR_ID_TIGERJET, PCI_DEVICE_ID_TIGERJET_100,
  124. PCI_SUBVENDOR_HST_SAPHIR3, PCI_SUB_ID_SEDLBAUER, 0, 0, INF_SAPHIR3 },
  125. { PCI_VDEVICE(ELSA, PCI_DEVICE_ID_ELSA_MICROLINK), INF_QS1000 },
  126. { PCI_VDEVICE(ELSA, PCI_DEVICE_ID_ELSA_QS3000), INF_QS3000 },
  127. { PCI_VDEVICE(SATSAGEM, PCI_DEVICE_ID_SATSAGEM_NICCY), INF_NICCY },
  128. { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9050,
  129. PCI_VENDOR_ID_BERKOM, PCI_DEVICE_ID_BERKOM_SCITEL_QUADRO, 0, 0,
  130. INF_SCT_1 },
  131. { PCI_VDEVICE(PLX, PCI_DEVICE_ID_PLX_R685), INF_GAZEL_R685 },
  132. { PCI_VDEVICE(PLX, PCI_DEVICE_ID_PLX_R753), INF_GAZEL_R753 },
  133. { PCI_VDEVICE(PLX, PCI_DEVICE_ID_PLX_DJINN_ITOO), INF_GAZEL_R753 },
  134. { PCI_VDEVICE(PLX, PCI_DEVICE_ID_PLX_OLITEC), INF_GAZEL_R753 },
  135. { }
  136. };
  137. MODULE_DEVICE_TABLE(pci, infineon_ids);
  138. /* PCI interface specific defines */
  139. /* Diva 2.0/2.0U */
  140. #define DIVA_HSCX_PORT 0x00
  141. #define DIVA_HSCX_ALE 0x04
  142. #define DIVA_ISAC_PORT 0x08
  143. #define DIVA_ISAC_ALE 0x0C
  144. #define DIVA_PCI_CTRL 0x10
  145. /* DIVA_PCI_CTRL bits */
  146. #define DIVA_IRQ_BIT 0x01
  147. #define DIVA_RESET_BIT 0x08
  148. #define DIVA_EEPROM_CLK 0x40
  149. #define DIVA_LED_A 0x10
  150. #define DIVA_LED_B 0x20
  151. #define DIVA_IRQ_CLR 0x80
  152. /* Diva 2.01/2.02 */
  153. /* Siemens PITA */
  154. #define PITA_ICR_REG 0x00
  155. #define PITA_INT0_STATUS 0x02
  156. #define PITA_MISC_REG 0x1c
  157. #define PITA_PARA_SOFTRESET 0x01000000
  158. #define PITA_SER_SOFTRESET 0x02000000
  159. #define PITA_PARA_MPX_MODE 0x04000000
  160. #define PITA_INT0_ENABLE 0x00020000
  161. /* TIGER 100 Registers */
  162. #define TIGER_RESET_ADDR 0x00
  163. #define TIGER_EXTERN_RESET 0x01
  164. #define TIGER_AUX_CTRL 0x02
  165. #define TIGER_AUX_DATA 0x03
  166. #define TIGER_AUX_IRQMASK 0x05
  167. #define TIGER_AUX_STATUS 0x07
  168. /* Tiger AUX BITs */
  169. #define TIGER_IOMASK 0xdd /* 1 and 5 are inputs */
  170. #define TIGER_IRQ_BIT 0x02
  171. #define TIGER_IPAC_ALE 0xC0
  172. #define TIGER_IPAC_PORT 0xC8
  173. /* ELSA (now Develo) PCI cards */
  174. #define ELSA_IRQ_ADDR 0x4c
  175. #define ELSA_IRQ_MASK 0x04
  176. #define QS1000_IRQ_OFF 0x01
  177. #define QS3000_IRQ_OFF 0x03
  178. #define QS1000_IRQ_ON 0x41
  179. #define QS3000_IRQ_ON 0x43
  180. /* Dr Neuhaus/Sagem Niccy */
  181. #define NICCY_ISAC_PORT 0x00
  182. #define NICCY_HSCX_PORT 0x01
  183. #define NICCY_ISAC_ALE 0x02
  184. #define NICCY_HSCX_ALE 0x03
  185. #define NICCY_IRQ_CTRL_REG 0x38
  186. #define NICCY_IRQ_ENABLE 0x001f00
  187. #define NICCY_IRQ_DISABLE 0xff0000
  188. #define NICCY_IRQ_BIT 0x800000
  189. /* Scitel PLX */
  190. #define SCT_PLX_IRQ_ADDR 0x4c
  191. #define SCT_PLX_RESET_ADDR 0x50
  192. #define SCT_PLX_IRQ_ENABLE 0x41
  193. #define SCT_PLX_RESET_BIT 0x04
  194. /* Gazel */
  195. #define GAZEL_IPAC_DATA_PORT 0x04
  196. /* Gazel PLX */
  197. #define GAZEL_CNTRL 0x50
  198. #define GAZEL_RESET 0x04
  199. #define GAZEL_RESET_9050 0x40000000
  200. #define GAZEL_INCSR 0x4C
  201. #define GAZEL_ISAC_EN 0x08
  202. #define GAZEL_INT_ISAC 0x20
  203. #define GAZEL_HSCX_EN 0x01
  204. #define GAZEL_INT_HSCX 0x04
  205. #define GAZEL_PCI_EN 0x40
  206. #define GAZEL_IPAC_EN 0x03
  207. static LIST_HEAD(Cards);
  208. static DEFINE_RWLOCK(card_lock); /* protect Cards */
  209. static void
  210. _set_debug(struct inf_hw *card)
  211. {
  212. card->ipac.isac.dch.debug = debug;
  213. card->ipac.hscx[0].bch.debug = debug;
  214. card->ipac.hscx[1].bch.debug = debug;
  215. }
  216. static int
  217. set_debug(const char *val, struct kernel_param *kp)
  218. {
  219. int ret;
  220. struct inf_hw *card;
  221. ret = param_set_uint(val, kp);
  222. if (!ret) {
  223. read_lock(&card_lock);
  224. list_for_each_entry(card, &Cards, list)
  225. _set_debug(card);
  226. read_unlock(&card_lock);
  227. }
  228. return ret;
  229. }
  230. MODULE_AUTHOR("Karsten Keil");
  231. MODULE_LICENSE("GPL v2");
  232. MODULE_VERSION(INFINEON_REV);
  233. module_param_call(debug, set_debug, param_get_uint, &debug, S_IRUGO | S_IWUSR);
  234. MODULE_PARM_DESC(debug, "infineon debug mask");
  235. module_param(irqloops, uint, S_IRUGO | S_IWUSR);
  236. MODULE_PARM_DESC(irqloops, "infineon maximal irqloops (default 4)");
  237. /* Interface functions */
  238. IOFUNC_IO(ISAC, inf_hw, isac.a.io)
  239. IOFUNC_IO(IPAC, inf_hw, hscx.a.io)
  240. IOFUNC_IND(ISAC, inf_hw, isac.a.io)
  241. IOFUNC_IND(IPAC, inf_hw, hscx.a.io)
  242. IOFUNC_MEMIO(ISAC, inf_hw, u32, isac.a.p)
  243. IOFUNC_MEMIO(IPAC, inf_hw, u32, hscx.a.p)
  244. static irqreturn_t
  245. diva_irq(int intno, void *dev_id)
  246. {
  247. struct inf_hw *hw = dev_id;
  248. u8 val;
  249. spin_lock(&hw->lock);
  250. val = inb((u32)hw->cfg.start + DIVA_PCI_CTRL);
  251. if (!(val & DIVA_IRQ_BIT)) { /* for us or shared ? */
  252. spin_unlock(&hw->lock);
  253. return IRQ_NONE; /* shared */
  254. }
  255. hw->irqcnt++;
  256. mISDNipac_irq(&hw->ipac, irqloops);
  257. spin_unlock(&hw->lock);
  258. return IRQ_HANDLED;
  259. }
  260. static irqreturn_t
  261. diva20x_irq(int intno, void *dev_id)
  262. {
  263. struct inf_hw *hw = dev_id;
  264. u8 val;
  265. spin_lock(&hw->lock);
  266. val = readb(hw->cfg.p);
  267. if (!(val & PITA_INT0_STATUS)) { /* for us or shared ? */
  268. spin_unlock(&hw->lock);
  269. return IRQ_NONE; /* shared */
  270. }
  271. hw->irqcnt++;
  272. mISDNipac_irq(&hw->ipac, irqloops);
  273. writeb(PITA_INT0_STATUS, hw->cfg.p); /* ACK PITA INT0 */
  274. spin_unlock(&hw->lock);
  275. return IRQ_HANDLED;
  276. }
  277. static irqreturn_t
  278. tiger_irq(int intno, void *dev_id)
  279. {
  280. struct inf_hw *hw = dev_id;
  281. u8 val;
  282. spin_lock(&hw->lock);
  283. val = inb((u32)hw->cfg.start + TIGER_AUX_STATUS);
  284. if (val & TIGER_IRQ_BIT) { /* for us or shared ? */
  285. spin_unlock(&hw->lock);
  286. return IRQ_NONE; /* shared */
  287. }
  288. hw->irqcnt++;
  289. mISDNipac_irq(&hw->ipac, irqloops);
  290. spin_unlock(&hw->lock);
  291. return IRQ_HANDLED;
  292. }
  293. static irqreturn_t
  294. elsa_irq(int intno, void *dev_id)
  295. {
  296. struct inf_hw *hw = dev_id;
  297. u8 val;
  298. spin_lock(&hw->lock);
  299. val = inb((u32)hw->cfg.start + ELSA_IRQ_ADDR);
  300. if (!(val & ELSA_IRQ_MASK)) {
  301. spin_unlock(&hw->lock);
  302. return IRQ_NONE; /* shared */
  303. }
  304. hw->irqcnt++;
  305. mISDNipac_irq(&hw->ipac, irqloops);
  306. spin_unlock(&hw->lock);
  307. return IRQ_HANDLED;
  308. }
  309. static irqreturn_t
  310. niccy_irq(int intno, void *dev_id)
  311. {
  312. struct inf_hw *hw = dev_id;
  313. u32 val;
  314. spin_lock(&hw->lock);
  315. val = inl((u32)hw->cfg.start + NICCY_IRQ_CTRL_REG);
  316. if (!(val & NICCY_IRQ_BIT)) { /* for us or shared ? */
  317. spin_unlock(&hw->lock);
  318. return IRQ_NONE; /* shared */
  319. }
  320. outl(val, (u32)hw->cfg.start + NICCY_IRQ_CTRL_REG);
  321. hw->irqcnt++;
  322. mISDNipac_irq(&hw->ipac, irqloops);
  323. spin_unlock(&hw->lock);
  324. return IRQ_HANDLED;
  325. }
  326. static irqreturn_t
  327. gazel_irq(int intno, void *dev_id)
  328. {
  329. struct inf_hw *hw = dev_id;
  330. irqreturn_t ret;
  331. spin_lock(&hw->lock);
  332. ret = mISDNipac_irq(&hw->ipac, irqloops);
  333. spin_unlock(&hw->lock);
  334. return ret;
  335. }
  336. static irqreturn_t
  337. ipac_irq(int intno, void *dev_id)
  338. {
  339. struct inf_hw *hw = dev_id;
  340. u8 val;
  341. spin_lock(&hw->lock);
  342. val = hw->ipac.read_reg(hw, IPAC_ISTA);
  343. if (!(val & 0x3f)) {
  344. spin_unlock(&hw->lock);
  345. return IRQ_NONE; /* shared */
  346. }
  347. hw->irqcnt++;
  348. mISDNipac_irq(&hw->ipac, irqloops);
  349. spin_unlock(&hw->lock);
  350. return IRQ_HANDLED;
  351. }
  352. static void
  353. enable_hwirq(struct inf_hw *hw)
  354. {
  355. u16 w;
  356. u32 val;
  357. switch (hw->ci->typ) {
  358. case INF_DIVA201:
  359. case INF_DIVA202:
  360. writel(PITA_INT0_ENABLE, hw->cfg.p);
  361. break;
  362. case INF_SPEEDWIN:
  363. case INF_SAPHIR3:
  364. outb(TIGER_IRQ_BIT, (u32)hw->cfg.start + TIGER_AUX_IRQMASK);
  365. break;
  366. case INF_QS1000:
  367. outb(QS1000_IRQ_ON, (u32)hw->cfg.start + ELSA_IRQ_ADDR);
  368. break;
  369. case INF_QS3000:
  370. outb(QS3000_IRQ_ON, (u32)hw->cfg.start + ELSA_IRQ_ADDR);
  371. break;
  372. case INF_NICCY:
  373. val = inl((u32)hw->cfg.start + NICCY_IRQ_CTRL_REG);
  374. val |= NICCY_IRQ_ENABLE;
  375. outl(val, (u32)hw->cfg.start + NICCY_IRQ_CTRL_REG);
  376. break;
  377. case INF_SCT_1:
  378. w = inw((u32)hw->cfg.start + SCT_PLX_IRQ_ADDR);
  379. w |= SCT_PLX_IRQ_ENABLE;
  380. outw(w, (u32)hw->cfg.start + SCT_PLX_IRQ_ADDR);
  381. break;
  382. case INF_GAZEL_R685:
  383. outb(GAZEL_ISAC_EN + GAZEL_HSCX_EN + GAZEL_PCI_EN,
  384. (u32)hw->cfg.start + GAZEL_INCSR);
  385. break;
  386. case INF_GAZEL_R753:
  387. outb(GAZEL_IPAC_EN + GAZEL_PCI_EN,
  388. (u32)hw->cfg.start + GAZEL_INCSR);
  389. break;
  390. default:
  391. break;
  392. }
  393. }
  394. static void
  395. disable_hwirq(struct inf_hw *hw)
  396. {
  397. u16 w;
  398. u32 val;
  399. switch (hw->ci->typ) {
  400. case INF_DIVA201:
  401. case INF_DIVA202:
  402. writel(0, hw->cfg.p);
  403. break;
  404. case INF_SPEEDWIN:
  405. case INF_SAPHIR3:
  406. outb(0, (u32)hw->cfg.start + TIGER_AUX_IRQMASK);
  407. break;
  408. case INF_QS1000:
  409. outb(QS1000_IRQ_OFF, (u32)hw->cfg.start + ELSA_IRQ_ADDR);
  410. break;
  411. case INF_QS3000:
  412. outb(QS3000_IRQ_OFF, (u32)hw->cfg.start + ELSA_IRQ_ADDR);
  413. break;
  414. case INF_NICCY:
  415. val = inl((u32)hw->cfg.start + NICCY_IRQ_CTRL_REG);
  416. val &= NICCY_IRQ_DISABLE;
  417. outl(val, (u32)hw->cfg.start + NICCY_IRQ_CTRL_REG);
  418. break;
  419. case INF_SCT_1:
  420. w = inw((u32)hw->cfg.start + SCT_PLX_IRQ_ADDR);
  421. w &= (~SCT_PLX_IRQ_ENABLE);
  422. outw(w, (u32)hw->cfg.start + SCT_PLX_IRQ_ADDR);
  423. break;
  424. case INF_GAZEL_R685:
  425. case INF_GAZEL_R753:
  426. outb(0, (u32)hw->cfg.start + GAZEL_INCSR);
  427. break;
  428. default:
  429. break;
  430. }
  431. }
  432. static void
  433. ipac_chip_reset(struct inf_hw *hw)
  434. {
  435. hw->ipac.write_reg(hw, IPAC_POTA2, 0x20);
  436. mdelay(5);
  437. hw->ipac.write_reg(hw, IPAC_POTA2, 0x00);
  438. mdelay(5);
  439. hw->ipac.write_reg(hw, IPAC_CONF, hw->ipac.conf);
  440. hw->ipac.write_reg(hw, IPAC_MASK, 0xc0);
  441. }
  442. static void
  443. reset_inf(struct inf_hw *hw)
  444. {
  445. u16 w;
  446. u32 val;
  447. if (debug & DEBUG_HW)
  448. pr_notice("%s: resetting card\n", hw->name);
  449. switch (hw->ci->typ) {
  450. case INF_DIVA20:
  451. case INF_DIVA20U:
  452. outb(0, (u32)hw->cfg.start + DIVA_PCI_CTRL);
  453. mdelay(10);
  454. outb(DIVA_RESET_BIT, (u32)hw->cfg.start + DIVA_PCI_CTRL);
  455. mdelay(10);
  456. /* Workaround PCI9060 */
  457. outb(9, (u32)hw->cfg.start + 0x69);
  458. outb(DIVA_RESET_BIT | DIVA_LED_A,
  459. (u32)hw->cfg.start + DIVA_PCI_CTRL);
  460. break;
  461. case INF_DIVA201:
  462. writel(PITA_PARA_SOFTRESET | PITA_PARA_MPX_MODE,
  463. hw->cfg.p + PITA_MISC_REG);
  464. mdelay(1);
  465. writel(PITA_PARA_MPX_MODE, hw->cfg.p + PITA_MISC_REG);
  466. mdelay(10);
  467. break;
  468. case INF_DIVA202:
  469. writel(PITA_PARA_SOFTRESET | PITA_PARA_MPX_MODE,
  470. hw->cfg.p + PITA_MISC_REG);
  471. mdelay(1);
  472. writel(PITA_PARA_MPX_MODE | PITA_SER_SOFTRESET,
  473. hw->cfg.p + PITA_MISC_REG);
  474. mdelay(10);
  475. break;
  476. case INF_SPEEDWIN:
  477. case INF_SAPHIR3:
  478. ipac_chip_reset(hw);
  479. hw->ipac.write_reg(hw, IPAC_ACFG, 0xff);
  480. hw->ipac.write_reg(hw, IPAC_AOE, 0x00);
  481. hw->ipac.write_reg(hw, IPAC_PCFG, 0x12);
  482. break;
  483. case INF_QS1000:
  484. case INF_QS3000:
  485. ipac_chip_reset(hw);
  486. hw->ipac.write_reg(hw, IPAC_ACFG, 0x00);
  487. hw->ipac.write_reg(hw, IPAC_AOE, 0x3c);
  488. hw->ipac.write_reg(hw, IPAC_ATX, 0xff);
  489. break;
  490. case INF_NICCY:
  491. break;
  492. case INF_SCT_1:
  493. w = inw((u32)hw->cfg.start + SCT_PLX_RESET_ADDR);
  494. w &= (~SCT_PLX_RESET_BIT);
  495. outw(w, (u32)hw->cfg.start + SCT_PLX_RESET_ADDR);
  496. mdelay(10);
  497. w = inw((u32)hw->cfg.start + SCT_PLX_RESET_ADDR);
  498. w |= SCT_PLX_RESET_BIT;
  499. outw(w, (u32)hw->cfg.start + SCT_PLX_RESET_ADDR);
  500. mdelay(10);
  501. break;
  502. case INF_GAZEL_R685:
  503. val = inl((u32)hw->cfg.start + GAZEL_CNTRL);
  504. val |= (GAZEL_RESET_9050 + GAZEL_RESET);
  505. outl(val, (u32)hw->cfg.start + GAZEL_CNTRL);
  506. val &= ~(GAZEL_RESET_9050 + GAZEL_RESET);
  507. mdelay(4);
  508. outl(val, (u32)hw->cfg.start + GAZEL_CNTRL);
  509. mdelay(10);
  510. hw->ipac.isac.adf2 = 0x87;
  511. hw->ipac.hscx[0].slot = 0x1f;
  512. hw->ipac.hscx[1].slot = 0x23;
  513. break;
  514. case INF_GAZEL_R753:
  515. val = inl((u32)hw->cfg.start + GAZEL_CNTRL);
  516. val |= (GAZEL_RESET_9050 + GAZEL_RESET);
  517. outl(val, (u32)hw->cfg.start + GAZEL_CNTRL);
  518. val &= ~(GAZEL_RESET_9050 + GAZEL_RESET);
  519. mdelay(4);
  520. outl(val, (u32)hw->cfg.start + GAZEL_CNTRL);
  521. mdelay(10);
  522. ipac_chip_reset(hw);
  523. hw->ipac.write_reg(hw, IPAC_ACFG, 0xff);
  524. hw->ipac.write_reg(hw, IPAC_AOE, 0x00);
  525. hw->ipac.conf = 0x01; /* IOM off */
  526. break;
  527. default:
  528. return;
  529. }
  530. enable_hwirq(hw);
  531. }
  532. static int
  533. inf_ctrl(struct inf_hw *hw, u32 cmd, u_long arg)
  534. {
  535. int ret = 0;
  536. switch (cmd) {
  537. case HW_RESET_REQ:
  538. reset_inf(hw);
  539. break;
  540. default:
  541. pr_info("%s: %s unknown command %x %lx\n",
  542. hw->name, __func__, cmd, arg);
  543. ret = -EINVAL;
  544. break;
  545. }
  546. return ret;
  547. }
  548. static int __devinit
  549. init_irq(struct inf_hw *hw)
  550. {
  551. int ret, cnt = 3;
  552. u_long flags;
  553. if (!hw->ci->irqfunc)
  554. return -EINVAL;
  555. ret = request_irq(hw->irq, hw->ci->irqfunc, IRQF_SHARED, hw->name, hw);
  556. if (ret) {
  557. pr_info("%s: couldn't get interrupt %d\n", hw->name, hw->irq);
  558. return ret;
  559. }
  560. while (cnt--) {
  561. spin_lock_irqsave(&hw->lock, flags);
  562. reset_inf(hw);
  563. ret = hw->ipac.init(&hw->ipac);
  564. if (ret) {
  565. spin_unlock_irqrestore(&hw->lock, flags);
  566. pr_info("%s: ISAC init failed with %d\n",
  567. hw->name, ret);
  568. break;
  569. }
  570. spin_unlock_irqrestore(&hw->lock, flags);
  571. msleep_interruptible(10);
  572. if (debug & DEBUG_HW)
  573. pr_notice("%s: IRQ %d count %d\n", hw->name,
  574. hw->irq, hw->irqcnt);
  575. if (!hw->irqcnt) {
  576. pr_info("%s: IRQ(%d) got no requests during init %d\n",
  577. hw->name, hw->irq, 3 - cnt);
  578. } else
  579. return 0;
  580. }
  581. free_irq(hw->irq, hw);
  582. return -EIO;
  583. }
  584. static void
  585. release_io(struct inf_hw *hw)
  586. {
  587. if (hw->cfg.mode) {
  588. if (hw->cfg.p) {
  589. release_mem_region(hw->cfg.start, hw->cfg.size);
  590. iounmap(hw->cfg.p);
  591. } else
  592. release_region(hw->cfg.start, hw->cfg.size);
  593. hw->cfg.mode = AM_NONE;
  594. }
  595. if (hw->addr.mode) {
  596. if (hw->addr.p) {
  597. release_mem_region(hw->addr.start, hw->addr.size);
  598. iounmap(hw->addr.p);
  599. } else
  600. release_region(hw->addr.start, hw->addr.size);
  601. hw->addr.mode = AM_NONE;
  602. }
  603. }
  604. static int __devinit
  605. setup_io(struct inf_hw *hw)
  606. {
  607. int err = 0;
  608. if (hw->ci->cfg_mode) {
  609. hw->cfg.start = pci_resource_start(hw->pdev, hw->ci->cfg_bar);
  610. hw->cfg.size = pci_resource_len(hw->pdev, hw->ci->cfg_bar);
  611. if (hw->ci->cfg_mode == AM_MEMIO) {
  612. if (!request_mem_region(hw->cfg.start, hw->cfg.size,
  613. hw->name))
  614. err = -EBUSY;
  615. } else {
  616. if (!request_region(hw->cfg.start, hw->cfg.size,
  617. hw->name))
  618. err = -EBUSY;
  619. }
  620. if (err) {
  621. pr_info("mISDN: %s config port %lx (%lu bytes)"
  622. "already in use\n", hw->name,
  623. (ulong)hw->cfg.start, (ulong)hw->cfg.size);
  624. return err;
  625. }
  626. if (hw->ci->cfg_mode == AM_MEMIO)
  627. hw->cfg.p = ioremap(hw->cfg.start, hw->cfg.size);
  628. hw->cfg.mode = hw->ci->cfg_mode;
  629. if (debug & DEBUG_HW)
  630. pr_notice("%s: IO cfg %lx (%lu bytes) mode%d\n",
  631. hw->name, (ulong)hw->cfg.start,
  632. (ulong)hw->cfg.size, hw->ci->cfg_mode);
  633. }
  634. if (hw->ci->addr_mode) {
  635. hw->addr.start = pci_resource_start(hw->pdev, hw->ci->addr_bar);
  636. hw->addr.size = pci_resource_len(hw->pdev, hw->ci->addr_bar);
  637. if (hw->ci->addr_mode == AM_MEMIO) {
  638. if (!request_mem_region(hw->addr.start, hw->addr.size,
  639. hw->name))
  640. err = -EBUSY;
  641. } else {
  642. if (!request_region(hw->addr.start, hw->addr.size,
  643. hw->name))
  644. err = -EBUSY;
  645. }
  646. if (err) {
  647. pr_info("mISDN: %s address port %lx (%lu bytes)"
  648. "already in use\n", hw->name,
  649. (ulong)hw->addr.start, (ulong)hw->addr.size);
  650. return err;
  651. }
  652. if (hw->ci->addr_mode == AM_MEMIO)
  653. hw->addr.p = ioremap(hw->addr.start, hw->addr.size);
  654. hw->addr.mode = hw->ci->addr_mode;
  655. if (debug & DEBUG_HW)
  656. pr_notice("%s: IO addr %lx (%lu bytes) mode%d\n",
  657. hw->name, (ulong)hw->addr.start,
  658. (ulong)hw->addr.size, hw->ci->addr_mode);
  659. }
  660. switch (hw->ci->typ) {
  661. case INF_DIVA20:
  662. case INF_DIVA20U:
  663. hw->ipac.type = IPAC_TYPE_ISAC | IPAC_TYPE_HSCX;
  664. hw->isac.mode = hw->cfg.mode;
  665. hw->isac.a.io.ale = (u32)hw->cfg.start + DIVA_ISAC_ALE;
  666. hw->isac.a.io.port = (u32)hw->cfg.start + DIVA_ISAC_PORT;
  667. hw->hscx.mode = hw->cfg.mode;
  668. hw->hscx.a.io.ale = (u32)hw->cfg.start + DIVA_HSCX_ALE;
  669. hw->hscx.a.io.port = (u32)hw->cfg.start + DIVA_HSCX_PORT;
  670. break;
  671. case INF_DIVA201:
  672. hw->ipac.type = IPAC_TYPE_IPAC;
  673. hw->ipac.isac.off = 0x80;
  674. hw->isac.mode = hw->addr.mode;
  675. hw->isac.a.p = hw->addr.p;
  676. hw->hscx.mode = hw->addr.mode;
  677. hw->hscx.a.p = hw->addr.p;
  678. break;
  679. case INF_DIVA202:
  680. hw->ipac.type = IPAC_TYPE_IPACX;
  681. hw->isac.mode = hw->addr.mode;
  682. hw->isac.a.p = hw->addr.p;
  683. hw->hscx.mode = hw->addr.mode;
  684. hw->hscx.a.p = hw->addr.p;
  685. break;
  686. case INF_SPEEDWIN:
  687. case INF_SAPHIR3:
  688. hw->ipac.type = IPAC_TYPE_IPAC;
  689. hw->ipac.isac.off = 0x80;
  690. hw->isac.mode = hw->cfg.mode;
  691. hw->isac.a.io.ale = (u32)hw->cfg.start + TIGER_IPAC_ALE;
  692. hw->isac.a.io.port = (u32)hw->cfg.start + TIGER_IPAC_PORT;
  693. hw->hscx.mode = hw->cfg.mode;
  694. hw->hscx.a.io.ale = (u32)hw->cfg.start + TIGER_IPAC_ALE;
  695. hw->hscx.a.io.port = (u32)hw->cfg.start + TIGER_IPAC_PORT;
  696. outb(0xff, (ulong)hw->cfg.start);
  697. mdelay(1);
  698. outb(0x00, (ulong)hw->cfg.start);
  699. mdelay(1);
  700. outb(TIGER_IOMASK, (ulong)hw->cfg.start + TIGER_AUX_CTRL);
  701. break;
  702. case INF_QS1000:
  703. case INF_QS3000:
  704. hw->ipac.type = IPAC_TYPE_IPAC;
  705. hw->ipac.isac.off = 0x80;
  706. hw->isac.a.io.ale = (u32)hw->addr.start;
  707. hw->isac.a.io.port = (u32)hw->addr.start + 1;
  708. hw->isac.mode = hw->addr.mode;
  709. hw->hscx.a.io.ale = (u32)hw->addr.start;
  710. hw->hscx.a.io.port = (u32)hw->addr.start + 1;
  711. hw->hscx.mode = hw->addr.mode;
  712. break;
  713. case INF_NICCY:
  714. hw->ipac.type = IPAC_TYPE_ISAC | IPAC_TYPE_HSCX;
  715. hw->isac.mode = hw->addr.mode;
  716. hw->isac.a.io.ale = (u32)hw->addr.start + NICCY_ISAC_ALE;
  717. hw->isac.a.io.port = (u32)hw->addr.start + NICCY_ISAC_PORT;
  718. hw->hscx.mode = hw->addr.mode;
  719. hw->hscx.a.io.ale = (u32)hw->addr.start + NICCY_HSCX_ALE;
  720. hw->hscx.a.io.port = (u32)hw->addr.start + NICCY_HSCX_PORT;
  721. break;
  722. case INF_SCT_1:
  723. hw->ipac.type = IPAC_TYPE_IPAC;
  724. hw->ipac.isac.off = 0x80;
  725. hw->isac.a.io.ale = (u32)hw->addr.start;
  726. hw->isac.a.io.port = hw->isac.a.io.ale + 4;
  727. hw->isac.mode = hw->addr.mode;
  728. hw->hscx.a.io.ale = hw->isac.a.io.ale;
  729. hw->hscx.a.io.port = hw->isac.a.io.port;
  730. hw->hscx.mode = hw->addr.mode;
  731. break;
  732. case INF_SCT_2:
  733. hw->ipac.type = IPAC_TYPE_IPAC;
  734. hw->ipac.isac.off = 0x80;
  735. hw->isac.a.io.ale = (u32)hw->addr.start + 0x08;
  736. hw->isac.a.io.port = hw->isac.a.io.ale + 4;
  737. hw->isac.mode = hw->addr.mode;
  738. hw->hscx.a.io.ale = hw->isac.a.io.ale;
  739. hw->hscx.a.io.port = hw->isac.a.io.port;
  740. hw->hscx.mode = hw->addr.mode;
  741. break;
  742. case INF_SCT_3:
  743. hw->ipac.type = IPAC_TYPE_IPAC;
  744. hw->ipac.isac.off = 0x80;
  745. hw->isac.a.io.ale = (u32)hw->addr.start + 0x10;
  746. hw->isac.a.io.port = hw->isac.a.io.ale + 4;
  747. hw->isac.mode = hw->addr.mode;
  748. hw->hscx.a.io.ale = hw->isac.a.io.ale;
  749. hw->hscx.a.io.port = hw->isac.a.io.port;
  750. hw->hscx.mode = hw->addr.mode;
  751. break;
  752. case INF_SCT_4:
  753. hw->ipac.type = IPAC_TYPE_IPAC;
  754. hw->ipac.isac.off = 0x80;
  755. hw->isac.a.io.ale = (u32)hw->addr.start + 0x20;
  756. hw->isac.a.io.port = hw->isac.a.io.ale + 4;
  757. hw->isac.mode = hw->addr.mode;
  758. hw->hscx.a.io.ale = hw->isac.a.io.ale;
  759. hw->hscx.a.io.port = hw->isac.a.io.port;
  760. hw->hscx.mode = hw->addr.mode;
  761. break;
  762. case INF_GAZEL_R685:
  763. hw->ipac.type = IPAC_TYPE_ISAC | IPAC_TYPE_HSCX;
  764. hw->ipac.isac.off = 0x80;
  765. hw->isac.mode = hw->addr.mode;
  766. hw->isac.a.io.port = (u32)hw->addr.start;
  767. hw->hscx.mode = hw->addr.mode;
  768. hw->hscx.a.io.port = hw->isac.a.io.port;
  769. break;
  770. case INF_GAZEL_R753:
  771. hw->ipac.type = IPAC_TYPE_IPAC;
  772. hw->ipac.isac.off = 0x80;
  773. hw->isac.mode = hw->addr.mode;
  774. hw->isac.a.io.ale = (u32)hw->addr.start;
  775. hw->isac.a.io.port = (u32)hw->addr.start + GAZEL_IPAC_DATA_PORT;
  776. hw->hscx.mode = hw->addr.mode;
  777. hw->hscx.a.io.ale = hw->isac.a.io.ale;
  778. hw->hscx.a.io.port = hw->isac.a.io.port;
  779. break;
  780. default:
  781. return -EINVAL;
  782. }
  783. switch (hw->isac.mode) {
  784. case AM_MEMIO:
  785. ASSIGN_FUNC_IPAC(MIO, hw->ipac);
  786. break;
  787. case AM_IND_IO:
  788. ASSIGN_FUNC_IPAC(IND, hw->ipac);
  789. break;
  790. case AM_IO:
  791. ASSIGN_FUNC_IPAC(IO, hw->ipac);
  792. break;
  793. default:
  794. return -EINVAL;
  795. }
  796. return 0;
  797. }
  798. static void
  799. release_card(struct inf_hw *card) {
  800. ulong flags;
  801. int i;
  802. spin_lock_irqsave(&card->lock, flags);
  803. disable_hwirq(card);
  804. spin_unlock_irqrestore(&card->lock, flags);
  805. card->ipac.isac.release(&card->ipac.isac);
  806. free_irq(card->irq, card);
  807. mISDN_unregister_device(&card->ipac.isac.dch.dev);
  808. release_io(card);
  809. write_lock_irqsave(&card_lock, flags);
  810. list_del(&card->list);
  811. write_unlock_irqrestore(&card_lock, flags);
  812. switch (card->ci->typ) {
  813. case INF_SCT_2:
  814. case INF_SCT_3:
  815. case INF_SCT_4:
  816. break;
  817. case INF_SCT_1:
  818. for (i = 0; i < 3; i++) {
  819. if (card->sc[i])
  820. release_card(card->sc[i]);
  821. card->sc[i] = NULL;
  822. }
  823. default:
  824. pci_disable_device(card->pdev);
  825. pci_set_drvdata(card->pdev, NULL);
  826. break;
  827. }
  828. kfree(card);
  829. inf_cnt--;
  830. }
  831. static int __devinit
  832. setup_instance(struct inf_hw *card)
  833. {
  834. int err;
  835. ulong flags;
  836. snprintf(card->name, MISDN_MAX_IDLEN - 1, "%s.%d", card->ci->name,
  837. inf_cnt + 1);
  838. write_lock_irqsave(&card_lock, flags);
  839. list_add_tail(&card->list, &Cards);
  840. write_unlock_irqrestore(&card_lock, flags);
  841. _set_debug(card);
  842. card->ipac.isac.name = card->name;
  843. card->ipac.name = card->name;
  844. card->ipac.owner = THIS_MODULE;
  845. spin_lock_init(&card->lock);
  846. card->ipac.isac.hwlock = &card->lock;
  847. card->ipac.hwlock = &card->lock;
  848. card->ipac.ctrl = (void *)&inf_ctrl;
  849. err = setup_io(card);
  850. if (err)
  851. goto error_setup;
  852. card->ipac.isac.dch.dev.Bprotocols =
  853. mISDNipac_init(&card->ipac, card);
  854. if (card->ipac.isac.dch.dev.Bprotocols == 0)
  855. goto error_setup;
  856. err = mISDN_register_device(&card->ipac.isac.dch.dev,
  857. &card->pdev->dev, card->name);
  858. if (err)
  859. goto error;
  860. err = init_irq(card);
  861. if (!err) {
  862. inf_cnt++;
  863. pr_notice("Infineon %d cards installed\n", inf_cnt);
  864. return 0;
  865. }
  866. mISDN_unregister_device(&card->ipac.isac.dch.dev);
  867. error:
  868. card->ipac.release(&card->ipac);
  869. error_setup:
  870. release_io(card);
  871. write_lock_irqsave(&card_lock, flags);
  872. list_del(&card->list);
  873. write_unlock_irqrestore(&card_lock, flags);
  874. return err;
  875. }
  876. static const struct inf_cinfo inf_card_info[] = {
  877. {
  878. INF_DIVA20,
  879. "Dialogic Diva 2.0",
  880. "diva20",
  881. AM_IND_IO, AM_NONE, 2, 0,
  882. &diva_irq
  883. },
  884. {
  885. INF_DIVA20U,
  886. "Dialogic Diva 2.0U",
  887. "diva20U",
  888. AM_IND_IO, AM_NONE, 2, 0,
  889. &diva_irq
  890. },
  891. {
  892. INF_DIVA201,
  893. "Dialogic Diva 2.01",
  894. "diva201",
  895. AM_MEMIO, AM_MEMIO, 0, 1,
  896. &diva20x_irq
  897. },
  898. {
  899. INF_DIVA202,
  900. "Dialogic Diva 2.02",
  901. "diva202",
  902. AM_MEMIO, AM_MEMIO, 0, 1,
  903. &diva20x_irq
  904. },
  905. {
  906. INF_SPEEDWIN,
  907. "Sedlbauer SpeedWin PCI",
  908. "speedwin",
  909. AM_IND_IO, AM_NONE, 0, 0,
  910. &tiger_irq
  911. },
  912. {
  913. INF_SAPHIR3,
  914. "HST Saphir 3",
  915. "saphir",
  916. AM_IND_IO, AM_NONE, 0, 0,
  917. &tiger_irq
  918. },
  919. {
  920. INF_QS1000,
  921. "Develo Microlink PCI",
  922. "qs1000",
  923. AM_IO, AM_IND_IO, 1, 3,
  924. &elsa_irq
  925. },
  926. {
  927. INF_QS3000,
  928. "Develo QuickStep 3000",
  929. "qs3000",
  930. AM_IO, AM_IND_IO, 1, 3,
  931. &elsa_irq
  932. },
  933. {
  934. INF_NICCY,
  935. "Sagem NICCY",
  936. "niccy",
  937. AM_IO, AM_IND_IO, 0, 1,
  938. &niccy_irq
  939. },
  940. {
  941. INF_SCT_1,
  942. "SciTel Quadro",
  943. "p1_scitel",
  944. AM_IO, AM_IND_IO, 1, 5,
  945. &ipac_irq
  946. },
  947. {
  948. INF_SCT_2,
  949. "SciTel Quadro",
  950. "p2_scitel",
  951. AM_NONE, AM_IND_IO, 0, 4,
  952. &ipac_irq
  953. },
  954. {
  955. INF_SCT_3,
  956. "SciTel Quadro",
  957. "p3_scitel",
  958. AM_NONE, AM_IND_IO, 0, 3,
  959. &ipac_irq
  960. },
  961. {
  962. INF_SCT_4,
  963. "SciTel Quadro",
  964. "p4_scitel",
  965. AM_NONE, AM_IND_IO, 0, 2,
  966. &ipac_irq
  967. },
  968. {
  969. INF_GAZEL_R685,
  970. "Gazel R685",
  971. "gazel685",
  972. AM_IO, AM_IO, 1, 2,
  973. &gazel_irq
  974. },
  975. {
  976. INF_GAZEL_R753,
  977. "Gazel R753",
  978. "gazel753",
  979. AM_IO, AM_IND_IO, 1, 2,
  980. &ipac_irq
  981. },
  982. {
  983. INF_NONE,
  984. }
  985. };
  986. static const struct inf_cinfo * __devinit
  987. get_card_info(enum inf_types typ)
  988. {
  989. const struct inf_cinfo *ci = inf_card_info;
  990. while (ci->typ != INF_NONE) {
  991. if (ci->typ == typ)
  992. return ci;
  993. ci++;
  994. }
  995. return NULL;
  996. }
  997. static int __devinit
  998. inf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
  999. {
  1000. int err = -ENOMEM;
  1001. struct inf_hw *card;
  1002. card = kzalloc(sizeof(struct inf_hw), GFP_KERNEL);
  1003. if (!card) {
  1004. pr_info("No memory for Infineon ISDN card\n");
  1005. return err;
  1006. }
  1007. card->pdev = pdev;
  1008. err = pci_enable_device(pdev);
  1009. if (err) {
  1010. kfree(card);
  1011. return err;
  1012. }
  1013. card->ci = get_card_info(ent->driver_data);
  1014. if (!card->ci) {
  1015. pr_info("mISDN: do not have informations about adapter at %s\n",
  1016. pci_name(pdev));
  1017. kfree(card);
  1018. pci_disable_device(pdev);
  1019. return -EINVAL;
  1020. } else
  1021. pr_notice("mISDN: found adapter %s at %s\n",
  1022. card->ci->full, pci_name(pdev));
  1023. card->irq = pdev->irq;
  1024. pci_set_drvdata(pdev, card);
  1025. err = setup_instance(card);
  1026. if (err) {
  1027. pci_disable_device(pdev);
  1028. kfree(card);
  1029. pci_set_drvdata(pdev, NULL);
  1030. } else if (ent->driver_data == INF_SCT_1) {
  1031. int i;
  1032. struct inf_hw *sc;
  1033. for (i = 1; i < 4; i++) {
  1034. sc = kzalloc(sizeof(struct inf_hw), GFP_KERNEL);
  1035. if (!sc) {
  1036. release_card(card);
  1037. pci_disable_device(pdev);
  1038. return -ENOMEM;
  1039. }
  1040. sc->irq = card->irq;
  1041. sc->pdev = card->pdev;
  1042. sc->ci = card->ci + i;
  1043. err = setup_instance(sc);
  1044. if (err) {
  1045. pci_disable_device(pdev);
  1046. kfree(sc);
  1047. release_card(card);
  1048. break;
  1049. } else
  1050. card->sc[i - 1] = sc;
  1051. }
  1052. }
  1053. return err;
  1054. }
  1055. static void __devexit
  1056. inf_remove(struct pci_dev *pdev)
  1057. {
  1058. struct inf_hw *card = pci_get_drvdata(pdev);
  1059. if (card)
  1060. release_card(card);
  1061. else
  1062. pr_debug("%s: drvdata already removed\n", __func__);
  1063. }
  1064. static struct pci_driver infineon_driver = {
  1065. .name = "ISDN Infineon pci",
  1066. .probe = inf_probe,
  1067. .remove = __devexit_p(inf_remove),
  1068. .id_table = infineon_ids,
  1069. };
  1070. static int __init
  1071. infineon_init(void)
  1072. {
  1073. int err;
  1074. pr_notice("Infineon ISDN Driver Rev. %s\n", INFINEON_REV);
  1075. err = pci_register_driver(&infineon_driver);
  1076. return err;
  1077. }
  1078. static void __exit
  1079. infineon_cleanup(void)
  1080. {
  1081. pci_unregister_driver(&infineon_driver);
  1082. }
  1083. module_init(infineon_init);
  1084. module_exit(infineon_cleanup);