w83977af_ir.c
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:33k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

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