w83977af_ir.c 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330
  1. /*********************************************************************
  2. *
  3. * Filename: w83977af_ir.c
  4. * Version: 1.0
  5. * Description: FIR driver for the Winbond W83977AF Super I/O chip
  6. * Status: Experimental.
  7. * Author: Paul VanderSpek
  8. * Created at: Wed Nov 4 11:46:16 1998
  9. * Modified at: Fri Jan 28 12:10:59 2000
  10. * Modified by: Dag Brattli <dagb@cs.uit.no>
  11. *
  12. * Copyright (c) 1998-2000 Dag Brattli <dagb@cs.uit.no>
  13. * Copyright (c) 1998-1999 Rebel.com
  14. *
  15. * This program is free software; you can redistribute it and/or
  16. * modify it under the terms of the GNU General Public License as
  17. * published by the Free Software Foundation; either version 2 of
  18. * the License, or (at your option) any later version.
  19. *
  20. * Neither Paul VanderSpek nor Rebel.com admit liability nor provide
  21. * warranty for any of this software. This material is provided "AS-IS"
  22. * and at no charge.
  23. *
  24. * If you find bugs in this file, its very likely that the same bug
  25. * will also be in pc87108.c since the implementations are quite
  26. * similar.
  27. *
  28. * Notice that all functions that needs to access the chip in _any_
  29. * way, must save BSR register on entry, and restore it on exit.
  30. * It is _very_ important to follow this policy!
  31. *
  32. * __u8 bank;
  33. *
  34. * bank = inb( iobase+BSR);
  35. *
  36. * do_your_stuff_here();
  37. *
  38. * outb( bank, iobase+BSR);
  39. *
  40. ********************************************************************/
  41. #include <linux/module.h>
  42. #include <linux/kernel.h>
  43. #include <linux/types.h>
  44. #include <linux/skbuff.h>
  45. #include <linux/netdevice.h>
  46. #include <linux/ioport.h>
  47. #include <linux/delay.h>
  48. #include <linux/init.h>
  49. #include <linux/rtnetlink.h>
  50. #include <linux/dma-mapping.h>
  51. #include <linux/gfp.h>
  52. #include <asm/io.h>
  53. #include <asm/dma.h>
  54. #include <asm/byteorder.h>
  55. #include <net/irda/irda.h>
  56. #include <net/irda/wrapper.h>
  57. #include <net/irda/irda_device.h>
  58. #include "w83977af.h"
  59. #include "w83977af_ir.h"
  60. #ifdef CONFIG_ARCH_NETWINDER /* Adjust to NetWinder differences */
  61. #undef CONFIG_NETWINDER_TX_DMA_PROBLEMS /* Not needed */
  62. #define CONFIG_NETWINDER_RX_DMA_PROBLEMS /* Must have this one! */
  63. #endif
  64. #define CONFIG_USE_W977_PNP /* Currently needed */
  65. #define PIO_MAX_SPEED 115200
  66. static char *driver_name = "w83977af_ir";
  67. static int qos_mtt_bits = 0x07; /* 1 ms or more */
  68. #define CHIP_IO_EXTENT 8
  69. static unsigned int io[] = { 0x180, ~0, ~0, ~0 };
  70. #ifdef CONFIG_ARCH_NETWINDER /* Adjust to NetWinder differences */
  71. static unsigned int irq[] = { 6, 0, 0, 0 };
  72. #else
  73. static unsigned int irq[] = { 11, 0, 0, 0 };
  74. #endif
  75. static unsigned int dma[] = { 1, 0, 0, 0 };
  76. static unsigned int efbase[] = { W977_EFIO_BASE, W977_EFIO2_BASE };
  77. static unsigned int efio = W977_EFIO_BASE;
  78. static struct w83977af_ir *dev_self[] = { NULL, NULL, NULL, NULL};
  79. /* Some prototypes */
  80. static int w83977af_open(int i, unsigned int iobase, unsigned int irq,
  81. unsigned int dma);
  82. static int w83977af_close(struct w83977af_ir *self);
  83. static int w83977af_probe(int iobase, int irq, int dma);
  84. static int w83977af_dma_receive(struct w83977af_ir *self);
  85. static int w83977af_dma_receive_complete(struct w83977af_ir *self);
  86. static netdev_tx_t w83977af_hard_xmit(struct sk_buff *skb,
  87. struct net_device *dev);
  88. static int w83977af_pio_write(int iobase, __u8 *buf, int len, int fifo_size);
  89. static void w83977af_dma_write(struct w83977af_ir *self, int iobase);
  90. static void w83977af_change_speed(struct w83977af_ir *self, __u32 speed);
  91. static int w83977af_is_receiving(struct w83977af_ir *self);
  92. static int w83977af_net_open(struct net_device *dev);
  93. static int w83977af_net_close(struct net_device *dev);
  94. static int w83977af_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
  95. /*
  96. * Function w83977af_init ()
  97. *
  98. * Initialize chip. Just try to find out how many chips we are dealing with
  99. * and where they are
  100. */
  101. static int __init w83977af_init(void)
  102. {
  103. int i;
  104. IRDA_DEBUG(0, "%s()\n", __func__ );
  105. for (i=0; i < ARRAY_SIZE(dev_self) && io[i] < 2000; i++) {
  106. if (w83977af_open(i, io[i], irq[i], dma[i]) == 0)
  107. return 0;
  108. }
  109. return -ENODEV;
  110. }
  111. /*
  112. * Function w83977af_cleanup ()
  113. *
  114. * Close all configured chips
  115. *
  116. */
  117. static void __exit w83977af_cleanup(void)
  118. {
  119. int i;
  120. IRDA_DEBUG(4, "%s()\n", __func__ );
  121. for (i=0; i < ARRAY_SIZE(dev_self); i++) {
  122. if (dev_self[i])
  123. w83977af_close(dev_self[i]);
  124. }
  125. }
  126. static const struct net_device_ops w83977_netdev_ops = {
  127. .ndo_open = w83977af_net_open,
  128. .ndo_stop = w83977af_net_close,
  129. .ndo_start_xmit = w83977af_hard_xmit,
  130. .ndo_do_ioctl = w83977af_net_ioctl,
  131. };
  132. /*
  133. * Function w83977af_open (iobase, irq)
  134. *
  135. * Open driver instance
  136. *
  137. */
  138. static int w83977af_open(int i, unsigned int iobase, unsigned int irq,
  139. unsigned int dma)
  140. {
  141. struct net_device *dev;
  142. struct w83977af_ir *self;
  143. int err;
  144. IRDA_DEBUG(0, "%s()\n", __func__ );
  145. /* Lock the port that we need */
  146. if (!request_region(iobase, CHIP_IO_EXTENT, driver_name)) {
  147. IRDA_DEBUG(0, "%s(), can't get iobase of 0x%03x\n",
  148. __func__ , iobase);
  149. return -ENODEV;
  150. }
  151. if (w83977af_probe(iobase, irq, dma) == -1) {
  152. err = -1;
  153. goto err_out;
  154. }
  155. /*
  156. * Allocate new instance of the driver
  157. */
  158. dev = alloc_irdadev(sizeof(struct w83977af_ir));
  159. if (dev == NULL) {
  160. printk( KERN_ERR "IrDA: Can't allocate memory for "
  161. "IrDA control block!\n");
  162. err = -ENOMEM;
  163. goto err_out;
  164. }
  165. self = netdev_priv(dev);
  166. spin_lock_init(&self->lock);
  167. /* Initialize IO */
  168. self->io.fir_base = iobase;
  169. self->io.irq = irq;
  170. self->io.fir_ext = CHIP_IO_EXTENT;
  171. self->io.dma = dma;
  172. self->io.fifo_size = 32;
  173. /* Initialize QoS for this device */
  174. irda_init_max_qos_capabilies(&self->qos);
  175. /* The only value we must override it the baudrate */
  176. /* FIXME: The HP HDLS-1100 does not support 1152000! */
  177. self->qos.baud_rate.bits = IR_9600|IR_19200|IR_38400|IR_57600|
  178. IR_115200|IR_576000|IR_1152000|(IR_4000000 << 8);
  179. /* The HP HDLS-1100 needs 1 ms according to the specs */
  180. self->qos.min_turn_time.bits = qos_mtt_bits;
  181. irda_qos_bits_to_value(&self->qos);
  182. /* Max DMA buffer size needed = (data_size + 6) * (window_size) + 6; */
  183. self->rx_buff.truesize = 14384;
  184. self->tx_buff.truesize = 4000;
  185. /* Allocate memory if needed */
  186. self->rx_buff.head =
  187. dma_alloc_coherent(NULL, self->rx_buff.truesize,
  188. &self->rx_buff_dma, GFP_KERNEL);
  189. if (self->rx_buff.head == NULL) {
  190. err = -ENOMEM;
  191. goto err_out1;
  192. }
  193. memset(self->rx_buff.head, 0, self->rx_buff.truesize);
  194. self->tx_buff.head =
  195. dma_alloc_coherent(NULL, self->tx_buff.truesize,
  196. &self->tx_buff_dma, GFP_KERNEL);
  197. if (self->tx_buff.head == NULL) {
  198. err = -ENOMEM;
  199. goto err_out2;
  200. }
  201. memset(self->tx_buff.head, 0, self->tx_buff.truesize);
  202. self->rx_buff.in_frame = FALSE;
  203. self->rx_buff.state = OUTSIDE_FRAME;
  204. self->tx_buff.data = self->tx_buff.head;
  205. self->rx_buff.data = self->rx_buff.head;
  206. self->netdev = dev;
  207. dev->netdev_ops = &w83977_netdev_ops;
  208. err = register_netdev(dev);
  209. if (err) {
  210. IRDA_ERROR("%s(), register_netdevice() failed!\n", __func__);
  211. goto err_out3;
  212. }
  213. IRDA_MESSAGE("IrDA: Registered device %s\n", dev->name);
  214. /* Need to store self somewhere */
  215. dev_self[i] = self;
  216. return 0;
  217. err_out3:
  218. dma_free_coherent(NULL, self->tx_buff.truesize,
  219. self->tx_buff.head, self->tx_buff_dma);
  220. err_out2:
  221. dma_free_coherent(NULL, self->rx_buff.truesize,
  222. self->rx_buff.head, self->rx_buff_dma);
  223. err_out1:
  224. free_netdev(dev);
  225. err_out:
  226. release_region(iobase, CHIP_IO_EXTENT);
  227. return err;
  228. }
  229. /*
  230. * Function w83977af_close (self)
  231. *
  232. * Close driver instance
  233. *
  234. */
  235. static int w83977af_close(struct w83977af_ir *self)
  236. {
  237. int iobase;
  238. IRDA_DEBUG(0, "%s()\n", __func__ );
  239. iobase = self->io.fir_base;
  240. #ifdef CONFIG_USE_W977_PNP
  241. /* enter PnP configuration mode */
  242. w977_efm_enter(efio);
  243. w977_select_device(W977_DEVICE_IR, efio);
  244. /* Deactivate device */
  245. w977_write_reg(0x30, 0x00, efio);
  246. w977_efm_exit(efio);
  247. #endif /* CONFIG_USE_W977_PNP */
  248. /* Remove netdevice */
  249. unregister_netdev(self->netdev);
  250. /* Release the PORT that this driver is using */
  251. IRDA_DEBUG(0 , "%s(), Releasing Region %03x\n",
  252. __func__ , self->io.fir_base);
  253. release_region(self->io.fir_base, self->io.fir_ext);
  254. if (self->tx_buff.head)
  255. dma_free_coherent(NULL, self->tx_buff.truesize,
  256. self->tx_buff.head, self->tx_buff_dma);
  257. if (self->rx_buff.head)
  258. dma_free_coherent(NULL, self->rx_buff.truesize,
  259. self->rx_buff.head, self->rx_buff_dma);
  260. free_netdev(self->netdev);
  261. return 0;
  262. }
  263. static int w83977af_probe(int iobase, int irq, int dma)
  264. {
  265. int version;
  266. int i;
  267. for (i=0; i < 2; i++) {
  268. IRDA_DEBUG( 0, "%s()\n", __func__ );
  269. #ifdef CONFIG_USE_W977_PNP
  270. /* Enter PnP configuration mode */
  271. w977_efm_enter(efbase[i]);
  272. w977_select_device(W977_DEVICE_IR, efbase[i]);
  273. /* Configure PnP port, IRQ, and DMA channel */
  274. w977_write_reg(0x60, (iobase >> 8) & 0xff, efbase[i]);
  275. w977_write_reg(0x61, (iobase) & 0xff, efbase[i]);
  276. w977_write_reg(0x70, irq, efbase[i]);
  277. #ifdef CONFIG_ARCH_NETWINDER
  278. /* Netwinder uses 1 higher than Linux */
  279. w977_write_reg(0x74, dma+1, efbase[i]);
  280. #else
  281. w977_write_reg(0x74, dma, efbase[i]);
  282. #endif /*CONFIG_ARCH_NETWINDER */
  283. w977_write_reg(0x75, 0x04, efbase[i]); /* Disable Tx DMA */
  284. /* Set append hardware CRC, enable IR bank selection */
  285. w977_write_reg(0xf0, APEDCRC|ENBNKSEL, efbase[i]);
  286. /* Activate device */
  287. w977_write_reg(0x30, 0x01, efbase[i]);
  288. w977_efm_exit(efbase[i]);
  289. #endif /* CONFIG_USE_W977_PNP */
  290. /* Disable Advanced mode */
  291. switch_bank(iobase, SET2);
  292. outb(iobase+2, 0x00);
  293. /* Turn on UART (global) interrupts */
  294. switch_bank(iobase, SET0);
  295. outb(HCR_EN_IRQ, iobase+HCR);
  296. /* Switch to advanced mode */
  297. switch_bank(iobase, SET2);
  298. outb(inb(iobase+ADCR1) | ADCR1_ADV_SL, iobase+ADCR1);
  299. /* Set default IR-mode */
  300. switch_bank(iobase, SET0);
  301. outb(HCR_SIR, iobase+HCR);
  302. /* Read the Advanced IR ID */
  303. switch_bank(iobase, SET3);
  304. version = inb(iobase+AUID);
  305. /* Should be 0x1? */
  306. if (0x10 == (version & 0xf0)) {
  307. efio = efbase[i];
  308. /* Set FIFO size to 32 */
  309. switch_bank(iobase, SET2);
  310. outb(ADCR2_RXFS32|ADCR2_TXFS32, iobase+ADCR2);
  311. /* Set FIFO threshold to TX17, RX16 */
  312. switch_bank(iobase, SET0);
  313. outb(UFR_RXTL|UFR_TXTL|UFR_TXF_RST|UFR_RXF_RST|
  314. UFR_EN_FIFO,iobase+UFR);
  315. /* Receiver frame length */
  316. switch_bank(iobase, SET4);
  317. outb(2048 & 0xff, iobase+6);
  318. outb((2048 >> 8) & 0x1f, iobase+7);
  319. /*
  320. * Init HP HSDL-1100 transceiver.
  321. *
  322. * Set IRX_MSL since we have 2 * receive paths IRRX,
  323. * and IRRXH. Clear IRSL0D since we want IRSL0 * to
  324. * be a input pin used for IRRXH
  325. *
  326. * IRRX pin 37 connected to receiver
  327. * IRTX pin 38 connected to transmitter
  328. * FIRRX pin 39 connected to receiver (IRSL0)
  329. * CIRRX pin 40 connected to pin 37
  330. */
  331. switch_bank(iobase, SET7);
  332. outb(0x40, iobase+7);
  333. IRDA_MESSAGE("W83977AF (IR) driver loaded. "
  334. "Version: 0x%02x\n", version);
  335. return 0;
  336. } else {
  337. /* Try next extented function register address */
  338. IRDA_DEBUG( 0, "%s(), Wrong chip version", __func__ );
  339. }
  340. }
  341. return -1;
  342. }
  343. static void w83977af_change_speed(struct w83977af_ir *self, __u32 speed)
  344. {
  345. int ir_mode = HCR_SIR;
  346. int iobase;
  347. __u8 set;
  348. iobase = self->io.fir_base;
  349. /* Update accounting for new speed */
  350. self->io.speed = speed;
  351. /* Save current bank */
  352. set = inb(iobase+SSR);
  353. /* Disable interrupts */
  354. switch_bank(iobase, SET0);
  355. outb(0, iobase+ICR);
  356. /* Select Set 2 */
  357. switch_bank(iobase, SET2);
  358. outb(0x00, iobase+ABHL);
  359. switch (speed) {
  360. case 9600: outb(0x0c, iobase+ABLL); break;
  361. case 19200: outb(0x06, iobase+ABLL); break;
  362. case 38400: outb(0x03, iobase+ABLL); break;
  363. case 57600: outb(0x02, iobase+ABLL); break;
  364. case 115200: outb(0x01, iobase+ABLL); break;
  365. case 576000:
  366. ir_mode = HCR_MIR_576;
  367. IRDA_DEBUG(0, "%s(), handling baud of 576000\n", __func__ );
  368. break;
  369. case 1152000:
  370. ir_mode = HCR_MIR_1152;
  371. IRDA_DEBUG(0, "%s(), handling baud of 1152000\n", __func__ );
  372. break;
  373. case 4000000:
  374. ir_mode = HCR_FIR;
  375. IRDA_DEBUG(0, "%s(), handling baud of 4000000\n", __func__ );
  376. break;
  377. default:
  378. ir_mode = HCR_FIR;
  379. IRDA_DEBUG(0, "%s(), unknown baud rate of %d\n", __func__ , speed);
  380. break;
  381. }
  382. /* Set speed mode */
  383. switch_bank(iobase, SET0);
  384. outb(ir_mode, iobase+HCR);
  385. /* set FIFO size to 32 */
  386. switch_bank(iobase, SET2);
  387. outb(ADCR2_RXFS32|ADCR2_TXFS32, iobase+ADCR2);
  388. /* set FIFO threshold to TX17, RX16 */
  389. switch_bank(iobase, SET0);
  390. outb(0x00, iobase+UFR); /* Reset */
  391. outb(UFR_EN_FIFO, iobase+UFR); /* First we must enable FIFO */
  392. outb(0xa7, iobase+UFR);
  393. netif_wake_queue(self->netdev);
  394. /* Enable some interrupts so we can receive frames */
  395. switch_bank(iobase, SET0);
  396. if (speed > PIO_MAX_SPEED) {
  397. outb(ICR_EFSFI, iobase+ICR);
  398. w83977af_dma_receive(self);
  399. } else
  400. outb(ICR_ERBRI, iobase+ICR);
  401. /* Restore SSR */
  402. outb(set, iobase+SSR);
  403. }
  404. /*
  405. * Function w83977af_hard_xmit (skb, dev)
  406. *
  407. * Sets up a DMA transfer to send the current frame.
  408. *
  409. */
  410. static netdev_tx_t w83977af_hard_xmit(struct sk_buff *skb,
  411. struct net_device *dev)
  412. {
  413. struct w83977af_ir *self;
  414. __s32 speed;
  415. int iobase;
  416. __u8 set;
  417. int mtt;
  418. self = netdev_priv(dev);
  419. iobase = self->io.fir_base;
  420. IRDA_DEBUG(4, "%s(%ld), skb->len=%d\n", __func__ , jiffies,
  421. (int) skb->len);
  422. /* Lock transmit buffer */
  423. netif_stop_queue(dev);
  424. /* Check if we need to change the speed */
  425. speed = irda_get_next_speed(skb);
  426. if ((speed != self->io.speed) && (speed != -1)) {
  427. /* Check for empty frame */
  428. if (!skb->len) {
  429. w83977af_change_speed(self, speed);
  430. dev_kfree_skb(skb);
  431. return NETDEV_TX_OK;
  432. } else
  433. self->new_speed = speed;
  434. }
  435. /* Save current set */
  436. set = inb(iobase+SSR);
  437. /* Decide if we should use PIO or DMA transfer */
  438. if (self->io.speed > PIO_MAX_SPEED) {
  439. self->tx_buff.data = self->tx_buff.head;
  440. skb_copy_from_linear_data(skb, self->tx_buff.data, skb->len);
  441. self->tx_buff.len = skb->len;
  442. mtt = irda_get_mtt(skb);
  443. IRDA_DEBUG(4, "%s(%ld), mtt=%d\n", __func__ , jiffies, mtt);
  444. if (mtt)
  445. udelay(mtt);
  446. /* Enable DMA interrupt */
  447. switch_bank(iobase, SET0);
  448. outb(ICR_EDMAI, iobase+ICR);
  449. w83977af_dma_write(self, iobase);
  450. } else {
  451. self->tx_buff.data = self->tx_buff.head;
  452. self->tx_buff.len = async_wrap_skb(skb, self->tx_buff.data,
  453. self->tx_buff.truesize);
  454. /* Add interrupt on tx low level (will fire immediately) */
  455. switch_bank(iobase, SET0);
  456. outb(ICR_ETXTHI, iobase+ICR);
  457. }
  458. dev_kfree_skb(skb);
  459. /* Restore set register */
  460. outb(set, iobase+SSR);
  461. return NETDEV_TX_OK;
  462. }
  463. /*
  464. * Function w83977af_dma_write (self, iobase)
  465. *
  466. * Send frame using DMA
  467. *
  468. */
  469. static void w83977af_dma_write(struct w83977af_ir *self, int iobase)
  470. {
  471. __u8 set;
  472. #ifdef CONFIG_NETWINDER_TX_DMA_PROBLEMS
  473. unsigned long flags;
  474. __u8 hcr;
  475. #endif
  476. IRDA_DEBUG(4, "%s(), len=%d\n", __func__ , self->tx_buff.len);
  477. /* Save current set */
  478. set = inb(iobase+SSR);
  479. /* Disable DMA */
  480. switch_bank(iobase, SET0);
  481. outb(inb(iobase+HCR) & ~HCR_EN_DMA, iobase+HCR);
  482. /* Choose transmit DMA channel */
  483. switch_bank(iobase, SET2);
  484. outb(ADCR1_D_CHSW|/*ADCR1_DMA_F|*/ADCR1_ADV_SL, iobase+ADCR1);
  485. #ifdef CONFIG_NETWINDER_TX_DMA_PROBLEMS
  486. spin_lock_irqsave(&self->lock, flags);
  487. disable_dma(self->io.dma);
  488. clear_dma_ff(self->io.dma);
  489. set_dma_mode(self->io.dma, DMA_MODE_READ);
  490. set_dma_addr(self->io.dma, self->tx_buff_dma);
  491. set_dma_count(self->io.dma, self->tx_buff.len);
  492. #else
  493. irda_setup_dma(self->io.dma, self->tx_buff_dma, self->tx_buff.len,
  494. DMA_MODE_WRITE);
  495. #endif
  496. self->io.direction = IO_XMIT;
  497. /* Enable DMA */
  498. switch_bank(iobase, SET0);
  499. #ifdef CONFIG_NETWINDER_TX_DMA_PROBLEMS
  500. hcr = inb(iobase+HCR);
  501. outb(hcr | HCR_EN_DMA, iobase+HCR);
  502. enable_dma(self->io.dma);
  503. spin_unlock_irqrestore(&self->lock, flags);
  504. #else
  505. outb(inb(iobase+HCR) | HCR_EN_DMA | HCR_TX_WT, iobase+HCR);
  506. #endif
  507. /* Restore set register */
  508. outb(set, iobase+SSR);
  509. }
  510. /*
  511. * Function w83977af_pio_write (iobase, buf, len, fifo_size)
  512. *
  513. *
  514. *
  515. */
  516. static int w83977af_pio_write(int iobase, __u8 *buf, int len, int fifo_size)
  517. {
  518. int actual = 0;
  519. __u8 set;
  520. IRDA_DEBUG(4, "%s()\n", __func__ );
  521. /* Save current bank */
  522. set = inb(iobase+SSR);
  523. switch_bank(iobase, SET0);
  524. if (!(inb_p(iobase+USR) & USR_TSRE)) {
  525. IRDA_DEBUG(4,
  526. "%s(), warning, FIFO not empty yet!\n", __func__ );
  527. fifo_size -= 17;
  528. IRDA_DEBUG(4, "%s(), %d bytes left in tx fifo\n",
  529. __func__ , fifo_size);
  530. }
  531. /* Fill FIFO with current frame */
  532. while ((fifo_size-- > 0) && (actual < len)) {
  533. /* Transmit next byte */
  534. outb(buf[actual++], iobase+TBR);
  535. }
  536. IRDA_DEBUG(4, "%s(), fifo_size %d ; %d sent of %d\n",
  537. __func__ , fifo_size, actual, len);
  538. /* Restore bank */
  539. outb(set, iobase+SSR);
  540. return actual;
  541. }
  542. /*
  543. * Function w83977af_dma_xmit_complete (self)
  544. *
  545. * The transfer of a frame in finished. So do the necessary things
  546. *
  547. *
  548. */
  549. static void w83977af_dma_xmit_complete(struct w83977af_ir *self)
  550. {
  551. int iobase;
  552. __u8 set;
  553. IRDA_DEBUG(4, "%s(%ld)\n", __func__ , jiffies);
  554. IRDA_ASSERT(self != NULL, return;);
  555. iobase = self->io.fir_base;
  556. /* Save current set */
  557. set = inb(iobase+SSR);
  558. /* Disable DMA */
  559. switch_bank(iobase, SET0);
  560. outb(inb(iobase+HCR) & ~HCR_EN_DMA, iobase+HCR);
  561. /* Check for underrrun! */
  562. if (inb(iobase+AUDR) & AUDR_UNDR) {
  563. IRDA_DEBUG(0, "%s(), Transmit underrun!\n", __func__ );
  564. self->netdev->stats.tx_errors++;
  565. self->netdev->stats.tx_fifo_errors++;
  566. /* Clear bit, by writing 1 to it */
  567. outb(AUDR_UNDR, iobase+AUDR);
  568. } else
  569. self->netdev->stats.tx_packets++;
  570. if (self->new_speed) {
  571. w83977af_change_speed(self, self->new_speed);
  572. self->new_speed = 0;
  573. }
  574. /* Unlock tx_buff and request another frame */
  575. /* Tell the network layer, that we want more frames */
  576. netif_wake_queue(self->netdev);
  577. /* Restore set */
  578. outb(set, iobase+SSR);
  579. }
  580. /*
  581. * Function w83977af_dma_receive (self)
  582. *
  583. * Get ready for receiving a frame. The device will initiate a DMA
  584. * if it starts to receive a frame.
  585. *
  586. */
  587. static int w83977af_dma_receive(struct w83977af_ir *self)
  588. {
  589. int iobase;
  590. __u8 set;
  591. #ifdef CONFIG_NETWINDER_RX_DMA_PROBLEMS
  592. unsigned long flags;
  593. __u8 hcr;
  594. #endif
  595. IRDA_ASSERT(self != NULL, return -1;);
  596. IRDA_DEBUG(4, "%s\n", __func__ );
  597. iobase= self->io.fir_base;
  598. /* Save current set */
  599. set = inb(iobase+SSR);
  600. /* Disable DMA */
  601. switch_bank(iobase, SET0);
  602. outb(inb(iobase+HCR) & ~HCR_EN_DMA, iobase+HCR);
  603. /* Choose DMA Rx, DMA Fairness, and Advanced mode */
  604. switch_bank(iobase, SET2);
  605. outb((inb(iobase+ADCR1) & ~ADCR1_D_CHSW)/*|ADCR1_DMA_F*/|ADCR1_ADV_SL,
  606. iobase+ADCR1);
  607. self->io.direction = IO_RECV;
  608. self->rx_buff.data = self->rx_buff.head;
  609. #ifdef CONFIG_NETWINDER_RX_DMA_PROBLEMS
  610. spin_lock_irqsave(&self->lock, flags);
  611. disable_dma(self->io.dma);
  612. clear_dma_ff(self->io.dma);
  613. set_dma_mode(self->io.dma, DMA_MODE_READ);
  614. set_dma_addr(self->io.dma, self->rx_buff_dma);
  615. set_dma_count(self->io.dma, self->rx_buff.truesize);
  616. #else
  617. irda_setup_dma(self->io.dma, self->rx_buff_dma, self->rx_buff.truesize,
  618. DMA_MODE_READ);
  619. #endif
  620. /*
  621. * Reset Rx FIFO. This will also flush the ST_FIFO, it's very
  622. * important that we don't reset the Tx FIFO since it might not
  623. * be finished transmitting yet
  624. */
  625. switch_bank(iobase, SET0);
  626. outb(UFR_RXTL|UFR_TXTL|UFR_RXF_RST|UFR_EN_FIFO, iobase+UFR);
  627. self->st_fifo.len = self->st_fifo.tail = self->st_fifo.head = 0;
  628. /* Enable DMA */
  629. switch_bank(iobase, SET0);
  630. #ifdef CONFIG_NETWINDER_RX_DMA_PROBLEMS
  631. hcr = inb(iobase+HCR);
  632. outb(hcr | HCR_EN_DMA, iobase+HCR);
  633. enable_dma(self->io.dma);
  634. spin_unlock_irqrestore(&self->lock, flags);
  635. #else
  636. outb(inb(iobase+HCR) | HCR_EN_DMA, iobase+HCR);
  637. #endif
  638. /* Restore set */
  639. outb(set, iobase+SSR);
  640. return 0;
  641. }
  642. /*
  643. * Function w83977af_receive_complete (self)
  644. *
  645. * Finished with receiving a frame
  646. *
  647. */
  648. static int w83977af_dma_receive_complete(struct w83977af_ir *self)
  649. {
  650. struct sk_buff *skb;
  651. struct st_fifo *st_fifo;
  652. int len;
  653. int iobase;
  654. __u8 set;
  655. __u8 status;
  656. IRDA_DEBUG(4, "%s\n", __func__ );
  657. st_fifo = &self->st_fifo;
  658. iobase = self->io.fir_base;
  659. /* Save current set */
  660. set = inb(iobase+SSR);
  661. iobase = self->io.fir_base;
  662. /* Read status FIFO */
  663. switch_bank(iobase, SET5);
  664. while ((status = inb(iobase+FS_FO)) & FS_FO_FSFDR) {
  665. st_fifo->entries[st_fifo->tail].status = status;
  666. st_fifo->entries[st_fifo->tail].len = inb(iobase+RFLFL);
  667. st_fifo->entries[st_fifo->tail].len |= inb(iobase+RFLFH) << 8;
  668. st_fifo->tail++;
  669. st_fifo->len++;
  670. }
  671. while (st_fifo->len) {
  672. /* Get first entry */
  673. status = st_fifo->entries[st_fifo->head].status;
  674. len = st_fifo->entries[st_fifo->head].len;
  675. st_fifo->head++;
  676. st_fifo->len--;
  677. /* Check for errors */
  678. if (status & FS_FO_ERR_MSK) {
  679. if (status & FS_FO_LST_FR) {
  680. /* Add number of lost frames to stats */
  681. self->netdev->stats.rx_errors += len;
  682. } else {
  683. /* Skip frame */
  684. self->netdev->stats.rx_errors++;
  685. self->rx_buff.data += len;
  686. if (status & FS_FO_MX_LEX)
  687. self->netdev->stats.rx_length_errors++;
  688. if (status & FS_FO_PHY_ERR)
  689. self->netdev->stats.rx_frame_errors++;
  690. if (status & FS_FO_CRC_ERR)
  691. self->netdev->stats.rx_crc_errors++;
  692. }
  693. /* The errors below can be reported in both cases */
  694. if (status & FS_FO_RX_OV)
  695. self->netdev->stats.rx_fifo_errors++;
  696. if (status & FS_FO_FSF_OV)
  697. self->netdev->stats.rx_fifo_errors++;
  698. } else {
  699. /* Check if we have transferred all data to memory */
  700. switch_bank(iobase, SET0);
  701. if (inb(iobase+USR) & USR_RDR) {
  702. udelay(80); /* Should be enough!? */
  703. }
  704. skb = dev_alloc_skb(len+1);
  705. if (skb == NULL) {
  706. printk(KERN_INFO
  707. "%s(), memory squeeze, dropping frame.\n", __func__);
  708. /* Restore set register */
  709. outb(set, iobase+SSR);
  710. return FALSE;
  711. }
  712. /* Align to 20 bytes */
  713. skb_reserve(skb, 1);
  714. /* Copy frame without CRC */
  715. if (self->io.speed < 4000000) {
  716. skb_put(skb, len-2);
  717. skb_copy_to_linear_data(skb,
  718. self->rx_buff.data,
  719. len - 2);
  720. } else {
  721. skb_put(skb, len-4);
  722. skb_copy_to_linear_data(skb,
  723. self->rx_buff.data,
  724. len - 4);
  725. }
  726. /* Move to next frame */
  727. self->rx_buff.data += len;
  728. self->netdev->stats.rx_packets++;
  729. skb->dev = self->netdev;
  730. skb_reset_mac_header(skb);
  731. skb->protocol = htons(ETH_P_IRDA);
  732. netif_rx(skb);
  733. }
  734. }
  735. /* Restore set register */
  736. outb(set, iobase+SSR);
  737. return TRUE;
  738. }
  739. /*
  740. * Function pc87108_pio_receive (self)
  741. *
  742. * Receive all data in receiver FIFO
  743. *
  744. */
  745. static void w83977af_pio_receive(struct w83977af_ir *self)
  746. {
  747. __u8 byte = 0x00;
  748. int iobase;
  749. IRDA_DEBUG(4, "%s()\n", __func__ );
  750. IRDA_ASSERT(self != NULL, return;);
  751. iobase = self->io.fir_base;
  752. /* Receive all characters in Rx FIFO */
  753. do {
  754. byte = inb(iobase+RBR);
  755. async_unwrap_char(self->netdev, &self->netdev->stats, &self->rx_buff,
  756. byte);
  757. } while (inb(iobase+USR) & USR_RDR); /* Data available */
  758. }
  759. /*
  760. * Function w83977af_sir_interrupt (self, eir)
  761. *
  762. * Handle SIR interrupt
  763. *
  764. */
  765. static __u8 w83977af_sir_interrupt(struct w83977af_ir *self, int isr)
  766. {
  767. int actual;
  768. __u8 new_icr = 0;
  769. __u8 set;
  770. int iobase;
  771. IRDA_DEBUG(4, "%s(), isr=%#x\n", __func__ , isr);
  772. iobase = self->io.fir_base;
  773. /* Transmit FIFO low on data */
  774. if (isr & ISR_TXTH_I) {
  775. /* Write data left in transmit buffer */
  776. actual = w83977af_pio_write(self->io.fir_base,
  777. self->tx_buff.data,
  778. self->tx_buff.len,
  779. self->io.fifo_size);
  780. self->tx_buff.data += actual;
  781. self->tx_buff.len -= actual;
  782. self->io.direction = IO_XMIT;
  783. /* Check if finished */
  784. if (self->tx_buff.len > 0) {
  785. new_icr |= ICR_ETXTHI;
  786. } else {
  787. set = inb(iobase+SSR);
  788. switch_bank(iobase, SET0);
  789. outb(AUDR_SFEND, iobase+AUDR);
  790. outb(set, iobase+SSR);
  791. self->netdev->stats.tx_packets++;
  792. /* Feed me more packets */
  793. netif_wake_queue(self->netdev);
  794. new_icr |= ICR_ETBREI;
  795. }
  796. }
  797. /* Check if transmission has completed */
  798. if (isr & ISR_TXEMP_I) {
  799. /* Check if we need to change the speed? */
  800. if (self->new_speed) {
  801. IRDA_DEBUG(2,
  802. "%s(), Changing speed!\n", __func__ );
  803. w83977af_change_speed(self, self->new_speed);
  804. self->new_speed = 0;
  805. }
  806. /* Turn around and get ready to receive some data */
  807. self->io.direction = IO_RECV;
  808. new_icr |= ICR_ERBRI;
  809. }
  810. /* Rx FIFO threshold or timeout */
  811. if (isr & ISR_RXTH_I) {
  812. w83977af_pio_receive(self);
  813. /* Keep receiving */
  814. new_icr |= ICR_ERBRI;
  815. }
  816. return new_icr;
  817. }
  818. /*
  819. * Function pc87108_fir_interrupt (self, eir)
  820. *
  821. * Handle MIR/FIR interrupt
  822. *
  823. */
  824. static __u8 w83977af_fir_interrupt(struct w83977af_ir *self, int isr)
  825. {
  826. __u8 new_icr = 0;
  827. __u8 set;
  828. int iobase;
  829. iobase = self->io.fir_base;
  830. set = inb(iobase+SSR);
  831. /* End of frame detected in FIFO */
  832. if (isr & (ISR_FEND_I|ISR_FSF_I)) {
  833. if (w83977af_dma_receive_complete(self)) {
  834. /* Wait for next status FIFO interrupt */
  835. new_icr |= ICR_EFSFI;
  836. } else {
  837. /* DMA not finished yet */
  838. /* Set timer value, resolution 1 ms */
  839. switch_bank(iobase, SET4);
  840. outb(0x01, iobase+TMRL); /* 1 ms */
  841. outb(0x00, iobase+TMRH);
  842. /* Start timer */
  843. outb(IR_MSL_EN_TMR, iobase+IR_MSL);
  844. new_icr |= ICR_ETMRI;
  845. }
  846. }
  847. /* Timer finished */
  848. if (isr & ISR_TMR_I) {
  849. /* Disable timer */
  850. switch_bank(iobase, SET4);
  851. outb(0, iobase+IR_MSL);
  852. /* Clear timer event */
  853. /* switch_bank(iobase, SET0); */
  854. /* outb(ASCR_CTE, iobase+ASCR); */
  855. /* Check if this is a TX timer interrupt */
  856. if (self->io.direction == IO_XMIT) {
  857. w83977af_dma_write(self, iobase);
  858. new_icr |= ICR_EDMAI;
  859. } else {
  860. /* Check if DMA has now finished */
  861. w83977af_dma_receive_complete(self);
  862. new_icr |= ICR_EFSFI;
  863. }
  864. }
  865. /* Finished with DMA */
  866. if (isr & ISR_DMA_I) {
  867. w83977af_dma_xmit_complete(self);
  868. /* Check if there are more frames to be transmitted */
  869. /* if (irda_device_txqueue_empty(self)) { */
  870. /* Prepare for receive
  871. *
  872. * ** Netwinder Tx DMA likes that we do this anyway **
  873. */
  874. w83977af_dma_receive(self);
  875. new_icr = ICR_EFSFI;
  876. /* } */
  877. }
  878. /* Restore set */
  879. outb(set, iobase+SSR);
  880. return new_icr;
  881. }
  882. /*
  883. * Function w83977af_interrupt (irq, dev_id, regs)
  884. *
  885. * An interrupt from the chip has arrived. Time to do some work
  886. *
  887. */
  888. static irqreturn_t w83977af_interrupt(int irq, void *dev_id)
  889. {
  890. struct net_device *dev = dev_id;
  891. struct w83977af_ir *self;
  892. __u8 set, icr, isr;
  893. int iobase;
  894. self = netdev_priv(dev);
  895. iobase = self->io.fir_base;
  896. /* Save current bank */
  897. set = inb(iobase+SSR);
  898. switch_bank(iobase, SET0);
  899. icr = inb(iobase+ICR);
  900. isr = inb(iobase+ISR) & icr; /* Mask out the interesting ones */
  901. outb(0, iobase+ICR); /* Disable interrupts */
  902. if (isr) {
  903. /* Dispatch interrupt handler for the current speed */
  904. if (self->io.speed > PIO_MAX_SPEED )
  905. icr = w83977af_fir_interrupt(self, isr);
  906. else
  907. icr = w83977af_sir_interrupt(self, isr);
  908. }
  909. outb(icr, iobase+ICR); /* Restore (new) interrupts */
  910. outb(set, iobase+SSR); /* Restore bank register */
  911. return IRQ_RETVAL(isr);
  912. }
  913. /*
  914. * Function w83977af_is_receiving (self)
  915. *
  916. * Return TRUE is we are currently receiving a frame
  917. *
  918. */
  919. static int w83977af_is_receiving(struct w83977af_ir *self)
  920. {
  921. int status = FALSE;
  922. int iobase;
  923. __u8 set;
  924. IRDA_ASSERT(self != NULL, return FALSE;);
  925. if (self->io.speed > 115200) {
  926. iobase = self->io.fir_base;
  927. /* Check if rx FIFO is not empty */
  928. set = inb(iobase+SSR);
  929. switch_bank(iobase, SET2);
  930. if ((inb(iobase+RXFDTH) & 0x3f) != 0) {
  931. /* We are receiving something */
  932. status = TRUE;
  933. }
  934. outb(set, iobase+SSR);
  935. } else
  936. status = (self->rx_buff.state != OUTSIDE_FRAME);
  937. return status;
  938. }
  939. /*
  940. * Function w83977af_net_open (dev)
  941. *
  942. * Start the device
  943. *
  944. */
  945. static int w83977af_net_open(struct net_device *dev)
  946. {
  947. struct w83977af_ir *self;
  948. int iobase;
  949. char hwname[32];
  950. __u8 set;
  951. IRDA_DEBUG(0, "%s()\n", __func__ );
  952. IRDA_ASSERT(dev != NULL, return -1;);
  953. self = netdev_priv(dev);
  954. IRDA_ASSERT(self != NULL, return 0;);
  955. iobase = self->io.fir_base;
  956. if (request_irq(self->io.irq, w83977af_interrupt, 0, dev->name,
  957. (void *) dev)) {
  958. return -EAGAIN;
  959. }
  960. /*
  961. * Always allocate the DMA channel after the IRQ,
  962. * and clean up on failure.
  963. */
  964. if (request_dma(self->io.dma, dev->name)) {
  965. free_irq(self->io.irq, self);
  966. return -EAGAIN;
  967. }
  968. /* Save current set */
  969. set = inb(iobase+SSR);
  970. /* Enable some interrupts so we can receive frames again */
  971. switch_bank(iobase, SET0);
  972. if (self->io.speed > 115200) {
  973. outb(ICR_EFSFI, iobase+ICR);
  974. w83977af_dma_receive(self);
  975. } else
  976. outb(ICR_ERBRI, iobase+ICR);
  977. /* Restore bank register */
  978. outb(set, iobase+SSR);
  979. /* Ready to play! */
  980. netif_start_queue(dev);
  981. /* Give self a hardware name */
  982. sprintf(hwname, "w83977af @ 0x%03x", self->io.fir_base);
  983. /*
  984. * Open new IrLAP layer instance, now that everything should be
  985. * initialized properly
  986. */
  987. self->irlap = irlap_open(dev, &self->qos, hwname);
  988. return 0;
  989. }
  990. /*
  991. * Function w83977af_net_close (dev)
  992. *
  993. * Stop the device
  994. *
  995. */
  996. static int w83977af_net_close(struct net_device *dev)
  997. {
  998. struct w83977af_ir *self;
  999. int iobase;
  1000. __u8 set;
  1001. IRDA_DEBUG(0, "%s()\n", __func__ );
  1002. IRDA_ASSERT(dev != NULL, return -1;);
  1003. self = netdev_priv(dev);
  1004. IRDA_ASSERT(self != NULL, return 0;);
  1005. iobase = self->io.fir_base;
  1006. /* Stop device */
  1007. netif_stop_queue(dev);
  1008. /* Stop and remove instance of IrLAP */
  1009. if (self->irlap)
  1010. irlap_close(self->irlap);
  1011. self->irlap = NULL;
  1012. disable_dma(self->io.dma);
  1013. /* Save current set */
  1014. set = inb(iobase+SSR);
  1015. /* Disable interrupts */
  1016. switch_bank(iobase, SET0);
  1017. outb(0, iobase+ICR);
  1018. free_irq(self->io.irq, dev);
  1019. free_dma(self->io.dma);
  1020. /* Restore bank register */
  1021. outb(set, iobase+SSR);
  1022. return 0;
  1023. }
  1024. /*
  1025. * Function w83977af_net_ioctl (dev, rq, cmd)
  1026. *
  1027. * Process IOCTL commands for this device
  1028. *
  1029. */
  1030. static int w83977af_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
  1031. {
  1032. struct if_irda_req *irq = (struct if_irda_req *) rq;
  1033. struct w83977af_ir *self;
  1034. unsigned long flags;
  1035. int ret = 0;
  1036. IRDA_ASSERT(dev != NULL, return -1;);
  1037. self = netdev_priv(dev);
  1038. IRDA_ASSERT(self != NULL, return -1;);
  1039. IRDA_DEBUG(2, "%s(), %s, (cmd=0x%X)\n", __func__ , dev->name, cmd);
  1040. spin_lock_irqsave(&self->lock, flags);
  1041. switch (cmd) {
  1042. case SIOCSBANDWIDTH: /* Set bandwidth */
  1043. if (!capable(CAP_NET_ADMIN)) {
  1044. ret = -EPERM;
  1045. goto out;
  1046. }
  1047. w83977af_change_speed(self, irq->ifr_baudrate);
  1048. break;
  1049. case SIOCSMEDIABUSY: /* Set media busy */
  1050. if (!capable(CAP_NET_ADMIN)) {
  1051. ret = -EPERM;
  1052. goto out;
  1053. }
  1054. irda_device_set_media_busy(self->netdev, TRUE);
  1055. break;
  1056. case SIOCGRECEIVING: /* Check if we are receiving right now */
  1057. irq->ifr_receiving = w83977af_is_receiving(self);
  1058. break;
  1059. default:
  1060. ret = -EOPNOTSUPP;
  1061. }
  1062. out:
  1063. spin_unlock_irqrestore(&self->lock, flags);
  1064. return ret;
  1065. }
  1066. MODULE_AUTHOR("Dag Brattli <dagb@cs.uit.no>");
  1067. MODULE_DESCRIPTION("Winbond W83977AF IrDA Device Driver");
  1068. MODULE_LICENSE("GPL");
  1069. module_param(qos_mtt_bits, int, 0);
  1070. MODULE_PARM_DESC(qos_mtt_bits, "Mimimum Turn Time");
  1071. module_param_array(io, int, NULL, 0);
  1072. MODULE_PARM_DESC(io, "Base I/O addresses");
  1073. module_param_array(irq, int, NULL, 0);
  1074. MODULE_PARM_DESC(irq, "IRQ lines");
  1075. /*
  1076. * Function init_module (void)
  1077. *
  1078. *
  1079. *
  1080. */
  1081. module_init(w83977af_init);
  1082. /*
  1083. * Function cleanup_module (void)
  1084. *
  1085. *
  1086. *
  1087. */
  1088. module_exit(w83977af_cleanup);