avmfritz.c 27 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177
  1. /*
  2. * avm_fritz.c low level stuff for AVM FRITZ!CARD PCI ISDN cards
  3. * Thanks to AVM, Berlin for informations
  4. *
  5. * Author Karsten Keil <keil@isdn4linux.de>
  6. *
  7. * Copyright 2009 by Karsten Keil <keil@isdn4linux.de>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21. *
  22. */
  23. #include <linux/interrupt.h>
  24. #include <linux/module.h>
  25. #include <linux/pci.h>
  26. #include <linux/delay.h>
  27. #include <linux/mISDNhw.h>
  28. #include <linux/slab.h>
  29. #include <asm/unaligned.h>
  30. #include "ipac.h"
  31. #define AVMFRITZ_REV "2.3"
  32. static int AVM_cnt;
  33. static int debug;
  34. enum {
  35. AVM_FRITZ_PCI,
  36. AVM_FRITZ_PCIV2,
  37. };
  38. #define HDLC_FIFO 0x0
  39. #define HDLC_STATUS 0x4
  40. #define CHIP_WINDOW 0x10
  41. #define CHIP_INDEX 0x4
  42. #define AVM_HDLC_1 0x00
  43. #define AVM_HDLC_2 0x01
  44. #define AVM_ISAC_FIFO 0x02
  45. #define AVM_ISAC_REG_LOW 0x04
  46. #define AVM_ISAC_REG_HIGH 0x06
  47. #define AVM_STATUS0_IRQ_ISAC 0x01
  48. #define AVM_STATUS0_IRQ_HDLC 0x02
  49. #define AVM_STATUS0_IRQ_TIMER 0x04
  50. #define AVM_STATUS0_IRQ_MASK 0x07
  51. #define AVM_STATUS0_RESET 0x01
  52. #define AVM_STATUS0_DIS_TIMER 0x02
  53. #define AVM_STATUS0_RES_TIMER 0x04
  54. #define AVM_STATUS0_ENA_IRQ 0x08
  55. #define AVM_STATUS0_TESTBIT 0x10
  56. #define AVM_STATUS1_INT_SEL 0x0f
  57. #define AVM_STATUS1_ENA_IOM 0x80
  58. #define HDLC_MODE_ITF_FLG 0x01
  59. #define HDLC_MODE_TRANS 0x02
  60. #define HDLC_MODE_CCR_7 0x04
  61. #define HDLC_MODE_CCR_16 0x08
  62. #define HDLC_FIFO_SIZE_128 0x20
  63. #define HDLC_MODE_TESTLOOP 0x80
  64. #define HDLC_INT_XPR 0x80
  65. #define HDLC_INT_XDU 0x40
  66. #define HDLC_INT_RPR 0x20
  67. #define HDLC_INT_MASK 0xE0
  68. #define HDLC_STAT_RME 0x01
  69. #define HDLC_STAT_RDO 0x10
  70. #define HDLC_STAT_CRCVFRRAB 0x0E
  71. #define HDLC_STAT_CRCVFR 0x06
  72. #define HDLC_STAT_RML_MASK_V1 0x3f00
  73. #define HDLC_STAT_RML_MASK_V2 0x7f00
  74. #define HDLC_CMD_XRS 0x80
  75. #define HDLC_CMD_XME 0x01
  76. #define HDLC_CMD_RRS 0x20
  77. #define HDLC_CMD_XML_MASK 0x3f00
  78. #define HDLC_FIFO_SIZE_V1 32
  79. #define HDLC_FIFO_SIZE_V2 128
  80. /* Fritz PCI v2.0 */
  81. #define AVM_HDLC_FIFO_1 0x10
  82. #define AVM_HDLC_FIFO_2 0x18
  83. #define AVM_HDLC_STATUS_1 0x14
  84. #define AVM_HDLC_STATUS_2 0x1c
  85. #define AVM_ISACX_INDEX 0x04
  86. #define AVM_ISACX_DATA 0x08
  87. /* data struct */
  88. #define LOG_SIZE 63
  89. struct hdlc_stat_reg {
  90. #ifdef __BIG_ENDIAN
  91. u8 fill;
  92. u8 mode;
  93. u8 xml;
  94. u8 cmd;
  95. #else
  96. u8 cmd;
  97. u8 xml;
  98. u8 mode;
  99. u8 fill;
  100. #endif
  101. } __attribute__((packed));
  102. struct hdlc_hw {
  103. union {
  104. u32 ctrl;
  105. struct hdlc_stat_reg sr;
  106. } ctrl;
  107. u32 stat;
  108. };
  109. struct fritzcard {
  110. struct list_head list;
  111. struct pci_dev *pdev;
  112. char name[MISDN_MAX_IDLEN];
  113. u8 type;
  114. u8 ctrlreg;
  115. u16 irq;
  116. u32 irqcnt;
  117. u32 addr;
  118. spinlock_t lock; /* hw lock */
  119. struct isac_hw isac;
  120. struct hdlc_hw hdlc[2];
  121. struct bchannel bch[2];
  122. char log[LOG_SIZE + 1];
  123. };
  124. static LIST_HEAD(Cards);
  125. static DEFINE_RWLOCK(card_lock); /* protect Cards */
  126. static void
  127. _set_debug(struct fritzcard *card)
  128. {
  129. card->isac.dch.debug = debug;
  130. card->bch[0].debug = debug;
  131. card->bch[1].debug = debug;
  132. }
  133. static int
  134. set_debug(const char *val, struct kernel_param *kp)
  135. {
  136. int ret;
  137. struct fritzcard *card;
  138. ret = param_set_uint(val, kp);
  139. if (!ret) {
  140. read_lock(&card_lock);
  141. list_for_each_entry(card, &Cards, list)
  142. _set_debug(card);
  143. read_unlock(&card_lock);
  144. }
  145. return ret;
  146. }
  147. MODULE_AUTHOR("Karsten Keil");
  148. MODULE_LICENSE("GPL v2");
  149. MODULE_VERSION(AVMFRITZ_REV);
  150. module_param_call(debug, set_debug, param_get_uint, &debug, S_IRUGO | S_IWUSR);
  151. MODULE_PARM_DESC(debug, "avmfritz debug mask");
  152. /* Interface functions */
  153. static u8
  154. ReadISAC_V1(void *p, u8 offset)
  155. {
  156. struct fritzcard *fc = p;
  157. u8 idx = (offset > 0x2f) ? AVM_ISAC_REG_HIGH : AVM_ISAC_REG_LOW;
  158. outb(idx, fc->addr + CHIP_INDEX);
  159. return inb(fc->addr + CHIP_WINDOW + (offset & 0xf));
  160. }
  161. static void
  162. WriteISAC_V1(void *p, u8 offset, u8 value)
  163. {
  164. struct fritzcard *fc = p;
  165. u8 idx = (offset > 0x2f) ? AVM_ISAC_REG_HIGH : AVM_ISAC_REG_LOW;
  166. outb(idx, fc->addr + CHIP_INDEX);
  167. outb(value, fc->addr + CHIP_WINDOW + (offset & 0xf));
  168. }
  169. static void
  170. ReadFiFoISAC_V1(void *p, u8 off, u8 *data, int size)
  171. {
  172. struct fritzcard *fc = p;
  173. outb(AVM_ISAC_FIFO, fc->addr + CHIP_INDEX);
  174. insb(fc->addr + CHIP_WINDOW, data, size);
  175. }
  176. static void
  177. WriteFiFoISAC_V1(void *p, u8 off, u8 *data, int size)
  178. {
  179. struct fritzcard *fc = p;
  180. outb(AVM_ISAC_FIFO, fc->addr + CHIP_INDEX);
  181. outsb(fc->addr + CHIP_WINDOW, data, size);
  182. }
  183. static u8
  184. ReadISAC_V2(void *p, u8 offset)
  185. {
  186. struct fritzcard *fc = p;
  187. outl(offset, fc->addr + AVM_ISACX_INDEX);
  188. return 0xff & inl(fc->addr + AVM_ISACX_DATA);
  189. }
  190. static void
  191. WriteISAC_V2(void *p, u8 offset, u8 value)
  192. {
  193. struct fritzcard *fc = p;
  194. outl(offset, fc->addr + AVM_ISACX_INDEX);
  195. outl(value, fc->addr + AVM_ISACX_DATA);
  196. }
  197. static void
  198. ReadFiFoISAC_V2(void *p, u8 off, u8 *data, int size)
  199. {
  200. struct fritzcard *fc = p;
  201. int i;
  202. outl(off, fc->addr + AVM_ISACX_INDEX);
  203. for (i = 0; i < size; i++)
  204. data[i] = 0xff & inl(fc->addr + AVM_ISACX_DATA);
  205. }
  206. static void
  207. WriteFiFoISAC_V2(void *p, u8 off, u8 *data, int size)
  208. {
  209. struct fritzcard *fc = p;
  210. int i;
  211. outl(off, fc->addr + AVM_ISACX_INDEX);
  212. for (i = 0; i < size; i++)
  213. outl(data[i], fc->addr + AVM_ISACX_DATA);
  214. }
  215. static struct bchannel *
  216. Sel_BCS(struct fritzcard *fc, u32 channel)
  217. {
  218. if (test_bit(FLG_ACTIVE, &fc->bch[0].Flags) &&
  219. (fc->bch[0].nr & channel))
  220. return &fc->bch[0];
  221. else if (test_bit(FLG_ACTIVE, &fc->bch[1].Flags) &&
  222. (fc->bch[1].nr & channel))
  223. return &fc->bch[1];
  224. else
  225. return NULL;
  226. }
  227. static inline void
  228. __write_ctrl_pci(struct fritzcard *fc, struct hdlc_hw *hdlc, u32 channel) {
  229. u32 idx = channel == 2 ? AVM_HDLC_2 : AVM_HDLC_1;
  230. outl(idx, fc->addr + CHIP_INDEX);
  231. outl(hdlc->ctrl.ctrl, fc->addr + CHIP_WINDOW + HDLC_STATUS);
  232. }
  233. static inline void
  234. __write_ctrl_pciv2(struct fritzcard *fc, struct hdlc_hw *hdlc, u32 channel) {
  235. outl(hdlc->ctrl.ctrl, fc->addr + (channel == 2 ? AVM_HDLC_STATUS_2 :
  236. AVM_HDLC_STATUS_1));
  237. }
  238. static void
  239. write_ctrl(struct bchannel *bch, int which) {
  240. struct fritzcard *fc = bch->hw;
  241. struct hdlc_hw *hdlc;
  242. hdlc = &fc->hdlc[(bch->nr - 1) & 1];
  243. pr_debug("%s: hdlc %c wr%x ctrl %x\n", fc->name, '@' + bch->nr,
  244. which, hdlc->ctrl.ctrl);
  245. switch (fc->type) {
  246. case AVM_FRITZ_PCIV2:
  247. __write_ctrl_pciv2(fc, hdlc, bch->nr);
  248. break;
  249. case AVM_FRITZ_PCI:
  250. __write_ctrl_pci(fc, hdlc, bch->nr);
  251. break;
  252. }
  253. }
  254. static inline u32
  255. __read_status_pci(u_long addr, u32 channel)
  256. {
  257. outl(channel == 2 ? AVM_HDLC_2 : AVM_HDLC_1, addr + CHIP_INDEX);
  258. return inl(addr + CHIP_WINDOW + HDLC_STATUS);
  259. }
  260. static inline u32
  261. __read_status_pciv2(u_long addr, u32 channel)
  262. {
  263. return inl(addr + (channel == 2 ? AVM_HDLC_STATUS_2 :
  264. AVM_HDLC_STATUS_1));
  265. }
  266. static u32
  267. read_status(struct fritzcard *fc, u32 channel)
  268. {
  269. switch (fc->type) {
  270. case AVM_FRITZ_PCIV2:
  271. return __read_status_pciv2(fc->addr, channel);
  272. case AVM_FRITZ_PCI:
  273. return __read_status_pci(fc->addr, channel);
  274. }
  275. /* dummy */
  276. return 0;
  277. }
  278. static void
  279. enable_hwirq(struct fritzcard *fc)
  280. {
  281. fc->ctrlreg |= AVM_STATUS0_ENA_IRQ;
  282. outb(fc->ctrlreg, fc->addr + 2);
  283. }
  284. static void
  285. disable_hwirq(struct fritzcard *fc)
  286. {
  287. fc->ctrlreg &= ~AVM_STATUS0_ENA_IRQ;
  288. outb(fc->ctrlreg, fc->addr + 2);
  289. }
  290. static int
  291. modehdlc(struct bchannel *bch, int protocol)
  292. {
  293. struct fritzcard *fc = bch->hw;
  294. struct hdlc_hw *hdlc;
  295. u8 mode;
  296. hdlc = &fc->hdlc[(bch->nr - 1) & 1];
  297. pr_debug("%s: hdlc %c protocol %x-->%x ch %d\n", fc->name,
  298. '@' + bch->nr, bch->state, protocol, bch->nr);
  299. hdlc->ctrl.ctrl = 0;
  300. mode = (fc->type == AVM_FRITZ_PCIV2) ? HDLC_FIFO_SIZE_128 : 0;
  301. switch (protocol) {
  302. case -1: /* used for init */
  303. bch->state = -1;
  304. case ISDN_P_NONE:
  305. if (bch->state == ISDN_P_NONE)
  306. break;
  307. hdlc->ctrl.sr.cmd = HDLC_CMD_XRS | HDLC_CMD_RRS;
  308. hdlc->ctrl.sr.mode = mode | HDLC_MODE_TRANS;
  309. write_ctrl(bch, 5);
  310. bch->state = ISDN_P_NONE;
  311. test_and_clear_bit(FLG_HDLC, &bch->Flags);
  312. test_and_clear_bit(FLG_TRANSPARENT, &bch->Flags);
  313. break;
  314. case ISDN_P_B_RAW:
  315. bch->state = protocol;
  316. hdlc->ctrl.sr.cmd = HDLC_CMD_XRS | HDLC_CMD_RRS;
  317. hdlc->ctrl.sr.mode = mode | HDLC_MODE_TRANS;
  318. write_ctrl(bch, 5);
  319. hdlc->ctrl.sr.cmd = HDLC_CMD_XRS;
  320. write_ctrl(bch, 1);
  321. hdlc->ctrl.sr.cmd = 0;
  322. test_and_set_bit(FLG_TRANSPARENT, &bch->Flags);
  323. break;
  324. case ISDN_P_B_HDLC:
  325. bch->state = protocol;
  326. hdlc->ctrl.sr.cmd = HDLC_CMD_XRS | HDLC_CMD_RRS;
  327. hdlc->ctrl.sr.mode = mode | HDLC_MODE_ITF_FLG;
  328. write_ctrl(bch, 5);
  329. hdlc->ctrl.sr.cmd = HDLC_CMD_XRS;
  330. write_ctrl(bch, 1);
  331. hdlc->ctrl.sr.cmd = 0;
  332. test_and_set_bit(FLG_HDLC, &bch->Flags);
  333. break;
  334. default:
  335. pr_info("%s: protocol not known %x\n", fc->name, protocol);
  336. return -ENOPROTOOPT;
  337. }
  338. return 0;
  339. }
  340. static void
  341. hdlc_empty_fifo(struct bchannel *bch, int count)
  342. {
  343. u32 *ptr;
  344. u8 *p;
  345. u32 val, addr;
  346. int cnt;
  347. struct fritzcard *fc = bch->hw;
  348. pr_debug("%s: %s %d\n", fc->name, __func__, count);
  349. if (test_bit(FLG_RX_OFF, &bch->Flags)) {
  350. p = NULL;
  351. bch->dropcnt += count;
  352. } else {
  353. cnt = bchannel_get_rxbuf(bch, count);
  354. if (cnt < 0) {
  355. pr_warning("%s.B%d: No bufferspace for %d bytes\n",
  356. fc->name, bch->nr, count);
  357. return;
  358. }
  359. p = skb_put(bch->rx_skb, count);
  360. }
  361. ptr = (u32 *)p;
  362. if (fc->type == AVM_FRITZ_PCIV2)
  363. addr = fc->addr + (bch->nr == 2 ?
  364. AVM_HDLC_FIFO_2 : AVM_HDLC_FIFO_1);
  365. else {
  366. addr = fc->addr + CHIP_WINDOW;
  367. outl(bch->nr == 2 ? AVM_HDLC_2 : AVM_HDLC_1, fc->addr);
  368. }
  369. cnt = 0;
  370. while (cnt < count) {
  371. val = le32_to_cpu(inl(addr));
  372. if (p) {
  373. put_unaligned(val, ptr);
  374. ptr++;
  375. }
  376. cnt += 4;
  377. }
  378. if (p && (debug & DEBUG_HW_BFIFO)) {
  379. snprintf(fc->log, LOG_SIZE, "B%1d-recv %s %d ",
  380. bch->nr, fc->name, count);
  381. print_hex_dump_bytes(fc->log, DUMP_PREFIX_OFFSET, p, count);
  382. }
  383. }
  384. static void
  385. hdlc_fill_fifo(struct bchannel *bch)
  386. {
  387. struct fritzcard *fc = bch->hw;
  388. struct hdlc_hw *hdlc;
  389. int count, fs, cnt = 0, idx;
  390. bool fillempty = false;
  391. u8 *p;
  392. u32 *ptr, val, addr;
  393. idx = (bch->nr - 1) & 1;
  394. hdlc = &fc->hdlc[idx];
  395. fs = (fc->type == AVM_FRITZ_PCIV2) ?
  396. HDLC_FIFO_SIZE_V2 : HDLC_FIFO_SIZE_V1;
  397. if (!bch->tx_skb) {
  398. if (!test_bit(FLG_TX_EMPTY, &bch->Flags))
  399. return;
  400. count = fs;
  401. p = bch->fill;
  402. fillempty = true;
  403. } else {
  404. count = bch->tx_skb->len - bch->tx_idx;
  405. if (count <= 0)
  406. return;
  407. p = bch->tx_skb->data + bch->tx_idx;
  408. }
  409. hdlc->ctrl.sr.cmd &= ~HDLC_CMD_XME;
  410. if (count > fs) {
  411. count = fs;
  412. } else {
  413. if (test_bit(FLG_HDLC, &bch->Flags))
  414. hdlc->ctrl.sr.cmd |= HDLC_CMD_XME;
  415. }
  416. ptr = (u32 *)p;
  417. if (!fillempty) {
  418. pr_debug("%s.B%d: %d/%d/%d", fc->name, bch->nr, count,
  419. bch->tx_idx, bch->tx_skb->len);
  420. bch->tx_idx += count;
  421. } else {
  422. pr_debug("%s.B%d: fillempty %d\n", fc->name, bch->nr, count);
  423. }
  424. hdlc->ctrl.sr.xml = ((count == fs) ? 0 : count);
  425. if (fc->type == AVM_FRITZ_PCIV2) {
  426. __write_ctrl_pciv2(fc, hdlc, bch->nr);
  427. addr = fc->addr + (bch->nr == 2 ?
  428. AVM_HDLC_FIFO_2 : AVM_HDLC_FIFO_1);
  429. } else {
  430. __write_ctrl_pci(fc, hdlc, bch->nr);
  431. addr = fc->addr + CHIP_WINDOW;
  432. }
  433. if (fillempty) {
  434. while (cnt < count) {
  435. /* all bytes the same - no worry about endian */
  436. outl(*ptr, addr);
  437. cnt += 4;
  438. }
  439. } else {
  440. while (cnt < count) {
  441. val = get_unaligned(ptr);
  442. outl(cpu_to_le32(val), addr);
  443. ptr++;
  444. cnt += 4;
  445. }
  446. }
  447. if ((debug & DEBUG_HW_BFIFO) && !fillempty) {
  448. snprintf(fc->log, LOG_SIZE, "B%1d-send %s %d ",
  449. bch->nr, fc->name, count);
  450. print_hex_dump_bytes(fc->log, DUMP_PREFIX_OFFSET, p, count);
  451. }
  452. }
  453. static void
  454. HDLC_irq_xpr(struct bchannel *bch)
  455. {
  456. if (bch->tx_skb && bch->tx_idx < bch->tx_skb->len) {
  457. hdlc_fill_fifo(bch);
  458. } else {
  459. if (bch->tx_skb)
  460. dev_kfree_skb(bch->tx_skb);
  461. if (get_next_bframe(bch)) {
  462. hdlc_fill_fifo(bch);
  463. test_and_clear_bit(FLG_TX_EMPTY, &bch->Flags);
  464. } else if (test_bit(FLG_TX_EMPTY, &bch->Flags)) {
  465. hdlc_fill_fifo(bch);
  466. }
  467. }
  468. }
  469. static void
  470. HDLC_irq(struct bchannel *bch, u32 stat)
  471. {
  472. struct fritzcard *fc = bch->hw;
  473. int len, fs;
  474. u32 rmlMask;
  475. struct hdlc_hw *hdlc;
  476. hdlc = &fc->hdlc[(bch->nr - 1) & 1];
  477. pr_debug("%s: ch%d stat %#x\n", fc->name, bch->nr, stat);
  478. if (fc->type == AVM_FRITZ_PCIV2) {
  479. rmlMask = HDLC_STAT_RML_MASK_V2;
  480. fs = HDLC_FIFO_SIZE_V2;
  481. } else {
  482. rmlMask = HDLC_STAT_RML_MASK_V1;
  483. fs = HDLC_FIFO_SIZE_V1;
  484. }
  485. if (stat & HDLC_INT_RPR) {
  486. if (stat & HDLC_STAT_RDO) {
  487. pr_warning("%s: ch%d stat %x RDO\n",
  488. fc->name, bch->nr, stat);
  489. hdlc->ctrl.sr.xml = 0;
  490. hdlc->ctrl.sr.cmd |= HDLC_CMD_RRS;
  491. write_ctrl(bch, 1);
  492. hdlc->ctrl.sr.cmd &= ~HDLC_CMD_RRS;
  493. write_ctrl(bch, 1);
  494. if (bch->rx_skb)
  495. skb_trim(bch->rx_skb, 0);
  496. } else {
  497. len = (stat & rmlMask) >> 8;
  498. if (!len)
  499. len = fs;
  500. hdlc_empty_fifo(bch, len);
  501. if (!bch->rx_skb)
  502. goto handle_tx;
  503. if (test_bit(FLG_TRANSPARENT, &bch->Flags)) {
  504. recv_Bchannel(bch, 0, false);
  505. } else if (stat & HDLC_STAT_RME) {
  506. if ((stat & HDLC_STAT_CRCVFRRAB) ==
  507. HDLC_STAT_CRCVFR) {
  508. recv_Bchannel(bch, 0, false);
  509. } else {
  510. pr_warning("%s: got invalid frame\n",
  511. fc->name);
  512. skb_trim(bch->rx_skb, 0);
  513. }
  514. }
  515. }
  516. }
  517. handle_tx:
  518. if (stat & HDLC_INT_XDU) {
  519. /* Here we lost an TX interrupt, so
  520. * restart transmitting the whole frame on HDLC
  521. * in transparent mode we send the next data
  522. */
  523. pr_warning("%s: ch%d stat %x XDU %s\n", fc->name, bch->nr,
  524. stat, bch->tx_skb ? "tx_skb" : "no tx_skb");
  525. if (bch->tx_skb && bch->tx_skb->len) {
  526. if (!test_bit(FLG_TRANSPARENT, &bch->Flags))
  527. bch->tx_idx = 0;
  528. } else if (test_bit(FLG_FILLEMPTY, &bch->Flags)) {
  529. test_and_set_bit(FLG_TX_EMPTY, &bch->Flags);
  530. }
  531. hdlc->ctrl.sr.xml = 0;
  532. hdlc->ctrl.sr.cmd |= HDLC_CMD_XRS;
  533. write_ctrl(bch, 1);
  534. hdlc->ctrl.sr.cmd &= ~HDLC_CMD_XRS;
  535. HDLC_irq_xpr(bch);
  536. return;
  537. } else if (stat & HDLC_INT_XPR)
  538. HDLC_irq_xpr(bch);
  539. }
  540. static inline void
  541. HDLC_irq_main(struct fritzcard *fc)
  542. {
  543. u32 stat;
  544. struct bchannel *bch;
  545. stat = read_status(fc, 1);
  546. if (stat & HDLC_INT_MASK) {
  547. bch = Sel_BCS(fc, 1);
  548. if (bch)
  549. HDLC_irq(bch, stat);
  550. else
  551. pr_debug("%s: spurious ch1 IRQ\n", fc->name);
  552. }
  553. stat = read_status(fc, 2);
  554. if (stat & HDLC_INT_MASK) {
  555. bch = Sel_BCS(fc, 2);
  556. if (bch)
  557. HDLC_irq(bch, stat);
  558. else
  559. pr_debug("%s: spurious ch2 IRQ\n", fc->name);
  560. }
  561. }
  562. static irqreturn_t
  563. avm_fritz_interrupt(int intno, void *dev_id)
  564. {
  565. struct fritzcard *fc = dev_id;
  566. u8 val;
  567. u8 sval;
  568. spin_lock(&fc->lock);
  569. sval = inb(fc->addr + 2);
  570. pr_debug("%s: irq stat0 %x\n", fc->name, sval);
  571. if ((sval & AVM_STATUS0_IRQ_MASK) == AVM_STATUS0_IRQ_MASK) {
  572. /* shared IRQ from other HW */
  573. spin_unlock(&fc->lock);
  574. return IRQ_NONE;
  575. }
  576. fc->irqcnt++;
  577. if (!(sval & AVM_STATUS0_IRQ_ISAC)) {
  578. val = ReadISAC_V1(fc, ISAC_ISTA);
  579. mISDNisac_irq(&fc->isac, val);
  580. }
  581. if (!(sval & AVM_STATUS0_IRQ_HDLC))
  582. HDLC_irq_main(fc);
  583. spin_unlock(&fc->lock);
  584. return IRQ_HANDLED;
  585. }
  586. static irqreturn_t
  587. avm_fritzv2_interrupt(int intno, void *dev_id)
  588. {
  589. struct fritzcard *fc = dev_id;
  590. u8 val;
  591. u8 sval;
  592. spin_lock(&fc->lock);
  593. sval = inb(fc->addr + 2);
  594. pr_debug("%s: irq stat0 %x\n", fc->name, sval);
  595. if (!(sval & AVM_STATUS0_IRQ_MASK)) {
  596. /* shared IRQ from other HW */
  597. spin_unlock(&fc->lock);
  598. return IRQ_NONE;
  599. }
  600. fc->irqcnt++;
  601. if (sval & AVM_STATUS0_IRQ_HDLC)
  602. HDLC_irq_main(fc);
  603. if (sval & AVM_STATUS0_IRQ_ISAC) {
  604. val = ReadISAC_V2(fc, ISACX_ISTA);
  605. mISDNisac_irq(&fc->isac, val);
  606. }
  607. if (sval & AVM_STATUS0_IRQ_TIMER) {
  608. pr_debug("%s: timer irq\n", fc->name);
  609. outb(fc->ctrlreg | AVM_STATUS0_RES_TIMER, fc->addr + 2);
  610. udelay(1);
  611. outb(fc->ctrlreg, fc->addr + 2);
  612. }
  613. spin_unlock(&fc->lock);
  614. return IRQ_HANDLED;
  615. }
  616. static int
  617. avm_l2l1B(struct mISDNchannel *ch, struct sk_buff *skb)
  618. {
  619. struct bchannel *bch = container_of(ch, struct bchannel, ch);
  620. struct fritzcard *fc = bch->hw;
  621. int ret = -EINVAL;
  622. struct mISDNhead *hh = mISDN_HEAD_P(skb);
  623. unsigned long flags;
  624. switch (hh->prim) {
  625. case PH_DATA_REQ:
  626. spin_lock_irqsave(&fc->lock, flags);
  627. ret = bchannel_senddata(bch, skb);
  628. if (ret > 0) { /* direct TX */
  629. hdlc_fill_fifo(bch);
  630. ret = 0;
  631. }
  632. spin_unlock_irqrestore(&fc->lock, flags);
  633. return ret;
  634. case PH_ACTIVATE_REQ:
  635. spin_lock_irqsave(&fc->lock, flags);
  636. if (!test_and_set_bit(FLG_ACTIVE, &bch->Flags))
  637. ret = modehdlc(bch, ch->protocol);
  638. else
  639. ret = 0;
  640. spin_unlock_irqrestore(&fc->lock, flags);
  641. if (!ret)
  642. _queue_data(ch, PH_ACTIVATE_IND, MISDN_ID_ANY, 0,
  643. NULL, GFP_KERNEL);
  644. break;
  645. case PH_DEACTIVATE_REQ:
  646. spin_lock_irqsave(&fc->lock, flags);
  647. mISDN_clear_bchannel(bch);
  648. modehdlc(bch, ISDN_P_NONE);
  649. spin_unlock_irqrestore(&fc->lock, flags);
  650. _queue_data(ch, PH_DEACTIVATE_IND, MISDN_ID_ANY, 0,
  651. NULL, GFP_KERNEL);
  652. ret = 0;
  653. break;
  654. }
  655. if (!ret)
  656. dev_kfree_skb(skb);
  657. return ret;
  658. }
  659. static void
  660. inithdlc(struct fritzcard *fc)
  661. {
  662. modehdlc(&fc->bch[0], -1);
  663. modehdlc(&fc->bch[1], -1);
  664. }
  665. static void
  666. clear_pending_hdlc_ints(struct fritzcard *fc)
  667. {
  668. u32 val;
  669. val = read_status(fc, 1);
  670. pr_debug("%s: HDLC 1 STA %x\n", fc->name, val);
  671. val = read_status(fc, 2);
  672. pr_debug("%s: HDLC 2 STA %x\n", fc->name, val);
  673. }
  674. static void
  675. reset_avm(struct fritzcard *fc)
  676. {
  677. switch (fc->type) {
  678. case AVM_FRITZ_PCI:
  679. fc->ctrlreg = AVM_STATUS0_RESET | AVM_STATUS0_DIS_TIMER;
  680. break;
  681. case AVM_FRITZ_PCIV2:
  682. fc->ctrlreg = AVM_STATUS0_RESET;
  683. break;
  684. }
  685. if (debug & DEBUG_HW)
  686. pr_notice("%s: reset\n", fc->name);
  687. disable_hwirq(fc);
  688. mdelay(5);
  689. switch (fc->type) {
  690. case AVM_FRITZ_PCI:
  691. fc->ctrlreg = AVM_STATUS0_DIS_TIMER | AVM_STATUS0_RES_TIMER;
  692. disable_hwirq(fc);
  693. outb(AVM_STATUS1_ENA_IOM, fc->addr + 3);
  694. break;
  695. case AVM_FRITZ_PCIV2:
  696. fc->ctrlreg = 0;
  697. disable_hwirq(fc);
  698. break;
  699. }
  700. mdelay(1);
  701. if (debug & DEBUG_HW)
  702. pr_notice("%s: S0/S1 %x/%x\n", fc->name,
  703. inb(fc->addr + 2), inb(fc->addr + 3));
  704. }
  705. static int
  706. init_card(struct fritzcard *fc)
  707. {
  708. int ret, cnt = 3;
  709. u_long flags;
  710. reset_avm(fc); /* disable IRQ */
  711. if (fc->type == AVM_FRITZ_PCIV2)
  712. ret = request_irq(fc->irq, avm_fritzv2_interrupt,
  713. IRQF_SHARED, fc->name, fc);
  714. else
  715. ret = request_irq(fc->irq, avm_fritz_interrupt,
  716. IRQF_SHARED, fc->name, fc);
  717. if (ret) {
  718. pr_info("%s: couldn't get interrupt %d\n",
  719. fc->name, fc->irq);
  720. return ret;
  721. }
  722. while (cnt--) {
  723. spin_lock_irqsave(&fc->lock, flags);
  724. ret = fc->isac.init(&fc->isac);
  725. if (ret) {
  726. spin_unlock_irqrestore(&fc->lock, flags);
  727. pr_info("%s: ISAC init failed with %d\n",
  728. fc->name, ret);
  729. break;
  730. }
  731. clear_pending_hdlc_ints(fc);
  732. inithdlc(fc);
  733. enable_hwirq(fc);
  734. /* RESET Receiver and Transmitter */
  735. if (fc->type == AVM_FRITZ_PCIV2) {
  736. WriteISAC_V2(fc, ISACX_MASK, 0);
  737. WriteISAC_V2(fc, ISACX_CMDRD, 0x41);
  738. } else {
  739. WriteISAC_V1(fc, ISAC_MASK, 0);
  740. WriteISAC_V1(fc, ISAC_CMDR, 0x41);
  741. }
  742. spin_unlock_irqrestore(&fc->lock, flags);
  743. /* Timeout 10ms */
  744. msleep_interruptible(10);
  745. if (debug & DEBUG_HW)
  746. pr_notice("%s: IRQ %d count %d\n", fc->name,
  747. fc->irq, fc->irqcnt);
  748. if (!fc->irqcnt) {
  749. pr_info("%s: IRQ(%d) getting no IRQs during init %d\n",
  750. fc->name, fc->irq, 3 - cnt);
  751. reset_avm(fc);
  752. } else
  753. return 0;
  754. }
  755. free_irq(fc->irq, fc);
  756. return -EIO;
  757. }
  758. static int
  759. channel_bctrl(struct bchannel *bch, struct mISDN_ctrl_req *cq)
  760. {
  761. return mISDN_ctrl_bchannel(bch, cq);
  762. }
  763. static int
  764. avm_bctrl(struct mISDNchannel *ch, u32 cmd, void *arg)
  765. {
  766. struct bchannel *bch = container_of(ch, struct bchannel, ch);
  767. struct fritzcard *fc = bch->hw;
  768. int ret = -EINVAL;
  769. u_long flags;
  770. pr_debug("%s: %s cmd:%x %p\n", fc->name, __func__, cmd, arg);
  771. switch (cmd) {
  772. case CLOSE_CHANNEL:
  773. test_and_clear_bit(FLG_OPEN, &bch->Flags);
  774. cancel_work_sync(&bch->workq);
  775. spin_lock_irqsave(&fc->lock, flags);
  776. mISDN_clear_bchannel(bch);
  777. modehdlc(bch, ISDN_P_NONE);
  778. spin_unlock_irqrestore(&fc->lock, flags);
  779. ch->protocol = ISDN_P_NONE;
  780. ch->peer = NULL;
  781. module_put(THIS_MODULE);
  782. ret = 0;
  783. break;
  784. case CONTROL_CHANNEL:
  785. ret = channel_bctrl(bch, arg);
  786. break;
  787. default:
  788. pr_info("%s: %s unknown prim(%x)\n", fc->name, __func__, cmd);
  789. }
  790. return ret;
  791. }
  792. static int
  793. channel_ctrl(struct fritzcard *fc, struct mISDN_ctrl_req *cq)
  794. {
  795. int ret = 0;
  796. switch (cq->op) {
  797. case MISDN_CTRL_GETOP:
  798. cq->op = MISDN_CTRL_LOOP | MISDN_CTRL_L1_TIMER3;
  799. break;
  800. case MISDN_CTRL_LOOP:
  801. /* cq->channel: 0 disable, 1 B1 loop 2 B2 loop, 3 both */
  802. if (cq->channel < 0 || cq->channel > 3) {
  803. ret = -EINVAL;
  804. break;
  805. }
  806. ret = fc->isac.ctrl(&fc->isac, HW_TESTLOOP, cq->channel);
  807. break;
  808. case MISDN_CTRL_L1_TIMER3:
  809. ret = fc->isac.ctrl(&fc->isac, HW_TIMER3_VALUE, cq->p1);
  810. break;
  811. default:
  812. pr_info("%s: %s unknown Op %x\n", fc->name, __func__, cq->op);
  813. ret = -EINVAL;
  814. break;
  815. }
  816. return ret;
  817. }
  818. static int
  819. open_bchannel(struct fritzcard *fc, struct channel_req *rq)
  820. {
  821. struct bchannel *bch;
  822. if (rq->adr.channel == 0 || rq->adr.channel > 2)
  823. return -EINVAL;
  824. if (rq->protocol == ISDN_P_NONE)
  825. return -EINVAL;
  826. bch = &fc->bch[rq->adr.channel - 1];
  827. if (test_and_set_bit(FLG_OPEN, &bch->Flags))
  828. return -EBUSY; /* b-channel can be only open once */
  829. bch->ch.protocol = rq->protocol;
  830. rq->ch = &bch->ch;
  831. return 0;
  832. }
  833. /*
  834. * device control function
  835. */
  836. static int
  837. avm_dctrl(struct mISDNchannel *ch, u32 cmd, void *arg)
  838. {
  839. struct mISDNdevice *dev = container_of(ch, struct mISDNdevice, D);
  840. struct dchannel *dch = container_of(dev, struct dchannel, dev);
  841. struct fritzcard *fc = dch->hw;
  842. struct channel_req *rq;
  843. int err = 0;
  844. pr_debug("%s: %s cmd:%x %p\n", fc->name, __func__, cmd, arg);
  845. switch (cmd) {
  846. case OPEN_CHANNEL:
  847. rq = arg;
  848. if (rq->protocol == ISDN_P_TE_S0)
  849. err = fc->isac.open(&fc->isac, rq);
  850. else
  851. err = open_bchannel(fc, rq);
  852. if (err)
  853. break;
  854. if (!try_module_get(THIS_MODULE))
  855. pr_info("%s: cannot get module\n", fc->name);
  856. break;
  857. case CLOSE_CHANNEL:
  858. pr_debug("%s: dev(%d) close from %p\n", fc->name, dch->dev.id,
  859. __builtin_return_address(0));
  860. module_put(THIS_MODULE);
  861. break;
  862. case CONTROL_CHANNEL:
  863. err = channel_ctrl(fc, arg);
  864. break;
  865. default:
  866. pr_debug("%s: %s unknown command %x\n",
  867. fc->name, __func__, cmd);
  868. return -EINVAL;
  869. }
  870. return err;
  871. }
  872. static int
  873. setup_fritz(struct fritzcard *fc)
  874. {
  875. u32 val, ver;
  876. if (!request_region(fc->addr, 32, fc->name)) {
  877. pr_info("%s: AVM config port %x-%x already in use\n",
  878. fc->name, fc->addr, fc->addr + 31);
  879. return -EIO;
  880. }
  881. switch (fc->type) {
  882. case AVM_FRITZ_PCI:
  883. val = inl(fc->addr);
  884. outl(AVM_HDLC_1, fc->addr + CHIP_INDEX);
  885. ver = inl(fc->addr + CHIP_WINDOW + HDLC_STATUS) >> 24;
  886. if (debug & DEBUG_HW) {
  887. pr_notice("%s: PCI stat %#x\n", fc->name, val);
  888. pr_notice("%s: PCI Class %X Rev %d\n", fc->name,
  889. val & 0xff, (val >> 8) & 0xff);
  890. pr_notice("%s: HDLC version %x\n", fc->name, ver & 0xf);
  891. }
  892. ASSIGN_FUNC(V1, ISAC, fc->isac);
  893. fc->isac.type = IPAC_TYPE_ISAC;
  894. break;
  895. case AVM_FRITZ_PCIV2:
  896. val = inl(fc->addr);
  897. ver = inl(fc->addr + AVM_HDLC_STATUS_1) >> 24;
  898. if (debug & DEBUG_HW) {
  899. pr_notice("%s: PCI V2 stat %#x\n", fc->name, val);
  900. pr_notice("%s: PCI V2 Class %X Rev %d\n", fc->name,
  901. val & 0xff, (val >> 8) & 0xff);
  902. pr_notice("%s: HDLC version %x\n", fc->name, ver & 0xf);
  903. }
  904. ASSIGN_FUNC(V2, ISAC, fc->isac);
  905. fc->isac.type = IPAC_TYPE_ISACX;
  906. break;
  907. default:
  908. release_region(fc->addr, 32);
  909. pr_info("%s: AVM unknown type %d\n", fc->name, fc->type);
  910. return -ENODEV;
  911. }
  912. pr_notice("%s: %s config irq:%d base:0x%X\n", fc->name,
  913. (fc->type == AVM_FRITZ_PCI) ? "AVM Fritz!CARD PCI" :
  914. "AVM Fritz!CARD PCIv2", fc->irq, fc->addr);
  915. return 0;
  916. }
  917. static void
  918. release_card(struct fritzcard *card)
  919. {
  920. u_long flags;
  921. disable_hwirq(card);
  922. spin_lock_irqsave(&card->lock, flags);
  923. modehdlc(&card->bch[0], ISDN_P_NONE);
  924. modehdlc(&card->bch[1], ISDN_P_NONE);
  925. spin_unlock_irqrestore(&card->lock, flags);
  926. card->isac.release(&card->isac);
  927. free_irq(card->irq, card);
  928. mISDN_freebchannel(&card->bch[1]);
  929. mISDN_freebchannel(&card->bch[0]);
  930. mISDN_unregister_device(&card->isac.dch.dev);
  931. release_region(card->addr, 32);
  932. pci_disable_device(card->pdev);
  933. pci_set_drvdata(card->pdev, NULL);
  934. write_lock_irqsave(&card_lock, flags);
  935. list_del(&card->list);
  936. write_unlock_irqrestore(&card_lock, flags);
  937. kfree(card);
  938. AVM_cnt--;
  939. }
  940. static int
  941. setup_instance(struct fritzcard *card)
  942. {
  943. int i, err;
  944. unsigned short minsize;
  945. u_long flags;
  946. snprintf(card->name, MISDN_MAX_IDLEN - 1, "AVM.%d", AVM_cnt + 1);
  947. write_lock_irqsave(&card_lock, flags);
  948. list_add_tail(&card->list, &Cards);
  949. write_unlock_irqrestore(&card_lock, flags);
  950. _set_debug(card);
  951. card->isac.name = card->name;
  952. spin_lock_init(&card->lock);
  953. card->isac.hwlock = &card->lock;
  954. mISDNisac_init(&card->isac, card);
  955. card->isac.dch.dev.Bprotocols = (1 << (ISDN_P_B_RAW & ISDN_P_B_MASK)) |
  956. (1 << (ISDN_P_B_HDLC & ISDN_P_B_MASK));
  957. card->isac.dch.dev.D.ctrl = avm_dctrl;
  958. for (i = 0; i < 2; i++) {
  959. card->bch[i].nr = i + 1;
  960. set_channelmap(i + 1, card->isac.dch.dev.channelmap);
  961. if (AVM_FRITZ_PCIV2 == card->type)
  962. minsize = HDLC_FIFO_SIZE_V2;
  963. else
  964. minsize = HDLC_FIFO_SIZE_V1;
  965. mISDN_initbchannel(&card->bch[i], MAX_DATA_MEM, minsize);
  966. card->bch[i].hw = card;
  967. card->bch[i].ch.send = avm_l2l1B;
  968. card->bch[i].ch.ctrl = avm_bctrl;
  969. card->bch[i].ch.nr = i + 1;
  970. list_add(&card->bch[i].ch.list, &card->isac.dch.dev.bchannels);
  971. }
  972. err = setup_fritz(card);
  973. if (err)
  974. goto error;
  975. err = mISDN_register_device(&card->isac.dch.dev, &card->pdev->dev,
  976. card->name);
  977. if (err)
  978. goto error_reg;
  979. err = init_card(card);
  980. if (!err) {
  981. AVM_cnt++;
  982. pr_notice("AVM %d cards installed DEBUG\n", AVM_cnt);
  983. return 0;
  984. }
  985. mISDN_unregister_device(&card->isac.dch.dev);
  986. error_reg:
  987. release_region(card->addr, 32);
  988. error:
  989. card->isac.release(&card->isac);
  990. mISDN_freebchannel(&card->bch[1]);
  991. mISDN_freebchannel(&card->bch[0]);
  992. write_lock_irqsave(&card_lock, flags);
  993. list_del(&card->list);
  994. write_unlock_irqrestore(&card_lock, flags);
  995. kfree(card);
  996. return err;
  997. }
  998. static int
  999. fritzpci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
  1000. {
  1001. int err = -ENOMEM;
  1002. struct fritzcard *card;
  1003. card = kzalloc(sizeof(struct fritzcard), GFP_KERNEL);
  1004. if (!card) {
  1005. pr_info("No kmem for fritzcard\n");
  1006. return err;
  1007. }
  1008. if (pdev->device == PCI_DEVICE_ID_AVM_A1_V2)
  1009. card->type = AVM_FRITZ_PCIV2;
  1010. else
  1011. card->type = AVM_FRITZ_PCI;
  1012. card->pdev = pdev;
  1013. err = pci_enable_device(pdev);
  1014. if (err) {
  1015. kfree(card);
  1016. return err;
  1017. }
  1018. pr_notice("mISDN: found adapter %s at %s\n",
  1019. (char *) ent->driver_data, pci_name(pdev));
  1020. card->addr = pci_resource_start(pdev, 1);
  1021. card->irq = pdev->irq;
  1022. pci_set_drvdata(pdev, card);
  1023. err = setup_instance(card);
  1024. if (err)
  1025. pci_set_drvdata(pdev, NULL);
  1026. return err;
  1027. }
  1028. static void
  1029. fritz_remove_pci(struct pci_dev *pdev)
  1030. {
  1031. struct fritzcard *card = pci_get_drvdata(pdev);
  1032. if (card)
  1033. release_card(card);
  1034. else
  1035. if (debug)
  1036. pr_info("%s: drvdata already removed\n", __func__);
  1037. }
  1038. static struct pci_device_id fcpci_ids[] = {
  1039. { PCI_VENDOR_ID_AVM, PCI_DEVICE_ID_AVM_A1, PCI_ANY_ID, PCI_ANY_ID,
  1040. 0, 0, (unsigned long) "Fritz!Card PCI"},
  1041. { PCI_VENDOR_ID_AVM, PCI_DEVICE_ID_AVM_A1_V2, PCI_ANY_ID, PCI_ANY_ID,
  1042. 0, 0, (unsigned long) "Fritz!Card PCI v2" },
  1043. { }
  1044. };
  1045. MODULE_DEVICE_TABLE(pci, fcpci_ids);
  1046. static struct pci_driver fcpci_driver = {
  1047. .name = "fcpci",
  1048. .probe = fritzpci_probe,
  1049. .remove = fritz_remove_pci,
  1050. .id_table = fcpci_ids,
  1051. };
  1052. static int __init AVM_init(void)
  1053. {
  1054. int err;
  1055. pr_notice("AVM Fritz PCI driver Rev. %s\n", AVMFRITZ_REV);
  1056. err = pci_register_driver(&fcpci_driver);
  1057. return err;
  1058. }
  1059. static void __exit AVM_cleanup(void)
  1060. {
  1061. pci_unregister_driver(&fcpci_driver);
  1062. }
  1063. module_init(AVM_init);
  1064. module_exit(AVM_cleanup);