avmfritz.c 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176
  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. 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. 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. 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);