1 /*********************************************************************
5 * Description: Driver for the Sharp Universal Infrared
6 * Communications Controller (UIRCC v 1.3)
7 * Status: Experimental.
8 * Author: Dag Brattli <dagb@cs.uit.no>
9 * Created at: Sat Dec 26 10:59:03 1998
10 * Modified at: Mon May 10 22:11:09 1999
11 * Modified by: Dag Brattli <dagb@cs.uit.no>
13 * Copyright (c) 1998-1999 Dag Brattli, All Rights Reserved.
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.
20 * Neither Dag Brattli nor University of Tromsø admit liability nor
21 * provide warranty for any of this software. This material is
22 * provided "AS-IS" and at no charge.
24 * Applicable Models : Tecra 510CDT, 500C Series, 530CDT, 520CDT,
25 * 740CDT, Portege 300CT, 660CDT, Satellite 220C Series,
26 * Satellite Pro, 440C Series, 470CDT, 460C Series, 480C Series
28 ********************************************************************/
30 #include <linux/module.h>
32 #include <linux/kernel.h>
33 #include <linux/types.h>
34 #include <linux/skbuff.h>
35 #include <linux/netdevice.h>
36 #include <linux/ioport.h>
37 #include <linux/delay.h>
38 #include <linux/malloc.h>
39 #include <linux/delay.h>
40 #include <linux/init.h>
41 #include <linux/init.h>
45 #include <asm/byteorder.h>
47 #include <net/irda/wrapper.h>
48 #include <net/irda/irda.h>
49 #include <net/irda/irmod.h>
50 #include <net/irda/irlap_frame.h>
51 #include <net/irda/irda_device.h>
53 #include <net/irda/uircc.h>
54 #include <net/irda/irport.h>
56 static char *driver_name
= "uircc";
58 #define CHIP_IO_EXTENT 16
60 static unsigned int io
[] = { 0x300, ~0, ~0, ~0 };
61 static unsigned int io2
[] = { 0x3e8, 0, 0, 0};
62 static unsigned int irq
[] = { 11, 0, 0, 0 };
63 static unsigned int dma
[] = { 5, 0, 0, 0 };
65 static struct uircc_cb
*dev_self
[] = { NULL
, NULL
, NULL
, NULL
};
68 static int uircc_open(int i
, unsigned int iobase
, unsigned int board_addr
,
69 unsigned int irq
, unsigned int dma
);
71 static int uircc_close(struct irda_device
*idev
);
73 static int uircc_probe(int iobase
, int board_addr
, int irq
, int dma
);
74 static int uircc_dma_receive(struct irda_device
*idev
);
75 static int uircc_dma_receive_complete(struct irda_device
*idev
, int iobase
);
76 static int uircc_hard_xmit(struct sk_buff
*skb
, struct device
*dev
);
77 static void uircc_dma_write(struct irda_device
*idev
, int iobase
);
78 static void uircc_change_speed(struct irda_device
*idev
, int baud
);
79 static void uircc_interrupt(int irq
, void *dev_id
, struct pt_regs
*regs
);
80 static void uircc_wait_until_sent(struct irda_device
*idev
);
81 static int uircc_is_receiving(struct irda_device
*idev
);
82 static int uircc_toshiba_cmd(int *retval
, int arg0
, int arg1
, int arg2
);
83 static int uircc_net_init(struct device
*dev
);
84 static int uircc_net_open(struct device
*dev
);
85 static int uircc_net_close(struct device
*dev
);
88 * Function uircc_init ()
90 * Initialize chip. Just try to find out how many chips we are dealing with
93 __initfunc(int uircc_init(void))
97 for ( i
=0; (io
[i
] < 2000) && (i
< 4); i
++) {
99 if (check_region(ioaddr
, CHIP_IO_EXTENT
) < 0)
101 if (uircc_open(i
, io
[i
], io2
[i
], irq
[i
], dma
[i
]) == 0)
108 * Function uircc_cleanup ()
110 * Close all configured chips
114 static void uircc_cleanup(void)
118 DEBUG(4, __FUNCTION__
"()\n");
120 for (i
=0; i
< 4; i
++) {
122 uircc_close(&(dev_self
[i
]->idev
));
128 * Function uircc_open (iobase, irq)
130 * Open driver instance
133 static int uircc_open(int i
, unsigned int iobase
, unsigned int iobase2
,
134 unsigned int irq
, unsigned int dma
)
136 struct uircc_cb
*self
;
137 struct irda_device
*idev
;
140 DEBUG(4, __FUNCTION__
"()\n");
142 if ((uircc_probe(iobase
, iobase2
, irq
, dma
)) == -1)
146 * Allocate new instance of the driver
148 self
= kmalloc( sizeof(struct uircc_cb
), GFP_KERNEL
);
150 printk(KERN_ERR
"IrDA: Can't allocate memory for "
151 "IrDA control block!\n");
154 memset(self
, 0, sizeof(struct uircc_cb
));
156 /* Need to store self somewhere */
162 idev
->io
.iobase
= iobase
;
163 idev
->io
.iobase2
= iobase2
; /* Used by irport */
165 idev
->io
.io_ext
= CHIP_IO_EXTENT
;
166 idev
->io
.io_ext2
= 8; /* Used by irport */
168 idev
->io
.fifo_size
= 16;
170 /* Lock the port that we need */
171 ret
= check_region(idev
->io
.iobase
, idev
->io
.io_ext
);
173 DEBUG(0, __FUNCTION__
"(), can't get iobase of 0x%03x\n",
175 /* uircc_cleanup( self->idev); */
178 ret
= check_region(idev
->io
.iobase2
, idev
->io
.io_ext2
);
180 DEBUG(0, __FUNCTION__
"(), can't get iobase of 0x%03x\n",
182 /* uircc_cleanup( self->idev); */
185 request_region(idev
->io
.iobase
, idev
->io
.io_ext
, idev
->name
);
186 request_region(idev
->io
.iobase2
, idev
->io
.io_ext2
, idev
->name
);
188 /* Initialize QoS for this device */
189 irda_init_max_qos_capabilies(&idev
->qos
);
191 /* The only value we must override it the baudrate */
192 idev
->qos
.baud_rate
.bits
= IR_9600
|IR_19200
|IR_38400
|IR_57600
|
193 IR_115200
/*IR_576000|IR_1152000 |(IR_4000000 << 8)*/;
195 idev
->qos
.min_turn_time
.bits
= 0x0f;
196 irda_qos_bits_to_value(&idev
->qos
);
198 idev
->flags
= IFF_FIR
|IFF_SIR
|IFF_DMA
|IFF_PIO
;
200 /* Specify which buffer allocation policy we need */
201 idev
->rx_buff
.flags
= GFP_KERNEL
| GFP_DMA
;
202 idev
->tx_buff
.flags
= GFP_KERNEL
| GFP_DMA
;
204 /* Max DMA buffer size needed = (data_size + 6) * (window_size) + 6; */
205 idev
->rx_buff
.truesize
= 4000;
206 idev
->tx_buff
.truesize
= 4000;
208 /* Initialize callbacks */
209 idev
->change_speed
= uircc_change_speed
;
210 idev
->wait_until_sent
= uircc_wait_until_sent
;
211 idev
->is_receiving
= uircc_is_receiving
;
213 /* Override the network functions we need to use */
214 idev
->netdev
.init
= uircc_net_init
;
215 idev
->netdev
.hard_start_xmit
= uircc_hard_xmit
;
216 idev
->netdev
.open
= uircc_net_open
;
217 idev
->netdev
.stop
= uircc_net_close
;
219 irport_start(iobase2
);
221 /* Open the IrDA device */
222 irda_device_open(idev
, driver_name
, self
);
228 * Function uircc_close (idev)
230 * Close driver instance
234 static int uircc_close(struct irda_device
*idev
)
236 struct uircc_cb
*self
;
240 DEBUG(4, __FUNCTION__
"()\n");
242 ASSERT(idev
!= NULL
, return -1;);
243 ASSERT(idev
->magic
== IRDA_DEVICE_MAGIC
, return -1;);
245 iobase
= idev
->io
.iobase
;
246 self
= (struct uircc_cb
*) idev
->priv
;
248 /* Some magic to disable FIR and enable SIR */
249 uircc_toshiba_cmd(&status
, 0xffff, 0x001b, 0x0000);
252 outb(0x00, iobase
+UIRCC_CR10
);
254 irport_stop(idev
->io
.iobase2
);
256 /* Release the PORT that this driver is using */
257 DEBUG(4, __FUNCTION__
"(), Releasing Region %03x\n", idev
->io
.iobase
);
258 release_region(idev
->io
.iobase
, idev
->io
.io_ext
);
260 if (idev
->io
.iobase2
) {
261 DEBUG(4, __FUNCTION__
"(), Releasing Region %03x\n",
263 release_region(idev
->io
.iobase2
, idev
->io
.io_ext2
);
265 irda_device_close(idev
);
274 * Function uircc_probe (iobase, board_addr, irq, dma)
276 * Returns non-negative on success.
279 static int uircc_probe(int iobase
, int iobase2
, int irq
, int dma
)
283 DEBUG(4, __FUNCTION__
"()\n");
285 /* read the chip version, should be 0x03 */
286 version
= inb(iobase
+UIRCC_SR8
);
288 if (version
!= 0x03) {
289 DEBUG(0, __FUNCTION__
"(), Wrong chip version");
292 printk(KERN_INFO
"Sharp UIRCC IrDA driver loaded. Version: 0x%02x\n",
296 outb(UIRCC_CR0_SYS_RST
, iobase
+UIRCC_CR0
);
298 /* Initialize some registers */
299 outb(0x03, iobase
+UIRCC_CR15
);
300 outb(0, iobase
+UIRCC_CR11
);
301 outb(0, iobase
+UIRCC_CR9
);
303 DEBUG(0, __FUNCTION__
"(), sr15=%#x\n", inb(iobase
+UIRCC_SR15
));
305 /* Enable DMA single mode */
306 outb(UIRCC_CR1_RX_DMA
|UIRCC_CR1_TX_DMA
|UIRCC_CR1_MUST_SET
,
309 /* Disable interrupts */
310 outb(0xff, iobase
+UIRCC_CR2
);
312 /* Set self poll address */
318 * Function uircc_change_speed (idev, baud)
320 * Change the speed of the device
323 static void uircc_change_speed(struct irda_device
*idev
, int speed
)
325 struct uircc_cb
*self
;
327 int modem
= UIRCC_CR10_SIR
;
330 DEBUG(0, __FUNCTION__
"()\n");
332 /* Just test the high speed stuff */
335 ASSERT(idev
!= NULL
, return;);
336 ASSERT(idev
->magic
== IRDA_DEVICE_MAGIC
, return;);
339 iobase
= idev
->io
.iobase
;
341 /* Update accounting for new speed */
342 idev
->io
.baudrate
= speed
;
344 /* Disable interrupts */
345 outb(0xff, iobase
+UIRCC_CR2
);
353 irport_start(idev
->io
.iobase2
);
354 irport_change_speed(idev
, speed
);
356 /* Some magic to disable FIR and enable SIR */
357 uircc_toshiba_cmd(&status
, 0xffff, 0x001b, 0x0000);
359 modem
= UIRCC_CR10_SIR
;
363 DEBUG(0, __FUNCTION__
"(), handling baud of 576000\n");
367 DEBUG(0, __FUNCTION__
"(), handling baud of 1152000\n");
370 irport_stop(idev
->io
.iobase2
);
372 /* Some magic to disable SIR and enable FIR */
373 uircc_toshiba_cmd(&status
, 0xffff, 0x001b, 0x0001);
375 modem
= UIRCC_CR10_FIR
;
376 DEBUG(0, __FUNCTION__
"(), handling baud of 4000000\n");
378 /* Set self pole address */
379 //outb(0xfe, iobase+UIRCC_CR8);
381 /* outb(0x10, iobase+UIRCC_CR11); */
384 DEBUG( 0, __FUNCTION__
"(), unknown baud rate of %d\n", speed
);
388 /* Set appropriate speed mode */
389 outb(modem
, iobase
+UIRCC_CR10
);
391 idev
->netdev
.tbusy
= 0;
393 /* Enable some interrupts so we can receive frames */
394 if (speed
> 115200) {
395 /* Enable DMA single mode */
396 outb(UIRCC_CR1_RX_DMA
|UIRCC_CR1_TX_DMA
|UIRCC_CR1_MUST_SET
,
399 /* Enable all interrupts */
400 outb(0, iobase
+UIRCC_CR2
);
401 uircc_dma_receive(idev
);
406 * Function uircc_hard_xmit (skb, dev)
408 * Transmit the frame!
411 static int uircc_hard_xmit(struct sk_buff
*skb
, struct device
*dev
)
413 struct irda_device
*idev
;
417 idev
= (struct irda_device
*) dev
->priv
;
419 ASSERT(idev
!= NULL
, return 0;);
420 ASSERT(idev
->magic
== IRDA_DEVICE_MAGIC
, return 0;);
422 iobase
= idev
->io
.iobase
;
424 DEBUG(4, __FUNCTION__
"(%ld), skb->len=%d\n", jiffies
, (int) skb
->len
);
426 /* Reset carrier latch */
427 /*outb(0x02, iobase+UIRCC_CR0);*/
429 /* Use irport for SIR speeds */
430 if (idev
->io
.baudrate
<= 115200) {
431 return irport_hard_xmit(skb
, dev
);
434 DEBUG(0, __FUNCTION__
"(), sr0=%#x, sr1=%#x, sr2=%#x, sr3=%#x, sr10=%#x, sr11=%#x\n",
435 inb(iobase
+UIRCC_SR0
), inb(iobase
+UIRCC_SR3
),
436 inb(iobase
+UIRCC_SR2
), inb(iobase
+UIRCC_SR3
),
437 inb(iobase
+UIRCC_SR10
), inb(iobase
+UIRCC_SR11
));
439 /* Lock transmit buffer */
440 if (irda_lock((void *) &dev
->tbusy
) == FALSE
)
443 memcpy(idev
->tx_buff
.data
, skb
->data
, skb
->len
);
445 /* Make sure that the length is a multiple of 16 bits */
449 idev
->tx_buff
.len
= skb
->len
;
450 idev
->tx_buff
.data
= idev
->tx_buff
.head
;
452 mtt
= irda_get_mtt(skb
);
454 /* Use udelay for delays less than 50 us. */
458 /* Enable transmit interrupts */
459 outb(0, iobase
+UIRCC_CR2
);
461 uircc_dma_write(idev
, iobase
);
469 * Function uircc_dma_write (idev, iobase)
471 * Transmit data using DMA
474 static void uircc_dma_write(struct irda_device
*idev
, int iobase
)
476 struct uircc_cb
*self
;
478 DEBUG(4, __FUNCTION__
"()\n");
480 ASSERT(idev
!= NULL
, return;);
481 ASSERT(idev
->magic
== IRDA_DEVICE_MAGIC
, return;);
485 /* Receiving disable */
486 self
->cr3
&= ~UIRCC_CR3_RECV_EN
;
487 outb(self
->cr3
, iobase
+UIRCC_CR3
);
490 outb(0x80, iobase
+UIRCC_CR10
);
492 /* Enable transmit DMA */
493 outb(UIRCC_CR1_TX_DMA
|UIRCC_CR1_MUST_SET
, iobase
+UIRCC_CR1
);
495 ASSERT((((__u32
)(idev
->tx_buff
.data
)) & 0x01) != 0x01, return;);
497 setup_dma(idev
->io
.dma
, idev
->tx_buff
.data
, idev
->tx_buff
.len
,
500 idev
->io
.direction
= IO_XMIT
;
502 /* Set frame length (should be the real length without padding */
503 outb(idev
->tx_buff
.len
& 0xff, iobase
+UIRCC_CR4
); /* Low byte */
504 outb(idev
->tx_buff
.len
>> 8, iobase
+UIRCC_CR5
); /* High byte */
506 /* Enable transmit and transmit CRC */
507 self
->cr3
|= (UIRCC_CR3_XMIT_EN
|UIRCC_CR3_TX_CRC_EN
);
508 outb(self
->cr3
, iobase
+UIRCC_CR3
);
512 * Function uircc_dma_xmit_complete (idev)
514 * The transfer of a frame in finished. This function will only be called
515 * by the interrupt handler
518 static void uircc_dma_xmit_complete( struct irda_device
*idev
, int underrun
)
520 struct uircc_cb
*self
;
524 DEBUG(4, __FUNCTION__
"()\n");
526 ASSERT(idev
!= NULL
, return;);
527 ASSERT(idev
->magic
== IRDA_DEVICE_MAGIC
, return;);
531 iobase
= idev
->io
.iobase
;
533 /* Select TX counter */
534 outb(UIRCC_CR0_CNT_SWT
, iobase
+UIRCC_CR0
);
536 /* Read TX length counter */
537 len
= inb(iobase
+UIRCC_SR4
); /* Low byte */
538 len
|= inb(iobase
+UIRCC_SR5
) << 8; /* High byte */
540 DEBUG(4, __FUNCTION__
"(), sent %d bytes\n", len
);
542 /* Disable transmit */
543 self
->cr3
&= ~UIRCC_CR3_XMIT_EN
;
544 outb(self
->cr3
, iobase
+UIRCC_CR3
);
546 /* Transmit reset (just to be sure) */
547 outb(UIRCC_CR0_XMIT_RST
, iobase
+UIRCC_CR0
);
549 /* Check for underrrun! */
551 idev
->stats
.tx_errors
++;
552 idev
->stats
.tx_fifo_errors
++;
554 idev
->stats
.tx_packets
++;
555 idev
->stats
.tx_bytes
+= idev
->tx_buff
.len
;
558 /* Unlock tx_buff and request another frame */
559 idev
->netdev
.tbusy
= 0; /* Unlock */
560 idev
->media_busy
= FALSE
;
562 /* Tell the network layer, that we can accept more frames */
567 * Function uircc_dma_receive (idev)
569 * Get ready for receiving a frame. The device will initiate a DMA
570 * if it starts to receive a frame.
573 static int uircc_dma_receive(struct irda_device
*idev
)
575 struct uircc_cb
*self
;
578 ASSERT(idev
!= NULL
, return -1;);
579 ASSERT(idev
->magic
== IRDA_DEVICE_MAGIC
, return -1;);
581 DEBUG(4, __FUNCTION__
"\n");
584 iobase
= idev
->io
.iobase
;
586 /* Transmit disable */
587 /* self->cr3 &= ~UIRCC_CR3_XMIT_EN; */
589 outb(self
->cr3
, iobase
+UIRCC_CR3
);
591 /* Transmit reset (just in case) */
592 outb(UIRCC_CR0_XMIT_RST
|0x17, iobase
+UIRCC_CR0
);
595 outb(0x08, iobase
+UIRCC_CR10
);
597 /* Enable receiving with CRC */
598 self
->cr3
= (UIRCC_CR3_RECV_EN
|UIRCC_CR3_RX_CRC_EN
);
599 outb(self
->cr3
, iobase
+UIRCC_CR3
);
601 /* Make sure Rx DMA is set */
602 outb(UIRCC_CR1_RX_DMA
|UIRCC_CR1_MUST_SET
, iobase
+UIRCC_CR1
);
605 /* outb(UIRCC_CR0_RECV_RST, iobase+UIRCC_CR0); */
607 setup_dma(idev
->io
.dma
, idev
->rx_buff
.data
,
608 idev
->rx_buff
.truesize
, DMA_MODE_READ
);
610 /* driver->media_busy = FALSE; */
611 idev
->io
.direction
= IO_RECV
;
612 idev
->rx_buff
.data
= idev
->rx_buff
.head
;
615 /* Enable receiving with CRC */
616 self
->cr3
= (UIRCC_CR3_RECV_EN
|UIRCC_CR3_RX_CRC_EN
);
617 outb(self
->cr3
, iobase
+UIRCC_CR3
);
619 DEBUG(4, __FUNCTION__
"(), cr3=%#x\n", self
->cr3
);
627 * Function uircc_dma_receive_complete (idev)
629 * Finished with receiving frames
633 static int uircc_dma_receive_complete(struct irda_device
*idev
, int iobase
)
636 struct uircc_cb
*self
;
641 DEBUG(0, __FUNCTION__
"()\n");
643 /* Check for CRC or framing error */
644 if (inb(iobase
+UIRCC_SR0
) & UIRCC_SR0_RX_CRCFRM
) {
645 DEBUG(0, __FUNCTION__
"(), CRC or FRAME error\n");
649 /* Select receive length counter */
650 outb(0x00, iobase
+UIRCC_CR0
);
652 /* Read frame length */
653 len
= inb(iobase
+UIRCC_SR4
); /* Low byte */
654 len
|= inb(iobase
+UIRCC_SR5
) << 8; /* High byte */
656 DEBUG(0, __FUNCTION__
"(), len=%d\n", len
);
658 /* Receiving disable */
659 self
->cr3
&= ~UIRCC_CR3_RECV_EN
;
660 outb(self
->cr3
, iobase
+UIRCC_CR3
);
662 skb
= dev_alloc_skb(len
+1);
664 printk(KERN_INFO __FUNCTION__
665 "(), memory squeeze, dropping frame.\n");
666 /* Restore bank register */
670 /* Make sure IP header gets aligned */
673 /* Copy frame without CRC */
674 /* if ( idev->io.baudrate < 4000000) { */
675 /* skb_put( skb, len-2); */
676 /* memcpy( skb->data, idev->rx_buff.head, len-2); */
678 /* skb_put( skb, len-4); */
679 /* memcpy( skb->data, idev->rx_buff.head, len-4); */
683 memcpy(skb
->data
, idev
->rx_buff
.data
, len
);
684 idev
->stats
.rx_packets
++;
686 skb
->dev
= &idev
->netdev
;
687 skb
->mac
.raw
= skb
->data
;
688 skb
->protocol
= htons(ETH_P_IRDA
);
695 * Function uircc_interrupt (irq, dev_id, regs)
697 * An interrupt from the chip has arrived. Time to do some work
700 static void uircc_interrupt(int irq
, void *dev_id
, struct pt_regs
*regs
)
705 struct irda_device
*idev
= (struct irda_device
*) dev_id
;
708 printk( KERN_WARNING
"%s: irq %d for unknown device.\n",
713 if (idev
->io
.baudrate
<= 115200)
714 return irport_interrupt( irq
, dev_id
, regs
);
716 iobase
= idev
->io
.iobase
;
718 /* Read interrupt status */
719 sr3
= inb( iobase
+UIRCC_SR3
);
724 idev
->netdev
.interrupt
= 1;
726 DEBUG(4, __FUNCTION__
"(), sr3=%#x, sr2=%#x, sr10=%#x\n",
727 inb( iobase
+UIRCC_SR3
), inb( iobase
+UIRCC_SR2
),
728 inb( iobase
+UIRCC_SR10
));
731 * Check what interrupt this is. The UIRCC will not report two
732 * different interrupts at the same time!
735 case UIRCC_SR3_RX_EOF
: /* Check for end of frame */
736 uircc_dma_receive_complete(idev
, iobase
);
738 case UIRCC_SR3_TXUR
: /* Check for transmit underrun */
739 uircc_dma_xmit_complete(idev
, TRUE
);
740 uircc_dma_receive(idev
);
741 outb(0, iobase
+UIRCC_CR2
);
743 case UIRCC_SR3_TX_DONE
:
744 uircc_dma_xmit_complete(idev
, FALSE
);
745 uircc_dma_receive(idev
);
747 outb(0x0d, iobase
+UIRCC_CR2
);
749 case UIRCC_SR3_TMR_OUT
:
751 outb(inb(iobase
+UIRCC_CR11
) & ~UIRCC_CR11_TMR_EN
,
755 DEBUG(0, __FUNCTION__
"(), unknown interrupt status=%#x\n",
759 idev
->netdev
.interrupt
= 0;
763 * Function uircc_wait_until_sent (idev)
765 * This function should put the current thread to sleep until all data
766 * have been sent, so it is safe to change the speed.
768 static void uircc_wait_until_sent( struct irda_device
*idev
)
770 /* Just delay 60 ms */
771 current
->state
= TASK_INTERRUPTIBLE
;
776 * Function uircc_is_receiving (idev)
778 * Return TRUE is we are currently receiving a frame
781 static int uircc_is_receiving( struct irda_device
*idev
)
786 ASSERT(idev
!= NULL
, return FALSE
;);
787 ASSERT(idev
->magic
== IRDA_DEVICE_MAGIC
, return FALSE
;);
789 if (idev
->io
.baudrate
> 115200) {
792 status
= (idev
->rx_buff
.state
!= OUTSIDE_FRAME
);
798 * Function uircc_net_init (dev)
800 * Initialize network device
803 static int uircc_net_init( struct device
*dev
)
805 DEBUG( 4, __FUNCTION__
"()\n");
807 /* Setup to be a normal IrDA network device driver */
808 irda_device_setup(dev
);
810 /* Insert overrides below this line! */
817 * Function uircc_net_open (dev)
822 static int uircc_net_open(struct device
*dev
)
824 struct irda_device
*idev
;
827 DEBUG( 4, __FUNCTION__
"()\n");
829 ASSERT(dev
!= NULL
, return -1;);
830 idev
= (struct irda_device
*) dev
->priv
;
832 ASSERT(idev
!= NULL
, return 0;);
833 ASSERT(idev
->magic
== IRDA_DEVICE_MAGIC
, return 0;);
835 iobase
= idev
->io
.iobase
;
837 if (request_irq(idev
->io
.irq
, uircc_interrupt
, 0, idev
->name
,
842 * Always allocate the DMA channel after the IRQ,
843 * and clean up on failure.
845 if (request_dma(idev
->io
.dma
, idev
->name
)) {
846 free_irq(idev
->io
.irq
, idev
);
855 /* turn on interrupts */
863 * Function uircc_net_close (dev)
868 static int uircc_net_close(struct device
*dev
)
870 struct irda_device
*idev
;
873 DEBUG(4, __FUNCTION__
"()\n");
879 ASSERT(dev
!= NULL
, return -1;);
880 idev
= (struct irda_device
*) dev
->priv
;
882 ASSERT(idev
!= NULL
, return 0;);
883 ASSERT(idev
->magic
== IRDA_DEVICE_MAGIC
, return 0;);
885 iobase
= idev
->io
.iobase
;
887 disable_dma(idev
->io
.dma
);
889 /* Disable interrupts */
891 free_irq(idev
->io
.irq
, idev
);
892 free_dma(idev
->io
.dma
);
900 * Function uircc_toshiba_cmd (arg0, arg1, arg2)
902 * disable FIR: uircc_toshiba_cmd(&status, 0xffff, 0x001b, 0x0000);
903 * enable FIR: uircc_toshiba_cmd(&status, 0xffff, 0x001b, 0x0001);
904 * IRDA status: uircc_toshiba_cmd(&status, 0xfefe, 0x001b, 0x0000);
906 static int uircc_toshiba_cmd(int *retval
, int arg0
, int arg1
, int arg2
)
908 char return_code
= 0;
910 __asm__
volatile ("inb $0xb2,%%al; "
923 * 0x80 = Function not supported by system
924 * 0x83 = Input data error
926 return (int) return_code
;
932 * Function init_module (void)
937 int init_module(void)
943 * Function cleanup_module (void)
948 void cleanup_module(void)