1 /*********************************************************************
5 * Description: Driver for the ALI M1535D and M1543C FIR Controller
6 * Status: Experimental.
7 * Author: Benjamin Kong <benjamin_kong@ali.com.tw>
8 * Created at: 2000/10/16 03:46PM
9 * Modified at: 2001/1/3 02:55PM
10 * Modified by: Benjamin Kong <benjamin_kong@ali.com.tw>
11 * Modified at: 2003/11/6 and support for ALi south-bridge chipsets M1563
12 * Modified by: Clear Zhang <clear_zhang@ali.com.tw>
14 * Copyright (c) 2000 Benjamin Kong <benjamin_kong@ali.com.tw>
17 * This program is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU General Public License as
19 * published by the Free Software Foundation; either version 2 of
20 * the License, or (at your option) any later version.
22 ********************************************************************/
24 #include <linux/module.h>
26 #include <linux/kernel.h>
27 #include <linux/types.h>
28 #include <linux/skbuff.h>
29 #include <linux/netdevice.h>
30 #include <linux/ioport.h>
31 #include <linux/delay.h>
32 #include <linux/slab.h>
33 #include <linux/init.h>
34 #include <linux/rtnetlink.h>
35 #include <linux/serial_reg.h>
36 #include <linux/dma-mapping.h>
37 #include <linux/platform_device.h>
41 #include <asm/byteorder.h>
43 #include <net/irda/wrapper.h>
44 #include <net/irda/irda.h>
45 #include <net/irda/irda_device.h>
49 #define CHIP_IO_EXTENT 8
50 #define BROKEN_DONGLE_ID
52 #define ALI_IRCC_DRIVER_NAME "ali-ircc"
54 /* Power Management */
55 static int ali_ircc_suspend(struct platform_device
*dev
, pm_message_t state
);
56 static int ali_ircc_resume(struct platform_device
*dev
);
58 static struct platform_driver ali_ircc_driver
= {
59 .suspend
= ali_ircc_suspend
,
60 .resume
= ali_ircc_resume
,
62 .name
= ALI_IRCC_DRIVER_NAME
,
66 /* Module parameters */
67 static int qos_mtt_bits
= 0x07; /* 1 ms or more */
69 /* Use BIOS settions by default, but user may supply module parameters */
70 static unsigned int io
[] = { ~0, ~0, ~0, ~0 };
71 static unsigned int irq
[] = { 0, 0, 0, 0 };
72 static unsigned int dma
[] = { 0, 0, 0, 0 };
74 static int ali_ircc_probe_53(ali_chip_t
*chip
, chipio_t
*info
);
75 static int ali_ircc_init_43(ali_chip_t
*chip
, chipio_t
*info
);
76 static int ali_ircc_init_53(ali_chip_t
*chip
, chipio_t
*info
);
78 /* These are the currently known ALi sourth-bridge chipsets, the only one difference
79 * is that M1543C doesn't support HP HDSL-3600
81 static ali_chip_t chips
[] =
83 { "M1543", { 0x3f0, 0x370 }, 0x51, 0x23, 0x20, 0x43, ali_ircc_probe_53
, ali_ircc_init_43
},
84 { "M1535", { 0x3f0, 0x370 }, 0x51, 0x23, 0x20, 0x53, ali_ircc_probe_53
, ali_ircc_init_53
},
85 { "M1563", { 0x3f0, 0x370 }, 0x51, 0x23, 0x20, 0x63, ali_ircc_probe_53
, ali_ircc_init_53
},
89 /* Max 4 instances for now */
90 static struct ali_ircc_cb
*dev_self
[] = { NULL
, NULL
, NULL
, NULL
};
93 static char *dongle_types
[] = {
97 "No dongle connected",
100 /* Some prototypes */
101 static int ali_ircc_open(int i
, chipio_t
*info
);
103 static int ali_ircc_close(struct ali_ircc_cb
*self
);
105 static int ali_ircc_setup(chipio_t
*info
);
106 static int ali_ircc_is_receiving(struct ali_ircc_cb
*self
);
107 static int ali_ircc_net_open(struct net_device
*dev
);
108 static int ali_ircc_net_close(struct net_device
*dev
);
109 static int ali_ircc_net_ioctl(struct net_device
*dev
, struct ifreq
*rq
, int cmd
);
110 static void ali_ircc_change_speed(struct ali_ircc_cb
*self
, __u32 baud
);
111 static struct net_device_stats
*ali_ircc_net_get_stats(struct net_device
*dev
);
114 static int ali_ircc_sir_hard_xmit(struct sk_buff
*skb
, struct net_device
*dev
);
115 static irqreturn_t
ali_ircc_sir_interrupt(struct ali_ircc_cb
*self
);
116 static void ali_ircc_sir_receive(struct ali_ircc_cb
*self
);
117 static void ali_ircc_sir_write_wakeup(struct ali_ircc_cb
*self
);
118 static int ali_ircc_sir_write(int iobase
, int fifo_size
, __u8
*buf
, int len
);
119 static void ali_ircc_sir_change_speed(struct ali_ircc_cb
*priv
, __u32 speed
);
122 static int ali_ircc_fir_hard_xmit(struct sk_buff
*skb
, struct net_device
*dev
);
123 static void ali_ircc_fir_change_speed(struct ali_ircc_cb
*priv
, __u32 speed
);
124 static irqreturn_t
ali_ircc_fir_interrupt(struct ali_ircc_cb
*self
);
125 static int ali_ircc_dma_receive(struct ali_ircc_cb
*self
);
126 static int ali_ircc_dma_receive_complete(struct ali_ircc_cb
*self
);
127 static int ali_ircc_dma_xmit_complete(struct ali_ircc_cb
*self
);
128 static void ali_ircc_dma_xmit(struct ali_ircc_cb
*self
);
131 static int ali_ircc_read_dongle_id (int i
, chipio_t
*info
);
132 static void ali_ircc_change_dongle_speed(struct ali_ircc_cb
*priv
, int speed
);
134 /* ALi chip function */
135 static void SIR2FIR(int iobase
);
136 static void FIR2SIR(int iobase
);
137 static void SetCOMInterrupts(struct ali_ircc_cb
*self
, unsigned char enable
);
140 * Function ali_ircc_init ()
142 * Initialize chip. Find out whay kinds of chips we are dealing with
143 * and their configuation registers address
145 static int __init
ali_ircc_init(void)
154 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __FUNCTION__
);
156 ret
= platform_driver_register(&ali_ircc_driver
);
158 IRDA_ERROR("%s, Can't register driver!\n",
159 ALI_IRCC_DRIVER_NAME
);
165 /* Probe for all the ALi chipsets we know about */
166 for (chip
= chips
; chip
->name
; chip
++, i
++)
168 IRDA_DEBUG(2, "%s(), Probing for %s ...\n", __FUNCTION__
, chip
->name
);
170 /* Try all config registers for this chip */
171 for (cfg
=0; cfg
<2; cfg
++)
173 cfg_base
= chip
->cfg
[cfg
];
177 memset(&info
, 0, sizeof(chipio_t
));
178 info
.cfg_base
= cfg_base
;
179 info
.fir_base
= io
[i
];
184 /* Enter Configuration */
185 outb(chip
->entr1
, cfg_base
);
186 outb(chip
->entr2
, cfg_base
);
188 /* Select Logical Device 5 Registers (UART2) */
189 outb(0x07, cfg_base
);
190 outb(0x05, cfg_base
+1);
192 /* Read Chip Identification Register */
193 outb(chip
->cid_index
, cfg_base
);
194 reg
= inb(cfg_base
+1);
196 if (reg
== chip
->cid_value
)
198 IRDA_DEBUG(2, "%s(), Chip found at 0x%03x\n", __FUNCTION__
, cfg_base
);
200 outb(0x1F, cfg_base
);
201 revision
= inb(cfg_base
+1);
202 IRDA_DEBUG(2, "%s(), Found %s chip, revision=%d\n", __FUNCTION__
,
203 chip
->name
, revision
);
206 * If the user supplies the base address, then
207 * we init the chip, if not we probe the values
212 chip
->init(chip
, &info
);
216 chip
->probe(chip
, &info
);
219 if (ali_ircc_open(i
, &info
) == 0)
225 IRDA_DEBUG(2, "%s(), No %s chip at 0x%03x\n", __FUNCTION__
, chip
->name
, cfg_base
);
227 /* Exit configuration */
228 outb(0xbb, cfg_base
);
232 IRDA_DEBUG(2, "%s(), ----------------- End -----------------\n", __FUNCTION__
);
235 platform_driver_unregister(&ali_ircc_driver
);
241 * Function ali_ircc_cleanup ()
243 * Close all configured chips
246 static void __exit
ali_ircc_cleanup(void)
250 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __FUNCTION__
);
252 for (i
=0; i
< ARRAY_SIZE(dev_self
); i
++) {
254 ali_ircc_close(dev_self
[i
]);
257 platform_driver_unregister(&ali_ircc_driver
);
259 IRDA_DEBUG(2, "%s(), ----------------- End -----------------\n", __FUNCTION__
);
263 * Function ali_ircc_open (int i, chipio_t *inf)
265 * Open driver instance
268 static int ali_ircc_open(int i
, chipio_t
*info
)
270 struct net_device
*dev
;
271 struct ali_ircc_cb
*self
;
275 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __FUNCTION__
);
277 if (i
>= ARRAY_SIZE(dev_self
)) {
278 IRDA_ERROR("%s(), maximum number of supported chips reached!\n",
283 /* Set FIR FIFO and DMA Threshold */
284 if ((ali_ircc_setup(info
)) == -1)
287 dev
= alloc_irdadev(sizeof(*self
));
289 IRDA_ERROR("%s(), can't allocate memory for control block!\n",
296 spin_lock_init(&self
->lock
);
298 /* Need to store self somewhere */
303 self
->io
.cfg_base
= info
->cfg_base
; /* In ali_ircc_probe_53 assign */
304 self
->io
.fir_base
= info
->fir_base
; /* info->sir_base = info->fir_base */
305 self
->io
.sir_base
= info
->sir_base
; /* ALi SIR and FIR use the same address */
306 self
->io
.irq
= info
->irq
;
307 self
->io
.fir_ext
= CHIP_IO_EXTENT
;
308 self
->io
.dma
= info
->dma
;
309 self
->io
.fifo_size
= 16; /* SIR: 16, FIR: 32 Benjamin 2000/11/1 */
311 /* Reserve the ioports that we need */
312 if (!request_region(self
->io
.fir_base
, self
->io
.fir_ext
,
313 ALI_IRCC_DRIVER_NAME
)) {
314 IRDA_WARNING("%s(), can't get iobase of 0x%03x\n", __FUNCTION__
,
320 /* Initialize QoS for this device */
321 irda_init_max_qos_capabilies(&self
->qos
);
323 /* The only value we must override it the baudrate */
324 self
->qos
.baud_rate
.bits
= IR_9600
|IR_19200
|IR_38400
|IR_57600
|
325 IR_115200
|IR_576000
|IR_1152000
|(IR_4000000
<< 8); // benjamin 2000/11/8 05:27PM
327 self
->qos
.min_turn_time
.bits
= qos_mtt_bits
;
329 irda_qos_bits_to_value(&self
->qos
);
331 /* Max DMA buffer size needed = (data_size + 6) * (window_size) + 6; */
332 self
->rx_buff
.truesize
= 14384;
333 self
->tx_buff
.truesize
= 14384;
335 /* Allocate memory if needed */
337 dma_alloc_coherent(NULL
, self
->rx_buff
.truesize
,
338 &self
->rx_buff_dma
, GFP_KERNEL
);
339 if (self
->rx_buff
.head
== NULL
) {
343 memset(self
->rx_buff
.head
, 0, self
->rx_buff
.truesize
);
346 dma_alloc_coherent(NULL
, self
->tx_buff
.truesize
,
347 &self
->tx_buff_dma
, GFP_KERNEL
);
348 if (self
->tx_buff
.head
== NULL
) {
352 memset(self
->tx_buff
.head
, 0, self
->tx_buff
.truesize
);
354 self
->rx_buff
.in_frame
= FALSE
;
355 self
->rx_buff
.state
= OUTSIDE_FRAME
;
356 self
->tx_buff
.data
= self
->tx_buff
.head
;
357 self
->rx_buff
.data
= self
->rx_buff
.head
;
359 /* Reset Tx queue info */
360 self
->tx_fifo
.len
= self
->tx_fifo
.ptr
= self
->tx_fifo
.free
= 0;
361 self
->tx_fifo
.tail
= self
->tx_buff
.head
;
364 /* Keep track of module usage */
365 SET_MODULE_OWNER(dev
);
367 /* Override the network functions we need to use */
368 dev
->hard_start_xmit
= ali_ircc_sir_hard_xmit
;
369 dev
->open
= ali_ircc_net_open
;
370 dev
->stop
= ali_ircc_net_close
;
371 dev
->do_ioctl
= ali_ircc_net_ioctl
;
372 dev
->get_stats
= ali_ircc_net_get_stats
;
374 err
= register_netdev(dev
);
376 IRDA_ERROR("%s(), register_netdev() failed!\n", __FUNCTION__
);
379 IRDA_MESSAGE("IrDA: Registered device %s\n", dev
->name
);
381 /* Check dongle id */
382 dongle_id
= ali_ircc_read_dongle_id(i
, info
);
383 IRDA_MESSAGE("%s(), %s, Found dongle: %s\n", __FUNCTION__
,
384 ALI_IRCC_DRIVER_NAME
, dongle_types
[dongle_id
]);
386 self
->io
.dongle_id
= dongle_id
;
388 IRDA_DEBUG(2, "%s(), ----------------- End -----------------\n", __FUNCTION__
);
393 dma_free_coherent(NULL
, self
->tx_buff
.truesize
,
394 self
->tx_buff
.head
, self
->tx_buff_dma
);
396 dma_free_coherent(NULL
, self
->rx_buff
.truesize
,
397 self
->rx_buff
.head
, self
->rx_buff_dma
);
399 release_region(self
->io
.fir_base
, self
->io
.fir_ext
);
408 * Function ali_ircc_close (self)
410 * Close driver instance
413 static int __exit
ali_ircc_close(struct ali_ircc_cb
*self
)
417 IRDA_DEBUG(4, "%s(), ---------------- Start ----------------\n", __FUNCTION__
);
419 IRDA_ASSERT(self
!= NULL
, return -1;);
421 iobase
= self
->io
.fir_base
;
423 /* Remove netdevice */
424 unregister_netdev(self
->netdev
);
426 /* Release the PORT that this driver is using */
427 IRDA_DEBUG(4, "%s(), Releasing Region %03x\n", __FUNCTION__
, self
->io
.fir_base
);
428 release_region(self
->io
.fir_base
, self
->io
.fir_ext
);
430 if (self
->tx_buff
.head
)
431 dma_free_coherent(NULL
, self
->tx_buff
.truesize
,
432 self
->tx_buff
.head
, self
->tx_buff_dma
);
434 if (self
->rx_buff
.head
)
435 dma_free_coherent(NULL
, self
->rx_buff
.truesize
,
436 self
->rx_buff
.head
, self
->rx_buff_dma
);
438 dev_self
[self
->index
] = NULL
;
439 free_netdev(self
->netdev
);
441 IRDA_DEBUG(2, "%s(), ----------------- End -----------------\n", __FUNCTION__
);
447 * Function ali_ircc_init_43 (chip, info)
449 * Initialize the ALi M1543 chip.
451 static int ali_ircc_init_43(ali_chip_t
*chip
, chipio_t
*info
)
453 /* All controller information like I/O address, DMA channel, IRQ
461 * Function ali_ircc_init_53 (chip, info)
463 * Initialize the ALi M1535 chip.
465 static int ali_ircc_init_53(ali_chip_t
*chip
, chipio_t
*info
)
467 /* All controller information like I/O address, DMA channel, IRQ
475 * Function ali_ircc_probe_53 (chip, info)
477 * Probes for the ALi M1535D or M1535
479 static int ali_ircc_probe_53(ali_chip_t
*chip
, chipio_t
*info
)
481 int cfg_base
= info
->cfg_base
;
484 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __FUNCTION__
);
486 /* Enter Configuration */
487 outb(chip
->entr1
, cfg_base
);
488 outb(chip
->entr2
, cfg_base
);
490 /* Select Logical Device 5 Registers (UART2) */
491 outb(0x07, cfg_base
);
492 outb(0x05, cfg_base
+1);
494 /* Read address control register */
495 outb(0x60, cfg_base
);
496 hi
= inb(cfg_base
+1);
497 outb(0x61, cfg_base
);
498 low
= inb(cfg_base
+1);
499 info
->fir_base
= (hi
<<8) + low
;
501 info
->sir_base
= info
->fir_base
;
503 IRDA_DEBUG(2, "%s(), probing fir_base=0x%03x\n", __FUNCTION__
, info
->fir_base
);
505 /* Read IRQ control register */
506 outb(0x70, cfg_base
);
507 reg
= inb(cfg_base
+1);
508 info
->irq
= reg
& 0x0f;
509 IRDA_DEBUG(2, "%s(), probing irq=%d\n", __FUNCTION__
, info
->irq
);
511 /* Read DMA channel */
512 outb(0x74, cfg_base
);
513 reg
= inb(cfg_base
+1);
514 info
->dma
= reg
& 0x07;
516 if(info
->dma
== 0x04)
517 IRDA_WARNING("%s(), No DMA channel assigned !\n", __FUNCTION__
);
519 IRDA_DEBUG(2, "%s(), probing dma=%d\n", __FUNCTION__
, info
->dma
);
521 /* Read Enabled Status */
522 outb(0x30, cfg_base
);
523 reg
= inb(cfg_base
+1);
524 info
->enabled
= (reg
& 0x80) && (reg
& 0x01);
525 IRDA_DEBUG(2, "%s(), probing enabled=%d\n", __FUNCTION__
, info
->enabled
);
527 /* Read Power Status */
528 outb(0x22, cfg_base
);
529 reg
= inb(cfg_base
+1);
530 info
->suspended
= (reg
& 0x20);
531 IRDA_DEBUG(2, "%s(), probing suspended=%d\n", __FUNCTION__
, info
->suspended
);
533 /* Exit configuration */
534 outb(0xbb, cfg_base
);
536 IRDA_DEBUG(2, "%s(), ----------------- End -----------------\n", __FUNCTION__
);
542 * Function ali_ircc_setup (info)
544 * Set FIR FIFO and DMA Threshold
545 * Returns non-negative on success.
548 static int ali_ircc_setup(chipio_t
*info
)
552 int iobase
= info
->fir_base
;
554 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __FUNCTION__
);
556 /* Locking comments :
557 * Most operations here need to be protected. We are called before
558 * the device instance is created in ali_ircc_open(), therefore
559 * nobody can bother us - Jean II */
561 /* Switch to FIR space */
565 outb(0x40, iobase
+FIR_MCR
); // benjamin 2000/11/30 11:45AM
567 /* Read FIR ID Version Register */
568 switch_bank(iobase
, BANK3
);
569 version
= inb(iobase
+FIR_ID_VR
);
571 /* Should be 0x00 in the M1535/M1535D */
574 IRDA_ERROR("%s, Wrong chip version %02x\n",
575 ALI_IRCC_DRIVER_NAME
, version
);
579 /* Set FIR FIFO Threshold Register */
580 switch_bank(iobase
, BANK1
);
581 outb(RX_FIFO_Threshold
, iobase
+FIR_FIFO_TR
);
583 /* Set FIR DMA Threshold Register */
584 outb(RX_DMA_Threshold
, iobase
+FIR_DMA_TR
);
587 switch_bank(iobase
, BANK2
);
588 outb(inb(iobase
+FIR_IRDA_CR
) | IRDA_CR_CRC
, iobase
+FIR_IRDA_CR
);
590 /* NDIS driver set TX Length here BANK2 Alias 3, Alias4*/
592 /* Switch to Bank 0 */
593 switch_bank(iobase
, BANK0
);
595 tmp
= inb(iobase
+FIR_LCR_B
);
596 tmp
&=~0x20; // disable SIP
597 tmp
|= 0x80; // these two steps make RX mode
599 outb(tmp
, iobase
+FIR_LCR_B
);
601 /* Disable Interrupt */
602 outb(0x00, iobase
+FIR_IER
);
605 /* Switch to SIR space */
608 IRDA_MESSAGE("%s, driver loaded (Benjamin Kong)\n",
609 ALI_IRCC_DRIVER_NAME
);
611 /* Enable receive interrupts */
612 // outb(UART_IER_RDI, iobase+UART_IER); //benjamin 2000/11/23 01:25PM
613 // Turn on the interrupts in ali_ircc_net_open
615 IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __FUNCTION__
);
621 * Function ali_ircc_read_dongle_id (int index, info)
623 * Try to read dongle indentification. This procedure needs to be executed
624 * once after power-on/reset. It also needs to be used whenever you suspect
625 * that the user may have plugged/unplugged the IrDA Dongle.
627 static int ali_ircc_read_dongle_id (int i
, chipio_t
*info
)
630 int cfg_base
= info
->cfg_base
;
632 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __FUNCTION__
);
634 /* Enter Configuration */
635 outb(chips
[i
].entr1
, cfg_base
);
636 outb(chips
[i
].entr2
, cfg_base
);
638 /* Select Logical Device 5 Registers (UART2) */
639 outb(0x07, cfg_base
);
640 outb(0x05, cfg_base
+1);
643 outb(0xf0, cfg_base
);
644 reg
= inb(cfg_base
+1);
645 dongle_id
= ((reg
>>6)&0x02) | ((reg
>>5)&0x01);
646 IRDA_DEBUG(2, "%s(), probing dongle_id=%d, dongle_types=%s\n", __FUNCTION__
,
647 dongle_id
, dongle_types
[dongle_id
]);
649 /* Exit configuration */
650 outb(0xbb, cfg_base
);
652 IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __FUNCTION__
);
658 * Function ali_ircc_interrupt (irq, dev_id, regs)
660 * An interrupt from the chip has arrived. Time to do some work
663 static irqreturn_t
ali_ircc_interrupt(int irq
, void *dev_id
)
665 struct net_device
*dev
= (struct net_device
*) dev_id
;
666 struct ali_ircc_cb
*self
;
669 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __FUNCTION__
);
672 IRDA_WARNING("%s: irq %d for unknown device.\n",
673 ALI_IRCC_DRIVER_NAME
, irq
);
677 self
= (struct ali_ircc_cb
*) dev
->priv
;
679 spin_lock(&self
->lock
);
681 /* Dispatch interrupt handler for the current speed */
682 if (self
->io
.speed
> 115200)
683 ret
= ali_ircc_fir_interrupt(self
);
685 ret
= ali_ircc_sir_interrupt(self
);
687 spin_unlock(&self
->lock
);
689 IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __FUNCTION__
);
693 * Function ali_ircc_fir_interrupt(irq, struct ali_ircc_cb *self)
695 * Handle MIR/FIR interrupt
698 static irqreturn_t
ali_ircc_fir_interrupt(struct ali_ircc_cb
*self
)
700 __u8 eir
, OldMessageCount
;
703 IRDA_DEBUG(1, "%s(), ---------------- Start ----------------\n", __FUNCTION__
);
705 iobase
= self
->io
.fir_base
;
707 switch_bank(iobase
, BANK0
);
708 self
->InterruptID
= inb(iobase
+FIR_IIR
);
709 self
->BusStatus
= inb(iobase
+FIR_BSR
);
711 OldMessageCount
= (self
->LineStatus
+ 1) & 0x07;
712 self
->LineStatus
= inb(iobase
+FIR_LSR
);
713 //self->ier = inb(iobase+FIR_IER); 2000/12/1 04:32PM
714 eir
= self
->InterruptID
& self
->ier
; /* Mask out the interesting ones */
716 IRDA_DEBUG(1, "%s(), self->InterruptID = %x\n", __FUNCTION__
,self
->InterruptID
);
717 IRDA_DEBUG(1, "%s(), self->LineStatus = %x\n", __FUNCTION__
,self
->LineStatus
);
718 IRDA_DEBUG(1, "%s(), self->ier = %x\n", __FUNCTION__
,self
->ier
);
719 IRDA_DEBUG(1, "%s(), eir = %x\n", __FUNCTION__
,eir
);
721 /* Disable interrupts */
722 SetCOMInterrupts(self
, FALSE
);
724 /* Tx or Rx Interrupt */
728 if (self
->io
.direction
== IO_XMIT
) /* TX */
730 IRDA_DEBUG(1, "%s(), ******* IIR_EOM (Tx) *******\n", __FUNCTION__
);
732 if(ali_ircc_dma_xmit_complete(self
))
734 if (irda_device_txqueue_empty(self
->netdev
))
736 /* Prepare for receive */
737 ali_ircc_dma_receive(self
);
749 IRDA_DEBUG(1, "%s(), ******* IIR_EOM (Rx) *******\n", __FUNCTION__
);
751 if(OldMessageCount
> ((self
->LineStatus
+1) & 0x07))
753 self
->rcvFramesOverflow
= TRUE
;
754 IRDA_DEBUG(1, "%s(), ******* self->rcvFramesOverflow = TRUE ******** \n", __FUNCTION__
);
757 if (ali_ircc_dma_receive_complete(self
))
759 IRDA_DEBUG(1, "%s(), ******* receive complete ******** \n", __FUNCTION__
);
765 IRDA_DEBUG(1, "%s(), ******* Not receive complete ******** \n", __FUNCTION__
);
767 self
->ier
= IER_EOM
| IER_TIMER
;
772 /* Timer Interrupt */
773 else if (eir
& IIR_TIMER
)
775 if(OldMessageCount
> ((self
->LineStatus
+1) & 0x07))
777 self
->rcvFramesOverflow
= TRUE
;
778 IRDA_DEBUG(1, "%s(), ******* self->rcvFramesOverflow = TRUE ******* \n", __FUNCTION__
);
781 switch_bank(iobase
, BANK1
);
782 tmp
= inb(iobase
+FIR_CR
);
783 outb( tmp
& ~CR_TIMER_EN
, iobase
+FIR_CR
);
785 /* Check if this is a Tx timer interrupt */
786 if (self
->io
.direction
== IO_XMIT
)
788 ali_ircc_dma_xmit(self
);
790 /* Interrupt on EOM */
796 if(ali_ircc_dma_receive_complete(self
))
802 self
->ier
= IER_EOM
| IER_TIMER
;
807 /* Restore Interrupt */
808 SetCOMInterrupts(self
, TRUE
);
810 IRDA_DEBUG(1, "%s(), ----------------- End ---------------\n", __FUNCTION__
);
811 return IRQ_RETVAL(eir
);
815 * Function ali_ircc_sir_interrupt (irq, self, eir)
817 * Handle SIR interrupt
820 static irqreturn_t
ali_ircc_sir_interrupt(struct ali_ircc_cb
*self
)
825 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __FUNCTION__
);
827 iobase
= self
->io
.sir_base
;
829 iir
= inb(iobase
+UART_IIR
) & UART_IIR_ID
;
831 /* Clear interrupt */
832 lsr
= inb(iobase
+UART_LSR
);
834 IRDA_DEBUG(4, "%s(), iir=%02x, lsr=%02x, iobase=%#x\n", __FUNCTION__
,
840 IRDA_DEBUG(2, "%s(), RLSI\n", __FUNCTION__
);
843 /* Receive interrupt */
844 ali_ircc_sir_receive(self
);
847 if (lsr
& UART_LSR_THRE
)
849 /* Transmitter ready for data */
850 ali_ircc_sir_write_wakeup(self
);
854 IRDA_DEBUG(0, "%s(), unhandled IIR=%#x\n", __FUNCTION__
, iir
);
861 IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __FUNCTION__
);
863 return IRQ_RETVAL(iir
);
868 * Function ali_ircc_sir_receive (self)
870 * Receive one frame from the infrared port
873 static void ali_ircc_sir_receive(struct ali_ircc_cb
*self
)
878 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __FUNCTION__
);
879 IRDA_ASSERT(self
!= NULL
, return;);
881 iobase
= self
->io
.sir_base
;
884 * Receive all characters in Rx FIFO, unwrap and unstuff them.
885 * async_unwrap_char will deliver all found frames
888 async_unwrap_char(self
->netdev
, &self
->stats
, &self
->rx_buff
,
889 inb(iobase
+UART_RX
));
891 /* Make sure we don't stay here too long */
892 if (boguscount
++ > 32) {
893 IRDA_DEBUG(2,"%s(), breaking!\n", __FUNCTION__
);
896 } while (inb(iobase
+UART_LSR
) & UART_LSR_DR
);
898 IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __FUNCTION__
);
902 * Function ali_ircc_sir_write_wakeup (tty)
904 * Called by the driver when there's room for more data. If we have
905 * more packets to send, we send them here.
908 static void ali_ircc_sir_write_wakeup(struct ali_ircc_cb
*self
)
913 IRDA_ASSERT(self
!= NULL
, return;);
915 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __FUNCTION__
);
917 iobase
= self
->io
.sir_base
;
919 /* Finished with frame? */
920 if (self
->tx_buff
.len
> 0)
922 /* Write data left in transmit buffer */
923 actual
= ali_ircc_sir_write(iobase
, self
->io
.fifo_size
,
924 self
->tx_buff
.data
, self
->tx_buff
.len
);
925 self
->tx_buff
.data
+= actual
;
926 self
->tx_buff
.len
-= actual
;
932 /* We must wait until all data are gone */
933 while(!(inb(iobase
+UART_LSR
) & UART_LSR_TEMT
))
934 IRDA_DEBUG(1, "%s(), UART_LSR_THRE\n", __FUNCTION__
);
936 IRDA_DEBUG(1, "%s(), Changing speed! self->new_speed = %d\n", __FUNCTION__
, self
->new_speed
);
937 ali_ircc_change_speed(self
, self
->new_speed
);
940 // benjamin 2000/11/10 06:32PM
941 if (self
->io
.speed
> 115200)
943 IRDA_DEBUG(2, "%s(), ali_ircc_change_speed from UART_LSR_TEMT \n", __FUNCTION__
);
946 // SetCOMInterrupts(self, TRUE);
952 netif_wake_queue(self
->netdev
);
955 self
->stats
.tx_packets
++;
957 /* Turn on receive interrupts */
958 outb(UART_IER_RDI
, iobase
+UART_IER
);
961 IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __FUNCTION__
);
964 static void ali_ircc_change_speed(struct ali_ircc_cb
*self
, __u32 baud
)
966 struct net_device
*dev
= self
->netdev
;
969 IRDA_DEBUG(1, "%s(), ---------------- Start ----------------\n", __FUNCTION__
);
971 IRDA_DEBUG(2, "%s(), setting speed = %d \n", __FUNCTION__
, baud
);
973 /* This function *must* be called with irq off and spin-lock.
976 iobase
= self
->io
.fir_base
;
978 SetCOMInterrupts(self
, FALSE
); // 2000/11/24 11:43AM
980 /* Go to MIR, FIR Speed */
985 ali_ircc_fir_change_speed(self
, baud
);
987 /* Install FIR xmit handler*/
988 dev
->hard_start_xmit
= ali_ircc_fir_hard_xmit
;
990 /* Enable Interuupt */
991 self
->ier
= IER_EOM
; // benjamin 2000/11/20 07:24PM
993 /* Be ready for incomming frames */
994 ali_ircc_dma_receive(self
); // benajmin 2000/11/8 07:46PM not complete
996 /* Go to SIR Speed */
999 ali_ircc_sir_change_speed(self
, baud
);
1001 /* Install SIR xmit handler*/
1002 dev
->hard_start_xmit
= ali_ircc_sir_hard_xmit
;
1006 SetCOMInterrupts(self
, TRUE
); // 2000/11/24 11:43AM
1008 netif_wake_queue(self
->netdev
);
1010 IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __FUNCTION__
);
1013 static void ali_ircc_fir_change_speed(struct ali_ircc_cb
*priv
, __u32 baud
)
1017 struct ali_ircc_cb
*self
= (struct ali_ircc_cb
*) priv
;
1018 struct net_device
*dev
;
1020 IRDA_DEBUG(1, "%s(), ---------------- Start ----------------\n", __FUNCTION__
);
1022 IRDA_ASSERT(self
!= NULL
, return;);
1025 iobase
= self
->io
.fir_base
;
1027 IRDA_DEBUG(1, "%s(), self->io.speed = %d, change to speed = %d\n", __FUNCTION__
,self
->io
.speed
,baud
);
1029 /* Come from SIR speed */
1030 if(self
->io
.speed
<=115200)
1035 /* Update accounting for new speed */
1036 self
->io
.speed
= baud
;
1038 // Set Dongle Speed mode
1039 ali_ircc_change_dongle_speed(self
, baud
);
1041 IRDA_DEBUG(1, "%s(), ----------------- End ------------------\n", __FUNCTION__
);
1045 * Function ali_sir_change_speed (self, speed)
1047 * Set speed of IrDA port to specified baudrate
1050 static void ali_ircc_sir_change_speed(struct ali_ircc_cb
*priv
, __u32 speed
)
1052 struct ali_ircc_cb
*self
= (struct ali_ircc_cb
*) priv
;
1053 unsigned long flags
;
1055 int fcr
; /* FIFO control reg */
1056 int lcr
; /* Line control reg */
1059 IRDA_DEBUG(1, "%s(), ---------------- Start ----------------\n", __FUNCTION__
);
1061 IRDA_DEBUG(1, "%s(), Setting speed to: %d\n", __FUNCTION__
, speed
);
1063 IRDA_ASSERT(self
!= NULL
, return;);
1065 iobase
= self
->io
.sir_base
;
1067 /* Come from MIR or FIR speed */
1068 if(self
->io
.speed
>115200)
1070 // Set Dongle Speed mode first
1071 ali_ircc_change_dongle_speed(self
, speed
);
1076 // Clear Line and Auxiluary status registers 2000/11/24 11:47AM
1078 inb(iobase
+UART_LSR
);
1079 inb(iobase
+UART_SCR
);
1081 /* Update accounting for new speed */
1082 self
->io
.speed
= speed
;
1084 spin_lock_irqsave(&self
->lock
, flags
);
1086 divisor
= 115200/speed
;
1088 fcr
= UART_FCR_ENABLE_FIFO
;
1091 * Use trigger level 1 to avoid 3 ms. timeout delay at 9600 bps, and
1092 * almost 1,7 ms at 19200 bps. At speeds above that we can just forget
1093 * about this timeout since it will always be fast enough.
1095 if (self
->io
.speed
< 38400)
1096 fcr
|= UART_FCR_TRIGGER_1
;
1098 fcr
|= UART_FCR_TRIGGER_14
;
1100 /* IrDA ports use 8N1 */
1101 lcr
= UART_LCR_WLEN8
;
1103 outb(UART_LCR_DLAB
| lcr
, iobase
+UART_LCR
); /* Set DLAB */
1104 outb(divisor
& 0xff, iobase
+UART_DLL
); /* Set speed */
1105 outb(divisor
>> 8, iobase
+UART_DLM
);
1106 outb(lcr
, iobase
+UART_LCR
); /* Set 8N1 */
1107 outb(fcr
, iobase
+UART_FCR
); /* Enable FIFO's */
1109 /* without this, the conection will be broken after come back from FIR speed,
1110 but with this, the SIR connection is harder to established */
1111 outb((UART_MCR_DTR
| UART_MCR_RTS
| UART_MCR_OUT2
), iobase
+UART_MCR
);
1113 spin_unlock_irqrestore(&self
->lock
, flags
);
1115 IRDA_DEBUG(1, "%s(), ----------------- End ------------------\n", __FUNCTION__
);
1118 static void ali_ircc_change_dongle_speed(struct ali_ircc_cb
*priv
, int speed
)
1121 struct ali_ircc_cb
*self
= (struct ali_ircc_cb
*) priv
;
1122 int iobase
,dongle_id
;
1125 IRDA_DEBUG(1, "%s(), ---------------- Start ----------------\n", __FUNCTION__
);
1127 iobase
= self
->io
.fir_base
; /* or iobase = self->io.sir_base; */
1128 dongle_id
= self
->io
.dongle_id
;
1130 /* We are already locked, no need to do it again */
1132 IRDA_DEBUG(1, "%s(), Set Speed for %s , Speed = %d\n", __FUNCTION__
, dongle_types
[dongle_id
], speed
);
1134 switch_bank(iobase
, BANK2
);
1135 tmp
= inb(iobase
+FIR_IRDA_CR
);
1137 /* IBM type dongle */
1140 if(speed
== 4000000)
1143 // SD/MODE __| |__ __
1148 tmp
&= ~IRDA_CR_HDLC
; // HDLC=0
1149 tmp
|= IRDA_CR_CRC
; // CRC=1
1151 switch_bank(iobase
, BANK2
);
1152 outb(tmp
, iobase
+FIR_IRDA_CR
);
1154 // T1 -> SD/MODE:0 IRTX:0
1157 outb(tmp
, iobase
+FIR_IRDA_CR
);
1160 // T2 -> SD/MODE:1 IRTX:0
1163 outb(tmp
, iobase
+FIR_IRDA_CR
);
1166 // T3 -> SD/MODE:1 IRTX:1
1168 outb(tmp
, iobase
+FIR_IRDA_CR
);
1171 // T4 -> SD/MODE:0 IRTX:1
1174 outb(tmp
, iobase
+FIR_IRDA_CR
);
1177 // T5 -> SD/MODE:0 IRTX:0
1180 outb(tmp
, iobase
+FIR_IRDA_CR
);
1183 // reset -> Normal TX output Signal
1184 outb(tmp
& ~0x02, iobase
+FIR_IRDA_CR
);
1186 else /* speed <=1152000 */
1194 /* MIR 115200, 57600 */
1197 tmp
|= 0xA0; //HDLC=1, 1.152Mbps=1
1201 tmp
&=~0x80; //HDLC 0.576Mbps
1202 tmp
|= 0x20; //HDLC=1,
1205 tmp
|= IRDA_CR_CRC
; // CRC=1
1207 switch_bank(iobase
, BANK2
);
1208 outb(tmp
, iobase
+FIR_IRDA_CR
);
1210 /* MIR 115200, 57600 */
1212 //switch_bank(iobase, BANK2);
1213 // T1 -> SD/MODE:0 IRTX:0
1216 outb(tmp
, iobase
+FIR_IRDA_CR
);
1219 // T2 -> SD/MODE:1 IRTX:0
1222 outb(tmp
, iobase
+FIR_IRDA_CR
);
1224 // T3 -> SD/MODE:0 IRTX:0
1227 outb(tmp
, iobase
+FIR_IRDA_CR
);
1230 // reset -> Normal TX output Signal
1231 outb(tmp
& ~0x02, iobase
+FIR_IRDA_CR
);
1234 else if (dongle_id
== 1) /* HP HDSL-3600 */
1239 tmp
&= ~IRDA_CR_HDLC
; // HDLC=0
1243 tmp
|= 0xA0; // HDLC=1, 1.152Mbps=1
1247 tmp
&=~0x80; // HDLC 0.576Mbps
1248 tmp
|= 0x20; // HDLC=1,
1252 tmp
|= IRDA_CR_CRC
; // CRC=1
1254 switch_bank(iobase
, BANK2
);
1255 outb(tmp
, iobase
+FIR_IRDA_CR
);
1257 else /* HP HDSL-1100 */
1259 if(speed
<= 115200) /* SIR */
1262 tmp
&= ~IRDA_CR_FIR_SIN
; // HP sin select = 0
1264 switch_bank(iobase
, BANK2
);
1265 outb(tmp
, iobase
+FIR_IRDA_CR
);
1273 tmp
&= ~IRDA_CR_HDLC
; // HDLC=0
1277 tmp
|= 0xA0; // HDLC=1, 1.152Mbps=1
1281 tmp
&=~0x80; // HDLC 0.576Mbps
1282 tmp
|= 0x20; // HDLC=1,
1286 tmp
|= IRDA_CR_CRC
; // CRC=1
1287 tmp
|= IRDA_CR_FIR_SIN
; // HP sin select = 1
1289 switch_bank(iobase
, BANK2
);
1290 outb(tmp
, iobase
+FIR_IRDA_CR
);
1294 switch_bank(iobase
, BANK0
);
1296 IRDA_DEBUG(1, "%s(), ----------------- End ------------------\n", __FUNCTION__
);
1300 * Function ali_ircc_sir_write (driver)
1302 * Fill Tx FIFO with transmit data
1305 static int ali_ircc_sir_write(int iobase
, int fifo_size
, __u8
*buf
, int len
)
1309 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __FUNCTION__
);
1311 /* Tx FIFO should be empty! */
1312 if (!(inb(iobase
+UART_LSR
) & UART_LSR_THRE
)) {
1313 IRDA_DEBUG(0, "%s(), failed, fifo not empty!\n", __FUNCTION__
);
1317 /* Fill FIFO with current frame */
1318 while ((fifo_size
-- > 0) && (actual
< len
)) {
1319 /* Transmit next byte */
1320 outb(buf
[actual
], iobase
+UART_TX
);
1325 IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __FUNCTION__
);
1330 * Function ali_ircc_net_open (dev)
1335 static int ali_ircc_net_open(struct net_device
*dev
)
1337 struct ali_ircc_cb
*self
;
1341 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __FUNCTION__
);
1343 IRDA_ASSERT(dev
!= NULL
, return -1;);
1345 self
= (struct ali_ircc_cb
*) dev
->priv
;
1347 IRDA_ASSERT(self
!= NULL
, return 0;);
1349 iobase
= self
->io
.fir_base
;
1351 /* Request IRQ and install Interrupt Handler */
1352 if (request_irq(self
->io
.irq
, ali_ircc_interrupt
, 0, dev
->name
, dev
))
1354 IRDA_WARNING("%s, unable to allocate irq=%d\n",
1355 ALI_IRCC_DRIVER_NAME
,
1361 * Always allocate the DMA channel after the IRQ, and clean up on
1364 if (request_dma(self
->io
.dma
, dev
->name
)) {
1365 IRDA_WARNING("%s, unable to allocate dma=%d\n",
1366 ALI_IRCC_DRIVER_NAME
,
1368 free_irq(self
->io
.irq
, self
);
1372 /* Turn on interrups */
1373 outb(UART_IER_RDI
, iobase
+UART_IER
);
1375 /* Ready to play! */
1376 netif_start_queue(dev
); //benjamin by irport
1378 /* Give self a hardware name */
1379 sprintf(hwname
, "ALI-FIR @ 0x%03x", self
->io
.fir_base
);
1382 * Open new IrLAP layer instance, now that everything should be
1383 * initialized properly
1385 self
->irlap
= irlap_open(dev
, &self
->qos
, hwname
);
1387 IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __FUNCTION__
);
1393 * Function ali_ircc_net_close (dev)
1398 static int ali_ircc_net_close(struct net_device
*dev
)
1401 struct ali_ircc_cb
*self
;
1404 IRDA_DEBUG(4, "%s(), ---------------- Start ----------------\n", __FUNCTION__
);
1406 IRDA_ASSERT(dev
!= NULL
, return -1;);
1408 self
= (struct ali_ircc_cb
*) dev
->priv
;
1409 IRDA_ASSERT(self
!= NULL
, return 0;);
1412 netif_stop_queue(dev
);
1414 /* Stop and remove instance of IrLAP */
1416 irlap_close(self
->irlap
);
1419 disable_dma(self
->io
.dma
);
1421 /* Disable interrupts */
1422 SetCOMInterrupts(self
, FALSE
);
1424 free_irq(self
->io
.irq
, dev
);
1425 free_dma(self
->io
.dma
);
1427 IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __FUNCTION__
);
1433 * Function ali_ircc_fir_hard_xmit (skb, dev)
1435 * Transmit the frame
1438 static int ali_ircc_fir_hard_xmit(struct sk_buff
*skb
, struct net_device
*dev
)
1440 struct ali_ircc_cb
*self
;
1441 unsigned long flags
;
1446 IRDA_DEBUG(1, "%s(), ---------------- Start -----------------\n", __FUNCTION__
);
1448 self
= (struct ali_ircc_cb
*) dev
->priv
;
1449 iobase
= self
->io
.fir_base
;
1451 netif_stop_queue(dev
);
1453 /* Make sure tests *& speed change are atomic */
1454 spin_lock_irqsave(&self
->lock
, flags
);
1456 /* Note : you should make sure that speed changes are not going
1457 * to corrupt any outgoing frame. Look at nsc-ircc for the gory
1458 * details - Jean II */
1460 /* Check if we need to change the speed */
1461 speed
= irda_get_next_speed(skb
);
1462 if ((speed
!= self
->io
.speed
) && (speed
!= -1)) {
1463 /* Check for empty frame */
1465 ali_ircc_change_speed(self
, speed
);
1466 dev
->trans_start
= jiffies
;
1467 spin_unlock_irqrestore(&self
->lock
, flags
);
1471 self
->new_speed
= speed
;
1474 /* Register and copy this frame to DMA memory */
1475 self
->tx_fifo
.queue
[self
->tx_fifo
.free
].start
= self
->tx_fifo
.tail
;
1476 self
->tx_fifo
.queue
[self
->tx_fifo
.free
].len
= skb
->len
;
1477 self
->tx_fifo
.tail
+= skb
->len
;
1479 self
->stats
.tx_bytes
+= skb
->len
;
1481 memcpy(self
->tx_fifo
.queue
[self
->tx_fifo
.free
].start
, skb
->data
,
1484 self
->tx_fifo
.len
++;
1485 self
->tx_fifo
.free
++;
1487 /* Start transmit only if there is currently no transmit going on */
1488 if (self
->tx_fifo
.len
== 1)
1490 /* Check if we must wait the min turn time or not */
1491 mtt
= irda_get_mtt(skb
);
1495 /* Check how much time we have used already */
1496 do_gettimeofday(&self
->now
);
1498 diff
= self
->now
.tv_usec
- self
->stamp
.tv_usec
;
1499 /* self->stamp is set from ali_ircc_dma_receive_complete() */
1501 IRDA_DEBUG(1, "%s(), ******* diff = %d ******* \n", __FUNCTION__
, diff
);
1506 /* Check if the mtt is larger than the time we have
1507 * already used by all the protocol processing
1514 * Use timer if delay larger than 1000 us, and
1515 * use udelay for smaller values which should
1520 /* Adjust for timer resolution */
1521 mtt
= (mtt
+250) / 500; /* 4 discard, 5 get advanced, Let's round off */
1523 IRDA_DEBUG(1, "%s(), ************** mtt = %d ***********\n", __FUNCTION__
, mtt
);
1526 if (mtt
== 1) /* 500 us */
1528 switch_bank(iobase
, BANK1
);
1529 outb(TIMER_IIR_500
, iobase
+FIR_TIMER_IIR
);
1531 else if (mtt
== 2) /* 1 ms */
1533 switch_bank(iobase
, BANK1
);
1534 outb(TIMER_IIR_1ms
, iobase
+FIR_TIMER_IIR
);
1536 else /* > 2ms -> 4ms */
1538 switch_bank(iobase
, BANK1
);
1539 outb(TIMER_IIR_2ms
, iobase
+FIR_TIMER_IIR
);
1544 outb(inb(iobase
+FIR_CR
) | CR_TIMER_EN
, iobase
+FIR_CR
);
1545 self
->io
.direction
= IO_XMIT
;
1547 /* Enable timer interrupt */
1548 self
->ier
= IER_TIMER
;
1549 SetCOMInterrupts(self
, TRUE
);
1551 /* Timer will take care of the rest */
1556 } // if (if (mtt > diff)
1559 /* Enable EOM interrupt */
1560 self
->ier
= IER_EOM
;
1561 SetCOMInterrupts(self
, TRUE
);
1563 /* Transmit frame */
1564 ali_ircc_dma_xmit(self
);
1565 } // if (self->tx_fifo.len == 1)
1569 /* Not busy transmitting anymore if window is not full */
1570 if (self
->tx_fifo
.free
< MAX_TX_WINDOW
)
1571 netif_wake_queue(self
->netdev
);
1573 /* Restore bank register */
1574 switch_bank(iobase
, BANK0
);
1576 dev
->trans_start
= jiffies
;
1577 spin_unlock_irqrestore(&self
->lock
, flags
);
1580 IRDA_DEBUG(1, "%s(), ----------------- End ------------------\n", __FUNCTION__
);
1585 static void ali_ircc_dma_xmit(struct ali_ircc_cb
*self
)
1588 unsigned char FIFO_OPTI
, Hi
, Lo
;
1591 IRDA_DEBUG(1, "%s(), ---------------- Start -----------------\n", __FUNCTION__
);
1593 iobase
= self
->io
.fir_base
;
1595 /* FIFO threshold , this method comes from NDIS5 code */
1597 if(self
->tx_fifo
.queue
[self
->tx_fifo
.ptr
].len
< TX_FIFO_Threshold
)
1598 FIFO_OPTI
= self
->tx_fifo
.queue
[self
->tx_fifo
.ptr
].len
-1;
1600 FIFO_OPTI
= TX_FIFO_Threshold
;
1603 switch_bank(iobase
, BANK1
);
1604 outb(inb(iobase
+FIR_CR
) & ~CR_DMA_EN
, iobase
+FIR_CR
);
1606 self
->io
.direction
= IO_XMIT
;
1608 irda_setup_dma(self
->io
.dma
,
1609 ((u8
*)self
->tx_fifo
.queue
[self
->tx_fifo
.ptr
].start
-
1610 self
->tx_buff
.head
) + self
->tx_buff_dma
,
1611 self
->tx_fifo
.queue
[self
->tx_fifo
.ptr
].len
,
1615 switch_bank(iobase
, BANK0
);
1616 outb(LCR_A_FIFO_RESET
, iobase
+FIR_LCR_A
);
1618 /* Set Tx FIFO threshold */
1619 if (self
->fifo_opti_buf
!=FIFO_OPTI
)
1621 switch_bank(iobase
, BANK1
);
1622 outb(FIFO_OPTI
, iobase
+FIR_FIFO_TR
) ;
1623 self
->fifo_opti_buf
=FIFO_OPTI
;
1626 /* Set Tx DMA threshold */
1627 switch_bank(iobase
, BANK1
);
1628 outb(TX_DMA_Threshold
, iobase
+FIR_DMA_TR
);
1630 /* Set max Tx frame size */
1631 Hi
= (self
->tx_fifo
.queue
[self
->tx_fifo
.ptr
].len
>> 8) & 0x0f;
1632 Lo
= self
->tx_fifo
.queue
[self
->tx_fifo
.ptr
].len
& 0xff;
1633 switch_bank(iobase
, BANK2
);
1634 outb(Hi
, iobase
+FIR_TX_DSR_HI
);
1635 outb(Lo
, iobase
+FIR_TX_DSR_LO
);
1637 /* Disable SIP , Disable Brick Wall (we don't support in TX mode), Change to TX mode */
1638 switch_bank(iobase
, BANK0
);
1639 tmp
= inb(iobase
+FIR_LCR_B
);
1640 tmp
&= ~0x20; // Disable SIP
1641 outb(((unsigned char)(tmp
& 0x3f) | LCR_B_TX_MODE
) & ~LCR_B_BW
, iobase
+FIR_LCR_B
);
1642 IRDA_DEBUG(1, "%s(), ******* Change to TX mode: FIR_LCR_B = 0x%x ******* \n", __FUNCTION__
, inb(iobase
+FIR_LCR_B
));
1644 outb(0, iobase
+FIR_LSR
);
1646 /* Enable DMA and Burst Mode */
1647 switch_bank(iobase
, BANK1
);
1648 outb(inb(iobase
+FIR_CR
) | CR_DMA_EN
| CR_DMA_BURST
, iobase
+FIR_CR
);
1650 switch_bank(iobase
, BANK0
);
1652 IRDA_DEBUG(1, "%s(), ----------------- End ------------------\n", __FUNCTION__
);
1655 static int ali_ircc_dma_xmit_complete(struct ali_ircc_cb
*self
)
1660 IRDA_DEBUG(1, "%s(), ---------------- Start -----------------\n", __FUNCTION__
);
1662 iobase
= self
->io
.fir_base
;
1665 switch_bank(iobase
, BANK1
);
1666 outb(inb(iobase
+FIR_CR
) & ~CR_DMA_EN
, iobase
+FIR_CR
);
1668 /* Check for underrun! */
1669 switch_bank(iobase
, BANK0
);
1670 if((inb(iobase
+FIR_LSR
) & LSR_FRAME_ABORT
) == LSR_FRAME_ABORT
)
1673 IRDA_ERROR("%s(), ********* LSR_FRAME_ABORT *********\n", __FUNCTION__
);
1674 self
->stats
.tx_errors
++;
1675 self
->stats
.tx_fifo_errors
++;
1679 self
->stats
.tx_packets
++;
1682 /* Check if we need to change the speed */
1683 if (self
->new_speed
)
1685 ali_ircc_change_speed(self
, self
->new_speed
);
1686 self
->new_speed
= 0;
1689 /* Finished with this frame, so prepare for next */
1690 self
->tx_fifo
.ptr
++;
1691 self
->tx_fifo
.len
--;
1693 /* Any frames to be sent back-to-back? */
1694 if (self
->tx_fifo
.len
)
1696 ali_ircc_dma_xmit(self
);
1698 /* Not finished yet! */
1702 { /* Reset Tx FIFO info */
1703 self
->tx_fifo
.len
= self
->tx_fifo
.ptr
= self
->tx_fifo
.free
= 0;
1704 self
->tx_fifo
.tail
= self
->tx_buff
.head
;
1707 /* Make sure we have room for more frames */
1708 if (self
->tx_fifo
.free
< MAX_TX_WINDOW
) {
1709 /* Not busy transmitting anymore */
1710 /* Tell the network layer, that we can accept more frames */
1711 netif_wake_queue(self
->netdev
);
1714 switch_bank(iobase
, BANK0
);
1716 IRDA_DEBUG(1, "%s(), ----------------- End ------------------\n", __FUNCTION__
);
1721 * Function ali_ircc_dma_receive (self)
1723 * Get ready for receiving a frame. The device will initiate a DMA
1724 * if it starts to receive a frame.
1727 static int ali_ircc_dma_receive(struct ali_ircc_cb
*self
)
1731 IRDA_DEBUG(1, "%s(), ---------------- Start -----------------\n", __FUNCTION__
);
1733 iobase
= self
->io
.fir_base
;
1735 /* Reset Tx FIFO info */
1736 self
->tx_fifo
.len
= self
->tx_fifo
.ptr
= self
->tx_fifo
.free
= 0;
1737 self
->tx_fifo
.tail
= self
->tx_buff
.head
;
1740 switch_bank(iobase
, BANK1
);
1741 outb(inb(iobase
+FIR_CR
) & ~CR_DMA_EN
, iobase
+FIR_CR
);
1743 /* Reset Message Count */
1744 switch_bank(iobase
, BANK0
);
1745 outb(0x07, iobase
+FIR_LSR
);
1747 self
->rcvFramesOverflow
= FALSE
;
1749 self
->LineStatus
= inb(iobase
+FIR_LSR
) ;
1751 /* Reset Rx FIFO info */
1752 self
->io
.direction
= IO_RECV
;
1753 self
->rx_buff
.data
= self
->rx_buff
.head
;
1756 // switch_bank(iobase, BANK0);
1757 outb(LCR_A_FIFO_RESET
, iobase
+FIR_LCR_A
);
1759 self
->st_fifo
.len
= self
->st_fifo
.pending_bytes
= 0;
1760 self
->st_fifo
.tail
= self
->st_fifo
.head
= 0;
1762 irda_setup_dma(self
->io
.dma
, self
->rx_buff_dma
, self
->rx_buff
.truesize
,
1765 /* Set Receive Mode,Brick Wall */
1766 //switch_bank(iobase, BANK0);
1767 tmp
= inb(iobase
+FIR_LCR_B
);
1768 outb((unsigned char)(tmp
&0x3f) | LCR_B_RX_MODE
| LCR_B_BW
, iobase
+ FIR_LCR_B
); // 2000/12/1 05:16PM
1769 IRDA_DEBUG(1, "%s(), *** Change To RX mode: FIR_LCR_B = 0x%x *** \n", __FUNCTION__
, inb(iobase
+FIR_LCR_B
));
1771 /* Set Rx Threshold */
1772 switch_bank(iobase
, BANK1
);
1773 outb(RX_FIFO_Threshold
, iobase
+FIR_FIFO_TR
);
1774 outb(RX_DMA_Threshold
, iobase
+FIR_DMA_TR
);
1776 /* Enable DMA and Burst Mode */
1777 // switch_bank(iobase, BANK1);
1778 outb(CR_DMA_EN
| CR_DMA_BURST
, iobase
+FIR_CR
);
1780 switch_bank(iobase
, BANK0
);
1781 IRDA_DEBUG(1, "%s(), ----------------- End ------------------\n", __FUNCTION__
);
1785 static int ali_ircc_dma_receive_complete(struct ali_ircc_cb
*self
)
1787 struct st_fifo
*st_fifo
;
1788 struct sk_buff
*skb
;
1789 __u8 status
, MessageCount
;
1790 int len
, i
, iobase
, val
;
1792 IRDA_DEBUG(1, "%s(), ---------------- Start -----------------\n", __FUNCTION__
);
1794 st_fifo
= &self
->st_fifo
;
1795 iobase
= self
->io
.fir_base
;
1797 switch_bank(iobase
, BANK0
);
1798 MessageCount
= inb(iobase
+ FIR_LSR
)&0x07;
1800 if (MessageCount
> 0)
1801 IRDA_DEBUG(0, "%s(), Messsage count = %d,\n", __FUNCTION__
, MessageCount
);
1803 for (i
=0; i
<=MessageCount
; i
++)
1806 switch_bank(iobase
, BANK0
);
1807 status
= inb(iobase
+FIR_LSR
);
1809 switch_bank(iobase
, BANK2
);
1810 len
= inb(iobase
+FIR_RX_DSR_HI
) & 0x0f;
1812 len
|= inb(iobase
+FIR_RX_DSR_LO
);
1814 IRDA_DEBUG(1, "%s(), RX Length = 0x%.2x,\n", __FUNCTION__
, len
);
1815 IRDA_DEBUG(1, "%s(), RX Status = 0x%.2x,\n", __FUNCTION__
, status
);
1817 if (st_fifo
->tail
>= MAX_RX_WINDOW
) {
1818 IRDA_DEBUG(0, "%s(), window is full!\n", __FUNCTION__
);
1822 st_fifo
->entries
[st_fifo
->tail
].status
= status
;
1823 st_fifo
->entries
[st_fifo
->tail
].len
= len
;
1824 st_fifo
->pending_bytes
+= len
;
1829 for (i
=0; i
<=MessageCount
; i
++)
1831 /* Get first entry */
1832 status
= st_fifo
->entries
[st_fifo
->head
].status
;
1833 len
= st_fifo
->entries
[st_fifo
->head
].len
;
1834 st_fifo
->pending_bytes
-= len
;
1838 /* Check for errors */
1839 if ((status
& 0xd8) || self
->rcvFramesOverflow
|| (len
==0))
1841 IRDA_DEBUG(0,"%s(), ************* RX Errors ************ \n", __FUNCTION__
);
1844 self
->stats
.rx_errors
++;
1846 self
->rx_buff
.data
+= len
;
1848 if (status
& LSR_FIFO_UR
)
1850 self
->stats
.rx_frame_errors
++;
1851 IRDA_DEBUG(0,"%s(), ************* FIFO Errors ************ \n", __FUNCTION__
);
1853 if (status
& LSR_FRAME_ERROR
)
1855 self
->stats
.rx_frame_errors
++;
1856 IRDA_DEBUG(0,"%s(), ************* FRAME Errors ************ \n", __FUNCTION__
);
1859 if (status
& LSR_CRC_ERROR
)
1861 self
->stats
.rx_crc_errors
++;
1862 IRDA_DEBUG(0,"%s(), ************* CRC Errors ************ \n", __FUNCTION__
);
1865 if(self
->rcvFramesOverflow
)
1867 self
->stats
.rx_frame_errors
++;
1868 IRDA_DEBUG(0,"%s(), ************* Overran DMA buffer ************ \n", __FUNCTION__
);
1872 self
->stats
.rx_frame_errors
++;
1873 IRDA_DEBUG(0,"%s(), ********** Receive Frame Size = 0 ********* \n", __FUNCTION__
);
1879 if (st_fifo
->pending_bytes
< 32)
1881 switch_bank(iobase
, BANK0
);
1882 val
= inb(iobase
+FIR_BSR
);
1883 if ((val
& BSR_FIFO_NOT_EMPTY
)== 0x80)
1885 IRDA_DEBUG(0, "%s(), ************* BSR_FIFO_NOT_EMPTY ************ \n", __FUNCTION__
);
1887 /* Put this entry back in fifo */
1890 st_fifo
->pending_bytes
+= len
;
1891 st_fifo
->entries
[st_fifo
->head
].status
= status
;
1892 st_fifo
->entries
[st_fifo
->head
].len
= len
;
1895 * DMA not finished yet, so try again
1896 * later, set timer value, resolution
1900 switch_bank(iobase
, BANK1
);
1901 outb(TIMER_IIR_500
, iobase
+FIR_TIMER_IIR
); // 2001/1/2 05:07PM
1904 outb(inb(iobase
+FIR_CR
) | CR_TIMER_EN
, iobase
+FIR_CR
);
1906 return FALSE
; /* I'll be back! */
1911 * Remember the time we received this frame, so we can
1912 * reduce the min turn time a bit since we will know
1913 * how much time we have used for protocol processing
1915 do_gettimeofday(&self
->stamp
);
1917 skb
= dev_alloc_skb(len
+1);
1920 IRDA_WARNING("%s(), memory squeeze, "
1921 "dropping frame.\n",
1923 self
->stats
.rx_dropped
++;
1928 /* Make sure IP header gets aligned */
1929 skb_reserve(skb
, 1);
1931 /* Copy frame without CRC, CRC is removed by hardware*/
1933 memcpy(skb
->data
, self
->rx_buff
.data
, len
);
1935 /* Move to next frame */
1936 self
->rx_buff
.data
+= len
;
1937 self
->stats
.rx_bytes
+= len
;
1938 self
->stats
.rx_packets
++;
1940 skb
->dev
= self
->netdev
;
1941 skb
->mac
.raw
= skb
->data
;
1942 skb
->protocol
= htons(ETH_P_IRDA
);
1944 self
->netdev
->last_rx
= jiffies
;
1948 switch_bank(iobase
, BANK0
);
1950 IRDA_DEBUG(1, "%s(), ----------------- End ------------------\n", __FUNCTION__
);
1957 * Function ali_ircc_sir_hard_xmit (skb, dev)
1959 * Transmit the frame!
1962 static int ali_ircc_sir_hard_xmit(struct sk_buff
*skb
, struct net_device
*dev
)
1964 struct ali_ircc_cb
*self
;
1965 unsigned long flags
;
1969 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __FUNCTION__
);
1971 IRDA_ASSERT(dev
!= NULL
, return 0;);
1973 self
= (struct ali_ircc_cb
*) dev
->priv
;
1974 IRDA_ASSERT(self
!= NULL
, return 0;);
1976 iobase
= self
->io
.sir_base
;
1978 netif_stop_queue(dev
);
1980 /* Make sure tests *& speed change are atomic */
1981 spin_lock_irqsave(&self
->lock
, flags
);
1983 /* Note : you should make sure that speed changes are not going
1984 * to corrupt any outgoing frame. Look at nsc-ircc for the gory
1985 * details - Jean II */
1987 /* Check if we need to change the speed */
1988 speed
= irda_get_next_speed(skb
);
1989 if ((speed
!= self
->io
.speed
) && (speed
!= -1)) {
1990 /* Check for empty frame */
1992 ali_ircc_change_speed(self
, speed
);
1993 dev
->trans_start
= jiffies
;
1994 spin_unlock_irqrestore(&self
->lock
, flags
);
1998 self
->new_speed
= speed
;
2001 /* Init tx buffer */
2002 self
->tx_buff
.data
= self
->tx_buff
.head
;
2004 /* Copy skb to tx_buff while wrapping, stuffing and making CRC */
2005 self
->tx_buff
.len
= async_wrap_skb(skb
, self
->tx_buff
.data
,
2006 self
->tx_buff
.truesize
);
2008 self
->stats
.tx_bytes
+= self
->tx_buff
.len
;
2010 /* Turn on transmit finished interrupt. Will fire immediately! */
2011 outb(UART_IER_THRI
, iobase
+UART_IER
);
2013 dev
->trans_start
= jiffies
;
2014 spin_unlock_irqrestore(&self
->lock
, flags
);
2018 IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __FUNCTION__
);
2025 * Function ali_ircc_net_ioctl (dev, rq, cmd)
2027 * Process IOCTL commands for this device
2030 static int ali_ircc_net_ioctl(struct net_device
*dev
, struct ifreq
*rq
, int cmd
)
2032 struct if_irda_req
*irq
= (struct if_irda_req
*) rq
;
2033 struct ali_ircc_cb
*self
;
2034 unsigned long flags
;
2037 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __FUNCTION__
);
2039 IRDA_ASSERT(dev
!= NULL
, return -1;);
2043 IRDA_ASSERT(self
!= NULL
, return -1;);
2045 IRDA_DEBUG(2, "%s(), %s, (cmd=0x%X)\n", __FUNCTION__
, dev
->name
, cmd
);
2048 case SIOCSBANDWIDTH
: /* Set bandwidth */
2049 IRDA_DEBUG(1, "%s(), SIOCSBANDWIDTH\n", __FUNCTION__
);
2051 * This function will also be used by IrLAP to change the
2052 * speed, so we still must allow for speed change within
2053 * interrupt context.
2055 if (!in_interrupt() && !capable(CAP_NET_ADMIN
))
2058 spin_lock_irqsave(&self
->lock
, flags
);
2059 ali_ircc_change_speed(self
, irq
->ifr_baudrate
);
2060 spin_unlock_irqrestore(&self
->lock
, flags
);
2062 case SIOCSMEDIABUSY
: /* Set media busy */
2063 IRDA_DEBUG(1, "%s(), SIOCSMEDIABUSY\n", __FUNCTION__
);
2064 if (!capable(CAP_NET_ADMIN
))
2066 irda_device_set_media_busy(self
->netdev
, TRUE
);
2068 case SIOCGRECEIVING
: /* Check if we are receiving right now */
2069 IRDA_DEBUG(2, "%s(), SIOCGRECEIVING\n", __FUNCTION__
);
2070 /* This is protected */
2071 irq
->ifr_receiving
= ali_ircc_is_receiving(self
);
2077 IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __FUNCTION__
);
2083 * Function ali_ircc_is_receiving (self)
2085 * Return TRUE is we are currently receiving a frame
2088 static int ali_ircc_is_receiving(struct ali_ircc_cb
*self
)
2090 unsigned long flags
;
2094 IRDA_DEBUG(2, "%s(), ---------------- Start -----------------\n", __FUNCTION__
);
2096 IRDA_ASSERT(self
!= NULL
, return FALSE
;);
2098 spin_lock_irqsave(&self
->lock
, flags
);
2100 if (self
->io
.speed
> 115200)
2102 iobase
= self
->io
.fir_base
;
2104 switch_bank(iobase
, BANK1
);
2105 if((inb(iobase
+FIR_FIFO_FR
) & 0x3f) != 0)
2107 /* We are receiving something */
2108 IRDA_DEBUG(1, "%s(), We are receiving something\n", __FUNCTION__
);
2111 switch_bank(iobase
, BANK0
);
2115 status
= (self
->rx_buff
.state
!= OUTSIDE_FRAME
);
2118 spin_unlock_irqrestore(&self
->lock
, flags
);
2120 IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __FUNCTION__
);
2125 static struct net_device_stats
*ali_ircc_net_get_stats(struct net_device
*dev
)
2127 struct ali_ircc_cb
*self
= (struct ali_ircc_cb
*) dev
->priv
;
2129 IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __FUNCTION__
);
2131 IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __FUNCTION__
);
2133 return &self
->stats
;
2136 static int ali_ircc_suspend(struct platform_device
*dev
, pm_message_t state
)
2138 struct ali_ircc_cb
*self
= platform_get_drvdata(dev
);
2140 IRDA_MESSAGE("%s, Suspending\n", ALI_IRCC_DRIVER_NAME
);
2142 if (self
->io
.suspended
)
2145 ali_ircc_net_close(self
->netdev
);
2147 self
->io
.suspended
= 1;
2152 static int ali_ircc_resume(struct platform_device
*dev
)
2154 struct ali_ircc_cb
*self
= platform_get_drvdata(dev
);
2156 if (!self
->io
.suspended
)
2159 ali_ircc_net_open(self
->netdev
);
2161 IRDA_MESSAGE("%s, Waking up\n", ALI_IRCC_DRIVER_NAME
);
2163 self
->io
.suspended
= 0;
2168 /* ALi Chip Function */
2170 static void SetCOMInterrupts(struct ali_ircc_cb
*self
, unsigned char enable
)
2173 unsigned char newMask
;
2175 int iobase
= self
->io
.fir_base
; /* or sir_base */
2177 IRDA_DEBUG(2, "%s(), -------- Start -------- ( Enable = %d )\n", __FUNCTION__
, enable
);
2179 /* Enable the interrupt which we wish to */
2181 if (self
->io
.direction
== IO_XMIT
)
2183 if (self
->io
.speed
> 115200) /* FIR, MIR */
2185 newMask
= self
->ier
;
2189 newMask
= UART_IER_THRI
| UART_IER_RDI
;
2193 if (self
->io
.speed
> 115200) /* FIR, MIR */
2195 newMask
= self
->ier
;
2199 newMask
= UART_IER_RDI
;
2203 else /* Disable all the interrupts */
2209 //SIR and FIR has different registers
2210 if (self
->io
.speed
> 115200)
2212 switch_bank(iobase
, BANK0
);
2213 outb(newMask
, iobase
+FIR_IER
);
2216 outb(newMask
, iobase
+UART_IER
);
2218 IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __FUNCTION__
);
2221 static void SIR2FIR(int iobase
)
2223 //unsigned char tmp;
2225 IRDA_DEBUG(1, "%s(), ---------------- Start ----------------\n", __FUNCTION__
);
2227 /* Already protected (change_speed() or setup()), no need to lock.
2230 outb(0x28, iobase
+UART_MCR
);
2231 outb(0x68, iobase
+UART_MCR
);
2232 outb(0x88, iobase
+UART_MCR
);
2234 outb(0x60, iobase
+FIR_MCR
); /* Master Reset */
2235 outb(0x20, iobase
+FIR_MCR
); /* Master Interrupt Enable */
2237 //tmp = inb(iobase+FIR_LCR_B); /* SIP enable */
2239 //outb(tmp, iobase+FIR_LCR_B);
2241 IRDA_DEBUG(1, "%s(), ----------------- End ------------------\n", __FUNCTION__
);
2244 static void FIR2SIR(int iobase
)
2248 IRDA_DEBUG(1, "%s(), ---------------- Start ----------------\n", __FUNCTION__
);
2250 /* Already protected (change_speed() or setup()), no need to lock.
2253 outb(0x20, iobase
+FIR_MCR
); /* IRQ to low */
2254 outb(0x00, iobase
+UART_IER
);
2256 outb(0xA0, iobase
+FIR_MCR
); /* Don't set master reset */
2257 outb(0x00, iobase
+UART_FCR
);
2258 outb(0x07, iobase
+UART_FCR
);
2260 val
= inb(iobase
+UART_RX
);
2261 val
= inb(iobase
+UART_LSR
);
2262 val
= inb(iobase
+UART_MSR
);
2264 IRDA_DEBUG(1, "%s(), ----------------- End ------------------\n", __FUNCTION__
);
2267 MODULE_AUTHOR("Benjamin Kong <benjamin_kong@ali.com.tw>");
2268 MODULE_DESCRIPTION("ALi FIR Controller Driver");
2269 MODULE_LICENSE("GPL");
2272 module_param_array(io
, int, NULL
, 0);
2273 MODULE_PARM_DESC(io
, "Base I/O addresses");
2274 module_param_array(irq
, int, NULL
, 0);
2275 MODULE_PARM_DESC(irq
, "IRQ lines");
2276 module_param_array(dma
, int, NULL
, 0);
2277 MODULE_PARM_DESC(dma
, "DMA channels");
2279 module_init(ali_ircc_init
);
2280 module_exit(ali_ircc_cleanup
);